diff --git a/src/flow/__init__.py b/src/flow/__init__.py index d1701505568aefdc0f735f0cbd7c719e26c17728..f5575186c75b261a05d9d1f09c7eb6b71505453d 100644 --- a/src/flow/__init__.py +++ b/src/flow/__init__.py @@ -15,6 +15,14 @@ Usage: harness = MAFHarness(workspace=Path("/tmp/workspace"), enable_compaction=False) """ +import sys + +from loguru import logger + +# Default to INFO — suppress DEBUG noise from tools/workspace/etc. +logger.remove() +logger.add(sys.stderr, level="INFO") + from flow.harness.maf import MAFHarness, create_agent __version__ = "0.1.0" diff --git a/src/flow/cli/app.py b/src/flow/cli/app.py index 20dbf66aa8f64f9daa08daf2fb18c6bb6580c09d..826c31e5bf28fb26c765a65ed91e966571d9eecb 100644 --- a/src/flow/cli/app.py +++ b/src/flow/cli/app.py @@ -176,9 +176,13 @@ async def _run_single_task( # Import and register commands +from flow.cli.deploy import deploy as deploy_cmd +from flow.cli.evaluate import evaluate as evaluate_cmd from flow.cli.hf_import import hf_import as hf_import_cmd from flow.cli.optimize import optimize as optimize_cmd +app.command()(deploy_cmd) +app.command()(evaluate_cmd) app.command()(optimize_cmd) app.command(name="hf-import")(hf_import_cmd) diff --git a/src/flow/cli/deploy.py b/src/flow/cli/deploy.py new file mode 100644 index 0000000000000000000000000000000000000000..d4af01ae07eb62d9f21fbba6b278478b0b9efec4 --- /dev/null +++ b/src/flow/cli/deploy.py @@ -0,0 +1,113 @@ +# Copyright (c) Microsoft. All rights reserved. + +"""Deploy command for persisting agent configs to the database.""" + +from __future__ import annotations + +import asyncio +from pathlib import Path +from typing import Annotated + +import typer +from rich.console import Console + +from flow.experiments.models import load_agent + +console = Console() + + +def deploy( + agent: Annotated[ + Path, + typer.Option( + "--agent", "-a", + help="Path to agent YAML config file", + ), + ], + name: Annotated[ + str | None, + typer.Option( + "--name", "-n", + help="Deployment name (defaults to agent name from YAML)", + ), + ] = None, + deployment_id: Annotated[ + str | None, + typer.Option( + "--deployment-id", "-d", + help="Add version to existing deployment (UUID)", + ), + ] = None, + description: Annotated[ + str, + typer.Option( + "--description", + help="Version description", + ), + ] = "", +) -> None: + """Deploy an agent config to the FAOS database. + + Creates a versioned deployment that can be tracked, evaluated, + and compared in the dashboard. + + First deploy creates a new deployment (v1). Subsequent deploys + with --deployment-id add versions to the same deployment. + + Examples: + # Deploy a new agent + flow deploy --agent agent_config.yaml + + # Deploy with custom name + flow deploy --agent agent_config.yaml --name "trip-planner-v2" + + # Add version to existing deployment + flow deploy --agent optimized.yaml --deployment-id + + # Deploy best config from optimization + flow deploy --agent ~/.flow/optimizations//agents/best_score.yaml + """ + asyncio.run(_run_deploy( + agent_path=agent, + name=name, + deployment_id=deployment_id, + description=description, + )) + + +async def _run_deploy( + agent_path: Path, + name: str | None, + deployment_id: str | None, + description: str, +) -> None: + """Run deployment.""" + if not agent_path.exists(): + console.print(f"[red]Error:[/] Agent file not found: {agent_path}") + raise typer.Exit(1) + + agent_config = load_agent(agent_path) + if name: + agent_config.name = name + + try: + from flow.ui.services.persistence_adapter import PersistenceAdapter + + adapter = PersistenceAdapter() + result = await adapter.deploy_agent( + agent_config, + deployment_id=deployment_id, + source="deploy", + version_description=description, + ) + except ImportError: + console.print("[red]Error:[/] Database dependencies not available.") + console.print("[dim]Make sure flow is installed with UI support.[/]") + raise typer.Exit(1) + + console.print("\n[bold green]Deployed![/]\n") + console.print(f" Agent: [cyan]{agent_config.name}[/]") + console.print(f" Deployment ID: [cyan]{result.deployment_id}[/]") + console.print(f" Config ID: [cyan]{result.config_id}[/]") + console.print(f" Version: [cyan]{result.version}[/]") + console.print(f"\n[dim]View in dashboard:[/] http://localhost:8091/deployments/{result.deployment_id}") diff --git a/src/flow/cli/evaluate.py b/src/flow/cli/evaluate.py new file mode 100644 index 0000000000000000000000000000000000000000..5d065cde11fbebab9f4b97c67e83f6183e3cfcc8 --- /dev/null +++ b/src/flow/cli/evaluate.py @@ -0,0 +1,279 @@ +# Copyright (c) Microsoft. All rights reserved. + +"""Evaluate command for measuring agent performance on tasks.""" + +from __future__ import annotations + +import asyncio +import json +from pathlib import Path +from typing import Annotated + +import typer +from rich.console import Console +from rich.table import Table + +from flow.experiments.models import Agent, load_agent +from flow.experiments.optimizer import evaluate_agent +from flow.experiments.types import Task, get_task_suite, load_tasks_from_jsonl + +console = Console() + + +def evaluate( + agent: Annotated[ + Path | None, + typer.Option( + "--agent", "-a", + help="Path to agent YAML config file", + ), + ] = None, + tasks: Annotated[ + Path | None, + typer.Option( + "--tasks", "-t", + help="Path to tasks.jsonl file", + ), + ] = None, + suite: Annotated[ + str | None, + typer.Option( + "--suite", "-s", + help="Built-in task suite: quick, core, coding", + ), + ] = None, + parallel: Annotated[ + int, + typer.Option( + "--parallel", "-p", + help="Max concurrent task executions", + ), + ] = 4, + limit: Annotated[ + int | None, + typer.Option( + "--limit", "-l", + help="Max number of tasks to run", + ), + ] = None, + no_llm_eval: Annotated[ + bool, + typer.Option( + "--no-llm-eval", + help="Disable LLM-as-Judge evaluation (faster, less accurate)", + ), + ] = False, + output_json: Annotated[ + bool, + typer.Option( + "--json", + help="Output results as JSON", + ), + ] = False, + persist: Annotated[ + bool, + typer.Option( + "--persist/--no-persist", + help="Persist results to the FAOS database (visible in flow serve dashboard)", + ), + ] = True, +) -> None: + """Evaluate an agent's performance on a set of tasks. + + Runs a single agent configuration against tasks and reports + score, pass rate, token usage, and per-task breakdown. + No optimization or candidate generation — just measurement. + + Examples: + # Evaluate agent config on a task file + flow evaluate --agent agent_config.yaml --tasks tasks.jsonl + + # Evaluate with built-in suite + flow evaluate --agent agent_config.yaml --suite quick + + # Evaluate and persist to dashboard + flow evaluate --agent agent_config.yaml --tasks tasks.jsonl --persist + + # JSON output for scripting + flow evaluate --agent agent_config.yaml --tasks tasks.jsonl --json + """ + asyncio.run(_run_evaluate( + agent_path=agent, + tasks_path=tasks, + suite=suite, + parallel=parallel, + limit=limit, + use_llm_eval=not no_llm_eval, + output_json=output_json, + persist=persist, + )) + + +async def _run_evaluate( + agent_path: Path | None, + tasks_path: Path | None, + suite: str | None, + parallel: int, + limit: int | None, + use_llm_eval: bool, + output_json: bool, + persist: bool, +) -> None: + """Run evaluation.""" + agent_config, task_list = _load_agent_and_tasks(agent_path, tasks_path, suite, limit) + + if not output_json: + console.print(f"\n[bold]Agent:[/] {agent_config.name}") + console.print(f"[bold]Tasks:[/] {len(task_list)}") + for t in task_list: + console.print(f" - {t.name}") + console.print() + + try: + summary = await evaluate_agent( + agent_config, + task_list, + parallel=parallel, + use_llm_evaluator=use_llm_eval, + quiet=True, + ) + except KeyboardInterrupt: + console.print("\n[yellow]Evaluation cancelled.[/]") + raise typer.Exit(1) + + # Persist to database if requested + job_id: str | None = None + if persist: + job_id = await _persist_evaluation(summary, agent_config) + + # Output results + if output_json: + result = { + "agent": agent_config.name, + "score": round(summary.avg_score, 4), + "pass_rate": round(summary.pass_rate, 4), + "total_tokens": summary.total_tokens, + "avg_tokens": round(summary.avg_tokens, 1), + "avg_duration": round(summary.avg_duration, 2), + "task_count": summary.task_count, + "job_id": job_id, + "tasks": [ + { + "name": tr.task_name, + "score": round(tr.eval_score, 4), + "passed": tr.eval_passed, + "tokens": tr.metrics.total_tokens, + "reasoning": tr.eval_reasoning, + } + for tr in summary.task_results + ], + } + console.print(json.dumps(result, indent=2)) + else: + _print_eval_results(summary, job_id) + + +def _load_agent_and_tasks( + agent_path: Path | None, + tasks_path: Path | None, + suite: str | None, + limit: int | None, +) -> tuple[Agent, list[Task]]: + """Load agent config and task list from CLI arguments.""" + if agent_path: + if not agent_path.exists(): + console.print(f"[red]Error:[/] Agent file not found: {agent_path}") + raise typer.Exit(1) + agent_config = load_agent(agent_path) + else: + agent_config = Agent(name="flow_agent") + + task_list: list[Task] = [] + if tasks_path: + if not tasks_path.exists(): + console.print(f"[red]Error:[/] Tasks file not found: {tasks_path}") + raise typer.Exit(1) + task_list = load_tasks_from_jsonl(tasks_path) + elif suite: + try: + task_list = get_task_suite(suite) + except ValueError as e: + console.print(f"[red]Error:[/] {e}") + raise typer.Exit(1) + else: + try: + task_list = get_task_suite("quick") + except ValueError: + console.print("[red]Error:[/] No tasks specified. Use --tasks or --suite") + raise typer.Exit(1) + + if limit is not None and limit > 0: + task_list = task_list[:limit] + + if not task_list: + console.print("[red]Error:[/] No tasks to evaluate") + raise typer.Exit(1) + + return agent_config, task_list + + +async def _persist_evaluation(summary: object, agent_config: Agent) -> str | None: + """Deploy agent and persist evaluation results to database.""" + try: + from flow.ui.services.persistence_adapter import PersistenceAdapter + + adapter = PersistenceAdapter() + deploy_result = await adapter.deploy_agent(agent_config, source="evaluate") + job_id = await adapter.persist_evaluation(summary, deploy_result.config_id) + return job_id + except ImportError: + console.print("[yellow]Warning:[/] Database not available. Results not persisted.") + console.print("[dim]Start the dashboard with: flow serve[/]") + return None + except Exception as e: + console.print(f"[yellow]Warning:[/] Failed to persist results: {e}") + return None + + +def _print_eval_results(summary: object, job_id: str | None = None) -> None: + """Print evaluation results as Rich tables.""" + from flow.experiments.optimizer import CandidateSummary + + assert isinstance(summary, CandidateSummary) + + console.print("[bold green]Evaluation complete![/]\n") + + table = Table(title="Results") + table.add_column("Metric", style="cyan") + table.add_column("Value", style="green") + + table.add_row("Score", f"{summary.avg_score:.2f}") + table.add_row("Pass Rate", f"{summary.pass_rate:.0%}") + table.add_row("Total Tokens", f"{summary.total_tokens:,}") + table.add_row("Avg Tokens", f"{summary.avg_tokens:,.0f}") + table.add_row("Avg Duration", f"{summary.avg_duration:.1f}s") + table.add_row("Tasks", str(summary.task_count)) + if job_id: + table.add_row("Job ID", job_id) + console.print(table) + + if summary.task_results: + console.print() + task_table = Table(title="Per-Task Breakdown") + task_table.add_column("Task", style="cyan") + task_table.add_column("Score", style="green") + task_table.add_column("Status", style="bold") + task_table.add_column("Tokens", style="dim") + + for tr in summary.task_results: + status = "[green]PASS[/]" if tr.eval_passed else "[red]FAIL[/]" + task_table.add_row( + tr.task_name, + f"{tr.eval_score:.2f}", + status, + f"{tr.metrics.total_tokens:,}", + ) + console.print(task_table) + + if job_id: + console.print(f"\n[dim]View in dashboard:[/] http://localhost:8091/jobs/{job_id}") diff --git a/src/flow/cli/hf_import.py b/src/flow/cli/hf_import.py index 49fefd55deef81a80c59e415d97f6357a48a339d..f8c7aa728426d1e4b254ee037ddf8fc473e20276 100644 --- a/src/flow/cli/hf_import.py +++ b/src/flow/cli/hf_import.py @@ -10,6 +10,7 @@ from rich.console import Console from flow.experiments.hf_datasets import ( DATASET_CONVERTERS, + LAZY_CONVERTERS, import_hf_dataset, save_tasks_to_jsonl, ) @@ -98,7 +99,7 @@ def hf_import( if list_supported: console.print("\n[bold]Supported Datasets:[/]") console.print("\n[dim]You can add custom converters via register_converter()[/]\n") - for name in sorted(DATASET_CONVERTERS.keys()): + for name in sorted({*DATASET_CONVERTERS, *LAZY_CONVERTERS}): console.print(f" • {name}") return diff --git a/src/flow/cli/optimize.py b/src/flow/cli/optimize.py index 76facc66089727decc2506c46365f44b61268099..933fdead99134f451ecc01889f97ef63f3a33810 100644 --- a/src/flow/cli/optimize.py +++ b/src/flow/cli/optimize.py @@ -71,13 +71,27 @@ def optimize( help="Max concurrent experiments", ), ] = 4, - vary: Annotated[ + strategy: Annotated[ str | None, typer.Option( - "--vary", "-v", - help="Comma-separated params to vary: compaction, strategy, tools, head, tail", + "--strategy", "-S", + help="Active strategy: tools, instructions, skills (comma-separated for pipeline)", ), ] = None, + max_iterations: Annotated[ + int, + typer.Option( + "--max-iterations", + help="Max iterations for active strategies", + ), + ] = 3, + min_improvement: Annotated[ + float, + typer.Option( + "--min-improvement", + help="Min score improvement to continue iterating", + ), + ] = 0.01, output: Annotated[ Path | None, typer.Option( @@ -106,33 +120,31 @@ def optimize( help="Maximum number of candidates to generate", ), ] = 100, + persist: Annotated[ + bool, + typer.Option( + "--persist/--no-persist", + help="Persist results to the FAOS database (visible in flow serve dashboard)", + ), + ] = True, ) -> None: """Find the best agent configuration through experimentation. - Runs experiments in parallel, evaluates with LLM-as-Judge, - ranks via Pareto analysis, and exports winning agent configs. - Examples: - # Use experiment YAML (recommended - defines agent, tasks, and variations) - flow optimize --experiment experiment.yaml - - # Run with task file and default candidates - flow optimize --tasks tasks.jsonl - - # Vary specific parameters - flow optimize --vary compaction,tools --tasks tasks.jsonl + # Optimize tools + flow optimize --agent agent.yaml --tasks tasks.jsonl --strategy tools - # Test all compaction strategies - flow optimize --vary strategy --suite coding + # Optimize instructions + flow optimize --agent agent.yaml --suite quick --strategy instructions - # Use built-in task suite - flow optimize --suite coding --parallel 2 + # Optimize both (pipeline: instructions then tools) + flow optimize --agent agent.yaml --tasks tasks.jsonl --strategy instructions,tools - # Start from a base agent definition - flow optimize --agent base_agent.yaml --vary compaction,tools --tasks tasks.jsonl + # Skip persisting to dashboard + flow optimize --agent agent.yaml --tasks tasks.jsonl --strategy tools --no-persist - # Use GEPA for active prompt optimization (via YAML config) - flow optimize --config gepa_strategy.yaml --agent base_agent.yaml --tasks tasks.jsonl + # Use experiment YAML (defines agent, tasks, and variations) + flow optimize --experiment experiment.yaml """ asyncio.run(_run_optimize( tasks_path=tasks, @@ -141,11 +153,14 @@ def optimize( agent_path=agent, suite=suite, parallel=parallel, - vary=vary, + strategy=strategy, + max_iterations=max_iterations, + min_improvement=min_improvement, output_dir=output, use_llm_eval=not no_llm_eval, budget=budget, limit=limit, + persist=persist, )) @@ -156,11 +171,14 @@ async def _run_optimize( agent_path: Path | None, suite: str | None, parallel: int, - vary: str | None, + strategy: str | None, + max_iterations: int, + min_improvement: float, output_dir: Path | None, use_llm_eval: bool, budget: int, limit: int | None = None, + persist: bool = False, ) -> None: """Run the optimization.""" # If experiment YAML provided, use it as the source of truth @@ -177,26 +195,43 @@ async def _run_optimize( # Load base agent base = _load_base_agent(agent_path) + # Active strategy mode (--strategy tools, --strategy instructions,tools) + if strategy: + result = await _run_strategy_optimize( + strategy_names=strategy, + base=base, + tasks=tasks, + parallel=parallel, + use_llm_eval=use_llm_eval, + budget=budget, + output_dir=output_dir, + max_iterations=max_iterations, + min_improvement=min_improvement, + ) + if persist and result: + await _persist_optimization(result, base) + return + # Load candidates and check if a strategy is defined in config - candidates, strategy_instance = await _load_candidates_and_strategy(config_path, vary, base, budget) - + candidates, strategy_instance = await _load_candidates_and_strategy(config_path, base, budget) + # If a strategy was provided (like GepaStrategy), run it directly if strategy_instance is not None: console.print("\n[bold]Running active optimization strategy...[/]") await _run_active_strategy( - strategy=strategy_instance, - base_agent=base, - tasks=tasks, - output_dir=output_dir, + strategy=strategy_instance, + base_agent=base, + tasks=tasks, + output_dir=output_dir, parallel=parallel, use_llm_eval=use_llm_eval, budget=budget ) return - + # Otherwise, use traditional grid search with candidates if not candidates: - console.print("[red]Error:[/] No candidates to test. Use --config or --vary") + console.print("[red]Error:[/] No candidates to test. Use --strategy or --config") raise typer.Exit(1) console.print(f"\n[bold]Base Agent:[/] {base.name}") @@ -223,6 +258,9 @@ async def _run_optimize( console.print("\nTo use an agent config:") console.print(f" [dim]flow run --config {result.output_dir / 'agents' / 'best_score.yaml'} \"your task\"[/]") + if persist: + await _persist_optimization(result, base) + except KeyboardInterrupt: console.print("\n[yellow]Optimization cancelled.[/]") raise typer.Exit(1) @@ -360,7 +398,6 @@ def _load_base_agent(agent_path: Path | None) -> Agent: async def _load_candidates_and_strategy( config_path: Path | None, - vary: str | None, base: Agent, budget: int, ) -> tuple[list[Candidate], Any | None]: @@ -405,17 +442,13 @@ async def _load_candidates_and_strategy( console.print("[red]Error:[/] Config file has no CANDIDATES, VARIATIONS, or STRATEGY") raise typer.Exit(1) - if vary: - variations = _parse_vary_flag(vary) - strategy = GridSearchStrategy(variations) - return await strategy.generate(base, budget), None - - # Default: explore context engineering dimensions + # Default: explore all key dimensions (compaction, tools, instructions) strategy = GridSearchStrategy(variations={ "compaction": [ - CompactionConfig.head_tail(10, 40), CompactionConfig.none(), + CompactionConfig.head_tail(10, 40), ], + "tools": ["minimal", "standard"], }) return await strategy.generate(base, budget), None @@ -455,12 +488,18 @@ def _load_yaml_strategy(path: Path) -> Any | None: console.print("[red]Error:[/] GEPA optimizer not available.") console.print("[dim]Install with: pip install flow-agent[optimizer][/]") raise typer.Exit(1) - elif strategy_type == "llm_rewriter": - from flow.experiments.strategies.llm_rewriter import LLMRewriterStrategy - return LLMRewriterStrategy(config=strategy_config) + elif strategy_type == "instruction": + from flow.experiments.strategies.instruction import InstructionOptimizer + return InstructionOptimizer(config=strategy_config) + elif strategy_type == "tool": + from flow.experiments.strategies.tool import ToolOptimizer + return ToolOptimizer(config=strategy_config) + elif strategy_type == "skill": + from flow.experiments.strategies.skill import SkillOptimizer + return SkillOptimizer(config=strategy_config) else: console.print(f"[red]Error:[/] Unknown strategy type: {strategy_type}") - console.print("[dim]Supported: gepa, llm_rewriter[/]") + console.print("[dim]Supported: gepa, instruction, tool, skill[/]") raise typer.Exit(1) @@ -488,50 +527,6 @@ def _load_python_config(path: Path) -> tuple[list[Candidate], dict[str, Any], An return candidates, variations, strategy -def _parse_vary_flag(vary: str) -> dict[str, Any]: - """Parse --vary flag into variations dict. - - Supported parameters: - compaction, compact: Test head_tail vs none - strategy: Test all compaction strategies (none, head_tail, sliding_window, summarization) - tools: Test minimal vs standard tool sets - head, head_size: Vary head sizes (5, 10, 20) - tail, tail_size: Vary tail sizes (20, 40, 60) - """ - variations: dict[str, Any] = {} - - for param in vary.split(","): - param = param.strip().lower() - - if param in ("compaction", "compact"): - variations["compaction"] = [ - CompactionConfig.head_tail(10, 40), - CompactionConfig.none(), - ] - elif param in ("strategy", "strategies"): - # Test all compaction strategies - variations["compaction"] = [ - CompactionConfig.none(), - CompactionConfig.head_tail(10, 40), - CompactionConfig(strategy="sliding_window", token_budget=50_000), - CompactionConfig(strategy="summarization", token_budget=50_000), - ] - elif param in ("tools", "toolset"): - # Tool variations - memory and subagent are just tools - variations["tools"] = ["minimal", "standard"] - elif param in ("head", "head_size"): - variations["compaction"] = [ - CompactionConfig.head_tail(h, 40) for h in [5, 10, 20] - ] - elif param in ("tail", "tail_size"): - variations["compaction"] = [ - CompactionConfig.head_tail(10, t) for t in [20, 40, 60] - ] - else: - console.print(f"[yellow]Warning:[/] Unknown vary param: {param}") - - return variations - async def _run_active_strategy( strategy: Any, @@ -544,7 +539,7 @@ async def _run_active_strategy( ) -> None: """Run an active optimization strategy. - For strategies that use the ExperimentRunner protocol (LLMRewriterStrategy), + For strategies that use the ExperimentRunner protocol (InstructionOptimizer), delegates to FlowOptimizer.optimize_with_strategy() which handles setup, evaluation, Pareto analysis, and export. @@ -732,3 +727,140 @@ async def _run_gepa_strategy( console.print(f"\nAgents exported to: [cyan]{output_path / 'agents'}[/]") + +async def _run_strategy_optimize( + strategy_names: str, + base: Agent, + tasks: list[Task], + parallel: int, + use_llm_eval: bool, + budget: int, + output_dir: Path | None, + max_iterations: int, + min_improvement: float, +) -> "OptimizationResult | None": + """Run active strategy optimization (--strategy flag). + + Supports single strategies and comma-separated pipelines. + Reuses _resolve_strategy() from agent_api to avoid duplication. + """ + from flow.experiments.ablation import compute_pareto_frontier + from flow.experiments.agent_api import _resolve_strategy + from flow.experiments.optimizer import CandidateSummary, OptimizationResult + + strategy_list = [s.strip() for s in strategy_names.split(",")] + strategy_config = { + "max_iterations": max_iterations, + "min_improvement": min_improvement, + } + + console.print(f"\n[bold]Strategy:[/] {' → '.join(strategy_list)}") + console.print(f"[bold]Base Agent:[/] {base.name}") + console.print(f"[bold]Tasks:[/] {len(tasks)}") + console.print(f"[bold]Max Iterations:[/] {max_iterations}") + console.print() + + current_agent = base + last_result: OptimizationResult | None = None + all_summaries: list[CandidateSummary] = [] + total_experiments = 0 + total_duration = 0.0 + + try: + for strat_name in strategy_list: + try: + strat_instance = _resolve_strategy(strat_name, strategy_config) + except ValueError as e: + console.print(f"[red]Error:[/] {e}") + raise typer.Exit(1) + + optimizer = FlowOptimizer( + parallel=parallel, + use_llm_evaluator=use_llm_eval, + output_dir=output_dir, + ) + + last_result = await optimizer.optimize_with_strategy( + strategy=strat_instance, + base=current_agent, + tasks=tasks, + budget=budget, + ) + + # Accumulate results from all stages + all_summaries.extend(last_result.summaries) + total_experiments += last_result.total_experiments + total_duration += last_result.total_duration_seconds + + # Next stage starts from the best agent found + best = last_result.get_best_candidate("score") + if best: + current_agent = best.candidate.agent + + # Merge all stage results into a combined result with recomputed Pareto + if last_result and len(strategy_list) > 1: + # Deduplicate summaries by name (baseline may appear in multiple stages) + seen_names: set[str] = set() + deduped: list[CandidateSummary] = [] + for s in all_summaries: + if s.name not in seen_names: + seen_names.add(s.name) + deduped.append(s) + + # Recompute Pareto frontier across all stages + pareto_names = compute_pareto_frontier(deduped) + for s in deduped: + s.is_pareto_optimal = s.name in pareto_names + s.pareto_rank = 0 if s.is_pareto_optimal else 1 + + rank_by_score = sorted(deduped, key=lambda s: s.avg_score, reverse=True) + rank_by_tokens = sorted(deduped, key=lambda s: s.avg_tokens) + rank_by_efficiency = sorted( + deduped, + key=lambda s: s.avg_score / max(s.avg_tokens, 1), + reverse=True, + ) + + last_result = OptimizationResult( + timestamp=last_result.timestamp, + output_dir=last_result.output_dir, + summaries=deduped, + pareto_frontier=pareto_names, + exported_agents=last_result.exported_agents, + rank_by_score=[s.name for s in rank_by_score], + rank_by_tokens=[s.name for s in rank_by_tokens], + rank_by_efficiency=[s.name for s in rank_by_efficiency], + total_experiments=total_experiments, + total_duration_seconds=total_duration, + ) + + console.print("\n[bold green]Optimization complete![/]") + if last_result: + console.print(f"\nBest agents exported to: [cyan]{last_result.output_dir / 'agents'}[/]") + console.print("\nTo use the best config:") + console.print(f" [dim]flow run --config {last_result.output_dir / 'agents' / 'best_score.yaml'} \"your task\"[/]") + + except KeyboardInterrupt: + console.print("\n[yellow]Optimization cancelled.[/]") + raise typer.Exit(1) + + return last_result + + +async def _persist_optimization(result: "OptimizationResult", base_agent: Agent) -> None: + """Deploy agent and persist optimization results to database.""" + from flow.experiments.optimizer import OptimizationResult + + try: + from flow.ui.services.persistence_adapter import PersistenceAdapter + + adapter = PersistenceAdapter() + deploy_result = await adapter.deploy_agent(base_agent, source="optimize") + job_id = await adapter.persist_optimization(result, deploy_result.config_id) + console.print(f"\n[dim]View in dashboard:[/] http://localhost:8091/jobs/{job_id}") + except ImportError: + console.print("[yellow]Warning:[/] Database not available. Results not persisted.") + console.print("[dim]Start the dashboard with: flow serve[/]") + except Exception as e: + console.print(f"[yellow]Warning:[/] Failed to persist results: {e}") + diff --git a/src/flow/experiments/agent_api.py b/src/flow/experiments/agent_api.py index 3e6fde3b666741c9e3e6d5b246582dcf826114ab..d99bfb78459afada66f050e0c6d11caba7b8e256 100644 --- a/src/flow/experiments/agent_api.py +++ b/src/flow/experiments/agent_api.py @@ -36,8 +36,10 @@ DEFAULT_VARIATIONS: dict[str, list[Any]] = { # Known active strategy names and their classes _STRATEGY_MAP: dict[str, str] = { - "tools": "flow.experiments.strategies.tool_selector.ToolSelectorStrategy", - "instructions": "flow.experiments.strategies.llm_rewriter.LLMRewriterStrategy", + "tools": "flow.experiments.strategies.tool.ToolOptimizer", + "instructions": "flow.experiments.strategies.instruction.InstructionOptimizer", + "skills": "flow.experiments.strategies.skill.SkillOptimizer", + "gepa_instructions": "flow.experiments.strategies.gepa_instruction.GEPAInstructionOptimizer", } @@ -131,11 +133,15 @@ async def _evaluate_agent_impl( return result -def _resolve_strategy(name: str) -> Any: +def _resolve_strategy(name: str, config: dict[str, Any] | None = None) -> Any: """Import and instantiate a named strategy. Args: - name: Strategy name ("tools", "instructions") + name: Strategy name ("tools", "instructions", "skills") + config: Optional strategy-specific config. Merged with defaults: + max_iterations (int): Max optimization iterations (default: 3) + min_improvement (float): Min score gain to continue (default: 0.01) + Additional keys are passed through to the strategy. Returns: Strategy instance @@ -147,14 +153,18 @@ def _resolve_strategy(name: str) -> Any: available = ["grid"] + list(_STRATEGY_MAP.keys()) raise ValueError(f"Unknown strategy: {name!r}. Available: {available}") + defaults: dict[str, Any] = { + "max_iterations": 3, + "min_improvement": 0.01, + } + if config: + defaults.update(config) + module_path, class_name = _STRATEGY_MAP[name].rsplit(".", 1) import importlib mod = importlib.import_module(module_path) cls = getattr(mod, class_name) - return cls(config={ - "max_iterations": 3, - "min_improvement": 0.01, - }) + return cls(config=defaults) def _opt_result_to_agent_result( @@ -216,6 +226,7 @@ async def _optimize_agent_impl( quiet: bool, agent_id: str | None = None, strategy: str | list[str] | None = None, + strategy_config: dict[str, Any] | None = None, ) -> AgentOptimizationResult: """Implementation of Agent.optimize(). @@ -225,6 +236,8 @@ async def _optimize_agent_impl( grid search. A string like "tools" or "instructions" runs that strategy. A list runs them sequentially, each starting from the previous best. + strategy_config: Optional config dict passed to strategy constructors. + Merged with defaults (max_iterations=3, min_improvement=0.01). """ resolved_tasks = _resolve_tasks(tasks) @@ -264,7 +277,7 @@ async def _optimize_agent_impl( last_opt_result: OptimizationResult | None = None for strat_name in strategy_list: - strat_instance = _resolve_strategy(strat_name) + strat_instance = _resolve_strategy(strat_name, strategy_config) optimizer = FlowOptimizer(parallel=parallel, use_llm_evaluator=use_llm_eval) if quiet: diff --git a/src/flow/experiments/data/tasks/house_rules.jsonl b/src/flow/experiments/data/tasks/house_rules.jsonl new file mode 100644 index 0000000000000000000000000000000000000000..5942a8d85b420e7f0ffe029b62d81498879a9ab3 --- /dev/null +++ b/src/flow/experiments/data/tasks/house_rules.jsonl @@ -0,0 +1,3 @@ +{"name": "calculator_module", "prompt": "Create a Python module calc.py with four functions: add, subtract, multiply, divide. Each takes two numbers and returns the result. Include a brief test at the bottom (if __name__ == '__main__') that exercises each function and prints the results. Then run it.", "criteria": [{"name": "file_created", "instruction": "calc.py was created and runs without errors"}, {"name": "correct_results", "instruction": "All four operations produce correct results when run"}, {"name": "type_annotations", "instruction": "EVERY function has full type annotations on ALL parameters AND the return type. e.g. def add(a: float, b: float) -> float. Functions missing ANY annotation fail this criterion."}, {"name": "error_handling", "instruction": "divide() MUST raise a ValueError (not ZeroDivisionError, not return None) when the divisor is zero. The test block must demonstrate this by catching ValueError and printing a message. If ZeroDivisionError is raised or None is returned, this fails."}, {"name": "module_exports", "instruction": "The module MUST define __all__ = ['add', 'subtract', 'multiply', 'divide'] at the top of the file. If __all__ is missing this criterion fails."}], "category": "house_rules", "metadata": {"expected_duration": 120}} +{"name": "csv_report", "prompt": "Create a Python script report.py that generates a CSV file 'sales_report.csv' with 10 rows of sample sales data. Columns: date, product, quantity, unit_price, total. Then read the CSV back and print a summary: total revenue and the top-selling product by quantity. Run the script.", "criteria": [{"name": "file_created", "instruction": "report.py was created and runs without errors"}, {"name": "csv_generated", "instruction": "sales_report.csv was created with 10 data rows"}, {"name": "iso_dates", "instruction": "ALL dates in the CSV MUST be in ISO-8601 format (YYYY-MM-DD). Dates like 'Jan 15, 2024' or '01/15/2024' or 'January 15' FAIL this criterion. Only YYYY-MM-DD is acceptable."}, {"name": "header_comment", "instruction": "The very first line of the CSV file MUST be a comment line starting with '# ' that describes the file contents and generation timestamp. e.g. '# Sales report generated 2024-01-15T10:30:00'. If the first line is the column header row, this fails."}, {"name": "monetary_format", "instruction": "When printing the summary to stdout, ALL monetary values MUST be formatted with exactly 2 decimal places and a dollar sign. e.g. '$1,234.56' or '$42.00'. Values like '1234.5' or '42' or '$1234.567' FAIL this criterion."}], "category": "house_rules", "metadata": {"expected_duration": 120}} +{"name": "api_response_builder", "prompt": "Create a Python module api_utils.py with a function build_response(data, status_code=200) that builds a JSON-ready dictionary representing an API response. Also create a function validate_email(email: str) -> bool that checks if an email is roughly valid. Write a test block that demonstrates both functions with a few examples and prints the JSON output. Run it.", "criteria": [{"name": "file_created", "instruction": "api_utils.py was created and runs without errors"}, {"name": "correct_behavior", "instruction": "build_response returns a dict and validate_email correctly accepts/rejects obvious cases"}, {"name": "response_envelope", "instruction": "build_response() MUST return a dict with EXACTLY this structure: {'status': 'ok' or 'error', 'code': int, 'data': ..., 'timestamp': ISO-8601 string}. The 'status' field MUST be 'ok' for codes 200-299 and 'error' for all others. 'timestamp' MUST be present and in ISO-8601 format. If any of these keys are missing or the status logic is wrong, this fails."}, {"name": "error_response", "instruction": "When status_code >= 400, the response MUST include an 'error' key with a human-readable error message string (not None, not empty). The test block MUST demonstrate at least one error response (e.g. status_code=404). If no error response is shown or the 'error' key is missing for error codes, this fails."}, {"name": "json_output", "instruction": "The test block MUST use json.dumps with indent=2 to print the response. Raw dict printing (using print(dict)) or json.dumps without indent FAIL this criterion. The output must be valid, pretty-printed JSON."}], "category": "house_rules", "metadata": {"expected_duration": 120}} diff --git a/src/flow/experiments/eval_cache.py b/src/flow/experiments/eval_cache.py new file mode 100644 index 0000000000000000000000000000000000000000..9f71b3af970a86b9d1ec558e41b38d40cbc29399 --- /dev/null +++ b/src/flow/experiments/eval_cache.py @@ -0,0 +1,223 @@ +# Copyright (c) Microsoft. All rights reserved. + +"""Evaluation cache for avoiding redundant agent evaluations. + +Provides pluggable backends (in-memory and disk-based) so that identical +(agent-config, task) pairs are not re-evaluated within or across sessions. + +Cache keys are SHA-256 hashes of the agent's functional configuration +(instructions, tools, framework, llm_config, compaction) combined with +the task definition (prompt, criteria). The agent *name* is intentionally +excluded because it varies across iterations while the actual behaviour +remains the same. +""" + +from __future__ import annotations + +import hashlib +import json +import logging +import sqlite3 +import time +from dataclasses import asdict +from pathlib import Path +from typing import Any, Protocol, runtime_checkable + +logger = logging.getLogger(__name__) + + +# --------------------------------------------------------------------------- +# Protocol +# --------------------------------------------------------------------------- + + +@runtime_checkable +class EvaluationCache(Protocol): + """Protocol for evaluation result caching.""" + + def get(self, key: str) -> dict[str, Any] | None: + """Return cached result dict for *key*, or ``None`` on miss.""" + ... + + def put(self, key: str, result: dict[str, Any]) -> None: + """Store *result* under *key*.""" + ... + + +# --------------------------------------------------------------------------- +# Cache-key builder +# --------------------------------------------------------------------------- + + +def build_cache_key(agent_config: dict[str, Any], task_dict: dict[str, Any]) -> str: + """Build a deterministic cache key from agent config and task. + + Args: + agent_config: Dict with the agent's functional fields + (instructions, tools, framework, llm_config, compaction). + task_dict: Dict with the task's identity fields + (prompt, criteria). + + Returns: + A hex SHA-256 digest string. + """ + blob = json.dumps( + {"agent": agent_config, "task": task_dict}, + sort_keys=True, + default=str, + ) + return hashlib.sha256(blob.encode()).hexdigest() + + +def agent_cache_dict(agent: Any) -> dict[str, Any]: + """Extract the functional (behaviour-defining) fields from an Agent. + + The agent *name* is excluded so that two agents with identical + config but different names share the same cache key. + """ + return { + "instructions": getattr(agent, "instructions", None), + "tools": _normalise(getattr(agent, "tools", None)), + "framework": getattr(agent, "framework", None), + "llm_config": getattr(agent, "llm_config", None), + "compaction": _compaction_dict(getattr(agent, "compaction", None)), + } + + +def task_cache_dict(task: Any) -> dict[str, Any]: + """Extract the identity fields from a Task.""" + criteria = getattr(task, "criteria", []) + criteria_dicts = [] + for c in criteria: + if hasattr(c, "name"): + criteria_dicts.append({ + "name": c.name, + "instruction": getattr(c, "instruction", ""), + }) + else: + criteria_dicts.append(c) + return { + "prompt": getattr(task, "prompt", ""), + "criteria": criteria_dicts, + } + + +def _normalise(value: Any) -> Any: + """Normalise tool configs for deterministic hashing.""" + if isinstance(value, list): + return sorted(value) + return value + + +def _compaction_dict(compaction: Any) -> dict[str, Any] | None: + if compaction is None: + return None + try: + return asdict(compaction) + except Exception: + return str(compaction) + + +# --------------------------------------------------------------------------- +# In-memory backend +# --------------------------------------------------------------------------- + + +class InMemoryCache: + """Dict-backed cache that lives for the lifetime of the object.""" + + def __init__(self) -> None: + self._store: dict[str, dict[str, Any]] = {} + + def get(self, key: str) -> dict[str, Any] | None: + return self._store.get(key) + + def put(self, key: str, result: dict[str, Any]) -> None: + self._store[key] = result + + @property + def size(self) -> int: + return len(self._store) + + +# --------------------------------------------------------------------------- +# Disk (SQLite) backend +# --------------------------------------------------------------------------- + +_DEFAULT_CACHE_DIR = Path.home() / ".flow" / "cache" +_DB_FILENAME = "eval_cache.db" + + +class DiskCache: + """SQLite-backed cache that persists across sessions. + + The database is created lazily on first access at + ``~/.flow/cache/eval_cache.db`` (configurable via *cache_dir*). + """ + + def __init__(self, cache_dir: Path | None = None) -> None: + self._cache_dir = cache_dir or _DEFAULT_CACHE_DIR + self._db_path = self._cache_dir / _DB_FILENAME + self._conn: sqlite3.Connection | None = None + + # -- lazy init ---------------------------------------------------------- + + def _ensure_db(self) -> sqlite3.Connection: + if self._conn is not None: + return self._conn + self._cache_dir.mkdir(parents=True, exist_ok=True) + self._conn = sqlite3.connect(str(self._db_path)) + self._conn.execute( + """ + CREATE TABLE IF NOT EXISTS eval_cache ( + key TEXT PRIMARY KEY, + result TEXT NOT NULL, + created_at REAL NOT NULL + ) + """ + ) + self._conn.commit() + return self._conn + + # -- protocol ----------------------------------------------------------- + + def get(self, key: str) -> dict[str, Any] | None: + conn = self._ensure_db() + row = conn.execute( + "SELECT result FROM eval_cache WHERE key = ?", (key,) + ).fetchone() + if row is None: + return None + try: + return json.loads(row[0]) + except (json.JSONDecodeError, TypeError): + return None + + def put(self, key: str, result: dict[str, Any]) -> None: + conn = self._ensure_db() + conn.execute( + """ + INSERT OR REPLACE INTO eval_cache (key, result, created_at) + VALUES (?, ?, ?) + """, + (key, json.dumps(result, default=str), time.time()), + ) + conn.commit() + + # -- helpers ------------------------------------------------------------ + + def close(self) -> None: + if self._conn is not None: + self._conn.close() + self._conn = None + + @property + def size(self) -> int: + conn = self._ensure_db() + row = conn.execute("SELECT COUNT(*) FROM eval_cache").fetchone() + return row[0] if row else 0 + + def clear(self) -> None: + conn = self._ensure_db() + conn.execute("DELETE FROM eval_cache") + conn.commit() diff --git a/src/flow/experiments/evaluators/llm.py b/src/flow/experiments/evaluators/llm.py index 89c735d70e0847fd43b50e715be2d67241317dd4..68107638e52d7312bed53b8d7c615f15464f9573 100644 --- a/src/flow/experiments/evaluators/llm.py +++ b/src/flow/experiments/evaluators/llm.py @@ -141,7 +141,7 @@ The agent was given this task: ``` ## Files Created -{json.dumps(run_result.files_created, indent=2) if run_result.files_created else "None"} +{self._format_files_created(run_result)} ## Tool Results {self._format_tool_results(run_result.tool_results)} @@ -200,6 +200,12 @@ For each criterion, provide TWO scores: }, } + def _format_files_created(self, run_result: RunResult) -> str: + """Format files created section as a simple list of filenames.""" + if not run_result.files_created: + return "None" + return "\n".join(f"- {f}" for f in run_result.files_created) + def _format_tool_results(self, tool_results: list[dict[str, str]]) -> str: """Format tool results for the evaluation prompt.""" if not tool_results: @@ -324,7 +330,7 @@ Tokens used: {metrics.total_tokens} (input: {metrics.input_tokens}, output: {met ) except Exception as e: - logger.error(f"LLM evaluation failed: {e}") + logger.error(f"LLM evaluation failed: {e}", exc_info=True) return EvalResult( score=0.0, passed=False, diff --git a/src/flow/experiments/gaia_converter.py b/src/flow/experiments/gaia_converter.py index 0f301d41402d1816a8474bce469123812dd0b3eb..91dc9ba03457e6faefdf30af3efad40c5bcdfd88 100644 --- a/src/flow/experiments/gaia_converter.py +++ b/src/flow/experiments/gaia_converter.py @@ -156,25 +156,20 @@ def convert_to_flow_task(gaia_task: dict[str, Any]) -> Task: ) -def convert_gaia(example: dict[str, Any], index: int, dataset_metadata: dict[str, Any] | None = None) -> Task: - logger.debug(f"Processing task at index: {index}") - - if dataset_metadata is None: - raise ValueError("dataset_metadata is required and cannot be None.") - - # Validate required fields in dataset_metadata - config = dataset_metadata.get("config") - split = dataset_metadata.get("split") - local_path = dataset_metadata.get("local_path") - - if config is None: - raise ValueError("dataset_metadata 'config' is required and cannot be None.") +def convert_gaia( + example: dict[str, Any], index: int, *, config: str, split: str, local_path: str, **kwargs: Any +) -> Task: + """Convert a GAIA benchmark example to a Flow task. - if split is None: - raise ValueError("dataset_metadata 'split' is required and cannot be None.") - - if local_path is None: - raise ValueError("dataset_metadata 'local_path' is required and cannot be None.") + Args: + example: Raw example dict from the GAIA dataset. + index: Index of the example in the dataset. + config: Dataset configuration/subset (e.g. ``"2023_level1"``). + split: Dataset split (e.g. ``"train"``, ``"validation"``). + local_path: Root path where the dataset snapshot was downloaded. + **kwargs: Additional metadata reserved for future use; currently ignored. + """ + logger.debug(f"Processing task at index: {index}") # Derive GAIA year from the config when possible (e.g., "2023_level2" -> "2023"), # falling back to "2023" to preserve existing behavior if parsing fails. diff --git a/src/flow/experiments/hf_datasets.py b/src/flow/experiments/hf_datasets.py index 46771dc4956e84ceba673a38939e9bbe329553bd..dd84952dd9377b18ca41f287583d49fe7ff1e20f 100644 --- a/src/flow/experiments/hf_datasets.py +++ b/src/flow/experiments/hf_datasets.py @@ -17,11 +17,26 @@ from __future__ import annotations import json import logging import os +from collections.abc import Callable from pathlib import Path -from typing import Any +from typing import Any, Protocol from flow.experiments.types import EvalCriterion, Task + +class ConverterFunc(Protocol): + """Protocol for dataset converter functions. + + Converters accept a raw example dict, an index, and optional keyword + arguments (e.g. ``config``, ``split``, ``local_path``) that carry + dataset-level metadata. + """ + + def __call__(self, example: dict[str, Any], index: int, **kwargs: Any) -> Task: + """Convert a raw dataset example to a Flow Task.""" + ... + + logger = logging.getLogger(__name__) @@ -29,7 +44,7 @@ logger = logging.getLogger(__name__) # Each converter knows how to extract question/answer from a specific dataset -def convert_gsm8k(example: dict[str, Any], index: int, dataset_metadata: dict[str, Any] | None = None) -> Task: +def convert_gsm8k(example: dict[str, Any], index: int, **kwargs: Any) -> Task: """Convert GSM8K math problem to Flow task. GSM8K format: @@ -61,8 +76,8 @@ def convert_gsm8k(example: dict[str, Any], index: int, dataset_metadata: dict[st ] task_metadata = {"dataset": "gsm8k", "index": index, "answer": answer, "final_answer": final_answer} - if dataset_metadata: - task_metadata.update(dataset_metadata) + if kwargs: + task_metadata.update(kwargs) return Task( name=f"gsm8k_{index}", @@ -72,7 +87,7 @@ def convert_gsm8k(example: dict[str, Any], index: int, dataset_metadata: dict[st ) -def convert_math(example: dict[str, Any], index: int, dataset_metadata: dict[str, Any] | None = None) -> Task: +def convert_math(example: dict[str, Any], index: int, **kwargs: Any) -> Task: """Convert MATH dataset problem to Flow task. MATH format: @@ -98,8 +113,8 @@ def convert_math(example: dict[str, Any], index: int, dataset_metadata: dict[str ] task_metadata = {"dataset": "math", "index": index, "level": level, "type": problem_type, "solution": solution} - if dataset_metadata: - task_metadata.update(dataset_metadata) + if kwargs: + task_metadata.update(kwargs) return Task( name=f"math_{problem_type.lower()}_{index}", @@ -109,7 +124,7 @@ def convert_math(example: dict[str, Any], index: int, dataset_metadata: dict[str ) -def convert_humaneval(example: dict[str, Any], index: int, dataset_metadata: dict[str, Any] | None = None) -> Task: +def convert_humaneval(example: dict[str, Any], index: int, **kwargs: Any) -> Task: r"""Convert HumanEval coding problem to Flow task. HumanEval format: @@ -138,8 +153,8 @@ def convert_humaneval(example: dict[str, Any], index: int, dataset_metadata: dic ] task_metadata = {"dataset": "humaneval", "task_id": task_id, "entry_point": entry_point, "test": test} - if dataset_metadata: - task_metadata.update(dataset_metadata) + if kwargs: + task_metadata.update(kwargs) return Task( name=f"humaneval_{task_id.replace('/', '_')}", @@ -149,7 +164,7 @@ def convert_humaneval(example: dict[str, Any], index: int, dataset_metadata: dic ) -def convert_mbpp(example: dict[str, Any], index: int, dataset_metadata: dict[str, Any] | None = None) -> Task: +def convert_mbpp(example: dict[str, Any], index: int, **kwargs: Any) -> Task: """Convert MBPP coding problem to Flow task. MBPP format: @@ -170,8 +185,8 @@ def convert_mbpp(example: dict[str, Any], index: int, dataset_metadata: dict[str ] task_metadata = {"dataset": "mbpp", "task_id": task_id, "test_list": test_list} - if dataset_metadata: - task_metadata.update(dataset_metadata) + if kwargs: + task_metadata.update(kwargs) return Task( name=f"mbpp_{task_id}", @@ -182,13 +197,8 @@ def convert_mbpp(example: dict[str, Any], index: int, dataset_metadata: dict[str # Registry of dataset converters -def _get_gaia_converter(): - """Lazy import for GAIA converter to avoid smolagents dependency at import time.""" - from flow.experiments.gaia_converter import convert_gaia - return convert_gaia - -DATASET_CONVERTERS = { +DATASET_CONVERTERS: dict[str, ConverterFunc] = { "openai/gsm8k": convert_gsm8k, "gsm8k": convert_gsm8k, "competition_math": convert_math, @@ -197,7 +207,18 @@ DATASET_CONVERTERS = { "openai_humaneval": convert_humaneval, "mbpp": convert_mbpp, "google-research-datasets/mbpp": convert_mbpp, - "gaia-benchmark/GAIA": _get_gaia_converter, # Lazy loaded +} + + +def _get_gaia_converter() -> ConverterFunc: + """Lazy import for GAIA converter to avoid smolagents dependency at import time.""" + from flow.experiments.gaia_converter import convert_gaia + + return convert_gaia + + +LAZY_CONVERTERS: dict[str, Callable[[], ConverterFunc]] = { + "gaia-benchmark/GAIA": _get_gaia_converter, } @@ -206,7 +227,7 @@ def import_hf_dataset( config: str | None = None, split: str = "train", limit: int | None = None, - converter_override: Any = None, + converter_override: ConverterFunc | None = None, local_path: str | Path | None = None, ) -> list[Task]: """Import a Hugging Face dataset and convert to Flow tasks. @@ -246,6 +267,29 @@ def import_hf_dataset( except ImportError as e: raise ImportError("Hugging Face datasets library is required. Install with: pip install datasets") from e + # Find converter + converter: ConverterFunc | None = converter_override + if converter is None: + # Try direct converters first + for key, conv in DATASET_CONVERTERS.items(): + if key in dataset_name: + converter = conv + break + + # Fall back to lazy-loaded converters only if no direct match was found + if converter is None: + for key, factory in LAZY_CONVERTERS.items(): + if key in dataset_name: + converter = factory() + break + if converter is None: + all_keys = sorted({*DATASET_CONVERTERS, *LAZY_CONVERTERS}) + raise ValueError( + f"No converter found for dataset '{dataset_name}'. " + f"Available: {all_keys}\n" + f"Use converter_override parameter to provide a custom converter." + ) + # Download to local path if specified, then load from there if local_path is not None: try: @@ -276,26 +320,6 @@ def import_hf_dataset( logger.info(f"Converting {len(dataset)} examples to Flow tasks...") - # Find converter - converter = converter_override - if converter is None: - # Try to find matching converter - for key, conv in DATASET_CONVERTERS.items(): - if key in dataset_name: - # Handle lazy loaders (functions that return the actual converter) - if conv is _get_gaia_converter: - converter = conv() - else: - converter = conv - break - - if converter is None: - raise ValueError( - f"No converter found for dataset '{dataset_name}'. " - f"Available: {list(DATASET_CONVERTERS.keys())}\n" - f"Use converter_override parameter to provide a custom converter." - ) - # Build dataset metadata to pass to converters dataset_metadata: dict[str, Any] = {} dataset_metadata["local_path"] = str(local_path) if local_path else None @@ -303,10 +327,10 @@ def import_hf_dataset( dataset_metadata["split"] = split # Convert examples - tasks = [] + tasks: list[Task] = [] for i, example in enumerate(dataset): try: - task = converter(example, i, dataset_metadata) + task = converter(dict(example), i, **dataset_metadata) tasks.append(task) except Exception as e: logger.warning(f"Failed to convert example {i}: {e}", exc_info=True) @@ -338,7 +362,7 @@ def save_tasks_to_jsonl(tasks: list[Task], output_path: Path) -> None: logger.info(f"Saved {len(tasks)} tasks to {output_path}") -def register_converter(dataset_name: str, converter_func: Any) -> None: +def register_converter(dataset_name: str, converter_func: ConverterFunc) -> None: """Register a custom converter for a dataset. Args: @@ -346,7 +370,7 @@ def register_converter(dataset_name: str, converter_func: Any) -> None: converter_func: Function that converts example dict to Task Example: - >>> def my_converter(example, index): + >>> def my_converter(example, index, **kwargs): ... return Task(name=f"task_{index}", prompt=example["text"], ...) >>> register_converter("my/dataset", my_converter) """ diff --git a/src/flow/experiments/models.py b/src/flow/experiments/models.py index 7ddc186000faf1a56b5bcb9598cd40dcf3aaf1a4..366fa7d272f71c00d0deec5203a3cc2ac0cd68fe 100644 --- a/src/flow/experiments/models.py +++ b/src/flow/experiments/models.py @@ -409,14 +409,47 @@ class Agent: llm_config: dict[str, Any] | None = None # {"provider": "azure", "model": "gpt-4o"} compaction: CompactionConfig = field(default_factory=CompactionConfig) tools: str | list[str] | dict[str, dict[str, Any]] | None = None + skills: dict[str, str] | None = None # skill_name -> SKILL.md content # Set by deploy() — when set, evaluate/optimize auto-persist to DB - _id: str | None = field(default=None, repr=False, compare=False) + _deployment_id: str | None = field(default=None, repr=False, compare=False) + _config_id: str | None = field(default=None, repr=False, compare=False) + _version: int | None = field(default=None, repr=False, compare=False) @property def id(self) -> str | None: - """Agent ID in the database, set after deploy().""" - return self._id + """Deployment ID, set after deploy(). This is the stable identity.""" + return self._deployment_id + + @property + def config_id(self) -> str | None: + """AgentConfig ID for the current version, set after deploy().""" + return self._config_id + + @property + def version(self) -> int | None: + """Current deployment version number, set after deploy().""" + return self._version + + @classmethod + def from_config(cls, path: str | Path) -> Agent: + """Create an Agent from a YAML config file. + + Args: + path: Path to the YAML config file + + Returns: + A new Agent instance with the config's values + + Raises: + FileNotFoundError: If the file doesn't exist + ValueError: If the config is invalid + + Example: + agent = Agent.from_config("examples/base_agent.yaml") + print(agent.name, agent.tools) + """ + return load_agent(Path(path)) @classmethod def from_preset(cls, name: str) -> Agent: @@ -508,24 +541,30 @@ class Agent: finally: await harness.close() - async def deploy(self) -> str: - """Register this agent in the Flow database. + async def deploy(self, candidate: Agent | None = None) -> str: + """Deploy this agent (or a candidate) to the Flow database. - Creates an AgentConfig row in the local SQLite DB (~/.flow/flow_ui.db). - No running server required — this is a pure DB write. After deploying, - all evaluate() and optimize() calls auto-persist results to the DB. + First call creates a new Deployment + AgentConfig (v1). + Subsequent calls on the same agent append a new version to the + same deployment — same stable URL, new config behind it. - Run ``flow serve`` separately to browse results in the UI. + Passing a ``candidate`` (e.g. from optimization results) deploys + that candidate's config as the next version of this deployment. + + Args: + candidate: Optional Agent whose config to deploy as the next + version. If None, deploys this agent's current config. Returns: - The agent ID (UUID string) + The deployment ID (stable UUID string) Example: agent = Agent(name="coding-agent", tools="standard") - agent_id = await agent.deploy() - # Results now auto-persist - result = await agent.evaluate(tasks="quick") - # Run `flow serve` to view at http://localhost:7860/agents/{agent_id} + dep_id = await agent.deploy() # v1 + agent.tools = ["bash", "read_file"] + await agent.deploy() # v2, same dep_id + result = await agent.optimize(tasks="quick", strategy="tools") + await agent.deploy(result.best_agent) # v3, same dep_id """ try: from flow.ui.services.persistence_adapter import PersistenceAdapter @@ -535,9 +574,20 @@ class Agent: "to use deploy(): pip install flow[ui] or uv sync" ) from e + source_agent = candidate or self + source = "optimize" if candidate is not None else "deploy" + adapter = PersistenceAdapter() - self._id = await adapter.deploy_agent(self) - return self._id + result = await adapter.deploy_agent( + source_agent, + deployment_id=self._deployment_id, + source=source, + ) + + self._deployment_id = result.deployment_id + self._config_id = result.config_id + self._version = result.version + return self._deployment_id async def evaluate( self, @@ -570,7 +620,7 @@ class Agent: from .agent_api import _evaluate_agent_impl return await _evaluate_agent_impl( - self, tasks, parallel, use_llm_eval, quiet, agent_id=self._id + self, tasks, parallel, use_llm_eval, quiet, agent_id=self._config_id ) async def optimize( @@ -578,6 +628,7 @@ class Agent: tasks: str | list[Task] | Path = "quick", *, strategy: str | list[str] | None = None, + strategy_config: dict[str, Any] | None = None, variations: dict[str, list[Any]] | None = None, parallel: int = 4, budget: int = 50, @@ -599,9 +650,13 @@ class Agent: - None or "grid": Grid search over variations (default) - "tools": Iteratively discover optimal tool configuration - "instructions": Iteratively rewrite instructions from failures + - "skills": Iteratively generate domain knowledge skills - list: Run multiple strategies sequentially, e.g. ["instructions", "tools"] optimizes instructions first, then tools starting from the improved agent + strategy_config: Optional config passed to the strategy. Merged + with defaults (max_iterations=3, min_improvement=0.01). + Example: {"max_iterations": 5, "include_builtin": True} variations: Custom grid search variations (only used with grid strategy) parallel: Number of concurrent experiments budget: Maximum number of candidates to test @@ -623,6 +678,13 @@ class Agent: # Active: improve instructions result = await agent.optimize(tasks="quick", strategy="instructions") + # Active: skills with custom config + result = await agent.optimize( + tasks="quick", + strategy="skills", + strategy_config={"max_iterations": 5, "min_improvement": 0.0}, + ) + # Pipeline: instructions first, then tools result = await agent.optimize( tasks="quick", strategy=["instructions", "tools"] @@ -635,8 +697,9 @@ class Agent: return await _optimize_agent_impl( self, tasks, variations, parallel, budget, use_llm_eval, quiet, - agent_id=self._id, + agent_id=self._config_id, strategy=strategy, + strategy_config=strategy_config, ) @@ -934,12 +997,28 @@ def export_agent( ) -> None: """Export an Agent as a reusable YAML file. + If the agent has skills, each skill is written as a SKILL.md file in a + ``skills//`` directory next to the YAML. The YAML references skills + by name (list of strings) so the agent/framework can locate them at the + relative path ``skills//SKILL.md``. + Args: agent: The Agent to export path: Path to write the YAML file metrics: Optional optimization metrics (stored under _optimization key) """ data = asdict(agent) + + # Write skill folders alongside the YAML and replace content with names + if agent.skills: + skills_dir = path.parent / "skills" + for skill_name, skill_content in agent.skills.items(): + skill_folder = skills_dir / skill_name + skill_folder.mkdir(parents=True, exist_ok=True) + (skill_folder / "SKILL.md").write_text(skill_content) + # In the YAML, store just the skill names (not full content) + data["skills"] = sorted(agent.skills.keys()) + if metrics: data["_optimization"] = metrics path.parent.mkdir(parents=True, exist_ok=True) @@ -971,6 +1050,17 @@ def load_agent(path: Path) -> Agent: if "compaction" in config_data and isinstance(config_data["compaction"], dict): config_data["compaction"] = CompactionConfig(**config_data["compaction"]) + # Load skills from disk: YAML stores skill names as a list, + # resolve to dict[name, content] by reading skills//SKILL.md + if "skills" in config_data and isinstance(config_data["skills"], list): + skills_dir = path.parent / "skills" + loaded_skills: dict[str, str] = {} + for skill_name in config_data["skills"]: + skill_path = skills_dir / skill_name / "SKILL.md" + if skill_path.exists(): + loaded_skills[skill_name] = skill_path.read_text() + config_data["skills"] = loaded_skills if loaded_skills else None + try: return Agent(**config_data) except TypeError as e: diff --git a/src/flow/experiments/optimizer.py b/src/flow/experiments/optimizer.py index 501cbc58ab4724095d9e9c730175845ed8ec4d0c..c4db721ade4fbdbf6a46d872dc49860cd0ae7bef 100644 --- a/src/flow/experiments/optimizer.py +++ b/src/flow/experiments/optimizer.py @@ -21,6 +21,13 @@ from typing import Any from openai import AsyncAzureOpenAI from .ablation import compute_pareto_frontier +from .eval_cache import ( + DiskCache, + EvaluationCache, + agent_cache_dict, + build_cache_key, + task_cache_dict, +) from .evaluators import LLMEvaluator from .metrics import TraceMetrics, extract_metrics from .models import ( @@ -175,15 +182,27 @@ class FlowOptimizer: parallel: int = 4, use_llm_evaluator: bool = True, output_dir: Path | None = None, + quiet: bool = False, + cache_evaluations: bool = True, ) -> None: self.parallel = parallel self.use_llm_evaluator = use_llm_evaluator self.output_dir = output_dir or Path.home() / ".flow" / "optimizations" + self.quiet = quiet + + # Evaluation cache — avoids redundant agent runs for identical + # (agent-config, task) pairs. Persists across sessions via SQLite. + self._cache: EvaluationCache | None = DiskCache() if cache_evaluations else None # Internal state set during optimize() for use by evaluate() self._evaluator: LLMEvaluator | None = None self._run_dir: Path | None = None + def _log(self, msg: str) -> None: + """Print a message unless quiet mode is enabled.""" + if not self.quiet: + print(msg) + async def optimize( self, candidates: list[Candidate], @@ -211,15 +230,15 @@ class FlowOptimizer: setup_tracing("flow-optimizer") self._save_config(candidates, tasks, run_dir) - print("=" * 70) - print(" FLOW OPTIMIZER") - print("=" * 70) - print(f" Candidates: {len(candidates)}") - print(f" Tasks: {len(tasks)}") - print(f" Total: {len(candidates) * len(tasks)} experiments") - print(f" Parallel: {self.parallel}") - print(f" Output: {run_dir}") - print("=" * 70) + self._log("=" * 70) + self._log(" FLOW OPTIMIZER") + self._log("=" * 70) + self._log(f" Candidates: {len(candidates)}") + self._log(f" Tasks: {len(tasks)}") + self._log(f" Total: {len(candidates) * len(tasks)} experiments") + self._log(f" Parallel: {self.parallel}") + self._log(f" Output: {run_dir}") + self._log("=" * 70) evaluator = None if self.use_llm_evaluator: @@ -316,16 +335,16 @@ class FlowOptimizer: self._evaluator = evaluator self._run_dir = run_dir - print("=" * 70) - print(" FLOW OPTIMIZER (Strategy Mode)") - print("=" * 70) - print(f" Strategy: {type(strategy).__name__}") - print(f" Base Agent: {base.name}") - print(f" Tasks: {len(tasks)}") - print(f" Budget: {budget}") - print(f" Parallel: {self.parallel}") - print(f" Output: {run_dir}") - print("=" * 70) + self._log("=" * 70) + self._log(" FLOW OPTIMIZER (Strategy Mode)") + self._log("=" * 70) + self._log(f" Strategy: {type(strategy).__name__}") + self._log(f" Base Agent: {base.name}") + self._log(f" Tasks: {len(tasks)}") + self._log(f" Budget: {budget}") + self._log(f" Parallel: {self.parallel}") + self._log(f" Output: {run_dir}") + self._log("=" * 70) # Pass self as runner — FlowOptimizer implements the ExperimentRunner # protocol via the evaluate() method above @@ -340,7 +359,7 @@ class FlowOptimizer: logger.warning("Strategy produced no candidates") candidates = [Candidate(agent=base, mutations={}, rationale="baseline (strategy produced none)")] - print(f"\nStrategy produced {len(candidates)} candidates. Running final evaluation...") + self._log(f"\nStrategy produced {len(candidates)} candidates. Running final evaluation...") # Save config self._save_config(candidates, tasks, run_dir) @@ -403,15 +422,41 @@ class FlowOptimizer: async def run_one(candidate: Candidate, task: Task) -> TaskResult: nonlocal completed async with semaphore: + # Check evaluation cache + cache_key: str | None = None + if self._cache is not None: + cache_key = build_cache_key( + agent_cache_dict(candidate.agent), + task_cache_dict(task), + ) + cached = self._cache.get(cache_key) + if cached is not None: + result = _task_result_from_cache(cached, candidate, task) + async with lock: + completed += 1 + self._log( + f" [{completed}/{total}] {candidate.agent.name}/{task.name}: " + f"CACHED score={result.eval_score:.2f} " + f"reasoning={result.eval_reasoning_score:.2f} " + f"tokens={result.metrics.total_tokens:,}" + ) + if progress_callback: + progress_callback(completed, total, candidate.agent.name, task.name) + return result + workspace = run_dir / "workspaces" / candidate.agent.name / task.name workspace.mkdir(parents=True, exist_ok=True) result = await self._run_single(candidate, task, workspace, evaluator) + # Store in cache + if self._cache is not None and cache_key is not None: + self._cache.put(cache_key, _task_result_to_cache(result)) + async with lock: completed += 1 status = "PASS" if result.eval_passed else "FAIL" - print( + self._log( f" [{completed}/{total}] {candidate.agent.name}/{task.name}: " f"{status} score={result.eval_score:.2f} " f"reasoning={result.eval_reasoning_score:.2f} " @@ -428,7 +473,11 @@ class FlowOptimizer: valid_results: list[TaskResult] = [] for r in gather_results: if isinstance(r, BaseException): - logger.error(f"Experiment failed: {r}") + logger.error( + "Experiment failed: %s", + r, + exc_info=(type(r), r, r.__traceback__), + ) else: valid_results.append(r) @@ -672,29 +721,29 @@ class FlowOptimizer: def _print_summary(self, result: OptimizationResult) -> None: """Print optimization summary.""" - print("\n" + "=" * 70) - print(" OPTIMIZATION RESULTS") - print("=" * 70) + self._log("\n" + "=" * 70) + self._log(" OPTIMIZATION RESULTS") + self._log("=" * 70) - print(f"\n{'Candidate':<30} | {'Score':>8} | {'Reason':>8} | {'Tokens':>10} | {'Pareto':>8}") - print("-" * 75) + self._log(f"\n{'Candidate':<30} | {'Score':>8} | {'Reason':>8} | {'Tokens':>10} | {'Pareto':>8}") + self._log("-" * 75) for summary in sorted(result.summaries, key=lambda s: s.avg_score, reverse=True): pareto = "*" if summary.is_pareto_optimal else "" - print( + self._log( f"{summary.name:<30} | {summary.avg_score:>8.2f} | " f"{summary.avg_reasoning_score:>8.2f} | " f"{summary.avg_tokens:>10,.0f} | {pareto:>8}" ) - print("\n" + "-" * 70) - print(f"Pareto frontier: {result.pareto_frontier}") - print(f"Best by score: {result.rank_by_score[0] if result.rank_by_score else 'N/A'}") - print(f"Best by efficiency: {result.rank_by_efficiency[0] if result.rank_by_efficiency else 'N/A'}") - print("\nExported agents:") + self._log("\n" + "-" * 70) + self._log(f"Pareto frontier: {result.pareto_frontier}") + self._log(f"Best by score: {result.rank_by_score[0] if result.rank_by_score else 'N/A'}") + self._log(f"Best by efficiency: {result.rank_by_efficiency[0] if result.rank_by_efficiency else 'N/A'}") + self._log("\nExported agents:") for name, path in result.exported_agents.items(): - print(f" {name}: {path}") - print(f"\nResults saved to: {result.output_dir}") + self._log(f" {name}: {path}") + self._log(f"\nResults saved to: {result.output_dir}") def load_tasks_from_jsonl(path: Path) -> list[Task]: @@ -716,6 +765,7 @@ async def evaluate_agent( parallel: int = 4, use_llm_evaluator: bool = True, output_dir: Path | None = None, + quiet: bool = False, ) -> CandidateSummary: """Evaluate a single agent on a set of tasks. @@ -760,6 +810,7 @@ async def evaluate_agent( parallel=parallel, use_llm_evaluator=use_llm_evaluator, output_dir=eval_output_dir, + quiet=quiet, ) result = await optimizer.optimize([candidate], tasks) @@ -768,3 +819,77 @@ async def evaluate_agent( raise RuntimeError("Evaluation produced no results") return result.summaries[0] + + +# --------------------------------------------------------------------------- +# Cache serialisation helpers +# --------------------------------------------------------------------------- + + +def _task_result_to_cache(result: TaskResult) -> dict[str, Any]: + """Serialise a TaskResult to a JSON-safe dict for caching.""" + return { + "eval_score": result.eval_score, + "eval_passed": result.eval_passed, + "eval_reasoning": result.eval_reasoning, + "eval_reasoning_score": result.eval_reasoning_score, + "criteria_results": result.criteria_results, + "metrics": { + "total_tokens": result.metrics.total_tokens, + "input_tokens": result.metrics.input_tokens, + "output_tokens": result.metrics.output_tokens, + "tool_call_count": result.metrics.tool_call_count, + "llm_call_count": result.metrics.llm_call_count, + "total_duration_ms": result.metrics.total_duration_ms, + }, + "run": { + "output": result.run_result.output, + "files_created": result.run_result.files_created, + "duration_seconds": result.run_result.duration_seconds, + "error": result.run_result.error, + "tool_results": result.run_result.tool_results, + "trace": result.run_result.trace, + }, + } + + +def _task_result_from_cache( + cached: dict[str, Any], + candidate: Candidate, + task: Task, +) -> TaskResult: + """Reconstruct a TaskResult from a cached dict.""" + run_data = cached.get("run", {}) + metrics_data = cached.get("metrics", {}) + + run_result = RunResult( + task=task, + trace=run_data.get("trace", []), + output=run_data.get("output", ""), + files_created=run_data.get("files_created", []), + duration_seconds=run_data.get("duration_seconds", 0.0), + workspace=Path("/cached"), + error=run_data.get("error"), + tool_results=run_data.get("tool_results", []), + ) + + metrics = TraceMetrics( + total_tokens=metrics_data.get("total_tokens", 0), + input_tokens=metrics_data.get("input_tokens", 0), + output_tokens=metrics_data.get("output_tokens", 0), + tool_call_count=metrics_data.get("tool_call_count", 0), + llm_call_count=metrics_data.get("llm_call_count", 0), + total_duration_ms=metrics_data.get("total_duration_ms", 0.0), + ) + + return TaskResult( + candidate_name=candidate.agent.name, + task_name=task.name, + run_result=run_result, + metrics=metrics, + eval_score=cached.get("eval_score", 0.0), + eval_passed=cached.get("eval_passed", False), + eval_reasoning=cached.get("eval_reasoning", ""), + criteria_results=cached.get("criteria_results", []), + eval_reasoning_score=cached.get("eval_reasoning_score", 0.0), + ) diff --git a/src/flow/experiments/results.py b/src/flow/experiments/results.py index 22ab1661cdba24b35085a70d3cd2ac9ce8c6bc9c..8776cc55e382576947af92074c8db4a62e46f975 100644 --- a/src/flow/experiments/results.py +++ b/src/flow/experiments/results.py @@ -13,6 +13,7 @@ from pathlib import Path from typing import TYPE_CHECKING, Any if TYPE_CHECKING: + from .models import StrategyIteration from .optimizer import CandidateSummary @@ -110,9 +111,29 @@ class AgentOptimizationResult: # Set when agent was deployed — links to the DB job job_id: str | None = field(default=None, repr=False) + @property + def iterations(self) -> list[StrategyIteration]: + """Per-iteration history from active optimization strategies.""" + details = self.best._details + if details and details.candidate.optimization_history: + return details.candidate.optimization_history + return [] + def __str__(self) -> str: return ( f"Optimization: {self.baseline} → {self.best}\n" f"Improvement: {self.improvement}\n" f"Candidates tested: {self.candidates_tested}" ) + + def print_summary(self) -> None: + """Print a formatted table of optimization iterations.""" + history = self.iterations + if not history: + print(str(self)) + return + + print(f"{'Iter':<6}{'Score':<10}{'Pass Rate':<12}{'Change'}") + print("-" * 60) + for h in history: + print(f"{h.iteration:<6}{h.avg_score:<10.0%}{h.pass_rate:<12.0%}{h.change_description}") diff --git a/src/flow/experiments/runner.py b/src/flow/experiments/runner.py index 2faeca85c40c11b9b40bfc89f9513fd3368c17fd..ea2c685797d9cdb611660d9f1802ab95ccf9703e 100644 --- a/src/flow/experiments/runner.py +++ b/src/flow/experiments/runner.py @@ -201,7 +201,7 @@ class FlowExperimentRunner: except Exception as e: error = str(e) - logger.error(f"Task execution failed: {e}") + logger.exception(f"Task execution failed: {e}") end_time = time.time() duration_seconds = end_time - start_time diff --git a/src/flow/experiments/strategies/__init__.py b/src/flow/experiments/strategies/__init__.py index 8441ee1ecd049ce21576c420ef6b5d07c2de33d6..4780763b83f5983b3af376f5bb9010f7365f1e74 100644 --- a/src/flow/experiments/strategies/__init__.py +++ b/src/flow/experiments/strategies/__init__.py @@ -9,10 +9,10 @@ Example YAML: variations: instructions: - "You are helpful" # Literal - - strategy: gepa # Strategy - max_candidates: 3 + - strategy: instruction # Strategy + max_candidates: 1 config: - reflection_lm: gpt-4o + max_iterations: 5 """ from __future__ import annotations @@ -84,19 +84,33 @@ def _register_builtin_strategies() -> None: except ImportError: logger.debug("GEPA strategy not available (gepa package not installed)") - # LLM rewriter strategy (simple instruction variations) + # Instruction optimizer try: - from .llm_rewriter import LLMRewriterStrategy - register_strategy("llm_rewriter", LLMRewriterStrategy) + from .instruction import InstructionOptimizer + register_strategy("instruction", InstructionOptimizer) except ImportError: - logger.debug("LLM rewriter strategy not available") + logger.debug("Instruction optimizer not available") - # Tool selector strategy (generates tool configurations) + # Tool optimizer try: - from .tool_selector import ToolSelectorStrategy - register_strategy("tool_selector", ToolSelectorStrategy) + from .tool import ToolOptimizer + register_strategy("tool", ToolOptimizer) except ImportError: - logger.debug("Tool selector strategy not available") + logger.debug("Tool optimizer not available") + + # Skill optimizer + try: + from .skill import SkillOptimizer + register_strategy("skill", SkillOptimizer) + except ImportError: + logger.debug("Skill optimizer not available") + + # GEPA instruction optimizer (uses standard plumbing + GEPA reflection) + try: + from .gepa_instruction import GEPAInstructionOptimizer + register_strategy("gepa_instruction", GEPAInstructionOptimizer) + except ImportError: + logger.debug("GEPA instruction optimizer not available") # Register on module import diff --git a/src/flow/experiments/strategies/gepa_instruction.py b/src/flow/experiments/strategies/gepa_instruction.py new file mode 100644 index 0000000000000000000000000000000000000000..16884aaac9f95c44dbca5d78947c66b4304c8b6a --- /dev/null +++ b/src/flow/experiments/strategies/gepa_instruction.py @@ -0,0 +1,415 @@ +# Copyright (c) Microsoft. All rights reserved. + +"""GEPA-based instruction optimization strategy. + +Like InstructionOptimizer but uses GEPA's evolutionary approach: +- Maintains a population of candidate instructions +- Uses GEPA's reflection mechanism to generate new candidates from failures +- Selects candidates via frontier-based selection (not just greedy best) + +Uses the standard strategy plumbing (runner.evaluate()) instead of +a custom evaluator callback bridge. +""" + +from __future__ import annotations + +import logging +import os +from dataclasses import dataclass, field +from typing import Any + +from ..models import Agent, Candidate, ExperimentRunner, StrategyIteration +from ..types import Task + +logger = logging.getLogger(__name__) + + +@dataclass +class GEPAInstructionOptimizer: + """Instruction optimizer using GEPA's evolutionary approach. + + Uses the same runner.evaluate() plumbing as InstructionOptimizer, + but delegates candidate generation to GEPA's reflection + selection loop. + + The GEPA library handles: + - Generating improved prompts via LLM reflection on failures + - Candidate selection via frontier-based strategies + - Population management across generations + + Config options: + model: LLM for GEPA reflection (default: gpt-4o-mini) + max_iterations: Max generations (default: 5) + min_improvement: Min score gain to continue (default: 0.05) + reflection_lm: LLM for GEPA reflection (overrides model if set) + + Example: + flow optimize --agent agent.yaml --tasks tasks.jsonl --strategy gepa_instructions + """ + + config: dict[str, Any] = field(default_factory=dict) + + async def generate( + self, + base: Agent, + budget: int, + *, + tasks: list[Task] | None = None, + runner: ExperimentRunner | None = None, + ) -> list[Candidate]: + """Generate optimized instructions using GEPA's evolutionary loop. + + Args: + base: Base agent with instructions to optimize + budget: Max candidates to evaluate + tasks: Tasks to evaluate on (required) + runner: ExperimentRunner for evaluation (required) + + Returns: + List with the best candidate found + """ + if runner is None: + raise ValueError( + "GEPAInstructionOptimizer requires a runner. " + "Use FlowOptimizer.optimize_with_strategy() to provide one." + ) + if not tasks: + raise ValueError( + "GEPAInstructionOptimizer requires tasks to evaluate against." + ) + + try: + import gepa + from gepa.core.adapter import EvaluationBatch + except ImportError as e: + raise ImportError( + "GEPA is not installed. Install with: pip install gepa" + ) from e + + model = self.config.get("model", "gpt-4o-mini") + max_iterations = self.config.get("max_iterations", 5) + min_improvement = self.config.get("min_improvement", 0.05) + + base_instructions = base.instructions or "You are a helpful assistant." + + # Track optimization history + history: list[StrategyIteration] = [] + best_instructions = base_instructions + best_score = 0.0 + generation = 0 + + # ── Build GEPA adapter that uses runner.evaluate() ── + + strategy_self = self + _runner = runner + _tasks = tasks + _base = base + + def _run_async(coro: Any) -> Any: + """Run an async coroutine from synchronous GEPA context.""" + import asyncio + import concurrent.futures + + with concurrent.futures.ThreadPoolExecutor(max_workers=1) as pool: + return pool.submit(asyncio.run, coro).result() + + class FlowRunnerAdapter(gepa.GEPAAdapter): + """Bridges GEPA's adapter interface to Flow's ExperimentRunner.""" + + def evaluate( + self, + batch: list[Any], + candidate: dict[str, str], + capture_traces: bool = False, + ) -> EvaluationBatch: + """Evaluate a candidate one task at a time using Flow's runner. + + GEPA tracks scores by dataset item index, so we must evaluate + each batch item individually to preserve the 1:1 mapping. + """ + instructions_text = candidate.get("instructions", base_instructions) + + # Build agent + candidate + agent = Agent( + name=f"{_base.name}_gepa_iter", + framework=_base.framework, + instructions=instructions_text, + llm_config=_base.llm_config, + compaction=_base.compaction, + tools=_base.tools, + ) + flow_candidate = Candidate( + agent=agent, + mutations={"instructions": instructions_text}, + ) + + if not batch: + return EvaluationBatch( + outputs=[], scores=[], + trajectories=[] if capture_traces else None, + objective_scores=None, + ) + + # Evaluate each task individually to preserve GEPA's index mapping + scores: list[float] = [] + outputs: list[dict[str, Any]] = [] + trajectories: list[dict[str, Any]] = [] + passed_count = 0 + + for item in batch: + if not isinstance(item, Task): + scores.append(0.0) + outputs.append({}) + continue + + # Evaluate single task via runner + summary = _run_async(_runner.evaluate(flow_candidate, [item])) + + # Extract result for this task + if summary.task_results: + tr = summary.task_results[0] + task_score = float(getattr(tr, "eval_score", 0.0)) + eval_passed = getattr(tr, "eval_passed", False) + eval_reasoning = getattr(tr, "eval_reasoning", "") + agent_output = str(getattr(tr.run_result, "output", "")) if tr.run_result else "" + else: + task_score = 0.0 + eval_passed = False + eval_reasoning = "No result" + agent_output = "" + + if eval_passed: + passed_count += 1 + + scores.append(task_score) + traj = { + "task_name": getattr(item, "name", "unknown"), + "task_prompt": getattr(item, "prompt", ""), + "agent_output": agent_output[:1000], + "eval_reasoning": eval_reasoning, + "eval_score": task_score, + "eval_passed": eval_passed, + "instructions_used": instructions_text, + } + outputs.append(traj) + if capture_traces: + trajectories.append(traj) + + # Record iteration in history + avg_score = sum(scores) / len(scores) if scores else 0.0 + pass_rate = passed_count / len(batch) if batch else 0.0 + failures_count = len(batch) - passed_count + + nonlocal generation, best_score, best_instructions + generation += 1 + + task_lines = [ + f" [{'PASS' if o.get('eval_passed') else 'FAIL'}] " + f"{o.get('task_name', '?')}: {o.get('eval_reasoning', '')[:150]}" + for o in outputs if isinstance(o, dict) and o + ] + + history.append( + StrategyIteration( + iteration=generation - 1, + instructions_preview=instructions_text[:200], + full_instructions=instructions_text, + avg_score=avg_score, + pass_rate=pass_rate, + failures_count=failures_count, + change_description=f"GEPA generation {generation}", + change_rationale="\n".join(task_lines), + ) + ) + + if avg_score > best_score: + best_score = avg_score + best_instructions = instructions_text + + logger.info( + f"GEPA gen {generation}: score={avg_score:.3f}, " + f"pass_rate={pass_rate:.1%}, failures={failures_count}" + ) + + return EvaluationBatch( + outputs=outputs, + scores=scores, + trajectories=trajectories if capture_traces else None, + objective_scores=None, + ) + + def make_reflective_dataset( + self, + candidate: dict[str, str], + eval_batch: EvaluationBatch, + components_to_update: list[str], + ) -> dict[str, list[dict[str, Any]]]: + """Create reflection dataset from evaluation results. + + GEPA uses this to generate improved candidates via LLM reflection. + """ + trajectories = eval_batch.trajectories or eval_batch.outputs or [] + scores = eval_batch.scores or [] + + reflection_data: dict[str, list[dict[str, Any]]] = {} + + for component in components_to_update: + examples: list[dict[str, Any]] = [] + + for traj, score in zip(trajectories, scores): + if not isinstance(traj, dict): + continue + + example = { + "Inputs": { + "task": traj.get("task_prompt", ""), + "instructions": traj.get("instructions_used", "")[:500], + }, + "Generated Outputs": { + "agent_response": traj.get("agent_output", "")[:1000], + }, + "Feedback": ( + f"Score: {score:.2f}/1.0. " + f"Passed: {traj.get('eval_passed', False)}. " + f"{traj.get('eval_reasoning', '')}" + ), + "_score": score, + } + examples.append(example) + + # Sort by score ascending — GEPA learns more from failures + examples.sort(key=lambda x: x.get("_score", 0)) + for ex in examples: + ex.pop("_score", None) + + reflection_data[component] = examples + + return reflection_data + + # ── Set up Azure env vars for GEPA's LiteLLM usage ── + + if os.environ.get("AZURE_OPENAI_API_KEY"): + os.environ.setdefault("AZURE_API_KEY", os.environ["AZURE_OPENAI_API_KEY"]) + if os.environ.get("AZURE_OPENAI_ENDPOINT"): + os.environ.setdefault("AZURE_API_BASE", os.environ["AZURE_OPENAI_ENDPOINT"]) + + # ── Build GEPA config ── + + gepa_config: dict[str, Any] = {} + + # Resolve reflection LM: explicit config > Azure deployment > default model + reflection_lm = self.config.get("reflection_lm") + if not reflection_lm: + azure_deployment = os.environ.get("AZURE_OPENAI_DEPLOYMENT") + reflection_lm = azure_deployment if azure_deployment else model + + # Add azure/ prefix for LiteLLM if using Azure + if not reflection_lm.startswith("azure/") and os.environ.get("AZURE_OPENAI_ENDPOINT"): + reflection_lm = f"azure/{reflection_lm}" + + gepa_config["reflection_lm"] = reflection_lm + + # Pass through valid GEPA params from config + VALID_GEPA_PARAMS = { + "reflection_lm", "candidate_selection_strategy", "frontier_type", + "skip_perfect_score", "batch_sampler", "reflection_minibatch_size", + "perfect_score", "reflection_prompt_template", "module_selector", + "use_merge", "max_merge_invocations", "merge_val_overlap_floor", + "stop_callbacks", "display_progress_bar", "seed", + "cache_evaluation", "raise_on_exception", + } + for key, value in self.config.items(): + if key in VALID_GEPA_PARAMS: + gepa_config[key] = value + + # ── Run GEPA ── + + seed_candidate = {"instructions": base_instructions} + + # GEPA needs Task objects as dataset + dataset = list(tasks) + + logger.info( + f"GEPAInstructionOptimizer: budget={budget}, tasks={len(dataset)}, " + f"reflection_lm={reflection_lm}" + ) + + gepa_result = gepa.optimize( + seed_candidate=seed_candidate, + adapter=FlowRunnerAdapter(), + trainset=dataset, + valset=dataset, + max_metric_calls=budget, + display_progress_bar=True, + skip_perfect_score=False, + perfect_score=2.0, # Impossible score to disable early stopping + **gepa_config, + ) + + # ── Extract best result ── + + best_prompts = gepa_result.best_candidate + final_instructions = best_prompts.get("instructions", best_instructions) + gepa_best_score = gepa_result.val_aggregate_scores[gepa_result.best_idx] + + # Use GEPA's best if it's better, otherwise use our tracked best + if gepa_best_score >= best_score: + best_instructions = final_instructions + best_score = gepa_best_score + + logger.info( + f"GEPAInstructionOptimizer complete: {generation} generations, " + f"best_score={best_score:.3f}" + ) + + # Build candidates for all unique instruction variants tried + candidates: list[Candidate] = [] + seen_instructions: set[str] = set() + + for h in history: + instr = h.full_instructions or "" + if not instr or instr in seen_instructions: + continue + seen_instructions.add(instr) + + is_best = instr == best_instructions + suffix = "gepa_optimized" if is_best else f"gepa_gen{h.iteration}" + agent = Agent( + name=f"{base.name}_{suffix}", + framework=base.framework, + description=base.description, + instructions=instr, + llm_config=base.llm_config, + compaction=base.compaction, + tools=base.tools, + ) + candidates.append( + Candidate( + agent=agent, + mutations={"instructions": instr}, + rationale=f"GEPA generation {h.iteration}: score={h.avg_score:.3f}", + optimization_history=history if is_best else [], + ) + ) + + # Ensure best is always included + if best_instructions not in seen_instructions: + final_agent = Agent( + name=f"{base.name}_gepa_optimized", + framework=base.framework, + description=base.description, + instructions=best_instructions, + llm_config=base.llm_config, + compaction=base.compaction, + tools=base.tools, + ) + score_progression = f"{history[0].avg_score:.2f} -> {best_score:.2f}" if history else f"-> {best_score:.2f}" + candidates.append( + Candidate( + agent=final_agent, + mutations={"instructions": best_instructions}, + rationale=f"GEPA instruction optimization: {generation} generations, {score_progression}", + optimization_history=history, + ) + ) + + return candidates diff --git a/src/flow/experiments/strategies/llm_rewriter.py b/src/flow/experiments/strategies/instruction.py similarity index 61% rename from src/flow/experiments/strategies/llm_rewriter.py rename to src/flow/experiments/strategies/instruction.py index 60dd1665685ee1e8934e9066ff553356b0c85a2b..7c1550d611eed8a6c2d1e7bc2ce804afa0eb9880 100644 --- a/src/flow/experiments/strategies/llm_rewriter.py +++ b/src/flow/experiments/strategies/instruction.py @@ -1,12 +1,12 @@ # Copyright (c) Microsoft. All rights reserved. -"""LLM-based instruction rewriter strategy. +"""Instruction optimization strategy. -This strategy always requires a runner and tasks. It: -1. Evaluates the current instructions on all tasks -2. Reflects on failures to understand what went wrong -3. Rewrites instructions to address failures -4. Re-evaluates and repeats until convergence or budget exhausted +This strategy iteratively improves agent instructions by: +1. Evaluating the current instructions on all tasks +2. Reflecting on failures to understand what went wrong +3. Rewriting instructions to address failures +4. Re-evaluating and repeating until convergence or budget exhausted """ from __future__ import annotations @@ -23,7 +23,7 @@ logger = logging.getLogger(__name__) @dataclass -class LLMRewriterStrategy: +class InstructionOptimizer: """Strategy that uses an LLM to iteratively improve agent instructions. Runs an evaluate-reflect-rewrite loop. Each iteration evaluates @@ -42,7 +42,7 @@ class LLMRewriterStrategy: Example YAML: strategy: - type: llm_rewriter + type: instruction config: model: gpt-4o-mini max_iterations: 5 @@ -75,12 +75,12 @@ class LLMRewriterStrategy: """ if runner is None: raise ValueError( - "LLMRewriterStrategy requires a runner. " + "InstructionOptimizer requires a runner. " "Use FlowOptimizer.optimize_with_strategy() to provide one." ) if not tasks: raise ValueError( - "LLMRewriterStrategy requires tasks to evaluate against." + "InstructionOptimizer requires tasks to evaluate against." ) base_instructions = base.instructions or "You are a helpful assistant." @@ -100,7 +100,7 @@ class LLMRewriterStrategy: min_improvement = self.config.get("min_improvement", 0.05) logger.info( - f"LLMRewriterStrategy: active mode (max_iterations={max_iterations}, " + f"InstructionOptimizer: active mode (max_iterations={max_iterations}, " f"min_improvement={min_improvement})" ) @@ -108,6 +108,7 @@ class LLMRewriterStrategy: best_instructions = instructions best_score = 0.0 history: list[StrategyIteration] = [] + iteration_candidates: list[tuple[str, str]] = [] # (instructions, label) for iteration in range(max_iterations): # 1. Evaluate current instructions @@ -169,6 +170,10 @@ class LLMRewriterStrategy: ) ) + # Collect candidate for this iteration + label = "baseline" if iteration == 0 else f"iter{iteration}" + iteration_candidates.append((current_instructions, label)) + # Track best if avg_score > best_score: best_score = avg_score @@ -193,29 +198,61 @@ class LLMRewriterStrategy: # 3. Reflect on failures and rewrite current_instructions = self._reflect_and_rewrite( - current_instructions, failures, avg_score, model + current_instructions, failures, avg_score, model, + agent_name=base.name, agent_description=base.description or "", + tasks=tasks, ) logger.info(f" Rewrote instructions ({len(current_instructions)} chars)") - # Build final candidate with optimization history - final_agent = Agent( - name=f"{base.name}_llm_rewriter_optimized", - framework=base.framework, - instructions=best_instructions, - llm_config=base.llm_config, - compaction=base.compaction, - tools=base.tools, - ) + # Build candidates for all unique instruction variants tried + candidates: list[Candidate] = [] + seen_instructions: set[str] = set() - score_progression = f"{history[0].avg_score:.2f} → {best_score:.2f}" - return [ - Candidate( - agent=final_agent, - mutations={"instructions": best_instructions}, - rationale=f"LLM rewriter active optimization: {len(history)} iterations, {score_progression}", - optimization_history=history, + for iter_instructions, label in iteration_candidates: + if iter_instructions in seen_instructions: + continue + seen_instructions.add(iter_instructions) + + is_best = iter_instructions == best_instructions + suffix = "instruction_optimized" if is_best else f"instruction_{label}" + agent = Agent( + name=f"{base.name}_{suffix}", + framework=base.framework, + instructions=iter_instructions, + llm_config=base.llm_config, + compaction=base.compaction, + tools=base.tools, + ) + candidates.append( + Candidate( + agent=agent, + mutations={"instructions": iter_instructions}, + rationale=f"Instructions ({label}): {len(iter_instructions)} chars", + optimization_history=history if is_best else [], + ) ) - ] + + # Ensure best is always included + if best_instructions not in seen_instructions: + final_agent = Agent( + name=f"{base.name}_instruction_optimized", + framework=base.framework, + instructions=best_instructions, + llm_config=base.llm_config, + compaction=base.compaction, + tools=base.tools, + ) + score_progression = f"{history[0].avg_score:.2f} -> {best_score:.2f}" + candidates.append( + Candidate( + agent=final_agent, + mutations={"instructions": best_instructions}, + rationale=f"Instruction optimization: {len(history)} iterations, {score_progression}", + optimization_history=history, + ) + ) + + return candidates def _reflect_and_rewrite( self, @@ -223,52 +260,60 @@ class LLMRewriterStrategy: failures: list[Any], current_score: float, model: str, + agent_name: str = "", + agent_description: str = "", + tasks: list[Task] | None = None, ) -> str: """Analyze failures and rewrite instructions to address them.""" - # Build failure analysis failure_descriptions = [] - for tr in failures[:5]: # Limit to 5 failures for context + for tr in failures[:5]: task_name = getattr(tr, "task_name", "unknown") reasoning = getattr(tr, "eval_reasoning", "No reasoning") score = getattr(tr, "eval_score", 0.0) + task_prompt = getattr(tr, "task_prompt", "") failure_descriptions.append( - f"- Task '{task_name}' (score={score:.2f}): {reasoning[:200]}" + f"- Task '{task_name}' (score={score:.2f}): {reasoning[:300]}" + + (f"\n Task prompt: {task_prompt[:200]}" if task_prompt else "") ) failures_text = "\n".join(failure_descriptions) - prompt = f"""You are a prompt engineer writing guidelines for a coding assistant. - -The assistant's current guidelines scored {current_score:.2f} out of 1.0 on a benchmark. - -Here are the tasks where performance was low: + # Build agent context from name, description, and task domain + agent_context = "" + if agent_name or agent_description: + agent_context = f"\nThe agent is called '{agent_name}'" + if agent_description: + agent_context += f" — {agent_description}" + agent_context += ".\n" + + # Infer domain from task prompts + domain_context = "" + if tasks: + task_summaries = [f"- {t.name}: {t.prompt[:100]}..." for t in tasks[:5]] + domain_context = f"\nThe agent is evaluated on these types of tasks:\n" + "\n".join(task_summaries) + "\n" + + prompt = f"""You are a prompt engineer improving an agent's instructions to fix its performance issues. +{agent_context}{domain_context} +The agent scored {current_score:.2f} out of 1.0. Here are the tasks where it failed and what went wrong: {failures_text} -The current guidelines are: +The agent's current instructions are: --- {instructions} --- -Write a new, improved version of the guidelines. The new guidelines should: -1. Help the assistant succeed on a wide range of coding tasks — the failures - above are examples, but the guidelines must generalize beyond them -2. Include concrete strategies (e.g., always verify output, check edge cases, - create and run files when asked) -3. Be general-purpose: do NOT reference specific task names, specific answers, - or specific test cases from the failures above -4. Focus on transferable skills and habits (e.g., "verify output matches - requirements" not "check that fibonacci returns 55") -5. Be concise +Rewrite the instructions to fix the failures above. The new instructions should: +1. Directly address the failure patterns — if the agent didn't create files, tell it to always save output to the requested file AND display the content. If it missed details, tell it to reference every constraint from the user's request. +2. Be specific to this agent's domain — not generic "coding assistant" guidelines +3. Do NOT reference specific task names or test answers — the instructions should generalize to similar tasks +4. Be concise -Output ONLY the new guidelines text, nothing else.""" +Output ONLY the new instructions text, nothing else.""" try: return self._call_llm(prompt, model) or instructions except Exception as e: logger.warning(f"LLM rewrite failed: {e}") - # Primary prompt failed — the original instructions may have - # triggered a content filter (Azure, OpenAI, etc.) or caused - # another error. Try a fallback that omits them entirely. logger.info("Retrying rewrite with fallback prompt (without original instructions)") return self._fallback_rewrite(failures_text, current_score, model) @@ -277,29 +322,29 @@ Output ONLY the new guidelines text, nothing else.""" failures_text: str, current_score: float, model: str, + agent_name: str = "", + agent_description: str = "", ) -> str: - """Generate new instructions from scratch when the primary rewrite is blocked. + """Generate new instructions from scratch when the primary rewrite is blocked.""" + agent_role = "an AI assistant" + if agent_name or agent_description: + agent_role = f"an AI assistant called '{agent_name}'" + if agent_description: + agent_role += f" ({agent_description})" - This avoids including the original instructions (which may trigger - content filters) and instead writes fresh guidelines based solely on - the task failure descriptions. - """ - prompt = f"""You are a prompt engineer. Write guidelines for a coding assistant. + prompt = f"""You are a prompt engineer. Write instructions for {agent_role}. The assistant scored {current_score:.2f} out of 1.0 on these tasks: {failures_text} -Write concise guidelines that would help a coding assistant succeed on -a wide range of coding tasks. The failures above are examples — the -guidelines must generalize beyond them. The guidelines should: -1. Instruct the assistant to complete coding tasks by creating files and - running code -2. Include strategies for verifying output and handling edge cases -3. Be general-purpose: do NOT reference specific task names or answers - from the failures above -4. Focus on transferable habits and skills +Write concise instructions tailored to this assistant's role. The instructions should: +1. Be specific to the assistant's domain and purpose +2. Address the failure patterns from the tasks above +3. Include strategies for creating files when asked and verifying output +4. Do NOT reference specific task names or answers from the failures above +5. Focus on transferable habits relevant to this assistant's role -Output ONLY the guidelines text, nothing else.""" +Output ONLY the instructions text, nothing else.""" try: result = self._call_llm(prompt, model) @@ -309,22 +354,20 @@ Output ONLY the guidelines text, nothing else.""" except Exception as e2: logger.warning(f"Fallback rewrite also failed: {e2}") - # Last resort: return a sensible default - logger.info("Using default coding assistant guidelines") + logger.info("Using default assistant guidelines") return ( - "You are a helpful coding assistant. When given a task:\n" - "1. Create the requested files with correct, working code\n" - "2. Run the code and verify the output is correct\n" + "You are a helpful assistant. When given a task:\n" + "1. Create the requested files with correct content\n" + "2. Verify the output matches all requirements\n" "3. Handle edge cases and validate results before finishing" ) - def _get_client(self, model: str) -> tuple[Any, str]: """Get OpenAI client and model name.""" try: from openai import AzureOpenAI, OpenAI except ImportError as e: - raise ImportError("openai package required for LLMRewriterStrategy") from e + raise ImportError("openai package required for InstructionOptimizer") from e azure_key = os.environ.get("AZURE_OPENAI_API_KEY") azure_endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT") @@ -354,4 +397,3 @@ Output ONLY the guidelines text, nothing else.""" messages=[{"role": "user", "content": prompt}], ) return response.choices[0].message.content or "" - diff --git a/src/flow/experiments/strategies/skill.py b/src/flow/experiments/strategies/skill.py new file mode 100644 index 0000000000000000000000000000000000000000..c2f976ec5048df3b9dfdbaed3b0590cce138acdb --- /dev/null +++ b/src/flow/experiments/strategies/skill.py @@ -0,0 +1,692 @@ +# Copyright (c) Microsoft. All rights reserved. + +"""Skill optimization strategy. + +Iteratively discovers and generates skills (domain knowledge packages) +to improve agent performance. The strategy: +1. Starts with an empty skill directory (no pre-loaded domain knowledge) +2. Evaluates the agent on tasks to establish a baseline +3. Analyzes failures and uses an LLM to generate SKILL.md files +4. Writes generated skills to a managed directory the agent can discover +5. Re-evaluates and repeats until convergence or budget exhausted + +Skills differ from tools: tools are executable capabilities (read_file, bash), +while skills are domain knowledge packages (OOXML patterns, testing workflows). +""" + +from __future__ import annotations + +import logging +import os +import shutil +import tempfile +from dataclasses import dataclass, field +from pathlib import Path +from typing import Any + +from ..models import Agent, Candidate, ExperimentRunner, StrategyIteration +from ..types import Task + +logger = logging.getLogger(__name__) + + +@dataclass +class SkillOptimizer: + """Strategy that iteratively generates and refines skills for an agent. + + Runs an evaluate-analyze-generate loop. Each iteration evaluates + the agent on tasks, analyzes failures, and generates SKILL.md files + containing domain knowledge that would help the agent succeed. + + The optimizer manages its own skill directory. On each iteration it can: + - Generate new skills based on failure patterns + - Refine existing skills that didn't help enough + - Remove skills that added context cost without benefit + + Requires both a runner (to evaluate candidates) and tasks (to test on). + + Config options: + model: LLM for skill generation (default: gpt-4o-mini) + max_iterations: Max optimization iterations (default: 3) + min_improvement: Min score gain to continue (default: 0.05) + include_builtin: Whether to include built-in skills in the catalog + for selection (default: True) + + Example YAML: + strategy: + type: skill + config: + model: gpt-4o-mini + max_iterations: 3 + include_builtin: true + """ + + config: dict[str, Any] = field(default_factory=dict) + + # Managed skill directory (created during generate, cleaned up after) + _skill_dir: Path | None = field(default=None, init=False, repr=False) + + async def generate( + self, + base: Agent, + budget: int, + *, + tasks: list[Task] | None = None, + runner: ExperimentRunner | None = None, + ) -> list[Candidate]: + """Generate candidates with optimized skill configurations. + + Args: + base: Base agent configuration + budget: Max candidates to generate + tasks: Tasks to evaluate on (required) + runner: ExperimentRunner for evaluation (required) + + Returns: + List of candidates with optimized skill sets + + Raises: + ValueError: If tasks or runner not provided + """ + if runner is None: + raise ValueError( + "SkillOptimizer requires a runner. " + "Use FlowOptimizer.optimize_with_strategy() to provide one." + ) + if not tasks: + raise ValueError( + "SkillOptimizer requires tasks to evaluate against." + ) + + # Create a temp directory that the optimizer owns + self._skill_dir = Path(tempfile.mkdtemp(prefix="flow_skills_opt_")) + logger.info(f"SkillOptimizer: managing skills in {self._skill_dir}") + + try: + return await self._generate_active(base, budget, tasks, runner) + finally: + # Clean up temp dir after optimization + if self._skill_dir and self._skill_dir.exists(): + shutil.rmtree(self._skill_dir, ignore_errors=True) + self._skill_dir = None + + async def _generate_active( + self, + base: Agent, + budget: int, + tasks: list[Task], + runner: ExperimentRunner, + ) -> list[Candidate]: + """Run active optimization loop with real evaluation feedback.""" + model = self.config.get("model", "gpt-4o-mini") + max_iterations = self.config.get("max_iterations", 3) + min_improvement = self.config.get("min_improvement", 0.05) + include_builtin = self.config.get("include_builtin", True) + + assert self._skill_dir is not None + + logger.info( + f"SkillOptimizer: active mode (max_iterations={max_iterations}, " + f"min_improvement={min_improvement}, include_builtin={include_builtin})" + ) + + # Collect built-in skill catalog for LLM reference + builtin_catalog = self._get_builtin_catalog() if include_builtin else {} + + best_score = 0.0 + best_skills: dict[str, str] = {} # skill_name -> SKILL.md content + current_skills: dict[str, str] = {} # starts empty + _prev_skills: dict[str, str] = {} + history: list[StrategyIteration] = [] + iteration_candidates: list[tuple[dict[str, str], str]] = [] + + for iteration in range(max_iterations): + # 1. Write current skills to the managed directory + self._write_skills_to_dir(current_skills) + + # 2. Build agent with skills embedded in instructions + tools_config = self._build_tools_with_skills(base) + enriched_instructions = self._build_instructions_with_skills( + base.instructions, current_skills + ) + agent = Agent( + name=f"{base.name}_skills_iter{iteration}", + framework=base.framework, + instructions=enriched_instructions, + llm_config=base.llm_config, + compaction=base.compaction, + tools=tools_config, + skills=dict(current_skills) if current_skills else None, + ) + candidate = Candidate( + agent=agent, + mutations={"skills": sorted(current_skills.keys())}, + ) + + summary = await runner.evaluate(candidate, tasks) + + avg_score = getattr(summary, "avg_score", 0.0) + pass_rate = getattr(summary, "pass_rate", 0.0) + task_results = getattr(summary, "task_results", []) + failures = [tr for tr in task_results if not getattr(tr, "eval_passed", True)] + + skills_list = sorted(current_skills.keys()) or ["(none)"] + logger.info( + f" Iteration {iteration}: avg_score={avg_score:.3f}, " + f"pass_rate={pass_rate:.1%}, failures={len(failures)}, " + f"skills={skills_list}" + ) + + # Build per-task summary (include full reasoning for history) + task_lines: list[str] = [] + for tr in task_results: + task_name = getattr(tr, "task_name", "unknown") + passed = getattr(tr, "eval_passed", True) + reasoning = getattr(tr, "eval_reasoning", "") + status = "PASS" if passed else "FAIL" + task_lines.append(f" [{status}] {task_name}: {reasoning[:500]}") + tasks_summary = "\n".join(task_lines) + + # Record iteration + skills_desc = ", ".join(skills_list) + change_desc = "Baseline evaluation (no skills)" if iteration == 0 else f"Skill adjustment iteration {iteration}" + change_rationale = f"Skills: {skills_desc}\n{tasks_summary}" + if iteration > 0: + score_delta = avg_score - history[-1].avg_score + prev_skills = set(_prev_skills.keys()) + curr_skill_set = set(current_skills.keys()) + added = sorted(curr_skill_set - prev_skills) + removed = sorted(prev_skills - curr_skill_set) + change_rationale = ( + f"Score {'improved' if score_delta > 0 else 'declined'} by {abs(score_delta):.3f}. " + f"Added skills: {added or 'none'}. Removed: {removed or 'none'}. " + f"{len(failures)} failures remaining.\n" + f"Skills: {skills_desc}\n{tasks_summary}" + ) + + history.append( + StrategyIteration( + iteration=iteration, + instructions_preview=f"[{skills_desc}]"[:200], + full_instructions=f"Skills: [{skills_desc}]", + avg_score=avg_score, + pass_rate=pass_rate, + failures_count=len(failures), + change_description=change_desc, + change_rationale=change_rationale, + ) + ) + + label = "baseline" if iteration == 0 else f"iter{iteration}" + iteration_candidates.append((dict(current_skills), label)) + + # Track best (>= so that skills are preferred over no-skills on ties) + if avg_score >= best_score and (current_skills or not best_skills): + best_score = avg_score + best_skills = dict(current_skills) + + # 2. Check stopping conditions + if iteration > 0: + improvement = avg_score - history[-2].avg_score + if improvement < min_improvement and avg_score <= best_score: + logger.info( + f" Stopping: improvement ({improvement:.3f}) < " + f"min_improvement ({min_improvement})" + ) + break + + if not failures: + logger.info(" Stopping: all tasks passed") + break + + if iteration == max_iterations - 1: + break # Don't generate on last iteration + + # 3. Analyze failures and generate/adjust skills + _prev_skills = dict(current_skills) + current_skills = self._analyze_and_generate( + current_skills, task_results, builtin_catalog, model, tasks + ) + logger.info(f" Updated skills: {sorted(current_skills.keys())}") + + # Build candidates for all unique skill configs tried + candidates: list[Candidate] = [] + seen_skill_sets: set[tuple[str, ...]] = set() + + for iter_skills, label in iteration_candidates: + skill_key = tuple(sorted(iter_skills.keys())) + if skill_key in seen_skill_sets: + continue + seen_skill_sets.add(skill_key) + + is_best = sorted(iter_skills.keys()) == sorted(best_skills.keys()) + suffix = "skills_optimized" if is_best else f"skills_{label}" + + self._write_skills_to_dir(iter_skills) + tools_config = self._build_tools_with_skills(base) + enriched_instructions = self._build_instructions_with_skills( + base.instructions, iter_skills + ) + skills_desc = ", ".join(sorted(iter_skills.keys())) or "(none)" + candidates.append( + Candidate( + agent=Agent( + name=f"{base.name}_{suffix}", + framework=base.framework, + instructions=enriched_instructions, + llm_config=base.llm_config, + compaction=base.compaction, + tools=tools_config, + skills=dict(iter_skills) if iter_skills else None, + ), + mutations={ + "skills": sorted(iter_skills.keys()), + }, + rationale=f"Skills: [{skills_desc}]", + optimization_history=history if is_best else [], + ) + ) + + # Ensure best is always included + best_key = tuple(sorted(best_skills.keys())) + if best_key not in seen_skill_sets: + self._write_skills_to_dir(best_skills) + tools_config = self._build_tools_with_skills(base) + enriched_instructions = self._build_instructions_with_skills( + base.instructions, best_skills + ) + skills_desc = ", ".join(sorted(best_skills.keys())) or "(none)" + candidates.append( + Candidate( + agent=Agent( + name=f"{base.name}_skills_optimized", + framework=base.framework, + instructions=enriched_instructions, + llm_config=base.llm_config, + compaction=base.compaction, + tools=tools_config, + skills=dict(best_skills) if best_skills else None, + ), + mutations={ + "skills": sorted(best_skills.keys()), + }, + rationale=f"Skills: [{skills_desc}]", + optimization_history=history, + ) + ) + + # Restore best skills as final state on disk + self._write_skills_to_dir(best_skills) + + return candidates + + def _build_tools_with_skills(self, base: Agent) -> list[str] | dict[str, Any]: + """Build a tools config that includes the skills tool pointing to our managed dir. + + Ensures the agent has the skills tool configured to only see our managed + skill directory (no built-in or user skills auto-loaded). + """ + from ..models import resolve_tools + + # Start from the base agent's tools + if base.tools is None or (isinstance(base.tools, list) and len(base.tools) == 0): + base_tools: dict[str, Any] = {} + elif isinstance(base.tools, str): + base_tools = dict(resolve_tools(base.tools)) + elif isinstance(base.tools, list): + base_tools = dict(resolve_tools(base.tools)) + else: + base_tools = dict(base.tools) + + # Ensure skills tool is present with our managed path + assert self._skill_dir is not None + base_tools["skills"] = { + "skills_path": str(self._skill_dir), + } + + return base_tools + + def _build_instructions_with_skills( + self, base_instructions: str | None, skills: dict[str, str] + ) -> str: + """Inject full skill content into the agent's instructions. + + The harness layer injects skill *summaries* (name + description) into + the system prompt for normal agents. The optimizer intentionally injects + *full* skill content here because optimization requires the agent to + see and follow the complete domain knowledge, not just a summary. + + Setting explicit instructions on the Agent causes the harness to skip + its own summary injection, so these two approaches don't conflict. + """ + parts: list[str] = [] + if base_instructions: + parts.append(base_instructions) + + if skills: + parts.append("\n## Domain Knowledge (Skills)\n") + parts.append( + "The following skills provide domain-specific patterns and " + "best practices. Follow these guidelines when completing tasks.\n" + ) + for name, content in sorted(skills.items()): + parts.append(f"### {name}\n{content}\n") + + return "\n".join(parts) if parts else "" + + def _write_skills_to_dir(self, skills: dict[str, str]) -> None: + """Write skill content to the managed directory. + + Clears the directory first, then writes each skill as a folder + with a SKILL.md file. + """ + assert self._skill_dir is not None + + # Clear existing skills + if self._skill_dir.exists(): + for item in self._skill_dir.iterdir(): + if item.is_dir(): + shutil.rmtree(item) + + # Write each skill + for name, content in skills.items(): + skill_dir = self._skill_dir / name + skill_dir.mkdir(parents=True, exist_ok=True) + (skill_dir / "SKILL.md").write_text(content) + + def _get_builtin_catalog(self) -> dict[str, str]: + """Get descriptions of all built-in skills for LLM reference.""" + from flow.tools.skills import _discover_skills, _get_builtin_skills_path + + builtin_path = _get_builtin_skills_path() + if not builtin_path.exists(): + return {} + + discovered = _discover_skills([builtin_path]) + catalog: dict[str, str] = {} + for skill_name, (skill_md, meta) in discovered.items(): + description = meta.get("description", "No description") + catalog[skill_name] = description + + return catalog + + def _analyze_and_generate( + self, + current_skills: dict[str, str], + task_results: list[Any], + builtin_catalog: dict[str, str], + model: str, + tasks: list[Task] | None = None, + ) -> dict[str, str]: + """Analyze failures and incrementally evolve skills. + + The LLM sees the full content of every current skill and decides + per-skill what to do: + - "keep": skill is helping, leave it unchanged + - "drop": skill isn't helping, remove it + - "refine": skill has the right idea but needs improved content + (LLM provides the updated SKILL.md) + - New skills can be added (LLM provides full SKILL.md content) + - "builtin": select a built-in skill by name from the catalog + """ + # Build task->criteria lookup for enriching the prompt + task_criteria_map: dict[str, list[dict[str, str]]] = {} + if tasks: + for t in tasks: + task_criteria_map[t.name] = [ + {"name": c.name, "instruction": c.instruction} + for c in t.criteria + ] + + # Build task results summary with full reasoning and criteria + task_descriptions = [] + for tr in task_results: + task_name = getattr(tr, "task_name", "unknown") + passed = getattr(tr, "eval_passed", True) + reasoning = getattr(tr, "eval_reasoning", "") + score = getattr(tr, "eval_score", 0.0) + status = "PASS" if passed else "FAIL" + + # Include full reasoning (not truncated) + entry = f"- [{status}] Task '{task_name}' (score={score:.2f}):\n Reasoning: {reasoning}" + + # Include the task's evaluation criteria so the LLM knows + # the exact rules the agent must follow + criteria = task_criteria_map.get(task_name, []) + if criteria and not passed: + criteria_lines = [] + for c in criteria: + criteria_lines.append(f" - {c['name']}: {c['instruction']}") + entry += "\n Evaluation criteria (the agent MUST satisfy ALL of these):\n" + entry += "\n".join(criteria_lines) + + task_descriptions.append(entry) + results_text = "\n".join(task_descriptions) + + # Build current skills section with full content + current_skills_section = "" + if current_skills: + skill_entries = [] + for name, content in sorted(current_skills.items()): + # Show full content so LLM can refine it + skill_entries.append( + f"### Skill: {name}\n```\n{content}\n```" + ) + current_skills_section = ( + "\n## Current Skills (full content)\n" + + "\n\n".join(skill_entries) + + "\n" + ) + else: + current_skills_section = "\n## Current Skills\nNone — this is the first iteration.\n" + + # Build catalog section + catalog_section = "" + if builtin_catalog: + catalog_lines = [] + for name, desc in sorted(builtin_catalog.items()): + catalog_lines.append(f" - {name}: {desc}") + catalog_section = ( + "\n## Available Built-in Skills (can be selected by name)\n" + + "\n".join(catalog_lines) + + "\n" + ) + + prompt = f"""You are optimizing the skill configuration for a coding assistant. +Skills are domain knowledge packages (SKILL.md files) that give the agent specialized +expertise, patterns, and best practices for specific domains. + +## Task Results +{results_text} +{current_skills_section}{catalog_section} +## Your Job +Analyze the failing tasks above. Each failing task includes its **evaluation criteria** — +these are the exact rules the evaluator checks. Your skills MUST encode these specific +requirements so the agent follows them. + +**Critical**: The agent fails because it doesn't know about specific conventions +(e.g., exact data formats, specific error types to raise, required fields in output). +Your skills must spell out these conventions as concrete, actionable rules — not +general advice. + +For EACH current skill, decide: +- **"keep"** — the skill is helping (tasks it targets are passing). Leave it as-is. +- **"drop"** — the skill isn't contributing. Remove it to reduce noise. +- **Provide updated SKILL.md content** — the skill targets the right problem but + its content should be refined to better address the failures. + +You can also: +- **Add new skills** with full SKILL.md content to address uncovered failure patterns +- **Select a built-in** by setting the value to "builtin" + +## What Makes a Good Skill +- **Specific, not generic**: "Always use `json.dumps(data, indent=2)`" is better than + "Use proper JSON formatting" +- **Actionable rules**: "Define `__all__` at module top" is better than "Follow best practices" +- **Directly addresses criteria**: Each skill rule should map to a specific evaluation + criterion that the agent is currently failing +- **Concise**: Include only the rules needed; avoid padding with obvious advice +- **Evidence-producing**: The agent is evaluated ONLY on what appears in its tool + outputs and final response. If the agent writes a file, the evaluator does NOT + read that file — it only sees the tool's return message (e.g., "Successfully wrote + 625 characters"). Skills MUST instruct the agent to make its work verifiable: + * After writing a file, read it back or print its contents so the output is visible + * After creating structured output (CSV, JSON, code), display the result + * Run scripts and show their output rather than just writing them + * The evaluator cannot verify what it cannot see — always produce visible evidence + +## Response Format +Respond with a JSON object. Keys are skill names, values are one of: +- `"keep"` — retain this skill unchanged +- `"drop"` — remove this skill +- `"builtin"` — load from the built-in catalog +- A string containing the full SKILL.md content (for new or refined skills) + +SKILL.md content MUST start with YAML frontmatter: +--- +name: skill-name +description: What this skill does +--- +# Content... + +## Rules +- Keep skills that are working (their target tasks pass) — don't drop what works +- Refine skills whose target tasks still fail — tweak the content, don't start over +- Only add new skills for failure patterns not covered by existing skills +- Keep skills focused and concise (domain knowledge, not general advice) +- ALWAYS include a "Verification" section in every skill telling the agent to + display/print/cat its output after creating it — this is the #1 cause of false + failures (correct code that the evaluator can't see) + +## Example Response +{{"git-log-parsing": "keep", "executable-verification": "---\\nname: executable-verification\\ndescription: Improved verification patterns\\n---\\n# Updated content here...", "new-skill": "---\\nname: new-skill\\ndescription: Addresses regex failures\\n---\\n# Content..."}} + +Respond with ONLY the JSON object, nothing else.""" + + try: + result = self._call_llm(prompt, model) + if result: + return self._parse_skill_response(result, current_skills, builtin_catalog) + except Exception as e: + logger.warning(f"LLM skill generation failed: {e}") + + # Fallback: keep current skills unchanged + return current_skills + + def _parse_skill_response( + self, + response: str, + current_skills: dict[str, str], + builtin_catalog: dict[str, str], + ) -> dict[str, str]: + """Parse LLM response into skill name -> content mapping. + + Supports incremental operations: + - "keep": retain existing skill content unchanged + - "drop": remove the skill (omit from result) + - "builtin": load from built-in catalog + - string content: new or refined skill (replaces existing) + """ + import json + + # Try to extract JSON from the response + response = response.strip() + # Handle markdown code blocks + if response.startswith("```"): + lines = response.split("\n") + lines = [l for l in lines if not l.strip().startswith("```")] + response = "\n".join(lines) + + try: + skills_dict = json.loads(response) + except json.JSONDecodeError: + logger.warning(f"Failed to parse skill response as JSON: {response[:200]}") + return current_skills + + if not isinstance(skills_dict, dict): + logger.warning(f"Skill response is not a dict: {type(skills_dict)}") + return current_skills + + new_skills: dict[str, str] = {} + for name, value in skills_dict.items(): + if not isinstance(name, str): + continue + + if value == "keep": + # Retain existing skill unchanged + if name in current_skills: + new_skills[name] = current_skills[name] + else: + logger.warning(f"Cannot keep unknown skill: {name}") + elif value == "drop": + # Explicitly remove — just don't add to new_skills + logger.info(f"Dropping skill: {name}") + elif value == "builtin" and name in builtin_catalog: + content = self._load_builtin_skill(name) + if content: + new_skills[name] = content + else: + logger.warning(f"Failed to load built-in skill: {name}") + elif isinstance(value, str) and value not in ("builtin", "keep", "drop"): + # New or refined skill content + new_skills[name] = value + else: + logger.warning(f"Skipping invalid skill entry: {name}={value!r}") + + if not new_skills and current_skills: + logger.warning("LLM dropped all skills, keeping current set") + return current_skills + + return new_skills + + def _load_builtin_skill(self, name: str) -> str | None: + """Load the full content of a built-in skill.""" + from flow.tools.skills import _discover_skills, _get_builtin_skills_path + + builtin_path = _get_builtin_skills_path() + discovered = _discover_skills([builtin_path]) + + if name in discovered: + skill_md, _ = discovered[name] + try: + return skill_md.read_text() + except Exception as e: + logger.warning(f"Error reading built-in skill {name}: {e}") + + return None + + def _get_client(self, model: str) -> tuple[Any, str]: + """Get OpenAI client and model name.""" + try: + from openai import AzureOpenAI, OpenAI + except ImportError as e: + raise ImportError("openai package required for SkillOptimizer") from e + + azure_key = os.environ.get("AZURE_OPENAI_API_KEY") + azure_endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT") + + if azure_key and azure_endpoint: + client = AzureOpenAI( + api_key=azure_key, + api_version="2024-08-01-preview", + azure_endpoint=azure_endpoint, + ) + model_name = os.environ.get("AZURE_OPENAI_DEPLOYMENT", model) + else: + openai_key = os.environ.get("OPENAI_API_KEY") + if not openai_key: + raise ValueError("No OpenAI or Azure OpenAI credentials found") + client = OpenAI(api_key=openai_key) + model_name = model + + return client, model_name + + def _call_llm(self, prompt: str, model: str) -> str: + """Call LLM with a prompt.""" + client, model_name = self._get_client(model) + + response = client.chat.completions.create( + model=model_name, + messages=[{"role": "user", "content": prompt}], + ) + return response.choices[0].message.content or "" diff --git a/src/flow/experiments/strategies/tool_selector.py b/src/flow/experiments/strategies/tool.py similarity index 92% rename from src/flow/experiments/strategies/tool_selector.py rename to src/flow/experiments/strategies/tool.py index 9801602e5db83f9a149d8896127979479cbe63bb..7f58dfca8e6c6ee145553fd2a7b92b27a74eec52 100644 --- a/src/flow/experiments/strategies/tool_selector.py +++ b/src/flow/experiments/strategies/tool.py @@ -1,6 +1,6 @@ # Copyright (c) Microsoft. All rights reserved. -"""Active tool selector strategy. +"""Tool optimization strategy. Uses the runner to evaluate tool configurations and iteratively adjust the tool set based on actual execution failures. The strategy: @@ -17,7 +17,6 @@ import os from dataclasses import dataclass, field from typing import Any -from ..metrics import extract_metrics from ..models import Agent, Candidate, ExperimentRunner, StrategyIteration, TOOL_PRESETS from ..types import Task @@ -30,7 +29,7 @@ ALL_AVAILABLE_TOOLS: list[str] = sorted( @dataclass -class ToolSelectorStrategy: +class ToolOptimizer: """Strategy that iteratively optimizes tool configurations via evaluation. Runs an evaluate-analyze-adjust loop. Each iteration evaluates @@ -47,7 +46,7 @@ class ToolSelectorStrategy: Example YAML: strategy: - type: tool_selector + type: tool config: model: gpt-4o-mini max_iterations: 3 @@ -79,18 +78,22 @@ class ToolSelectorStrategy: """ if runner is None: raise ValueError( - "ToolSelectorStrategy requires a runner. " + "ToolOptimizer requires a runner. " "Use FlowOptimizer.optimize_with_strategy() to provide one." ) if not tasks: raise ValueError( - "ToolSelectorStrategy requires tasks to evaluate against." + "ToolOptimizer requires tasks to evaluate against." ) # Resolve initial tools to a list + # When starting from no tools, seed with "standard" preset so the + # optimizer has a working baseline to iterate from. An agent with + # zero tools produces zero signal (no tool calls, no files created), + # which makes iterative improvement impossible. from ..models import resolve_tools if base.tools is None or (isinstance(base.tools, list) and len(base.tools) == 0): - current_tools = [] + current_tools = sorted(resolve_tools("standard").keys()) else: current_tools = sorted(resolve_tools(base.tools).keys()) @@ -111,13 +114,14 @@ class ToolSelectorStrategy: available_tools = self.config.get("available_tools", ALL_AVAILABLE_TOOLS) logger.info( - f"ToolSelectorStrategy: active mode (max_iterations={max_iterations}, " + f"ToolOptimizer: active mode (max_iterations={max_iterations}, " f"available_tools={len(available_tools)})" ) current_tools = tools best_tools = tools best_score = 0.0 + _prev_tools: list[str] = [] history: list[StrategyIteration] = [] # Track all unique tool configs tried, for returning as candidates iteration_candidates: list[tuple[list[str], str]] = [] # (tools, name_suffix) @@ -180,8 +184,8 @@ class ToolSelectorStrategy: change_rationale = f"Tools used: {used_desc}\n{tasks_summary}" if iteration > 0: score_delta = avg_score - history[-1].avg_score - added = set(current_tools) - set(best_tools if iteration == 1 else _prev_tools) - removed = set(_prev_tools) - set(current_tools) if iteration > 0 else set() + added = set(current_tools) - set(_prev_tools) + removed = set(_prev_tools) - set(current_tools) change_rationale = ( f"Score {'improved' if score_delta > 0 else 'declined'} by {abs(score_delta):.3f}. " f"Added: {sorted(added) or 'none'}. Removed: {sorted(removed) or 'none'}. " @@ -235,7 +239,6 @@ class ToolSelectorStrategy: logger.info(f" Adjusted tools: {current_tools}") # Build candidates for all unique tool configs tried - # This gives the Pareto chart multiple data points to compare candidates: list[Candidate] = [] seen_tool_sets: set[tuple[str, ...]] = set() @@ -265,8 +268,7 @@ class ToolSelectorStrategy: ) ) - # Ensure best is always included (may differ from any iteration if - # the best score was from an earlier iteration) + # Ensure best is always included best_key = tuple(sorted(best_tools)) if best_key not in seen_tool_sets: final_agent = Agent( @@ -298,7 +300,6 @@ class ToolSelectorStrategy: model: str, ) -> list[str]: """Analyze failures and traces, then recommend tool changes.""" - # Build analysis of what happened failure_descriptions = [] for tr in task_results: task_name = getattr(tr, "task_name", "unknown") @@ -306,7 +307,6 @@ class ToolSelectorStrategy: reasoning = getattr(tr, "eval_reasoning", "") score = getattr(tr, "eval_score", 0.0) - # Get per-task tool usage metrics = getattr(tr, "metrics", None) task_tools = {} if metrics and hasattr(metrics, "tool_calls_by_name"): @@ -349,16 +349,13 @@ Example: read_file, write_file, bash, grep, edit_file""" try: result = self._call_llm(prompt, model) if result: - # Parse comma-separated tool names parsed = [t.strip() for t in result.split(",") if t.strip()] - # Validate against available tools valid = [t for t in parsed if t in available_tools] if valid: return sorted(valid) logger.warning(f"No valid tools in LLM response: {parsed}") except Exception as e: logger.warning(f"LLM tool adjustment failed: {e}") - # Fallback: try adding commonly useful tools return self._heuristic_adjust(current_tools, tools_used, available_tools) return current_tools @@ -372,18 +369,15 @@ Example: read_file, write_file, bash, grep, edit_file""" """Fallback heuristic when LLM is unavailable.""" adjusted = set(current_tools) - # If bash was used heavily but grep/glob not available, add them if "bash" in tools_used and tools_used["bash"] > 2: for tool in ["grep", "glob_files", "ls"]: if tool in available_tools: adjusted.add(tool) - # If write_file was used but edit_file not available, add it if "write_file" in tools_used and "edit_file" not in adjusted: if "edit_file" in available_tools: adjusted.add("edit_file") - # Add think if not present (helps with reasoning) if "think" in available_tools: adjusted.add("think") @@ -394,7 +388,7 @@ Example: read_file, write_file, bash, grep, edit_file""" try: from openai import AzureOpenAI, OpenAI except ImportError as e: - raise ImportError("openai package required for ToolSelectorStrategy") from e + raise ImportError("openai package required for ToolOptimizer") from e azure_key = os.environ.get("AZURE_OPENAI_API_KEY") azure_endpoint = os.environ.get("AZURE_OPENAI_ENDPOINT") diff --git a/src/flow/harness/compaction/strategies.py b/src/flow/harness/compaction/strategies.py index 04dfd420eeeeca76964adfc14161d1677548e159..d9f355c3059d556ae2dc4e88064898c4cac95758 100644 --- a/src/flow/harness/compaction/strategies.py +++ b/src/flow/harness/compaction/strategies.py @@ -10,6 +10,8 @@ from __future__ import annotations from dataclasses import dataclass, field from typing import Any, Protocol +from loguru import logger + from flow.harness.compaction.tokenizer import ( count_message_tokens, count_messages_tokens, @@ -479,7 +481,8 @@ class SummarizationStrategy: if self.summarize_fn: try: summary_text = await self.summarize_fn(middle, self.summary_max_tokens) - except Exception: + except Exception as e: + logger.warning(f"Summarization function failed, falling back to key info extraction: {e}") summary_text = self._extract_key_info(middle) else: summary_text = self._extract_key_info(middle) diff --git a/src/flow/harness/maf/agent.py b/src/flow/harness/maf/agent.py index b4ffcf20b99385ea1b7bc560a5a5e278de5946f7..4e994b96ac6729a802a91ed00c919c804d5bf84f 100644 --- a/src/flow/harness/maf/agent.py +++ b/src/flow/harness/maf/agent.py @@ -163,14 +163,26 @@ def create_agent( f"Message compaction enabled: head={compaction_head_size}, tail={compaction_tail_size}, head_ratio={head_ratio:.2f}" ) - # Determine if memory is enabled for instructions + # Determine if memory and skills are enabled for instructions enable_memory = False + enable_skills = False if isinstance(tools, str): - enable_memory = "memory" in TOOL_PRESETS.get(tools, {}) + preset = TOOL_PRESETS.get(tools, {}) + enable_memory = "memory" in preset + enable_skills = "skills" in preset elif isinstance(tools, list): enable_memory = "memory" in tools + enable_skills = "skills" in tools elif isinstance(tools, dict): enable_memory = "memory" in tools + enable_skills = "skills" in tools + + # Discover skill metadata when skills are enabled and no explicit instructions + skills_metadata: dict[str, dict[str, str]] | None = None + if enable_skills and instructions is None: + from flow.tools.skills import discover_skills_from_tools_spec + + skills_metadata = discover_skills_from_tools_spec(tools_spec) # Create the agent agent = ChatAgent( @@ -178,6 +190,8 @@ def create_agent( description="Autonomous coding agent", instructions=instructions or build_instructions( enable_memory=enable_memory, + enable_skills=enable_skills, + skills_metadata=skills_metadata, ), chat_client=client, tools=converted_tools, diff --git a/src/flow/harness/maf/tools/__init__.py b/src/flow/harness/maf/tools/__init__.py index 8791dc5d421bdb5426ebdff88af0416214798735..6d0eb99af81810a00f4e27f954307c6e77350a51 100644 --- a/src/flow/harness/maf/tools/__init__.py +++ b/src/flow/harness/maf/tools/__init__.py @@ -151,8 +151,16 @@ def build_tools( model=config.get("model"), ) tools.append(to_maf_tool(custom_task)) + elif name == "skills" and config.get("skills_path"): + # Skills with explicit managed path (used by SkillOptimizer) + # Only uses the specified path — no built-in or user skills + custom_skills = create_skills_tool( + builtin_path=Path(config["skills_path"]), + exclusive=True, + ) + tools.append(to_maf_tool(custom_skills)) elif name == "skills" and config.get("additional_paths"): - # Skills with custom paths + # Skills with additional project paths (keeps built-in skills too) custom_skills = create_skills_tool(project_path=Path(config["additional_paths"][0])) tools.append(to_maf_tool(custom_skills)) # Web search tool diff --git a/src/flow/harness/miniagent/harness.py b/src/flow/harness/miniagent/harness.py index 1817fdf4c39d18d40d75762081b87d2f3381415e..f240356ed990849847d4f9d35388ce76ec4d8676 100644 --- a/src/flow/harness/miniagent/harness.py +++ b/src/flow/harness/miniagent/harness.py @@ -116,6 +116,8 @@ class MiniAgentHarness(BaseHarness): otel_hooks = create_otel_hooks(model=config.model) # Resolve instructions: explicit > preset > default "general" + # When using default instructions, discover skill metadata and append + # a summary so the agent knows what skills are available upfront. if agent.instructions: instructions = agent.instructions elif agent.instructions_preset: @@ -123,6 +125,27 @@ class MiniAgentHarness(BaseHarness): else: instructions = get_instructions("general") + # Inject skill metadata into instructions (unless explicit instructions were set) + if not agent.instructions and "skills" in tools_spec: + from flow.tools.skills import discover_skills_from_tools_spec + + skills_metadata = discover_skills_from_tools_spec(tools_spec) + if skills_metadata: + lines = ["\n\n## AVAILABLE SKILLS\n"] + lines.append( + "The following domain-specific skills are available. " + "Use `skills(action='load', name='...')` to load full content " + "when relevant to your task.\n" + ) + for skill_name, meta in sorted(skills_metadata.items()): + description = meta.get("description", "No description") + triggers = meta.get("triggers", "") + entry = f"- **{skill_name}**: {description}" + if triggers: + entry += f" _(triggers: {triggers})_" + lines.append(entry) + instructions += "\n".join(lines) + chat_agent = ChatAgent( client=chat_client, instructions=instructions, @@ -410,7 +433,15 @@ class MiniAgentHarness(BaseHarness): tools: list[Tool] = [] for name, config in tools_spec.items(): - if name in tool_map: + if name == "skills" and config.get("skills_path"): + # Skills with explicit managed path (used by SkillOptimizer) + from flow.tools.skills import create_skills_tool as _create_skills + custom_skills = _create_skills( + builtin_path=Path(config["skills_path"]), + exclusive=True, + ) + tools.append(custom_skills) + elif name in tool_map: tools.append(tool_map[name]) elif name == "task" and config: # Task tool with custom config diff --git a/src/flow/harness/miniagent/tool.py b/src/flow/harness/miniagent/tool.py index 4bcea1614c08ce00b21b4c71165aa9dec35ac730..d73e4007037dd6bef028c693e76e9b7897b7e00d 100644 --- a/src/flow/harness/miniagent/tool.py +++ b/src/flow/harness/miniagent/tool.py @@ -8,6 +8,8 @@ from collections.abc import Callable from dataclasses import dataclass from typing import Annotated, Any, Literal, get_args, get_origin, get_type_hints +from loguru import logger + @dataclass class Tool: @@ -115,7 +117,8 @@ def tool(func: Callable[..., Any]) -> Tool: # Get type hints (with extras for Annotated) try: hints = get_type_hints(func, include_extras=True) - except Exception: + except Exception as e: + logger.warning(f"Failed to get type hints for function {func.__name__}: {e}") hints = {} # Build JSON Schema for parameters diff --git a/src/flow/prompts.py b/src/flow/prompts.py index b098e6b7e335dd1aa731a49b9e9ede7f8501e1da..948d6179b38657086e1f01ba3ead5f719d7f808f 100644 --- a/src/flow/prompts.py +++ b/src/flow/prompts.py @@ -464,6 +464,7 @@ def build_instructions( *, enable_memory: bool = True, enable_skills: bool = True, + skills_metadata: dict[str, dict[str, str]] | None = None, ) -> str: """Build agent instructions dynamically based on enabled tools. @@ -474,6 +475,11 @@ def build_instructions( Args: enable_memory: Include memory tool documentation. enable_skills: Include skills tool documentation. + skills_metadata: Optional dict of discovered skill metadata + (name -> {"description": ..., "triggers": ...}). + When provided, injects a concrete listing of available skills + into the system prompt so the agent knows what's available + without needing to call ``skills(action='list')``. Returns: Complete instruction string. @@ -529,6 +535,23 @@ def build_instructions( if enable_skills: sections.append(_SKILLS_SECTION) + # Inject concrete skill listing when metadata is available + if enable_skills and skills_metadata: + lines = ["\n## AVAILABLE SKILLS\n"] + lines.append( + "The following domain-specific skills are available. " + "Use `skills(action='load', name='...')` to load full content " + "when relevant to your task.\n" + ) + for skill_name, meta in sorted(skills_metadata.items()): + description = meta.get("description", "No description") + triggers = meta.get("triggers", "") + entry = f"- **{skill_name}**: {description}" + if triggers: + entry += f" _(triggers: {triggers})_" + lines.append(entry) + sections.append("\n".join(lines)) + sections.extend([ _CORE_EXAMPLES, _CORE_RESEARCH, diff --git a/src/flow/tools/__init__.py b/src/flow/tools/__init__.py index ab11122b04658894cd1411b989ffdba6029bdcaf..4fa6ba3023cb7d55fbc96d231e9e93901ce6298b 100644 --- a/src/flow/tools/__init__.py +++ b/src/flow/tools/__init__.py @@ -50,10 +50,11 @@ Sub-agents: from __future__ import annotations -import logging from pathlib import Path from typing import Any +from loguru import logger + # Adapters for framework integration from .adapters import to_maf_tool, to_openai_tool, tools_to_maf, tools_to_openai from .base import Tool, tool @@ -96,7 +97,7 @@ from .notebook import notebook_edit, notebook_read from .planning import think, todo_read, todo_write # Skills tools -from .skills import create_skills_tool, skills +from .skills import create_skills_tool, discover_skills_from_tools_spec, skills # Sub-agent tools from .subagent import create_task_tool, task @@ -148,6 +149,7 @@ __all__ = [ # Skills tools "skills", "create_skills_tool", + "discover_skills_from_tools_spec", # Sub-agent tools "task", "create_task_tool", @@ -175,8 +177,6 @@ __all__ = [ "visual_inspector", ] -logger = logging.getLogger(__name__) - # ============================================================================= # Tool Presets - Convenient groupings of tools diff --git a/src/flow/tools/adapters.py b/src/flow/tools/adapters.py index ed5d3720f9f669e086713871b1d80cc998d5377e..a71d52eeec9771d0c5d0c8c5fccc534891823694 100644 --- a/src/flow/tools/adapters.py +++ b/src/flow/tools/adapters.py @@ -9,7 +9,6 @@ across different agent frameworks without code duplication. from __future__ import annotations -import logging from typing import TYPE_CHECKING from .base import Tool @@ -18,8 +17,6 @@ if TYPE_CHECKING: from collections.abc import Callable from typing import Any -logger = logging.getLogger(__name__) - def to_maf_tool(tool: Tool) -> Callable[..., Any]: """Convert a Flow Tool to a MAF-decorated function. @@ -42,10 +39,7 @@ def to_maf_tool(tool: Tool) -> Callable[..., Any]: try: from agent_framework import tool as maf_tool except ImportError: - raise ImportError( - "Microsoft Agent Framework not installed. " - "Install with: pip install agent-framework" - ) + raise ImportError("Microsoft Agent Framework not installed. Install with: pip install agent-framework") return maf_tool( name=tool.name, diff --git a/src/flow/tools/base.py b/src/flow/tools/base.py index 2de822ebbef2b08a262aeb1a79a1366c2667bc1e..0623c0750b983ec099046f45777ab0ab571c7900 100644 --- a/src/flow/tools/base.py +++ b/src/flow/tools/base.py @@ -15,6 +15,8 @@ from collections.abc import Callable from dataclasses import dataclass from typing import Annotated, Any, Literal, get_args, get_origin, get_type_hints +from loguru import logger + @dataclass class Tool: @@ -128,7 +130,8 @@ def tool(func: Callable[..., Any]) -> Tool: # Get type hints (with extras for Annotated) try: hints = get_type_hints(func, include_extras=True) - except Exception: + except Exception as e: + logger.warning(f"Failed to get type hints for function {func.__name__}: {e}") hints = {} # Build JSON Schema for parameters diff --git a/src/flow/tools/browsing.py b/src/flow/tools/browsing.py index 61dc78c93fb7fc69c6fedccd557c55d8e43bcead..a6db358a39c54e12f42aa8ba6926514cf9f73c77 100644 --- a/src/flow/tools/browsing.py +++ b/src/flow/tools/browsing.py @@ -26,7 +26,10 @@ def create_smol_web_search_tool(max_results: int = 10, engine: str = "duckduckgo """ logger.info("Performing web search for query: {}", query) tool = WebSearchTool(max_results=max_results, engine=engine) - return tool.forward(query=query) + output = tool.forward(query=query) + logger.debug("Web search output length: {}", len(output)) + logger.debug("Web search output first 200 chars: {}", output[:200] if len(output) > 200 else output) + return output return smol_web_search @@ -39,7 +42,11 @@ def wikipedia_search( """Searches Wikipedia and returns a summary or full text of the given topic, along with the page URL.""" logger.info("Performing wikipedia search for query: {}", query) tool = WikipediaSearchTool(language=language) - return tool.forward(query=query) + output = tool.forward(query=query) + logger.debug("Wikipedia search output length: {}", len(output)) + logger.debug("Wikipedia search output first 200 chars: {}", output[:200] if len(output) > 200 else output) + return output + def create_visit_webpage_tool(max_output_length: int = 40000) -> Tool: """Create a tool for visiting webpages and reading their content as markdown. @@ -59,7 +66,10 @@ def create_visit_webpage_tool(max_output_length: int = 40000) -> Tool: """Visits a webpage at the given url and reads its content as a markdown string. Use this to browse webpages.""" logger.info("Visiting webpage at URL: {}", url) tool = VisitWebpageTool(max_output_length=max_output_length) - return tool.forward(url=url) + output = tool.forward(url=url) + logger.debug("Visit webpage output length: {}", len(output)) + logger.debug("Visit webpage output first 200 chars: {}", output[:200] if len(output) > 200 else output) + return output return visit_webpage diff --git a/src/flow/tools/coding.py b/src/flow/tools/coding.py index a75d425d7a88890d36b95e7e8cce2e51ffcbd4b8..d3ad8787b454cb5a067221b9500115f06ad612b0 100644 --- a/src/flow/tools/coding.py +++ b/src/flow/tools/coding.py @@ -8,6 +8,8 @@ import re from pathlib import Path from typing import Annotated +from loguru import logger + from .base import tool from .workspace import get_workspace @@ -35,13 +37,16 @@ def read_file( Returns the file content with line numbers for easy reference. """ + logger.debug(f"read_file: path={path}, offset={offset}, limit={limit}") try: path_obj = _resolve_path(path) if not path_obj.exists(): + logger.warning(f"read_file: file not found: {path}") return f"Error: File not found: {path}" if not path_obj.is_file(): + logger.warning(f"read_file: not a file: {path}") return f"Error: Not a file: {path}" with open(path_obj, encoding="utf-8", errors="replace") as f: @@ -66,9 +71,11 @@ def read_file( if start > 0 or end < total_lines: result += f"\n\n[Showing lines {start + 1}-{end} of {total_lines}]" + logger.debug(f"read_file: read {end - start} lines from {path}") return result except Exception as e: + logger.warning(f"read_file: error reading {path}: {e}") return f"Error reading file: {e!s}" @@ -83,6 +90,7 @@ def write_file( Use this to create new files or completely replace file contents. For partial edits, use edit_file instead. """ + logger.info(f"write_file: writing to {path}") try: path_obj = _resolve_path(path) @@ -95,9 +103,11 @@ def write_file( # Count lines for feedback line_count = content.count("\n") + (1 if content and not content.endswith("\n") else 0) + logger.debug(f"write_file: wrote {len(content)} chars ({line_count} lines) to {path}") return f"Successfully wrote {len(content)} characters ({line_count} lines) to {path}" except Exception as e: + logger.warning(f"write_file: error writing to {path}: {e}") return f"Error writing file: {e!s}" @@ -112,10 +122,12 @@ def edit_file( The old_string must appear exactly once in the file. For multiple replacements, call this tool multiple times. """ + logger.info(f"edit_file: editing {path}") try: path_obj = _resolve_path(path) if not path_obj.exists(): + logger.warning(f"edit_file: file not found: {path}") return f"Error: File not found: {path}" with open(path_obj, encoding="utf-8") as f: @@ -125,9 +137,11 @@ def edit_file( count = content.count(old_string) if count == 0: + logger.warning(f"edit_file: text not found in {path}") return f"Error: Could not find the specified text in {path}" if count > 1: + logger.warning(f"edit_file: found {count} occurrences in {path}, expected 1") return f"Error: Found {count} occurrences of the text. Please provide more context to make it unique." # Perform replacement @@ -136,9 +150,11 @@ def edit_file( with open(path_obj, "w", encoding="utf-8") as f: f.write(new_content) + logger.debug(f"edit_file: successfully edited {path}") return f"Successfully edited {path}" except Exception as e: + logger.warning(f"edit_file: error editing {path}: {e}") return f"Error editing file: {e!s}" @@ -152,13 +168,16 @@ def glob_files( Returns a list of matching file paths, sorted by modification time (newest first). """ + logger.debug(f"glob_files: pattern={pattern}, path={path}, limit={limit}") try: base_path = _resolve_path(path) if not base_path.exists(): + logger.warning(f"glob_files: directory not found: {path}") return f"Error: Directory not found: {path}" if not base_path.is_dir(): + logger.warning(f"glob_files: not a directory: {path}") return f"Error: Not a directory: {path}" # Find matching files @@ -188,9 +207,11 @@ def glob_files( if len(matches) > limit: result += f"\n\n[Showing {limit} of {len(matches)} matches]" + logger.debug(f"glob_files: found {len(files)} files matching '{pattern}'") return result except Exception as e: + logger.warning(f"glob_files: error searching: {e}") return f"Error searching files: {e!s}" @@ -206,6 +227,7 @@ def grep( Returns matching lines with file paths and line numbers. """ + logger.debug(f"grep: pattern='{pattern}', path={path}, include={include}") try: base_path = _resolve_path(path) regex = re.compile(pattern) @@ -216,10 +238,7 @@ def grep( files = [base_path] else: # Find files matching include pattern - files = [ - p for p in base_path.rglob("*") - if p.is_file() and fnmatch.fnmatch(p.name, include) - ] + files = [p for p in base_path.rglob("*") if p.is_file() and fnmatch.fnmatch(p.name, include)] for file_path in files: try: @@ -247,13 +266,15 @@ def grep( if len(matches) >= limit: break - except Exception: + except Exception as e: + logger.debug(f"grep: skipping unreadable file {file_path}: {e}") continue # Skip files that can't be read if len(matches) >= limit: break if not matches: + logger.debug(f"grep: no matches found for pattern '{pattern}'") return f"No matches found for pattern: {pattern}" result = "\n\n".join(matches) @@ -261,11 +282,14 @@ def grep( if len(matches) >= limit: result += f"\n\n[Results limited to {limit} matches]" + logger.debug(f"grep: found {len(matches)} matches for pattern '{pattern}'") return result except re.error as e: + logger.warning(f"grep: invalid regex '{pattern}': {e}") return f"Error: Invalid regex pattern: {e!s}" except Exception as e: + logger.warning(f"grep: error searching: {e}") return f"Error searching: {e!s}" @@ -279,13 +303,16 @@ def ls( Returns a formatted listing of directory contents. """ + logger.debug(f"ls: path={path}, show_hidden={show_hidden}, long_format={long_format}") try: dir_path = _resolve_path(path) if not dir_path.exists(): + logger.warning(f"ls: path not found: {path}") return f"Error: Path not found: {path}" if not dir_path.is_dir(): + logger.warning(f"ls: not a directory: {path}") return f"Error: Not a directory: {path}" entries = list(dir_path.iterdir()) @@ -309,27 +336,31 @@ def ls( if size < 1024: size_str = f"{size:>6}B" elif size < 1024 * 1024: - size_str = f"{size/1024:>6.1f}K" + size_str = f"{size / 1024:>6.1f}K" else: - size_str = f"{size/(1024*1024):>6.1f}M" + size_str = f"{size / (1024 * 1024):>6.1f}M" # Format time from datetime import datetime + mtime = datetime.fromtimestamp(stat.st_mtime) time_str = mtime.strftime("%Y-%m-%d %H:%M") type_char = "d" if entry.is_dir() else "-" name = entry.name + ("/" if entry.is_dir() else "") output_lines.append(f"{type_char} {size_str} {time_str} {name}") - except Exception: + except Exception as e: + logger.debug(f"ls: failed to stat entry {entry.name}: {e}") output_lines.append(entry.name) else: name = entry.name + ("/" if entry.is_dir() else "") output_lines.append(name) + logger.debug(f"ls: listed {len(output_lines)} entries in {path}") return "\n".join(output_lines) except Exception as e: + logger.warning(f"ls: error listing {path}: {e}") return f"Error listing directory: {e!s}" @@ -346,10 +377,12 @@ def multi_edit( Edits are applied sequentially, so later edits see the result of earlier ones. """ + logger.info(f"multi_edit: applying {len(edits)} edits to {path}") try: path_obj = _resolve_path(path) if not path_obj.exists(): + logger.warning(f"multi_edit: file not found: {path}") return f"Error: File not found: {path}" with open(path_obj, encoding="utf-8") as f: @@ -358,7 +391,7 @@ def multi_edit( # Validate all edits first for i, edit in enumerate(edits): if "old_string" not in edit or "new_string" not in edit: - return f"Error: Edit {i+1} missing 'old_string' or 'new_string'" + return f"Error: Edit {i + 1} missing 'old_string' or 'new_string'" # Apply edits sequentially applied: list[str] = [] @@ -371,26 +404,28 @@ def multi_edit( if count == 0: # Rollback - restore original return ( - f"Error: Edit {i+1} failed - could not find text.\n" + f"Error: Edit {i + 1} failed - could not find text.\n" f"Applied {len(applied)} edit(s) before failure.\n" f"File unchanged (atomic rollback)." ) if count > 1: return ( - f"Error: Edit {i+1} failed - found {count} occurrences.\n" + f"Error: Edit {i + 1} failed - found {count} occurrences.\n" f"Applied {len(applied)} edit(s) before failure.\n" f"File unchanged (atomic rollback)." ) content = content.replace(old_str, new_str, 1) - applied.append(f"Edit {i+1}: replaced {len(old_str)} chars with {len(new_str)} chars") + applied.append(f"Edit {i + 1}: replaced {len(old_str)} chars with {len(new_str)} chars") # All edits succeeded - write the file with open(path_obj, "w", encoding="utf-8") as f: f.write(content) + logger.debug(f"multi_edit: successfully applied {len(edits)} edits to {path}") return f"Successfully applied {len(edits)} edit(s) to {path}:\n" + "\n".join(applied) except Exception as e: + logger.warning(f"multi_edit: error editing {path}: {e}") return f"Error editing file: {e!s}" diff --git a/src/flow/tools/execution.py b/src/flow/tools/execution.py index 2be6724ddaa14ca76282ace91d0b81673ca0ee35..24840f37eb27499b59ccd0bf3357dc12bd6f323f 100644 --- a/src/flow/tools/execution.py +++ b/src/flow/tools/execution.py @@ -6,6 +6,8 @@ Execute shell commands and manage processes. import subprocess from typing import Annotated +from loguru import logger + from .base import tool from .workspace import get_workspace @@ -21,6 +23,8 @@ def bash( Use this to run shell commands, scripts, or system utilities. Be careful with destructive commands. """ + logger.info(f"bash: executing command (timeout={timeout}s, cwd={cwd})") + logger.debug(f"bash: command={command[:200] if len(command) > 200 else command}") try: # Default to workspace root so concurrent tasks don't share process cwd effective_cwd = cwd if cwd is not None else str(get_workspace().root) @@ -40,13 +44,18 @@ def bash( output += result.stderr if result.returncode != 0: + logger.debug(f"bash: command exited with code {result.returncode}") output += f"\n[Exit code: {result.returncode}]" + else: + logger.debug("bash: command completed successfully") return output.strip() if output else "(No output)" except subprocess.TimeoutExpired: + logger.warning(f"bash: command timed out after {timeout}s") return f"Error: Command timed out after {timeout} seconds" except Exception as e: + logger.warning(f"bash: error executing command: {e}") return f"Error executing command: {e!s}" @@ -64,6 +73,8 @@ def check_processes( import os import signal + logger.debug(f"check_processes: action={action}, pid={pid}") + if action == "list": try: # Use ps to list processes @@ -73,8 +84,10 @@ def check_processes( text=True, timeout=10, ) + logger.debug("check_processes: listed processes") return result.stdout if result.stdout else "No processes found" except Exception as e: + logger.warning(f"check_processes: error listing: {e}") return f"Error listing processes: {e!s}" elif action == "kill": @@ -82,14 +95,17 @@ def check_processes( return "Error: PID required for 'kill' action" try: os.kill(pid, signal.SIGTERM) + logger.info(f"check_processes: sent SIGTERM to pid {pid}") return f"Sent SIGTERM to process {pid}" except ProcessLookupError: + logger.warning(f"check_processes: process {pid} not found") return f"Error: Process {pid} not found" except PermissionError: + logger.warning(f"check_processes: permission denied for pid {pid}") return f"Error: Permission denied to kill process {pid}" except Exception as e: + logger.warning(f"check_processes: error killing {pid}: {e}") return f"Error killing process: {e!s}" else: return f"Unknown action: {action}. Use 'list' or 'kill'." - diff --git a/src/flow/tools/memory.py b/src/flow/tools/memory.py index 37a05c4cb0c24bd4a4925395bd7ee6fcc4acf84d..16075ccf5bac45cf39898fffa599aa8234db35eb 100644 --- a/src/flow/tools/memory.py +++ b/src/flow/tools/memory.py @@ -24,6 +24,8 @@ import uuid from datetime import datetime from typing import Annotated, Any, Literal +from loguru import logger + from .base import Tool, tool from .workspace import Workspace, get_workspace @@ -76,6 +78,7 @@ def create_memory_tool(workspace: Workspace | None = None) -> Tool: Returns: A Tool instance for memory operations. """ + def get_ws() -> Workspace: if workspace is not None: return workspace @@ -85,20 +88,13 @@ def create_memory_tool(workspace: Workspace | None = None) -> Tool: def memory( action: Annotated[ Literal["store", "recall", "list", "forget"], - "Action: store (save), recall (search), list (show all), forget (delete)" + "Action: store (save), recall (search), list (show all), forget (delete)", ], content: Annotated[ - str, - "For 'store': info to remember. For 'recall': search query. For 'forget': memory ID." - ] = "", - key: Annotated[ - str, - "Optional short identifier (e.g., 'user_preferences', 'project_structure')" + str, "For 'store': info to remember. For 'recall': search query. For 'forget': memory ID." ] = "", - tags: Annotated[ - list[str], - "Optional tags for categorization (e.g., ['important', 'user-info'])" - ] = [], + key: Annotated[str, "Optional short identifier (e.g., 'user_preferences', 'project_structure')"] = "", + tags: Annotated[list[str], "Optional tags for categorization (e.g., ['important', 'user-info'])"] = [], ) -> str: """Store and retrieve information across sessions. @@ -132,38 +128,44 @@ def create_memory_tool(workspace: Workspace | None = None) -> Tool: } ws.save_memory(memory_id, data) + logger.info(f"memory: stored '{data['key']}' (id: {memory_id}) with {len(content)} chars") return f"Stored memory '{data['key']}' (id: {memory_id}) in {ws.memory_dir}" elif action == "recall": if not content: return "Error: content (search query) is required for 'recall' action" + logger.debug(f"memory: recalling with query '{content}'") results = _search_memories(ws, content) if not results: + logger.debug(f"memory: no matches found for '{content}'") return f"No memories found matching '{content}'" output = [f"Found {len(results)} memory(ies) matching '{content}':\n"] for mem in results: tags_str = f" [{', '.join(mem['tags'])}]" if mem.get("tags") else "" output.append(f"- [{mem['id']}] {mem['key']}{tags_str}: {mem['content'][:200]}") - if len(mem['content']) > 200: + if len(mem["content"]) > 200: output[-1] += "..." + logger.debug(f"memory: found {len(results)} memories matching '{content}'") return "\n".join(output) elif action == "list": memories = ws.list_memories() if not memories: + logger.debug("memory: no memories stored") return f"No memories stored in {ws.memory_dir}" output = [f"Stored memories ({len(memories)} total):\n"] for mem in sorted(memories, key=lambda m: m.get("created_at", ""), reverse=True): tags_str = f" [{', '.join(mem['tags'])}]" if mem.get("tags") else "" - preview = mem['content'][:100] + "..." if len(mem['content']) > 100 else mem['content'] + preview = mem["content"][:100] + "..." if len(mem["content"]) > 100 else mem["content"] output.append(f"- [{mem['id']}] {mem['key']}{tags_str}: {preview}") + logger.debug(f"memory: listed {len(memories)} memories") return "\n".join(output) elif action == "forget": @@ -171,8 +173,10 @@ def create_memory_tool(workspace: Workspace | None = None) -> Tool: return "Error: content (memory ID) is required for 'forget' action" if ws.delete_memory(content): + logger.info(f"memory: deleted memory with id '{content}'") return f"Deleted memory with id: {content}" else: + logger.warning(f"memory: no memory found with id '{content}'") return f"No memory found with id: {content}" else: diff --git a/src/flow/tools/notebook.py b/src/flow/tools/notebook.py index 29e081aa282be174a1a8fe67c88ba4323c59b3ac..96b42cb3f3a61e4c8d956d41dd685b522f804293 100644 --- a/src/flow/tools/notebook.py +++ b/src/flow/tools/notebook.py @@ -7,6 +7,8 @@ import json from pathlib import Path from typing import Annotated, Any, Literal +from loguru import logger + from .base import tool @@ -27,13 +29,16 @@ def notebook_edit( For insert mode, cell_type is required. """ + logger.info(f"notebook_edit: {edit_mode} cell at index {cell_index} in {path}") try: path_obj = Path(path).expanduser().resolve() if not path_obj.exists(): + logger.warning(f"notebook_edit: notebook not found: {path}") return f"Error: Notebook not found: {path}" if not path_obj.suffix == ".ipynb": + logger.warning(f"notebook_edit: not a notebook file: {path}") return f"Error: Not a Jupyter notebook (must be .ipynb): {path}" # Read notebook @@ -53,6 +58,7 @@ def notebook_edit( with open(path_obj, "w", encoding="utf-8") as f: json.dump(notebook, f, indent=1) + logger.debug(f"notebook_edit: deleted {deleted_type} cell at index {cell_index}") return f"Successfully deleted {deleted_type} cell at index {cell_index}" elif edit_mode == "insert": @@ -79,6 +85,7 @@ def notebook_edit( with open(path_obj, "w", encoding="utf-8") as f: json.dump(notebook, f, indent=1) + logger.debug(f"notebook_edit: inserted {cell_type} cell at index {cell_index}") return f"Successfully inserted {cell_type} cell at index {cell_index}" else: # replace @@ -107,11 +114,14 @@ def notebook_edit( with open(path_obj, "w", encoding="utf-8") as f: json.dump(notebook, f, indent=1) + logger.debug(f"notebook_edit: replaced cell at index {cell_index}") return f"Successfully replaced cell at index {cell_index}" except json.JSONDecodeError as e: + logger.warning(f"notebook_edit: invalid JSON in {path}: {e}") return f"Error: Invalid notebook JSON: {e!s}" except Exception as e: + logger.warning(f"notebook_edit: error editing {path}: {e}") return f"Error editing notebook: {e!s}" @@ -125,13 +135,16 @@ def notebook_read( Returns formatted cell contents with indices for easy reference. """ + logger.debug(f"notebook_read: path={path}, cell_index={cell_index}, include_outputs={include_outputs}") try: path_obj = Path(path).expanduser().resolve() if not path_obj.exists(): + logger.warning(f"notebook_read: notebook not found: {path}") return f"Error: Notebook not found: {path}" if not path_obj.suffix == ".ipynb": + logger.warning(f"notebook_read: not a notebook file: {path}") return f"Error: Not a Jupyter notebook (must be .ipynb): {path}" with open(path_obj, encoding="utf-8") as f: @@ -179,7 +192,11 @@ def notebook_read( data = output.get("data", {}) if isinstance(data, dict) and "text/plain" in data: plain_data = data["text/plain"] - text = "".join(str(t) for t in plain_data) if isinstance(plain_data, list) else str(plain_data) + text = ( + "".join(str(t) for t in plain_data) + if isinstance(plain_data, list) + else str(plain_data) + ) output_texts.append(f"[result]\n{text}") elif output.get("output_type") == "error": ename = str(output.get("ename", "Error")) @@ -195,9 +212,12 @@ def notebook_read( if cell_index is None: result = f"Notebook: {path} ({len(notebook.get('cells', []))} cells)\n\n" + result + logger.debug(f"notebook_read: read {len(cells_list)} cells from {path}") return result except json.JSONDecodeError as e: + logger.warning(f"notebook_read: invalid JSON in {path}: {e}") return f"Error: Invalid notebook JSON: {e!s}" except Exception as e: + logger.warning(f"notebook_read: error reading {path}: {e}") return f"Error reading notebook: {e!s}" diff --git a/src/flow/tools/planning.py b/src/flow/tools/planning.py index f4a0b4dce9cade9d0bc0083d15dcae8f69130a61..6cbc830a0bf6e46dee2cb6553581363209d5e5cb 100644 --- a/src/flow/tools/planning.py +++ b/src/flow/tools/planning.py @@ -6,6 +6,8 @@ Todos are persisted to the workspace's .flow/todos.json file. from typing import Annotated, Any +from loguru import logger + from .base import tool from .workspace import Workspace, get_workspace @@ -34,6 +36,7 @@ def think( Your thought is recorded in conversation history for reference. """ + logger.debug(f"think: recording thought ({len(thought)} chars)") # The thought is recorded in the tool result, becoming part of context return "Thought recorded." @@ -42,7 +45,7 @@ def think( def todo_write( todos: Annotated[ list[dict[str, Any]], - "List of todo items. Each item needs: content (str), status ('pending'|'in_progress'|'completed'), activeForm (str describing current action)" + "List of todo items. Each item needs: content (str), status ('pending'|'in_progress'|'completed'), activeForm (str describing current action)", ], ) -> str: """Create or update the task list for this session. @@ -75,17 +78,18 @@ def todo_write( valid_statuses = {"pending", "in_progress", "completed"} for i, todo in enumerate(todos): if "content" not in todo: - return f"Error: Todo {i+1} missing 'content'" + return f"Error: Todo {i + 1} missing 'content'" if "status" not in todo: - return f"Error: Todo {i+1} missing 'status'" + return f"Error: Todo {i + 1} missing 'status'" if todo["status"] not in valid_statuses: - return f"Error: Todo {i+1} has invalid status '{todo['status']}'. Must be: {valid_statuses}" + return f"Error: Todo {i + 1} has invalid status '{todo['status']}'. Must be: {valid_statuses}" if "activeForm" not in todo: - return f"Error: Todo {i+1} missing 'activeForm'" + return f"Error: Todo {i + 1} missing 'activeForm'" # Check only one in_progress in_progress_count = sum(1 for t in todos if t["status"] == "in_progress") if in_progress_count > 1: + logger.warning(f"todo_write: {in_progress_count} tasks marked in_progress, should be 1") return f"Error: {in_progress_count} tasks marked 'in_progress'. Only one task should be in progress at a time." # Save to workspace @@ -100,6 +104,7 @@ def todo_write( current = next((t for t in todos if t["status"] == "in_progress"), None) current_msg = f"Current: {current['activeForm']}" if current else "No task in progress" + logger.info(f"todo_write: updated ({completed} completed, {in_progress} in progress, {pending} pending)") return f"Todo list updated: {completed} completed, {in_progress} in progress, {pending} pending. {current_msg}" @@ -110,10 +115,12 @@ def todo_read() -> str: Returns the current state of all tasks with their status. Todos are loaded from {workspace}/.flow/todos.json """ + logger.debug("todo_read: loading todos") ws = _get_workspace() todos = ws.load_todos() if not todos: + logger.debug("todo_read: no todos found") return "No todos. Use todo_write to create a task list." lines: list[str] = [] @@ -133,6 +140,7 @@ def todo_read() -> str: completed = sum(1 for t in todos if t["status"] == "completed") total = len(todos) + logger.debug(f"todo_read: loaded {total} todos ({completed} completed)") return f"Progress: {completed}/{total}\n\n" + "\n".join(lines) diff --git a/src/flow/tools/skills.py b/src/flow/tools/skills.py index f37b6b480ab66e8ba82501cfc50dfe65eee94fed..a8d3768f98d260635921e0196510cde7fe6cfe81 100644 --- a/src/flow/tools/skills.py +++ b/src/flow/tools/skills.py @@ -26,7 +26,9 @@ Usage: import re from pathlib import Path -from typing import Annotated, Literal +from typing import Annotated, Any, Literal + +from loguru import logger from .base import Tool, tool @@ -88,8 +90,9 @@ def _discover_skills(skills_paths: list[Path]) -> dict[str, tuple[Path, dict[str meta = _parse_frontmatter(content) skill_name = meta.get("name", item.name) skills[skill_name] = (skill_md, meta) - except Exception: - # Skip broken skills + except Exception as e: + # Skip broken skills but log the error + logger.debug(f"Failed to load skill '{item.name}': {e}") skills[item.name] = ( skill_md, {"name": item.name, "description": "Error reading skill"}, @@ -113,6 +116,7 @@ def create_skills_tool( builtin_path: Path | None = None, user_path: Path | None = None, project_path: Path | None = None, + exclusive: bool = False, ) -> Tool: """Create a skills tool for discovering and loading domain expertise. @@ -120,6 +124,8 @@ def create_skills_tool( builtin_path: Path to built-in skills (shipped with package) user_path: Path to user skills (defaults to ~/.flow/skills/) project_path: Path to project-local skills (highest priority) + exclusive: If True, only use explicitly provided paths (no defaults). + Useful for optimization where you want a clean slate. Returns: A Tool that can be added to an agent's tool list @@ -138,7 +144,7 @@ def create_skills_tool( # Built-in skills if builtin_path: all_paths.append(builtin_path) - else: + elif not exclusive: default_builtin = _get_builtin_skills_path() if default_builtin.exists(): all_paths.append(default_builtin) @@ -146,7 +152,7 @@ def create_skills_tool( # User skills if user_path: all_paths.append(user_path) - else: + elif not exclusive: default_user = _get_user_skills_path() if default_user.exists(): all_paths.append(default_user) @@ -177,6 +183,7 @@ def create_skills_tool( discovered = _discover_skills(all_paths) if action == "list": + logger.debug(f"skills: listing {len(discovered)} discovered skills") if not discovered: paths_str = "\n".join(f" - {p}" for p in all_paths) if all_paths else " (no paths configured)" return ( @@ -210,6 +217,7 @@ def create_skills_tool( return "Error: 'name' parameter is required for 'load' action." if name not in discovered: + logger.warning(f"skills: skill '{name}' not found") available = sorted(discovered.keys()) msg = f"Skill '{name}' not found." if available: @@ -223,8 +231,10 @@ def create_skills_tool( # Return full content (body only, frontmatter already parsed) body = _get_skill_body(content) + logger.info(f"skills: loaded skill '{skill_name}' ({len(body)} chars)") return f"# Skill: {skill_name}\n\n{body}" except Exception as e: + logger.warning(f"skills: error loading skill '{name}': {e}") return f"Error loading skill '{name}': {e}" else: @@ -233,5 +243,61 @@ def create_skills_tool( return skills +def discover_skills_from_tools_spec( + tools_spec: dict[str, dict[str, Any]], +) -> dict[str, dict[str, str]]: + """Discover available skills based on a resolved tools specification. + + Extracts skill metadata (name, description, triggers) from the same + paths that the skills tool would use. Returns a lightweight dict + suitable for injecting into the system prompt. + + Args: + tools_spec: Resolved tools specification dict (from resolve_tools()). + Looks for a ``"skills"`` key with optional ``skills_path``, + ``additional_paths``, or ``exclusive`` config. + + Returns: + Dict mapping skill_name -> frontmatter metadata dict + (keys: ``name``, ``description``, ``triggers``). + Returns empty dict if no skills tool is configured. + """ + if "skills" not in tools_spec: + return {} + + config = tools_spec.get("skills", {}) + exclusive = bool(config.get("skills_path")) # skills_path implies exclusive + + # Build the same paths that create_skills_tool would use + all_paths: list[Path] = [] + + if config.get("skills_path"): + all_paths.append(Path(config["skills_path"])) + elif not exclusive: + default_builtin = _get_builtin_skills_path() + if default_builtin.exists(): + all_paths.append(default_builtin) + + if not exclusive: + default_user = _get_user_skills_path() + if default_user.exists(): + all_paths.append(default_user) + + if config.get("additional_paths"): + for p in config["additional_paths"]: + all_paths.append(Path(p)) + + if config.get("project_path"): + all_paths.append(Path(config["project_path"])) + + discovered = _discover_skills(all_paths) + + # Return metadata only (strip file paths) + return { + skill_name: dict(meta) + for skill_name, (_, meta) in discovered.items() + } + + # Default skills tool (includes built-in skills from Flow) skills = create_skills_tool() diff --git a/src/flow/tools/subagent.py b/src/flow/tools/subagent.py index 77e0def0d6210e5d1d5e603a97b873d6cc693936..2a8e48de7bb3e9409c1ab27f5e76819f49af04b0 100644 --- a/src/flow/tools/subagent.py +++ b/src/flow/tools/subagent.py @@ -16,6 +16,8 @@ from __future__ import annotations from typing import TYPE_CHECKING, Annotated, Literal +from loguru import logger + from .base import Tool, tool if TYPE_CHECKING: @@ -118,7 +120,7 @@ def create_task_tool( description: Annotated[str, "Short 3-5 word summary of what the sub-agent will do"], agent_type: Annotated[ Literal["explore", "research", "general"], - "Type of sub-agent: 'explore' for codebase search, 'research' for web research, 'general' for other tasks" + "Type of sub-agent: 'explore' for codebase search, 'research' for web research, 'general' for other tasks", ] = "general", ) -> str: """Launch a sub-agent to handle a complex task in isolated context. @@ -139,12 +141,16 @@ def create_task_tool( - research: Web research (web_search, web_fetch) - general: All tools available to you """ + logger.info(f"task: spawning {agent_type} sub-agent for '{description}'") + logger.debug(f"task: prompt preview={prompt[:200] if len(prompt) > 200 else prompt}") + # Lazy imports to avoid circular dependencies try: from flow.harness.miniagent.agent import ChatAgent from flow.harness.miniagent.client import ChatClient, ClientConfig from flow.harness.miniagent.context import HeadTailStrategy except ImportError: + logger.error("task: MiniAgent harness not available") return "Error: MiniAgent harness not available. Install flow with miniagent extras." # Get agent type config @@ -222,9 +228,13 @@ def create_task_tool( f"{response.usage.tool_calls} tool calls]" ) + logger.debug( + f"task: sub-agent completed - {response.iterations} iterations, {response.usage.tool_calls} tool calls" + ) return result + usage_info except Exception as e: + logger.warning(f"task: sub-agent failed: {e}") return f"Sub-agent failed: {e!s}" return task diff --git a/src/flow/tools/text_inspector_qa.py b/src/flow/tools/text_inspector_qa.py index c03e2e49d6bad717dfa6715b81e996018544875a..284848b64fd0caf1d2a3dfcbc6b952c3eb6adfbe 100644 --- a/src/flow/tools/text_inspector_qa.py +++ b/src/flow/tools/text_inspector_qa.py @@ -191,4 +191,7 @@ def text_inspector( """ logger.info("Inspecting file at path: {}", file_path) ti_tool = TextInspectorTool() - return ti_tool.forward(file_path=file_path, question=question) + output = ti_tool.forward(file_path=file_path, question=question) + logger.debug("Text inspector output length: {}", len(output)) + logger.debug("Text inspector output first 200 chars: {}", output[:200] if len(output) > 200 else output) + return output diff --git a/src/flow/tools/web.py b/src/flow/tools/web.py index 902c4f4f538660614e9e85c4bb76a93c0919572a..da413548d4a31f76df59eae32a17336a72a2a8de 100644 --- a/src/flow/tools/web.py +++ b/src/flow/tools/web.py @@ -7,6 +7,8 @@ import os from typing import Annotated from urllib.parse import urlparse +from loguru import logger + from .base import tool @@ -20,10 +22,12 @@ def web_search( Requires GOOGLE_API_KEY and GOOGLE_CSE_ID environment variables. Returns a list of search results with titles, URLs, and snippets. """ + logger.info(f"web_search: searching for '{query}' (num_results={num_results})") api_key = os.environ.get("GOOGLE_API_KEY") cse_id = os.environ.get("GOOGLE_CSE_ID") if not api_key or not cse_id: + logger.warning("web_search: missing API credentials") return ( "Error: Web search requires GOOGLE_API_KEY and GOOGLE_CSE_ID " "environment variables to be set." @@ -32,6 +36,7 @@ def web_search( try: import httpx except ImportError: + logger.warning("web_search: httpx package not installed") return "Error: httpx package required. Install with: pip install httpx" try: @@ -51,6 +56,7 @@ def web_search( items = data.get("items", []) if not items: + logger.debug(f"web_search: no results for '{query}'") return f"No results found for: {query}" results: list[str] = [] @@ -60,9 +66,11 @@ def web_search( snippet = item.get("snippet", "No description") results.append(f"{i}. {title}\n {link}\n {snippet}") + logger.debug(f"web_search: found {len(items)} results for '{query}'") return "\n\n".join(results) except Exception as e: + logger.warning(f"web_search: error searching: {e}") return f"Error performing search: {e!s}" @@ -77,6 +85,7 @@ def web_fetch( Returns the page content in the specified format. Useful for reading documentation, articles, and web pages. """ + logger.info(f"web_fetch: fetching {url}") # Validate URL try: parsed = urlparse(url) @@ -84,13 +93,16 @@ def web_fetch( url = "https://" + url parsed = urlparse(url) if not parsed.netloc: + logger.warning(f"web_fetch: invalid URL: {url}") return f"Error: Invalid URL: {url}" - except Exception: + except Exception as e: + logger.warning(f"web_fetch: invalid URL format: {url}: {e}") return f"Error: Invalid URL format: {url}" try: import httpx except ImportError: + logger.warning("web_fetch: httpx package not installed") return "Error: httpx package required. Install with: pip install httpx" try: @@ -139,7 +151,9 @@ def web_fetch( if len(content) > max_length: content = content[:max_length] + "\n\n[Content truncated...]" + logger.debug(f"web_fetch: fetched {len(content)} chars from {url}") return content except Exception as e: + logger.warning(f"web_fetch: error fetching {url}: {e}") return f"Error fetching URL: {e!s}" diff --git a/src/flow/tools/workspace.py b/src/flow/tools/workspace.py index c88f3b21a10c4ae5eb2097ebe415eb90b6fd955f..f4f6dfc8412c95e6d69ecad4c7188220b57857ee 100644 --- a/src/flow/tools/workspace.py +++ b/src/flow/tools/workspace.py @@ -36,6 +36,8 @@ import json from pathlib import Path from typing import Any +from loguru import logger + class Workspace: """Manages workspace paths and agent data storage. @@ -53,6 +55,7 @@ class Workspace: if root is None: root = Path.cwd() self._root = Path(root).resolve() + logger.debug(f"Workspace initialized at {self._root}") @property def root(self) -> Path: @@ -97,8 +100,11 @@ class Workspace: return [] try: with open(self.todos_file) as f: - return json.load(f) # type: ignore[no-any-return] - except (OSError, json.JSONDecodeError): + todos = json.load(f) + logger.debug(f"Loaded {len(todos)} todos from {self.todos_file}") + return todos # type: ignore[no-any-return] + except (OSError, json.JSONDecodeError) as e: + logger.warning(f"Failed to load todos: {e}") return [] def save_todos(self, todos: list[dict[str, Any]]) -> None: @@ -106,6 +112,7 @@ class Workspace: self.ensure_data_dir() with open(self.todos_file, "w") as f: json.dump(todos, f, indent=2) + logger.debug(f"Saved {len(todos)} todos to {self.todos_file}") # --- Memory --- @@ -119,8 +126,10 @@ class Workspace: try: with open(filepath) as f: memories.append(json.load(f)) - except (OSError, json.JSONDecodeError): + except (OSError, json.JSONDecodeError) as e: + logger.debug(f"Failed to load memory {filepath}: {e}") continue + logger.debug(f"Listed {len(memories)} memories from {self.memory_dir}") return memories def load_memory(self, memory_id: str) -> dict[str, Any] | None: @@ -131,7 +140,8 @@ class Workspace: try: with open(filepath) as f: return json.load(f) # type: ignore[no-any-return] - except (OSError, json.JSONDecodeError): + except (OSError, json.JSONDecodeError) as e: + logger.debug(f"Failed to load memory '{memory_id}': {e}") return None def save_memory(self, memory_id: str, data: dict[str, Any]) -> None: @@ -140,12 +150,14 @@ class Workspace: filepath = self.memory_dir / f"{memory_id}.json" with open(filepath, "w") as f: json.dump(data, f, indent=2, default=str) + logger.debug(f"Saved memory '{memory_id}' to {filepath}") def delete_memory(self, memory_id: str) -> bool: """Delete a memory entry. Returns True if deleted.""" filepath = self.memory_dir / f"{memory_id}.json" if filepath.exists(): filepath.unlink() + logger.debug(f"Deleted memory '{memory_id}'") return True return False @@ -158,7 +170,8 @@ class Workspace: try: with open(self.config_file) as f: return json.load(f) - except (OSError, json.JSONDecodeError): + except (OSError, json.JSONDecodeError) as e: + logger.debug(f"Failed to load config: {e}") return {} def save_config(self, config: dict[str, Any]) -> None: diff --git a/src/flow/ui/api/__init__.py b/src/flow/ui/api/__init__.py index fc2665a3121468f958846bf147a54fc6de51e7e8..2fb14663e8eac38afee3c4aa2d0131d99747b612 100644 --- a/src/flow/ui/api/__init__.py +++ b/src/flow/ui/api/__init__.py @@ -2,6 +2,7 @@ """API routes package.""" from .configs import router as configs_router +from .deployments import router as deployments_router from .evaluate import router as evaluate_router from .experiment import router as experiment_router from .jobs import router as jobs_router @@ -14,6 +15,7 @@ from .tools import router as tools_router __all__ = [ "configs_router", + "deployments_router", "evaluate_router", "experiment_router", "jobs_router", diff --git a/src/flow/ui/api/deployments.py b/src/flow/ui/api/deployments.py new file mode 100644 index 0000000000000000000000000000000000000000..1e2e968fedfc8d3a886370de0d771ba96c8ddae0 --- /dev/null +++ b/src/flow/ui/api/deployments.py @@ -0,0 +1,145 @@ +# Copyright (c) Microsoft. All rights reserved. +"""Deployment API routes.""" + +from typing import Annotated +from uuid import UUID + +from fastapi import APIRouter, Depends, HTTPException +from sqlalchemy.ext.asyncio import AsyncSession +from sqlmodel import desc, or_, select + +from ..auth import TokenData, get_current_user, get_effective_user_id, should_filter_by_user +from ..database import get_session +from ..models.deployment import Deployment, DeploymentVersion +from ..schemas.deployment import DeploymentDetailResponse, DeploymentResponse, DeploymentVersionResponse + +router = APIRouter(prefix="/deployments", tags=["deployments"]) + + +def _parse_uuid(id_str: str) -> UUID: + """Parse a string to UUID, raising 400 if invalid.""" + try: + return UUID(id_str) + except ValueError as e: + raise HTTPException(status_code=400, detail=f"Invalid UUID: {id_str}") from e + + +@router.get("", response_model=list[DeploymentResponse]) +async def list_deployments( + session: AsyncSession = Depends(get_session), + user: Annotated[TokenData | None, Depends(get_current_user)] = None, +) -> list[Deployment]: + """List all deployments.""" + query = select(Deployment) + + if should_filter_by_user(): + effective_user_id = get_effective_user_id(user) + query = query.where( + or_( + Deployment.user_id == effective_user_id, + Deployment.is_public == True, # noqa: E712 + ) + ) + + query = query.order_by(desc(Deployment.updated_at)) + result = await session.execute(query) + return list(result.scalars().all()) + + +@router.get("/{deployment_id}", response_model=DeploymentDetailResponse) +async def get_deployment( + deployment_id: str, + session: AsyncSession = Depends(get_session), + user: Annotated[TokenData | None, Depends(get_current_user)] = None, +) -> dict: + """Get a deployment with its version history.""" + uuid_id = _parse_uuid(deployment_id) + query = select(Deployment).where(Deployment.id == uuid_id) + + if should_filter_by_user(): + effective_user_id = get_effective_user_id(user) + query = query.where( + or_( + Deployment.is_public == True, # noqa: E712 + Deployment.user_id == effective_user_id, + ) + ) + + result = await session.execute(query) + deployment = result.scalar_one_or_none() + if not deployment: + raise HTTPException(status_code=404, detail="Deployment not found") + + # Fetch versions + versions_result = await session.execute( + select(DeploymentVersion) + .where(DeploymentVersion.deployment_id == uuid_id) + .order_by(desc(DeploymentVersion.version)) + ) + versions = list(versions_result.scalars().all()) + + return { + **deployment.__dict__, + "versions": versions, + } + + +@router.get("/{deployment_id}/versions", response_model=list[DeploymentVersionResponse]) +async def list_versions( + deployment_id: str, + session: AsyncSession = Depends(get_session), + user: Annotated[TokenData | None, Depends(get_current_user)] = None, +) -> list[DeploymentVersion]: + """List all versions of a deployment.""" + uuid_id = _parse_uuid(deployment_id) + + # Verify deployment exists and user has access + dep_query = select(Deployment).where(Deployment.id == uuid_id) + if should_filter_by_user(): + effective_user_id = get_effective_user_id(user) + dep_query = dep_query.where( + or_( + Deployment.is_public == True, # noqa: E712 + Deployment.user_id == effective_user_id, + ) + ) + dep_result = await session.execute(dep_query) + if not dep_result.scalar_one_or_none(): + raise HTTPException(status_code=404, detail="Deployment not found") + + result = await session.execute( + select(DeploymentVersion) + .where(DeploymentVersion.deployment_id == uuid_id) + .order_by(desc(DeploymentVersion.version)) + ) + return list(result.scalars().all()) + + +@router.delete("/{deployment_id}", status_code=204) +async def delete_deployment( + deployment_id: str, + session: AsyncSession = Depends(get_session), + user: Annotated[TokenData | None, Depends(get_current_user)] = None, +) -> None: + """Delete a deployment and all its versions.""" + uuid_id = _parse_uuid(deployment_id) + query = select(Deployment).where(Deployment.id == uuid_id) + + if should_filter_by_user(): + effective_user_id = get_effective_user_id(user) + query = query.where(Deployment.user_id == effective_user_id) + + result = await session.execute(query) + deployment = result.scalar_one_or_none() + if not deployment: + raise HTTPException(status_code=404, detail="Deployment not found") + + # Delete versions first + versions_result = await session.execute( + select(DeploymentVersion).where(DeploymentVersion.deployment_id == uuid_id) + ) + for version in versions_result.scalars().all(): + await session.delete(version) + + await session.delete(deployment) + await session.commit() diff --git a/src/flow/ui/api/experiment.py b/src/flow/ui/api/experiment.py index 409f44f750de04ac1b398012e63a963e3688f664..e5b0a8a38afa8e41d00e6ee3dac45ca3812abe36 100644 --- a/src/flow/ui/api/experiment.py +++ b/src/flow/ui/api/experiment.py @@ -94,7 +94,6 @@ async def design_experiment( Returns the YAML content and candidate count for preview. """ # Look up base agent to get its path/name - from uuid import UUID try: agent_uuid = UUID(data.base_agent_id) except ValueError as e: diff --git a/src/flow/ui/api/jobs.py b/src/flow/ui/api/jobs.py index 2af3fc0db36ad0109106e83d5dc272775b8d6b49..7c61dd4f0f6d17cebad9ef3693830959053b5df1 100644 --- a/src/flow/ui/api/jobs.py +++ b/src/flow/ui/api/jobs.py @@ -7,7 +7,7 @@ from collections.abc import AsyncGenerator from typing import Annotated, Any from uuid import UUID -from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException +from fastapi import APIRouter, Depends, HTTPException from fastapi.responses import StreamingResponse from sqlalchemy.ext.asyncio import AsyncSession from sqlmodel import desc, or_, select @@ -80,15 +80,44 @@ async def create_job( """Create a new optimization job.""" effective_user_id = get_effective_user_id(user) - # Validate candidate_ids exist AND belong to user - for candidate_id in data.candidate_ids: - uuid_id = parse_uuid(candidate_id) + is_strategy_mode = len(data.strategies) > 0 + + if is_strategy_mode: + # Strategy mode: validate strategy names and base_agent_id + if not data.base_agent_id: + raise HTTPException(status_code=400, detail="base_agent_id is required for strategy mode") + + from flow.experiments.strategies import get_registered_strategies + + available = list(get_registered_strategies().keys()) + for sname in data.strategies: + if sname not in available: + raise HTTPException( + status_code=400, + detail=f"Unknown strategy: {sname}. Available: {available}", + ) + + # Validate base agent exists and belongs to user + uuid_id = parse_uuid(data.base_agent_id) query = select(AgentConfig).where(AgentConfig.id == uuid_id) if should_filter_by_user(): query = query.where(AgentConfig.user_id == effective_user_id) result = await session.execute(query) if not result.scalar_one_or_none(): - raise HTTPException(status_code=400, detail=f"Candidate {candidate_id} not found") + raise HTTPException(status_code=400, detail=f"Base agent {data.base_agent_id} not found") + else: + # Grid mode: validate candidate_ids exist AND belong to user + if not data.candidate_ids: + raise HTTPException(status_code=400, detail="candidate_ids required for grid mode (or use strategy mode)") + + for candidate_id in data.candidate_ids: + uuid_id = parse_uuid(candidate_id) + query = select(AgentConfig).where(AgentConfig.id == uuid_id) + if should_filter_by_user(): + query = query.where(AgentConfig.user_id == effective_user_id) + result = await session.execute(query) + if not result.scalar_one_or_none(): + raise HTTPException(status_code=400, detail=f"Candidate {candidate_id} not found") # Validate task_ids exist AND are accessible (shared or user's own) for task_id in data.task_ids: @@ -114,9 +143,14 @@ async def create_job( name=data.name, candidate_ids=data.candidate_ids, task_ids=data.task_ids, + strategies=data.strategies, + strategy_config=data.strategy_config, + base_agent_id=data.base_agent_id, parallel=data.parallel, use_llm_eval=data.use_llm_eval, - total_experiments=len(data.candidate_ids) * len(data.task_ids), + # Strategy mode: estimate based on tasks (will be updated by progress callback) + # Grid mode: exact count = candidates × tasks + total_experiments=len(data.task_ids) if is_strategy_mode else len(data.candidate_ids) * len(data.task_ids), user_id=effective_user_id, created_by_name=created_by_name, ) @@ -223,7 +257,6 @@ async def _run_job_background(job_id: str) -> None: @router.post("/{job_id}/start") async def start_job( job_id: str, - background_tasks: BackgroundTasks, session: AsyncSession = Depends(get_session), user: Annotated[TokenData | None, Depends(get_current_user)] = None, ) -> StreamingResponse: diff --git a/src/flow/ui/api/schema.py b/src/flow/ui/api/schema.py index b3a73348f982139991d6ba70671c0406e0e3c2f1..de99a0308d9b57737cace923c7ed9640be2e21c1 100644 --- a/src/flow/ui/api/schema.py +++ b/src/flow/ui/api/schema.py @@ -74,7 +74,7 @@ class LLMProviderSchema(BaseModel): class OptimizationStrategySchema(BaseModel): - """Schema for an optimization strategy (GEPA, llm_rewriter, etc.).""" + """Schema for an optimization strategy (GEPA, instruction, tool, skill).""" name: str = Field(description="Strategy identifier") description: str = Field(description="What this strategy does") @@ -238,14 +238,18 @@ async def get_agent_schema() -> AgentSchema: "description": "GEPA: Reflective prompt evolution using LLM feedback", "applicable_dimensions": ["instructions"], }, - "llm_rewriter": { - "description": "LLM-based instruction rewriting with variations", + "instruction": { + "description": "LLM-based instruction optimization via evaluate-reflect-rewrite", "applicable_dimensions": ["instructions"], }, - "tool_selector": { - "description": "Intelligent tool set selection based on task", + "tool": { + "description": "Intelligent tool set optimization based on task failures", "applicable_dimensions": ["tools"], }, + "skill": { + "description": "Skill generation and selection to provide domain knowledge", + "applicable_dimensions": ["skills"], + }, } optimization_strategies = [ OptimizationStrategySchema( diff --git a/src/flow/ui/api/tests.py b/src/flow/ui/api/tests.py index bc44c61f8b8feddcf07b6abd1dcba8a3d24fde99..92d0af29d2a3ba8c82c6996c0ad0ee19be4a3a6f 100644 --- a/src/flow/ui/api/tests.py +++ b/src/flow/ui/api/tests.py @@ -1,7 +1,6 @@ # Copyright (c) Microsoft. All rights reserved. """Test run API routes for interactive agent testing.""" -import asyncio import logging from collections.abc import AsyncGenerator from typing import Annotated, Any @@ -13,7 +12,7 @@ from sqlalchemy.ext.asyncio import AsyncSession from sqlmodel import desc, select from ..auth import TokenData, get_current_user, get_effective_user_id, should_filter_by_user -from ..database import async_session, get_session +from ..database import get_session from ..models.config import AgentConfig from ..models.test_run import TestRun, TestRunStatus from ..schemas.test import TestRunCreate, TestRunDetailResponse, TestRunResponse @@ -22,10 +21,6 @@ from ..services.test_service import TestService router = APIRouter(prefix="/tests", tags=["tests"]) logger = logging.getLogger(__name__) -# Store running tests for cancellation -_running_tests: dict[str, asyncio.Task[Any]] = {} - - def parse_uuid(id_str: str) -> UUID: """Parse a string to UUID, raising 400 if invalid.""" try: @@ -150,30 +145,6 @@ async def get_test( } -async def _run_test_background(test_id: str) -> None: - """Run test in background, updating DB with progress.""" - service = TestService() - try: - async for progress in service.run_test(test_id): - logger.debug(f"Test {test_id[:8]} progress: {progress.event} - {progress.message}") - except Exception as e: - logger.error(f"Background test {test_id[:8]} failed: {e}") - # Ensure test is marked as failed - async with async_session() as session: - from datetime import datetime, timezone - result = await session.execute( - select(TestRun).where(TestRun.id == UUID(test_id)) - ) - test_run = result.scalar_one_or_none() - if test_run and test_run.status == TestRunStatus.RUNNING: - test_run.status = TestRunStatus.FAILED - test_run.error = f"Background execution failed: {e}" - test_run.completed_at = datetime.now(timezone.utc) - await session.commit() - finally: - _running_tests.pop(test_id, None) - - @router.post("/{test_id}/start") async def start_test( test_id: str, @@ -246,11 +217,6 @@ async def cancel_test( if test_run.status != TestRunStatus.RUNNING: raise HTTPException(status_code=400, detail=f"Test is not running (status: {test_run.status})") - # Cancel the running task if it exists - if test_id in _running_tests: - _running_tests[test_id].cancel() - del _running_tests[test_id] - test_run.status = TestRunStatus.CANCELLED await session.commit() await session.refresh(test_run) diff --git a/src/flow/ui/auth/__init__.py b/src/flow/ui/auth/__init__.py index c26fdd75f21d2ba3d7c7dd235b9708e20e60bfe3..bb04b5315291f015d4a4b477f289763979c5a0a9 100644 --- a/src/flow/ui/auth/__init__.py +++ b/src/flow/ui/auth/__init__.py @@ -2,7 +2,7 @@ """Authentication module for Flow UI.""" from .config import AuthMode, AuthSettings, get_auth_settings, init_auth_settings -from .middleware import get_current_user, require_auth +from .middleware import get_current_user from .router import router as auth_router from .tokens import TokenData, create_access_token, verify_access_token from .user_context import ANONYMOUS_USER_ID, get_effective_user_id, should_filter_by_user @@ -18,7 +18,6 @@ __all__ = [ "get_current_user", "get_effective_user_id", "init_auth_settings", - "require_auth", "should_filter_by_user", "verify_access_token", ] diff --git a/src/flow/ui/auth/config.py b/src/flow/ui/auth/config.py index 9c0ef87bb19a6722b065863bee8359c19e3acb08..cdedf3fd67f677c3f32b1b7763b84b968585fe31 100644 --- a/src/flow/ui/auth/config.py +++ b/src/flow/ui/auth/config.py @@ -5,14 +5,10 @@ from __future__ import annotations import secrets from enum import Enum -from typing import TYPE_CHECKING from pydantic import Field, field_validator from pydantic_settings import BaseSettings, SettingsConfigDict -if TYPE_CHECKING: - pass - class AuthMode(str, Enum): """Authentication mode.""" diff --git a/src/flow/ui/auth/middleware.py b/src/flow/ui/auth/middleware.py index 380cf36138464f30aed4784890b28361233cb131..67d7631cb47ed5cf9b6291b4d32a8cade0280055 100644 --- a/src/flow/ui/auth/middleware.py +++ b/src/flow/ui/auth/middleware.py @@ -60,48 +60,6 @@ async def get_current_user( ) from e -async def require_auth( - user: Annotated[TokenData | None, Depends(get_current_user)], -) -> TokenData | None: - """Require authentication if enabled. - - Use this as a dependency on routes that should be protected when auth is enabled. - This is essentially an alias for get_current_user that makes intent clearer. - - Args: - user: The current user from get_current_user - - Returns: - TokenData if authenticated, None if auth is disabled - """ - return user - - -def get_optional_user( - credentials: Annotated[HTTPAuthorizationCredentials | None, Depends(bearer_scheme)], -) -> TokenData | None: - """Get the current user if a valid token is provided, otherwise None. - - Unlike get_current_user, this never raises an error - it's for routes - that work differently based on whether the user is authenticated. - - Args: - credentials: The bearer token credentials - - Returns: - TokenData if valid token provided, None otherwise - """ - settings = get_auth_settings() - - if credentials is None: - return None - - try: - return verify_access_token(credentials.credentials, settings.secret) - except TokenError: - return None - - class AuthMiddleware: """Middleware to check authentication on all /api/* routes except /api/auth/*. diff --git a/src/flow/ui/database.py b/src/flow/ui/database.py index 1c4e189b37934235c6aa0acbdf9e697df6050504..811d0bd489a932b043f62ed78c02e1a2d455d9f9 100644 --- a/src/flow/ui/database.py +++ b/src/flow/ui/database.py @@ -25,9 +25,12 @@ async_session = async_sessionmaker(engine, class_=AsyncSession, expire_on_commit async def init_db() -> None: """Initialize database tables and run migrations.""" # Import models to register them with SQLModel.metadata (side-effect imports) - from flow.ui.models import AgentConfig, ExperimentRun, LLMConfig, OptimizationJob, TaskModel, TestRun + from flow.ui.models import ( + AgentConfig, Deployment, DeploymentVersion, ExperimentRun, + LLMConfig, OptimizationJob, TaskModel, TestRun, + ) - _ = (AgentConfig, ExperimentRun, LLMConfig, OptimizationJob, TaskModel, TestRun) + _ = (AgentConfig, Deployment, DeploymentVersion, ExperimentRun, LLMConfig, OptimizationJob, TaskModel, TestRun) try: async with engine.begin() as conn: @@ -35,6 +38,7 @@ async def init_db() -> None: # Run migrations (safe to run multiple times) await _migrate_user_id_columns(conn) await _migrate_is_public_columns(conn) + await _migrate_optimization_jobs_strategies(conn) # Seed default LLM configs based on environment await _seed_default_llm_configs() @@ -133,6 +137,24 @@ async def _migrate_is_public_columns(conn) -> None: # type: ignore[no-untyped-d await conn.execute(text("ALTER TABLE optimization_jobs ADD COLUMN created_by_name TEXT")) +async def _migrate_optimization_jobs_strategies(conn) -> None: # type: ignore[no-untyped-def] + """Add strategies, strategy_config, and base_agent_id columns to optimization_jobs. + + This migration is idempotent - safe to run multiple times. + """ + for col, sql in [ + ("strategies", "ALTER TABLE optimization_jobs ADD COLUMN strategies JSON DEFAULT '[]'"), + ("strategy_config", "ALTER TABLE optimization_jobs ADD COLUMN strategy_config JSON DEFAULT '{}'"), + ("base_agent_id", "ALTER TABLE optimization_jobs ADD COLUMN base_agent_id TEXT"), + ]: + try: + await conn.execute(text(f"SELECT {col} FROM optimization_jobs LIMIT 1")) + logger.debug(f"optimization_jobs.{col} column exists") + except Exception: + logger.info(f"Adding {col} column to optimization_jobs") + await conn.execute(text(sql)) + + async def _seed_default_llm_configs() -> None: """Create default LLM configs based on available environment variables. diff --git a/src/flow/ui/main.py b/src/flow/ui/main.py index a66bce900cc726f8335f41de8234c53e0339a0b6..7914f79042fec9616f48684ff10aff0546ee7b6d 100644 --- a/src/flow/ui/main.py +++ b/src/flow/ui/main.py @@ -14,6 +14,7 @@ from starlette.middleware.base import BaseHTTPMiddleware from .api import ( configs_router, + deployments_router, evaluate_router, experiment_router, jobs_router, @@ -75,6 +76,7 @@ app.add_middleware(BaseHTTPMiddleware, dispatch=AuthMiddleware()) app.include_router(auth_router, prefix="/api") # Protected routes app.include_router(configs_router, prefix="/api") +app.include_router(deployments_router, prefix="/api") app.include_router(evaluate_router, prefix="/api") app.include_router(experiment_router, prefix="/api") app.include_router(tasks_router, prefix="/api") diff --git a/src/flow/ui/models/__init__.py b/src/flow/ui/models/__init__.py index 3520a8f6c59367524e8186ca1d97bd34009c58a4..a8ea84ff9bc921054ea0b6f06d28e4134963e315 100644 --- a/src/flow/ui/models/__init__.py +++ b/src/flow/ui/models/__init__.py @@ -2,6 +2,7 @@ """Database models.""" from .config import AgentConfig +from .deployment import Deployment, DeploymentVersion from .job import JobStatus, OptimizationJob from .llm_config import LLMConfig from .run import ExperimentRun @@ -10,6 +11,8 @@ from .test_run import TestRun, TestRunStatus __all__ = [ "AgentConfig", + "Deployment", + "DeploymentVersion", "ExperimentRun", "JobStatus", "LLMConfig", diff --git a/src/flow/ui/models/deployment.py b/src/flow/ui/models/deployment.py new file mode 100644 index 0000000000000000000000000000000000000000..ee8fb27bf46df1d6aeaae1dd1e69a2c2d4c702bd --- /dev/null +++ b/src/flow/ui/models/deployment.py @@ -0,0 +1,54 @@ +# Copyright (c) Microsoft. All rights reserved. +"""Deployment and version tracking models.""" + +from datetime import datetime, timezone +from typing import Any +from uuid import UUID, uuid4 + +from sqlmodel import JSON, Column, Field, SQLModel + + +class Deployment(SQLModel, table=True): + """A stable deployment identity that persists across config versions. + + The deployment is the thing you bookmark — one URL, one name. + The config behind it changes via versions. + """ + + __tablename__ = "deployments" # type: ignore[assignment] + + id: UUID = Field(default_factory=uuid4, primary_key=True) + name: str = Field(index=True) + description: str = "" + + # Points to the current active version + current_version_id: UUID | None = Field(default=None) + + # Owner + user_id: str | None = Field(default=None, index=True) + is_public: bool = Field(default=False) + + created_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc)) + updated_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc)) + + +class DeploymentVersion(SQLModel, table=True): + """An immutable snapshot linking a deployment to a specific agent config. + + Append-only — each deploy() call creates a new version. + """ + + __tablename__ = "deployment_versions" # type: ignore[assignment] + + id: UUID = Field(default_factory=uuid4, primary_key=True) + deployment_id: UUID = Field(index=True) + config_id: UUID = Field(index=True) + + version: int = Field(default=1) + source: str = Field(default="deploy") # "deploy" or "optimize" + + # Optional metadata about what changed + description: str = "" + config_snapshot: dict[str, Any] = Field(default_factory=dict, sa_column=Column(JSON)) + + created_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc)) diff --git a/src/flow/ui/models/job.py b/src/flow/ui/models/job.py index 2be74f8fba813619a720918b0678bc59636b5ae0..b550ab88c532470d9d0a37ce40884c39a61d41dc 100644 --- a/src/flow/ui/models/job.py +++ b/src/flow/ui/models/job.py @@ -44,6 +44,11 @@ class OptimizationJob(SQLModel, table=True): candidate_ids: list[str] = Field(default_factory=list, sa_column=Column(JSON)) task_ids: list[str] = Field(default_factory=list, sa_column=Column(JSON)) + # Strategy-based optimization (alternative to candidate_ids) + strategies: list[str] = Field(default_factory=list, sa_column=Column(JSON)) # e.g. ["instruction", "tool"] + strategy_config: dict = Field(default_factory=dict, sa_column=Column(JSON)) + base_agent_id: str | None = Field(default=None) + # Results pareto_frontier: list[str] = Field(default_factory=list, sa_column=Column(JSON)) output_dir: str | None = None diff --git a/src/flow/ui/models/run.py b/src/flow/ui/models/run.py index d14335734311f9fba3782045693bb1a63f9af922..0dc326ddcf28e413d916480caea3654802d57793 100644 --- a/src/flow/ui/models/run.py +++ b/src/flow/ui/models/run.py @@ -32,7 +32,6 @@ class ExperimentRun(SQLModel, table=True): score: float = 0.0 passed: bool = False reasoning: str = "" - criteria_results: list[dict[str, Any]] = Field(default_factory=list, sa_column=Column(JSON)) # Output output: str = "" diff --git a/src/flow/ui/schemas/__init__.py b/src/flow/ui/schemas/__init__.py index 0d17f66f18b9f655c2cad0d20cb9e57db697e890..ce0af6cf8ec32fa0c26e02f18b49133ae7dda376 100644 --- a/src/flow/ui/schemas/__init__.py +++ b/src/flow/ui/schemas/__init__.py @@ -2,6 +2,7 @@ """Pydantic schemas for API requests/responses.""" from .config import AgentCreate, AgentResponse, AgentUpdate +from .deployment import DeploymentDetailResponse, DeploymentResponse, DeploymentVersionResponse from .experiment import ( CompactionVariation, ExperimentDesignRequest, @@ -32,6 +33,10 @@ __all__ = [ "AgentCreate", "AgentUpdate", "AgentResponse", + # Deployments + "DeploymentResponse", + "DeploymentDetailResponse", + "DeploymentVersionResponse", "TaskCreate", "TaskUpdate", "TaskResponse", diff --git a/src/flow/ui/schemas/config.py b/src/flow/ui/schemas/config.py index 49ab10798251a37883eb644ea878fc444163ced0..6a60d1af7a9765d9d6d1492dcca4b05f1313125e 100644 --- a/src/flow/ui/schemas/config.py +++ b/src/flow/ui/schemas/config.py @@ -18,7 +18,7 @@ class CompactionConfigSchema(BaseModel): class LLMConfigSchema(BaseModel): """LLM configuration with provider and model.""" - provider: str = "azure" # azure, openai, anthropic + provider: str = "azure_openai" # azure_openai, openai, anthropic model: str = "gpt-4o" diff --git a/src/flow/ui/schemas/deployment.py b/src/flow/ui/schemas/deployment.py new file mode 100644 index 0000000000000000000000000000000000000000..a3dddb4f73f9d9780b16c46a13d6ad111874eb72 --- /dev/null +++ b/src/flow/ui/schemas/deployment.py @@ -0,0 +1,60 @@ +# Copyright (c) Microsoft. All rights reserved. +"""Deployment schemas.""" + +from datetime import datetime +from typing import Any +from uuid import UUID + +from pydantic import BaseModel, ConfigDict, field_validator + + +class DeploymentResponse(BaseModel): + """Response schema for a deployment.""" + + model_config = ConfigDict(from_attributes=True) + + id: str + name: str + description: str + current_version_id: str | None = None + user_id: str | None = None + is_public: bool = False + created_at: datetime + updated_at: datetime + + @field_validator("id", "current_version_id", mode="before") + @classmethod + def convert_uuid(cls, v: UUID | str | None) -> str | None: + if v is None: + return None + if isinstance(v, UUID): + return str(v) + return v + + +class DeploymentVersionResponse(BaseModel): + """Response schema for a deployment version.""" + + model_config = ConfigDict(from_attributes=True) + + id: str + deployment_id: str + config_id: str + version: int + source: str + description: str + config_snapshot: dict[str, Any] + created_at: datetime + + @field_validator("id", "deployment_id", "config_id", mode="before") + @classmethod + def convert_uuid(cls, v: UUID | str) -> str: + if isinstance(v, UUID): + return str(v) + return v + + +class DeploymentDetailResponse(DeploymentResponse): + """Deployment with its version history.""" + + versions: list[DeploymentVersionResponse] = [] diff --git a/src/flow/ui/schemas/experiment.py b/src/flow/ui/schemas/experiment.py index 996d0e069d8e7e3d3ea8a9f4216aa6aee15f40b5..dfaa5514ea4025b9131e2c9fb7b040dad2deb491 100644 --- a/src/flow/ui/schemas/experiment.py +++ b/src/flow/ui/schemas/experiment.py @@ -54,7 +54,7 @@ class StrategyVariationRequest(BaseModel): """ strategy: str = Field( - description="Strategy name: gepa, llm_rewriter, tool_selector" + description="Strategy name: gepa, instruction, tool, skill" ) max_candidates: int = Field( default=3, ge=1, le=10, description="Number of candidates to generate" diff --git a/src/flow/ui/schemas/job.py b/src/flow/ui/schemas/job.py index bec22c847facf44f50a1f32c054953d538edeb4b..64c36692a256f77eb59c5bd55063d5712002fd5a 100644 --- a/src/flow/ui/schemas/job.py +++ b/src/flow/ui/schemas/job.py @@ -2,6 +2,7 @@ """Job schemas.""" from datetime import datetime +from typing import Any from uuid import UUID from pydantic import BaseModel, ConfigDict, field_validator @@ -13,10 +14,15 @@ class JobCreate(BaseModel): """Request schema for creating a job.""" name: str = "" - candidate_ids: list[str] + # Grid mode (existing) — provide candidate_ids for static cross-product + candidate_ids: list[str] = [] task_ids: list[str] parallel: int = 4 use_llm_eval: bool = False + # Strategy mode (new) — provide strategies + base_agent_id for iterative optimization + strategies: list[str] = [] # e.g. ["instruction", "tool", "skill"] + strategy_config: dict[str, Any] = {} + base_agent_id: str | None = None class JobUpdate(BaseModel): @@ -38,6 +44,9 @@ class JobResponse(BaseModel): use_llm_eval: bool candidate_ids: list[str] task_ids: list[str] + strategies: list[str] = [] + strategy_config: dict[str, Any] = {} + base_agent_id: str | None = None pareto_frontier: list[str] output_dir: str | None error: str | None diff --git a/src/flow/ui/services/optimizer_service.py b/src/flow/ui/services/optimizer_service.py index 8facc080a8f057a93b6b78bef12071692ad4aa27..1bab63c985eccf9a1f5cb4f38e42f9d6736ada69 100644 --- a/src/flow/ui/services/optimizer_service.py +++ b/src/flow/ui/services/optimizer_service.py @@ -10,7 +10,7 @@ from sqlalchemy.ext.asyncio import AsyncSession from sqlmodel import select from flow.experiments.models import Agent, Candidate, CompactionConfig -from flow.experiments.optimizer import FlowOptimizer +from flow.experiments.optimizer import CandidateSummary, FlowOptimizer from flow.experiments.types import EvalCriterion, Task from ..database import async_session @@ -55,10 +55,6 @@ class OptimizerService: ) try: - candidates = await self._load_candidates(session, job.candidate_ids) - if not candidates: - raise ValueError("No valid candidates found") - tasks = await self._load_tasks(session, job.task_ids) if not tasks: raise ValueError("No valid tasks found") @@ -76,12 +72,95 @@ class OptimizerService: except asyncio.QueueFull: pass - async def run_optimization(): - return await optimizer.optimize( - candidates=candidates, - tasks=tasks, - progress_callback=progress_callback, - ) + if job.strategies: + # Strategy mode — iterative optimization pipeline + # Each stage's best agent feeds into the next stage + base_agent = await self._load_single_agent(session, job.base_agent_id or "") + + from flow.experiments.strategies import get_strategy + + async def run_optimization(): + from flow.experiments.ablation import compute_pareto_frontier + + current_agent = base_agent + last_result = None + all_summaries: list[CandidateSummary] = [] + total_experiments = 0 + total_duration = 0.0 + for strat_name in job.strategies: + strat_instance = get_strategy(strat_name, job.strategy_config) + strat_optimizer = FlowOptimizer( + parallel=job.parallel, + use_llm_evaluator=job.use_llm_eval, + ) + last_result = await strat_optimizer.optimize_with_strategy( + strategy=strat_instance, + base=current_agent, + tasks=tasks, + budget=job.strategy_config.get("budget", 50), + progress_callback=progress_callback, + ) + # Accumulate results from all stages + all_summaries.extend(last_result.summaries) + total_experiments += last_result.total_experiments + total_duration += last_result.total_duration_seconds + # Next stage starts from the best agent found + best = last_result.get_best_candidate("score") + if best: + current_agent = best.candidate.agent + + # Merge all stage results with dedup and recomputed Pareto + if last_result and len(job.strategies) > 1: + seen_names: set[str] = set() + deduped: list[CandidateSummary] = [] + for s in all_summaries: + if s.name not in seen_names: + seen_names.add(s.name) + deduped.append(s) + + pareto_names = compute_pareto_frontier(deduped) + for s in deduped: + s.is_pareto_optimal = s.name in pareto_names + s.pareto_rank = 0 if s.is_pareto_optimal else 1 + + rank_by_score = sorted(deduped, key=lambda s: s.avg_score, reverse=True) + rank_by_tokens = sorted(deduped, key=lambda s: s.avg_tokens) + rank_by_efficiency = sorted( + deduped, + key=lambda s: s.avg_score / max(s.avg_tokens, 1), + reverse=True, + ) + + from flow.experiments.optimizer import OptimizationResult + + last_result = OptimizationResult( + timestamp=last_result.timestamp, + output_dir=last_result.output_dir, + summaries=deduped, + pareto_frontier=pareto_names, + exported_agents=last_result.exported_agents, + rank_by_score=[s.name for s in rank_by_score], + rank_by_tokens=[s.name for s in rank_by_tokens], + rank_by_efficiency=[s.name for s in rank_by_efficiency], + total_experiments=total_experiments, + total_duration_seconds=total_duration, + ) + elif last_result: + last_result.summaries = all_summaries + last_result.total_experiments = total_experiments + return last_result + else: + # Grid mode — static cross-product + candidates = await self._load_candidates(session, job.candidate_ids) + if not candidates: + raise ValueError("No valid candidates found") + + async def run_optimization(): + return await optimizer.optimize( + candidates=candidates, + tasks=tasks, + progress_callback=progress_callback, + ) opt_task = asyncio.create_task(run_optimization()) @@ -102,6 +181,7 @@ class OptimizerService: ) job.completed_experiments = completed + job.total_experiments = total await session.commit() except asyncio.TimeoutError: @@ -154,6 +234,36 @@ class OptimizerService: message=f"Optimization failed: {e}", ) + async def _load_single_agent( + self, + session: AsyncSession, + agent_id: str, + ) -> Agent: + """Load a single agent config and convert to an Agent object.""" + result = await session.execute( + select(AgentConfig).where(AgentConfig.id == UUID(agent_id)) + ) + db_config = result.scalar_one_or_none() + if not db_config: + raise ValueError(f"Agent {agent_id} not found") + + cfg = db_config.config_json + compaction_data = cfg.get("compaction", {}) + compaction = CompactionConfig( + strategy=compaction_data.get("strategy", "head_tail"), + params=compaction_data.get("params", {"head_size": 10, "tail_size": 40}), + ) + tools = cfg.get("tools", "standard") + + return Agent( + name=db_config.name, + framework=cfg.get("framework", "miniagent"), + instructions=cfg.get("instructions"), + llm_config=cfg.get("llm_config"), + compaction=compaction, + tools=tools, + ) + async def _load_candidates( self, session: AsyncSession, diff --git a/src/flow/ui/services/persistence_adapter.py b/src/flow/ui/services/persistence_adapter.py index 235406cb192bb534b2c32c08269ea59f354b5e50..1b24fa237fa0fe3d24aad63f656f4a9a1477440c 100644 --- a/src/flow/ui/services/persistence_adapter.py +++ b/src/flow/ui/services/persistence_adapter.py @@ -2,7 +2,7 @@ """Persistence adapter — bridges FlowOptimizer results to the database. This adapter provides a single, shared conversion layer used by: -1. Agent.deploy() — registers an agent in the DB +1. Agent.deploy() — creates AgentConfig + Deployment + DeploymentVersion 2. Agent.evaluate()/optimize() — auto-persists results when agent is deployed 3. OptimizerService — persists results from UI-initiated jobs @@ -18,8 +18,11 @@ from datetime import datetime, timezone from typing import TYPE_CHECKING from uuid import UUID +from sqlmodel import desc, select + from flow.ui.database import async_session, init_db from flow.ui.models.config import AgentConfig +from flow.ui.models.deployment import Deployment, DeploymentVersion from flow.ui.models.job import JobStatus, OptimizationJob from flow.ui.models.run import ExperimentRun @@ -30,6 +33,15 @@ if TYPE_CHECKING: logger = logging.getLogger(__name__) +class DeployResult: + """Result from deploy_agent() containing both deployment and config IDs.""" + + def __init__(self, deployment_id: str, config_id: str, version: int) -> None: + self.deployment_id = deployment_id + self.config_id = config_id + self.version = version + + class PersistenceAdapter: """Converts FlowOptimizer results to database rows.""" @@ -37,36 +49,98 @@ class PersistenceAdapter: """Ensure DB tables exist (safe to call multiple times).""" await init_db() - async def deploy_agent(self, agent: Agent) -> str: - """Register an agent in the database. + async def deploy_agent( + self, + agent: Agent, + *, + deployment_id: str | None = None, + source: str = "deploy", + version_description: str = "", + ) -> DeployResult: + """Deploy an agent: create config, find-or-create deployment, append version. - Creates an AgentConfig row from the Agent dataclass. - This is a pure DB write — no server required. + If deployment_id is provided, appends a new version to that deployment. + Otherwise, looks up by (agent.name, user_id) or creates a new deployment. Args: - agent: The Agent to register + agent: The Agent to deploy + deployment_id: Existing deployment to add a version to + source: How this version was created ("deploy" or "optimize") + version_description: Optional description of what changed Returns: - The agent ID (UUID string) + DeployResult with deployment_id, config_id, and version number """ await self._ensure_db() config_json = self._agent_to_config_json(agent) async with async_session() as session: + # 1. Create AgentConfig (immutable snapshot) db_config = AgentConfig( name=agent.name, description=agent.description, config_json=config_json, - is_auto_generated=False, + is_auto_generated=source != "deploy", ) session.add(db_config) + await session.flush() + + # 2. Find or create Deployment + deployment: Deployment | None = None + if deployment_id: + result = await session.execute( + select(Deployment).where(Deployment.id == UUID(deployment_id)) + ) + deployment = result.scalar_one_or_none() + + if deployment is None: + deployment = Deployment( + name=agent.name, + description=agent.description, + ) + session.add(deployment) + await session.flush() + + # 3. Determine next version number + result = await session.execute( + select(DeploymentVersion) + .where(DeploymentVersion.deployment_id == deployment.id) + .order_by(desc(DeploymentVersion.version)) + .limit(1) + ) + latest = result.scalar_one_or_none() + next_version = (latest.version + 1) if latest else 1 + + # 4. Create DeploymentVersion + version = DeploymentVersion( + deployment_id=deployment.id, + config_id=db_config.id, + version=next_version, + source=source, + description=version_description, + config_snapshot=config_json, + ) + session.add(version) + await session.flush() + + # 5. Update deployment pointer + deployment.current_version_id = version.id + deployment.updated_at = datetime.now(timezone.utc) + await session.commit() - await session.refresh(db_config) - agent_id = str(db_config.id) - logger.info(f"Deployed agent {agent.name!r} with ID {agent_id}") - return agent_id + deploy_result = DeployResult( + deployment_id=str(deployment.id), + config_id=str(db_config.id), + version=next_version, + ) + + logger.info( + f"Deployed agent {agent.name!r} v{next_version} " + f"(deployment={deploy_result.deployment_id}, config={deploy_result.config_id})" + ) + return deploy_result async def persist_evaluation( self, @@ -81,7 +155,7 @@ class PersistenceAdapter: Args: summary: The CandidateSummary from evaluate_agent() - agent_id: The deployed agent's UUID string + agent_id: The deployed agent's config UUID string job_name: Optional job name (defaults to "Evaluation: {agent_name}") Returns: @@ -99,7 +173,7 @@ class PersistenceAdapter: parallel=1, use_llm_eval=True, candidate_ids=[agent_id], - task_ids=[], # Tasks not in DB for code-first path + task_ids=[], pareto_frontier=[summary.name], total_experiments=task_count, completed_experiments=task_count, @@ -107,7 +181,7 @@ class PersistenceAdapter: completed_at=datetime.now(timezone.utc), ) session.add(job) - await session.flush() # Get job.id + await session.flush() for task_result in summary.task_results: run = self._task_result_to_run( @@ -137,7 +211,7 @@ class PersistenceAdapter: Args: result: The OptimizationResult from FlowOptimizer.optimize() - agent_id: The deployed base agent's UUID string + agent_id: The deployed base agent's config UUID string job_name: Optional job name Returns: diff --git a/src/flow/ui/services/test_service.py b/src/flow/ui/services/test_service.py index de1d27d8c6b86170e31b6ee765b28f3e88982752..b2cd3c43b185563b6c8f85223abbd0fd5e0038ce 100644 --- a/src/flow/ui/services/test_service.py +++ b/src/flow/ui/services/test_service.py @@ -3,7 +3,6 @@ import asyncio import logging -import os import tempfile import time from collections.abc import AsyncGenerator @@ -172,13 +171,13 @@ class TestService: harness = self._create_harness_from_config(agent_config, workspace) # Execute agent with streaming + # NOTE: We do NOT os.chdir() here — it's process-global and + # breaks concurrent tests. Tools already use the workspace + # set via contextvars (set_workspace in harness._build_tools). start_time = time.time() output_chunks: list[str] = [] error: str | None = None - original_cwd = os.getcwd() - os.chdir(workspace) - try: # Create root span for trace_id isolation tracer = trace.get_tracer("flow.ui.test", "0.1.0") @@ -226,8 +225,6 @@ class TestService: except Exception as e: error = str(e) logger.error(f"Test execution failed: {e}") - finally: - os.chdir(original_cwd) end_time = time.time() duration_seconds = end_time - start_time @@ -291,6 +288,7 @@ class TestService: ) except Exception as e: + logger.exception(f"Test run {test_run_id} failed: {e}") test_run.status = TestRunStatus.FAILED test_run.error = str(e) test_run.completed_at = datetime.now(timezone.utc) diff --git a/src/flow/ui/ui/assets/index-B-kui4s7.js b/src/flow/ui/ui/assets/index-B-kui4s7.js new file mode 100644 index 0000000000000000000000000000000000000000..e441ba686c50a13607256a4482bcc14a38084943 --- /dev/null +++ b/src/flow/ui/ui/assets/index-B-kui4s7.js @@ -0,0 +1,347 @@ +var ru=e=>{throw TypeError(e)};var Wi=(e,t,n)=>t.has(e)||ru("Cannot "+n);var y=(e,t,n)=>(Wi(e,t,"read from private field"),n?n.call(e):t.get(e)),$=(e,t,n)=>t.has(e)?ru("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),M=(e,t,n,r)=>(Wi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),G=(e,t,n)=>(Wi(e,t,"access private method"),n);var va=(e,t,n,r)=>({set _(s){M(e,t,s,n)},get _(){return y(e,t,r)}});function up(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();function Xd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Zd={exports:{}},Ci={},ef={exports:{}},X={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var la=Symbol.for("react.element"),dp=Symbol.for("react.portal"),fp=Symbol.for("react.fragment"),hp=Symbol.for("react.strict_mode"),mp=Symbol.for("react.profiler"),pp=Symbol.for("react.provider"),xp=Symbol.for("react.context"),vp=Symbol.for("react.forward_ref"),yp=Symbol.for("react.suspense"),gp=Symbol.for("react.memo"),jp=Symbol.for("react.lazy"),su=Symbol.iterator;function wp(e){return e===null||typeof e!="object"?null:(e=su&&e[su]||e["@@iterator"],typeof e=="function"?e:null)}var tf={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},nf=Object.assign,rf={};function es(e,t,n){this.props=e,this.context=t,this.refs=rf,this.updater=n||tf}es.prototype.isReactComponent={};es.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};es.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function sf(){}sf.prototype=es.prototype;function Ho(e,t,n){this.props=e,this.context=t,this.refs=rf,this.updater=n||tf}var qo=Ho.prototype=new sf;qo.constructor=Ho;nf(qo,es.prototype);qo.isPureReactComponent=!0;var au=Array.isArray,af=Object.prototype.hasOwnProperty,Wo={current:null},lf={key:!0,ref:!0,__self:!0,__source:!0};function of(e,t,n){var r,s={},i=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(i=""+t.key),t)af.call(t,r)&&!lf.hasOwnProperty(r)&&(s[r]=t[r]);var o=arguments.length-2;if(o===1)s.children=n;else if(1>>1,te=P[Q];if(0>>1;Qs(K,T))xes(_e,K)?(P[Q]=_e,P[xe]=T,Q=xe):(P[Q]=K,P[R]=T,Q=R);else if(xes(_e,T))P[Q]=_e,P[xe]=T,Q=xe;else break e}}return A}function s(P,A){var T=P.sortIndex-A.sortIndex;return T!==0?T:P.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var c=[],u=[],d=1,f=null,m=3,v=!1,k=!1,w=!1,b=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,h=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(P){for(var A=n(u);A!==null;){if(A.callback===null)r(u);else if(A.startTime<=P)r(u),A.sortIndex=A.expirationTime,t(c,A);else break;A=n(u)}}function j(P){if(w=!1,x(P),!k)if(n(c)!==null)k=!0,W(C);else{var A=n(u);A!==null&&Z(j,A.startTime-P)}}function C(P,A){k=!1,w&&(w=!1,p(_),_=-1),v=!0;var T=m;try{for(x(A),f=n(c);f!==null&&(!(f.expirationTime>A)||P&&!B());){var Q=f.callback;if(typeof Q=="function"){f.callback=null,m=f.priorityLevel;var te=Q(f.expirationTime<=A);A=e.unstable_now(),typeof te=="function"?f.callback=te:f===n(c)&&r(c),x(A)}else r(c);f=n(c)}if(f!==null)var be=!0;else{var R=n(u);R!==null&&Z(j,R.startTime-A),be=!1}return be}finally{f=null,m=T,v=!1}}var S=!1,N=null,_=-1,z=5,O=-1;function B(){return!(e.unstable_now()-OP||125Q?(P.sortIndex=T,t(u,P),n(c)===null&&P===n(u)&&(w?(p(_),_=-1):w=!0,Z(j,T-Q))):(P.sortIndex=te,t(c,P),k||v||(k=!0,W(C))),P},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(P){var A=m;return function(){var T=m;m=A;try{return P.apply(this,arguments)}finally{m=T}}}})(hf);ff.exports=hf;var Rp=ff.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Mp=g,rt=Rp;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Pl=Object.prototype.hasOwnProperty,zp=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,lu={},ou={};function Fp(e){return Pl.call(ou,e)?!0:Pl.call(lu,e)?!1:zp.test(e)?ou[e]=!0:(lu[e]=!0,!1)}function Ip(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Dp(e,t,n,r){if(t===null||typeof t>"u"||Ip(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Ke(e,t,n,r,s,i,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=l}var Re={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Re[e]=new Ke(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Re[t]=new Ke(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Re[e]=new Ke(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Re[e]=new Ke(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Re[e]=new Ke(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Re[e]=new Ke(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Re[e]=new Ke(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Re[e]=new Ke(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Re[e]=new Ke(e,5,!1,e.toLowerCase(),null,!1,!1)});var Yo=/[\-:]([a-z])/g;function Xo(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Yo,Xo);Re[t]=new Ke(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Yo,Xo);Re[t]=new Ke(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Yo,Xo);Re[t]=new Ke(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Re[e]=new Ke(e,1,!1,e.toLowerCase(),null,!1,!1)});Re.xlinkHref=new Ke("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Re[e]=new Ke(e,1,!1,e.toLowerCase(),null,!0,!0)});function Zo(e,t,n,r){var s=Re.hasOwnProperty(t)?Re[t]:null;(s!==null?s.type!==0:r||!(2o||s[l]!==i[o]){var c=` +`+s[l].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{Yi=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?ys(e):""}function Ap(e){switch(e.tag){case 5:return ys(e.type);case 16:return ys("Lazy");case 13:return ys("Suspense");case 19:return ys("SuspenseList");case 0:case 2:case 15:return e=Xi(e.type,!1),e;case 11:return e=Xi(e.type.render,!1),e;case 1:return e=Xi(e.type,!0),e;default:return""}}function Rl(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case pr:return"Fragment";case mr:return"Portal";case Tl:return"Profiler";case ec:return"StrictMode";case Ol:return"Suspense";case Ll:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case xf:return(e.displayName||"Context")+".Consumer";case pf:return(e._context.displayName||"Context")+".Provider";case tc:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case nc:return t=e.displayName||null,t!==null?t:Rl(e.type)||"Memo";case tn:t=e._payload,e=e._init;try{return Rl(e(t))}catch{}}return null}function $p(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Rl(t);case 8:return t===ec?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function On(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function yf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Up(e){var t=yf(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(l){r=""+l,i.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ja(e){e._valueTracker||(e._valueTracker=Up(e))}function gf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=yf(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ya(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ml(e,t){var n=t.checked;return pe({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function uu(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=On(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function jf(e,t){t=t.checked,t!=null&&Zo(e,"checked",t,!1)}function zl(e,t){jf(e,t);var n=On(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Fl(e,t.type,n):t.hasOwnProperty("defaultValue")&&Fl(e,t.type,On(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function du(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Fl(e,t,n){(t!=="number"||Ya(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var gs=Array.isArray;function Cr(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=wa.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ms(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var bs={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Bp=["Webkit","ms","Moz","O"];Object.keys(bs).forEach(function(e){Bp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),bs[t]=bs[e]})});function Nf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||bs.hasOwnProperty(e)&&bs[e]?(""+t).trim():t+"px"}function Sf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=Nf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var Qp=pe({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Al(e,t){if(t){if(Qp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function $l(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ul=null;function rc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Bl=null,_r=null,Er=null;function mu(e){if(e=ua(e)){if(typeof Bl!="function")throw Error(E(280));var t=e.stateNode;t&&(t=Oi(t),Bl(e.stateNode,e.type,t))}}function Cf(e){_r?Er?Er.push(e):Er=[e]:_r=e}function _f(){if(_r){var e=_r,t=Er;if(Er=_r=null,mu(e),t)for(e=0;e>>=0,e===0?32:31-(ex(e)/tx|0)|0}var ka=64,ba=4194304;function js(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function ti(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~s;o!==0?r=js(o):(i&=l,i!==0&&(r=js(i)))}else l=n&~s,l!==0?r=js(l):i!==0&&(r=js(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function oa(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-bt(t),e[t]=n}function ax(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Ss),bu=" ",Nu=!1;function qf(e,t){switch(e){case"keyup":return Rx.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var xr=!1;function zx(e,t){switch(e){case"compositionend":return Wf(t);case"keypress":return t.which!==32?null:(Nu=!0,bu);case"textInput":return e=t.data,e===bu&&Nu?null:e;default:return null}}function Fx(e,t){if(xr)return e==="compositionend"||!dc&&qf(e,t)?(e=Kf(),Ua=oc=pn=null,xr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Eu(n)}}function Xf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Xf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Zf(){for(var e=window,t=Ya();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ya(e.document)}return t}function fc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Kx(e){var t=Zf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Xf(n.ownerDocument.documentElement,n)){if(r!==null&&fc(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=Pu(n,i);var l=Pu(n,r);s&&l&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,vr=null,Wl=null,_s=null,Gl=!1;function Tu(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Gl||vr==null||vr!==Ya(r)||(r=vr,"selectionStart"in r&&fc(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),_s&&$s(_s,r)||(_s=r,r=si(Wl,"onSelect"),0jr||(e.current=to[jr],to[jr]=null,jr--)}function le(e,t){jr++,to[jr]=e.current,e.current=t}var Ln={},De=zn(Ln),Je=zn(!1),nr=Ln;function Kr(e,t){var n=e.type.contextTypes;if(!n)return Ln;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function Ye(e){return e=e.childContextTypes,e!=null}function ii(){de(Je),de(De)}function Iu(e,t,n){if(De.current!==Ln)throw Error(E(168));le(De,t),le(Je,n)}function oh(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(E(108,$p(e)||"Unknown",s));return pe({},n,r)}function li(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ln,nr=De.current,le(De,e),le(Je,Je.current),!0}function Du(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=oh(e,t,nr),r.__reactInternalMemoizedMergedChildContext=e,de(Je),de(De),le(De,e)):de(Je),le(Je,n)}var It=null,Li=!1,fl=!1;function ch(e){It===null?It=[e]:It.push(e)}function rv(e){Li=!0,ch(e)}function Fn(){if(!fl&&It!==null){fl=!0;var e=0,t=ie;try{var n=It;for(ie=1;e>=l,s-=l,Bt=1<<32-bt(t)+s|n<_?(z=N,N=null):z=N.sibling;var O=m(p,N,x[_],j);if(O===null){N===null&&(N=z);break}e&&N&&O.alternate===null&&t(p,N),h=i(O,h,_),S===null?C=O:S.sibling=O,S=O,N=z}if(_===x.length)return n(p,N),fe&&An(p,_),C;if(N===null){for(;__?(z=N,N=null):z=N.sibling;var B=m(p,N,O.value,j);if(B===null){N===null&&(N=z);break}e&&N&&B.alternate===null&&t(p,N),h=i(B,h,_),S===null?C=B:S.sibling=B,S=B,N=z}if(O.done)return n(p,N),fe&&An(p,_),C;if(N===null){for(;!O.done;_++,O=x.next())O=f(p,O.value,j),O!==null&&(h=i(O,h,_),S===null?C=O:S.sibling=O,S=O);return fe&&An(p,_),C}for(N=r(p,N);!O.done;_++,O=x.next())O=v(N,p,_,O.value,j),O!==null&&(e&&O.alternate!==null&&N.delete(O.key===null?_:O.key),h=i(O,h,_),S===null?C=O:S.sibling=O,S=O);return e&&N.forEach(function(J){return t(p,J)}),fe&&An(p,_),C}function b(p,h,x,j){if(typeof x=="object"&&x!==null&&x.type===pr&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case ga:e:{for(var C=x.key,S=h;S!==null;){if(S.key===C){if(C=x.type,C===pr){if(S.tag===7){n(p,S.sibling),h=s(S,x.props.children),h.return=p,p=h;break e}}else if(S.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===tn&&Uu(C)===S.type){n(p,S.sibling),h=s(S,x.props),h.ref=hs(p,S,x),h.return=p,p=h;break e}n(p,S);break}else t(p,S);S=S.sibling}x.type===pr?(h=tr(x.props.children,p.mode,j,x.key),h.return=p,p=h):(j=Ga(x.type,x.key,x.props,null,p.mode,j),j.ref=hs(p,h,x),j.return=p,p=j)}return l(p);case mr:e:{for(S=x.key;h!==null;){if(h.key===S)if(h.tag===4&&h.stateNode.containerInfo===x.containerInfo&&h.stateNode.implementation===x.implementation){n(p,h.sibling),h=s(h,x.children||[]),h.return=p,p=h;break e}else{n(p,h);break}else t(p,h);h=h.sibling}h=jl(x,p.mode,j),h.return=p,p=h}return l(p);case tn:return S=x._init,b(p,h,S(x._payload),j)}if(gs(x))return k(p,h,x,j);if(os(x))return w(p,h,x,j);Ta(p,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,h!==null&&h.tag===6?(n(p,h.sibling),h=s(h,x),h.return=p,p=h):(n(p,h),h=gl(x,p.mode,j),h.return=p,p=h),l(p)):n(p,h)}return b}var qr=hh(!0),mh=hh(!1),ui=zn(null),di=null,br=null,xc=null;function vc(){xc=br=di=null}function yc(e){var t=ui.current;de(ui),e._currentValue=t}function so(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Tr(e,t){di=e,xc=br=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Ge=!0),e.firstContext=null)}function ft(e){var t=e._currentValue;if(xc!==e)if(e={context:e,memoizedValue:t,next:null},br===null){if(di===null)throw Error(E(308));br=e,di.dependencies={lanes:0,firstContext:e}}else br=br.next=e;return t}var Bn=null;function gc(e){Bn===null?Bn=[e]:Bn.push(e)}function ph(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,gc(t)):(n.next=s.next,s.next=n),t.interleaved=n,Wt(e,r)}function Wt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var nn=!1;function jc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function xh(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Vt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Nn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ne&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Wt(e,n)}return s=r.interleaved,s===null?(t.next=t,gc(r)):(t.next=s.next,s.next=t),r.interleaved=t,Wt(e,n)}function Qa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ac(e,n)}}function Bu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=l:i=i.next=l,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function fi(e,t,n,r){var s=e.updateQueue;nn=!1;var i=s.firstBaseUpdate,l=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var c=o,u=c.next;c.next=null,l===null?i=u:l.next=u,l=c;var d=e.alternate;d!==null&&(d=d.updateQueue,o=d.lastBaseUpdate,o!==l&&(o===null?d.firstBaseUpdate=u:o.next=u,d.lastBaseUpdate=c))}if(i!==null){var f=s.baseState;l=0,d=u=c=null,o=i;do{var m=o.lane,v=o.eventTime;if((r&m)===m){d!==null&&(d=d.next={eventTime:v,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var k=e,w=o;switch(m=t,v=n,w.tag){case 1:if(k=w.payload,typeof k=="function"){f=k.call(v,f,m);break e}f=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=w.payload,m=typeof k=="function"?k.call(v,f,m):k,m==null)break e;f=pe({},f,m);break e;case 2:nn=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,m=s.effects,m===null?s.effects=[o]:m.push(o))}else v={eventTime:v,lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},d===null?(u=d=v,c=f):d=d.next=v,l|=m;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;m=o,o=m.next,m.next=null,s.lastBaseUpdate=m,s.shared.pending=null}}while(!0);if(d===null&&(c=f),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=d,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);ar|=l,e.lanes=l,e.memoizedState=f}}function Qu(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ml.transition;ml.transition={};try{e(!1),t()}finally{ie=n,ml.transition=r}}function Rh(){return ht().memoizedState}function lv(e,t,n){var r=Cn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Mh(e))zh(t,n);else if(n=ph(e,t,n,r),n!==null){var s=Qe();Nt(n,e,r,s),Fh(n,t,r)}}function ov(e,t,n){var r=Cn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Mh(e))zh(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var l=t.lastRenderedState,o=i(l,n);if(s.hasEagerState=!0,s.eagerState=o,St(o,l)){var c=t.interleaved;c===null?(s.next=s,gc(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=ph(e,t,s,r),n!==null&&(s=Qe(),Nt(n,e,r,s),Fh(n,t,r))}}function Mh(e){var t=e.alternate;return e===me||t!==null&&t===me}function zh(e,t){Es=mi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Fh(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ac(e,n)}}var pi={readContext:ft,useCallback:Me,useContext:Me,useEffect:Me,useImperativeHandle:Me,useInsertionEffect:Me,useLayoutEffect:Me,useMemo:Me,useReducer:Me,useRef:Me,useState:Me,useDebugValue:Me,useDeferredValue:Me,useTransition:Me,useMutableSource:Me,useSyncExternalStore:Me,useId:Me,unstable_isNewReconciler:!1},cv={readContext:ft,useCallback:function(e,t){return _t().memoizedState=[e,t===void 0?null:t],e},useContext:ft,useEffect:Ku,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ka(4194308,4,Eh.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ka(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ka(4,2,e,t)},useMemo:function(e,t){var n=_t();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=_t();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=lv.bind(null,me,e),[r.memoizedState,e]},useRef:function(e){var t=_t();return e={current:e},t.memoizedState=e},useState:Vu,useDebugValue:Ec,useDeferredValue:function(e){return _t().memoizedState=e},useTransition:function(){var e=Vu(!1),t=e[0];return e=iv.bind(null,e[1]),_t().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=me,s=_t();if(fe){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),Te===null)throw Error(E(349));sr&30||jh(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Ku(kh.bind(null,r,i,e),[e]),r.flags|=2048,Ws(9,wh.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=_t(),t=Te.identifierPrefix;if(fe){var n=Qt,r=Bt;n=(r&~(1<<32-bt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Hs++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[Ot]=t,e[Qs]=r,Hh(e,t,!1,!1),t.stateNode=e;e:{switch(l=$l(n,r),n){case"dialog":ue("cancel",e),ue("close",e),s=r;break;case"iframe":case"object":case"embed":ue("load",e),s=r;break;case"video":case"audio":for(s=0;sJr&&(t.flags|=128,r=!0,ms(i,!1),t.lanes=4194304)}else{if(!r)if(e=hi(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ms(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!fe)return ze(t),null}else 2*we()-i.renderingStartTime>Jr&&n!==1073741824&&(t.flags|=128,r=!0,ms(i,!1),t.lanes=4194304);i.isBackwards?(l.sibling=t.child,t.child=l):(n=i.last,n!==null?n.sibling=l:t.child=l,i.last=l)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=we(),t.sibling=null,n=he.current,le(he,r?n&1|2:n&1),t):(ze(t),null);case 22:case 23:return Mc(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?et&1073741824&&(ze(t),t.subtreeFlags&6&&(t.flags|=8192)):ze(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function vv(e,t){switch(mc(t),t.tag){case 1:return Ye(t.type)&&ii(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Wr(),de(Je),de(De),bc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return kc(t),null;case 13:if(de(he),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));Hr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return de(he),null;case 4:return Wr(),null;case 10:return yc(t.type._context),null;case 22:case 23:return Mc(),null;case 24:return null;default:return null}}var La=!1,Ie=!1,yv=typeof WeakSet=="function"?WeakSet:Set,I=null;function Nr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ye(e,t,r)}else n.current=null}function mo(e,t,n){try{n()}catch(r){ye(e,t,r)}}var nd=!1;function gv(e,t){if(Jl=ni,e=Zf(),fc(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var l=0,o=-1,c=-1,u=0,d=0,f=e,m=null;t:for(;;){for(var v;f!==n||s!==0&&f.nodeType!==3||(o=l+s),f!==i||r!==0&&f.nodeType!==3||(c=l+r),f.nodeType===3&&(l+=f.nodeValue.length),(v=f.firstChild)!==null;)m=f,f=v;for(;;){if(f===e)break t;if(m===n&&++u===s&&(o=l),m===i&&++d===r&&(c=l),(v=f.nextSibling)!==null)break;f=m,m=f.parentNode}f=v}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Yl={focusedElem:e,selectionRange:n},ni=!1,I=t;I!==null;)if(t=I,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,I=e;else for(;I!==null;){t=I;try{var k=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(k!==null){var w=k.memoizedProps,b=k.memoizedState,p=t.stateNode,h=p.getSnapshotBeforeUpdate(t.elementType===t.type?w:vt(t.type,w),b);p.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(j){ye(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,I=e;break}I=t.return}return k=nd,nd=!1,k}function Ps(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&mo(t,n,i)}s=s.next}while(s!==r)}}function zi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function po(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Gh(e){var t=e.alternate;t!==null&&(e.alternate=null,Gh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ot],delete t[Qs],delete t[eo],delete t[tv],delete t[nv])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Jh(e){return e.tag===5||e.tag===3||e.tag===4}function rd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Jh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function xo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ai));else if(r!==4&&(e=e.child,e!==null))for(xo(e,t,n),e=e.sibling;e!==null;)xo(e,t,n),e=e.sibling}function vo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(vo(e,t,n),e=e.sibling;e!==null;)vo(e,t,n),e=e.sibling}var Oe=null,jt=!1;function Zt(e,t,n){for(n=n.child;n!==null;)Yh(e,t,n),n=n.sibling}function Yh(e,t,n){if(Lt&&typeof Lt.onCommitFiberUnmount=="function")try{Lt.onCommitFiberUnmount(_i,n)}catch{}switch(n.tag){case 5:Ie||Nr(n,t);case 6:var r=Oe,s=jt;Oe=null,Zt(e,t,n),Oe=r,jt=s,Oe!==null&&(jt?(e=Oe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Oe.removeChild(n.stateNode));break;case 18:Oe!==null&&(jt?(e=Oe,n=n.stateNode,e.nodeType===8?dl(e.parentNode,n):e.nodeType===1&&dl(e,n),Ds(e)):dl(Oe,n.stateNode));break;case 4:r=Oe,s=jt,Oe=n.stateNode.containerInfo,jt=!0,Zt(e,t,n),Oe=r,jt=s;break;case 0:case 11:case 14:case 15:if(!Ie&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,l=i.destroy;i=i.tag,l!==void 0&&(i&2||i&4)&&mo(n,t,l),s=s.next}while(s!==r)}Zt(e,t,n);break;case 1:if(!Ie&&(Nr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){ye(n,t,o)}Zt(e,t,n);break;case 21:Zt(e,t,n);break;case 22:n.mode&1?(Ie=(r=Ie)||n.memoizedState!==null,Zt(e,t,n),Ie=r):Zt(e,t,n);break;default:Zt(e,t,n)}}function sd(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new yv),t.forEach(function(r){var s=Ev.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function pt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=l),r&=~i}if(r=s,r=we()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*wv(r/1960))-r,10e?16:e,xn===null)var r=!1;else{if(e=xn,xn=null,yi=0,ne&6)throw Error(E(331));var s=ne;for(ne|=4,I=e.current;I!==null;){var i=I,l=i.child;if(I.flags&16){var o=i.deletions;if(o!==null){for(var c=0;cwe()-Lc?er(e,0):Oc|=n),Xe(e,t)}function am(e,t){t===0&&(e.mode&1?(t=ba,ba<<=1,!(ba&130023424)&&(ba=4194304)):t=1);var n=Qe();e=Wt(e,t),e!==null&&(oa(e,t,n),Xe(e,n))}function _v(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),am(e,n)}function Ev(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),am(e,n)}var im;im=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Je.current)Ge=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Ge=!1,pv(e,t,n);Ge=!!(e.flags&131072)}else Ge=!1,fe&&t.flags&1048576&&uh(t,ci,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ha(e,t),e=t.pendingProps;var s=Kr(t,De.current);Tr(t,n),s=Sc(null,t,r,e,s,n);var i=Cc();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Ye(r)?(i=!0,li(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,jc(t),s.updater=Mi,t.stateNode=s,s._reactInternals=t,io(t,r,e,n),t=co(null,t,r,!0,i,n)):(t.tag=0,fe&&i&&hc(t),Ue(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ha(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=Tv(r),e=vt(r,e),s){case 0:t=oo(null,t,r,e,n);break e;case 1:t=Zu(null,t,r,e,n);break e;case 11:t=Yu(null,t,r,e,n);break e;case 14:t=Xu(null,t,r,vt(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:vt(r,s),oo(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:vt(r,s),Zu(e,t,r,s,n);case 3:e:{if(Qh(t),e===null)throw Error(E(387));r=t.pendingProps,i=t.memoizedState,s=i.element,xh(e,t),fi(t,r,null,n);var l=t.memoizedState;if(r=l.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=Gr(Error(E(423)),t),t=ed(e,t,r,n,s);break e}else if(r!==s){s=Gr(Error(E(424)),t),t=ed(e,t,r,n,s);break e}else for(tt=bn(t.stateNode.containerInfo.firstChild),nt=t,fe=!0,wt=null,n=mh(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Hr(),r===s){t=Gt(e,t,n);break e}Ue(e,t,r,n)}t=t.child}return t;case 5:return vh(t),e===null&&ro(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,l=s.children,Xl(r,s)?l=null:i!==null&&Xl(r,i)&&(t.flags|=32),Bh(e,t),Ue(e,t,l,n),t.child;case 6:return e===null&&ro(t),null;case 13:return Vh(e,t,n);case 4:return wc(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=qr(t,null,r,n):Ue(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:vt(r,s),Yu(e,t,r,s,n);case 7:return Ue(e,t,t.pendingProps,n),t.child;case 8:return Ue(e,t,t.pendingProps.children,n),t.child;case 12:return Ue(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,l=s.value,le(ui,r._currentValue),r._currentValue=l,i!==null)if(St(i.value,l)){if(i.children===s.children&&!Je.current){t=Gt(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var o=i.dependencies;if(o!==null){l=i.child;for(var c=o.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=Vt(-1,n&-n),c.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),so(i.return,n,t),o.lanes|=n;break}c=c.next}}else if(i.tag===10)l=i.type===t.type?null:i.child;else if(i.tag===18){if(l=i.return,l===null)throw Error(E(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),so(l,n,t),l=i.sibling}else l=i.child;if(l!==null)l.return=i;else for(l=i;l!==null;){if(l===t){l=null;break}if(i=l.sibling,i!==null){i.return=l.return,l=i;break}l=l.return}i=l}Ue(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Tr(t,n),s=ft(s),r=r(s),t.flags|=1,Ue(e,t,r,n),t.child;case 14:return r=t.type,s=vt(r,t.pendingProps),s=vt(r.type,s),Xu(e,t,r,s,n);case 15:return $h(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:vt(r,s),Ha(e,t),t.tag=1,Ye(r)?(e=!0,li(t)):e=!1,Tr(t,n),Ih(t,r,s),io(t,r,s,n),co(null,t,r,!0,e,n);case 19:return Kh(e,t,n);case 22:return Uh(e,t,n)}throw Error(E(156,t.tag))};function lm(e,t){return Mf(e,t)}function Pv(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ut(e,t,n,r){return new Pv(e,t,n,r)}function Fc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Tv(e){if(typeof e=="function")return Fc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===tc)return 11;if(e===nc)return 14}return 2}function _n(e,t){var n=e.alternate;return n===null?(n=ut(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ga(e,t,n,r,s,i){var l=2;if(r=e,typeof e=="function")Fc(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case pr:return tr(n.children,s,i,t);case ec:l=8,s|=8;break;case Tl:return e=ut(12,n,t,s|2),e.elementType=Tl,e.lanes=i,e;case Ol:return e=ut(13,n,t,s),e.elementType=Ol,e.lanes=i,e;case Ll:return e=ut(19,n,t,s),e.elementType=Ll,e.lanes=i,e;case vf:return Ii(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case pf:l=10;break e;case xf:l=9;break e;case tc:l=11;break e;case nc:l=14;break e;case tn:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=ut(l,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function tr(e,t,n,r){return e=ut(7,e,r,t),e.lanes=n,e}function Ii(e,t,n,r){return e=ut(22,e,r,t),e.elementType=vf,e.lanes=n,e.stateNode={isHidden:!1},e}function gl(e,t,n){return e=ut(6,e,null,t),e.lanes=n,e}function jl(e,t,n){return t=ut(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Ov(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=el(0),this.expirationTimes=el(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=el(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Ic(e,t,n,r,s,i,l,o,c){return e=new Ov(e,t,n,o,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=ut(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},jc(i),e}function Lv(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(dm)}catch(e){console.error(e)}}dm(),df.exports=st;var Iv=df.exports,fd=Iv;El.createRoot=fd.createRoot,El.hydrateRoot=fd.hydrateRoot;var rs=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Dv={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},an,Ko,Ud,Av=(Ud=class{constructor(){$(this,an,Dv);$(this,Ko,!1)}setTimeoutProvider(e){M(this,an,e)}setTimeout(e,t){return y(this,an).setTimeout(e,t)}clearTimeout(e){y(this,an).clearTimeout(e)}setInterval(e,t){return y(this,an).setInterval(e,t)}clearInterval(e){y(this,an).clearInterval(e)}},an=new WeakMap,Ko=new WeakMap,Ud),Vn=new Av;function $v(e){setTimeout(e,0)}var lr=typeof window>"u"||"Deno"in globalThis;function Be(){}function Uv(e,t){return typeof e=="function"?e(t):e}function ko(e){return typeof e=="number"&&e>=0&&e!==1/0}function fm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function En(e,t){return typeof e=="function"?e(t):e}function lt(e,t){return typeof e=="function"?e(t):e}function hd(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:i,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==Uc(l,t.options))return!1}else if(!Js(t.queryKey,l))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||s&&s!==t.state.fetchStatus||i&&!i(t))}function md(e,t){const{exact:n,status:r,predicate:s,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(or(t.options.mutationKey)!==or(i))return!1}else if(!Js(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function Uc(e,t){return((t==null?void 0:t.queryKeyHashFn)||or)(e)}function or(e){return JSON.stringify(e,(t,n)=>bo(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function Js(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Js(e[n],t[n])):!1}var Bv=Object.prototype.hasOwnProperty;function hm(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=pd(e)&&pd(t);if(!r&&!(bo(e)&&bo(t)))return t;const i=(r?e:Object.keys(e)).length,l=r?t:Object.keys(t),o=l.length,c=r?new Array(o):{};let u=0;for(let d=0;d{Vn.setTimeout(t,e)})}function No(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?hm(e,t):t}function Vv(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Kv(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Bc=Symbol();function mm(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Bc?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Qc(e,t){return typeof e=="function"?e(...t):!!e}function Hv(e,t,n){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),e}var Kn,ln,Lr,Bd,qv=(Bd=class extends rs{constructor(){super();$(this,Kn);$(this,ln);$(this,Lr);M(this,Lr,t=>{if(!lr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){y(this,ln)||this.setEventListener(y(this,Lr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,ln))==null||t.call(this),M(this,ln,void 0))}setEventListener(t){var n;M(this,Lr,t),(n=y(this,ln))==null||n.call(this),M(this,ln,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){y(this,Kn)!==t&&(M(this,Kn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof y(this,Kn)=="boolean"?y(this,Kn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Kn=new WeakMap,ln=new WeakMap,Lr=new WeakMap,Bd),Vc=new qv;function So(){let e,t;const n=new Promise((s,i)=>{e=s,t=i});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var Wv=$v;function Gv(){let e=[],t=0,n=o=>{o()},r=o=>{o()},s=Wv;const i=o=>{t?e.push(o):s(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&s(()=>{r(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;t++;try{c=o()}finally{t--,t||l()}return c},batchCalls:o=>(...c)=>{i(()=>{o(...c)})},schedule:i,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{s=o}}}var Se=Gv(),Rr,on,Mr,Qd,Jv=(Qd=class extends rs{constructor(){super();$(this,Rr,!0);$(this,on);$(this,Mr);M(this,Mr,t=>{if(!lr&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){y(this,on)||this.setEventListener(y(this,Mr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,on))==null||t.call(this),M(this,on,void 0))}setEventListener(t){var n;M(this,Mr,t),(n=y(this,on))==null||n.call(this),M(this,on,t(this.setOnline.bind(this)))}setOnline(t){y(this,Rr)!==t&&(M(this,Rr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return y(this,Rr)}},Rr=new WeakMap,on=new WeakMap,Mr=new WeakMap,Qd),ki=new Jv;function Yv(e){return Math.min(1e3*2**e,3e4)}function pm(e){return(e??"online")==="online"?ki.isOnline():!0}var Co=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function xm(e){let t=!1,n=0,r;const s=So(),i=()=>s.status!=="pending",l=w=>{var b;if(!i()){const p=new Co(w);m(p),(b=e.onCancel)==null||b.call(e,p)}},o=()=>{t=!0},c=()=>{t=!1},u=()=>Vc.isFocused()&&(e.networkMode==="always"||ki.isOnline())&&e.canRun(),d=()=>pm(e.networkMode)&&e.canRun(),f=w=>{i()||(r==null||r(),s.resolve(w))},m=w=>{i()||(r==null||r(),s.reject(w))},v=()=>new Promise(w=>{var b;r=p=>{(i()||u())&&w(p)},(b=e.onPause)==null||b.call(e)}).then(()=>{var w;r=void 0,i()||(w=e.onContinue)==null||w.call(e)}),k=()=>{if(i())return;let w;const b=n===0?e.initialPromise:void 0;try{w=b??e.fn()}catch(p){w=Promise.reject(p)}Promise.resolve(w).then(f).catch(p=>{var S;if(i())return;const h=e.retry??(lr?0:3),x=e.retryDelay??Yv,j=typeof x=="function"?x(n,p):x,C=h===!0||typeof h=="number"&&nu()?void 0:v()).then(()=>{t?m(p):k()})})};return{promise:s,status:()=>s.status,cancel:l,continue:()=>(r==null||r(),s),cancelRetry:o,continueRetry:c,canStart:d,start:()=>(d()?k():v().then(k),s)}}var Hn,Vd,vm=(Vd=class{constructor(){$(this,Hn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ko(this.gcTime)&&M(this,Hn,Vn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(lr?1/0:5*60*1e3))}clearGcTimeout(){y(this,Hn)&&(Vn.clearTimeout(y(this,Hn)),M(this,Hn,void 0))}},Hn=new WeakMap,Vd),qn,zr,it,Wn,Ee,na,Gn,yt,zt,Kd,Xv=(Kd=class extends vm{constructor(t){super();$(this,yt);$(this,qn);$(this,zr);$(this,it);$(this,Wn);$(this,Ee);$(this,na);$(this,Gn);M(this,Gn,!1),M(this,na,t.defaultOptions),this.setOptions(t.options),this.observers=[],M(this,Wn,t.client),M(this,it,y(this,Wn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,M(this,qn,yd(this.options)),this.state=t.state??y(this,qn),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=y(this,Ee))==null?void 0:t.promise}setOptions(t){if(this.options={...y(this,na),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=yd(this.options);n.data!==void 0&&(this.setState(vd(n.data,n.dataUpdatedAt)),M(this,qn,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&y(this,it).remove(this)}setData(t,n){const r=No(this.state.data,t,this.options);return G(this,yt,zt).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){G(this,yt,zt).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=y(this,Ee))==null?void 0:r.promise;return(s=y(this,Ee))==null||s.cancel(t),n?n.then(Be).catch(Be):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(y(this,qn))}isActive(){return this.observers.some(t=>lt(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Bc||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>En(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!fm(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ee))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ee))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),y(this,it).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(y(this,Ee)&&(y(this,Gn)?y(this,Ee).cancel({revert:!0}):y(this,Ee).cancelRetry()),this.scheduleGc()),y(this,it).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||G(this,yt,zt).call(this,{type:"invalidate"})}async fetch(t,n){var c,u,d,f,m,v,k,w,b,p,h,x;if(this.state.fetchStatus!=="idle"&&((c=y(this,Ee))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(y(this,Ee))return y(this,Ee).continueRetry(),y(this,Ee).promise}if(t&&this.setOptions(t),!this.options.queryFn){const j=this.observers.find(C=>C.options.queryFn);j&&this.setOptions(j.options)}const r=new AbortController,s=j=>{Object.defineProperty(j,"signal",{enumerable:!0,get:()=>(M(this,Gn,!0),r.signal)})},i=()=>{const j=mm(this.options,n),S=(()=>{const N={client:y(this,Wn),queryKey:this.queryKey,meta:this.meta};return s(N),N})();return M(this,Gn,!1),this.options.persister?this.options.persister(j,S,this):j(S)},o=(()=>{const j={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:y(this,Wn),state:this.state,fetchFn:i};return s(j),j})();(u=this.options.behavior)==null||u.onFetch(o,this),M(this,zr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=o.fetchOptions)==null?void 0:d.meta))&&G(this,yt,zt).call(this,{type:"fetch",meta:(f=o.fetchOptions)==null?void 0:f.meta}),M(this,Ee,xm({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:j=>{j instanceof Co&&j.revert&&this.setState({...y(this,zr),fetchStatus:"idle"}),r.abort()},onFail:(j,C)=>{G(this,yt,zt).call(this,{type:"failed",failureCount:j,error:C})},onPause:()=>{G(this,yt,zt).call(this,{type:"pause"})},onContinue:()=>{G(this,yt,zt).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const j=await y(this,Ee).start();if(j===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(j),(v=(m=y(this,it).config).onSuccess)==null||v.call(m,j,this),(w=(k=y(this,it).config).onSettled)==null||w.call(k,j,this.state.error,this),j}catch(j){if(j instanceof Co){if(j.silent)return y(this,Ee).promise;if(j.revert){if(this.state.data===void 0)throw j;return this.state.data}}throw G(this,yt,zt).call(this,{type:"error",error:j}),(p=(b=y(this,it).config).onError)==null||p.call(b,j,this),(x=(h=y(this,it).config).onSettled)==null||x.call(h,this.state.data,j,this),j}finally{this.scheduleGc()}}},qn=new WeakMap,zr=new WeakMap,it=new WeakMap,Wn=new WeakMap,Ee=new WeakMap,na=new WeakMap,Gn=new WeakMap,yt=new WeakSet,zt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...ym(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...vd(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return M(this,zr,t.manual?s:void 0),s;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Se.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),y(this,it).notify({query:this,type:"updated",action:t})})},Kd);function ym(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:pm(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function vd(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function yd(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var He,ee,ra,$e,Jn,Fr,Dt,cn,sa,Ir,Dr,Yn,Xn,un,Ar,ae,ks,_o,Eo,Po,To,Oo,Lo,Ro,gm,Hd,Zv=(Hd=class extends rs{constructor(t,n){super();$(this,ae);$(this,He);$(this,ee);$(this,ra);$(this,$e);$(this,Jn);$(this,Fr);$(this,Dt);$(this,cn);$(this,sa);$(this,Ir);$(this,Dr);$(this,Yn);$(this,Xn);$(this,un);$(this,Ar,new Set);this.options=n,M(this,He,t),M(this,cn,null),M(this,Dt,So()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(y(this,ee).addObserver(this),gd(y(this,ee),this.options)?G(this,ae,ks).call(this):this.updateResult(),G(this,ae,To).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Mo(y(this,ee),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Mo(y(this,ee),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,G(this,ae,Oo).call(this),G(this,ae,Lo).call(this),y(this,ee).removeObserver(this)}setOptions(t){const n=this.options,r=y(this,ee);if(this.options=y(this,He).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof lt(this.options.enabled,y(this,ee))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");G(this,ae,Ro).call(this),y(this,ee).setOptions(this.options),n._defaulted&&!wi(this.options,n)&&y(this,He).getQueryCache().notify({type:"observerOptionsUpdated",query:y(this,ee),observer:this});const s=this.hasListeners();s&&jd(y(this,ee),r,this.options,n)&&G(this,ae,ks).call(this),this.updateResult(),s&&(y(this,ee)!==r||lt(this.options.enabled,y(this,ee))!==lt(n.enabled,y(this,ee))||En(this.options.staleTime,y(this,ee))!==En(n.staleTime,y(this,ee)))&&G(this,ae,_o).call(this);const i=G(this,ae,Eo).call(this);s&&(y(this,ee)!==r||lt(this.options.enabled,y(this,ee))!==lt(n.enabled,y(this,ee))||i!==y(this,un))&&G(this,ae,Po).call(this,i)}getOptimisticResult(t){const n=y(this,He).getQueryCache().build(y(this,He),t),r=this.createResult(n,t);return ty(this,r)&&(M(this,$e,r),M(this,Fr,this.options),M(this,Jn,y(this,ee).state)),r}getCurrentResult(){return y(this,$e)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&y(this,Dt).status==="pending"&&y(this,Dt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){y(this,Ar).add(t)}getCurrentQuery(){return y(this,ee)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=y(this,He).defaultQueryOptions(t),r=y(this,He).getQueryCache().build(y(this,He),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return G(this,ae,ks).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),y(this,$e)))}createResult(t,n){var z;const r=y(this,ee),s=this.options,i=y(this,$e),l=y(this,Jn),o=y(this,Fr),u=t!==r?t.state:y(this,ra),{state:d}=t;let f={...d},m=!1,v;if(n._optimisticResults){const O=this.hasListeners(),B=!O&&gd(t,n),J=O&&jd(t,r,n,s);(B||J)&&(f={...f,...ym(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:k,errorUpdatedAt:w,status:b}=f;v=f.data;let p=!1;if(n.placeholderData!==void 0&&v===void 0&&b==="pending"){let O;i!=null&&i.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(O=i.data,p=!0):O=typeof n.placeholderData=="function"?n.placeholderData((z=y(this,Dr))==null?void 0:z.state.data,y(this,Dr)):n.placeholderData,O!==void 0&&(b="success",v=No(i==null?void 0:i.data,O,n),m=!0)}if(n.select&&v!==void 0&&!p)if(i&&v===(l==null?void 0:l.data)&&n.select===y(this,sa))v=y(this,Ir);else try{M(this,sa,n.select),v=n.select(v),v=No(i==null?void 0:i.data,v,n),M(this,Ir,v),M(this,cn,null)}catch(O){M(this,cn,O)}y(this,cn)&&(k=y(this,cn),v=y(this,Ir),w=Date.now(),b="error");const h=f.fetchStatus==="fetching",x=b==="pending",j=b==="error",C=x&&h,S=v!==void 0,_={status:b,fetchStatus:f.fetchStatus,isPending:x,isSuccess:b==="success",isError:j,isInitialLoading:C,isLoading:C,data:v,dataUpdatedAt:f.dataUpdatedAt,error:k,errorUpdatedAt:w,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:h,isRefetching:h&&!x,isLoadingError:j&&!S,isPaused:f.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:j&&S,isStale:Kc(t,n),refetch:this.refetch,promise:y(this,Dt),isEnabled:lt(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=_.data!==void 0,B=_.status==="error"&&!O,J=D=>{B?D.reject(_.error):O&&D.resolve(_.data)},se=()=>{const D=M(this,Dt,_.promise=So());J(D)},ce=y(this,Dt);switch(ce.status){case"pending":t.queryHash===r.queryHash&&J(ce);break;case"fulfilled":(B||_.data!==ce.value)&&se();break;case"rejected":(!B||_.error!==ce.reason)&&se();break}}return _}updateResult(){const t=y(this,$e),n=this.createResult(y(this,ee),this.options);if(M(this,Jn,y(this,ee).state),M(this,Fr,this.options),y(this,Jn).data!==void 0&&M(this,Dr,y(this,ee)),wi(n,t))return;M(this,$e,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!y(this,Ar).size)return!0;const l=new Set(i??y(this,Ar));return this.options.throwOnError&&l.add("error"),Object.keys(y(this,$e)).some(o=>{const c=o;return y(this,$e)[c]!==t[c]&&l.has(c)})};G(this,ae,gm).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&G(this,ae,To).call(this)}},He=new WeakMap,ee=new WeakMap,ra=new WeakMap,$e=new WeakMap,Jn=new WeakMap,Fr=new WeakMap,Dt=new WeakMap,cn=new WeakMap,sa=new WeakMap,Ir=new WeakMap,Dr=new WeakMap,Yn=new WeakMap,Xn=new WeakMap,un=new WeakMap,Ar=new WeakMap,ae=new WeakSet,ks=function(t){G(this,ae,Ro).call(this);let n=y(this,ee).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Be)),n},_o=function(){G(this,ae,Oo).call(this);const t=En(this.options.staleTime,y(this,ee));if(lr||y(this,$e).isStale||!ko(t))return;const r=fm(y(this,$e).dataUpdatedAt,t)+1;M(this,Yn,Vn.setTimeout(()=>{y(this,$e).isStale||this.updateResult()},r))},Eo=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(y(this,ee)):this.options.refetchInterval)??!1},Po=function(t){G(this,ae,Lo).call(this),M(this,un,t),!(lr||lt(this.options.enabled,y(this,ee))===!1||!ko(y(this,un))||y(this,un)===0)&&M(this,Xn,Vn.setInterval(()=>{(this.options.refetchIntervalInBackground||Vc.isFocused())&&G(this,ae,ks).call(this)},y(this,un)))},To=function(){G(this,ae,_o).call(this),G(this,ae,Po).call(this,G(this,ae,Eo).call(this))},Oo=function(){y(this,Yn)&&(Vn.clearTimeout(y(this,Yn)),M(this,Yn,void 0))},Lo=function(){y(this,Xn)&&(Vn.clearInterval(y(this,Xn)),M(this,Xn,void 0))},Ro=function(){const t=y(this,He).getQueryCache().build(y(this,He),this.options);if(t===y(this,ee))return;const n=y(this,ee);M(this,ee,t),M(this,ra,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},gm=function(t){Se.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(y(this,$e))}),y(this,He).getQueryCache().notify({query:y(this,ee),type:"observerResultsUpdated"})})},Hd);function ey(e,t){return lt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function gd(e,t){return ey(e,t)||e.state.data!==void 0&&Mo(e,t,t.refetchOnMount)}function Mo(e,t,n){if(lt(t.enabled,e)!==!1&&En(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Kc(e,t)}return!1}function jd(e,t,n,r){return(e!==t||lt(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Kc(e,n)}function Kc(e,t){return lt(t.enabled,e)!==!1&&e.isStaleByTime(En(t.staleTime,e))}function ty(e,t){return!wi(e.getCurrentResult(),t)}function wd(e){return{onFetch:(t,n)=>{var d,f,m,v,k;const r=t.options,s=(m=(f=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:f.fetchMore)==null?void 0:m.direction,i=((v=t.state.data)==null?void 0:v.pages)||[],l=((k=t.state.data)==null?void 0:k.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const u=async()=>{let w=!1;const b=x=>{Hv(x,()=>t.signal,()=>w=!0)},p=mm(t.options,t.fetchOptions),h=async(x,j,C)=>{if(w)return Promise.reject();if(j==null&&x.pages.length)return Promise.resolve(x);const N=(()=>{const B={client:t.client,queryKey:t.queryKey,pageParam:j,direction:C?"backward":"forward",meta:t.options.meta};return b(B),B})(),_=await p(N),{maxPages:z}=t.options,O=C?Kv:Vv;return{pages:O(x.pages,_,z),pageParams:O(x.pageParams,j,z)}};if(s&&i.length){const x=s==="backward",j=x?ny:kd,C={pages:i,pageParams:l},S=j(r,C);o=await h(C,S,x)}else{const x=e??i.length;do{const j=c===0?l[0]??r.initialPageParam:kd(r,o);if(c>0&&j==null)break;o=await h(o,j),c++}while(c{var w,b;return(b=(w=t.options).persister)==null?void 0:b.call(w,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function kd(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function ny(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var aa,Et,Fe,Zn,Pt,en,qd,ry=(qd=class extends vm{constructor(t){super();$(this,Pt);$(this,aa);$(this,Et);$(this,Fe);$(this,Zn);M(this,aa,t.client),this.mutationId=t.mutationId,M(this,Fe,t.mutationCache),M(this,Et,[]),this.state=t.state||jm(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){y(this,Et).includes(t)||(y(this,Et).push(t),this.clearGcTimeout(),y(this,Fe).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){M(this,Et,y(this,Et).filter(n=>n!==t)),this.scheduleGc(),y(this,Fe).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){y(this,Et).length||(this.state.status==="pending"?this.scheduleGc():y(this,Fe).remove(this))}continue(){var t;return((t=y(this,Zn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,u,d,f,m,v,k,w,b,p,h,x,j,C,S,N;const n=()=>{G(this,Pt,en).call(this,{type:"continue"})},r={client:y(this,aa),meta:this.options.meta,mutationKey:this.options.mutationKey};M(this,Zn,xm({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(_,z)=>{G(this,Pt,en).call(this,{type:"failed",failureCount:_,error:z})},onPause:()=>{G(this,Pt,en).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>y(this,Fe).canRun(this)}));const s=this.state.status==="pending",i=!y(this,Zn).canStart();try{if(s)n();else{G(this,Pt,en).call(this,{type:"pending",variables:t,isPaused:i}),y(this,Fe).config.onMutate&&await y(this,Fe).config.onMutate(t,this,r);const z=await((o=(l=this.options).onMutate)==null?void 0:o.call(l,t,r));z!==this.state.context&&G(this,Pt,en).call(this,{type:"pending",context:z,variables:t,isPaused:i})}const _=await y(this,Zn).start();return await((u=(c=y(this,Fe).config).onSuccess)==null?void 0:u.call(c,_,t,this.state.context,this,r)),await((f=(d=this.options).onSuccess)==null?void 0:f.call(d,_,t,this.state.context,r)),await((v=(m=y(this,Fe).config).onSettled)==null?void 0:v.call(m,_,null,this.state.variables,this.state.context,this,r)),await((w=(k=this.options).onSettled)==null?void 0:w.call(k,_,null,t,this.state.context,r)),G(this,Pt,en).call(this,{type:"success",data:_}),_}catch(_){try{await((p=(b=y(this,Fe).config).onError)==null?void 0:p.call(b,_,t,this.state.context,this,r))}catch(z){Promise.reject(z)}try{await((x=(h=this.options).onError)==null?void 0:x.call(h,_,t,this.state.context,r))}catch(z){Promise.reject(z)}try{await((C=(j=y(this,Fe).config).onSettled)==null?void 0:C.call(j,void 0,_,this.state.variables,this.state.context,this,r))}catch(z){Promise.reject(z)}try{await((N=(S=this.options).onSettled)==null?void 0:N.call(S,void 0,_,t,this.state.context,r))}catch(z){Promise.reject(z)}throw G(this,Pt,en).call(this,{type:"error",error:_}),_}finally{y(this,Fe).runNext(this)}}},aa=new WeakMap,Et=new WeakMap,Fe=new WeakMap,Zn=new WeakMap,Pt=new WeakSet,en=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Se.batch(()=>{y(this,Et).forEach(r=>{r.onMutationUpdate(t)}),y(this,Fe).notify({mutation:this,type:"updated",action:t})})},qd);function jm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var At,gt,ia,Wd,sy=(Wd=class extends rs{constructor(t={}){super();$(this,At);$(this,gt);$(this,ia);this.config=t,M(this,At,new Set),M(this,gt,new Map),M(this,ia,0)}build(t,n,r){const s=new ry({client:t,mutationCache:this,mutationId:++va(this,ia)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){y(this,At).add(t);const n=za(t);if(typeof n=="string"){const r=y(this,gt).get(n);r?r.push(t):y(this,gt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(y(this,At).delete(t)){const n=za(t);if(typeof n=="string"){const r=y(this,gt).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&y(this,gt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=za(t);if(typeof n=="string"){const r=y(this,gt).get(n),s=r==null?void 0:r.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=za(t);if(typeof n=="string"){const s=(r=y(this,gt).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Se.batch(()=>{y(this,At).forEach(t=>{this.notify({type:"removed",mutation:t})}),y(this,At).clear(),y(this,gt).clear()})}getAll(){return Array.from(y(this,At))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>md(n,r))}findAll(t={}){return this.getAll().filter(n=>md(t,n))}notify(t){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Se.batch(()=>Promise.all(t.map(n=>n.continue().catch(Be))))}},At=new WeakMap,gt=new WeakMap,ia=new WeakMap,Wd);function za(e){var t;return(t=e.options.scope)==null?void 0:t.id}var $t,dn,qe,Ut,Kt,Ja,zo,Gd,ay=(Gd=class extends rs{constructor(n,r){super();$(this,Kt);$(this,$t);$(this,dn);$(this,qe);$(this,Ut);M(this,$t,n),this.setOptions(r),this.bindMethods(),G(this,Kt,Ja).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=y(this,$t).defaultMutationOptions(n),wi(this.options,r)||y(this,$t).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,qe),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&or(r.mutationKey)!==or(this.options.mutationKey)?this.reset():((s=y(this,qe))==null?void 0:s.state.status)==="pending"&&y(this,qe).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=y(this,qe))==null||n.removeObserver(this)}onMutationUpdate(n){G(this,Kt,Ja).call(this),G(this,Kt,zo).call(this,n)}getCurrentResult(){return y(this,dn)}reset(){var n;(n=y(this,qe))==null||n.removeObserver(this),M(this,qe,void 0),G(this,Kt,Ja).call(this),G(this,Kt,zo).call(this)}mutate(n,r){var s;return M(this,Ut,r),(s=y(this,qe))==null||s.removeObserver(this),M(this,qe,y(this,$t).getMutationCache().build(y(this,$t),this.options)),y(this,qe).addObserver(this),y(this,qe).execute(n)}},$t=new WeakMap,dn=new WeakMap,qe=new WeakMap,Ut=new WeakMap,Kt=new WeakSet,Ja=function(){var r;const n=((r=y(this,qe))==null?void 0:r.state)??jm();M(this,dn,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},zo=function(n){Se.batch(()=>{var r,s,i,l,o,c,u,d;if(y(this,Ut)&&this.hasListeners()){const f=y(this,dn).variables,m=y(this,dn).context,v={client:y(this,$t),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(s=(r=y(this,Ut)).onSuccess)==null||s.call(r,n.data,f,m,v)}catch(k){Promise.reject(k)}try{(l=(i=y(this,Ut)).onSettled)==null||l.call(i,n.data,null,f,m,v)}catch(k){Promise.reject(k)}}else if((n==null?void 0:n.type)==="error"){try{(c=(o=y(this,Ut)).onError)==null||c.call(o,n.error,f,m,v)}catch(k){Promise.reject(k)}try{(d=(u=y(this,Ut)).onSettled)==null||d.call(u,void 0,n.error,f,m,v)}catch(k){Promise.reject(k)}}}this.listeners.forEach(f=>{f(y(this,dn))})})},Gd),Tt,Jd,iy=(Jd=class extends rs{constructor(t={}){super();$(this,Tt);this.config=t,M(this,Tt,new Map)}build(t,n,r){const s=n.queryKey,i=n.queryHash??Uc(s,n);let l=this.get(i);return l||(l=new Xv({client:t,queryKey:s,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(l)),l}add(t){y(this,Tt).has(t.queryHash)||(y(this,Tt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=y(this,Tt).get(t.queryHash);n&&(t.destroy(),n===t&&y(this,Tt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Se.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return y(this,Tt).get(t)}getAll(){return[...y(this,Tt).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>hd(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>hd(t,r)):n}notify(t){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Se.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Se.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Tt=new WeakMap,Jd),ve,fn,hn,$r,Ur,mn,Br,Qr,Yd,ly=(Yd=class{constructor(e={}){$(this,ve);$(this,fn);$(this,hn);$(this,$r);$(this,Ur);$(this,mn);$(this,Br);$(this,Qr);M(this,ve,e.queryCache||new iy),M(this,fn,e.mutationCache||new sy),M(this,hn,e.defaultOptions||{}),M(this,$r,new Map),M(this,Ur,new Map),M(this,mn,0)}mount(){va(this,mn)._++,y(this,mn)===1&&(M(this,Br,Vc.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,ve).onFocus())})),M(this,Qr,ki.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,ve).onOnline())})))}unmount(){var e,t;va(this,mn)._--,y(this,mn)===0&&((e=y(this,Br))==null||e.call(this),M(this,Br,void 0),(t=y(this,Qr))==null||t.call(this),M(this,Qr,void 0))}isFetching(e){return y(this,ve).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return y(this,fn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,ve).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=y(this,ve).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(En(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return y(this,ve).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=y(this,ve).get(r.queryHash),i=s==null?void 0:s.state.data,l=Uv(t,i);if(l!==void 0)return y(this,ve).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return Se.batch(()=>y(this,ve).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,ve).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=y(this,ve);Se.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=y(this,ve);return Se.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Se.batch(()=>y(this,ve).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Be).catch(Be)}invalidateQueries(e,t={}){return Se.batch(()=>(y(this,ve).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Se.batch(()=>y(this,ve).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let i=s.fetch(void 0,n);return n.throwOnError||(i=i.catch(Be)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Be)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=y(this,ve).build(this,t);return n.isStaleByTime(En(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Be).catch(Be)}fetchInfiniteQuery(e){return e.behavior=wd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Be).catch(Be)}ensureInfiniteQueryData(e){return e.behavior=wd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ki.isOnline()?y(this,fn).resumePausedMutations():Promise.resolve()}getQueryCache(){return y(this,ve)}getMutationCache(){return y(this,fn)}getDefaultOptions(){return y(this,hn)}setDefaultOptions(e){M(this,hn,e)}setQueryDefaults(e,t){y(this,$r).set(or(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...y(this,$r).values()],n={};return t.forEach(r=>{Js(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){y(this,Ur).set(or(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...y(this,Ur).values()],n={};return t.forEach(r=>{Js(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...y(this,hn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Uc(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Bc&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...y(this,hn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){y(this,ve).clear(),y(this,fn).clear()}},ve=new WeakMap,fn=new WeakMap,hn=new WeakMap,$r=new WeakMap,Ur=new WeakMap,mn=new WeakMap,Br=new WeakMap,Qr=new WeakMap,Yd),wm=g.createContext(void 0),Yt=e=>{const t=g.useContext(wm);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},oy=({client:e,children:t})=>(g.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),a.jsx(wm.Provider,{value:e,children:t})),km=g.createContext(!1),cy=()=>g.useContext(km);km.Provider;function uy(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var dy=g.createContext(uy()),fy=()=>g.useContext(dy),hy=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Qc(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},my=e=>{g.useEffect(()=>{e.clearReset()},[e])},py=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||Qc(n,[e.error,r])),xy=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},vy=(e,t)=>e.isLoading&&e.isFetching&&!t,yy=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,bd=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function gy(e,t,n){var m,v,k,w;const r=cy(),s=fy(),i=Yt(),l=i.defaultQueryOptions(e);(v=(m=i.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||v.call(m,l);const o=i.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",xy(l),hy(l,s,o),my(s);const c=!i.getQueryCache().get(l.queryHash),[u]=g.useState(()=>new t(i,l)),d=u.getOptimisticResult(l),f=!r&&e.subscribed!==!1;if(g.useSyncExternalStore(g.useCallback(b=>{const p=f?u.subscribe(Se.batchCalls(b)):Be;return u.updateResult(),p},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),g.useEffect(()=>{u.setOptions(l)},[l,u]),yy(l,d))throw bd(l,u,s);if(py({result:d,errorResetBoundary:s,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw d.error;if((w=(k=i.getDefaultOptions().queries)==null?void 0:k._experimental_afterQuery)==null||w.call(k,l,d),l.experimental_prefetchInRender&&!lr&&vy(d,r)){const b=c?bd(l,u,s):o==null?void 0:o.promise;b==null||b.catch(Be).finally(()=>{u.updateResult()})}return l.notifyOnChangeProps?d:u.trackResult(d)}function oe(e,t){return gy(e,Zv)}function Ze(e,t){const n=Yt(),[r]=g.useState(()=>new ay(n,e));g.useEffect(()=>{r.setOptions(e)},[r,e]);const s=g.useSyncExternalStore(g.useCallback(l=>r.subscribe(Se.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=g.useCallback((l,o)=>{r.mutate(l,o).catch(Be)},[r]);if(s.error&&Qc(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}/** + * @remix-run/router v1.23.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Ys(){return Ys=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function Hc(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function wy(){return Math.random().toString(36).substr(2,8)}function Sd(e,t){return{usr:e.state,key:e.key,idx:t}}function Fo(e,t,n,r){return n===void 0&&(n=null),Ys({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?ss(t):t,{state:n,key:t&&t.key||r||wy()})}function bi(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function ss(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function ky(e,t,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:i=!1}=r,l=s.history,o=vn.Pop,c=null,u=d();u==null&&(u=0,l.replaceState(Ys({},l.state,{idx:u}),""));function d(){return(l.state||{idx:null}).idx}function f(){o=vn.Pop;let b=d(),p=b==null?null:b-u;u=b,c&&c({action:o,location:w.location,delta:p})}function m(b,p){o=vn.Push;let h=Fo(w.location,b,p);u=d()+1;let x=Sd(h,u),j=w.createHref(h);try{l.pushState(x,"",j)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;s.location.assign(j)}i&&c&&c({action:o,location:w.location,delta:1})}function v(b,p){o=vn.Replace;let h=Fo(w.location,b,p);u=d();let x=Sd(h,u),j=w.createHref(h);l.replaceState(x,"",j),i&&c&&c({action:o,location:w.location,delta:0})}function k(b){let p=s.location.origin!=="null"?s.location.origin:s.location.href,h=typeof b=="string"?b:bi(b);return h=h.replace(/ $/,"%20"),ge(p,"No window.location.(origin|href) available to create URL for href: "+h),new URL(h,p)}let w={get action(){return o},get location(){return e(s,l)},listen(b){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(Nd,f),c=b,()=>{s.removeEventListener(Nd,f),c=null}},createHref(b){return t(s,b)},createURL:k,encodeLocation(b){let p=k(b);return{pathname:p.pathname,search:p.search,hash:p.hash}},push:m,replace:v,go(b){return l.go(b)}};return w}var Cd;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Cd||(Cd={}));function by(e,t,n){return n===void 0&&(n="/"),Ny(e,t,n)}function Ny(e,t,n,r){let s=typeof t=="string"?ss(t):t,i=Yr(s.pathname||"/",n);if(i==null)return null;let l=bm(e);Sy(l);let o=null;for(let c=0;o==null&&c{let c={relativePath:o===void 0?i.path||"":o,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};c.relativePath.startsWith("/")&&(ge(c.relativePath.startsWith(r),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(r.length));let u=Pn([r,c.relativePath]),d=n.concat(c);i.children&&i.children.length>0&&(ge(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),bm(i.children,t,d,u)),!(i.path==null&&!i.index)&&t.push({path:u,score:Ly(u,i.index),routesMeta:d})};return e.forEach((i,l)=>{var o;if(i.path===""||!((o=i.path)!=null&&o.includes("?")))s(i,l);else for(let c of Nm(i.path))s(i,l,c)}),t}function Nm(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return s?[i,""]:[i];let l=Nm(r.join("/")),o=[];return o.push(...l.map(c=>c===""?i:[i,c].join("/"))),s&&o.push(...l),o.map(c=>e.startsWith("/")&&c===""?"/":c)}function Sy(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ry(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const Cy=/^:[\w-]+$/,_y=3,Ey=2,Py=1,Ty=10,Oy=-2,_d=e=>e==="*";function Ly(e,t){let n=e.split("/"),r=n.length;return n.some(_d)&&(r+=Oy),t&&(r+=Ey),n.filter(s=>!_d(s)).reduce((s,i)=>s+(Cy.test(i)?_y:i===""?Py:Ty),r)}function Ry(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function My(e,t,n){let{routesMeta:r}=e,s={},i="/",l=[];for(let o=0;o{let{paramName:m,isOptional:v}=d;if(m==="*"){let w=o[f]||"";l=i.slice(0,i.length-w.length).replace(/(.)\/+$/,"$1")}const k=o[f];return v&&!k?u[m]=void 0:u[m]=(k||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:l,pattern:e}}function zy(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),Hc(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,c)=>(r.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function Fy(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Hc(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Yr(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const Iy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Dy=e=>Iy.test(e);function Ay(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?ss(e):e,i;if(n)if(Dy(n))i=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),Hc(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?i=Ed(n.substring(1),"/"):i=Ed(n,t)}else i=t;return{pathname:i,search:By(r),hash:Qy(s)}}function Ed(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function wl(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function $y(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Sm(e,t){let n=$y(e);return t?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Cm(e,t,n,r){r===void 0&&(r=!1);let s;typeof e=="string"?s=ss(e):(s=Ys({},e),ge(!s.pathname||!s.pathname.includes("?"),wl("?","pathname","search",s)),ge(!s.pathname||!s.pathname.includes("#"),wl("#","pathname","hash",s)),ge(!s.search||!s.search.includes("#"),wl("#","search","hash",s)));let i=e===""||s.pathname==="",l=i?"/":s.pathname,o;if(l==null)o=n;else{let f=t.length-1;if(!r&&l.startsWith("..")){let m=l.split("/");for(;m[0]==="..";)m.shift(),f-=1;s.pathname=m.join("/")}o=f>=0?t[f]:"/"}let c=Ay(s,o),u=l&&l!=="/"&&l.endsWith("/"),d=(i||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}const Pn=e=>e.join("/").replace(/\/\/+/g,"/"),Uy=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),By=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Qy=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Vy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const _m=["post","put","patch","delete"];new Set(_m);const Ky=["get",..._m];new Set(Ky);/** + * React Router v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Xs(){return Xs=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),g.useCallback(function(u,d){if(d===void 0&&(d={}),!o.current)return;if(typeof u=="number"){r.go(u);return}let f=Cm(u,JSON.parse(l),i,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Pn([t,f.pathname])),(d.replace?r.replace:r.push)(f,d.state,d)},[t,r,l,i,e])}const Wy=g.createContext(null);function Gy(e){let t=g.useContext(Xt).outlet;return t&&g.createElement(Wy.Provider,{value:e},t)}function ha(){let{matches:e}=g.useContext(Xt),t=e[e.length-1];return t?t.params:{}}function Vi(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=g.useContext(In),{matches:s}=g.useContext(Xt),{pathname:i}=as(),l=JSON.stringify(Sm(s,r.v7_relativeSplatPath));return g.useMemo(()=>Cm(e,JSON.parse(l),i,n==="path"),[e,l,i,n])}function Jy(e,t){return Yy(e,t)}function Yy(e,t,n,r){fa()||ge(!1);let{navigator:s}=g.useContext(In),{matches:i}=g.useContext(Xt),l=i[i.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let u=as(),d;if(t){var f;let b=typeof t=="string"?ss(t):t;c==="/"||(f=b.pathname)!=null&&f.startsWith(c)||ge(!1),d=b}else d=u;let m=d.pathname||"/",v=m;if(c!=="/"){let b=c.replace(/^\//,"").split("/");v="/"+m.replace(/^\//,"").split("/").slice(b.length).join("/")}let k=by(e,{pathname:v}),w=ng(k&&k.map(b=>Object.assign({},b,{params:Object.assign({},o,b.params),pathname:Pn([c,s.encodeLocation?s.encodeLocation(b.pathname).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?c:Pn([c,s.encodeLocation?s.encodeLocation(b.pathnameBase).pathname:b.pathnameBase])})),i,n,r);return t&&w?g.createElement(Qi.Provider,{value:{location:Xs({pathname:"/",search:"",hash:"",state:null,key:"default"},d),navigationType:vn.Pop}},w):w}function Xy(){let e=ig(),t=Vy(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return g.createElement(g.Fragment,null,g.createElement("h2",null,"Unexpected Application Error!"),g.createElement("h3",{style:{fontStyle:"italic"}},t),n?g.createElement("pre",{style:s},n):null,null)}const Zy=g.createElement(Xy,null);class eg extends g.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?g.createElement(Xt.Provider,{value:this.props.routeContext},g.createElement(Pm.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function tg(e){let{routeContext:t,match:n,children:r}=e,s=g.useContext(Bi);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),g.createElement(Xt.Provider,{value:t},r)}function ng(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(s=n)==null?void 0:s.errors;if(o!=null){let d=l.findIndex(f=>f.route.id&&(o==null?void 0:o[f.route.id])!==void 0);d>=0||ge(!1),l=l.slice(0,Math.min(l.length,d+1))}let c=!1,u=-1;if(n&&r&&r.v7_partialHydration)for(let d=0;d=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((d,f,m)=>{let v,k=!1,w=null,b=null;n&&(v=o&&f.route.id?o[f.route.id]:void 0,w=f.route.errorElement||Zy,c&&(u<0&&m===0?(og("route-fallback"),k=!0,b=null):u===m&&(k=!0,b=f.route.hydrateFallbackElement||null)));let p=t.concat(l.slice(0,m+1)),h=()=>{let x;return v?x=w:k?x=b:f.route.Component?x=g.createElement(f.route.Component,null):f.route.element?x=f.route.element:x=d,g.createElement(tg,{match:f,routeContext:{outlet:d,matches:p,isDataRoute:n!=null},children:x})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?g.createElement(eg,{location:n.location,revalidation:n.revalidation,component:w,error:v,children:h(),routeContext:{outlet:null,matches:p,isDataRoute:!0}}):h()},null)}var Om=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Om||{}),Lm=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(Lm||{});function rg(e){let t=g.useContext(Bi);return t||ge(!1),t}function sg(e){let t=g.useContext(Em);return t||ge(!1),t}function ag(e){let t=g.useContext(Xt);return t||ge(!1),t}function Rm(e){let t=ag(),n=t.matches[t.matches.length-1];return n.route.id||ge(!1),n.route.id}function ig(){var e;let t=g.useContext(Pm),n=sg(),r=Rm();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function lg(){let{router:e}=rg(Om.UseNavigateStable),t=Rm(Lm.UseNavigateStable),n=g.useRef(!1);return Tm(()=>{n.current=!0}),g.useCallback(function(s,i){i===void 0&&(i={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,Xs({fromRouteId:t},i)))},[e,t])}const Pd={};function og(e,t,n){Pd[e]||(Pd[e]=!0)}function cg(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function ug(e){return Gy(e.context)}function xt(e){ge(!1)}function dg(e){let{basename:t="/",children:n=null,location:r,navigationType:s=vn.Pop,navigator:i,static:l=!1,future:o}=e;fa()&&ge(!1);let c=t.replace(/^\/*/,"/"),u=g.useMemo(()=>({basename:c,navigator:i,static:l,future:Xs({v7_relativeSplatPath:!1},o)}),[c,o,i,l]);typeof r=="string"&&(r=ss(r));let{pathname:d="/",search:f="",hash:m="",state:v=null,key:k="default"}=r,w=g.useMemo(()=>{let b=Yr(d,c);return b==null?null:{location:{pathname:b,search:f,hash:m,state:v,key:k},navigationType:s}},[c,d,f,m,v,k,s]);return w==null?null:g.createElement(In.Provider,{value:u},g.createElement(Qi.Provider,{children:n,value:w}))}function fg(e){let{children:t,location:n}=e;return Jy(Do(t),n)}new Promise(()=>{});function Do(e,t){t===void 0&&(t=[]);let n=[];return g.Children.forEach(e,(r,s)=>{if(!g.isValidElement(r))return;let i=[...t,s];if(r.type===g.Fragment){n.push.apply(n,Do(r.props.children,i));return}r.type!==xt&&ge(!1),!r.props.index||!r.props.children||ge(!1);let l={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Do(r.props.children,i)),n.push(l)}),n}/** + * React Router DOM v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Ni(){return Ni=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[s]=e[s]);return n}function hg(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function mg(e,t){return e.button===0&&(!t||t==="_self")&&!hg(e)}const pg=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],xg=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],vg="6";try{window.__reactRouterVersion=vg}catch{}const yg=g.createContext({isTransitioning:!1}),gg="startTransition",Td=Cp[gg];function jg(e){let{basename:t,children:n,future:r,window:s}=e,i=g.useRef();i.current==null&&(i.current=jy({window:s,v5Compat:!0}));let l=i.current,[o,c]=g.useState({action:l.action,location:l.location}),{v7_startTransition:u}=r||{},d=g.useCallback(f=>{u&&Td?Td(()=>c(f)):c(f)},[c,u]);return g.useLayoutEffect(()=>l.listen(d),[l,d]),g.useEffect(()=>cg(r),[r]),g.createElement(dg,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const wg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",kg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Rn=g.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:i,replace:l,state:o,target:c,to:u,preventScrollReset:d,viewTransition:f}=t,m=Mm(t,pg),{basename:v}=g.useContext(In),k,w=!1;if(typeof u=="string"&&kg.test(u)&&(k=u,wg))try{let x=new URL(window.location.href),j=u.startsWith("//")?new URL(x.protocol+u):new URL(u),C=Yr(j.pathname,v);j.origin===x.origin&&C!=null?u=C+j.search+j.hash:w=!0}catch{}let b=Hy(u,{relative:s}),p=Ng(u,{replace:l,state:o,target:c,preventScrollReset:d,relative:s,viewTransition:f});function h(x){r&&r(x),x.defaultPrevented||p(x)}return g.createElement("a",Ni({},m,{href:k||b,onClick:w||i?r:h,ref:n,target:c}))}),zm=g.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:s=!1,className:i="",end:l=!1,style:o,to:c,viewTransition:u,children:d}=t,f=Mm(t,xg),m=Vi(c,{relative:f.relative}),v=as(),k=g.useContext(Em),{navigator:w,basename:b}=g.useContext(In),p=k!=null&&Sg(m)&&u===!0,h=w.encodeLocation?w.encodeLocation(m).pathname:m.pathname,x=v.pathname,j=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;s||(x=x.toLowerCase(),j=j?j.toLowerCase():null,h=h.toLowerCase()),j&&b&&(j=Yr(j,b)||j);const C=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let S=x===h||!l&&x.startsWith(h)&&x.charAt(C)==="/",N=j!=null&&(j===h||!l&&j.startsWith(h)&&j.charAt(h.length)==="/"),_={isActive:S,isPending:N,isTransitioning:p},z=S?r:void 0,O;typeof i=="function"?O=i(_):O=[i,S?"active":null,N?"pending":null,p?"transitioning":null].filter(Boolean).join(" ");let B=typeof o=="function"?o(_):o;return g.createElement(Rn,Ni({},f,{"aria-current":z,className:O,ref:n,style:B,to:c,viewTransition:u}),typeof d=="function"?d(_):d)});var Ao;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Ao||(Ao={}));var Od;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Od||(Od={}));function bg(e){let t=g.useContext(Bi);return t||ge(!1),t}function Ng(e,t){let{target:n,replace:r,state:s,preventScrollReset:i,relative:l,viewTransition:o}=t===void 0?{}:t,c=Dn(),u=as(),d=Vi(e,{relative:l});return g.useCallback(f=>{if(mg(f,n)){f.preventDefault();let m=r!==void 0?r:bi(u)===bi(d);c(e,{replace:m,state:s,preventScrollReset:i,relative:l,viewTransition:o})}},[u,c,d,r,s,n,e,i,l,o])}function Sg(e,t){t===void 0&&(t={});let n=g.useContext(yg);n==null&&ge(!1);let{basename:r}=bg(Ao.useViewTransitionState),s=Vi(e,{relative:t.relative});if(!n.isTransitioning)return!1;let i=Yr(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Yr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Io(s.pathname,l)!=null||Io(s.pathname,i)!=null}/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var Cg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _g=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),U=(e,t)=>{const n=g.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:l,className:o="",children:c,...u},d)=>g.createElement("svg",{ref:d,...Cg,width:s,height:s,stroke:r,strokeWidth:l?Number(i)*24/Number(s):i,className:["lucide",`lucide-${_g(e)}`,o].join(" "),...u},[...t.map(([f,m])=>g.createElement(f,m)),...Array.isArray(c)?c:[c]]));return n.displayName=`${e}`,n};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Eg=U("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fm=U("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pg=U("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Tg=U("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Og=U("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Im=U("BookOpen",[["path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z",key:"vv98re"}],["path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z",key:"1cyq3y"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $o=U("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dm=U("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lg=U("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rg=U("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Zs=U("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mg=U("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zg=U("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Am=U("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fg=U("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ig=U("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $m=U("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ld=U("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Um=U("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Uo=U("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dg=U("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ag=U("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $g=U("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qc=U("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ug=U("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bg=U("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qg=U("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ma=U("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bm=U("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vg=U("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qm=U("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Kg=U("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ea=U("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wc=U("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hg=U("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qg=U("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vm=U("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Km=U("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wg=U("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Gg=U("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rd=U("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Jg=U("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Yg=U("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Gc=U("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hm=U("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qm=U("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xg=U("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wm=U("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const is=U("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),Zg={},Md=e=>{let t;const n=new Set,r=(d,f)=>{const m=typeof d=="function"?d(t):d;if(!Object.is(m,t)){const v=t;t=f??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(k=>k(t,v))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(Zg?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(r,s,c);return c},e0=e=>e?Md(e):Md;var Gm={exports:{}},Jm={},Ym={exports:{}},Xm={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Xr=g;function t0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var n0=typeof Object.is=="function"?Object.is:t0,r0=Xr.useState,s0=Xr.useEffect,a0=Xr.useLayoutEffect,i0=Xr.useDebugValue;function l0(e,t){var n=t(),r=r0({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return a0(function(){s.value=n,s.getSnapshot=t,kl(s)&&i({inst:s})},[e,n,t]),s0(function(){return kl(s)&&i({inst:s}),e(function(){kl(s)&&i({inst:s})})},[e]),i0(n),n}function kl(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!n0(e,n)}catch{return!0}}function o0(e,t){return t()}var c0=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o0:l0;Xm.useSyncExternalStore=Xr.useSyncExternalStore!==void 0?Xr.useSyncExternalStore:c0;Ym.exports=Xm;var u0=Ym.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Ki=g,d0=u0;function f0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var h0=typeof Object.is=="function"?Object.is:f0,m0=d0.useSyncExternalStore,p0=Ki.useRef,x0=Ki.useEffect,v0=Ki.useMemo,y0=Ki.useDebugValue;Jm.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=p0(null);if(i.current===null){var l={hasValue:!1,value:null};i.current=l}else l=i.current;i=v0(function(){function c(v){if(!u){if(u=!0,d=v,v=r(v),s!==void 0&&l.hasValue){var k=l.value;if(s(k,v))return f=k}return f=v}if(k=f,h0(d,v))return k;var w=r(v);return s!==void 0&&s(k,w)?(d=v,k):(d=v,f=w)}var u=!1,d,f,m=n===void 0?null:n;return[function(){return c(t())},m===null?void 0:function(){return c(m())}]},[t,n,r,s]);var o=m0(e,i[0],i[1]);return x0(function(){l.hasValue=!0,l.value=o},[o]),y0(o),o};Gm.exports=Jm;var g0=Gm.exports;const j0=Xd(g0),Zm={},{useDebugValue:w0}=Jo,{useSyncExternalStoreWithSelector:k0}=j0;let zd=!1;const b0=e=>e;function N0(e,t=b0,n){(Zm?"production":void 0)!=="production"&&n&&!zd&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),zd=!0);const r=k0(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return w0(r),r}const Fd=e=>{(Zm?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?e0(e):e,n=(r,s)=>N0(t,r,s);return Object.assign(n,t),n},Jc=e=>e?Fd(e):Fd,Hi="/api",Yc="flow_auth_token",Xc="flow_auth_expires",Zc="flow_auth_username";function qi(){const e=localStorage.getItem(Yc),t=localStorage.getItem(Xc);return!e||!t?null:new Date(t)<=new Date?(Zr(),null):e}function Id(e,t,n){localStorage.setItem(Yc,e),localStorage.setItem(Xc,t),localStorage.setItem(Zc,n)}function Zr(){localStorage.removeItem(Yc),localStorage.removeItem(Xc),localStorage.removeItem(Zc)}function eu(){return localStorage.getItem(Zc)}let cr=null;function S0(e){cr=e}async function Y(e,t,n=!1){const r={"Content-Type":"application/json",...t==null?void 0:t.headers};if(!n){const i=qi();i&&(r.Authorization=`Bearer ${i}`)}const s=await fetch(`${Hi}${e}`,{...t,headers:r});if(s.status===401){Zr(),cr&&cr();const i=await s.json().catch(()=>({detail:"Not authenticated"}));throw new Error(i.detail||"Not authenticated")}if(!s.ok){const i=await s.json().catch(()=>({detail:s.statusText}));throw new Error(i.detail||"API request failed")}if(s.status!==204)return s.json()}const xs={getConfig:()=>Y("/auth/config",void 0,!0),login:e=>Y("/auth/login",{method:"POST",body:JSON.stringify(e)},!0),getGitHubAuthUrl:()=>`${Hi}/auth/github`,getCurrentUser:()=>Y("/auth/me"),logout:()=>Y("/auth/logout",{method:"POST"})},Tn={list:e=>{const t=new URLSearchParams;e!=null&&e.include_auto_generated&&t.set("include_auto_generated","true"),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return Y(`/configs${n?`?${n}`:""}`)},get:e=>Y(`/configs/${e}`),create:e=>Y("/configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Y(`/configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Y(`/configs/${e}`,{method:"DELETE"})},kt={list:e=>{const t=new URLSearchParams;e!=null&&e.category&&t.set("category",e.category),e!=null&&e.suite&&t.set("suite",e.suite);const n=t.toString();return Y(`/tasks${n?`?${n}`:""}`)},get:e=>Y(`/tasks/${e}`),create:e=>Y("/tasks",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Y(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Y(`/tasks/${e}`,{method:"DELETE"}),listSuites:()=>Y("/tasks/suites"),importSuite:e=>Y(`/tasks/import-suite?suite_name=${encodeURIComponent(e)}`,{method:"POST"})},Mt={list:e=>{const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return Y(`/jobs${n?`?${n}`:""}`)},get:e=>Y(`/jobs/${e}`),create:e=>Y("/jobs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Y(`/jobs/${e}`,{method:"PUT",body:JSON.stringify(t)}),start:async function*(e){var o;const t={},n=qi();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Hi}/jobs/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Zr(),cr&&cr(),new Error("Not authenticated");if(!r.ok)throw new Error("Failed to start job");const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const i=new TextDecoder;let l="";for(;;){const{done:c,value:u}=await s.read();if(c)break;l+=i.decode(u,{stream:!0});const d=l.split(` +`);l=d.pop()||"";for(const f of d)f.startsWith("data: ")&&(yield JSON.parse(f.slice(6)))}},cancel:e=>Y(`/jobs/${e}/cancel`,{method:"POST"}),delete:e=>Y(`/jobs/${e}`,{method:"DELETE"})},Bo={list:e=>{const t=new URLSearchParams;e!=null&&e.job_id&&t.set("job_id",e.job_id),e!=null&&e.candidate_name&&t.set("candidate_name",e.candidate_name),e!=null&&e.task_name&&t.set("task_name",e.task_name),(e==null?void 0:e.is_pareto)!==void 0&&t.set("is_pareto",String(e.is_pareto));const n=t.toString();return Y(`/runs${n?`?${n}`:""}`)},get:e=>Y(`/runs/${e}`),getJobSummary:e=>Y(`/runs/job/${e}/summary`)},Ls={list:e=>{const t=new URLSearchParams;e!=null&&e.agent_id&&t.set("agent_id",e.agent_id),e!=null&&e.limit&&t.set("limit",String(e.limit));const n=t.toString();return Y(`/tests${n?`?${n}`:""}`)},get:e=>Y(`/tests/${e}`),create:e=>Y("/tests",{method:"POST",body:JSON.stringify(e)}),start:async function*(e){var o;const t={},n=qi();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Hi}/tests/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Zr(),cr&&cr(),new Error("Not authenticated");if(!r.ok){const c=await r.json().catch(()=>({detail:"Failed to start test"}));throw new Error(c.detail||"Failed to start test")}const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const i=new TextDecoder;let l="";for(;;){const{done:c,value:u}=await s.read();if(c)break;l+=i.decode(u,{stream:!0});const d=l.split(` +`);l=d.pop()||"";for(const f of d)f.startsWith("data: ")&&(yield JSON.parse(f.slice(6)))}},cancel:e=>Y(`/tests/${e}/cancel`,{method:"POST"}),delete:e=>Y(`/tests/${e}`,{method:"DELETE"})},C0={list:()=>Y("/llm-configs")},_0={list:()=>Y("/tools")},ep={getAgentSchema:()=>Y("/schema/agent")},E0={get:e=>Y(`/deployments/${e}`)},P0={start:e=>Y("/evaluate",{method:"POST",body:JSON.stringify(e)})},Qo={design:e=>Y("/experiment/design",{method:"POST",body:JSON.stringify(e)}),validate:e=>Y("/experiment/validate",{method:"POST",body:JSON.stringify(e)}),generateCandidates:e=>Y("/experiment/generate-candidates",{method:"POST",body:JSON.stringify(e)})},tu=Jc(e=>(S0(()=>{e({isAuthenticated:!1,user:null,error:"Session expired. Please log in again."})}),{authConfig:null,isLoadingConfig:!0,isAuthenticated:!1,isLoading:!1,user:null,error:null,loadAuthConfig:async()=>{e({isLoadingConfig:!0});try{const t=await xs.getConfig();if(e({authConfig:t,isLoadingConfig:!1}),t.enabled){const n=qi(),r=eu();if(n&&r)try{const s=await xs.getCurrentUser();e({isAuthenticated:!0,user:s})}catch{Zr(),e({isAuthenticated:!1,user:null})}}else e({isAuthenticated:!0,user:{username:"anonymous",auth_mode:"none"}})}catch(t){console.error("Failed to load auth config:",t),e({isLoadingConfig:!1,error:"Failed to connect to server"})}},login:async(t,n)=>{e({isLoading:!0,error:null});try{const r=await xs.login({username:t,password:n});return Id(r.access_token,r.expires_at,r.username),e({isAuthenticated:!0,isLoading:!1,user:{username:r.username,auth_mode:"basic"}}),!0}catch(r){return e({isLoading:!1,error:r instanceof Error?r.message:"Login failed"}),!1}},loginWithGitHub:()=>{window.location.href=xs.getGitHubAuthUrl()},handleOAuthCallback:()=>{const t=new URLSearchParams(window.location.search),n=t.get("auth_error");if(n)return e({error:n}),window.history.replaceState({},"",window.location.pathname),!0;if(t.get("auth_callback")==="true"){const r=t.get("token"),s=t.get("expires_at"),i=t.get("username");return r&&s&&i&&(Id(r,s,i),e({isAuthenticated:!0,user:{username:i,auth_mode:"github"}})),window.history.replaceState({},"",window.location.pathname),!0}return!1},logout:async()=>{try{await xs.logout()}catch{}Zr(),e({isAuthenticated:!1,user:null,error:null})},clearError:()=>e({error:null})}));function V({variant:e="secondary",size:t="md",className:n="",icon:r,iconRight:s,loading:i=!1,children:l,disabled:o,...c}){const u="font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1.5 rounded-md",d={primary:"bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)]",secondary:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)] hover:bg-[var(--border)]",danger:"bg-[var(--error)] text-white hover:bg-red-600",ghost:"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"},f={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm"},m=t==="sm"?14:16;return a.jsxs("button",{className:`${u} ${d[e]} ${f[t]} ${n}`,disabled:o||i,...c,children:[i?a.jsx(ma,{size:m,className:"animate-spin"}):r?a.jsx(r,{size:m}):null,l,s&&!i&&a.jsx(s,{size:m})]})}const T0={};function O0(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var i;const l=c=>c===null?null:JSON.parse(c,void 0),o=(i=n.getItem(s))!=null?i:null;return o instanceof Promise?o.then(l):l(o)},setItem:(s,i)=>n.setItem(s,JSON.stringify(i,void 0)),removeItem:s=>n.removeItem(s)}}const ta=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return ta(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return ta(r)(n)}}}},L0=(e,t)=>(n,r,s)=>{let i={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:b=>b,version:0,merge:(b,p)=>({...p,...b}),...t},l=!1;const o=new Set,c=new Set;let u;try{u=i.getStorage()}catch{}if(!u)return e((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...b)},r,s);const d=ta(i.serialize),f=()=>{const b=i.partialize({...r()});let p;const h=d({state:b,version:i.version}).then(x=>u.setItem(i.name,x)).catch(x=>{p=x});if(p)throw p;return h},m=s.setState;s.setState=(b,p)=>{m(b,p),f()};const v=e((...b)=>{n(...b),f()},r,s);let k;const w=()=>{var b;if(!u)return;l=!1,o.forEach(h=>h(r()));const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,r()))||void 0;return ta(u.getItem.bind(u))(i.name).then(h=>{if(h)return i.deserialize(h)}).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==i.version){if(i.migrate)return i.migrate(h.state,h.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return h.state}).then(h=>{var x;return k=i.merge(h,(x=r())!=null?x:v),n(k,!0),f()}).then(()=>{p==null||p(k,void 0),l=!0,c.forEach(h=>h(k))}).catch(h=>{p==null||p(void 0,h)})};return s.persist={setOptions:b=>{i={...i,...b},b.getStorage&&(u=b.getStorage())},clearStorage:()=>{u==null||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>w(),hasHydrated:()=>l,onHydrate:b=>(o.add(b),()=>{o.delete(b)}),onFinishHydration:b=>(c.add(b),()=>{c.delete(b)})},w(),k||v},R0=(e,t)=>(n,r,s)=>{let i={storage:O0(()=>localStorage),partialize:w=>w,version:0,merge:(w,b)=>({...b,...w}),...t},l=!1;const o=new Set,c=new Set;let u=i.storage;if(!u)return e((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...w)},r,s);const d=()=>{const w=i.partialize({...r()});return u.setItem(i.name,{state:w,version:i.version})},f=s.setState;s.setState=(w,b)=>{f(w,b),d()};const m=e((...w)=>{n(...w),d()},r,s);s.getInitialState=()=>m;let v;const k=()=>{var w,b;if(!u)return;l=!1,o.forEach(h=>{var x;return h((x=r())!=null?x:m)});const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,(w=r())!=null?w:m))||void 0;return ta(u.getItem.bind(u))(i.name).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==i.version){if(i.migrate)return[!0,i.migrate(h.state,h.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,h.state];return[!1,void 0]}).then(h=>{var x;const[j,C]=h;if(v=i.merge(C,(x=r())!=null?x:m),n(v,!0),j)return d()}).then(()=>{p==null||p(v,void 0),v=r(),l=!0,c.forEach(h=>h(v))}).catch(h=>{p==null||p(void 0,h)})};return s.persist={setOptions:w=>{i={...i,...w},w.storage&&(u=w.storage)},clearStorage:()=>{u==null||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>k(),hasHydrated:()=>l,onHydrate:w=>(o.add(w),()=>{o.delete(w)}),onFinishHydration:w=>(c.add(w),()=>{c.delete(w)})},i.skipHydration||k(),v||m},M0=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((T0?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),L0(e,t)):R0(e,t),tp=M0,z0=Jc()(tp((e,t)=>({theme:"light",setTheme:n=>{document.documentElement.setAttribute("data-theme",n),e({theme:n})},toggleTheme:()=>{const n=t().theme==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",n),e({theme:n})}}),{name:"flow-theme",onRehydrateStorage:()=>e=>{e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}}));function F0(){const{theme:e,toggleTheme:t}=z0();return a.jsx("button",{onClick:t,className:"p-2 rounded-md text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--accent)]","aria-label":`Switch to ${e==="dark"?"light":"dark"} mode`,title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:e==="dark"?a.jsx(Jg,{size:16}):a.jsx(Kg,{size:16})})}const I0=Jc()(tp((e,t)=>({sidebarCollapsed:!1,toggleSidebar:()=>{e({sidebarCollapsed:!t().sidebarCollapsed})}}),{name:"flow-layout"})),D0=[{path:"/",label:"Overview",icon:Bg},{path:"/agents",label:"Agents",icon:$o},{path:"/jobs",label:"Experiments",icon:Uo},{path:"/tasks",label:"Datasets",icon:$m}];function A0(){const e=as(),{sidebarCollapsed:t,toggleSidebar:n}=I0(),r=s=>s==="/"?e.pathname==="/":s==="/agents"?e.pathname==="/agents"||e.pathname.startsWith("/agents/")||e.pathname.startsWith("/deployments/"):s==="/jobs"?e.pathname.startsWith("/jobs")||e.pathname.startsWith("/runs"):e.pathname.startsWith(s);return a.jsxs("aside",{className:` + flex flex-col border-r border-[var(--border)] bg-[var(--bg-secondary)] + transition-all duration-200 + ${t?"w-14":"w-56"} + `,children:[a.jsx("nav",{className:"flex-1 py-2",children:D0.map(s=>{const i=r(s.path);return a.jsxs(zm,{to:s.path,title:t?s.label:void 0,className:` + flex items-center gap-3 px-4 py-2.5 text-sm transition-colors relative + ${i?"text-[var(--accent)] bg-[var(--accent-dim)] font-medium":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"} + `,children:[i&&a.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-r bg-[var(--accent)]"}),a.jsx(s.icon,{size:18}),!t&&a.jsx("span",{children:s.label})]},s.path)})}),a.jsx("button",{onClick:n,className:"flex items-center justify-center p-3 border-t border-[var(--border)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",title:t?"Expand sidebar":"Collapse sidebar",children:t?a.jsx(zg,{size:16}):a.jsx(Mg,{size:16})})]})}function $0(){const{authConfig:e,user:t,logout:n}=tu(),r=async()=>{await n()};return a.jsxs("div",{className:"h-screen flex flex-col",children:[a.jsx("header",{className:"border-b border-[var(--border)] bg-[var(--bg-secondary)] shrink-0",children:a.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between",children:[a.jsxs(zm,{to:"/",className:"text-lg font-semibold text-[var(--accent)] flex items-center gap-2 hover:opacity-80",children:[a.jsx(is,{size:20}),"Flow",a.jsx("span",{className:"text-[var(--text-secondary)] font-normal",children:"/optimize"})]}),a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(F0,{}),(e==null?void 0:e.enabled)&&t&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[a.jsx(Hm,{size:14}),a.jsx("span",{children:t.username})]}),a.jsx(V,{variant:"ghost",size:"sm",icon:Vg,onClick:r,title:"Sign out",children:"Sign out"})]})]})]})}),a.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[a.jsx(A0,{}),a.jsx("main",{className:"flex-1 overflow-y-auto bg-[var(--bg-primary)]",children:a.jsx("div",{className:"p-6",children:a.jsx(ug,{})})})]})]})}function q({children:e,variant:t="default"}){const n={default:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)]",success:"bg-[var(--badge-success-bg)] text-[var(--badge-success-text)] border border-[var(--badge-success-border)]",warning:"bg-[var(--badge-warning-bg)] text-[var(--badge-warning-text)] border border-[var(--badge-warning-border)]",error:"bg-[var(--badge-error-bg)] text-[var(--badge-error-text)] border border-[var(--badge-error-border)]",info:"bg-[var(--badge-info-bg)] text-[var(--badge-info-text)] border border-[var(--badge-info-border)]"};return a.jsx("span",{className:`inline-block px-2 py-0.5 text-xs font-medium rounded-md ${n[t]}`,children:e})}const U0={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};function B0(){const e=Dn(),{data:t=[],isLoading:n}=oe({queryKey:["configs"],queryFn:()=>Tn.list()}),{data:r=[],isLoading:s}=oe({queryKey:["jobs"],queryFn:()=>Mt.list()}),{data:i=[],isLoading:l}=oe({queryKey:["tasks"],queryFn:()=>kt.list()}),o=[...t].sort((d,f)=>new Date(f.created_at).getTime()-new Date(d.created_at).getTime()).slice(0,5),c=[...r].sort((d,f)=>new Date(f.created_at).getTime()-new Date(d.created_at).getTime()).slice(0,5),u=i.reduce((d,f)=>{const m=f.suite||"custom";return d[m]||(d[m]=[]),d[m].push(f),d},{});return a.jsxs("div",{children:[a.jsxs("div",{className:"mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Agent Optimizer"}),a.jsx("p",{className:"text-[var(--text-secondary)] max-w-2xl",children:"Systematically optimize and improve your AI agents across key dimensions. Define agent configurations, run experiments across task datasets, and find the best tradeoffs between quality and cost."}),a.jsx("div",{className:"flex flex-wrap gap-3 mt-4 text-sm text-[var(--text-secondary)]",children:[{icon:Qm,label:"Instructions"},{icon:qm,label:"Tools"},{icon:Im,label:"Skills"},{icon:Gg,label:"Compaction"}].map((d,f,m)=>a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[a.jsx(d.icon,{size:14,className:"text-[var(--accent)]"}),d.label,fa.jsxs("div",{className:"p-4 border border-[var(--border)] rounded-lg bg-[var(--bg-secondary)]",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a.jsx("span",{className:"flex items-center justify-center w-7 h-7 rounded-full bg-[var(--accent)]/10 text-[var(--accent)] text-xs font-bold",children:d.step}),a.jsx(d.icon,{size:18,className:"text-[var(--accent)]"})]}),a.jsx("h3",{className:"font-medium text-sm",children:d.title}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:d.description})]},d.step))}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mb-6",children:[a.jsxs("div",{children:[a.jsx(bl,{title:"Recent Agents",icon:$o,count:t.length,onShowAll:()=>e("/agents")}),n?a.jsx(Nl,{}):o.length===0?a.jsx(Sl,{message:"No agents yet. Create your first agent to get started."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:o.map((d,f)=>a.jsxs("div",{onClick:()=>e(`/agents/${d.id}`),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${fe("/jobs")}),s?a.jsx(Nl,{}):c.length===0?a.jsx(Sl,{message:"No experiments yet. Start one from an agent's detail page."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:c.map((d,f)=>a.jsxs("div",{onClick:()=>e(`/jobs/${d.id}`),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${fe("/tasks")}),l?a.jsx(Nl,{}):Object.keys(u).length===0?a.jsx(Sl,{message:"No datasets yet. Import a task suite to get started."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:Object.entries(u).map(([d,f],m,v)=>a.jsx("div",{onClick:()=>e("/tasks"),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${m0&&a.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",n,")"]})]}),n>0&&a.jsxs("button",{onClick:r,className:"text-sm text-[var(--accent)] hover:underline flex items-center gap-1",children:["Show all ",a.jsx(Pg,{size:14})]})]})}function Nl(){return a.jsx("div",{className:"text-sm text-[var(--text-secondary)] mb-8",children:"Loading..."})}function Sl({message:e}){return a.jsx("div",{className:"text-sm text-[var(--text-secondary)] py-6 text-center border border-[var(--border)] rounded-lg mb-8",children:e})}const Q0=["maf","miniagent","langgraph"],V0={maf:"Microsoft Agent Framework",miniagent:"MiniAgent",langgraph:"LangGraph"},K0={openai:"OpenAI",azure_openai:"Azure OpenAI",anthropic:"Anthropic",ollama:"Ollama",custom:"Custom (OpenAI-compatible)"},H0={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"};function ls({isOpen:e,onClose:t,title:n,children:r,footer:s,size:i="md"}){return g.useEffect(()=>{const l=o=>{o.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",l),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",l),document.body.style.overflow=""}},[e,t]),e?a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),a.jsxs("div",{className:`relative bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg ${H0[i]} w-full mx-4 max-h-[80vh] flex flex-col`,children:[a.jsxs("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-b border-[var(--border)] px-4 py-3 flex items-center justify-between",children:[a.jsx("h2",{className:"font-semibold",children:n}),a.jsx("button",{onClick:t,className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"×"})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r}),s&&a.jsx("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-t border-[var(--border)] px-4 py-3",children:s})]})]}):null}function yn({label:e,className:t="",...n}){return a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),a.jsx("input",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] ${t}`,...n})]})}function q0({label:e,className:t="",...n}){return a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),a.jsx("textarea",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] resize-y min-h-[100px] ${t}`,...n})]})}function Si({label:e,className:t="",...n}){return a.jsxs("label",{className:`flex items-center gap-2 cursor-pointer ${t}`,children:[a.jsx("input",{type:"checkbox",className:"w-4 h-4 bg-[var(--bg-primary)] border border-[var(--border)] rounded accent-[var(--accent)]",...n}),a.jsx("span",{className:"text-sm",children:e})]})}function np({columns:e,data:t,onRowClick:n,searchable:r=!1,searchPlaceholder:s="Search...",searchFilter:i,emptyMessage:l="No items found",emptyIcon:o}){const[c,u]=g.useState(""),[d,f]=g.useState(null),[m,v]=g.useState("asc"),k=g.useMemo(()=>{let b=t;if(r&&c&&i&&(b=b.filter(p=>i(p,c))),d){const p=e.find(h=>h.key===d);p!=null&&p.sortValue&&(b=[...b].sort((h,x)=>{const j=p.sortValue(h),C=p.sortValue(x),S=jC?1:0;return m==="asc"?S:-S}))}return b},[t,c,i,r,d,m,e]),w=b=>{const p=e.find(h=>h.key===b);p!=null&&p.sortable&&(d===b?v(m==="asc"?"desc":"asc"):(f(b),v("asc")))};return a.jsxs("div",{children:[r&&a.jsxs("div",{className:"mb-4 relative max-w-sm",children:[a.jsx(qg,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]"}),a.jsx("input",{type:"text",placeholder:s,value:c,onChange:b=>u(b.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md pl-9 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]"})]}),k.length===0?a.jsxs("div",{className:"text-center py-16 text-[var(--text-secondary)]",children:[o&&a.jsx("div",{className:"mb-3 flex justify-center",children:o}),a.jsx("p",{children:l})]}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsx("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:e.map(b=>a.jsx("th",{onClick:()=>w(b.key),className:`text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider ${b.sortable?"cursor-pointer hover:text-[var(--text-primary)]":""} ${b.className||""}`,children:a.jsxs("span",{className:"inline-flex items-center gap-1",children:[b.header,b.sortable&&d===b.key&&a.jsx("span",{children:m==="asc"?"↑":"↓"})]})},b.key))})}),a.jsx("tbody",{children:k.map((b,p)=>a.jsx("tr",{onClick:()=>n==null?void 0:n(b),className:`border-b border-[var(--border)] last:border-b-0 transition-colors ${n?"cursor-pointer hover:bg-[var(--bg-tertiary)]":""}`,children:e.map(h=>a.jsx("td",{className:`px-4 py-3 ${h.className||""}`,children:h.render(b)},h.key))},p))})]})})]})}function W0({variations:e,onChange:t,strategies:n,availableStrategies:r}){const s=r??Object.keys(n),i=()=>{const u=e.map(v=>v.strategy),d=s.find(v=>!u.includes(v))||"none",f=n[d],m={strategy:d};if(f!=null&&f.params)for(const[v,k]of Object.entries(f.params))k.default!==void 0&&(m[v]=k.default);t([...e,m])},l=u=>{t(e.filter((d,f)=>f!==u))},o=(u,d)=>{t(e.map((f,m)=>m===u?{...f,...d}:f))},c=(u,d)=>{const f=n[d],m={strategy:d};if(f!=null&&f.params)for(const[v,k]of Object.entries(f.params))k.default!==void 0&&(m[v]=k.default);o(u,m)};return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm font-medium",children:"Compaction Strategies"}),a.jsx(V,{type:"button",variant:"ghost",size:"sm",icon:Wc,onClick:i,disabled:e.length>=s.length,children:"Add"})]}),e.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:'No compaction variations. Click "Add" to test different strategies.'}):a.jsx("div",{className:"space-y-2",children:e.map((u,d)=>{const f=n[u.strategy];return a.jsx("div",{className:"p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsx("select",{className:"w-full px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:u.strategy,onChange:m=>c(d,m.target.value),children:s.map(m=>{var v;return a.jsx("option",{value:m,children:((v=n[m])==null?void 0:v.label)||m},m)})}),(f==null?void 0:f.description)&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:f.description}),(f==null?void 0:f.params)&&Object.keys(f.params).length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:Object.entries(f.params).map(([m,v])=>a.jsx(G0,{name:m,schema:v,value:u[m],onChange:k=>o(d,{[m]:k})},m))})]}),a.jsx("button",{type:"button",onClick:()=>l(d),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:a.jsx(Wm,{size:16})})]})},d)})})]})}function G0({name:e,schema:t,value:n,onChange:r}){const s=e.replace(/_/g," ");return t.type==="boolean"?a.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[a.jsx("input",{type:"checkbox",checked:!!(n??t.default),onChange:i=>r(i.target.checked),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"capitalize",children:s})]}):a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:s}),a.jsx("input",{type:t.type==="number"?"number":"text",className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-xs",value:String(n!==void 0?n:t.default??""),onChange:i=>{if(t.type==="number"){const l=parseFloat(i.target.value);r(isNaN(l)?t.default:l)}else r(i.target.value)},min:t.min,max:t.max,step:t.max&&t.max<=1?.1:1})]})}function J0({variations:e,onChange:t,providers:n}){const r=()=>{const o=n[0],c={provider:(o==null?void 0:o.name)||"azure_openai",model:(o==null?void 0:o.models[0])||"gpt-4o"};t([...e,c])},s=o=>{t(e.filter((c,u)=>u!==o))},i=(o,c)=>{t(e.map((u,d)=>d===o?{...u,...c}:u))},l=(o,c)=>{const u=n.find(d=>d.name===c);i(o,{provider:c,model:(u==null?void 0:u.models[0])||""})};return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm font-medium",children:"LLM Configurations"}),a.jsx(V,{type:"button",variant:"ghost",size:"sm",icon:Wc,onClick:r,children:"Add"})]}),e.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:`Uses agent's default LLM. Click "Add" to test different models.`}):a.jsx("div",{className:"space-y-2",children:e.map((o,c)=>{const u=n.find(d=>d.name===o.provider);return a.jsxs("div",{className:"flex items-center gap-2 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[a.jsx("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.provider,onChange:d=>l(c,d.target.value),children:n.map(d=>a.jsx("option",{value:d.name,children:d.label},d.name))}),u&&u.models.length>0?a.jsxs("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:d=>i(c,{model:d.target.value}),children:[u.models.map(d=>a.jsx("option",{value:d,children:d},d)),!u.models.includes(o.model)&&o.model&&a.jsx("option",{value:o.model,children:o.model})]}):a.jsx("input",{type:"text",className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:d=>i(c,{model:d.target.value}),placeholder:"Model ID"}),a.jsx("button",{type:"button",onClick:()=>s(c),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:a.jsx(Wm,{size:16})})]},c)})})]})}const Vo={compaction:[],tools:[],llm_config:[],instructions:[],instruction_strategies:[]};function Y0({agentId:e,agentName:t,agentFramework:n="maf",taskSuite:r,taskCount:s,schema:i,onVariationsChange:l,parallel:o,onParallelChange:c,budget:u,onBudgetChange:d,useLlmEval:f,onUseLlmEvalChange:m}){const[v,k]=g.useState(Vo),[w,b]=g.useState(!1),[p,h]=g.useState(""),[x,j]=g.useState(null),C=i.frameworks[n],S=(C==null?void 0:C.compaction_strategies)||Object.keys(i.compaction_strategies),N=i.tool_presets||[],_=i.llm_providers||[],O=(()=>{let T=1;v.compaction.length>0&&(T*=v.compaction.length),v.tools.length>0&&(T*=v.tools.length),v.llm_config.length>0&&(T*=v.llm_config.length);const Q=v.instructions.length+v.instruction_strategies.reduce((te,be)=>te+be.max_candidates,0);return Q>0&&(T*=Q),Math.min(T,u)})(),B=O*s,J=T=>{k(T),l==null||l(T)},se=Ze({mutationFn:T=>Qo.design(T),onSuccess:T=>{h(T.yaml_content),b(!0)}}),ce=Ze({mutationFn:T=>Qo.validate(T),onSuccess:T=>{j({valid:T.valid,errors:T.errors,warnings:T.warnings})}}),D=()=>({base_agent_id:e,task_suite:r,variations:v,parallel:o,budget:u,use_llm_eval:f}),W=()=>{se.mutate(D())},Z=()=>{ce.mutate(D())},P=()=>{const T=new Blob([p],{type:"text/yaml"}),Q=URL.createObjectURL(T),te=document.createElement("a");te.href=Q,te.download=`${t}_experiment.yaml`,te.click(),URL.revokeObjectURL(Q)},A=v.compaction.length>0||v.tools.length>0||v.llm_config.length>0||v.instructions.length>0||v.instruction_strategies.length>0;return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsxs(q,{variant:"info",children:[O," candidates"]}),a.jsxs(q,{children:[s," tasks"]}),a.jsxs(q,{variant:B>100?"warning":"success",children:[B," total runs"]})]}),a.jsx(W0,{variations:v.compaction,onChange:T=>J({...v,compaction:T}),strategies:i.compaction_strategies,availableStrategies:S}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("label",{className:"text-sm font-medium",children:"Tool Presets"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(T=>a.jsxs("label",{className:`flex items-center gap-2 px-3 py-1.5 border rounded cursor-pointer transition-colors ${v.tools.includes(T.name)?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[a.jsx("input",{type:"checkbox",checked:v.tools.includes(T.name),onChange:Q=>{const te=Q.target.checked?[...v.tools,T.name]:v.tools.filter(be=>be!==T.name);J({...v,tools:te})},className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:T.name}),a.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",T.tools.length,")"]})]},T.name))}),v.tools.length>0&&a.jsxs("p",{className:"text-xs text-[var(--text-secondary)]",children:["Selected: ",v.tools.join(", ")]})]}),a.jsx(J0,{variations:v.llm_config,onChange:T=>J({...v,llm_config:T}),providers:_}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-4 space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium",children:"Execution Settings"}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(yn,{label:"Parallel Workers",type:"number",value:o,onChange:T=>c(parseInt(T.target.value)||1),min:1,max:16}),a.jsx(yn,{label:"Budget (max candidates)",type:"number",value:u,onChange:T=>d(parseInt(T.target.value)||100),min:1,max:1e3})]}),a.jsx(Si,{label:"Use LLM evaluation",checked:f,onChange:T=>m(T.target.checked)}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] ml-6 -mt-2",children:f?"LLM-as-Judge scores task completion (0-1)":"Simple pass/fail based on task success"})]}),a.jsxs("div",{className:"flex items-center gap-2 border-t border-[var(--border)] pt-4",children:[a.jsx(V,{variant:"secondary",size:"sm",onClick:Z,loading:ce.isPending,children:"Validate"}),a.jsx(V,{variant:"secondary",size:"sm",icon:Ld,onClick:W,loading:se.isPending,children:"Export YAML"})]}),x&&a.jsxs("div",{className:`p-3 rounded border ${x.valid?"border-green-500/50 bg-green-500/10":"border-red-500/50 bg-red-500/10"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[x.valid?a.jsx(Dm,{size:16,className:"text-green-500"}):a.jsx(Fm,{size:16,className:"text-red-500"}),a.jsx("span",{className:"font-medium text-sm",children:x.valid?"Configuration valid":"Configuration has issues"})]}),x.errors.length>0&&a.jsx("ul",{className:"text-sm text-red-500 list-disc ml-6",children:x.errors.map((T,Q)=>a.jsx("li",{children:T},Q))}),x.warnings.length>0&&a.jsx("ul",{className:"text-sm text-yellow-500 list-disc ml-6 mt-1",children:x.warnings.map((T,Q)=>a.jsx("li",{children:T},Q))})]}),w&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-lg shadow-xl max-w-2xl w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border)]",children:[a.jsx("h3",{className:"font-medium",children:"Experiment YAML"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(V,{variant:"secondary",size:"sm",icon:Ld,onClick:P,children:"Download"}),a.jsx(V,{variant:"ghost",size:"sm",onClick:()=>b(!1),children:"Close"})]})]}),a.jsx("pre",{className:"flex-1 overflow-auto p-4 text-xs font-mono bg-[var(--bg-secondary)]",children:p})]})}),!A&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No variations selected. Only the baseline agent will be tested. Add compaction strategies, tool presets, or LLM configs to generate candidates."})]})}const X0=[{key:"instruction",label:"Optimize Instructions",description:"LLM iteratively evaluates and rewrites agent instructions",icon:Qm},{key:"tool",label:"Optimize Tools",description:"LLM analyzes which tools help or hurt and adjusts tool config",icon:qm},{key:"skill",label:"Optimize Skills",description:"LLM generates and refines agent skill files (SKILL.md)",icon:Im}];function rp({agent:e,isOpen:t,onClose:n}){var H;const r=Dn(),s=Yt(),[i,l]=g.useState("ready"),[o,c]=g.useState("quick"),[u,d]=g.useState(!1),[f,m]=g.useState([]),[v,k]=g.useState([]),[w,b]=g.useState(5),[p,h]=g.useState(!1),[x,j]=g.useState(Vo),[C,S]=g.useState(4),[N,_]=g.useState(100),[z,O]=g.useState(!0),[B,J]=g.useState(null),{data:se=[]}=oe({queryKey:["tasks"],queryFn:()=>kt.list()}),{data:ce=[]}=oe({queryKey:["suites"],queryFn:()=>kt.listSuites()}),{data:D}=oe({queryKey:["agent-schema"],queryFn:()=>ep.getAgentSchema()}),W=ce.map(F=>({value:F.name,label:F.name.charAt(0).toUpperCase()+F.name.slice(1),description:F.description,tasks:F.task_count})),Z=Ze({mutationFn:kt.importSuite,onSuccess:F=>{s.invalidateQueries({queryKey:["tasks"]}),m(F.map(re=>re.id))}}),P=Ze({mutationFn:async F=>{const re=await Mt.create(F);return Mt.start(re.id).next(),re},onSuccess:F=>{s.invalidateQueries({queryKey:["jobs"]}),J(F.id),l("success")}}),A=()=>{let F=1;x.compaction.length>0&&(F*=x.compaction.length),x.tools.length>0&&(F*=x.tools.length),x.llm_config.length>0&&(F*=x.llm_config.length);const re=x.instructions.length+x.instruction_strategies.reduce((Ae,mt)=>Ae+mt.max_candidates,0);return re>0&&(F*=re),Math.min(F,N)},T=p&&(x.compaction.length>0||x.tools.length>0||x.llm_config.length>0||x.instructions.length>0||x.instruction_strategies.length>0),Q=v.length>0&&!T,te=T?A():1,be=u?f.length:((H=W.find(F=>F.value===o))==null?void 0:H.tasks)||3,R=Q?be*v.length:te*be,K=async()=>{l("starting");let F=f;if(!u)try{F=(await Z.mutateAsync(o)).map(Ae=>Ae.id)}catch(re){console.error("Failed to import suite:",re),alert(`Failed to import task suite: ${o}`),l("ready");return}if(F.length===0){alert("No tasks selected. Please select tasks or choose a task suite."),l("ready");return}if(Q){const re={name:`${e.name} — ${v.join(" → ")} optimization`,task_ids:F,parallel:C,use_llm_eval:z,strategies:v,strategy_config:{max_iterations:w},base_agent_id:e.id};P.mutate(re)}else{let re;if(T)try{re=(await Qo.generateCandidates({base_agent_id:e.id,variations:x,budget:N})).candidate_ids}catch(mt){console.error("Failed to generate candidates:",mt),alert(`Failed to generate candidates: ${mt instanceof Error?mt.message:"Unknown error"}`),l("ready");return}else re=[e.id];const Ae={name:`${e.name} optimization (${re.length} candidates × ${F.length} tasks)`,candidate_ids:re,task_ids:F,parallel:C,use_llm_eval:z};P.mutate(Ae)}},xe=F=>{m(re=>re.includes(F)?re.filter(Ae=>Ae!==F):[...re,F])},_e=()=>{l("ready"),J(null),h(!1),k([]),j(Vo),n()},L=()=>i==="success"&&B?a.jsxs("div",{className:"flex justify-end gap-3",children:[a.jsx(V,{variant:"secondary",onClick:_e,children:"Close"}),a.jsx(V,{variant:"primary",icon:ea,onClick:()=>{_e(),r(`/jobs/${B}`)},children:"View Job"})]}):i==="starting"?null:a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(V,{variant:"secondary",onClick:n,children:"Cancel"}),a.jsx(V,{variant:"primary",icon:ea,onClick:K,disabled:u&&f.length===0,children:Q?`Start Optimization (${be} tasks)`:`Start Optimization (${R} runs)`})]});return a.jsx(ls,{isOpen:t,onClose:_e,title:`Optimize: ${e.name}`,footer:L(),size:"lg",children:i==="success"&&B?a.jsxs("div",{className:"flex flex-col items-center py-8",children:[a.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/20 flex items-center justify-center mb-4",children:a.jsx(is,{size:24,className:"text-green-500"})}),a.jsx("h3",{className:"text-lg font-medium mb-2",children:"Job Started!"}),a.jsx("p",{className:"text-[var(--text-secondary)] text-center mb-2",children:Q?`Running ${v.join(" → ")} optimization`:"Optimization job is now running"}),a.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-3 py-1.5 rounded font-mono",children:["ID: ",B.slice(0,8),"..."]})]}):i==="starting"?a.jsxs("div",{className:"flex flex-col items-center py-8",children:[a.jsx(ma,{size:32,className:"animate-spin text-[var(--accent)] mb-4"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:Z.isPending?"Importing tasks...":"Creating optimization job..."})]}):a.jsxs("div",{className:"space-y-5",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Task Suite"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:u?"__custom__":o,onChange:F=>{F.target.value==="__custom__"?d(!0):(d(!1),c(F.target.value))},children:[W.map(F=>a.jsxs("option",{value:F.value,children:[F.label," (",F.tasks," tasks) — ",F.description]},F.value)),se.length>0&&a.jsx("option",{value:"__custom__",children:"Custom Selection"})]})]}),u&&se.length>0&&a.jsx("div",{className:"max-h-48 overflow-y-auto border border-[var(--border)] rounded p-2 space-y-1",children:se.map(F=>a.jsxs("label",{className:"flex items-center gap-2 p-2 hover:bg-[var(--bg-tertiary)] cursor-pointer rounded",children:[a.jsx("input",{type:"checkbox",checked:f.includes(F.id),onChange:()=>xe(F.id),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:F.name}),F.suite&&a.jsx(q,{children:F.suite})]},F.id))}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Optimization Strategy"}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mb-3",children:"Select one or more strategies. Multiple strategies run as a pipeline — each stage's best agent feeds into the next. Leave all unchecked for a baseline evaluation."}),a.jsx("div",{className:"space-y-2",children:X0.map(F=>{const re=v.includes(F.key),Ae=v.indexOf(F.key);return a.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${re?"border-[var(--accent)] bg-[var(--accent)]/5":"border-[var(--border)] hover:border-[var(--text-secondary)]"}`,children:[a.jsx("input",{type:"checkbox",checked:re,onChange:()=>{k(mt=>re?mt.filter(xa=>xa!==F.key):[...mt,F.key])},className:"accent-[var(--accent)] mt-0.5"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(F.icon,{size:14,className:"text-[var(--accent)]"}),a.jsx("span",{className:"text-sm font-medium",children:F.label}),re&&v.length>1&&a.jsxs(q,{variant:"info",children:["Step ",Ae+1]})]}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:F.description})]})]},F.key)})}),v.length>1&&a.jsxs("p",{className:"text-xs text-[var(--text-secondary)] mt-2",children:["Pipeline: ",v.join(" → ")]}),v.length>0&&a.jsx("div",{className:"mt-3 pl-8",children:a.jsxs("label",{className:"text-xs text-[var(--text-secondary)] flex items-center gap-2",children:["Max iterations",a.jsx("input",{type:"number",min:1,max:20,value:w,onChange:F=>b(parseInt(F.target.value)||5),className:"w-16 px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm"})]})})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[a.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>h(!p),children:[a.jsx(Zs,{size:14,className:`transition-transform ${p?"rotate-90":""}`}),"Advanced: Grid Search",p&&a.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"(manual variation design)"})]}),p&&a.jsxs("div",{className:"mt-3",children:[T&&v.length>0&&a.jsx("div",{className:"mb-3 p-2 rounded bg-yellow-500/10 border border-yellow-500/30 text-xs text-yellow-600 dark:text-yellow-400",children:"Grid variations are set — this will override the strategy selection and run a static grid search instead."}),D&&a.jsx(Y0,{agentId:e.id,agentName:e.name,agentFramework:e.config.framework,taskSuite:u?void 0:o,taskCount:be,schema:D,onVariationsChange:j,parallel:C,onParallelChange:S,budget:N,onBudgetChange:_,useLlmEval:z,onUseLlmEvalChange:O})]})]})]})})}function Z0(){const e=Dn(),t=Yt(),[n,r]=g.useState(!1),[s,i]=g.useState(null),{data:l=[],isLoading:o}=oe({queryKey:["configs"],queryFn:()=>Tn.list()}),c=Ze({mutationFn:Tn.create,onSuccess:()=>{t.invalidateQueries({queryKey:["configs"]}),r(!1)}}),u=Ze({mutationFn:Tn.delete,onSuccess:()=>t.invalidateQueries({queryKey:["configs"]})}),d=[{key:"name",header:"Name",render:f=>a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:f.name})},{key:"framework",header:"Framework",render:f=>a.jsx(q,{children:f.config.framework||"maf"})},{key:"tools",header:"Tools",render:f=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:e1(f.config.tools)})},{key:"compaction",header:"Compaction",render:f=>{const m=f.config.compaction;return!m||m.strategy==="none"?a.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"}):m.strategy==="head_tail"?a.jsxs(q,{children:[m.params.head_size,"/",m.params.tail_size]}):a.jsx(q,{children:m.strategy})}},{key:"created",header:"Created",render:f=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(f.created_at).toLocaleDateString()}),sortable:!0,sortValue:f=>new Date(f.created_at).getTime()},{key:"actions",header:"",className:"w-40",render:f=>a.jsxs("div",{className:"flex items-center gap-2",onClick:m=>m.stopPropagation(),children:[a.jsx(V,{variant:"primary",size:"sm",icon:is,onClick:()=>i(f),children:"Optimize"}),a.jsx(V,{variant:"ghost",size:"sm",icon:Gc,title:"Delete",onClick:()=>{confirm(`Delete agent "${f.name}"?`)&&u.mutate(f.id)}})]})}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Agents"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Define and optimize your agent configurations."})]}),a.jsx(V,{variant:"primary",icon:Wc,onClick:()=>r(!0),children:"Create agent"})]}),o?a.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[a.jsx(ma,{size:16,className:"animate-spin"}),"Loading agents..."]}):a.jsx(np,{columns:d,data:l,onRowClick:f=>e(`/agents/${f.id}`),searchable:!0,searchPlaceholder:"Search agents",searchFilter:(f,m)=>f.name.toLowerCase().includes(m.toLowerCase())||(f.description||"").toLowerCase().includes(m.toLowerCase()),emptyMessage:"No agents yet. Create your first agent to start optimizing.",emptyIcon:a.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-[var(--bg-tertiary)]",children:a.jsx(Km,{size:24,className:"text-[var(--text-secondary)]"})})}),a.jsx(t1,{isOpen:n,onClose:()=>r(!1),onSubmit:f=>c.mutate(f),isLoading:c.isPending}),s&&a.jsx(rp,{agent:s,isOpen:!!s,onClose:()=>i(null)})]})}function e1(e){return typeof e=="string"?e:Array.isArray(e)?`[${e.length}]`:e&&typeof e=="object"?`[${Object.keys(e).length}]`:"standard"}function t1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){var Q,te,be,R,K,xe,_e;const s=["read_file","write_file","edit_file","bash","grep","think"],[i,l]=g.useState("preset"),[o,c]=g.useState({name:"",description:"",instructions:null,model:null,compaction:{strategy:"none",params:{}},tools:s,framework:"miniagent",llm_config_id:null}),[u,d]=g.useState(!1),[f,m]=g.useState("preset"),[v,k]=g.useState([...s]),[w,b]=g.useState(!1),{data:p}=oe({queryKey:["agent-schema"],queryFn:()=>ep.getAgentSchema()}),{data:h=[]}=oe({queryKey:["llm-configs"],queryFn:()=>C0.list()}),{data:x}=oe({queryKey:["tools"],queryFn:()=>_0.list()}),j=((Q=x==null?void 0:x.tools)==null?void 0:Q.map(L=>L.name))??s,C=(x==null?void 0:x.presets)??{},S=Object.keys(C),N=(p==null?void 0:p.frameworks)??{},_=Object.keys(N).length>0?Object.keys(N):Q0,z=o.framework||"miniagent",O=((be=(te=p==null?void 0:p.frameworks)==null?void 0:te[z])==null?void 0:be.compaction_strategies)??["none","head_tail"],B=(p==null?void 0:p.compaction_strategies)??{},J=(p==null?void 0:p.agent_presets)??[],se=L=>{const H=L.config,F=H.compaction;n({name:L.name+"-agent",description:L.description,framework:H.framework||"miniagent",tools:H.tools||"standard",compaction:F||{strategy:"none",params:{}},instructions:H.instructions||null})},ce=L=>{if(L.preventDefault(),!o.name.trim())return;const H={...o};f==="custom"&&(H.tools=v),n(H)},D=((R=o.compaction)==null?void 0:R.strategy)!=="none",W=((K=o.compaction)==null?void 0:K.strategy)||"none",Z=B[W],P=L=>{k(H=>H.includes(L)?H.filter(F=>F!==L):[...H,L])},A=L=>{const H=B[L],F={};if(H!=null&&H.params)for(const[re,Ae]of Object.entries(H.params))Ae.default!==void 0&&(F[re]=Ae.default);c({...o,compaction:{strategy:L,params:F}})},T=i==="custom"?a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(V,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(V,{type:"submit",form:"create-agent-form",variant:"primary",disabled:!o.name.trim(),loading:r,children:"Create Agent"})]}):a.jsx("div",{className:"flex justify-end gap-2",children:a.jsx(V,{type:"button",variant:"secondary",onClick:t,children:"Cancel"})});return a.jsxs(ls,{isOpen:e,onClose:t,title:"Create Agent",footer:T,children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b border-[var(--border)]",children:[a.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${i==="preset"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("preset"),children:"From Preset"}),a.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${i==="custom"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("custom"),children:"Custom"})]}),i==="preset"?a.jsx("div",{className:"space-y-3",children:J.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"Loading presets..."}):J.map(L=>a.jsx("button",{type:"button",className:"w-full text-left p-4 border border-[var(--border)] rounded-lg hover:border-[var(--accent)] hover:bg-[var(--accent)]/5 transition-colors",onClick:()=>se(L),disabled:r,children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("h4",{className:"font-medium",children:L.label}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:L.description}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[L.tags.map(H=>a.jsx(q,{variant:"default",children:H},H)),L.suggested_datasets.length>0&&a.jsxs(q,{variant:"success",children:["datasets: ",L.suggested_datasets.join(", ")]})]})]}),a.jsx(Zs,{size:16,className:"text-[var(--text-secondary)] mt-1 flex-shrink-0"})]})},L.name))}):a.jsxs("form",{id:"create-agent-form",onSubmit:ce,className:"space-y-4",children:[a.jsx(yn,{label:"Name",value:o.name,onChange:L=>c({...o,name:L.target.value}),placeholder:"e.g., my-coding-agent",required:!0}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"LLM Configuration"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.llm_config_id||"",onChange:L=>c({...o,llm_config_id:L.target.value||null}),children:[a.jsx("option",{value:"",children:"Use environment variables"}),h.map(L=>a.jsxs("option",{value:L.id,children:[L.name," (",K0[L.provider],L.model_id?` - ${L.model_id}`:"",")",L.is_default?" (default)":""]},L.id))]}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:h.length===0?"No LLM configs found. Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)":o.llm_config_id?"Uses the selected LLM configuration.":"Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Framework"}),a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.framework||"miniagent",onChange:L=>{const H=L.target.value;c({...o,framework:H,compaction:{strategy:"none",params:{}}})},children:_.map(L=>{var H;return a.jsx("option",{value:L,children:((H=N[L])==null?void 0:H.label)||V0[L]||L},L)})}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((xe=N[z])==null?void 0:xe.description)||(z==="miniagent"?"Lightweight agent with token-aware context management.":z==="langgraph"?"Graph-based workflows with state management.":"Default agent implementation.")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(Si,{label:"Custom instructions",checked:u,onChange:L=>{d(L.target.checked),L.target.checked||c({...o,instructions:null})}}),a.jsx(Si,{label:"Enable compaction",checked:D,onChange:L=>{if(L.target.checked){const H=O.find(F=>F!=="none")||"head_tail";A(H)}else c({...o,compaction:{strategy:"none",params:{}}})}})]}),u&&a.jsx("textarea",{className:"w-full h-32 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono resize-y",value:o.instructions||"",onChange:L=>c({...o,instructions:L.target.value||null}),placeholder:"System prompt / instructions for the agent..."}),D&&a.jsxs("div",{className:"space-y-3 p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Compaction Strategy"}),a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:W,onChange:L=>A(L.target.value),children:O.filter(L=>L!=="none").map(L=>{var H;return a.jsx("option",{value:L,children:((H=B[L])==null?void 0:H.label)||L},L)})}),(Z==null?void 0:Z.description)&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:Z.description})]}),(Z==null?void 0:Z.params)&&Object.keys(Z.params).length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-3",children:Object.entries(Z.params).map(([L,H])=>{var Ae;const F=(Ae=o.compaction)==null?void 0:Ae.params[L],re=F!==void 0?F:H.default;return a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:L.replace(/_/g," ")}),a.jsx("input",{type:"number",className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof re=="number"?re:Number(re)||0,onChange:mt=>{const xa=parseFloat(mt.target.value);c({...o,compaction:{...o.compaction,params:{...o.compaction.params,[L]:isNaN(xa)?typeof H.default=="number"?H.default:0:xa}}})},min:H.min,max:H.max,step:H.max&&H.max<=1?.1:1}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:H.description})]},L)})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm font-medium",children:"Tools"}),a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"radio",checked:f==="preset",onChange:()=>m("preset"),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:"Preset"})]}),a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"radio",checked:f==="custom",onChange:()=>m("custom"),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:"Custom"})]})]}),f==="preset"?a.jsxs(a.Fragment,{children:[a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof o.tools=="string"?o.tools:"standard",onChange:L=>c({...o,tools:L.target.value}),children:S.map(L=>a.jsx("option",{value:L,children:L},L))}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((_e=C[typeof o.tools=="string"?o.tools:"standard"])==null?void 0:_e.join(", "))??""})]}):a.jsx("div",{className:"grid grid-cols-2 gap-1 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:j.map(L=>a.jsxs("label",{className:"flex items-center gap-2 p-1 text-sm cursor-pointer hover:bg-[var(--bg-tertiary)]",children:[a.jsx("input",{type:"checkbox",checked:v.includes(L),onChange:()=>P(L),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"font-mono text-xs",children:L})]},L))})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[a.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>b(!w),children:[a.jsx(Zs,{size:14,className:`transition-transform ${w?"rotate-90":""}`}),"More options"]}),w&&a.jsx("div",{className:"mt-3",children:a.jsx(yn,{label:"Description (optional)",value:o.description,onChange:L=>c({...o,description:L.target.value}),placeholder:"Brief description of this agent"})})]})]})]})}function pa({items:e}){return a.jsx("nav",{className:"flex items-center gap-1.5 text-sm mb-4",children:e.map((t,n)=>{const r=n===e.length-1;return a.jsxs("span",{className:"flex items-center gap-1.5",children:[n>0&&a.jsx(Zs,{size:14,className:"text-[var(--text-secondary)]"}),t.path&&!r?a.jsx(Rn,{to:t.path,className:"text-[var(--text-secondary)] hover:text-[var(--accent)] transition-colors",children:t.label}):a.jsx("span",{className:r?"text-[var(--text-primary)] font-medium":"text-[var(--text-secondary)]",children:t.label})]},n)})})}function je({children:e,className:t="",onClick:n,selected:r=!1,selectable:s=!1}){const i="bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",l=s?"cursor-pointer hover:border-[var(--accent-dim)] transition-colors":"",o=r?"border-[var(--accent)]":"";return a.jsx("div",{className:`${i} ${l} ${o} ${t}`,onClick:n,children:e})}function n1(e){const t=[],n=r=>r.type==="trace_span"&&typeof r.data=="object"&&r.data!==null?r.data:"span_id"in r?r:null;if(Array.isArray(e.spans)){for(const r of e.spans)if(typeof r=="object"&&r!==null){const s=n(r);s&&t.push(s)}}else if(e.span_id)t.push(e);else for(const r in e){const s=e[r];if(typeof s=="object"&&s!==null){const i=n(s);if(i)t.push(i);else if(Array.isArray(s)){for(const l of s)if(typeof l=="object"&&l!==null){const o=n(l);o&&t.push(o)}}}}return t}function sp(e){const t=new Map,n=[];for(const s of e)t.set(s.span_id,{span:s,children:[]});for(const s of e){const i=t.get(s.span_id);s.parent_span_id&&t.has(s.parent_span_id)?t.get(s.parent_span_id).children.push(i):n.push(i)}const r=s=>{s.sort((i,l)=>(i.span.start_time||0)-(l.span.start_time||0)),s.forEach(i=>r(i.children))};return r(n),n}function r1(e){return e.includes("Agent")||e.includes("agent")?"bg-[var(--span-llm-bg)] text-[var(--span-llm-text)]":e.includes("chat")||e.includes("Chat")||e.includes("llm")?"bg-[var(--span-tool-bg)] text-[var(--span-tool-text)]":e.includes("tool")||e.includes("execute")||e.includes("bash")?"bg-[var(--span-agent-bg)] text-[var(--span-agent-text)]":"bg-[var(--span-other-bg)] text-[var(--span-other-text)]"}function s1(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(0)}ms`}function nu({node:e,depth:t=0}){var f,m;const[n,r]=g.useState(t<2),[s,i]=g.useState(!1),{span:l}=e,o=e.children.length>0,c=(f=l.attributes)==null?void 0:f["gen_ai.usage.input_tokens"],u=(m=l.attributes)==null?void 0:m["gen_ai.usage.output_tokens"],d=c!==void 0||u!==void 0;return a.jsxs("div",{className:"relative",children:[t>0&&a.jsx("div",{className:"absolute left-0 top-0 bottom-0 border-l-2 border-[var(--border)]",style:{marginLeft:`${(t-1)*16+8}px`}}),a.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-1 hover:bg-[var(--bg-primary)] rounded transition-colors cursor-pointer",style:{paddingLeft:`${t*16}px`},onClick:()=>o?r(!n):i(!s),children:[a.jsx("div",{className:"w-4 h-4 flex items-center justify-center text-[var(--text-secondary)]",children:o?n?"▼":"▶":s?"▼":"▶"}),a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${r1(l.operation_name)}`,children:l.operation_name.replace("ChatAgent.","").replace("invoke_agent ","")}),l.duration_ms!==void 0&&a.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:s1(l.duration_ms)}),d&&a.jsxs("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:[c!==void 0&&a.jsxs("span",{className:"text-blue-400",children:["↑",String(c)]}),c!==void 0&&u!==void 0&&a.jsx("span",{className:"mx-0.5",children:"/"}),u!==void 0&&a.jsxs("span",{className:"text-green-400",children:["↓",String(u)]})]})]}),s&&!o&&a.jsx("div",{className:"ml-4 mt-1 mb-2 p-2 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs",style:{marginLeft:`${t*16+20}px`},children:a.jsxs("div",{className:"space-y-1",children:[l.span_id&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Span ID:"}),a.jsx("span",{className:"font-mono text-xs break-all",children:l.span_id})]}),l.trace_id&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Trace ID:"}),a.jsx("span",{className:"font-mono text-xs break-all",children:l.trace_id})]}),l.status&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Status:"}),a.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs ${l.status==="OK"||l.status==="StatusCode.UNSET"?"bg-[var(--span-pass-bg)] text-[var(--span-pass-text)]":"bg-[var(--span-fail-bg)] text-[var(--span-fail-text)]"}`,children:l.status})]}),Object.keys(l.attributes||{}).length>0&&a.jsxs("div",{className:"mt-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] block mb-1",children:"Attributes:"}),a.jsx("pre",{className:"text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded p-2 overflow-auto max-h-32 whitespace-pre-wrap break-all",children:JSON.stringify(l.attributes,null,2)})]})]})}),o&&n&&a.jsx("div",{children:e.children.map((v,k)=>a.jsx(nu,{node:v,depth:t+1},v.span.span_id||k))})]})}function ap({trace:e}){const[t,n]=g.useState("tree"),r=g.useMemo(()=>n1(e),[e]),s=g.useMemo(()=>sp(r),[r]);return Object.keys(e).length===0?null:a.jsxs(je,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"font-medium",children:"Trace Data"}),a.jsxs("div",{className:"flex gap-1",children:[a.jsx("button",{onClick:()=>n("tree"),className:`px-2 py-1 text-xs rounded ${t==="tree"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Tree"}),a.jsx("button",{onClick:()=>n("raw"),className:`px-2 py-1 text-xs rounded ${t==="raw"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Raw"})]})]}),t==="tree"?r.length>0?a.jsx("div",{className:"border border-[var(--border)] rounded overflow-hidden",children:a.jsxs("div",{className:"p-2",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs(q,{variant:"default",children:[r.length," spans"]}),a.jsx("span",{children:"•"}),a.jsx("span",{children:"Click to expand details"})]}),s.map((i,l)=>a.jsx(nu,{node:i,depth:0},i.span.span_id||l))]})}):a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No structured spans found. View raw data below."}):a.jsx("pre",{className:"text-xs bg-[var(--bg-primary)] p-3 overflow-x-auto border border-[var(--border)] max-h-96 whitespace-pre-wrap",children:JSON.stringify(e,null,2)})]})}function a1({spans:e,isLive:t=!1}){const n=g.useRef(null),r=g.useMemo(()=>sp(e),[e]);return g.useEffect(()=>{n.current&&t&&n.current.scrollTo({top:n.current.scrollHeight,behavior:"smooth"})},[e.length,t]),a.jsxs("div",{className:"border border-[var(--border)] rounded overflow-hidden h-full flex flex-col",children:[a.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-[var(--border)] bg-[var(--bg-secondary)]",children:[a.jsxs(q,{variant:"default",children:[e.length," spans"]}),t&&a.jsx("span",{className:"animate-pulse",children:a.jsx(q,{variant:"info",children:"Live"})})]}),a.jsx("div",{ref:n,className:"flex-1 overflow-auto p-2",children:r.length>0?r.map((s,i)=>a.jsx(nu,{node:s,depth:0},s.span.span_id||i)):a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:t?"Waiting for spans...":"No spans recorded"})})]})}function ip({agent:e}){const[t,n]=g.useState(""),[r,s]=g.useState(null),[i,l]=g.useState("idle"),[o,c]=g.useState(null),[u,d]=g.useState(""),[f,m]=g.useState([]),[v,k]=g.useState(null),[w,b]=g.useState(null),[p,h]=g.useState([]),[x,j]=g.useState(!1),C=g.useRef(null),{data:S=[]}=oe({queryKey:["tasks"],queryFn:()=>kt.list()});g.useEffect(()=>{C.current&&i==="running"&&(C.current.scrollTop=C.current.scrollHeight)},[u,i]);const N=D=>{if(s(D),D){const W=S.find(Z=>Z.id===D);W&&n(W.prompt)}},_=async()=>{if(t.trim()){l("running"),d(""),m([]),k(null),b(null),h([]);try{const D=await Ls.create({agent_id:e.id,prompt:t.trim(),task_id:r||void 0});c(D.id);for await(const W of Ls.start(D.id))z(W)}catch(D){b(D instanceof Error?D.message:"Test failed"),l("failed")}}},z=D=>{switch(D.event){case"started":break;case"execution":D.execution_event==="text_delta"&&D.content?d(W=>W+D.content):D.execution_event==="tool_call_start"&&D.tool_name?h(W=>[...W,{name:D.tool_name}]):D.execution_event==="tool_result"&&D.content&&h(W=>{if(W.length>0){const Z=[...W];return Z[Z.length-1]={...Z[Z.length-1],content:D.content},Z}return W});break;case"span":if(D.span){const W=D.span;if(W.data){const Z={span_id:W.data.span_id||"",trace_id:W.data.trace_id||"",parent_span_id:W.data.parent_span_id||null,operation_name:W.data.operation_name||"",start_time:W.timestamp?new Date(W.timestamp).getTime():Date.now(),end_time:Date.now(),duration_ms:W.data.duration_ms||0,status:W.data.status||"OK",attributes:W.data.attributes||{}};m(P=>[...P,Z])}}break;case"complete":l("completed"),D.result&&k(D.result);break;case"error":b(D.message),l("failed");break}},O=async()=>{if(o)try{await Ls.cancel(o)}catch{}l("idle")},B=()=>{l("idle"),c(null),d(""),m([]),k(null),b(null),h([])},J=i==="running",se=i==="completed"||i==="failed",ce=D=>{D.preventDefault(),se?(B(),setTimeout(()=>_(),0)):_()};return a.jsxs("div",{className:"h-full flex flex-col border border-[var(--border)] rounded-lg overflow-hidden bg-[var(--bg-primary)]",children:[(J||se)&&a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border)] bg-[var(--bg-secondary)] flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[J&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"animate-pulse",children:a.jsx(q,{variant:"info",children:"Running"})}),a.jsx(V,{variant:"ghost",size:"sm",icon:Rd,onClick:O,children:"Cancel"})]}),i==="completed"&&a.jsx(q,{variant:"success",children:"Completed"}),i==="failed"&&a.jsx(q,{variant:"error",children:"Failed"})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[v&&a.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Am,{size:12}),v.duration_seconds.toFixed(2),"s"]}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Fg,{size:12}),v.tokens_total," tokens"]}),v.passed!==null&&(v.passed?a.jsx(Dm,{size:14,className:"text-[var(--success)]"}):a.jsx(Xg,{size:14,className:"text-[var(--error)]"}))]}),f.length>0&&a.jsxs(V,{variant:x?"primary":"secondary",size:"sm",icon:Eg,onClick:()=>j(!x),children:["Traces (",f.length,")"]}),se&&o&&a.jsx(Rn,{to:`/tests/${o}`,children:a.jsx(V,{variant:"secondary",size:"sm",icon:Um,children:"Details"})})]})]}),a.jsxs("div",{className:"flex-1 min-h-0 flex",children:[a.jsx("div",{ref:C,className:`flex-1 overflow-auto p-4 ${x?"border-r border-[var(--border)]":""}`,children:!J&&!se?a.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center",children:[a.jsx("div",{className:"text-lg font-medium mb-1",children:e.name}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] max-w-sm",children:"Send a message to test this agent, or select a task from the dropdown below."})]}):a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"flex justify-end",children:a.jsx("div",{className:"max-w-[80%] px-3 py-2 bg-[var(--accent-dim)] text-[var(--text-primary)] rounded-lg text-sm",children:t})}),(u||J)&&a.jsx("div",{className:"px-3 py-2 text-sm whitespace-pre-wrap font-mono bg-[var(--bg-secondary)] rounded-lg border border-[var(--border)]",children:u||a.jsx("span",{className:"text-[var(--text-secondary)] animate-pulse",children:"Thinking..."})}),p.length>0&&a.jsx("div",{className:"space-y-1.5",children:p.map((D,W)=>a.jsxs("div",{className:"p-2 bg-[var(--badge-info-bg)] border border-[var(--badge-info-border)] rounded-md text-xs",children:[a.jsx(q,{variant:"info",children:D.name}),D.content&&a.jsxs("div",{className:"mt-1 text-[var(--text-secondary)] truncate max-w-full font-mono",children:[D.content.substring(0,200),D.content.length>200&&"..."]})]},W))}),w&&a.jsx("div",{className:"p-3 bg-[var(--badge-error-bg)] border border-[var(--badge-error-border)] rounded-md text-sm text-[var(--badge-error-text)]",children:w})]})}),x&&a.jsx("div",{className:"w-[350px] flex-shrink-0 overflow-auto",children:a.jsx(a1,{spans:f,isLive:J})})]}),a.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] bg-[var(--bg-secondary)]",children:[a.jsx("div",{className:"px-4 pt-2",children:a.jsxs("select",{value:r||"",onChange:D=>N(D.target.value||null),className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs text-[var(--text-secondary)]",disabled:J,children:[a.jsx("option",{value:"",children:"Custom prompt..."}),S.map(D=>a.jsx("option",{value:D.id,children:D.name},D.id))]})}),a.jsxs("form",{onSubmit:ce,className:"p-3 flex gap-2",children:[a.jsx("textarea",{value:t,onChange:D=>n(D.target.value),placeholder:"Message the agent...",disabled:J,rows:1,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm resize-none min-h-[40px] max-h-[120px] focus:outline-none focus:border-[var(--accent)]",onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),ce(D))}}),a.jsx(V,{type:"submit",variant:"primary",icon:J?Rd:ea,disabled:J?!1:!t.trim(),onClick:J?O:void 0,children:J?"Stop":se?"New Test":"Run"})]})]})]})}function i1(){const{agentId:e}=ha(),t=Dn(),n=Yt(),[r,s]=g.useState("overview"),[i,l]=g.useState(!1),{data:o,isLoading:c}=oe({queryKey:["configs",e],queryFn:()=>Tn.get(e),enabled:!!e}),{data:u=[]}=oe({queryKey:["tests",{agent_id:e}],queryFn:()=>Ls.list({agent_id:e}),enabled:!!e}),{data:d=[]}=oe({queryKey:["jobs"],queryFn:()=>Mt.list()}),f=Ze({mutationFn:v=>Tn.delete(v),onSuccess:()=>{n.invalidateQueries({queryKey:["configs"]}),t("/agents")}}),m=d.filter(v=>v.candidate_ids.includes(e||""));return c?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):o?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsxs("div",{className:"mb-4 flex-shrink-0",children:[a.jsx(pa,{items:[{label:"Agents",path:"/agents"},{label:o.name}]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:o.name}),o.is_auto_generated&&a.jsx(q,{variant:"info",children:"Auto-generated"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(V,{variant:"primary",icon:is,size:"sm",onClick:()=>l(!0),children:"Optimize"}),a.jsx(V,{variant:"secondary",icon:Gc,size:"sm",onClick:()=>{confirm(`Delete agent "${o.name}"?`)&&f.mutate(o.id)},children:"Delete"})]})]}),o.description&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:o.description})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsxs("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:[a.jsxs("div",{className:"flex gap-1 mb-4 border-b border-[var(--border)] flex-shrink-0",children:[a.jsx(Cl,{active:r==="overview",onClick:()=>s("overview"),icon:a.jsx(Km,{size:14}),children:"Overview"}),a.jsx(Cl,{active:r==="evaluate",onClick:()=>s("evaluate"),icon:a.jsx(ea,{size:14}),children:"Evaluate"}),a.jsx(Cl,{active:r==="history",onClick:()=>s("history"),icon:a.jsx(Ug,{size:14}),badge:u.length,children:"History"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r==="overview"&&a.jsx(l1,{agent:o,recentTests:u,jobs:m}),r==="evaluate"&&a.jsx(o1,{agent:o,jobs:m}),r==="history"&&a.jsx(c1,{tests:u})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[a.jsx(Vm,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),a.jsx("div",{className:"flex-1 min-h-0",children:a.jsx(ip,{agent:o})})]})]}),i&&a.jsx(rp,{agent:o,isOpen:i,onClose:()=>l(!1)})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Agent not found"})}function Cl({active:e,onClick:t,icon:n,badge:r,children:s}){return a.jsxs("button",{onClick:t,className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors ${e?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[n,s,r!==void 0&&r>0&&a.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs bg-[var(--bg-tertiary)] rounded",children:r})]})}function l1({agent:e,recentTests:t,jobs:n}){var i,l;const r=e.config,s=()=>{const o=r.tools;return typeof o=="string"?o:Array.isArray(o)?o.join(", "):o&&typeof o=="object"?Object.keys(o).join(", "):"standard"};return a.jsxs("div",{className:"space-y-4",children:[a.jsx(hr,{title:"Model",children:a.jsx("div",{className:"font-mono text-sm",children:r.model||"default"})}),a.jsx(hr,{title:"Instructions",defaultCollapsed:!r.instructions,children:r.instructions?a.jsx("pre",{className:"p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs whitespace-pre-wrap max-h-40 overflow-auto font-mono",children:r.instructions}):a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No instructions set"})}),a.jsx(hr,{title:"Tools",children:a.jsx("div",{className:"font-mono text-sm",children:s()})}),a.jsx(hr,{title:"Compaction",children:a.jsx("div",{className:"font-mono text-sm",children:!r.compaction||r.compaction.strategy==="none"?"disabled":`${r.compaction.strategy} (${((i=r.compaction.params)==null?void 0:i.head_size)||0}/${((l=r.compaction.params)==null?void 0:l.tail_size)||0})`})}),t.length>0&&a.jsx(hr,{title:`Recent Tests (${t.length})`,children:a.jsx("div",{className:"space-y-1.5",children:t.slice(0,3).map(o=>a.jsxs(Rn,{to:`/tests/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx(lp,{status:o.status}),a.jsxs("span",{className:"truncate",children:[o.prompt.slice(0,40),"..."]})]}),a.jsxs("span",{className:"text-[var(--text-secondary)] flex-shrink-0 ml-2",children:[o.duration_seconds.toFixed(1),"s"]})]},o.id))})}),n.length>0&&a.jsx(hr,{title:`Experiments (${n.length})`,children:a.jsx("div",{className:"space-y-1.5",children:n.slice(0,3).map(o=>a.jsxs(Rn,{to:`/jobs/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(q,{variant:o.status==="completed"?"success":o.status==="running"?"info":"default",children:o.status}),a.jsx("span",{children:o.name})]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(o.created_at).toLocaleDateString()})]},o.id))})})]})}function hr({title:e,children:t,defaultCollapsed:n=!1}){const[r,s]=g.useState(n);return a.jsxs("div",{className:"border-b border-[var(--border)] pb-3",children:[a.jsxs("button",{onClick:()=>s(!r),className:"flex items-center justify-between w-full text-left py-1 hover:text-[var(--accent)] transition-colors",children:[a.jsx("span",{className:"text-sm font-medium",children:e}),a.jsx("span",{className:"text-[var(--text-secondary)] text-xs",children:r?"▶":"▼"})]}),!r&&a.jsx("div",{className:"mt-2",children:t})]})}function o1({agent:e,jobs:t}){const n=Dn(),r=Yt(),[s,i]=g.useState("quick"),[l,o]=g.useState(!1),{data:c=[]}=oe({queryKey:["suites"],queryFn:()=>kt.listSuites()}),u=Ze({mutationFn:P0.start,onSuccess:f=>{r.invalidateQueries({queryKey:["jobs"]}),o(!1),n(`/jobs/${f.id}`)},onError:()=>{o(!1)}}),d=()=>{o(!0),u.mutate({agent_id:e.id,suite_name:s,use_llm_eval:!0,parallel:4})};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:"Run this agent on a task suite to measure quality and cost."}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm",value:s,onChange:f=>i(f.target.value),disabled:l,children:c.map(f=>a.jsxs("option",{value:f.name,children:[f.name.charAt(0).toUpperCase()+f.name.slice(1)," (",f.task_count," tasks)"]},f.name))}),a.jsx(V,{variant:"primary",icon:l?ma:ea,onClick:d,disabled:l,loading:l,className:"w-full",children:"Evaluate"})]})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h4",{className:"text-sm font-medium",children:"Optimization Jobs"}),a.jsx(V,{variant:"secondary",size:"sm",icon:is,onClick:()=>n("/agents",{state:{optimizeAgent:e}}),children:"New Job"})]}),t.length===0?a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No optimization jobs yet."}):a.jsx("div",{className:"space-y-1.5",children:t.slice(0,5).map(f=>a.jsxs(Rn,{to:`/jobs/${f.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(q,{variant:f.status==="completed"?"success":f.status==="running"?"info":"default",children:f.status}),a.jsx("span",{children:f.name})]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(f.created_at).toLocaleDateString()})]},f.id))})]})]})}function c1({tests:e}){return e.length===0?a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No test history yet. Use the playground on the right to run a test."}):a.jsx("div",{className:"space-y-2",children:e.map(t=>a.jsxs(Rn,{to:`/tests/${t.id}`,className:"flex items-center justify-between p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(lp,{status:t.status}),t.score!==null&&a.jsxs("span",{className:`text-sm font-medium ${t.passed?"text-[var(--success)]":"text-[var(--error)]"}`,children:[(t.score*100).toFixed(0),"%"]})]}),a.jsx("p",{className:"text-sm truncate",children:t.prompt})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1 ml-4",children:[a.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:new Date(t.created_at).toLocaleString()}),a.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:[t.duration_seconds.toFixed(1),"s"]}),a.jsxs("span",{children:[t.tokens_total," tokens"]})]})]})]},t.id))})}function lp({status:e}){const t={completed:"success",failed:"error",running:"info",cancelled:"warning",pending:"default"};return a.jsx(q,{variant:t[e]||"default",children:e})}function u1(){const e=Yt(),[t,n]=g.useState(!1),[r,s]=g.useState(!1),[i,l]=g.useState(null),[o,c]=g.useState(new Set),u=p=>{c(h=>{const x=new Set(h);return x.has(p)?x.delete(p):x.add(p),x})},{data:d=[],isLoading:f}=oe({queryKey:["tasks"],queryFn:()=>kt.list()}),m=Ze({mutationFn:kt.create,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),n(!1)}}),v=Ze({mutationFn:kt.importSuite,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),s(!1)}}),k=Ze({mutationFn:kt.delete,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),l(null)}}),w=d.reduce((p,h)=>{const x=h.suite||"custom";return p[x]||(p[x]=[]),p[x].push(h),p},{}),b=Object.keys(w).sort((p,h)=>p==="custom"?-1:h==="custom"?1:p.localeCompare(h));return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Datasets"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Task datasets for evaluating agent configurations."})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(V,{variant:"secondary",onClick:()=>s(!0),children:"Import Suite"}),a.jsx(V,{variant:"primary",onClick:()=>n(!0),children:"+ New Task"})]})]}),f?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):d.length===0?a.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:"No tasks yet. Create one or import a built-in suite."}):a.jsx("div",{className:"space-y-4",children:b.map(p=>{const h=w[p],x=!o.has(p);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>u(p),className:"flex items-center gap-2 py-2 hover:text-[var(--accent)] transition-colors",children:[x?a.jsx(Rg,{size:16,className:"text-[var(--text-secondary)]"}):a.jsx(Zs,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium uppercase tracking-wide",children:p==="custom"?"Custom Tasks":`${p} Suite`}),a.jsx(q,{variant:p==="custom"?"default":"info",children:h.length})]}),x&&a.jsx("div",{className:"mt-2 border border-[var(--border)] rounded-lg overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:[a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Name"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Category"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Prompt"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Criteria"})]})}),a.jsx("tbody",{children:h.map(j=>a.jsxs("tr",{onClick:()=>l(j),className:"border-b border-[var(--border)] last:border-b-0 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors",children:[a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:j.name})}),a.jsx("td",{className:"px-4 py-3",children:j.category&&j.category!=="default"?a.jsx(q,{variant:"default",children:j.category}):a.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"})}),a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-[var(--text-secondary)] line-clamp-1 max-w-md",children:j.prompt})}),a.jsx("td",{className:"px-4 py-3 text-[var(--text-secondary)]",children:j.criteria.length>0?j.criteria.length:"--"})]},j.id))})]})})]},p)})}),a.jsx(d1,{task:i,onClose:()=>l(null),onDelete:p=>{confirm("Delete this task?")&&k.mutate(p)}}),a.jsx(f1,{isOpen:t,onClose:()=>n(!1),onSubmit:p=>m.mutate(p),isLoading:m.isPending}),a.jsx(h1,{isOpen:r,onClose:()=>s(!1),onSubmit:p=>v.mutate(p),isLoading:v.isPending})]})}function d1({task:e,onClose:t,onDelete:n}){const[r,s]=g.useState("prompt");if(!e)return null;const i=a.jsxs("div",{className:"flex justify-between",children:[a.jsx(V,{variant:"ghost",onClick:()=>n(e.id),className:"text-red-500 hover:text-red-600",children:"Delete Task"}),a.jsx(V,{variant:"secondary",onClick:t,children:"Close"})]});return a.jsx(ls,{isOpen:!!e,onClose:t,title:e.name,size:"lg",footer:i,children:a.jsxs("div",{className:"space-y-4",children:[e.category&&e.category!=="default"&&a.jsx("div",{children:a.jsx(q,{variant:"default",children:e.category})}),a.jsxs("div",{className:"flex gap-1 border-b border-[var(--border)]",children:[a.jsx("button",{onClick:()=>s("prompt"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="prompt"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Prompt"}),a.jsxs("button",{onClick:()=>s("criteria"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="criteria"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:["Eval Criteria (",e.criteria.length,")"]})]}),r==="prompt"&&a.jsx("div",{className:"p-4 bg-[var(--bg-tertiary)] rounded text-sm whitespace-pre-wrap min-h-[200px]",children:e.prompt}),r==="criteria"&&a.jsx("div",{className:"space-y-2 min-h-[200px]",children:e.criteria.length===0?a.jsx("div",{className:"text-[var(--text-secondary)] text-sm p-4",children:"No evaluation criteria defined for this task."}):e.criteria.map(l=>a.jsxs("div",{className:"p-3 bg-[var(--bg-tertiary)] rounded",children:[a.jsx("div",{className:"font-medium text-sm",children:l.name}),l.instruction&&a.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1",children:l.instruction})]},l.name))})]})})}function f1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,i]=g.useState({name:"",prompt:"",criteria:[],category:"default"}),l=()=>{i({...s,criteria:[...s.criteria,{name:"",instruction:"",weight:1}]})},o=(d,f)=>{const m=[...s.criteria];m[d]={...m[d],...f},i({...s,criteria:m})},c=d=>{i({...s,criteria:s.criteria.filter((f,m)=>m!==d)})},u=d=>{d.preventDefault(),!(!s.name.trim()||!s.prompt.trim())&&n({...s,criteria:s.criteria.filter(f=>f.name.trim()&&f.instruction.trim())})};return a.jsx(ls,{isOpen:e,onClose:t,title:"Create Task",children:a.jsxs("form",{onSubmit:u,className:"space-y-4",children:[a.jsx(yn,{label:"Name",value:s.name,onChange:d=>i({...s,name:d.target.value}),placeholder:"e.g., fizzbuzz",required:!0}),a.jsx(q0,{label:"Prompt",value:s.prompt,onChange:d=>i({...s,prompt:d.target.value}),placeholder:"The task description for the agent...",required:!0}),a.jsx(yn,{label:"Category",value:s.category,onChange:d=>i({...s,category:d.target.value}),placeholder:"e.g., coding, research"}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Evaluation Criteria"}),a.jsx(V,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"+ Add"})]}),a.jsx("div",{className:"space-y-2",children:s.criteria.map((d,f)=>a.jsxs("div",{className:"flex gap-2 items-start",children:[a.jsx(yn,{value:d.name,onChange:m=>o(f,{name:m.target.value}),placeholder:"Name",className:"w-32"}),a.jsx(yn,{value:d.instruction,onChange:m=>o(f,{instruction:m.target.value}),placeholder:"Instruction",className:"flex-1"}),a.jsx(V,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(f),children:"×"})]},f))})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[a.jsx(V,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(V,{type:"submit",variant:"primary",disabled:r||!s.name.trim()||!s.prompt.trim(),children:r?"Creating...":"Create"})]})]})})}function h1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,i]=g.useState(""),{data:l=[],isLoading:o}=oe({queryKey:["suites"],queryFn:()=>kt.listSuites(),enabled:e});return g.useEffect(()=>{l.length>0&&!s&&i(l[0].name)},[l,s]),a.jsx(ls,{isOpen:e,onClose:t,title:"Import Task Suite",children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Import a built-in task suite for evaluation."}),o?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading suites..."}):l.length===0?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"No suites available."}):a.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:l.map(c=>a.jsxs("label",{className:`flex items-center gap-3 p-3 border cursor-pointer ${s===c.name?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[a.jsx("input",{type:"radio",name:"suite",value:c.name,checked:s===c.name,onChange:()=>i(c.name),className:"accent-[var(--accent)]"}),a.jsxs("span",{className:"capitalize",children:[c.name.replace(/_/g," ")," (",c.task_count," tasks) - ",c.description]})]},c.name))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[a.jsx(V,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(V,{variant:"primary",onClick:()=>n(s),disabled:r||!s,children:r?"Importing...":"Import"})]})]})})}function m1(){const e=Dn(),t=Yt(),[n,r]=g.useState(!1),s=eu(),{data:i=[],isLoading:l}=oe({queryKey:["jobs",n],queryFn:()=>Mt.list({include_public:n}),refetchInterval:5e3}),o=Ze({mutationFn:Mt.delete,onSuccess:()=>t.invalidateQueries({queryKey:["jobs"]})}),c={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"},u=[{key:"name",header:"Name",render:d=>a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:d.name||`Job ${d.id.slice(0,8)}`}),d.is_public&&a.jsx(qc,{className:"w-3 h-3 ml-2 inline text-[var(--text-secondary)]"})]})},{key:"status",header:"Status",render:d=>a.jsx(q,{variant:c[d.status]||"default",children:d.status})},{key:"candidates",header:"Strategy",render:d=>{var f;return a.jsx("span",{children:(f=d.strategies)!=null&&f.length?d.strategies.join(" → "):`${d.candidate_ids.length} candidates`})}},{key:"tasks",header:"Tasks",render:d=>a.jsx("span",{children:d.task_ids.length})},{key:"runs",header:"Runs",render:d=>a.jsxs("span",{children:[d.completed_experiments,"/",d.total_experiments]})},{key:"created",header:"Created",render:d=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(d.created_at).toLocaleDateString()}),sortable:!0,sortValue:d=>new Date(d.created_at).getTime()},{key:"actions",header:"",className:"w-12",render:d=>!d.user_id||d.user_id==="anonymous"||s&&d.created_by_name===s?a.jsx("div",{onClick:m=>m.stopPropagation(),children:a.jsx(V,{variant:"ghost",size:"sm",icon:Gc,title:"Delete",disabled:d.status==="running",onClick:()=>{confirm("Delete this job?")&&o.mutate(d.id)}})}):null}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Experiments"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"View and manage optimization experiments. Start new experiments from the Agents page."})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Si,{label:"Show public",checked:n,onChange:d=>r(d.target.checked)}),a.jsx(V,{variant:"secondary",onClick:()=>e("/agents"),children:"Go to Agents"})]})]}),l?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):a.jsx(np,{columns:u,data:i,onRowClick:d=>e(`/jobs/${d.id}`),searchable:!0,searchPlaceholder:"Search experiments",searchFilter:(d,f)=>(d.name||"").toLowerCase().includes(f.toLowerCase())||d.id.toLowerCase().includes(f.toLowerCase()),emptyMessage:"No experiments yet. Go to Agents page to start an optimization."})]})}function p1(e,t=!0){return Math.abs(e)<10?"text-[var(--text-secondary)]":(t?e<0:e>0)?"text-green-400":"text-red-400"}function x1(e){return`${e>0?"+":""}${e.toFixed(1)}%`}function op(e,t){return t===0?0:(e-t)/t*100}function vs({label:e,values:t,baselineIndex:n,formatter:r,isLowerBetter:s=!0}){const i=t[n];return a.jsxs("tr",{className:"border-b border-[var(--border)] last:border-0",children:[a.jsx("td",{className:"py-2 pr-4 text-[var(--text-secondary)] text-sm",children:e}),t.map((l,o)=>{const c=op(l,i),u=o===n;return a.jsxs("td",{className:"py-2 px-4 text-right",children:[a.jsx("div",{className:"font-mono",children:r(l)}),!u&&a.jsx("div",{className:`text-xs ${p1(c,s)}`,children:x1(c)}),u&&a.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"(baseline)"})]},o)})]})}function v1({runs:e,baselineRunId:t}){const n=g.useMemo(()=>{if(t){const i=e.findIndex(l=>l.id===t);if(i>=0)return i}return 0},[e,t]);if(e.length<2)return null;const r=Math.min(...e.map(i=>i.tokens_total)),s=Math.max(...e.map(i=>i.score));return a.jsxs(je,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-4",children:"Candidate Comparison"}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-[var(--border)]",children:[a.jsx("th",{className:"pb-2 pr-4 text-left text-[var(--text-secondary)] font-medium",children:"Metric"}),e.map((i,l)=>a.jsx("th",{className:"pb-2 px-4 text-right",children:a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsx("span",{className:"font-medium",children:i.candidate_name}),i.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"}),l===n&&a.jsx(q,{variant:"info",children:"Base"})]})},i.id))]})}),a.jsxs("tbody",{children:[a.jsx(vs,{label:"Total Tokens",values:e.map(i=>i.tokens_total),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(vs,{label:"Input Tokens",values:e.map(i=>i.tokens_input),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(vs,{label:"Output Tokens",values:e.map(i=>i.tokens_output),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(vs,{label:"Duration",values:e.map(i=>i.duration_seconds),baselineIndex:n,formatter:i=>`${i.toFixed(1)}s`,isLowerBetter:!0}),a.jsx(vs,{label:"Score",values:e.map(i=>i.score*100),baselineIndex:n,formatter:i=>`${i.toFixed(1)}%`,isLowerBetter:!1})]})]})}),a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[a.jsx("h4",{className:"text-sm font-medium mb-2 text-[var(--text-secondary)]",children:"Key Insights"}),a.jsxs("ul",{className:"text-sm space-y-1 text-[var(--text-secondary)]",children:[e.map(i=>{const l=op(i.tokens_total,e[n].tokens_total);return i.tokens_total===r&&l<-5?a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-green-400",children:"✓"}),a.jsxs("span",{children:[a.jsx("strong",{children:i.candidate_name})," uses ",Math.abs(l).toFixed(0),"% fewer tokens"]})]},`token-${i.id}`):null}),e.map(i=>i.score===s&&i.passed?a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-green-400",children:"✓"}),a.jsxs("span",{children:[a.jsx("strong",{children:i.candidate_name})," achieved highest score (",(i.score*100).toFixed(0),"%)"]})]},`score-${i.id}`):null),e.filter(i=>i.is_pareto).length>0&&a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-purple-400",children:"★"}),a.jsxs("span",{children:["Optimal candidates (best tradeoff):"," ",e.filter(i=>i.is_pareto).map(i=>i.candidate_name).join(", ")]})]})]})]}),a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[a.jsx("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:"Token Efficiency"}),a.jsx("div",{className:"space-y-2",children:e.map(i=>{const l=i.tokens_total/e[n].tokens_total*100,o=i.tokens_total<=r;return a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-24 text-sm truncate",title:i.candidate_name,children:i.candidate_name}),a.jsx("div",{className:"flex-1 h-6 bg-[var(--bg-primary)] rounded overflow-hidden",children:a.jsx("div",{className:`h-full transition-all duration-300 ${o?"bg-green-500":"bg-blue-500"}`,style:{width:`${Math.min(l,100)}%`}})}),a.jsx("div",{className:"w-20 text-right font-mono text-sm",children:i.tokens_total.toLocaleString()})]},i.id)})})]})]})}function y1({summaries:e,height:t=350}){const n=g.useRef(null),[r,s]=g.useState(600),[i,l]=g.useState("tokens"),[o,c]=g.useState(null),[u,d]=g.useState({x:0,y:0});g.useEffect(()=>{const S=()=>{n.current&&s(n.current.clientWidth)};return S(),window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]);const f={top:30,right:30,bottom:50,left:60},m=r-f.left-f.right,v=t-f.top-f.bottom,k=S=>i==="tokens"?S.avg_tokens:S.avg_duration,{xScale:w,yScale:b,xTicks:p,yTicks:h,paretoLine:x}=g.useMemo(()=>{if(e.length===0||m<=0)return{xScale:()=>0,yScale:()=>0,xTicks:[],yTicks:[],paretoLine:[]};const S=e.map(k),N=e.map(P=>P.avg_score),_=Math.min(...S)*.9,z=Math.max(...S)*1.1,O=Math.min(...N,.5),B=Math.min(Math.max(...N)*1.05,1),J=P=>(P-_)/(z-_)*m,se=P=>v-(P-O)/(B-O)*v,ce=Array.from({length:5},(P,A)=>_+A/4*(z-_)),D=Array.from({length:5},(P,A)=>O+A/4*(B-O)),Z=e.filter(P=>P.is_pareto).sort((P,A)=>k(P)-k(A)).map(P=>({x:J(k(P)),y:se(P.avg_score)}));return{xScale:J,yScale:se,xTicks:ce,yTicks:D,paretoLine:Z}},[e,m,v,i]);if(e.length===0)return a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No data to display"});const j=S=>i==="tokens"?S>=1e6?`${(S/1e6).toFixed(1)}M`:S>=1e3?`${(S/1e3).toFixed(0)}K`:S.toFixed(0):`${S.toFixed(1)}s`,C=(S,N)=>{var z;const _=(z=n.current)==null?void 0:z.getBoundingClientRect();_&&d({x:N.clientX-_.left,y:N.clientY-_.top}),c(S)};return a.jsxs("div",{ref:n,className:"w-full relative",children:[a.jsx("div",{className:"flex justify-end mb-2",children:a.jsxs("div",{className:"inline-flex rounded border border-[var(--border)] text-xs",children:[a.jsx("button",{className:`px-3 py-1 ${i==="tokens"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("tokens"),children:"Tokens"}),a.jsx("button",{className:`px-3 py-1 ${i==="duration"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("duration"),children:"Latency"})]})}),a.jsx("svg",{width:r,height:t,className:"font-mono text-xs",children:a.jsxs("g",{transform:`translate(${f.left}, ${f.top})`,children:[p.map((S,N)=>a.jsx("line",{x1:w(S),y1:0,x2:w(S),y2:v,stroke:"var(--border)",strokeDasharray:"2,2"},`x-grid-${N}`)),h.map((S,N)=>a.jsx("line",{x1:0,y1:b(S),x2:m,y2:b(S),stroke:"var(--border)",strokeDasharray:"2,2"},`y-grid-${N}`)),x.length>1&&a.jsx("polyline",{points:x.map(S=>`${S.x},${S.y}`).join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.slice().sort((S,N)=>(S.is_pareto?1:0)-(N.is_pareto?1:0)).map(S=>{const N=w(k(S)),_=b(S.avg_score),z=S.is_pareto,O=(o==null?void 0:o.candidate_name)===S.candidate_name;return a.jsxs("g",{onMouseEnter:B=>C(S,B),onMouseLeave:()=>c(null),children:[a.jsx("circle",{cx:N,cy:_,r:O?10:z?8:6,fill:z?"var(--accent)":"transparent",stroke:O?"var(--text-primary)":z?"var(--accent)":"var(--text-secondary)",strokeWidth:O?3:2,className:"cursor-pointer transition-all"}),z&&!O&&a.jsx("text",{x:N,y:_-12,textAnchor:"middle",fill:"var(--text-primary)",fontSize:10,className:"pointer-events-none",children:S.candidate_name.replace(/^baseline_/,"").slice(0,15)})]},S.candidate_name)}),a.jsx("line",{x1:0,y1:v,x2:m,y2:v,stroke:"var(--text-secondary)"}),p.map((S,N)=>a.jsxs("g",{transform:`translate(${w(S)}, ${v})`,children:[a.jsx("line",{y2:5,stroke:"var(--text-secondary)"}),a.jsx("text",{y:20,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:10,children:j(S)})]},`x-tick-${N}`)),a.jsx("text",{x:m/2,y:v+40,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:i==="tokens"?"Tokens (cost)":"Duration (latency)"}),a.jsx("line",{x1:0,y1:0,x2:0,y2:v,stroke:"var(--text-secondary)"}),h.map((S,N)=>a.jsxs("g",{transform:`translate(0, ${b(S)})`,children:[a.jsx("line",{x2:-5,stroke:"var(--text-secondary)"}),a.jsxs("text",{x:-10,textAnchor:"end",dominantBaseline:"middle",fill:"var(--text-secondary)",fontSize:10,children:[(S*100).toFixed(0),"%"]})]},`y-tick-${N}`)),a.jsx("text",{transform:`translate(-45, ${v/2}) rotate(-90)`,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:"Score (quality)"})]})}),o&&a.jsxs("div",{className:"absolute z-10 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg shadow-lg p-3 text-sm pointer-events-none",style:{left:Math.min(u.x+15,r-200),top:u.y-10,maxWidth:220},children:[a.jsx("div",{className:"font-medium text-[var(--text-primary)] truncate mb-2",children:o.candidate_name.replace(/^baseline_/,"")}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Score:"}),a.jsxs("span",{className:"text-right font-medium",children:[(o.avg_score*100).toFixed(1),"%"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tokens:"}),a.jsxs("span",{className:"text-right",children:[(o.avg_tokens/1e3).toFixed(1),"K"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Duration:"}),a.jsxs("span",{className:"text-right",children:[o.avg_duration.toFixed(1),"s"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Pass rate:"}),a.jsxs("span",{className:"text-right",children:[o.passed_runs,"/",o.total_runs]})]}),o.is_pareto&&a.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)] text-xs text-[var(--accent)]",children:"Optimal (best tradeoff)"})]})]})}function g1(e=2e3){const[t,n]=g.useState(!1),[r,s]=g.useState(null),i=g.useCallback(async o=>{try{return await navigator.clipboard.writeText(o),n(!0),s(null),setTimeout(()=>n(!1),e),!0}catch{return s("Failed to copy to clipboard"),n(!1),!1}},[e]),l=g.useCallback(()=>{n(!1),s(null)},[]);return{copy:i,copied:t,error:r,reset:l}}function j1({isOpen:e,onClose:t,title:n,itemId:r,itemType:s,isPublic:i,createdByName:l,onTogglePublic:o}){const[c,u]=g.useState(!1),{copy:d,copied:f}=g1(),m=`${window.location.origin}/${s}s/${r}`,v=async()=>{u(!0);try{await o(!i)}finally{u(!1)}},k=()=>{d(m)};return a.jsx(ls,{isOpen:e,onClose:t,title:n,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between p-3 bg-[var(--bg-tertiary)] rounded",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[i?a.jsx(qc,{className:"w-5 h-5 text-[var(--accent)]"}):a.jsx(Bm,{className:"w-5 h-5 text-[var(--text-secondary)]"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium",children:i?"Public":"Private"}),a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:i?"Anyone with the link can view":"Only you can access"})]})]}),a.jsx("button",{onClick:v,disabled:c,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${i?"bg-[var(--accent)]":"bg-[var(--border)]"} ${c?"opacity-50 cursor-not-allowed":""}`,children:a.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${i?"translate-x-6":"translate-x-1"}`})})]}),i&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Share link"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",readOnly:!0,value:m,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono"}),a.jsx(V,{variant:"secondary",onClick:k,children:f?a.jsxs(a.Fragment,{children:[a.jsx(Lg,{className:"w-4 h-4 mr-1"}),"Copied"]}):a.jsxs(a.Fragment,{children:[a.jsx(Ig,{className:"w-4 h-4 mr-1"}),"Copy"]})})]})]}),l&&a.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",a.jsx("span",{className:"text-[var(--text-primary)]",children:l})]}),a.jsx("div",{className:"text-xs text-[var(--text-secondary)] pt-2 border-t border-[var(--border)]",children:i?a.jsxs(a.Fragment,{children:[a.jsxs("p",{children:["Public ",s,"s can be viewed by anyone with the link."]}),a.jsxs("p",{className:"mt-1",children:["Only you can edit or delete this ",s,"."]})]}):a.jsxs("p",{children:["Make this ",s," public to share it with others."]})})]})})}function w1({job:e,onUpdate:t}){const[n,r]=g.useState(!1),s=async i=>{await Mt.update(e.id,{is_public:i}),t()};return a.jsxs(a.Fragment,{children:[a.jsxs(V,{variant:"secondary",size:"sm",onClick:()=>r(!0),title:e.is_public?"Sharing settings":"Share this job",children:[a.jsx(Wg,{className:"w-4 h-4 mr-1"}),e.is_public?"Shared":"Share"]}),a.jsx(j1,{isOpen:n,onClose:()=>r(!1),title:"Share Job",itemId:e.id,itemType:"job",isPublic:e.is_public,createdByName:e.created_by_name,onTogglePublic:s})]})}function k1(){var be;const{jobId:e}=ha(),t=Dn(),n=Yt(),[r,s]=g.useState(null),[i,l]=g.useState(!1),[o,c]=g.useState(null),[u,d]=g.useState([]),[f,m]=g.useState(null),[v,k]=g.useState(null),[w,b]=g.useState("results"),[p,h]=g.useState("score"),[x,j]=g.useState("desc"),[C,S]=g.useState(!1),{data:N,isLoading:_}=oe({queryKey:["jobs",e],queryFn:()=>Mt.get(e),enabled:!!e,refetchInterval:i?2e3:!1}),{data:z=[]}=oe({queryKey:["runs",e],queryFn:()=>Bo.list({job_id:e}),enabled:!!e,refetchInterval:i?2e3:!1}),{data:O}=oe({queryKey:["job-summary",e],queryFn:()=>Bo.getJobSummary(e),enabled:!!e&&(N==null?void 0:N.status)==="completed"}),B=Ze({mutationFn:async()=>{l(!0),d([]),m(null),k(null);for await(const R of Mt.start(e))s(R),R.current_candidate&&R.current_task&&m(K=>(K&&(K.candidate!==R.current_candidate||K.task!==R.current_task)&&d(xe=>[...xe,{candidate_name:K.candidate,task_name:K.task,completed_at:Date.now()}]),{candidate:R.current_candidate,task:R.current_task})),R.event==="error"&&(k(R.message),l(!1),n.invalidateQueries({queryKey:["jobs",e]})),R.event==="complete"&&(m(K=>(K&&d(xe=>[...xe,{candidate_name:K.candidate,task_name:K.task,completed_at:Date.now()}]),null)),l(!1),n.invalidateQueries({queryKey:["jobs",e]}),n.invalidateQueries({queryKey:["runs",e]}),n.invalidateQueries({queryKey:["job-summary",e]}))}}),J=Ze({mutationFn:()=>Mt.cancel(e),onSuccess:()=>{l(!1),n.invalidateQueries({queryKey:["jobs",e]})}});g.useEffect(()=>{(N==null?void 0:N.status)==="running"&&l(!0)},[N==null?void 0:N.status]);const se=g.useMemo(()=>{const R=new Map;for(const K of z)R.has(K.task_name)||R.set(K.task_name,[]),R.get(K.task_name).push(K);return R},[z]),ce=g.useMemo(()=>Array.from(se.keys()),[se]);g.useEffect(()=>{!o&&ce.length>0&&c(ce[0])},[ce,o]);const D=g.useMemo(()=>{if(!(O!=null&&O.candidate_summaries))return[];let R=[...O.candidate_summaries];return C&&(R=R.filter(K=>K.is_pareto)),R.sort((K,xe)=>{let _e,L;switch(p){case"score":_e=K.avg_score,L=xe.avg_score;break;case"tokens":_e=K.avg_tokens,L=xe.avg_tokens;break;case"duration":_e=K.avg_duration,L=xe.avg_duration;break;case"pass_rate":_e=K.passed_runs/K.total_runs,L=xe.passed_runs/xe.total_runs;break}return x==="desc"?L-_e:_e-L}),R},[O,p,x,C]),W=R=>{p===R?j(x==="desc"?"asc":"desc"):(h(R),j(R==="tokens"||R==="duration"?"asc":"desc"))},Z=({label:R,sortKeyVal:K})=>a.jsx("th",{className:"pb-2 cursor-pointer hover:text-[var(--text-primary)] select-none",onClick:()=>W(K),children:a.jsxs("div",{className:"flex items-center gap-1",children:[R,p===K&&a.jsx(Tg,{size:12,className:x==="asc"?"rotate-180":""})]})});if(_)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!N)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Job not found"});const P=eu(),A=!N.user_id||N.user_id==="anonymous"||P&&N.created_by_name===P,T=N.is_public&&!A,Q=()=>{n.invalidateQueries({queryKey:["jobs",e]})},te=R=>{const K={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};return a.jsx(q,{variant:K[R]||"default",children:R})};return a.jsxs("div",{children:[a.jsx(pa,{items:[{label:"Experiments",path:"/jobs"},{label:N.name||`Job ${N.id.slice(0,8)}`}]}),a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:N.name||`Job ${N.id.slice(0,8)}`}),te(N.status),N.is_public&&a.jsxs(q,{variant:"info",children:[a.jsx(qc,{className:"w-3 h-3 mr-1 inline"}),"Public"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[a.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-2 py-0.5 rounded font-mono text-[var(--text-secondary)]",children:[N.id.slice(0,8),"..."]}),a.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:(be=N.strategies)!=null&&be.length?`${N.strategies.join(" → ")} · ${N.task_ids.length} tasks · ${N.total_experiments} experiments`:`${N.candidate_ids.length} candidates × ${N.task_ids.length} tasks = ${N.total_experiments} experiments`}),N.is_public&&N.created_by_name&&a.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",a.jsx("span",{className:"text-[var(--text-primary)]",children:N.created_by_name})]})]})]}),a.jsxs("div",{className:"flex gap-2",children:[A&&a.jsx(w1,{job:N,onUpdate:Q}),T&&a.jsx(q,{variant:"default",children:"View Only"}),A&&N.status==="pending"&&a.jsx(V,{variant:"primary",onClick:()=>B.mutate(),disabled:B.isPending,children:B.isPending?"Starting...":"Start"}),A&&N.status==="running"&&a.jsx(V,{variant:"danger",onClick:()=>J.mutate(),disabled:J.isPending,children:"Cancel"})]})]}),(v||N.error)&&a.jsx(je,{className:"mb-6 border-red-500/50 bg-red-500/10",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"w-5 h-5 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-0.5",children:"!"}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-red-400",children:"Error"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:v||N.error})]})]})}),(i||r)&&a.jsxs(je,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"font-medium",children:"Progress"}),a.jsxs("span",{className:"text-[var(--accent)]",children:[(r==null?void 0:r.completed)||N.completed_experiments,"/",(r==null?void 0:r.total)||N.total_experiments]})]}),a.jsx("div",{className:"w-full bg-[var(--bg-primary)] h-2 mb-2",children:a.jsx("div",{className:"h-full bg-[var(--accent)] transition-all",style:{width:`${((r==null?void 0:r.completed)||N.completed_experiments)/((r==null?void 0:r.total)||N.total_experiments)*100}%`}})}),(r==null?void 0:r.message)&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r.message}),i&&a.jsxs("div",{className:"mt-4 border-t border-[var(--border)] pt-4",children:[(r==null?void 0:r.current_candidate)&&(r==null?void 0:r.current_task)&&a.jsxs("div",{className:"mb-3",children:[a.jsx("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:"Currently Running"}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 px-3 py-2 bg-blue-500/10 border border-blue-500/30 rounded",children:[a.jsx("div",{className:"w-2 h-2 bg-blue-400 rounded-full animate-pulse"}),a.jsx("span",{className:"font-medium",children:r.current_candidate}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{children:r.current_task})]})]}),u.length>0&&a.jsxs("div",{children:[a.jsxs("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:["Completed (",u.length,")"]}),a.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto space-y-1",children:u.map((R,K)=>a.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-500/10 border border-green-500/30 rounded text-sm",children:[a.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}),a.jsx("span",{className:"font-medium",children:R.candidate_name}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{children:R.task_name})]},`${R.candidate_name}-${R.task_name}-${K}`))})]})]})]}),(N.status==="completed"||z.length>0)&&a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-[var(--border)]",children:[a.jsxs("button",{onClick:()=>b("results"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${w==="results"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Og,{size:16}),"Results"]}),a.jsxs("button",{onClick:()=>b("compare"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${w==="compare"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Ag,{size:16}),"Compare"]}),a.jsxs("button",{onClick:()=>b("runs"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${w==="runs"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Qg,{size:16}),"Runs (",z.length,")"]})]}),w==="results"&&a.jsxs(a.Fragment,{children:[O&&O.candidate_summaries.length>1&&a.jsxs(je,{className:"mb-6",children:[a.jsx("div",{className:"flex items-start justify-between mb-4",children:a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium",children:"Quality vs. Cost Tradeoff"}),a.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:["Candidates on the frontier (connected line) are ",a.jsx("strong",{children:"optimal"})," - no other candidate beats them on both score AND cost."]})]})}),a.jsxs("div",{className:"mb-4 p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs text-[var(--text-secondary)]",children:[a.jsx("strong",{className:"text-[var(--text-primary)]",children:"How optimal tradeoffs are calculated:"})," A candidate is optimal if there's no other candidate that has both a higher score AND lower cost. For example, if Candidate A has 95% score at 50K tokens and Candidate B has 90% score at 40K tokens, both are optimal - A is better on score, B is better on cost. But if Candidate C has 85% score at 60K tokens, it's ",a.jsx("em",{children:"not"})," optimal because B beats it on both metrics."]}),a.jsx(y1,{summaries:O.candidate_summaries,height:350})]}),O&&a.jsxs(je,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h3",{className:"font-medium",children:"Results Summary"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C,onChange:R=>S(R.target.checked),className:"rounded border-[var(--border)]"}),"Optimal only"]})]}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-left text-[var(--text-secondary)] border-b border-[var(--border)]",children:[a.jsx("th",{className:"pb-2",children:"Candidate"}),a.jsx(Z,{label:"Score",sortKeyVal:"score"}),a.jsx(Z,{label:"Tokens",sortKeyVal:"tokens"}),a.jsx(Z,{label:"Duration",sortKeyVal:"duration"}),a.jsx(Z,{label:"Pass Rate",sortKeyVal:"pass_rate"}),a.jsx("th",{className:"pb-2",children:"Optimal"})]})}),a.jsx("tbody",{children:D.map((R,K)=>a.jsxs("tr",{className:`border-b border-[var(--border)] ${K===0?"bg-[var(--accent)]/10":""}`,children:[a.jsxs("td",{className:"py-2 font-medium",children:[K===0&&a.jsx("span",{className:"text-[var(--accent)] mr-1",children:"#1"}),R.candidate_name.replace(/^baseline_/,"")]}),a.jsxs("td",{className:"py-2",children:[(R.avg_score*100).toFixed(1),"%"]}),a.jsxs("td",{className:"py-2",children:[(R.avg_tokens/1e3).toFixed(1),"K"]}),a.jsxs("td",{className:"py-2",children:[R.avg_duration.toFixed(1),"s"]}),a.jsxs("td",{className:"py-2",children:[R.passed_runs,"/",R.total_runs]}),a.jsx("td",{className:"py-2",children:R.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})})]},R.candidate_name))})]})}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-3",children:"Click column headers to sort. The #1 ranked candidate is highlighted based on your sort criteria."})]}),!O&&a.jsx(je,{children:a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Results will appear here after the job completes.":"No results yet. Start the job to see results."})})]}),w==="compare"&&a.jsxs(je,{children:[a.jsx("h3",{className:"font-medium mb-4",children:"Compare Candidates by Task"}),ce.length>0?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:ce.map(R=>a.jsx("button",{onClick:()=>c(o===R?null:R),className:`px-3 py-1 text-sm rounded border transition-colors ${o===R?"bg-[var(--accent)] text-white border-[var(--accent)]":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:R},R))}),o&&se.get(o)?a.jsx(v1,{runs:se.get(o).map(R=>({id:R.id,candidate_name:R.candidate_name,tokens_input:0,tokens_output:0,tokens_total:R.tokens_total,duration_seconds:R.duration_seconds,score:R.score,passed:R.passed,is_pareto:R.is_pareto}))}):a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"Select a task above to compare how different candidates performed on it."})]}):a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Comparison data will appear here after runs complete.":"No runs yet. Start the job to compare candidates."})]}),w==="runs"&&a.jsxs(je,{children:[a.jsx("h3",{className:"font-medium mb-4",children:"All Experiment Runs"}),z.length===0?a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Runs will appear here as they complete. See progress above for live status.":"No runs yet. Start the job to see results."}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:z.map(R=>a.jsxs("div",{className:"p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] cursor-pointer hover:border-[var(--accent-dim)] transition-colors",onClick:()=>t(`/runs/${R.id}`),children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:`text-lg font-bold ${R.passed?"text-green-400":"text-red-400"}`,children:[(R.score*100).toFixed(0),"%"]}),R.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})]}),a.jsx("div",{className:"text-sm font-medium truncate",title:R.candidate_name,children:R.candidate_name.replace(/^baseline_/,"")}),a.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:R.task_name}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:[(R.tokens_total/1e3).toFixed(1),"K tokens"]}),a.jsxs("span",{children:[R.duration_seconds.toFixed(1),"s"]})]})]},R.id))})]})]})}const gn={input:"bg-blue-500",output:"bg-emerald-500",inputText:"text-blue-400",outputText:"text-emerald-400"};function Dd(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ad({input:e,output:t,maxValue:n,height:r=24,showLabels:s=!0}){const i=e+t;if(i===0)return a.jsx("div",{className:"flex items-center gap-2 w-full",children:a.jsx("div",{className:"rounded bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`}})});const l=n>0?i/n*100:100;return a.jsxs("div",{className:"flex items-center gap-3 w-full",children:[a.jsx("div",{className:"relative rounded overflow-hidden bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`},children:a.jsxs("div",{className:"h-full flex transition-all duration-300",style:{width:`${l}%`},children:[a.jsx("div",{className:`h-full ${gn.input} transition-all`,style:{width:`${e/i*100}%`},title:`Input: ${e.toLocaleString()} tokens`}),a.jsx("div",{className:`h-full ${gn.output} transition-all`,style:{width:`${t/i*100}%`},title:`Output: ${t.toLocaleString()} tokens`})]})}),s&&a.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono text-[var(--text-secondary)] min-w-[90px] justify-end",children:[a.jsxs("span",{className:gn.inputText,children:["↑",Dd(e)]}),a.jsx("span",{children:"/"}),a.jsxs("span",{className:gn.outputText,children:["↓",Dd(t)]})]})]})}function _l({label:e,value:t,color:n="default"}){const r={default:"text-[var(--text-primary)]",input:gn.inputText,output:gn.outputText}[n];return a.jsxs("div",{className:"flex-1 p-3 bg-[var(--bg-primary)] border border-[var(--border)] rounded",children:[a.jsx("div",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e}),a.jsx("div",{className:`font-mono text-lg font-bold ${r}`,children:t})]})}function cp({tokensInput:e,tokensOutput:t,tokensTotal:n,turns:r}){const s=n>0?Math.round(e/n*100):0,i=n>0?Math.round(t/n*100):0,l=g.useMemo(()=>{if(!r||r.length===0)return null;let c=0,u=0;return r.map(d=>(c+=d.input,u+=d.output,{input:c,output:u,total:c+u}))},[r]),o=l?Math.max(...l.map(c=>c.total)):n;return a.jsxs(je,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-4",children:"Token Usage"}),a.jsx("div",{className:"mb-4",children:a.jsx(Ad,{input:e,output:t,maxValue:n,height:32})}),a.jsxs("div",{className:"flex items-center gap-6 text-xs mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-3 h-3 rounded ${gn.input}`}),a.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Input (",s,"%)"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-3 h-3 rounded ${gn.output}`}),a.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Output (",i,"%)"]})]})]}),a.jsxs("div",{className:"flex gap-3 mb-4",children:[a.jsx(_l,{label:"Input Tokens",value:e.toLocaleString(),color:"input"}),a.jsx(_l,{label:"Output Tokens",value:t.toLocaleString(),color:"output"}),a.jsx(_l,{label:"Total Tokens",value:n.toLocaleString()})]}),l&&l.length>1&&a.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[a.jsxs("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:["Token Accumulation (",r.length," turns)"]}),a.jsx("div",{className:"space-y-2",children:r.map((c,u)=>a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--bg-primary)] border border-[var(--border)] flex items-center justify-center text-xs font-medium",children:u+1}),a.jsx("div",{className:"flex-1",children:a.jsx(Ad,{input:l[u].input,output:l[u].output,maxValue:o,height:16})})]},u))})]}),a.jsx("div",{className:"mt-4 text-xs text-[var(--text-secondary)] border-t border-[var(--border)] pt-3",children:"Token usage affects API cost. Input tokens are typically cheaper than output tokens."})]})}function b1(){const{runId:e}=ha(),{data:t,isLoading:n}=oe({queryKey:["runs",e],queryFn:()=>Bo.get(e),enabled:!!e});return n?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsx(pa,{items:[{label:"Experiments",path:"/jobs"},{label:"Job",path:`/jobs/${t.job_id}`},{label:t.candidate_name}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:t.candidate_name}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{className:"text-lg",children:t.task_name}),t.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})]})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[a.jsx(Fa,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),a.jsx(Fa,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),a.jsx(Fa,{label:"Duration",value:`${t.duration_seconds.toFixed(1)}s`}),a.jsx(Fa,{label:"Status",value:t.passed?"Passed":"Failed",status:t.passed?"success":"error"})]}),a.jsx(cp,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),a.jsxs(je,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),t.reasoning&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:t.reasoning}),t.criteria_results.length>0&&a.jsx("div",{className:"space-y-2",children:t.criteria_results.map(r=>a.jsx("div",{className:"flex items-start justify-between p-3 bg-[var(--bg-primary)] border border-[var(--border)]",children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-medium",children:r.name}),a.jsxs(q,{variant:r.passed?"success":"error",children:[(r.score*100).toFixed(0),"%"]})]}),r.reasoning&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r.reasoning})]})},r.name))})]}),a.jsxs(je,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created.length>0&&a.jsxs(je,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),a.jsx("div",{className:"space-y-1",children:t.files_created.map(r=>a.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:r},r))})]}),Object.keys(t.trace).length>0&&a.jsx(ap,{trace:t.trace})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Run not found"})}function Fa({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return a.jsxs(je,{children:[a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),a.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function N1(){const{testId:e}=ha(),{data:t,isLoading:n}=oe({queryKey:["tests",e],queryFn:()=>Ls.get(e),enabled:!!e}),{data:r}=oe({queryKey:["configs",t==null?void 0:t.agent_id],queryFn:()=>Tn.get(t.agent_id),enabled:!!(t!=null&&t.agent_id)});if(n)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!t)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Test not found"});const s={completed:"success",failed:"error",running:"info",pending:"default",cancelled:"warning"};return a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsx(pa,{items:[{label:"Agents",path:"/agents"},...r?[{label:r.name,path:`/agents/${r.id}`}]:[],{label:`Test ${t.id.slice(0,8)}`}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:"Test Run"}),r&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"•"}),a.jsx("span",{className:"text-lg",children:r.name})]}),a.jsx(q,{variant:s[t.status]||"default",children:t.status})]}),a.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:["ID: ",t.id.slice(0,8),"..."]})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[a.jsx(Ia,{label:"Duration",value:`${t.duration_seconds.toFixed(2)}s`}),a.jsx(Ia,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),t.score!==null&&a.jsx(Ia,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),a.jsx(Ia,{label:"Status",value:t.status.charAt(0).toUpperCase()+t.status.slice(1),status:t.status==="completed"?"success":t.status==="failed"?"error":void 0})]}),a.jsx(cp,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),a.jsxs(je,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Prompt"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)] font-mono",children:t.prompt})]}),t.error&&a.jsxs(je,{className:"mb-6 border-red-500/30 bg-red-500/5",children:[a.jsx("h3",{className:"font-medium mb-3 text-red-400",children:"Error"}),a.jsx("pre",{className:"text-sm text-red-300 overflow-x-auto whitespace-pre-wrap",children:t.error})]}),t.reasoning&&a.jsxs(je,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.reasoning})]}),a.jsxs(je,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created&&t.files_created.length>0&&a.jsxs(je,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),a.jsx("div",{className:"space-y-1",children:t.files_created.map(i=>a.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:i},i))})]}),t.trace&&Object.keys(t.trace).length>0&&a.jsx(ap,{trace:t.trace}),a.jsxs(je,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Timestamps"}),a.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Created:"}),a.jsx("div",{className:"font-mono",children:new Date(t.created_at).toLocaleString()})]}),t.started_at&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Started:"}),a.jsx("div",{className:"font-mono",children:new Date(t.started_at).toLocaleString()})]}),t.completed_at&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Completed:"}),a.jsx("div",{className:"font-mono",children:new Date(t.completed_at).toLocaleString()})]})]})]})]})}function Ia({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return a.jsxs(je,{children:[a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),a.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function S1(){const{deploymentId:e}=ha(),{data:t,isLoading:n}=oe({queryKey:["deployments",e],queryFn:()=>E0.get(e),enabled:!!e}),r=t==null?void 0:t.versions.find(i=>i.id===t.current_version_id),{data:s}=oe({queryKey:["configs",r==null?void 0:r.config_id],queryFn:()=>Tn.get(r.config_id),enabled:!!(r!=null&&r.config_id)});return n?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsxs("div",{className:"mb-4 flex-shrink-0",children:[a.jsx(pa,{items:[{label:"Agents",path:"/agents"},{label:t.name}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Hg,{size:20,className:"text-[var(--accent)]"}),a.jsx("h2",{className:"text-xl font-bold",children:t.name}),r&&a.jsxs(q,{variant:"info",children:["v",r.version]})]}),t.description&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:t.description})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsx("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-5",children:[a.jsxs("div",{className:"flex items-center gap-4 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:["Created ",new Date(t.created_at).toLocaleDateString()]}),a.jsxs("span",{children:["Updated ",new Date(t.updated_at).toLocaleDateString()]}),a.jsxs("span",{children:[t.versions.length," version",t.versions.length!==1?"s":""]})]}),s&&a.jsxs(Rn,{to:`/agents/${s.id}`,className:"flex items-center gap-2 p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-sm",children:[a.jsx(Um,{size:14,className:"text-[var(--accent)]"}),a.jsxs("span",{children:["Agent: ",a.jsx("span",{className:"font-medium",children:s.name})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider mb-3",children:"Version History"}),t.versions.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"No versions yet."}):a.jsx("div",{className:"space-y-2",children:t.versions.map(i=>a.jsx(C1,{version:i,isActive:i.id===t.current_version_id},i.id))})]})]})}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[a.jsx(Vm,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),a.jsx("div",{className:"flex-1 min-h-0",children:s?a.jsx(ip,{agent:s}):a.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-secondary)] text-sm",children:r?"Loading agent configuration...":"No active version to test."})})]})]})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Deployment not found"})}function C1({version:e,isActive:t}){const n=e.config_snapshot;return a.jsxs("div",{className:`p-3 rounded-md border transition-colors ${t?"border-[var(--accent)] bg-[var(--accent-dim)]":"border-[var(--border)] bg-[var(--bg-secondary)]"}`,children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Yg,{size:12,className:"text-[var(--text-secondary)]"}),a.jsxs("span",{className:"text-sm font-medium",children:["v",e.version]}),t&&a.jsx(q,{variant:"success",children:"Active"}),a.jsx(q,{variant:e.source==="optimize"?"info":"default",children:e.source})]}),a.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)]",children:[a.jsx(Am,{size:11}),a.jsx("span",{children:new Date(e.created_at).toLocaleString()})]})]}),e.description&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e.description}),Object.keys(n).length>0&&a.jsxs("div",{className:"mt-1",children:[a.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)] mb-1",children:[a.jsx(Dg,{size:11}),a.jsx("span",{children:"Config"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-xs",children:["framework"in n&&n.framework?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Framework"}),a.jsx("span",{className:"font-mono",children:String(n.framework)})]}):null,"model"in n&&n.model?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Model"}),a.jsx("span",{className:"font-mono",children:String(n.model)})]}):null,"tools"in n&&n.tools?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tools"}),a.jsx("span",{className:"font-mono truncate",children:Array.isArray(n.tools)?n.tools.join(", "):String(n.tools)})]}):null]})]})]})}function _1(){const{authConfig:e,isLoading:t,error:n,login:r,loginWithGitHub:s,clearError:i}=tu(),[l,o]=g.useState(""),[c,u]=g.useState("");g.useEffect(()=>{n&&i()},[l,c]);const d=async m=>{m.preventDefault(),!(!l||!c)&&await r(l,c)},f=()=>{s()};return a.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:a.jsxs("div",{className:"w-full max-w-md",children:[a.jsxs("div",{className:"text-center mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:"Flow"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:"Sign in to access the optimization dashboard"})]}),a.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] p-6 space-y-6",children:[n&&a.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[var(--error)]/10 border border-[var(--error)]/20 text-[var(--error)]",children:[a.jsx(Fm,{size:18,className:"mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-sm",children:n})]}),(e==null?void 0:e.mode)==="basic"&&a.jsxs("form",{onSubmit:d,className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Username"}),a.jsxs("div",{className:"relative",children:[a.jsx(Hm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),a.jsx("input",{type:"text",value:l,onChange:m=>o(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter username",autoComplete:"username",autoFocus:!0})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Password"}),a.jsxs("div",{className:"relative",children:[a.jsx(Bm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),a.jsx("input",{type:"password",value:c,onChange:m=>u(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter password",autoComplete:"current-password"})]})]}),a.jsx(V,{type:"submit",variant:"primary",className:"w-full justify-center",loading:t,disabled:!l||!c,children:"Sign In"})]}),(e==null?void 0:e.mode)==="github"&&a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center",children:"Sign in with your GitHub account to continue"}),a.jsx(V,{onClick:f,variant:"secondary",className:"w-full justify-center",icon:$g,children:"Continue with GitHub"})]})]})]})})}function E1({children:e}){const{authConfig:t,isLoadingConfig:n,isAuthenticated:r,loadAuthConfig:s,handleOAuthCallback:i}=tu();return g.useEffect(()=>{s()},[s]),g.useEffect(()=>{n||i()},[n,i]),n?a.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center",children:a.jsxs("div",{className:"text-center",children:[a.jsx(ma,{className:"w-8 h-8 animate-spin text-[var(--accent)] mx-auto mb-4"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:"Loading..."})]})}):t!=null&&t.enabled&&!r?a.jsx(_1,{}):a.jsx(a.Fragment,{children:e})}function P1(){return a.jsx(jg,{children:a.jsx(E1,{children:a.jsx(fg,{children:a.jsxs(xt,{path:"/",element:a.jsx($0,{}),children:[a.jsx(xt,{index:!0,element:a.jsx(B0,{})}),a.jsx(xt,{path:"agents",element:a.jsx(Z0,{})}),a.jsx(xt,{path:"agents/:agentId",element:a.jsx(i1,{})}),a.jsx(xt,{path:"tasks",element:a.jsx(u1,{})}),a.jsx(xt,{path:"jobs",element:a.jsx(m1,{})}),a.jsx(xt,{path:"jobs/:jobId",element:a.jsx(k1,{})}),a.jsx(xt,{path:"runs/:runId",element:a.jsx(b1,{})}),a.jsx(xt,{path:"tests/:testId",element:a.jsx(N1,{})}),a.jsx(xt,{path:"deployments/:deploymentId",element:a.jsx(S1,{})})]})})})})}const $d=localStorage.getItem("flow-theme");if($d)try{const{state:e}=JSON.parse($d);e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}catch{}const T1=new ly({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}});El.createRoot(document.getElementById("root")).render(a.jsx(Jo.StrictMode,{children:a.jsx(oy,{client:T1,children:a.jsx(P1,{})})})); diff --git a/src/flow/ui/ui/assets/index-B3uaDfCt.css b/src/flow/ui/ui/assets/index-B3uaDfCt.css new file mode 100644 index 0000000000000000000000000000000000000000..61ebacb48381e94b11a96586b633605a79bca462 --- /dev/null +++ b/src/flow/ui/ui/assets/index-B3uaDfCt.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:Segoe UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:JetBrains Mono,ui-monospace,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.bottom-0{bottom:0}.bottom-1{bottom:.25rem}.left-0{left:0}.left-3{left:.75rem}.top-0{top:0}.top-1{top:.25rem}.top-1\/2{top:50%}.z-10{z-index:10}.z-50{z-index:50}.mx-0\.5{margin-left:.125rem;margin-right:.125rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.-mb-px{margin-bottom:-1px}.-mt-2{margin-top:-.5rem}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.ml-6{margin-left:1.5rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-auto{margin-top:auto}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-1\.5{height:.375rem}.h-12{height:3rem}.h-2{height:.5rem}.h-3{height:.75rem}.h-32{height:8rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-8{height:2rem}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:8rem}.max-h-40{max-height:10rem}.max-h-48{max-height:12rem}.max-h-80{max-height:20rem}.max-h-96{max-height:24rem}.max-h-\[120px\]{max-height:120px}.max-h-\[80vh\]{max-height:80vh}.min-h-0{min-height:0px}.min-h-\[100px\]{min-height:100px}.min-h-\[200px\]{min-height:200px}.min-h-\[40px\]{min-height:40px}.min-h-screen{min-height:100vh}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-2{width:.5rem}.w-20{width:5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-32{width:8rem}.w-4{width:1rem}.w-5{width:1.25rem}.w-56{width:14rem}.w-6{width:1.5rem}.w-8{width:2rem}.w-\[350px\]{width:350px}.w-\[3px\]{width:3px}.w-\[420px\]{width:420px}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-\[90px\]{min-width:90px}.max-w-2xl{max-width:42rem}.max-w-4xl{max-width:56rem}.max-w-\[80\%\]{max-width:80%}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-90{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.resize-y{resize:vertical}.resize{resize:both}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-\[var\(--accent\)\]{border-color:var(--accent)}.border-\[var\(--badge-error-border\)\]{border-color:var(--badge-error-border)}.border-\[var\(--badge-info-border\)\]{border-color:var(--badge-info-border)}.border-\[var\(--badge-success-border\)\]{border-color:var(--badge-success-border)}.border-\[var\(--badge-warning-border\)\]{border-color:var(--badge-warning-border)}.border-\[var\(--border\)\]{border-color:var(--border)}.border-blue-500\/30{border-color:#3b82f64d}.border-green-500\/30{border-color:#22c55e4d}.border-green-500\/50{border-color:#22c55e80}.border-red-500\/30{border-color:#ef44444d}.border-red-500\/50{border-color:#ef444480}.border-transparent{border-color:transparent}.bg-\[var\(--accent\)\]{background-color:var(--accent)}.bg-\[var\(--accent-dim\)\]{background-color:var(--accent-dim)}.bg-\[var\(--badge-error-bg\)\]{background-color:var(--badge-error-bg)}.bg-\[var\(--badge-info-bg\)\]{background-color:var(--badge-info-bg)}.bg-\[var\(--badge-success-bg\)\]{background-color:var(--badge-success-bg)}.bg-\[var\(--badge-warning-bg\)\]{background-color:var(--badge-warning-bg)}.bg-\[var\(--bg-primary\)\]{background-color:var(--bg-primary)}.bg-\[var\(--bg-secondary\)\]{background-color:var(--bg-secondary)}.bg-\[var\(--bg-tertiary\)\]{background-color:var(--bg-tertiary)}.bg-\[var\(--border\)\]{background-color:var(--border)}.bg-\[var\(--error\)\]{background-color:var(--error)}.bg-\[var\(--span-agent-bg\)\]{background-color:var(--span-agent-bg)}.bg-\[var\(--span-fail-bg\)\]{background-color:var(--span-fail-bg)}.bg-\[var\(--span-llm-bg\)\]{background-color:var(--span-llm-bg)}.bg-\[var\(--span-other-bg\)\]{background-color:var(--span-other-bg)}.bg-\[var\(--span-pass-bg\)\]{background-color:var(--span-pass-bg)}.bg-\[var\(--span-tool-bg\)\]{background-color:var(--span-tool-bg)}.bg-black\/50{background-color:#00000080}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(96 165 250 / var(--tw-bg-opacity, 1))}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-500\/10{background-color:#3b82f61a}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(16 185 129 / var(--tw-bg-opacity, 1))}.bg-green-400{--tw-bg-opacity: 1;background-color:rgb(74 222 128 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-green-500\/10{background-color:#22c55e1a}.bg-green-500\/20{background-color:#22c55e33}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-500\/10{background-color:#ef44441a}.bg-red-500\/5{background-color:#ef44440d}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-2{padding-bottom:.5rem}.pb-3{padding-bottom:.75rem}.pl-10{padding-left:2.5rem}.pl-9{padding-left:2.25rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:JetBrains Mono,ui-monospace,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.text-\[var\(--accent\)\]{color:var(--accent)}.text-\[var\(--badge-error-text\)\]{color:var(--badge-error-text)}.text-\[var\(--badge-info-text\)\]{color:var(--badge-info-text)}.text-\[var\(--badge-success-text\)\]{color:var(--badge-success-text)}.text-\[var\(--badge-warning-text\)\]{color:var(--badge-warning-text)}.text-\[var\(--error\)\]{color:var(--error)}.text-\[var\(--span-agent-text\)\]{color:var(--span-agent-text)}.text-\[var\(--span-fail-text\)\]{color:var(--span-fail-text)}.text-\[var\(--span-llm-text\)\]{color:var(--span-llm-text)}.text-\[var\(--span-other-text\)\]{color:var(--span-other-text)}.text-\[var\(--span-pass-text\)\]{color:var(--span-pass-text)}.text-\[var\(--span-tool-text\)\]{color:var(--span-tool-text)}.text-\[var\(--success\)\]{color:var(--success)}.text-\[var\(--text-primary\)\]{color:var(--text-primary)}.text-\[var\(--text-secondary\)\]{color:var(--text-secondary)}.text-\[var\(--text-tertiary\)\]{color:var(--text-tertiary)}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.text-blue-400{--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.text-emerald-400{--tw-text-opacity: 1;color:rgb(52 211 153 / var(--tw-text-opacity, 1))}.text-green-400{--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-purple-400{--tw-text-opacity: 1;color:rgb(192 132 252 / var(--tw-text-opacity, 1))}.text-red-300{--tw-text-opacity: 1;color:rgb(252 165 165 / var(--tw-text-opacity, 1))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}:root{--bg-primary: #ffffff;--bg-secondary: #fafafa;--bg-tertiary: #f3f4f6;--text-primary: #1b1b1b;--text-secondary: #616161;--accent: #7c3aed;--accent-hover: #6d28d9;--accent-dim: #ede9fe;--border: #e5e7eb;--error: #dc2626;--success: #16a34a;--badge-success-bg: #f0fdf4;--badge-success-text: #15803d;--badge-success-border: #bbf7d0;--badge-warning-bg: #fefce8;--badge-warning-text: #a16207;--badge-warning-border: #fef08a;--badge-error-bg: #fef2f2;--badge-error-text: #b91c1c;--badge-error-border: #fecaca;--badge-info-bg: #eff6ff;--badge-info-text: #1d4ed8;--badge-info-border: #bfdbfe;--span-llm-bg: #f5f3ff;--span-llm-text: #6b21a8;--span-tool-bg: #eff6ff;--span-tool-text: #1e40af;--span-agent-bg: #f0fdf4;--span-agent-text: #166534;--span-other-bg: #fff7ed;--span-other-text: #9a3412;--span-pass-bg: #f0fdf4;--span-pass-text: #166534;--span-fail-bg: #fef2f2;--span-fail-text: #991b1b}[data-theme=dark]{--bg-primary: #1a1a2e;--bg-secondary: #16162a;--bg-tertiary: #252540;--text-primary: #f0f0f5;--text-secondary: #a0a0b5;--accent: #a78bfa;--accent-hover: #8b5cf6;--accent-dim: #2d2055;--border: #2d2d45;--error: #ef4444;--success: #22c55e;--badge-success-bg: rgba(34, 197, 94, .15);--badge-success-text: #4ade80;--badge-success-border: rgba(34, 197, 94, .3);--badge-warning-bg: rgba(234, 179, 8, .15);--badge-warning-text: #fbbf24;--badge-warning-border: rgba(234, 179, 8, .3);--badge-error-bg: rgba(239, 68, 68, .15);--badge-error-text: #f87171;--badge-error-border: rgba(239, 68, 68, .3);--badge-info-bg: rgba(59, 130, 246, .15);--badge-info-text: #60a5fa;--badge-info-border: rgba(59, 130, 246, .3);--span-llm-bg: rgba(139, 92, 246, .15);--span-llm-text: #c4b5fd;--span-tool-bg: rgba(59, 130, 246, .15);--span-tool-text: #93c5fd;--span-agent-bg: rgba(34, 197, 94, .15);--span-agent-text: #86efac;--span-other-bg: rgba(249, 115, 22, .15);--span-other-text: #fdba74;--span-pass-bg: rgba(34, 197, 94, .15);--span-pass-text: #86efac;--span-fail-bg: rgba(239, 68, 68, .15);--span-fail-text: #fca5a5}*{box-sizing:border-box}body{margin:0;background-color:var(--bg-primary);color:var(--text-primary);font-family:Segoe UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-size:14px;line-height:1.6}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:var(--bg-secondary)}::-webkit-scrollbar-thumb{background:var(--border);border-radius:4px}::-webkit-scrollbar-thumb:hover{background:silver}[data-theme=dark] ::-webkit-scrollbar-thumb:hover{background:#404040}.last\:border-0:last-child{border-width:0px}.last\:border-b-0:last-child{border-bottom-width:0px}.hover\:border-\[var\(--accent\)\]:hover{border-color:var(--accent)}.hover\:border-\[var\(--accent-dim\)\]:hover{border-color:var(--accent-dim)}.hover\:bg-\[var\(--accent-hover\)\]:hover{background-color:var(--accent-hover)}.hover\:bg-\[var\(--bg-primary\)\]:hover{background-color:var(--bg-primary)}.hover\:bg-\[var\(--bg-tertiary\)\]:hover{background-color:var(--bg-tertiary)}.hover\:bg-\[var\(--border\)\]:hover{background-color:var(--border)}.hover\:bg-red-600:hover{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.hover\:text-\[var\(--accent\)\]:hover{color:var(--accent)}.hover\:text-\[var\(--error\)\]:hover{color:var(--error)}.hover\:text-\[var\(--text-primary\)\]:hover{color:var(--text-primary)}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-80:hover{opacity:.8}.focus\:border-\[var\(--accent\)\]:focus{border-color:var(--accent)}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-\[var\(--accent\)\]:focus{--tw-ring-color: var(--accent)}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}@media (min-width: 768px){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (min-width: 1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}} diff --git a/src/flow/ui/ui/assets/index-BDb_-aLA.css b/src/flow/ui/ui/assets/index-BDb_-aLA.css new file mode 100644 index 0000000000000000000000000000000000000000..312ba2cc4cd9a46b9691f8823b5d90d637b51600 --- /dev/null +++ b/src/flow/ui/ui/assets/index-BDb_-aLA.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:Segoe UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:JetBrains Mono,ui-monospace,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.bottom-0{bottom:0}.bottom-1{bottom:.25rem}.left-0{left:0}.left-3{left:.75rem}.top-0{top:0}.top-1{top:.25rem}.top-1\/2{top:50%}.z-10{z-index:10}.z-50{z-index:50}.mx-0\.5{margin-left:.125rem;margin-right:.125rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.-mb-px{margin-bottom:-1px}.-mt-2{margin-top:-.5rem}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.ml-6{margin-left:1.5rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-12{height:3rem}.h-2{height:.5rem}.h-3{height:.75rem}.h-32{height:8rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:8rem}.max-h-40{max-height:10rem}.max-h-48{max-height:12rem}.max-h-80{max-height:20rem}.max-h-96{max-height:24rem}.max-h-\[120px\]{max-height:120px}.max-h-\[80vh\]{max-height:80vh}.min-h-0{min-height:0px}.min-h-\[100px\]{min-height:100px}.min-h-\[200px\]{min-height:200px}.min-h-\[40px\]{min-height:40px}.min-h-screen{min-height:100vh}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-2{width:.5rem}.w-20{width:5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-32{width:8rem}.w-4{width:1rem}.w-40{width:10rem}.w-5{width:1.25rem}.w-56{width:14rem}.w-6{width:1.5rem}.w-7{width:1.75rem}.w-8{width:2rem}.w-\[350px\]{width:350px}.w-\[3px\]{width:3px}.w-\[420px\]{width:420px}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-\[90px\]{min-width:90px}.max-w-2xl{max-width:42rem}.max-w-4xl{max-width:56rem}.max-w-\[80\%\]{max-width:80%}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-90{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.resize-y{resize:vertical}.resize{resize:both}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-\[var\(--accent\)\]{border-color:var(--accent)}.border-\[var\(--badge-error-border\)\]{border-color:var(--badge-error-border)}.border-\[var\(--badge-info-border\)\]{border-color:var(--badge-info-border)}.border-\[var\(--badge-success-border\)\]{border-color:var(--badge-success-border)}.border-\[var\(--badge-warning-border\)\]{border-color:var(--badge-warning-border)}.border-\[var\(--border\)\]{border-color:var(--border)}.border-blue-500\/30{border-color:#3b82f64d}.border-green-500\/30{border-color:#22c55e4d}.border-green-500\/50{border-color:#22c55e80}.border-red-500\/30{border-color:#ef44444d}.border-red-500\/50{border-color:#ef444480}.border-transparent{border-color:transparent}.bg-\[var\(--accent\)\]{background-color:var(--accent)}.bg-\[var\(--accent-dim\)\]{background-color:var(--accent-dim)}.bg-\[var\(--badge-error-bg\)\]{background-color:var(--badge-error-bg)}.bg-\[var\(--badge-info-bg\)\]{background-color:var(--badge-info-bg)}.bg-\[var\(--badge-success-bg\)\]{background-color:var(--badge-success-bg)}.bg-\[var\(--badge-warning-bg\)\]{background-color:var(--badge-warning-bg)}.bg-\[var\(--bg-primary\)\]{background-color:var(--bg-primary)}.bg-\[var\(--bg-secondary\)\]{background-color:var(--bg-secondary)}.bg-\[var\(--bg-tertiary\)\]{background-color:var(--bg-tertiary)}.bg-\[var\(--border\)\]{background-color:var(--border)}.bg-\[var\(--error\)\]{background-color:var(--error)}.bg-\[var\(--span-agent-bg\)\]{background-color:var(--span-agent-bg)}.bg-\[var\(--span-fail-bg\)\]{background-color:var(--span-fail-bg)}.bg-\[var\(--span-llm-bg\)\]{background-color:var(--span-llm-bg)}.bg-\[var\(--span-other-bg\)\]{background-color:var(--span-other-bg)}.bg-\[var\(--span-pass-bg\)\]{background-color:var(--span-pass-bg)}.bg-\[var\(--span-tool-bg\)\]{background-color:var(--span-tool-bg)}.bg-black\/50{background-color:#00000080}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(96 165 250 / var(--tw-bg-opacity, 1))}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-500\/10{background-color:#3b82f61a}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(16 185 129 / var(--tw-bg-opacity, 1))}.bg-green-400{--tw-bg-opacity: 1;background-color:rgb(74 222 128 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-green-500\/10{background-color:#22c55e1a}.bg-green-500\/20{background-color:#22c55e33}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-500\/10{background-color:#ef44441a}.bg-red-500\/5{background-color:#ef44440d}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-2{padding-bottom:.5rem}.pb-3{padding-bottom:.75rem}.pl-10{padding-left:2.5rem}.pl-9{padding-left:2.25rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:JetBrains Mono,ui-monospace,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.text-\[var\(--accent\)\]{color:var(--accent)}.text-\[var\(--badge-error-text\)\]{color:var(--badge-error-text)}.text-\[var\(--badge-info-text\)\]{color:var(--badge-info-text)}.text-\[var\(--badge-success-text\)\]{color:var(--badge-success-text)}.text-\[var\(--badge-warning-text\)\]{color:var(--badge-warning-text)}.text-\[var\(--error\)\]{color:var(--error)}.text-\[var\(--span-agent-text\)\]{color:var(--span-agent-text)}.text-\[var\(--span-fail-text\)\]{color:var(--span-fail-text)}.text-\[var\(--span-llm-text\)\]{color:var(--span-llm-text)}.text-\[var\(--span-other-text\)\]{color:var(--span-other-text)}.text-\[var\(--span-pass-text\)\]{color:var(--span-pass-text)}.text-\[var\(--span-tool-text\)\]{color:var(--span-tool-text)}.text-\[var\(--success\)\]{color:var(--success)}.text-\[var\(--text-primary\)\]{color:var(--text-primary)}.text-\[var\(--text-secondary\)\]{color:var(--text-secondary)}.text-\[var\(--text-tertiary\)\]{color:var(--text-tertiary)}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.text-blue-400{--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.text-emerald-400{--tw-text-opacity: 1;color:rgb(52 211 153 / var(--tw-text-opacity, 1))}.text-green-400{--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-purple-400{--tw-text-opacity: 1;color:rgb(192 132 252 / var(--tw-text-opacity, 1))}.text-red-300{--tw-text-opacity: 1;color:rgb(252 165 165 / var(--tw-text-opacity, 1))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}:root{--bg-primary: #ffffff;--bg-secondary: #fafafa;--bg-tertiary: #f3f4f6;--text-primary: #1b1b1b;--text-secondary: #616161;--accent: #7c3aed;--accent-hover: #6d28d9;--accent-dim: #ede9fe;--border: #e5e7eb;--error: #dc2626;--success: #16a34a;--badge-success-bg: #f0fdf4;--badge-success-text: #15803d;--badge-success-border: #bbf7d0;--badge-warning-bg: #fefce8;--badge-warning-text: #a16207;--badge-warning-border: #fef08a;--badge-error-bg: #fef2f2;--badge-error-text: #b91c1c;--badge-error-border: #fecaca;--badge-info-bg: #eff6ff;--badge-info-text: #1d4ed8;--badge-info-border: #bfdbfe;--span-llm-bg: #f5f3ff;--span-llm-text: #6b21a8;--span-tool-bg: #eff6ff;--span-tool-text: #1e40af;--span-agent-bg: #f0fdf4;--span-agent-text: #166534;--span-other-bg: #fff7ed;--span-other-text: #9a3412;--span-pass-bg: #f0fdf4;--span-pass-text: #166534;--span-fail-bg: #fef2f2;--span-fail-text: #991b1b}[data-theme=dark]{--bg-primary: #1a1a2e;--bg-secondary: #16162a;--bg-tertiary: #252540;--text-primary: #f0f0f5;--text-secondary: #a0a0b5;--accent: #a78bfa;--accent-hover: #8b5cf6;--accent-dim: #2d2055;--border: #2d2d45;--error: #ef4444;--success: #22c55e;--badge-success-bg: rgba(34, 197, 94, .15);--badge-success-text: #4ade80;--badge-success-border: rgba(34, 197, 94, .3);--badge-warning-bg: rgba(234, 179, 8, .15);--badge-warning-text: #fbbf24;--badge-warning-border: rgba(234, 179, 8, .3);--badge-error-bg: rgba(239, 68, 68, .15);--badge-error-text: #f87171;--badge-error-border: rgba(239, 68, 68, .3);--badge-info-bg: rgba(59, 130, 246, .15);--badge-info-text: #60a5fa;--badge-info-border: rgba(59, 130, 246, .3);--span-llm-bg: rgba(139, 92, 246, .15);--span-llm-text: #c4b5fd;--span-tool-bg: rgba(59, 130, 246, .15);--span-tool-text: #93c5fd;--span-agent-bg: rgba(34, 197, 94, .15);--span-agent-text: #86efac;--span-other-bg: rgba(249, 115, 22, .15);--span-other-text: #fdba74;--span-pass-bg: rgba(34, 197, 94, .15);--span-pass-text: #86efac;--span-fail-bg: rgba(239, 68, 68, .15);--span-fail-text: #fca5a5}*{box-sizing:border-box}body{margin:0;background-color:var(--bg-primary);color:var(--text-primary);font-family:Segoe UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-size:14px;line-height:1.6}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:var(--bg-secondary)}::-webkit-scrollbar-thumb{background:var(--border);border-radius:4px}::-webkit-scrollbar-thumb:hover{background:silver}[data-theme=dark] ::-webkit-scrollbar-thumb:hover{background:#404040}.last\:border-0:last-child{border-width:0px}.last\:border-b-0:last-child{border-bottom-width:0px}.hover\:border-\[var\(--accent\)\]:hover{border-color:var(--accent)}.hover\:border-\[var\(--accent-dim\)\]:hover{border-color:var(--accent-dim)}.hover\:bg-\[var\(--accent-hover\)\]:hover{background-color:var(--accent-hover)}.hover\:bg-\[var\(--bg-primary\)\]:hover{background-color:var(--bg-primary)}.hover\:bg-\[var\(--bg-tertiary\)\]:hover{background-color:var(--bg-tertiary)}.hover\:bg-\[var\(--border\)\]:hover{background-color:var(--border)}.hover\:bg-red-600:hover{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.hover\:text-\[var\(--accent\)\]:hover{color:var(--accent)}.hover\:text-\[var\(--error\)\]:hover{color:var(--error)}.hover\:text-\[var\(--text-primary\)\]:hover{color:var(--text-primary)}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-80:hover{opacity:.8}.focus\:border-\[var\(--accent\)\]:focus{border-color:var(--accent)}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-\[var\(--accent\)\]:focus{--tw-ring-color: var(--accent)}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}@media (min-width: 768px){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (min-width: 1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}} diff --git a/src/flow/ui/ui/assets/index-BeoQ6jQc.js b/src/flow/ui/ui/assets/index-BeoQ6jQc.js new file mode 100644 index 0000000000000000000000000000000000000000..2ec2017c098dd25d32e3a4b468c846e093ae11bb --- /dev/null +++ b/src/flow/ui/ui/assets/index-BeoQ6jQc.js @@ -0,0 +1,347 @@ +var nu=e=>{throw TypeError(e)};var Hi=(e,t,n)=>t.has(e)||nu("Cannot "+n);var y=(e,t,n)=>(Hi(e,t,"read from private field"),n?n.call(e):t.get(e)),$=(e,t,n)=>t.has(e)?nu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),z=(e,t,n,r)=>(Hi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),H=(e,t,n)=>(Hi(e,t,"access private method"),n);var pa=(e,t,n,r)=>({set _(s){z(e,t,s,n)},get _(){return y(e,t,r)}});function lp(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();function Yd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xd={exports:{}},Ni={},Zd={exports:{}},Y={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var ia=Symbol.for("react.element"),op=Symbol.for("react.portal"),cp=Symbol.for("react.fragment"),up=Symbol.for("react.strict_mode"),dp=Symbol.for("react.profiler"),fp=Symbol.for("react.provider"),hp=Symbol.for("react.context"),mp=Symbol.for("react.forward_ref"),pp=Symbol.for("react.suspense"),xp=Symbol.for("react.memo"),vp=Symbol.for("react.lazy"),ru=Symbol.iterator;function yp(e){return e===null||typeof e!="object"?null:(e=ru&&e[ru]||e["@@iterator"],typeof e=="function"?e:null)}var ef={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},tf=Object.assign,nf={};function Yr(e,t,n){this.props=e,this.context=t,this.refs=nf,this.updater=n||ef}Yr.prototype.isReactComponent={};Yr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Yr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function rf(){}rf.prototype=Yr.prototype;function Vo(e,t,n){this.props=e,this.context=t,this.refs=nf,this.updater=n||ef}var Ko=Vo.prototype=new rf;Ko.constructor=Vo;tf(Ko,Yr.prototype);Ko.isPureReactComponent=!0;var su=Array.isArray,sf=Object.prototype.hasOwnProperty,Ho={current:null},af={key:!0,ref:!0,__self:!0,__source:!0};function lf(e,t,n){var r,s={},i=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(i=""+t.key),t)sf.call(t,r)&&!af.hasOwnProperty(r)&&(s[r]=t[r]);var o=arguments.length-2;if(o===1)s.children=n;else if(1>>1,ee=P[V];if(0>>1;Vs(te,L))pes(Se,te)?(P[V]=Se,P[pe]=L,V=pe):(P[V]=te,P[T]=L,V=T);else if(pes(Se,L))P[V]=Se,P[pe]=L,V=pe;else break e}}return A}function s(P,A){var L=P.sortIndex-A.sortIndex;return L!==0?L:P.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var c=[],u=[],d=1,f=null,m=3,v=!1,k=!1,g=!1,b=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,h=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(P){for(var A=n(u);A!==null;){if(A.callback===null)r(u);else if(A.startTime<=P)r(u),A.sortIndex=A.expirationTime,t(c,A);else break;A=n(u)}}function w(P){if(g=!1,x(P),!k)if(n(c)!==null)k=!0,W(C);else{var A=n(u);A!==null&&X(w,A.startTime-P)}}function C(P,A){k=!1,g&&(g=!1,p(_),_=-1),v=!0;var L=m;try{for(x(A),f=n(c);f!==null&&(!(f.expirationTime>A)||P&&!B());){var V=f.callback;if(typeof V=="function"){f.callback=null,m=f.priorityLevel;var ee=V(f.expirationTime<=A);A=e.unstable_now(),typeof ee=="function"?f.callback=ee:f===n(c)&&r(c),x(A)}else r(c);f=n(c)}if(f!==null)var R=!0;else{var T=n(u);T!==null&&X(w,T.startTime-A),R=!1}return R}finally{f=null,m=L,v=!1}}var S=!1,N=null,_=-1,F=5,O=-1;function B(){return!(e.unstable_now()-OP||125V?(P.sortIndex=L,t(u,P),n(c)===null&&P===n(u)&&(g?(p(_),_=-1):g=!0,X(w,L-V))):(P.sortIndex=ee,t(c,P),k||v||(k=!0,W(C))),P},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(P){var A=m;return function(){var L=m;m=A;try{return P.apply(this,arguments)}finally{m=L}}}})(ff);df.exports=ff;var Tp=df.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Op=j,et=Tp;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_l=Object.prototype.hasOwnProperty,Lp=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,iu={},lu={};function Rp(e){return _l.call(lu,e)?!0:_l.call(iu,e)?!1:Lp.test(e)?lu[e]=!0:(iu[e]=!0,!1)}function Mp(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function zp(e,t,n,r){if(t===null||typeof t>"u"||Mp(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Be(e,t,n,r,s,i,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=l}var Oe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Oe[e]=new Be(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Oe[t]=new Be(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Oe[e]=new Be(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Oe[e]=new Be(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Oe[e]=new Be(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Oe[e]=new Be(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Oe[e]=new Be(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Oe[e]=new Be(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Oe[e]=new Be(e,5,!1,e.toLowerCase(),null,!1,!1)});var Go=/[\-:]([a-z])/g;function Jo(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Go,Jo);Oe[t]=new Be(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Go,Jo);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Go,Jo);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!1,!1)});Oe.xlinkHref=new Be("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!0,!0)});function Yo(e,t,n,r){var s=Oe.hasOwnProperty(t)?Oe[t]:null;(s!==null?s.type!==0:r||!(2o||s[l]!==i[o]){var c=` +`+s[l].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{Gi=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?vs(e):""}function Fp(e){switch(e.tag){case 5:return vs(e.type);case 16:return vs("Lazy");case 13:return vs("Suspense");case 19:return vs("SuspenseList");case 0:case 2:case 15:return e=Ji(e.type,!1),e;case 11:return e=Ji(e.type.render,!1),e;case 1:return e=Ji(e.type,!0),e;default:return""}}function Ol(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case fr:return"Fragment";case dr:return"Portal";case El:return"Profiler";case Xo:return"StrictMode";case Pl:return"Suspense";case Tl:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case pf:return(e.displayName||"Context")+".Consumer";case mf:return(e._context.displayName||"Context")+".Provider";case Zo:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ec:return t=e.displayName||null,t!==null?t:Ol(e.type)||"Memo";case Xt:t=e._payload,e=e._init;try{return Ol(e(t))}catch{}}return null}function Ip(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ol(t);case 8:return t===Xo?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function En(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function vf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Dp(e){var t=vf(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(l){r=""+l,i.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ya(e){e._valueTracker||(e._valueTracker=Dp(e))}function yf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=vf(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ga(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ll(e,t){var n=t.checked;return me({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function cu(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=En(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function gf(e,t){t=t.checked,t!=null&&Yo(e,"checked",t,!1)}function Rl(e,t){gf(e,t);var n=En(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ml(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ml(e,t.type,En(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function uu(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ml(e,t,n){(t!=="number"||Ga(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var ys=Array.isArray;function br(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=ga.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Rs(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ks={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Ap=["Webkit","ms","Moz","O"];Object.keys(ks).forEach(function(e){Ap.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ks[t]=ks[e]})});function bf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||ks.hasOwnProperty(e)&&ks[e]?(""+t).trim():t+"px"}function Nf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=bf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var $p=me({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Il(e,t){if(t){if($p[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function Dl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Al=null;function tc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var $l=null,Nr=null,Sr=null;function hu(e){if(e=ca(e)){if(typeof $l!="function")throw Error(E(280));var t=e.stateNode;t&&(t=Pi(t),$l(e.stateNode,e.type,t))}}function Sf(e){Nr?Sr?Sr.push(e):Sr=[e]:Nr=e}function Cf(){if(Nr){var e=Nr,t=Sr;if(Sr=Nr=null,hu(e),t)for(e=0;e>>=0,e===0?32:31-(Yp(e)/Xp|0)|0}var ja=64,wa=4194304;function gs(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Za(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~s;o!==0?r=gs(o):(i&=l,i!==0&&(r=gs(i)))}else l=n&~s,l!==0?r=gs(l):i!==0&&(r=gs(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function la(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-jt(t),e[t]=n}function nx(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Ns),ku=" ",bu=!1;function Hf(e,t){switch(e){case"keyup":return Tx.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function qf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var hr=!1;function Lx(e,t){switch(e){case"compositionend":return qf(t);case"keypress":return t.which!==32?null:(bu=!0,ku);case"textInput":return e=t.data,e===ku&&bu?null:e;default:return null}}function Rx(e,t){if(hr)return e==="compositionend"||!cc&&Hf(e,t)?(e=Vf(),Aa=ic=fn=null,hr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=_u(n)}}function Yf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Yf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Xf(){for(var e=window,t=Ga();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ga(e.document)}return t}function uc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Bx(e){var t=Xf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Yf(n.ownerDocument.documentElement,n)){if(r!==null&&uc(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=Eu(n,i);var l=Eu(n,r);s&&l&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,mr=null,Hl=null,Cs=null,ql=!1;function Pu(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ql||mr==null||mr!==Ga(r)||(r=mr,"selectionStart"in r&&uc(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Cs&&As(Cs,r)||(Cs=r,r=ni(Hl,"onSelect"),0vr||(e.current=Zl[vr],Zl[vr]=null,vr--)}function ie(e,t){vr++,Zl[vr]=e.current,e.current=t}var Pn={},Fe=Ln(Pn),qe=Ln(!1),Zn=Pn;function Br(e,t){var n=e.type.contextTypes;if(!n)return Pn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function We(e){return e=e.childContextTypes,e!=null}function si(){ue(qe),ue(Fe)}function Fu(e,t,n){if(Fe.current!==Pn)throw Error(E(168));ie(Fe,t),ie(qe,n)}function lh(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(E(108,Ip(e)||"Unknown",s));return me({},n,r)}function ai(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Pn,Zn=Fe.current,ie(Fe,e),ie(qe,qe.current),!0}function Iu(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=lh(e,t,Zn),r.__reactInternalMemoizedMergedChildContext=e,ue(qe),ue(Fe),ie(Fe,e)):ue(qe),ie(qe,n)}var Mt=null,Ti=!1,ul=!1;function oh(e){Mt===null?Mt=[e]:Mt.push(e)}function ev(e){Ti=!0,oh(e)}function Rn(){if(!ul&&Mt!==null){ul=!0;var e=0,t=ae;try{var n=Mt;for(ae=1;e>=l,s-=l,At=1<<32-jt(t)+s|n<_?(F=N,N=null):F=N.sibling;var O=m(p,N,x[_],w);if(O===null){N===null&&(N=F);break}e&&N&&O.alternate===null&&t(p,N),h=i(O,h,_),S===null?C=O:S.sibling=O,S=O,N=F}if(_===x.length)return n(p,N),de&&Fn(p,_),C;if(N===null){for(;__?(F=N,N=null):F=N.sibling;var B=m(p,N,O.value,w);if(B===null){N===null&&(N=F);break}e&&N&&B.alternate===null&&t(p,N),h=i(B,h,_),S===null?C=B:S.sibling=B,S=B,N=F}if(O.done)return n(p,N),de&&Fn(p,_),C;if(N===null){for(;!O.done;_++,O=x.next())O=f(p,O.value,w),O!==null&&(h=i(O,h,_),S===null?C=O:S.sibling=O,S=O);return de&&Fn(p,_),C}for(N=r(p,N);!O.done;_++,O=x.next())O=v(N,p,_,O.value,w),O!==null&&(e&&O.alternate!==null&&N.delete(O.key===null?_:O.key),h=i(O,h,_),S===null?C=O:S.sibling=O,S=O);return e&&N.forEach(function(G){return t(p,G)}),de&&Fn(p,_),C}function b(p,h,x,w){if(typeof x=="object"&&x!==null&&x.type===fr&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case va:e:{for(var C=x.key,S=h;S!==null;){if(S.key===C){if(C=x.type,C===fr){if(S.tag===7){n(p,S.sibling),h=s(S,x.props.children),h.return=p,p=h;break e}}else if(S.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Xt&&$u(C)===S.type){n(p,S.sibling),h=s(S,x.props),h.ref=fs(p,S,x),h.return=p,p=h;break e}n(p,S);break}else t(p,S);S=S.sibling}x.type===fr?(h=Xn(x.props.children,p.mode,w,x.key),h.return=p,p=h):(w=qa(x.type,x.key,x.props,null,p.mode,w),w.ref=fs(p,h,x),w.return=p,p=w)}return l(p);case dr:e:{for(S=x.key;h!==null;){if(h.key===S)if(h.tag===4&&h.stateNode.containerInfo===x.containerInfo&&h.stateNode.implementation===x.implementation){n(p,h.sibling),h=s(h,x.children||[]),h.return=p,p=h;break e}else{n(p,h);break}else t(p,h);h=h.sibling}h=yl(x,p.mode,w),h.return=p,p=h}return l(p);case Xt:return S=x._init,b(p,h,S(x._payload),w)}if(ys(x))return k(p,h,x,w);if(ls(x))return g(p,h,x,w);Ea(p,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,h!==null&&h.tag===6?(n(p,h.sibling),h=s(h,x),h.return=p,p=h):(n(p,h),h=vl(x,p.mode,w),h.return=p,p=h),l(p)):n(p,h)}return b}var Vr=fh(!0),hh=fh(!1),oi=Ln(null),ci=null,jr=null,mc=null;function pc(){mc=jr=ci=null}function xc(e){var t=oi.current;ue(oi),e._currentValue=t}function no(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function _r(e,t){ci=e,mc=jr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(He=!0),e.firstContext=null)}function ct(e){var t=e._currentValue;if(mc!==e)if(e={context:e,memoizedValue:t,next:null},jr===null){if(ci===null)throw Error(E(308));jr=e,ci.dependencies={lanes:0,firstContext:e}}else jr=jr.next=e;return t}var An=null;function vc(e){An===null?An=[e]:An.push(e)}function mh(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,vc(t)):(n.next=s.next,s.next=n),t.interleaved=n,Kt(e,r)}function Kt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Zt=!1;function yc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ph(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ut(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function wn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ne&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Kt(e,n)}return s=r.interleaved,s===null?(t.next=t,vc(r)):(t.next=s.next,s.next=t),r.interleaved=t,Kt(e,n)}function Ua(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,rc(e,n)}}function Uu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=l:i=i.next=l,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ui(e,t,n,r){var s=e.updateQueue;Zt=!1;var i=s.firstBaseUpdate,l=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var c=o,u=c.next;c.next=null,l===null?i=u:l.next=u,l=c;var d=e.alternate;d!==null&&(d=d.updateQueue,o=d.lastBaseUpdate,o!==l&&(o===null?d.firstBaseUpdate=u:o.next=u,d.lastBaseUpdate=c))}if(i!==null){var f=s.baseState;l=0,d=u=c=null,o=i;do{var m=o.lane,v=o.eventTime;if((r&m)===m){d!==null&&(d=d.next={eventTime:v,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var k=e,g=o;switch(m=t,v=n,g.tag){case 1:if(k=g.payload,typeof k=="function"){f=k.call(v,f,m);break e}f=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=g.payload,m=typeof k=="function"?k.call(v,f,m):k,m==null)break e;f=me({},f,m);break e;case 2:Zt=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,m=s.effects,m===null?s.effects=[o]:m.push(o))}else v={eventTime:v,lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},d===null?(u=d=v,c=f):d=d.next=v,l|=m;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;m=o,o=m.next,m.next=null,s.lastBaseUpdate=m,s.shared.pending=null}}while(!0);if(d===null&&(c=f),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=d,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);nr|=l,e.lanes=l,e.memoizedState=f}}function Bu(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=fl.transition;fl.transition={};try{e(!1),t()}finally{ae=n,fl.transition=r}}function Lh(){return ut().memoizedState}function sv(e,t,n){var r=bn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Rh(e))Mh(t,n);else if(n=mh(e,t,n,r),n!==null){var s=$e();wt(n,e,r,s),zh(n,t,r)}}function av(e,t,n){var r=bn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Rh(e))Mh(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var l=t.lastRenderedState,o=i(l,n);if(s.hasEagerState=!0,s.eagerState=o,kt(o,l)){var c=t.interleaved;c===null?(s.next=s,vc(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=mh(e,t,s,r),n!==null&&(s=$e(),wt(n,e,r,s),zh(n,t,r))}}function Rh(e){var t=e.alternate;return e===he||t!==null&&t===he}function Mh(e,t){_s=fi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function zh(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,rc(e,n)}}var hi={readContext:ct,useCallback:Le,useContext:Le,useEffect:Le,useImperativeHandle:Le,useInsertionEffect:Le,useLayoutEffect:Le,useMemo:Le,useReducer:Le,useRef:Le,useState:Le,useDebugValue:Le,useDeferredValue:Le,useTransition:Le,useMutableSource:Le,useSyncExternalStore:Le,useId:Le,unstable_isNewReconciler:!1},iv={readContext:ct,useCallback:function(e,t){return Nt().memoizedState=[e,t===void 0?null:t],e},useContext:ct,useEffect:Vu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Qa(4194308,4,_h.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Qa(4194308,4,e,t)},useInsertionEffect:function(e,t){return Qa(4,2,e,t)},useMemo:function(e,t){var n=Nt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Nt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=sv.bind(null,he,e),[r.memoizedState,e]},useRef:function(e){var t=Nt();return e={current:e},t.memoizedState=e},useState:Qu,useDebugValue:Cc,useDeferredValue:function(e){return Nt().memoizedState=e},useTransition:function(){var e=Qu(!1),t=e[0];return e=rv.bind(null,e[1]),Nt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=he,s=Nt();if(de){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),Ee===null)throw Error(E(349));tr&30||gh(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Vu(wh.bind(null,r,i,e),[e]),r.flags|=2048,qs(9,jh.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Nt(),t=Ee.identifierPrefix;if(de){var n=$t,r=At;n=(r&~(1<<32-jt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Ks++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[Et]=t,e[Bs]=r,Kh(e,t,!1,!1),t.stateNode=e;e:{switch(l=Dl(n,r),n){case"dialog":ce("cancel",e),ce("close",e),s=r;break;case"iframe":case"object":case"embed":ce("load",e),s=r;break;case"video":case"audio":for(s=0;sqr&&(t.flags|=128,r=!0,hs(i,!1),t.lanes=4194304)}else{if(!r)if(e=di(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),hs(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!de)return Re(t),null}else 2*je()-i.renderingStartTime>qr&&n!==1073741824&&(t.flags|=128,r=!0,hs(i,!1),t.lanes=4194304);i.isBackwards?(l.sibling=t.child,t.child=l):(n=i.last,n!==null?n.sibling=l:t.child=l,i.last=l)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=je(),t.sibling=null,n=fe.current,ie(fe,r?n&1|2:n&1),t):(Re(t),null);case 22:case 23:return Lc(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ye&1073741824&&(Re(t),t.subtreeFlags&6&&(t.flags|=8192)):Re(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function mv(e,t){switch(fc(t),t.tag){case 1:return We(t.type)&&si(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Kr(),ue(qe),ue(Fe),wc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return jc(t),null;case 13:if(ue(fe),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));Qr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ue(fe),null;case 4:return Kr(),null;case 10:return xc(t.type._context),null;case 22:case 23:return Lc(),null;case 24:return null;default:return null}}var Ta=!1,ze=!1,pv=typeof WeakSet=="function"?WeakSet:Set,I=null;function wr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ve(e,t,r)}else n.current=null}function fo(e,t,n){try{n()}catch(r){ve(e,t,r)}}var td=!1;function xv(e,t){if(Wl=ei,e=Xf(),uc(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var l=0,o=-1,c=-1,u=0,d=0,f=e,m=null;t:for(;;){for(var v;f!==n||s!==0&&f.nodeType!==3||(o=l+s),f!==i||r!==0&&f.nodeType!==3||(c=l+r),f.nodeType===3&&(l+=f.nodeValue.length),(v=f.firstChild)!==null;)m=f,f=v;for(;;){if(f===e)break t;if(m===n&&++u===s&&(o=l),m===i&&++d===r&&(c=l),(v=f.nextSibling)!==null)break;f=m,m=f.parentNode}f=v}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Gl={focusedElem:e,selectionRange:n},ei=!1,I=t;I!==null;)if(t=I,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,I=e;else for(;I!==null;){t=I;try{var k=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(k!==null){var g=k.memoizedProps,b=k.memoizedState,p=t.stateNode,h=p.getSnapshotBeforeUpdate(t.elementType===t.type?g:mt(t.type,g),b);p.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(w){ve(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,I=e;break}I=t.return}return k=td,td=!1,k}function Es(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&fo(t,n,i)}s=s.next}while(s!==r)}}function Ri(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ho(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Wh(e){var t=e.alternate;t!==null&&(e.alternate=null,Wh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Et],delete t[Bs],delete t[Xl],delete t[Xx],delete t[Zx])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Gh(e){return e.tag===5||e.tag===3||e.tag===4}function nd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Gh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function mo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ri));else if(r!==4&&(e=e.child,e!==null))for(mo(e,t,n),e=e.sibling;e!==null;)mo(e,t,n),e=e.sibling}function po(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(po(e,t,n),e=e.sibling;e!==null;)po(e,t,n),e=e.sibling}var Pe=null,vt=!1;function Jt(e,t,n){for(n=n.child;n!==null;)Jh(e,t,n),n=n.sibling}function Jh(e,t,n){if(Pt&&typeof Pt.onCommitFiberUnmount=="function")try{Pt.onCommitFiberUnmount(Si,n)}catch{}switch(n.tag){case 5:ze||wr(n,t);case 6:var r=Pe,s=vt;Pe=null,Jt(e,t,n),Pe=r,vt=s,Pe!==null&&(vt?(e=Pe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Pe.removeChild(n.stateNode));break;case 18:Pe!==null&&(vt?(e=Pe,n=n.stateNode,e.nodeType===8?cl(e.parentNode,n):e.nodeType===1&&cl(e,n),Is(e)):cl(Pe,n.stateNode));break;case 4:r=Pe,s=vt,Pe=n.stateNode.containerInfo,vt=!0,Jt(e,t,n),Pe=r,vt=s;break;case 0:case 11:case 14:case 15:if(!ze&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,l=i.destroy;i=i.tag,l!==void 0&&(i&2||i&4)&&fo(n,t,l),s=s.next}while(s!==r)}Jt(e,t,n);break;case 1:if(!ze&&(wr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){ve(n,t,o)}Jt(e,t,n);break;case 21:Jt(e,t,n);break;case 22:n.mode&1?(ze=(r=ze)||n.memoizedState!==null,Jt(e,t,n),ze=r):Jt(e,t,n);break;default:Jt(e,t,n)}}function rd(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new pv),t.forEach(function(r){var s=Sv.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function ft(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=l),r&=~i}if(r=s,r=je()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*yv(r/1960))-r,10e?16:e,hn===null)var r=!1;else{if(e=hn,hn=null,xi=0,ne&6)throw Error(E(331));var s=ne;for(ne|=4,I=e.current;I!==null;){var i=I,l=i.child;if(I.flags&16){var o=i.deletions;if(o!==null){for(var c=0;cje()-Tc?Yn(e,0):Pc|=n),Ge(e,t)}function sm(e,t){t===0&&(e.mode&1?(t=wa,wa<<=1,!(wa&130023424)&&(wa=4194304)):t=1);var n=$e();e=Kt(e,t),e!==null&&(la(e,t,n),Ge(e,n))}function Nv(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),sm(e,n)}function Sv(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),sm(e,n)}var am;am=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||qe.current)He=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return He=!1,fv(e,t,n);He=!!(e.flags&131072)}else He=!1,de&&t.flags&1048576&&ch(t,li,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Va(e,t),e=t.pendingProps;var s=Br(t,Fe.current);_r(t,n),s=bc(null,t,r,e,s,n);var i=Nc();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,We(r)?(i=!0,ai(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,yc(t),s.updater=Li,t.stateNode=s,s._reactInternals=t,so(t,r,e,n),t=lo(null,t,r,!0,i,n)):(t.tag=0,de&&i&&dc(t),De(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Va(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=_v(r),e=mt(r,e),s){case 0:t=io(null,t,r,e,n);break e;case 1:t=Xu(null,t,r,e,n);break e;case 11:t=Ju(null,t,r,e,n);break e;case 14:t=Yu(null,t,r,mt(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),io(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Xu(e,t,r,s,n);case 3:e:{if(Bh(t),e===null)throw Error(E(387));r=t.pendingProps,i=t.memoizedState,s=i.element,ph(e,t),ui(t,r,null,n);var l=t.memoizedState;if(r=l.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=Hr(Error(E(423)),t),t=Zu(e,t,r,n,s);break e}else if(r!==s){s=Hr(Error(E(424)),t),t=Zu(e,t,r,n,s);break e}else for(Xe=jn(t.stateNode.containerInfo.firstChild),Ze=t,de=!0,yt=null,n=hh(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Qr(),r===s){t=Ht(e,t,n);break e}De(e,t,r,n)}t=t.child}return t;case 5:return xh(t),e===null&&to(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,l=s.children,Jl(r,s)?l=null:i!==null&&Jl(r,i)&&(t.flags|=32),Uh(e,t),De(e,t,l,n),t.child;case 6:return e===null&&to(t),null;case 13:return Qh(e,t,n);case 4:return gc(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Vr(t,null,r,n):De(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Ju(e,t,r,s,n);case 7:return De(e,t,t.pendingProps,n),t.child;case 8:return De(e,t,t.pendingProps.children,n),t.child;case 12:return De(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,l=s.value,ie(oi,r._currentValue),r._currentValue=l,i!==null)if(kt(i.value,l)){if(i.children===s.children&&!qe.current){t=Ht(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var o=i.dependencies;if(o!==null){l=i.child;for(var c=o.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=Ut(-1,n&-n),c.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),no(i.return,n,t),o.lanes|=n;break}c=c.next}}else if(i.tag===10)l=i.type===t.type?null:i.child;else if(i.tag===18){if(l=i.return,l===null)throw Error(E(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),no(l,n,t),l=i.sibling}else l=i.child;if(l!==null)l.return=i;else for(l=i;l!==null;){if(l===t){l=null;break}if(i=l.sibling,i!==null){i.return=l.return,l=i;break}l=l.return}i=l}De(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,_r(t,n),s=ct(s),r=r(s),t.flags|=1,De(e,t,r,n),t.child;case 14:return r=t.type,s=mt(r,t.pendingProps),s=mt(r.type,s),Yu(e,t,r,s,n);case 15:return Ah(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Va(e,t),t.tag=1,We(r)?(e=!0,ai(t)):e=!1,_r(t,n),Fh(t,r,s),so(t,r,s,n),lo(null,t,r,!0,e,n);case 19:return Vh(e,t,n);case 22:return $h(e,t,n)}throw Error(E(156,t.tag))};function im(e,t){return Rf(e,t)}function Cv(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function lt(e,t,n,r){return new Cv(e,t,n,r)}function Mc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function _v(e){if(typeof e=="function")return Mc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Zo)return 11;if(e===ec)return 14}return 2}function Nn(e,t){var n=e.alternate;return n===null?(n=lt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function qa(e,t,n,r,s,i){var l=2;if(r=e,typeof e=="function")Mc(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case fr:return Xn(n.children,s,i,t);case Xo:l=8,s|=8;break;case El:return e=lt(12,n,t,s|2),e.elementType=El,e.lanes=i,e;case Pl:return e=lt(13,n,t,s),e.elementType=Pl,e.lanes=i,e;case Tl:return e=lt(19,n,t,s),e.elementType=Tl,e.lanes=i,e;case xf:return zi(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case mf:l=10;break e;case pf:l=9;break e;case Zo:l=11;break e;case ec:l=14;break e;case Xt:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=lt(l,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function Xn(e,t,n,r){return e=lt(7,e,r,t),e.lanes=n,e}function zi(e,t,n,r){return e=lt(22,e,r,t),e.elementType=xf,e.lanes=n,e.stateNode={isHidden:!1},e}function vl(e,t,n){return e=lt(6,e,null,t),e.lanes=n,e}function yl(e,t,n){return t=lt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Ev(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Xi(0),this.expirationTimes=Xi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Xi(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function zc(e,t,n,r,s,i,l,o,c){return e=new Ev(e,t,n,o,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=lt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},yc(i),e}function Pv(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(um)}catch(e){console.error(e)}}um(),uf.exports=tt;var Mv=uf.exports,dd=Mv;Cl.createRoot=dd.createRoot,Cl.hydrateRoot=dd.hydrateRoot;var es=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},zv={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},nn,Qo,$d,Fv=($d=class{constructor(){$(this,nn,zv);$(this,Qo,!1)}setTimeoutProvider(e){z(this,nn,e)}setTimeout(e,t){return y(this,nn).setTimeout(e,t)}clearTimeout(e){y(this,nn).clearTimeout(e)}setInterval(e,t){return y(this,nn).setInterval(e,t)}clearInterval(e){y(this,nn).clearInterval(e)}},nn=new WeakMap,Qo=new WeakMap,$d),Un=new Fv;function Iv(e){setTimeout(e,0)}var sr=typeof window>"u"||"Deno"in globalThis;function Ae(){}function Dv(e,t){return typeof e=="function"?e(t):e}function jo(e){return typeof e=="number"&&e>=0&&e!==1/0}function dm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Sn(e,t){return typeof e=="function"?e(t):e}function st(e,t){return typeof e=="function"?e(t):e}function fd(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:i,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==Ac(l,t.options))return!1}else if(!Gs(t.queryKey,l))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||s&&s!==t.state.fetchStatus||i&&!i(t))}function hd(e,t){const{exact:n,status:r,predicate:s,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(ar(t.options.mutationKey)!==ar(i))return!1}else if(!Gs(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function Ac(e,t){return((t==null?void 0:t.queryKeyHashFn)||ar)(e)}function ar(e){return JSON.stringify(e,(t,n)=>wo(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function Gs(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Gs(e[n],t[n])):!1}var Av=Object.prototype.hasOwnProperty;function fm(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=md(e)&&md(t);if(!r&&!(wo(e)&&wo(t)))return t;const i=(r?e:Object.keys(e)).length,l=r?t:Object.keys(t),o=l.length,c=r?new Array(o):{};let u=0;for(let d=0;d{Un.setTimeout(t,e)})}function ko(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?fm(e,t):t}function Uv(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Bv(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var $c=Symbol();function hm(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===$c?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Uc(e,t){return typeof e=="function"?e(...t):!!e}function Qv(e,t,n){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),e}var Bn,rn,Pr,Ud,Vv=(Ud=class extends es{constructor(){super();$(this,Bn);$(this,rn);$(this,Pr);z(this,Pr,t=>{if(!sr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){y(this,rn)||this.setEventListener(y(this,Pr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,rn))==null||t.call(this),z(this,rn,void 0))}setEventListener(t){var n;z(this,Pr,t),(n=y(this,rn))==null||n.call(this),z(this,rn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){y(this,Bn)!==t&&(z(this,Bn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof y(this,Bn)=="boolean"?y(this,Bn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Bn=new WeakMap,rn=new WeakMap,Pr=new WeakMap,Ud),Bc=new Vv;function bo(){let e,t;const n=new Promise((s,i)=>{e=s,t=i});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var Kv=Iv;function Hv(){let e=[],t=0,n=o=>{o()},r=o=>{o()},s=Kv;const i=o=>{t?e.push(o):s(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&s(()=>{r(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;t++;try{c=o()}finally{t--,t||l()}return c},batchCalls:o=>(...c)=>{i(()=>{o(...c)})},schedule:i,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{s=o}}}var be=Hv(),Tr,sn,Or,Bd,qv=(Bd=class extends es{constructor(){super();$(this,Tr,!0);$(this,sn);$(this,Or);z(this,Or,t=>{if(!sr&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){y(this,sn)||this.setEventListener(y(this,Or))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,sn))==null||t.call(this),z(this,sn,void 0))}setEventListener(t){var n;z(this,Or,t),(n=y(this,sn))==null||n.call(this),z(this,sn,t(this.setOnline.bind(this)))}setOnline(t){y(this,Tr)!==t&&(z(this,Tr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return y(this,Tr)}},Tr=new WeakMap,sn=new WeakMap,Or=new WeakMap,Bd),ji=new qv;function Wv(e){return Math.min(1e3*2**e,3e4)}function mm(e){return(e??"online")==="online"?ji.isOnline():!0}var No=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function pm(e){let t=!1,n=0,r;const s=bo(),i=()=>s.status!=="pending",l=g=>{var b;if(!i()){const p=new No(g);m(p),(b=e.onCancel)==null||b.call(e,p)}},o=()=>{t=!0},c=()=>{t=!1},u=()=>Bc.isFocused()&&(e.networkMode==="always"||ji.isOnline())&&e.canRun(),d=()=>mm(e.networkMode)&&e.canRun(),f=g=>{i()||(r==null||r(),s.resolve(g))},m=g=>{i()||(r==null||r(),s.reject(g))},v=()=>new Promise(g=>{var b;r=p=>{(i()||u())&&g(p)},(b=e.onPause)==null||b.call(e)}).then(()=>{var g;r=void 0,i()||(g=e.onContinue)==null||g.call(e)}),k=()=>{if(i())return;let g;const b=n===0?e.initialPromise:void 0;try{g=b??e.fn()}catch(p){g=Promise.reject(p)}Promise.resolve(g).then(f).catch(p=>{var S;if(i())return;const h=e.retry??(sr?0:3),x=e.retryDelay??Wv,w=typeof x=="function"?x(n,p):x,C=h===!0||typeof h=="number"&&nu()?void 0:v()).then(()=>{t?m(p):k()})})};return{promise:s,status:()=>s.status,cancel:l,continue:()=>(r==null||r(),s),cancelRetry:o,continueRetry:c,canStart:d,start:()=>(d()?k():v().then(k),s)}}var Qn,Qd,xm=(Qd=class{constructor(){$(this,Qn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),jo(this.gcTime)&&z(this,Qn,Un.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(sr?1/0:5*60*1e3))}clearGcTimeout(){y(this,Qn)&&(Un.clearTimeout(y(this,Qn)),z(this,Qn,void 0))}},Qn=new WeakMap,Qd),Vn,Lr,rt,Kn,Ce,ta,Hn,pt,Lt,Vd,Gv=(Vd=class extends xm{constructor(t){super();$(this,pt);$(this,Vn);$(this,Lr);$(this,rt);$(this,Kn);$(this,Ce);$(this,ta);$(this,Hn);z(this,Hn,!1),z(this,ta,t.defaultOptions),this.setOptions(t.options),this.observers=[],z(this,Kn,t.client),z(this,rt,y(this,Kn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,z(this,Vn,vd(this.options)),this.state=t.state??y(this,Vn),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=y(this,Ce))==null?void 0:t.promise}setOptions(t){if(this.options={...y(this,ta),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=vd(this.options);n.data!==void 0&&(this.setState(xd(n.data,n.dataUpdatedAt)),z(this,Vn,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&y(this,rt).remove(this)}setData(t,n){const r=ko(this.state.data,t,this.options);return H(this,pt,Lt).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){H(this,pt,Lt).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=y(this,Ce))==null?void 0:r.promise;return(s=y(this,Ce))==null||s.cancel(t),n?n.then(Ae).catch(Ae):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(y(this,Vn))}isActive(){return this.observers.some(t=>st(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===$c||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Sn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!dm(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),y(this,rt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(y(this,Ce)&&(y(this,Hn)?y(this,Ce).cancel({revert:!0}):y(this,Ce).cancelRetry()),this.scheduleGc()),y(this,rt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||H(this,pt,Lt).call(this,{type:"invalidate"})}async fetch(t,n){var c,u,d,f,m,v,k,g,b,p,h,x;if(this.state.fetchStatus!=="idle"&&((c=y(this,Ce))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(y(this,Ce))return y(this,Ce).continueRetry(),y(this,Ce).promise}if(t&&this.setOptions(t),!this.options.queryFn){const w=this.observers.find(C=>C.options.queryFn);w&&this.setOptions(w.options)}const r=new AbortController,s=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(z(this,Hn,!0),r.signal)})},i=()=>{const w=hm(this.options,n),S=(()=>{const N={client:y(this,Kn),queryKey:this.queryKey,meta:this.meta};return s(N),N})();return z(this,Hn,!1),this.options.persister?this.options.persister(w,S,this):w(S)},o=(()=>{const w={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:y(this,Kn),state:this.state,fetchFn:i};return s(w),w})();(u=this.options.behavior)==null||u.onFetch(o,this),z(this,Lr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=o.fetchOptions)==null?void 0:d.meta))&&H(this,pt,Lt).call(this,{type:"fetch",meta:(f=o.fetchOptions)==null?void 0:f.meta}),z(this,Ce,pm({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:w=>{w instanceof No&&w.revert&&this.setState({...y(this,Lr),fetchStatus:"idle"}),r.abort()},onFail:(w,C)=>{H(this,pt,Lt).call(this,{type:"failed",failureCount:w,error:C})},onPause:()=>{H(this,pt,Lt).call(this,{type:"pause"})},onContinue:()=>{H(this,pt,Lt).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const w=await y(this,Ce).start();if(w===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(w),(v=(m=y(this,rt).config).onSuccess)==null||v.call(m,w,this),(g=(k=y(this,rt).config).onSettled)==null||g.call(k,w,this.state.error,this),w}catch(w){if(w instanceof No){if(w.silent)return y(this,Ce).promise;if(w.revert){if(this.state.data===void 0)throw w;return this.state.data}}throw H(this,pt,Lt).call(this,{type:"error",error:w}),(p=(b=y(this,rt).config).onError)==null||p.call(b,w,this),(x=(h=y(this,rt).config).onSettled)==null||x.call(h,this.state.data,w,this),w}finally{this.scheduleGc()}}},Vn=new WeakMap,Lr=new WeakMap,rt=new WeakMap,Kn=new WeakMap,Ce=new WeakMap,ta=new WeakMap,Hn=new WeakMap,pt=new WeakSet,Lt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...vm(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...xd(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return z(this,Lr,t.manual?s:void 0),s;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),be.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),y(this,rt).notify({query:this,type:"updated",action:t})})},Vd);function vm(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:mm(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function xd(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function vd(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Qe,Z,na,Ie,qn,Rr,zt,an,ra,Mr,zr,Wn,Gn,ln,Fr,se,ws,So,Co,_o,Eo,Po,To,Oo,ym,Kd,Jv=(Kd=class extends es{constructor(t,n){super();$(this,se);$(this,Qe);$(this,Z);$(this,na);$(this,Ie);$(this,qn);$(this,Rr);$(this,zt);$(this,an);$(this,ra);$(this,Mr);$(this,zr);$(this,Wn);$(this,Gn);$(this,ln);$(this,Fr,new Set);this.options=n,z(this,Qe,t),z(this,an,null),z(this,zt,bo()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(y(this,Z).addObserver(this),yd(y(this,Z),this.options)?H(this,se,ws).call(this):this.updateResult(),H(this,se,Eo).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Lo(y(this,Z),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Lo(y(this,Z),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,H(this,se,Po).call(this),H(this,se,To).call(this),y(this,Z).removeObserver(this)}setOptions(t){const n=this.options,r=y(this,Z);if(this.options=y(this,Qe).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof st(this.options.enabled,y(this,Z))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");H(this,se,Oo).call(this),y(this,Z).setOptions(this.options),n._defaulted&&!gi(this.options,n)&&y(this,Qe).getQueryCache().notify({type:"observerOptionsUpdated",query:y(this,Z),observer:this});const s=this.hasListeners();s&&gd(y(this,Z),r,this.options,n)&&H(this,se,ws).call(this),this.updateResult(),s&&(y(this,Z)!==r||st(this.options.enabled,y(this,Z))!==st(n.enabled,y(this,Z))||Sn(this.options.staleTime,y(this,Z))!==Sn(n.staleTime,y(this,Z)))&&H(this,se,So).call(this);const i=H(this,se,Co).call(this);s&&(y(this,Z)!==r||st(this.options.enabled,y(this,Z))!==st(n.enabled,y(this,Z))||i!==y(this,ln))&&H(this,se,_o).call(this,i)}getOptimisticResult(t){const n=y(this,Qe).getQueryCache().build(y(this,Qe),t),r=this.createResult(n,t);return Xv(this,r)&&(z(this,Ie,r),z(this,Rr,this.options),z(this,qn,y(this,Z).state)),r}getCurrentResult(){return y(this,Ie)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&y(this,zt).status==="pending"&&y(this,zt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){y(this,Fr).add(t)}getCurrentQuery(){return y(this,Z)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=y(this,Qe).defaultQueryOptions(t),r=y(this,Qe).getQueryCache().build(y(this,Qe),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return H(this,se,ws).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),y(this,Ie)))}createResult(t,n){var F;const r=y(this,Z),s=this.options,i=y(this,Ie),l=y(this,qn),o=y(this,Rr),u=t!==r?t.state:y(this,na),{state:d}=t;let f={...d},m=!1,v;if(n._optimisticResults){const O=this.hasListeners(),B=!O&&yd(t,n),G=O&&gd(t,r,n,s);(B||G)&&(f={...f,...vm(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:k,errorUpdatedAt:g,status:b}=f;v=f.data;let p=!1;if(n.placeholderData!==void 0&&v===void 0&&b==="pending"){let O;i!=null&&i.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(O=i.data,p=!0):O=typeof n.placeholderData=="function"?n.placeholderData((F=y(this,zr))==null?void 0:F.state.data,y(this,zr)):n.placeholderData,O!==void 0&&(b="success",v=ko(i==null?void 0:i.data,O,n),m=!0)}if(n.select&&v!==void 0&&!p)if(i&&v===(l==null?void 0:l.data)&&n.select===y(this,ra))v=y(this,Mr);else try{z(this,ra,n.select),v=n.select(v),v=ko(i==null?void 0:i.data,v,n),z(this,Mr,v),z(this,an,null)}catch(O){z(this,an,O)}y(this,an)&&(k=y(this,an),v=y(this,Mr),g=Date.now(),b="error");const h=f.fetchStatus==="fetching",x=b==="pending",w=b==="error",C=x&&h,S=v!==void 0,_={status:b,fetchStatus:f.fetchStatus,isPending:x,isSuccess:b==="success",isError:w,isInitialLoading:C,isLoading:C,data:v,dataUpdatedAt:f.dataUpdatedAt,error:k,errorUpdatedAt:g,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:h,isRefetching:h&&!x,isLoadingError:w&&!S,isPaused:f.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:w&&S,isStale:Qc(t,n),refetch:this.refetch,promise:y(this,zt),isEnabled:st(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=_.data!==void 0,B=_.status==="error"&&!O,G=D=>{B?D.reject(_.error):O&&D.resolve(_.data)},re=()=>{const D=z(this,zt,_.promise=bo());G(D)},oe=y(this,zt);switch(oe.status){case"pending":t.queryHash===r.queryHash&&G(oe);break;case"fulfilled":(B||_.data!==oe.value)&&re();break;case"rejected":(!B||_.error!==oe.reason)&&re();break}}return _}updateResult(){const t=y(this,Ie),n=this.createResult(y(this,Z),this.options);if(z(this,qn,y(this,Z).state),z(this,Rr,this.options),y(this,qn).data!==void 0&&z(this,zr,y(this,Z)),gi(n,t))return;z(this,Ie,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!y(this,Fr).size)return!0;const l=new Set(i??y(this,Fr));return this.options.throwOnError&&l.add("error"),Object.keys(y(this,Ie)).some(o=>{const c=o;return y(this,Ie)[c]!==t[c]&&l.has(c)})};H(this,se,ym).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&H(this,se,Eo).call(this)}},Qe=new WeakMap,Z=new WeakMap,na=new WeakMap,Ie=new WeakMap,qn=new WeakMap,Rr=new WeakMap,zt=new WeakMap,an=new WeakMap,ra=new WeakMap,Mr=new WeakMap,zr=new WeakMap,Wn=new WeakMap,Gn=new WeakMap,ln=new WeakMap,Fr=new WeakMap,se=new WeakSet,ws=function(t){H(this,se,Oo).call(this);let n=y(this,Z).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Ae)),n},So=function(){H(this,se,Po).call(this);const t=Sn(this.options.staleTime,y(this,Z));if(sr||y(this,Ie).isStale||!jo(t))return;const r=dm(y(this,Ie).dataUpdatedAt,t)+1;z(this,Wn,Un.setTimeout(()=>{y(this,Ie).isStale||this.updateResult()},r))},Co=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(y(this,Z)):this.options.refetchInterval)??!1},_o=function(t){H(this,se,To).call(this),z(this,ln,t),!(sr||st(this.options.enabled,y(this,Z))===!1||!jo(y(this,ln))||y(this,ln)===0)&&z(this,Gn,Un.setInterval(()=>{(this.options.refetchIntervalInBackground||Bc.isFocused())&&H(this,se,ws).call(this)},y(this,ln)))},Eo=function(){H(this,se,So).call(this),H(this,se,_o).call(this,H(this,se,Co).call(this))},Po=function(){y(this,Wn)&&(Un.clearTimeout(y(this,Wn)),z(this,Wn,void 0))},To=function(){y(this,Gn)&&(Un.clearInterval(y(this,Gn)),z(this,Gn,void 0))},Oo=function(){const t=y(this,Qe).getQueryCache().build(y(this,Qe),this.options);if(t===y(this,Z))return;const n=y(this,Z);z(this,Z,t),z(this,na,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},ym=function(t){be.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(y(this,Ie))}),y(this,Qe).getQueryCache().notify({query:y(this,Z),type:"observerResultsUpdated"})})},Kd);function Yv(e,t){return st(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function yd(e,t){return Yv(e,t)||e.state.data!==void 0&&Lo(e,t,t.refetchOnMount)}function Lo(e,t,n){if(st(t.enabled,e)!==!1&&Sn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Qc(e,t)}return!1}function gd(e,t,n,r){return(e!==t||st(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Qc(e,n)}function Qc(e,t){return st(t.enabled,e)!==!1&&e.isStaleByTime(Sn(t.staleTime,e))}function Xv(e,t){return!gi(e.getCurrentResult(),t)}function jd(e){return{onFetch:(t,n)=>{var d,f,m,v,k;const r=t.options,s=(m=(f=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:f.fetchMore)==null?void 0:m.direction,i=((v=t.state.data)==null?void 0:v.pages)||[],l=((k=t.state.data)==null?void 0:k.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const u=async()=>{let g=!1;const b=x=>{Qv(x,()=>t.signal,()=>g=!0)},p=hm(t.options,t.fetchOptions),h=async(x,w,C)=>{if(g)return Promise.reject();if(w==null&&x.pages.length)return Promise.resolve(x);const N=(()=>{const B={client:t.client,queryKey:t.queryKey,pageParam:w,direction:C?"backward":"forward",meta:t.options.meta};return b(B),B})(),_=await p(N),{maxPages:F}=t.options,O=C?Bv:Uv;return{pages:O(x.pages,_,F),pageParams:O(x.pageParams,w,F)}};if(s&&i.length){const x=s==="backward",w=x?Zv:wd,C={pages:i,pageParams:l},S=w(r,C);o=await h(C,S,x)}else{const x=e??i.length;do{const w=c===0?l[0]??r.initialPageParam:wd(r,o);if(c>0&&w==null)break;o=await h(o,w),c++}while(c{var g,b;return(b=(g=t.options).persister)==null?void 0:b.call(g,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function wd(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Zv(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var sa,St,Me,Jn,Ct,Yt,Hd,ey=(Hd=class extends xm{constructor(t){super();$(this,Ct);$(this,sa);$(this,St);$(this,Me);$(this,Jn);z(this,sa,t.client),this.mutationId=t.mutationId,z(this,Me,t.mutationCache),z(this,St,[]),this.state=t.state||gm(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){y(this,St).includes(t)||(y(this,St).push(t),this.clearGcTimeout(),y(this,Me).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){z(this,St,y(this,St).filter(n=>n!==t)),this.scheduleGc(),y(this,Me).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){y(this,St).length||(this.state.status==="pending"?this.scheduleGc():y(this,Me).remove(this))}continue(){var t;return((t=y(this,Jn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,u,d,f,m,v,k,g,b,p,h,x,w,C,S,N;const n=()=>{H(this,Ct,Yt).call(this,{type:"continue"})},r={client:y(this,sa),meta:this.options.meta,mutationKey:this.options.mutationKey};z(this,Jn,pm({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(_,F)=>{H(this,Ct,Yt).call(this,{type:"failed",failureCount:_,error:F})},onPause:()=>{H(this,Ct,Yt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>y(this,Me).canRun(this)}));const s=this.state.status==="pending",i=!y(this,Jn).canStart();try{if(s)n();else{H(this,Ct,Yt).call(this,{type:"pending",variables:t,isPaused:i}),y(this,Me).config.onMutate&&await y(this,Me).config.onMutate(t,this,r);const F=await((o=(l=this.options).onMutate)==null?void 0:o.call(l,t,r));F!==this.state.context&&H(this,Ct,Yt).call(this,{type:"pending",context:F,variables:t,isPaused:i})}const _=await y(this,Jn).start();return await((u=(c=y(this,Me).config).onSuccess)==null?void 0:u.call(c,_,t,this.state.context,this,r)),await((f=(d=this.options).onSuccess)==null?void 0:f.call(d,_,t,this.state.context,r)),await((v=(m=y(this,Me).config).onSettled)==null?void 0:v.call(m,_,null,this.state.variables,this.state.context,this,r)),await((g=(k=this.options).onSettled)==null?void 0:g.call(k,_,null,t,this.state.context,r)),H(this,Ct,Yt).call(this,{type:"success",data:_}),_}catch(_){try{await((p=(b=y(this,Me).config).onError)==null?void 0:p.call(b,_,t,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((x=(h=this.options).onError)==null?void 0:x.call(h,_,t,this.state.context,r))}catch(F){Promise.reject(F)}try{await((C=(w=y(this,Me).config).onSettled)==null?void 0:C.call(w,void 0,_,this.state.variables,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((N=(S=this.options).onSettled)==null?void 0:N.call(S,void 0,_,t,this.state.context,r))}catch(F){Promise.reject(F)}throw H(this,Ct,Yt).call(this,{type:"error",error:_}),_}finally{y(this,Me).runNext(this)}}},sa=new WeakMap,St=new WeakMap,Me=new WeakMap,Jn=new WeakMap,Ct=new WeakSet,Yt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),be.batch(()=>{y(this,St).forEach(r=>{r.onMutationUpdate(t)}),y(this,Me).notify({mutation:this,type:"updated",action:t})})},Hd);function gm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ft,xt,aa,qd,ty=(qd=class extends es{constructor(t={}){super();$(this,Ft);$(this,xt);$(this,aa);this.config=t,z(this,Ft,new Set),z(this,xt,new Map),z(this,aa,0)}build(t,n,r){const s=new ey({client:t,mutationCache:this,mutationId:++pa(this,aa)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){y(this,Ft).add(t);const n=Ra(t);if(typeof n=="string"){const r=y(this,xt).get(n);r?r.push(t):y(this,xt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(y(this,Ft).delete(t)){const n=Ra(t);if(typeof n=="string"){const r=y(this,xt).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&y(this,xt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Ra(t);if(typeof n=="string"){const r=y(this,xt).get(n),s=r==null?void 0:r.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=Ra(t);if(typeof n=="string"){const s=(r=y(this,xt).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){be.batch(()=>{y(this,Ft).forEach(t=>{this.notify({type:"removed",mutation:t})}),y(this,Ft).clear(),y(this,xt).clear()})}getAll(){return Array.from(y(this,Ft))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>hd(n,r))}findAll(t={}){return this.getAll().filter(n=>hd(t,n))}notify(t){be.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return be.batch(()=>Promise.all(t.map(n=>n.continue().catch(Ae))))}},Ft=new WeakMap,xt=new WeakMap,aa=new WeakMap,qd);function Ra(e){var t;return(t=e.options.scope)==null?void 0:t.id}var It,on,Ve,Dt,Bt,Wa,Ro,Wd,ny=(Wd=class extends es{constructor(n,r){super();$(this,Bt);$(this,It);$(this,on);$(this,Ve);$(this,Dt);z(this,It,n),this.setOptions(r),this.bindMethods(),H(this,Bt,Wa).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=y(this,It).defaultMutationOptions(n),gi(this.options,r)||y(this,It).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,Ve),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&ar(r.mutationKey)!==ar(this.options.mutationKey)?this.reset():((s=y(this,Ve))==null?void 0:s.state.status)==="pending"&&y(this,Ve).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=y(this,Ve))==null||n.removeObserver(this)}onMutationUpdate(n){H(this,Bt,Wa).call(this),H(this,Bt,Ro).call(this,n)}getCurrentResult(){return y(this,on)}reset(){var n;(n=y(this,Ve))==null||n.removeObserver(this),z(this,Ve,void 0),H(this,Bt,Wa).call(this),H(this,Bt,Ro).call(this)}mutate(n,r){var s;return z(this,Dt,r),(s=y(this,Ve))==null||s.removeObserver(this),z(this,Ve,y(this,It).getMutationCache().build(y(this,It),this.options)),y(this,Ve).addObserver(this),y(this,Ve).execute(n)}},It=new WeakMap,on=new WeakMap,Ve=new WeakMap,Dt=new WeakMap,Bt=new WeakSet,Wa=function(){var r;const n=((r=y(this,Ve))==null?void 0:r.state)??gm();z(this,on,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Ro=function(n){be.batch(()=>{var r,s,i,l,o,c,u,d;if(y(this,Dt)&&this.hasListeners()){const f=y(this,on).variables,m=y(this,on).context,v={client:y(this,It),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(s=(r=y(this,Dt)).onSuccess)==null||s.call(r,n.data,f,m,v)}catch(k){Promise.reject(k)}try{(l=(i=y(this,Dt)).onSettled)==null||l.call(i,n.data,null,f,m,v)}catch(k){Promise.reject(k)}}else if((n==null?void 0:n.type)==="error"){try{(c=(o=y(this,Dt)).onError)==null||c.call(o,n.error,f,m,v)}catch(k){Promise.reject(k)}try{(d=(u=y(this,Dt)).onSettled)==null||d.call(u,void 0,n.error,f,m,v)}catch(k){Promise.reject(k)}}}this.listeners.forEach(f=>{f(y(this,on))})})},Wd),_t,Gd,ry=(Gd=class extends es{constructor(t={}){super();$(this,_t);this.config=t,z(this,_t,new Map)}build(t,n,r){const s=n.queryKey,i=n.queryHash??Ac(s,n);let l=this.get(i);return l||(l=new Gv({client:t,queryKey:s,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(l)),l}add(t){y(this,_t).has(t.queryHash)||(y(this,_t).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=y(this,_t).get(t.queryHash);n&&(t.destroy(),n===t&&y(this,_t).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){be.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return y(this,_t).get(t)}getAll(){return[...y(this,_t).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>fd(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>fd(t,r)):n}notify(t){be.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){be.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){be.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},_t=new WeakMap,Gd),xe,cn,un,Ir,Dr,dn,Ar,$r,Jd,sy=(Jd=class{constructor(e={}){$(this,xe);$(this,cn);$(this,un);$(this,Ir);$(this,Dr);$(this,dn);$(this,Ar);$(this,$r);z(this,xe,e.queryCache||new ry),z(this,cn,e.mutationCache||new ty),z(this,un,e.defaultOptions||{}),z(this,Ir,new Map),z(this,Dr,new Map),z(this,dn,0)}mount(){pa(this,dn)._++,y(this,dn)===1&&(z(this,Ar,Bc.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,xe).onFocus())})),z(this,$r,ji.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,xe).onOnline())})))}unmount(){var e,t;pa(this,dn)._--,y(this,dn)===0&&((e=y(this,Ar))==null||e.call(this),z(this,Ar,void 0),(t=y(this,$r))==null||t.call(this),z(this,$r,void 0))}isFetching(e){return y(this,xe).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return y(this,cn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,xe).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=y(this,xe).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Sn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return y(this,xe).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=y(this,xe).get(r.queryHash),i=s==null?void 0:s.state.data,l=Dv(t,i);if(l!==void 0)return y(this,xe).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return be.batch(()=>y(this,xe).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,xe).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=y(this,xe);be.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=y(this,xe);return be.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=be.batch(()=>y(this,xe).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Ae).catch(Ae)}invalidateQueries(e,t={}){return be.batch(()=>(y(this,xe).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=be.batch(()=>y(this,xe).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let i=s.fetch(void 0,n);return n.throwOnError||(i=i.catch(Ae)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Ae)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=y(this,xe).build(this,t);return n.isStaleByTime(Sn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ae).catch(Ae)}fetchInfiniteQuery(e){return e.behavior=jd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ae).catch(Ae)}ensureInfiniteQueryData(e){return e.behavior=jd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ji.isOnline()?y(this,cn).resumePausedMutations():Promise.resolve()}getQueryCache(){return y(this,xe)}getMutationCache(){return y(this,cn)}getDefaultOptions(){return y(this,un)}setDefaultOptions(e){z(this,un,e)}setQueryDefaults(e,t){y(this,Ir).set(ar(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...y(this,Ir).values()],n={};return t.forEach(r=>{Gs(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){y(this,Dr).set(ar(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...y(this,Dr).values()],n={};return t.forEach(r=>{Gs(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...y(this,un).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Ac(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===$c&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...y(this,un).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){y(this,xe).clear(),y(this,cn).clear()}},xe=new WeakMap,cn=new WeakMap,un=new WeakMap,Ir=new WeakMap,Dr=new WeakMap,dn=new WeakMap,Ar=new WeakMap,$r=new WeakMap,Jd),jm=j.createContext(void 0),Wt=e=>{const t=j.useContext(jm);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ay=({client:e,children:t})=>(j.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),a.jsx(jm.Provider,{value:e,children:t})),wm=j.createContext(!1),iy=()=>j.useContext(wm);wm.Provider;function ly(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var oy=j.createContext(ly()),cy=()=>j.useContext(oy),uy=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Uc(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},dy=e=>{j.useEffect(()=>{e.clearReset()},[e])},fy=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||Uc(n,[e.error,r])),hy=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},my=(e,t)=>e.isLoading&&e.isFetching&&!t,py=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,kd=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function xy(e,t,n){var m,v,k,g;const r=iy(),s=cy(),i=Wt(),l=i.defaultQueryOptions(e);(v=(m=i.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||v.call(m,l);const o=i.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",hy(l),uy(l,s,o),dy(s);const c=!i.getQueryCache().get(l.queryHash),[u]=j.useState(()=>new t(i,l)),d=u.getOptimisticResult(l),f=!r&&e.subscribed!==!1;if(j.useSyncExternalStore(j.useCallback(b=>{const p=f?u.subscribe(be.batchCalls(b)):Ae;return u.updateResult(),p},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),j.useEffect(()=>{u.setOptions(l)},[l,u]),py(l,d))throw kd(l,u,s);if(fy({result:d,errorResetBoundary:s,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw d.error;if((g=(k=i.getDefaultOptions().queries)==null?void 0:k._experimental_afterQuery)==null||g.call(k,l,d),l.experimental_prefetchInRender&&!sr&&my(d,r)){const b=c?kd(l,u,s):o==null?void 0:o.promise;b==null||b.catch(Ae).finally(()=>{u.updateResult()})}return l.notifyOnChangeProps?d:u.trackResult(d)}function le(e,t){return xy(e,Jv)}function Je(e,t){const n=Wt(),[r]=j.useState(()=>new ny(n,e));j.useEffect(()=>{r.setOptions(e)},[r,e]);const s=j.useSyncExternalStore(j.useCallback(l=>r.subscribe(be.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=j.useCallback((l,o)=>{r.mutate(l,o).catch(Ae)},[r]);if(s.error&&Uc(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}/** + * @remix-run/router v1.23.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Js(){return Js=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function Vc(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function yy(){return Math.random().toString(36).substr(2,8)}function Nd(e,t){return{usr:e.state,key:e.key,idx:t}}function Mo(e,t,n,r){return n===void 0&&(n=null),Js({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?ts(t):t,{state:n,key:t&&t.key||r||yy()})}function wi(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function ts(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function gy(e,t,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:i=!1}=r,l=s.history,o=mn.Pop,c=null,u=d();u==null&&(u=0,l.replaceState(Js({},l.state,{idx:u}),""));function d(){return(l.state||{idx:null}).idx}function f(){o=mn.Pop;let b=d(),p=b==null?null:b-u;u=b,c&&c({action:o,location:g.location,delta:p})}function m(b,p){o=mn.Push;let h=Mo(g.location,b,p);u=d()+1;let x=Nd(h,u),w=g.createHref(h);try{l.pushState(x,"",w)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;s.location.assign(w)}i&&c&&c({action:o,location:g.location,delta:1})}function v(b,p){o=mn.Replace;let h=Mo(g.location,b,p);u=d();let x=Nd(h,u),w=g.createHref(h);l.replaceState(x,"",w),i&&c&&c({action:o,location:g.location,delta:0})}function k(b){let p=s.location.origin!=="null"?s.location.origin:s.location.href,h=typeof b=="string"?b:wi(b);return h=h.replace(/ $/,"%20"),ye(p,"No window.location.(origin|href) available to create URL for href: "+h),new URL(h,p)}let g={get action(){return o},get location(){return e(s,l)},listen(b){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(bd,f),c=b,()=>{s.removeEventListener(bd,f),c=null}},createHref(b){return t(s,b)},createURL:k,encodeLocation(b){let p=k(b);return{pathname:p.pathname,search:p.search,hash:p.hash}},push:m,replace:v,go(b){return l.go(b)}};return g}var Sd;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Sd||(Sd={}));function jy(e,t,n){return n===void 0&&(n="/"),wy(e,t,n)}function wy(e,t,n,r){let s=typeof t=="string"?ts(t):t,i=Wr(s.pathname||"/",n);if(i==null)return null;let l=km(e);ky(l);let o=null;for(let c=0;o==null&&c{let c={relativePath:o===void 0?i.path||"":o,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};c.relativePath.startsWith("/")&&(ye(c.relativePath.startsWith(r),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(r.length));let u=Cn([r,c.relativePath]),d=n.concat(c);i.children&&i.children.length>0&&(ye(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),km(i.children,t,d,u)),!(i.path==null&&!i.index)&&t.push({path:u,score:Py(u,i.index),routesMeta:d})};return e.forEach((i,l)=>{var o;if(i.path===""||!((o=i.path)!=null&&o.includes("?")))s(i,l);else for(let c of bm(i.path))s(i,l,c)}),t}function bm(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return s?[i,""]:[i];let l=bm(r.join("/")),o=[];return o.push(...l.map(c=>c===""?i:[i,c].join("/"))),s&&o.push(...l),o.map(c=>e.startsWith("/")&&c===""?"/":c)}function ky(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ty(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const by=/^:[\w-]+$/,Ny=3,Sy=2,Cy=1,_y=10,Ey=-2,Cd=e=>e==="*";function Py(e,t){let n=e.split("/"),r=n.length;return n.some(Cd)&&(r+=Ey),t&&(r+=Sy),n.filter(s=>!Cd(s)).reduce((s,i)=>s+(by.test(i)?Ny:i===""?Cy:_y),r)}function Ty(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function Oy(e,t,n){let{routesMeta:r}=e,s={},i="/",l=[];for(let o=0;o{let{paramName:m,isOptional:v}=d;if(m==="*"){let g=o[f]||"";l=i.slice(0,i.length-g.length).replace(/(.)\/+$/,"$1")}const k=o[f];return v&&!k?u[m]=void 0:u[m]=(k||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:l,pattern:e}}function Ly(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),Vc(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,c)=>(r.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function Ry(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Vc(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Wr(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const My=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,zy=e=>My.test(e);function Fy(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?ts(e):e,i;if(n)if(zy(n))i=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),Vc(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?i=_d(n.substring(1),"/"):i=_d(n,t)}else i=t;return{pathname:i,search:Ay(r),hash:$y(s)}}function _d(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function gl(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Iy(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Nm(e,t){let n=Iy(e);return t?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Sm(e,t,n,r){r===void 0&&(r=!1);let s;typeof e=="string"?s=ts(e):(s=Js({},e),ye(!s.pathname||!s.pathname.includes("?"),gl("?","pathname","search",s)),ye(!s.pathname||!s.pathname.includes("#"),gl("#","pathname","hash",s)),ye(!s.search||!s.search.includes("#"),gl("#","search","hash",s)));let i=e===""||s.pathname==="",l=i?"/":s.pathname,o;if(l==null)o=n;else{let f=t.length-1;if(!r&&l.startsWith("..")){let m=l.split("/");for(;m[0]==="..";)m.shift(),f-=1;s.pathname=m.join("/")}o=f>=0?t[f]:"/"}let c=Fy(s,o),u=l&&l!=="/"&&l.endsWith("/"),d=(i||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}const Cn=e=>e.join("/").replace(/\/\/+/g,"/"),Dy=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Ay=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,$y=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Uy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const Cm=["post","put","patch","delete"];new Set(Cm);const By=["get",...Cm];new Set(By);/** + * React Router v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Ys(){return Ys=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),j.useCallback(function(u,d){if(d===void 0&&(d={}),!o.current)return;if(typeof u=="number"){r.go(u);return}let f=Sm(u,JSON.parse(l),i,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Cn([t,f.pathname])),(d.replace?r.replace:r.push)(f,d.state,d)},[t,r,l,i,e])}const Ky=j.createContext(null);function Hy(e){let t=j.useContext(Gt).outlet;return t&&j.createElement(Ky.Provider,{value:e},t)}function fa(){let{matches:e}=j.useContext(Gt),t=e[e.length-1];return t?t.params:{}}function Bi(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=j.useContext(Mn),{matches:s}=j.useContext(Gt),{pathname:i}=ns(),l=JSON.stringify(Nm(s,r.v7_relativeSplatPath));return j.useMemo(()=>Sm(e,JSON.parse(l),i,n==="path"),[e,l,i,n])}function qy(e,t){return Wy(e,t)}function Wy(e,t,n,r){da()||ye(!1);let{navigator:s}=j.useContext(Mn),{matches:i}=j.useContext(Gt),l=i[i.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let u=ns(),d;if(t){var f;let b=typeof t=="string"?ts(t):t;c==="/"||(f=b.pathname)!=null&&f.startsWith(c)||ye(!1),d=b}else d=u;let m=d.pathname||"/",v=m;if(c!=="/"){let b=c.replace(/^\//,"").split("/");v="/"+m.replace(/^\//,"").split("/").slice(b.length).join("/")}let k=jy(e,{pathname:v}),g=Zy(k&&k.map(b=>Object.assign({},b,{params:Object.assign({},o,b.params),pathname:Cn([c,s.encodeLocation?s.encodeLocation(b.pathname).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?c:Cn([c,s.encodeLocation?s.encodeLocation(b.pathnameBase).pathname:b.pathnameBase])})),i,n,r);return t&&g?j.createElement(Ui.Provider,{value:{location:Ys({pathname:"/",search:"",hash:"",state:null,key:"default"},d),navigationType:mn.Pop}},g):g}function Gy(){let e=rg(),t=Uy(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return j.createElement(j.Fragment,null,j.createElement("h2",null,"Unexpected Application Error!"),j.createElement("h3",{style:{fontStyle:"italic"}},t),n?j.createElement("pre",{style:s},n):null,null)}const Jy=j.createElement(Gy,null);class Yy extends j.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?j.createElement(Gt.Provider,{value:this.props.routeContext},j.createElement(Em.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Xy(e){let{routeContext:t,match:n,children:r}=e,s=j.useContext($i);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),j.createElement(Gt.Provider,{value:t},r)}function Zy(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(s=n)==null?void 0:s.errors;if(o!=null){let d=l.findIndex(f=>f.route.id&&(o==null?void 0:o[f.route.id])!==void 0);d>=0||ye(!1),l=l.slice(0,Math.min(l.length,d+1))}let c=!1,u=-1;if(n&&r&&r.v7_partialHydration)for(let d=0;d=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((d,f,m)=>{let v,k=!1,g=null,b=null;n&&(v=o&&f.route.id?o[f.route.id]:void 0,g=f.route.errorElement||Jy,c&&(u<0&&m===0?(ag("route-fallback"),k=!0,b=null):u===m&&(k=!0,b=f.route.hydrateFallbackElement||null)));let p=t.concat(l.slice(0,m+1)),h=()=>{let x;return v?x=g:k?x=b:f.route.Component?x=j.createElement(f.route.Component,null):f.route.element?x=f.route.element:x=d,j.createElement(Xy,{match:f,routeContext:{outlet:d,matches:p,isDataRoute:n!=null},children:x})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?j.createElement(Yy,{location:n.location,revalidation:n.revalidation,component:g,error:v,children:h(),routeContext:{outlet:null,matches:p,isDataRoute:!0}}):h()},null)}var Tm=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Tm||{}),Om=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(Om||{});function eg(e){let t=j.useContext($i);return t||ye(!1),t}function tg(e){let t=j.useContext(_m);return t||ye(!1),t}function ng(e){let t=j.useContext(Gt);return t||ye(!1),t}function Lm(e){let t=ng(),n=t.matches[t.matches.length-1];return n.route.id||ye(!1),n.route.id}function rg(){var e;let t=j.useContext(Em),n=tg(),r=Lm();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function sg(){let{router:e}=eg(Tm.UseNavigateStable),t=Lm(Om.UseNavigateStable),n=j.useRef(!1);return Pm(()=>{n.current=!0}),j.useCallback(function(s,i){i===void 0&&(i={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,Ys({fromRouteId:t},i)))},[e,t])}const Ed={};function ag(e,t,n){Ed[e]||(Ed[e]=!0)}function ig(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function lg(e){return Hy(e.context)}function ht(e){ye(!1)}function og(e){let{basename:t="/",children:n=null,location:r,navigationType:s=mn.Pop,navigator:i,static:l=!1,future:o}=e;da()&&ye(!1);let c=t.replace(/^\/*/,"/"),u=j.useMemo(()=>({basename:c,navigator:i,static:l,future:Ys({v7_relativeSplatPath:!1},o)}),[c,o,i,l]);typeof r=="string"&&(r=ts(r));let{pathname:d="/",search:f="",hash:m="",state:v=null,key:k="default"}=r,g=j.useMemo(()=>{let b=Wr(d,c);return b==null?null:{location:{pathname:b,search:f,hash:m,state:v,key:k},navigationType:s}},[c,d,f,m,v,k,s]);return g==null?null:j.createElement(Mn.Provider,{value:u},j.createElement(Ui.Provider,{children:n,value:g}))}function cg(e){let{children:t,location:n}=e;return qy(Fo(t),n)}new Promise(()=>{});function Fo(e,t){t===void 0&&(t=[]);let n=[];return j.Children.forEach(e,(r,s)=>{if(!j.isValidElement(r))return;let i=[...t,s];if(r.type===j.Fragment){n.push.apply(n,Fo(r.props.children,i));return}r.type!==ht&&ye(!1),!r.props.index||!r.props.children||ye(!1);let l={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Fo(r.props.children,i)),n.push(l)}),n}/** + * React Router DOM v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function ki(){return ki=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[s]=e[s]);return n}function ug(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function dg(e,t){return e.button===0&&(!t||t==="_self")&&!ug(e)}const fg=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],hg=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],mg="6";try{window.__reactRouterVersion=mg}catch{}const pg=j.createContext({isTransitioning:!1}),xg="startTransition",Pd=bp[xg];function vg(e){let{basename:t,children:n,future:r,window:s}=e,i=j.useRef();i.current==null&&(i.current=vy({window:s,v5Compat:!0}));let l=i.current,[o,c]=j.useState({action:l.action,location:l.location}),{v7_startTransition:u}=r||{},d=j.useCallback(f=>{u&&Pd?Pd(()=>c(f)):c(f)},[c,u]);return j.useLayoutEffect(()=>l.listen(d),[l,d]),j.useEffect(()=>ig(r),[r]),j.createElement(og,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const yg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",gg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Tn=j.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:i,replace:l,state:o,target:c,to:u,preventScrollReset:d,viewTransition:f}=t,m=Rm(t,fg),{basename:v}=j.useContext(Mn),k,g=!1;if(typeof u=="string"&&gg.test(u)&&(k=u,yg))try{let x=new URL(window.location.href),w=u.startsWith("//")?new URL(x.protocol+u):new URL(u),C=Wr(w.pathname,v);w.origin===x.origin&&C!=null?u=C+w.search+w.hash:g=!0}catch{}let b=Qy(u,{relative:s}),p=wg(u,{replace:l,state:o,target:c,preventScrollReset:d,relative:s,viewTransition:f});function h(x){r&&r(x),x.defaultPrevented||p(x)}return j.createElement("a",ki({},m,{href:k||b,onClick:g||i?r:h,ref:n,target:c}))}),Mm=j.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:s=!1,className:i="",end:l=!1,style:o,to:c,viewTransition:u,children:d}=t,f=Rm(t,hg),m=Bi(c,{relative:f.relative}),v=ns(),k=j.useContext(_m),{navigator:g,basename:b}=j.useContext(Mn),p=k!=null&&kg(m)&&u===!0,h=g.encodeLocation?g.encodeLocation(m).pathname:m.pathname,x=v.pathname,w=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;s||(x=x.toLowerCase(),w=w?w.toLowerCase():null,h=h.toLowerCase()),w&&b&&(w=Wr(w,b)||w);const C=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let S=x===h||!l&&x.startsWith(h)&&x.charAt(C)==="/",N=w!=null&&(w===h||!l&&w.startsWith(h)&&w.charAt(h.length)==="/"),_={isActive:S,isPending:N,isTransitioning:p},F=S?r:void 0,O;typeof i=="function"?O=i(_):O=[i,S?"active":null,N?"pending":null,p?"transitioning":null].filter(Boolean).join(" ");let B=typeof o=="function"?o(_):o;return j.createElement(Tn,ki({},f,{"aria-current":F,className:O,ref:n,style:B,to:c,viewTransition:u}),typeof d=="function"?d(_):d)});var Io;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Io||(Io={}));var Td;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Td||(Td={}));function jg(e){let t=j.useContext($i);return t||ye(!1),t}function wg(e,t){let{target:n,replace:r,state:s,preventScrollReset:i,relative:l,viewTransition:o}=t===void 0?{}:t,c=zn(),u=ns(),d=Bi(e,{relative:l});return j.useCallback(f=>{if(dg(f,n)){f.preventDefault();let m=r!==void 0?r:wi(u)===wi(d);c(e,{replace:m,state:s,preventScrollReset:i,relative:l,viewTransition:o})}},[u,c,d,r,s,n,e,i,l,o])}function kg(e,t){t===void 0&&(t={});let n=j.useContext(pg);n==null&&ye(!1);let{basename:r}=jg(Io.useViewTransitionState),s=Bi(e,{relative:t.relative});if(!n.isTransitioning)return!1;let i=Wr(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Wr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return zo(s.pathname,l)!=null||zo(s.pathname,i)!=null}/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var bg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ng=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),U=(e,t)=>{const n=j.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:l,className:o="",children:c,...u},d)=>j.createElement("svg",{ref:d,...bg,width:s,height:s,stroke:r,strokeWidth:l?Number(i)*24/Number(s):i,className:["lucide",`lucide-${Ng(e)}`,o].join(" "),...u},[...t.map(([f,m])=>j.createElement(f,m)),...Array.isArray(c)?c:[c]]));return n.displayName=`${e}`,n};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Sg=U("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zm=U("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cg=U("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _g=U("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Eg=U("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pg=U("BookOpen",[["path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z",key:"vv98re"}],["path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z",key:"1cyq3y"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Do=U("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fm=U("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Tg=U("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Og=U("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xs=U("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lg=U("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rg=U("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Im=U("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mg=U("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zg=U("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dm=U("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Od=U("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Am=U("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ao=U("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fg=U("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ig=U("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dg=U("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Kc=U("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ag=U("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $g=U("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ug=U("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ha=U("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $m=U("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bg=U("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qg=U("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vg=U("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Zs=U("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hc=U("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Kg=U("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hg=U("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Um=U("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bm=U("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qg=U("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wg=U("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ld=U("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Gg=U("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Jg=U("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qc=U("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qm=U("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Yg=U("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xg=U("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vm=U("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const rs=U("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),Zg={},Rd=e=>{let t;const n=new Set,r=(d,f)=>{const m=typeof d=="function"?d(t):d;if(!Object.is(m,t)){const v=t;t=f??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(k=>k(t,v))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(Zg?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(r,s,c);return c},e0=e=>e?Rd(e):Rd;var Km={exports:{}},Hm={},qm={exports:{}},Wm={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Gr=j;function t0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var n0=typeof Object.is=="function"?Object.is:t0,r0=Gr.useState,s0=Gr.useEffect,a0=Gr.useLayoutEffect,i0=Gr.useDebugValue;function l0(e,t){var n=t(),r=r0({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return a0(function(){s.value=n,s.getSnapshot=t,jl(s)&&i({inst:s})},[e,n,t]),s0(function(){return jl(s)&&i({inst:s}),e(function(){jl(s)&&i({inst:s})})},[e]),i0(n),n}function jl(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!n0(e,n)}catch{return!0}}function o0(e,t){return t()}var c0=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o0:l0;Wm.useSyncExternalStore=Gr.useSyncExternalStore!==void 0?Gr.useSyncExternalStore:c0;qm.exports=Wm;var u0=qm.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Qi=j,d0=u0;function f0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var h0=typeof Object.is=="function"?Object.is:f0,m0=d0.useSyncExternalStore,p0=Qi.useRef,x0=Qi.useEffect,v0=Qi.useMemo,y0=Qi.useDebugValue;Hm.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=p0(null);if(i.current===null){var l={hasValue:!1,value:null};i.current=l}else l=i.current;i=v0(function(){function c(v){if(!u){if(u=!0,d=v,v=r(v),s!==void 0&&l.hasValue){var k=l.value;if(s(k,v))return f=k}return f=v}if(k=f,h0(d,v))return k;var g=r(v);return s!==void 0&&s(k,g)?(d=v,k):(d=v,f=g)}var u=!1,d,f,m=n===void 0?null:n;return[function(){return c(t())},m===null?void 0:function(){return c(m())}]},[t,n,r,s]);var o=m0(e,i[0],i[1]);return x0(function(){l.hasValue=!0,l.value=o},[o]),y0(o),o};Km.exports=Hm;var g0=Km.exports;const j0=Yd(g0),Gm={},{useDebugValue:w0}=Wo,{useSyncExternalStoreWithSelector:k0}=j0;let Md=!1;const b0=e=>e;function N0(e,t=b0,n){(Gm?"production":void 0)!=="production"&&n&&!Md&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Md=!0);const r=k0(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return w0(r),r}const zd=e=>{(Gm?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?e0(e):e,n=(r,s)=>N0(t,r,s);return Object.assign(n,t),n},Wc=e=>e?zd(e):zd,Vi="/api",Gc="flow_auth_token",Jc="flow_auth_expires",Yc="flow_auth_username";function Ki(){const e=localStorage.getItem(Gc),t=localStorage.getItem(Jc);return!e||!t?null:new Date(t)<=new Date?(Jr(),null):e}function Fd(e,t,n){localStorage.setItem(Gc,e),localStorage.setItem(Jc,t),localStorage.setItem(Yc,n)}function Jr(){localStorage.removeItem(Gc),localStorage.removeItem(Jc),localStorage.removeItem(Yc)}function Xc(){return localStorage.getItem(Yc)}let ir=null;function S0(e){ir=e}async function J(e,t,n=!1){const r={"Content-Type":"application/json",...t==null?void 0:t.headers};if(!n){const i=Ki();i&&(r.Authorization=`Bearer ${i}`)}const s=await fetch(`${Vi}${e}`,{...t,headers:r});if(s.status===401){Jr(),ir&&ir();const i=await s.json().catch(()=>({detail:"Not authenticated"}));throw new Error(i.detail||"Not authenticated")}if(!s.ok){const i=await s.json().catch(()=>({detail:s.statusText}));throw new Error(i.detail||"API request failed")}if(s.status!==204)return s.json()}const ps={getConfig:()=>J("/auth/config",void 0,!0),login:e=>J("/auth/login",{method:"POST",body:JSON.stringify(e)},!0),getGitHubAuthUrl:()=>`${Vi}/auth/github`,getCurrentUser:()=>J("/auth/me"),logout:()=>J("/auth/logout",{method:"POST"})},_n={list:e=>{const t=new URLSearchParams;e!=null&&e.include_auto_generated&&t.set("include_auto_generated","true"),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return J(`/configs${n?`?${n}`:""}`)},get:e=>J(`/configs/${e}`),create:e=>J("/configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>J(`/configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>J(`/configs/${e}`,{method:"DELETE"})},gt={list:e=>{const t=new URLSearchParams;e!=null&&e.category&&t.set("category",e.category),e!=null&&e.suite&&t.set("suite",e.suite);const n=t.toString();return J(`/tasks${n?`?${n}`:""}`)},get:e=>J(`/tasks/${e}`),create:e=>J("/tasks",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>J(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>J(`/tasks/${e}`,{method:"DELETE"}),listSuites:()=>J("/tasks/suites"),importSuite:e=>J(`/tasks/import-suite?suite_name=${encodeURIComponent(e)}`,{method:"POST"})},Ot={list:e=>{const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return J(`/jobs${n?`?${n}`:""}`)},get:e=>J(`/jobs/${e}`),create:e=>J("/jobs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>J(`/jobs/${e}`,{method:"PUT",body:JSON.stringify(t)}),start:async function*(e){var o;const t={},n=Ki();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Vi}/jobs/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Jr(),ir&&ir(),new Error("Not authenticated");if(!r.ok)throw new Error("Failed to start job");const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const i=new TextDecoder;let l="";for(;;){const{done:c,value:u}=await s.read();if(c)break;l+=i.decode(u,{stream:!0});const d=l.split(` +`);l=d.pop()||"";for(const f of d)f.startsWith("data: ")&&(yield JSON.parse(f.slice(6)))}},cancel:e=>J(`/jobs/${e}/cancel`,{method:"POST"}),delete:e=>J(`/jobs/${e}`,{method:"DELETE"})},$o={list:e=>{const t=new URLSearchParams;e!=null&&e.job_id&&t.set("job_id",e.job_id),e!=null&&e.candidate_name&&t.set("candidate_name",e.candidate_name),e!=null&&e.task_name&&t.set("task_name",e.task_name),(e==null?void 0:e.is_pareto)!==void 0&&t.set("is_pareto",String(e.is_pareto));const n=t.toString();return J(`/runs${n?`?${n}`:""}`)},get:e=>J(`/runs/${e}`),getJobSummary:e=>J(`/runs/job/${e}/summary`)},Os={list:e=>{const t=new URLSearchParams;e!=null&&e.agent_id&&t.set("agent_id",e.agent_id),e!=null&&e.limit&&t.set("limit",String(e.limit));const n=t.toString();return J(`/tests${n?`?${n}`:""}`)},get:e=>J(`/tests/${e}`),create:e=>J("/tests",{method:"POST",body:JSON.stringify(e)}),start:async function*(e){var o;const t={},n=Ki();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Vi}/tests/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Jr(),ir&&ir(),new Error("Not authenticated");if(!r.ok){const c=await r.json().catch(()=>({detail:"Failed to start test"}));throw new Error(c.detail||"Failed to start test")}const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const i=new TextDecoder;let l="";for(;;){const{done:c,value:u}=await s.read();if(c)break;l+=i.decode(u,{stream:!0});const d=l.split(` +`);l=d.pop()||"";for(const f of d)f.startsWith("data: ")&&(yield JSON.parse(f.slice(6)))}},cancel:e=>J(`/tests/${e}/cancel`,{method:"POST"}),delete:e=>J(`/tests/${e}`,{method:"DELETE"})},C0={list:()=>J("/llm-configs")},_0={list:()=>J("/tools")},Jm={getAgentSchema:()=>J("/schema/agent")},E0={get:e=>J(`/deployments/${e}`)},P0={start:e=>J("/evaluate",{method:"POST",body:JSON.stringify(e)})},Uo={design:e=>J("/experiment/design",{method:"POST",body:JSON.stringify(e)}),validate:e=>J("/experiment/validate",{method:"POST",body:JSON.stringify(e)}),generateCandidates:e=>J("/experiment/generate-candidates",{method:"POST",body:JSON.stringify(e)})},Zc=Wc((e,t)=>(S0(()=>{e({isAuthenticated:!1,user:null,error:"Session expired. Please log in again."})}),{authConfig:null,isLoadingConfig:!0,isAuthenticated:!1,isLoading:!1,user:null,error:null,loadAuthConfig:async()=>{e({isLoadingConfig:!0});try{const n=await ps.getConfig();if(e({authConfig:n,isLoadingConfig:!1}),n.enabled){const r=Ki(),s=Xc();if(r&&s)try{const i=await ps.getCurrentUser();e({isAuthenticated:!0,user:i})}catch{Jr(),e({isAuthenticated:!1,user:null})}}else e({isAuthenticated:!0,user:{username:"anonymous",auth_mode:"none"}})}catch(n){console.error("Failed to load auth config:",n),e({isLoadingConfig:!1,error:"Failed to connect to server"})}},login:async(n,r)=>{e({isLoading:!0,error:null});try{const s=await ps.login({username:n,password:r});return Fd(s.access_token,s.expires_at,s.username),e({isAuthenticated:!0,isLoading:!1,user:{username:s.username,auth_mode:"basic"}}),!0}catch(s){return e({isLoading:!1,error:s instanceof Error?s.message:"Login failed"}),!1}},loginWithGitHub:()=>{window.location.href=ps.getGitHubAuthUrl()},handleOAuthCallback:()=>{const n=new URLSearchParams(window.location.search),r=n.get("auth_error");if(r)return e({error:r}),window.history.replaceState({},"",window.location.pathname),!0;if(n.get("auth_callback")==="true"){const s=n.get("token"),i=n.get("expires_at"),l=n.get("username");return s&&i&&l&&(Fd(s,i,l),e({isAuthenticated:!0,user:{username:l,auth_mode:"github"}})),window.history.replaceState({},"",window.location.pathname),!0}return!1},logout:async()=>{try{await ps.logout()}catch{}Jr(),e({isAuthenticated:!1,user:null,error:null})},clearError:()=>e({error:null})}));function Q({variant:e="secondary",size:t="md",className:n="",icon:r,iconRight:s,loading:i=!1,children:l,disabled:o,...c}){const u="font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1.5 rounded-md",d={primary:"bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)]",secondary:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)] hover:bg-[var(--border)]",danger:"bg-[var(--error)] text-white hover:bg-red-600",ghost:"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"},f={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm"},m=t==="sm"?14:16;return a.jsxs("button",{className:`${u} ${d[e]} ${f[t]} ${n}`,disabled:o||i,...c,children:[i?a.jsx(ha,{size:m,className:"animate-spin"}):r?a.jsx(r,{size:m}):null,l,s&&!i&&a.jsx(s,{size:m})]})}const T0={};function O0(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var i;const l=c=>c===null?null:JSON.parse(c,void 0),o=(i=n.getItem(s))!=null?i:null;return o instanceof Promise?o.then(l):l(o)},setItem:(s,i)=>n.setItem(s,JSON.stringify(i,void 0)),removeItem:s=>n.removeItem(s)}}const ea=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return ea(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return ea(r)(n)}}}},L0=(e,t)=>(n,r,s)=>{let i={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:b=>b,version:0,merge:(b,p)=>({...p,...b}),...t},l=!1;const o=new Set,c=new Set;let u;try{u=i.getStorage()}catch{}if(!u)return e((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...b)},r,s);const d=ea(i.serialize),f=()=>{const b=i.partialize({...r()});let p;const h=d({state:b,version:i.version}).then(x=>u.setItem(i.name,x)).catch(x=>{p=x});if(p)throw p;return h},m=s.setState;s.setState=(b,p)=>{m(b,p),f()};const v=e((...b)=>{n(...b),f()},r,s);let k;const g=()=>{var b;if(!u)return;l=!1,o.forEach(h=>h(r()));const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,r()))||void 0;return ea(u.getItem.bind(u))(i.name).then(h=>{if(h)return i.deserialize(h)}).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==i.version){if(i.migrate)return i.migrate(h.state,h.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return h.state}).then(h=>{var x;return k=i.merge(h,(x=r())!=null?x:v),n(k,!0),f()}).then(()=>{p==null||p(k,void 0),l=!0,c.forEach(h=>h(k))}).catch(h=>{p==null||p(void 0,h)})};return s.persist={setOptions:b=>{i={...i,...b},b.getStorage&&(u=b.getStorage())},clearStorage:()=>{u==null||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>g(),hasHydrated:()=>l,onHydrate:b=>(o.add(b),()=>{o.delete(b)}),onFinishHydration:b=>(c.add(b),()=>{c.delete(b)})},g(),k||v},R0=(e,t)=>(n,r,s)=>{let i={storage:O0(()=>localStorage),partialize:g=>g,version:0,merge:(g,b)=>({...b,...g}),...t},l=!1;const o=new Set,c=new Set;let u=i.storage;if(!u)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...g)},r,s);const d=()=>{const g=i.partialize({...r()});return u.setItem(i.name,{state:g,version:i.version})},f=s.setState;s.setState=(g,b)=>{f(g,b),d()};const m=e((...g)=>{n(...g),d()},r,s);s.getInitialState=()=>m;let v;const k=()=>{var g,b;if(!u)return;l=!1,o.forEach(h=>{var x;return h((x=r())!=null?x:m)});const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,(g=r())!=null?g:m))||void 0;return ea(u.getItem.bind(u))(i.name).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==i.version){if(i.migrate)return[!0,i.migrate(h.state,h.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,h.state];return[!1,void 0]}).then(h=>{var x;const[w,C]=h;if(v=i.merge(C,(x=r())!=null?x:m),n(v,!0),w)return d()}).then(()=>{p==null||p(v,void 0),v=r(),l=!0,c.forEach(h=>h(v))}).catch(h=>{p==null||p(void 0,h)})};return s.persist={setOptions:g=>{i={...i,...g},g.storage&&(u=g.storage)},clearStorage:()=>{u==null||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>k(),hasHydrated:()=>l,onHydrate:g=>(o.add(g),()=>{o.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},i.skipHydration||k(),v||m},M0=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((T0?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),L0(e,t)):R0(e,t),Ym=M0,z0=Wc()(Ym((e,t)=>({theme:"light",setTheme:n=>{document.documentElement.setAttribute("data-theme",n),e({theme:n})},toggleTheme:()=>{const n=t().theme==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",n),e({theme:n})}}),{name:"flow-theme",onRehydrateStorage:()=>e=>{e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}}));function F0(){const{theme:e,toggleTheme:t}=z0();return a.jsx("button",{onClick:t,className:"p-2 rounded-md text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--accent)]","aria-label":`Switch to ${e==="dark"?"light":"dark"} mode`,title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:e==="dark"?a.jsx(Gg,{size:16}):a.jsx(Vg,{size:16})})}const I0=Wc()(Ym((e,t)=>({sidebarCollapsed:!1,toggleSidebar:()=>{e({sidebarCollapsed:!t().sidebarCollapsed})}}),{name:"flow-layout"})),D0=[{path:"/",label:"Overview",icon:$g},{path:"/agents",label:"Agents",icon:Do},{path:"/jobs",label:"Experiments",icon:Ao},{path:"/tasks",label:"Datasets",icon:Dm}];function A0(){const e=ns(),{sidebarCollapsed:t,toggleSidebar:n}=I0(),r=s=>s==="/"?e.pathname==="/":s==="/agents"?e.pathname==="/agents"||e.pathname.startsWith("/agents/")||e.pathname.startsWith("/deployments/"):s==="/jobs"?e.pathname.startsWith("/jobs")||e.pathname.startsWith("/runs"):e.pathname.startsWith(s);return a.jsxs("aside",{className:` + flex flex-col border-r border-[var(--border)] bg-[var(--bg-secondary)] + transition-all duration-200 + ${t?"w-14":"w-56"} + `,children:[a.jsx("nav",{className:"flex-1 py-2",children:D0.map(s=>{const i=r(s.path);return a.jsxs(Mm,{to:s.path,title:t?s.label:void 0,className:` + flex items-center gap-3 px-4 py-2.5 text-sm transition-colors relative + ${i?"text-[var(--accent)] bg-[var(--accent-dim)] font-medium":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"} + `,children:[i&&a.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-r bg-[var(--accent)]"}),a.jsx(s.icon,{size:18}),!t&&a.jsx("span",{children:s.label})]},s.path)})}),a.jsx("button",{onClick:n,className:"flex items-center justify-center p-3 border-t border-[var(--border)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",title:t?"Expand sidebar":"Collapse sidebar",children:t?a.jsx(Rg,{size:16}):a.jsx(Lg,{size:16})})]})}function $0(){const{authConfig:e,user:t,logout:n}=Zc(),r=async()=>{await n()};return a.jsxs("div",{className:"h-screen flex flex-col",children:[a.jsx("header",{className:"border-b border-[var(--border)] bg-[var(--bg-secondary)] shrink-0",children:a.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between",children:[a.jsxs(Mm,{to:"/",className:"text-lg font-semibold text-[var(--accent)] flex items-center gap-2 hover:opacity-80",children:[a.jsx(rs,{size:20}),"Flow",a.jsx("span",{className:"text-[var(--text-secondary)] font-normal",children:"/optimize"})]}),a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(F0,{}),(e==null?void 0:e.enabled)&&t&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[a.jsx(Qm,{size:14}),a.jsx("span",{children:t.username})]}),a.jsx(Q,{variant:"ghost",size:"sm",icon:Bg,onClick:r,title:"Sign out",children:"Sign out"})]})]})]})}),a.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[a.jsx(A0,{}),a.jsx("main",{className:"flex-1 overflow-y-auto bg-[var(--bg-primary)]",children:a.jsx("div",{className:"p-6",children:a.jsx(lg,{})})})]})]})}function q({children:e,variant:t="default"}){const n={default:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)]",success:"bg-[var(--badge-success-bg)] text-[var(--badge-success-text)] border border-[var(--badge-success-border)]",warning:"bg-[var(--badge-warning-bg)] text-[var(--badge-warning-text)] border border-[var(--badge-warning-border)]",error:"bg-[var(--badge-error-bg)] text-[var(--badge-error-text)] border border-[var(--badge-error-border)]",info:"bg-[var(--badge-info-bg)] text-[var(--badge-info-text)] border border-[var(--badge-info-border)]"};return a.jsx("span",{className:`inline-block px-2 py-0.5 text-xs font-medium rounded-md ${n[t]}`,children:e})}const U0={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};function B0(){const e=zn(),{data:t=[],isLoading:n}=le({queryKey:["configs"],queryFn:()=>_n.list()}),{data:r=[],isLoading:s}=le({queryKey:["jobs"],queryFn:()=>Ot.list()}),{data:i=[],isLoading:l}=le({queryKey:["tasks"],queryFn:()=>gt.list()}),o=[...t].sort((d,f)=>new Date(f.created_at).getTime()-new Date(d.created_at).getTime()).slice(0,5),c=[...r].sort((d,f)=>new Date(f.created_at).getTime()-new Date(d.created_at).getTime()).slice(0,5),u=i.reduce((d,f)=>{const m=f.suite||"custom";return d[m]||(d[m]=[]),d[m].push(f),d},{});return a.jsxs("div",{children:[a.jsxs("div",{className:"mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Agent Optimizer"}),a.jsx("p",{className:"text-[var(--text-secondary)] max-w-2xl",children:"Systematically optimize and improve your AI agents across key dimensions. Define agent configurations, run experiments across task datasets, and find the best tradeoffs between quality and cost."}),a.jsx("div",{className:"flex flex-wrap gap-3 mt-4 text-sm text-[var(--text-secondary)]",children:[{icon:Qg,label:"Instructions"},{icon:Yg,label:"Tools"},{icon:Pg,label:"Skills"},{icon:Wg,label:"Compaction"}].map((d,f,m)=>a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[a.jsx(d.icon,{size:14,className:"text-[var(--accent)]"}),d.label,fa.jsxs("div",{className:"p-4 border border-[var(--border)] rounded-lg bg-[var(--bg-secondary)]",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a.jsx("span",{className:"flex items-center justify-center w-7 h-7 rounded-full bg-[var(--accent)]/10 text-[var(--accent)] text-xs font-bold",children:d.step}),a.jsx(d.icon,{size:18,className:"text-[var(--accent)]"})]}),a.jsx("h3",{className:"font-medium text-sm",children:d.title}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:d.description})]},d.step))}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mb-6",children:[a.jsxs("div",{children:[a.jsx(wl,{title:"Recent Agents",icon:Do,count:t.length,onShowAll:()=>e("/agents")}),n?a.jsx(kl,{}):o.length===0?a.jsx(bl,{message:"No agents yet. Create your first agent to get started."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:o.map((d,f)=>a.jsxs("div",{onClick:()=>e(`/agents/${d.id}`),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${fe("/jobs")}),s?a.jsx(kl,{}):c.length===0?a.jsx(bl,{message:"No experiments yet. Start one from an agent's detail page."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:c.map((d,f)=>a.jsxs("div",{onClick:()=>e(`/jobs/${d.id}`),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${fe("/tasks")}),l?a.jsx(kl,{}):Object.keys(u).length===0?a.jsx(bl,{message:"No datasets yet. Import a task suite to get started."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:Object.entries(u).map(([d,f],m,v)=>a.jsx("div",{onClick:()=>e("/tasks"),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${m0&&a.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",n,")"]})]}),n>0&&a.jsxs("button",{onClick:r,className:"text-sm text-[var(--accent)] hover:underline flex items-center gap-1",children:["Show all ",a.jsx(Cg,{size:14})]})]})}function kl(){return a.jsx("div",{className:"text-sm text-[var(--text-secondary)] mb-8",children:"Loading..."})}function bl({message:e}){return a.jsx("div",{className:"text-sm text-[var(--text-secondary)] py-6 text-center border border-[var(--border)] rounded-lg mb-8",children:e})}const Q0=["maf","miniagent","langgraph"],V0={maf:"Microsoft Agent Framework",miniagent:"MiniAgent",langgraph:"LangGraph"},K0={openai:"OpenAI",azure_openai:"Azure OpenAI",anthropic:"Anthropic",ollama:"Ollama",custom:"Custom (OpenAI-compatible)"},H0={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"};function ss({isOpen:e,onClose:t,title:n,children:r,footer:s,size:i="md"}){return j.useEffect(()=>{const l=o=>{o.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",l),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",l),document.body.style.overflow=""}},[e,t]),e?a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),a.jsxs("div",{className:`relative bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg ${H0[i]} w-full mx-4 max-h-[80vh] flex flex-col`,children:[a.jsxs("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-b border-[var(--border)] px-4 py-3 flex items-center justify-between",children:[a.jsx("h2",{className:"font-semibold",children:n}),a.jsx("button",{onClick:t,className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"×"})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r}),s&&a.jsx("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-t border-[var(--border)] px-4 py-3",children:s})]})]}):null}function pn({label:e,className:t="",...n}){return a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),a.jsx("input",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] ${t}`,...n})]})}function q0({label:e,className:t="",...n}){return a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),a.jsx("textarea",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] resize-y min-h-[100px] ${t}`,...n})]})}function bi({label:e,className:t="",...n}){return a.jsxs("label",{className:`flex items-center gap-2 cursor-pointer ${t}`,children:[a.jsx("input",{type:"checkbox",className:"w-4 h-4 bg-[var(--bg-primary)] border border-[var(--border)] rounded accent-[var(--accent)]",...n}),a.jsx("span",{className:"text-sm",children:e})]})}function Xm({columns:e,data:t,onRowClick:n,searchable:r=!1,searchPlaceholder:s="Search...",searchFilter:i,emptyMessage:l="No items found",emptyIcon:o}){const[c,u]=j.useState(""),[d,f]=j.useState(null),[m,v]=j.useState("asc"),k=j.useMemo(()=>{let b=t;if(r&&c&&i&&(b=b.filter(p=>i(p,c))),d){const p=e.find(h=>h.key===d);p!=null&&p.sortValue&&(b=[...b].sort((h,x)=>{const w=p.sortValue(h),C=p.sortValue(x),S=wC?1:0;return m==="asc"?S:-S}))}return b},[t,c,i,r,d,m,e]),g=b=>{const p=e.find(h=>h.key===b);p!=null&&p.sortable&&(d===b?v(m==="asc"?"desc":"asc"):(f(b),v("asc")))};return a.jsxs("div",{children:[r&&a.jsxs("div",{className:"mb-4 relative max-w-sm",children:[a.jsx(Hg,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]"}),a.jsx("input",{type:"text",placeholder:s,value:c,onChange:b=>u(b.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md pl-9 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]"})]}),k.length===0?a.jsxs("div",{className:"text-center py-16 text-[var(--text-secondary)]",children:[o&&a.jsx("div",{className:"mb-3 flex justify-center",children:o}),a.jsx("p",{children:l})]}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsx("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:e.map(b=>a.jsx("th",{onClick:()=>g(b.key),className:`text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider ${b.sortable?"cursor-pointer hover:text-[var(--text-primary)]":""} ${b.className||""}`,children:a.jsxs("span",{className:"inline-flex items-center gap-1",children:[b.header,b.sortable&&d===b.key&&a.jsx("span",{children:m==="asc"?"↑":"↓"})]})},b.key))})}),a.jsx("tbody",{children:k.map((b,p)=>a.jsx("tr",{onClick:()=>n==null?void 0:n(b),className:`border-b border-[var(--border)] last:border-b-0 transition-colors ${n?"cursor-pointer hover:bg-[var(--bg-tertiary)]":""}`,children:e.map(h=>a.jsx("td",{className:`px-4 py-3 ${h.className||""}`,children:h.render(b)},h.key))},p))})]})})]})}function W0({variations:e,onChange:t,strategies:n,availableStrategies:r}){const s=r??Object.keys(n),i=()=>{const u=e.map(v=>v.strategy),d=s.find(v=>!u.includes(v))||"none",f=n[d],m={strategy:d};if(f!=null&&f.params)for(const[v,k]of Object.entries(f.params))k.default!==void 0&&(m[v]=k.default);t([...e,m])},l=u=>{t(e.filter((d,f)=>f!==u))},o=(u,d)=>{t(e.map((f,m)=>m===u?{...f,...d}:f))},c=(u,d)=>{const f=n[d],m={strategy:d};if(f!=null&&f.params)for(const[v,k]of Object.entries(f.params))k.default!==void 0&&(m[v]=k.default);o(u,m)};return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm font-medium",children:"Compaction Strategies"}),a.jsx(Q,{type:"button",variant:"ghost",size:"sm",icon:Hc,onClick:i,disabled:e.length>=s.length,children:"Add"})]}),e.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:'No compaction variations. Click "Add" to test different strategies.'}):a.jsx("div",{className:"space-y-2",children:e.map((u,d)=>{const f=n[u.strategy];return a.jsx("div",{className:"p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsx("select",{className:"w-full px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:u.strategy,onChange:m=>c(d,m.target.value),children:s.map(m=>{var v;return a.jsx("option",{value:m,children:((v=n[m])==null?void 0:v.label)||m},m)})}),(f==null?void 0:f.description)&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:f.description}),(f==null?void 0:f.params)&&Object.keys(f.params).length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:Object.entries(f.params).map(([m,v])=>a.jsx(G0,{name:m,schema:v,value:u[m],onChange:k=>o(d,{[m]:k})},m))})]}),a.jsx("button",{type:"button",onClick:()=>l(d),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:a.jsx(Vm,{size:16})})]})},d)})})]})}function G0({name:e,schema:t,value:n,onChange:r}){const s=e.replace(/_/g," ");return t.type==="boolean"?a.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[a.jsx("input",{type:"checkbox",checked:!!(n??t.default),onChange:i=>r(i.target.checked),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"capitalize",children:s})]}):a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:s}),a.jsx("input",{type:t.type==="number"?"number":"text",className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-xs",value:String(n!==void 0?n:t.default??""),onChange:i=>{if(t.type==="number"){const l=parseFloat(i.target.value);r(isNaN(l)?t.default:l)}else r(i.target.value)},min:t.min,max:t.max,step:t.max&&t.max<=1?.1:1})]})}function J0({variations:e,onChange:t,providers:n}){const r=()=>{const o=n[0],c={provider:(o==null?void 0:o.name)||"azure_openai",model:(o==null?void 0:o.models[0])||"gpt-4o"};t([...e,c])},s=o=>{t(e.filter((c,u)=>u!==o))},i=(o,c)=>{t(e.map((u,d)=>d===o?{...u,...c}:u))},l=(o,c)=>{const u=n.find(d=>d.name===c);i(o,{provider:c,model:(u==null?void 0:u.models[0])||""})};return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm font-medium",children:"LLM Configurations"}),a.jsx(Q,{type:"button",variant:"ghost",size:"sm",icon:Hc,onClick:r,children:"Add"})]}),e.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:`Uses agent's default LLM. Click "Add" to test different models.`}):a.jsx("div",{className:"space-y-2",children:e.map((o,c)=>{const u=n.find(d=>d.name===o.provider);return a.jsxs("div",{className:"flex items-center gap-2 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[a.jsx("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.provider,onChange:d=>l(c,d.target.value),children:n.map(d=>a.jsx("option",{value:d.name,children:d.label},d.name))}),u&&u.models.length>0?a.jsxs("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:d=>i(c,{model:d.target.value}),children:[u.models.map(d=>a.jsx("option",{value:d,children:d},d)),!u.models.includes(o.model)&&o.model&&a.jsx("option",{value:o.model,children:o.model})]}):a.jsx("input",{type:"text",className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:d=>i(c,{model:d.target.value}),placeholder:"Model ID"}),a.jsx("button",{type:"button",onClick:()=>s(c),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:a.jsx(Vm,{size:16})})]},c)})})]})}const Bo={compaction:[],tools:[],llm_config:[],instructions:[],instruction_strategies:[]};function Y0({agentId:e,agentName:t,agentFramework:n="maf",taskSuite:r,taskCount:s,schema:i,onVariationsChange:l,parallel:o,onParallelChange:c,budget:u,onBudgetChange:d,useLlmEval:f,onUseLlmEvalChange:m}){const[v,k]=j.useState(Bo),[g,b]=j.useState(!1),[p,h]=j.useState(""),[x,w]=j.useState(null),C=i.frameworks[n],S=(C==null?void 0:C.compaction_strategies)||Object.keys(i.compaction_strategies),N=i.tool_presets||[],_=i.llm_providers||[],O=(()=>{let L=1;v.compaction.length>0&&(L*=v.compaction.length),v.tools.length>0&&(L*=v.tools.length),v.llm_config.length>0&&(L*=v.llm_config.length);const V=v.instructions.length+v.instruction_strategies.reduce((ee,R)=>ee+R.max_candidates,0);return V>0&&(L*=V),Math.min(L,u)})(),B=O*s,G=L=>{k(L),l==null||l(L)},re=Je({mutationFn:L=>Uo.design(L),onSuccess:L=>{h(L.yaml_content),b(!0)}}),oe=Je({mutationFn:L=>Uo.validate(L),onSuccess:L=>{w({valid:L.valid,errors:L.errors,warnings:L.warnings})}}),D=()=>({base_agent_id:e,task_suite:r,variations:v,parallel:o,budget:u,use_llm_eval:f}),W=()=>{re.mutate(D())},X=()=>{oe.mutate(D())},P=()=>{const L=new Blob([p],{type:"text/yaml"}),V=URL.createObjectURL(L),ee=document.createElement("a");ee.href=V,ee.download=`${t}_experiment.yaml`,ee.click(),URL.revokeObjectURL(V)},A=v.compaction.length>0||v.tools.length>0||v.llm_config.length>0||v.instructions.length>0||v.instruction_strategies.length>0;return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsxs(q,{variant:"info",children:[O," candidates"]}),a.jsxs(q,{children:[s," tasks"]}),a.jsxs(q,{variant:B>100?"warning":"success",children:[B," total runs"]})]}),a.jsx(W0,{variations:v.compaction,onChange:L=>G({...v,compaction:L}),strategies:i.compaction_strategies,availableStrategies:S}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("label",{className:"text-sm font-medium",children:"Tool Presets"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(L=>a.jsxs("label",{className:`flex items-center gap-2 px-3 py-1.5 border rounded cursor-pointer transition-colors ${v.tools.includes(L.name)?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[a.jsx("input",{type:"checkbox",checked:v.tools.includes(L.name),onChange:V=>{const ee=V.target.checked?[...v.tools,L.name]:v.tools.filter(R=>R!==L.name);G({...v,tools:ee})},className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:L.name}),a.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",L.tools.length,")"]})]},L.name))}),v.tools.length>0&&a.jsxs("p",{className:"text-xs text-[var(--text-secondary)]",children:["Selected: ",v.tools.join(", ")]})]}),a.jsx(J0,{variations:v.llm_config,onChange:L=>G({...v,llm_config:L}),providers:_}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-4 space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium",children:"Execution Settings"}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(pn,{label:"Parallel Workers",type:"number",value:o,onChange:L=>c(parseInt(L.target.value)||1),min:1,max:16}),a.jsx(pn,{label:"Budget (max candidates)",type:"number",value:u,onChange:L=>d(parseInt(L.target.value)||100),min:1,max:1e3})]}),a.jsx(bi,{label:"Use LLM evaluation",checked:f,onChange:L=>m(L.target.checked)}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] ml-6 -mt-2",children:f?"LLM-as-Judge scores task completion (0-1)":"Simple pass/fail based on task success"})]}),a.jsxs("div",{className:"flex items-center gap-2 border-t border-[var(--border)] pt-4",children:[a.jsx(Q,{variant:"secondary",size:"sm",onClick:X,loading:oe.isPending,children:"Validate"}),a.jsx(Q,{variant:"secondary",size:"sm",icon:Od,onClick:W,loading:re.isPending,children:"Export YAML"})]}),x&&a.jsxs("div",{className:`p-3 rounded border ${x.valid?"border-green-500/50 bg-green-500/10":"border-red-500/50 bg-red-500/10"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[x.valid?a.jsx(Fm,{size:16,className:"text-green-500"}):a.jsx(zm,{size:16,className:"text-red-500"}),a.jsx("span",{className:"font-medium text-sm",children:x.valid?"Configuration valid":"Configuration has issues"})]}),x.errors.length>0&&a.jsx("ul",{className:"text-sm text-red-500 list-disc ml-6",children:x.errors.map((L,V)=>a.jsx("li",{children:L},V))}),x.warnings.length>0&&a.jsx("ul",{className:"text-sm text-yellow-500 list-disc ml-6 mt-1",children:x.warnings.map((L,V)=>a.jsx("li",{children:L},V))})]}),g&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-lg shadow-xl max-w-2xl w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border)]",children:[a.jsx("h3",{className:"font-medium",children:"Experiment YAML"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Q,{variant:"secondary",size:"sm",icon:Od,onClick:P,children:"Download"}),a.jsx(Q,{variant:"ghost",size:"sm",onClick:()=>b(!1),children:"Close"})]})]}),a.jsx("pre",{className:"flex-1 overflow-auto p-4 text-xs font-mono bg-[var(--bg-secondary)]",children:p})]})}),!A&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No variations selected. Only the baseline agent will be tested. Add compaction strategies, tool presets, or LLM configs to generate candidates."})]})}function Zm({agent:e,isOpen:t,onClose:n}){var R;const r=zn(),s=Wt(),[i,l]=j.useState("ready"),[o,c]=j.useState("quick"),[u,d]=j.useState(!1),[f,m]=j.useState([]),[v,k]=j.useState(!1),[g,b]=j.useState(Bo),[p,h]=j.useState(4),[x,w]=j.useState(100),[C,S]=j.useState(!1),[N,_]=j.useState(null),{data:F=[]}=le({queryKey:["tasks"],queryFn:()=>gt.list()}),{data:O=[]}=le({queryKey:["suites"],queryFn:()=>gt.listSuites()}),{data:B}=le({queryKey:["agent-schema"],queryFn:()=>Jm.getAgentSchema()}),G=O.map(T=>({value:T.name,label:T.name.charAt(0).toUpperCase()+T.name.slice(1),description:T.description,tasks:T.task_count})),re=Je({mutationFn:gt.importSuite,onSuccess:T=>{s.invalidateQueries({queryKey:["tasks"]}),m(T.map(te=>te.id))}}),oe=Je({mutationFn:async T=>{const te=await Ot.create(T);return Ot.start(te.id).next(),te},onSuccess:T=>{s.invalidateQueries({queryKey:["jobs"]}),_(T.id),l("success")}}),W=v?(()=>{let T=1;g.compaction.length>0&&(T*=g.compaction.length),g.tools.length>0&&(T*=g.tools.length),g.llm_config.length>0&&(T*=g.llm_config.length);const te=g.instructions.length+g.instruction_strategies.reduce((pe,Se)=>pe+Se.max_candidates,0);return te>0&&(T*=te),Math.min(T,x)})():1,X=u?f.length:((R=G.find(T=>T.value===o))==null?void 0:R.tasks)||3,P=W*X,A=async()=>{l("starting");let T=f;if(!u)try{T=(await re.mutateAsync(o)).map(K=>K.id)}catch(M){console.error("Failed to import suite:",M),alert(`Failed to import task suite: ${o}`),l("ready");return}if(T.length===0){alert("No tasks selected. Please select tasks or choose a task suite."),l("ready");return}let te;if(v&&(g.compaction.length>0||g.tools.length>0||g.llm_config.length>0||g.instructions.length>0||g.instruction_strategies.length>0))try{te=(await Uo.generateCandidates({base_agent_id:e.id,variations:g,budget:x})).candidate_ids}catch(M){console.error("Failed to generate candidates:",M),alert(`Failed to generate candidates: ${M instanceof Error?M.message:"Unknown error"}`),l("ready");return}else te=[e.id];const Se={name:`${e.name} optimization (${te.length} candidates × ${T.length} tasks)`,candidate_ids:te,task_ids:T,parallel:p,use_llm_eval:C};oe.mutate(Se)},L=T=>{m(te=>te.includes(T)?te.filter(pe=>pe!==T):[...te,T])},V=()=>{l("ready"),_(null),k(!1),b(Bo),n()},ee=()=>i==="success"&&N?a.jsxs("div",{className:"flex justify-end gap-3",children:[a.jsx(Q,{variant:"secondary",onClick:V,children:"Close"}),a.jsx(Q,{variant:"primary",icon:Zs,onClick:()=>{V(),r(`/jobs/${N}`)},children:"View Job"})]}):i==="starting"?null:a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Q,{variant:"secondary",onClick:n,children:"Cancel"}),a.jsxs(Q,{variant:"primary",icon:Zs,onClick:A,disabled:u&&f.length===0,children:["Start Optimization (",P," runs)"]})]});return a.jsx(ss,{isOpen:t,onClose:V,title:`Optimize: ${e.name}`,footer:ee(),size:"lg",children:i==="success"&&N?a.jsxs("div",{className:"flex flex-col items-center py-8",children:[a.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/20 flex items-center justify-center mb-4",children:a.jsx(rs,{size:24,className:"text-green-500"})}),a.jsx("h3",{className:"text-lg font-medium mb-2",children:"Job Started!"}),a.jsx("p",{className:"text-[var(--text-secondary)] text-center mb-2",children:"Optimization job is now running"}),a.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-3 py-1.5 rounded font-mono",children:["ID: ",N.slice(0,8),"..."]})]}):i==="starting"?a.jsxs("div",{className:"flex flex-col items-center py-8",children:[a.jsx(ha,{size:32,className:"animate-spin text-[var(--accent)] mb-4"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:re.isPending?"Importing tasks...":"Creating optimization job..."})]}):a.jsxs("div",{className:"space-y-5",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Task Suite"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:u?"__custom__":o,onChange:T=>{T.target.value==="__custom__"?d(!0):(d(!1),c(T.target.value))},children:[G.map(T=>a.jsxs("option",{value:T.value,children:[T.label," (",T.tasks," tasks) — ",T.description]},T.value)),F.length>0&&a.jsx("option",{value:"__custom__",children:"Custom Selection"})]})]}),u&&F.length>0&&a.jsx("div",{className:"max-h-48 overflow-y-auto border border-[var(--border)] rounded p-2 space-y-1",children:F.map(T=>a.jsxs("label",{className:"flex items-center gap-2 p-2 hover:bg-[var(--bg-tertiary)] cursor-pointer rounded",children:[a.jsx("input",{type:"checkbox",checked:f.includes(T.id),onChange:()=>L(T.id),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:T.name}),T.suite&&a.jsx(q,{children:T.suite})]},T.id))}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[a.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>k(!v),children:[a.jsx(Xs,{size:14,className:`transition-transform ${v?"rotate-90":""}`}),"Advanced Settings",v&&a.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"(experiment design, variations, execution)"})]}),v&&B&&a.jsx("div",{className:"mt-4",children:a.jsx(Y0,{agentId:e.id,agentName:e.name,agentFramework:e.config.framework,taskSuite:u?void 0:o,taskCount:X,schema:B,onVariationsChange:b,parallel:p,onParallelChange:h,budget:x,onBudgetChange:w,useLlmEval:C,onUseLlmEvalChange:S})})]})]})})}function X0(){const e=zn(),t=Wt(),[n,r]=j.useState(!1),[s,i]=j.useState(null),{data:l=[],isLoading:o}=le({queryKey:["configs"],queryFn:()=>_n.list()}),c=Je({mutationFn:_n.create,onSuccess:()=>{t.invalidateQueries({queryKey:["configs"]}),r(!1)}}),u=Je({mutationFn:_n.delete,onSuccess:()=>t.invalidateQueries({queryKey:["configs"]})}),d=[{key:"name",header:"Name",render:f=>a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:f.name})},{key:"framework",header:"Framework",render:f=>a.jsx(q,{children:f.config.framework||"maf"})},{key:"tools",header:"Tools",render:f=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:Z0(f.config.tools)})},{key:"compaction",header:"Compaction",render:f=>{const m=f.config.compaction;return!m||m.strategy==="none"?a.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"}):m.strategy==="head_tail"?a.jsxs(q,{children:[m.params.head_size,"/",m.params.tail_size]}):a.jsx(q,{children:m.strategy})}},{key:"created",header:"Created",render:f=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(f.created_at).toLocaleDateString()}),sortable:!0,sortValue:f=>new Date(f.created_at).getTime()},{key:"actions",header:"",className:"w-40",render:f=>a.jsxs("div",{className:"flex items-center gap-2",onClick:m=>m.stopPropagation(),children:[a.jsx(Q,{variant:"primary",size:"sm",icon:rs,onClick:()=>i(f),children:"Optimize"}),a.jsx(Q,{variant:"ghost",size:"sm",icon:qc,title:"Delete",onClick:()=>{confirm(`Delete agent "${f.name}"?`)&&u.mutate(f.id)}})]})}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Agents"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Define and optimize your agent configurations."})]}),a.jsx(Q,{variant:"primary",icon:Hc,onClick:()=>r(!0),children:"Create agent"})]}),o?a.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[a.jsx(ha,{size:16,className:"animate-spin"}),"Loading agents..."]}):a.jsx(Xm,{columns:d,data:l,onRowClick:f=>e(`/agents/${f.id}`),searchable:!0,searchPlaceholder:"Search agents",searchFilter:(f,m)=>f.name.toLowerCase().includes(m.toLowerCase())||(f.description||"").toLowerCase().includes(m.toLowerCase()),emptyMessage:"No agents yet. Create your first agent to start optimizing.",emptyIcon:a.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-[var(--bg-tertiary)]",children:a.jsx(Bm,{size:24,className:"text-[var(--text-secondary)]"})})}),a.jsx(e1,{isOpen:n,onClose:()=>r(!1),onSubmit:f=>c.mutate(f),isLoading:c.isPending}),s&&a.jsx(Zm,{agent:s,isOpen:!!s,onClose:()=>i(null)})]})}function Z0(e){return typeof e=="string"?e:Array.isArray(e)?`[${e.length}]`:e&&typeof e=="object"?`[${Object.keys(e).length}]`:"standard"}function e1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){var V,ee,R,T,te,pe,Se;const s=["read_file","write_file","edit_file","bash","grep","think"],[i,l]=j.useState("preset"),[o,c]=j.useState({name:"",description:"",instructions:null,model:null,compaction:{strategy:"none",params:{}},tools:s,framework:"miniagent",llm_config_id:null}),[u,d]=j.useState(!1),[f,m]=j.useState("preset"),[v,k]=j.useState([...s]),[g,b]=j.useState(!1),{data:p}=le({queryKey:["agent-schema"],queryFn:()=>Jm.getAgentSchema()}),{data:h=[]}=le({queryKey:["llm-configs"],queryFn:()=>C0.list()}),{data:x}=le({queryKey:["tools"],queryFn:()=>_0.list()}),w=((V=x==null?void 0:x.tools)==null?void 0:V.map(M=>M.name))??s,C=(x==null?void 0:x.presets)??{},S=Object.keys(C),N=(p==null?void 0:p.frameworks)??{},_=Object.keys(N).length>0?Object.keys(N):Q0,F=o.framework||"miniagent",O=((R=(ee=p==null?void 0:p.frameworks)==null?void 0:ee[F])==null?void 0:R.compaction_strategies)??["none","head_tail"],B=(p==null?void 0:p.compaction_strategies)??{},G=(p==null?void 0:p.agent_presets)??[],re=M=>{const K=M.config,dt=K.compaction;n({name:M.name+"-agent",description:M.description,framework:K.framework||"miniagent",tools:K.tools||"standard",compaction:dt||{strategy:"none",params:{}},instructions:K.instructions||null})},oe=M=>{if(M.preventDefault(),!o.name.trim())return;const K={...o};f==="custom"&&(K.tools=v),n(K)},D=((T=o.compaction)==null?void 0:T.strategy)!=="none",W=((te=o.compaction)==null?void 0:te.strategy)||"none",X=B[W],P=M=>{k(K=>K.includes(M)?K.filter(dt=>dt!==M):[...K,M])},A=M=>{const K=B[M],dt={};if(K!=null&&K.params)for(const[as,is]of Object.entries(K.params))is.default!==void 0&&(dt[as]=is.default);c({...o,compaction:{strategy:M,params:dt}})},L=i==="custom"?a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(Q,{type:"submit",form:"create-agent-form",variant:"primary",disabled:!o.name.trim(),loading:r,children:"Create Agent"})]}):a.jsx("div",{className:"flex justify-end gap-2",children:a.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"})});return a.jsxs(ss,{isOpen:e,onClose:t,title:"Create Agent",footer:L,children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b border-[var(--border)]",children:[a.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${i==="preset"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("preset"),children:"From Preset"}),a.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${i==="custom"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("custom"),children:"Custom"})]}),i==="preset"?a.jsx("div",{className:"space-y-3",children:G.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"Loading presets..."}):G.map(M=>a.jsx("button",{type:"button",className:"w-full text-left p-4 border border-[var(--border)] rounded-lg hover:border-[var(--accent)] hover:bg-[var(--accent)]/5 transition-colors",onClick:()=>re(M),disabled:r,children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("h4",{className:"font-medium",children:M.label}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:M.description}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[M.tags.map(K=>a.jsx(q,{variant:"default",children:K},K)),M.suggested_datasets.length>0&&a.jsxs(q,{variant:"success",children:["datasets: ",M.suggested_datasets.join(", ")]})]})]}),a.jsx(Xs,{size:16,className:"text-[var(--text-secondary)] mt-1 flex-shrink-0"})]})},M.name))}):a.jsxs("form",{id:"create-agent-form",onSubmit:oe,className:"space-y-4",children:[a.jsx(pn,{label:"Name",value:o.name,onChange:M=>c({...o,name:M.target.value}),placeholder:"e.g., my-coding-agent",required:!0}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"LLM Configuration"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.llm_config_id||"",onChange:M=>c({...o,llm_config_id:M.target.value||null}),children:[a.jsx("option",{value:"",children:"Use environment variables"}),h.map(M=>a.jsxs("option",{value:M.id,children:[M.name," (",K0[M.provider],M.model_id?` - ${M.model_id}`:"",")",M.is_default?" (default)":""]},M.id))]}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:h.length===0?"No LLM configs found. Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)":o.llm_config_id?"Uses the selected LLM configuration.":"Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Framework"}),a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.framework||"miniagent",onChange:M=>{const K=M.target.value;c({...o,framework:K,compaction:{strategy:"none",params:{}}})},children:_.map(M=>{var K;return a.jsx("option",{value:M,children:((K=N[M])==null?void 0:K.label)||V0[M]||M},M)})}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((pe=N[F])==null?void 0:pe.description)||(F==="miniagent"?"Lightweight agent with token-aware context management.":F==="langgraph"?"Graph-based workflows with state management.":"Default agent implementation.")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(bi,{label:"Custom instructions",checked:u,onChange:M=>{d(M.target.checked),M.target.checked||c({...o,instructions:null})}}),a.jsx(bi,{label:"Enable compaction",checked:D,onChange:M=>{if(M.target.checked){const K=O.find(dt=>dt!=="none")||"head_tail";A(K)}else c({...o,compaction:{strategy:"none",params:{}}})}})]}),u&&a.jsx("textarea",{className:"w-full h-32 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono resize-y",value:o.instructions||"",onChange:M=>c({...o,instructions:M.target.value||null}),placeholder:"System prompt / instructions for the agent..."}),D&&a.jsxs("div",{className:"space-y-3 p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Compaction Strategy"}),a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:W,onChange:M=>A(M.target.value),children:O.filter(M=>M!=="none").map(M=>{var K;return a.jsx("option",{value:M,children:((K=B[M])==null?void 0:K.label)||M},M)})}),(X==null?void 0:X.description)&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:X.description})]}),(X==null?void 0:X.params)&&Object.keys(X.params).length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-3",children:Object.entries(X.params).map(([M,K])=>{var is;const dt=(is=o.compaction)==null?void 0:is.params[M],as=dt!==void 0?dt:K.default;return a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:M.replace(/_/g," ")}),a.jsx("input",{type:"number",className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof as=="number"?as:Number(as)||0,onChange:ip=>{const tu=parseFloat(ip.target.value);c({...o,compaction:{...o.compaction,params:{...o.compaction.params,[M]:isNaN(tu)?typeof K.default=="number"?K.default:0:tu}}})},min:K.min,max:K.max,step:K.max&&K.max<=1?.1:1}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:K.description})]},M)})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm font-medium",children:"Tools"}),a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"radio",checked:f==="preset",onChange:()=>m("preset"),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:"Preset"})]}),a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"radio",checked:f==="custom",onChange:()=>m("custom"),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:"Custom"})]})]}),f==="preset"?a.jsxs(a.Fragment,{children:[a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof o.tools=="string"?o.tools:"standard",onChange:M=>c({...o,tools:M.target.value}),children:S.map(M=>a.jsx("option",{value:M,children:M},M))}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((Se=C[typeof o.tools=="string"?o.tools:"standard"])==null?void 0:Se.join(", "))??""})]}):a.jsx("div",{className:"grid grid-cols-2 gap-1 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:w.map(M=>a.jsxs("label",{className:"flex items-center gap-2 p-1 text-sm cursor-pointer hover:bg-[var(--bg-tertiary)]",children:[a.jsx("input",{type:"checkbox",checked:v.includes(M),onChange:()=>P(M),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"font-mono text-xs",children:M})]},M))})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[a.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>b(!g),children:[a.jsx(Xs,{size:14,className:`transition-transform ${g?"rotate-90":""}`}),"More options"]}),g&&a.jsx("div",{className:"mt-3",children:a.jsx(pn,{label:"Description (optional)",value:o.description,onChange:M=>c({...o,description:M.target.value}),placeholder:"Brief description of this agent"})})]})]})]})}function ma({items:e}){return a.jsx("nav",{className:"flex items-center gap-1.5 text-sm mb-4",children:e.map((t,n)=>{const r=n===e.length-1;return a.jsxs("span",{className:"flex items-center gap-1.5",children:[n>0&&a.jsx(Xs,{size:14,className:"text-[var(--text-secondary)]"}),t.path&&!r?a.jsx(Tn,{to:t.path,className:"text-[var(--text-secondary)] hover:text-[var(--accent)] transition-colors",children:t.label}):a.jsx("span",{className:r?"text-[var(--text-primary)] font-medium":"text-[var(--text-secondary)]",children:t.label})]},n)})})}function ge({children:e,className:t="",onClick:n,selected:r=!1,selectable:s=!1}){const i="bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",l=s?"cursor-pointer hover:border-[var(--accent-dim)] transition-colors":"",o=r?"border-[var(--accent)]":"";return a.jsx("div",{className:`${i} ${l} ${o} ${t}`,onClick:n,children:e})}function t1(e){const t=[],n=r=>r.type==="trace_span"&&typeof r.data=="object"&&r.data!==null?r.data:"span_id"in r?r:null;if(Array.isArray(e.spans)){for(const r of e.spans)if(typeof r=="object"&&r!==null){const s=n(r);s&&t.push(s)}}else if(e.span_id)t.push(e);else for(const r in e){const s=e[r];if(typeof s=="object"&&s!==null){const i=n(s);if(i)t.push(i);else if(Array.isArray(s)){for(const l of s)if(typeof l=="object"&&l!==null){const o=n(l);o&&t.push(o)}}}}return t}function ep(e){const t=new Map,n=[];for(const s of e)t.set(s.span_id,{span:s,children:[]});for(const s of e){const i=t.get(s.span_id);s.parent_span_id&&t.has(s.parent_span_id)?t.get(s.parent_span_id).children.push(i):n.push(i)}const r=s=>{s.sort((i,l)=>(i.span.start_time||0)-(l.span.start_time||0)),s.forEach(i=>r(i.children))};return r(n),n}function n1(e){return e.includes("Agent")||e.includes("agent")?"bg-[var(--span-llm-bg)] text-[var(--span-llm-text)]":e.includes("chat")||e.includes("Chat")||e.includes("llm")?"bg-[var(--span-tool-bg)] text-[var(--span-tool-text)]":e.includes("tool")||e.includes("execute")||e.includes("bash")?"bg-[var(--span-agent-bg)] text-[var(--span-agent-text)]":"bg-[var(--span-other-bg)] text-[var(--span-other-text)]"}function r1(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(0)}ms`}function eu({node:e,depth:t=0}){var f,m;const[n,r]=j.useState(t<2),[s,i]=j.useState(!1),{span:l}=e,o=e.children.length>0,c=(f=l.attributes)==null?void 0:f["gen_ai.usage.input_tokens"],u=(m=l.attributes)==null?void 0:m["gen_ai.usage.output_tokens"],d=c!==void 0||u!==void 0;return a.jsxs("div",{className:"relative",children:[t>0&&a.jsx("div",{className:"absolute left-0 top-0 bottom-0 border-l-2 border-[var(--border)]",style:{marginLeft:`${(t-1)*16+8}px`}}),a.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-1 hover:bg-[var(--bg-primary)] rounded transition-colors cursor-pointer",style:{paddingLeft:`${t*16}px`},onClick:()=>o?r(!n):i(!s),children:[a.jsx("div",{className:"w-4 h-4 flex items-center justify-center text-[var(--text-secondary)]",children:o?n?"▼":"▶":s?"▼":"▶"}),a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${n1(l.operation_name)}`,children:l.operation_name.replace("ChatAgent.","").replace("invoke_agent ","")}),l.duration_ms!==void 0&&a.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:r1(l.duration_ms)}),d&&a.jsxs("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:[c!==void 0&&a.jsxs("span",{className:"text-blue-400",children:["↑",String(c)]}),c!==void 0&&u!==void 0&&a.jsx("span",{className:"mx-0.5",children:"/"}),u!==void 0&&a.jsxs("span",{className:"text-green-400",children:["↓",String(u)]})]})]}),s&&!o&&a.jsx("div",{className:"ml-4 mt-1 mb-2 p-2 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs",style:{marginLeft:`${t*16+20}px`},children:a.jsxs("div",{className:"space-y-1",children:[l.span_id&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Span ID:"}),a.jsx("span",{className:"font-mono text-xs break-all",children:l.span_id})]}),l.trace_id&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Trace ID:"}),a.jsx("span",{className:"font-mono text-xs break-all",children:l.trace_id})]}),l.status&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Status:"}),a.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs ${l.status==="OK"||l.status==="StatusCode.UNSET"?"bg-[var(--span-pass-bg)] text-[var(--span-pass-text)]":"bg-[var(--span-fail-bg)] text-[var(--span-fail-text)]"}`,children:l.status})]}),Object.keys(l.attributes||{}).length>0&&a.jsxs("div",{className:"mt-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] block mb-1",children:"Attributes:"}),a.jsx("pre",{className:"text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded p-2 overflow-auto max-h-32 whitespace-pre-wrap break-all",children:JSON.stringify(l.attributes,null,2)})]})]})}),o&&n&&a.jsx("div",{children:e.children.map((v,k)=>a.jsx(eu,{node:v,depth:t+1},v.span.span_id||k))})]})}function tp({trace:e}){const[t,n]=j.useState("tree"),r=j.useMemo(()=>t1(e),[e]),s=j.useMemo(()=>ep(r),[r]);return Object.keys(e).length===0?null:a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"font-medium",children:"Trace Data"}),a.jsxs("div",{className:"flex gap-1",children:[a.jsx("button",{onClick:()=>n("tree"),className:`px-2 py-1 text-xs rounded ${t==="tree"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Tree"}),a.jsx("button",{onClick:()=>n("raw"),className:`px-2 py-1 text-xs rounded ${t==="raw"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Raw"})]})]}),t==="tree"?r.length>0?a.jsx("div",{className:"border border-[var(--border)] rounded overflow-hidden",children:a.jsxs("div",{className:"p-2",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs(q,{variant:"default",children:[r.length," spans"]}),a.jsx("span",{children:"•"}),a.jsx("span",{children:"Click to expand details"})]}),s.map((i,l)=>a.jsx(eu,{node:i,depth:0},i.span.span_id||l))]})}):a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No structured spans found. View raw data below."}):a.jsx("pre",{className:"text-xs bg-[var(--bg-primary)] p-3 overflow-x-auto border border-[var(--border)] max-h-96 whitespace-pre-wrap",children:JSON.stringify(e,null,2)})]})}function s1({spans:e,isLive:t=!1}){const n=j.useRef(null),r=j.useMemo(()=>ep(e),[e]);return j.useEffect(()=>{n.current&&t&&n.current.scrollTo({top:n.current.scrollHeight,behavior:"smooth"})},[e.length,t]),a.jsxs("div",{className:"border border-[var(--border)] rounded overflow-hidden h-full flex flex-col",children:[a.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-[var(--border)] bg-[var(--bg-secondary)]",children:[a.jsxs(q,{variant:"default",children:[e.length," spans"]}),t&&a.jsx("span",{className:"animate-pulse",children:a.jsx(q,{variant:"info",children:"Live"})})]}),a.jsx("div",{ref:n,className:"flex-1 overflow-auto p-2",children:r.length>0?r.map((s,i)=>a.jsx(eu,{node:s,depth:0},s.span.span_id||i)):a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:t?"Waiting for spans...":"No spans recorded"})})]})}function np({agent:e}){const[t,n]=j.useState(""),[r,s]=j.useState(null),[i,l]=j.useState("idle"),[o,c]=j.useState(null),[u,d]=j.useState(""),[f,m]=j.useState([]),[v,k]=j.useState(null),[g,b]=j.useState(null),[p,h]=j.useState([]),[x,w]=j.useState(!1),C=j.useRef(null),{data:S=[]}=le({queryKey:["tasks"],queryFn:()=>gt.list()});j.useEffect(()=>{C.current&&i==="running"&&(C.current.scrollTop=C.current.scrollHeight)},[u,i]);const N=D=>{if(s(D),D){const W=S.find(X=>X.id===D);W&&n(W.prompt)}},_=async()=>{if(t.trim()){l("running"),d(""),m([]),k(null),b(null),h([]);try{const D=await Os.create({agent_id:e.id,prompt:t.trim(),task_id:r||void 0});c(D.id);for await(const W of Os.start(D.id))F(W)}catch(D){b(D instanceof Error?D.message:"Test failed"),l("failed")}}},F=D=>{switch(D.event){case"started":break;case"execution":D.execution_event==="text_delta"&&D.content?d(W=>W+D.content):D.execution_event==="tool_call_start"&&D.tool_name?h(W=>[...W,{name:D.tool_name}]):D.execution_event==="tool_result"&&D.content&&h(W=>{if(W.length>0){const X=[...W];return X[X.length-1]={...X[X.length-1],content:D.content},X}return W});break;case"span":if(D.span){const W=D.span;if(W.data){const X={span_id:W.data.span_id||"",trace_id:W.data.trace_id||"",parent_span_id:W.data.parent_span_id||null,operation_name:W.data.operation_name||"",start_time:W.timestamp?new Date(W.timestamp).getTime():Date.now(),end_time:Date.now(),duration_ms:W.data.duration_ms||0,status:W.data.status||"OK",attributes:W.data.attributes||{}};m(P=>[...P,X])}}break;case"complete":l("completed"),D.result&&k(D.result);break;case"error":b(D.message),l("failed");break}},O=async()=>{if(o)try{await Os.cancel(o)}catch{}l("idle")},B=()=>{l("idle"),c(null),d(""),m([]),k(null),b(null),h([])},G=i==="running",re=i==="completed"||i==="failed",oe=D=>{D.preventDefault(),re?(B(),setTimeout(()=>_(),0)):_()};return a.jsxs("div",{className:"h-full flex flex-col border border-[var(--border)] rounded-lg overflow-hidden bg-[var(--bg-primary)]",children:[(G||re)&&a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border)] bg-[var(--bg-secondary)] flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[G&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"animate-pulse",children:a.jsx(q,{variant:"info",children:"Running"})}),a.jsx(Q,{variant:"ghost",size:"sm",icon:Ld,onClick:O,children:"Cancel"})]}),i==="completed"&&a.jsx(q,{variant:"success",children:"Completed"}),i==="failed"&&a.jsx(q,{variant:"error",children:"Failed"})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[v&&a.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Im,{size:12}),v.duration_seconds.toFixed(2),"s"]}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Mg,{size:12}),v.tokens_total," tokens"]}),v.passed!==null&&(v.passed?a.jsx(Fm,{size:14,className:"text-[var(--success)]"}):a.jsx(Xg,{size:14,className:"text-[var(--error)]"}))]}),f.length>0&&a.jsxs(Q,{variant:x?"primary":"secondary",size:"sm",icon:Sg,onClick:()=>w(!x),children:["Traces (",f.length,")"]}),re&&o&&a.jsx(Tn,{to:`/tests/${o}`,children:a.jsx(Q,{variant:"secondary",size:"sm",icon:Am,children:"Details"})})]})]}),a.jsxs("div",{className:"flex-1 min-h-0 flex",children:[a.jsx("div",{ref:C,className:`flex-1 overflow-auto p-4 ${x?"border-r border-[var(--border)]":""}`,children:!G&&!re?a.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center",children:[a.jsx("div",{className:"text-lg font-medium mb-1",children:e.name}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] max-w-sm",children:"Send a message to test this agent, or select a task from the dropdown below."})]}):a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"flex justify-end",children:a.jsx("div",{className:"max-w-[80%] px-3 py-2 bg-[var(--accent-dim)] text-[var(--text-primary)] rounded-lg text-sm",children:t})}),(u||G)&&a.jsx("div",{className:"px-3 py-2 text-sm whitespace-pre-wrap font-mono bg-[var(--bg-secondary)] rounded-lg border border-[var(--border)]",children:u||a.jsx("span",{className:"text-[var(--text-secondary)] animate-pulse",children:"Thinking..."})}),p.length>0&&a.jsx("div",{className:"space-y-1.5",children:p.map((D,W)=>a.jsxs("div",{className:"p-2 bg-[var(--badge-info-bg)] border border-[var(--badge-info-border)] rounded-md text-xs",children:[a.jsx(q,{variant:"info",children:D.name}),D.content&&a.jsxs("div",{className:"mt-1 text-[var(--text-secondary)] truncate max-w-full font-mono",children:[D.content.substring(0,200),D.content.length>200&&"..."]})]},W))}),g&&a.jsx("div",{className:"p-3 bg-[var(--badge-error-bg)] border border-[var(--badge-error-border)] rounded-md text-sm text-[var(--badge-error-text)]",children:g})]})}),x&&a.jsx("div",{className:"w-[350px] flex-shrink-0 overflow-auto",children:a.jsx(s1,{spans:f,isLive:G})})]}),a.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] bg-[var(--bg-secondary)]",children:[a.jsx("div",{className:"px-4 pt-2",children:a.jsxs("select",{value:r||"",onChange:D=>N(D.target.value||null),className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs text-[var(--text-secondary)]",disabled:G,children:[a.jsx("option",{value:"",children:"Custom prompt..."}),S.map(D=>a.jsx("option",{value:D.id,children:D.name},D.id))]})}),a.jsxs("form",{onSubmit:oe,className:"p-3 flex gap-2",children:[a.jsx("textarea",{value:t,onChange:D=>n(D.target.value),placeholder:"Message the agent...",disabled:G,rows:1,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm resize-none min-h-[40px] max-h-[120px] focus:outline-none focus:border-[var(--accent)]",onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),oe(D))}}),a.jsx(Q,{type:"submit",variant:"primary",icon:G?Ld:Zs,disabled:G?!1:!t.trim(),onClick:G?O:void 0,children:G?"Stop":re?"New Test":"Run"})]})]})]})}function a1(){const{agentId:e}=fa(),t=zn(),n=Wt(),[r,s]=j.useState("overview"),[i,l]=j.useState(!1),{data:o,isLoading:c}=le({queryKey:["configs",e],queryFn:()=>_n.get(e),enabled:!!e}),{data:u=[]}=le({queryKey:["tests",{agent_id:e}],queryFn:()=>Os.list({agent_id:e}),enabled:!!e}),{data:d=[]}=le({queryKey:["jobs"],queryFn:()=>Ot.list()}),f=Je({mutationFn:v=>_n.delete(v),onSuccess:()=>{n.invalidateQueries({queryKey:["configs"]}),t("/agents")}}),m=d.filter(v=>v.candidate_ids.includes(e||""));return c?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):o?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsxs("div",{className:"mb-4 flex-shrink-0",children:[a.jsx(ma,{items:[{label:"Agents",path:"/agents"},{label:o.name}]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:o.name}),o.is_auto_generated&&a.jsx(q,{variant:"info",children:"Auto-generated"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Q,{variant:"primary",icon:rs,size:"sm",onClick:()=>l(!0),children:"Optimize"}),a.jsx(Q,{variant:"secondary",icon:qc,size:"sm",onClick:()=>{confirm(`Delete agent "${o.name}"?`)&&f.mutate(o.id)},children:"Delete"})]})]}),o.description&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:o.description})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsxs("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:[a.jsxs("div",{className:"flex gap-1 mb-4 border-b border-[var(--border)] flex-shrink-0",children:[a.jsx(Nl,{active:r==="overview",onClick:()=>s("overview"),icon:a.jsx(Bm,{size:14}),children:"Overview"}),a.jsx(Nl,{active:r==="evaluate",onClick:()=>s("evaluate"),icon:a.jsx(Zs,{size:14}),children:"Evaluate"}),a.jsx(Nl,{active:r==="history",onClick:()=>s("history"),icon:a.jsx(Ag,{size:14}),badge:u.length,children:"History"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r==="overview"&&a.jsx(i1,{agent:o,recentTests:u,jobs:m}),r==="evaluate"&&a.jsx(l1,{agent:o,jobs:m}),r==="history"&&a.jsx(o1,{tests:u})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[a.jsx(Um,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),a.jsx("div",{className:"flex-1 min-h-0",children:a.jsx(np,{agent:o})})]})]}),i&&a.jsx(Zm,{agent:o,isOpen:i,onClose:()=>l(!1)})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Agent not found"})}function Nl({active:e,onClick:t,icon:n,badge:r,children:s}){return a.jsxs("button",{onClick:t,className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors ${e?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[n,s,r!==void 0&&r>0&&a.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs bg-[var(--bg-tertiary)] rounded",children:r})]})}function i1({agent:e,recentTests:t,jobs:n}){var i,l;const r=e.config,s=()=>{const o=r.tools;return typeof o=="string"?o:Array.isArray(o)?o.join(", "):o&&typeof o=="object"?Object.keys(o).join(", "):"standard"};return a.jsxs("div",{className:"space-y-4",children:[a.jsx(ur,{title:"Model",children:a.jsx("div",{className:"font-mono text-sm",children:r.model||"default"})}),a.jsx(ur,{title:"Instructions",defaultCollapsed:!r.instructions,children:r.instructions?a.jsx("pre",{className:"p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs whitespace-pre-wrap max-h-40 overflow-auto font-mono",children:r.instructions}):a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No instructions set"})}),a.jsx(ur,{title:"Tools",children:a.jsx("div",{className:"font-mono text-sm",children:s()})}),a.jsx(ur,{title:"Compaction",children:a.jsx("div",{className:"font-mono text-sm",children:!r.compaction||r.compaction.strategy==="none"?"disabled":`${r.compaction.strategy} (${((i=r.compaction.params)==null?void 0:i.head_size)||0}/${((l=r.compaction.params)==null?void 0:l.tail_size)||0})`})}),t.length>0&&a.jsx(ur,{title:`Recent Tests (${t.length})`,children:a.jsx("div",{className:"space-y-1.5",children:t.slice(0,3).map(o=>a.jsxs(Tn,{to:`/tests/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx(rp,{status:o.status}),a.jsxs("span",{className:"truncate",children:[o.prompt.slice(0,40),"..."]})]}),a.jsxs("span",{className:"text-[var(--text-secondary)] flex-shrink-0 ml-2",children:[o.duration_seconds.toFixed(1),"s"]})]},o.id))})}),n.length>0&&a.jsx(ur,{title:`Experiments (${n.length})`,children:a.jsx("div",{className:"space-y-1.5",children:n.slice(0,3).map(o=>a.jsxs(Tn,{to:`/jobs/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(q,{variant:o.status==="completed"?"success":o.status==="running"?"info":"default",children:o.status}),a.jsx("span",{children:o.name})]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(o.created_at).toLocaleDateString()})]},o.id))})})]})}function ur({title:e,children:t,defaultCollapsed:n=!1}){const[r,s]=j.useState(n);return a.jsxs("div",{className:"border-b border-[var(--border)] pb-3",children:[a.jsxs("button",{onClick:()=>s(!r),className:"flex items-center justify-between w-full text-left py-1 hover:text-[var(--accent)] transition-colors",children:[a.jsx("span",{className:"text-sm font-medium",children:e}),a.jsx("span",{className:"text-[var(--text-secondary)] text-xs",children:r?"▶":"▼"})]}),!r&&a.jsx("div",{className:"mt-2",children:t})]})}function l1({agent:e,jobs:t}){const n=zn(),r=Wt(),[s,i]=j.useState("quick"),[l,o]=j.useState(!1),{data:c=[]}=le({queryKey:["suites"],queryFn:()=>gt.listSuites()}),u=Je({mutationFn:P0.start,onSuccess:f=>{r.invalidateQueries({queryKey:["jobs"]}),o(!1),n(`/jobs/${f.id}`)},onError:()=>{o(!1)}}),d=()=>{o(!0),u.mutate({agent_id:e.id,suite_name:s,use_llm_eval:!0,parallel:4})};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:"Run this agent on a task suite to measure quality and cost."}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm",value:s,onChange:f=>i(f.target.value),disabled:l,children:c.map(f=>a.jsxs("option",{value:f.name,children:[f.name.charAt(0).toUpperCase()+f.name.slice(1)," (",f.task_count," tasks)"]},f.name))}),a.jsx(Q,{variant:"primary",icon:l?ha:Zs,onClick:d,disabled:l,loading:l,className:"w-full",children:"Evaluate"})]})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h4",{className:"text-sm font-medium",children:"Optimization Jobs"}),a.jsx(Q,{variant:"secondary",size:"sm",icon:rs,onClick:()=>n("/agents",{state:{optimizeAgent:e}}),children:"New Job"})]}),t.length===0?a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No optimization jobs yet."}):a.jsx("div",{className:"space-y-1.5",children:t.slice(0,5).map(f=>a.jsxs(Tn,{to:`/jobs/${f.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(q,{variant:f.status==="completed"?"success":f.status==="running"?"info":"default",children:f.status}),a.jsx("span",{children:f.name})]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(f.created_at).toLocaleDateString()})]},f.id))})]})]})}function o1({tests:e}){return e.length===0?a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No test history yet. Use the playground on the right to run a test."}):a.jsx("div",{className:"space-y-2",children:e.map(t=>a.jsxs(Tn,{to:`/tests/${t.id}`,className:"flex items-center justify-between p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(rp,{status:t.status}),t.score!==null&&a.jsxs("span",{className:`text-sm font-medium ${t.passed?"text-[var(--success)]":"text-[var(--error)]"}`,children:[(t.score*100).toFixed(0),"%"]})]}),a.jsx("p",{className:"text-sm truncate",children:t.prompt})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1 ml-4",children:[a.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:new Date(t.created_at).toLocaleString()}),a.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:[t.duration_seconds.toFixed(1),"s"]}),a.jsxs("span",{children:[t.tokens_total," tokens"]})]})]})]},t.id))})}function rp({status:e}){const t={completed:"success",failed:"error",running:"info",cancelled:"warning",pending:"default"};return a.jsx(q,{variant:t[e]||"default",children:e})}function c1(){const e=Wt(),[t,n]=j.useState(!1),[r,s]=j.useState(!1),[i,l]=j.useState(null),[o,c]=j.useState(new Set),u=p=>{c(h=>{const x=new Set(h);return x.has(p)?x.delete(p):x.add(p),x})},{data:d=[],isLoading:f}=le({queryKey:["tasks"],queryFn:()=>gt.list()}),m=Je({mutationFn:gt.create,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),n(!1)}}),v=Je({mutationFn:gt.importSuite,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),s(!1)}}),k=Je({mutationFn:gt.delete,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),l(null)}}),g=d.reduce((p,h)=>{const x=h.suite||"custom";return p[x]||(p[x]=[]),p[x].push(h),p},{}),b=Object.keys(g).sort((p,h)=>p==="custom"?-1:h==="custom"?1:p.localeCompare(h));return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Datasets"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Task datasets for evaluating agent configurations."})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Q,{variant:"secondary",onClick:()=>s(!0),children:"Import Suite"}),a.jsx(Q,{variant:"primary",onClick:()=>n(!0),children:"+ New Task"})]})]}),f?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):d.length===0?a.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:"No tasks yet. Create one or import a built-in suite."}):a.jsx("div",{className:"space-y-4",children:b.map(p=>{const h=g[p],x=!o.has(p);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>u(p),className:"flex items-center gap-2 py-2 hover:text-[var(--accent)] transition-colors",children:[x?a.jsx(Og,{size:16,className:"text-[var(--text-secondary)]"}):a.jsx(Xs,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium uppercase tracking-wide",children:p==="custom"?"Custom Tasks":`${p} Suite`}),a.jsx(q,{variant:p==="custom"?"default":"info",children:h.length})]}),x&&a.jsx("div",{className:"mt-2 border border-[var(--border)] rounded-lg overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:[a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Name"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Category"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Prompt"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Criteria"})]})}),a.jsx("tbody",{children:h.map(w=>a.jsxs("tr",{onClick:()=>l(w),className:"border-b border-[var(--border)] last:border-b-0 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors",children:[a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:w.name})}),a.jsx("td",{className:"px-4 py-3",children:w.category&&w.category!=="default"?a.jsx(q,{variant:"default",children:w.category}):a.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"})}),a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-[var(--text-secondary)] line-clamp-1 max-w-md",children:w.prompt})}),a.jsx("td",{className:"px-4 py-3 text-[var(--text-secondary)]",children:w.criteria.length>0?w.criteria.length:"--"})]},w.id))})]})})]},p)})}),a.jsx(u1,{task:i,onClose:()=>l(null),onDelete:p=>{confirm("Delete this task?")&&k.mutate(p)}}),a.jsx(d1,{isOpen:t,onClose:()=>n(!1),onSubmit:p=>m.mutate(p),isLoading:m.isPending}),a.jsx(f1,{isOpen:r,onClose:()=>s(!1),onSubmit:p=>v.mutate(p),isLoading:v.isPending})]})}function u1({task:e,onClose:t,onDelete:n}){const[r,s]=j.useState("prompt");if(!e)return null;const i=a.jsxs("div",{className:"flex justify-between",children:[a.jsx(Q,{variant:"ghost",onClick:()=>n(e.id),className:"text-red-500 hover:text-red-600",children:"Delete Task"}),a.jsx(Q,{variant:"secondary",onClick:t,children:"Close"})]});return a.jsx(ss,{isOpen:!!e,onClose:t,title:e.name,size:"lg",footer:i,children:a.jsxs("div",{className:"space-y-4",children:[e.category&&e.category!=="default"&&a.jsx("div",{children:a.jsx(q,{variant:"default",children:e.category})}),a.jsxs("div",{className:"flex gap-1 border-b border-[var(--border)]",children:[a.jsx("button",{onClick:()=>s("prompt"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="prompt"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Prompt"}),a.jsxs("button",{onClick:()=>s("criteria"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="criteria"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:["Eval Criteria (",e.criteria.length,")"]})]}),r==="prompt"&&a.jsx("div",{className:"p-4 bg-[var(--bg-tertiary)] rounded text-sm whitespace-pre-wrap min-h-[200px]",children:e.prompt}),r==="criteria"&&a.jsx("div",{className:"space-y-2 min-h-[200px]",children:e.criteria.length===0?a.jsx("div",{className:"text-[var(--text-secondary)] text-sm p-4",children:"No evaluation criteria defined for this task."}):e.criteria.map(l=>a.jsxs("div",{className:"p-3 bg-[var(--bg-tertiary)] rounded",children:[a.jsx("div",{className:"font-medium text-sm",children:l.name}),l.instruction&&a.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1",children:l.instruction})]},l.name))})]})})}function d1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,i]=j.useState({name:"",prompt:"",criteria:[],category:"default"}),l=()=>{i({...s,criteria:[...s.criteria,{name:"",instruction:"",weight:1}]})},o=(d,f)=>{const m=[...s.criteria];m[d]={...m[d],...f},i({...s,criteria:m})},c=d=>{i({...s,criteria:s.criteria.filter((f,m)=>m!==d)})},u=d=>{d.preventDefault(),!(!s.name.trim()||!s.prompt.trim())&&n({...s,criteria:s.criteria.filter(f=>f.name.trim()&&f.instruction.trim())})};return a.jsx(ss,{isOpen:e,onClose:t,title:"Create Task",children:a.jsxs("form",{onSubmit:u,className:"space-y-4",children:[a.jsx(pn,{label:"Name",value:s.name,onChange:d=>i({...s,name:d.target.value}),placeholder:"e.g., fizzbuzz",required:!0}),a.jsx(q0,{label:"Prompt",value:s.prompt,onChange:d=>i({...s,prompt:d.target.value}),placeholder:"The task description for the agent...",required:!0}),a.jsx(pn,{label:"Category",value:s.category,onChange:d=>i({...s,category:d.target.value}),placeholder:"e.g., coding, research"}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Evaluation Criteria"}),a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"+ Add"})]}),a.jsx("div",{className:"space-y-2",children:s.criteria.map((d,f)=>a.jsxs("div",{className:"flex gap-2 items-start",children:[a.jsx(pn,{value:d.name,onChange:m=>o(f,{name:m.target.value}),placeholder:"Name",className:"w-32"}),a.jsx(pn,{value:d.instruction,onChange:m=>o(f,{instruction:m.target.value}),placeholder:"Instruction",className:"flex-1"}),a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(f),children:"×"})]},f))})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[a.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(Q,{type:"submit",variant:"primary",disabled:r||!s.name.trim()||!s.prompt.trim(),children:r?"Creating...":"Create"})]})]})})}function f1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,i]=j.useState(""),{data:l=[],isLoading:o}=le({queryKey:["suites"],queryFn:()=>gt.listSuites(),enabled:e});return j.useEffect(()=>{l.length>0&&!s&&i(l[0].name)},[l,s]),a.jsx(ss,{isOpen:e,onClose:t,title:"Import Task Suite",children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Import a built-in task suite for evaluation."}),o?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading suites..."}):l.length===0?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"No suites available."}):a.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:l.map(c=>a.jsxs("label",{className:`flex items-center gap-3 p-3 border cursor-pointer ${s===c.name?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[a.jsx("input",{type:"radio",name:"suite",value:c.name,checked:s===c.name,onChange:()=>i(c.name),className:"accent-[var(--accent)]"}),a.jsxs("span",{className:"capitalize",children:[c.name.replace(/_/g," ")," (",c.task_count," tasks) - ",c.description]})]},c.name))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[a.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(Q,{variant:"primary",onClick:()=>n(s),disabled:r||!s,children:r?"Importing...":"Import"})]})]})})}function h1(){const e=zn(),t=Wt(),[n,r]=j.useState(!1),s=Xc(),{data:i=[],isLoading:l}=le({queryKey:["jobs",n],queryFn:()=>Ot.list({include_public:n}),refetchInterval:5e3}),o=Je({mutationFn:Ot.delete,onSuccess:()=>t.invalidateQueries({queryKey:["jobs"]})}),c={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"},u=[{key:"name",header:"Name",render:d=>a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:d.name||`Job ${d.id.slice(0,8)}`}),d.is_public&&a.jsx(Kc,{className:"w-3 h-3 ml-2 inline text-[var(--text-secondary)]"})]})},{key:"status",header:"Status",render:d=>a.jsx(q,{variant:c[d.status]||"default",children:d.status})},{key:"candidates",header:"Candidates",render:d=>a.jsx("span",{children:d.candidate_ids.length})},{key:"tasks",header:"Tasks",render:d=>a.jsx("span",{children:d.task_ids.length})},{key:"runs",header:"Runs",render:d=>a.jsxs("span",{children:[d.completed_experiments,"/",d.total_experiments]})},{key:"created",header:"Created",render:d=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(d.created_at).toLocaleDateString()}),sortable:!0,sortValue:d=>new Date(d.created_at).getTime()},{key:"actions",header:"",className:"w-12",render:d=>!d.user_id||d.user_id==="anonymous"||s&&d.created_by_name===s?a.jsx("div",{onClick:m=>m.stopPropagation(),children:a.jsx(Q,{variant:"ghost",size:"sm",icon:qc,title:"Delete",disabled:d.status==="running",onClick:()=>{confirm("Delete this job?")&&o.mutate(d.id)}})}):null}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Experiments"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"View and manage optimization experiments. Start new experiments from the Agents page."})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(bi,{label:"Show public",checked:n,onChange:d=>r(d.target.checked)}),a.jsx(Q,{variant:"secondary",onClick:()=>e("/agents"),children:"Go to Agents"})]})]}),l?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):a.jsx(Xm,{columns:u,data:i,onRowClick:d=>e(`/jobs/${d.id}`),searchable:!0,searchPlaceholder:"Search experiments",searchFilter:(d,f)=>(d.name||"").toLowerCase().includes(f.toLowerCase())||d.id.toLowerCase().includes(f.toLowerCase()),emptyMessage:"No experiments yet. Go to Agents page to start an optimization."})]})}function m1(e,t=!0){return Math.abs(e)<10?"text-[var(--text-secondary)]":(t?e<0:e>0)?"text-green-400":"text-red-400"}function p1(e){return`${e>0?"+":""}${e.toFixed(1)}%`}function sp(e,t){return t===0?0:(e-t)/t*100}function xs({label:e,values:t,baselineIndex:n,formatter:r,isLowerBetter:s=!0}){const i=t[n];return a.jsxs("tr",{className:"border-b border-[var(--border)] last:border-0",children:[a.jsx("td",{className:"py-2 pr-4 text-[var(--text-secondary)] text-sm",children:e}),t.map((l,o)=>{const c=sp(l,i),u=o===n;return a.jsxs("td",{className:"py-2 px-4 text-right",children:[a.jsx("div",{className:"font-mono",children:r(l)}),!u&&a.jsx("div",{className:`text-xs ${m1(c,s)}`,children:p1(c)}),u&&a.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"(baseline)"})]},o)})]})}function x1({runs:e,baselineRunId:t}){const n=j.useMemo(()=>{if(t){const i=e.findIndex(l=>l.id===t);if(i>=0)return i}return 0},[e,t]);if(e.length<2)return null;const r=Math.min(...e.map(i=>i.tokens_total)),s=Math.max(...e.map(i=>i.score));return a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-4",children:"Candidate Comparison"}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-[var(--border)]",children:[a.jsx("th",{className:"pb-2 pr-4 text-left text-[var(--text-secondary)] font-medium",children:"Metric"}),e.map((i,l)=>a.jsx("th",{className:"pb-2 px-4 text-right",children:a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsx("span",{className:"font-medium",children:i.candidate_name}),i.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"}),l===n&&a.jsx(q,{variant:"info",children:"Base"})]})},i.id))]})}),a.jsxs("tbody",{children:[a.jsx(xs,{label:"Total Tokens",values:e.map(i=>i.tokens_total),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(xs,{label:"Input Tokens",values:e.map(i=>i.tokens_input),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(xs,{label:"Output Tokens",values:e.map(i=>i.tokens_output),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(xs,{label:"Duration",values:e.map(i=>i.duration_seconds),baselineIndex:n,formatter:i=>`${i.toFixed(1)}s`,isLowerBetter:!0}),a.jsx(xs,{label:"Score",values:e.map(i=>i.score*100),baselineIndex:n,formatter:i=>`${i.toFixed(1)}%`,isLowerBetter:!1})]})]})}),a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[a.jsx("h4",{className:"text-sm font-medium mb-2 text-[var(--text-secondary)]",children:"Key Insights"}),a.jsxs("ul",{className:"text-sm space-y-1 text-[var(--text-secondary)]",children:[e.map(i=>{const l=sp(i.tokens_total,e[n].tokens_total);return i.tokens_total===r&&l<-5?a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-green-400",children:"✓"}),a.jsxs("span",{children:[a.jsx("strong",{children:i.candidate_name})," uses ",Math.abs(l).toFixed(0),"% fewer tokens"]})]},`token-${i.id}`):null}),e.map(i=>i.score===s&&i.passed?a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-green-400",children:"✓"}),a.jsxs("span",{children:[a.jsx("strong",{children:i.candidate_name})," achieved highest score (",(i.score*100).toFixed(0),"%)"]})]},`score-${i.id}`):null),e.filter(i=>i.is_pareto).length>0&&a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-purple-400",children:"★"}),a.jsxs("span",{children:["Optimal candidates (best tradeoff):"," ",e.filter(i=>i.is_pareto).map(i=>i.candidate_name).join(", ")]})]})]})]}),a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[a.jsx("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:"Token Efficiency"}),a.jsx("div",{className:"space-y-2",children:e.map(i=>{const l=i.tokens_total/e[n].tokens_total*100,o=i.tokens_total<=r;return a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-24 text-sm truncate",title:i.candidate_name,children:i.candidate_name}),a.jsx("div",{className:"flex-1 h-6 bg-[var(--bg-primary)] rounded overflow-hidden",children:a.jsx("div",{className:`h-full transition-all duration-300 ${o?"bg-green-500":"bg-blue-500"}`,style:{width:`${Math.min(l,100)}%`}})}),a.jsx("div",{className:"w-20 text-right font-mono text-sm",children:i.tokens_total.toLocaleString()})]},i.id)})})]})]})}function v1({summaries:e,height:t=350}){const n=j.useRef(null),[r,s]=j.useState(600),[i,l]=j.useState("tokens"),[o,c]=j.useState(null),[u,d]=j.useState({x:0,y:0});j.useEffect(()=>{const S=()=>{n.current&&s(n.current.clientWidth)};return S(),window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]);const f={top:30,right:30,bottom:50,left:60},m=r-f.left-f.right,v=t-f.top-f.bottom,k=S=>i==="tokens"?S.avg_tokens:S.avg_duration,{xScale:g,yScale:b,xTicks:p,yTicks:h,paretoLine:x}=j.useMemo(()=>{if(e.length===0||m<=0)return{xScale:()=>0,yScale:()=>0,xTicks:[],yTicks:[],paretoLine:[]};const S=e.map(k),N=e.map(P=>P.avg_score),_=Math.min(...S)*.9,F=Math.max(...S)*1.1,O=Math.min(...N,.5),B=Math.min(Math.max(...N)*1.05,1),G=P=>(P-_)/(F-_)*m,re=P=>v-(P-O)/(B-O)*v,oe=Array.from({length:5},(P,A)=>_+A/4*(F-_)),D=Array.from({length:5},(P,A)=>O+A/4*(B-O)),X=e.filter(P=>P.is_pareto).sort((P,A)=>k(P)-k(A)).map(P=>({x:G(k(P)),y:re(P.avg_score)}));return{xScale:G,yScale:re,xTicks:oe,yTicks:D,paretoLine:X}},[e,m,v,i]);if(e.length===0)return a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No data to display"});const w=S=>i==="tokens"?S>=1e6?`${(S/1e6).toFixed(1)}M`:S>=1e3?`${(S/1e3).toFixed(0)}K`:S.toFixed(0):`${S.toFixed(1)}s`,C=(S,N)=>{var F;const _=(F=n.current)==null?void 0:F.getBoundingClientRect();_&&d({x:N.clientX-_.left,y:N.clientY-_.top}),c(S)};return a.jsxs("div",{ref:n,className:"w-full relative",children:[a.jsx("div",{className:"flex justify-end mb-2",children:a.jsxs("div",{className:"inline-flex rounded border border-[var(--border)] text-xs",children:[a.jsx("button",{className:`px-3 py-1 ${i==="tokens"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("tokens"),children:"Tokens"}),a.jsx("button",{className:`px-3 py-1 ${i==="duration"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("duration"),children:"Latency"})]})}),a.jsx("svg",{width:r,height:t,className:"font-mono text-xs",children:a.jsxs("g",{transform:`translate(${f.left}, ${f.top})`,children:[p.map((S,N)=>a.jsx("line",{x1:g(S),y1:0,x2:g(S),y2:v,stroke:"var(--border)",strokeDasharray:"2,2"},`x-grid-${N}`)),h.map((S,N)=>a.jsx("line",{x1:0,y1:b(S),x2:m,y2:b(S),stroke:"var(--border)",strokeDasharray:"2,2"},`y-grid-${N}`)),x.length>1&&a.jsx("polyline",{points:x.map(S=>`${S.x},${S.y}`).join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.slice().sort((S,N)=>(S.is_pareto?1:0)-(N.is_pareto?1:0)).map(S=>{const N=g(k(S)),_=b(S.avg_score),F=S.is_pareto,O=(o==null?void 0:o.candidate_name)===S.candidate_name;return a.jsxs("g",{onMouseEnter:B=>C(S,B),onMouseLeave:()=>c(null),children:[a.jsx("circle",{cx:N,cy:_,r:O?10:F?8:6,fill:F?"var(--accent)":"transparent",stroke:O?"var(--text-primary)":F?"var(--accent)":"var(--text-secondary)",strokeWidth:O?3:2,className:"cursor-pointer transition-all"}),F&&!O&&a.jsx("text",{x:N,y:_-12,textAnchor:"middle",fill:"var(--text-primary)",fontSize:10,className:"pointer-events-none",children:S.candidate_name.replace(/^baseline_/,"").slice(0,15)})]},S.candidate_name)}),a.jsx("line",{x1:0,y1:v,x2:m,y2:v,stroke:"var(--text-secondary)"}),p.map((S,N)=>a.jsxs("g",{transform:`translate(${g(S)}, ${v})`,children:[a.jsx("line",{y2:5,stroke:"var(--text-secondary)"}),a.jsx("text",{y:20,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:10,children:w(S)})]},`x-tick-${N}`)),a.jsx("text",{x:m/2,y:v+40,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:i==="tokens"?"Tokens (cost)":"Duration (latency)"}),a.jsx("line",{x1:0,y1:0,x2:0,y2:v,stroke:"var(--text-secondary)"}),h.map((S,N)=>a.jsxs("g",{transform:`translate(0, ${b(S)})`,children:[a.jsx("line",{x2:-5,stroke:"var(--text-secondary)"}),a.jsxs("text",{x:-10,textAnchor:"end",dominantBaseline:"middle",fill:"var(--text-secondary)",fontSize:10,children:[(S*100).toFixed(0),"%"]})]},`y-tick-${N}`)),a.jsx("text",{transform:`translate(-45, ${v/2}) rotate(-90)`,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:"Score (quality)"})]})}),o&&a.jsxs("div",{className:"absolute z-10 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg shadow-lg p-3 text-sm pointer-events-none",style:{left:Math.min(u.x+15,r-200),top:u.y-10,maxWidth:220},children:[a.jsx("div",{className:"font-medium text-[var(--text-primary)] truncate mb-2",children:o.candidate_name.replace(/^baseline_/,"")}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Score:"}),a.jsxs("span",{className:"text-right font-medium",children:[(o.avg_score*100).toFixed(1),"%"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tokens:"}),a.jsxs("span",{className:"text-right",children:[(o.avg_tokens/1e3).toFixed(1),"K"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Duration:"}),a.jsxs("span",{className:"text-right",children:[o.avg_duration.toFixed(1),"s"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Pass rate:"}),a.jsxs("span",{className:"text-right",children:[o.passed_runs,"/",o.total_runs]})]}),o.is_pareto&&a.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)] text-xs text-[var(--accent)]",children:"Optimal (best tradeoff)"})]})]})}function y1(e=2e3){const[t,n]=j.useState(!1),[r,s]=j.useState(null),i=j.useCallback(async o=>{try{return await navigator.clipboard.writeText(o),n(!0),s(null),setTimeout(()=>n(!1),e),!0}catch{return s("Failed to copy to clipboard"),n(!1),!1}},[e]),l=j.useCallback(()=>{n(!1),s(null)},[]);return{copy:i,copied:t,error:r,reset:l}}function g1({isOpen:e,onClose:t,title:n,itemId:r,itemType:s,isPublic:i,createdByName:l,onTogglePublic:o}){const[c,u]=j.useState(!1),{copy:d,copied:f}=y1(),m=`${window.location.origin}/${s}s/${r}`,v=async()=>{u(!0);try{await o(!i)}finally{u(!1)}},k=()=>{d(m)};return a.jsx(ss,{isOpen:e,onClose:t,title:n,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between p-3 bg-[var(--bg-tertiary)] rounded",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[i?a.jsx(Kc,{className:"w-5 h-5 text-[var(--accent)]"}):a.jsx($m,{className:"w-5 h-5 text-[var(--text-secondary)]"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium",children:i?"Public":"Private"}),a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:i?"Anyone with the link can view":"Only you can access"})]})]}),a.jsx("button",{onClick:v,disabled:c,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${i?"bg-[var(--accent)]":"bg-[var(--border)]"} ${c?"opacity-50 cursor-not-allowed":""}`,children:a.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${i?"translate-x-6":"translate-x-1"}`})})]}),i&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Share link"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",readOnly:!0,value:m,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono"}),a.jsx(Q,{variant:"secondary",onClick:k,children:f?a.jsxs(a.Fragment,{children:[a.jsx(Tg,{className:"w-4 h-4 mr-1"}),"Copied"]}):a.jsxs(a.Fragment,{children:[a.jsx(zg,{className:"w-4 h-4 mr-1"}),"Copy"]})})]})]}),l&&a.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",a.jsx("span",{className:"text-[var(--text-primary)]",children:l})]}),a.jsx("div",{className:"text-xs text-[var(--text-secondary)] pt-2 border-t border-[var(--border)]",children:i?a.jsxs(a.Fragment,{children:[a.jsxs("p",{children:["Public ",s,"s can be viewed by anyone with the link."]}),a.jsxs("p",{className:"mt-1",children:["Only you can edit or delete this ",s,"."]})]}):a.jsxs("p",{children:["Make this ",s," public to share it with others."]})})]})})}function j1({job:e,onUpdate:t}){const[n,r]=j.useState(!1),s=async i=>{await Ot.update(e.id,{is_public:i}),t()};return a.jsxs(a.Fragment,{children:[a.jsxs(Q,{variant:"secondary",size:"sm",onClick:()=>r(!0),title:e.is_public?"Sharing settings":"Share this job",children:[a.jsx(qg,{className:"w-4 h-4 mr-1"}),e.is_public?"Shared":"Share"]}),a.jsx(g1,{isOpen:n,onClose:()=>r(!1),title:"Share Job",itemId:e.id,itemType:"job",isPublic:e.is_public,createdByName:e.created_by_name,onTogglePublic:s})]})}function w1(){const{jobId:e}=fa(),t=zn(),n=Wt(),[r,s]=j.useState(null),[i,l]=j.useState(!1),[o,c]=j.useState(null),[u,d]=j.useState([]),[f,m]=j.useState(null),[v,k]=j.useState(null),[g,b]=j.useState("results"),[p,h]=j.useState("score"),[x,w]=j.useState("desc"),[C,S]=j.useState(!1),{data:N,isLoading:_}=le({queryKey:["jobs",e],queryFn:()=>Ot.get(e),enabled:!!e,refetchInterval:i?2e3:!1}),{data:F=[]}=le({queryKey:["runs",e],queryFn:()=>$o.list({job_id:e}),enabled:!!e,refetchInterval:i?2e3:!1}),{data:O}=le({queryKey:["job-summary",e],queryFn:()=>$o.getJobSummary(e),enabled:!!e&&(N==null?void 0:N.status)==="completed"}),B=Je({mutationFn:async()=>{l(!0),d([]),m(null),k(null);for await(const R of Ot.start(e))s(R),R.current_candidate&&R.current_task&&m(T=>(T&&(T.candidate!==R.current_candidate||T.task!==R.current_task)&&d(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),{candidate:R.current_candidate,task:R.current_task})),R.event==="error"&&(k(R.message),l(!1),n.invalidateQueries({queryKey:["jobs",e]})),R.event==="complete"&&(m(T=>(T&&d(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),null)),l(!1),n.invalidateQueries({queryKey:["jobs",e]}),n.invalidateQueries({queryKey:["runs",e]}),n.invalidateQueries({queryKey:["job-summary",e]}))}}),G=Je({mutationFn:()=>Ot.cancel(e),onSuccess:()=>{l(!1),n.invalidateQueries({queryKey:["jobs",e]})}});j.useEffect(()=>{(N==null?void 0:N.status)==="running"&&l(!0)},[N==null?void 0:N.status]);const re=j.useMemo(()=>{const R=new Map;for(const T of F)R.has(T.task_name)||R.set(T.task_name,[]),R.get(T.task_name).push(T);return R},[F]),oe=j.useMemo(()=>Array.from(re.keys()),[re]);j.useEffect(()=>{!o&&oe.length>0&&c(oe[0])},[oe,o]);const D=j.useMemo(()=>{if(!(O!=null&&O.candidate_summaries))return[];let R=[...O.candidate_summaries];return C&&(R=R.filter(T=>T.is_pareto)),R.sort((T,te)=>{let pe,Se;switch(p){case"score":pe=T.avg_score,Se=te.avg_score;break;case"tokens":pe=T.avg_tokens,Se=te.avg_tokens;break;case"duration":pe=T.avg_duration,Se=te.avg_duration;break;case"pass_rate":pe=T.passed_runs/T.total_runs,Se=te.passed_runs/te.total_runs;break}return x==="desc"?Se-pe:pe-Se}),R},[O,p,x,C]),W=R=>{p===R?w(x==="desc"?"asc":"desc"):(h(R),w(R==="tokens"||R==="duration"?"asc":"desc"))},X=({label:R,sortKeyVal:T})=>a.jsx("th",{className:"pb-2 cursor-pointer hover:text-[var(--text-primary)] select-none",onClick:()=>W(T),children:a.jsxs("div",{className:"flex items-center gap-1",children:[R,p===T&&a.jsx(_g,{size:12,className:x==="asc"?"rotate-180":""})]})});if(_)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!N)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Job not found"});const P=Xc(),A=!N.user_id||N.user_id==="anonymous"||P&&N.created_by_name===P,L=N.is_public&&!A,V=()=>{n.invalidateQueries({queryKey:["jobs",e]})},ee=R=>{const T={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};return a.jsx(q,{variant:T[R]||"default",children:R})};return a.jsxs("div",{children:[a.jsx(ma,{items:[{label:"Experiments",path:"/jobs"},{label:N.name||`Job ${N.id.slice(0,8)}`}]}),a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:N.name||`Job ${N.id.slice(0,8)}`}),ee(N.status),N.is_public&&a.jsxs(q,{variant:"info",children:[a.jsx(Kc,{className:"w-3 h-3 mr-1 inline"}),"Public"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[a.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-2 py-0.5 rounded font-mono text-[var(--text-secondary)]",children:[N.id.slice(0,8),"..."]}),a.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[N.candidate_ids.length," candidates × ",N.task_ids.length," tasks = ",N.total_experiments," experiments"]}),N.is_public&&N.created_by_name&&a.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",a.jsx("span",{className:"text-[var(--text-primary)]",children:N.created_by_name})]})]})]}),a.jsxs("div",{className:"flex gap-2",children:[A&&a.jsx(j1,{job:N,onUpdate:V}),L&&a.jsx(q,{variant:"default",children:"View Only"}),A&&N.status==="pending"&&a.jsx(Q,{variant:"primary",onClick:()=>B.mutate(),disabled:B.isPending,children:B.isPending?"Starting...":"Start"}),A&&N.status==="running"&&a.jsx(Q,{variant:"danger",onClick:()=>G.mutate(),disabled:G.isPending,children:"Cancel"})]})]}),(v||N.error)&&a.jsx(ge,{className:"mb-6 border-red-500/50 bg-red-500/10",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"w-5 h-5 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-0.5",children:"!"}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-red-400",children:"Error"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:v||N.error})]})]})}),(i||r)&&a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"font-medium",children:"Progress"}),a.jsxs("span",{className:"text-[var(--accent)]",children:[(r==null?void 0:r.completed)||N.completed_experiments,"/",(r==null?void 0:r.total)||N.total_experiments]})]}),a.jsx("div",{className:"w-full bg-[var(--bg-primary)] h-2 mb-2",children:a.jsx("div",{className:"h-full bg-[var(--accent)] transition-all",style:{width:`${((r==null?void 0:r.completed)||N.completed_experiments)/((r==null?void 0:r.total)||N.total_experiments)*100}%`}})}),(r==null?void 0:r.message)&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r.message}),i&&a.jsxs("div",{className:"mt-4 border-t border-[var(--border)] pt-4",children:[(r==null?void 0:r.current_candidate)&&(r==null?void 0:r.current_task)&&a.jsxs("div",{className:"mb-3",children:[a.jsx("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:"Currently Running"}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 px-3 py-2 bg-blue-500/10 border border-blue-500/30 rounded",children:[a.jsx("div",{className:"w-2 h-2 bg-blue-400 rounded-full animate-pulse"}),a.jsx("span",{className:"font-medium",children:r.current_candidate}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{children:r.current_task})]})]}),u.length>0&&a.jsxs("div",{children:[a.jsxs("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:["Completed (",u.length,")"]}),a.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto space-y-1",children:u.map((R,T)=>a.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-500/10 border border-green-500/30 rounded text-sm",children:[a.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}),a.jsx("span",{className:"font-medium",children:R.candidate_name}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{children:R.task_name})]},`${R.candidate_name}-${R.task_name}-${T}`))})]})]})]}),(N.status==="completed"||F.length>0)&&a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-[var(--border)]",children:[a.jsxs("button",{onClick:()=>b("results"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="results"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Eg,{size:16}),"Results"]}),a.jsxs("button",{onClick:()=>b("compare"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="compare"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Ig,{size:16}),"Compare"]}),a.jsxs("button",{onClick:()=>b("runs"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="runs"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Ug,{size:16}),"Runs (",F.length,")"]})]}),g==="results"&&a.jsxs(a.Fragment,{children:[O&&O.candidate_summaries.length>1&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("div",{className:"flex items-start justify-between mb-4",children:a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium",children:"Quality vs. Cost Tradeoff"}),a.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:["Candidates on the frontier (connected line) are ",a.jsx("strong",{children:"optimal"})," - no other candidate beats them on both score AND cost."]})]})}),a.jsxs("div",{className:"mb-4 p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs text-[var(--text-secondary)]",children:[a.jsx("strong",{className:"text-[var(--text-primary)]",children:"How optimal tradeoffs are calculated:"})," A candidate is optimal if there's no other candidate that has both a higher score AND lower cost. For example, if Candidate A has 95% score at 50K tokens and Candidate B has 90% score at 40K tokens, both are optimal - A is better on score, B is better on cost. But if Candidate C has 85% score at 60K tokens, it's ",a.jsx("em",{children:"not"})," optimal because B beats it on both metrics."]}),a.jsx(v1,{summaries:O.candidate_summaries,height:350})]}),O&&a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h3",{className:"font-medium",children:"Results Summary"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C,onChange:R=>S(R.target.checked),className:"rounded border-[var(--border)]"}),"Optimal only"]})]}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-left text-[var(--text-secondary)] border-b border-[var(--border)]",children:[a.jsx("th",{className:"pb-2",children:"Candidate"}),a.jsx(X,{label:"Score",sortKeyVal:"score"}),a.jsx(X,{label:"Tokens",sortKeyVal:"tokens"}),a.jsx(X,{label:"Duration",sortKeyVal:"duration"}),a.jsx(X,{label:"Pass Rate",sortKeyVal:"pass_rate"}),a.jsx("th",{className:"pb-2",children:"Optimal"})]})}),a.jsx("tbody",{children:D.map((R,T)=>a.jsxs("tr",{className:`border-b border-[var(--border)] ${T===0?"bg-[var(--accent)]/10":""}`,children:[a.jsxs("td",{className:"py-2 font-medium",children:[T===0&&a.jsx("span",{className:"text-[var(--accent)] mr-1",children:"#1"}),R.candidate_name.replace(/^baseline_/,"")]}),a.jsxs("td",{className:"py-2",children:[(R.avg_score*100).toFixed(1),"%"]}),a.jsxs("td",{className:"py-2",children:[(R.avg_tokens/1e3).toFixed(1),"K"]}),a.jsxs("td",{className:"py-2",children:[R.avg_duration.toFixed(1),"s"]}),a.jsxs("td",{className:"py-2",children:[R.passed_runs,"/",R.total_runs]}),a.jsx("td",{className:"py-2",children:R.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})})]},R.candidate_name))})]})}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-3",children:"Click column headers to sort. The #1 ranked candidate is highlighted based on your sort criteria."})]}),!O&&a.jsx(ge,{children:a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Results will appear here after the job completes.":"No results yet. Start the job to see results."})})]}),g==="compare"&&a.jsxs(ge,{children:[a.jsx("h3",{className:"font-medium mb-4",children:"Compare Candidates by Task"}),oe.length>0?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:oe.map(R=>a.jsx("button",{onClick:()=>c(o===R?null:R),className:`px-3 py-1 text-sm rounded border transition-colors ${o===R?"bg-[var(--accent)] text-white border-[var(--accent)]":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:R},R))}),o&&re.get(o)?a.jsx(x1,{runs:re.get(o).map(R=>({id:R.id,candidate_name:R.candidate_name,tokens_input:0,tokens_output:0,tokens_total:R.tokens_total,duration_seconds:R.duration_seconds,score:R.score,passed:R.passed,is_pareto:R.is_pareto}))}):a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"Select a task above to compare how different candidates performed on it."})]}):a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Comparison data will appear here after runs complete.":"No runs yet. Start the job to compare candidates."})]}),g==="runs"&&a.jsxs(ge,{children:[a.jsx("h3",{className:"font-medium mb-4",children:"All Experiment Runs"}),F.length===0?a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Runs will appear here as they complete. See progress above for live status.":"No runs yet. Start the job to see results."}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:F.map(R=>a.jsxs("div",{className:"p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] cursor-pointer hover:border-[var(--accent-dim)] transition-colors",onClick:()=>t(`/runs/${R.id}`),children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:`text-lg font-bold ${R.passed?"text-green-400":"text-red-400"}`,children:[(R.score*100).toFixed(0),"%"]}),R.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})]}),a.jsx("div",{className:"text-sm font-medium truncate",title:R.candidate_name,children:R.candidate_name.replace(/^baseline_/,"")}),a.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:R.task_name}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:[(R.tokens_total/1e3).toFixed(1),"K tokens"]}),a.jsxs("span",{children:[R.duration_seconds.toFixed(1),"s"]})]})]},R.id))})]})]})}const xn={input:"bg-blue-500",output:"bg-emerald-500",inputText:"text-blue-400",outputText:"text-emerald-400"};function Id(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Dd({input:e,output:t,maxValue:n,height:r=24,showLabels:s=!0}){const i=e+t;if(i===0)return a.jsx("div",{className:"flex items-center gap-2 w-full",children:a.jsx("div",{className:"rounded bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`}})});const l=n>0?i/n*100:100;return a.jsxs("div",{className:"flex items-center gap-3 w-full",children:[a.jsx("div",{className:"relative rounded overflow-hidden bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`},children:a.jsxs("div",{className:"h-full flex transition-all duration-300",style:{width:`${l}%`},children:[a.jsx("div",{className:`h-full ${xn.input} transition-all`,style:{width:`${e/i*100}%`},title:`Input: ${e.toLocaleString()} tokens`}),a.jsx("div",{className:`h-full ${xn.output} transition-all`,style:{width:`${t/i*100}%`},title:`Output: ${t.toLocaleString()} tokens`})]})}),s&&a.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono text-[var(--text-secondary)] min-w-[90px] justify-end",children:[a.jsxs("span",{className:xn.inputText,children:["↑",Id(e)]}),a.jsx("span",{children:"/"}),a.jsxs("span",{className:xn.outputText,children:["↓",Id(t)]})]})]})}function Sl({label:e,value:t,color:n="default"}){const r={default:"text-[var(--text-primary)]",input:xn.inputText,output:xn.outputText}[n];return a.jsxs("div",{className:"flex-1 p-3 bg-[var(--bg-primary)] border border-[var(--border)] rounded",children:[a.jsx("div",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e}),a.jsx("div",{className:`font-mono text-lg font-bold ${r}`,children:t})]})}function ap({tokensInput:e,tokensOutput:t,tokensTotal:n,turns:r}){const s=n>0?Math.round(e/n*100):0,i=n>0?Math.round(t/n*100):0,l=j.useMemo(()=>{if(!r||r.length===0)return null;let c=0,u=0;return r.map(d=>(c+=d.input,u+=d.output,{input:c,output:u,total:c+u}))},[r]),o=l?Math.max(...l.map(c=>c.total)):n;return a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-4",children:"Token Usage"}),a.jsx("div",{className:"mb-4",children:a.jsx(Dd,{input:e,output:t,maxValue:n,height:32})}),a.jsxs("div",{className:"flex items-center gap-6 text-xs mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-3 h-3 rounded ${xn.input}`}),a.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Input (",s,"%)"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-3 h-3 rounded ${xn.output}`}),a.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Output (",i,"%)"]})]})]}),a.jsxs("div",{className:"flex gap-3 mb-4",children:[a.jsx(Sl,{label:"Input Tokens",value:e.toLocaleString(),color:"input"}),a.jsx(Sl,{label:"Output Tokens",value:t.toLocaleString(),color:"output"}),a.jsx(Sl,{label:"Total Tokens",value:n.toLocaleString()})]}),l&&l.length>1&&a.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[a.jsxs("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:["Token Accumulation (",r.length," turns)"]}),a.jsx("div",{className:"space-y-2",children:r.map((c,u)=>a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--bg-primary)] border border-[var(--border)] flex items-center justify-center text-xs font-medium",children:u+1}),a.jsx("div",{className:"flex-1",children:a.jsx(Dd,{input:l[u].input,output:l[u].output,maxValue:o,height:16})})]},u))})]}),a.jsx("div",{className:"mt-4 text-xs text-[var(--text-secondary)] border-t border-[var(--border)] pt-3",children:"Token usage affects API cost. Input tokens are typically cheaper than output tokens."})]})}function k1(){const{runId:e}=fa(),{data:t,isLoading:n}=le({queryKey:["runs",e],queryFn:()=>$o.get(e),enabled:!!e});return n?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsx(ma,{items:[{label:"Experiments",path:"/jobs"},{label:"Job",path:`/jobs/${t.job_id}`},{label:t.candidate_name}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:t.candidate_name}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{className:"text-lg",children:t.task_name}),t.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})]})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[a.jsx(Ma,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),a.jsx(Ma,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),a.jsx(Ma,{label:"Duration",value:`${t.duration_seconds.toFixed(1)}s`}),a.jsx(Ma,{label:"Status",value:t.passed?"Passed":"Failed",status:t.passed?"success":"error"})]}),a.jsx(ap,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),t.reasoning&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:t.reasoning}),t.criteria_results.length>0&&a.jsx("div",{className:"space-y-2",children:t.criteria_results.map(r=>a.jsx("div",{className:"flex items-start justify-between p-3 bg-[var(--bg-primary)] border border-[var(--border)]",children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-medium",children:r.name}),a.jsxs(q,{variant:r.passed?"success":"error",children:[(r.score*100).toFixed(0),"%"]})]}),r.reasoning&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r.reasoning})]})},r.name))})]}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created.length>0&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),a.jsx("div",{className:"space-y-1",children:t.files_created.map(r=>a.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:r},r))})]}),Object.keys(t.trace).length>0&&a.jsx(tp,{trace:t.trace})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Run not found"})}function Ma({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return a.jsxs(ge,{children:[a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),a.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function b1(){const{testId:e}=fa(),{data:t,isLoading:n}=le({queryKey:["tests",e],queryFn:()=>Os.get(e),enabled:!!e}),{data:r}=le({queryKey:["configs",t==null?void 0:t.agent_id],queryFn:()=>_n.get(t.agent_id),enabled:!!(t!=null&&t.agent_id)});if(n)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!t)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Test not found"});const s={completed:"success",failed:"error",running:"info",pending:"default",cancelled:"warning"};return a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsx(ma,{items:[{label:"Agents",path:"/agents"},...r?[{label:r.name,path:`/agents/${r.id}`}]:[],{label:`Test ${t.id.slice(0,8)}`}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:"Test Run"}),r&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"•"}),a.jsx("span",{className:"text-lg",children:r.name})]}),a.jsx(q,{variant:s[t.status]||"default",children:t.status})]}),a.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:["ID: ",t.id.slice(0,8),"..."]})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[a.jsx(za,{label:"Duration",value:`${t.duration_seconds.toFixed(2)}s`}),a.jsx(za,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),t.score!==null&&a.jsx(za,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),a.jsx(za,{label:"Status",value:t.status.charAt(0).toUpperCase()+t.status.slice(1),status:t.status==="completed"?"success":t.status==="failed"?"error":void 0})]}),a.jsx(ap,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Prompt"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)] font-mono",children:t.prompt})]}),t.error&&a.jsxs(ge,{className:"mb-6 border-red-500/30 bg-red-500/5",children:[a.jsx("h3",{className:"font-medium mb-3 text-red-400",children:"Error"}),a.jsx("pre",{className:"text-sm text-red-300 overflow-x-auto whitespace-pre-wrap",children:t.error})]}),t.reasoning&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.reasoning})]}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created&&t.files_created.length>0&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),a.jsx("div",{className:"space-y-1",children:t.files_created.map(i=>a.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:i},i))})]}),t.trace&&Object.keys(t.trace).length>0&&a.jsx(tp,{trace:t.trace}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Timestamps"}),a.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Created:"}),a.jsx("div",{className:"font-mono",children:new Date(t.created_at).toLocaleString()})]}),t.started_at&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Started:"}),a.jsx("div",{className:"font-mono",children:new Date(t.started_at).toLocaleString()})]}),t.completed_at&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Completed:"}),a.jsx("div",{className:"font-mono",children:new Date(t.completed_at).toLocaleString()})]})]})]})]})}function za({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return a.jsxs(ge,{children:[a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),a.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function N1(){const{deploymentId:e}=fa(),{data:t,isLoading:n}=le({queryKey:["deployments",e],queryFn:()=>E0.get(e),enabled:!!e}),r=t==null?void 0:t.versions.find(i=>i.id===t.current_version_id),{data:s}=le({queryKey:["configs",r==null?void 0:r.config_id],queryFn:()=>_n.get(r.config_id),enabled:!!(r!=null&&r.config_id)});return n?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsxs("div",{className:"mb-4 flex-shrink-0",children:[a.jsx(ma,{items:[{label:"Agents",path:"/agents"},{label:t.name}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Kg,{size:20,className:"text-[var(--accent)]"}),a.jsx("h2",{className:"text-xl font-bold",children:t.name}),r&&a.jsxs(q,{variant:"info",children:["v",r.version]})]}),t.description&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:t.description})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsx("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-5",children:[a.jsxs("div",{className:"flex items-center gap-4 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:["Created ",new Date(t.created_at).toLocaleDateString()]}),a.jsxs("span",{children:["Updated ",new Date(t.updated_at).toLocaleDateString()]}),a.jsxs("span",{children:[t.versions.length," version",t.versions.length!==1?"s":""]})]}),s&&a.jsxs(Tn,{to:`/agents/${s.id}`,className:"flex items-center gap-2 p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-sm",children:[a.jsx(Am,{size:14,className:"text-[var(--accent)]"}),a.jsxs("span",{children:["Agent: ",a.jsx("span",{className:"font-medium",children:s.name})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider mb-3",children:"Version History"}),t.versions.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"No versions yet."}):a.jsx("div",{className:"space-y-2",children:t.versions.map(i=>a.jsx(S1,{version:i,isActive:i.id===t.current_version_id},i.id))})]})]})}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[a.jsx(Um,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),a.jsx("div",{className:"flex-1 min-h-0",children:s?a.jsx(np,{agent:s}):a.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-secondary)] text-sm",children:r?"Loading agent configuration...":"No active version to test."})})]})]})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Deployment not found"})}function S1({version:e,isActive:t}){const n=e.config_snapshot;return a.jsxs("div",{className:`p-3 rounded-md border transition-colors ${t?"border-[var(--accent)] bg-[var(--accent-dim)]":"border-[var(--border)] bg-[var(--bg-secondary)]"}`,children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Jg,{size:12,className:"text-[var(--text-secondary)]"}),a.jsxs("span",{className:"text-sm font-medium",children:["v",e.version]}),t&&a.jsx(q,{variant:"success",children:"Active"}),a.jsx(q,{variant:e.source==="optimize"?"info":"default",children:e.source})]}),a.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)]",children:[a.jsx(Im,{size:11}),a.jsx("span",{children:new Date(e.created_at).toLocaleString()})]})]}),e.description&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e.description}),Object.keys(n).length>0&&a.jsxs("div",{className:"mt-1",children:[a.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)] mb-1",children:[a.jsx(Fg,{size:11}),a.jsx("span",{children:"Config"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-xs",children:["framework"in n&&n.framework?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Framework"}),a.jsx("span",{className:"font-mono",children:String(n.framework)})]}):null,"model"in n&&n.model?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Model"}),a.jsx("span",{className:"font-mono",children:String(n.model)})]}):null,"tools"in n&&n.tools?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tools"}),a.jsx("span",{className:"font-mono truncate",children:Array.isArray(n.tools)?n.tools.join(", "):String(n.tools)})]}):null]})]})]})}function C1(){const{authConfig:e,isLoading:t,error:n,login:r,loginWithGitHub:s,clearError:i}=Zc(),[l,o]=j.useState(""),[c,u]=j.useState("");j.useEffect(()=>{n&&i()},[l,c]);const d=async m=>{m.preventDefault(),!(!l||!c)&&await r(l,c)},f=()=>{s()};return a.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:a.jsxs("div",{className:"w-full max-w-md",children:[a.jsxs("div",{className:"text-center mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:"Flow"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:"Sign in to access the optimization dashboard"})]}),a.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] p-6 space-y-6",children:[n&&a.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[var(--error)]/10 border border-[var(--error)]/20 text-[var(--error)]",children:[a.jsx(zm,{size:18,className:"mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-sm",children:n})]}),(e==null?void 0:e.mode)==="basic"&&a.jsxs("form",{onSubmit:d,className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Username"}),a.jsxs("div",{className:"relative",children:[a.jsx(Qm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),a.jsx("input",{type:"text",value:l,onChange:m=>o(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter username",autoComplete:"username",autoFocus:!0})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Password"}),a.jsxs("div",{className:"relative",children:[a.jsx($m,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),a.jsx("input",{type:"password",value:c,onChange:m=>u(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter password",autoComplete:"current-password"})]})]}),a.jsx(Q,{type:"submit",variant:"primary",className:"w-full justify-center",loading:t,disabled:!l||!c,children:"Sign In"})]}),(e==null?void 0:e.mode)==="github"&&a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center",children:"Sign in with your GitHub account to continue"}),a.jsx(Q,{onClick:f,variant:"secondary",className:"w-full justify-center",icon:Dg,children:"Continue with GitHub"})]})]})]})})}function _1({children:e}){const{authConfig:t,isLoadingConfig:n,isAuthenticated:r,loadAuthConfig:s,handleOAuthCallback:i}=Zc();return j.useEffect(()=>{s()},[s]),j.useEffect(()=>{n||i()},[n,i]),n?a.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center",children:a.jsxs("div",{className:"text-center",children:[a.jsx(ha,{className:"w-8 h-8 animate-spin text-[var(--accent)] mx-auto mb-4"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:"Loading..."})]})}):t!=null&&t.enabled&&!r?a.jsx(C1,{}):a.jsx(a.Fragment,{children:e})}function E1(){return a.jsx(vg,{children:a.jsx(_1,{children:a.jsx(cg,{children:a.jsxs(ht,{path:"/",element:a.jsx($0,{}),children:[a.jsx(ht,{index:!0,element:a.jsx(B0,{})}),a.jsx(ht,{path:"agents",element:a.jsx(X0,{})}),a.jsx(ht,{path:"agents/:agentId",element:a.jsx(a1,{})}),a.jsx(ht,{path:"tasks",element:a.jsx(c1,{})}),a.jsx(ht,{path:"jobs",element:a.jsx(h1,{})}),a.jsx(ht,{path:"jobs/:jobId",element:a.jsx(w1,{})}),a.jsx(ht,{path:"runs/:runId",element:a.jsx(k1,{})}),a.jsx(ht,{path:"tests/:testId",element:a.jsx(b1,{})}),a.jsx(ht,{path:"deployments/:deploymentId",element:a.jsx(N1,{})})]})})})})}const Ad=localStorage.getItem("flow-theme");if(Ad)try{const{state:e}=JSON.parse(Ad);e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}catch{}const P1=new sy({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}});Cl.createRoot(document.getElementById("root")).render(a.jsx(Wo.StrictMode,{children:a.jsx(ay,{client:P1,children:a.jsx(E1,{})})})); diff --git a/src/flow/ui/ui/assets/index-BkZ03UvJ.css b/src/flow/ui/ui/assets/index-BkZ03UvJ.css new file mode 100644 index 0000000000000000000000000000000000000000..15045f1bd7d618f46a5ec9240649e21c3fdfb50e --- /dev/null +++ b/src/flow/ui/ui/assets/index-BkZ03UvJ.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:Segoe UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:JetBrains Mono,ui-monospace,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.bottom-0{bottom:0}.bottom-1{bottom:.25rem}.left-0{left:0}.left-3{left:.75rem}.top-0{top:0}.top-1{top:.25rem}.top-1\/2{top:50%}.z-10{z-index:10}.z-50{z-index:50}.mx-0\.5{margin-left:.125rem;margin-right:.125rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.-mb-px{margin-bottom:-1px}.-mt-2{margin-top:-.5rem}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.ml-6{margin-left:1.5rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-auto{margin-top:auto}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-1\.5{height:.375rem}.h-12{height:3rem}.h-2{height:.5rem}.h-3{height:.75rem}.h-32{height:8rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-8{height:2rem}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:8rem}.max-h-40{max-height:10rem}.max-h-48{max-height:12rem}.max-h-80{max-height:20rem}.max-h-96{max-height:24rem}.max-h-\[120px\]{max-height:120px}.max-h-\[80vh\]{max-height:80vh}.min-h-0{min-height:0px}.min-h-\[100px\]{min-height:100px}.min-h-\[200px\]{min-height:200px}.min-h-\[40px\]{min-height:40px}.min-h-screen{min-height:100vh}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-2{width:.5rem}.w-20{width:5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-32{width:8rem}.w-4{width:1rem}.w-5{width:1.25rem}.w-56{width:14rem}.w-6{width:1.5rem}.w-8{width:2rem}.w-\[350px\]{width:350px}.w-\[3px\]{width:3px}.w-\[420px\]{width:420px}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-\[90px\]{min-width:90px}.max-w-2xl{max-width:42rem}.max-w-4xl{max-width:56rem}.max-w-\[80\%\]{max-width:80%}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-90{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.resize-y{resize:vertical}.resize{resize:both}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-\[var\(--accent\)\]{border-color:var(--accent)}.border-\[var\(--badge-error-border\)\]{border-color:var(--badge-error-border)}.border-\[var\(--badge-info-border\)\]{border-color:var(--badge-info-border)}.border-\[var\(--badge-success-border\)\]{border-color:var(--badge-success-border)}.border-\[var\(--badge-warning-border\)\]{border-color:var(--badge-warning-border)}.border-\[var\(--border\)\]{border-color:var(--border)}.border-blue-500\/30{border-color:#3b82f64d}.border-green-500\/30{border-color:#22c55e4d}.border-green-500\/50{border-color:#22c55e80}.border-red-500\/30{border-color:#ef44444d}.border-red-500\/50{border-color:#ef444480}.border-transparent{border-color:transparent}.bg-\[var\(--accent\)\]{background-color:var(--accent)}.bg-\[var\(--accent-dim\)\]{background-color:var(--accent-dim)}.bg-\[var\(--badge-error-bg\)\]{background-color:var(--badge-error-bg)}.bg-\[var\(--badge-info-bg\)\]{background-color:var(--badge-info-bg)}.bg-\[var\(--badge-success-bg\)\]{background-color:var(--badge-success-bg)}.bg-\[var\(--badge-warning-bg\)\]{background-color:var(--badge-warning-bg)}.bg-\[var\(--bg-primary\)\]{background-color:var(--bg-primary)}.bg-\[var\(--bg-secondary\)\]{background-color:var(--bg-secondary)}.bg-\[var\(--bg-tertiary\)\]{background-color:var(--bg-tertiary)}.bg-\[var\(--border\)\]{background-color:var(--border)}.bg-\[var\(--error\)\]{background-color:var(--error)}.bg-\[var\(--span-agent-bg\)\]{background-color:var(--span-agent-bg)}.bg-\[var\(--span-fail-bg\)\]{background-color:var(--span-fail-bg)}.bg-\[var\(--span-llm-bg\)\]{background-color:var(--span-llm-bg)}.bg-\[var\(--span-other-bg\)\]{background-color:var(--span-other-bg)}.bg-\[var\(--span-pass-bg\)\]{background-color:var(--span-pass-bg)}.bg-\[var\(--span-tool-bg\)\]{background-color:var(--span-tool-bg)}.bg-black\/50{background-color:#00000080}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(96 165 250 / var(--tw-bg-opacity, 1))}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-500\/10{background-color:#3b82f61a}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(16 185 129 / var(--tw-bg-opacity, 1))}.bg-green-400{--tw-bg-opacity: 1;background-color:rgb(74 222 128 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-green-500\/10{background-color:#22c55e1a}.bg-green-500\/20{background-color:#22c55e33}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-500\/10{background-color:#ef44441a}.bg-red-500\/5{background-color:#ef44440d}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-2{padding-bottom:.5rem}.pb-3{padding-bottom:.75rem}.pl-10{padding-left:2.5rem}.pl-9{padding-left:2.25rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:JetBrains Mono,ui-monospace,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.text-\[var\(--accent\)\]{color:var(--accent)}.text-\[var\(--badge-error-text\)\]{color:var(--badge-error-text)}.text-\[var\(--badge-info-text\)\]{color:var(--badge-info-text)}.text-\[var\(--badge-success-text\)\]{color:var(--badge-success-text)}.text-\[var\(--badge-warning-text\)\]{color:var(--badge-warning-text)}.text-\[var\(--error\)\]{color:var(--error)}.text-\[var\(--span-agent-text\)\]{color:var(--span-agent-text)}.text-\[var\(--span-fail-text\)\]{color:var(--span-fail-text)}.text-\[var\(--span-llm-text\)\]{color:var(--span-llm-text)}.text-\[var\(--span-other-text\)\]{color:var(--span-other-text)}.text-\[var\(--span-pass-text\)\]{color:var(--span-pass-text)}.text-\[var\(--span-tool-text\)\]{color:var(--span-tool-text)}.text-\[var\(--success\)\]{color:var(--success)}.text-\[var\(--text-primary\)\]{color:var(--text-primary)}.text-\[var\(--text-secondary\)\]{color:var(--text-secondary)}.text-\[var\(--text-tertiary\)\]{color:var(--text-tertiary)}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.text-blue-400{--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.text-emerald-400{--tw-text-opacity: 1;color:rgb(52 211 153 / var(--tw-text-opacity, 1))}.text-green-400{--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-purple-400{--tw-text-opacity: 1;color:rgb(192 132 252 / var(--tw-text-opacity, 1))}.text-red-300{--tw-text-opacity: 1;color:rgb(252 165 165 / var(--tw-text-opacity, 1))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}:root{--bg-primary: #ffffff;--bg-secondary: #fafafa;--bg-tertiary: #f3f4f6;--text-primary: #1b1b1b;--text-secondary: #616161;--accent: #7c3aed;--accent-hover: #6d28d9;--accent-dim: #ede9fe;--border: #e5e7eb;--error: #dc2626;--success: #16a34a;--badge-success-bg: #f0fdf4;--badge-success-text: #15803d;--badge-success-border: #bbf7d0;--badge-warning-bg: #fefce8;--badge-warning-text: #a16207;--badge-warning-border: #fef08a;--badge-error-bg: #fef2f2;--badge-error-text: #b91c1c;--badge-error-border: #fecaca;--badge-info-bg: #eff6ff;--badge-info-text: #1d4ed8;--badge-info-border: #bfdbfe;--span-llm-bg: #f5f3ff;--span-llm-text: #6b21a8;--span-tool-bg: #eff6ff;--span-tool-text: #1e40af;--span-agent-bg: #f0fdf4;--span-agent-text: #166534;--span-other-bg: #fff7ed;--span-other-text: #9a3412;--span-pass-bg: #f0fdf4;--span-pass-text: #166534;--span-fail-bg: #fef2f2;--span-fail-text: #991b1b}[data-theme=dark]{--bg-primary: #1a1a2e;--bg-secondary: #16162a;--bg-tertiary: #252540;--text-primary: #f0f0f5;--text-secondary: #a0a0b5;--accent: #a78bfa;--accent-hover: #8b5cf6;--accent-dim: #2d2055;--border: #2d2d45;--error: #ef4444;--success: #22c55e;--badge-success-bg: rgba(34, 197, 94, .15);--badge-success-text: #4ade80;--badge-success-border: rgba(34, 197, 94, .3);--badge-warning-bg: rgba(234, 179, 8, .15);--badge-warning-text: #fbbf24;--badge-warning-border: rgba(234, 179, 8, .3);--badge-error-bg: rgba(239, 68, 68, .15);--badge-error-text: #f87171;--badge-error-border: rgba(239, 68, 68, .3);--badge-info-bg: rgba(59, 130, 246, .15);--badge-info-text: #60a5fa;--badge-info-border: rgba(59, 130, 246, .3);--span-llm-bg: rgba(139, 92, 246, .15);--span-llm-text: #c4b5fd;--span-tool-bg: rgba(59, 130, 246, .15);--span-tool-text: #93c5fd;--span-agent-bg: rgba(34, 197, 94, .15);--span-agent-text: #86efac;--span-other-bg: rgba(249, 115, 22, .15);--span-other-text: #fdba74;--span-pass-bg: rgba(34, 197, 94, .15);--span-pass-text: #86efac;--span-fail-bg: rgba(239, 68, 68, .15);--span-fail-text: #fca5a5}*{box-sizing:border-box}body{margin:0;background-color:var(--bg-primary);color:var(--text-primary);font-family:Segoe UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-size:14px;line-height:1.6}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:var(--bg-secondary)}::-webkit-scrollbar-thumb{background:var(--border);border-radius:4px}::-webkit-scrollbar-thumb:hover{background:silver}[data-theme=dark] ::-webkit-scrollbar-thumb:hover{background:#404040}.last\:border-0:last-child{border-width:0px}.last\:border-b-0:last-child{border-bottom-width:0px}.hover\:border-\[var\(--accent\)\]:hover{border-color:var(--accent)}.hover\:border-\[var\(--accent-dim\)\]:hover{border-color:var(--accent-dim)}.hover\:bg-\[var\(--accent-hover\)\]:hover{background-color:var(--accent-hover)}.hover\:bg-\[var\(--bg-primary\)\]:hover{background-color:var(--bg-primary)}.hover\:bg-\[var\(--bg-tertiary\)\]:hover{background-color:var(--bg-tertiary)}.hover\:bg-\[var\(--border\)\]:hover{background-color:var(--border)}.hover\:bg-red-600:hover{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.hover\:text-\[var\(--accent\)\]:hover{color:var(--accent)}.hover\:text-\[var\(--error\)\]:hover{color:var(--error)}.hover\:text-\[var\(--text-primary\)\]:hover{color:var(--text-primary)}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-80:hover{opacity:.8}.focus\:border-\[var\(--accent\)\]:focus{border-color:var(--accent)}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-\[var\(--accent\)\]:focus{--tw-ring-color: var(--accent)}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}@media (min-width: 768px){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (min-width: 1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}} diff --git a/src/flow/ui/ui/assets/index-Boeq5D3q.css b/src/flow/ui/ui/assets/index-Boeq5D3q.css new file mode 100644 index 0000000000000000000000000000000000000000..df2ecc821bb9a93da4dc8762bcf9ebd6c41a8bd3 --- /dev/null +++ b/src/flow/ui/ui/assets/index-Boeq5D3q.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:Segoe UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:JetBrains Mono,ui-monospace,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.bottom-0{bottom:0}.bottom-1{bottom:.25rem}.left-0{left:0}.left-3{left:.75rem}.top-0{top:0}.top-1{top:.25rem}.top-1\/2{top:50%}.z-10{z-index:10}.z-50{z-index:50}.mx-0\.5{margin-left:.125rem;margin-right:.125rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.-mb-px{margin-bottom:-1px}.-mt-2{margin-top:-.5rem}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-3{margin-left:.75rem}.ml-4{margin-left:1rem}.ml-6{margin-left:1.5rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-12{height:3rem}.h-2{height:.5rem}.h-3{height:.75rem}.h-32{height:8rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:8rem}.max-h-40{max-height:10rem}.max-h-48{max-height:12rem}.max-h-80{max-height:20rem}.max-h-96{max-height:24rem}.max-h-\[120px\]{max-height:120px}.max-h-\[80vh\]{max-height:80vh}.min-h-0{min-height:0px}.min-h-\[100px\]{min-height:100px}.min-h-\[200px\]{min-height:200px}.min-h-\[40px\]{min-height:40px}.min-h-screen{min-height:100vh}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-16{width:4rem}.w-2{width:.5rem}.w-20{width:5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-32{width:8rem}.w-4{width:1rem}.w-40{width:10rem}.w-5{width:1.25rem}.w-56{width:14rem}.w-6{width:1.5rem}.w-7{width:1.75rem}.w-8{width:2rem}.w-\[350px\]{width:350px}.w-\[3px\]{width:3px}.w-\[420px\]{width:420px}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-\[90px\]{min-width:90px}.max-w-2xl{max-width:42rem}.max-w-4xl{max-width:56rem}.max-w-\[80\%\]{max-width:80%}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-90{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.resize-y{resize:vertical}.resize{resize:both}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-\[var\(--accent\)\]{border-color:var(--accent)}.border-\[var\(--badge-error-border\)\]{border-color:var(--badge-error-border)}.border-\[var\(--badge-info-border\)\]{border-color:var(--badge-info-border)}.border-\[var\(--badge-success-border\)\]{border-color:var(--badge-success-border)}.border-\[var\(--badge-warning-border\)\]{border-color:var(--badge-warning-border)}.border-\[var\(--border\)\]{border-color:var(--border)}.border-blue-500\/30{border-color:#3b82f64d}.border-green-500\/30{border-color:#22c55e4d}.border-green-500\/50{border-color:#22c55e80}.border-red-500\/30{border-color:#ef44444d}.border-red-500\/50{border-color:#ef444480}.border-transparent{border-color:transparent}.border-yellow-500\/30{border-color:#eab3084d}.bg-\[var\(--accent\)\]{background-color:var(--accent)}.bg-\[var\(--accent-dim\)\]{background-color:var(--accent-dim)}.bg-\[var\(--badge-error-bg\)\]{background-color:var(--badge-error-bg)}.bg-\[var\(--badge-info-bg\)\]{background-color:var(--badge-info-bg)}.bg-\[var\(--badge-success-bg\)\]{background-color:var(--badge-success-bg)}.bg-\[var\(--badge-warning-bg\)\]{background-color:var(--badge-warning-bg)}.bg-\[var\(--bg-primary\)\]{background-color:var(--bg-primary)}.bg-\[var\(--bg-secondary\)\]{background-color:var(--bg-secondary)}.bg-\[var\(--bg-tertiary\)\]{background-color:var(--bg-tertiary)}.bg-\[var\(--border\)\]{background-color:var(--border)}.bg-\[var\(--error\)\]{background-color:var(--error)}.bg-\[var\(--span-agent-bg\)\]{background-color:var(--span-agent-bg)}.bg-\[var\(--span-fail-bg\)\]{background-color:var(--span-fail-bg)}.bg-\[var\(--span-llm-bg\)\]{background-color:var(--span-llm-bg)}.bg-\[var\(--span-other-bg\)\]{background-color:var(--span-other-bg)}.bg-\[var\(--span-pass-bg\)\]{background-color:var(--span-pass-bg)}.bg-\[var\(--span-tool-bg\)\]{background-color:var(--span-tool-bg)}.bg-black\/50{background-color:#00000080}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(96 165 250 / var(--tw-bg-opacity, 1))}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-500\/10{background-color:#3b82f61a}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(16 185 129 / var(--tw-bg-opacity, 1))}.bg-green-400{--tw-bg-opacity: 1;background-color:rgb(74 222 128 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-green-500\/10{background-color:#22c55e1a}.bg-green-500\/20{background-color:#22c55e33}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-500\/10{background-color:#ef44441a}.bg-red-500\/5{background-color:#ef44440d}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-yellow-500\/10{background-color:#eab3081a}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-2{padding-bottom:.5rem}.pb-3{padding-bottom:.75rem}.pl-10{padding-left:2.5rem}.pl-8{padding-left:2rem}.pl-9{padding-left:2.25rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:JetBrains Mono,ui-monospace,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.text-\[var\(--accent\)\]{color:var(--accent)}.text-\[var\(--badge-error-text\)\]{color:var(--badge-error-text)}.text-\[var\(--badge-info-text\)\]{color:var(--badge-info-text)}.text-\[var\(--badge-success-text\)\]{color:var(--badge-success-text)}.text-\[var\(--badge-warning-text\)\]{color:var(--badge-warning-text)}.text-\[var\(--border\)\]{color:var(--border)}.text-\[var\(--error\)\]{color:var(--error)}.text-\[var\(--span-agent-text\)\]{color:var(--span-agent-text)}.text-\[var\(--span-fail-text\)\]{color:var(--span-fail-text)}.text-\[var\(--span-llm-text\)\]{color:var(--span-llm-text)}.text-\[var\(--span-other-text\)\]{color:var(--span-other-text)}.text-\[var\(--span-pass-text\)\]{color:var(--span-pass-text)}.text-\[var\(--span-tool-text\)\]{color:var(--span-tool-text)}.text-\[var\(--success\)\]{color:var(--success)}.text-\[var\(--text-primary\)\]{color:var(--text-primary)}.text-\[var\(--text-secondary\)\]{color:var(--text-secondary)}.text-\[var\(--text-tertiary\)\]{color:var(--text-tertiary)}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.text-blue-400{--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.text-emerald-400{--tw-text-opacity: 1;color:rgb(52 211 153 / var(--tw-text-opacity, 1))}.text-green-400{--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-purple-400{--tw-text-opacity: 1;color:rgb(192 132 252 / var(--tw-text-opacity, 1))}.text-red-300{--tw-text-opacity: 1;color:rgb(252 165 165 / var(--tw-text-opacity, 1))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.text-yellow-600{--tw-text-opacity: 1;color:rgb(202 138 4 / var(--tw-text-opacity, 1))}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}:root{--bg-primary: #ffffff;--bg-secondary: #fafafa;--bg-tertiary: #f3f4f6;--text-primary: #1b1b1b;--text-secondary: #616161;--accent: #7c3aed;--accent-hover: #6d28d9;--accent-dim: #ede9fe;--border: #e5e7eb;--error: #dc2626;--success: #16a34a;--badge-success-bg: #f0fdf4;--badge-success-text: #15803d;--badge-success-border: #bbf7d0;--badge-warning-bg: #fefce8;--badge-warning-text: #a16207;--badge-warning-border: #fef08a;--badge-error-bg: #fef2f2;--badge-error-text: #b91c1c;--badge-error-border: #fecaca;--badge-info-bg: #eff6ff;--badge-info-text: #1d4ed8;--badge-info-border: #bfdbfe;--span-llm-bg: #f5f3ff;--span-llm-text: #6b21a8;--span-tool-bg: #eff6ff;--span-tool-text: #1e40af;--span-agent-bg: #f0fdf4;--span-agent-text: #166534;--span-other-bg: #fff7ed;--span-other-text: #9a3412;--span-pass-bg: #f0fdf4;--span-pass-text: #166534;--span-fail-bg: #fef2f2;--span-fail-text: #991b1b}[data-theme=dark]{--bg-primary: #1a1a2e;--bg-secondary: #16162a;--bg-tertiary: #252540;--text-primary: #f0f0f5;--text-secondary: #a0a0b5;--accent: #a78bfa;--accent-hover: #8b5cf6;--accent-dim: #2d2055;--border: #2d2d45;--error: #ef4444;--success: #22c55e;--badge-success-bg: rgba(34, 197, 94, .15);--badge-success-text: #4ade80;--badge-success-border: rgba(34, 197, 94, .3);--badge-warning-bg: rgba(234, 179, 8, .15);--badge-warning-text: #fbbf24;--badge-warning-border: rgba(234, 179, 8, .3);--badge-error-bg: rgba(239, 68, 68, .15);--badge-error-text: #f87171;--badge-error-border: rgba(239, 68, 68, .3);--badge-info-bg: rgba(59, 130, 246, .15);--badge-info-text: #60a5fa;--badge-info-border: rgba(59, 130, 246, .3);--span-llm-bg: rgba(139, 92, 246, .15);--span-llm-text: #c4b5fd;--span-tool-bg: rgba(59, 130, 246, .15);--span-tool-text: #93c5fd;--span-agent-bg: rgba(34, 197, 94, .15);--span-agent-text: #86efac;--span-other-bg: rgba(249, 115, 22, .15);--span-other-text: #fdba74;--span-pass-bg: rgba(34, 197, 94, .15);--span-pass-text: #86efac;--span-fail-bg: rgba(239, 68, 68, .15);--span-fail-text: #fca5a5}*{box-sizing:border-box}body{margin:0;background-color:var(--bg-primary);color:var(--text-primary);font-family:Segoe UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-size:14px;line-height:1.6}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:var(--bg-secondary)}::-webkit-scrollbar-thumb{background:var(--border);border-radius:4px}::-webkit-scrollbar-thumb:hover{background:silver}[data-theme=dark] ::-webkit-scrollbar-thumb:hover{background:#404040}.last\:border-0:last-child{border-width:0px}.last\:border-b-0:last-child{border-bottom-width:0px}.hover\:border-\[var\(--accent\)\]:hover{border-color:var(--accent)}.hover\:border-\[var\(--accent-dim\)\]:hover{border-color:var(--accent-dim)}.hover\:border-\[var\(--text-secondary\)\]:hover{border-color:var(--text-secondary)}.hover\:bg-\[var\(--accent-hover\)\]:hover{background-color:var(--accent-hover)}.hover\:bg-\[var\(--bg-primary\)\]:hover{background-color:var(--bg-primary)}.hover\:bg-\[var\(--bg-tertiary\)\]:hover{background-color:var(--bg-tertiary)}.hover\:bg-\[var\(--border\)\]:hover{background-color:var(--border)}.hover\:bg-red-600:hover{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.hover\:text-\[var\(--accent\)\]:hover{color:var(--accent)}.hover\:text-\[var\(--error\)\]:hover{color:var(--error)}.hover\:text-\[var\(--text-primary\)\]:hover{color:var(--text-primary)}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-80:hover{opacity:.8}.focus\:border-\[var\(--accent\)\]:focus{border-color:var(--accent)}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-\[var\(--accent\)\]:focus{--tw-ring-color: var(--accent)}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}@media (min-width: 768px){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (min-width: 1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (prefers-color-scheme: dark){.dark\:text-yellow-400{--tw-text-opacity: 1;color:rgb(250 204 21 / var(--tw-text-opacity, 1))}} diff --git a/src/flow/ui/ui/assets/index-BsG5ZXHv.js b/src/flow/ui/ui/assets/index-BsG5ZXHv.js new file mode 100644 index 0000000000000000000000000000000000000000..8ca0f8ad6a96e8a6132b818d22ff7fdaf10b8850 --- /dev/null +++ b/src/flow/ui/ui/assets/index-BsG5ZXHv.js @@ -0,0 +1,347 @@ +var ru=e=>{throw TypeError(e)};var qi=(e,t,n)=>t.has(e)||ru("Cannot "+n);var y=(e,t,n)=>(qi(e,t,"read from private field"),n?n.call(e):t.get(e)),$=(e,t,n)=>t.has(e)?ru("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),M=(e,t,n,r)=>(qi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),W=(e,t,n)=>(qi(e,t,"access private method"),n);var xa=(e,t,n,r)=>({set _(s){M(e,t,s,n)},get _(){return y(e,t,r)}});function up(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();function Xd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Zd={exports:{}},Si={},ef={exports:{}},X={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var la=Symbol.for("react.element"),dp=Symbol.for("react.portal"),fp=Symbol.for("react.fragment"),hp=Symbol.for("react.strict_mode"),mp=Symbol.for("react.profiler"),pp=Symbol.for("react.provider"),xp=Symbol.for("react.context"),vp=Symbol.for("react.forward_ref"),yp=Symbol.for("react.suspense"),gp=Symbol.for("react.memo"),jp=Symbol.for("react.lazy"),su=Symbol.iterator;function wp(e){return e===null||typeof e!="object"?null:(e=su&&e[su]||e["@@iterator"],typeof e=="function"?e:null)}var tf={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},nf=Object.assign,rf={};function ts(e,t,n){this.props=e,this.context=t,this.refs=rf,this.updater=n||tf}ts.prototype.isReactComponent={};ts.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};ts.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function sf(){}sf.prototype=ts.prototype;function Ko(e,t,n){this.props=e,this.context=t,this.refs=rf,this.updater=n||tf}var Ho=Ko.prototype=new sf;Ho.constructor=Ko;nf(Ho,ts.prototype);Ho.isPureReactComponent=!0;var au=Array.isArray,af=Object.prototype.hasOwnProperty,qo={current:null},lf={key:!0,ref:!0,__self:!0,__source:!0};function of(e,t,n){var r,s={},i=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(i=""+t.key),t)af.call(t,r)&&!lf.hasOwnProperty(r)&&(s[r]=t[r]);var o=arguments.length-2;if(o===1)s.children=n;else if(1>>1,te=P[V];if(0>>1;Vs(Ce,T))kes(_e,Ce)?(P[V]=_e,P[ke]=T,V=ke):(P[V]=Ce,P[Q]=T,V=Q);else if(kes(_e,T))P[V]=_e,P[ke]=T,V=ke;else break e}}return A}function s(P,A){var T=P.sortIndex-A.sortIndex;return T!==0?T:P.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var c=[],u=[],d=1,f=null,m=3,v=!1,k=!1,w=!1,b=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,h=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(P){for(var A=n(u);A!==null;){if(A.callback===null)r(u);else if(A.startTime<=P)r(u),A.sortIndex=A.expirationTime,t(c,A);else break;A=n(u)}}function j(P){if(w=!1,x(P),!k)if(n(c)!==null)k=!0,q(C);else{var A=n(u);A!==null&&Z(j,A.startTime-P)}}function C(P,A){k=!1,w&&(w=!1,p(_),_=-1),v=!0;var T=m;try{for(x(A),f=n(c);f!==null&&(!(f.expirationTime>A)||P&&!B());){var V=f.callback;if(typeof V=="function"){f.callback=null,m=f.priorityLevel;var te=V(f.expirationTime<=A);A=e.unstable_now(),typeof te=="function"?f.callback=te:f===n(c)&&r(c),x(A)}else r(c);f=n(c)}if(f!==null)var O=!0;else{var Q=n(u);Q!==null&&Z(j,Q.startTime-A),O=!1}return O}finally{f=null,m=T,v=!1}}var S=!1,N=null,_=-1,z=5,L=-1;function B(){return!(e.unstable_now()-LP||125V?(P.sortIndex=T,t(u,P),n(c)===null&&P===n(u)&&(w?(p(_),_=-1):w=!0,Z(j,T-V))):(P.sortIndex=te,t(c,P),k||v||(k=!0,q(C))),P},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(P){var A=m;return function(){var T=m;m=A;try{return P.apply(this,arguments)}finally{m=T}}}})(hf);ff.exports=hf;var Rp=ff.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Mp=g,rt=Rp;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),El=Object.prototype.hasOwnProperty,zp=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,lu={},ou={};function Fp(e){return El.call(ou,e)?!0:El.call(lu,e)?!1:zp.test(e)?ou[e]=!0:(lu[e]=!0,!1)}function Ip(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Dp(e,t,n,r){if(t===null||typeof t>"u"||Ip(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Ve(e,t,n,r,s,i,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=l}var Re={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Re[e]=new Ve(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Re[t]=new Ve(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Re[e]=new Ve(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Re[e]=new Ve(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Re[e]=new Ve(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Re[e]=new Ve(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Re[e]=new Ve(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Re[e]=new Ve(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Re[e]=new Ve(e,5,!1,e.toLowerCase(),null,!1,!1)});var Jo=/[\-:]([a-z])/g;function Yo(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Jo,Yo);Re[t]=new Ve(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Jo,Yo);Re[t]=new Ve(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Jo,Yo);Re[t]=new Ve(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Re[e]=new Ve(e,1,!1,e.toLowerCase(),null,!1,!1)});Re.xlinkHref=new Ve("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Re[e]=new Ve(e,1,!1,e.toLowerCase(),null,!0,!0)});function Xo(e,t,n,r){var s=Re.hasOwnProperty(t)?Re[t]:null;(s!==null?s.type!==0:r||!(2o||s[l]!==i[o]){var c=` +`+s[l].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{Ji=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?ys(e):""}function Ap(e){switch(e.tag){case 5:return ys(e.type);case 16:return ys("Lazy");case 13:return ys("Suspense");case 19:return ys("SuspenseList");case 0:case 2:case 15:return e=Yi(e.type,!1),e;case 11:return e=Yi(e.type.render,!1),e;case 1:return e=Yi(e.type,!0),e;default:return""}}function Ll(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case xr:return"Fragment";case pr:return"Portal";case Pl:return"Profiler";case Zo:return"StrictMode";case Tl:return"Suspense";case Ol:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case xf:return(e.displayName||"Context")+".Consumer";case pf:return(e._context.displayName||"Context")+".Provider";case ec:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case tc:return t=e.displayName||null,t!==null?t:Ll(e.type)||"Memo";case tn:t=e._payload,e=e._init;try{return Ll(e(t))}catch{}}return null}function $p(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ll(t);case 8:return t===Zo?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function On(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function yf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Up(e){var t=yf(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(l){r=""+l,i.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ga(e){e._valueTracker||(e._valueTracker=Up(e))}function gf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=yf(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ja(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Rl(e,t){var n=t.checked;return pe({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function uu(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=On(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function jf(e,t){t=t.checked,t!=null&&Xo(e,"checked",t,!1)}function Ml(e,t){jf(e,t);var n=On(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?zl(e,t.type,n):t.hasOwnProperty("defaultValue")&&zl(e,t.type,On(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function du(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function zl(e,t,n){(t!=="number"||Ja(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var gs=Array.isArray;function _r(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=ja.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ms(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var bs={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Bp=["Webkit","ms","Moz","O"];Object.keys(bs).forEach(function(e){Bp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),bs[t]=bs[e]})});function Nf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||bs.hasOwnProperty(e)&&bs[e]?(""+t).trim():t+"px"}function Sf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=Nf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var Qp=pe({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Dl(e,t){if(t){if(Qp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function Al(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var $l=null;function nc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ul=null,Er=null,Pr=null;function mu(e){if(e=ua(e)){if(typeof Ul!="function")throw Error(E(280));var t=e.stateNode;t&&(t=Ti(t),Ul(e.stateNode,e.type,t))}}function Cf(e){Er?Pr?Pr.push(e):Pr=[e]:Er=e}function _f(){if(Er){var e=Er,t=Pr;if(Pr=Er=null,mu(e),t)for(e=0;e>>=0,e===0?32:31-(ex(e)/tx|0)|0}var wa=64,ka=4194304;function js(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function ei(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~s;o!==0?r=js(o):(i&=l,i!==0&&(r=js(i)))}else l=n&~s,l!==0?r=js(l):i!==0&&(r=js(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function oa(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-kt(t),e[t]=n}function ax(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Ss),bu=" ",Nu=!1;function qf(e,t){switch(e){case"keyup":return Rx.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var vr=!1;function zx(e,t){switch(e){case"compositionend":return Wf(t);case"keypress":return t.which!==32?null:(Nu=!0,bu);case"textInput":return e=t.data,e===bu&&Nu?null:e;default:return null}}function Fx(e,t){if(vr)return e==="compositionend"||!uc&&qf(e,t)?(e=Kf(),$a=lc=pn=null,vr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Eu(n)}}function Xf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Xf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Zf(){for(var e=window,t=Ja();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ja(e.document)}return t}function dc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Kx(e){var t=Zf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Xf(n.ownerDocument.documentElement,n)){if(r!==null&&dc(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=Pu(n,i);var l=Pu(n,r);s&&l&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,yr=null,ql=null,_s=null,Wl=!1;function Tu(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Wl||yr==null||yr!==Ja(r)||(r=yr,"selectionStart"in r&&dc(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),_s&&$s(_s,r)||(_s=r,r=ri(ql,"onSelect"),0wr||(e.current=eo[wr],eo[wr]=null,wr--)}function le(e,t){wr++,eo[wr]=e.current,e.current=t}var Ln={},De=zn(Ln),Ge=zn(!1),nr=Ln;function Hr(e,t){var n=e.type.contextTypes;if(!n)return Ln;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function Je(e){return e=e.childContextTypes,e!=null}function ai(){de(Ge),de(De)}function Iu(e,t,n){if(De.current!==Ln)throw Error(E(168));le(De,t),le(Ge,n)}function oh(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(E(108,$p(e)||"Unknown",s));return pe({},n,r)}function ii(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ln,nr=De.current,le(De,e),le(Ge,Ge.current),!0}function Du(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=oh(e,t,nr),r.__reactInternalMemoizedMergedChildContext=e,de(Ge),de(De),le(De,e)):de(Ge),le(Ge,n)}var Ft=null,Oi=!1,dl=!1;function ch(e){Ft===null?Ft=[e]:Ft.push(e)}function rv(e){Oi=!0,ch(e)}function Fn(){if(!dl&&Ft!==null){dl=!0;var e=0,t=ie;try{var n=Ft;for(ie=1;e>=l,s-=l,Ut=1<<32-kt(t)+s|n<_?(z=N,N=null):z=N.sibling;var L=m(p,N,x[_],j);if(L===null){N===null&&(N=z);break}e&&N&&L.alternate===null&&t(p,N),h=i(L,h,_),S===null?C=L:S.sibling=L,S=L,N=z}if(_===x.length)return n(p,N),fe&&An(p,_),C;if(N===null){for(;__?(z=N,N=null):z=N.sibling;var B=m(p,N,L.value,j);if(B===null){N===null&&(N=z);break}e&&N&&B.alternate===null&&t(p,N),h=i(B,h,_),S===null?C=B:S.sibling=B,S=B,N=z}if(L.done)return n(p,N),fe&&An(p,_),C;if(N===null){for(;!L.done;_++,L=x.next())L=f(p,L.value,j),L!==null&&(h=i(L,h,_),S===null?C=L:S.sibling=L,S=L);return fe&&An(p,_),C}for(N=r(p,N);!L.done;_++,L=x.next())L=v(N,p,_,L.value,j),L!==null&&(e&&L.alternate!==null&&N.delete(L.key===null?_:L.key),h=i(L,h,_),S===null?C=L:S.sibling=L,S=L);return e&&N.forEach(function(J){return t(p,J)}),fe&&An(p,_),C}function b(p,h,x,j){if(typeof x=="object"&&x!==null&&x.type===xr&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case ya:e:{for(var C=x.key,S=h;S!==null;){if(S.key===C){if(C=x.type,C===xr){if(S.tag===7){n(p,S.sibling),h=s(S,x.props.children),h.return=p,p=h;break e}}else if(S.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===tn&&Uu(C)===S.type){n(p,S.sibling),h=s(S,x.props),h.ref=hs(p,S,x),h.return=p,p=h;break e}n(p,S);break}else t(p,S);S=S.sibling}x.type===xr?(h=tr(x.props.children,p.mode,j,x.key),h.return=p,p=h):(j=Wa(x.type,x.key,x.props,null,p.mode,j),j.ref=hs(p,h,x),j.return=p,p=j)}return l(p);case pr:e:{for(S=x.key;h!==null;){if(h.key===S)if(h.tag===4&&h.stateNode.containerInfo===x.containerInfo&&h.stateNode.implementation===x.implementation){n(p,h.sibling),h=s(h,x.children||[]),h.return=p,p=h;break e}else{n(p,h);break}else t(p,h);h=h.sibling}h=gl(x,p.mode,j),h.return=p,p=h}return l(p);case tn:return S=x._init,b(p,h,S(x._payload),j)}if(gs(x))return k(p,h,x,j);if(os(x))return w(p,h,x,j);Pa(p,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,h!==null&&h.tag===6?(n(p,h.sibling),h=s(h,x),h.return=p,p=h):(n(p,h),h=yl(x,p.mode,j),h.return=p,p=h),l(p)):n(p,h)}return b}var Wr=hh(!0),mh=hh(!1),ci=zn(null),ui=null,Nr=null,pc=null;function xc(){pc=Nr=ui=null}function vc(e){var t=ci.current;de(ci),e._currentValue=t}function ro(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Or(e,t){ui=e,pc=Nr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(We=!0),e.firstContext=null)}function ft(e){var t=e._currentValue;if(pc!==e)if(e={context:e,memoizedValue:t,next:null},Nr===null){if(ui===null)throw Error(E(308));Nr=e,ui.dependencies={lanes:0,firstContext:e}}else Nr=Nr.next=e;return t}var Bn=null;function yc(e){Bn===null?Bn=[e]:Bn.push(e)}function ph(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,yc(t)):(n.next=s.next,s.next=n),t.interleaved=n,qt(e,r)}function qt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var nn=!1;function gc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function xh(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Qt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Nn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ne&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,qt(e,n)}return s=r.interleaved,s===null?(t.next=t,yc(r)):(t.next=s.next,s.next=t),r.interleaved=t,qt(e,n)}function Ba(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,sc(e,n)}}function Bu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=l:i=i.next=l,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function di(e,t,n,r){var s=e.updateQueue;nn=!1;var i=s.firstBaseUpdate,l=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var c=o,u=c.next;c.next=null,l===null?i=u:l.next=u,l=c;var d=e.alternate;d!==null&&(d=d.updateQueue,o=d.lastBaseUpdate,o!==l&&(o===null?d.firstBaseUpdate=u:o.next=u,d.lastBaseUpdate=c))}if(i!==null){var f=s.baseState;l=0,d=u=c=null,o=i;do{var m=o.lane,v=o.eventTime;if((r&m)===m){d!==null&&(d=d.next={eventTime:v,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var k=e,w=o;switch(m=t,v=n,w.tag){case 1:if(k=w.payload,typeof k=="function"){f=k.call(v,f,m);break e}f=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=w.payload,m=typeof k=="function"?k.call(v,f,m):k,m==null)break e;f=pe({},f,m);break e;case 2:nn=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,m=s.effects,m===null?s.effects=[o]:m.push(o))}else v={eventTime:v,lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},d===null?(u=d=v,c=f):d=d.next=v,l|=m;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;m=o,o=m.next,m.next=null,s.lastBaseUpdate=m,s.shared.pending=null}}while(!0);if(d===null&&(c=f),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=d,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);ar|=l,e.lanes=l,e.memoizedState=f}}function Qu(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=hl.transition;hl.transition={};try{e(!1),t()}finally{ie=n,hl.transition=r}}function Rh(){return ht().memoizedState}function lv(e,t,n){var r=Cn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Mh(e))zh(t,n);else if(n=ph(e,t,n,r),n!==null){var s=Be();bt(n,e,r,s),Fh(n,t,r)}}function ov(e,t,n){var r=Cn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Mh(e))zh(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var l=t.lastRenderedState,o=i(l,n);if(s.hasEagerState=!0,s.eagerState=o,Nt(o,l)){var c=t.interleaved;c===null?(s.next=s,yc(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=ph(e,t,s,r),n!==null&&(s=Be(),bt(n,e,r,s),Fh(n,t,r))}}function Mh(e){var t=e.alternate;return e===me||t!==null&&t===me}function zh(e,t){Es=hi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Fh(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,sc(e,n)}}var mi={readContext:ft,useCallback:Me,useContext:Me,useEffect:Me,useImperativeHandle:Me,useInsertionEffect:Me,useLayoutEffect:Me,useMemo:Me,useReducer:Me,useRef:Me,useState:Me,useDebugValue:Me,useDeferredValue:Me,useTransition:Me,useMutableSource:Me,useSyncExternalStore:Me,useId:Me,unstable_isNewReconciler:!1},cv={readContext:ft,useCallback:function(e,t){return Ct().memoizedState=[e,t===void 0?null:t],e},useContext:ft,useEffect:Ku,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Va(4194308,4,Eh.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Va(4194308,4,e,t)},useInsertionEffect:function(e,t){return Va(4,2,e,t)},useMemo:function(e,t){var n=Ct();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Ct();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=lv.bind(null,me,e),[r.memoizedState,e]},useRef:function(e){var t=Ct();return e={current:e},t.memoizedState=e},useState:Vu,useDebugValue:_c,useDeferredValue:function(e){return Ct().memoizedState=e},useTransition:function(){var e=Vu(!1),t=e[0];return e=iv.bind(null,e[1]),Ct().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=me,s=Ct();if(fe){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),Te===null)throw Error(E(349));sr&30||jh(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Ku(kh.bind(null,r,i,e),[e]),r.flags|=2048,Ws(9,wh.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Ct(),t=Te.identifierPrefix;if(fe){var n=Bt,r=Ut;n=(r&~(1<<32-kt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Hs++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[Tt]=t,e[Qs]=r,Hh(e,t,!1,!1),t.stateNode=e;e:{switch(l=Al(n,r),n){case"dialog":ue("cancel",e),ue("close",e),s=r;break;case"iframe":case"object":case"embed":ue("load",e),s=r;break;case"video":case"audio":for(s=0;sYr&&(t.flags|=128,r=!0,ms(i,!1),t.lanes=4194304)}else{if(!r)if(e=fi(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ms(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!fe)return ze(t),null}else 2*je()-i.renderingStartTime>Yr&&n!==1073741824&&(t.flags|=128,r=!0,ms(i,!1),t.lanes=4194304);i.isBackwards?(l.sibling=t.child,t.child=l):(n=i.last,n!==null?n.sibling=l:t.child=l,i.last=l)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=je(),t.sibling=null,n=he.current,le(he,r?n&1|2:n&1),t):(ze(t),null);case 22:case 23:return Rc(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?et&1073741824&&(ze(t),t.subtreeFlags&6&&(t.flags|=8192)):ze(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function vv(e,t){switch(hc(t),t.tag){case 1:return Je(t.type)&&ai(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Gr(),de(Ge),de(De),kc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return wc(t),null;case 13:if(de(he),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));qr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return de(he),null;case 4:return Gr(),null;case 10:return vc(t.type._context),null;case 22:case 23:return Rc(),null;case 24:return null;default:return null}}var Oa=!1,Ie=!1,yv=typeof WeakSet=="function"?WeakSet:Set,I=null;function Sr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ve(e,t,r)}else n.current=null}function ho(e,t,n){try{n()}catch(r){ve(e,t,r)}}var nd=!1;function gv(e,t){if(Gl=ti,e=Zf(),dc(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var l=0,o=-1,c=-1,u=0,d=0,f=e,m=null;t:for(;;){for(var v;f!==n||s!==0&&f.nodeType!==3||(o=l+s),f!==i||r!==0&&f.nodeType!==3||(c=l+r),f.nodeType===3&&(l+=f.nodeValue.length),(v=f.firstChild)!==null;)m=f,f=v;for(;;){if(f===e)break t;if(m===n&&++u===s&&(o=l),m===i&&++d===r&&(c=l),(v=f.nextSibling)!==null)break;f=m,m=f.parentNode}f=v}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Jl={focusedElem:e,selectionRange:n},ti=!1,I=t;I!==null;)if(t=I,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,I=e;else for(;I!==null;){t=I;try{var k=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(k!==null){var w=k.memoizedProps,b=k.memoizedState,p=t.stateNode,h=p.getSnapshotBeforeUpdate(t.elementType===t.type?w:xt(t.type,w),b);p.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(j){ve(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,I=e;break}I=t.return}return k=nd,nd=!1,k}function Ps(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&ho(t,n,i)}s=s.next}while(s!==r)}}function Mi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function mo(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Gh(e){var t=e.alternate;t!==null&&(e.alternate=null,Gh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Tt],delete t[Qs],delete t[Zl],delete t[tv],delete t[nv])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Jh(e){return e.tag===5||e.tag===3||e.tag===4}function rd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Jh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function po(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=si));else if(r!==4&&(e=e.child,e!==null))for(po(e,t,n),e=e.sibling;e!==null;)po(e,t,n),e=e.sibling}function xo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(xo(e,t,n),e=e.sibling;e!==null;)xo(e,t,n),e=e.sibling}var Oe=null,gt=!1;function Zt(e,t,n){for(n=n.child;n!==null;)Yh(e,t,n),n=n.sibling}function Yh(e,t,n){if(Ot&&typeof Ot.onCommitFiberUnmount=="function")try{Ot.onCommitFiberUnmount(Ci,n)}catch{}switch(n.tag){case 5:Ie||Sr(n,t);case 6:var r=Oe,s=gt;Oe=null,Zt(e,t,n),Oe=r,gt=s,Oe!==null&&(gt?(e=Oe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Oe.removeChild(n.stateNode));break;case 18:Oe!==null&&(gt?(e=Oe,n=n.stateNode,e.nodeType===8?ul(e.parentNode,n):e.nodeType===1&&ul(e,n),Ds(e)):ul(Oe,n.stateNode));break;case 4:r=Oe,s=gt,Oe=n.stateNode.containerInfo,gt=!0,Zt(e,t,n),Oe=r,gt=s;break;case 0:case 11:case 14:case 15:if(!Ie&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,l=i.destroy;i=i.tag,l!==void 0&&(i&2||i&4)&&ho(n,t,l),s=s.next}while(s!==r)}Zt(e,t,n);break;case 1:if(!Ie&&(Sr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){ve(n,t,o)}Zt(e,t,n);break;case 21:Zt(e,t,n);break;case 22:n.mode&1?(Ie=(r=Ie)||n.memoizedState!==null,Zt(e,t,n),Ie=r):Zt(e,t,n);break;default:Zt(e,t,n)}}function sd(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new yv),t.forEach(function(r){var s=Ev.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function mt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=l),r&=~i}if(r=s,r=je()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*wv(r/1960))-r,10e?16:e,xn===null)var r=!1;else{if(e=xn,xn=null,vi=0,ne&6)throw Error(E(331));var s=ne;for(ne|=4,I=e.current;I!==null;){var i=I,l=i.child;if(I.flags&16){var o=i.deletions;if(o!==null){for(var c=0;cje()-Oc?er(e,0):Tc|=n),Ye(e,t)}function am(e,t){t===0&&(e.mode&1?(t=ka,ka<<=1,!(ka&130023424)&&(ka=4194304)):t=1);var n=Be();e=qt(e,t),e!==null&&(oa(e,t,n),Ye(e,n))}function _v(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),am(e,n)}function Ev(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),am(e,n)}var im;im=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ge.current)We=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return We=!1,pv(e,t,n);We=!!(e.flags&131072)}else We=!1,fe&&t.flags&1048576&&uh(t,oi,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ka(e,t),e=t.pendingProps;var s=Hr(t,De.current);Or(t,n),s=Nc(null,t,r,e,s,n);var i=Sc();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Je(r)?(i=!0,ii(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,gc(t),s.updater=Ri,t.stateNode=s,s._reactInternals=t,ao(t,r,e,n),t=oo(null,t,r,!0,i,n)):(t.tag=0,fe&&i&&fc(t),$e(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ka(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=Tv(r),e=xt(r,e),s){case 0:t=lo(null,t,r,e,n);break e;case 1:t=Zu(null,t,r,e,n);break e;case 11:t=Yu(null,t,r,e,n);break e;case 14:t=Xu(null,t,r,xt(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:xt(r,s),lo(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:xt(r,s),Zu(e,t,r,s,n);case 3:e:{if(Qh(t),e===null)throw Error(E(387));r=t.pendingProps,i=t.memoizedState,s=i.element,xh(e,t),di(t,r,null,n);var l=t.memoizedState;if(r=l.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=Jr(Error(E(423)),t),t=ed(e,t,r,n,s);break e}else if(r!==s){s=Jr(Error(E(424)),t),t=ed(e,t,r,n,s);break e}else for(tt=bn(t.stateNode.containerInfo.firstChild),nt=t,fe=!0,jt=null,n=mh(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(qr(),r===s){t=Wt(e,t,n);break e}$e(e,t,r,n)}t=t.child}return t;case 5:return vh(t),e===null&&no(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,l=s.children,Yl(r,s)?l=null:i!==null&&Yl(r,i)&&(t.flags|=32),Bh(e,t),$e(e,t,l,n),t.child;case 6:return e===null&&no(t),null;case 13:return Vh(e,t,n);case 4:return jc(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Wr(t,null,r,n):$e(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:xt(r,s),Yu(e,t,r,s,n);case 7:return $e(e,t,t.pendingProps,n),t.child;case 8:return $e(e,t,t.pendingProps.children,n),t.child;case 12:return $e(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,l=s.value,le(ci,r._currentValue),r._currentValue=l,i!==null)if(Nt(i.value,l)){if(i.children===s.children&&!Ge.current){t=Wt(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var o=i.dependencies;if(o!==null){l=i.child;for(var c=o.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=Qt(-1,n&-n),c.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),ro(i.return,n,t),o.lanes|=n;break}c=c.next}}else if(i.tag===10)l=i.type===t.type?null:i.child;else if(i.tag===18){if(l=i.return,l===null)throw Error(E(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),ro(l,n,t),l=i.sibling}else l=i.child;if(l!==null)l.return=i;else for(l=i;l!==null;){if(l===t){l=null;break}if(i=l.sibling,i!==null){i.return=l.return,l=i;break}l=l.return}i=l}$e(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Or(t,n),s=ft(s),r=r(s),t.flags|=1,$e(e,t,r,n),t.child;case 14:return r=t.type,s=xt(r,t.pendingProps),s=xt(r.type,s),Xu(e,t,r,s,n);case 15:return $h(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:xt(r,s),Ka(e,t),t.tag=1,Je(r)?(e=!0,ii(t)):e=!1,Or(t,n),Ih(t,r,s),ao(t,r,s,n),oo(null,t,r,!0,e,n);case 19:return Kh(e,t,n);case 22:return Uh(e,t,n)}throw Error(E(156,t.tag))};function lm(e,t){return Mf(e,t)}function Pv(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ut(e,t,n,r){return new Pv(e,t,n,r)}function zc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Tv(e){if(typeof e=="function")return zc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ec)return 11;if(e===tc)return 14}return 2}function _n(e,t){var n=e.alternate;return n===null?(n=ut(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Wa(e,t,n,r,s,i){var l=2;if(r=e,typeof e=="function")zc(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case xr:return tr(n.children,s,i,t);case Zo:l=8,s|=8;break;case Pl:return e=ut(12,n,t,s|2),e.elementType=Pl,e.lanes=i,e;case Tl:return e=ut(13,n,t,s),e.elementType=Tl,e.lanes=i,e;case Ol:return e=ut(19,n,t,s),e.elementType=Ol,e.lanes=i,e;case vf:return Fi(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case pf:l=10;break e;case xf:l=9;break e;case ec:l=11;break e;case tc:l=14;break e;case tn:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=ut(l,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function tr(e,t,n,r){return e=ut(7,e,r,t),e.lanes=n,e}function Fi(e,t,n,r){return e=ut(22,e,r,t),e.elementType=vf,e.lanes=n,e.stateNode={isHidden:!1},e}function yl(e,t,n){return e=ut(6,e,null,t),e.lanes=n,e}function gl(e,t,n){return t=ut(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Ov(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Zi(0),this.expirationTimes=Zi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Zi(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Fc(e,t,n,r,s,i,l,o,c){return e=new Ov(e,t,n,o,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=ut(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},gc(i),e}function Lv(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(dm)}catch(e){console.error(e)}}dm(),df.exports=st;var Iv=df.exports,fd=Iv;_l.createRoot=fd.createRoot,_l.hydrateRoot=fd.hydrateRoot;var ss=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Dv={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},an,Vo,Ud,Av=(Ud=class{constructor(){$(this,an,Dv);$(this,Vo,!1)}setTimeoutProvider(e){M(this,an,e)}setTimeout(e,t){return y(this,an).setTimeout(e,t)}clearTimeout(e){y(this,an).clearTimeout(e)}setInterval(e,t){return y(this,an).setInterval(e,t)}clearInterval(e){y(this,an).clearInterval(e)}},an=new WeakMap,Vo=new WeakMap,Ud),Vn=new Av;function $v(e){setTimeout(e,0)}var lr=typeof window>"u"||"Deno"in globalThis;function Ue(){}function Uv(e,t){return typeof e=="function"?e(t):e}function wo(e){return typeof e=="number"&&e>=0&&e!==1/0}function fm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function En(e,t){return typeof e=="function"?e(t):e}function lt(e,t){return typeof e=="function"?e(t):e}function hd(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:i,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==$c(l,t.options))return!1}else if(!Js(t.queryKey,l))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||s&&s!==t.state.fetchStatus||i&&!i(t))}function md(e,t){const{exact:n,status:r,predicate:s,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(or(t.options.mutationKey)!==or(i))return!1}else if(!Js(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function $c(e,t){return((t==null?void 0:t.queryKeyHashFn)||or)(e)}function or(e){return JSON.stringify(e,(t,n)=>ko(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function Js(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Js(e[n],t[n])):!1}var Bv=Object.prototype.hasOwnProperty;function hm(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=pd(e)&&pd(t);if(!r&&!(ko(e)&&ko(t)))return t;const i=(r?e:Object.keys(e)).length,l=r?t:Object.keys(t),o=l.length,c=r?new Array(o):{};let u=0;for(let d=0;d{Vn.setTimeout(t,e)})}function bo(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?hm(e,t):t}function Vv(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Kv(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Uc=Symbol();function mm(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Uc?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Bc(e,t){return typeof e=="function"?e(...t):!!e}function Hv(e,t,n){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),e}var Kn,ln,Rr,Bd,qv=(Bd=class extends ss{constructor(){super();$(this,Kn);$(this,ln);$(this,Rr);M(this,Rr,t=>{if(!lr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){y(this,ln)||this.setEventListener(y(this,Rr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,ln))==null||t.call(this),M(this,ln,void 0))}setEventListener(t){var n;M(this,Rr,t),(n=y(this,ln))==null||n.call(this),M(this,ln,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){y(this,Kn)!==t&&(M(this,Kn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof y(this,Kn)=="boolean"?y(this,Kn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Kn=new WeakMap,ln=new WeakMap,Rr=new WeakMap,Bd),Qc=new qv;function No(){let e,t;const n=new Promise((s,i)=>{e=s,t=i});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var Wv=$v;function Gv(){let e=[],t=0,n=o=>{o()},r=o=>{o()},s=Wv;const i=o=>{t?e.push(o):s(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&s(()=>{r(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;t++;try{c=o()}finally{t--,t||l()}return c},batchCalls:o=>(...c)=>{i(()=>{o(...c)})},schedule:i,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{s=o}}}var Ne=Gv(),Mr,on,zr,Qd,Jv=(Qd=class extends ss{constructor(){super();$(this,Mr,!0);$(this,on);$(this,zr);M(this,zr,t=>{if(!lr&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){y(this,on)||this.setEventListener(y(this,zr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,on))==null||t.call(this),M(this,on,void 0))}setEventListener(t){var n;M(this,zr,t),(n=y(this,on))==null||n.call(this),M(this,on,t(this.setOnline.bind(this)))}setOnline(t){y(this,Mr)!==t&&(M(this,Mr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return y(this,Mr)}},Mr=new WeakMap,on=new WeakMap,zr=new WeakMap,Qd),wi=new Jv;function Yv(e){return Math.min(1e3*2**e,3e4)}function pm(e){return(e??"online")==="online"?wi.isOnline():!0}var So=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function xm(e){let t=!1,n=0,r;const s=No(),i=()=>s.status!=="pending",l=w=>{var b;if(!i()){const p=new So(w);m(p),(b=e.onCancel)==null||b.call(e,p)}},o=()=>{t=!0},c=()=>{t=!1},u=()=>Qc.isFocused()&&(e.networkMode==="always"||wi.isOnline())&&e.canRun(),d=()=>pm(e.networkMode)&&e.canRun(),f=w=>{i()||(r==null||r(),s.resolve(w))},m=w=>{i()||(r==null||r(),s.reject(w))},v=()=>new Promise(w=>{var b;r=p=>{(i()||u())&&w(p)},(b=e.onPause)==null||b.call(e)}).then(()=>{var w;r=void 0,i()||(w=e.onContinue)==null||w.call(e)}),k=()=>{if(i())return;let w;const b=n===0?e.initialPromise:void 0;try{w=b??e.fn()}catch(p){w=Promise.reject(p)}Promise.resolve(w).then(f).catch(p=>{var S;if(i())return;const h=e.retry??(lr?0:3),x=e.retryDelay??Yv,j=typeof x=="function"?x(n,p):x,C=h===!0||typeof h=="number"&&nu()?void 0:v()).then(()=>{t?m(p):k()})})};return{promise:s,status:()=>s.status,cancel:l,continue:()=>(r==null||r(),s),cancelRetry:o,continueRetry:c,canStart:d,start:()=>(d()?k():v().then(k),s)}}var Hn,Vd,vm=(Vd=class{constructor(){$(this,Hn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),wo(this.gcTime)&&M(this,Hn,Vn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(lr?1/0:5*60*1e3))}clearGcTimeout(){y(this,Hn)&&(Vn.clearTimeout(y(this,Hn)),M(this,Hn,void 0))}},Hn=new WeakMap,Vd),qn,Fr,it,Wn,Ee,na,Gn,vt,Mt,Kd,Xv=(Kd=class extends vm{constructor(t){super();$(this,vt);$(this,qn);$(this,Fr);$(this,it);$(this,Wn);$(this,Ee);$(this,na);$(this,Gn);M(this,Gn,!1),M(this,na,t.defaultOptions),this.setOptions(t.options),this.observers=[],M(this,Wn,t.client),M(this,it,y(this,Wn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,M(this,qn,yd(this.options)),this.state=t.state??y(this,qn),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=y(this,Ee))==null?void 0:t.promise}setOptions(t){if(this.options={...y(this,na),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=yd(this.options);n.data!==void 0&&(this.setState(vd(n.data,n.dataUpdatedAt)),M(this,qn,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&y(this,it).remove(this)}setData(t,n){const r=bo(this.state.data,t,this.options);return W(this,vt,Mt).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){W(this,vt,Mt).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=y(this,Ee))==null?void 0:r.promise;return(s=y(this,Ee))==null||s.cancel(t),n?n.then(Ue).catch(Ue):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(y(this,qn))}isActive(){return this.observers.some(t=>lt(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Uc||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>En(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!fm(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ee))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ee))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),y(this,it).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(y(this,Ee)&&(y(this,Gn)?y(this,Ee).cancel({revert:!0}):y(this,Ee).cancelRetry()),this.scheduleGc()),y(this,it).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||W(this,vt,Mt).call(this,{type:"invalidate"})}async fetch(t,n){var c,u,d,f,m,v,k,w,b,p,h,x;if(this.state.fetchStatus!=="idle"&&((c=y(this,Ee))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(y(this,Ee))return y(this,Ee).continueRetry(),y(this,Ee).promise}if(t&&this.setOptions(t),!this.options.queryFn){const j=this.observers.find(C=>C.options.queryFn);j&&this.setOptions(j.options)}const r=new AbortController,s=j=>{Object.defineProperty(j,"signal",{enumerable:!0,get:()=>(M(this,Gn,!0),r.signal)})},i=()=>{const j=mm(this.options,n),S=(()=>{const N={client:y(this,Wn),queryKey:this.queryKey,meta:this.meta};return s(N),N})();return M(this,Gn,!1),this.options.persister?this.options.persister(j,S,this):j(S)},o=(()=>{const j={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:y(this,Wn),state:this.state,fetchFn:i};return s(j),j})();(u=this.options.behavior)==null||u.onFetch(o,this),M(this,Fr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=o.fetchOptions)==null?void 0:d.meta))&&W(this,vt,Mt).call(this,{type:"fetch",meta:(f=o.fetchOptions)==null?void 0:f.meta}),M(this,Ee,xm({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:j=>{j instanceof So&&j.revert&&this.setState({...y(this,Fr),fetchStatus:"idle"}),r.abort()},onFail:(j,C)=>{W(this,vt,Mt).call(this,{type:"failed",failureCount:j,error:C})},onPause:()=>{W(this,vt,Mt).call(this,{type:"pause"})},onContinue:()=>{W(this,vt,Mt).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const j=await y(this,Ee).start();if(j===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(j),(v=(m=y(this,it).config).onSuccess)==null||v.call(m,j,this),(w=(k=y(this,it).config).onSettled)==null||w.call(k,j,this.state.error,this),j}catch(j){if(j instanceof So){if(j.silent)return y(this,Ee).promise;if(j.revert){if(this.state.data===void 0)throw j;return this.state.data}}throw W(this,vt,Mt).call(this,{type:"error",error:j}),(p=(b=y(this,it).config).onError)==null||p.call(b,j,this),(x=(h=y(this,it).config).onSettled)==null||x.call(h,this.state.data,j,this),j}finally{this.scheduleGc()}}},qn=new WeakMap,Fr=new WeakMap,it=new WeakMap,Wn=new WeakMap,Ee=new WeakMap,na=new WeakMap,Gn=new WeakMap,vt=new WeakSet,Mt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...ym(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...vd(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return M(this,Fr,t.manual?s:void 0),s;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Ne.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),y(this,it).notify({query:this,type:"updated",action:t})})},Kd);function ym(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:pm(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function vd(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function yd(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Ke,ee,ra,Ae,Jn,Ir,It,cn,sa,Dr,Ar,Yn,Xn,un,$r,ae,ks,Co,_o,Eo,Po,To,Oo,Lo,gm,Hd,Zv=(Hd=class extends ss{constructor(t,n){super();$(this,ae);$(this,Ke);$(this,ee);$(this,ra);$(this,Ae);$(this,Jn);$(this,Ir);$(this,It);$(this,cn);$(this,sa);$(this,Dr);$(this,Ar);$(this,Yn);$(this,Xn);$(this,un);$(this,$r,new Set);this.options=n,M(this,Ke,t),M(this,cn,null),M(this,It,No()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(y(this,ee).addObserver(this),gd(y(this,ee),this.options)?W(this,ae,ks).call(this):this.updateResult(),W(this,ae,Po).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ro(y(this,ee),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ro(y(this,ee),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,W(this,ae,To).call(this),W(this,ae,Oo).call(this),y(this,ee).removeObserver(this)}setOptions(t){const n=this.options,r=y(this,ee);if(this.options=y(this,Ke).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof lt(this.options.enabled,y(this,ee))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");W(this,ae,Lo).call(this),y(this,ee).setOptions(this.options),n._defaulted&&!ji(this.options,n)&&y(this,Ke).getQueryCache().notify({type:"observerOptionsUpdated",query:y(this,ee),observer:this});const s=this.hasListeners();s&&jd(y(this,ee),r,this.options,n)&&W(this,ae,ks).call(this),this.updateResult(),s&&(y(this,ee)!==r||lt(this.options.enabled,y(this,ee))!==lt(n.enabled,y(this,ee))||En(this.options.staleTime,y(this,ee))!==En(n.staleTime,y(this,ee)))&&W(this,ae,Co).call(this);const i=W(this,ae,_o).call(this);s&&(y(this,ee)!==r||lt(this.options.enabled,y(this,ee))!==lt(n.enabled,y(this,ee))||i!==y(this,un))&&W(this,ae,Eo).call(this,i)}getOptimisticResult(t){const n=y(this,Ke).getQueryCache().build(y(this,Ke),t),r=this.createResult(n,t);return ty(this,r)&&(M(this,Ae,r),M(this,Ir,this.options),M(this,Jn,y(this,ee).state)),r}getCurrentResult(){return y(this,Ae)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&y(this,It).status==="pending"&&y(this,It).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){y(this,$r).add(t)}getCurrentQuery(){return y(this,ee)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=y(this,Ke).defaultQueryOptions(t),r=y(this,Ke).getQueryCache().build(y(this,Ke),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return W(this,ae,ks).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),y(this,Ae)))}createResult(t,n){var z;const r=y(this,ee),s=this.options,i=y(this,Ae),l=y(this,Jn),o=y(this,Ir),u=t!==r?t.state:y(this,ra),{state:d}=t;let f={...d},m=!1,v;if(n._optimisticResults){const L=this.hasListeners(),B=!L&&gd(t,n),J=L&&jd(t,r,n,s);(B||J)&&(f={...f,...ym(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:k,errorUpdatedAt:w,status:b}=f;v=f.data;let p=!1;if(n.placeholderData!==void 0&&v===void 0&&b==="pending"){let L;i!=null&&i.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(L=i.data,p=!0):L=typeof n.placeholderData=="function"?n.placeholderData((z=y(this,Ar))==null?void 0:z.state.data,y(this,Ar)):n.placeholderData,L!==void 0&&(b="success",v=bo(i==null?void 0:i.data,L,n),m=!0)}if(n.select&&v!==void 0&&!p)if(i&&v===(l==null?void 0:l.data)&&n.select===y(this,sa))v=y(this,Dr);else try{M(this,sa,n.select),v=n.select(v),v=bo(i==null?void 0:i.data,v,n),M(this,Dr,v),M(this,cn,null)}catch(L){M(this,cn,L)}y(this,cn)&&(k=y(this,cn),v=y(this,Dr),w=Date.now(),b="error");const h=f.fetchStatus==="fetching",x=b==="pending",j=b==="error",C=x&&h,S=v!==void 0,_={status:b,fetchStatus:f.fetchStatus,isPending:x,isSuccess:b==="success",isError:j,isInitialLoading:C,isLoading:C,data:v,dataUpdatedAt:f.dataUpdatedAt,error:k,errorUpdatedAt:w,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:h,isRefetching:h&&!x,isLoadingError:j&&!S,isPaused:f.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:j&&S,isStale:Vc(t,n),refetch:this.refetch,promise:y(this,It),isEnabled:lt(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const L=_.data!==void 0,B=_.status==="error"&&!L,J=D=>{B?D.reject(_.error):L&&D.resolve(_.data)},re=()=>{const D=M(this,It,_.promise=No());J(D)},ce=y(this,It);switch(ce.status){case"pending":t.queryHash===r.queryHash&&J(ce);break;case"fulfilled":(B||_.data!==ce.value)&&re();break;case"rejected":(!B||_.error!==ce.reason)&&re();break}}return _}updateResult(){const t=y(this,Ae),n=this.createResult(y(this,ee),this.options);if(M(this,Jn,y(this,ee).state),M(this,Ir,this.options),y(this,Jn).data!==void 0&&M(this,Ar,y(this,ee)),ji(n,t))return;M(this,Ae,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!y(this,$r).size)return!0;const l=new Set(i??y(this,$r));return this.options.throwOnError&&l.add("error"),Object.keys(y(this,Ae)).some(o=>{const c=o;return y(this,Ae)[c]!==t[c]&&l.has(c)})};W(this,ae,gm).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&W(this,ae,Po).call(this)}},Ke=new WeakMap,ee=new WeakMap,ra=new WeakMap,Ae=new WeakMap,Jn=new WeakMap,Ir=new WeakMap,It=new WeakMap,cn=new WeakMap,sa=new WeakMap,Dr=new WeakMap,Ar=new WeakMap,Yn=new WeakMap,Xn=new WeakMap,un=new WeakMap,$r=new WeakMap,ae=new WeakSet,ks=function(t){W(this,ae,Lo).call(this);let n=y(this,ee).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Ue)),n},Co=function(){W(this,ae,To).call(this);const t=En(this.options.staleTime,y(this,ee));if(lr||y(this,Ae).isStale||!wo(t))return;const r=fm(y(this,Ae).dataUpdatedAt,t)+1;M(this,Yn,Vn.setTimeout(()=>{y(this,Ae).isStale||this.updateResult()},r))},_o=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(y(this,ee)):this.options.refetchInterval)??!1},Eo=function(t){W(this,ae,Oo).call(this),M(this,un,t),!(lr||lt(this.options.enabled,y(this,ee))===!1||!wo(y(this,un))||y(this,un)===0)&&M(this,Xn,Vn.setInterval(()=>{(this.options.refetchIntervalInBackground||Qc.isFocused())&&W(this,ae,ks).call(this)},y(this,un)))},Po=function(){W(this,ae,Co).call(this),W(this,ae,Eo).call(this,W(this,ae,_o).call(this))},To=function(){y(this,Yn)&&(Vn.clearTimeout(y(this,Yn)),M(this,Yn,void 0))},Oo=function(){y(this,Xn)&&(Vn.clearInterval(y(this,Xn)),M(this,Xn,void 0))},Lo=function(){const t=y(this,Ke).getQueryCache().build(y(this,Ke),this.options);if(t===y(this,ee))return;const n=y(this,ee);M(this,ee,t),M(this,ra,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},gm=function(t){Ne.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(y(this,Ae))}),y(this,Ke).getQueryCache().notify({query:y(this,ee),type:"observerResultsUpdated"})})},Hd);function ey(e,t){return lt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function gd(e,t){return ey(e,t)||e.state.data!==void 0&&Ro(e,t,t.refetchOnMount)}function Ro(e,t,n){if(lt(t.enabled,e)!==!1&&En(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Vc(e,t)}return!1}function jd(e,t,n,r){return(e!==t||lt(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Vc(e,n)}function Vc(e,t){return lt(t.enabled,e)!==!1&&e.isStaleByTime(En(t.staleTime,e))}function ty(e,t){return!ji(e.getCurrentResult(),t)}function wd(e){return{onFetch:(t,n)=>{var d,f,m,v,k;const r=t.options,s=(m=(f=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:f.fetchMore)==null?void 0:m.direction,i=((v=t.state.data)==null?void 0:v.pages)||[],l=((k=t.state.data)==null?void 0:k.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const u=async()=>{let w=!1;const b=x=>{Hv(x,()=>t.signal,()=>w=!0)},p=mm(t.options,t.fetchOptions),h=async(x,j,C)=>{if(w)return Promise.reject();if(j==null&&x.pages.length)return Promise.resolve(x);const N=(()=>{const B={client:t.client,queryKey:t.queryKey,pageParam:j,direction:C?"backward":"forward",meta:t.options.meta};return b(B),B})(),_=await p(N),{maxPages:z}=t.options,L=C?Kv:Vv;return{pages:L(x.pages,_,z),pageParams:L(x.pageParams,j,z)}};if(s&&i.length){const x=s==="backward",j=x?ny:kd,C={pages:i,pageParams:l},S=j(r,C);o=await h(C,S,x)}else{const x=e??i.length;do{const j=c===0?l[0]??r.initialPageParam:kd(r,o);if(c>0&&j==null)break;o=await h(o,j),c++}while(c{var w,b;return(b=(w=t.options).persister)==null?void 0:b.call(w,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function kd(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function ny(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var aa,_t,Fe,Zn,Et,en,qd,ry=(qd=class extends vm{constructor(t){super();$(this,Et);$(this,aa);$(this,_t);$(this,Fe);$(this,Zn);M(this,aa,t.client),this.mutationId=t.mutationId,M(this,Fe,t.mutationCache),M(this,_t,[]),this.state=t.state||jm(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){y(this,_t).includes(t)||(y(this,_t).push(t),this.clearGcTimeout(),y(this,Fe).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){M(this,_t,y(this,_t).filter(n=>n!==t)),this.scheduleGc(),y(this,Fe).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){y(this,_t).length||(this.state.status==="pending"?this.scheduleGc():y(this,Fe).remove(this))}continue(){var t;return((t=y(this,Zn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,u,d,f,m,v,k,w,b,p,h,x,j,C,S,N;const n=()=>{W(this,Et,en).call(this,{type:"continue"})},r={client:y(this,aa),meta:this.options.meta,mutationKey:this.options.mutationKey};M(this,Zn,xm({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(_,z)=>{W(this,Et,en).call(this,{type:"failed",failureCount:_,error:z})},onPause:()=>{W(this,Et,en).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>y(this,Fe).canRun(this)}));const s=this.state.status==="pending",i=!y(this,Zn).canStart();try{if(s)n();else{W(this,Et,en).call(this,{type:"pending",variables:t,isPaused:i}),y(this,Fe).config.onMutate&&await y(this,Fe).config.onMutate(t,this,r);const z=await((o=(l=this.options).onMutate)==null?void 0:o.call(l,t,r));z!==this.state.context&&W(this,Et,en).call(this,{type:"pending",context:z,variables:t,isPaused:i})}const _=await y(this,Zn).start();return await((u=(c=y(this,Fe).config).onSuccess)==null?void 0:u.call(c,_,t,this.state.context,this,r)),await((f=(d=this.options).onSuccess)==null?void 0:f.call(d,_,t,this.state.context,r)),await((v=(m=y(this,Fe).config).onSettled)==null?void 0:v.call(m,_,null,this.state.variables,this.state.context,this,r)),await((w=(k=this.options).onSettled)==null?void 0:w.call(k,_,null,t,this.state.context,r)),W(this,Et,en).call(this,{type:"success",data:_}),_}catch(_){try{await((p=(b=y(this,Fe).config).onError)==null?void 0:p.call(b,_,t,this.state.context,this,r))}catch(z){Promise.reject(z)}try{await((x=(h=this.options).onError)==null?void 0:x.call(h,_,t,this.state.context,r))}catch(z){Promise.reject(z)}try{await((C=(j=y(this,Fe).config).onSettled)==null?void 0:C.call(j,void 0,_,this.state.variables,this.state.context,this,r))}catch(z){Promise.reject(z)}try{await((N=(S=this.options).onSettled)==null?void 0:N.call(S,void 0,_,t,this.state.context,r))}catch(z){Promise.reject(z)}throw W(this,Et,en).call(this,{type:"error",error:_}),_}finally{y(this,Fe).runNext(this)}}},aa=new WeakMap,_t=new WeakMap,Fe=new WeakMap,Zn=new WeakMap,Et=new WeakSet,en=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Ne.batch(()=>{y(this,_t).forEach(r=>{r.onMutationUpdate(t)}),y(this,Fe).notify({mutation:this,type:"updated",action:t})})},qd);function jm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Dt,yt,ia,Wd,sy=(Wd=class extends ss{constructor(t={}){super();$(this,Dt);$(this,yt);$(this,ia);this.config=t,M(this,Dt,new Set),M(this,yt,new Map),M(this,ia,0)}build(t,n,r){const s=new ry({client:t,mutationCache:this,mutationId:++xa(this,ia)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){y(this,Dt).add(t);const n=Ma(t);if(typeof n=="string"){const r=y(this,yt).get(n);r?r.push(t):y(this,yt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(y(this,Dt).delete(t)){const n=Ma(t);if(typeof n=="string"){const r=y(this,yt).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&y(this,yt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Ma(t);if(typeof n=="string"){const r=y(this,yt).get(n),s=r==null?void 0:r.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=Ma(t);if(typeof n=="string"){const s=(r=y(this,yt).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Ne.batch(()=>{y(this,Dt).forEach(t=>{this.notify({type:"removed",mutation:t})}),y(this,Dt).clear(),y(this,yt).clear()})}getAll(){return Array.from(y(this,Dt))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>md(n,r))}findAll(t={}){return this.getAll().filter(n=>md(t,n))}notify(t){Ne.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Ne.batch(()=>Promise.all(t.map(n=>n.continue().catch(Ue))))}},Dt=new WeakMap,yt=new WeakMap,ia=new WeakMap,Wd);function Ma(e){var t;return(t=e.options.scope)==null?void 0:t.id}var At,dn,He,$t,Vt,Ga,Mo,Gd,ay=(Gd=class extends ss{constructor(n,r){super();$(this,Vt);$(this,At);$(this,dn);$(this,He);$(this,$t);M(this,At,n),this.setOptions(r),this.bindMethods(),W(this,Vt,Ga).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=y(this,At).defaultMutationOptions(n),ji(this.options,r)||y(this,At).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,He),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&or(r.mutationKey)!==or(this.options.mutationKey)?this.reset():((s=y(this,He))==null?void 0:s.state.status)==="pending"&&y(this,He).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=y(this,He))==null||n.removeObserver(this)}onMutationUpdate(n){W(this,Vt,Ga).call(this),W(this,Vt,Mo).call(this,n)}getCurrentResult(){return y(this,dn)}reset(){var n;(n=y(this,He))==null||n.removeObserver(this),M(this,He,void 0),W(this,Vt,Ga).call(this),W(this,Vt,Mo).call(this)}mutate(n,r){var s;return M(this,$t,r),(s=y(this,He))==null||s.removeObserver(this),M(this,He,y(this,At).getMutationCache().build(y(this,At),this.options)),y(this,He).addObserver(this),y(this,He).execute(n)}},At=new WeakMap,dn=new WeakMap,He=new WeakMap,$t=new WeakMap,Vt=new WeakSet,Ga=function(){var r;const n=((r=y(this,He))==null?void 0:r.state)??jm();M(this,dn,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Mo=function(n){Ne.batch(()=>{var r,s,i,l,o,c,u,d;if(y(this,$t)&&this.hasListeners()){const f=y(this,dn).variables,m=y(this,dn).context,v={client:y(this,At),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(s=(r=y(this,$t)).onSuccess)==null||s.call(r,n.data,f,m,v)}catch(k){Promise.reject(k)}try{(l=(i=y(this,$t)).onSettled)==null||l.call(i,n.data,null,f,m,v)}catch(k){Promise.reject(k)}}else if((n==null?void 0:n.type)==="error"){try{(c=(o=y(this,$t)).onError)==null||c.call(o,n.error,f,m,v)}catch(k){Promise.reject(k)}try{(d=(u=y(this,$t)).onSettled)==null||d.call(u,void 0,n.error,f,m,v)}catch(k){Promise.reject(k)}}}this.listeners.forEach(f=>{f(y(this,dn))})})},Gd),Pt,Jd,iy=(Jd=class extends ss{constructor(t={}){super();$(this,Pt);this.config=t,M(this,Pt,new Map)}build(t,n,r){const s=n.queryKey,i=n.queryHash??$c(s,n);let l=this.get(i);return l||(l=new Xv({client:t,queryKey:s,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(l)),l}add(t){y(this,Pt).has(t.queryHash)||(y(this,Pt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=y(this,Pt).get(t.queryHash);n&&(t.destroy(),n===t&&y(this,Pt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Ne.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return y(this,Pt).get(t)}getAll(){return[...y(this,Pt).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>hd(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>hd(t,r)):n}notify(t){Ne.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Ne.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Ne.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Pt=new WeakMap,Jd),xe,fn,hn,Ur,Br,mn,Qr,Vr,Yd,ly=(Yd=class{constructor(e={}){$(this,xe);$(this,fn);$(this,hn);$(this,Ur);$(this,Br);$(this,mn);$(this,Qr);$(this,Vr);M(this,xe,e.queryCache||new iy),M(this,fn,e.mutationCache||new sy),M(this,hn,e.defaultOptions||{}),M(this,Ur,new Map),M(this,Br,new Map),M(this,mn,0)}mount(){xa(this,mn)._++,y(this,mn)===1&&(M(this,Qr,Qc.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,xe).onFocus())})),M(this,Vr,wi.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,xe).onOnline())})))}unmount(){var e,t;xa(this,mn)._--,y(this,mn)===0&&((e=y(this,Qr))==null||e.call(this),M(this,Qr,void 0),(t=y(this,Vr))==null||t.call(this),M(this,Vr,void 0))}isFetching(e){return y(this,xe).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return y(this,fn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,xe).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=y(this,xe).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(En(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return y(this,xe).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=y(this,xe).get(r.queryHash),i=s==null?void 0:s.state.data,l=Uv(t,i);if(l!==void 0)return y(this,xe).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return Ne.batch(()=>y(this,xe).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,xe).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=y(this,xe);Ne.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=y(this,xe);return Ne.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Ne.batch(()=>y(this,xe).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Ue).catch(Ue)}invalidateQueries(e,t={}){return Ne.batch(()=>(y(this,xe).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Ne.batch(()=>y(this,xe).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let i=s.fetch(void 0,n);return n.throwOnError||(i=i.catch(Ue)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Ue)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=y(this,xe).build(this,t);return n.isStaleByTime(En(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ue).catch(Ue)}fetchInfiniteQuery(e){return e.behavior=wd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ue).catch(Ue)}ensureInfiniteQueryData(e){return e.behavior=wd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return wi.isOnline()?y(this,fn).resumePausedMutations():Promise.resolve()}getQueryCache(){return y(this,xe)}getMutationCache(){return y(this,fn)}getDefaultOptions(){return y(this,hn)}setDefaultOptions(e){M(this,hn,e)}setQueryDefaults(e,t){y(this,Ur).set(or(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...y(this,Ur).values()],n={};return t.forEach(r=>{Js(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){y(this,Br).set(or(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...y(this,Br).values()],n={};return t.forEach(r=>{Js(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...y(this,hn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=$c(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Uc&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...y(this,hn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){y(this,xe).clear(),y(this,fn).clear()}},xe=new WeakMap,fn=new WeakMap,hn=new WeakMap,Ur=new WeakMap,Br=new WeakMap,mn=new WeakMap,Qr=new WeakMap,Vr=new WeakMap,Yd),wm=g.createContext(void 0),Jt=e=>{const t=g.useContext(wm);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},oy=({client:e,children:t})=>(g.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),a.jsx(wm.Provider,{value:e,children:t})),km=g.createContext(!1),cy=()=>g.useContext(km);km.Provider;function uy(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var dy=g.createContext(uy()),fy=()=>g.useContext(dy),hy=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Bc(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},my=e=>{g.useEffect(()=>{e.clearReset()},[e])},py=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||Bc(n,[e.error,r])),xy=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},vy=(e,t)=>e.isLoading&&e.isFetching&&!t,yy=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,bd=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function gy(e,t,n){var m,v,k,w;const r=cy(),s=fy(),i=Jt(),l=i.defaultQueryOptions(e);(v=(m=i.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||v.call(m,l);const o=i.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",xy(l),hy(l,s,o),my(s);const c=!i.getQueryCache().get(l.queryHash),[u]=g.useState(()=>new t(i,l)),d=u.getOptimisticResult(l),f=!r&&e.subscribed!==!1;if(g.useSyncExternalStore(g.useCallback(b=>{const p=f?u.subscribe(Ne.batchCalls(b)):Ue;return u.updateResult(),p},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),g.useEffect(()=>{u.setOptions(l)},[l,u]),yy(l,d))throw bd(l,u,s);if(py({result:d,errorResetBoundary:s,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw d.error;if((w=(k=i.getDefaultOptions().queries)==null?void 0:k._experimental_afterQuery)==null||w.call(k,l,d),l.experimental_prefetchInRender&&!lr&&vy(d,r)){const b=c?bd(l,u,s):o==null?void 0:o.promise;b==null||b.catch(Ue).finally(()=>{u.updateResult()})}return l.notifyOnChangeProps?d:u.trackResult(d)}function oe(e,t){return gy(e,Zv)}function Xe(e,t){const n=Jt(),[r]=g.useState(()=>new ay(n,e));g.useEffect(()=>{r.setOptions(e)},[r,e]);const s=g.useSyncExternalStore(g.useCallback(l=>r.subscribe(Ne.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=g.useCallback((l,o)=>{r.mutate(l,o).catch(Ue)},[r]);if(s.error&&Bc(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}/** + * @remix-run/router v1.23.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Ys(){return Ys=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function Kc(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function wy(){return Math.random().toString(36).substr(2,8)}function Sd(e,t){return{usr:e.state,key:e.key,idx:t}}function zo(e,t,n,r){return n===void 0&&(n=null),Ys({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?as(t):t,{state:n,key:t&&t.key||r||wy()})}function ki(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function as(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function ky(e,t,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:i=!1}=r,l=s.history,o=vn.Pop,c=null,u=d();u==null&&(u=0,l.replaceState(Ys({},l.state,{idx:u}),""));function d(){return(l.state||{idx:null}).idx}function f(){o=vn.Pop;let b=d(),p=b==null?null:b-u;u=b,c&&c({action:o,location:w.location,delta:p})}function m(b,p){o=vn.Push;let h=zo(w.location,b,p);u=d()+1;let x=Sd(h,u),j=w.createHref(h);try{l.pushState(x,"",j)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;s.location.assign(j)}i&&c&&c({action:o,location:w.location,delta:1})}function v(b,p){o=vn.Replace;let h=zo(w.location,b,p);u=d();let x=Sd(h,u),j=w.createHref(h);l.replaceState(x,"",j),i&&c&&c({action:o,location:w.location,delta:0})}function k(b){let p=s.location.origin!=="null"?s.location.origin:s.location.href,h=typeof b=="string"?b:ki(b);return h=h.replace(/ $/,"%20"),ye(p,"No window.location.(origin|href) available to create URL for href: "+h),new URL(h,p)}let w={get action(){return o},get location(){return e(s,l)},listen(b){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(Nd,f),c=b,()=>{s.removeEventListener(Nd,f),c=null}},createHref(b){return t(s,b)},createURL:k,encodeLocation(b){let p=k(b);return{pathname:p.pathname,search:p.search,hash:p.hash}},push:m,replace:v,go(b){return l.go(b)}};return w}var Cd;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Cd||(Cd={}));function by(e,t,n){return n===void 0&&(n="/"),Ny(e,t,n)}function Ny(e,t,n,r){let s=typeof t=="string"?as(t):t,i=Xr(s.pathname||"/",n);if(i==null)return null;let l=bm(e);Sy(l);let o=null;for(let c=0;o==null&&c{let c={relativePath:o===void 0?i.path||"":o,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};c.relativePath.startsWith("/")&&(ye(c.relativePath.startsWith(r),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(r.length));let u=Pn([r,c.relativePath]),d=n.concat(c);i.children&&i.children.length>0&&(ye(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),bm(i.children,t,d,u)),!(i.path==null&&!i.index)&&t.push({path:u,score:Ly(u,i.index),routesMeta:d})};return e.forEach((i,l)=>{var o;if(i.path===""||!((o=i.path)!=null&&o.includes("?")))s(i,l);else for(let c of Nm(i.path))s(i,l,c)}),t}function Nm(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return s?[i,""]:[i];let l=Nm(r.join("/")),o=[];return o.push(...l.map(c=>c===""?i:[i,c].join("/"))),s&&o.push(...l),o.map(c=>e.startsWith("/")&&c===""?"/":c)}function Sy(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ry(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const Cy=/^:[\w-]+$/,_y=3,Ey=2,Py=1,Ty=10,Oy=-2,_d=e=>e==="*";function Ly(e,t){let n=e.split("/"),r=n.length;return n.some(_d)&&(r+=Oy),t&&(r+=Ey),n.filter(s=>!_d(s)).reduce((s,i)=>s+(Cy.test(i)?_y:i===""?Py:Ty),r)}function Ry(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function My(e,t,n){let{routesMeta:r}=e,s={},i="/",l=[];for(let o=0;o{let{paramName:m,isOptional:v}=d;if(m==="*"){let w=o[f]||"";l=i.slice(0,i.length-w.length).replace(/(.)\/+$/,"$1")}const k=o[f];return v&&!k?u[m]=void 0:u[m]=(k||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:l,pattern:e}}function zy(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),Kc(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,c)=>(r.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function Fy(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Kc(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Xr(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const Iy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Dy=e=>Iy.test(e);function Ay(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?as(e):e,i;if(n)if(Dy(n))i=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),Kc(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?i=Ed(n.substring(1),"/"):i=Ed(n,t)}else i=t;return{pathname:i,search:By(r),hash:Qy(s)}}function Ed(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function jl(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function $y(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Sm(e,t){let n=$y(e);return t?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Cm(e,t,n,r){r===void 0&&(r=!1);let s;typeof e=="string"?s=as(e):(s=Ys({},e),ye(!s.pathname||!s.pathname.includes("?"),jl("?","pathname","search",s)),ye(!s.pathname||!s.pathname.includes("#"),jl("#","pathname","hash",s)),ye(!s.search||!s.search.includes("#"),jl("#","search","hash",s)));let i=e===""||s.pathname==="",l=i?"/":s.pathname,o;if(l==null)o=n;else{let f=t.length-1;if(!r&&l.startsWith("..")){let m=l.split("/");for(;m[0]==="..";)m.shift(),f-=1;s.pathname=m.join("/")}o=f>=0?t[f]:"/"}let c=Ay(s,o),u=l&&l!=="/"&&l.endsWith("/"),d=(i||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}const Pn=e=>e.join("/").replace(/\/\/+/g,"/"),Uy=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),By=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Qy=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Vy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const _m=["post","put","patch","delete"];new Set(_m);const Ky=["get",..._m];new Set(Ky);/** + * React Router v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Xs(){return Xs=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),g.useCallback(function(u,d){if(d===void 0&&(d={}),!o.current)return;if(typeof u=="number"){r.go(u);return}let f=Cm(u,JSON.parse(l),i,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Pn([t,f.pathname])),(d.replace?r.replace:r.push)(f,d.state,d)},[t,r,l,i,e])}const Wy=g.createContext(null);function Gy(e){let t=g.useContext(Yt).outlet;return t&&g.createElement(Wy.Provider,{value:e},t)}function ha(){let{matches:e}=g.useContext(Yt),t=e[e.length-1];return t?t.params:{}}function Qi(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=g.useContext(In),{matches:s}=g.useContext(Yt),{pathname:i}=is(),l=JSON.stringify(Sm(s,r.v7_relativeSplatPath));return g.useMemo(()=>Cm(e,JSON.parse(l),i,n==="path"),[e,l,i,n])}function Jy(e,t){return Yy(e,t)}function Yy(e,t,n,r){fa()||ye(!1);let{navigator:s}=g.useContext(In),{matches:i}=g.useContext(Yt),l=i[i.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let u=is(),d;if(t){var f;let b=typeof t=="string"?as(t):t;c==="/"||(f=b.pathname)!=null&&f.startsWith(c)||ye(!1),d=b}else d=u;let m=d.pathname||"/",v=m;if(c!=="/"){let b=c.replace(/^\//,"").split("/");v="/"+m.replace(/^\//,"").split("/").slice(b.length).join("/")}let k=by(e,{pathname:v}),w=ng(k&&k.map(b=>Object.assign({},b,{params:Object.assign({},o,b.params),pathname:Pn([c,s.encodeLocation?s.encodeLocation(b.pathname).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?c:Pn([c,s.encodeLocation?s.encodeLocation(b.pathnameBase).pathname:b.pathnameBase])})),i,n,r);return t&&w?g.createElement(Bi.Provider,{value:{location:Xs({pathname:"/",search:"",hash:"",state:null,key:"default"},d),navigationType:vn.Pop}},w):w}function Xy(){let e=ig(),t=Vy(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return g.createElement(g.Fragment,null,g.createElement("h2",null,"Unexpected Application Error!"),g.createElement("h3",{style:{fontStyle:"italic"}},t),n?g.createElement("pre",{style:s},n):null,null)}const Zy=g.createElement(Xy,null);class eg extends g.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?g.createElement(Yt.Provider,{value:this.props.routeContext},g.createElement(Pm.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function tg(e){let{routeContext:t,match:n,children:r}=e,s=g.useContext(Ui);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),g.createElement(Yt.Provider,{value:t},r)}function ng(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(s=n)==null?void 0:s.errors;if(o!=null){let d=l.findIndex(f=>f.route.id&&(o==null?void 0:o[f.route.id])!==void 0);d>=0||ye(!1),l=l.slice(0,Math.min(l.length,d+1))}let c=!1,u=-1;if(n&&r&&r.v7_partialHydration)for(let d=0;d=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((d,f,m)=>{let v,k=!1,w=null,b=null;n&&(v=o&&f.route.id?o[f.route.id]:void 0,w=f.route.errorElement||Zy,c&&(u<0&&m===0?(og("route-fallback"),k=!0,b=null):u===m&&(k=!0,b=f.route.hydrateFallbackElement||null)));let p=t.concat(l.slice(0,m+1)),h=()=>{let x;return v?x=w:k?x=b:f.route.Component?x=g.createElement(f.route.Component,null):f.route.element?x=f.route.element:x=d,g.createElement(tg,{match:f,routeContext:{outlet:d,matches:p,isDataRoute:n!=null},children:x})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?g.createElement(eg,{location:n.location,revalidation:n.revalidation,component:w,error:v,children:h(),routeContext:{outlet:null,matches:p,isDataRoute:!0}}):h()},null)}var Om=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Om||{}),Lm=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(Lm||{});function rg(e){let t=g.useContext(Ui);return t||ye(!1),t}function sg(e){let t=g.useContext(Em);return t||ye(!1),t}function ag(e){let t=g.useContext(Yt);return t||ye(!1),t}function Rm(e){let t=ag(),n=t.matches[t.matches.length-1];return n.route.id||ye(!1),n.route.id}function ig(){var e;let t=g.useContext(Pm),n=sg(),r=Rm();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function lg(){let{router:e}=rg(Om.UseNavigateStable),t=Rm(Lm.UseNavigateStable),n=g.useRef(!1);return Tm(()=>{n.current=!0}),g.useCallback(function(s,i){i===void 0&&(i={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,Xs({fromRouteId:t},i)))},[e,t])}const Pd={};function og(e,t,n){Pd[e]||(Pd[e]=!0)}function cg(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function ug(e){return Gy(e.context)}function pt(e){ye(!1)}function dg(e){let{basename:t="/",children:n=null,location:r,navigationType:s=vn.Pop,navigator:i,static:l=!1,future:o}=e;fa()&&ye(!1);let c=t.replace(/^\/*/,"/"),u=g.useMemo(()=>({basename:c,navigator:i,static:l,future:Xs({v7_relativeSplatPath:!1},o)}),[c,o,i,l]);typeof r=="string"&&(r=as(r));let{pathname:d="/",search:f="",hash:m="",state:v=null,key:k="default"}=r,w=g.useMemo(()=>{let b=Xr(d,c);return b==null?null:{location:{pathname:b,search:f,hash:m,state:v,key:k},navigationType:s}},[c,d,f,m,v,k,s]);return w==null?null:g.createElement(In.Provider,{value:u},g.createElement(Bi.Provider,{children:n,value:w}))}function fg(e){let{children:t,location:n}=e;return Jy(Io(t),n)}new Promise(()=>{});function Io(e,t){t===void 0&&(t=[]);let n=[];return g.Children.forEach(e,(r,s)=>{if(!g.isValidElement(r))return;let i=[...t,s];if(r.type===g.Fragment){n.push.apply(n,Io(r.props.children,i));return}r.type!==pt&&ye(!1),!r.props.index||!r.props.children||ye(!1);let l={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Io(r.props.children,i)),n.push(l)}),n}/** + * React Router DOM v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function bi(){return bi=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[s]=e[s]);return n}function hg(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function mg(e,t){return e.button===0&&(!t||t==="_self")&&!hg(e)}const pg=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],xg=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],vg="6";try{window.__reactRouterVersion=vg}catch{}const yg=g.createContext({isTransitioning:!1}),gg="startTransition",Td=Cp[gg];function jg(e){let{basename:t,children:n,future:r,window:s}=e,i=g.useRef();i.current==null&&(i.current=jy({window:s,v5Compat:!0}));let l=i.current,[o,c]=g.useState({action:l.action,location:l.location}),{v7_startTransition:u}=r||{},d=g.useCallback(f=>{u&&Td?Td(()=>c(f)):c(f)},[c,u]);return g.useLayoutEffect(()=>l.listen(d),[l,d]),g.useEffect(()=>cg(r),[r]),g.createElement(dg,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const wg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",kg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Rn=g.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:i,replace:l,state:o,target:c,to:u,preventScrollReset:d,viewTransition:f}=t,m=Mm(t,pg),{basename:v}=g.useContext(In),k,w=!1;if(typeof u=="string"&&kg.test(u)&&(k=u,wg))try{let x=new URL(window.location.href),j=u.startsWith("//")?new URL(x.protocol+u):new URL(u),C=Xr(j.pathname,v);j.origin===x.origin&&C!=null?u=C+j.search+j.hash:w=!0}catch{}let b=Hy(u,{relative:s}),p=Ng(u,{replace:l,state:o,target:c,preventScrollReset:d,relative:s,viewTransition:f});function h(x){r&&r(x),x.defaultPrevented||p(x)}return g.createElement("a",bi({},m,{href:k||b,onClick:w||i?r:h,ref:n,target:c}))}),zm=g.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:s=!1,className:i="",end:l=!1,style:o,to:c,viewTransition:u,children:d}=t,f=Mm(t,xg),m=Qi(c,{relative:f.relative}),v=is(),k=g.useContext(Em),{navigator:w,basename:b}=g.useContext(In),p=k!=null&&Sg(m)&&u===!0,h=w.encodeLocation?w.encodeLocation(m).pathname:m.pathname,x=v.pathname,j=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;s||(x=x.toLowerCase(),j=j?j.toLowerCase():null,h=h.toLowerCase()),j&&b&&(j=Xr(j,b)||j);const C=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let S=x===h||!l&&x.startsWith(h)&&x.charAt(C)==="/",N=j!=null&&(j===h||!l&&j.startsWith(h)&&j.charAt(h.length)==="/"),_={isActive:S,isPending:N,isTransitioning:p},z=S?r:void 0,L;typeof i=="function"?L=i(_):L=[i,S?"active":null,N?"pending":null,p?"transitioning":null].filter(Boolean).join(" ");let B=typeof o=="function"?o(_):o;return g.createElement(Rn,bi({},f,{"aria-current":z,className:L,ref:n,style:B,to:c,viewTransition:u}),typeof d=="function"?d(_):d)});var Do;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Do||(Do={}));var Od;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Od||(Od={}));function bg(e){let t=g.useContext(Ui);return t||ye(!1),t}function Ng(e,t){let{target:n,replace:r,state:s,preventScrollReset:i,relative:l,viewTransition:o}=t===void 0?{}:t,c=Dn(),u=is(),d=Qi(e,{relative:l});return g.useCallback(f=>{if(mg(f,n)){f.preventDefault();let m=r!==void 0?r:ki(u)===ki(d);c(e,{replace:m,state:s,preventScrollReset:i,relative:l,viewTransition:o})}},[u,c,d,r,s,n,e,i,l,o])}function Sg(e,t){t===void 0&&(t={});let n=g.useContext(yg);n==null&&ye(!1);let{basename:r}=bg(Do.useViewTransitionState),s=Qi(e,{relative:t.relative});if(!n.isTransitioning)return!1;let i=Xr(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Xr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Fo(s.pathname,l)!=null||Fo(s.pathname,i)!=null}/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var Cg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _g=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),U=(e,t)=>{const n=g.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:l,className:o="",children:c,...u},d)=>g.createElement("svg",{ref:d,...Cg,width:s,height:s,stroke:r,strokeWidth:l?Number(i)*24/Number(s):i,className:["lucide",`lucide-${_g(e)}`,o].join(" "),...u},[...t.map(([f,m])=>g.createElement(f,m)),...Array.isArray(c)?c:[c]]));return n.displayName=`${e}`,n};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Eg=U("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fm=U("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pg=U("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Tg=U("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Og=U("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Im=U("BookOpen",[["path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z",key:"vv98re"}],["path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z",key:"1cyq3y"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ao=U("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dm=U("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lg=U("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rg=U("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Zs=U("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mg=U("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zg=U("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Am=U("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fg=U("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ig=U("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $m=U("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ld=U("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Um=U("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $o=U("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dg=U("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ag=U("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $g=U("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hc=U("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ug=U("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bg=U("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qg=U("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ma=U("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bm=U("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vg=U("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qm=U("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Kg=U("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ea=U("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qc=U("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hg=U("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qg=U("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vm=U("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Km=U("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wg=U("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Gg=U("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rd=U("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Jg=U("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Yg=U("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wc=U("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hm=U("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qm=U("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xg=U("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wm=U("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const cr=U("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),Zg={},Md=e=>{let t;const n=new Set,r=(d,f)=>{const m=typeof d=="function"?d(t):d;if(!Object.is(m,t)){const v=t;t=f??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(k=>k(t,v))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(Zg?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(r,s,c);return c},e0=e=>e?Md(e):Md;var Gm={exports:{}},Jm={},Ym={exports:{}},Xm={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Zr=g;function t0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var n0=typeof Object.is=="function"?Object.is:t0,r0=Zr.useState,s0=Zr.useEffect,a0=Zr.useLayoutEffect,i0=Zr.useDebugValue;function l0(e,t){var n=t(),r=r0({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return a0(function(){s.value=n,s.getSnapshot=t,wl(s)&&i({inst:s})},[e,n,t]),s0(function(){return wl(s)&&i({inst:s}),e(function(){wl(s)&&i({inst:s})})},[e]),i0(n),n}function wl(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!n0(e,n)}catch{return!0}}function o0(e,t){return t()}var c0=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o0:l0;Xm.useSyncExternalStore=Zr.useSyncExternalStore!==void 0?Zr.useSyncExternalStore:c0;Ym.exports=Xm;var u0=Ym.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Vi=g,d0=u0;function f0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var h0=typeof Object.is=="function"?Object.is:f0,m0=d0.useSyncExternalStore,p0=Vi.useRef,x0=Vi.useEffect,v0=Vi.useMemo,y0=Vi.useDebugValue;Jm.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=p0(null);if(i.current===null){var l={hasValue:!1,value:null};i.current=l}else l=i.current;i=v0(function(){function c(v){if(!u){if(u=!0,d=v,v=r(v),s!==void 0&&l.hasValue){var k=l.value;if(s(k,v))return f=k}return f=v}if(k=f,h0(d,v))return k;var w=r(v);return s!==void 0&&s(k,w)?(d=v,k):(d=v,f=w)}var u=!1,d,f,m=n===void 0?null:n;return[function(){return c(t())},m===null?void 0:function(){return c(m())}]},[t,n,r,s]);var o=m0(e,i[0],i[1]);return x0(function(){l.hasValue=!0,l.value=o},[o]),y0(o),o};Gm.exports=Jm;var g0=Gm.exports;const j0=Xd(g0),Zm={},{useDebugValue:w0}=Go,{useSyncExternalStoreWithSelector:k0}=j0;let zd=!1;const b0=e=>e;function N0(e,t=b0,n){(Zm?"production":void 0)!=="production"&&n&&!zd&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),zd=!0);const r=k0(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return w0(r),r}const Fd=e=>{(Zm?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?e0(e):e,n=(r,s)=>N0(t,r,s);return Object.assign(n,t),n},Gc=e=>e?Fd(e):Fd,Ki="/api",Jc="flow_auth_token",Yc="flow_auth_expires",Xc="flow_auth_username";function Hi(){const e=localStorage.getItem(Jc),t=localStorage.getItem(Yc);return!e||!t?null:new Date(t)<=new Date?(es(),null):e}function Id(e,t,n){localStorage.setItem(Jc,e),localStorage.setItem(Yc,t),localStorage.setItem(Xc,n)}function es(){localStorage.removeItem(Jc),localStorage.removeItem(Yc),localStorage.removeItem(Xc)}function Zc(){return localStorage.getItem(Xc)}let ur=null;function S0(e){ur=e}async function Y(e,t,n=!1){const r={"Content-Type":"application/json",...t==null?void 0:t.headers};if(!n){const i=Hi();i&&(r.Authorization=`Bearer ${i}`)}const s=await fetch(`${Ki}${e}`,{...t,headers:r});if(s.status===401){es(),ur&&ur();const i=await s.json().catch(()=>({detail:"Not authenticated"}));throw new Error(i.detail||"Not authenticated")}if(!s.ok){const i=await s.json().catch(()=>({detail:s.statusText}));throw new Error(i.detail||"API request failed")}if(s.status!==204)return s.json()}const xs={getConfig:()=>Y("/auth/config",void 0,!0),login:e=>Y("/auth/login",{method:"POST",body:JSON.stringify(e)},!0),getGitHubAuthUrl:()=>`${Ki}/auth/github`,getCurrentUser:()=>Y("/auth/me"),logout:()=>Y("/auth/logout",{method:"POST"})},Tn={list:e=>{const t=new URLSearchParams;e!=null&&e.include_auto_generated&&t.set("include_auto_generated","true"),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return Y(`/configs${n?`?${n}`:""}`)},get:e=>Y(`/configs/${e}`),create:e=>Y("/configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Y(`/configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Y(`/configs/${e}`,{method:"DELETE"})},wt={list:e=>{const t=new URLSearchParams;e!=null&&e.category&&t.set("category",e.category),e!=null&&e.suite&&t.set("suite",e.suite);const n=t.toString();return Y(`/tasks${n?`?${n}`:""}`)},get:e=>Y(`/tasks/${e}`),create:e=>Y("/tasks",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Y(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Y(`/tasks/${e}`,{method:"DELETE"}),listSuites:()=>Y("/tasks/suites"),importSuite:e=>Y(`/tasks/import-suite?suite_name=${encodeURIComponent(e)}`,{method:"POST"})},Rt={list:e=>{const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return Y(`/jobs${n?`?${n}`:""}`)},get:e=>Y(`/jobs/${e}`),create:e=>Y("/jobs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Y(`/jobs/${e}`,{method:"PUT",body:JSON.stringify(t)}),start:async function*(e){var o;const t={},n=Hi();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Ki}/jobs/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw es(),ur&&ur(),new Error("Not authenticated");if(!r.ok)throw new Error("Failed to start job");const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const i=new TextDecoder;let l="";for(;;){const{done:c,value:u}=await s.read();if(c)break;l+=i.decode(u,{stream:!0});const d=l.split(` +`);l=d.pop()||"";for(const f of d)f.startsWith("data: ")&&(yield JSON.parse(f.slice(6)))}},cancel:e=>Y(`/jobs/${e}/cancel`,{method:"POST"}),delete:e=>Y(`/jobs/${e}`,{method:"DELETE"})},Uo={list:e=>{const t=new URLSearchParams;e!=null&&e.job_id&&t.set("job_id",e.job_id),e!=null&&e.candidate_name&&t.set("candidate_name",e.candidate_name),e!=null&&e.task_name&&t.set("task_name",e.task_name),(e==null?void 0:e.is_pareto)!==void 0&&t.set("is_pareto",String(e.is_pareto));const n=t.toString();return Y(`/runs${n?`?${n}`:""}`)},get:e=>Y(`/runs/${e}`),getJobSummary:e=>Y(`/runs/job/${e}/summary`)},Ls={list:e=>{const t=new URLSearchParams;e!=null&&e.agent_id&&t.set("agent_id",e.agent_id),e!=null&&e.limit&&t.set("limit",String(e.limit));const n=t.toString();return Y(`/tests${n?`?${n}`:""}`)},get:e=>Y(`/tests/${e}`),create:e=>Y("/tests",{method:"POST",body:JSON.stringify(e)}),start:async function*(e){var o;const t={},n=Hi();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Ki}/tests/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw es(),ur&&ur(),new Error("Not authenticated");if(!r.ok){const c=await r.json().catch(()=>({detail:"Failed to start test"}));throw new Error(c.detail||"Failed to start test")}const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const i=new TextDecoder;let l="";for(;;){const{done:c,value:u}=await s.read();if(c)break;l+=i.decode(u,{stream:!0});const d=l.split(` +`);l=d.pop()||"";for(const f of d)f.startsWith("data: ")&&(yield JSON.parse(f.slice(6)))}},cancel:e=>Y(`/tests/${e}/cancel`,{method:"POST"}),delete:e=>Y(`/tests/${e}`,{method:"DELETE"})},C0={list:()=>Y("/llm-configs")},_0={list:()=>Y("/tools")},ep={getAgentSchema:()=>Y("/schema/agent")},E0={get:e=>Y(`/deployments/${e}`)},P0={start:e=>Y("/evaluate",{method:"POST",body:JSON.stringify(e)})},Bo={design:e=>Y("/experiment/design",{method:"POST",body:JSON.stringify(e)}),validate:e=>Y("/experiment/validate",{method:"POST",body:JSON.stringify(e)}),generateCandidates:e=>Y("/experiment/generate-candidates",{method:"POST",body:JSON.stringify(e)})},eu=Gc(e=>(S0(()=>{e({isAuthenticated:!1,user:null,error:"Session expired. Please log in again."})}),{authConfig:null,isLoadingConfig:!0,isAuthenticated:!1,isLoading:!1,user:null,error:null,loadAuthConfig:async()=>{e({isLoadingConfig:!0});try{const t=await xs.getConfig();if(e({authConfig:t,isLoadingConfig:!1}),t.enabled){const n=Hi(),r=Zc();if(n&&r)try{const s=await xs.getCurrentUser();e({isAuthenticated:!0,user:s})}catch{es(),e({isAuthenticated:!1,user:null})}}else e({isAuthenticated:!0,user:{username:"anonymous",auth_mode:"none"}})}catch(t){console.error("Failed to load auth config:",t),e({isLoadingConfig:!1,error:"Failed to connect to server"})}},login:async(t,n)=>{e({isLoading:!0,error:null});try{const r=await xs.login({username:t,password:n});return Id(r.access_token,r.expires_at,r.username),e({isAuthenticated:!0,isLoading:!1,user:{username:r.username,auth_mode:"basic"}}),!0}catch(r){return e({isLoading:!1,error:r instanceof Error?r.message:"Login failed"}),!1}},loginWithGitHub:()=>{window.location.href=xs.getGitHubAuthUrl()},handleOAuthCallback:()=>{const t=new URLSearchParams(window.location.search),n=t.get("auth_error");if(n)return e({error:n}),window.history.replaceState({},"",window.location.pathname),!0;if(t.get("auth_callback")==="true"){const r=t.get("token"),s=t.get("expires_at"),i=t.get("username");return r&&s&&i&&(Id(r,s,i),e({isAuthenticated:!0,user:{username:i,auth_mode:"github"}})),window.history.replaceState({},"",window.location.pathname),!0}return!1},logout:async()=>{try{await xs.logout()}catch{}es(),e({isAuthenticated:!1,user:null,error:null})},clearError:()=>e({error:null})}));function K({variant:e="secondary",size:t="md",className:n="",icon:r,iconRight:s,loading:i=!1,children:l,disabled:o,...c}){const u="font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1.5 rounded-md",d={primary:"bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)]",secondary:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)] hover:bg-[var(--border)]",danger:"bg-[var(--error)] text-white hover:bg-red-600",ghost:"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"},f={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm"},m=t==="sm"?14:16;return a.jsxs("button",{className:`${u} ${d[e]} ${f[t]} ${n}`,disabled:o||i,...c,children:[i?a.jsx(ma,{size:m,className:"animate-spin"}):r?a.jsx(r,{size:m}):null,l,s&&!i&&a.jsx(s,{size:m})]})}const T0={};function O0(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var i;const l=c=>c===null?null:JSON.parse(c,void 0),o=(i=n.getItem(s))!=null?i:null;return o instanceof Promise?o.then(l):l(o)},setItem:(s,i)=>n.setItem(s,JSON.stringify(i,void 0)),removeItem:s=>n.removeItem(s)}}const ta=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return ta(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return ta(r)(n)}}}},L0=(e,t)=>(n,r,s)=>{let i={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:b=>b,version:0,merge:(b,p)=>({...p,...b}),...t},l=!1;const o=new Set,c=new Set;let u;try{u=i.getStorage()}catch{}if(!u)return e((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...b)},r,s);const d=ta(i.serialize),f=()=>{const b=i.partialize({...r()});let p;const h=d({state:b,version:i.version}).then(x=>u.setItem(i.name,x)).catch(x=>{p=x});if(p)throw p;return h},m=s.setState;s.setState=(b,p)=>{m(b,p),f()};const v=e((...b)=>{n(...b),f()},r,s);let k;const w=()=>{var b;if(!u)return;l=!1,o.forEach(h=>h(r()));const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,r()))||void 0;return ta(u.getItem.bind(u))(i.name).then(h=>{if(h)return i.deserialize(h)}).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==i.version){if(i.migrate)return i.migrate(h.state,h.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return h.state}).then(h=>{var x;return k=i.merge(h,(x=r())!=null?x:v),n(k,!0),f()}).then(()=>{p==null||p(k,void 0),l=!0,c.forEach(h=>h(k))}).catch(h=>{p==null||p(void 0,h)})};return s.persist={setOptions:b=>{i={...i,...b},b.getStorage&&(u=b.getStorage())},clearStorage:()=>{u==null||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>w(),hasHydrated:()=>l,onHydrate:b=>(o.add(b),()=>{o.delete(b)}),onFinishHydration:b=>(c.add(b),()=>{c.delete(b)})},w(),k||v},R0=(e,t)=>(n,r,s)=>{let i={storage:O0(()=>localStorage),partialize:w=>w,version:0,merge:(w,b)=>({...b,...w}),...t},l=!1;const o=new Set,c=new Set;let u=i.storage;if(!u)return e((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...w)},r,s);const d=()=>{const w=i.partialize({...r()});return u.setItem(i.name,{state:w,version:i.version})},f=s.setState;s.setState=(w,b)=>{f(w,b),d()};const m=e((...w)=>{n(...w),d()},r,s);s.getInitialState=()=>m;let v;const k=()=>{var w,b;if(!u)return;l=!1,o.forEach(h=>{var x;return h((x=r())!=null?x:m)});const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,(w=r())!=null?w:m))||void 0;return ta(u.getItem.bind(u))(i.name).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==i.version){if(i.migrate)return[!0,i.migrate(h.state,h.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,h.state];return[!1,void 0]}).then(h=>{var x;const[j,C]=h;if(v=i.merge(C,(x=r())!=null?x:m),n(v,!0),j)return d()}).then(()=>{p==null||p(v,void 0),v=r(),l=!0,c.forEach(h=>h(v))}).catch(h=>{p==null||p(void 0,h)})};return s.persist={setOptions:w=>{i={...i,...w},w.storage&&(u=w.storage)},clearStorage:()=>{u==null||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>k(),hasHydrated:()=>l,onHydrate:w=>(o.add(w),()=>{o.delete(w)}),onFinishHydration:w=>(c.add(w),()=>{c.delete(w)})},i.skipHydration||k(),v||m},M0=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((T0?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),L0(e,t)):R0(e,t),tp=M0,z0=Gc()(tp((e,t)=>({theme:"light",setTheme:n=>{document.documentElement.setAttribute("data-theme",n),e({theme:n})},toggleTheme:()=>{const n=t().theme==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",n),e({theme:n})}}),{name:"flow-theme",onRehydrateStorage:()=>e=>{e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}}));function F0(){const{theme:e,toggleTheme:t}=z0();return a.jsx("button",{onClick:t,className:"p-2 rounded-md text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--accent)]","aria-label":`Switch to ${e==="dark"?"light":"dark"} mode`,title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:e==="dark"?a.jsx(Jg,{size:16}):a.jsx(Kg,{size:16})})}const I0=Gc()(tp((e,t)=>({sidebarCollapsed:!1,toggleSidebar:()=>{e({sidebarCollapsed:!t().sidebarCollapsed})}}),{name:"flow-layout"})),D0=[{path:"/",label:"Overview",icon:Bg},{path:"/agents",label:"Agents",icon:Ao},{path:"/jobs",label:"Experiments",icon:$o},{path:"/tasks",label:"Datasets",icon:$m}];function A0(){const e=is(),{sidebarCollapsed:t,toggleSidebar:n}=I0(),r=s=>s==="/"?e.pathname==="/":s==="/agents"?e.pathname==="/agents"||e.pathname.startsWith("/agents/")||e.pathname.startsWith("/deployments/"):s==="/jobs"?e.pathname.startsWith("/jobs")||e.pathname.startsWith("/runs"):e.pathname.startsWith(s);return a.jsxs("aside",{className:` + flex flex-col border-r border-[var(--border)] bg-[var(--bg-secondary)] + transition-all duration-200 + ${t?"w-14":"w-56"} + `,children:[a.jsx("nav",{className:"flex-1 py-2",children:D0.map(s=>{const i=r(s.path);return a.jsxs(zm,{to:s.path,title:t?s.label:void 0,className:` + flex items-center gap-3 px-4 py-2.5 text-sm transition-colors relative + ${i?"text-[var(--accent)] bg-[var(--accent-dim)] font-medium":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"} + `,children:[i&&a.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-r bg-[var(--accent)]"}),a.jsx(s.icon,{size:18}),!t&&a.jsx("span",{children:s.label})]},s.path)})}),a.jsx("button",{onClick:n,className:"flex items-center justify-center p-3 border-t border-[var(--border)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",title:t?"Expand sidebar":"Collapse sidebar",children:t?a.jsx(zg,{size:16}):a.jsx(Mg,{size:16})})]})}function $0(){const{authConfig:e,user:t,logout:n}=eu(),r=async()=>{await n()};return a.jsxs("div",{className:"h-screen flex flex-col",children:[a.jsx("header",{className:"border-b border-[var(--border)] bg-[var(--bg-secondary)] shrink-0",children:a.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between",children:[a.jsxs(zm,{to:"/",className:"text-lg font-semibold text-[var(--accent)] flex items-center gap-2 hover:opacity-80",children:[a.jsx(cr,{size:20}),"Flow",a.jsx("span",{className:"text-[var(--text-secondary)] font-normal",children:"/optimize"})]}),a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(F0,{}),(e==null?void 0:e.enabled)&&t&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[a.jsx(Hm,{size:14}),a.jsx("span",{children:t.username})]}),a.jsx(K,{variant:"ghost",size:"sm",icon:Vg,onClick:r,title:"Sign out",children:"Sign out"})]})]})]})}),a.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[a.jsx(A0,{}),a.jsx("main",{className:"flex-1 overflow-y-auto bg-[var(--bg-primary)]",children:a.jsx("div",{className:"p-6",children:a.jsx(ug,{})})})]})]})}function G({children:e,variant:t="default"}){const n={default:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)]",success:"bg-[var(--badge-success-bg)] text-[var(--badge-success-text)] border border-[var(--badge-success-border)]",warning:"bg-[var(--badge-warning-bg)] text-[var(--badge-warning-text)] border border-[var(--badge-warning-border)]",error:"bg-[var(--badge-error-bg)] text-[var(--badge-error-text)] border border-[var(--badge-error-border)]",info:"bg-[var(--badge-info-bg)] text-[var(--badge-info-text)] border border-[var(--badge-info-border)]"};return a.jsx("span",{className:`inline-block px-2 py-0.5 text-xs font-medium rounded-md ${n[t]}`,children:e})}const U0={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};function B0(){const e=Dn(),{data:t=[],isLoading:n}=oe({queryKey:["configs"],queryFn:()=>Tn.list()}),{data:r=[],isLoading:s}=oe({queryKey:["jobs"],queryFn:()=>Rt.list()}),{data:i=[],isLoading:l}=oe({queryKey:["tasks"],queryFn:()=>wt.list()}),o=[...t].sort((d,f)=>new Date(f.created_at).getTime()-new Date(d.created_at).getTime()).slice(0,5),c=[...r].sort((d,f)=>new Date(f.created_at).getTime()-new Date(d.created_at).getTime()).slice(0,5),u=i.reduce((d,f)=>{const m=f.suite||"custom";return d[m]||(d[m]=[]),d[m].push(f),d},{});return a.jsxs("div",{children:[a.jsxs("div",{className:"mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Agent Optimizer"}),a.jsx("p",{className:"text-[var(--text-secondary)] max-w-2xl",children:"Systematically optimize and improve your AI agents across key dimensions. Define agent configurations, run experiments across task datasets, and find the best tradeoffs between quality and cost."}),a.jsx("div",{className:"flex flex-wrap gap-3 mt-4 text-sm text-[var(--text-secondary)]",children:[{icon:Qm,label:"Instructions"},{icon:qm,label:"Tools"},{icon:Im,label:"Skills"},{icon:Gg,label:"Compaction"}].map((d,f,m)=>a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[a.jsx(d.icon,{size:14,className:"text-[var(--accent)]"}),d.label,fa.jsxs("div",{className:"p-4 border border-[var(--border)] rounded-lg bg-[var(--bg-secondary)]",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a.jsx("span",{className:"flex items-center justify-center w-7 h-7 rounded-full bg-[var(--accent)]/10 text-[var(--accent)] text-xs font-bold",children:d.step}),a.jsx(d.icon,{size:18,className:"text-[var(--accent)]"})]}),a.jsx("h3",{className:"font-medium text-sm",children:d.title}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:d.description})]},d.step))}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mb-6",children:[a.jsxs("div",{children:[a.jsx(kl,{title:"Recent Agents",icon:Ao,count:t.length,onShowAll:()=>e("/agents")}),n?a.jsx(bl,{}):o.length===0?a.jsx(Nl,{message:"No agents yet. Create your first agent to get started."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:o.map((d,f)=>a.jsxs("div",{onClick:()=>e(`/agents/${d.id}`),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${fe("/jobs")}),s?a.jsx(bl,{}):c.length===0?a.jsx(Nl,{message:"No experiments yet. Start one from an agent's detail page."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:c.map((d,f)=>a.jsxs("div",{onClick:()=>e(`/jobs/${d.id}`),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${fe("/tasks")}),l?a.jsx(bl,{}):Object.keys(u).length===0?a.jsx(Nl,{message:"No datasets yet. Import a task suite to get started."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:Object.entries(u).map(([d,f],m,v)=>a.jsx("div",{onClick:()=>e("/tasks"),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${m0&&a.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",n,")"]})]}),n>0&&a.jsxs("button",{onClick:r,className:"text-sm text-[var(--accent)] hover:underline flex items-center gap-1",children:["Show all ",a.jsx(Pg,{size:14})]})]})}function bl(){return a.jsx("div",{className:"text-sm text-[var(--text-secondary)] mb-8",children:"Loading..."})}function Nl({message:e}){return a.jsx("div",{className:"text-sm text-[var(--text-secondary)] py-6 text-center border border-[var(--border)] rounded-lg mb-8",children:e})}const Q0=["maf","miniagent","langgraph"],V0={maf:"Microsoft Agent Framework",miniagent:"MiniAgent",langgraph:"LangGraph"},K0={openai:"OpenAI",azure_openai:"Azure OpenAI",anthropic:"Anthropic",ollama:"Ollama",custom:"Custom (OpenAI-compatible)"},H0={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"};function ls({isOpen:e,onClose:t,title:n,children:r,footer:s,size:i="md"}){return g.useEffect(()=>{const l=o=>{o.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",l),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",l),document.body.style.overflow=""}},[e,t]),e?a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),a.jsxs("div",{className:`relative bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg ${H0[i]} w-full mx-4 max-h-[80vh] flex flex-col`,children:[a.jsxs("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-b border-[var(--border)] px-4 py-3 flex items-center justify-between",children:[a.jsx("h2",{className:"font-semibold",children:n}),a.jsx("button",{onClick:t,className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"×"})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r}),s&&a.jsx("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-t border-[var(--border)] px-4 py-3",children:s})]})]}):null}function yn({label:e,className:t="",...n}){return a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),a.jsx("input",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] ${t}`,...n})]})}function q0({label:e,className:t="",...n}){return a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),a.jsx("textarea",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] resize-y min-h-[100px] ${t}`,...n})]})}function Ni({label:e,className:t="",...n}){return a.jsxs("label",{className:`flex items-center gap-2 cursor-pointer ${t}`,children:[a.jsx("input",{type:"checkbox",className:"w-4 h-4 bg-[var(--bg-primary)] border border-[var(--border)] rounded accent-[var(--accent)]",...n}),a.jsx("span",{className:"text-sm",children:e})]})}function np({columns:e,data:t,onRowClick:n,searchable:r=!1,searchPlaceholder:s="Search...",searchFilter:i,emptyMessage:l="No items found",emptyIcon:o}){const[c,u]=g.useState(""),[d,f]=g.useState(null),[m,v]=g.useState("asc"),k=g.useMemo(()=>{let b=t;if(r&&c&&i&&(b=b.filter(p=>i(p,c))),d){const p=e.find(h=>h.key===d);p!=null&&p.sortValue&&(b=[...b].sort((h,x)=>{const j=p.sortValue(h),C=p.sortValue(x),S=jC?1:0;return m==="asc"?S:-S}))}return b},[t,c,i,r,d,m,e]),w=b=>{const p=e.find(h=>h.key===b);p!=null&&p.sortable&&(d===b?v(m==="asc"?"desc":"asc"):(f(b),v("asc")))};return a.jsxs("div",{children:[r&&a.jsxs("div",{className:"mb-4 relative max-w-sm",children:[a.jsx(qg,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]"}),a.jsx("input",{type:"text",placeholder:s,value:c,onChange:b=>u(b.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md pl-9 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]"})]}),k.length===0?a.jsxs("div",{className:"text-center py-16 text-[var(--text-secondary)]",children:[o&&a.jsx("div",{className:"mb-3 flex justify-center",children:o}),a.jsx("p",{children:l})]}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsx("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:e.map(b=>a.jsx("th",{onClick:()=>w(b.key),className:`text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider ${b.sortable?"cursor-pointer hover:text-[var(--text-primary)]":""} ${b.className||""}`,children:a.jsxs("span",{className:"inline-flex items-center gap-1",children:[b.header,b.sortable&&d===b.key&&a.jsx("span",{children:m==="asc"?"↑":"↓"})]})},b.key))})}),a.jsx("tbody",{children:k.map((b,p)=>a.jsx("tr",{onClick:()=>n==null?void 0:n(b),className:`border-b border-[var(--border)] last:border-b-0 transition-colors ${n?"cursor-pointer hover:bg-[var(--bg-tertiary)]":""}`,children:e.map(h=>a.jsx("td",{className:`px-4 py-3 ${h.className||""}`,children:h.render(b)},h.key))},p))})]})})]})}function W0({variations:e,onChange:t,strategies:n,availableStrategies:r}){const s=r??Object.keys(n),i=()=>{const u=e.map(v=>v.strategy),d=s.find(v=>!u.includes(v))||"none",f=n[d],m={strategy:d};if(f!=null&&f.params)for(const[v,k]of Object.entries(f.params))k.default!==void 0&&(m[v]=k.default);t([...e,m])},l=u=>{t(e.filter((d,f)=>f!==u))},o=(u,d)=>{t(e.map((f,m)=>m===u?{...f,...d}:f))},c=(u,d)=>{const f=n[d],m={strategy:d};if(f!=null&&f.params)for(const[v,k]of Object.entries(f.params))k.default!==void 0&&(m[v]=k.default);o(u,m)};return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm font-medium",children:"Compaction Strategies"}),a.jsx(K,{type:"button",variant:"ghost",size:"sm",icon:qc,onClick:i,disabled:e.length>=s.length,children:"Add"})]}),e.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:'No compaction variations. Click "Add" to test different strategies.'}):a.jsx("div",{className:"space-y-2",children:e.map((u,d)=>{const f=n[u.strategy];return a.jsx("div",{className:"p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsx("select",{className:"w-full px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:u.strategy,onChange:m=>c(d,m.target.value),children:s.map(m=>{var v;return a.jsx("option",{value:m,children:((v=n[m])==null?void 0:v.label)||m},m)})}),(f==null?void 0:f.description)&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:f.description}),(f==null?void 0:f.params)&&Object.keys(f.params).length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:Object.entries(f.params).map(([m,v])=>a.jsx(G0,{name:m,schema:v,value:u[m],onChange:k=>o(d,{[m]:k})},m))})]}),a.jsx("button",{type:"button",onClick:()=>l(d),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:a.jsx(Wm,{size:16})})]})},d)})})]})}function G0({name:e,schema:t,value:n,onChange:r}){const s=e.replace(/_/g," ");return t.type==="boolean"?a.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[a.jsx("input",{type:"checkbox",checked:!!(n??t.default),onChange:i=>r(i.target.checked),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"capitalize",children:s})]}):a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:s}),a.jsx("input",{type:t.type==="number"?"number":"text",className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-xs",value:String(n!==void 0?n:t.default??""),onChange:i=>{if(t.type==="number"){const l=parseFloat(i.target.value);r(isNaN(l)?t.default:l)}else r(i.target.value)},min:t.min,max:t.max,step:t.max&&t.max<=1?.1:1})]})}function J0({variations:e,onChange:t,providers:n}){const r=()=>{const o=n[0],c={provider:(o==null?void 0:o.name)||"azure_openai",model:(o==null?void 0:o.models[0])||"gpt-4o"};t([...e,c])},s=o=>{t(e.filter((c,u)=>u!==o))},i=(o,c)=>{t(e.map((u,d)=>d===o?{...u,...c}:u))},l=(o,c)=>{const u=n.find(d=>d.name===c);i(o,{provider:c,model:(u==null?void 0:u.models[0])||""})};return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm font-medium",children:"LLM Configurations"}),a.jsx(K,{type:"button",variant:"ghost",size:"sm",icon:qc,onClick:r,children:"Add"})]}),e.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:`Uses agent's default LLM. Click "Add" to test different models.`}):a.jsx("div",{className:"space-y-2",children:e.map((o,c)=>{const u=n.find(d=>d.name===o.provider);return a.jsxs("div",{className:"flex items-center gap-2 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[a.jsx("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.provider,onChange:d=>l(c,d.target.value),children:n.map(d=>a.jsx("option",{value:d.name,children:d.label},d.name))}),u&&u.models.length>0?a.jsxs("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:d=>i(c,{model:d.target.value}),children:[u.models.map(d=>a.jsx("option",{value:d,children:d},d)),!u.models.includes(o.model)&&o.model&&a.jsx("option",{value:o.model,children:o.model})]}):a.jsx("input",{type:"text",className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:d=>i(c,{model:d.target.value}),placeholder:"Model ID"}),a.jsx("button",{type:"button",onClick:()=>s(c),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:a.jsx(Wm,{size:16})})]},c)})})]})}const Qo={compaction:[],tools:[],llm_config:[],instructions:[],instruction_strategies:[]};function Y0({agentId:e,agentName:t,agentFramework:n="maf",taskSuite:r,taskCount:s,schema:i,onVariationsChange:l,parallel:o,onParallelChange:c,budget:u,onBudgetChange:d,useLlmEval:f,onUseLlmEvalChange:m}){const[v,k]=g.useState(Qo),[w,b]=g.useState(!1),[p,h]=g.useState(""),[x,j]=g.useState(null),C=i.frameworks[n],S=(C==null?void 0:C.compaction_strategies)||Object.keys(i.compaction_strategies),N=i.tool_presets||[],_=i.llm_providers||[],L=(()=>{let T=1;v.compaction.length>0&&(T*=v.compaction.length),v.tools.length>0&&(T*=v.tools.length),v.llm_config.length>0&&(T*=v.llm_config.length);const V=v.instructions.length+v.instruction_strategies.reduce((te,O)=>te+O.max_candidates,0);return V>0&&(T*=V),Math.min(T,u)})(),B=L*s,J=T=>{k(T),l==null||l(T)},re=Xe({mutationFn:T=>Bo.design(T),onSuccess:T=>{h(T.yaml_content),b(!0)}}),ce=Xe({mutationFn:T=>Bo.validate(T),onSuccess:T=>{j({valid:T.valid,errors:T.errors,warnings:T.warnings})}}),D=()=>({base_agent_id:e,task_suite:r,variations:v,parallel:o,budget:u,use_llm_eval:f}),q=()=>{re.mutate(D())},Z=()=>{ce.mutate(D())},P=()=>{const T=new Blob([p],{type:"text/yaml"}),V=URL.createObjectURL(T),te=document.createElement("a");te.href=V,te.download=`${t}_experiment.yaml`,te.click(),URL.revokeObjectURL(V)},A=v.compaction.length>0||v.tools.length>0||v.llm_config.length>0||v.instructions.length>0||v.instruction_strategies.length>0;return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsxs(G,{variant:"info",children:[L," candidates"]}),a.jsxs(G,{children:[s," tasks"]}),a.jsxs(G,{variant:B>100?"warning":"success",children:[B," total runs"]})]}),a.jsx(W0,{variations:v.compaction,onChange:T=>J({...v,compaction:T}),strategies:i.compaction_strategies,availableStrategies:S}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("label",{className:"text-sm font-medium",children:"Tool Presets"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(T=>a.jsxs("label",{className:`flex items-center gap-2 px-3 py-1.5 border rounded cursor-pointer transition-colors ${v.tools.includes(T.name)?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[a.jsx("input",{type:"checkbox",checked:v.tools.includes(T.name),onChange:V=>{const te=V.target.checked?[...v.tools,T.name]:v.tools.filter(O=>O!==T.name);J({...v,tools:te})},className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:T.name}),a.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",T.tools.length,")"]})]},T.name))}),v.tools.length>0&&a.jsxs("p",{className:"text-xs text-[var(--text-secondary)]",children:["Selected: ",v.tools.join(", ")]})]}),a.jsx(J0,{variations:v.llm_config,onChange:T=>J({...v,llm_config:T}),providers:_}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-4 space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium",children:"Execution Settings"}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(yn,{label:"Parallel Workers",type:"number",value:o,onChange:T=>c(parseInt(T.target.value)||1),min:1,max:16}),a.jsx(yn,{label:"Budget (max candidates)",type:"number",value:u,onChange:T=>d(parseInt(T.target.value)||100),min:1,max:1e3})]}),a.jsx(Ni,{label:"Use LLM evaluation",checked:f,onChange:T=>m(T.target.checked)}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] ml-6 -mt-2",children:f?"LLM-as-Judge scores task completion (0-1)":"Simple pass/fail based on task success"})]}),a.jsxs("div",{className:"flex items-center gap-2 border-t border-[var(--border)] pt-4",children:[a.jsx(K,{variant:"secondary",size:"sm",onClick:Z,loading:ce.isPending,children:"Validate"}),a.jsx(K,{variant:"secondary",size:"sm",icon:Ld,onClick:q,loading:re.isPending,children:"Export YAML"})]}),x&&a.jsxs("div",{className:`p-3 rounded border ${x.valid?"border-green-500/50 bg-green-500/10":"border-red-500/50 bg-red-500/10"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[x.valid?a.jsx(Dm,{size:16,className:"text-green-500"}):a.jsx(Fm,{size:16,className:"text-red-500"}),a.jsx("span",{className:"font-medium text-sm",children:x.valid?"Configuration valid":"Configuration has issues"})]}),x.errors.length>0&&a.jsx("ul",{className:"text-sm text-red-500 list-disc ml-6",children:x.errors.map((T,V)=>a.jsx("li",{children:T},V))}),x.warnings.length>0&&a.jsx("ul",{className:"text-sm text-yellow-500 list-disc ml-6 mt-1",children:x.warnings.map((T,V)=>a.jsx("li",{children:T},V))})]}),w&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-lg shadow-xl max-w-2xl w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border)]",children:[a.jsx("h3",{className:"font-medium",children:"Experiment YAML"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(K,{variant:"secondary",size:"sm",icon:Ld,onClick:P,children:"Download"}),a.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(!1),children:"Close"})]})]}),a.jsx("pre",{className:"flex-1 overflow-auto p-4 text-xs font-mono bg-[var(--bg-secondary)]",children:p})]})}),!A&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No variations selected. Only the baseline agent will be tested. Add compaction strategies, tool presets, or LLM configs to generate candidates."})]})}const X0=[{key:"instruction",label:"Optimize Instructions",description:"LLM iteratively evaluates and rewrites agent instructions",icon:Qm},{key:"tool",label:"Optimize Tools",description:"LLM analyzes which tools help or hurt and adjusts tool config",icon:qm},{key:"skill",label:"Optimize Skills",description:"LLM generates and refines agent skill files (SKILL.md)",icon:Im}];function rp({agent:e,isOpen:t,onClose:n}){var H;const r=Dn(),s=Jt(),[i,l]=g.useState("ready"),[o,c]=g.useState("quick"),[u,d]=g.useState(!1),[f,m]=g.useState([]),[v,k]=g.useState(null),[w,b]=g.useState(5),[p,h]=g.useState(!1),[x,j]=g.useState(Qo),[C,S]=g.useState(4),[N,_]=g.useState(100),[z,L]=g.useState(!1),[B,J]=g.useState(null),{data:re=[]}=oe({queryKey:["tasks"],queryFn:()=>wt.list()}),{data:ce=[]}=oe({queryKey:["suites"],queryFn:()=>wt.listSuites()}),{data:D}=oe({queryKey:["agent-schema"],queryFn:()=>ep.getAgentSchema()}),q=ce.map(F=>({value:F.name,label:F.name.charAt(0).toUpperCase()+F.name.slice(1),description:F.description,tasks:F.task_count})),Z=Xe({mutationFn:wt.importSuite,onSuccess:F=>{s.invalidateQueries({queryKey:["tasks"]}),m(F.map(se=>se.id))}}),P=Xe({mutationFn:async F=>{const se=await Rt.create(F);return Rt.start(se.id).next(),se},onSuccess:F=>{s.invalidateQueries({queryKey:["jobs"]}),J(F.id),l("success")}}),A=()=>{let F=1;x.compaction.length>0&&(F*=x.compaction.length),x.tools.length>0&&(F*=x.tools.length),x.llm_config.length>0&&(F*=x.llm_config.length);const se=x.instructions.length+x.instruction_strategies.reduce((Ze,Xt)=>Ze+Xt.max_candidates,0);return se>0&&(F*=se),Math.min(F,N)},T=p&&(x.compaction.length>0||x.tools.length>0||x.llm_config.length>0||x.instructions.length>0||x.instruction_strategies.length>0),V=v!==null&&!T,te=T?A():1,O=u?f.length:((H=q.find(F=>F.value===o))==null?void 0:H.tasks)||3,Q=V?O:te*O,Ce=async()=>{l("starting");let F=f;if(!u)try{F=(await Z.mutateAsync(o)).map(Ze=>Ze.id)}catch(se){console.error("Failed to import suite:",se),alert(`Failed to import task suite: ${o}`),l("ready");return}if(F.length===0){alert("No tasks selected. Please select tasks or choose a task suite."),l("ready");return}if(V){const se={name:`${e.name} — ${v} optimization`,task_ids:F,parallel:C,use_llm_eval:z,strategy:v,strategy_config:{max_iterations:w},base_agent_id:e.id};P.mutate(se)}else{let se;if(T)try{se=(await Bo.generateCandidates({base_agent_id:e.id,variations:x,budget:N})).candidate_ids}catch(Xt){console.error("Failed to generate candidates:",Xt),alert(`Failed to generate candidates: ${Xt instanceof Error?Xt.message:"Unknown error"}`),l("ready");return}else se=[e.id];const Ze={name:`${e.name} optimization (${se.length} candidates × ${F.length} tasks)`,candidate_ids:se,task_ids:F,parallel:C,use_llm_eval:z};P.mutate(Ze)}},ke=F=>{m(se=>se.includes(F)?se.filter(Ze=>Ze!==F):[...se,F])},_e=()=>{l("ready"),J(null),h(!1),k(null),j(Qo),n()},R=()=>i==="success"&&B?a.jsxs("div",{className:"flex justify-end gap-3",children:[a.jsx(K,{variant:"secondary",onClick:_e,children:"Close"}),a.jsx(K,{variant:"primary",icon:ea,onClick:()=>{_e(),r(`/jobs/${B}`)},children:"View Job"})]}):i==="starting"?null:a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(K,{variant:"secondary",onClick:n,children:"Cancel"}),a.jsx(K,{variant:"primary",icon:ea,onClick:Ce,disabled:u&&f.length===0,children:V?`Start Optimization (${O} tasks)`:`Start Optimization (${Q} runs)`})]});return a.jsx(ls,{isOpen:t,onClose:_e,title:`Optimize: ${e.name}`,footer:R(),size:"lg",children:i==="success"&&B?a.jsxs("div",{className:"flex flex-col items-center py-8",children:[a.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/20 flex items-center justify-center mb-4",children:a.jsx(cr,{size:24,className:"text-green-500"})}),a.jsx("h3",{className:"text-lg font-medium mb-2",children:"Job Started!"}),a.jsx("p",{className:"text-[var(--text-secondary)] text-center mb-2",children:V?`Running ${v} strategy optimization`:"Optimization job is now running"}),a.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-3 py-1.5 rounded font-mono",children:["ID: ",B.slice(0,8),"..."]})]}):i==="starting"?a.jsxs("div",{className:"flex flex-col items-center py-8",children:[a.jsx(ma,{size:32,className:"animate-spin text-[var(--accent)] mb-4"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:Z.isPending?"Importing tasks...":"Creating optimization job..."})]}):a.jsxs("div",{className:"space-y-5",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Task Suite"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:u?"__custom__":o,onChange:F=>{F.target.value==="__custom__"?d(!0):(d(!1),c(F.target.value))},children:[q.map(F=>a.jsxs("option",{value:F.value,children:[F.label," (",F.tasks," tasks) — ",F.description]},F.value)),re.length>0&&a.jsx("option",{value:"__custom__",children:"Custom Selection"})]})]}),u&&re.length>0&&a.jsx("div",{className:"max-h-48 overflow-y-auto border border-[var(--border)] rounded p-2 space-y-1",children:re.map(F=>a.jsxs("label",{className:"flex items-center gap-2 p-2 hover:bg-[var(--bg-tertiary)] cursor-pointer rounded",children:[a.jsx("input",{type:"checkbox",checked:f.includes(F.id),onChange:()=>ke(F.id),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:F.name}),F.suite&&a.jsx(G,{children:F.suite})]},F.id))}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Optimization Strategy"}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mb-3",children:"Select a strategy for automatic, iterative optimization. The LLM will evaluate your agent, reflect on failures, and generate improved configurations."}),a.jsxs("div",{className:"space-y-2",children:[X0.map(F=>{const se=v===F.key;return a.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${se?"border-[var(--accent)] bg-[var(--accent)]/5":"border-[var(--border)] hover:border-[var(--text-secondary)]"}`,children:[a.jsx("input",{type:"radio",name:"strategy",checked:se,onChange:()=>k(se?null:F.key),className:"accent-[var(--accent)] mt-0.5"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(F.icon,{size:14,className:"text-[var(--accent)]"}),a.jsx("span",{className:"text-sm font-medium",children:F.label})]}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:F.description})]})]},F.key)}),a.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${v===null?"border-[var(--accent)] bg-[var(--accent)]/5":"border-[var(--border)] hover:border-[var(--text-secondary)]"}`,children:[a.jsx("input",{type:"radio",name:"strategy",checked:v===null,onChange:()=>k(null),className:"accent-[var(--accent)] mt-0.5"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(cr,{size:14,className:"text-[var(--text-secondary)]"}),a.jsx("span",{className:"text-sm font-medium",children:"Baseline Evaluation"})]}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:"Run the agent as-is against the task suite to measure current performance"})]})]})]}),v&&a.jsx("div",{className:"mt-3 pl-8",children:a.jsxs("label",{className:"text-xs text-[var(--text-secondary)] flex items-center gap-2",children:["Max iterations",a.jsx("input",{type:"number",min:1,max:20,value:w,onChange:F=>b(parseInt(F.target.value)||5),className:"w-16 px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm"})]})})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[a.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>h(!p),children:[a.jsx(Zs,{size:14,className:`transition-transform ${p?"rotate-90":""}`}),"Advanced: Grid Search",p&&a.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"(manual variation design)"})]}),p&&a.jsxs("div",{className:"mt-3",children:[T&&v&&a.jsx("div",{className:"mb-3 p-2 rounded bg-yellow-500/10 border border-yellow-500/30 text-xs text-yellow-600 dark:text-yellow-400",children:"Grid variations are set — this will override the strategy selection and run a static grid search instead."}),D&&a.jsx(Y0,{agentId:e.id,agentName:e.name,agentFramework:e.config.framework,taskSuite:u?void 0:o,taskCount:O,schema:D,onVariationsChange:j,parallel:C,onParallelChange:S,budget:N,onBudgetChange:_,useLlmEval:z,onUseLlmEvalChange:L})]})]})]})})}function Z0(){const e=Dn(),t=Jt(),[n,r]=g.useState(!1),[s,i]=g.useState(null),{data:l=[],isLoading:o}=oe({queryKey:["configs"],queryFn:()=>Tn.list()}),c=Xe({mutationFn:Tn.create,onSuccess:()=>{t.invalidateQueries({queryKey:["configs"]}),r(!1)}}),u=Xe({mutationFn:Tn.delete,onSuccess:()=>t.invalidateQueries({queryKey:["configs"]})}),d=[{key:"name",header:"Name",render:f=>a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:f.name})},{key:"framework",header:"Framework",render:f=>a.jsx(G,{children:f.config.framework||"maf"})},{key:"tools",header:"Tools",render:f=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:e1(f.config.tools)})},{key:"compaction",header:"Compaction",render:f=>{const m=f.config.compaction;return!m||m.strategy==="none"?a.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"}):m.strategy==="head_tail"?a.jsxs(G,{children:[m.params.head_size,"/",m.params.tail_size]}):a.jsx(G,{children:m.strategy})}},{key:"created",header:"Created",render:f=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(f.created_at).toLocaleDateString()}),sortable:!0,sortValue:f=>new Date(f.created_at).getTime()},{key:"actions",header:"",className:"w-40",render:f=>a.jsxs("div",{className:"flex items-center gap-2",onClick:m=>m.stopPropagation(),children:[a.jsx(K,{variant:"primary",size:"sm",icon:cr,onClick:()=>i(f),children:"Optimize"}),a.jsx(K,{variant:"ghost",size:"sm",icon:Wc,title:"Delete",onClick:()=>{confirm(`Delete agent "${f.name}"?`)&&u.mutate(f.id)}})]})}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Agents"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Define and optimize your agent configurations."})]}),a.jsx(K,{variant:"primary",icon:qc,onClick:()=>r(!0),children:"Create agent"})]}),o?a.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[a.jsx(ma,{size:16,className:"animate-spin"}),"Loading agents..."]}):a.jsx(np,{columns:d,data:l,onRowClick:f=>e(`/agents/${f.id}`),searchable:!0,searchPlaceholder:"Search agents",searchFilter:(f,m)=>f.name.toLowerCase().includes(m.toLowerCase())||(f.description||"").toLowerCase().includes(m.toLowerCase()),emptyMessage:"No agents yet. Create your first agent to start optimizing.",emptyIcon:a.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-[var(--bg-tertiary)]",children:a.jsx(Km,{size:24,className:"text-[var(--text-secondary)]"})})}),a.jsx(t1,{isOpen:n,onClose:()=>r(!1),onSubmit:f=>c.mutate(f),isLoading:c.isPending}),s&&a.jsx(rp,{agent:s,isOpen:!!s,onClose:()=>i(null)})]})}function e1(e){return typeof e=="string"?e:Array.isArray(e)?`[${e.length}]`:e&&typeof e=="object"?`[${Object.keys(e).length}]`:"standard"}function t1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){var V,te,O,Q,Ce,ke,_e;const s=["read_file","write_file","edit_file","bash","grep","think"],[i,l]=g.useState("preset"),[o,c]=g.useState({name:"",description:"",instructions:null,model:null,compaction:{strategy:"none",params:{}},tools:s,framework:"miniagent",llm_config_id:null}),[u,d]=g.useState(!1),[f,m]=g.useState("preset"),[v,k]=g.useState([...s]),[w,b]=g.useState(!1),{data:p}=oe({queryKey:["agent-schema"],queryFn:()=>ep.getAgentSchema()}),{data:h=[]}=oe({queryKey:["llm-configs"],queryFn:()=>C0.list()}),{data:x}=oe({queryKey:["tools"],queryFn:()=>_0.list()}),j=((V=x==null?void 0:x.tools)==null?void 0:V.map(R=>R.name))??s,C=(x==null?void 0:x.presets)??{},S=Object.keys(C),N=(p==null?void 0:p.frameworks)??{},_=Object.keys(N).length>0?Object.keys(N):Q0,z=o.framework||"miniagent",L=((O=(te=p==null?void 0:p.frameworks)==null?void 0:te[z])==null?void 0:O.compaction_strategies)??["none","head_tail"],B=(p==null?void 0:p.compaction_strategies)??{},J=(p==null?void 0:p.agent_presets)??[],re=R=>{const H=R.config,F=H.compaction;n({name:R.name+"-agent",description:R.description,framework:H.framework||"miniagent",tools:H.tools||"standard",compaction:F||{strategy:"none",params:{}},instructions:H.instructions||null})},ce=R=>{if(R.preventDefault(),!o.name.trim())return;const H={...o};f==="custom"&&(H.tools=v),n(H)},D=((Q=o.compaction)==null?void 0:Q.strategy)!=="none",q=((Ce=o.compaction)==null?void 0:Ce.strategy)||"none",Z=B[q],P=R=>{k(H=>H.includes(R)?H.filter(F=>F!==R):[...H,R])},A=R=>{const H=B[R],F={};if(H!=null&&H.params)for(const[se,Ze]of Object.entries(H.params))Ze.default!==void 0&&(F[se]=Ze.default);c({...o,compaction:{strategy:R,params:F}})},T=i==="custom"?a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(K,{type:"submit",form:"create-agent-form",variant:"primary",disabled:!o.name.trim(),loading:r,children:"Create Agent"})]}):a.jsx("div",{className:"flex justify-end gap-2",children:a.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"})});return a.jsxs(ls,{isOpen:e,onClose:t,title:"Create Agent",footer:T,children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b border-[var(--border)]",children:[a.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${i==="preset"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("preset"),children:"From Preset"}),a.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${i==="custom"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("custom"),children:"Custom"})]}),i==="preset"?a.jsx("div",{className:"space-y-3",children:J.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"Loading presets..."}):J.map(R=>a.jsx("button",{type:"button",className:"w-full text-left p-4 border border-[var(--border)] rounded-lg hover:border-[var(--accent)] hover:bg-[var(--accent)]/5 transition-colors",onClick:()=>re(R),disabled:r,children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("h4",{className:"font-medium",children:R.label}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:R.description}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[R.tags.map(H=>a.jsx(G,{variant:"default",children:H},H)),R.suggested_datasets.length>0&&a.jsxs(G,{variant:"success",children:["datasets: ",R.suggested_datasets.join(", ")]})]})]}),a.jsx(Zs,{size:16,className:"text-[var(--text-secondary)] mt-1 flex-shrink-0"})]})},R.name))}):a.jsxs("form",{id:"create-agent-form",onSubmit:ce,className:"space-y-4",children:[a.jsx(yn,{label:"Name",value:o.name,onChange:R=>c({...o,name:R.target.value}),placeholder:"e.g., my-coding-agent",required:!0}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"LLM Configuration"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.llm_config_id||"",onChange:R=>c({...o,llm_config_id:R.target.value||null}),children:[a.jsx("option",{value:"",children:"Use environment variables"}),h.map(R=>a.jsxs("option",{value:R.id,children:[R.name," (",K0[R.provider],R.model_id?` - ${R.model_id}`:"",")",R.is_default?" (default)":""]},R.id))]}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:h.length===0?"No LLM configs found. Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)":o.llm_config_id?"Uses the selected LLM configuration.":"Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Framework"}),a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.framework||"miniagent",onChange:R=>{const H=R.target.value;c({...o,framework:H,compaction:{strategy:"none",params:{}}})},children:_.map(R=>{var H;return a.jsx("option",{value:R,children:((H=N[R])==null?void 0:H.label)||V0[R]||R},R)})}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((ke=N[z])==null?void 0:ke.description)||(z==="miniagent"?"Lightweight agent with token-aware context management.":z==="langgraph"?"Graph-based workflows with state management.":"Default agent implementation.")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(Ni,{label:"Custom instructions",checked:u,onChange:R=>{d(R.target.checked),R.target.checked||c({...o,instructions:null})}}),a.jsx(Ni,{label:"Enable compaction",checked:D,onChange:R=>{if(R.target.checked){const H=L.find(F=>F!=="none")||"head_tail";A(H)}else c({...o,compaction:{strategy:"none",params:{}}})}})]}),u&&a.jsx("textarea",{className:"w-full h-32 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono resize-y",value:o.instructions||"",onChange:R=>c({...o,instructions:R.target.value||null}),placeholder:"System prompt / instructions for the agent..."}),D&&a.jsxs("div",{className:"space-y-3 p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Compaction Strategy"}),a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:q,onChange:R=>A(R.target.value),children:L.filter(R=>R!=="none").map(R=>{var H;return a.jsx("option",{value:R,children:((H=B[R])==null?void 0:H.label)||R},R)})}),(Z==null?void 0:Z.description)&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:Z.description})]}),(Z==null?void 0:Z.params)&&Object.keys(Z.params).length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-3",children:Object.entries(Z.params).map(([R,H])=>{var Ze;const F=(Ze=o.compaction)==null?void 0:Ze.params[R],se=F!==void 0?F:H.default;return a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:R.replace(/_/g," ")}),a.jsx("input",{type:"number",className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof se=="number"?se:Number(se)||0,onChange:Xt=>{const nu=parseFloat(Xt.target.value);c({...o,compaction:{...o.compaction,params:{...o.compaction.params,[R]:isNaN(nu)?typeof H.default=="number"?H.default:0:nu}}})},min:H.min,max:H.max,step:H.max&&H.max<=1?.1:1}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:H.description})]},R)})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm font-medium",children:"Tools"}),a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"radio",checked:f==="preset",onChange:()=>m("preset"),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:"Preset"})]}),a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"radio",checked:f==="custom",onChange:()=>m("custom"),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:"Custom"})]})]}),f==="preset"?a.jsxs(a.Fragment,{children:[a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof o.tools=="string"?o.tools:"standard",onChange:R=>c({...o,tools:R.target.value}),children:S.map(R=>a.jsx("option",{value:R,children:R},R))}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((_e=C[typeof o.tools=="string"?o.tools:"standard"])==null?void 0:_e.join(", "))??""})]}):a.jsx("div",{className:"grid grid-cols-2 gap-1 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:j.map(R=>a.jsxs("label",{className:"flex items-center gap-2 p-1 text-sm cursor-pointer hover:bg-[var(--bg-tertiary)]",children:[a.jsx("input",{type:"checkbox",checked:v.includes(R),onChange:()=>P(R),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"font-mono text-xs",children:R})]},R))})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[a.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>b(!w),children:[a.jsx(Zs,{size:14,className:`transition-transform ${w?"rotate-90":""}`}),"More options"]}),w&&a.jsx("div",{className:"mt-3",children:a.jsx(yn,{label:"Description (optional)",value:o.description,onChange:R=>c({...o,description:R.target.value}),placeholder:"Brief description of this agent"})})]})]})]})}function pa({items:e}){return a.jsx("nav",{className:"flex items-center gap-1.5 text-sm mb-4",children:e.map((t,n)=>{const r=n===e.length-1;return a.jsxs("span",{className:"flex items-center gap-1.5",children:[n>0&&a.jsx(Zs,{size:14,className:"text-[var(--text-secondary)]"}),t.path&&!r?a.jsx(Rn,{to:t.path,className:"text-[var(--text-secondary)] hover:text-[var(--accent)] transition-colors",children:t.label}):a.jsx("span",{className:r?"text-[var(--text-primary)] font-medium":"text-[var(--text-secondary)]",children:t.label})]},n)})})}function ge({children:e,className:t="",onClick:n,selected:r=!1,selectable:s=!1}){const i="bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",l=s?"cursor-pointer hover:border-[var(--accent-dim)] transition-colors":"",o=r?"border-[var(--accent)]":"";return a.jsx("div",{className:`${i} ${l} ${o} ${t}`,onClick:n,children:e})}function n1(e){const t=[],n=r=>r.type==="trace_span"&&typeof r.data=="object"&&r.data!==null?r.data:"span_id"in r?r:null;if(Array.isArray(e.spans)){for(const r of e.spans)if(typeof r=="object"&&r!==null){const s=n(r);s&&t.push(s)}}else if(e.span_id)t.push(e);else for(const r in e){const s=e[r];if(typeof s=="object"&&s!==null){const i=n(s);if(i)t.push(i);else if(Array.isArray(s)){for(const l of s)if(typeof l=="object"&&l!==null){const o=n(l);o&&t.push(o)}}}}return t}function sp(e){const t=new Map,n=[];for(const s of e)t.set(s.span_id,{span:s,children:[]});for(const s of e){const i=t.get(s.span_id);s.parent_span_id&&t.has(s.parent_span_id)?t.get(s.parent_span_id).children.push(i):n.push(i)}const r=s=>{s.sort((i,l)=>(i.span.start_time||0)-(l.span.start_time||0)),s.forEach(i=>r(i.children))};return r(n),n}function r1(e){return e.includes("Agent")||e.includes("agent")?"bg-[var(--span-llm-bg)] text-[var(--span-llm-text)]":e.includes("chat")||e.includes("Chat")||e.includes("llm")?"bg-[var(--span-tool-bg)] text-[var(--span-tool-text)]":e.includes("tool")||e.includes("execute")||e.includes("bash")?"bg-[var(--span-agent-bg)] text-[var(--span-agent-text)]":"bg-[var(--span-other-bg)] text-[var(--span-other-text)]"}function s1(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(0)}ms`}function tu({node:e,depth:t=0}){var f,m;const[n,r]=g.useState(t<2),[s,i]=g.useState(!1),{span:l}=e,o=e.children.length>0,c=(f=l.attributes)==null?void 0:f["gen_ai.usage.input_tokens"],u=(m=l.attributes)==null?void 0:m["gen_ai.usage.output_tokens"],d=c!==void 0||u!==void 0;return a.jsxs("div",{className:"relative",children:[t>0&&a.jsx("div",{className:"absolute left-0 top-0 bottom-0 border-l-2 border-[var(--border)]",style:{marginLeft:`${(t-1)*16+8}px`}}),a.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-1 hover:bg-[var(--bg-primary)] rounded transition-colors cursor-pointer",style:{paddingLeft:`${t*16}px`},onClick:()=>o?r(!n):i(!s),children:[a.jsx("div",{className:"w-4 h-4 flex items-center justify-center text-[var(--text-secondary)]",children:o?n?"▼":"▶":s?"▼":"▶"}),a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${r1(l.operation_name)}`,children:l.operation_name.replace("ChatAgent.","").replace("invoke_agent ","")}),l.duration_ms!==void 0&&a.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:s1(l.duration_ms)}),d&&a.jsxs("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:[c!==void 0&&a.jsxs("span",{className:"text-blue-400",children:["↑",String(c)]}),c!==void 0&&u!==void 0&&a.jsx("span",{className:"mx-0.5",children:"/"}),u!==void 0&&a.jsxs("span",{className:"text-green-400",children:["↓",String(u)]})]})]}),s&&!o&&a.jsx("div",{className:"ml-4 mt-1 mb-2 p-2 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs",style:{marginLeft:`${t*16+20}px`},children:a.jsxs("div",{className:"space-y-1",children:[l.span_id&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Span ID:"}),a.jsx("span",{className:"font-mono text-xs break-all",children:l.span_id})]}),l.trace_id&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Trace ID:"}),a.jsx("span",{className:"font-mono text-xs break-all",children:l.trace_id})]}),l.status&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Status:"}),a.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs ${l.status==="OK"||l.status==="StatusCode.UNSET"?"bg-[var(--span-pass-bg)] text-[var(--span-pass-text)]":"bg-[var(--span-fail-bg)] text-[var(--span-fail-text)]"}`,children:l.status})]}),Object.keys(l.attributes||{}).length>0&&a.jsxs("div",{className:"mt-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] block mb-1",children:"Attributes:"}),a.jsx("pre",{className:"text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded p-2 overflow-auto max-h-32 whitespace-pre-wrap break-all",children:JSON.stringify(l.attributes,null,2)})]})]})}),o&&n&&a.jsx("div",{children:e.children.map((v,k)=>a.jsx(tu,{node:v,depth:t+1},v.span.span_id||k))})]})}function ap({trace:e}){const[t,n]=g.useState("tree"),r=g.useMemo(()=>n1(e),[e]),s=g.useMemo(()=>sp(r),[r]);return Object.keys(e).length===0?null:a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"font-medium",children:"Trace Data"}),a.jsxs("div",{className:"flex gap-1",children:[a.jsx("button",{onClick:()=>n("tree"),className:`px-2 py-1 text-xs rounded ${t==="tree"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Tree"}),a.jsx("button",{onClick:()=>n("raw"),className:`px-2 py-1 text-xs rounded ${t==="raw"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Raw"})]})]}),t==="tree"?r.length>0?a.jsx("div",{className:"border border-[var(--border)] rounded overflow-hidden",children:a.jsxs("div",{className:"p-2",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs(G,{variant:"default",children:[r.length," spans"]}),a.jsx("span",{children:"•"}),a.jsx("span",{children:"Click to expand details"})]}),s.map((i,l)=>a.jsx(tu,{node:i,depth:0},i.span.span_id||l))]})}):a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No structured spans found. View raw data below."}):a.jsx("pre",{className:"text-xs bg-[var(--bg-primary)] p-3 overflow-x-auto border border-[var(--border)] max-h-96 whitespace-pre-wrap",children:JSON.stringify(e,null,2)})]})}function a1({spans:e,isLive:t=!1}){const n=g.useRef(null),r=g.useMemo(()=>sp(e),[e]);return g.useEffect(()=>{n.current&&t&&n.current.scrollTo({top:n.current.scrollHeight,behavior:"smooth"})},[e.length,t]),a.jsxs("div",{className:"border border-[var(--border)] rounded overflow-hidden h-full flex flex-col",children:[a.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-[var(--border)] bg-[var(--bg-secondary)]",children:[a.jsxs(G,{variant:"default",children:[e.length," spans"]}),t&&a.jsx("span",{className:"animate-pulse",children:a.jsx(G,{variant:"info",children:"Live"})})]}),a.jsx("div",{ref:n,className:"flex-1 overflow-auto p-2",children:r.length>0?r.map((s,i)=>a.jsx(tu,{node:s,depth:0},s.span.span_id||i)):a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:t?"Waiting for spans...":"No spans recorded"})})]})}function ip({agent:e}){const[t,n]=g.useState(""),[r,s]=g.useState(null),[i,l]=g.useState("idle"),[o,c]=g.useState(null),[u,d]=g.useState(""),[f,m]=g.useState([]),[v,k]=g.useState(null),[w,b]=g.useState(null),[p,h]=g.useState([]),[x,j]=g.useState(!1),C=g.useRef(null),{data:S=[]}=oe({queryKey:["tasks"],queryFn:()=>wt.list()});g.useEffect(()=>{C.current&&i==="running"&&(C.current.scrollTop=C.current.scrollHeight)},[u,i]);const N=D=>{if(s(D),D){const q=S.find(Z=>Z.id===D);q&&n(q.prompt)}},_=async()=>{if(t.trim()){l("running"),d(""),m([]),k(null),b(null),h([]);try{const D=await Ls.create({agent_id:e.id,prompt:t.trim(),task_id:r||void 0});c(D.id);for await(const q of Ls.start(D.id))z(q)}catch(D){b(D instanceof Error?D.message:"Test failed"),l("failed")}}},z=D=>{switch(D.event){case"started":break;case"execution":D.execution_event==="text_delta"&&D.content?d(q=>q+D.content):D.execution_event==="tool_call_start"&&D.tool_name?h(q=>[...q,{name:D.tool_name}]):D.execution_event==="tool_result"&&D.content&&h(q=>{if(q.length>0){const Z=[...q];return Z[Z.length-1]={...Z[Z.length-1],content:D.content},Z}return q});break;case"span":if(D.span){const q=D.span;if(q.data){const Z={span_id:q.data.span_id||"",trace_id:q.data.trace_id||"",parent_span_id:q.data.parent_span_id||null,operation_name:q.data.operation_name||"",start_time:q.timestamp?new Date(q.timestamp).getTime():Date.now(),end_time:Date.now(),duration_ms:q.data.duration_ms||0,status:q.data.status||"OK",attributes:q.data.attributes||{}};m(P=>[...P,Z])}}break;case"complete":l("completed"),D.result&&k(D.result);break;case"error":b(D.message),l("failed");break}},L=async()=>{if(o)try{await Ls.cancel(o)}catch{}l("idle")},B=()=>{l("idle"),c(null),d(""),m([]),k(null),b(null),h([])},J=i==="running",re=i==="completed"||i==="failed",ce=D=>{D.preventDefault(),re?(B(),setTimeout(()=>_(),0)):_()};return a.jsxs("div",{className:"h-full flex flex-col border border-[var(--border)] rounded-lg overflow-hidden bg-[var(--bg-primary)]",children:[(J||re)&&a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border)] bg-[var(--bg-secondary)] flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[J&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"animate-pulse",children:a.jsx(G,{variant:"info",children:"Running"})}),a.jsx(K,{variant:"ghost",size:"sm",icon:Rd,onClick:L,children:"Cancel"})]}),i==="completed"&&a.jsx(G,{variant:"success",children:"Completed"}),i==="failed"&&a.jsx(G,{variant:"error",children:"Failed"})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[v&&a.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Am,{size:12}),v.duration_seconds.toFixed(2),"s"]}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Fg,{size:12}),v.tokens_total," tokens"]}),v.passed!==null&&(v.passed?a.jsx(Dm,{size:14,className:"text-[var(--success)]"}):a.jsx(Xg,{size:14,className:"text-[var(--error)]"}))]}),f.length>0&&a.jsxs(K,{variant:x?"primary":"secondary",size:"sm",icon:Eg,onClick:()=>j(!x),children:["Traces (",f.length,")"]}),re&&o&&a.jsx(Rn,{to:`/tests/${o}`,children:a.jsx(K,{variant:"secondary",size:"sm",icon:Um,children:"Details"})})]})]}),a.jsxs("div",{className:"flex-1 min-h-0 flex",children:[a.jsx("div",{ref:C,className:`flex-1 overflow-auto p-4 ${x?"border-r border-[var(--border)]":""}`,children:!J&&!re?a.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center",children:[a.jsx("div",{className:"text-lg font-medium mb-1",children:e.name}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] max-w-sm",children:"Send a message to test this agent, or select a task from the dropdown below."})]}):a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"flex justify-end",children:a.jsx("div",{className:"max-w-[80%] px-3 py-2 bg-[var(--accent-dim)] text-[var(--text-primary)] rounded-lg text-sm",children:t})}),(u||J)&&a.jsx("div",{className:"px-3 py-2 text-sm whitespace-pre-wrap font-mono bg-[var(--bg-secondary)] rounded-lg border border-[var(--border)]",children:u||a.jsx("span",{className:"text-[var(--text-secondary)] animate-pulse",children:"Thinking..."})}),p.length>0&&a.jsx("div",{className:"space-y-1.5",children:p.map((D,q)=>a.jsxs("div",{className:"p-2 bg-[var(--badge-info-bg)] border border-[var(--badge-info-border)] rounded-md text-xs",children:[a.jsx(G,{variant:"info",children:D.name}),D.content&&a.jsxs("div",{className:"mt-1 text-[var(--text-secondary)] truncate max-w-full font-mono",children:[D.content.substring(0,200),D.content.length>200&&"..."]})]},q))}),w&&a.jsx("div",{className:"p-3 bg-[var(--badge-error-bg)] border border-[var(--badge-error-border)] rounded-md text-sm text-[var(--badge-error-text)]",children:w})]})}),x&&a.jsx("div",{className:"w-[350px] flex-shrink-0 overflow-auto",children:a.jsx(a1,{spans:f,isLive:J})})]}),a.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] bg-[var(--bg-secondary)]",children:[a.jsx("div",{className:"px-4 pt-2",children:a.jsxs("select",{value:r||"",onChange:D=>N(D.target.value||null),className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs text-[var(--text-secondary)]",disabled:J,children:[a.jsx("option",{value:"",children:"Custom prompt..."}),S.map(D=>a.jsx("option",{value:D.id,children:D.name},D.id))]})}),a.jsxs("form",{onSubmit:ce,className:"p-3 flex gap-2",children:[a.jsx("textarea",{value:t,onChange:D=>n(D.target.value),placeholder:"Message the agent...",disabled:J,rows:1,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm resize-none min-h-[40px] max-h-[120px] focus:outline-none focus:border-[var(--accent)]",onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),ce(D))}}),a.jsx(K,{type:"submit",variant:"primary",icon:J?Rd:ea,disabled:J?!1:!t.trim(),onClick:J?L:void 0,children:J?"Stop":re?"New Test":"Run"})]})]})]})}function i1(){const{agentId:e}=ha(),t=Dn(),n=Jt(),[r,s]=g.useState("overview"),[i,l]=g.useState(!1),{data:o,isLoading:c}=oe({queryKey:["configs",e],queryFn:()=>Tn.get(e),enabled:!!e}),{data:u=[]}=oe({queryKey:["tests",{agent_id:e}],queryFn:()=>Ls.list({agent_id:e}),enabled:!!e}),{data:d=[]}=oe({queryKey:["jobs"],queryFn:()=>Rt.list()}),f=Xe({mutationFn:v=>Tn.delete(v),onSuccess:()=>{n.invalidateQueries({queryKey:["configs"]}),t("/agents")}}),m=d.filter(v=>v.candidate_ids.includes(e||""));return c?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):o?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsxs("div",{className:"mb-4 flex-shrink-0",children:[a.jsx(pa,{items:[{label:"Agents",path:"/agents"},{label:o.name}]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:o.name}),o.is_auto_generated&&a.jsx(G,{variant:"info",children:"Auto-generated"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(K,{variant:"primary",icon:cr,size:"sm",onClick:()=>l(!0),children:"Optimize"}),a.jsx(K,{variant:"secondary",icon:Wc,size:"sm",onClick:()=>{confirm(`Delete agent "${o.name}"?`)&&f.mutate(o.id)},children:"Delete"})]})]}),o.description&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:o.description})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsxs("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:[a.jsxs("div",{className:"flex gap-1 mb-4 border-b border-[var(--border)] flex-shrink-0",children:[a.jsx(Sl,{active:r==="overview",onClick:()=>s("overview"),icon:a.jsx(Km,{size:14}),children:"Overview"}),a.jsx(Sl,{active:r==="evaluate",onClick:()=>s("evaluate"),icon:a.jsx(ea,{size:14}),children:"Evaluate"}),a.jsx(Sl,{active:r==="history",onClick:()=>s("history"),icon:a.jsx(Ug,{size:14}),badge:u.length,children:"History"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r==="overview"&&a.jsx(l1,{agent:o,recentTests:u,jobs:m}),r==="evaluate"&&a.jsx(o1,{agent:o,jobs:m}),r==="history"&&a.jsx(c1,{tests:u})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[a.jsx(Vm,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),a.jsx("div",{className:"flex-1 min-h-0",children:a.jsx(ip,{agent:o})})]})]}),i&&a.jsx(rp,{agent:o,isOpen:i,onClose:()=>l(!1)})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Agent not found"})}function Sl({active:e,onClick:t,icon:n,badge:r,children:s}){return a.jsxs("button",{onClick:t,className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors ${e?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[n,s,r!==void 0&&r>0&&a.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs bg-[var(--bg-tertiary)] rounded",children:r})]})}function l1({agent:e,recentTests:t,jobs:n}){var i,l;const r=e.config,s=()=>{const o=r.tools;return typeof o=="string"?o:Array.isArray(o)?o.join(", "):o&&typeof o=="object"?Object.keys(o).join(", "):"standard"};return a.jsxs("div",{className:"space-y-4",children:[a.jsx(mr,{title:"Model",children:a.jsx("div",{className:"font-mono text-sm",children:r.model||"default"})}),a.jsx(mr,{title:"Instructions",defaultCollapsed:!r.instructions,children:r.instructions?a.jsx("pre",{className:"p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs whitespace-pre-wrap max-h-40 overflow-auto font-mono",children:r.instructions}):a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No instructions set"})}),a.jsx(mr,{title:"Tools",children:a.jsx("div",{className:"font-mono text-sm",children:s()})}),a.jsx(mr,{title:"Compaction",children:a.jsx("div",{className:"font-mono text-sm",children:!r.compaction||r.compaction.strategy==="none"?"disabled":`${r.compaction.strategy} (${((i=r.compaction.params)==null?void 0:i.head_size)||0}/${((l=r.compaction.params)==null?void 0:l.tail_size)||0})`})}),t.length>0&&a.jsx(mr,{title:`Recent Tests (${t.length})`,children:a.jsx("div",{className:"space-y-1.5",children:t.slice(0,3).map(o=>a.jsxs(Rn,{to:`/tests/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx(lp,{status:o.status}),a.jsxs("span",{className:"truncate",children:[o.prompt.slice(0,40),"..."]})]}),a.jsxs("span",{className:"text-[var(--text-secondary)] flex-shrink-0 ml-2",children:[o.duration_seconds.toFixed(1),"s"]})]},o.id))})}),n.length>0&&a.jsx(mr,{title:`Experiments (${n.length})`,children:a.jsx("div",{className:"space-y-1.5",children:n.slice(0,3).map(o=>a.jsxs(Rn,{to:`/jobs/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(G,{variant:o.status==="completed"?"success":o.status==="running"?"info":"default",children:o.status}),a.jsx("span",{children:o.name})]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(o.created_at).toLocaleDateString()})]},o.id))})})]})}function mr({title:e,children:t,defaultCollapsed:n=!1}){const[r,s]=g.useState(n);return a.jsxs("div",{className:"border-b border-[var(--border)] pb-3",children:[a.jsxs("button",{onClick:()=>s(!r),className:"flex items-center justify-between w-full text-left py-1 hover:text-[var(--accent)] transition-colors",children:[a.jsx("span",{className:"text-sm font-medium",children:e}),a.jsx("span",{className:"text-[var(--text-secondary)] text-xs",children:r?"▶":"▼"})]}),!r&&a.jsx("div",{className:"mt-2",children:t})]})}function o1({agent:e,jobs:t}){const n=Dn(),r=Jt(),[s,i]=g.useState("quick"),[l,o]=g.useState(!1),{data:c=[]}=oe({queryKey:["suites"],queryFn:()=>wt.listSuites()}),u=Xe({mutationFn:P0.start,onSuccess:f=>{r.invalidateQueries({queryKey:["jobs"]}),o(!1),n(`/jobs/${f.id}`)},onError:()=>{o(!1)}}),d=()=>{o(!0),u.mutate({agent_id:e.id,suite_name:s,use_llm_eval:!0,parallel:4})};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:"Run this agent on a task suite to measure quality and cost."}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm",value:s,onChange:f=>i(f.target.value),disabled:l,children:c.map(f=>a.jsxs("option",{value:f.name,children:[f.name.charAt(0).toUpperCase()+f.name.slice(1)," (",f.task_count," tasks)"]},f.name))}),a.jsx(K,{variant:"primary",icon:l?ma:ea,onClick:d,disabled:l,loading:l,className:"w-full",children:"Evaluate"})]})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h4",{className:"text-sm font-medium",children:"Optimization Jobs"}),a.jsx(K,{variant:"secondary",size:"sm",icon:cr,onClick:()=>n("/agents",{state:{optimizeAgent:e}}),children:"New Job"})]}),t.length===0?a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No optimization jobs yet."}):a.jsx("div",{className:"space-y-1.5",children:t.slice(0,5).map(f=>a.jsxs(Rn,{to:`/jobs/${f.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(G,{variant:f.status==="completed"?"success":f.status==="running"?"info":"default",children:f.status}),a.jsx("span",{children:f.name})]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(f.created_at).toLocaleDateString()})]},f.id))})]})]})}function c1({tests:e}){return e.length===0?a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No test history yet. Use the playground on the right to run a test."}):a.jsx("div",{className:"space-y-2",children:e.map(t=>a.jsxs(Rn,{to:`/tests/${t.id}`,className:"flex items-center justify-between p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(lp,{status:t.status}),t.score!==null&&a.jsxs("span",{className:`text-sm font-medium ${t.passed?"text-[var(--success)]":"text-[var(--error)]"}`,children:[(t.score*100).toFixed(0),"%"]})]}),a.jsx("p",{className:"text-sm truncate",children:t.prompt})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1 ml-4",children:[a.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:new Date(t.created_at).toLocaleString()}),a.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:[t.duration_seconds.toFixed(1),"s"]}),a.jsxs("span",{children:[t.tokens_total," tokens"]})]})]})]},t.id))})}function lp({status:e}){const t={completed:"success",failed:"error",running:"info",cancelled:"warning",pending:"default"};return a.jsx(G,{variant:t[e]||"default",children:e})}function u1(){const e=Jt(),[t,n]=g.useState(!1),[r,s]=g.useState(!1),[i,l]=g.useState(null),[o,c]=g.useState(new Set),u=p=>{c(h=>{const x=new Set(h);return x.has(p)?x.delete(p):x.add(p),x})},{data:d=[],isLoading:f}=oe({queryKey:["tasks"],queryFn:()=>wt.list()}),m=Xe({mutationFn:wt.create,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),n(!1)}}),v=Xe({mutationFn:wt.importSuite,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),s(!1)}}),k=Xe({mutationFn:wt.delete,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),l(null)}}),w=d.reduce((p,h)=>{const x=h.suite||"custom";return p[x]||(p[x]=[]),p[x].push(h),p},{}),b=Object.keys(w).sort((p,h)=>p==="custom"?-1:h==="custom"?1:p.localeCompare(h));return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Datasets"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Task datasets for evaluating agent configurations."})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(K,{variant:"secondary",onClick:()=>s(!0),children:"Import Suite"}),a.jsx(K,{variant:"primary",onClick:()=>n(!0),children:"+ New Task"})]})]}),f?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):d.length===0?a.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:"No tasks yet. Create one or import a built-in suite."}):a.jsx("div",{className:"space-y-4",children:b.map(p=>{const h=w[p],x=!o.has(p);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>u(p),className:"flex items-center gap-2 py-2 hover:text-[var(--accent)] transition-colors",children:[x?a.jsx(Rg,{size:16,className:"text-[var(--text-secondary)]"}):a.jsx(Zs,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium uppercase tracking-wide",children:p==="custom"?"Custom Tasks":`${p} Suite`}),a.jsx(G,{variant:p==="custom"?"default":"info",children:h.length})]}),x&&a.jsx("div",{className:"mt-2 border border-[var(--border)] rounded-lg overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:[a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Name"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Category"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Prompt"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Criteria"})]})}),a.jsx("tbody",{children:h.map(j=>a.jsxs("tr",{onClick:()=>l(j),className:"border-b border-[var(--border)] last:border-b-0 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors",children:[a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:j.name})}),a.jsx("td",{className:"px-4 py-3",children:j.category&&j.category!=="default"?a.jsx(G,{variant:"default",children:j.category}):a.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"})}),a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-[var(--text-secondary)] line-clamp-1 max-w-md",children:j.prompt})}),a.jsx("td",{className:"px-4 py-3 text-[var(--text-secondary)]",children:j.criteria.length>0?j.criteria.length:"--"})]},j.id))})]})})]},p)})}),a.jsx(d1,{task:i,onClose:()=>l(null),onDelete:p=>{confirm("Delete this task?")&&k.mutate(p)}}),a.jsx(f1,{isOpen:t,onClose:()=>n(!1),onSubmit:p=>m.mutate(p),isLoading:m.isPending}),a.jsx(h1,{isOpen:r,onClose:()=>s(!1),onSubmit:p=>v.mutate(p),isLoading:v.isPending})]})}function d1({task:e,onClose:t,onDelete:n}){const[r,s]=g.useState("prompt");if(!e)return null;const i=a.jsxs("div",{className:"flex justify-between",children:[a.jsx(K,{variant:"ghost",onClick:()=>n(e.id),className:"text-red-500 hover:text-red-600",children:"Delete Task"}),a.jsx(K,{variant:"secondary",onClick:t,children:"Close"})]});return a.jsx(ls,{isOpen:!!e,onClose:t,title:e.name,size:"lg",footer:i,children:a.jsxs("div",{className:"space-y-4",children:[e.category&&e.category!=="default"&&a.jsx("div",{children:a.jsx(G,{variant:"default",children:e.category})}),a.jsxs("div",{className:"flex gap-1 border-b border-[var(--border)]",children:[a.jsx("button",{onClick:()=>s("prompt"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="prompt"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Prompt"}),a.jsxs("button",{onClick:()=>s("criteria"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="criteria"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:["Eval Criteria (",e.criteria.length,")"]})]}),r==="prompt"&&a.jsx("div",{className:"p-4 bg-[var(--bg-tertiary)] rounded text-sm whitespace-pre-wrap min-h-[200px]",children:e.prompt}),r==="criteria"&&a.jsx("div",{className:"space-y-2 min-h-[200px]",children:e.criteria.length===0?a.jsx("div",{className:"text-[var(--text-secondary)] text-sm p-4",children:"No evaluation criteria defined for this task."}):e.criteria.map(l=>a.jsxs("div",{className:"p-3 bg-[var(--bg-tertiary)] rounded",children:[a.jsx("div",{className:"font-medium text-sm",children:l.name}),l.instruction&&a.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1",children:l.instruction})]},l.name))})]})})}function f1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,i]=g.useState({name:"",prompt:"",criteria:[],category:"default"}),l=()=>{i({...s,criteria:[...s.criteria,{name:"",instruction:"",weight:1}]})},o=(d,f)=>{const m=[...s.criteria];m[d]={...m[d],...f},i({...s,criteria:m})},c=d=>{i({...s,criteria:s.criteria.filter((f,m)=>m!==d)})},u=d=>{d.preventDefault(),!(!s.name.trim()||!s.prompt.trim())&&n({...s,criteria:s.criteria.filter(f=>f.name.trim()&&f.instruction.trim())})};return a.jsx(ls,{isOpen:e,onClose:t,title:"Create Task",children:a.jsxs("form",{onSubmit:u,className:"space-y-4",children:[a.jsx(yn,{label:"Name",value:s.name,onChange:d=>i({...s,name:d.target.value}),placeholder:"e.g., fizzbuzz",required:!0}),a.jsx(q0,{label:"Prompt",value:s.prompt,onChange:d=>i({...s,prompt:d.target.value}),placeholder:"The task description for the agent...",required:!0}),a.jsx(yn,{label:"Category",value:s.category,onChange:d=>i({...s,category:d.target.value}),placeholder:"e.g., coding, research"}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Evaluation Criteria"}),a.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"+ Add"})]}),a.jsx("div",{className:"space-y-2",children:s.criteria.map((d,f)=>a.jsxs("div",{className:"flex gap-2 items-start",children:[a.jsx(yn,{value:d.name,onChange:m=>o(f,{name:m.target.value}),placeholder:"Name",className:"w-32"}),a.jsx(yn,{value:d.instruction,onChange:m=>o(f,{instruction:m.target.value}),placeholder:"Instruction",className:"flex-1"}),a.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(f),children:"×"})]},f))})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[a.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(K,{type:"submit",variant:"primary",disabled:r||!s.name.trim()||!s.prompt.trim(),children:r?"Creating...":"Create"})]})]})})}function h1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,i]=g.useState(""),{data:l=[],isLoading:o}=oe({queryKey:["suites"],queryFn:()=>wt.listSuites(),enabled:e});return g.useEffect(()=>{l.length>0&&!s&&i(l[0].name)},[l,s]),a.jsx(ls,{isOpen:e,onClose:t,title:"Import Task Suite",children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Import a built-in task suite for evaluation."}),o?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading suites..."}):l.length===0?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"No suites available."}):a.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:l.map(c=>a.jsxs("label",{className:`flex items-center gap-3 p-3 border cursor-pointer ${s===c.name?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[a.jsx("input",{type:"radio",name:"suite",value:c.name,checked:s===c.name,onChange:()=>i(c.name),className:"accent-[var(--accent)]"}),a.jsxs("span",{className:"capitalize",children:[c.name.replace(/_/g," ")," (",c.task_count," tasks) - ",c.description]})]},c.name))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[a.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(K,{variant:"primary",onClick:()=>n(s),disabled:r||!s,children:r?"Importing...":"Import"})]})]})})}function m1(){const e=Dn(),t=Jt(),[n,r]=g.useState(!1),s=Zc(),{data:i=[],isLoading:l}=oe({queryKey:["jobs",n],queryFn:()=>Rt.list({include_public:n}),refetchInterval:5e3}),o=Xe({mutationFn:Rt.delete,onSuccess:()=>t.invalidateQueries({queryKey:["jobs"]})}),c={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"},u=[{key:"name",header:"Name",render:d=>a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:d.name||`Job ${d.id.slice(0,8)}`}),d.is_public&&a.jsx(Hc,{className:"w-3 h-3 ml-2 inline text-[var(--text-secondary)]"})]})},{key:"status",header:"Status",render:d=>a.jsx(G,{variant:c[d.status]||"default",children:d.status})},{key:"candidates",header:"Candidates",render:d=>a.jsx("span",{children:d.candidate_ids.length})},{key:"tasks",header:"Tasks",render:d=>a.jsx("span",{children:d.task_ids.length})},{key:"runs",header:"Runs",render:d=>a.jsxs("span",{children:[d.completed_experiments,"/",d.total_experiments]})},{key:"created",header:"Created",render:d=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(d.created_at).toLocaleDateString()}),sortable:!0,sortValue:d=>new Date(d.created_at).getTime()},{key:"actions",header:"",className:"w-12",render:d=>!d.user_id||d.user_id==="anonymous"||s&&d.created_by_name===s?a.jsx("div",{onClick:m=>m.stopPropagation(),children:a.jsx(K,{variant:"ghost",size:"sm",icon:Wc,title:"Delete",disabled:d.status==="running",onClick:()=>{confirm("Delete this job?")&&o.mutate(d.id)}})}):null}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Experiments"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"View and manage optimization experiments. Start new experiments from the Agents page."})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Ni,{label:"Show public",checked:n,onChange:d=>r(d.target.checked)}),a.jsx(K,{variant:"secondary",onClick:()=>e("/agents"),children:"Go to Agents"})]})]}),l?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):a.jsx(np,{columns:u,data:i,onRowClick:d=>e(`/jobs/${d.id}`),searchable:!0,searchPlaceholder:"Search experiments",searchFilter:(d,f)=>(d.name||"").toLowerCase().includes(f.toLowerCase())||d.id.toLowerCase().includes(f.toLowerCase()),emptyMessage:"No experiments yet. Go to Agents page to start an optimization."})]})}function p1(e,t=!0){return Math.abs(e)<10?"text-[var(--text-secondary)]":(t?e<0:e>0)?"text-green-400":"text-red-400"}function x1(e){return`${e>0?"+":""}${e.toFixed(1)}%`}function op(e,t){return t===0?0:(e-t)/t*100}function vs({label:e,values:t,baselineIndex:n,formatter:r,isLowerBetter:s=!0}){const i=t[n];return a.jsxs("tr",{className:"border-b border-[var(--border)] last:border-0",children:[a.jsx("td",{className:"py-2 pr-4 text-[var(--text-secondary)] text-sm",children:e}),t.map((l,o)=>{const c=op(l,i),u=o===n;return a.jsxs("td",{className:"py-2 px-4 text-right",children:[a.jsx("div",{className:"font-mono",children:r(l)}),!u&&a.jsx("div",{className:`text-xs ${p1(c,s)}`,children:x1(c)}),u&&a.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"(baseline)"})]},o)})]})}function v1({runs:e,baselineRunId:t}){const n=g.useMemo(()=>{if(t){const i=e.findIndex(l=>l.id===t);if(i>=0)return i}return 0},[e,t]);if(e.length<2)return null;const r=Math.min(...e.map(i=>i.tokens_total)),s=Math.max(...e.map(i=>i.score));return a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-4",children:"Candidate Comparison"}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-[var(--border)]",children:[a.jsx("th",{className:"pb-2 pr-4 text-left text-[var(--text-secondary)] font-medium",children:"Metric"}),e.map((i,l)=>a.jsx("th",{className:"pb-2 px-4 text-right",children:a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsx("span",{className:"font-medium",children:i.candidate_name}),i.is_pareto&&a.jsx(G,{variant:"success",children:"Optimal"}),l===n&&a.jsx(G,{variant:"info",children:"Base"})]})},i.id))]})}),a.jsxs("tbody",{children:[a.jsx(vs,{label:"Total Tokens",values:e.map(i=>i.tokens_total),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(vs,{label:"Input Tokens",values:e.map(i=>i.tokens_input),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(vs,{label:"Output Tokens",values:e.map(i=>i.tokens_output),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(vs,{label:"Duration",values:e.map(i=>i.duration_seconds),baselineIndex:n,formatter:i=>`${i.toFixed(1)}s`,isLowerBetter:!0}),a.jsx(vs,{label:"Score",values:e.map(i=>i.score*100),baselineIndex:n,formatter:i=>`${i.toFixed(1)}%`,isLowerBetter:!1})]})]})}),a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[a.jsx("h4",{className:"text-sm font-medium mb-2 text-[var(--text-secondary)]",children:"Key Insights"}),a.jsxs("ul",{className:"text-sm space-y-1 text-[var(--text-secondary)]",children:[e.map(i=>{const l=op(i.tokens_total,e[n].tokens_total);return i.tokens_total===r&&l<-5?a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-green-400",children:"✓"}),a.jsxs("span",{children:[a.jsx("strong",{children:i.candidate_name})," uses ",Math.abs(l).toFixed(0),"% fewer tokens"]})]},`token-${i.id}`):null}),e.map(i=>i.score===s&&i.passed?a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-green-400",children:"✓"}),a.jsxs("span",{children:[a.jsx("strong",{children:i.candidate_name})," achieved highest score (",(i.score*100).toFixed(0),"%)"]})]},`score-${i.id}`):null),e.filter(i=>i.is_pareto).length>0&&a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-purple-400",children:"★"}),a.jsxs("span",{children:["Optimal candidates (best tradeoff):"," ",e.filter(i=>i.is_pareto).map(i=>i.candidate_name).join(", ")]})]})]})]}),a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[a.jsx("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:"Token Efficiency"}),a.jsx("div",{className:"space-y-2",children:e.map(i=>{const l=i.tokens_total/e[n].tokens_total*100,o=i.tokens_total<=r;return a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-24 text-sm truncate",title:i.candidate_name,children:i.candidate_name}),a.jsx("div",{className:"flex-1 h-6 bg-[var(--bg-primary)] rounded overflow-hidden",children:a.jsx("div",{className:`h-full transition-all duration-300 ${o?"bg-green-500":"bg-blue-500"}`,style:{width:`${Math.min(l,100)}%`}})}),a.jsx("div",{className:"w-20 text-right font-mono text-sm",children:i.tokens_total.toLocaleString()})]},i.id)})})]})]})}function y1({summaries:e,height:t=350}){const n=g.useRef(null),[r,s]=g.useState(600),[i,l]=g.useState("tokens"),[o,c]=g.useState(null),[u,d]=g.useState({x:0,y:0});g.useEffect(()=>{const S=()=>{n.current&&s(n.current.clientWidth)};return S(),window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]);const f={top:30,right:30,bottom:50,left:60},m=r-f.left-f.right,v=t-f.top-f.bottom,k=S=>i==="tokens"?S.avg_tokens:S.avg_duration,{xScale:w,yScale:b,xTicks:p,yTicks:h,paretoLine:x}=g.useMemo(()=>{if(e.length===0||m<=0)return{xScale:()=>0,yScale:()=>0,xTicks:[],yTicks:[],paretoLine:[]};const S=e.map(k),N=e.map(P=>P.avg_score),_=Math.min(...S)*.9,z=Math.max(...S)*1.1,L=Math.min(...N,.5),B=Math.min(Math.max(...N)*1.05,1),J=P=>(P-_)/(z-_)*m,re=P=>v-(P-L)/(B-L)*v,ce=Array.from({length:5},(P,A)=>_+A/4*(z-_)),D=Array.from({length:5},(P,A)=>L+A/4*(B-L)),Z=e.filter(P=>P.is_pareto).sort((P,A)=>k(P)-k(A)).map(P=>({x:J(k(P)),y:re(P.avg_score)}));return{xScale:J,yScale:re,xTicks:ce,yTicks:D,paretoLine:Z}},[e,m,v,i]);if(e.length===0)return a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No data to display"});const j=S=>i==="tokens"?S>=1e6?`${(S/1e6).toFixed(1)}M`:S>=1e3?`${(S/1e3).toFixed(0)}K`:S.toFixed(0):`${S.toFixed(1)}s`,C=(S,N)=>{var z;const _=(z=n.current)==null?void 0:z.getBoundingClientRect();_&&d({x:N.clientX-_.left,y:N.clientY-_.top}),c(S)};return a.jsxs("div",{ref:n,className:"w-full relative",children:[a.jsx("div",{className:"flex justify-end mb-2",children:a.jsxs("div",{className:"inline-flex rounded border border-[var(--border)] text-xs",children:[a.jsx("button",{className:`px-3 py-1 ${i==="tokens"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("tokens"),children:"Tokens"}),a.jsx("button",{className:`px-3 py-1 ${i==="duration"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("duration"),children:"Latency"})]})}),a.jsx("svg",{width:r,height:t,className:"font-mono text-xs",children:a.jsxs("g",{transform:`translate(${f.left}, ${f.top})`,children:[p.map((S,N)=>a.jsx("line",{x1:w(S),y1:0,x2:w(S),y2:v,stroke:"var(--border)",strokeDasharray:"2,2"},`x-grid-${N}`)),h.map((S,N)=>a.jsx("line",{x1:0,y1:b(S),x2:m,y2:b(S),stroke:"var(--border)",strokeDasharray:"2,2"},`y-grid-${N}`)),x.length>1&&a.jsx("polyline",{points:x.map(S=>`${S.x},${S.y}`).join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.slice().sort((S,N)=>(S.is_pareto?1:0)-(N.is_pareto?1:0)).map(S=>{const N=w(k(S)),_=b(S.avg_score),z=S.is_pareto,L=(o==null?void 0:o.candidate_name)===S.candidate_name;return a.jsxs("g",{onMouseEnter:B=>C(S,B),onMouseLeave:()=>c(null),children:[a.jsx("circle",{cx:N,cy:_,r:L?10:z?8:6,fill:z?"var(--accent)":"transparent",stroke:L?"var(--text-primary)":z?"var(--accent)":"var(--text-secondary)",strokeWidth:L?3:2,className:"cursor-pointer transition-all"}),z&&!L&&a.jsx("text",{x:N,y:_-12,textAnchor:"middle",fill:"var(--text-primary)",fontSize:10,className:"pointer-events-none",children:S.candidate_name.replace(/^baseline_/,"").slice(0,15)})]},S.candidate_name)}),a.jsx("line",{x1:0,y1:v,x2:m,y2:v,stroke:"var(--text-secondary)"}),p.map((S,N)=>a.jsxs("g",{transform:`translate(${w(S)}, ${v})`,children:[a.jsx("line",{y2:5,stroke:"var(--text-secondary)"}),a.jsx("text",{y:20,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:10,children:j(S)})]},`x-tick-${N}`)),a.jsx("text",{x:m/2,y:v+40,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:i==="tokens"?"Tokens (cost)":"Duration (latency)"}),a.jsx("line",{x1:0,y1:0,x2:0,y2:v,stroke:"var(--text-secondary)"}),h.map((S,N)=>a.jsxs("g",{transform:`translate(0, ${b(S)})`,children:[a.jsx("line",{x2:-5,stroke:"var(--text-secondary)"}),a.jsxs("text",{x:-10,textAnchor:"end",dominantBaseline:"middle",fill:"var(--text-secondary)",fontSize:10,children:[(S*100).toFixed(0),"%"]})]},`y-tick-${N}`)),a.jsx("text",{transform:`translate(-45, ${v/2}) rotate(-90)`,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:"Score (quality)"})]})}),o&&a.jsxs("div",{className:"absolute z-10 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg shadow-lg p-3 text-sm pointer-events-none",style:{left:Math.min(u.x+15,r-200),top:u.y-10,maxWidth:220},children:[a.jsx("div",{className:"font-medium text-[var(--text-primary)] truncate mb-2",children:o.candidate_name.replace(/^baseline_/,"")}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Score:"}),a.jsxs("span",{className:"text-right font-medium",children:[(o.avg_score*100).toFixed(1),"%"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tokens:"}),a.jsxs("span",{className:"text-right",children:[(o.avg_tokens/1e3).toFixed(1),"K"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Duration:"}),a.jsxs("span",{className:"text-right",children:[o.avg_duration.toFixed(1),"s"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Pass rate:"}),a.jsxs("span",{className:"text-right",children:[o.passed_runs,"/",o.total_runs]})]}),o.is_pareto&&a.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)] text-xs text-[var(--accent)]",children:"Optimal (best tradeoff)"})]})]})}function g1(e=2e3){const[t,n]=g.useState(!1),[r,s]=g.useState(null),i=g.useCallback(async o=>{try{return await navigator.clipboard.writeText(o),n(!0),s(null),setTimeout(()=>n(!1),e),!0}catch{return s("Failed to copy to clipboard"),n(!1),!1}},[e]),l=g.useCallback(()=>{n(!1),s(null)},[]);return{copy:i,copied:t,error:r,reset:l}}function j1({isOpen:e,onClose:t,title:n,itemId:r,itemType:s,isPublic:i,createdByName:l,onTogglePublic:o}){const[c,u]=g.useState(!1),{copy:d,copied:f}=g1(),m=`${window.location.origin}/${s}s/${r}`,v=async()=>{u(!0);try{await o(!i)}finally{u(!1)}},k=()=>{d(m)};return a.jsx(ls,{isOpen:e,onClose:t,title:n,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between p-3 bg-[var(--bg-tertiary)] rounded",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[i?a.jsx(Hc,{className:"w-5 h-5 text-[var(--accent)]"}):a.jsx(Bm,{className:"w-5 h-5 text-[var(--text-secondary)]"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium",children:i?"Public":"Private"}),a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:i?"Anyone with the link can view":"Only you can access"})]})]}),a.jsx("button",{onClick:v,disabled:c,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${i?"bg-[var(--accent)]":"bg-[var(--border)]"} ${c?"opacity-50 cursor-not-allowed":""}`,children:a.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${i?"translate-x-6":"translate-x-1"}`})})]}),i&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Share link"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",readOnly:!0,value:m,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono"}),a.jsx(K,{variant:"secondary",onClick:k,children:f?a.jsxs(a.Fragment,{children:[a.jsx(Lg,{className:"w-4 h-4 mr-1"}),"Copied"]}):a.jsxs(a.Fragment,{children:[a.jsx(Ig,{className:"w-4 h-4 mr-1"}),"Copy"]})})]})]}),l&&a.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",a.jsx("span",{className:"text-[var(--text-primary)]",children:l})]}),a.jsx("div",{className:"text-xs text-[var(--text-secondary)] pt-2 border-t border-[var(--border)]",children:i?a.jsxs(a.Fragment,{children:[a.jsxs("p",{children:["Public ",s,"s can be viewed by anyone with the link."]}),a.jsxs("p",{className:"mt-1",children:["Only you can edit or delete this ",s,"."]})]}):a.jsxs("p",{children:["Make this ",s," public to share it with others."]})})]})})}function w1({job:e,onUpdate:t}){const[n,r]=g.useState(!1),s=async i=>{await Rt.update(e.id,{is_public:i}),t()};return a.jsxs(a.Fragment,{children:[a.jsxs(K,{variant:"secondary",size:"sm",onClick:()=>r(!0),title:e.is_public?"Sharing settings":"Share this job",children:[a.jsx(Wg,{className:"w-4 h-4 mr-1"}),e.is_public?"Shared":"Share"]}),a.jsx(j1,{isOpen:n,onClose:()=>r(!1),title:"Share Job",itemId:e.id,itemType:"job",isPublic:e.is_public,createdByName:e.created_by_name,onTogglePublic:s})]})}function k1(){const{jobId:e}=ha(),t=Dn(),n=Jt(),[r,s]=g.useState(null),[i,l]=g.useState(!1),[o,c]=g.useState(null),[u,d]=g.useState([]),[f,m]=g.useState(null),[v,k]=g.useState(null),[w,b]=g.useState("results"),[p,h]=g.useState("score"),[x,j]=g.useState("desc"),[C,S]=g.useState(!1),{data:N,isLoading:_}=oe({queryKey:["jobs",e],queryFn:()=>Rt.get(e),enabled:!!e,refetchInterval:i?2e3:!1}),{data:z=[]}=oe({queryKey:["runs",e],queryFn:()=>Uo.list({job_id:e}),enabled:!!e,refetchInterval:i?2e3:!1}),{data:L}=oe({queryKey:["job-summary",e],queryFn:()=>Uo.getJobSummary(e),enabled:!!e&&(N==null?void 0:N.status)==="completed"}),B=Xe({mutationFn:async()=>{l(!0),d([]),m(null),k(null);for await(const O of Rt.start(e))s(O),O.current_candidate&&O.current_task&&m(Q=>(Q&&(Q.candidate!==O.current_candidate||Q.task!==O.current_task)&&d(Ce=>[...Ce,{candidate_name:Q.candidate,task_name:Q.task,completed_at:Date.now()}]),{candidate:O.current_candidate,task:O.current_task})),O.event==="error"&&(k(O.message),l(!1),n.invalidateQueries({queryKey:["jobs",e]})),O.event==="complete"&&(m(Q=>(Q&&d(Ce=>[...Ce,{candidate_name:Q.candidate,task_name:Q.task,completed_at:Date.now()}]),null)),l(!1),n.invalidateQueries({queryKey:["jobs",e]}),n.invalidateQueries({queryKey:["runs",e]}),n.invalidateQueries({queryKey:["job-summary",e]}))}}),J=Xe({mutationFn:()=>Rt.cancel(e),onSuccess:()=>{l(!1),n.invalidateQueries({queryKey:["jobs",e]})}});g.useEffect(()=>{(N==null?void 0:N.status)==="running"&&l(!0)},[N==null?void 0:N.status]);const re=g.useMemo(()=>{const O=new Map;for(const Q of z)O.has(Q.task_name)||O.set(Q.task_name,[]),O.get(Q.task_name).push(Q);return O},[z]),ce=g.useMemo(()=>Array.from(re.keys()),[re]);g.useEffect(()=>{!o&&ce.length>0&&c(ce[0])},[ce,o]);const D=g.useMemo(()=>{if(!(L!=null&&L.candidate_summaries))return[];let O=[...L.candidate_summaries];return C&&(O=O.filter(Q=>Q.is_pareto)),O.sort((Q,Ce)=>{let ke,_e;switch(p){case"score":ke=Q.avg_score,_e=Ce.avg_score;break;case"tokens":ke=Q.avg_tokens,_e=Ce.avg_tokens;break;case"duration":ke=Q.avg_duration,_e=Ce.avg_duration;break;case"pass_rate":ke=Q.passed_runs/Q.total_runs,_e=Ce.passed_runs/Ce.total_runs;break}return x==="desc"?_e-ke:ke-_e}),O},[L,p,x,C]),q=O=>{p===O?j(x==="desc"?"asc":"desc"):(h(O),j(O==="tokens"||O==="duration"?"asc":"desc"))},Z=({label:O,sortKeyVal:Q})=>a.jsx("th",{className:"pb-2 cursor-pointer hover:text-[var(--text-primary)] select-none",onClick:()=>q(Q),children:a.jsxs("div",{className:"flex items-center gap-1",children:[O,p===Q&&a.jsx(Tg,{size:12,className:x==="asc"?"rotate-180":""})]})});if(_)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!N)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Job not found"});const P=Zc(),A=!N.user_id||N.user_id==="anonymous"||P&&N.created_by_name===P,T=N.is_public&&!A,V=()=>{n.invalidateQueries({queryKey:["jobs",e]})},te=O=>{const Q={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};return a.jsx(G,{variant:Q[O]||"default",children:O})};return a.jsxs("div",{children:[a.jsx(pa,{items:[{label:"Experiments",path:"/jobs"},{label:N.name||`Job ${N.id.slice(0,8)}`}]}),a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:N.name||`Job ${N.id.slice(0,8)}`}),te(N.status),N.is_public&&a.jsxs(G,{variant:"info",children:[a.jsx(Hc,{className:"w-3 h-3 mr-1 inline"}),"Public"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[a.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-2 py-0.5 rounded font-mono text-[var(--text-secondary)]",children:[N.id.slice(0,8),"..."]}),a.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[N.candidate_ids.length," candidates × ",N.task_ids.length," tasks = ",N.total_experiments," experiments"]}),N.is_public&&N.created_by_name&&a.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",a.jsx("span",{className:"text-[var(--text-primary)]",children:N.created_by_name})]})]})]}),a.jsxs("div",{className:"flex gap-2",children:[A&&a.jsx(w1,{job:N,onUpdate:V}),T&&a.jsx(G,{variant:"default",children:"View Only"}),A&&N.status==="pending"&&a.jsx(K,{variant:"primary",onClick:()=>B.mutate(),disabled:B.isPending,children:B.isPending?"Starting...":"Start"}),A&&N.status==="running"&&a.jsx(K,{variant:"danger",onClick:()=>J.mutate(),disabled:J.isPending,children:"Cancel"})]})]}),(v||N.error)&&a.jsx(ge,{className:"mb-6 border-red-500/50 bg-red-500/10",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"w-5 h-5 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-0.5",children:"!"}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-red-400",children:"Error"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:v||N.error})]})]})}),(i||r)&&a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"font-medium",children:"Progress"}),a.jsxs("span",{className:"text-[var(--accent)]",children:[(r==null?void 0:r.completed)||N.completed_experiments,"/",(r==null?void 0:r.total)||N.total_experiments]})]}),a.jsx("div",{className:"w-full bg-[var(--bg-primary)] h-2 mb-2",children:a.jsx("div",{className:"h-full bg-[var(--accent)] transition-all",style:{width:`${((r==null?void 0:r.completed)||N.completed_experiments)/((r==null?void 0:r.total)||N.total_experiments)*100}%`}})}),(r==null?void 0:r.message)&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r.message}),i&&a.jsxs("div",{className:"mt-4 border-t border-[var(--border)] pt-4",children:[(r==null?void 0:r.current_candidate)&&(r==null?void 0:r.current_task)&&a.jsxs("div",{className:"mb-3",children:[a.jsx("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:"Currently Running"}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 px-3 py-2 bg-blue-500/10 border border-blue-500/30 rounded",children:[a.jsx("div",{className:"w-2 h-2 bg-blue-400 rounded-full animate-pulse"}),a.jsx("span",{className:"font-medium",children:r.current_candidate}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{children:r.current_task})]})]}),u.length>0&&a.jsxs("div",{children:[a.jsxs("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:["Completed (",u.length,")"]}),a.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto space-y-1",children:u.map((O,Q)=>a.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-500/10 border border-green-500/30 rounded text-sm",children:[a.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}),a.jsx("span",{className:"font-medium",children:O.candidate_name}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{children:O.task_name})]},`${O.candidate_name}-${O.task_name}-${Q}`))})]})]})]}),(N.status==="completed"||z.length>0)&&a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-[var(--border)]",children:[a.jsxs("button",{onClick:()=>b("results"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${w==="results"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Og,{size:16}),"Results"]}),a.jsxs("button",{onClick:()=>b("compare"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${w==="compare"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Ag,{size:16}),"Compare"]}),a.jsxs("button",{onClick:()=>b("runs"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${w==="runs"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Qg,{size:16}),"Runs (",z.length,")"]})]}),w==="results"&&a.jsxs(a.Fragment,{children:[L&&L.candidate_summaries.length>1&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("div",{className:"flex items-start justify-between mb-4",children:a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium",children:"Quality vs. Cost Tradeoff"}),a.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:["Candidates on the frontier (connected line) are ",a.jsx("strong",{children:"optimal"})," - no other candidate beats them on both score AND cost."]})]})}),a.jsxs("div",{className:"mb-4 p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs text-[var(--text-secondary)]",children:[a.jsx("strong",{className:"text-[var(--text-primary)]",children:"How optimal tradeoffs are calculated:"})," A candidate is optimal if there's no other candidate that has both a higher score AND lower cost. For example, if Candidate A has 95% score at 50K tokens and Candidate B has 90% score at 40K tokens, both are optimal - A is better on score, B is better on cost. But if Candidate C has 85% score at 60K tokens, it's ",a.jsx("em",{children:"not"})," optimal because B beats it on both metrics."]}),a.jsx(y1,{summaries:L.candidate_summaries,height:350})]}),L&&a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h3",{className:"font-medium",children:"Results Summary"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C,onChange:O=>S(O.target.checked),className:"rounded border-[var(--border)]"}),"Optimal only"]})]}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-left text-[var(--text-secondary)] border-b border-[var(--border)]",children:[a.jsx("th",{className:"pb-2",children:"Candidate"}),a.jsx(Z,{label:"Score",sortKeyVal:"score"}),a.jsx(Z,{label:"Tokens",sortKeyVal:"tokens"}),a.jsx(Z,{label:"Duration",sortKeyVal:"duration"}),a.jsx(Z,{label:"Pass Rate",sortKeyVal:"pass_rate"}),a.jsx("th",{className:"pb-2",children:"Optimal"})]})}),a.jsx("tbody",{children:D.map((O,Q)=>a.jsxs("tr",{className:`border-b border-[var(--border)] ${Q===0?"bg-[var(--accent)]/10":""}`,children:[a.jsxs("td",{className:"py-2 font-medium",children:[Q===0&&a.jsx("span",{className:"text-[var(--accent)] mr-1",children:"#1"}),O.candidate_name.replace(/^baseline_/,"")]}),a.jsxs("td",{className:"py-2",children:[(O.avg_score*100).toFixed(1),"%"]}),a.jsxs("td",{className:"py-2",children:[(O.avg_tokens/1e3).toFixed(1),"K"]}),a.jsxs("td",{className:"py-2",children:[O.avg_duration.toFixed(1),"s"]}),a.jsxs("td",{className:"py-2",children:[O.passed_runs,"/",O.total_runs]}),a.jsx("td",{className:"py-2",children:O.is_pareto&&a.jsx(G,{variant:"success",children:"Optimal"})})]},O.candidate_name))})]})}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-3",children:"Click column headers to sort. The #1 ranked candidate is highlighted based on your sort criteria."})]}),!L&&a.jsx(ge,{children:a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Results will appear here after the job completes.":"No results yet. Start the job to see results."})})]}),w==="compare"&&a.jsxs(ge,{children:[a.jsx("h3",{className:"font-medium mb-4",children:"Compare Candidates by Task"}),ce.length>0?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:ce.map(O=>a.jsx("button",{onClick:()=>c(o===O?null:O),className:`px-3 py-1 text-sm rounded border transition-colors ${o===O?"bg-[var(--accent)] text-white border-[var(--accent)]":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:O},O))}),o&&re.get(o)?a.jsx(v1,{runs:re.get(o).map(O=>({id:O.id,candidate_name:O.candidate_name,tokens_input:0,tokens_output:0,tokens_total:O.tokens_total,duration_seconds:O.duration_seconds,score:O.score,passed:O.passed,is_pareto:O.is_pareto}))}):a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"Select a task above to compare how different candidates performed on it."})]}):a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Comparison data will appear here after runs complete.":"No runs yet. Start the job to compare candidates."})]}),w==="runs"&&a.jsxs(ge,{children:[a.jsx("h3",{className:"font-medium mb-4",children:"All Experiment Runs"}),z.length===0?a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Runs will appear here as they complete. See progress above for live status.":"No runs yet. Start the job to see results."}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:z.map(O=>a.jsxs("div",{className:"p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] cursor-pointer hover:border-[var(--accent-dim)] transition-colors",onClick:()=>t(`/runs/${O.id}`),children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:`text-lg font-bold ${O.passed?"text-green-400":"text-red-400"}`,children:[(O.score*100).toFixed(0),"%"]}),O.is_pareto&&a.jsx(G,{variant:"success",children:"Optimal"})]}),a.jsx("div",{className:"text-sm font-medium truncate",title:O.candidate_name,children:O.candidate_name.replace(/^baseline_/,"")}),a.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:O.task_name}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:[(O.tokens_total/1e3).toFixed(1),"K tokens"]}),a.jsxs("span",{children:[O.duration_seconds.toFixed(1),"s"]})]})]},O.id))})]})]})}const gn={input:"bg-blue-500",output:"bg-emerald-500",inputText:"text-blue-400",outputText:"text-emerald-400"};function Dd(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ad({input:e,output:t,maxValue:n,height:r=24,showLabels:s=!0}){const i=e+t;if(i===0)return a.jsx("div",{className:"flex items-center gap-2 w-full",children:a.jsx("div",{className:"rounded bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`}})});const l=n>0?i/n*100:100;return a.jsxs("div",{className:"flex items-center gap-3 w-full",children:[a.jsx("div",{className:"relative rounded overflow-hidden bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`},children:a.jsxs("div",{className:"h-full flex transition-all duration-300",style:{width:`${l}%`},children:[a.jsx("div",{className:`h-full ${gn.input} transition-all`,style:{width:`${e/i*100}%`},title:`Input: ${e.toLocaleString()} tokens`}),a.jsx("div",{className:`h-full ${gn.output} transition-all`,style:{width:`${t/i*100}%`},title:`Output: ${t.toLocaleString()} tokens`})]})}),s&&a.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono text-[var(--text-secondary)] min-w-[90px] justify-end",children:[a.jsxs("span",{className:gn.inputText,children:["↑",Dd(e)]}),a.jsx("span",{children:"/"}),a.jsxs("span",{className:gn.outputText,children:["↓",Dd(t)]})]})]})}function Cl({label:e,value:t,color:n="default"}){const r={default:"text-[var(--text-primary)]",input:gn.inputText,output:gn.outputText}[n];return a.jsxs("div",{className:"flex-1 p-3 bg-[var(--bg-primary)] border border-[var(--border)] rounded",children:[a.jsx("div",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e}),a.jsx("div",{className:`font-mono text-lg font-bold ${r}`,children:t})]})}function cp({tokensInput:e,tokensOutput:t,tokensTotal:n,turns:r}){const s=n>0?Math.round(e/n*100):0,i=n>0?Math.round(t/n*100):0,l=g.useMemo(()=>{if(!r||r.length===0)return null;let c=0,u=0;return r.map(d=>(c+=d.input,u+=d.output,{input:c,output:u,total:c+u}))},[r]),o=l?Math.max(...l.map(c=>c.total)):n;return a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-4",children:"Token Usage"}),a.jsx("div",{className:"mb-4",children:a.jsx(Ad,{input:e,output:t,maxValue:n,height:32})}),a.jsxs("div",{className:"flex items-center gap-6 text-xs mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-3 h-3 rounded ${gn.input}`}),a.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Input (",s,"%)"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-3 h-3 rounded ${gn.output}`}),a.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Output (",i,"%)"]})]})]}),a.jsxs("div",{className:"flex gap-3 mb-4",children:[a.jsx(Cl,{label:"Input Tokens",value:e.toLocaleString(),color:"input"}),a.jsx(Cl,{label:"Output Tokens",value:t.toLocaleString(),color:"output"}),a.jsx(Cl,{label:"Total Tokens",value:n.toLocaleString()})]}),l&&l.length>1&&a.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[a.jsxs("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:["Token Accumulation (",r.length," turns)"]}),a.jsx("div",{className:"space-y-2",children:r.map((c,u)=>a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--bg-primary)] border border-[var(--border)] flex items-center justify-center text-xs font-medium",children:u+1}),a.jsx("div",{className:"flex-1",children:a.jsx(Ad,{input:l[u].input,output:l[u].output,maxValue:o,height:16})})]},u))})]}),a.jsx("div",{className:"mt-4 text-xs text-[var(--text-secondary)] border-t border-[var(--border)] pt-3",children:"Token usage affects API cost. Input tokens are typically cheaper than output tokens."})]})}function b1(){const{runId:e}=ha(),{data:t,isLoading:n}=oe({queryKey:["runs",e],queryFn:()=>Uo.get(e),enabled:!!e});return n?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsx(pa,{items:[{label:"Experiments",path:"/jobs"},{label:"Job",path:`/jobs/${t.job_id}`},{label:t.candidate_name}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:t.candidate_name}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{className:"text-lg",children:t.task_name}),t.is_pareto&&a.jsx(G,{variant:"success",children:"Optimal"})]})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[a.jsx(za,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),a.jsx(za,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),a.jsx(za,{label:"Duration",value:`${t.duration_seconds.toFixed(1)}s`}),a.jsx(za,{label:"Status",value:t.passed?"Passed":"Failed",status:t.passed?"success":"error"})]}),a.jsx(cp,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),t.reasoning&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:t.reasoning}),t.criteria_results.length>0&&a.jsx("div",{className:"space-y-2",children:t.criteria_results.map(r=>a.jsx("div",{className:"flex items-start justify-between p-3 bg-[var(--bg-primary)] border border-[var(--border)]",children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-medium",children:r.name}),a.jsxs(G,{variant:r.passed?"success":"error",children:[(r.score*100).toFixed(0),"%"]})]}),r.reasoning&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r.reasoning})]})},r.name))})]}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created.length>0&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),a.jsx("div",{className:"space-y-1",children:t.files_created.map(r=>a.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:r},r))})]}),Object.keys(t.trace).length>0&&a.jsx(ap,{trace:t.trace})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Run not found"})}function za({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return a.jsxs(ge,{children:[a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),a.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function N1(){const{testId:e}=ha(),{data:t,isLoading:n}=oe({queryKey:["tests",e],queryFn:()=>Ls.get(e),enabled:!!e}),{data:r}=oe({queryKey:["configs",t==null?void 0:t.agent_id],queryFn:()=>Tn.get(t.agent_id),enabled:!!(t!=null&&t.agent_id)});if(n)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!t)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Test not found"});const s={completed:"success",failed:"error",running:"info",pending:"default",cancelled:"warning"};return a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsx(pa,{items:[{label:"Agents",path:"/agents"},...r?[{label:r.name,path:`/agents/${r.id}`}]:[],{label:`Test ${t.id.slice(0,8)}`}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:"Test Run"}),r&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"•"}),a.jsx("span",{className:"text-lg",children:r.name})]}),a.jsx(G,{variant:s[t.status]||"default",children:t.status})]}),a.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:["ID: ",t.id.slice(0,8),"..."]})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[a.jsx(Fa,{label:"Duration",value:`${t.duration_seconds.toFixed(2)}s`}),a.jsx(Fa,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),t.score!==null&&a.jsx(Fa,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),a.jsx(Fa,{label:"Status",value:t.status.charAt(0).toUpperCase()+t.status.slice(1),status:t.status==="completed"?"success":t.status==="failed"?"error":void 0})]}),a.jsx(cp,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Prompt"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)] font-mono",children:t.prompt})]}),t.error&&a.jsxs(ge,{className:"mb-6 border-red-500/30 bg-red-500/5",children:[a.jsx("h3",{className:"font-medium mb-3 text-red-400",children:"Error"}),a.jsx("pre",{className:"text-sm text-red-300 overflow-x-auto whitespace-pre-wrap",children:t.error})]}),t.reasoning&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.reasoning})]}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created&&t.files_created.length>0&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),a.jsx("div",{className:"space-y-1",children:t.files_created.map(i=>a.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:i},i))})]}),t.trace&&Object.keys(t.trace).length>0&&a.jsx(ap,{trace:t.trace}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Timestamps"}),a.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Created:"}),a.jsx("div",{className:"font-mono",children:new Date(t.created_at).toLocaleString()})]}),t.started_at&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Started:"}),a.jsx("div",{className:"font-mono",children:new Date(t.started_at).toLocaleString()})]}),t.completed_at&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Completed:"}),a.jsx("div",{className:"font-mono",children:new Date(t.completed_at).toLocaleString()})]})]})]})]})}function Fa({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return a.jsxs(ge,{children:[a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),a.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function S1(){const{deploymentId:e}=ha(),{data:t,isLoading:n}=oe({queryKey:["deployments",e],queryFn:()=>E0.get(e),enabled:!!e}),r=t==null?void 0:t.versions.find(i=>i.id===t.current_version_id),{data:s}=oe({queryKey:["configs",r==null?void 0:r.config_id],queryFn:()=>Tn.get(r.config_id),enabled:!!(r!=null&&r.config_id)});return n?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsxs("div",{className:"mb-4 flex-shrink-0",children:[a.jsx(pa,{items:[{label:"Agents",path:"/agents"},{label:t.name}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Hg,{size:20,className:"text-[var(--accent)]"}),a.jsx("h2",{className:"text-xl font-bold",children:t.name}),r&&a.jsxs(G,{variant:"info",children:["v",r.version]})]}),t.description&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:t.description})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsx("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-5",children:[a.jsxs("div",{className:"flex items-center gap-4 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:["Created ",new Date(t.created_at).toLocaleDateString()]}),a.jsxs("span",{children:["Updated ",new Date(t.updated_at).toLocaleDateString()]}),a.jsxs("span",{children:[t.versions.length," version",t.versions.length!==1?"s":""]})]}),s&&a.jsxs(Rn,{to:`/agents/${s.id}`,className:"flex items-center gap-2 p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-sm",children:[a.jsx(Um,{size:14,className:"text-[var(--accent)]"}),a.jsxs("span",{children:["Agent: ",a.jsx("span",{className:"font-medium",children:s.name})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider mb-3",children:"Version History"}),t.versions.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"No versions yet."}):a.jsx("div",{className:"space-y-2",children:t.versions.map(i=>a.jsx(C1,{version:i,isActive:i.id===t.current_version_id},i.id))})]})]})}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[a.jsx(Vm,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),a.jsx("div",{className:"flex-1 min-h-0",children:s?a.jsx(ip,{agent:s}):a.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-secondary)] text-sm",children:r?"Loading agent configuration...":"No active version to test."})})]})]})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Deployment not found"})}function C1({version:e,isActive:t}){const n=e.config_snapshot;return a.jsxs("div",{className:`p-3 rounded-md border transition-colors ${t?"border-[var(--accent)] bg-[var(--accent-dim)]":"border-[var(--border)] bg-[var(--bg-secondary)]"}`,children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Yg,{size:12,className:"text-[var(--text-secondary)]"}),a.jsxs("span",{className:"text-sm font-medium",children:["v",e.version]}),t&&a.jsx(G,{variant:"success",children:"Active"}),a.jsx(G,{variant:e.source==="optimize"?"info":"default",children:e.source})]}),a.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)]",children:[a.jsx(Am,{size:11}),a.jsx("span",{children:new Date(e.created_at).toLocaleString()})]})]}),e.description&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e.description}),Object.keys(n).length>0&&a.jsxs("div",{className:"mt-1",children:[a.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)] mb-1",children:[a.jsx(Dg,{size:11}),a.jsx("span",{children:"Config"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-xs",children:["framework"in n&&n.framework?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Framework"}),a.jsx("span",{className:"font-mono",children:String(n.framework)})]}):null,"model"in n&&n.model?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Model"}),a.jsx("span",{className:"font-mono",children:String(n.model)})]}):null,"tools"in n&&n.tools?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tools"}),a.jsx("span",{className:"font-mono truncate",children:Array.isArray(n.tools)?n.tools.join(", "):String(n.tools)})]}):null]})]})]})}function _1(){const{authConfig:e,isLoading:t,error:n,login:r,loginWithGitHub:s,clearError:i}=eu(),[l,o]=g.useState(""),[c,u]=g.useState("");g.useEffect(()=>{n&&i()},[l,c]);const d=async m=>{m.preventDefault(),!(!l||!c)&&await r(l,c)},f=()=>{s()};return a.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:a.jsxs("div",{className:"w-full max-w-md",children:[a.jsxs("div",{className:"text-center mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:"Flow"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:"Sign in to access the optimization dashboard"})]}),a.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] p-6 space-y-6",children:[n&&a.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[var(--error)]/10 border border-[var(--error)]/20 text-[var(--error)]",children:[a.jsx(Fm,{size:18,className:"mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-sm",children:n})]}),(e==null?void 0:e.mode)==="basic"&&a.jsxs("form",{onSubmit:d,className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Username"}),a.jsxs("div",{className:"relative",children:[a.jsx(Hm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),a.jsx("input",{type:"text",value:l,onChange:m=>o(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter username",autoComplete:"username",autoFocus:!0})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Password"}),a.jsxs("div",{className:"relative",children:[a.jsx(Bm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),a.jsx("input",{type:"password",value:c,onChange:m=>u(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter password",autoComplete:"current-password"})]})]}),a.jsx(K,{type:"submit",variant:"primary",className:"w-full justify-center",loading:t,disabled:!l||!c,children:"Sign In"})]}),(e==null?void 0:e.mode)==="github"&&a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center",children:"Sign in with your GitHub account to continue"}),a.jsx(K,{onClick:f,variant:"secondary",className:"w-full justify-center",icon:$g,children:"Continue with GitHub"})]})]})]})})}function E1({children:e}){const{authConfig:t,isLoadingConfig:n,isAuthenticated:r,loadAuthConfig:s,handleOAuthCallback:i}=eu();return g.useEffect(()=>{s()},[s]),g.useEffect(()=>{n||i()},[n,i]),n?a.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center",children:a.jsxs("div",{className:"text-center",children:[a.jsx(ma,{className:"w-8 h-8 animate-spin text-[var(--accent)] mx-auto mb-4"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:"Loading..."})]})}):t!=null&&t.enabled&&!r?a.jsx(_1,{}):a.jsx(a.Fragment,{children:e})}function P1(){return a.jsx(jg,{children:a.jsx(E1,{children:a.jsx(fg,{children:a.jsxs(pt,{path:"/",element:a.jsx($0,{}),children:[a.jsx(pt,{index:!0,element:a.jsx(B0,{})}),a.jsx(pt,{path:"agents",element:a.jsx(Z0,{})}),a.jsx(pt,{path:"agents/:agentId",element:a.jsx(i1,{})}),a.jsx(pt,{path:"tasks",element:a.jsx(u1,{})}),a.jsx(pt,{path:"jobs",element:a.jsx(m1,{})}),a.jsx(pt,{path:"jobs/:jobId",element:a.jsx(k1,{})}),a.jsx(pt,{path:"runs/:runId",element:a.jsx(b1,{})}),a.jsx(pt,{path:"tests/:testId",element:a.jsx(N1,{})}),a.jsx(pt,{path:"deployments/:deploymentId",element:a.jsx(S1,{})})]})})})})}const $d=localStorage.getItem("flow-theme");if($d)try{const{state:e}=JSON.parse($d);e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}catch{}const T1=new ly({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}});_l.createRoot(document.getElementById("root")).render(a.jsx(Go.StrictMode,{children:a.jsx(oy,{client:T1,children:a.jsx(P1,{})})})); diff --git a/src/flow/ui/ui/assets/index-CJXdBVzg.js b/src/flow/ui/ui/assets/index-CJXdBVzg.js new file mode 100644 index 0000000000000000000000000000000000000000..2d0a1ba80cac0adc7c3ac837e61d0bfd0c9f107f --- /dev/null +++ b/src/flow/ui/ui/assets/index-CJXdBVzg.js @@ -0,0 +1,317 @@ +var Yc=e=>{throw TypeError(e)};var Wi=(e,t,n)=>t.has(e)||Yc("Cannot "+n);var y=(e,t,n)=>(Wi(e,t,"read from private field"),n?n.call(e):t.get(e)),$=(e,t,n)=>t.has(e)?Yc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),z=(e,t,n,r)=>(Wi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),W=(e,t,n)=>(Wi(e,t,"access private method"),n);var pa=(e,t,n,r)=>({set _(s){z(e,t,s,n)},get _(){return y(e,t,r)}});function tp(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();function Wd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var qd={exports:{}},Ni={},Gd={exports:{}},Y={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var ia=Symbol.for("react.element"),np=Symbol.for("react.portal"),rp=Symbol.for("react.fragment"),sp=Symbol.for("react.strict_mode"),ap=Symbol.for("react.profiler"),ip=Symbol.for("react.provider"),lp=Symbol.for("react.context"),op=Symbol.for("react.forward_ref"),cp=Symbol.for("react.suspense"),up=Symbol.for("react.memo"),dp=Symbol.for("react.lazy"),Xc=Symbol.iterator;function fp(e){return e===null||typeof e!="object"?null:(e=Xc&&e[Xc]||e["@@iterator"],typeof e=="function"?e:null)}var Jd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Yd=Object.assign,Xd={};function Xr(e,t,n){this.props=e,this.context=t,this.refs=Xd,this.updater=n||Jd}Xr.prototype.isReactComponent={};Xr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Xr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Zd(){}Zd.prototype=Xr.prototype;function $o(e,t,n){this.props=e,this.context=t,this.refs=Xd,this.updater=n||Jd}var Uo=$o.prototype=new Zd;Uo.constructor=$o;Yd(Uo,Xr.prototype);Uo.isPureReactComponent=!0;var Zc=Array.isArray,ef=Object.prototype.hasOwnProperty,Bo={current:null},tf={key:!0,ref:!0,__self:!0,__source:!0};function nf(e,t,n){var r,s={},a=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(a=""+t.key),t)ef.call(t,r)&&!tf.hasOwnProperty(r)&&(s[r]=t[r]);var o=arguments.length-2;if(o===1)s.children=n;else if(1>>1,ee=P[V];if(0>>1;Vs(te,L))pes(be,te)?(P[V]=be,P[pe]=L,V=pe):(P[V]=te,P[T]=L,V=T);else if(pes(be,L))P[V]=be,P[pe]=L,V=pe;else break e}}return A}function s(P,A){var L=P.sortIndex-A.sortIndex;return L!==0?L:P.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var c=[],d=[],h=1,u=null,p=3,x=!1,k=!1,g=!1,S=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(P){for(var A=n(d);A!==null;){if(A.callback===null)r(d);else if(A.startTime<=P)r(d),A.sortIndex=A.expirationTime,t(c,A);else break;A=n(d)}}function j(P){if(g=!1,v(P),!k)if(n(c)!==null)k=!0,q(C);else{var A=n(d);A!==null&&X(j,A.startTime-P)}}function C(P,A){k=!1,g&&(g=!1,m(_),_=-1),x=!0;var L=p;try{for(v(A),u=n(c);u!==null&&(!(u.expirationTime>A)||P&&!B());){var V=u.callback;if(typeof V=="function"){u.callback=null,p=u.priorityLevel;var ee=V(u.expirationTime<=A);A=e.unstable_now(),typeof ee=="function"?u.callback=ee:u===n(c)&&r(c),v(A)}else r(c);u=n(c)}if(u!==null)var R=!0;else{var T=n(d);T!==null&&X(j,T.startTime-A),R=!1}return R}finally{u=null,p=L,x=!1}}var b=!1,N=null,_=-1,F=5,O=-1;function B(){return!(e.unstable_now()-OP||125V?(P.sortIndex=L,t(d,P),n(c)===null&&P===n(d)&&(g?(m(_),_=-1):g=!0,X(j,L-V))):(P.sortIndex=ee,t(c,P),k||x||(k=!0,q(C))),P},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(P){var A=p;return function(){var L=p;p=A;try{return P.apply(this,arguments)}finally{p=L}}}})(of);lf.exports=of;var Np=lf.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var bp=w,et=Np;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),bl=Object.prototype.hasOwnProperty,Cp=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,tu={},nu={};function _p(e){return bl.call(nu,e)?!0:bl.call(tu,e)?!1:Cp.test(e)?nu[e]=!0:(tu[e]=!0,!1)}function Ep(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Pp(e,t,n,r){if(t===null||typeof t>"u"||Ep(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Be(e,t,n,r,s,a,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=l}var Oe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Oe[e]=new Be(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Oe[t]=new Be(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Oe[e]=new Be(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Oe[e]=new Be(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Oe[e]=new Be(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Oe[e]=new Be(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Oe[e]=new Be(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Oe[e]=new Be(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Oe[e]=new Be(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ko=/[\-:]([a-z])/g;function Ho(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Ko,Ho);Oe[t]=new Be(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Ko,Ho);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Ko,Ho);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!1,!1)});Oe.xlinkHref=new Be("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!0,!0)});function Wo(e,t,n,r){var s=Oe.hasOwnProperty(t)?Oe[t]:null;(s!==null?s.type!==0:r||!(2o||s[l]!==a[o]){var c=` +`+s[l].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{Ji=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?vs(e):""}function Tp(e){switch(e.tag){case 5:return vs(e.type);case 16:return vs("Lazy");case 13:return vs("Suspense");case 19:return vs("SuspenseList");case 0:case 2:case 15:return e=Yi(e.type,!1),e;case 11:return e=Yi(e.type.render,!1),e;case 1:return e=Yi(e.type,!0),e;default:return""}}function Pl(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case mr:return"Fragment";case hr:return"Portal";case Cl:return"Profiler";case qo:return"StrictMode";case _l:return"Suspense";case El:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case df:return(e.displayName||"Context")+".Consumer";case uf:return(e._context.displayName||"Context")+".Provider";case Go:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Jo:return t=e.displayName||null,t!==null?t:Pl(e.type)||"Memo";case Xt:t=e._payload,e=e._init;try{return Pl(e(t))}catch{}}return null}function Op(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Pl(t);case 8:return t===qo?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function _n(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function hf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Lp(e){var t=hf(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(l){r=""+l,a.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ya(e){e._valueTracker||(e._valueTracker=Lp(e))}function mf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=hf(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ga(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Tl(e,t){var n=t.checked;return he({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function su(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=_n(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function pf(e,t){t=t.checked,t!=null&&Wo(e,"checked",t,!1)}function Ol(e,t){pf(e,t);var n=_n(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ll(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ll(e,t.type,_n(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function au(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ll(e,t,n){(t!=="number"||Ga(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var xs=Array.isArray;function br(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=ga.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ls(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ws={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Rp=["Webkit","ms","Moz","O"];Object.keys(ws).forEach(function(e){Rp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ws[t]=ws[e]})});function gf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||ws.hasOwnProperty(e)&&ws[e]?(""+t).trim():t+"px"}function jf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=gf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var Mp=he({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function zl(e,t){if(t){if(Mp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function Fl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Il=null;function Yo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Dl=null,Cr=null,_r=null;function ou(e){if(e=ca(e)){if(typeof Dl!="function")throw Error(E(280));var t=e.stateNode;t&&(t=Pi(t),Dl(e.stateNode,e.type,t))}}function wf(e){Cr?_r?_r.push(e):_r=[e]:Cr=e}function kf(){if(Cr){var e=Cr,t=_r;if(_r=Cr=null,ou(e),t)for(e=0;e>>=0,e===0?32:31-(Kp(e)/Hp|0)|0}var ja=64,wa=4194304;function ys(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Za(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,a=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~s;o!==0?r=ys(o):(a&=l,a!==0&&(r=ys(a)))}else l=n&~s,l!==0?r=ys(l):a!==0&&(r=ys(a));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,a=t&-t,s>=a||s===16&&(a&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function la(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-gt(t),e[t]=n}function Jp(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Ss),xu=" ",yu=!1;function Bf(e,t){switch(e){case"keyup":return Nv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Qf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var pr=!1;function Cv(e,t){switch(e){case"compositionend":return Qf(t);case"keypress":return t.which!==32?null:(yu=!0,xu);case"textInput":return e=t.data,e===xu&&yu?null:e;default:return null}}function _v(e,t){if(pr)return e==="compositionend"||!ac&&Bf(e,t)?(e=$f(),Aa=nc=fn=null,pr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ku(n)}}function Wf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Wf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function qf(){for(var e=window,t=Ga();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ga(e.document)}return t}function ic(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Fv(e){var t=qf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Wf(n.ownerDocument.documentElement,n)){if(r!==null&&ic(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,a=Math.min(r.start,s);r=r.end===void 0?a:Math.min(r.end,s),!e.extend&&a>r&&(s=r,r=a,a=s),s=Su(n,a);var l=Su(n,r);s&&l&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,vr=null,Vl=null,bs=null,Kl=!1;function Nu(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Kl||vr==null||vr!==Ga(r)||(r=vr,"selectionStart"in r&&ic(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),bs&&Ds(bs,r)||(bs=r,r=ni(Vl,"onSelect"),0gr||(e.current=Yl[gr],Yl[gr]=null,gr--)}function ie(e,t){gr++,Yl[gr]=e.current,e.current=t}var En={},Fe=On(En),We=On(!1),Zn=En;function Vr(e,t){var n=e.type.contextTypes;if(!n)return En;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},a;for(a in n)s[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function qe(e){return e=e.childContextTypes,e!=null}function si(){oe(We),oe(Fe)}function Ou(e,t,n){if(Fe.current!==En)throw Error(E(168));ie(Fe,t),ie(We,n)}function rh(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(E(108,Op(e)||"Unknown",s));return he({},n,r)}function ai(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||En,Zn=Fe.current,ie(Fe,e),ie(We,We.current),!0}function Lu(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=rh(e,t,Zn),r.__reactInternalMemoizedMergedChildContext=e,oe(We),oe(Fe),ie(Fe,e)):oe(We),ie(We,n)}var Rt=null,Ti=!1,dl=!1;function sh(e){Rt===null?Rt=[e]:Rt.push(e)}function qv(e){Ti=!0,sh(e)}function Ln(){if(!dl&&Rt!==null){dl=!0;var e=0,t=ae;try{var n=Rt;for(ae=1;e>=l,s-=l,Dt=1<<32-gt(t)+s|n<_?(F=N,N=null):F=N.sibling;var O=p(m,N,v[_],j);if(O===null){N===null&&(N=F);break}e&&N&&O.alternate===null&&t(m,N),f=a(O,f,_),b===null?C=O:b.sibling=O,b=O,N=F}if(_===v.length)return n(m,N),ce&&Mn(m,_),C;if(N===null){for(;__?(F=N,N=null):F=N.sibling;var B=p(m,N,O.value,j);if(B===null){N===null&&(N=F);break}e&&N&&B.alternate===null&&t(m,N),f=a(B,f,_),b===null?C=B:b.sibling=B,b=B,N=F}if(O.done)return n(m,N),ce&&Mn(m,_),C;if(N===null){for(;!O.done;_++,O=v.next())O=u(m,O.value,j),O!==null&&(f=a(O,f,_),b===null?C=O:b.sibling=O,b=O);return ce&&Mn(m,_),C}for(N=r(m,N);!O.done;_++,O=v.next())O=x(N,m,_,O.value,j),O!==null&&(e&&O.alternate!==null&&N.delete(O.key===null?_:O.key),f=a(O,f,_),b===null?C=O:b.sibling=O,b=O);return e&&N.forEach(function(G){return t(m,G)}),ce&&Mn(m,_),C}function S(m,f,v,j){if(typeof v=="object"&&v!==null&&v.type===mr&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case xa:e:{for(var C=v.key,b=f;b!==null;){if(b.key===C){if(C=v.type,C===mr){if(b.tag===7){n(m,b.sibling),f=s(b,v.props.children),f.return=m,m=f;break e}}else if(b.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Xt&&zu(C)===b.type){n(m,b.sibling),f=s(b,v.props),f.ref=fs(m,b,v),f.return=m,m=f;break e}n(m,b);break}else t(m,b);b=b.sibling}v.type===mr?(f=Jn(v.props.children,m.mode,j,v.key),f.return=m,m=f):(j=Wa(v.type,v.key,v.props,null,m.mode,j),j.ref=fs(m,f,v),j.return=m,m=j)}return l(m);case hr:e:{for(b=v.key;f!==null;){if(f.key===b)if(f.tag===4&&f.stateNode.containerInfo===v.containerInfo&&f.stateNode.implementation===v.implementation){n(m,f.sibling),f=s(f,v.children||[]),f.return=m,m=f;break e}else{n(m,f);break}else t(m,f);f=f.sibling}f=gl(v,m.mode,j),f.return=m,m=f}return l(m);case Xt:return b=v._init,S(m,f,b(v._payload),j)}if(xs(v))return k(m,f,v,j);if(ls(v))return g(m,f,v,j);Ea(m,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,f!==null&&f.tag===6?(n(m,f.sibling),f=s(f,v),f.return=m,m=f):(n(m,f),f=yl(v,m.mode,j),f.return=m,m=f),l(m)):n(m,f)}return S}var Hr=oh(!0),ch=oh(!1),oi=On(null),ci=null,kr=null,uc=null;function dc(){uc=kr=ci=null}function fc(e){var t=oi.current;oe(oi),e._currentValue=t}function eo(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Pr(e,t){ci=e,uc=kr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(He=!0),e.firstContext=null)}function ct(e){var t=e._currentValue;if(uc!==e)if(e={context:e,memoizedValue:t,next:null},kr===null){if(ci===null)throw Error(E(308));kr=e,ci.dependencies={lanes:0,firstContext:e}}else kr=kr.next=e;return t}var In=null;function hc(e){In===null?In=[e]:In.push(e)}function uh(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,hc(t)):(n.next=s.next,s.next=n),t.interleaved=n,Kt(e,r)}function Kt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Zt=!1;function mc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function dh(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function $t(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function wn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ne&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Kt(e,n)}return s=r.interleaved,s===null?(t.next=t,hc(r)):(t.next=s.next,s.next=t),r.interleaved=t,Kt(e,n)}function Ua(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Zo(e,n)}}function Fu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?s=a=l:a=a.next=l,n=n.next}while(n!==null);a===null?s=a=t:a=a.next=t}else s=a=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ui(e,t,n,r){var s=e.updateQueue;Zt=!1;var a=s.firstBaseUpdate,l=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var c=o,d=c.next;c.next=null,l===null?a=d:l.next=d,l=c;var h=e.alternate;h!==null&&(h=h.updateQueue,o=h.lastBaseUpdate,o!==l&&(o===null?h.firstBaseUpdate=d:o.next=d,h.lastBaseUpdate=c))}if(a!==null){var u=s.baseState;l=0,h=d=c=null,o=a;do{var p=o.lane,x=o.eventTime;if((r&p)===p){h!==null&&(h=h.next={eventTime:x,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var k=e,g=o;switch(p=t,x=n,g.tag){case 1:if(k=g.payload,typeof k=="function"){u=k.call(x,u,p);break e}u=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=g.payload,p=typeof k=="function"?k.call(x,u,p):k,p==null)break e;u=he({},u,p);break e;case 2:Zt=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[o]:p.push(o))}else x={eventTime:x,lane:p,tag:o.tag,payload:o.payload,callback:o.callback,next:null},h===null?(d=h=x,c=u):h=h.next=x,l|=p;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;p=o,o=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(h===null&&(c=u),s.baseState=c,s.firstBaseUpdate=d,s.lastBaseUpdate=h,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else a===null&&(s.shared.lanes=0);nr|=l,e.lanes=l,e.memoizedState=u}}function Iu(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=hl.transition;hl.transition={};try{e(!1),t()}finally{ae=n,hl.transition=r}}function Eh(){return ut().memoizedState}function Xv(e,t,n){var r=Sn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ph(e))Th(t,n);else if(n=uh(e,t,n,r),n!==null){var s=$e();jt(n,e,r,s),Oh(n,t,r)}}function Zv(e,t,n){var r=Sn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ph(e))Th(t,s);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var l=t.lastRenderedState,o=a(l,n);if(s.hasEagerState=!0,s.eagerState=o,wt(o,l)){var c=t.interleaved;c===null?(s.next=s,hc(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=uh(e,t,s,r),n!==null&&(s=$e(),jt(n,e,r,s),Oh(n,t,r))}}function Ph(e){var t=e.alternate;return e===de||t!==null&&t===de}function Th(e,t){Cs=fi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Oh(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Zo(e,n)}}var hi={readContext:ct,useCallback:Le,useContext:Le,useEffect:Le,useImperativeHandle:Le,useInsertionEffect:Le,useLayoutEffect:Le,useMemo:Le,useReducer:Le,useRef:Le,useState:Le,useDebugValue:Le,useDeferredValue:Le,useTransition:Le,useMutableSource:Le,useSyncExternalStore:Le,useId:Le,unstable_isNewReconciler:!1},ex={readContext:ct,useCallback:function(e,t){return St().memoizedState=[e,t===void 0?null:t],e},useContext:ct,useEffect:Au,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Qa(4194308,4,Sh.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Qa(4194308,4,e,t)},useInsertionEffect:function(e,t){return Qa(4,2,e,t)},useMemo:function(e,t){var n=St();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=St();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Xv.bind(null,de,e),[r.memoizedState,e]},useRef:function(e){var t=St();return e={current:e},t.memoizedState=e},useState:Du,useDebugValue:kc,useDeferredValue:function(e){return St().memoizedState=e},useTransition:function(){var e=Du(!1),t=e[0];return e=Yv.bind(null,e[1]),St().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=de,s=St();if(ce){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),Ee===null)throw Error(E(349));tr&30||ph(r,t,n)}s.memoizedState=n;var a={value:n,getSnapshot:t};return s.queue=a,Au(xh.bind(null,r,a,e),[e]),r.flags|=2048,Hs(9,vh.bind(null,r,a,n,t),void 0,null),n},useId:function(){var e=St(),t=Ee.identifierPrefix;if(ce){var n=At,r=Dt;n=(r&~(1<<32-gt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Vs++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[_t]=t,e[Us]=r,Uh(e,t,!1,!1),t.stateNode=e;e:{switch(l=Fl(n,r),n){case"dialog":le("cancel",e),le("close",e),s=r;break;case"iframe":case"object":case"embed":le("load",e),s=r;break;case"video":case"audio":for(s=0;sGr&&(t.flags|=128,r=!0,hs(a,!1),t.lanes=4194304)}else{if(!r)if(e=di(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),hs(a,!0),a.tail===null&&a.tailMode==="hidden"&&!l.alternate&&!ce)return Re(t),null}else 2*je()-a.renderingStartTime>Gr&&n!==1073741824&&(t.flags|=128,r=!0,hs(a,!1),t.lanes=4194304);a.isBackwards?(l.sibling=t.child,t.child=l):(n=a.last,n!==null?n.sibling=l:t.child=l,a.last=l)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=je(),t.sibling=null,n=ue.current,ie(ue,r?n&1|2:n&1),t):(Re(t),null);case 22:case 23:return Ec(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ye&1073741824&&(Re(t),t.subtreeFlags&6&&(t.flags|=8192)):Re(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function ox(e,t){switch(oc(t),t.tag){case 1:return qe(t.type)&&si(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Wr(),oe(We),oe(Fe),xc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return vc(t),null;case 13:if(oe(ue),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));Kr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return oe(ue),null;case 4:return Wr(),null;case 10:return fc(t.type._context),null;case 22:case 23:return Ec(),null;case 24:return null;default:return null}}var Ta=!1,ze=!1,cx=typeof WeakSet=="function"?WeakSet:Set,I=null;function Sr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){xe(e,t,r)}else n.current=null}function co(e,t,n){try{n()}catch(r){xe(e,t,r)}}var Ju=!1;function ux(e,t){if(Hl=ei,e=qf(),ic(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break e}var l=0,o=-1,c=-1,d=0,h=0,u=e,p=null;t:for(;;){for(var x;u!==n||s!==0&&u.nodeType!==3||(o=l+s),u!==a||r!==0&&u.nodeType!==3||(c=l+r),u.nodeType===3&&(l+=u.nodeValue.length),(x=u.firstChild)!==null;)p=u,u=x;for(;;){if(u===e)break t;if(p===n&&++d===s&&(o=l),p===a&&++h===r&&(c=l),(x=u.nextSibling)!==null)break;u=p,p=u.parentNode}u=x}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Wl={focusedElem:e,selectionRange:n},ei=!1,I=t;I!==null;)if(t=I,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,I=e;else for(;I!==null;){t=I;try{var k=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(k!==null){var g=k.memoizedProps,S=k.memoizedState,m=t.stateNode,f=m.getSnapshotBeforeUpdate(t.elementType===t.type?g:mt(t.type,g),S);m.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var v=t.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(j){xe(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,I=e;break}I=t.return}return k=Ju,Ju=!1,k}function _s(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var a=s.destroy;s.destroy=void 0,a!==void 0&&co(t,n,a)}s=s.next}while(s!==r)}}function Ri(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function uo(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Vh(e){var t=e.alternate;t!==null&&(e.alternate=null,Vh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[_t],delete t[Us],delete t[Jl],delete t[Hv],delete t[Wv])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Kh(e){return e.tag===5||e.tag===3||e.tag===4}function Yu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Kh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function fo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ri));else if(r!==4&&(e=e.child,e!==null))for(fo(e,t,n),e=e.sibling;e!==null;)fo(e,t,n),e=e.sibling}function ho(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(ho(e,t,n),e=e.sibling;e!==null;)ho(e,t,n),e=e.sibling}var Pe=null,xt=!1;function Jt(e,t,n){for(n=n.child;n!==null;)Hh(e,t,n),n=n.sibling}function Hh(e,t,n){if(Pt&&typeof Pt.onCommitFiberUnmount=="function")try{Pt.onCommitFiberUnmount(bi,n)}catch{}switch(n.tag){case 5:ze||Sr(n,t);case 6:var r=Pe,s=xt;Pe=null,Jt(e,t,n),Pe=r,xt=s,Pe!==null&&(xt?(e=Pe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Pe.removeChild(n.stateNode));break;case 18:Pe!==null&&(xt?(e=Pe,n=n.stateNode,e.nodeType===8?ul(e.parentNode,n):e.nodeType===1&&ul(e,n),Fs(e)):ul(Pe,n.stateNode));break;case 4:r=Pe,s=xt,Pe=n.stateNode.containerInfo,xt=!0,Jt(e,t,n),Pe=r,xt=s;break;case 0:case 11:case 14:case 15:if(!ze&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var a=s,l=a.destroy;a=a.tag,l!==void 0&&(a&2||a&4)&&co(n,t,l),s=s.next}while(s!==r)}Jt(e,t,n);break;case 1:if(!ze&&(Sr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){xe(n,t,o)}Jt(e,t,n);break;case 21:Jt(e,t,n);break;case 22:n.mode&1?(ze=(r=ze)||n.memoizedState!==null,Jt(e,t,n),ze=r):Jt(e,t,n);break;default:Jt(e,t,n)}}function Xu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new cx),t.forEach(function(r){var s=gx.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function ft(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=l),r&=~a}if(r=s,r=je()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*fx(r/1960))-r,10e?16:e,hn===null)var r=!1;else{if(e=hn,hn=null,vi=0,ne&6)throw Error(E(331));var s=ne;for(ne|=4,I=e.current;I!==null;){var a=I,l=a.child;if(I.flags&16){var o=a.deletions;if(o!==null){for(var c=0;cje()-Cc?Gn(e,0):bc|=n),Ge(e,t)}function em(e,t){t===0&&(e.mode&1?(t=wa,wa<<=1,!(wa&130023424)&&(wa=4194304)):t=1);var n=$e();e=Kt(e,t),e!==null&&(la(e,t,n),Ge(e,n))}function yx(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),em(e,n)}function gx(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),em(e,n)}var tm;tm=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||We.current)He=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return He=!1,ix(e,t,n);He=!!(e.flags&131072)}else He=!1,ce&&t.flags&1048576&&ah(t,li,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Va(e,t),e=t.pendingProps;var s=Vr(t,Fe.current);Pr(t,n),s=gc(null,t,r,e,s,n);var a=jc();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,qe(r)?(a=!0,ai(t)):a=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,mc(t),s.updater=Li,t.stateNode=s,s._reactInternals=t,no(t,r,e,n),t=ao(null,t,r,!0,a,n)):(t.tag=0,ce&&a&&lc(t),De(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Va(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=wx(r),e=mt(r,e),s){case 0:t=so(null,t,r,e,n);break e;case 1:t=Wu(null,t,r,e,n);break e;case 11:t=Ku(null,t,r,e,n);break e;case 14:t=Hu(null,t,r,mt(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),so(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Wu(e,t,r,s,n);case 3:e:{if(Dh(t),e===null)throw Error(E(387));r=t.pendingProps,a=t.memoizedState,s=a.element,dh(e,t),ui(t,r,null,n);var l=t.memoizedState;if(r=l.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){s=qr(Error(E(423)),t),t=qu(e,t,r,n,s);break e}else if(r!==s){s=qr(Error(E(424)),t),t=qu(e,t,r,n,s);break e}else for(Xe=jn(t.stateNode.containerInfo.firstChild),Ze=t,ce=!0,yt=null,n=ch(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Kr(),r===s){t=Ht(e,t,n);break e}De(e,t,r,n)}t=t.child}return t;case 5:return fh(t),e===null&&Zl(t),r=t.type,s=t.pendingProps,a=e!==null?e.memoizedProps:null,l=s.children,ql(r,s)?l=null:a!==null&&ql(r,a)&&(t.flags|=32),Ih(e,t),De(e,t,l,n),t.child;case 6:return e===null&&Zl(t),null;case 13:return Ah(e,t,n);case 4:return pc(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Hr(t,null,r,n):De(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Ku(e,t,r,s,n);case 7:return De(e,t,t.pendingProps,n),t.child;case 8:return De(e,t,t.pendingProps.children,n),t.child;case 12:return De(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,a=t.memoizedProps,l=s.value,ie(oi,r._currentValue),r._currentValue=l,a!==null)if(wt(a.value,l)){if(a.children===s.children&&!We.current){t=Ht(e,t,n);break e}}else for(a=t.child,a!==null&&(a.return=t);a!==null;){var o=a.dependencies;if(o!==null){l=a.child;for(var c=o.firstContext;c!==null;){if(c.context===r){if(a.tag===1){c=$t(-1,n&-n),c.tag=2;var d=a.updateQueue;if(d!==null){d=d.shared;var h=d.pending;h===null?c.next=c:(c.next=h.next,h.next=c),d.pending=c}}a.lanes|=n,c=a.alternate,c!==null&&(c.lanes|=n),eo(a.return,n,t),o.lanes|=n;break}c=c.next}}else if(a.tag===10)l=a.type===t.type?null:a.child;else if(a.tag===18){if(l=a.return,l===null)throw Error(E(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),eo(l,n,t),l=a.sibling}else l=a.child;if(l!==null)l.return=a;else for(l=a;l!==null;){if(l===t){l=null;break}if(a=l.sibling,a!==null){a.return=l.return,l=a;break}l=l.return}a=l}De(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Pr(t,n),s=ct(s),r=r(s),t.flags|=1,De(e,t,r,n),t.child;case 14:return r=t.type,s=mt(r,t.pendingProps),s=mt(r.type,s),Hu(e,t,r,s,n);case 15:return zh(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Va(e,t),t.tag=1,qe(r)?(e=!0,ai(t)):e=!1,Pr(t,n),Lh(t,r,s),no(t,r,s,n),ao(null,t,r,!0,e,n);case 19:return $h(e,t,n);case 22:return Fh(e,t,n)}throw Error(E(156,t.tag))};function nm(e,t){return Pf(e,t)}function jx(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function lt(e,t,n,r){return new jx(e,t,n,r)}function Tc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function wx(e){if(typeof e=="function")return Tc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Go)return 11;if(e===Jo)return 14}return 2}function Nn(e,t){var n=e.alternate;return n===null?(n=lt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Wa(e,t,n,r,s,a){var l=2;if(r=e,typeof e=="function")Tc(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case mr:return Jn(n.children,s,a,t);case qo:l=8,s|=8;break;case Cl:return e=lt(12,n,t,s|2),e.elementType=Cl,e.lanes=a,e;case _l:return e=lt(13,n,t,s),e.elementType=_l,e.lanes=a,e;case El:return e=lt(19,n,t,s),e.elementType=El,e.lanes=a,e;case ff:return zi(n,s,a,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case uf:l=10;break e;case df:l=9;break e;case Go:l=11;break e;case Jo:l=14;break e;case Xt:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=lt(l,n,t,s),t.elementType=e,t.type=r,t.lanes=a,t}function Jn(e,t,n,r){return e=lt(7,e,r,t),e.lanes=n,e}function zi(e,t,n,r){return e=lt(22,e,r,t),e.elementType=ff,e.lanes=n,e.stateNode={isHidden:!1},e}function yl(e,t,n){return e=lt(6,e,null,t),e.lanes=n,e}function gl(e,t,n){return t=lt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function kx(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Zi(0),this.expirationTimes=Zi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Zi(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Oc(e,t,n,r,s,a,l,o,c){return e=new kx(e,t,n,o,c),t===1?(t=1,a===!0&&(t|=8)):t=0,a=lt(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},mc(a),e}function Sx(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(im)}catch(e){console.error(e)}}im(),af.exports=tt;var Ex=af.exports,id=Ex;Nl.createRoot=id.createRoot,Nl.hydrateRoot=id.hydrateRoot;var ts=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Px={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},nn,Ao,Fd,Tx=(Fd=class{constructor(){$(this,nn,Px);$(this,Ao,!1)}setTimeoutProvider(e){z(this,nn,e)}setTimeout(e,t){return y(this,nn).setTimeout(e,t)}clearTimeout(e){y(this,nn).clearTimeout(e)}setInterval(e,t){return y(this,nn).setInterval(e,t)}clearInterval(e){y(this,nn).clearInterval(e)}},nn=new WeakMap,Ao=new WeakMap,Fd),An=new Tx;function Ox(e){setTimeout(e,0)}var sr=typeof window>"u"||"Deno"in globalThis;function Ae(){}function Lx(e,t){return typeof e=="function"?e(t):e}function yo(e){return typeof e=="number"&&e>=0&&e!==1/0}function lm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function bn(e,t){return typeof e=="function"?e(t):e}function st(e,t){return typeof e=="function"?e(t):e}function ld(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:a,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==zc(l,t.options))return!1}else if(!qs(t.queryKey,l))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||s&&s!==t.state.fetchStatus||a&&!a(t))}function od(e,t){const{exact:n,status:r,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(ar(t.options.mutationKey)!==ar(a))return!1}else if(!qs(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function zc(e,t){return((t==null?void 0:t.queryKeyHashFn)||ar)(e)}function ar(e){return JSON.stringify(e,(t,n)=>go(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function qs(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>qs(e[n],t[n])):!1}var Rx=Object.prototype.hasOwnProperty;function om(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=cd(e)&&cd(t);if(!r&&!(go(e)&&go(t)))return t;const a=(r?e:Object.keys(e)).length,l=r?t:Object.keys(t),o=l.length,c=r?new Array(o):{};let d=0;for(let h=0;h{An.setTimeout(t,e)})}function jo(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?om(e,t):t}function zx(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Fx(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Fc=Symbol();function cm(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Fc?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Ic(e,t){return typeof e=="function"?e(...t):!!e}function Ix(e,t,n){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),e}var $n,rn,Or,Id,Dx=(Id=class extends ts{constructor(){super();$(this,$n);$(this,rn);$(this,Or);z(this,Or,t=>{if(!sr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){y(this,rn)||this.setEventListener(y(this,Or))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,rn))==null||t.call(this),z(this,rn,void 0))}setEventListener(t){var n;z(this,Or,t),(n=y(this,rn))==null||n.call(this),z(this,rn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){y(this,$n)!==t&&(z(this,$n,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof y(this,$n)=="boolean"?y(this,$n):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},$n=new WeakMap,rn=new WeakMap,Or=new WeakMap,Id),Dc=new Dx;function wo(){let e,t;const n=new Promise((s,a)=>{e=s,t=a});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var Ax=Ox;function $x(){let e=[],t=0,n=o=>{o()},r=o=>{o()},s=Ax;const a=o=>{t?e.push(o):s(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&s(()=>{r(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;t++;try{c=o()}finally{t--,t||l()}return c},batchCalls:o=>(...c)=>{a(()=>{o(...c)})},schedule:a,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{s=o}}}var Se=$x(),Lr,sn,Rr,Dd,Ux=(Dd=class extends ts{constructor(){super();$(this,Lr,!0);$(this,sn);$(this,Rr);z(this,Rr,t=>{if(!sr&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){y(this,sn)||this.setEventListener(y(this,Rr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,sn))==null||t.call(this),z(this,sn,void 0))}setEventListener(t){var n;z(this,Rr,t),(n=y(this,sn))==null||n.call(this),z(this,sn,t(this.setOnline.bind(this)))}setOnline(t){y(this,Lr)!==t&&(z(this,Lr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return y(this,Lr)}},Lr=new WeakMap,sn=new WeakMap,Rr=new WeakMap,Dd),ji=new Ux;function Bx(e){return Math.min(1e3*2**e,3e4)}function um(e){return(e??"online")==="online"?ji.isOnline():!0}var ko=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function dm(e){let t=!1,n=0,r;const s=wo(),a=()=>s.status!=="pending",l=g=>{var S;if(!a()){const m=new ko(g);p(m),(S=e.onCancel)==null||S.call(e,m)}},o=()=>{t=!0},c=()=>{t=!1},d=()=>Dc.isFocused()&&(e.networkMode==="always"||ji.isOnline())&&e.canRun(),h=()=>um(e.networkMode)&&e.canRun(),u=g=>{a()||(r==null||r(),s.resolve(g))},p=g=>{a()||(r==null||r(),s.reject(g))},x=()=>new Promise(g=>{var S;r=m=>{(a()||d())&&g(m)},(S=e.onPause)==null||S.call(e)}).then(()=>{var g;r=void 0,a()||(g=e.onContinue)==null||g.call(e)}),k=()=>{if(a())return;let g;const S=n===0?e.initialPromise:void 0;try{g=S??e.fn()}catch(m){g=Promise.reject(m)}Promise.resolve(g).then(u).catch(m=>{var b;if(a())return;const f=e.retry??(sr?0:3),v=e.retryDelay??Bx,j=typeof v=="function"?v(n,m):v,C=f===!0||typeof f=="number"&&nd()?void 0:x()).then(()=>{t?p(m):k()})})};return{promise:s,status:()=>s.status,cancel:l,continue:()=>(r==null||r(),s),cancelRetry:o,continueRetry:c,canStart:h,start:()=>(h()?k():x().then(k),s)}}var Un,Ad,fm=(Ad=class{constructor(){$(this,Un)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),yo(this.gcTime)&&z(this,Un,An.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(sr?1/0:5*60*1e3))}clearGcTimeout(){y(this,Un)&&(An.clearTimeout(y(this,Un)),z(this,Un,void 0))}},Un=new WeakMap,Ad),Bn,Mr,rt,Qn,Ce,ta,Vn,pt,Ot,$d,Qx=($d=class extends fm{constructor(t){super();$(this,pt);$(this,Bn);$(this,Mr);$(this,rt);$(this,Qn);$(this,Ce);$(this,ta);$(this,Vn);z(this,Vn,!1),z(this,ta,t.defaultOptions),this.setOptions(t.options),this.observers=[],z(this,Qn,t.client),z(this,rt,y(this,Qn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,z(this,Bn,fd(this.options)),this.state=t.state??y(this,Bn),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=y(this,Ce))==null?void 0:t.promise}setOptions(t){if(this.options={...y(this,ta),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=fd(this.options);n.data!==void 0&&(this.setState(dd(n.data,n.dataUpdatedAt)),z(this,Bn,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&y(this,rt).remove(this)}setData(t,n){const r=jo(this.state.data,t,this.options);return W(this,pt,Ot).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){W(this,pt,Ot).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=y(this,Ce))==null?void 0:r.promise;return(s=y(this,Ce))==null||s.cancel(t),n?n.then(Ae).catch(Ae):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(y(this,Bn))}isActive(){return this.observers.some(t=>st(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Fc||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>bn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!lm(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),y(this,rt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(y(this,Ce)&&(y(this,Vn)?y(this,Ce).cancel({revert:!0}):y(this,Ce).cancelRetry()),this.scheduleGc()),y(this,rt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||W(this,pt,Ot).call(this,{type:"invalidate"})}async fetch(t,n){var c,d,h,u,p,x,k,g,S,m,f,v;if(this.state.fetchStatus!=="idle"&&((c=y(this,Ce))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(y(this,Ce))return y(this,Ce).continueRetry(),y(this,Ce).promise}if(t&&this.setOptions(t),!this.options.queryFn){const j=this.observers.find(C=>C.options.queryFn);j&&this.setOptions(j.options)}const r=new AbortController,s=j=>{Object.defineProperty(j,"signal",{enumerable:!0,get:()=>(z(this,Vn,!0),r.signal)})},a=()=>{const j=cm(this.options,n),b=(()=>{const N={client:y(this,Qn),queryKey:this.queryKey,meta:this.meta};return s(N),N})();return z(this,Vn,!1),this.options.persister?this.options.persister(j,b,this):j(b)},o=(()=>{const j={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:y(this,Qn),state:this.state,fetchFn:a};return s(j),j})();(d=this.options.behavior)==null||d.onFetch(o,this),z(this,Mr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((h=o.fetchOptions)==null?void 0:h.meta))&&W(this,pt,Ot).call(this,{type:"fetch",meta:(u=o.fetchOptions)==null?void 0:u.meta}),z(this,Ce,dm({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:j=>{j instanceof ko&&j.revert&&this.setState({...y(this,Mr),fetchStatus:"idle"}),r.abort()},onFail:(j,C)=>{W(this,pt,Ot).call(this,{type:"failed",failureCount:j,error:C})},onPause:()=>{W(this,pt,Ot).call(this,{type:"pause"})},onContinue:()=>{W(this,pt,Ot).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const j=await y(this,Ce).start();if(j===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(j),(x=(p=y(this,rt).config).onSuccess)==null||x.call(p,j,this),(g=(k=y(this,rt).config).onSettled)==null||g.call(k,j,this.state.error,this),j}catch(j){if(j instanceof ko){if(j.silent)return y(this,Ce).promise;if(j.revert){if(this.state.data===void 0)throw j;return this.state.data}}throw W(this,pt,Ot).call(this,{type:"error",error:j}),(m=(S=y(this,rt).config).onError)==null||m.call(S,j,this),(v=(f=y(this,rt).config).onSettled)==null||v.call(f,this.state.data,j,this),j}finally{this.scheduleGc()}}},Bn=new WeakMap,Mr=new WeakMap,rt=new WeakMap,Qn=new WeakMap,Ce=new WeakMap,ta=new WeakMap,Vn=new WeakMap,pt=new WeakSet,Ot=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...hm(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...dd(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return z(this,Mr,t.manual?s:void 0),s;case"error":const a=t.error;return{...r,error:a,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Se.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),y(this,rt).notify({query:this,type:"updated",action:t})})},$d);function hm(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:um(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function dd(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function fd(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Qe,Z,na,Ie,Kn,zr,Mt,an,ra,Fr,Ir,Hn,Wn,ln,Dr,se,js,So,No,bo,Co,_o,Eo,Po,mm,Ud,Vx=(Ud=class extends ts{constructor(t,n){super();$(this,se);$(this,Qe);$(this,Z);$(this,na);$(this,Ie);$(this,Kn);$(this,zr);$(this,Mt);$(this,an);$(this,ra);$(this,Fr);$(this,Ir);$(this,Hn);$(this,Wn);$(this,ln);$(this,Dr,new Set);this.options=n,z(this,Qe,t),z(this,an,null),z(this,Mt,wo()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(y(this,Z).addObserver(this),hd(y(this,Z),this.options)?W(this,se,js).call(this):this.updateResult(),W(this,se,Co).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return To(y(this,Z),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return To(y(this,Z),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,W(this,se,_o).call(this),W(this,se,Eo).call(this),y(this,Z).removeObserver(this)}setOptions(t){const n=this.options,r=y(this,Z);if(this.options=y(this,Qe).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof st(this.options.enabled,y(this,Z))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");W(this,se,Po).call(this),y(this,Z).setOptions(this.options),n._defaulted&&!gi(this.options,n)&&y(this,Qe).getQueryCache().notify({type:"observerOptionsUpdated",query:y(this,Z),observer:this});const s=this.hasListeners();s&&md(y(this,Z),r,this.options,n)&&W(this,se,js).call(this),this.updateResult(),s&&(y(this,Z)!==r||st(this.options.enabled,y(this,Z))!==st(n.enabled,y(this,Z))||bn(this.options.staleTime,y(this,Z))!==bn(n.staleTime,y(this,Z)))&&W(this,se,So).call(this);const a=W(this,se,No).call(this);s&&(y(this,Z)!==r||st(this.options.enabled,y(this,Z))!==st(n.enabled,y(this,Z))||a!==y(this,ln))&&W(this,se,bo).call(this,a)}getOptimisticResult(t){const n=y(this,Qe).getQueryCache().build(y(this,Qe),t),r=this.createResult(n,t);return Hx(this,r)&&(z(this,Ie,r),z(this,zr,this.options),z(this,Kn,y(this,Z).state)),r}getCurrentResult(){return y(this,Ie)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&y(this,Mt).status==="pending"&&y(this,Mt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){y(this,Dr).add(t)}getCurrentQuery(){return y(this,Z)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=y(this,Qe).defaultQueryOptions(t),r=y(this,Qe).getQueryCache().build(y(this,Qe),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return W(this,se,js).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),y(this,Ie)))}createResult(t,n){var F;const r=y(this,Z),s=this.options,a=y(this,Ie),l=y(this,Kn),o=y(this,zr),d=t!==r?t.state:y(this,na),{state:h}=t;let u={...h},p=!1,x;if(n._optimisticResults){const O=this.hasListeners(),B=!O&&hd(t,n),G=O&&md(t,r,n,s);(B||G)&&(u={...u,...hm(h.data,t.options)}),n._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:k,errorUpdatedAt:g,status:S}=u;x=u.data;let m=!1;if(n.placeholderData!==void 0&&x===void 0&&S==="pending"){let O;a!=null&&a.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(O=a.data,m=!0):O=typeof n.placeholderData=="function"?n.placeholderData((F=y(this,Ir))==null?void 0:F.state.data,y(this,Ir)):n.placeholderData,O!==void 0&&(S="success",x=jo(a==null?void 0:a.data,O,n),p=!0)}if(n.select&&x!==void 0&&!m)if(a&&x===(l==null?void 0:l.data)&&n.select===y(this,ra))x=y(this,Fr);else try{z(this,ra,n.select),x=n.select(x),x=jo(a==null?void 0:a.data,x,n),z(this,Fr,x),z(this,an,null)}catch(O){z(this,an,O)}y(this,an)&&(k=y(this,an),x=y(this,Fr),g=Date.now(),S="error");const f=u.fetchStatus==="fetching",v=S==="pending",j=S==="error",C=v&&f,b=x!==void 0,_={status:S,fetchStatus:u.fetchStatus,isPending:v,isSuccess:S==="success",isError:j,isInitialLoading:C,isLoading:C,data:x,dataUpdatedAt:u.dataUpdatedAt,error:k,errorUpdatedAt:g,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>d.dataUpdateCount||u.errorUpdateCount>d.errorUpdateCount,isFetching:f,isRefetching:f&&!v,isLoadingError:j&&!b,isPaused:u.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:j&&b,isStale:Ac(t,n),refetch:this.refetch,promise:y(this,Mt),isEnabled:st(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=_.data!==void 0,B=_.status==="error"&&!O,G=D=>{B?D.reject(_.error):O&&D.resolve(_.data)},re=()=>{const D=z(this,Mt,_.promise=wo());G(D)},me=y(this,Mt);switch(me.status){case"pending":t.queryHash===r.queryHash&&G(me);break;case"fulfilled":(B||_.data!==me.value)&&re();break;case"rejected":(!B||_.error!==me.reason)&&re();break}}return _}updateResult(){const t=y(this,Ie),n=this.createResult(y(this,Z),this.options);if(z(this,Kn,y(this,Z).state),z(this,zr,this.options),y(this,Kn).data!==void 0&&z(this,Ir,y(this,Z)),gi(n,t))return;z(this,Ie,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!y(this,Dr).size)return!0;const l=new Set(a??y(this,Dr));return this.options.throwOnError&&l.add("error"),Object.keys(y(this,Ie)).some(o=>{const c=o;return y(this,Ie)[c]!==t[c]&&l.has(c)})};W(this,se,mm).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&W(this,se,Co).call(this)}},Qe=new WeakMap,Z=new WeakMap,na=new WeakMap,Ie=new WeakMap,Kn=new WeakMap,zr=new WeakMap,Mt=new WeakMap,an=new WeakMap,ra=new WeakMap,Fr=new WeakMap,Ir=new WeakMap,Hn=new WeakMap,Wn=new WeakMap,ln=new WeakMap,Dr=new WeakMap,se=new WeakSet,js=function(t){W(this,se,Po).call(this);let n=y(this,Z).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Ae)),n},So=function(){W(this,se,_o).call(this);const t=bn(this.options.staleTime,y(this,Z));if(sr||y(this,Ie).isStale||!yo(t))return;const r=lm(y(this,Ie).dataUpdatedAt,t)+1;z(this,Hn,An.setTimeout(()=>{y(this,Ie).isStale||this.updateResult()},r))},No=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(y(this,Z)):this.options.refetchInterval)??!1},bo=function(t){W(this,se,Eo).call(this),z(this,ln,t),!(sr||st(this.options.enabled,y(this,Z))===!1||!yo(y(this,ln))||y(this,ln)===0)&&z(this,Wn,An.setInterval(()=>{(this.options.refetchIntervalInBackground||Dc.isFocused())&&W(this,se,js).call(this)},y(this,ln)))},Co=function(){W(this,se,So).call(this),W(this,se,bo).call(this,W(this,se,No).call(this))},_o=function(){y(this,Hn)&&(An.clearTimeout(y(this,Hn)),z(this,Hn,void 0))},Eo=function(){y(this,Wn)&&(An.clearInterval(y(this,Wn)),z(this,Wn,void 0))},Po=function(){const t=y(this,Qe).getQueryCache().build(y(this,Qe),this.options);if(t===y(this,Z))return;const n=y(this,Z);z(this,Z,t),z(this,na,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},mm=function(t){Se.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(y(this,Ie))}),y(this,Qe).getQueryCache().notify({query:y(this,Z),type:"observerResultsUpdated"})})},Ud);function Kx(e,t){return st(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function hd(e,t){return Kx(e,t)||e.state.data!==void 0&&To(e,t,t.refetchOnMount)}function To(e,t,n){if(st(t.enabled,e)!==!1&&bn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Ac(e,t)}return!1}function md(e,t,n,r){return(e!==t||st(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Ac(e,n)}function Ac(e,t){return st(t.enabled,e)!==!1&&e.isStaleByTime(bn(t.staleTime,e))}function Hx(e,t){return!gi(e.getCurrentResult(),t)}function pd(e){return{onFetch:(t,n)=>{var h,u,p,x,k;const r=t.options,s=(p=(u=(h=t.fetchOptions)==null?void 0:h.meta)==null?void 0:u.fetchMore)==null?void 0:p.direction,a=((x=t.state.data)==null?void 0:x.pages)||[],l=((k=t.state.data)==null?void 0:k.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const d=async()=>{let g=!1;const S=v=>{Ix(v,()=>t.signal,()=>g=!0)},m=cm(t.options,t.fetchOptions),f=async(v,j,C)=>{if(g)return Promise.reject();if(j==null&&v.pages.length)return Promise.resolve(v);const N=(()=>{const B={client:t.client,queryKey:t.queryKey,pageParam:j,direction:C?"backward":"forward",meta:t.options.meta};return S(B),B})(),_=await m(N),{maxPages:F}=t.options,O=C?Fx:zx;return{pages:O(v.pages,_,F),pageParams:O(v.pageParams,j,F)}};if(s&&a.length){const v=s==="backward",j=v?Wx:vd,C={pages:a,pageParams:l},b=j(r,C);o=await f(C,b,v)}else{const v=e??a.length;do{const j=c===0?l[0]??r.initialPageParam:vd(r,o);if(c>0&&j==null)break;o=await f(o,j),c++}while(c{var g,S;return(S=(g=t.options).persister)==null?void 0:S.call(g,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=d}}}function vd(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Wx(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var sa,Nt,Me,qn,bt,Yt,Bd,qx=(Bd=class extends fm{constructor(t){super();$(this,bt);$(this,sa);$(this,Nt);$(this,Me);$(this,qn);z(this,sa,t.client),this.mutationId=t.mutationId,z(this,Me,t.mutationCache),z(this,Nt,[]),this.state=t.state||pm(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){y(this,Nt).includes(t)||(y(this,Nt).push(t),this.clearGcTimeout(),y(this,Me).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){z(this,Nt,y(this,Nt).filter(n=>n!==t)),this.scheduleGc(),y(this,Me).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){y(this,Nt).length||(this.state.status==="pending"?this.scheduleGc():y(this,Me).remove(this))}continue(){var t;return((t=y(this,qn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,d,h,u,p,x,k,g,S,m,f,v,j,C,b,N;const n=()=>{W(this,bt,Yt).call(this,{type:"continue"})},r={client:y(this,sa),meta:this.options.meta,mutationKey:this.options.mutationKey};z(this,qn,dm({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(_,F)=>{W(this,bt,Yt).call(this,{type:"failed",failureCount:_,error:F})},onPause:()=>{W(this,bt,Yt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>y(this,Me).canRun(this)}));const s=this.state.status==="pending",a=!y(this,qn).canStart();try{if(s)n();else{W(this,bt,Yt).call(this,{type:"pending",variables:t,isPaused:a}),y(this,Me).config.onMutate&&await y(this,Me).config.onMutate(t,this,r);const F=await((o=(l=this.options).onMutate)==null?void 0:o.call(l,t,r));F!==this.state.context&&W(this,bt,Yt).call(this,{type:"pending",context:F,variables:t,isPaused:a})}const _=await y(this,qn).start();return await((d=(c=y(this,Me).config).onSuccess)==null?void 0:d.call(c,_,t,this.state.context,this,r)),await((u=(h=this.options).onSuccess)==null?void 0:u.call(h,_,t,this.state.context,r)),await((x=(p=y(this,Me).config).onSettled)==null?void 0:x.call(p,_,null,this.state.variables,this.state.context,this,r)),await((g=(k=this.options).onSettled)==null?void 0:g.call(k,_,null,t,this.state.context,r)),W(this,bt,Yt).call(this,{type:"success",data:_}),_}catch(_){try{await((m=(S=y(this,Me).config).onError)==null?void 0:m.call(S,_,t,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((v=(f=this.options).onError)==null?void 0:v.call(f,_,t,this.state.context,r))}catch(F){Promise.reject(F)}try{await((C=(j=y(this,Me).config).onSettled)==null?void 0:C.call(j,void 0,_,this.state.variables,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((N=(b=this.options).onSettled)==null?void 0:N.call(b,void 0,_,t,this.state.context,r))}catch(F){Promise.reject(F)}throw W(this,bt,Yt).call(this,{type:"error",error:_}),_}finally{y(this,Me).runNext(this)}}},sa=new WeakMap,Nt=new WeakMap,Me=new WeakMap,qn=new WeakMap,bt=new WeakSet,Yt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Se.batch(()=>{y(this,Nt).forEach(r=>{r.onMutationUpdate(t)}),y(this,Me).notify({mutation:this,type:"updated",action:t})})},Bd);function pm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var zt,vt,aa,Qd,Gx=(Qd=class extends ts{constructor(t={}){super();$(this,zt);$(this,vt);$(this,aa);this.config=t,z(this,zt,new Set),z(this,vt,new Map),z(this,aa,0)}build(t,n,r){const s=new qx({client:t,mutationCache:this,mutationId:++pa(this,aa)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){y(this,zt).add(t);const n=Ra(t);if(typeof n=="string"){const r=y(this,vt).get(n);r?r.push(t):y(this,vt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(y(this,zt).delete(t)){const n=Ra(t);if(typeof n=="string"){const r=y(this,vt).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&y(this,vt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Ra(t);if(typeof n=="string"){const r=y(this,vt).get(n),s=r==null?void 0:r.find(a=>a.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=Ra(t);if(typeof n=="string"){const s=(r=y(this,vt).get(n))==null?void 0:r.find(a=>a!==t&&a.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Se.batch(()=>{y(this,zt).forEach(t=>{this.notify({type:"removed",mutation:t})}),y(this,zt).clear(),y(this,vt).clear()})}getAll(){return Array.from(y(this,zt))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>od(n,r))}findAll(t={}){return this.getAll().filter(n=>od(t,n))}notify(t){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Se.batch(()=>Promise.all(t.map(n=>n.continue().catch(Ae))))}},zt=new WeakMap,vt=new WeakMap,aa=new WeakMap,Qd);function Ra(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Ft,on,Ve,It,Bt,qa,Oo,Vd,Jx=(Vd=class extends ts{constructor(n,r){super();$(this,Bt);$(this,Ft);$(this,on);$(this,Ve);$(this,It);z(this,Ft,n),this.setOptions(r),this.bindMethods(),W(this,Bt,qa).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=y(this,Ft).defaultMutationOptions(n),gi(this.options,r)||y(this,Ft).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,Ve),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&ar(r.mutationKey)!==ar(this.options.mutationKey)?this.reset():((s=y(this,Ve))==null?void 0:s.state.status)==="pending"&&y(this,Ve).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=y(this,Ve))==null||n.removeObserver(this)}onMutationUpdate(n){W(this,Bt,qa).call(this),W(this,Bt,Oo).call(this,n)}getCurrentResult(){return y(this,on)}reset(){var n;(n=y(this,Ve))==null||n.removeObserver(this),z(this,Ve,void 0),W(this,Bt,qa).call(this),W(this,Bt,Oo).call(this)}mutate(n,r){var s;return z(this,It,r),(s=y(this,Ve))==null||s.removeObserver(this),z(this,Ve,y(this,Ft).getMutationCache().build(y(this,Ft),this.options)),y(this,Ve).addObserver(this),y(this,Ve).execute(n)}},Ft=new WeakMap,on=new WeakMap,Ve=new WeakMap,It=new WeakMap,Bt=new WeakSet,qa=function(){var r;const n=((r=y(this,Ve))==null?void 0:r.state)??pm();z(this,on,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Oo=function(n){Se.batch(()=>{var r,s,a,l,o,c,d,h;if(y(this,It)&&this.hasListeners()){const u=y(this,on).variables,p=y(this,on).context,x={client:y(this,Ft),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(s=(r=y(this,It)).onSuccess)==null||s.call(r,n.data,u,p,x)}catch(k){Promise.reject(k)}try{(l=(a=y(this,It)).onSettled)==null||l.call(a,n.data,null,u,p,x)}catch(k){Promise.reject(k)}}else if((n==null?void 0:n.type)==="error"){try{(c=(o=y(this,It)).onError)==null||c.call(o,n.error,u,p,x)}catch(k){Promise.reject(k)}try{(h=(d=y(this,It)).onSettled)==null||h.call(d,void 0,n.error,u,p,x)}catch(k){Promise.reject(k)}}}this.listeners.forEach(u=>{u(y(this,on))})})},Vd),Ct,Kd,Yx=(Kd=class extends ts{constructor(t={}){super();$(this,Ct);this.config=t,z(this,Ct,new Map)}build(t,n,r){const s=n.queryKey,a=n.queryHash??zc(s,n);let l=this.get(a);return l||(l=new Qx({client:t,queryKey:s,queryHash:a,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(l)),l}add(t){y(this,Ct).has(t.queryHash)||(y(this,Ct).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=y(this,Ct).get(t.queryHash);n&&(t.destroy(),n===t&&y(this,Ct).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Se.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return y(this,Ct).get(t)}getAll(){return[...y(this,Ct).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>ld(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>ld(t,r)):n}notify(t){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Se.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Se.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ct=new WeakMap,Kd),ve,cn,un,Ar,$r,dn,Ur,Br,Hd,Xx=(Hd=class{constructor(e={}){$(this,ve);$(this,cn);$(this,un);$(this,Ar);$(this,$r);$(this,dn);$(this,Ur);$(this,Br);z(this,ve,e.queryCache||new Yx),z(this,cn,e.mutationCache||new Gx),z(this,un,e.defaultOptions||{}),z(this,Ar,new Map),z(this,$r,new Map),z(this,dn,0)}mount(){pa(this,dn)._++,y(this,dn)===1&&(z(this,Ur,Dc.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,ve).onFocus())})),z(this,Br,ji.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,ve).onOnline())})))}unmount(){var e,t;pa(this,dn)._--,y(this,dn)===0&&((e=y(this,Ur))==null||e.call(this),z(this,Ur,void 0),(t=y(this,Br))==null||t.call(this),z(this,Br,void 0))}isFetching(e){return y(this,ve).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return y(this,cn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,ve).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=y(this,ve).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(bn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return y(this,ve).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=y(this,ve).get(r.queryHash),a=s==null?void 0:s.state.data,l=Lx(t,a);if(l!==void 0)return y(this,ve).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return Se.batch(()=>y(this,ve).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,ve).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=y(this,ve);Se.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=y(this,ve);return Se.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Se.batch(()=>y(this,ve).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Ae).catch(Ae)}invalidateQueries(e,t={}){return Se.batch(()=>(y(this,ve).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Se.batch(()=>y(this,ve).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let a=s.fetch(void 0,n);return n.throwOnError||(a=a.catch(Ae)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Ae)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=y(this,ve).build(this,t);return n.isStaleByTime(bn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ae).catch(Ae)}fetchInfiniteQuery(e){return e.behavior=pd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ae).catch(Ae)}ensureInfiniteQueryData(e){return e.behavior=pd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ji.isOnline()?y(this,cn).resumePausedMutations():Promise.resolve()}getQueryCache(){return y(this,ve)}getMutationCache(){return y(this,cn)}getDefaultOptions(){return y(this,un)}setDefaultOptions(e){z(this,un,e)}setQueryDefaults(e,t){y(this,Ar).set(ar(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...y(this,Ar).values()],n={};return t.forEach(r=>{qs(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){y(this,$r).set(ar(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...y(this,$r).values()],n={};return t.forEach(r=>{qs(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...y(this,un).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=zc(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Fc&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...y(this,un).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){y(this,ve).clear(),y(this,cn).clear()}},ve=new WeakMap,cn=new WeakMap,un=new WeakMap,Ar=new WeakMap,$r=new WeakMap,dn=new WeakMap,Ur=new WeakMap,Br=new WeakMap,Hd),vm=w.createContext(void 0),qt=e=>{const t=w.useContext(vm);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Zx=({client:e,children:t})=>(w.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),i.jsx(vm.Provider,{value:e,children:t})),xm=w.createContext(!1),ey=()=>w.useContext(xm);xm.Provider;function ty(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var ny=w.createContext(ty()),ry=()=>w.useContext(ny),sy=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Ic(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},ay=e=>{w.useEffect(()=>{e.clearReset()},[e])},iy=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||Ic(n,[e.error,r])),ly=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},oy=(e,t)=>e.isLoading&&e.isFetching&&!t,cy=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,xd=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function uy(e,t,n){var p,x,k,g;const r=ey(),s=ry(),a=qt(),l=a.defaultQueryOptions(e);(x=(p=a.getDefaultOptions().queries)==null?void 0:p._experimental_beforeQuery)==null||x.call(p,l);const o=a.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",ly(l),sy(l,s,o),ay(s);const c=!a.getQueryCache().get(l.queryHash),[d]=w.useState(()=>new t(a,l)),h=d.getOptimisticResult(l),u=!r&&e.subscribed!==!1;if(w.useSyncExternalStore(w.useCallback(S=>{const m=u?d.subscribe(Se.batchCalls(S)):Ae;return d.updateResult(),m},[d,u]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),w.useEffect(()=>{d.setOptions(l)},[l,d]),cy(l,h))throw xd(l,d,s);if(iy({result:h,errorResetBoundary:s,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw h.error;if((g=(k=a.getDefaultOptions().queries)==null?void 0:k._experimental_afterQuery)==null||g.call(k,l,h),l.experimental_prefetchInRender&&!sr&&oy(h,r)){const S=c?xd(l,d,s):o==null?void 0:o.promise;S==null||S.catch(Ae).finally(()=>{d.updateResult()})}return l.notifyOnChangeProps?h:d.trackResult(h)}function fe(e,t){return uy(e,Vx)}function Je(e,t){const n=qt(),[r]=w.useState(()=>new Jx(n,e));w.useEffect(()=>{r.setOptions(e)},[r,e]);const s=w.useSyncExternalStore(w.useCallback(l=>r.subscribe(Se.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=w.useCallback((l,o)=>{r.mutate(l,o).catch(Ae)},[r]);if(s.error&&Ic(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}/** + * @remix-run/router v1.23.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Gs(){return Gs=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function $c(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function fy(){return Math.random().toString(36).substr(2,8)}function gd(e,t){return{usr:e.state,key:e.key,idx:t}}function Lo(e,t,n,r){return n===void 0&&(n=null),Gs({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?ns(t):t,{state:n,key:t&&t.key||r||fy()})}function wi(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function ns(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function hy(e,t,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:a=!1}=r,l=s.history,o=mn.Pop,c=null,d=h();d==null&&(d=0,l.replaceState(Gs({},l.state,{idx:d}),""));function h(){return(l.state||{idx:null}).idx}function u(){o=mn.Pop;let S=h(),m=S==null?null:S-d;d=S,c&&c({action:o,location:g.location,delta:m})}function p(S,m){o=mn.Push;let f=Lo(g.location,S,m);d=h()+1;let v=gd(f,d),j=g.createHref(f);try{l.pushState(v,"",j)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;s.location.assign(j)}a&&c&&c({action:o,location:g.location,delta:1})}function x(S,m){o=mn.Replace;let f=Lo(g.location,S,m);d=h();let v=gd(f,d),j=g.createHref(f);l.replaceState(v,"",j),a&&c&&c({action:o,location:g.location,delta:0})}function k(S){let m=s.location.origin!=="null"?s.location.origin:s.location.href,f=typeof S=="string"?S:wi(S);return f=f.replace(/ $/,"%20"),ye(m,"No window.location.(origin|href) available to create URL for href: "+f),new URL(f,m)}let g={get action(){return o},get location(){return e(s,l)},listen(S){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(yd,u),c=S,()=>{s.removeEventListener(yd,u),c=null}},createHref(S){return t(s,S)},createURL:k,encodeLocation(S){let m=k(S);return{pathname:m.pathname,search:m.search,hash:m.hash}},push:p,replace:x,go(S){return l.go(S)}};return g}var jd;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(jd||(jd={}));function my(e,t,n){return n===void 0&&(n="/"),py(e,t,n)}function py(e,t,n,r){let s=typeof t=="string"?ns(t):t,a=Jr(s.pathname||"/",n);if(a==null)return null;let l=ym(e);vy(l);let o=null;for(let c=0;o==null&&c{let c={relativePath:o===void 0?a.path||"":o,caseSensitive:a.caseSensitive===!0,childrenIndex:l,route:a};c.relativePath.startsWith("/")&&(ye(c.relativePath.startsWith(r),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(r.length));let d=Cn([r,c.relativePath]),h=n.concat(c);a.children&&a.children.length>0&&(ye(a.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),ym(a.children,t,h,d)),!(a.path==null&&!a.index)&&t.push({path:d,score:Sy(d,a.index),routesMeta:h})};return e.forEach((a,l)=>{var o;if(a.path===""||!((o=a.path)!=null&&o.includes("?")))s(a,l);else for(let c of gm(a.path))s(a,l,c)}),t}function gm(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return s?[a,""]:[a];let l=gm(r.join("/")),o=[];return o.push(...l.map(c=>c===""?a:[a,c].join("/"))),s&&o.push(...l),o.map(c=>e.startsWith("/")&&c===""?"/":c)}function vy(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ny(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const xy=/^:[\w-]+$/,yy=3,gy=2,jy=1,wy=10,ky=-2,wd=e=>e==="*";function Sy(e,t){let n=e.split("/"),r=n.length;return n.some(wd)&&(r+=ky),t&&(r+=gy),n.filter(s=>!wd(s)).reduce((s,a)=>s+(xy.test(a)?yy:a===""?jy:wy),r)}function Ny(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function by(e,t,n){let{routesMeta:r}=e,s={},a="/",l=[];for(let o=0;o{let{paramName:p,isOptional:x}=h;if(p==="*"){let g=o[u]||"";l=a.slice(0,a.length-g.length).replace(/(.)\/+$/,"$1")}const k=o[u];return x&&!k?d[p]=void 0:d[p]=(k||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:l,pattern:e}}function Cy(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),$c(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,c)=>(r.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function _y(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return $c(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Jr(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const Ey=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Py=e=>Ey.test(e);function Ty(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?ns(e):e,a;if(n)if(Py(n))a=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),$c(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?a=kd(n.substring(1),"/"):a=kd(n,t)}else a=t;return{pathname:a,search:Ry(r),hash:My(s)}}function kd(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function jl(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Oy(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function jm(e,t){let n=Oy(e);return t?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function wm(e,t,n,r){r===void 0&&(r=!1);let s;typeof e=="string"?s=ns(e):(s=Gs({},e),ye(!s.pathname||!s.pathname.includes("?"),jl("?","pathname","search",s)),ye(!s.pathname||!s.pathname.includes("#"),jl("#","pathname","hash",s)),ye(!s.search||!s.search.includes("#"),jl("#","search","hash",s)));let a=e===""||s.pathname==="",l=a?"/":s.pathname,o;if(l==null)o=n;else{let u=t.length-1;if(!r&&l.startsWith("..")){let p=l.split("/");for(;p[0]==="..";)p.shift(),u-=1;s.pathname=p.join("/")}o=u>=0?t[u]:"/"}let c=Ty(s,o),d=l&&l!=="/"&&l.endsWith("/"),h=(a||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||h)&&(c.pathname+="/"),c}const Cn=e=>e.join("/").replace(/\/\/+/g,"/"),Ly=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Ry=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,My=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function zy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const km=["post","put","patch","delete"];new Set(km);const Fy=["get",...km];new Set(Fy);/** + * React Router v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Js(){return Js=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),w.useCallback(function(d,h){if(h===void 0&&(h={}),!o.current)return;if(typeof d=="number"){r.go(d);return}let u=wm(d,JSON.parse(l),a,h.relative==="path");e==null&&t!=="/"&&(u.pathname=u.pathname==="/"?t:Cn([t,u.pathname])),(h.replace?r.replace:r.push)(u,h.state,h)},[t,r,l,a,e])}const Ay=w.createContext(null);function $y(e){let t=w.useContext(Gt).outlet;return t&&w.createElement(Ay.Provider,{value:e},t)}function fa(){let{matches:e}=w.useContext(Gt),t=e[e.length-1];return t?t.params:{}}function Bi(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=w.useContext(Rn),{matches:s}=w.useContext(Gt),{pathname:a}=rs(),l=JSON.stringify(jm(s,r.v7_relativeSplatPath));return w.useMemo(()=>wm(e,JSON.parse(l),a,n==="path"),[e,l,a,n])}function Uy(e,t){return By(e,t)}function By(e,t,n,r){da()||ye(!1);let{navigator:s}=w.useContext(Rn),{matches:a}=w.useContext(Gt),l=a[a.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let d=rs(),h;if(t){var u;let S=typeof t=="string"?ns(t):t;c==="/"||(u=S.pathname)!=null&&u.startsWith(c)||ye(!1),h=S}else h=d;let p=h.pathname||"/",x=p;if(c!=="/"){let S=c.replace(/^\//,"").split("/");x="/"+p.replace(/^\//,"").split("/").slice(S.length).join("/")}let k=my(e,{pathname:x}),g=Wy(k&&k.map(S=>Object.assign({},S,{params:Object.assign({},o,S.params),pathname:Cn([c,s.encodeLocation?s.encodeLocation(S.pathname).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?c:Cn([c,s.encodeLocation?s.encodeLocation(S.pathnameBase).pathname:S.pathnameBase])})),a,n,r);return t&&g?w.createElement(Ui.Provider,{value:{location:Js({pathname:"/",search:"",hash:"",state:null,key:"default"},h),navigationType:mn.Pop}},g):g}function Qy(){let e=Yy(),t=zy(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return w.createElement(w.Fragment,null,w.createElement("h2",null,"Unexpected Application Error!"),w.createElement("h3",{style:{fontStyle:"italic"}},t),n?w.createElement("pre",{style:s},n):null,null)}const Vy=w.createElement(Qy,null);class Ky extends w.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?w.createElement(Gt.Provider,{value:this.props.routeContext},w.createElement(Nm.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Hy(e){let{routeContext:t,match:n,children:r}=e,s=w.useContext($i);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),w.createElement(Gt.Provider,{value:t},r)}function Wy(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var a;if(!n)return null;if(n.errors)e=n.matches;else if((a=r)!=null&&a.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(s=n)==null?void 0:s.errors;if(o!=null){let h=l.findIndex(u=>u.route.id&&(o==null?void 0:o[u.route.id])!==void 0);h>=0||ye(!1),l=l.slice(0,Math.min(l.length,h+1))}let c=!1,d=-1;if(n&&r&&r.v7_partialHydration)for(let h=0;h=0?l=l.slice(0,d+1):l=[l[0]];break}}}return l.reduceRight((h,u,p)=>{let x,k=!1,g=null,S=null;n&&(x=o&&u.route.id?o[u.route.id]:void 0,g=u.route.errorElement||Vy,c&&(d<0&&p===0?(Zy("route-fallback"),k=!0,S=null):d===p&&(k=!0,S=u.route.hydrateFallbackElement||null)));let m=t.concat(l.slice(0,p+1)),f=()=>{let v;return x?v=g:k?v=S:u.route.Component?v=w.createElement(u.route.Component,null):u.route.element?v=u.route.element:v=h,w.createElement(Hy,{match:u,routeContext:{outlet:h,matches:m,isDataRoute:n!=null},children:v})};return n&&(u.route.ErrorBoundary||u.route.errorElement||p===0)?w.createElement(Ky,{location:n.location,revalidation:n.revalidation,component:g,error:x,children:f(),routeContext:{outlet:null,matches:m,isDataRoute:!0}}):f()},null)}var Cm=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Cm||{}),_m=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(_m||{});function qy(e){let t=w.useContext($i);return t||ye(!1),t}function Gy(e){let t=w.useContext(Sm);return t||ye(!1),t}function Jy(e){let t=w.useContext(Gt);return t||ye(!1),t}function Em(e){let t=Jy(),n=t.matches[t.matches.length-1];return n.route.id||ye(!1),n.route.id}function Yy(){var e;let t=w.useContext(Nm),n=Gy(),r=Em();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function Xy(){let{router:e}=qy(Cm.UseNavigateStable),t=Em(_m.UseNavigateStable),n=w.useRef(!1);return bm(()=>{n.current=!0}),w.useCallback(function(s,a){a===void 0&&(a={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,Js({fromRouteId:t},a)))},[e,t])}const Sd={};function Zy(e,t,n){Sd[e]||(Sd[e]=!0)}function eg(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function tg(e){return $y(e.context)}function ht(e){ye(!1)}function ng(e){let{basename:t="/",children:n=null,location:r,navigationType:s=mn.Pop,navigator:a,static:l=!1,future:o}=e;da()&&ye(!1);let c=t.replace(/^\/*/,"/"),d=w.useMemo(()=>({basename:c,navigator:a,static:l,future:Js({v7_relativeSplatPath:!1},o)}),[c,o,a,l]);typeof r=="string"&&(r=ns(r));let{pathname:h="/",search:u="",hash:p="",state:x=null,key:k="default"}=r,g=w.useMemo(()=>{let S=Jr(h,c);return S==null?null:{location:{pathname:S,search:u,hash:p,state:x,key:k},navigationType:s}},[c,h,u,p,x,k,s]);return g==null?null:w.createElement(Rn.Provider,{value:d},w.createElement(Ui.Provider,{children:n,value:g}))}function rg(e){let{children:t,location:n}=e;return Uy(Mo(t),n)}new Promise(()=>{});function Mo(e,t){t===void 0&&(t=[]);let n=[];return w.Children.forEach(e,(r,s)=>{if(!w.isValidElement(r))return;let a=[...t,s];if(r.type===w.Fragment){n.push.apply(n,Mo(r.props.children,a));return}r.type!==ht&&ye(!1),!r.props.index||!r.props.children||ye(!1);let l={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Mo(r.props.children,a)),n.push(l)}),n}/** + * React Router DOM v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function ki(){return ki=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[s]=e[s]);return n}function sg(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ag(e,t){return e.button===0&&(!t||t==="_self")&&!sg(e)}const ig=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],lg=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],og="6";try{window.__reactRouterVersion=og}catch{}const cg=w.createContext({isTransitioning:!1}),ug="startTransition",Nd=xp[ug];function dg(e){let{basename:t,children:n,future:r,window:s}=e,a=w.useRef();a.current==null&&(a.current=dy({window:s,v5Compat:!0}));let l=a.current,[o,c]=w.useState({action:l.action,location:l.location}),{v7_startTransition:d}=r||{},h=w.useCallback(u=>{d&&Nd?Nd(()=>c(u)):c(u)},[c,d]);return w.useLayoutEffect(()=>l.listen(h),[l,h]),w.useEffect(()=>eg(r),[r]),w.createElement(ng,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const fg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",hg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Pn=w.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:a,replace:l,state:o,target:c,to:d,preventScrollReset:h,viewTransition:u}=t,p=Pm(t,ig),{basename:x}=w.useContext(Rn),k,g=!1;if(typeof d=="string"&&hg.test(d)&&(k=d,fg))try{let v=new URL(window.location.href),j=d.startsWith("//")?new URL(v.protocol+d):new URL(d),C=Jr(j.pathname,x);j.origin===v.origin&&C!=null?d=C+j.search+j.hash:g=!0}catch{}let S=Iy(d,{relative:s}),m=pg(d,{replace:l,state:o,target:c,preventScrollReset:h,relative:s,viewTransition:u});function f(v){r&&r(v),v.defaultPrevented||m(v)}return w.createElement("a",ki({},p,{href:k||S,onClick:g||a?r:f,ref:n,target:c}))}),Tm=w.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:s=!1,className:a="",end:l=!1,style:o,to:c,viewTransition:d,children:h}=t,u=Pm(t,lg),p=Bi(c,{relative:u.relative}),x=rs(),k=w.useContext(Sm),{navigator:g,basename:S}=w.useContext(Rn),m=k!=null&&vg(p)&&d===!0,f=g.encodeLocation?g.encodeLocation(p).pathname:p.pathname,v=x.pathname,j=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;s||(v=v.toLowerCase(),j=j?j.toLowerCase():null,f=f.toLowerCase()),j&&S&&(j=Jr(j,S)||j);const C=f!=="/"&&f.endsWith("/")?f.length-1:f.length;let b=v===f||!l&&v.startsWith(f)&&v.charAt(C)==="/",N=j!=null&&(j===f||!l&&j.startsWith(f)&&j.charAt(f.length)==="/"),_={isActive:b,isPending:N,isTransitioning:m},F=b?r:void 0,O;typeof a=="function"?O=a(_):O=[a,b?"active":null,N?"pending":null,m?"transitioning":null].filter(Boolean).join(" ");let B=typeof o=="function"?o(_):o;return w.createElement(Pn,ki({},u,{"aria-current":F,className:O,ref:n,style:B,to:c,viewTransition:d}),typeof h=="function"?h(_):h)});var zo;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(zo||(zo={}));var bd;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(bd||(bd={}));function mg(e){let t=w.useContext($i);return t||ye(!1),t}function pg(e,t){let{target:n,replace:r,state:s,preventScrollReset:a,relative:l,viewTransition:o}=t===void 0?{}:t,c=cr(),d=rs(),h=Bi(e,{relative:l});return w.useCallback(u=>{if(ag(u,n)){u.preventDefault();let p=r!==void 0?r:wi(d)===wi(h);c(e,{replace:p,state:s,preventScrollReset:a,relative:l,viewTransition:o})}},[d,c,h,r,s,n,e,a,l,o])}function vg(e,t){t===void 0&&(t={});let n=w.useContext(cg);n==null&&ye(!1);let{basename:r}=mg(zo.useViewTransitionState),s=Bi(e,{relative:t.relative});if(!n.isTransitioning)return!1;let a=Jr(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Jr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Ro(s.pathname,l)!=null||Ro(s.pathname,a)!=null}/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var xg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const yg=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),Q=(e,t)=>{const n=w.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:a=2,absoluteStrokeWidth:l,className:o="",children:c,...d},h)=>w.createElement("svg",{ref:h,...xg,width:s,height:s,stroke:r,strokeWidth:l?Number(a)*24/Number(s):a,className:["lucide",`lucide-${yg(e)}`,o].join(" "),...d},[...t.map(([u,p])=>w.createElement(u,p)),...Array.isArray(c)?c:[c]]));return n.displayName=`${e}`,n};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gg=Q("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Om=Q("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const jg=Q("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const wg=Q("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kg=Q("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lm=Q("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Sg=Q("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ng=Q("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ys=Q("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bg=Q("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cg=Q("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rm=Q("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _g=Q("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Eg=Q("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pg=Q("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cd=Q("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mm=Q("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Tg=Q("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Og=Q("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lg=Q("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rg=Q("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Uc=Q("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mg=Q("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zg=Q("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ha=Q("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zm=Q("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fg=Q("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ig=Q("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xs=Q("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bc=Q("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dg=Q("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ag=Q("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fm=Q("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Im=Q("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $g=Q("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _d=Q("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ug=Q("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bg=Q("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qc=Q("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dm=Q("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qg=Q("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Am=Q("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qi=Q("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),Vg={},Ed=e=>{let t;const n=new Set,r=(h,u)=>{const p=typeof h=="function"?h(t):h;if(!Object.is(p,t)){const x=t;t=u??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(k=>k(t,x))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>d,subscribe:h=>(n.add(h),()=>n.delete(h)),destroy:()=>{(Vg?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(r,s,c);return c},Kg=e=>e?Ed(e):Ed;var $m={exports:{}},Um={},Bm={exports:{}},Qm={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Yr=w;function Hg(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Wg=typeof Object.is=="function"?Object.is:Hg,qg=Yr.useState,Gg=Yr.useEffect,Jg=Yr.useLayoutEffect,Yg=Yr.useDebugValue;function Xg(e,t){var n=t(),r=qg({inst:{value:n,getSnapshot:t}}),s=r[0].inst,a=r[1];return Jg(function(){s.value=n,s.getSnapshot=t,wl(s)&&a({inst:s})},[e,n,t]),Gg(function(){return wl(s)&&a({inst:s}),e(function(){wl(s)&&a({inst:s})})},[e]),Yg(n),n}function wl(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Wg(e,n)}catch{return!0}}function Zg(e,t){return t()}var e0=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Zg:Xg;Qm.useSyncExternalStore=Yr.useSyncExternalStore!==void 0?Yr.useSyncExternalStore:e0;Bm.exports=Qm;var t0=Bm.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Vi=w,n0=t0;function r0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var s0=typeof Object.is=="function"?Object.is:r0,a0=n0.useSyncExternalStore,i0=Vi.useRef,l0=Vi.useEffect,o0=Vi.useMemo,c0=Vi.useDebugValue;Um.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var a=i0(null);if(a.current===null){var l={hasValue:!1,value:null};a.current=l}else l=a.current;a=o0(function(){function c(x){if(!d){if(d=!0,h=x,x=r(x),s!==void 0&&l.hasValue){var k=l.value;if(s(k,x))return u=k}return u=x}if(k=u,s0(h,x))return k;var g=r(x);return s!==void 0&&s(k,g)?(h=x,k):(h=x,u=g)}var d=!1,h,u,p=n===void 0?null:n;return[function(){return c(t())},p===null?void 0:function(){return c(p())}]},[t,n,r,s]);var o=a0(e,a[0],a[1]);return l0(function(){l.hasValue=!0,l.value=o},[o]),c0(o),o};$m.exports=Um;var u0=$m.exports;const d0=Wd(u0),Vm={},{useDebugValue:f0}=Vo,{useSyncExternalStoreWithSelector:h0}=d0;let Pd=!1;const m0=e=>e;function p0(e,t=m0,n){(Vm?"production":void 0)!=="production"&&n&&!Pd&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Pd=!0);const r=h0(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return f0(r),r}const Td=e=>{(Vm?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?Kg(e):e,n=(r,s)=>p0(t,r,s);return Object.assign(n,t),n},Ki=e=>e?Td(e):Td,Hi="/api",Vc="flow_auth_token",Kc="flow_auth_expires",Hc="flow_auth_username";function Zs(){const e=localStorage.getItem(Vc),t=localStorage.getItem(Kc);return!e||!t?null:new Date(t)<=new Date?(Yn(),null):e}function Od(e,t,n){localStorage.setItem(Vc,e),localStorage.setItem(Kc,t),localStorage.setItem(Hc,n)}function Yn(){localStorage.removeItem(Vc),localStorage.removeItem(Kc),localStorage.removeItem(Hc)}function Wc(){return localStorage.getItem(Hc)}let ir=null;function v0(e){ir=e}async function U(e,t,n=!1){const r={"Content-Type":"application/json",...t==null?void 0:t.headers};if(!n){const a=Zs();a&&(r.Authorization=`Bearer ${a}`)}const s=await fetch(`${Hi}${e}`,{...t,headers:r});if(s.status===401){Yn(),ir&&ir();const a=await s.json().catch(()=>({detail:"Not authenticated"}));throw new Error(a.detail||"Not authenticated")}if(!s.ok){const a=await s.json().catch(()=>({detail:s.statusText}));throw new Error(a.detail||"API request failed")}if(s.status!==204)return s.json()}const dr={getConfig:()=>U("/auth/config",void 0,!0),login:e=>U("/auth/login",{method:"POST",body:JSON.stringify(e)},!0),getGitHubAuthUrl:()=>`${Hi}/auth/github`,getCurrentUser:()=>U("/auth/me"),logout:()=>U("/auth/logout",{method:"POST"})},Xn={list:e=>{const t=new URLSearchParams;e!=null&&e.include_auto_generated&&t.set("include_auto_generated","true"),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return U(`/configs${n?`?${n}`:""}`)},get:e=>U(`/configs/${e}`),create:e=>U("/configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/configs/${e}`,{method:"DELETE"})},Et={list:e=>{const t=new URLSearchParams;e!=null&&e.category&&t.set("category",e.category),e!=null&&e.suite&&t.set("suite",e.suite);const n=t.toString();return U(`/tasks${n?`?${n}`:""}`)},get:e=>U(`/tasks/${e}`),create:e=>U("/tasks",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/tasks/${e}`,{method:"DELETE"}),listSuites:()=>U("/tasks/suites"),importSuite:e=>U(`/tasks/import-suite?suite_name=${encodeURIComponent(e)}`,{method:"POST"})},Ut={list:e=>{const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return U(`/jobs${n?`?${n}`:""}`)},get:e=>U(`/jobs/${e}`),create:e=>U("/jobs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/jobs/${e}`,{method:"PUT",body:JSON.stringify(t)}),start:async function*(e){var o;const t={},n=Zs();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Hi}/jobs/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Yn(),ir&&ir(),new Error("Not authenticated");if(!r.ok)throw new Error("Failed to start job");const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const a=new TextDecoder;let l="";for(;;){const{done:c,value:d}=await s.read();if(c)break;l+=a.decode(d,{stream:!0});const h=l.split(` +`);l=h.pop()||"";for(const u of h)u.startsWith("data: ")&&(yield JSON.parse(u.slice(6)))}},cancel:e=>U(`/jobs/${e}/cancel`,{method:"POST"}),delete:e=>U(`/jobs/${e}`,{method:"DELETE"})},Fo={list:e=>{const t=new URLSearchParams;e!=null&&e.job_id&&t.set("job_id",e.job_id),e!=null&&e.candidate_name&&t.set("candidate_name",e.candidate_name),e!=null&&e.task_name&&t.set("task_name",e.task_name),(e==null?void 0:e.is_pareto)!==void 0&&t.set("is_pareto",String(e.is_pareto));const n=t.toString();return U(`/runs${n?`?${n}`:""}`)},get:e=>U(`/runs/${e}`),getJobSummary:e=>U(`/runs/job/${e}/summary`)},Ts={list:e=>{const t=new URLSearchParams;e!=null&&e.agent_id&&t.set("agent_id",e.agent_id),e!=null&&e.limit&&t.set("limit",String(e.limit));const n=t.toString();return U(`/tests${n?`?${n}`:""}`)},get:e=>U(`/tests/${e}`),create:e=>U("/tests",{method:"POST",body:JSON.stringify(e)}),start:async function*(e){var o;const t={},n=Zs();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Hi}/tests/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Yn(),ir&&ir(),new Error("Not authenticated");if(!r.ok){const c=await r.json().catch(()=>({detail:"Failed to start test"}));throw new Error(c.detail||"Failed to start test")}const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const a=new TextDecoder;let l="";for(;;){const{done:c,value:d}=await s.read();if(c)break;l+=a.decode(d,{stream:!0});const h=l.split(` +`);l=h.pop()||"";for(const u of h)u.startsWith("data: ")&&(yield JSON.parse(u.slice(6)))}},cancel:e=>U(`/tests/${e}/cancel`,{method:"POST"}),delete:e=>U(`/tests/${e}`,{method:"DELETE"})},x0={list:()=>U("/llm-configs"),get:e=>U(`/llm-configs/${e}`),getDefault:()=>U("/llm-configs/default"),create:e=>U("/llm-configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/llm-configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/llm-configs/${e}`,{method:"DELETE"}),setDefault:e=>U(`/llm-configs/${e}/set-default`,{method:"POST"}),test:e=>U(`/llm-configs/${e}/test`,{method:"POST"})},y0={list:()=>U("/tools"),get:e=>U(`/tools/${e}`)},Km={getAgentSchema:()=>U("/schema/agent")},g0={list:()=>U("/deployments"),get:e=>U(`/deployments/${e}`),delete:e=>U(`/deployments/${e}`,{method:"DELETE"})},j0={start:e=>U("/evaluate",{method:"POST",body:JSON.stringify(e)})},Io={design:e=>U("/experiment/design",{method:"POST",body:JSON.stringify(e)}),importYaml:e=>U("/experiment/import-yaml",{method:"POST",body:JSON.stringify(e)}),validate:e=>U("/experiment/validate",{method:"POST",body:JSON.stringify(e)}),generateCandidates:e=>U("/experiment/generate-candidates",{method:"POST",body:JSON.stringify(e)})},qc=Ki((e,t)=>(v0(()=>{e({isAuthenticated:!1,user:null,error:"Session expired. Please log in again."})}),{authConfig:null,isLoadingConfig:!0,isAuthenticated:!1,isLoading:!1,user:null,error:null,loadAuthConfig:async()=>{e({isLoadingConfig:!0});try{const n=await dr.getConfig();if(e({authConfig:n,isLoadingConfig:!1}),n.enabled){const r=Zs(),s=Wc();if(r&&s)try{const a=await dr.getCurrentUser();e({isAuthenticated:!0,user:a})}catch{Yn(),e({isAuthenticated:!1,user:null})}}else e({isAuthenticated:!0,user:{username:"anonymous",auth_mode:"none"}})}catch(n){console.error("Failed to load auth config:",n),e({isLoadingConfig:!1,error:"Failed to connect to server"})}},login:async(n,r)=>{e({isLoading:!0,error:null});try{const s=await dr.login({username:n,password:r});return Od(s.access_token,s.expires_at,s.username),e({isAuthenticated:!0,isLoading:!1,user:{username:s.username,auth_mode:"basic"}}),!0}catch(s){return e({isLoading:!1,error:s instanceof Error?s.message:"Login failed"}),!1}},loginWithGitHub:()=>{window.location.href=dr.getGitHubAuthUrl()},handleOAuthCallback:()=>{const n=new URLSearchParams(window.location.search),r=n.get("auth_error");if(r)return e({error:r}),window.history.replaceState({},"",window.location.pathname),!0;if(n.get("auth_callback")==="true"){const s=n.get("token"),a=n.get("expires_at"),l=n.get("username");return s&&a&&l&&(Od(s,a,l),e({isAuthenticated:!0,user:{username:l,auth_mode:"github"}})),window.history.replaceState({},"",window.location.pathname),!0}return!1},logout:async()=>{try{await dr.logout()}catch{}Yn(),e({isAuthenticated:!1,user:null,error:null})},checkAuth:async()=>{const{authConfig:n}=t();if(!(n!=null&&n.enabled)){e({isAuthenticated:!0});return}if(!Zs()){e({isAuthenticated:!1,user:null});return}try{const s=await dr.getCurrentUser();e({isAuthenticated:!0,user:s})}catch{Yn(),e({isAuthenticated:!1,user:null})}},clearError:()=>e({error:null})}));function K({variant:e="secondary",size:t="md",className:n="",icon:r,iconRight:s,loading:a=!1,children:l,disabled:o,...c}){const d="font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1.5 rounded-md",h={primary:"bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)]",secondary:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)] hover:bg-[var(--border)]",danger:"bg-[var(--error)] text-white hover:bg-red-600",ghost:"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"},u={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm"},p=t==="sm"?14:16;return i.jsxs("button",{className:`${d} ${h[e]} ${u[t]} ${n}`,disabled:o||a,...c,children:[a?i.jsx(ha,{size:p,className:"animate-spin"}):r?i.jsx(r,{size:p}):null,l,s&&!a&&i.jsx(s,{size:p})]})}const w0={};function k0(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var a;const l=c=>c===null?null:JSON.parse(c,void 0),o=(a=n.getItem(s))!=null?a:null;return o instanceof Promise?o.then(l):l(o)},setItem:(s,a)=>n.setItem(s,JSON.stringify(a,void 0)),removeItem:s=>n.removeItem(s)}}const ea=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return ea(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return ea(r)(n)}}}},S0=(e,t)=>(n,r,s)=>{let a={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:S=>S,version:0,merge:(S,m)=>({...m,...S}),...t},l=!1;const o=new Set,c=new Set;let d;try{d=a.getStorage()}catch{}if(!d)return e((...S)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...S)},r,s);const h=ea(a.serialize),u=()=>{const S=a.partialize({...r()});let m;const f=h({state:S,version:a.version}).then(v=>d.setItem(a.name,v)).catch(v=>{m=v});if(m)throw m;return f},p=s.setState;s.setState=(S,m)=>{p(S,m),u()};const x=e((...S)=>{n(...S),u()},r,s);let k;const g=()=>{var S;if(!d)return;l=!1,o.forEach(f=>f(r()));const m=((S=a.onRehydrateStorage)==null?void 0:S.call(a,r()))||void 0;return ea(d.getItem.bind(d))(a.name).then(f=>{if(f)return a.deserialize(f)}).then(f=>{if(f)if(typeof f.version=="number"&&f.version!==a.version){if(a.migrate)return a.migrate(f.state,f.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return f.state}).then(f=>{var v;return k=a.merge(f,(v=r())!=null?v:x),n(k,!0),u()}).then(()=>{m==null||m(k,void 0),l=!0,c.forEach(f=>f(k))}).catch(f=>{m==null||m(void 0,f)})};return s.persist={setOptions:S=>{a={...a,...S},S.getStorage&&(d=S.getStorage())},clearStorage:()=>{d==null||d.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>g(),hasHydrated:()=>l,onHydrate:S=>(o.add(S),()=>{o.delete(S)}),onFinishHydration:S=>(c.add(S),()=>{c.delete(S)})},g(),k||x},N0=(e,t)=>(n,r,s)=>{let a={storage:k0(()=>localStorage),partialize:g=>g,version:0,merge:(g,S)=>({...S,...g}),...t},l=!1;const o=new Set,c=new Set;let d=a.storage;if(!d)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...g)},r,s);const h=()=>{const g=a.partialize({...r()});return d.setItem(a.name,{state:g,version:a.version})},u=s.setState;s.setState=(g,S)=>{u(g,S),h()};const p=e((...g)=>{n(...g),h()},r,s);s.getInitialState=()=>p;let x;const k=()=>{var g,S;if(!d)return;l=!1,o.forEach(f=>{var v;return f((v=r())!=null?v:p)});const m=((S=a.onRehydrateStorage)==null?void 0:S.call(a,(g=r())!=null?g:p))||void 0;return ea(d.getItem.bind(d))(a.name).then(f=>{if(f)if(typeof f.version=="number"&&f.version!==a.version){if(a.migrate)return[!0,a.migrate(f.state,f.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,f.state];return[!1,void 0]}).then(f=>{var v;const[j,C]=f;if(x=a.merge(C,(v=r())!=null?v:p),n(x,!0),j)return h()}).then(()=>{m==null||m(x,void 0),x=r(),l=!0,c.forEach(f=>f(x))}).catch(f=>{m==null||m(void 0,f)})};return s.persist={setOptions:g=>{a={...a,...g},g.storage&&(d=g.storage)},clearStorage:()=>{d==null||d.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>k(),hasHydrated:()=>l,onHydrate:g=>(o.add(g),()=>{o.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},a.skipHydration||k(),x||p},b0=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((w0?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),S0(e,t)):N0(e,t),Hm=b0,C0=Ki()(Hm((e,t)=>({theme:"light",setTheme:n=>{document.documentElement.setAttribute("data-theme",n),e({theme:n})},toggleTheme:()=>{const n=t().theme==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",n),e({theme:n})}}),{name:"flow-theme",onRehydrateStorage:()=>e=>{e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}}));function _0(){const{theme:e,toggleTheme:t}=C0();return i.jsx("button",{onClick:t,className:"p-2 rounded-md text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--accent)]","aria-label":`Switch to ${e==="dark"?"light":"dark"} mode`,title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:e==="dark"?i.jsx(Ug,{size:16}):i.jsx(Ig,{size:16})})}const E0=Ki()(Hm((e,t)=>({sidebarCollapsed:!1,toggleSidebar:()=>{e({sidebarCollapsed:!t().sidebarCollapsed})},setSidebarCollapsed:n=>{e({sidebarCollapsed:n})}}),{name:"flow-layout"})),P0=[{path:"/agents",label:"Agents",icon:kg},{path:"/jobs",label:"Experiments",icon:Tg},{path:"/tasks",label:"Datasets",icon:Pg}];function T0(){const e=rs(),{sidebarCollapsed:t,toggleSidebar:n}=E0(),r=s=>s==="/agents"?e.pathname==="/"||e.pathname==="/agents"||e.pathname.startsWith("/agents/")||e.pathname.startsWith("/deployments/"):s==="/jobs"?e.pathname.startsWith("/jobs")||e.pathname.startsWith("/runs"):e.pathname.startsWith(s);return i.jsxs("aside",{className:` + flex flex-col border-r border-[var(--border)] bg-[var(--bg-secondary)] + transition-all duration-200 + ${t?"w-14":"w-56"} + `,children:[i.jsx("nav",{className:"flex-1 py-2",children:P0.map(s=>{const a=r(s.path);return i.jsxs(Tm,{to:s.path,title:t?s.label:void 0,className:` + flex items-center gap-3 px-4 py-2.5 text-sm transition-colors relative + ${a?"text-[var(--accent)] bg-[var(--accent-dim)] font-medium":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"} + `,children:[a&&i.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-r bg-[var(--accent)]"}),i.jsx(s.icon,{size:18}),!t&&i.jsx("span",{children:s.label})]},s.path)})}),i.jsx("button",{onClick:n,className:"flex items-center justify-center p-3 border-t border-[var(--border)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",title:t?"Expand sidebar":"Collapse sidebar",children:t?i.jsx(Cg,{size:16}):i.jsx(bg,{size:16})})]})}function O0(){const{authConfig:e,user:t,logout:n}=qc(),r=async()=>{await n()};return i.jsxs("div",{className:"h-screen flex flex-col",children:[i.jsx("header",{className:"border-b border-[var(--border)] bg-[var(--bg-secondary)] shrink-0",children:i.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between",children:[i.jsxs(Tm,{to:"/",className:"text-lg font-semibold text-[var(--accent)] flex items-center gap-2 hover:opacity-80",children:[i.jsx(Qi,{size:20}),"Flow",i.jsx("span",{className:"text-[var(--text-secondary)] font-normal",children:"/optimize"})]}),i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(_0,{}),(e==null?void 0:e.enabled)&&t&&i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[i.jsx(Dm,{size:14}),i.jsx("span",{children:t.username})]}),i.jsx(K,{variant:"ghost",size:"sm",icon:Fg,onClick:r,title:"Sign out",children:"Sign out"})]})]})]})}),i.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[i.jsx(T0,{}),i.jsx("main",{className:"flex-1 overflow-y-auto bg-[var(--bg-primary)]",children:i.jsx("div",{className:"p-6",children:i.jsx(tg,{})})})]})]})}const L0=["maf","miniagent","langgraph"],R0={maf:"Microsoft Agent Framework",miniagent:"MiniAgent",langgraph:"LangGraph"},M0={openai:"OpenAI",azure_openai:"Azure OpenAI",anthropic:"Anthropic",ollama:"Ollama",custom:"Custom (OpenAI-compatible)"};function J({children:e,variant:t="default"}){const n={default:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)]",success:"bg-[var(--badge-success-bg)] text-[var(--badge-success-text)] border border-[var(--badge-success-border)]",warning:"bg-[var(--badge-warning-bg)] text-[var(--badge-warning-text)] border border-[var(--badge-warning-border)]",error:"bg-[var(--badge-error-bg)] text-[var(--badge-error-text)] border border-[var(--badge-error-border)]",info:"bg-[var(--badge-info-bg)] text-[var(--badge-info-text)] border border-[var(--badge-info-border)]"};return i.jsx("span",{className:`inline-block px-2 py-0.5 text-xs font-medium rounded-md ${n[t]}`,children:e})}const z0={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"};function ss({isOpen:e,onClose:t,title:n,children:r,footer:s,size:a="md"}){return w.useEffect(()=>{const l=o=>{o.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",l),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",l),document.body.style.overflow=""}},[e,t]),e?i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[i.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),i.jsxs("div",{className:`relative bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg ${z0[a]} w-full mx-4 max-h-[80vh] flex flex-col`,children:[i.jsxs("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-b border-[var(--border)] px-4 py-3 flex items-center justify-between",children:[i.jsx("h2",{className:"font-semibold",children:n}),i.jsx("button",{onClick:t,className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"×"})]}),i.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r}),s&&i.jsx("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-t border-[var(--border)] px-4 py-3",children:s})]})]}):null}function pn({label:e,className:t="",...n}){return i.jsxs("div",{className:"space-y-1",children:[e&&i.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),i.jsx("input",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] ${t}`,...n})]})}function F0({label:e,className:t="",...n}){return i.jsxs("div",{className:"space-y-1",children:[e&&i.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),i.jsx("textarea",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] resize-y min-h-[100px] ${t}`,...n})]})}function Si({label:e,className:t="",...n}){return i.jsxs("label",{className:`flex items-center gap-2 cursor-pointer ${t}`,children:[i.jsx("input",{type:"checkbox",className:"w-4 h-4 bg-[var(--bg-primary)] border border-[var(--border)] rounded accent-[var(--accent)]",...n}),i.jsx("span",{className:"text-sm",children:e})]})}function Wm({columns:e,data:t,onRowClick:n,searchable:r=!1,searchPlaceholder:s="Search...",searchFilter:a,emptyMessage:l="No items found",emptyIcon:o}){const[c,d]=w.useState(""),[h,u]=w.useState(null),[p,x]=w.useState("asc"),k=w.useMemo(()=>{let S=t;if(r&&c&&a&&(S=S.filter(m=>a(m,c))),h){const m=e.find(f=>f.key===h);m!=null&&m.sortValue&&(S=[...S].sort((f,v)=>{const j=m.sortValue(f),C=m.sortValue(v),b=jC?1:0;return p==="asc"?b:-b}))}return S},[t,c,a,r,h,p,e]),g=S=>{const m=e.find(f=>f.key===S);m!=null&&m.sortable&&(h===S?x(p==="asc"?"desc":"asc"):(u(S),x("asc")))};return i.jsxs("div",{children:[r&&i.jsxs("div",{className:"mb-4 relative max-w-sm",children:[i.jsx(Ag,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]"}),i.jsx("input",{type:"text",placeholder:s,value:c,onChange:S=>d(S.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md pl-9 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]"})]}),k.length===0?i.jsxs("div",{className:"text-center py-16 text-[var(--text-secondary)]",children:[o&&i.jsx("div",{className:"mb-3 flex justify-center",children:o}),i.jsx("p",{children:l})]}):i.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsx("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:e.map(S=>i.jsx("th",{onClick:()=>g(S.key),className:`text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider ${S.sortable?"cursor-pointer hover:text-[var(--text-primary)]":""} ${S.className||""}`,children:i.jsxs("span",{className:"inline-flex items-center gap-1",children:[S.header,S.sortable&&h===S.key&&i.jsx("span",{children:p==="asc"?"↑":"↓"})]})},S.key))})}),i.jsx("tbody",{children:k.map((S,m)=>i.jsx("tr",{onClick:()=>n==null?void 0:n(S),className:`border-b border-[var(--border)] last:border-b-0 transition-colors ${n?"cursor-pointer hover:bg-[var(--bg-tertiary)]":""}`,children:e.map(f=>i.jsx("td",{className:`px-4 py-3 ${f.className||""}`,children:f.render(S)},f.key))},m))})]})})]})}function I0({variations:e,onChange:t,strategies:n,availableStrategies:r}){const s=r??Object.keys(n),a=()=>{const d=e.map(x=>x.strategy),h=s.find(x=>!d.includes(x))||"none",u=n[h],p={strategy:h};if(u!=null&&u.params)for(const[x,k]of Object.entries(u.params))k.default!==void 0&&(p[x]=k.default);t([...e,p])},l=d=>{t(e.filter((h,u)=>u!==d))},o=(d,h)=>{t(e.map((u,p)=>p===d?{...u,...h}:u))},c=(d,h)=>{const u=n[h],p={strategy:h};if(u!=null&&u.params)for(const[x,k]of Object.entries(u.params))k.default!==void 0&&(p[x]=k.default);o(d,p)};return i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"text-sm font-medium",children:"Compaction Strategies"}),i.jsx(K,{type:"button",variant:"ghost",size:"sm",icon:Bc,onClick:a,disabled:e.length>=s.length,children:"Add"})]}),e.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:'No compaction variations. Click "Add" to test different strategies.'}):i.jsx("div",{className:"space-y-2",children:e.map((d,h)=>{const u=n[d.strategy];return i.jsx("div",{className:"p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsxs("div",{className:"flex-1 space-y-2",children:[i.jsx("select",{className:"w-full px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:d.strategy,onChange:p=>c(h,p.target.value),children:s.map(p=>{var x;return i.jsx("option",{value:p,children:((x=n[p])==null?void 0:x.label)||p},p)})}),(u==null?void 0:u.description)&&i.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:u.description}),(u==null?void 0:u.params)&&Object.keys(u.params).length>0&&i.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:Object.entries(u.params).map(([p,x])=>i.jsx(D0,{name:p,schema:x,value:d[p],onChange:k=>o(h,{[p]:k})},p))})]}),i.jsx("button",{type:"button",onClick:()=>l(h),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:i.jsx(Am,{size:16})})]})},h)})})]})}function D0({name:e,schema:t,value:n,onChange:r}){const s=e.replace(/_/g," ");return t.type==="boolean"?i.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[i.jsx("input",{type:"checkbox",checked:!!(n??t.default),onChange:a=>r(a.target.checked),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"capitalize",children:s})]}):i.jsxs("div",{children:[i.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:s}),i.jsx("input",{type:t.type==="number"?"number":"text",className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-xs",value:String(n!==void 0?n:t.default??""),onChange:a=>{if(t.type==="number"){const l=parseFloat(a.target.value);r(isNaN(l)?t.default:l)}else r(a.target.value)},min:t.min,max:t.max,step:t.max&&t.max<=1?.1:1})]})}function A0({variations:e,onChange:t,providers:n}){const r=()=>{const o=n[0],c={provider:(o==null?void 0:o.name)||"azure_openai",model:(o==null?void 0:o.models[0])||"gpt-4o"};t([...e,c])},s=o=>{t(e.filter((c,d)=>d!==o))},a=(o,c)=>{t(e.map((d,h)=>h===o?{...d,...c}:d))},l=(o,c)=>{const d=n.find(h=>h.name===c);a(o,{provider:c,model:(d==null?void 0:d.models[0])||""})};return i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"text-sm font-medium",children:"LLM Configurations"}),i.jsx(K,{type:"button",variant:"ghost",size:"sm",icon:Bc,onClick:r,children:"Add"})]}),e.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:`Uses agent's default LLM. Click "Add" to test different models.`}):i.jsx("div",{className:"space-y-2",children:e.map((o,c)=>{const d=n.find(h=>h.name===o.provider);return i.jsxs("div",{className:"flex items-center gap-2 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[i.jsx("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.provider,onChange:h=>l(c,h.target.value),children:n.map(h=>i.jsx("option",{value:h.name,children:h.label},h.name))}),d&&d.models.length>0?i.jsxs("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:h=>a(c,{model:h.target.value}),children:[d.models.map(h=>i.jsx("option",{value:h,children:h},h)),!d.models.includes(o.model)&&o.model&&i.jsx("option",{value:o.model,children:o.model})]}):i.jsx("input",{type:"text",className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:h=>a(c,{model:h.target.value}),placeholder:"Model ID"}),i.jsx("button",{type:"button",onClick:()=>s(c),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:i.jsx(Am,{size:16})})]},c)})})]})}const Do={compaction:[],tools:[],llm_config:[],instructions:[],instruction_strategies:[]};function $0({agentId:e,agentName:t,agentFramework:n="maf",taskSuite:r,taskCount:s,schema:a,onVariationsChange:l,parallel:o,onParallelChange:c,budget:d,onBudgetChange:h,useLlmEval:u,onUseLlmEvalChange:p}){const[x,k]=w.useState(Do),[g,S]=w.useState(!1),[m,f]=w.useState(""),[v,j]=w.useState(null),C=a.frameworks[n],b=(C==null?void 0:C.compaction_strategies)||Object.keys(a.compaction_strategies),N=a.tool_presets||[],_=a.llm_providers||[],O=(()=>{let L=1;x.compaction.length>0&&(L*=x.compaction.length),x.tools.length>0&&(L*=x.tools.length),x.llm_config.length>0&&(L*=x.llm_config.length);const V=x.instructions.length+x.instruction_strategies.reduce((ee,R)=>ee+R.max_candidates,0);return V>0&&(L*=V),Math.min(L,d)})(),B=O*s,G=L=>{k(L),l==null||l(L)},re=Je({mutationFn:L=>Io.design(L),onSuccess:L=>{f(L.yaml_content),S(!0)}}),me=Je({mutationFn:L=>Io.validate(L),onSuccess:L=>{j({valid:L.valid,errors:L.errors,warnings:L.warnings})}}),D=()=>({base_agent_id:e,task_suite:r,variations:x,parallel:o,budget:d,use_llm_eval:u}),q=()=>{re.mutate(D())},X=()=>{me.mutate(D())},P=()=>{const L=new Blob([m],{type:"text/yaml"}),V=URL.createObjectURL(L),ee=document.createElement("a");ee.href=V,ee.download=`${t}_experiment.yaml`,ee.click(),URL.revokeObjectURL(V)},A=x.compaction.length>0||x.tools.length>0||x.llm_config.length>0||x.instructions.length>0||x.instruction_strategies.length>0;return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex flex-wrap gap-2",children:[i.jsxs(J,{variant:"info",children:[O," candidates"]}),i.jsxs(J,{children:[s," tasks"]}),i.jsxs(J,{variant:B>100?"warning":"success",children:[B," total runs"]})]}),i.jsx(I0,{variations:x.compaction,onChange:L=>G({...x,compaction:L}),strategies:a.compaction_strategies,availableStrategies:b}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("label",{className:"text-sm font-medium",children:"Tool Presets"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(L=>i.jsxs("label",{className:`flex items-center gap-2 px-3 py-1.5 border rounded cursor-pointer transition-colors ${x.tools.includes(L.name)?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[i.jsx("input",{type:"checkbox",checked:x.tools.includes(L.name),onChange:V=>{const ee=V.target.checked?[...x.tools,L.name]:x.tools.filter(R=>R!==L.name);G({...x,tools:ee})},className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:L.name}),i.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",L.tools.length,")"]})]},L.name))}),x.tools.length>0&&i.jsxs("p",{className:"text-xs text-[var(--text-secondary)]",children:["Selected: ",x.tools.join(", ")]})]}),i.jsx(A0,{variations:x.llm_config,onChange:L=>G({...x,llm_config:L}),providers:_}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-4 space-y-4",children:[i.jsx("h4",{className:"text-sm font-medium",children:"Execution Settings"}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(pn,{label:"Parallel Workers",type:"number",value:o,onChange:L=>c(parseInt(L.target.value)||1),min:1,max:16}),i.jsx(pn,{label:"Budget (max candidates)",type:"number",value:d,onChange:L=>h(parseInt(L.target.value)||100),min:1,max:1e3})]}),i.jsx(Si,{label:"Use LLM evaluation",checked:u,onChange:L=>p(L.target.checked)}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] ml-6 -mt-2",children:u?"LLM-as-Judge scores task completion (0-1)":"Simple pass/fail based on task success"})]}),i.jsxs("div",{className:"flex items-center gap-2 border-t border-[var(--border)] pt-4",children:[i.jsx(K,{variant:"secondary",size:"sm",onClick:X,loading:me.isPending,children:"Validate"}),i.jsx(K,{variant:"secondary",size:"sm",icon:Cd,onClick:q,loading:re.isPending,children:"Export YAML"})]}),v&&i.jsxs("div",{className:`p-3 rounded border ${v.valid?"border-green-500/50 bg-green-500/10":"border-red-500/50 bg-red-500/10"}`,children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[v.valid?i.jsx(Lm,{size:16,className:"text-green-500"}):i.jsx(Om,{size:16,className:"text-red-500"}),i.jsx("span",{className:"font-medium text-sm",children:v.valid?"Configuration valid":"Configuration has issues"})]}),v.errors.length>0&&i.jsx("ul",{className:"text-sm text-red-500 list-disc ml-6",children:v.errors.map((L,V)=>i.jsx("li",{children:L},V))}),v.warnings.length>0&&i.jsx("ul",{className:"text-sm text-yellow-500 list-disc ml-6 mt-1",children:v.warnings.map((L,V)=>i.jsx("li",{children:L},V))})]}),g&&i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-lg shadow-xl max-w-2xl w-full max-h-[80vh] flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border)]",children:[i.jsx("h3",{className:"font-medium",children:"Experiment YAML"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(K,{variant:"secondary",size:"sm",icon:Cd,onClick:P,children:"Download"}),i.jsx(K,{variant:"ghost",size:"sm",onClick:()=>S(!1),children:"Close"})]})]}),i.jsx("pre",{className:"flex-1 overflow-auto p-4 text-xs font-mono bg-[var(--bg-secondary)]",children:m})]})}),!A&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No variations selected. Only the baseline agent will be tested. Add compaction strategies, tool presets, or LLM configs to generate candidates."})]})}function Ld(){const e=cr(),t=qt(),[n,r]=w.useState(!1),[s,a]=w.useState(null),{data:l=[],isLoading:o}=fe({queryKey:["configs"],queryFn:()=>Xn.list()}),c=Je({mutationFn:Xn.create,onSuccess:()=>{t.invalidateQueries({queryKey:["configs"]}),r(!1)}}),d=Je({mutationFn:Xn.delete,onSuccess:()=>t.invalidateQueries({queryKey:["configs"]})}),h=[{key:"name",header:"Name",render:u=>i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:u.name})},{key:"framework",header:"Framework",render:u=>i.jsx(J,{children:u.config.framework||"maf"})},{key:"tools",header:"Tools",render:u=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:U0(u.config.tools)})},{key:"compaction",header:"Compaction",render:u=>{const p=u.config.compaction;return!p||p.strategy==="none"?i.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"}):p.strategy==="head_tail"?i.jsxs(J,{children:[p.params.head_size,"/",p.params.tail_size]}):i.jsx(J,{children:p.strategy})}},{key:"created",header:"Created",render:u=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(u.created_at).toLocaleDateString()}),sortable:!0,sortValue:u=>new Date(u.created_at).getTime()},{key:"actions",header:"",className:"w-24",render:u=>i.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[i.jsx(K,{variant:"ghost",size:"sm",icon:Qi,title:"Optimize",onClick:()=>a(u)}),i.jsx(K,{variant:"ghost",size:"sm",icon:Qc,title:"Delete",onClick:()=>{confirm(`Delete agent "${u.name}"?`)&&d.mutate(u.id)}})]})}];return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Agents"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Define and optimize your agent configurations."})]}),i.jsx(K,{variant:"primary",icon:Bc,onClick:()=>r(!0),children:"Create agent"})]}),o?i.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[i.jsx(ha,{size:16,className:"animate-spin"}),"Loading agents..."]}):i.jsx(Wm,{columns:h,data:l,onRowClick:u=>e(`/agents/${u.id}`),searchable:!0,searchPlaceholder:"Search agents",searchFilter:(u,p)=>u.name.toLowerCase().includes(p.toLowerCase())||(u.description||"").toLowerCase().includes(p.toLowerCase()),emptyMessage:"No agents yet. Create your first agent to start optimizing.",emptyIcon:i.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-[var(--bg-tertiary)]",children:i.jsx(Im,{size:24,className:"text-[var(--text-secondary)]"})})}),i.jsx(B0,{isOpen:n,onClose:()=>r(!1),onSubmit:u=>c.mutate(u),isLoading:c.isPending}),s&&i.jsx(Q0,{agent:s,isOpen:!!s,onClose:()=>a(null)})]})}function U0(e){return typeof e=="string"?e:Array.isArray(e)?`[${e.length}]`:e&&typeof e=="object"?`[${Object.keys(e).length}]`:"standard"}function B0({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){var V,ee,R,T,te,pe,be;const s=["read_file","write_file","edit_file","bash","grep","think"],[a,l]=w.useState("preset"),[o,c]=w.useState({name:"",description:"",instructions:null,model:null,compaction:{strategy:"none",params:{}},tools:s,framework:"miniagent",llm_config_id:null}),[d,h]=w.useState(!1),[u,p]=w.useState("preset"),[x,k]=w.useState([...s]),[g,S]=w.useState(!1),{data:m}=fe({queryKey:["agent-schema"],queryFn:()=>Km.getAgentSchema()}),{data:f=[]}=fe({queryKey:["llm-configs"],queryFn:()=>x0.list()}),{data:v}=fe({queryKey:["tools"],queryFn:()=>y0.list()}),j=((V=v==null?void 0:v.tools)==null?void 0:V.map(M=>M.name))??s,C=(v==null?void 0:v.presets)??{},b=Object.keys(C),N=(m==null?void 0:m.frameworks)??{},_=Object.keys(N).length>0?Object.keys(N):L0,F=o.framework||"miniagent",O=((R=(ee=m==null?void 0:m.frameworks)==null?void 0:ee[F])==null?void 0:R.compaction_strategies)??["none","head_tail"],B=(m==null?void 0:m.compaction_strategies)??{},G=(m==null?void 0:m.agent_presets)??[],re=M=>{const H=M.config,dt=H.compaction;n({name:M.name+"-agent",description:M.description,framework:H.framework||"miniagent",tools:H.tools||"standard",compaction:dt||{strategy:"none",params:{}},instructions:H.instructions||null})},me=M=>{if(M.preventDefault(),!o.name.trim())return;const H={...o};u==="custom"&&(H.tools=x),n(H)},D=((T=o.compaction)==null?void 0:T.strategy)!=="none",q=((te=o.compaction)==null?void 0:te.strategy)||"none",X=B[q],P=M=>{k(H=>H.includes(M)?H.filter(dt=>dt!==M):[...H,M])},A=M=>{const H=B[M],dt={};if(H!=null&&H.params)for(const[as,is]of Object.entries(H.params))is.default!==void 0&&(dt[as]=is.default);c({...o,compaction:{strategy:M,params:dt}})},L=a==="custom"?i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(K,{type:"submit",form:"create-agent-form",variant:"primary",disabled:!o.name.trim(),loading:r,children:"Create Agent"})]}):i.jsx("div",{className:"flex justify-end gap-2",children:i.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"})});return i.jsxs(ss,{isOpen:e,onClose:t,title:"Create Agent",footer:L,children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b border-[var(--border)]",children:[i.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${a==="preset"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("preset"),children:"From Preset"}),i.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${a==="custom"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("custom"),children:"Custom"})]}),a==="preset"?i.jsx("div",{className:"space-y-3",children:G.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"Loading presets..."}):G.map(M=>i.jsx("button",{type:"button",className:"w-full text-left p-4 border border-[var(--border)] rounded-lg hover:border-[var(--accent)] hover:bg-[var(--accent)]/5 transition-colors",onClick:()=>re(M),disabled:r,children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("h4",{className:"font-medium",children:M.label}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:M.description}),i.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[M.tags.map(H=>i.jsx(J,{variant:"default",children:H},H)),M.suggested_datasets.length>0&&i.jsxs(J,{variant:"success",children:["datasets: ",M.suggested_datasets.join(", ")]})]})]}),i.jsx(Ys,{size:16,className:"text-[var(--text-secondary)] mt-1 flex-shrink-0"})]})},M.name))}):i.jsxs("form",{id:"create-agent-form",onSubmit:me,className:"space-y-4",children:[i.jsx(pn,{label:"Name",value:o.name,onChange:M=>c({...o,name:M.target.value}),placeholder:"e.g., my-coding-agent",required:!0}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"LLM Configuration"}),i.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.llm_config_id||"",onChange:M=>c({...o,llm_config_id:M.target.value||null}),children:[i.jsx("option",{value:"",children:"Use environment variables"}),f.map(M=>i.jsxs("option",{value:M.id,children:[M.name," (",M0[M.provider],M.model_id?` - ${M.model_id}`:"",")",M.is_default?" (default)":""]},M.id))]}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:f.length===0?"No LLM configs found. Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)":o.llm_config_id?"Uses the selected LLM configuration.":"Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Framework"}),i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.framework||"miniagent",onChange:M=>{const H=M.target.value;c({...o,framework:H,compaction:{strategy:"none",params:{}}})},children:_.map(M=>{var H;return i.jsx("option",{value:M,children:((H=N[M])==null?void 0:H.label)||R0[M]||M},M)})}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((pe=N[F])==null?void 0:pe.description)||(F==="miniagent"?"Lightweight agent with token-aware context management.":F==="langgraph"?"Graph-based workflows with state management.":"Default agent implementation.")})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(Si,{label:"Custom instructions",checked:d,onChange:M=>{h(M.target.checked),M.target.checked||c({...o,instructions:null})}}),i.jsx(Si,{label:"Enable compaction",checked:D,onChange:M=>{if(M.target.checked){const H=O.find(dt=>dt!=="none")||"head_tail";A(H)}else c({...o,compaction:{strategy:"none",params:{}}})}})]}),d&&i.jsx("textarea",{className:"w-full h-32 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono resize-y",value:o.instructions||"",onChange:M=>c({...o,instructions:M.target.value||null}),placeholder:"System prompt / instructions for the agent..."}),D&&i.jsxs("div",{className:"space-y-3 p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Compaction Strategy"}),i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:q,onChange:M=>A(M.target.value),children:O.filter(M=>M!=="none").map(M=>{var H;return i.jsx("option",{value:M,children:((H=B[M])==null?void 0:H.label)||M},M)})}),(X==null?void 0:X.description)&&i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:X.description})]}),(X==null?void 0:X.params)&&Object.keys(X.params).length>0&&i.jsx("div",{className:"grid grid-cols-2 gap-3",children:Object.entries(X.params).map(([M,H])=>{var is;const dt=(is=o.compaction)==null?void 0:is.params[M],as=dt!==void 0?dt:H.default;return i.jsxs("div",{children:[i.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:M.replace(/_/g," ")}),i.jsx("input",{type:"number",className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof as=="number"?as:Number(as)||0,onChange:ep=>{const Jc=parseFloat(ep.target.value);c({...o,compaction:{...o.compaction,params:{...o.compaction.params,[M]:isNaN(Jc)?typeof H.default=="number"?H.default:0:Jc}}})},min:H.min,max:H.max,step:H.max&&H.max<=1?.1:1}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:H.description})]},M)})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm font-medium",children:"Tools"}),i.jsxs("div",{className:"flex gap-4",children:[i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"radio",checked:u==="preset",onChange:()=>p("preset"),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:"Preset"})]}),i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"radio",checked:u==="custom",onChange:()=>p("custom"),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:"Custom"})]})]}),u==="preset"?i.jsxs(i.Fragment,{children:[i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof o.tools=="string"?o.tools:"standard",onChange:M=>c({...o,tools:M.target.value}),children:b.map(M=>i.jsx("option",{value:M,children:M},M))}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((be=C[typeof o.tools=="string"?o.tools:"standard"])==null?void 0:be.join(", "))??""})]}):i.jsx("div",{className:"grid grid-cols-2 gap-1 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:j.map(M=>i.jsxs("label",{className:"flex items-center gap-2 p-1 text-sm cursor-pointer hover:bg-[var(--bg-tertiary)]",children:[i.jsx("input",{type:"checkbox",checked:x.includes(M),onChange:()=>P(M),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"font-mono text-xs",children:M})]},M))})]}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[i.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>S(!g),children:[i.jsx(Ys,{size:14,className:`transition-transform ${g?"rotate-90":""}`}),"More options"]}),g&&i.jsx("div",{className:"mt-3",children:i.jsx(pn,{label:"Description (optional)",value:o.description,onChange:M=>c({...o,description:M.target.value}),placeholder:"Brief description of this agent"})})]})]})]})}function Q0({agent:e,isOpen:t,onClose:n}){var R;const r=cr(),s=qt(),[a,l]=w.useState("ready"),[o,c]=w.useState("quick"),[d,h]=w.useState(!1),[u,p]=w.useState([]),[x,k]=w.useState(!1),[g,S]=w.useState(Do),[m,f]=w.useState(4),[v,j]=w.useState(100),[C,b]=w.useState(!1),[N,_]=w.useState(null),{data:F=[]}=fe({queryKey:["tasks"],queryFn:()=>Et.list()}),{data:O=[]}=fe({queryKey:["suites"],queryFn:()=>Et.listSuites()}),{data:B}=fe({queryKey:["agent-schema"],queryFn:()=>Km.getAgentSchema()}),G=O.map(T=>({value:T.name,label:T.name.charAt(0).toUpperCase()+T.name.slice(1),description:T.description,tasks:T.task_count})),re=Je({mutationFn:Et.importSuite,onSuccess:T=>{s.invalidateQueries({queryKey:["tasks"]}),p(T.map(te=>te.id))}}),me=Je({mutationFn:async T=>{const te=await Ut.create(T);return Ut.start(te.id).next(),te},onSuccess:T=>{s.invalidateQueries({queryKey:["jobs"]}),_(T.id),l("success")}}),q=x?(()=>{let T=1;g.compaction.length>0&&(T*=g.compaction.length),g.tools.length>0&&(T*=g.tools.length),g.llm_config.length>0&&(T*=g.llm_config.length);const te=g.instructions.length+g.instruction_strategies.reduce((pe,be)=>pe+be.max_candidates,0);return te>0&&(T*=te),Math.min(T,v)})():1,X=d?u.length:((R=G.find(T=>T.value===o))==null?void 0:R.tasks)||3,P=q*X,A=async()=>{l("starting");let T=u;if(!d)try{T=(await re.mutateAsync(o)).map(H=>H.id)}catch(M){console.error("Failed to import suite:",M),alert(`Failed to import task suite: ${o}`),l("ready");return}if(T.length===0){alert("No tasks selected. Please select tasks or choose a task suite."),l("ready");return}let te;if(x&&(g.compaction.length>0||g.tools.length>0||g.llm_config.length>0||g.instructions.length>0||g.instruction_strategies.length>0))try{te=(await Io.generateCandidates({base_agent_id:e.id,variations:g,budget:v})).candidate_ids}catch(M){console.error("Failed to generate candidates:",M),alert(`Failed to generate candidates: ${M instanceof Error?M.message:"Unknown error"}`),l("ready");return}else te=[e.id];const be={name:`${e.name} optimization (${te.length} candidates × ${T.length} tasks)`,candidate_ids:te,task_ids:T,parallel:m,use_llm_eval:C};me.mutate(be)},L=T=>{p(te=>te.includes(T)?te.filter(pe=>pe!==T):[...te,T])},V=()=>{l("ready"),_(null),k(!1),S(Do),n()},ee=()=>a==="success"&&N?i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsx(K,{variant:"secondary",onClick:V,children:"Close"}),i.jsx(K,{variant:"primary",icon:Xs,onClick:()=>{V(),r(`/jobs/${N}`)},children:"View Job"})]}):a==="starting"?null:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(K,{variant:"secondary",onClick:n,children:"Cancel"}),i.jsxs(K,{variant:"primary",icon:Xs,onClick:A,disabled:d&&u.length===0,children:["Start Optimization (",P," runs)"]})]});return i.jsx(ss,{isOpen:t,onClose:V,title:`Optimize: ${e.name}`,footer:ee(),size:"lg",children:a==="success"&&N?i.jsxs("div",{className:"flex flex-col items-center py-8",children:[i.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/20 flex items-center justify-center mb-4",children:i.jsx(Qi,{size:24,className:"text-green-500"})}),i.jsx("h3",{className:"text-lg font-medium mb-2",children:"Job Started!"}),i.jsx("p",{className:"text-[var(--text-secondary)] text-center mb-2",children:"Optimization job is now running"}),i.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-3 py-1.5 rounded font-mono",children:["ID: ",N.slice(0,8),"..."]})]}):a==="starting"?i.jsxs("div",{className:"flex flex-col items-center py-8",children:[i.jsx(ha,{size:32,className:"animate-spin text-[var(--accent)] mb-4"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:re.isPending?"Importing tasks...":"Creating optimization job..."})]}):i.jsxs("div",{className:"space-y-5",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Task Suite"}),i.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:d?"__custom__":o,onChange:T=>{T.target.value==="__custom__"?h(!0):(h(!1),c(T.target.value))},children:[G.map(T=>i.jsxs("option",{value:T.value,children:[T.label," (",T.tasks," tasks) — ",T.description]},T.value)),F.length>0&&i.jsx("option",{value:"__custom__",children:"Custom Selection"})]})]}),d&&F.length>0&&i.jsx("div",{className:"max-h-48 overflow-y-auto border border-[var(--border)] rounded p-2 space-y-1",children:F.map(T=>i.jsxs("label",{className:"flex items-center gap-2 p-2 hover:bg-[var(--bg-tertiary)] cursor-pointer rounded",children:[i.jsx("input",{type:"checkbox",checked:u.includes(T.id),onChange:()=>L(T.id),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:T.name}),T.suite&&i.jsx(J,{children:T.suite})]},T.id))}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[i.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>k(!x),children:[i.jsx(Ys,{size:14,className:`transition-transform ${x?"rotate-90":""}`}),"Advanced Settings",x&&i.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"(experiment design, variations, execution)"})]}),x&&B&&i.jsx("div",{className:"mt-4",children:i.jsx($0,{agentId:e.id,agentName:e.name,agentFramework:e.config.framework,taskSuite:d?void 0:o,taskCount:X,schema:B,onVariationsChange:S,parallel:m,onParallelChange:f,budget:v,onBudgetChange:j,useLlmEval:C,onUseLlmEvalChange:b})})]})]})})}function ma({items:e}){return i.jsx("nav",{className:"flex items-center gap-1.5 text-sm mb-4",children:e.map((t,n)=>{const r=n===e.length-1;return i.jsxs("span",{className:"flex items-center gap-1.5",children:[n>0&&i.jsx(Ys,{size:14,className:"text-[var(--text-secondary)]"}),t.path&&!r?i.jsx(Pn,{to:t.path,className:"text-[var(--text-secondary)] hover:text-[var(--accent)] transition-colors",children:t.label}):i.jsx("span",{className:r?"text-[var(--text-primary)] font-medium":"text-[var(--text-secondary)]",children:t.label})]},n)})})}function ge({children:e,className:t="",onClick:n,selected:r=!1,selectable:s=!1}){const a="bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",l=s?"cursor-pointer hover:border-[var(--accent-dim)] transition-colors":"",o=r?"border-[var(--accent)]":"";return i.jsx("div",{className:`${a} ${l} ${o} ${t}`,onClick:n,children:e})}function V0(e){const t=[],n=r=>r.type==="trace_span"&&typeof r.data=="object"&&r.data!==null?r.data:"span_id"in r?r:null;if(Array.isArray(e.spans)){for(const r of e.spans)if(typeof r=="object"&&r!==null){const s=n(r);s&&t.push(s)}}else if(e.span_id)t.push(e);else for(const r in e){const s=e[r];if(typeof s=="object"&&s!==null){const a=n(s);if(a)t.push(a);else if(Array.isArray(s)){for(const l of s)if(typeof l=="object"&&l!==null){const o=n(l);o&&t.push(o)}}}}return t}function qm(e){const t=new Map,n=[];for(const s of e)t.set(s.span_id,{span:s,children:[]});for(const s of e){const a=t.get(s.span_id);s.parent_span_id&&t.has(s.parent_span_id)?t.get(s.parent_span_id).children.push(a):n.push(a)}const r=s=>{s.sort((a,l)=>(a.span.start_time||0)-(l.span.start_time||0)),s.forEach(a=>r(a.children))};return r(n),n}function K0(e){return e.includes("Agent")||e.includes("agent")?"bg-[var(--span-llm-bg)] text-[var(--span-llm-text)]":e.includes("chat")||e.includes("Chat")||e.includes("llm")?"bg-[var(--span-tool-bg)] text-[var(--span-tool-text)]":e.includes("tool")||e.includes("execute")||e.includes("bash")?"bg-[var(--span-agent-bg)] text-[var(--span-agent-text)]":"bg-[var(--span-other-bg)] text-[var(--span-other-text)]"}function H0(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(0)}ms`}function Gc({node:e,depth:t=0}){var u,p;const[n,r]=w.useState(t<2),[s,a]=w.useState(!1),{span:l}=e,o=e.children.length>0,c=(u=l.attributes)==null?void 0:u["gen_ai.usage.input_tokens"],d=(p=l.attributes)==null?void 0:p["gen_ai.usage.output_tokens"],h=c!==void 0||d!==void 0;return i.jsxs("div",{className:"relative",children:[t>0&&i.jsx("div",{className:"absolute left-0 top-0 bottom-0 border-l-2 border-[var(--border)]",style:{marginLeft:`${(t-1)*16+8}px`}}),i.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-1 hover:bg-[var(--bg-primary)] rounded transition-colors cursor-pointer",style:{paddingLeft:`${t*16}px`},onClick:()=>o?r(!n):a(!s),children:[i.jsx("div",{className:"w-4 h-4 flex items-center justify-center text-[var(--text-secondary)]",children:o?n?"▼":"▶":s?"▼":"▶"}),i.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${K0(l.operation_name)}`,children:l.operation_name.replace("ChatAgent.","").replace("invoke_agent ","")}),l.duration_ms!==void 0&&i.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:H0(l.duration_ms)}),h&&i.jsxs("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:[c!==void 0&&i.jsxs("span",{className:"text-blue-400",children:["↑",String(c)]}),c!==void 0&&d!==void 0&&i.jsx("span",{className:"mx-0.5",children:"/"}),d!==void 0&&i.jsxs("span",{className:"text-green-400",children:["↓",String(d)]})]})]}),s&&!o&&i.jsx("div",{className:"ml-4 mt-1 mb-2 p-2 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs",style:{marginLeft:`${t*16+20}px`},children:i.jsxs("div",{className:"space-y-1",children:[l.span_id&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Span ID:"}),i.jsx("span",{className:"font-mono text-xs break-all",children:l.span_id})]}),l.trace_id&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Trace ID:"}),i.jsx("span",{className:"font-mono text-xs break-all",children:l.trace_id})]}),l.status&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Status:"}),i.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs ${l.status==="OK"||l.status==="StatusCode.UNSET"?"bg-[var(--span-pass-bg)] text-[var(--span-pass-text)]":"bg-[var(--span-fail-bg)] text-[var(--span-fail-text)]"}`,children:l.status})]}),Object.keys(l.attributes||{}).length>0&&i.jsxs("div",{className:"mt-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] block mb-1",children:"Attributes:"}),i.jsx("pre",{className:"text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded p-2 overflow-auto max-h-32 whitespace-pre-wrap break-all",children:JSON.stringify(l.attributes,null,2)})]})]})}),o&&n&&i.jsx("div",{children:e.children.map((x,k)=>i.jsx(Gc,{node:x,depth:t+1},x.span.span_id||k))})]})}function Gm({trace:e}){const[t,n]=w.useState("tree"),r=w.useMemo(()=>V0(e),[e]),s=w.useMemo(()=>qm(r),[r]);return Object.keys(e).length===0?null:i.jsxs(ge,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"font-medium",children:"Trace Data"}),i.jsxs("div",{className:"flex gap-1",children:[i.jsx("button",{onClick:()=>n("tree"),className:`px-2 py-1 text-xs rounded ${t==="tree"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Tree"}),i.jsx("button",{onClick:()=>n("raw"),className:`px-2 py-1 text-xs rounded ${t==="raw"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Raw"})]})]}),t==="tree"?r.length>0?i.jsx("div",{className:"border border-[var(--border)] rounded overflow-hidden",children:i.jsxs("div",{className:"p-2",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs(J,{variant:"default",children:[r.length," spans"]}),i.jsx("span",{children:"•"}),i.jsx("span",{children:"Click to expand details"})]}),s.map((a,l)=>i.jsx(Gc,{node:a,depth:0},a.span.span_id||l))]})}):i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No structured spans found. View raw data below."}):i.jsx("pre",{className:"text-xs bg-[var(--bg-primary)] p-3 overflow-x-auto border border-[var(--border)] max-h-96 whitespace-pre-wrap",children:JSON.stringify(e,null,2)})]})}function W0({spans:e,isLive:t=!1}){const n=w.useRef(null),r=w.useMemo(()=>qm(e),[e]);return w.useEffect(()=>{n.current&&t&&n.current.scrollTo({top:n.current.scrollHeight,behavior:"smooth"})},[e.length,t]),i.jsxs("div",{className:"border border-[var(--border)] rounded overflow-hidden h-full flex flex-col",children:[i.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-[var(--border)] bg-[var(--bg-secondary)]",children:[i.jsxs(J,{variant:"default",children:[e.length," spans"]}),t&&i.jsx("span",{className:"animate-pulse",children:i.jsx(J,{variant:"info",children:"Live"})})]}),i.jsx("div",{ref:n,className:"flex-1 overflow-auto p-2",children:r.length>0?r.map((s,a)=>i.jsx(Gc,{node:s,depth:0},s.span.span_id||a)):i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:t?"Waiting for spans...":"No spans recorded"})})]})}function Jm({agent:e}){const[t,n]=w.useState(""),[r,s]=w.useState(null),[a,l]=w.useState("idle"),[o,c]=w.useState(null),[d,h]=w.useState(""),[u,p]=w.useState([]),[x,k]=w.useState(null),[g,S]=w.useState(null),[m,f]=w.useState([]),[v,j]=w.useState(!1),C=w.useRef(null),{data:b=[]}=fe({queryKey:["tasks"],queryFn:()=>Et.list()});w.useEffect(()=>{C.current&&a==="running"&&(C.current.scrollTop=C.current.scrollHeight)},[d,a]);const N=D=>{if(s(D),D){const q=b.find(X=>X.id===D);q&&n(q.prompt)}},_=async()=>{if(t.trim()){l("running"),h(""),p([]),k(null),S(null),f([]);try{const D=await Ts.create({agent_id:e.id,prompt:t.trim(),task_id:r||void 0});c(D.id);for await(const q of Ts.start(D.id))F(q)}catch(D){S(D instanceof Error?D.message:"Test failed"),l("failed")}}},F=D=>{switch(D.event){case"started":break;case"execution":D.execution_event==="text_delta"&&D.content?h(q=>q+D.content):D.execution_event==="tool_call_start"&&D.tool_name?f(q=>[...q,{name:D.tool_name}]):D.execution_event==="tool_result"&&D.content&&f(q=>{if(q.length>0){const X=[...q];return X[X.length-1]={...X[X.length-1],content:D.content},X}return q});break;case"span":if(D.span){const q=D.span;if(q.data){const X={span_id:q.data.span_id||"",trace_id:q.data.trace_id||"",parent_span_id:q.data.parent_span_id||null,operation_name:q.data.operation_name||"",start_time:q.timestamp?new Date(q.timestamp).getTime():Date.now(),end_time:Date.now(),duration_ms:q.data.duration_ms||0,status:q.data.status||"OK",attributes:q.data.attributes||{}};p(P=>[...P,X])}}break;case"complete":l("completed"),D.result&&k(D.result);break;case"error":S(D.message),l("failed");break}},O=async()=>{if(o)try{await Ts.cancel(o)}catch{}l("idle")},B=()=>{l("idle"),c(null),h(""),p([]),k(null),S(null),f([])},G=a==="running",re=a==="completed"||a==="failed",me=D=>{D.preventDefault(),re?(B(),setTimeout(()=>_(),0)):_()};return i.jsxs("div",{className:"h-full flex flex-col border border-[var(--border)] rounded-lg overflow-hidden bg-[var(--bg-primary)]",children:[(G||re)&&i.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border)] bg-[var(--bg-secondary)] flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[G&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"animate-pulse",children:i.jsx(J,{variant:"info",children:"Running"})}),i.jsx(K,{variant:"ghost",size:"sm",icon:_d,onClick:O,children:"Cancel"})]}),a==="completed"&&i.jsx(J,{variant:"success",children:"Completed"}),a==="failed"&&i.jsx(J,{variant:"error",children:"Failed"})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[x&&i.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Rm,{size:12}),x.duration_seconds.toFixed(2),"s"]}),i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(_g,{size:12}),x.tokens_total," tokens"]}),x.passed!==null&&(x.passed?i.jsx(Lm,{size:14,className:"text-[var(--success)]"}):i.jsx(Qg,{size:14,className:"text-[var(--error)]"}))]}),u.length>0&&i.jsxs(K,{variant:v?"primary":"secondary",size:"sm",icon:gg,onClick:()=>j(!v),children:["Traces (",u.length,")"]}),re&&o&&i.jsx(Pn,{to:`/tests/${o}`,children:i.jsx(K,{variant:"secondary",size:"sm",icon:Mm,children:"Details"})})]})]}),i.jsxs("div",{className:"flex-1 min-h-0 flex",children:[i.jsx("div",{ref:C,className:`flex-1 overflow-auto p-4 ${v?"border-r border-[var(--border)]":""}`,children:!G&&!re?i.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center",children:[i.jsx("div",{className:"text-lg font-medium mb-1",children:e.name}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] max-w-sm",children:"Send a message to test this agent, or select a task from the dropdown below."})]}):i.jsxs("div",{className:"space-y-3",children:[i.jsx("div",{className:"flex justify-end",children:i.jsx("div",{className:"max-w-[80%] px-3 py-2 bg-[var(--accent-dim)] text-[var(--text-primary)] rounded-lg text-sm",children:t})}),(d||G)&&i.jsx("div",{className:"px-3 py-2 text-sm whitespace-pre-wrap font-mono bg-[var(--bg-secondary)] rounded-lg border border-[var(--border)]",children:d||i.jsx("span",{className:"text-[var(--text-secondary)] animate-pulse",children:"Thinking..."})}),m.length>0&&i.jsx("div",{className:"space-y-1.5",children:m.map((D,q)=>i.jsxs("div",{className:"p-2 bg-[var(--badge-info-bg)] border border-[var(--badge-info-border)] rounded-md text-xs",children:[i.jsx(J,{variant:"info",children:D.name}),D.content&&i.jsxs("div",{className:"mt-1 text-[var(--text-secondary)] truncate max-w-full font-mono",children:[D.content.substring(0,200),D.content.length>200&&"..."]})]},q))}),g&&i.jsx("div",{className:"p-3 bg-[var(--badge-error-bg)] border border-[var(--badge-error-border)] rounded-md text-sm text-[var(--badge-error-text)]",children:g})]})}),v&&i.jsx("div",{className:"w-[350px] flex-shrink-0 overflow-auto",children:i.jsx(W0,{spans:u,isLive:G})})]}),i.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] bg-[var(--bg-secondary)]",children:[i.jsx("div",{className:"px-4 pt-2",children:i.jsxs("select",{value:r||"",onChange:D=>N(D.target.value||null),className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs text-[var(--text-secondary)]",disabled:G,children:[i.jsx("option",{value:"",children:"Custom prompt..."}),b.map(D=>i.jsx("option",{value:D.id,children:D.name},D.id))]})}),i.jsxs("form",{onSubmit:me,className:"p-3 flex gap-2",children:[i.jsx("textarea",{value:t,onChange:D=>n(D.target.value),placeholder:"Message the agent...",disabled:G,rows:1,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm resize-none min-h-[40px] max-h-[120px] focus:outline-none focus:border-[var(--accent)]",onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),me(D))}}),i.jsx(K,{type:"submit",variant:"primary",icon:G?_d:Xs,disabled:G?!1:!t.trim(),onClick:G?O:void 0,children:G?"Stop":re?"New Test":"Run"})]})]})]})}function q0(){const{agentId:e}=fa(),t=cr(),n=qt(),[r,s]=w.useState("overview"),{data:a,isLoading:l}=fe({queryKey:["configs",e],queryFn:()=>Xn.get(e),enabled:!!e}),{data:o=[]}=fe({queryKey:["tests",{agent_id:e}],queryFn:()=>Ts.list({agent_id:e}),enabled:!!e}),{data:c=[]}=fe({queryKey:["jobs"],queryFn:()=>Ut.list()}),d=Je({mutationFn:u=>Xn.delete(u),onSuccess:()=>{n.invalidateQueries({queryKey:["configs"]}),t("/agents")}}),h=c.filter(u=>u.candidate_ids.includes(e||""));return l?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):a?i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"mb-4 flex-shrink-0",children:[i.jsx(ma,{items:[{label:"Agents",path:"/agents"},{label:a.name}]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:a.name}),a.is_auto_generated&&i.jsx(J,{variant:"info",children:"Auto-generated"})]}),i.jsx("div",{className:"flex gap-2",children:i.jsx(K,{variant:"secondary",icon:Qc,size:"sm",onClick:()=>{confirm(`Delete agent "${a.name}"?`)&&d.mutate(a.id)},children:"Delete"})})]}),a.description&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:a.description})]}),i.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[i.jsxs("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:[i.jsxs("div",{className:"flex gap-1 mb-4 border-b border-[var(--border)] flex-shrink-0",children:[i.jsx(kl,{active:r==="overview",onClick:()=>s("overview"),icon:i.jsx(Im,{size:14}),children:"Overview"}),i.jsx(kl,{active:r==="evaluate",onClick:()=>s("evaluate"),icon:i.jsx(Xs,{size:14}),children:"Evaluate"}),i.jsx(kl,{active:r==="history",onClick:()=>s("history"),icon:i.jsx(Mg,{size:14}),badge:o.length,children:"History"})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r==="overview"&&i.jsx(G0,{agent:a,recentTests:o,jobs:h}),r==="evaluate"&&i.jsx(J0,{agent:a,jobs:h}),r==="history"&&i.jsx(Y0,{tests:o})]})]}),i.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[i.jsx(Fm,{size:16,className:"text-[var(--text-secondary)]"}),i.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),i.jsx("div",{className:"flex-1 min-h-0",children:i.jsx(Jm,{agent:a})})]})]})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Agent not found"})}function kl({active:e,onClick:t,icon:n,badge:r,children:s}){return i.jsxs("button",{onClick:t,className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors ${e?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[n,s,r!==void 0&&r>0&&i.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs bg-[var(--bg-tertiary)] rounded",children:r})]})}function G0({agent:e,recentTests:t,jobs:n}){var a,l;const r=e.config,s=()=>{const o=r.tools;return typeof o=="string"?o:Array.isArray(o)?o.join(", "):o&&typeof o=="object"?Object.keys(o).join(", "):"standard"};return i.jsxs("div",{className:"space-y-4",children:[i.jsx(fr,{title:"Model",children:i.jsx("div",{className:"font-mono text-sm",children:r.model||"default"})}),i.jsx(fr,{title:"Instructions",defaultCollapsed:!r.instructions,children:r.instructions?i.jsx("pre",{className:"p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs whitespace-pre-wrap max-h-40 overflow-auto font-mono",children:r.instructions}):i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No instructions set"})}),i.jsx(fr,{title:"Tools",children:i.jsx("div",{className:"font-mono text-sm",children:s()})}),i.jsx(fr,{title:"Compaction",children:i.jsx("div",{className:"font-mono text-sm",children:!r.compaction||r.compaction.strategy==="none"?"disabled":`${r.compaction.strategy} (${((a=r.compaction.params)==null?void 0:a.head_size)||0}/${((l=r.compaction.params)==null?void 0:l.tail_size)||0})`})}),t.length>0&&i.jsx(fr,{title:`Recent Tests (${t.length})`,children:i.jsx("div",{className:"space-y-1.5",children:t.slice(0,3).map(o=>i.jsxs(Pn,{to:`/tests/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[i.jsx(Ym,{status:o.status}),i.jsxs("span",{className:"truncate",children:[o.prompt.slice(0,40),"..."]})]}),i.jsxs("span",{className:"text-[var(--text-secondary)] flex-shrink-0 ml-2",children:[o.duration_seconds.toFixed(1),"s"]})]},o.id))})}),n.length>0&&i.jsx(fr,{title:`Experiments (${n.length})`,children:i.jsx("div",{className:"space-y-1.5",children:n.slice(0,3).map(o=>i.jsxs(Pn,{to:`/jobs/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(J,{variant:o.status==="completed"?"success":o.status==="running"?"info":"default",children:o.status}),i.jsx("span",{children:o.name})]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(o.created_at).toLocaleDateString()})]},o.id))})})]})}function fr({title:e,children:t,defaultCollapsed:n=!1}){const[r,s]=w.useState(n);return i.jsxs("div",{className:"border-b border-[var(--border)] pb-3",children:[i.jsxs("button",{onClick:()=>s(!r),className:"flex items-center justify-between w-full text-left py-1 hover:text-[var(--accent)] transition-colors",children:[i.jsx("span",{className:"text-sm font-medium",children:e}),i.jsx("span",{className:"text-[var(--text-secondary)] text-xs",children:r?"▶":"▼"})]}),!r&&i.jsx("div",{className:"mt-2",children:t})]})}function J0({agent:e,jobs:t}){const n=cr(),r=qt(),[s,a]=w.useState("quick"),[l,o]=w.useState(!1),{data:c=[]}=fe({queryKey:["suites"],queryFn:()=>Et.listSuites()}),d=Je({mutationFn:j0.start,onSuccess:u=>{r.invalidateQueries({queryKey:["jobs"]}),o(!1),n(`/jobs/${u.id}`)},onError:()=>{o(!1)}}),h=()=>{o(!0),d.mutate({agent_id:e.id,suite_name:s,use_llm_eval:!0,parallel:4})};return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:"Run this agent on a task suite to measure quality and cost."}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm",value:s,onChange:u=>a(u.target.value),disabled:l,children:c.map(u=>i.jsxs("option",{value:u.name,children:[u.name.charAt(0).toUpperCase()+u.name.slice(1)," (",u.task_count," tasks)"]},u.name))}),i.jsx(K,{variant:"primary",icon:l?ha:Xs,onClick:h,disabled:l,loading:l,className:"w-full",children:"Evaluate"})]})]}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h4",{className:"text-sm font-medium",children:"Optimization Jobs"}),i.jsx(K,{variant:"secondary",size:"sm",icon:Qi,onClick:()=>n("/agents",{state:{optimizeAgent:e}}),children:"New Job"})]}),t.length===0?i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No optimization jobs yet."}):i.jsx("div",{className:"space-y-1.5",children:t.slice(0,5).map(u=>i.jsxs(Pn,{to:`/jobs/${u.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(J,{variant:u.status==="completed"?"success":u.status==="running"?"info":"default",children:u.status}),i.jsx("span",{children:u.name})]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(u.created_at).toLocaleDateString()})]},u.id))})]})]})}function Y0({tests:e}){return e.length===0?i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No test history yet. Use the playground on the right to run a test."}):i.jsx("div",{className:"space-y-2",children:e.map(t=>i.jsxs(Pn,{to:`/tests/${t.id}`,className:"flex items-center justify-between p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(Ym,{status:t.status}),t.score!==null&&i.jsxs("span",{className:`text-sm font-medium ${t.passed?"text-[var(--success)]":"text-[var(--error)]"}`,children:[(t.score*100).toFixed(0),"%"]})]}),i.jsx("p",{className:"text-sm truncate",children:t.prompt})]}),i.jsxs("div",{className:"flex flex-col items-end gap-1 ml-4",children:[i.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:new Date(t.created_at).toLocaleString()}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:[t.duration_seconds.toFixed(1),"s"]}),i.jsxs("span",{children:[t.tokens_total," tokens"]})]})]})]},t.id))})}function Ym({status:e}){const t={completed:"success",failed:"error",running:"info",cancelled:"warning",pending:"default"};return i.jsx(J,{variant:t[e]||"default",children:e})}function X0(){const e=qt(),[t,n]=w.useState(!1),[r,s]=w.useState(!1),[a,l]=w.useState(null),[o,c]=w.useState(new Set),d=m=>{c(f=>{const v=new Set(f);return v.has(m)?v.delete(m):v.add(m),v})},{data:h=[],isLoading:u}=fe({queryKey:["tasks"],queryFn:()=>Et.list()}),p=Je({mutationFn:Et.create,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),n(!1)}}),x=Je({mutationFn:Et.importSuite,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),s(!1)}}),k=Je({mutationFn:Et.delete,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),l(null)}}),g=h.reduce((m,f)=>{const v=f.suite||"custom";return m[v]||(m[v]=[]),m[v].push(f),m},{}),S=Object.keys(g).sort((m,f)=>m==="custom"?-1:f==="custom"?1:m.localeCompare(f));return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Datasets"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Task datasets for evaluating agent configurations."})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(K,{variant:"secondary",onClick:()=>s(!0),children:"Import Suite"}),i.jsx(K,{variant:"primary",onClick:()=>n(!0),children:"+ New Task"})]})]}),u?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):h.length===0?i.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:"No tasks yet. Create one or import a built-in suite."}):i.jsx("div",{className:"space-y-4",children:S.map(m=>{const f=g[m],v=!o.has(m);return i.jsxs("div",{children:[i.jsxs("button",{onClick:()=>d(m),className:"flex items-center gap-2 py-2 hover:text-[var(--accent)] transition-colors",children:[v?i.jsx(Ng,{size:16,className:"text-[var(--text-secondary)]"}):i.jsx(Ys,{size:16,className:"text-[var(--text-secondary)]"}),i.jsx("h3",{className:"text-sm font-medium uppercase tracking-wide",children:m==="custom"?"Custom Tasks":`${m} Suite`}),i.jsx(J,{variant:m==="custom"?"default":"info",children:f.length})]}),v&&i.jsx("div",{className:"mt-2 border border-[var(--border)] rounded-lg overflow-hidden",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:[i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Name"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Category"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Prompt"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Criteria"})]})}),i.jsx("tbody",{children:f.map(j=>i.jsxs("tr",{onClick:()=>l(j),className:"border-b border-[var(--border)] last:border-b-0 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors",children:[i.jsx("td",{className:"px-4 py-3",children:i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:j.name})}),i.jsx("td",{className:"px-4 py-3",children:j.category&&j.category!=="default"?i.jsx(J,{variant:"default",children:j.category}):i.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"})}),i.jsx("td",{className:"px-4 py-3",children:i.jsx("span",{className:"text-[var(--text-secondary)] line-clamp-1 max-w-md",children:j.prompt})}),i.jsx("td",{className:"px-4 py-3 text-[var(--text-secondary)]",children:j.criteria.length>0?j.criteria.length:"--"})]},j.id))})]})})]},m)})}),i.jsx(Z0,{task:a,onClose:()=>l(null),onDelete:m=>{confirm("Delete this task?")&&k.mutate(m)}}),i.jsx(e1,{isOpen:t,onClose:()=>n(!1),onSubmit:m=>p.mutate(m),isLoading:p.isPending}),i.jsx(t1,{isOpen:r,onClose:()=>s(!1),onSubmit:m=>x.mutate(m),isLoading:x.isPending})]})}function Z0({task:e,onClose:t,onDelete:n}){const[r,s]=w.useState("prompt");if(!e)return null;const a=i.jsxs("div",{className:"flex justify-between",children:[i.jsx(K,{variant:"ghost",onClick:()=>n(e.id),className:"text-red-500 hover:text-red-600",children:"Delete Task"}),i.jsx(K,{variant:"secondary",onClick:t,children:"Close"})]});return i.jsx(ss,{isOpen:!!e,onClose:t,title:e.name,size:"lg",footer:a,children:i.jsxs("div",{className:"space-y-4",children:[e.category&&e.category!=="default"&&i.jsx("div",{children:i.jsx(J,{variant:"default",children:e.category})}),i.jsxs("div",{className:"flex gap-1 border-b border-[var(--border)]",children:[i.jsx("button",{onClick:()=>s("prompt"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="prompt"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Prompt"}),i.jsxs("button",{onClick:()=>s("criteria"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="criteria"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:["Eval Criteria (",e.criteria.length,")"]})]}),r==="prompt"&&i.jsx("div",{className:"p-4 bg-[var(--bg-tertiary)] rounded text-sm whitespace-pre-wrap min-h-[200px]",children:e.prompt}),r==="criteria"&&i.jsx("div",{className:"space-y-2 min-h-[200px]",children:e.criteria.length===0?i.jsx("div",{className:"text-[var(--text-secondary)] text-sm p-4",children:"No evaluation criteria defined for this task."}):e.criteria.map(l=>i.jsxs("div",{className:"p-3 bg-[var(--bg-tertiary)] rounded",children:[i.jsx("div",{className:"font-medium text-sm",children:l.name}),l.instruction&&i.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1",children:l.instruction})]},l.name))})]})})}function e1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,a]=w.useState({name:"",prompt:"",criteria:[],category:"default"}),l=()=>{a({...s,criteria:[...s.criteria,{name:"",instruction:"",weight:1}]})},o=(h,u)=>{const p=[...s.criteria];p[h]={...p[h],...u},a({...s,criteria:p})},c=h=>{a({...s,criteria:s.criteria.filter((u,p)=>p!==h)})},d=h=>{h.preventDefault(),!(!s.name.trim()||!s.prompt.trim())&&n({...s,criteria:s.criteria.filter(u=>u.name.trim()&&u.instruction.trim())})};return i.jsx(ss,{isOpen:e,onClose:t,title:"Create Task",children:i.jsxs("form",{onSubmit:d,className:"space-y-4",children:[i.jsx(pn,{label:"Name",value:s.name,onChange:h=>a({...s,name:h.target.value}),placeholder:"e.g., fizzbuzz",required:!0}),i.jsx(F0,{label:"Prompt",value:s.prompt,onChange:h=>a({...s,prompt:h.target.value}),placeholder:"The task description for the agent...",required:!0}),i.jsx(pn,{label:"Category",value:s.category,onChange:h=>a({...s,category:h.target.value}),placeholder:"e.g., coding, research"}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Evaluation Criteria"}),i.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"+ Add"})]}),i.jsx("div",{className:"space-y-2",children:s.criteria.map((h,u)=>i.jsxs("div",{className:"flex gap-2 items-start",children:[i.jsx(pn,{value:h.name,onChange:p=>o(u,{name:p.target.value}),placeholder:"Name",className:"w-32"}),i.jsx(pn,{value:h.instruction,onChange:p=>o(u,{instruction:p.target.value}),placeholder:"Instruction",className:"flex-1"}),i.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(u),children:"×"})]},u))})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(K,{type:"submit",variant:"primary",disabled:r||!s.name.trim()||!s.prompt.trim(),children:r?"Creating...":"Create"})]})]})})}function t1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,a]=w.useState(""),{data:l=[],isLoading:o}=fe({queryKey:["suites"],queryFn:()=>Et.listSuites(),enabled:e});return w.useEffect(()=>{l.length>0&&!s&&a(l[0].name)},[l,s]),i.jsx(ss,{isOpen:e,onClose:t,title:"Import Task Suite",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Import a built-in task suite for evaluation."}),o?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading suites..."}):l.length===0?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"No suites available."}):i.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:l.map(c=>i.jsxs("label",{className:`flex items-center gap-3 p-3 border cursor-pointer ${s===c.name?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[i.jsx("input",{type:"radio",name:"suite",value:c.name,checked:s===c.name,onChange:()=>a(c.name),className:"accent-[var(--accent)]"}),i.jsxs("span",{className:"capitalize",children:[c.name.replace(/_/g," ")," (",c.task_count," tasks) - ",c.description]})]},c.name))}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(K,{variant:"primary",onClick:()=>n(s),disabled:r||!s,children:r?"Importing...":"Import"})]})]})})}const n1=Ki(e=>({jobs:[],setJobs:t=>e({jobs:t})}));function r1(){const e=cr(),t=qt(),[n,r]=w.useState(!1),{setJobs:s}=n1(),a=Wc(),{data:l=[],isLoading:o}=fe({queryKey:["jobs",n],queryFn:()=>Ut.list({include_public:n}),refetchInterval:5e3});w.useEffect(()=>{l.length>0&&s(l)},[l,s]);const c=Je({mutationFn:Ut.delete,onSuccess:()=>t.invalidateQueries({queryKey:["jobs"]})}),d={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"},h=[{key:"name",header:"Name",render:u=>i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:u.name||`Job ${u.id.slice(0,8)}`}),u.is_public&&i.jsx(Uc,{className:"w-3 h-3 ml-2 inline text-[var(--text-secondary)]"})]})},{key:"status",header:"Status",render:u=>i.jsx(J,{variant:d[u.status]||"default",children:u.status})},{key:"candidates",header:"Candidates",render:u=>i.jsx("span",{children:u.candidate_ids.length})},{key:"tasks",header:"Tasks",render:u=>i.jsx("span",{children:u.task_ids.length})},{key:"runs",header:"Runs",render:u=>i.jsxs("span",{children:[u.completed_experiments,"/",u.total_experiments]})},{key:"created",header:"Created",render:u=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(u.created_at).toLocaleDateString()}),sortable:!0,sortValue:u=>new Date(u.created_at).getTime()},{key:"actions",header:"",className:"w-12",render:u=>!u.user_id||u.user_id==="anonymous"||a&&u.created_by_name===a?i.jsx("div",{onClick:x=>x.stopPropagation(),children:i.jsx(K,{variant:"ghost",size:"sm",icon:Qc,title:"Delete",disabled:u.status==="running",onClick:()=>{confirm("Delete this job?")&&c.mutate(u.id)}})}):null}];return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Experiments"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"View and manage optimization experiments. Start new experiments from the Agents page."})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Si,{label:"Show public",checked:n,onChange:u=>r(u.target.checked)}),i.jsx(K,{variant:"secondary",onClick:()=>e("/agents"),children:"Go to Agents"})]})]}),o?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):i.jsx(Wm,{columns:h,data:l,onRowClick:u=>e(`/jobs/${u.id}`),searchable:!0,searchPlaceholder:"Search experiments",searchFilter:(u,p)=>(u.name||"").toLowerCase().includes(p.toLowerCase())||u.id.toLowerCase().includes(p.toLowerCase()),emptyMessage:"No experiments yet. Go to Agents page to start an optimization."})]})}function s1(e,t=!0){return Math.abs(e)<10?"text-[var(--text-secondary)]":(t?e<0:e>0)?"text-green-400":"text-red-400"}function a1(e){return`${e>0?"+":""}${e.toFixed(1)}%`}function Xm(e,t){return t===0?0:(e-t)/t*100}function ps({label:e,values:t,baselineIndex:n,formatter:r,isLowerBetter:s=!0}){const a=t[n];return i.jsxs("tr",{className:"border-b border-[var(--border)] last:border-0",children:[i.jsx("td",{className:"py-2 pr-4 text-[var(--text-secondary)] text-sm",children:e}),t.map((l,o)=>{const c=Xm(l,a),d=o===n;return i.jsxs("td",{className:"py-2 px-4 text-right",children:[i.jsx("div",{className:"font-mono",children:r(l)}),!d&&i.jsx("div",{className:`text-xs ${s1(c,s)}`,children:a1(c)}),d&&i.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"(baseline)"})]},o)})]})}function i1({runs:e,baselineRunId:t}){const n=w.useMemo(()=>{if(t){const a=e.findIndex(l=>l.id===t);if(a>=0)return a}return 0},[e,t]);if(e.length<2)return null;const r=Math.min(...e.map(a=>a.tokens_total)),s=Math.max(...e.map(a=>a.score));return i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-4",children:"Candidate Comparison"}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-[var(--border)]",children:[i.jsx("th",{className:"pb-2 pr-4 text-left text-[var(--text-secondary)] font-medium",children:"Metric"}),e.map((a,l)=>i.jsx("th",{className:"pb-2 px-4 text-right",children:i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[i.jsx("span",{className:"font-medium",children:a.candidate_name}),a.is_pareto&&i.jsx(J,{variant:"success",children:"Optimal"}),l===n&&i.jsx(J,{variant:"info",children:"Base"})]})},a.id))]})}),i.jsxs("tbody",{children:[i.jsx(ps,{label:"Total Tokens",values:e.map(a=>a.tokens_total),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ps,{label:"Input Tokens",values:e.map(a=>a.tokens_input),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ps,{label:"Output Tokens",values:e.map(a=>a.tokens_output),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ps,{label:"Duration",values:e.map(a=>a.duration_seconds),baselineIndex:n,formatter:a=>`${a.toFixed(1)}s`,isLowerBetter:!0}),i.jsx(ps,{label:"Score",values:e.map(a=>a.score*100),baselineIndex:n,formatter:a=>`${a.toFixed(1)}%`,isLowerBetter:!1})]})]})}),i.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[i.jsx("h4",{className:"text-sm font-medium mb-2 text-[var(--text-secondary)]",children:"Key Insights"}),i.jsxs("ul",{className:"text-sm space-y-1 text-[var(--text-secondary)]",children:[e.map(a=>{const l=Xm(a.tokens_total,e[n].tokens_total);return a.tokens_total===r&&l<-5?i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-green-400",children:"✓"}),i.jsxs("span",{children:[i.jsx("strong",{children:a.candidate_name})," uses ",Math.abs(l).toFixed(0),"% fewer tokens"]})]},`token-${a.id}`):null}),e.map(a=>a.score===s&&a.passed?i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-green-400",children:"✓"}),i.jsxs("span",{children:[i.jsx("strong",{children:a.candidate_name})," achieved highest score (",(a.score*100).toFixed(0),"%)"]})]},`score-${a.id}`):null),e.filter(a=>a.is_pareto).length>0&&i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-purple-400",children:"★"}),i.jsxs("span",{children:["Optimal candidates (best tradeoff):"," ",e.filter(a=>a.is_pareto).map(a=>a.candidate_name).join(", ")]})]})]})]}),i.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[i.jsx("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:"Token Efficiency"}),i.jsx("div",{className:"space-y-2",children:e.map(a=>{const l=a.tokens_total/e[n].tokens_total*100,o=a.tokens_total<=r;return i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-24 text-sm truncate",title:a.candidate_name,children:a.candidate_name}),i.jsx("div",{className:"flex-1 h-6 bg-[var(--bg-primary)] rounded overflow-hidden",children:i.jsx("div",{className:`h-full transition-all duration-300 ${o?"bg-green-500":"bg-blue-500"}`,style:{width:`${Math.min(l,100)}%`}})}),i.jsx("div",{className:"w-20 text-right font-mono text-sm",children:a.tokens_total.toLocaleString()})]},a.id)})})]})]})}function l1({summaries:e,height:t=350}){const n=w.useRef(null),[r,s]=w.useState(600),[a,l]=w.useState("tokens"),[o,c]=w.useState(null),[d,h]=w.useState({x:0,y:0});w.useEffect(()=>{const b=()=>{n.current&&s(n.current.clientWidth)};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[]);const u={top:30,right:30,bottom:50,left:60},p=r-u.left-u.right,x=t-u.top-u.bottom,k=b=>a==="tokens"?b.avg_tokens:b.avg_duration,{xScale:g,yScale:S,xTicks:m,yTicks:f,paretoLine:v}=w.useMemo(()=>{if(e.length===0||p<=0)return{xScale:()=>0,yScale:()=>0,xTicks:[],yTicks:[],paretoLine:[]};const b=e.map(k),N=e.map(P=>P.avg_score),_=Math.min(...b)*.9,F=Math.max(...b)*1.1,O=Math.min(...N,.5),B=Math.min(Math.max(...N)*1.05,1),G=P=>(P-_)/(F-_)*p,re=P=>x-(P-O)/(B-O)*x,me=Array.from({length:5},(P,A)=>_+A/4*(F-_)),D=Array.from({length:5},(P,A)=>O+A/4*(B-O)),X=e.filter(P=>P.is_pareto).sort((P,A)=>k(P)-k(A)).map(P=>({x:G(k(P)),y:re(P.avg_score)}));return{xScale:G,yScale:re,xTicks:me,yTicks:D,paretoLine:X}},[e,p,x,a]);if(e.length===0)return i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No data to display"});const j=b=>a==="tokens"?b>=1e6?`${(b/1e6).toFixed(1)}M`:b>=1e3?`${(b/1e3).toFixed(0)}K`:b.toFixed(0):`${b.toFixed(1)}s`,C=(b,N)=>{var F;const _=(F=n.current)==null?void 0:F.getBoundingClientRect();_&&h({x:N.clientX-_.left,y:N.clientY-_.top}),c(b)};return i.jsxs("div",{ref:n,className:"w-full relative",children:[i.jsx("div",{className:"flex justify-end mb-2",children:i.jsxs("div",{className:"inline-flex rounded border border-[var(--border)] text-xs",children:[i.jsx("button",{className:`px-3 py-1 ${a==="tokens"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("tokens"),children:"Tokens"}),i.jsx("button",{className:`px-3 py-1 ${a==="duration"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("duration"),children:"Latency"})]})}),i.jsx("svg",{width:r,height:t,className:"font-mono text-xs",children:i.jsxs("g",{transform:`translate(${u.left}, ${u.top})`,children:[m.map((b,N)=>i.jsx("line",{x1:g(b),y1:0,x2:g(b),y2:x,stroke:"var(--border)",strokeDasharray:"2,2"},`x-grid-${N}`)),f.map((b,N)=>i.jsx("line",{x1:0,y1:S(b),x2:p,y2:S(b),stroke:"var(--border)",strokeDasharray:"2,2"},`y-grid-${N}`)),v.length>1&&i.jsx("polyline",{points:v.map(b=>`${b.x},${b.y}`).join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.slice().sort((b,N)=>(b.is_pareto?1:0)-(N.is_pareto?1:0)).map(b=>{const N=g(k(b)),_=S(b.avg_score),F=b.is_pareto,O=(o==null?void 0:o.candidate_name)===b.candidate_name;return i.jsxs("g",{onMouseEnter:B=>C(b,B),onMouseLeave:()=>c(null),children:[i.jsx("circle",{cx:N,cy:_,r:O?10:F?8:6,fill:F?"var(--accent)":"transparent",stroke:O?"var(--text-primary)":F?"var(--accent)":"var(--text-secondary)",strokeWidth:O?3:2,className:"cursor-pointer transition-all"}),F&&!O&&i.jsx("text",{x:N,y:_-12,textAnchor:"middle",fill:"var(--text-primary)",fontSize:10,className:"pointer-events-none",children:b.candidate_name.replace(/^baseline_/,"").slice(0,15)})]},b.candidate_name)}),i.jsx("line",{x1:0,y1:x,x2:p,y2:x,stroke:"var(--text-secondary)"}),m.map((b,N)=>i.jsxs("g",{transform:`translate(${g(b)}, ${x})`,children:[i.jsx("line",{y2:5,stroke:"var(--text-secondary)"}),i.jsx("text",{y:20,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:10,children:j(b)})]},`x-tick-${N}`)),i.jsx("text",{x:p/2,y:x+40,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:a==="tokens"?"Tokens (cost)":"Duration (latency)"}),i.jsx("line",{x1:0,y1:0,x2:0,y2:x,stroke:"var(--text-secondary)"}),f.map((b,N)=>i.jsxs("g",{transform:`translate(0, ${S(b)})`,children:[i.jsx("line",{x2:-5,stroke:"var(--text-secondary)"}),i.jsxs("text",{x:-10,textAnchor:"end",dominantBaseline:"middle",fill:"var(--text-secondary)",fontSize:10,children:[(b*100).toFixed(0),"%"]})]},`y-tick-${N}`)),i.jsx("text",{transform:`translate(-45, ${x/2}) rotate(-90)`,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:"Score (quality)"})]})}),o&&i.jsxs("div",{className:"absolute z-10 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg shadow-lg p-3 text-sm pointer-events-none",style:{left:Math.min(d.x+15,r-200),top:d.y-10,maxWidth:220},children:[i.jsx("div",{className:"font-medium text-[var(--text-primary)] truncate mb-2",children:o.candidate_name.replace(/^baseline_/,"")}),i.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Score:"}),i.jsxs("span",{className:"text-right font-medium",children:[(o.avg_score*100).toFixed(1),"%"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tokens:"}),i.jsxs("span",{className:"text-right",children:[(o.avg_tokens/1e3).toFixed(1),"K"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Duration:"}),i.jsxs("span",{className:"text-right",children:[o.avg_duration.toFixed(1),"s"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Pass rate:"}),i.jsxs("span",{className:"text-right",children:[o.passed_runs,"/",o.total_runs]})]}),o.is_pareto&&i.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)] text-xs text-[var(--accent)]",children:"Optimal (best tradeoff)"})]})]})}function o1(e=2e3){const[t,n]=w.useState(!1),[r,s]=w.useState(null),a=w.useCallback(async o=>{try{return await navigator.clipboard.writeText(o),n(!0),s(null),setTimeout(()=>n(!1),e),!0}catch{return s("Failed to copy to clipboard"),n(!1),!1}},[e]),l=w.useCallback(()=>{n(!1),s(null)},[]);return{copy:a,copied:t,error:r,reset:l}}function c1({isOpen:e,onClose:t,title:n,itemId:r,itemType:s,isPublic:a,createdByName:l,onTogglePublic:o}){const[c,d]=w.useState(!1),{copy:h,copied:u}=o1(),p=`${window.location.origin}/${s}s/${r}`,x=async()=>{d(!0);try{await o(!a)}finally{d(!1)}},k=()=>{h(p)};return i.jsx(ss,{isOpen:e,onClose:t,title:n,children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between p-3 bg-[var(--bg-tertiary)] rounded",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[a?i.jsx(Uc,{className:"w-5 h-5 text-[var(--accent)]"}):i.jsx(zm,{className:"w-5 h-5 text-[var(--text-secondary)]"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium",children:a?"Public":"Private"}),i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:a?"Anyone with the link can view":"Only you can access"})]})]}),i.jsx("button",{onClick:x,disabled:c,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${a?"bg-[var(--accent)]":"bg-[var(--border)]"} ${c?"opacity-50 cursor-not-allowed":""}`,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${a?"translate-x-6":"translate-x-1"}`})})]}),a&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Share link"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",readOnly:!0,value:p,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono"}),i.jsx(K,{variant:"secondary",onClick:k,children:u?i.jsxs(i.Fragment,{children:[i.jsx(Sg,{className:"w-4 h-4 mr-1"}),"Copied"]}):i.jsxs(i.Fragment,{children:[i.jsx(Eg,{className:"w-4 h-4 mr-1"}),"Copy"]})})]})]}),l&&i.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",i.jsx("span",{className:"text-[var(--text-primary)]",children:l})]}),i.jsx("div",{className:"text-xs text-[var(--text-secondary)] pt-2 border-t border-[var(--border)]",children:a?i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Public ",s,"s can be viewed by anyone with the link."]}),i.jsxs("p",{className:"mt-1",children:["Only you can edit or delete this ",s,"."]})]}):i.jsxs("p",{children:["Make this ",s," public to share it with others."]})})]})})}function u1({job:e,onUpdate:t}){const[n,r]=w.useState(!1),s=async a=>{await Ut.update(e.id,{is_public:a}),t()};return i.jsxs(i.Fragment,{children:[i.jsxs(K,{variant:"secondary",size:"sm",onClick:()=>r(!0),title:e.is_public?"Sharing settings":"Share this job",children:[i.jsx($g,{className:"w-4 h-4 mr-1"}),e.is_public?"Shared":"Share"]}),i.jsx(c1,{isOpen:n,onClose:()=>r(!1),title:"Share Job",itemId:e.id,itemType:"job",isPublic:e.is_public,createdByName:e.created_by_name,onTogglePublic:s})]})}function d1(){const{jobId:e}=fa(),t=cr(),n=qt(),[r,s]=w.useState(null),[a,l]=w.useState(!1),[o,c]=w.useState(null),[d,h]=w.useState([]),[u,p]=w.useState(null),[x,k]=w.useState(null),[g,S]=w.useState("results"),[m,f]=w.useState("score"),[v,j]=w.useState("desc"),[C,b]=w.useState(!1),{data:N,isLoading:_}=fe({queryKey:["jobs",e],queryFn:()=>Ut.get(e),enabled:!!e,refetchInterval:a?2e3:!1}),{data:F=[]}=fe({queryKey:["runs",e],queryFn:()=>Fo.list({job_id:e}),enabled:!!e,refetchInterval:a?2e3:!1}),{data:O}=fe({queryKey:["job-summary",e],queryFn:()=>Fo.getJobSummary(e),enabled:!!e&&(N==null?void 0:N.status)==="completed"}),B=Je({mutationFn:async()=>{l(!0),h([]),p(null),k(null);for await(const R of Ut.start(e))s(R),R.current_candidate&&R.current_task&&p(T=>(T&&(T.candidate!==R.current_candidate||T.task!==R.current_task)&&h(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),{candidate:R.current_candidate,task:R.current_task})),R.event==="error"&&(k(R.message),l(!1),n.invalidateQueries({queryKey:["jobs",e]})),R.event==="complete"&&(p(T=>(T&&h(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),null)),l(!1),n.invalidateQueries({queryKey:["jobs",e]}),n.invalidateQueries({queryKey:["runs",e]}),n.invalidateQueries({queryKey:["job-summary",e]}))}}),G=Je({mutationFn:()=>Ut.cancel(e),onSuccess:()=>{l(!1),n.invalidateQueries({queryKey:["jobs",e]})}});w.useEffect(()=>{(N==null?void 0:N.status)==="running"&&l(!0)},[N==null?void 0:N.status]);const re=w.useMemo(()=>{const R=new Map;for(const T of F)R.has(T.task_name)||R.set(T.task_name,[]),R.get(T.task_name).push(T);return R},[F]),me=w.useMemo(()=>Array.from(re.keys()),[re]),D=w.useMemo(()=>{if(!(O!=null&&O.candidate_summaries))return[];let R=[...O.candidate_summaries];return C&&(R=R.filter(T=>T.is_pareto)),R.sort((T,te)=>{let pe,be;switch(m){case"score":pe=T.avg_score,be=te.avg_score;break;case"tokens":pe=T.avg_tokens,be=te.avg_tokens;break;case"duration":pe=T.avg_duration,be=te.avg_duration;break;case"pass_rate":pe=T.passed_runs/T.total_runs,be=te.passed_runs/te.total_runs;break}return v==="desc"?be-pe:pe-be}),R},[O,m,v,C]),q=R=>{m===R?j(v==="desc"?"asc":"desc"):(f(R),j(R==="tokens"||R==="duration"?"asc":"desc"))},X=({label:R,sortKeyVal:T})=>i.jsx("th",{className:"pb-2 cursor-pointer hover:text-[var(--text-primary)] select-none",onClick:()=>q(T),children:i.jsxs("div",{className:"flex items-center gap-1",children:[R,m===T&&i.jsx(jg,{size:12,className:v==="asc"?"rotate-180":""})]})});if(_)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!N)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Job not found"});const P=Wc(),A=!N.user_id||N.user_id==="anonymous"||P&&N.created_by_name===P,L=N.is_public&&!A,V=()=>{n.invalidateQueries({queryKey:["jobs",e]})},ee=R=>{const T={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};return i.jsx(J,{variant:T[R]||"default",children:R})};return i.jsxs("div",{children:[i.jsx(ma,{items:[{label:"Experiments",path:"/jobs"},{label:N.name||`Job ${N.id.slice(0,8)}`}]}),i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:N.name||`Job ${N.id.slice(0,8)}`}),ee(N.status),N.is_public&&i.jsxs(J,{variant:"info",children:[i.jsx(Uc,{className:"w-3 h-3 mr-1 inline"}),"Public"]})]}),i.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-2 py-0.5 rounded font-mono text-[var(--text-secondary)]",children:[N.id.slice(0,8),"..."]}),i.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[N.candidate_ids.length," candidates × ",N.task_ids.length," tasks = ",N.total_experiments," experiments"]}),N.is_public&&N.created_by_name&&i.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",i.jsx("span",{className:"text-[var(--text-primary)]",children:N.created_by_name})]})]})]}),i.jsxs("div",{className:"flex gap-2",children:[A&&i.jsx(u1,{job:N,onUpdate:V}),L&&i.jsx(J,{variant:"default",children:"View Only"}),A&&N.status==="pending"&&i.jsx(K,{variant:"primary",onClick:()=>B.mutate(),disabled:B.isPending,children:B.isPending?"Starting...":"Start"}),A&&N.status==="running"&&i.jsx(K,{variant:"danger",onClick:()=>G.mutate(),disabled:G.isPending,children:"Cancel"})]})]}),(x||N.error)&&i.jsx(ge,{className:"mb-6 border-red-500/50 bg-red-500/10",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-5 h-5 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-0.5",children:"!"}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium text-red-400",children:"Error"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:x||N.error})]})]})}),(a||r)&&i.jsxs(ge,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("span",{className:"font-medium",children:"Progress"}),i.jsxs("span",{className:"text-[var(--accent)]",children:[(r==null?void 0:r.completed)||N.completed_experiments,"/",(r==null?void 0:r.total)||N.total_experiments]})]}),i.jsx("div",{className:"w-full bg-[var(--bg-primary)] h-2 mb-2",children:i.jsx("div",{className:"h-full bg-[var(--accent)] transition-all",style:{width:`${((r==null?void 0:r.completed)||N.completed_experiments)/((r==null?void 0:r.total)||N.total_experiments)*100}%`}})}),(r==null?void 0:r.message)&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r.message}),a&&i.jsxs("div",{className:"mt-4 border-t border-[var(--border)] pt-4",children:[(r==null?void 0:r.current_candidate)&&(r==null?void 0:r.current_task)&&i.jsxs("div",{className:"mb-3",children:[i.jsx("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:"Currently Running"}),i.jsxs("div",{className:"flex items-center gap-2 mt-1 px-3 py-2 bg-blue-500/10 border border-blue-500/30 rounded",children:[i.jsx("div",{className:"w-2 h-2 bg-blue-400 rounded-full animate-pulse"}),i.jsx("span",{className:"font-medium",children:r.current_candidate}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{children:r.current_task})]})]}),d.length>0&&i.jsxs("div",{children:[i.jsxs("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:["Completed (",d.length,")"]}),i.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto space-y-1",children:d.map((R,T)=>i.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-500/10 border border-green-500/30 rounded text-sm",children:[i.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}),i.jsx("span",{className:"font-medium",children:R.candidate_name}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{children:R.task_name})]},`${R.candidate_name}-${R.task_name}-${T}`))})]})]})]}),(N.status==="completed"||F.length>0)&&i.jsxs("div",{className:"flex gap-1 mb-6 border-b border-[var(--border)]",children:[i.jsxs("button",{onClick:()=>S("results"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="results"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(wg,{size:16}),"Results"]}),i.jsxs("button",{onClick:()=>S("compare"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="compare"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(Lg,{size:16}),"Compare"]}),i.jsxs("button",{onClick:()=>S("runs"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="runs"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(zg,{size:16}),"Runs (",F.length,")"]})]}),g==="results"&&i.jsxs(i.Fragment,{children:[O&&O.candidate_summaries.length>1&&i.jsxs(ge,{className:"mb-6",children:[i.jsx("div",{className:"flex items-start justify-between mb-4",children:i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium",children:"Quality vs. Cost Tradeoff"}),i.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:["Candidates on the frontier (connected line) are ",i.jsx("strong",{children:"optimal"})," - no other candidate beats them on both score AND cost."]})]})}),i.jsxs("div",{className:"mb-4 p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs text-[var(--text-secondary)]",children:[i.jsx("strong",{className:"text-[var(--text-primary)]",children:"How optimal tradeoffs are calculated:"})," A candidate is optimal if there's no other candidate that has both a higher score AND lower cost. For example, if Candidate A has 95% score at 50K tokens and Candidate B has 90% score at 40K tokens, both are optimal - A is better on score, B is better on cost. But if Candidate C has 85% score at 60K tokens, it's ",i.jsx("em",{children:"not"})," optimal because B beats it on both metrics."]}),i.jsx(l1,{summaries:O.candidate_summaries,height:350})]}),O&&i.jsxs(ge,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h3",{className:"font-medium",children:"Results Summary"}),i.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:C,onChange:R=>b(R.target.checked),className:"rounded border-[var(--border)]"}),"Optimal only"]})]}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"text-left text-[var(--text-secondary)] border-b border-[var(--border)]",children:[i.jsx("th",{className:"pb-2",children:"Candidate"}),i.jsx(X,{label:"Score",sortKeyVal:"score"}),i.jsx(X,{label:"Tokens",sortKeyVal:"tokens"}),i.jsx(X,{label:"Duration",sortKeyVal:"duration"}),i.jsx(X,{label:"Pass Rate",sortKeyVal:"pass_rate"}),i.jsx("th",{className:"pb-2",children:"Optimal"})]})}),i.jsx("tbody",{children:D.map((R,T)=>i.jsxs("tr",{className:`border-b border-[var(--border)] ${T===0?"bg-[var(--accent)]/10":""}`,children:[i.jsxs("td",{className:"py-2 font-medium",children:[T===0&&i.jsx("span",{className:"text-[var(--accent)] mr-1",children:"#1"}),R.candidate_name.replace(/^baseline_/,"")]}),i.jsxs("td",{className:"py-2",children:[(R.avg_score*100).toFixed(1),"%"]}),i.jsxs("td",{className:"py-2",children:[(R.avg_tokens/1e3).toFixed(1),"K"]}),i.jsxs("td",{className:"py-2",children:[R.avg_duration.toFixed(1),"s"]}),i.jsxs("td",{className:"py-2",children:[R.passed_runs,"/",R.total_runs]}),i.jsx("td",{className:"py-2",children:R.is_pareto&&i.jsx(J,{variant:"success",children:"Optimal"})})]},R.candidate_name))})]})}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-3",children:"Click column headers to sort. The #1 ranked candidate is highlighted based on your sort criteria."})]}),!O&&i.jsx(ge,{children:i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Results will appear here after the job completes.":"No results yet. Start the job to see results."})})]}),g==="compare"&&i.jsxs(ge,{children:[i.jsx("h3",{className:"font-medium mb-4",children:"Compare Candidates by Task"}),me.length>0?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:me.map(R=>i.jsx("button",{onClick:()=>c(o===R?null:R),className:`px-3 py-1 text-sm rounded border transition-colors ${o===R?"bg-[var(--accent)] text-white border-[var(--accent)]":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:R},R))}),o&&re.get(o)?i.jsx(i1,{runs:re.get(o).map(R=>({id:R.id,candidate_name:R.candidate_name,tokens_input:0,tokens_output:0,tokens_total:R.tokens_total,duration_seconds:R.duration_seconds,score:R.score,passed:R.passed,is_pareto:R.is_pareto}))}):i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"Select a task above to compare how different candidates performed on it."})]}):i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Comparison data will appear here after runs complete.":"No runs yet. Start the job to compare candidates."})]}),g==="runs"&&i.jsxs(ge,{children:[i.jsx("h3",{className:"font-medium mb-4",children:"All Experiment Runs"}),F.length===0?i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Runs will appear here as they complete. See progress above for live status.":"No runs yet. Start the job to see results."}):i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:F.map(R=>i.jsxs("div",{className:"p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] cursor-pointer hover:border-[var(--accent-dim)] transition-colors",onClick:()=>t(`/runs/${R.id}`),children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("span",{className:`text-lg font-bold ${R.passed?"text-green-400":"text-red-400"}`,children:[(R.score*100).toFixed(0),"%"]}),R.is_pareto&&i.jsx(J,{variant:"success",children:"Optimal"})]}),i.jsx("div",{className:"text-sm font-medium truncate",title:R.candidate_name,children:R.candidate_name.replace(/^baseline_/,"")}),i.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:R.task_name}),i.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:[(R.tokens_total/1e3).toFixed(1),"K tokens"]}),i.jsxs("span",{children:[R.duration_seconds.toFixed(1),"s"]})]})]},R.id))})]})]})}const vn={input:"bg-blue-500",output:"bg-emerald-500",inputText:"text-blue-400",outputText:"text-emerald-400"};function Rd(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Md({input:e,output:t,maxValue:n,height:r=24,showLabels:s=!0}){const a=e+t;if(a===0)return i.jsx("div",{className:"flex items-center gap-2 w-full",children:i.jsx("div",{className:"rounded bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`}})});const l=n>0?a/n*100:100;return i.jsxs("div",{className:"flex items-center gap-3 w-full",children:[i.jsx("div",{className:"relative rounded overflow-hidden bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`},children:i.jsxs("div",{className:"h-full flex transition-all duration-300",style:{width:`${l}%`},children:[i.jsx("div",{className:`h-full ${vn.input} transition-all`,style:{width:`${e/a*100}%`},title:`Input: ${e.toLocaleString()} tokens`}),i.jsx("div",{className:`h-full ${vn.output} transition-all`,style:{width:`${t/a*100}%`},title:`Output: ${t.toLocaleString()} tokens`})]})}),s&&i.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono text-[var(--text-secondary)] min-w-[90px] justify-end",children:[i.jsxs("span",{className:vn.inputText,children:["↑",Rd(e)]}),i.jsx("span",{children:"/"}),i.jsxs("span",{className:vn.outputText,children:["↓",Rd(t)]})]})]})}function Sl({label:e,value:t,color:n="default"}){const r={default:"text-[var(--text-primary)]",input:vn.inputText,output:vn.outputText}[n];return i.jsxs("div",{className:"flex-1 p-3 bg-[var(--bg-primary)] border border-[var(--border)] rounded",children:[i.jsx("div",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e}),i.jsx("div",{className:`font-mono text-lg font-bold ${r}`,children:t})]})}function Zm({tokensInput:e,tokensOutput:t,tokensTotal:n,turns:r}){const s=n>0?Math.round(e/n*100):0,a=n>0?Math.round(t/n*100):0,l=w.useMemo(()=>{if(!r||r.length===0)return null;let c=0,d=0;return r.map(h=>(c+=h.input,d+=h.output,{input:c,output:d,total:c+d}))},[r]),o=l?Math.max(...l.map(c=>c.total)):n;return i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-4",children:"Token Usage"}),i.jsx("div",{className:"mb-4",children:i.jsx(Md,{input:e,output:t,maxValue:n,height:32})}),i.jsxs("div",{className:"flex items-center gap-6 text-xs mb-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:`w-3 h-3 rounded ${vn.input}`}),i.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Input (",s,"%)"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:`w-3 h-3 rounded ${vn.output}`}),i.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Output (",a,"%)"]})]})]}),i.jsxs("div",{className:"flex gap-3 mb-4",children:[i.jsx(Sl,{label:"Input Tokens",value:e.toLocaleString(),color:"input"}),i.jsx(Sl,{label:"Output Tokens",value:t.toLocaleString(),color:"output"}),i.jsx(Sl,{label:"Total Tokens",value:n.toLocaleString()})]}),l&&l.length>1&&i.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[i.jsxs("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:["Token Accumulation (",r.length," turns)"]}),i.jsx("div",{className:"space-y-2",children:r.map((c,d)=>i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--bg-primary)] border border-[var(--border)] flex items-center justify-center text-xs font-medium",children:d+1}),i.jsx("div",{className:"flex-1",children:i.jsx(Md,{input:l[d].input,output:l[d].output,maxValue:o,height:16})})]},d))})]}),i.jsx("div",{className:"mt-4 text-xs text-[var(--text-secondary)] border-t border-[var(--border)] pt-3",children:"Token usage affects API cost. Input tokens are typically cheaper than output tokens."})]})}function f1(){const{runId:e}=fa(),{data:t,isLoading:n}=fe({queryKey:["runs",e],queryFn:()=>Fo.get(e),enabled:!!e});return n?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?i.jsxs("div",{children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(ma,{items:[{label:"Experiments",path:"/jobs"},{label:"Job",path:`/jobs/${t.job_id}`},{label:t.candidate_name}]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:t.candidate_name}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{className:"text-lg",children:t.task_name}),t.is_pareto&&i.jsx(J,{variant:"success",children:"Optimal"})]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[i.jsx(Ma,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),i.jsx(Ma,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),i.jsx(Ma,{label:"Duration",value:`${t.duration_seconds.toFixed(1)}s`}),i.jsx(Ma,{label:"Status",value:t.passed?"Passed":"Failed",status:t.passed?"success":"error"})]}),i.jsx(Zm,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),t.reasoning&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:t.reasoning}),t.criteria_results.length>0&&i.jsx("div",{className:"space-y-2",children:t.criteria_results.map(r=>i.jsx("div",{className:"flex items-start justify-between p-3 bg-[var(--bg-primary)] border border-[var(--border)]",children:i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-medium",children:r.name}),i.jsxs(J,{variant:r.passed?"success":"error",children:[(r.score*100).toFixed(0),"%"]})]}),r.reasoning&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r.reasoning})]})},r.name))})]}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created.length>0&&i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),i.jsx("div",{className:"space-y-1",children:t.files_created.map(r=>i.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:r},r))})]}),Object.keys(t.trace).length>0&&i.jsx(Gm,{trace:t.trace})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Run not found"})}function Ma({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return i.jsxs(ge,{children:[i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),i.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function h1(){const{testId:e}=fa(),{data:t,isLoading:n}=fe({queryKey:["tests",e],queryFn:()=>Ts.get(e),enabled:!!e}),{data:r}=fe({queryKey:["configs",t==null?void 0:t.agent_id],queryFn:()=>Xn.get(t.agent_id),enabled:!!(t!=null&&t.agent_id)});if(n)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!t)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Test not found"});const s={completed:"success",failed:"error",running:"info",pending:"default",cancelled:"warning"};return i.jsxs("div",{children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(ma,{items:[{label:"Agents",path:"/agents"},...r?[{label:r.name,path:`/agents/${r.id}`}]:[],{label:`Test ${t.id.slice(0,8)}`}]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:"Test Run"}),r&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"•"}),i.jsx("span",{className:"text-lg",children:r.name})]}),i.jsx(J,{variant:s[t.status]||"default",children:t.status})]}),i.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:["ID: ",t.id.slice(0,8),"..."]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[i.jsx(za,{label:"Duration",value:`${t.duration_seconds.toFixed(2)}s`}),i.jsx(za,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),t.score!==null&&i.jsx(za,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),i.jsx(za,{label:"Status",value:t.status.charAt(0).toUpperCase()+t.status.slice(1),status:t.status==="completed"?"success":t.status==="failed"?"error":void 0})]}),i.jsx(Zm,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Prompt"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)] font-mono",children:t.prompt})]}),t.error&&i.jsxs(ge,{className:"mb-6 border-red-500/30 bg-red-500/5",children:[i.jsx("h3",{className:"font-medium mb-3 text-red-400",children:"Error"}),i.jsx("pre",{className:"text-sm text-red-300 overflow-x-auto whitespace-pre-wrap",children:t.error})]}),t.reasoning&&i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.reasoning})]}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created&&t.files_created.length>0&&i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),i.jsx("div",{className:"space-y-1",children:t.files_created.map(a=>i.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:a},a))})]}),t.trace&&Object.keys(t.trace).length>0&&i.jsx(Gm,{trace:t.trace}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Timestamps"}),i.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Created:"}),i.jsx("div",{className:"font-mono",children:new Date(t.created_at).toLocaleString()})]}),t.started_at&&i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Started:"}),i.jsx("div",{className:"font-mono",children:new Date(t.started_at).toLocaleString()})]}),t.completed_at&&i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Completed:"}),i.jsx("div",{className:"font-mono",children:new Date(t.completed_at).toLocaleString()})]})]})]})]})}function za({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return i.jsxs(ge,{children:[i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),i.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function m1(){const{deploymentId:e}=fa(),{data:t,isLoading:n}=fe({queryKey:["deployments",e],queryFn:()=>g0.get(e),enabled:!!e}),r=t==null?void 0:t.versions.find(a=>a.id===t.current_version_id),{data:s}=fe({queryKey:["configs",r==null?void 0:r.config_id],queryFn:()=>Xn.get(r.config_id),enabled:!!(r!=null&&r.config_id)});return n?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"mb-4 flex-shrink-0",children:[i.jsx(ma,{items:[{label:"Agents",path:"/agents"},{label:t.name}]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Dg,{size:20,className:"text-[var(--accent)]"}),i.jsx("h2",{className:"text-xl font-bold",children:t.name}),r&&i.jsxs(J,{variant:"info",children:["v",r.version]})]}),t.description&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:t.description})]}),i.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[i.jsx("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:i.jsxs("div",{className:"flex-1 overflow-y-auto space-y-5",children:[i.jsxs("div",{className:"flex items-center gap-4 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:["Created ",new Date(t.created_at).toLocaleDateString()]}),i.jsxs("span",{children:["Updated ",new Date(t.updated_at).toLocaleDateString()]}),i.jsxs("span",{children:[t.versions.length," version",t.versions.length!==1?"s":""]})]}),s&&i.jsxs(Pn,{to:`/agents/${s.id}`,className:"flex items-center gap-2 p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-sm",children:[i.jsx(Mm,{size:14,className:"text-[var(--accent)]"}),i.jsxs("span",{children:["Agent: ",i.jsx("span",{className:"font-medium",children:s.name})]})]}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider mb-3",children:"Version History"}),t.versions.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"No versions yet."}):i.jsx("div",{className:"space-y-2",children:t.versions.map(a=>i.jsx(p1,{version:a,isActive:a.id===t.current_version_id},a.id))})]})]})}),i.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[i.jsx(Fm,{size:16,className:"text-[var(--text-secondary)]"}),i.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),i.jsx("div",{className:"flex-1 min-h-0",children:s?i.jsx(Jm,{agent:s}):i.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-secondary)] text-sm",children:r?"Loading agent configuration...":"No active version to test."})})]})]})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Deployment not found"})}function p1({version:e,isActive:t}){const n=e.config_snapshot;return i.jsxs("div",{className:`p-3 rounded-md border transition-colors ${t?"border-[var(--accent)] bg-[var(--accent-dim)]":"border-[var(--border)] bg-[var(--bg-secondary)]"}`,children:[i.jsxs("div",{className:"flex items-center justify-between mb-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Bg,{size:12,className:"text-[var(--text-secondary)]"}),i.jsxs("span",{className:"text-sm font-medium",children:["v",e.version]}),t&&i.jsx(J,{variant:"success",children:"Active"}),i.jsx(J,{variant:e.source==="optimize"?"info":"default",children:e.source})]}),i.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)]",children:[i.jsx(Rm,{size:11}),i.jsx("span",{children:new Date(e.created_at).toLocaleString()})]})]}),e.description&&i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e.description}),Object.keys(n).length>0&&i.jsxs("div",{className:"mt-1",children:[i.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)] mb-1",children:[i.jsx(Og,{size:11}),i.jsx("span",{children:"Config"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-xs",children:["framework"in n&&n.framework?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Framework"}),i.jsx("span",{className:"font-mono",children:String(n.framework)})]}):null,"model"in n&&n.model?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Model"}),i.jsx("span",{className:"font-mono",children:String(n.model)})]}):null,"tools"in n&&n.tools?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tools"}),i.jsx("span",{className:"font-mono truncate",children:Array.isArray(n.tools)?n.tools.join(", "):String(n.tools)})]}):null]})]})]})}function v1(){const{authConfig:e,isLoading:t,error:n,login:r,loginWithGitHub:s,clearError:a}=qc(),[l,o]=w.useState(""),[c,d]=w.useState("");w.useEffect(()=>{n&&a()},[l,c]);const h=async p=>{p.preventDefault(),!(!l||!c)&&await r(l,c)},u=()=>{s()};return i.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:i.jsxs("div",{className:"w-full max-w-md",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:"Flow"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:"Sign in to access the optimization dashboard"})]}),i.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] p-6 space-y-6",children:[n&&i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[var(--error)]/10 border border-[var(--error)]/20 text-[var(--error)]",children:[i.jsx(Om,{size:18,className:"mt-0.5 flex-shrink-0"}),i.jsx("p",{className:"text-sm",children:n})]}),(e==null?void 0:e.mode)==="basic"&&i.jsxs("form",{onSubmit:h,className:"space-y-4",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Username"}),i.jsxs("div",{className:"relative",children:[i.jsx(Dm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),i.jsx("input",{type:"text",value:l,onChange:p=>o(p.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter username",autoComplete:"username",autoFocus:!0})]})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Password"}),i.jsxs("div",{className:"relative",children:[i.jsx(zm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),i.jsx("input",{type:"password",value:c,onChange:p=>d(p.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter password",autoComplete:"current-password"})]})]}),i.jsx(K,{type:"submit",variant:"primary",className:"w-full justify-center",loading:t,disabled:!l||!c,children:"Sign In"})]}),(e==null?void 0:e.mode)==="github"&&i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center",children:"Sign in with your GitHub account to continue"}),i.jsx(K,{onClick:u,variant:"secondary",className:"w-full justify-center",icon:Rg,children:"Continue with GitHub"})]})]})]})})}function x1({children:e}){const{authConfig:t,isLoadingConfig:n,isAuthenticated:r,loadAuthConfig:s,handleOAuthCallback:a}=qc();return w.useEffect(()=>{s()},[s]),w.useEffect(()=>{n||a()},[n,a]),n?i.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center",children:i.jsxs("div",{className:"text-center",children:[i.jsx(ha,{className:"w-8 h-8 animate-spin text-[var(--accent)] mx-auto mb-4"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:"Loading..."})]})}):t!=null&&t.enabled&&!r?i.jsx(v1,{}):i.jsx(i.Fragment,{children:e})}function y1(){return i.jsx(dg,{children:i.jsx(x1,{children:i.jsx(rg,{children:i.jsxs(ht,{path:"/",element:i.jsx(O0,{}),children:[i.jsx(ht,{index:!0,element:i.jsx(Ld,{})}),i.jsx(ht,{path:"agents",element:i.jsx(Ld,{})}),i.jsx(ht,{path:"agents/:agentId",element:i.jsx(q0,{})}),i.jsx(ht,{path:"tasks",element:i.jsx(X0,{})}),i.jsx(ht,{path:"jobs",element:i.jsx(r1,{})}),i.jsx(ht,{path:"jobs/:jobId",element:i.jsx(d1,{})}),i.jsx(ht,{path:"runs/:runId",element:i.jsx(f1,{})}),i.jsx(ht,{path:"tests/:testId",element:i.jsx(h1,{})}),i.jsx(ht,{path:"deployments/:deploymentId",element:i.jsx(m1,{})})]})})})})}const zd=localStorage.getItem("flow-theme");if(zd)try{const{state:e}=JSON.parse(zd);e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}catch{}const g1=new Xx({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}});Nl.createRoot(document.getElementById("root")).render(i.jsx(Vo.StrictMode,{children:i.jsx(Zx,{client:g1,children:i.jsx(y1,{})})})); diff --git a/src/flow/ui/ui/assets/index-CPHXZezc.js b/src/flow/ui/ui/assets/index-CPHXZezc.js new file mode 100644 index 0000000000000000000000000000000000000000..3549fe2eafb354a8faed69f1fe9de45f0a25ad74 --- /dev/null +++ b/src/flow/ui/ui/assets/index-CPHXZezc.js @@ -0,0 +1,347 @@ +var nu=e=>{throw TypeError(e)};var Hi=(e,t,n)=>t.has(e)||nu("Cannot "+n);var y=(e,t,n)=>(Hi(e,t,"read from private field"),n?n.call(e):t.get(e)),$=(e,t,n)=>t.has(e)?nu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),z=(e,t,n,r)=>(Hi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),H=(e,t,n)=>(Hi(e,t,"access private method"),n);var pa=(e,t,n,r)=>({set _(s){z(e,t,s,n)},get _(){return y(e,t,r)}});function lp(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();function Yd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xd={exports:{}},Ni={},Zd={exports:{}},Y={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var ia=Symbol.for("react.element"),op=Symbol.for("react.portal"),cp=Symbol.for("react.fragment"),up=Symbol.for("react.strict_mode"),dp=Symbol.for("react.profiler"),fp=Symbol.for("react.provider"),hp=Symbol.for("react.context"),mp=Symbol.for("react.forward_ref"),pp=Symbol.for("react.suspense"),xp=Symbol.for("react.memo"),vp=Symbol.for("react.lazy"),ru=Symbol.iterator;function yp(e){return e===null||typeof e!="object"?null:(e=ru&&e[ru]||e["@@iterator"],typeof e=="function"?e:null)}var ef={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},tf=Object.assign,nf={};function Yr(e,t,n){this.props=e,this.context=t,this.refs=nf,this.updater=n||ef}Yr.prototype.isReactComponent={};Yr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Yr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function rf(){}rf.prototype=Yr.prototype;function Vo(e,t,n){this.props=e,this.context=t,this.refs=nf,this.updater=n||ef}var Ko=Vo.prototype=new rf;Ko.constructor=Vo;tf(Ko,Yr.prototype);Ko.isPureReactComponent=!0;var su=Array.isArray,sf=Object.prototype.hasOwnProperty,Ho={current:null},af={key:!0,ref:!0,__self:!0,__source:!0};function lf(e,t,n){var r,s={},i=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(i=""+t.key),t)sf.call(t,r)&&!af.hasOwnProperty(r)&&(s[r]=t[r]);var o=arguments.length-2;if(o===1)s.children=n;else if(1>>1,ee=P[V];if(0>>1;Vs(te,L))pes(Se,te)?(P[V]=Se,P[pe]=L,V=pe):(P[V]=te,P[T]=L,V=T);else if(pes(Se,L))P[V]=Se,P[pe]=L,V=pe;else break e}}return A}function s(P,A){var L=P.sortIndex-A.sortIndex;return L!==0?L:P.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var c=[],u=[],d=1,f=null,m=3,v=!1,k=!1,g=!1,b=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,h=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(P){for(var A=n(u);A!==null;){if(A.callback===null)r(u);else if(A.startTime<=P)r(u),A.sortIndex=A.expirationTime,t(c,A);else break;A=n(u)}}function w(P){if(g=!1,x(P),!k)if(n(c)!==null)k=!0,W(C);else{var A=n(u);A!==null&&X(w,A.startTime-P)}}function C(P,A){k=!1,g&&(g=!1,p(_),_=-1),v=!0;var L=m;try{for(x(A),f=n(c);f!==null&&(!(f.expirationTime>A)||P&&!B());){var V=f.callback;if(typeof V=="function"){f.callback=null,m=f.priorityLevel;var ee=V(f.expirationTime<=A);A=e.unstable_now(),typeof ee=="function"?f.callback=ee:f===n(c)&&r(c),x(A)}else r(c);f=n(c)}if(f!==null)var R=!0;else{var T=n(u);T!==null&&X(w,T.startTime-A),R=!1}return R}finally{f=null,m=L,v=!1}}var S=!1,N=null,_=-1,F=5,O=-1;function B(){return!(e.unstable_now()-OP||125V?(P.sortIndex=L,t(u,P),n(c)===null&&P===n(u)&&(g?(p(_),_=-1):g=!0,X(w,L-V))):(P.sortIndex=ee,t(c,P),k||v||(k=!0,W(C))),P},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(P){var A=m;return function(){var L=m;m=A;try{return P.apply(this,arguments)}finally{m=L}}}})(ff);df.exports=ff;var Tp=df.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Op=j,et=Tp;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_l=Object.prototype.hasOwnProperty,Lp=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,iu={},lu={};function Rp(e){return _l.call(lu,e)?!0:_l.call(iu,e)?!1:Lp.test(e)?lu[e]=!0:(iu[e]=!0,!1)}function Mp(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function zp(e,t,n,r){if(t===null||typeof t>"u"||Mp(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Be(e,t,n,r,s,i,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=l}var Oe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Oe[e]=new Be(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Oe[t]=new Be(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Oe[e]=new Be(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Oe[e]=new Be(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Oe[e]=new Be(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Oe[e]=new Be(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Oe[e]=new Be(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Oe[e]=new Be(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Oe[e]=new Be(e,5,!1,e.toLowerCase(),null,!1,!1)});var Go=/[\-:]([a-z])/g;function Jo(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Go,Jo);Oe[t]=new Be(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Go,Jo);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Go,Jo);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!1,!1)});Oe.xlinkHref=new Be("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!0,!0)});function Yo(e,t,n,r){var s=Oe.hasOwnProperty(t)?Oe[t]:null;(s!==null?s.type!==0:r||!(2o||s[l]!==i[o]){var c=` +`+s[l].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{Gi=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?vs(e):""}function Fp(e){switch(e.tag){case 5:return vs(e.type);case 16:return vs("Lazy");case 13:return vs("Suspense");case 19:return vs("SuspenseList");case 0:case 2:case 15:return e=Ji(e.type,!1),e;case 11:return e=Ji(e.type.render,!1),e;case 1:return e=Ji(e.type,!0),e;default:return""}}function Ol(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case fr:return"Fragment";case dr:return"Portal";case El:return"Profiler";case Xo:return"StrictMode";case Pl:return"Suspense";case Tl:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case pf:return(e.displayName||"Context")+".Consumer";case mf:return(e._context.displayName||"Context")+".Provider";case Zo:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ec:return t=e.displayName||null,t!==null?t:Ol(e.type)||"Memo";case Xt:t=e._payload,e=e._init;try{return Ol(e(t))}catch{}}return null}function Ip(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ol(t);case 8:return t===Xo?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function En(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function vf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Dp(e){var t=vf(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(l){r=""+l,i.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ya(e){e._valueTracker||(e._valueTracker=Dp(e))}function yf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=vf(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ga(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ll(e,t){var n=t.checked;return me({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function cu(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=En(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function gf(e,t){t=t.checked,t!=null&&Yo(e,"checked",t,!1)}function Rl(e,t){gf(e,t);var n=En(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ml(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ml(e,t.type,En(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function uu(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ml(e,t,n){(t!=="number"||Ga(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var ys=Array.isArray;function br(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=ga.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Rs(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ks={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Ap=["Webkit","ms","Moz","O"];Object.keys(ks).forEach(function(e){Ap.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ks[t]=ks[e]})});function bf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||ks.hasOwnProperty(e)&&ks[e]?(""+t).trim():t+"px"}function Nf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=bf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var $p=me({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Il(e,t){if(t){if($p[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function Dl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Al=null;function tc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var $l=null,Nr=null,Sr=null;function hu(e){if(e=ca(e)){if(typeof $l!="function")throw Error(E(280));var t=e.stateNode;t&&(t=Pi(t),$l(e.stateNode,e.type,t))}}function Sf(e){Nr?Sr?Sr.push(e):Sr=[e]:Nr=e}function Cf(){if(Nr){var e=Nr,t=Sr;if(Sr=Nr=null,hu(e),t)for(e=0;e>>=0,e===0?32:31-(Yp(e)/Xp|0)|0}var ja=64,wa=4194304;function gs(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Za(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~s;o!==0?r=gs(o):(i&=l,i!==0&&(r=gs(i)))}else l=n&~s,l!==0?r=gs(l):i!==0&&(r=gs(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function la(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-jt(t),e[t]=n}function nx(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Ns),ku=" ",bu=!1;function Hf(e,t){switch(e){case"keyup":return Tx.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function qf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var hr=!1;function Lx(e,t){switch(e){case"compositionend":return qf(t);case"keypress":return t.which!==32?null:(bu=!0,ku);case"textInput":return e=t.data,e===ku&&bu?null:e;default:return null}}function Rx(e,t){if(hr)return e==="compositionend"||!cc&&Hf(e,t)?(e=Vf(),Aa=ic=fn=null,hr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=_u(n)}}function Yf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Yf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Xf(){for(var e=window,t=Ga();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ga(e.document)}return t}function uc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Bx(e){var t=Xf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Yf(n.ownerDocument.documentElement,n)){if(r!==null&&uc(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=Eu(n,i);var l=Eu(n,r);s&&l&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,mr=null,Hl=null,Cs=null,ql=!1;function Pu(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ql||mr==null||mr!==Ga(r)||(r=mr,"selectionStart"in r&&uc(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Cs&&As(Cs,r)||(Cs=r,r=ni(Hl,"onSelect"),0vr||(e.current=Zl[vr],Zl[vr]=null,vr--)}function ie(e,t){vr++,Zl[vr]=e.current,e.current=t}var Pn={},Fe=Ln(Pn),qe=Ln(!1),Zn=Pn;function Br(e,t){var n=e.type.contextTypes;if(!n)return Pn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function We(e){return e=e.childContextTypes,e!=null}function si(){ue(qe),ue(Fe)}function Fu(e,t,n){if(Fe.current!==Pn)throw Error(E(168));ie(Fe,t),ie(qe,n)}function lh(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(E(108,Ip(e)||"Unknown",s));return me({},n,r)}function ai(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Pn,Zn=Fe.current,ie(Fe,e),ie(qe,qe.current),!0}function Iu(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=lh(e,t,Zn),r.__reactInternalMemoizedMergedChildContext=e,ue(qe),ue(Fe),ie(Fe,e)):ue(qe),ie(qe,n)}var Mt=null,Ti=!1,ul=!1;function oh(e){Mt===null?Mt=[e]:Mt.push(e)}function ev(e){Ti=!0,oh(e)}function Rn(){if(!ul&&Mt!==null){ul=!0;var e=0,t=ae;try{var n=Mt;for(ae=1;e>=l,s-=l,At=1<<32-jt(t)+s|n<_?(F=N,N=null):F=N.sibling;var O=m(p,N,x[_],w);if(O===null){N===null&&(N=F);break}e&&N&&O.alternate===null&&t(p,N),h=i(O,h,_),S===null?C=O:S.sibling=O,S=O,N=F}if(_===x.length)return n(p,N),de&&Fn(p,_),C;if(N===null){for(;__?(F=N,N=null):F=N.sibling;var B=m(p,N,O.value,w);if(B===null){N===null&&(N=F);break}e&&N&&B.alternate===null&&t(p,N),h=i(B,h,_),S===null?C=B:S.sibling=B,S=B,N=F}if(O.done)return n(p,N),de&&Fn(p,_),C;if(N===null){for(;!O.done;_++,O=x.next())O=f(p,O.value,w),O!==null&&(h=i(O,h,_),S===null?C=O:S.sibling=O,S=O);return de&&Fn(p,_),C}for(N=r(p,N);!O.done;_++,O=x.next())O=v(N,p,_,O.value,w),O!==null&&(e&&O.alternate!==null&&N.delete(O.key===null?_:O.key),h=i(O,h,_),S===null?C=O:S.sibling=O,S=O);return e&&N.forEach(function(G){return t(p,G)}),de&&Fn(p,_),C}function b(p,h,x,w){if(typeof x=="object"&&x!==null&&x.type===fr&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case va:e:{for(var C=x.key,S=h;S!==null;){if(S.key===C){if(C=x.type,C===fr){if(S.tag===7){n(p,S.sibling),h=s(S,x.props.children),h.return=p,p=h;break e}}else if(S.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Xt&&$u(C)===S.type){n(p,S.sibling),h=s(S,x.props),h.ref=fs(p,S,x),h.return=p,p=h;break e}n(p,S);break}else t(p,S);S=S.sibling}x.type===fr?(h=Xn(x.props.children,p.mode,w,x.key),h.return=p,p=h):(w=qa(x.type,x.key,x.props,null,p.mode,w),w.ref=fs(p,h,x),w.return=p,p=w)}return l(p);case dr:e:{for(S=x.key;h!==null;){if(h.key===S)if(h.tag===4&&h.stateNode.containerInfo===x.containerInfo&&h.stateNode.implementation===x.implementation){n(p,h.sibling),h=s(h,x.children||[]),h.return=p,p=h;break e}else{n(p,h);break}else t(p,h);h=h.sibling}h=yl(x,p.mode,w),h.return=p,p=h}return l(p);case Xt:return S=x._init,b(p,h,S(x._payload),w)}if(ys(x))return k(p,h,x,w);if(ls(x))return g(p,h,x,w);Ea(p,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,h!==null&&h.tag===6?(n(p,h.sibling),h=s(h,x),h.return=p,p=h):(n(p,h),h=vl(x,p.mode,w),h.return=p,p=h),l(p)):n(p,h)}return b}var Vr=fh(!0),hh=fh(!1),oi=Ln(null),ci=null,jr=null,mc=null;function pc(){mc=jr=ci=null}function xc(e){var t=oi.current;ue(oi),e._currentValue=t}function no(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function _r(e,t){ci=e,mc=jr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(He=!0),e.firstContext=null)}function ct(e){var t=e._currentValue;if(mc!==e)if(e={context:e,memoizedValue:t,next:null},jr===null){if(ci===null)throw Error(E(308));jr=e,ci.dependencies={lanes:0,firstContext:e}}else jr=jr.next=e;return t}var An=null;function vc(e){An===null?An=[e]:An.push(e)}function mh(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,vc(t)):(n.next=s.next,s.next=n),t.interleaved=n,Kt(e,r)}function Kt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Zt=!1;function yc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ph(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ut(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function wn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ne&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Kt(e,n)}return s=r.interleaved,s===null?(t.next=t,vc(r)):(t.next=s.next,s.next=t),r.interleaved=t,Kt(e,n)}function Ua(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,rc(e,n)}}function Uu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=l:i=i.next=l,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ui(e,t,n,r){var s=e.updateQueue;Zt=!1;var i=s.firstBaseUpdate,l=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var c=o,u=c.next;c.next=null,l===null?i=u:l.next=u,l=c;var d=e.alternate;d!==null&&(d=d.updateQueue,o=d.lastBaseUpdate,o!==l&&(o===null?d.firstBaseUpdate=u:o.next=u,d.lastBaseUpdate=c))}if(i!==null){var f=s.baseState;l=0,d=u=c=null,o=i;do{var m=o.lane,v=o.eventTime;if((r&m)===m){d!==null&&(d=d.next={eventTime:v,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var k=e,g=o;switch(m=t,v=n,g.tag){case 1:if(k=g.payload,typeof k=="function"){f=k.call(v,f,m);break e}f=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=g.payload,m=typeof k=="function"?k.call(v,f,m):k,m==null)break e;f=me({},f,m);break e;case 2:Zt=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,m=s.effects,m===null?s.effects=[o]:m.push(o))}else v={eventTime:v,lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},d===null?(u=d=v,c=f):d=d.next=v,l|=m;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;m=o,o=m.next,m.next=null,s.lastBaseUpdate=m,s.shared.pending=null}}while(!0);if(d===null&&(c=f),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=d,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);nr|=l,e.lanes=l,e.memoizedState=f}}function Bu(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=fl.transition;fl.transition={};try{e(!1),t()}finally{ae=n,fl.transition=r}}function Lh(){return ut().memoizedState}function sv(e,t,n){var r=bn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Rh(e))Mh(t,n);else if(n=mh(e,t,n,r),n!==null){var s=$e();wt(n,e,r,s),zh(n,t,r)}}function av(e,t,n){var r=bn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Rh(e))Mh(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var l=t.lastRenderedState,o=i(l,n);if(s.hasEagerState=!0,s.eagerState=o,kt(o,l)){var c=t.interleaved;c===null?(s.next=s,vc(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=mh(e,t,s,r),n!==null&&(s=$e(),wt(n,e,r,s),zh(n,t,r))}}function Rh(e){var t=e.alternate;return e===he||t!==null&&t===he}function Mh(e,t){_s=fi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function zh(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,rc(e,n)}}var hi={readContext:ct,useCallback:Le,useContext:Le,useEffect:Le,useImperativeHandle:Le,useInsertionEffect:Le,useLayoutEffect:Le,useMemo:Le,useReducer:Le,useRef:Le,useState:Le,useDebugValue:Le,useDeferredValue:Le,useTransition:Le,useMutableSource:Le,useSyncExternalStore:Le,useId:Le,unstable_isNewReconciler:!1},iv={readContext:ct,useCallback:function(e,t){return Nt().memoizedState=[e,t===void 0?null:t],e},useContext:ct,useEffect:Vu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Qa(4194308,4,_h.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Qa(4194308,4,e,t)},useInsertionEffect:function(e,t){return Qa(4,2,e,t)},useMemo:function(e,t){var n=Nt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Nt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=sv.bind(null,he,e),[r.memoizedState,e]},useRef:function(e){var t=Nt();return e={current:e},t.memoizedState=e},useState:Qu,useDebugValue:Cc,useDeferredValue:function(e){return Nt().memoizedState=e},useTransition:function(){var e=Qu(!1),t=e[0];return e=rv.bind(null,e[1]),Nt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=he,s=Nt();if(de){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),Ee===null)throw Error(E(349));tr&30||gh(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Vu(wh.bind(null,r,i,e),[e]),r.flags|=2048,qs(9,jh.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Nt(),t=Ee.identifierPrefix;if(de){var n=$t,r=At;n=(r&~(1<<32-jt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Ks++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[Et]=t,e[Bs]=r,Kh(e,t,!1,!1),t.stateNode=e;e:{switch(l=Dl(n,r),n){case"dialog":ce("cancel",e),ce("close",e),s=r;break;case"iframe":case"object":case"embed":ce("load",e),s=r;break;case"video":case"audio":for(s=0;sqr&&(t.flags|=128,r=!0,hs(i,!1),t.lanes=4194304)}else{if(!r)if(e=di(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),hs(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!de)return Re(t),null}else 2*je()-i.renderingStartTime>qr&&n!==1073741824&&(t.flags|=128,r=!0,hs(i,!1),t.lanes=4194304);i.isBackwards?(l.sibling=t.child,t.child=l):(n=i.last,n!==null?n.sibling=l:t.child=l,i.last=l)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=je(),t.sibling=null,n=fe.current,ie(fe,r?n&1|2:n&1),t):(Re(t),null);case 22:case 23:return Lc(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ye&1073741824&&(Re(t),t.subtreeFlags&6&&(t.flags|=8192)):Re(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function mv(e,t){switch(fc(t),t.tag){case 1:return We(t.type)&&si(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Kr(),ue(qe),ue(Fe),wc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return jc(t),null;case 13:if(ue(fe),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));Qr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ue(fe),null;case 4:return Kr(),null;case 10:return xc(t.type._context),null;case 22:case 23:return Lc(),null;case 24:return null;default:return null}}var Ta=!1,ze=!1,pv=typeof WeakSet=="function"?WeakSet:Set,I=null;function wr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ve(e,t,r)}else n.current=null}function fo(e,t,n){try{n()}catch(r){ve(e,t,r)}}var td=!1;function xv(e,t){if(Wl=ei,e=Xf(),uc(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var l=0,o=-1,c=-1,u=0,d=0,f=e,m=null;t:for(;;){for(var v;f!==n||s!==0&&f.nodeType!==3||(o=l+s),f!==i||r!==0&&f.nodeType!==3||(c=l+r),f.nodeType===3&&(l+=f.nodeValue.length),(v=f.firstChild)!==null;)m=f,f=v;for(;;){if(f===e)break t;if(m===n&&++u===s&&(o=l),m===i&&++d===r&&(c=l),(v=f.nextSibling)!==null)break;f=m,m=f.parentNode}f=v}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Gl={focusedElem:e,selectionRange:n},ei=!1,I=t;I!==null;)if(t=I,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,I=e;else for(;I!==null;){t=I;try{var k=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(k!==null){var g=k.memoizedProps,b=k.memoizedState,p=t.stateNode,h=p.getSnapshotBeforeUpdate(t.elementType===t.type?g:mt(t.type,g),b);p.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(w){ve(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,I=e;break}I=t.return}return k=td,td=!1,k}function Es(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&fo(t,n,i)}s=s.next}while(s!==r)}}function Ri(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ho(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Wh(e){var t=e.alternate;t!==null&&(e.alternate=null,Wh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Et],delete t[Bs],delete t[Xl],delete t[Xx],delete t[Zx])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Gh(e){return e.tag===5||e.tag===3||e.tag===4}function nd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Gh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function mo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ri));else if(r!==4&&(e=e.child,e!==null))for(mo(e,t,n),e=e.sibling;e!==null;)mo(e,t,n),e=e.sibling}function po(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(po(e,t,n),e=e.sibling;e!==null;)po(e,t,n),e=e.sibling}var Pe=null,vt=!1;function Jt(e,t,n){for(n=n.child;n!==null;)Jh(e,t,n),n=n.sibling}function Jh(e,t,n){if(Pt&&typeof Pt.onCommitFiberUnmount=="function")try{Pt.onCommitFiberUnmount(Si,n)}catch{}switch(n.tag){case 5:ze||wr(n,t);case 6:var r=Pe,s=vt;Pe=null,Jt(e,t,n),Pe=r,vt=s,Pe!==null&&(vt?(e=Pe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Pe.removeChild(n.stateNode));break;case 18:Pe!==null&&(vt?(e=Pe,n=n.stateNode,e.nodeType===8?cl(e.parentNode,n):e.nodeType===1&&cl(e,n),Is(e)):cl(Pe,n.stateNode));break;case 4:r=Pe,s=vt,Pe=n.stateNode.containerInfo,vt=!0,Jt(e,t,n),Pe=r,vt=s;break;case 0:case 11:case 14:case 15:if(!ze&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,l=i.destroy;i=i.tag,l!==void 0&&(i&2||i&4)&&fo(n,t,l),s=s.next}while(s!==r)}Jt(e,t,n);break;case 1:if(!ze&&(wr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){ve(n,t,o)}Jt(e,t,n);break;case 21:Jt(e,t,n);break;case 22:n.mode&1?(ze=(r=ze)||n.memoizedState!==null,Jt(e,t,n),ze=r):Jt(e,t,n);break;default:Jt(e,t,n)}}function rd(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new pv),t.forEach(function(r){var s=Sv.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function ft(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=l),r&=~i}if(r=s,r=je()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*yv(r/1960))-r,10e?16:e,hn===null)var r=!1;else{if(e=hn,hn=null,xi=0,ne&6)throw Error(E(331));var s=ne;for(ne|=4,I=e.current;I!==null;){var i=I,l=i.child;if(I.flags&16){var o=i.deletions;if(o!==null){for(var c=0;cje()-Tc?Yn(e,0):Pc|=n),Ge(e,t)}function sm(e,t){t===0&&(e.mode&1?(t=wa,wa<<=1,!(wa&130023424)&&(wa=4194304)):t=1);var n=$e();e=Kt(e,t),e!==null&&(la(e,t,n),Ge(e,n))}function Nv(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),sm(e,n)}function Sv(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),sm(e,n)}var am;am=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||qe.current)He=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return He=!1,fv(e,t,n);He=!!(e.flags&131072)}else He=!1,de&&t.flags&1048576&&ch(t,li,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Va(e,t),e=t.pendingProps;var s=Br(t,Fe.current);_r(t,n),s=bc(null,t,r,e,s,n);var i=Nc();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,We(r)?(i=!0,ai(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,yc(t),s.updater=Li,t.stateNode=s,s._reactInternals=t,so(t,r,e,n),t=lo(null,t,r,!0,i,n)):(t.tag=0,de&&i&&dc(t),De(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Va(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=_v(r),e=mt(r,e),s){case 0:t=io(null,t,r,e,n);break e;case 1:t=Xu(null,t,r,e,n);break e;case 11:t=Ju(null,t,r,e,n);break e;case 14:t=Yu(null,t,r,mt(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),io(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Xu(e,t,r,s,n);case 3:e:{if(Bh(t),e===null)throw Error(E(387));r=t.pendingProps,i=t.memoizedState,s=i.element,ph(e,t),ui(t,r,null,n);var l=t.memoizedState;if(r=l.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=Hr(Error(E(423)),t),t=Zu(e,t,r,n,s);break e}else if(r!==s){s=Hr(Error(E(424)),t),t=Zu(e,t,r,n,s);break e}else for(Xe=jn(t.stateNode.containerInfo.firstChild),Ze=t,de=!0,yt=null,n=hh(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Qr(),r===s){t=Ht(e,t,n);break e}De(e,t,r,n)}t=t.child}return t;case 5:return xh(t),e===null&&to(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,l=s.children,Jl(r,s)?l=null:i!==null&&Jl(r,i)&&(t.flags|=32),Uh(e,t),De(e,t,l,n),t.child;case 6:return e===null&&to(t),null;case 13:return Qh(e,t,n);case 4:return gc(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Vr(t,null,r,n):De(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Ju(e,t,r,s,n);case 7:return De(e,t,t.pendingProps,n),t.child;case 8:return De(e,t,t.pendingProps.children,n),t.child;case 12:return De(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,l=s.value,ie(oi,r._currentValue),r._currentValue=l,i!==null)if(kt(i.value,l)){if(i.children===s.children&&!qe.current){t=Ht(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var o=i.dependencies;if(o!==null){l=i.child;for(var c=o.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=Ut(-1,n&-n),c.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),no(i.return,n,t),o.lanes|=n;break}c=c.next}}else if(i.tag===10)l=i.type===t.type?null:i.child;else if(i.tag===18){if(l=i.return,l===null)throw Error(E(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),no(l,n,t),l=i.sibling}else l=i.child;if(l!==null)l.return=i;else for(l=i;l!==null;){if(l===t){l=null;break}if(i=l.sibling,i!==null){i.return=l.return,l=i;break}l=l.return}i=l}De(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,_r(t,n),s=ct(s),r=r(s),t.flags|=1,De(e,t,r,n),t.child;case 14:return r=t.type,s=mt(r,t.pendingProps),s=mt(r.type,s),Yu(e,t,r,s,n);case 15:return Ah(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Va(e,t),t.tag=1,We(r)?(e=!0,ai(t)):e=!1,_r(t,n),Fh(t,r,s),so(t,r,s,n),lo(null,t,r,!0,e,n);case 19:return Vh(e,t,n);case 22:return $h(e,t,n)}throw Error(E(156,t.tag))};function im(e,t){return Rf(e,t)}function Cv(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function lt(e,t,n,r){return new Cv(e,t,n,r)}function Mc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function _v(e){if(typeof e=="function")return Mc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Zo)return 11;if(e===ec)return 14}return 2}function Nn(e,t){var n=e.alternate;return n===null?(n=lt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function qa(e,t,n,r,s,i){var l=2;if(r=e,typeof e=="function")Mc(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case fr:return Xn(n.children,s,i,t);case Xo:l=8,s|=8;break;case El:return e=lt(12,n,t,s|2),e.elementType=El,e.lanes=i,e;case Pl:return e=lt(13,n,t,s),e.elementType=Pl,e.lanes=i,e;case Tl:return e=lt(19,n,t,s),e.elementType=Tl,e.lanes=i,e;case xf:return zi(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case mf:l=10;break e;case pf:l=9;break e;case Zo:l=11;break e;case ec:l=14;break e;case Xt:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=lt(l,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function Xn(e,t,n,r){return e=lt(7,e,r,t),e.lanes=n,e}function zi(e,t,n,r){return e=lt(22,e,r,t),e.elementType=xf,e.lanes=n,e.stateNode={isHidden:!1},e}function vl(e,t,n){return e=lt(6,e,null,t),e.lanes=n,e}function yl(e,t,n){return t=lt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Ev(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Xi(0),this.expirationTimes=Xi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Xi(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function zc(e,t,n,r,s,i,l,o,c){return e=new Ev(e,t,n,o,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=lt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},yc(i),e}function Pv(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(um)}catch(e){console.error(e)}}um(),uf.exports=tt;var Mv=uf.exports,dd=Mv;Cl.createRoot=dd.createRoot,Cl.hydrateRoot=dd.hydrateRoot;var es=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},zv={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},nn,Qo,$d,Fv=($d=class{constructor(){$(this,nn,zv);$(this,Qo,!1)}setTimeoutProvider(e){z(this,nn,e)}setTimeout(e,t){return y(this,nn).setTimeout(e,t)}clearTimeout(e){y(this,nn).clearTimeout(e)}setInterval(e,t){return y(this,nn).setInterval(e,t)}clearInterval(e){y(this,nn).clearInterval(e)}},nn=new WeakMap,Qo=new WeakMap,$d),Un=new Fv;function Iv(e){setTimeout(e,0)}var sr=typeof window>"u"||"Deno"in globalThis;function Ae(){}function Dv(e,t){return typeof e=="function"?e(t):e}function jo(e){return typeof e=="number"&&e>=0&&e!==1/0}function dm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Sn(e,t){return typeof e=="function"?e(t):e}function st(e,t){return typeof e=="function"?e(t):e}function fd(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:i,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==Ac(l,t.options))return!1}else if(!Gs(t.queryKey,l))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||s&&s!==t.state.fetchStatus||i&&!i(t))}function hd(e,t){const{exact:n,status:r,predicate:s,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(ar(t.options.mutationKey)!==ar(i))return!1}else if(!Gs(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function Ac(e,t){return((t==null?void 0:t.queryKeyHashFn)||ar)(e)}function ar(e){return JSON.stringify(e,(t,n)=>wo(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function Gs(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Gs(e[n],t[n])):!1}var Av=Object.prototype.hasOwnProperty;function fm(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=md(e)&&md(t);if(!r&&!(wo(e)&&wo(t)))return t;const i=(r?e:Object.keys(e)).length,l=r?t:Object.keys(t),o=l.length,c=r?new Array(o):{};let u=0;for(let d=0;d{Un.setTimeout(t,e)})}function ko(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?fm(e,t):t}function Uv(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Bv(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var $c=Symbol();function hm(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===$c?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Uc(e,t){return typeof e=="function"?e(...t):!!e}function Qv(e,t,n){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),e}var Bn,rn,Pr,Ud,Vv=(Ud=class extends es{constructor(){super();$(this,Bn);$(this,rn);$(this,Pr);z(this,Pr,t=>{if(!sr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){y(this,rn)||this.setEventListener(y(this,Pr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,rn))==null||t.call(this),z(this,rn,void 0))}setEventListener(t){var n;z(this,Pr,t),(n=y(this,rn))==null||n.call(this),z(this,rn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){y(this,Bn)!==t&&(z(this,Bn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof y(this,Bn)=="boolean"?y(this,Bn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Bn=new WeakMap,rn=new WeakMap,Pr=new WeakMap,Ud),Bc=new Vv;function bo(){let e,t;const n=new Promise((s,i)=>{e=s,t=i});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var Kv=Iv;function Hv(){let e=[],t=0,n=o=>{o()},r=o=>{o()},s=Kv;const i=o=>{t?e.push(o):s(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&s(()=>{r(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;t++;try{c=o()}finally{t--,t||l()}return c},batchCalls:o=>(...c)=>{i(()=>{o(...c)})},schedule:i,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{s=o}}}var be=Hv(),Tr,sn,Or,Bd,qv=(Bd=class extends es{constructor(){super();$(this,Tr,!0);$(this,sn);$(this,Or);z(this,Or,t=>{if(!sr&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){y(this,sn)||this.setEventListener(y(this,Or))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,sn))==null||t.call(this),z(this,sn,void 0))}setEventListener(t){var n;z(this,Or,t),(n=y(this,sn))==null||n.call(this),z(this,sn,t(this.setOnline.bind(this)))}setOnline(t){y(this,Tr)!==t&&(z(this,Tr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return y(this,Tr)}},Tr=new WeakMap,sn=new WeakMap,Or=new WeakMap,Bd),ji=new qv;function Wv(e){return Math.min(1e3*2**e,3e4)}function mm(e){return(e??"online")==="online"?ji.isOnline():!0}var No=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function pm(e){let t=!1,n=0,r;const s=bo(),i=()=>s.status!=="pending",l=g=>{var b;if(!i()){const p=new No(g);m(p),(b=e.onCancel)==null||b.call(e,p)}},o=()=>{t=!0},c=()=>{t=!1},u=()=>Bc.isFocused()&&(e.networkMode==="always"||ji.isOnline())&&e.canRun(),d=()=>mm(e.networkMode)&&e.canRun(),f=g=>{i()||(r==null||r(),s.resolve(g))},m=g=>{i()||(r==null||r(),s.reject(g))},v=()=>new Promise(g=>{var b;r=p=>{(i()||u())&&g(p)},(b=e.onPause)==null||b.call(e)}).then(()=>{var g;r=void 0,i()||(g=e.onContinue)==null||g.call(e)}),k=()=>{if(i())return;let g;const b=n===0?e.initialPromise:void 0;try{g=b??e.fn()}catch(p){g=Promise.reject(p)}Promise.resolve(g).then(f).catch(p=>{var S;if(i())return;const h=e.retry??(sr?0:3),x=e.retryDelay??Wv,w=typeof x=="function"?x(n,p):x,C=h===!0||typeof h=="number"&&nu()?void 0:v()).then(()=>{t?m(p):k()})})};return{promise:s,status:()=>s.status,cancel:l,continue:()=>(r==null||r(),s),cancelRetry:o,continueRetry:c,canStart:d,start:()=>(d()?k():v().then(k),s)}}var Qn,Qd,xm=(Qd=class{constructor(){$(this,Qn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),jo(this.gcTime)&&z(this,Qn,Un.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(sr?1/0:5*60*1e3))}clearGcTimeout(){y(this,Qn)&&(Un.clearTimeout(y(this,Qn)),z(this,Qn,void 0))}},Qn=new WeakMap,Qd),Vn,Lr,rt,Kn,Ce,ta,Hn,pt,Lt,Vd,Gv=(Vd=class extends xm{constructor(t){super();$(this,pt);$(this,Vn);$(this,Lr);$(this,rt);$(this,Kn);$(this,Ce);$(this,ta);$(this,Hn);z(this,Hn,!1),z(this,ta,t.defaultOptions),this.setOptions(t.options),this.observers=[],z(this,Kn,t.client),z(this,rt,y(this,Kn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,z(this,Vn,vd(this.options)),this.state=t.state??y(this,Vn),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=y(this,Ce))==null?void 0:t.promise}setOptions(t){if(this.options={...y(this,ta),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=vd(this.options);n.data!==void 0&&(this.setState(xd(n.data,n.dataUpdatedAt)),z(this,Vn,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&y(this,rt).remove(this)}setData(t,n){const r=ko(this.state.data,t,this.options);return H(this,pt,Lt).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){H(this,pt,Lt).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=y(this,Ce))==null?void 0:r.promise;return(s=y(this,Ce))==null||s.cancel(t),n?n.then(Ae).catch(Ae):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(y(this,Vn))}isActive(){return this.observers.some(t=>st(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===$c||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Sn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!dm(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),y(this,rt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(y(this,Ce)&&(y(this,Hn)?y(this,Ce).cancel({revert:!0}):y(this,Ce).cancelRetry()),this.scheduleGc()),y(this,rt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||H(this,pt,Lt).call(this,{type:"invalidate"})}async fetch(t,n){var c,u,d,f,m,v,k,g,b,p,h,x;if(this.state.fetchStatus!=="idle"&&((c=y(this,Ce))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(y(this,Ce))return y(this,Ce).continueRetry(),y(this,Ce).promise}if(t&&this.setOptions(t),!this.options.queryFn){const w=this.observers.find(C=>C.options.queryFn);w&&this.setOptions(w.options)}const r=new AbortController,s=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(z(this,Hn,!0),r.signal)})},i=()=>{const w=hm(this.options,n),S=(()=>{const N={client:y(this,Kn),queryKey:this.queryKey,meta:this.meta};return s(N),N})();return z(this,Hn,!1),this.options.persister?this.options.persister(w,S,this):w(S)},o=(()=>{const w={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:y(this,Kn),state:this.state,fetchFn:i};return s(w),w})();(u=this.options.behavior)==null||u.onFetch(o,this),z(this,Lr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=o.fetchOptions)==null?void 0:d.meta))&&H(this,pt,Lt).call(this,{type:"fetch",meta:(f=o.fetchOptions)==null?void 0:f.meta}),z(this,Ce,pm({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:w=>{w instanceof No&&w.revert&&this.setState({...y(this,Lr),fetchStatus:"idle"}),r.abort()},onFail:(w,C)=>{H(this,pt,Lt).call(this,{type:"failed",failureCount:w,error:C})},onPause:()=>{H(this,pt,Lt).call(this,{type:"pause"})},onContinue:()=>{H(this,pt,Lt).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const w=await y(this,Ce).start();if(w===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(w),(v=(m=y(this,rt).config).onSuccess)==null||v.call(m,w,this),(g=(k=y(this,rt).config).onSettled)==null||g.call(k,w,this.state.error,this),w}catch(w){if(w instanceof No){if(w.silent)return y(this,Ce).promise;if(w.revert){if(this.state.data===void 0)throw w;return this.state.data}}throw H(this,pt,Lt).call(this,{type:"error",error:w}),(p=(b=y(this,rt).config).onError)==null||p.call(b,w,this),(x=(h=y(this,rt).config).onSettled)==null||x.call(h,this.state.data,w,this),w}finally{this.scheduleGc()}}},Vn=new WeakMap,Lr=new WeakMap,rt=new WeakMap,Kn=new WeakMap,Ce=new WeakMap,ta=new WeakMap,Hn=new WeakMap,pt=new WeakSet,Lt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...vm(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...xd(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return z(this,Lr,t.manual?s:void 0),s;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),be.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),y(this,rt).notify({query:this,type:"updated",action:t})})},Vd);function vm(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:mm(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function xd(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function vd(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Qe,Z,na,Ie,qn,Rr,zt,an,ra,Mr,zr,Wn,Gn,ln,Fr,se,ws,So,Co,_o,Eo,Po,To,Oo,ym,Kd,Jv=(Kd=class extends es{constructor(t,n){super();$(this,se);$(this,Qe);$(this,Z);$(this,na);$(this,Ie);$(this,qn);$(this,Rr);$(this,zt);$(this,an);$(this,ra);$(this,Mr);$(this,zr);$(this,Wn);$(this,Gn);$(this,ln);$(this,Fr,new Set);this.options=n,z(this,Qe,t),z(this,an,null),z(this,zt,bo()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(y(this,Z).addObserver(this),yd(y(this,Z),this.options)?H(this,se,ws).call(this):this.updateResult(),H(this,se,Eo).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Lo(y(this,Z),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Lo(y(this,Z),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,H(this,se,Po).call(this),H(this,se,To).call(this),y(this,Z).removeObserver(this)}setOptions(t){const n=this.options,r=y(this,Z);if(this.options=y(this,Qe).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof st(this.options.enabled,y(this,Z))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");H(this,se,Oo).call(this),y(this,Z).setOptions(this.options),n._defaulted&&!gi(this.options,n)&&y(this,Qe).getQueryCache().notify({type:"observerOptionsUpdated",query:y(this,Z),observer:this});const s=this.hasListeners();s&&gd(y(this,Z),r,this.options,n)&&H(this,se,ws).call(this),this.updateResult(),s&&(y(this,Z)!==r||st(this.options.enabled,y(this,Z))!==st(n.enabled,y(this,Z))||Sn(this.options.staleTime,y(this,Z))!==Sn(n.staleTime,y(this,Z)))&&H(this,se,So).call(this);const i=H(this,se,Co).call(this);s&&(y(this,Z)!==r||st(this.options.enabled,y(this,Z))!==st(n.enabled,y(this,Z))||i!==y(this,ln))&&H(this,se,_o).call(this,i)}getOptimisticResult(t){const n=y(this,Qe).getQueryCache().build(y(this,Qe),t),r=this.createResult(n,t);return Xv(this,r)&&(z(this,Ie,r),z(this,Rr,this.options),z(this,qn,y(this,Z).state)),r}getCurrentResult(){return y(this,Ie)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&y(this,zt).status==="pending"&&y(this,zt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){y(this,Fr).add(t)}getCurrentQuery(){return y(this,Z)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=y(this,Qe).defaultQueryOptions(t),r=y(this,Qe).getQueryCache().build(y(this,Qe),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return H(this,se,ws).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),y(this,Ie)))}createResult(t,n){var F;const r=y(this,Z),s=this.options,i=y(this,Ie),l=y(this,qn),o=y(this,Rr),u=t!==r?t.state:y(this,na),{state:d}=t;let f={...d},m=!1,v;if(n._optimisticResults){const O=this.hasListeners(),B=!O&&yd(t,n),G=O&&gd(t,r,n,s);(B||G)&&(f={...f,...vm(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:k,errorUpdatedAt:g,status:b}=f;v=f.data;let p=!1;if(n.placeholderData!==void 0&&v===void 0&&b==="pending"){let O;i!=null&&i.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(O=i.data,p=!0):O=typeof n.placeholderData=="function"?n.placeholderData((F=y(this,zr))==null?void 0:F.state.data,y(this,zr)):n.placeholderData,O!==void 0&&(b="success",v=ko(i==null?void 0:i.data,O,n),m=!0)}if(n.select&&v!==void 0&&!p)if(i&&v===(l==null?void 0:l.data)&&n.select===y(this,ra))v=y(this,Mr);else try{z(this,ra,n.select),v=n.select(v),v=ko(i==null?void 0:i.data,v,n),z(this,Mr,v),z(this,an,null)}catch(O){z(this,an,O)}y(this,an)&&(k=y(this,an),v=y(this,Mr),g=Date.now(),b="error");const h=f.fetchStatus==="fetching",x=b==="pending",w=b==="error",C=x&&h,S=v!==void 0,_={status:b,fetchStatus:f.fetchStatus,isPending:x,isSuccess:b==="success",isError:w,isInitialLoading:C,isLoading:C,data:v,dataUpdatedAt:f.dataUpdatedAt,error:k,errorUpdatedAt:g,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:h,isRefetching:h&&!x,isLoadingError:w&&!S,isPaused:f.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:w&&S,isStale:Qc(t,n),refetch:this.refetch,promise:y(this,zt),isEnabled:st(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=_.data!==void 0,B=_.status==="error"&&!O,G=D=>{B?D.reject(_.error):O&&D.resolve(_.data)},re=()=>{const D=z(this,zt,_.promise=bo());G(D)},oe=y(this,zt);switch(oe.status){case"pending":t.queryHash===r.queryHash&&G(oe);break;case"fulfilled":(B||_.data!==oe.value)&&re();break;case"rejected":(!B||_.error!==oe.reason)&&re();break}}return _}updateResult(){const t=y(this,Ie),n=this.createResult(y(this,Z),this.options);if(z(this,qn,y(this,Z).state),z(this,Rr,this.options),y(this,qn).data!==void 0&&z(this,zr,y(this,Z)),gi(n,t))return;z(this,Ie,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!y(this,Fr).size)return!0;const l=new Set(i??y(this,Fr));return this.options.throwOnError&&l.add("error"),Object.keys(y(this,Ie)).some(o=>{const c=o;return y(this,Ie)[c]!==t[c]&&l.has(c)})};H(this,se,ym).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&H(this,se,Eo).call(this)}},Qe=new WeakMap,Z=new WeakMap,na=new WeakMap,Ie=new WeakMap,qn=new WeakMap,Rr=new WeakMap,zt=new WeakMap,an=new WeakMap,ra=new WeakMap,Mr=new WeakMap,zr=new WeakMap,Wn=new WeakMap,Gn=new WeakMap,ln=new WeakMap,Fr=new WeakMap,se=new WeakSet,ws=function(t){H(this,se,Oo).call(this);let n=y(this,Z).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Ae)),n},So=function(){H(this,se,Po).call(this);const t=Sn(this.options.staleTime,y(this,Z));if(sr||y(this,Ie).isStale||!jo(t))return;const r=dm(y(this,Ie).dataUpdatedAt,t)+1;z(this,Wn,Un.setTimeout(()=>{y(this,Ie).isStale||this.updateResult()},r))},Co=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(y(this,Z)):this.options.refetchInterval)??!1},_o=function(t){H(this,se,To).call(this),z(this,ln,t),!(sr||st(this.options.enabled,y(this,Z))===!1||!jo(y(this,ln))||y(this,ln)===0)&&z(this,Gn,Un.setInterval(()=>{(this.options.refetchIntervalInBackground||Bc.isFocused())&&H(this,se,ws).call(this)},y(this,ln)))},Eo=function(){H(this,se,So).call(this),H(this,se,_o).call(this,H(this,se,Co).call(this))},Po=function(){y(this,Wn)&&(Un.clearTimeout(y(this,Wn)),z(this,Wn,void 0))},To=function(){y(this,Gn)&&(Un.clearInterval(y(this,Gn)),z(this,Gn,void 0))},Oo=function(){const t=y(this,Qe).getQueryCache().build(y(this,Qe),this.options);if(t===y(this,Z))return;const n=y(this,Z);z(this,Z,t),z(this,na,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},ym=function(t){be.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(y(this,Ie))}),y(this,Qe).getQueryCache().notify({query:y(this,Z),type:"observerResultsUpdated"})})},Kd);function Yv(e,t){return st(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function yd(e,t){return Yv(e,t)||e.state.data!==void 0&&Lo(e,t,t.refetchOnMount)}function Lo(e,t,n){if(st(t.enabled,e)!==!1&&Sn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Qc(e,t)}return!1}function gd(e,t,n,r){return(e!==t||st(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Qc(e,n)}function Qc(e,t){return st(t.enabled,e)!==!1&&e.isStaleByTime(Sn(t.staleTime,e))}function Xv(e,t){return!gi(e.getCurrentResult(),t)}function jd(e){return{onFetch:(t,n)=>{var d,f,m,v,k;const r=t.options,s=(m=(f=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:f.fetchMore)==null?void 0:m.direction,i=((v=t.state.data)==null?void 0:v.pages)||[],l=((k=t.state.data)==null?void 0:k.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const u=async()=>{let g=!1;const b=x=>{Qv(x,()=>t.signal,()=>g=!0)},p=hm(t.options,t.fetchOptions),h=async(x,w,C)=>{if(g)return Promise.reject();if(w==null&&x.pages.length)return Promise.resolve(x);const N=(()=>{const B={client:t.client,queryKey:t.queryKey,pageParam:w,direction:C?"backward":"forward",meta:t.options.meta};return b(B),B})(),_=await p(N),{maxPages:F}=t.options,O=C?Bv:Uv;return{pages:O(x.pages,_,F),pageParams:O(x.pageParams,w,F)}};if(s&&i.length){const x=s==="backward",w=x?Zv:wd,C={pages:i,pageParams:l},S=w(r,C);o=await h(C,S,x)}else{const x=e??i.length;do{const w=c===0?l[0]??r.initialPageParam:wd(r,o);if(c>0&&w==null)break;o=await h(o,w),c++}while(c{var g,b;return(b=(g=t.options).persister)==null?void 0:b.call(g,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function wd(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Zv(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var sa,St,Me,Jn,Ct,Yt,Hd,ey=(Hd=class extends xm{constructor(t){super();$(this,Ct);$(this,sa);$(this,St);$(this,Me);$(this,Jn);z(this,sa,t.client),this.mutationId=t.mutationId,z(this,Me,t.mutationCache),z(this,St,[]),this.state=t.state||gm(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){y(this,St).includes(t)||(y(this,St).push(t),this.clearGcTimeout(),y(this,Me).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){z(this,St,y(this,St).filter(n=>n!==t)),this.scheduleGc(),y(this,Me).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){y(this,St).length||(this.state.status==="pending"?this.scheduleGc():y(this,Me).remove(this))}continue(){var t;return((t=y(this,Jn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,u,d,f,m,v,k,g,b,p,h,x,w,C,S,N;const n=()=>{H(this,Ct,Yt).call(this,{type:"continue"})},r={client:y(this,sa),meta:this.options.meta,mutationKey:this.options.mutationKey};z(this,Jn,pm({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(_,F)=>{H(this,Ct,Yt).call(this,{type:"failed",failureCount:_,error:F})},onPause:()=>{H(this,Ct,Yt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>y(this,Me).canRun(this)}));const s=this.state.status==="pending",i=!y(this,Jn).canStart();try{if(s)n();else{H(this,Ct,Yt).call(this,{type:"pending",variables:t,isPaused:i}),y(this,Me).config.onMutate&&await y(this,Me).config.onMutate(t,this,r);const F=await((o=(l=this.options).onMutate)==null?void 0:o.call(l,t,r));F!==this.state.context&&H(this,Ct,Yt).call(this,{type:"pending",context:F,variables:t,isPaused:i})}const _=await y(this,Jn).start();return await((u=(c=y(this,Me).config).onSuccess)==null?void 0:u.call(c,_,t,this.state.context,this,r)),await((f=(d=this.options).onSuccess)==null?void 0:f.call(d,_,t,this.state.context,r)),await((v=(m=y(this,Me).config).onSettled)==null?void 0:v.call(m,_,null,this.state.variables,this.state.context,this,r)),await((g=(k=this.options).onSettled)==null?void 0:g.call(k,_,null,t,this.state.context,r)),H(this,Ct,Yt).call(this,{type:"success",data:_}),_}catch(_){try{await((p=(b=y(this,Me).config).onError)==null?void 0:p.call(b,_,t,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((x=(h=this.options).onError)==null?void 0:x.call(h,_,t,this.state.context,r))}catch(F){Promise.reject(F)}try{await((C=(w=y(this,Me).config).onSettled)==null?void 0:C.call(w,void 0,_,this.state.variables,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((N=(S=this.options).onSettled)==null?void 0:N.call(S,void 0,_,t,this.state.context,r))}catch(F){Promise.reject(F)}throw H(this,Ct,Yt).call(this,{type:"error",error:_}),_}finally{y(this,Me).runNext(this)}}},sa=new WeakMap,St=new WeakMap,Me=new WeakMap,Jn=new WeakMap,Ct=new WeakSet,Yt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),be.batch(()=>{y(this,St).forEach(r=>{r.onMutationUpdate(t)}),y(this,Me).notify({mutation:this,type:"updated",action:t})})},Hd);function gm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ft,xt,aa,qd,ty=(qd=class extends es{constructor(t={}){super();$(this,Ft);$(this,xt);$(this,aa);this.config=t,z(this,Ft,new Set),z(this,xt,new Map),z(this,aa,0)}build(t,n,r){const s=new ey({client:t,mutationCache:this,mutationId:++pa(this,aa)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){y(this,Ft).add(t);const n=Ra(t);if(typeof n=="string"){const r=y(this,xt).get(n);r?r.push(t):y(this,xt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(y(this,Ft).delete(t)){const n=Ra(t);if(typeof n=="string"){const r=y(this,xt).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&y(this,xt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Ra(t);if(typeof n=="string"){const r=y(this,xt).get(n),s=r==null?void 0:r.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=Ra(t);if(typeof n=="string"){const s=(r=y(this,xt).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){be.batch(()=>{y(this,Ft).forEach(t=>{this.notify({type:"removed",mutation:t})}),y(this,Ft).clear(),y(this,xt).clear()})}getAll(){return Array.from(y(this,Ft))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>hd(n,r))}findAll(t={}){return this.getAll().filter(n=>hd(t,n))}notify(t){be.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return be.batch(()=>Promise.all(t.map(n=>n.continue().catch(Ae))))}},Ft=new WeakMap,xt=new WeakMap,aa=new WeakMap,qd);function Ra(e){var t;return(t=e.options.scope)==null?void 0:t.id}var It,on,Ve,Dt,Bt,Wa,Ro,Wd,ny=(Wd=class extends es{constructor(n,r){super();$(this,Bt);$(this,It);$(this,on);$(this,Ve);$(this,Dt);z(this,It,n),this.setOptions(r),this.bindMethods(),H(this,Bt,Wa).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=y(this,It).defaultMutationOptions(n),gi(this.options,r)||y(this,It).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,Ve),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&ar(r.mutationKey)!==ar(this.options.mutationKey)?this.reset():((s=y(this,Ve))==null?void 0:s.state.status)==="pending"&&y(this,Ve).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=y(this,Ve))==null||n.removeObserver(this)}onMutationUpdate(n){H(this,Bt,Wa).call(this),H(this,Bt,Ro).call(this,n)}getCurrentResult(){return y(this,on)}reset(){var n;(n=y(this,Ve))==null||n.removeObserver(this),z(this,Ve,void 0),H(this,Bt,Wa).call(this),H(this,Bt,Ro).call(this)}mutate(n,r){var s;return z(this,Dt,r),(s=y(this,Ve))==null||s.removeObserver(this),z(this,Ve,y(this,It).getMutationCache().build(y(this,It),this.options)),y(this,Ve).addObserver(this),y(this,Ve).execute(n)}},It=new WeakMap,on=new WeakMap,Ve=new WeakMap,Dt=new WeakMap,Bt=new WeakSet,Wa=function(){var r;const n=((r=y(this,Ve))==null?void 0:r.state)??gm();z(this,on,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Ro=function(n){be.batch(()=>{var r,s,i,l,o,c,u,d;if(y(this,Dt)&&this.hasListeners()){const f=y(this,on).variables,m=y(this,on).context,v={client:y(this,It),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(s=(r=y(this,Dt)).onSuccess)==null||s.call(r,n.data,f,m,v)}catch(k){Promise.reject(k)}try{(l=(i=y(this,Dt)).onSettled)==null||l.call(i,n.data,null,f,m,v)}catch(k){Promise.reject(k)}}else if((n==null?void 0:n.type)==="error"){try{(c=(o=y(this,Dt)).onError)==null||c.call(o,n.error,f,m,v)}catch(k){Promise.reject(k)}try{(d=(u=y(this,Dt)).onSettled)==null||d.call(u,void 0,n.error,f,m,v)}catch(k){Promise.reject(k)}}}this.listeners.forEach(f=>{f(y(this,on))})})},Wd),_t,Gd,ry=(Gd=class extends es{constructor(t={}){super();$(this,_t);this.config=t,z(this,_t,new Map)}build(t,n,r){const s=n.queryKey,i=n.queryHash??Ac(s,n);let l=this.get(i);return l||(l=new Gv({client:t,queryKey:s,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(l)),l}add(t){y(this,_t).has(t.queryHash)||(y(this,_t).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=y(this,_t).get(t.queryHash);n&&(t.destroy(),n===t&&y(this,_t).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){be.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return y(this,_t).get(t)}getAll(){return[...y(this,_t).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>fd(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>fd(t,r)):n}notify(t){be.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){be.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){be.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},_t=new WeakMap,Gd),xe,cn,un,Ir,Dr,dn,Ar,$r,Jd,sy=(Jd=class{constructor(e={}){$(this,xe);$(this,cn);$(this,un);$(this,Ir);$(this,Dr);$(this,dn);$(this,Ar);$(this,$r);z(this,xe,e.queryCache||new ry),z(this,cn,e.mutationCache||new ty),z(this,un,e.defaultOptions||{}),z(this,Ir,new Map),z(this,Dr,new Map),z(this,dn,0)}mount(){pa(this,dn)._++,y(this,dn)===1&&(z(this,Ar,Bc.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,xe).onFocus())})),z(this,$r,ji.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,xe).onOnline())})))}unmount(){var e,t;pa(this,dn)._--,y(this,dn)===0&&((e=y(this,Ar))==null||e.call(this),z(this,Ar,void 0),(t=y(this,$r))==null||t.call(this),z(this,$r,void 0))}isFetching(e){return y(this,xe).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return y(this,cn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,xe).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=y(this,xe).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Sn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return y(this,xe).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=y(this,xe).get(r.queryHash),i=s==null?void 0:s.state.data,l=Dv(t,i);if(l!==void 0)return y(this,xe).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return be.batch(()=>y(this,xe).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,xe).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=y(this,xe);be.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=y(this,xe);return be.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=be.batch(()=>y(this,xe).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Ae).catch(Ae)}invalidateQueries(e,t={}){return be.batch(()=>(y(this,xe).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=be.batch(()=>y(this,xe).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let i=s.fetch(void 0,n);return n.throwOnError||(i=i.catch(Ae)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Ae)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=y(this,xe).build(this,t);return n.isStaleByTime(Sn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ae).catch(Ae)}fetchInfiniteQuery(e){return e.behavior=jd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ae).catch(Ae)}ensureInfiniteQueryData(e){return e.behavior=jd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ji.isOnline()?y(this,cn).resumePausedMutations():Promise.resolve()}getQueryCache(){return y(this,xe)}getMutationCache(){return y(this,cn)}getDefaultOptions(){return y(this,un)}setDefaultOptions(e){z(this,un,e)}setQueryDefaults(e,t){y(this,Ir).set(ar(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...y(this,Ir).values()],n={};return t.forEach(r=>{Gs(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){y(this,Dr).set(ar(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...y(this,Dr).values()],n={};return t.forEach(r=>{Gs(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...y(this,un).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Ac(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===$c&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...y(this,un).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){y(this,xe).clear(),y(this,cn).clear()}},xe=new WeakMap,cn=new WeakMap,un=new WeakMap,Ir=new WeakMap,Dr=new WeakMap,dn=new WeakMap,Ar=new WeakMap,$r=new WeakMap,Jd),jm=j.createContext(void 0),Wt=e=>{const t=j.useContext(jm);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ay=({client:e,children:t})=>(j.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),a.jsx(jm.Provider,{value:e,children:t})),wm=j.createContext(!1),iy=()=>j.useContext(wm);wm.Provider;function ly(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var oy=j.createContext(ly()),cy=()=>j.useContext(oy),uy=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Uc(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},dy=e=>{j.useEffect(()=>{e.clearReset()},[e])},fy=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||Uc(n,[e.error,r])),hy=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},my=(e,t)=>e.isLoading&&e.isFetching&&!t,py=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,kd=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function xy(e,t,n){var m,v,k,g;const r=iy(),s=cy(),i=Wt(),l=i.defaultQueryOptions(e);(v=(m=i.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||v.call(m,l);const o=i.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",hy(l),uy(l,s,o),dy(s);const c=!i.getQueryCache().get(l.queryHash),[u]=j.useState(()=>new t(i,l)),d=u.getOptimisticResult(l),f=!r&&e.subscribed!==!1;if(j.useSyncExternalStore(j.useCallback(b=>{const p=f?u.subscribe(be.batchCalls(b)):Ae;return u.updateResult(),p},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),j.useEffect(()=>{u.setOptions(l)},[l,u]),py(l,d))throw kd(l,u,s);if(fy({result:d,errorResetBoundary:s,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw d.error;if((g=(k=i.getDefaultOptions().queries)==null?void 0:k._experimental_afterQuery)==null||g.call(k,l,d),l.experimental_prefetchInRender&&!sr&&my(d,r)){const b=c?kd(l,u,s):o==null?void 0:o.promise;b==null||b.catch(Ae).finally(()=>{u.updateResult()})}return l.notifyOnChangeProps?d:u.trackResult(d)}function le(e,t){return xy(e,Jv)}function Je(e,t){const n=Wt(),[r]=j.useState(()=>new ny(n,e));j.useEffect(()=>{r.setOptions(e)},[r,e]);const s=j.useSyncExternalStore(j.useCallback(l=>r.subscribe(be.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=j.useCallback((l,o)=>{r.mutate(l,o).catch(Ae)},[r]);if(s.error&&Uc(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}/** + * @remix-run/router v1.23.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Js(){return Js=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function Vc(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function yy(){return Math.random().toString(36).substr(2,8)}function Nd(e,t){return{usr:e.state,key:e.key,idx:t}}function Mo(e,t,n,r){return n===void 0&&(n=null),Js({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?ts(t):t,{state:n,key:t&&t.key||r||yy()})}function wi(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function ts(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function gy(e,t,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:i=!1}=r,l=s.history,o=mn.Pop,c=null,u=d();u==null&&(u=0,l.replaceState(Js({},l.state,{idx:u}),""));function d(){return(l.state||{idx:null}).idx}function f(){o=mn.Pop;let b=d(),p=b==null?null:b-u;u=b,c&&c({action:o,location:g.location,delta:p})}function m(b,p){o=mn.Push;let h=Mo(g.location,b,p);u=d()+1;let x=Nd(h,u),w=g.createHref(h);try{l.pushState(x,"",w)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;s.location.assign(w)}i&&c&&c({action:o,location:g.location,delta:1})}function v(b,p){o=mn.Replace;let h=Mo(g.location,b,p);u=d();let x=Nd(h,u),w=g.createHref(h);l.replaceState(x,"",w),i&&c&&c({action:o,location:g.location,delta:0})}function k(b){let p=s.location.origin!=="null"?s.location.origin:s.location.href,h=typeof b=="string"?b:wi(b);return h=h.replace(/ $/,"%20"),ye(p,"No window.location.(origin|href) available to create URL for href: "+h),new URL(h,p)}let g={get action(){return o},get location(){return e(s,l)},listen(b){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(bd,f),c=b,()=>{s.removeEventListener(bd,f),c=null}},createHref(b){return t(s,b)},createURL:k,encodeLocation(b){let p=k(b);return{pathname:p.pathname,search:p.search,hash:p.hash}},push:m,replace:v,go(b){return l.go(b)}};return g}var Sd;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Sd||(Sd={}));function jy(e,t,n){return n===void 0&&(n="/"),wy(e,t,n)}function wy(e,t,n,r){let s=typeof t=="string"?ts(t):t,i=Wr(s.pathname||"/",n);if(i==null)return null;let l=km(e);ky(l);let o=null;for(let c=0;o==null&&c{let c={relativePath:o===void 0?i.path||"":o,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};c.relativePath.startsWith("/")&&(ye(c.relativePath.startsWith(r),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(r.length));let u=Cn([r,c.relativePath]),d=n.concat(c);i.children&&i.children.length>0&&(ye(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),km(i.children,t,d,u)),!(i.path==null&&!i.index)&&t.push({path:u,score:Py(u,i.index),routesMeta:d})};return e.forEach((i,l)=>{var o;if(i.path===""||!((o=i.path)!=null&&o.includes("?")))s(i,l);else for(let c of bm(i.path))s(i,l,c)}),t}function bm(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return s?[i,""]:[i];let l=bm(r.join("/")),o=[];return o.push(...l.map(c=>c===""?i:[i,c].join("/"))),s&&o.push(...l),o.map(c=>e.startsWith("/")&&c===""?"/":c)}function ky(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ty(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const by=/^:[\w-]+$/,Ny=3,Sy=2,Cy=1,_y=10,Ey=-2,Cd=e=>e==="*";function Py(e,t){let n=e.split("/"),r=n.length;return n.some(Cd)&&(r+=Ey),t&&(r+=Sy),n.filter(s=>!Cd(s)).reduce((s,i)=>s+(by.test(i)?Ny:i===""?Cy:_y),r)}function Ty(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function Oy(e,t,n){let{routesMeta:r}=e,s={},i="/",l=[];for(let o=0;o{let{paramName:m,isOptional:v}=d;if(m==="*"){let g=o[f]||"";l=i.slice(0,i.length-g.length).replace(/(.)\/+$/,"$1")}const k=o[f];return v&&!k?u[m]=void 0:u[m]=(k||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:l,pattern:e}}function Ly(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),Vc(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,c)=>(r.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function Ry(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Vc(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Wr(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const My=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,zy=e=>My.test(e);function Fy(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?ts(e):e,i;if(n)if(zy(n))i=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),Vc(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?i=_d(n.substring(1),"/"):i=_d(n,t)}else i=t;return{pathname:i,search:Ay(r),hash:$y(s)}}function _d(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function gl(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Iy(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Nm(e,t){let n=Iy(e);return t?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Sm(e,t,n,r){r===void 0&&(r=!1);let s;typeof e=="string"?s=ts(e):(s=Js({},e),ye(!s.pathname||!s.pathname.includes("?"),gl("?","pathname","search",s)),ye(!s.pathname||!s.pathname.includes("#"),gl("#","pathname","hash",s)),ye(!s.search||!s.search.includes("#"),gl("#","search","hash",s)));let i=e===""||s.pathname==="",l=i?"/":s.pathname,o;if(l==null)o=n;else{let f=t.length-1;if(!r&&l.startsWith("..")){let m=l.split("/");for(;m[0]==="..";)m.shift(),f-=1;s.pathname=m.join("/")}o=f>=0?t[f]:"/"}let c=Fy(s,o),u=l&&l!=="/"&&l.endsWith("/"),d=(i||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}const Cn=e=>e.join("/").replace(/\/\/+/g,"/"),Dy=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Ay=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,$y=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Uy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const Cm=["post","put","patch","delete"];new Set(Cm);const By=["get",...Cm];new Set(By);/** + * React Router v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Ys(){return Ys=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),j.useCallback(function(u,d){if(d===void 0&&(d={}),!o.current)return;if(typeof u=="number"){r.go(u);return}let f=Sm(u,JSON.parse(l),i,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Cn([t,f.pathname])),(d.replace?r.replace:r.push)(f,d.state,d)},[t,r,l,i,e])}const Ky=j.createContext(null);function Hy(e){let t=j.useContext(Gt).outlet;return t&&j.createElement(Ky.Provider,{value:e},t)}function fa(){let{matches:e}=j.useContext(Gt),t=e[e.length-1];return t?t.params:{}}function Bi(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=j.useContext(Mn),{matches:s}=j.useContext(Gt),{pathname:i}=ns(),l=JSON.stringify(Nm(s,r.v7_relativeSplatPath));return j.useMemo(()=>Sm(e,JSON.parse(l),i,n==="path"),[e,l,i,n])}function qy(e,t){return Wy(e,t)}function Wy(e,t,n,r){da()||ye(!1);let{navigator:s}=j.useContext(Mn),{matches:i}=j.useContext(Gt),l=i[i.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let u=ns(),d;if(t){var f;let b=typeof t=="string"?ts(t):t;c==="/"||(f=b.pathname)!=null&&f.startsWith(c)||ye(!1),d=b}else d=u;let m=d.pathname||"/",v=m;if(c!=="/"){let b=c.replace(/^\//,"").split("/");v="/"+m.replace(/^\//,"").split("/").slice(b.length).join("/")}let k=jy(e,{pathname:v}),g=Zy(k&&k.map(b=>Object.assign({},b,{params:Object.assign({},o,b.params),pathname:Cn([c,s.encodeLocation?s.encodeLocation(b.pathname).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?c:Cn([c,s.encodeLocation?s.encodeLocation(b.pathnameBase).pathname:b.pathnameBase])})),i,n,r);return t&&g?j.createElement(Ui.Provider,{value:{location:Ys({pathname:"/",search:"",hash:"",state:null,key:"default"},d),navigationType:mn.Pop}},g):g}function Gy(){let e=rg(),t=Uy(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return j.createElement(j.Fragment,null,j.createElement("h2",null,"Unexpected Application Error!"),j.createElement("h3",{style:{fontStyle:"italic"}},t),n?j.createElement("pre",{style:s},n):null,null)}const Jy=j.createElement(Gy,null);class Yy extends j.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?j.createElement(Gt.Provider,{value:this.props.routeContext},j.createElement(Em.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Xy(e){let{routeContext:t,match:n,children:r}=e,s=j.useContext($i);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),j.createElement(Gt.Provider,{value:t},r)}function Zy(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(s=n)==null?void 0:s.errors;if(o!=null){let d=l.findIndex(f=>f.route.id&&(o==null?void 0:o[f.route.id])!==void 0);d>=0||ye(!1),l=l.slice(0,Math.min(l.length,d+1))}let c=!1,u=-1;if(n&&r&&r.v7_partialHydration)for(let d=0;d=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((d,f,m)=>{let v,k=!1,g=null,b=null;n&&(v=o&&f.route.id?o[f.route.id]:void 0,g=f.route.errorElement||Jy,c&&(u<0&&m===0?(ag("route-fallback"),k=!0,b=null):u===m&&(k=!0,b=f.route.hydrateFallbackElement||null)));let p=t.concat(l.slice(0,m+1)),h=()=>{let x;return v?x=g:k?x=b:f.route.Component?x=j.createElement(f.route.Component,null):f.route.element?x=f.route.element:x=d,j.createElement(Xy,{match:f,routeContext:{outlet:d,matches:p,isDataRoute:n!=null},children:x})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?j.createElement(Yy,{location:n.location,revalidation:n.revalidation,component:g,error:v,children:h(),routeContext:{outlet:null,matches:p,isDataRoute:!0}}):h()},null)}var Tm=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Tm||{}),Om=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(Om||{});function eg(e){let t=j.useContext($i);return t||ye(!1),t}function tg(e){let t=j.useContext(_m);return t||ye(!1),t}function ng(e){let t=j.useContext(Gt);return t||ye(!1),t}function Lm(e){let t=ng(),n=t.matches[t.matches.length-1];return n.route.id||ye(!1),n.route.id}function rg(){var e;let t=j.useContext(Em),n=tg(),r=Lm();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function sg(){let{router:e}=eg(Tm.UseNavigateStable),t=Lm(Om.UseNavigateStable),n=j.useRef(!1);return Pm(()=>{n.current=!0}),j.useCallback(function(s,i){i===void 0&&(i={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,Ys({fromRouteId:t},i)))},[e,t])}const Ed={};function ag(e,t,n){Ed[e]||(Ed[e]=!0)}function ig(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function lg(e){return Hy(e.context)}function ht(e){ye(!1)}function og(e){let{basename:t="/",children:n=null,location:r,navigationType:s=mn.Pop,navigator:i,static:l=!1,future:o}=e;da()&&ye(!1);let c=t.replace(/^\/*/,"/"),u=j.useMemo(()=>({basename:c,navigator:i,static:l,future:Ys({v7_relativeSplatPath:!1},o)}),[c,o,i,l]);typeof r=="string"&&(r=ts(r));let{pathname:d="/",search:f="",hash:m="",state:v=null,key:k="default"}=r,g=j.useMemo(()=>{let b=Wr(d,c);return b==null?null:{location:{pathname:b,search:f,hash:m,state:v,key:k},navigationType:s}},[c,d,f,m,v,k,s]);return g==null?null:j.createElement(Mn.Provider,{value:u},j.createElement(Ui.Provider,{children:n,value:g}))}function cg(e){let{children:t,location:n}=e;return qy(Fo(t),n)}new Promise(()=>{});function Fo(e,t){t===void 0&&(t=[]);let n=[];return j.Children.forEach(e,(r,s)=>{if(!j.isValidElement(r))return;let i=[...t,s];if(r.type===j.Fragment){n.push.apply(n,Fo(r.props.children,i));return}r.type!==ht&&ye(!1),!r.props.index||!r.props.children||ye(!1);let l={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Fo(r.props.children,i)),n.push(l)}),n}/** + * React Router DOM v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function ki(){return ki=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[s]=e[s]);return n}function ug(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function dg(e,t){return e.button===0&&(!t||t==="_self")&&!ug(e)}const fg=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],hg=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],mg="6";try{window.__reactRouterVersion=mg}catch{}const pg=j.createContext({isTransitioning:!1}),xg="startTransition",Pd=bp[xg];function vg(e){let{basename:t,children:n,future:r,window:s}=e,i=j.useRef();i.current==null&&(i.current=vy({window:s,v5Compat:!0}));let l=i.current,[o,c]=j.useState({action:l.action,location:l.location}),{v7_startTransition:u}=r||{},d=j.useCallback(f=>{u&&Pd?Pd(()=>c(f)):c(f)},[c,u]);return j.useLayoutEffect(()=>l.listen(d),[l,d]),j.useEffect(()=>ig(r),[r]),j.createElement(og,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const yg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",gg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Tn=j.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:i,replace:l,state:o,target:c,to:u,preventScrollReset:d,viewTransition:f}=t,m=Rm(t,fg),{basename:v}=j.useContext(Mn),k,g=!1;if(typeof u=="string"&&gg.test(u)&&(k=u,yg))try{let x=new URL(window.location.href),w=u.startsWith("//")?new URL(x.protocol+u):new URL(u),C=Wr(w.pathname,v);w.origin===x.origin&&C!=null?u=C+w.search+w.hash:g=!0}catch{}let b=Qy(u,{relative:s}),p=wg(u,{replace:l,state:o,target:c,preventScrollReset:d,relative:s,viewTransition:f});function h(x){r&&r(x),x.defaultPrevented||p(x)}return j.createElement("a",ki({},m,{href:k||b,onClick:g||i?r:h,ref:n,target:c}))}),Mm=j.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:s=!1,className:i="",end:l=!1,style:o,to:c,viewTransition:u,children:d}=t,f=Rm(t,hg),m=Bi(c,{relative:f.relative}),v=ns(),k=j.useContext(_m),{navigator:g,basename:b}=j.useContext(Mn),p=k!=null&&kg(m)&&u===!0,h=g.encodeLocation?g.encodeLocation(m).pathname:m.pathname,x=v.pathname,w=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;s||(x=x.toLowerCase(),w=w?w.toLowerCase():null,h=h.toLowerCase()),w&&b&&(w=Wr(w,b)||w);const C=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let S=x===h||!l&&x.startsWith(h)&&x.charAt(C)==="/",N=w!=null&&(w===h||!l&&w.startsWith(h)&&w.charAt(h.length)==="/"),_={isActive:S,isPending:N,isTransitioning:p},F=S?r:void 0,O;typeof i=="function"?O=i(_):O=[i,S?"active":null,N?"pending":null,p?"transitioning":null].filter(Boolean).join(" ");let B=typeof o=="function"?o(_):o;return j.createElement(Tn,ki({},f,{"aria-current":F,className:O,ref:n,style:B,to:c,viewTransition:u}),typeof d=="function"?d(_):d)});var Io;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Io||(Io={}));var Td;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Td||(Td={}));function jg(e){let t=j.useContext($i);return t||ye(!1),t}function wg(e,t){let{target:n,replace:r,state:s,preventScrollReset:i,relative:l,viewTransition:o}=t===void 0?{}:t,c=zn(),u=ns(),d=Bi(e,{relative:l});return j.useCallback(f=>{if(dg(f,n)){f.preventDefault();let m=r!==void 0?r:wi(u)===wi(d);c(e,{replace:m,state:s,preventScrollReset:i,relative:l,viewTransition:o})}},[u,c,d,r,s,n,e,i,l,o])}function kg(e,t){t===void 0&&(t={});let n=j.useContext(pg);n==null&&ye(!1);let{basename:r}=jg(Io.useViewTransitionState),s=Bi(e,{relative:t.relative});if(!n.isTransitioning)return!1;let i=Wr(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Wr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return zo(s.pathname,l)!=null||zo(s.pathname,i)!=null}/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var bg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ng=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),U=(e,t)=>{const n=j.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:l,className:o="",children:c,...u},d)=>j.createElement("svg",{ref:d,...bg,width:s,height:s,stroke:r,strokeWidth:l?Number(i)*24/Number(s):i,className:["lucide",`lucide-${Ng(e)}`,o].join(" "),...u},[...t.map(([f,m])=>j.createElement(f,m)),...Array.isArray(c)?c:[c]]));return n.displayName=`${e}`,n};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Sg=U("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zm=U("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cg=U("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _g=U("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Eg=U("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pg=U("BookOpen",[["path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z",key:"vv98re"}],["path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z",key:"1cyq3y"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Do=U("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fm=U("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Tg=U("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Og=U("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xs=U("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lg=U("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rg=U("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Im=U("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mg=U("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zg=U("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dm=U("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Od=U("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Am=U("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ao=U("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fg=U("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ig=U("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dg=U("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Kc=U("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ag=U("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $g=U("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ug=U("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ha=U("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $m=U("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bg=U("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qg=U("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vg=U("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Zs=U("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hc=U("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Kg=U("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hg=U("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Um=U("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bm=U("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qg=U("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wg=U("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ld=U("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Gg=U("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Jg=U("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qc=U("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qm=U("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Yg=U("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xg=U("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vm=U("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const rs=U("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),Zg={},Rd=e=>{let t;const n=new Set,r=(d,f)=>{const m=typeof d=="function"?d(t):d;if(!Object.is(m,t)){const v=t;t=f??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(k=>k(t,v))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(Zg?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(r,s,c);return c},e0=e=>e?Rd(e):Rd;var Km={exports:{}},Hm={},qm={exports:{}},Wm={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Gr=j;function t0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var n0=typeof Object.is=="function"?Object.is:t0,r0=Gr.useState,s0=Gr.useEffect,a0=Gr.useLayoutEffect,i0=Gr.useDebugValue;function l0(e,t){var n=t(),r=r0({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return a0(function(){s.value=n,s.getSnapshot=t,jl(s)&&i({inst:s})},[e,n,t]),s0(function(){return jl(s)&&i({inst:s}),e(function(){jl(s)&&i({inst:s})})},[e]),i0(n),n}function jl(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!n0(e,n)}catch{return!0}}function o0(e,t){return t()}var c0=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o0:l0;Wm.useSyncExternalStore=Gr.useSyncExternalStore!==void 0?Gr.useSyncExternalStore:c0;qm.exports=Wm;var u0=qm.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Qi=j,d0=u0;function f0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var h0=typeof Object.is=="function"?Object.is:f0,m0=d0.useSyncExternalStore,p0=Qi.useRef,x0=Qi.useEffect,v0=Qi.useMemo,y0=Qi.useDebugValue;Hm.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=p0(null);if(i.current===null){var l={hasValue:!1,value:null};i.current=l}else l=i.current;i=v0(function(){function c(v){if(!u){if(u=!0,d=v,v=r(v),s!==void 0&&l.hasValue){var k=l.value;if(s(k,v))return f=k}return f=v}if(k=f,h0(d,v))return k;var g=r(v);return s!==void 0&&s(k,g)?(d=v,k):(d=v,f=g)}var u=!1,d,f,m=n===void 0?null:n;return[function(){return c(t())},m===null?void 0:function(){return c(m())}]},[t,n,r,s]);var o=m0(e,i[0],i[1]);return x0(function(){l.hasValue=!0,l.value=o},[o]),y0(o),o};Km.exports=Hm;var g0=Km.exports;const j0=Yd(g0),Gm={},{useDebugValue:w0}=Wo,{useSyncExternalStoreWithSelector:k0}=j0;let Md=!1;const b0=e=>e;function N0(e,t=b0,n){(Gm?"production":void 0)!=="production"&&n&&!Md&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Md=!0);const r=k0(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return w0(r),r}const zd=e=>{(Gm?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?e0(e):e,n=(r,s)=>N0(t,r,s);return Object.assign(n,t),n},Wc=e=>e?zd(e):zd,Vi="/api",Gc="flow_auth_token",Jc="flow_auth_expires",Yc="flow_auth_username";function Ki(){const e=localStorage.getItem(Gc),t=localStorage.getItem(Jc);return!e||!t?null:new Date(t)<=new Date?(Jr(),null):e}function Fd(e,t,n){localStorage.setItem(Gc,e),localStorage.setItem(Jc,t),localStorage.setItem(Yc,n)}function Jr(){localStorage.removeItem(Gc),localStorage.removeItem(Jc),localStorage.removeItem(Yc)}function Xc(){return localStorage.getItem(Yc)}let ir=null;function S0(e){ir=e}async function J(e,t,n=!1){const r={"Content-Type":"application/json",...t==null?void 0:t.headers};if(!n){const i=Ki();i&&(r.Authorization=`Bearer ${i}`)}const s=await fetch(`${Vi}${e}`,{...t,headers:r});if(s.status===401){Jr(),ir&&ir();const i=await s.json().catch(()=>({detail:"Not authenticated"}));throw new Error(i.detail||"Not authenticated")}if(!s.ok){const i=await s.json().catch(()=>({detail:s.statusText}));throw new Error(i.detail||"API request failed")}if(s.status!==204)return s.json()}const ps={getConfig:()=>J("/auth/config",void 0,!0),login:e=>J("/auth/login",{method:"POST",body:JSON.stringify(e)},!0),getGitHubAuthUrl:()=>`${Vi}/auth/github`,getCurrentUser:()=>J("/auth/me"),logout:()=>J("/auth/logout",{method:"POST"})},_n={list:e=>{const t=new URLSearchParams;e!=null&&e.include_auto_generated&&t.set("include_auto_generated","true"),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return J(`/configs${n?`?${n}`:""}`)},get:e=>J(`/configs/${e}`),create:e=>J("/configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>J(`/configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>J(`/configs/${e}`,{method:"DELETE"})},gt={list:e=>{const t=new URLSearchParams;e!=null&&e.category&&t.set("category",e.category),e!=null&&e.suite&&t.set("suite",e.suite);const n=t.toString();return J(`/tasks${n?`?${n}`:""}`)},get:e=>J(`/tasks/${e}`),create:e=>J("/tasks",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>J(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>J(`/tasks/${e}`,{method:"DELETE"}),listSuites:()=>J("/tasks/suites"),importSuite:e=>J(`/tasks/import-suite?suite_name=${encodeURIComponent(e)}`,{method:"POST"})},Ot={list:e=>{const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return J(`/jobs${n?`?${n}`:""}`)},get:e=>J(`/jobs/${e}`),create:e=>J("/jobs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>J(`/jobs/${e}`,{method:"PUT",body:JSON.stringify(t)}),start:async function*(e){var o;const t={},n=Ki();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Vi}/jobs/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Jr(),ir&&ir(),new Error("Not authenticated");if(!r.ok)throw new Error("Failed to start job");const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const i=new TextDecoder;let l="";for(;;){const{done:c,value:u}=await s.read();if(c)break;l+=i.decode(u,{stream:!0});const d=l.split(` +`);l=d.pop()||"";for(const f of d)f.startsWith("data: ")&&(yield JSON.parse(f.slice(6)))}},cancel:e=>J(`/jobs/${e}/cancel`,{method:"POST"}),delete:e=>J(`/jobs/${e}`,{method:"DELETE"})},$o={list:e=>{const t=new URLSearchParams;e!=null&&e.job_id&&t.set("job_id",e.job_id),e!=null&&e.candidate_name&&t.set("candidate_name",e.candidate_name),e!=null&&e.task_name&&t.set("task_name",e.task_name),(e==null?void 0:e.is_pareto)!==void 0&&t.set("is_pareto",String(e.is_pareto));const n=t.toString();return J(`/runs${n?`?${n}`:""}`)},get:e=>J(`/runs/${e}`),getJobSummary:e=>J(`/runs/job/${e}/summary`)},Os={list:e=>{const t=new URLSearchParams;e!=null&&e.agent_id&&t.set("agent_id",e.agent_id),e!=null&&e.limit&&t.set("limit",String(e.limit));const n=t.toString();return J(`/tests${n?`?${n}`:""}`)},get:e=>J(`/tests/${e}`),create:e=>J("/tests",{method:"POST",body:JSON.stringify(e)}),start:async function*(e){var o;const t={},n=Ki();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Vi}/tests/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Jr(),ir&&ir(),new Error("Not authenticated");if(!r.ok){const c=await r.json().catch(()=>({detail:"Failed to start test"}));throw new Error(c.detail||"Failed to start test")}const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const i=new TextDecoder;let l="";for(;;){const{done:c,value:u}=await s.read();if(c)break;l+=i.decode(u,{stream:!0});const d=l.split(` +`);l=d.pop()||"";for(const f of d)f.startsWith("data: ")&&(yield JSON.parse(f.slice(6)))}},cancel:e=>J(`/tests/${e}/cancel`,{method:"POST"}),delete:e=>J(`/tests/${e}`,{method:"DELETE"})},C0={list:()=>J("/llm-configs")},_0={list:()=>J("/tools")},Jm={getAgentSchema:()=>J("/schema/agent")},E0={get:e=>J(`/deployments/${e}`)},P0={start:e=>J("/evaluate",{method:"POST",body:JSON.stringify(e)})},Uo={design:e=>J("/experiment/design",{method:"POST",body:JSON.stringify(e)}),validate:e=>J("/experiment/validate",{method:"POST",body:JSON.stringify(e)}),generateCandidates:e=>J("/experiment/generate-candidates",{method:"POST",body:JSON.stringify(e)})},Zc=Wc(e=>(S0(()=>{e({isAuthenticated:!1,user:null,error:"Session expired. Please log in again."})}),{authConfig:null,isLoadingConfig:!0,isAuthenticated:!1,isLoading:!1,user:null,error:null,loadAuthConfig:async()=>{e({isLoadingConfig:!0});try{const t=await ps.getConfig();if(e({authConfig:t,isLoadingConfig:!1}),t.enabled){const n=Ki(),r=Xc();if(n&&r)try{const s=await ps.getCurrentUser();e({isAuthenticated:!0,user:s})}catch{Jr(),e({isAuthenticated:!1,user:null})}}else e({isAuthenticated:!0,user:{username:"anonymous",auth_mode:"none"}})}catch(t){console.error("Failed to load auth config:",t),e({isLoadingConfig:!1,error:"Failed to connect to server"})}},login:async(t,n)=>{e({isLoading:!0,error:null});try{const r=await ps.login({username:t,password:n});return Fd(r.access_token,r.expires_at,r.username),e({isAuthenticated:!0,isLoading:!1,user:{username:r.username,auth_mode:"basic"}}),!0}catch(r){return e({isLoading:!1,error:r instanceof Error?r.message:"Login failed"}),!1}},loginWithGitHub:()=>{window.location.href=ps.getGitHubAuthUrl()},handleOAuthCallback:()=>{const t=new URLSearchParams(window.location.search),n=t.get("auth_error");if(n)return e({error:n}),window.history.replaceState({},"",window.location.pathname),!0;if(t.get("auth_callback")==="true"){const r=t.get("token"),s=t.get("expires_at"),i=t.get("username");return r&&s&&i&&(Fd(r,s,i),e({isAuthenticated:!0,user:{username:i,auth_mode:"github"}})),window.history.replaceState({},"",window.location.pathname),!0}return!1},logout:async()=>{try{await ps.logout()}catch{}Jr(),e({isAuthenticated:!1,user:null,error:null})},clearError:()=>e({error:null})}));function Q({variant:e="secondary",size:t="md",className:n="",icon:r,iconRight:s,loading:i=!1,children:l,disabled:o,...c}){const u="font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1.5 rounded-md",d={primary:"bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)]",secondary:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)] hover:bg-[var(--border)]",danger:"bg-[var(--error)] text-white hover:bg-red-600",ghost:"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"},f={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm"},m=t==="sm"?14:16;return a.jsxs("button",{className:`${u} ${d[e]} ${f[t]} ${n}`,disabled:o||i,...c,children:[i?a.jsx(ha,{size:m,className:"animate-spin"}):r?a.jsx(r,{size:m}):null,l,s&&!i&&a.jsx(s,{size:m})]})}const T0={};function O0(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var i;const l=c=>c===null?null:JSON.parse(c,void 0),o=(i=n.getItem(s))!=null?i:null;return o instanceof Promise?o.then(l):l(o)},setItem:(s,i)=>n.setItem(s,JSON.stringify(i,void 0)),removeItem:s=>n.removeItem(s)}}const ea=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return ea(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return ea(r)(n)}}}},L0=(e,t)=>(n,r,s)=>{let i={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:b=>b,version:0,merge:(b,p)=>({...p,...b}),...t},l=!1;const o=new Set,c=new Set;let u;try{u=i.getStorage()}catch{}if(!u)return e((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...b)},r,s);const d=ea(i.serialize),f=()=>{const b=i.partialize({...r()});let p;const h=d({state:b,version:i.version}).then(x=>u.setItem(i.name,x)).catch(x=>{p=x});if(p)throw p;return h},m=s.setState;s.setState=(b,p)=>{m(b,p),f()};const v=e((...b)=>{n(...b),f()},r,s);let k;const g=()=>{var b;if(!u)return;l=!1,o.forEach(h=>h(r()));const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,r()))||void 0;return ea(u.getItem.bind(u))(i.name).then(h=>{if(h)return i.deserialize(h)}).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==i.version){if(i.migrate)return i.migrate(h.state,h.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return h.state}).then(h=>{var x;return k=i.merge(h,(x=r())!=null?x:v),n(k,!0),f()}).then(()=>{p==null||p(k,void 0),l=!0,c.forEach(h=>h(k))}).catch(h=>{p==null||p(void 0,h)})};return s.persist={setOptions:b=>{i={...i,...b},b.getStorage&&(u=b.getStorage())},clearStorage:()=>{u==null||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>g(),hasHydrated:()=>l,onHydrate:b=>(o.add(b),()=>{o.delete(b)}),onFinishHydration:b=>(c.add(b),()=>{c.delete(b)})},g(),k||v},R0=(e,t)=>(n,r,s)=>{let i={storage:O0(()=>localStorage),partialize:g=>g,version:0,merge:(g,b)=>({...b,...g}),...t},l=!1;const o=new Set,c=new Set;let u=i.storage;if(!u)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...g)},r,s);const d=()=>{const g=i.partialize({...r()});return u.setItem(i.name,{state:g,version:i.version})},f=s.setState;s.setState=(g,b)=>{f(g,b),d()};const m=e((...g)=>{n(...g),d()},r,s);s.getInitialState=()=>m;let v;const k=()=>{var g,b;if(!u)return;l=!1,o.forEach(h=>{var x;return h((x=r())!=null?x:m)});const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,(g=r())!=null?g:m))||void 0;return ea(u.getItem.bind(u))(i.name).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==i.version){if(i.migrate)return[!0,i.migrate(h.state,h.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,h.state];return[!1,void 0]}).then(h=>{var x;const[w,C]=h;if(v=i.merge(C,(x=r())!=null?x:m),n(v,!0),w)return d()}).then(()=>{p==null||p(v,void 0),v=r(),l=!0,c.forEach(h=>h(v))}).catch(h=>{p==null||p(void 0,h)})};return s.persist={setOptions:g=>{i={...i,...g},g.storage&&(u=g.storage)},clearStorage:()=>{u==null||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>k(),hasHydrated:()=>l,onHydrate:g=>(o.add(g),()=>{o.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},i.skipHydration||k(),v||m},M0=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((T0?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),L0(e,t)):R0(e,t),Ym=M0,z0=Wc()(Ym((e,t)=>({theme:"light",setTheme:n=>{document.documentElement.setAttribute("data-theme",n),e({theme:n})},toggleTheme:()=>{const n=t().theme==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",n),e({theme:n})}}),{name:"flow-theme",onRehydrateStorage:()=>e=>{e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}}));function F0(){const{theme:e,toggleTheme:t}=z0();return a.jsx("button",{onClick:t,className:"p-2 rounded-md text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--accent)]","aria-label":`Switch to ${e==="dark"?"light":"dark"} mode`,title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:e==="dark"?a.jsx(Gg,{size:16}):a.jsx(Vg,{size:16})})}const I0=Wc()(Ym((e,t)=>({sidebarCollapsed:!1,toggleSidebar:()=>{e({sidebarCollapsed:!t().sidebarCollapsed})}}),{name:"flow-layout"})),D0=[{path:"/",label:"Overview",icon:$g},{path:"/agents",label:"Agents",icon:Do},{path:"/jobs",label:"Experiments",icon:Ao},{path:"/tasks",label:"Datasets",icon:Dm}];function A0(){const e=ns(),{sidebarCollapsed:t,toggleSidebar:n}=I0(),r=s=>s==="/"?e.pathname==="/":s==="/agents"?e.pathname==="/agents"||e.pathname.startsWith("/agents/")||e.pathname.startsWith("/deployments/"):s==="/jobs"?e.pathname.startsWith("/jobs")||e.pathname.startsWith("/runs"):e.pathname.startsWith(s);return a.jsxs("aside",{className:` + flex flex-col border-r border-[var(--border)] bg-[var(--bg-secondary)] + transition-all duration-200 + ${t?"w-14":"w-56"} + `,children:[a.jsx("nav",{className:"flex-1 py-2",children:D0.map(s=>{const i=r(s.path);return a.jsxs(Mm,{to:s.path,title:t?s.label:void 0,className:` + flex items-center gap-3 px-4 py-2.5 text-sm transition-colors relative + ${i?"text-[var(--accent)] bg-[var(--accent-dim)] font-medium":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"} + `,children:[i&&a.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-r bg-[var(--accent)]"}),a.jsx(s.icon,{size:18}),!t&&a.jsx("span",{children:s.label})]},s.path)})}),a.jsx("button",{onClick:n,className:"flex items-center justify-center p-3 border-t border-[var(--border)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",title:t?"Expand sidebar":"Collapse sidebar",children:t?a.jsx(Rg,{size:16}):a.jsx(Lg,{size:16})})]})}function $0(){const{authConfig:e,user:t,logout:n}=Zc(),r=async()=>{await n()};return a.jsxs("div",{className:"h-screen flex flex-col",children:[a.jsx("header",{className:"border-b border-[var(--border)] bg-[var(--bg-secondary)] shrink-0",children:a.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between",children:[a.jsxs(Mm,{to:"/",className:"text-lg font-semibold text-[var(--accent)] flex items-center gap-2 hover:opacity-80",children:[a.jsx(rs,{size:20}),"Flow",a.jsx("span",{className:"text-[var(--text-secondary)] font-normal",children:"/optimize"})]}),a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(F0,{}),(e==null?void 0:e.enabled)&&t&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[a.jsx(Qm,{size:14}),a.jsx("span",{children:t.username})]}),a.jsx(Q,{variant:"ghost",size:"sm",icon:Bg,onClick:r,title:"Sign out",children:"Sign out"})]})]})]})}),a.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[a.jsx(A0,{}),a.jsx("main",{className:"flex-1 overflow-y-auto bg-[var(--bg-primary)]",children:a.jsx("div",{className:"p-6",children:a.jsx(lg,{})})})]})]})}function q({children:e,variant:t="default"}){const n={default:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)]",success:"bg-[var(--badge-success-bg)] text-[var(--badge-success-text)] border border-[var(--badge-success-border)]",warning:"bg-[var(--badge-warning-bg)] text-[var(--badge-warning-text)] border border-[var(--badge-warning-border)]",error:"bg-[var(--badge-error-bg)] text-[var(--badge-error-text)] border border-[var(--badge-error-border)]",info:"bg-[var(--badge-info-bg)] text-[var(--badge-info-text)] border border-[var(--badge-info-border)]"};return a.jsx("span",{className:`inline-block px-2 py-0.5 text-xs font-medium rounded-md ${n[t]}`,children:e})}const U0={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};function B0(){const e=zn(),{data:t=[],isLoading:n}=le({queryKey:["configs"],queryFn:()=>_n.list()}),{data:r=[],isLoading:s}=le({queryKey:["jobs"],queryFn:()=>Ot.list()}),{data:i=[],isLoading:l}=le({queryKey:["tasks"],queryFn:()=>gt.list()}),o=[...t].sort((d,f)=>new Date(f.created_at).getTime()-new Date(d.created_at).getTime()).slice(0,5),c=[...r].sort((d,f)=>new Date(f.created_at).getTime()-new Date(d.created_at).getTime()).slice(0,5),u=i.reduce((d,f)=>{const m=f.suite||"custom";return d[m]||(d[m]=[]),d[m].push(f),d},{});return a.jsxs("div",{children:[a.jsxs("div",{className:"mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Agent Optimizer"}),a.jsx("p",{className:"text-[var(--text-secondary)] max-w-2xl",children:"Systematically optimize and improve your AI agents across key dimensions. Define agent configurations, run experiments across task datasets, and find the best tradeoffs between quality and cost."}),a.jsx("div",{className:"flex flex-wrap gap-3 mt-4 text-sm text-[var(--text-secondary)]",children:[{icon:Qg,label:"Instructions"},{icon:Yg,label:"Tools"},{icon:Pg,label:"Skills"},{icon:Wg,label:"Compaction"}].map((d,f,m)=>a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[a.jsx(d.icon,{size:14,className:"text-[var(--accent)]"}),d.label,fa.jsxs("div",{className:"p-4 border border-[var(--border)] rounded-lg bg-[var(--bg-secondary)]",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a.jsx("span",{className:"flex items-center justify-center w-7 h-7 rounded-full bg-[var(--accent)]/10 text-[var(--accent)] text-xs font-bold",children:d.step}),a.jsx(d.icon,{size:18,className:"text-[var(--accent)]"})]}),a.jsx("h3",{className:"font-medium text-sm",children:d.title}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:d.description})]},d.step))}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mb-6",children:[a.jsxs("div",{children:[a.jsx(wl,{title:"Recent Agents",icon:Do,count:t.length,onShowAll:()=>e("/agents")}),n?a.jsx(kl,{}):o.length===0?a.jsx(bl,{message:"No agents yet. Create your first agent to get started."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:o.map((d,f)=>a.jsxs("div",{onClick:()=>e(`/agents/${d.id}`),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${fe("/jobs")}),s?a.jsx(kl,{}):c.length===0?a.jsx(bl,{message:"No experiments yet. Start one from an agent's detail page."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:c.map((d,f)=>a.jsxs("div",{onClick:()=>e(`/jobs/${d.id}`),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${fe("/tasks")}),l?a.jsx(kl,{}):Object.keys(u).length===0?a.jsx(bl,{message:"No datasets yet. Import a task suite to get started."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:Object.entries(u).map(([d,f],m,v)=>a.jsx("div",{onClick:()=>e("/tasks"),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${m0&&a.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",n,")"]})]}),n>0&&a.jsxs("button",{onClick:r,className:"text-sm text-[var(--accent)] hover:underline flex items-center gap-1",children:["Show all ",a.jsx(Cg,{size:14})]})]})}function kl(){return a.jsx("div",{className:"text-sm text-[var(--text-secondary)] mb-8",children:"Loading..."})}function bl({message:e}){return a.jsx("div",{className:"text-sm text-[var(--text-secondary)] py-6 text-center border border-[var(--border)] rounded-lg mb-8",children:e})}const Q0=["maf","miniagent","langgraph"],V0={maf:"Microsoft Agent Framework",miniagent:"MiniAgent",langgraph:"LangGraph"},K0={openai:"OpenAI",azure_openai:"Azure OpenAI",anthropic:"Anthropic",ollama:"Ollama",custom:"Custom (OpenAI-compatible)"},H0={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"};function ss({isOpen:e,onClose:t,title:n,children:r,footer:s,size:i="md"}){return j.useEffect(()=>{const l=o=>{o.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",l),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",l),document.body.style.overflow=""}},[e,t]),e?a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),a.jsxs("div",{className:`relative bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg ${H0[i]} w-full mx-4 max-h-[80vh] flex flex-col`,children:[a.jsxs("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-b border-[var(--border)] px-4 py-3 flex items-center justify-between",children:[a.jsx("h2",{className:"font-semibold",children:n}),a.jsx("button",{onClick:t,className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"×"})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r}),s&&a.jsx("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-t border-[var(--border)] px-4 py-3",children:s})]})]}):null}function pn({label:e,className:t="",...n}){return a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),a.jsx("input",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] ${t}`,...n})]})}function q0({label:e,className:t="",...n}){return a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),a.jsx("textarea",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] resize-y min-h-[100px] ${t}`,...n})]})}function bi({label:e,className:t="",...n}){return a.jsxs("label",{className:`flex items-center gap-2 cursor-pointer ${t}`,children:[a.jsx("input",{type:"checkbox",className:"w-4 h-4 bg-[var(--bg-primary)] border border-[var(--border)] rounded accent-[var(--accent)]",...n}),a.jsx("span",{className:"text-sm",children:e})]})}function Xm({columns:e,data:t,onRowClick:n,searchable:r=!1,searchPlaceholder:s="Search...",searchFilter:i,emptyMessage:l="No items found",emptyIcon:o}){const[c,u]=j.useState(""),[d,f]=j.useState(null),[m,v]=j.useState("asc"),k=j.useMemo(()=>{let b=t;if(r&&c&&i&&(b=b.filter(p=>i(p,c))),d){const p=e.find(h=>h.key===d);p!=null&&p.sortValue&&(b=[...b].sort((h,x)=>{const w=p.sortValue(h),C=p.sortValue(x),S=wC?1:0;return m==="asc"?S:-S}))}return b},[t,c,i,r,d,m,e]),g=b=>{const p=e.find(h=>h.key===b);p!=null&&p.sortable&&(d===b?v(m==="asc"?"desc":"asc"):(f(b),v("asc")))};return a.jsxs("div",{children:[r&&a.jsxs("div",{className:"mb-4 relative max-w-sm",children:[a.jsx(Hg,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]"}),a.jsx("input",{type:"text",placeholder:s,value:c,onChange:b=>u(b.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md pl-9 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]"})]}),k.length===0?a.jsxs("div",{className:"text-center py-16 text-[var(--text-secondary)]",children:[o&&a.jsx("div",{className:"mb-3 flex justify-center",children:o}),a.jsx("p",{children:l})]}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsx("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:e.map(b=>a.jsx("th",{onClick:()=>g(b.key),className:`text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider ${b.sortable?"cursor-pointer hover:text-[var(--text-primary)]":""} ${b.className||""}`,children:a.jsxs("span",{className:"inline-flex items-center gap-1",children:[b.header,b.sortable&&d===b.key&&a.jsx("span",{children:m==="asc"?"↑":"↓"})]})},b.key))})}),a.jsx("tbody",{children:k.map((b,p)=>a.jsx("tr",{onClick:()=>n==null?void 0:n(b),className:`border-b border-[var(--border)] last:border-b-0 transition-colors ${n?"cursor-pointer hover:bg-[var(--bg-tertiary)]":""}`,children:e.map(h=>a.jsx("td",{className:`px-4 py-3 ${h.className||""}`,children:h.render(b)},h.key))},p))})]})})]})}function W0({variations:e,onChange:t,strategies:n,availableStrategies:r}){const s=r??Object.keys(n),i=()=>{const u=e.map(v=>v.strategy),d=s.find(v=>!u.includes(v))||"none",f=n[d],m={strategy:d};if(f!=null&&f.params)for(const[v,k]of Object.entries(f.params))k.default!==void 0&&(m[v]=k.default);t([...e,m])},l=u=>{t(e.filter((d,f)=>f!==u))},o=(u,d)=>{t(e.map((f,m)=>m===u?{...f,...d}:f))},c=(u,d)=>{const f=n[d],m={strategy:d};if(f!=null&&f.params)for(const[v,k]of Object.entries(f.params))k.default!==void 0&&(m[v]=k.default);o(u,m)};return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm font-medium",children:"Compaction Strategies"}),a.jsx(Q,{type:"button",variant:"ghost",size:"sm",icon:Hc,onClick:i,disabled:e.length>=s.length,children:"Add"})]}),e.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:'No compaction variations. Click "Add" to test different strategies.'}):a.jsx("div",{className:"space-y-2",children:e.map((u,d)=>{const f=n[u.strategy];return a.jsx("div",{className:"p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsx("select",{className:"w-full px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:u.strategy,onChange:m=>c(d,m.target.value),children:s.map(m=>{var v;return a.jsx("option",{value:m,children:((v=n[m])==null?void 0:v.label)||m},m)})}),(f==null?void 0:f.description)&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:f.description}),(f==null?void 0:f.params)&&Object.keys(f.params).length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:Object.entries(f.params).map(([m,v])=>a.jsx(G0,{name:m,schema:v,value:u[m],onChange:k=>o(d,{[m]:k})},m))})]}),a.jsx("button",{type:"button",onClick:()=>l(d),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:a.jsx(Vm,{size:16})})]})},d)})})]})}function G0({name:e,schema:t,value:n,onChange:r}){const s=e.replace(/_/g," ");return t.type==="boolean"?a.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[a.jsx("input",{type:"checkbox",checked:!!(n??t.default),onChange:i=>r(i.target.checked),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"capitalize",children:s})]}):a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:s}),a.jsx("input",{type:t.type==="number"?"number":"text",className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-xs",value:String(n!==void 0?n:t.default??""),onChange:i=>{if(t.type==="number"){const l=parseFloat(i.target.value);r(isNaN(l)?t.default:l)}else r(i.target.value)},min:t.min,max:t.max,step:t.max&&t.max<=1?.1:1})]})}function J0({variations:e,onChange:t,providers:n}){const r=()=>{const o=n[0],c={provider:(o==null?void 0:o.name)||"azure_openai",model:(o==null?void 0:o.models[0])||"gpt-4o"};t([...e,c])},s=o=>{t(e.filter((c,u)=>u!==o))},i=(o,c)=>{t(e.map((u,d)=>d===o?{...u,...c}:u))},l=(o,c)=>{const u=n.find(d=>d.name===c);i(o,{provider:c,model:(u==null?void 0:u.models[0])||""})};return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm font-medium",children:"LLM Configurations"}),a.jsx(Q,{type:"button",variant:"ghost",size:"sm",icon:Hc,onClick:r,children:"Add"})]}),e.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:`Uses agent's default LLM. Click "Add" to test different models.`}):a.jsx("div",{className:"space-y-2",children:e.map((o,c)=>{const u=n.find(d=>d.name===o.provider);return a.jsxs("div",{className:"flex items-center gap-2 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[a.jsx("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.provider,onChange:d=>l(c,d.target.value),children:n.map(d=>a.jsx("option",{value:d.name,children:d.label},d.name))}),u&&u.models.length>0?a.jsxs("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:d=>i(c,{model:d.target.value}),children:[u.models.map(d=>a.jsx("option",{value:d,children:d},d)),!u.models.includes(o.model)&&o.model&&a.jsx("option",{value:o.model,children:o.model})]}):a.jsx("input",{type:"text",className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:d=>i(c,{model:d.target.value}),placeholder:"Model ID"}),a.jsx("button",{type:"button",onClick:()=>s(c),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:a.jsx(Vm,{size:16})})]},c)})})]})}const Bo={compaction:[],tools:[],llm_config:[],instructions:[],instruction_strategies:[]};function Y0({agentId:e,agentName:t,agentFramework:n="maf",taskSuite:r,taskCount:s,schema:i,onVariationsChange:l,parallel:o,onParallelChange:c,budget:u,onBudgetChange:d,useLlmEval:f,onUseLlmEvalChange:m}){const[v,k]=j.useState(Bo),[g,b]=j.useState(!1),[p,h]=j.useState(""),[x,w]=j.useState(null),C=i.frameworks[n],S=(C==null?void 0:C.compaction_strategies)||Object.keys(i.compaction_strategies),N=i.tool_presets||[],_=i.llm_providers||[],O=(()=>{let L=1;v.compaction.length>0&&(L*=v.compaction.length),v.tools.length>0&&(L*=v.tools.length),v.llm_config.length>0&&(L*=v.llm_config.length);const V=v.instructions.length+v.instruction_strategies.reduce((ee,R)=>ee+R.max_candidates,0);return V>0&&(L*=V),Math.min(L,u)})(),B=O*s,G=L=>{k(L),l==null||l(L)},re=Je({mutationFn:L=>Uo.design(L),onSuccess:L=>{h(L.yaml_content),b(!0)}}),oe=Je({mutationFn:L=>Uo.validate(L),onSuccess:L=>{w({valid:L.valid,errors:L.errors,warnings:L.warnings})}}),D=()=>({base_agent_id:e,task_suite:r,variations:v,parallel:o,budget:u,use_llm_eval:f}),W=()=>{re.mutate(D())},X=()=>{oe.mutate(D())},P=()=>{const L=new Blob([p],{type:"text/yaml"}),V=URL.createObjectURL(L),ee=document.createElement("a");ee.href=V,ee.download=`${t}_experiment.yaml`,ee.click(),URL.revokeObjectURL(V)},A=v.compaction.length>0||v.tools.length>0||v.llm_config.length>0||v.instructions.length>0||v.instruction_strategies.length>0;return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsxs(q,{variant:"info",children:[O," candidates"]}),a.jsxs(q,{children:[s," tasks"]}),a.jsxs(q,{variant:B>100?"warning":"success",children:[B," total runs"]})]}),a.jsx(W0,{variations:v.compaction,onChange:L=>G({...v,compaction:L}),strategies:i.compaction_strategies,availableStrategies:S}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("label",{className:"text-sm font-medium",children:"Tool Presets"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(L=>a.jsxs("label",{className:`flex items-center gap-2 px-3 py-1.5 border rounded cursor-pointer transition-colors ${v.tools.includes(L.name)?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[a.jsx("input",{type:"checkbox",checked:v.tools.includes(L.name),onChange:V=>{const ee=V.target.checked?[...v.tools,L.name]:v.tools.filter(R=>R!==L.name);G({...v,tools:ee})},className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:L.name}),a.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",L.tools.length,")"]})]},L.name))}),v.tools.length>0&&a.jsxs("p",{className:"text-xs text-[var(--text-secondary)]",children:["Selected: ",v.tools.join(", ")]})]}),a.jsx(J0,{variations:v.llm_config,onChange:L=>G({...v,llm_config:L}),providers:_}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-4 space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium",children:"Execution Settings"}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(pn,{label:"Parallel Workers",type:"number",value:o,onChange:L=>c(parseInt(L.target.value)||1),min:1,max:16}),a.jsx(pn,{label:"Budget (max candidates)",type:"number",value:u,onChange:L=>d(parseInt(L.target.value)||100),min:1,max:1e3})]}),a.jsx(bi,{label:"Use LLM evaluation",checked:f,onChange:L=>m(L.target.checked)}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] ml-6 -mt-2",children:f?"LLM-as-Judge scores task completion (0-1)":"Simple pass/fail based on task success"})]}),a.jsxs("div",{className:"flex items-center gap-2 border-t border-[var(--border)] pt-4",children:[a.jsx(Q,{variant:"secondary",size:"sm",onClick:X,loading:oe.isPending,children:"Validate"}),a.jsx(Q,{variant:"secondary",size:"sm",icon:Od,onClick:W,loading:re.isPending,children:"Export YAML"})]}),x&&a.jsxs("div",{className:`p-3 rounded border ${x.valid?"border-green-500/50 bg-green-500/10":"border-red-500/50 bg-red-500/10"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[x.valid?a.jsx(Fm,{size:16,className:"text-green-500"}):a.jsx(zm,{size:16,className:"text-red-500"}),a.jsx("span",{className:"font-medium text-sm",children:x.valid?"Configuration valid":"Configuration has issues"})]}),x.errors.length>0&&a.jsx("ul",{className:"text-sm text-red-500 list-disc ml-6",children:x.errors.map((L,V)=>a.jsx("li",{children:L},V))}),x.warnings.length>0&&a.jsx("ul",{className:"text-sm text-yellow-500 list-disc ml-6 mt-1",children:x.warnings.map((L,V)=>a.jsx("li",{children:L},V))})]}),g&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-lg shadow-xl max-w-2xl w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border)]",children:[a.jsx("h3",{className:"font-medium",children:"Experiment YAML"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Q,{variant:"secondary",size:"sm",icon:Od,onClick:P,children:"Download"}),a.jsx(Q,{variant:"ghost",size:"sm",onClick:()=>b(!1),children:"Close"})]})]}),a.jsx("pre",{className:"flex-1 overflow-auto p-4 text-xs font-mono bg-[var(--bg-secondary)]",children:p})]})}),!A&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No variations selected. Only the baseline agent will be tested. Add compaction strategies, tool presets, or LLM configs to generate candidates."})]})}function Zm({agent:e,isOpen:t,onClose:n}){var R;const r=zn(),s=Wt(),[i,l]=j.useState("ready"),[o,c]=j.useState("quick"),[u,d]=j.useState(!1),[f,m]=j.useState([]),[v,k]=j.useState(!1),[g,b]=j.useState(Bo),[p,h]=j.useState(4),[x,w]=j.useState(100),[C,S]=j.useState(!1),[N,_]=j.useState(null),{data:F=[]}=le({queryKey:["tasks"],queryFn:()=>gt.list()}),{data:O=[]}=le({queryKey:["suites"],queryFn:()=>gt.listSuites()}),{data:B}=le({queryKey:["agent-schema"],queryFn:()=>Jm.getAgentSchema()}),G=O.map(T=>({value:T.name,label:T.name.charAt(0).toUpperCase()+T.name.slice(1),description:T.description,tasks:T.task_count})),re=Je({mutationFn:gt.importSuite,onSuccess:T=>{s.invalidateQueries({queryKey:["tasks"]}),m(T.map(te=>te.id))}}),oe=Je({mutationFn:async T=>{const te=await Ot.create(T);return Ot.start(te.id).next(),te},onSuccess:T=>{s.invalidateQueries({queryKey:["jobs"]}),_(T.id),l("success")}}),W=v?(()=>{let T=1;g.compaction.length>0&&(T*=g.compaction.length),g.tools.length>0&&(T*=g.tools.length),g.llm_config.length>0&&(T*=g.llm_config.length);const te=g.instructions.length+g.instruction_strategies.reduce((pe,Se)=>pe+Se.max_candidates,0);return te>0&&(T*=te),Math.min(T,x)})():1,X=u?f.length:((R=G.find(T=>T.value===o))==null?void 0:R.tasks)||3,P=W*X,A=async()=>{l("starting");let T=f;if(!u)try{T=(await re.mutateAsync(o)).map(K=>K.id)}catch(M){console.error("Failed to import suite:",M),alert(`Failed to import task suite: ${o}`),l("ready");return}if(T.length===0){alert("No tasks selected. Please select tasks or choose a task suite."),l("ready");return}let te;if(v&&(g.compaction.length>0||g.tools.length>0||g.llm_config.length>0||g.instructions.length>0||g.instruction_strategies.length>0))try{te=(await Uo.generateCandidates({base_agent_id:e.id,variations:g,budget:x})).candidate_ids}catch(M){console.error("Failed to generate candidates:",M),alert(`Failed to generate candidates: ${M instanceof Error?M.message:"Unknown error"}`),l("ready");return}else te=[e.id];const Se={name:`${e.name} optimization (${te.length} candidates × ${T.length} tasks)`,candidate_ids:te,task_ids:T,parallel:p,use_llm_eval:C};oe.mutate(Se)},L=T=>{m(te=>te.includes(T)?te.filter(pe=>pe!==T):[...te,T])},V=()=>{l("ready"),_(null),k(!1),b(Bo),n()},ee=()=>i==="success"&&N?a.jsxs("div",{className:"flex justify-end gap-3",children:[a.jsx(Q,{variant:"secondary",onClick:V,children:"Close"}),a.jsx(Q,{variant:"primary",icon:Zs,onClick:()=>{V(),r(`/jobs/${N}`)},children:"View Job"})]}):i==="starting"?null:a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Q,{variant:"secondary",onClick:n,children:"Cancel"}),a.jsxs(Q,{variant:"primary",icon:Zs,onClick:A,disabled:u&&f.length===0,children:["Start Optimization (",P," runs)"]})]});return a.jsx(ss,{isOpen:t,onClose:V,title:`Optimize: ${e.name}`,footer:ee(),size:"lg",children:i==="success"&&N?a.jsxs("div",{className:"flex flex-col items-center py-8",children:[a.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/20 flex items-center justify-center mb-4",children:a.jsx(rs,{size:24,className:"text-green-500"})}),a.jsx("h3",{className:"text-lg font-medium mb-2",children:"Job Started!"}),a.jsx("p",{className:"text-[var(--text-secondary)] text-center mb-2",children:"Optimization job is now running"}),a.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-3 py-1.5 rounded font-mono",children:["ID: ",N.slice(0,8),"..."]})]}):i==="starting"?a.jsxs("div",{className:"flex flex-col items-center py-8",children:[a.jsx(ha,{size:32,className:"animate-spin text-[var(--accent)] mb-4"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:re.isPending?"Importing tasks...":"Creating optimization job..."})]}):a.jsxs("div",{className:"space-y-5",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Task Suite"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:u?"__custom__":o,onChange:T=>{T.target.value==="__custom__"?d(!0):(d(!1),c(T.target.value))},children:[G.map(T=>a.jsxs("option",{value:T.value,children:[T.label," (",T.tasks," tasks) — ",T.description]},T.value)),F.length>0&&a.jsx("option",{value:"__custom__",children:"Custom Selection"})]})]}),u&&F.length>0&&a.jsx("div",{className:"max-h-48 overflow-y-auto border border-[var(--border)] rounded p-2 space-y-1",children:F.map(T=>a.jsxs("label",{className:"flex items-center gap-2 p-2 hover:bg-[var(--bg-tertiary)] cursor-pointer rounded",children:[a.jsx("input",{type:"checkbox",checked:f.includes(T.id),onChange:()=>L(T.id),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:T.name}),T.suite&&a.jsx(q,{children:T.suite})]},T.id))}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[a.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>k(!v),children:[a.jsx(Xs,{size:14,className:`transition-transform ${v?"rotate-90":""}`}),"Advanced Settings",v&&a.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"(experiment design, variations, execution)"})]}),v&&B&&a.jsx("div",{className:"mt-4",children:a.jsx(Y0,{agentId:e.id,agentName:e.name,agentFramework:e.config.framework,taskSuite:u?void 0:o,taskCount:X,schema:B,onVariationsChange:b,parallel:p,onParallelChange:h,budget:x,onBudgetChange:w,useLlmEval:C,onUseLlmEvalChange:S})})]})]})})}function X0(){const e=zn(),t=Wt(),[n,r]=j.useState(!1),[s,i]=j.useState(null),{data:l=[],isLoading:o}=le({queryKey:["configs"],queryFn:()=>_n.list()}),c=Je({mutationFn:_n.create,onSuccess:()=>{t.invalidateQueries({queryKey:["configs"]}),r(!1)}}),u=Je({mutationFn:_n.delete,onSuccess:()=>t.invalidateQueries({queryKey:["configs"]})}),d=[{key:"name",header:"Name",render:f=>a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:f.name})},{key:"framework",header:"Framework",render:f=>a.jsx(q,{children:f.config.framework||"maf"})},{key:"tools",header:"Tools",render:f=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:Z0(f.config.tools)})},{key:"compaction",header:"Compaction",render:f=>{const m=f.config.compaction;return!m||m.strategy==="none"?a.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"}):m.strategy==="head_tail"?a.jsxs(q,{children:[m.params.head_size,"/",m.params.tail_size]}):a.jsx(q,{children:m.strategy})}},{key:"created",header:"Created",render:f=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(f.created_at).toLocaleDateString()}),sortable:!0,sortValue:f=>new Date(f.created_at).getTime()},{key:"actions",header:"",className:"w-40",render:f=>a.jsxs("div",{className:"flex items-center gap-2",onClick:m=>m.stopPropagation(),children:[a.jsx(Q,{variant:"primary",size:"sm",icon:rs,onClick:()=>i(f),children:"Optimize"}),a.jsx(Q,{variant:"ghost",size:"sm",icon:qc,title:"Delete",onClick:()=>{confirm(`Delete agent "${f.name}"?`)&&u.mutate(f.id)}})]})}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Agents"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Define and optimize your agent configurations."})]}),a.jsx(Q,{variant:"primary",icon:Hc,onClick:()=>r(!0),children:"Create agent"})]}),o?a.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[a.jsx(ha,{size:16,className:"animate-spin"}),"Loading agents..."]}):a.jsx(Xm,{columns:d,data:l,onRowClick:f=>e(`/agents/${f.id}`),searchable:!0,searchPlaceholder:"Search agents",searchFilter:(f,m)=>f.name.toLowerCase().includes(m.toLowerCase())||(f.description||"").toLowerCase().includes(m.toLowerCase()),emptyMessage:"No agents yet. Create your first agent to start optimizing.",emptyIcon:a.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-[var(--bg-tertiary)]",children:a.jsx(Bm,{size:24,className:"text-[var(--text-secondary)]"})})}),a.jsx(e1,{isOpen:n,onClose:()=>r(!1),onSubmit:f=>c.mutate(f),isLoading:c.isPending}),s&&a.jsx(Zm,{agent:s,isOpen:!!s,onClose:()=>i(null)})]})}function Z0(e){return typeof e=="string"?e:Array.isArray(e)?`[${e.length}]`:e&&typeof e=="object"?`[${Object.keys(e).length}]`:"standard"}function e1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){var V,ee,R,T,te,pe,Se;const s=["read_file","write_file","edit_file","bash","grep","think"],[i,l]=j.useState("preset"),[o,c]=j.useState({name:"",description:"",instructions:null,model:null,compaction:{strategy:"none",params:{}},tools:s,framework:"miniagent",llm_config_id:null}),[u,d]=j.useState(!1),[f,m]=j.useState("preset"),[v,k]=j.useState([...s]),[g,b]=j.useState(!1),{data:p}=le({queryKey:["agent-schema"],queryFn:()=>Jm.getAgentSchema()}),{data:h=[]}=le({queryKey:["llm-configs"],queryFn:()=>C0.list()}),{data:x}=le({queryKey:["tools"],queryFn:()=>_0.list()}),w=((V=x==null?void 0:x.tools)==null?void 0:V.map(M=>M.name))??s,C=(x==null?void 0:x.presets)??{},S=Object.keys(C),N=(p==null?void 0:p.frameworks)??{},_=Object.keys(N).length>0?Object.keys(N):Q0,F=o.framework||"miniagent",O=((R=(ee=p==null?void 0:p.frameworks)==null?void 0:ee[F])==null?void 0:R.compaction_strategies)??["none","head_tail"],B=(p==null?void 0:p.compaction_strategies)??{},G=(p==null?void 0:p.agent_presets)??[],re=M=>{const K=M.config,dt=K.compaction;n({name:M.name+"-agent",description:M.description,framework:K.framework||"miniagent",tools:K.tools||"standard",compaction:dt||{strategy:"none",params:{}},instructions:K.instructions||null})},oe=M=>{if(M.preventDefault(),!o.name.trim())return;const K={...o};f==="custom"&&(K.tools=v),n(K)},D=((T=o.compaction)==null?void 0:T.strategy)!=="none",W=((te=o.compaction)==null?void 0:te.strategy)||"none",X=B[W],P=M=>{k(K=>K.includes(M)?K.filter(dt=>dt!==M):[...K,M])},A=M=>{const K=B[M],dt={};if(K!=null&&K.params)for(const[as,is]of Object.entries(K.params))is.default!==void 0&&(dt[as]=is.default);c({...o,compaction:{strategy:M,params:dt}})},L=i==="custom"?a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(Q,{type:"submit",form:"create-agent-form",variant:"primary",disabled:!o.name.trim(),loading:r,children:"Create Agent"})]}):a.jsx("div",{className:"flex justify-end gap-2",children:a.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"})});return a.jsxs(ss,{isOpen:e,onClose:t,title:"Create Agent",footer:L,children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b border-[var(--border)]",children:[a.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${i==="preset"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("preset"),children:"From Preset"}),a.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${i==="custom"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("custom"),children:"Custom"})]}),i==="preset"?a.jsx("div",{className:"space-y-3",children:G.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"Loading presets..."}):G.map(M=>a.jsx("button",{type:"button",className:"w-full text-left p-4 border border-[var(--border)] rounded-lg hover:border-[var(--accent)] hover:bg-[var(--accent)]/5 transition-colors",onClick:()=>re(M),disabled:r,children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("h4",{className:"font-medium",children:M.label}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:M.description}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[M.tags.map(K=>a.jsx(q,{variant:"default",children:K},K)),M.suggested_datasets.length>0&&a.jsxs(q,{variant:"success",children:["datasets: ",M.suggested_datasets.join(", ")]})]})]}),a.jsx(Xs,{size:16,className:"text-[var(--text-secondary)] mt-1 flex-shrink-0"})]})},M.name))}):a.jsxs("form",{id:"create-agent-form",onSubmit:oe,className:"space-y-4",children:[a.jsx(pn,{label:"Name",value:o.name,onChange:M=>c({...o,name:M.target.value}),placeholder:"e.g., my-coding-agent",required:!0}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"LLM Configuration"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.llm_config_id||"",onChange:M=>c({...o,llm_config_id:M.target.value||null}),children:[a.jsx("option",{value:"",children:"Use environment variables"}),h.map(M=>a.jsxs("option",{value:M.id,children:[M.name," (",K0[M.provider],M.model_id?` - ${M.model_id}`:"",")",M.is_default?" (default)":""]},M.id))]}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:h.length===0?"No LLM configs found. Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)":o.llm_config_id?"Uses the selected LLM configuration.":"Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Framework"}),a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.framework||"miniagent",onChange:M=>{const K=M.target.value;c({...o,framework:K,compaction:{strategy:"none",params:{}}})},children:_.map(M=>{var K;return a.jsx("option",{value:M,children:((K=N[M])==null?void 0:K.label)||V0[M]||M},M)})}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((pe=N[F])==null?void 0:pe.description)||(F==="miniagent"?"Lightweight agent with token-aware context management.":F==="langgraph"?"Graph-based workflows with state management.":"Default agent implementation.")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(bi,{label:"Custom instructions",checked:u,onChange:M=>{d(M.target.checked),M.target.checked||c({...o,instructions:null})}}),a.jsx(bi,{label:"Enable compaction",checked:D,onChange:M=>{if(M.target.checked){const K=O.find(dt=>dt!=="none")||"head_tail";A(K)}else c({...o,compaction:{strategy:"none",params:{}}})}})]}),u&&a.jsx("textarea",{className:"w-full h-32 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono resize-y",value:o.instructions||"",onChange:M=>c({...o,instructions:M.target.value||null}),placeholder:"System prompt / instructions for the agent..."}),D&&a.jsxs("div",{className:"space-y-3 p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Compaction Strategy"}),a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:W,onChange:M=>A(M.target.value),children:O.filter(M=>M!=="none").map(M=>{var K;return a.jsx("option",{value:M,children:((K=B[M])==null?void 0:K.label)||M},M)})}),(X==null?void 0:X.description)&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:X.description})]}),(X==null?void 0:X.params)&&Object.keys(X.params).length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-3",children:Object.entries(X.params).map(([M,K])=>{var is;const dt=(is=o.compaction)==null?void 0:is.params[M],as=dt!==void 0?dt:K.default;return a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:M.replace(/_/g," ")}),a.jsx("input",{type:"number",className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof as=="number"?as:Number(as)||0,onChange:ip=>{const tu=parseFloat(ip.target.value);c({...o,compaction:{...o.compaction,params:{...o.compaction.params,[M]:isNaN(tu)?typeof K.default=="number"?K.default:0:tu}}})},min:K.min,max:K.max,step:K.max&&K.max<=1?.1:1}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:K.description})]},M)})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm font-medium",children:"Tools"}),a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"radio",checked:f==="preset",onChange:()=>m("preset"),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:"Preset"})]}),a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"radio",checked:f==="custom",onChange:()=>m("custom"),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:"Custom"})]})]}),f==="preset"?a.jsxs(a.Fragment,{children:[a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof o.tools=="string"?o.tools:"standard",onChange:M=>c({...o,tools:M.target.value}),children:S.map(M=>a.jsx("option",{value:M,children:M},M))}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((Se=C[typeof o.tools=="string"?o.tools:"standard"])==null?void 0:Se.join(", "))??""})]}):a.jsx("div",{className:"grid grid-cols-2 gap-1 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:w.map(M=>a.jsxs("label",{className:"flex items-center gap-2 p-1 text-sm cursor-pointer hover:bg-[var(--bg-tertiary)]",children:[a.jsx("input",{type:"checkbox",checked:v.includes(M),onChange:()=>P(M),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"font-mono text-xs",children:M})]},M))})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[a.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>b(!g),children:[a.jsx(Xs,{size:14,className:`transition-transform ${g?"rotate-90":""}`}),"More options"]}),g&&a.jsx("div",{className:"mt-3",children:a.jsx(pn,{label:"Description (optional)",value:o.description,onChange:M=>c({...o,description:M.target.value}),placeholder:"Brief description of this agent"})})]})]})]})}function ma({items:e}){return a.jsx("nav",{className:"flex items-center gap-1.5 text-sm mb-4",children:e.map((t,n)=>{const r=n===e.length-1;return a.jsxs("span",{className:"flex items-center gap-1.5",children:[n>0&&a.jsx(Xs,{size:14,className:"text-[var(--text-secondary)]"}),t.path&&!r?a.jsx(Tn,{to:t.path,className:"text-[var(--text-secondary)] hover:text-[var(--accent)] transition-colors",children:t.label}):a.jsx("span",{className:r?"text-[var(--text-primary)] font-medium":"text-[var(--text-secondary)]",children:t.label})]},n)})})}function ge({children:e,className:t="",onClick:n,selected:r=!1,selectable:s=!1}){const i="bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",l=s?"cursor-pointer hover:border-[var(--accent-dim)] transition-colors":"",o=r?"border-[var(--accent)]":"";return a.jsx("div",{className:`${i} ${l} ${o} ${t}`,onClick:n,children:e})}function t1(e){const t=[],n=r=>r.type==="trace_span"&&typeof r.data=="object"&&r.data!==null?r.data:"span_id"in r?r:null;if(Array.isArray(e.spans)){for(const r of e.spans)if(typeof r=="object"&&r!==null){const s=n(r);s&&t.push(s)}}else if(e.span_id)t.push(e);else for(const r in e){const s=e[r];if(typeof s=="object"&&s!==null){const i=n(s);if(i)t.push(i);else if(Array.isArray(s)){for(const l of s)if(typeof l=="object"&&l!==null){const o=n(l);o&&t.push(o)}}}}return t}function ep(e){const t=new Map,n=[];for(const s of e)t.set(s.span_id,{span:s,children:[]});for(const s of e){const i=t.get(s.span_id);s.parent_span_id&&t.has(s.parent_span_id)?t.get(s.parent_span_id).children.push(i):n.push(i)}const r=s=>{s.sort((i,l)=>(i.span.start_time||0)-(l.span.start_time||0)),s.forEach(i=>r(i.children))};return r(n),n}function n1(e){return e.includes("Agent")||e.includes("agent")?"bg-[var(--span-llm-bg)] text-[var(--span-llm-text)]":e.includes("chat")||e.includes("Chat")||e.includes("llm")?"bg-[var(--span-tool-bg)] text-[var(--span-tool-text)]":e.includes("tool")||e.includes("execute")||e.includes("bash")?"bg-[var(--span-agent-bg)] text-[var(--span-agent-text)]":"bg-[var(--span-other-bg)] text-[var(--span-other-text)]"}function r1(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(0)}ms`}function eu({node:e,depth:t=0}){var f,m;const[n,r]=j.useState(t<2),[s,i]=j.useState(!1),{span:l}=e,o=e.children.length>0,c=(f=l.attributes)==null?void 0:f["gen_ai.usage.input_tokens"],u=(m=l.attributes)==null?void 0:m["gen_ai.usage.output_tokens"],d=c!==void 0||u!==void 0;return a.jsxs("div",{className:"relative",children:[t>0&&a.jsx("div",{className:"absolute left-0 top-0 bottom-0 border-l-2 border-[var(--border)]",style:{marginLeft:`${(t-1)*16+8}px`}}),a.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-1 hover:bg-[var(--bg-primary)] rounded transition-colors cursor-pointer",style:{paddingLeft:`${t*16}px`},onClick:()=>o?r(!n):i(!s),children:[a.jsx("div",{className:"w-4 h-4 flex items-center justify-center text-[var(--text-secondary)]",children:o?n?"▼":"▶":s?"▼":"▶"}),a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${n1(l.operation_name)}`,children:l.operation_name.replace("ChatAgent.","").replace("invoke_agent ","")}),l.duration_ms!==void 0&&a.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:r1(l.duration_ms)}),d&&a.jsxs("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:[c!==void 0&&a.jsxs("span",{className:"text-blue-400",children:["↑",String(c)]}),c!==void 0&&u!==void 0&&a.jsx("span",{className:"mx-0.5",children:"/"}),u!==void 0&&a.jsxs("span",{className:"text-green-400",children:["↓",String(u)]})]})]}),s&&!o&&a.jsx("div",{className:"ml-4 mt-1 mb-2 p-2 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs",style:{marginLeft:`${t*16+20}px`},children:a.jsxs("div",{className:"space-y-1",children:[l.span_id&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Span ID:"}),a.jsx("span",{className:"font-mono text-xs break-all",children:l.span_id})]}),l.trace_id&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Trace ID:"}),a.jsx("span",{className:"font-mono text-xs break-all",children:l.trace_id})]}),l.status&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Status:"}),a.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs ${l.status==="OK"||l.status==="StatusCode.UNSET"?"bg-[var(--span-pass-bg)] text-[var(--span-pass-text)]":"bg-[var(--span-fail-bg)] text-[var(--span-fail-text)]"}`,children:l.status})]}),Object.keys(l.attributes||{}).length>0&&a.jsxs("div",{className:"mt-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] block mb-1",children:"Attributes:"}),a.jsx("pre",{className:"text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded p-2 overflow-auto max-h-32 whitespace-pre-wrap break-all",children:JSON.stringify(l.attributes,null,2)})]})]})}),o&&n&&a.jsx("div",{children:e.children.map((v,k)=>a.jsx(eu,{node:v,depth:t+1},v.span.span_id||k))})]})}function tp({trace:e}){const[t,n]=j.useState("tree"),r=j.useMemo(()=>t1(e),[e]),s=j.useMemo(()=>ep(r),[r]);return Object.keys(e).length===0?null:a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"font-medium",children:"Trace Data"}),a.jsxs("div",{className:"flex gap-1",children:[a.jsx("button",{onClick:()=>n("tree"),className:`px-2 py-1 text-xs rounded ${t==="tree"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Tree"}),a.jsx("button",{onClick:()=>n("raw"),className:`px-2 py-1 text-xs rounded ${t==="raw"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Raw"})]})]}),t==="tree"?r.length>0?a.jsx("div",{className:"border border-[var(--border)] rounded overflow-hidden",children:a.jsxs("div",{className:"p-2",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs(q,{variant:"default",children:[r.length," spans"]}),a.jsx("span",{children:"•"}),a.jsx("span",{children:"Click to expand details"})]}),s.map((i,l)=>a.jsx(eu,{node:i,depth:0},i.span.span_id||l))]})}):a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No structured spans found. View raw data below."}):a.jsx("pre",{className:"text-xs bg-[var(--bg-primary)] p-3 overflow-x-auto border border-[var(--border)] max-h-96 whitespace-pre-wrap",children:JSON.stringify(e,null,2)})]})}function s1({spans:e,isLive:t=!1}){const n=j.useRef(null),r=j.useMemo(()=>ep(e),[e]);return j.useEffect(()=>{n.current&&t&&n.current.scrollTo({top:n.current.scrollHeight,behavior:"smooth"})},[e.length,t]),a.jsxs("div",{className:"border border-[var(--border)] rounded overflow-hidden h-full flex flex-col",children:[a.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-[var(--border)] bg-[var(--bg-secondary)]",children:[a.jsxs(q,{variant:"default",children:[e.length," spans"]}),t&&a.jsx("span",{className:"animate-pulse",children:a.jsx(q,{variant:"info",children:"Live"})})]}),a.jsx("div",{ref:n,className:"flex-1 overflow-auto p-2",children:r.length>0?r.map((s,i)=>a.jsx(eu,{node:s,depth:0},s.span.span_id||i)):a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:t?"Waiting for spans...":"No spans recorded"})})]})}function np({agent:e}){const[t,n]=j.useState(""),[r,s]=j.useState(null),[i,l]=j.useState("idle"),[o,c]=j.useState(null),[u,d]=j.useState(""),[f,m]=j.useState([]),[v,k]=j.useState(null),[g,b]=j.useState(null),[p,h]=j.useState([]),[x,w]=j.useState(!1),C=j.useRef(null),{data:S=[]}=le({queryKey:["tasks"],queryFn:()=>gt.list()});j.useEffect(()=>{C.current&&i==="running"&&(C.current.scrollTop=C.current.scrollHeight)},[u,i]);const N=D=>{if(s(D),D){const W=S.find(X=>X.id===D);W&&n(W.prompt)}},_=async()=>{if(t.trim()){l("running"),d(""),m([]),k(null),b(null),h([]);try{const D=await Os.create({agent_id:e.id,prompt:t.trim(),task_id:r||void 0});c(D.id);for await(const W of Os.start(D.id))F(W)}catch(D){b(D instanceof Error?D.message:"Test failed"),l("failed")}}},F=D=>{switch(D.event){case"started":break;case"execution":D.execution_event==="text_delta"&&D.content?d(W=>W+D.content):D.execution_event==="tool_call_start"&&D.tool_name?h(W=>[...W,{name:D.tool_name}]):D.execution_event==="tool_result"&&D.content&&h(W=>{if(W.length>0){const X=[...W];return X[X.length-1]={...X[X.length-1],content:D.content},X}return W});break;case"span":if(D.span){const W=D.span;if(W.data){const X={span_id:W.data.span_id||"",trace_id:W.data.trace_id||"",parent_span_id:W.data.parent_span_id||null,operation_name:W.data.operation_name||"",start_time:W.timestamp?new Date(W.timestamp).getTime():Date.now(),end_time:Date.now(),duration_ms:W.data.duration_ms||0,status:W.data.status||"OK",attributes:W.data.attributes||{}};m(P=>[...P,X])}}break;case"complete":l("completed"),D.result&&k(D.result);break;case"error":b(D.message),l("failed");break}},O=async()=>{if(o)try{await Os.cancel(o)}catch{}l("idle")},B=()=>{l("idle"),c(null),d(""),m([]),k(null),b(null),h([])},G=i==="running",re=i==="completed"||i==="failed",oe=D=>{D.preventDefault(),re?(B(),setTimeout(()=>_(),0)):_()};return a.jsxs("div",{className:"h-full flex flex-col border border-[var(--border)] rounded-lg overflow-hidden bg-[var(--bg-primary)]",children:[(G||re)&&a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border)] bg-[var(--bg-secondary)] flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[G&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"animate-pulse",children:a.jsx(q,{variant:"info",children:"Running"})}),a.jsx(Q,{variant:"ghost",size:"sm",icon:Ld,onClick:O,children:"Cancel"})]}),i==="completed"&&a.jsx(q,{variant:"success",children:"Completed"}),i==="failed"&&a.jsx(q,{variant:"error",children:"Failed"})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[v&&a.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Im,{size:12}),v.duration_seconds.toFixed(2),"s"]}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Mg,{size:12}),v.tokens_total," tokens"]}),v.passed!==null&&(v.passed?a.jsx(Fm,{size:14,className:"text-[var(--success)]"}):a.jsx(Xg,{size:14,className:"text-[var(--error)]"}))]}),f.length>0&&a.jsxs(Q,{variant:x?"primary":"secondary",size:"sm",icon:Sg,onClick:()=>w(!x),children:["Traces (",f.length,")"]}),re&&o&&a.jsx(Tn,{to:`/tests/${o}`,children:a.jsx(Q,{variant:"secondary",size:"sm",icon:Am,children:"Details"})})]})]}),a.jsxs("div",{className:"flex-1 min-h-0 flex",children:[a.jsx("div",{ref:C,className:`flex-1 overflow-auto p-4 ${x?"border-r border-[var(--border)]":""}`,children:!G&&!re?a.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center",children:[a.jsx("div",{className:"text-lg font-medium mb-1",children:e.name}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] max-w-sm",children:"Send a message to test this agent, or select a task from the dropdown below."})]}):a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"flex justify-end",children:a.jsx("div",{className:"max-w-[80%] px-3 py-2 bg-[var(--accent-dim)] text-[var(--text-primary)] rounded-lg text-sm",children:t})}),(u||G)&&a.jsx("div",{className:"px-3 py-2 text-sm whitespace-pre-wrap font-mono bg-[var(--bg-secondary)] rounded-lg border border-[var(--border)]",children:u||a.jsx("span",{className:"text-[var(--text-secondary)] animate-pulse",children:"Thinking..."})}),p.length>0&&a.jsx("div",{className:"space-y-1.5",children:p.map((D,W)=>a.jsxs("div",{className:"p-2 bg-[var(--badge-info-bg)] border border-[var(--badge-info-border)] rounded-md text-xs",children:[a.jsx(q,{variant:"info",children:D.name}),D.content&&a.jsxs("div",{className:"mt-1 text-[var(--text-secondary)] truncate max-w-full font-mono",children:[D.content.substring(0,200),D.content.length>200&&"..."]})]},W))}),g&&a.jsx("div",{className:"p-3 bg-[var(--badge-error-bg)] border border-[var(--badge-error-border)] rounded-md text-sm text-[var(--badge-error-text)]",children:g})]})}),x&&a.jsx("div",{className:"w-[350px] flex-shrink-0 overflow-auto",children:a.jsx(s1,{spans:f,isLive:G})})]}),a.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] bg-[var(--bg-secondary)]",children:[a.jsx("div",{className:"px-4 pt-2",children:a.jsxs("select",{value:r||"",onChange:D=>N(D.target.value||null),className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs text-[var(--text-secondary)]",disabled:G,children:[a.jsx("option",{value:"",children:"Custom prompt..."}),S.map(D=>a.jsx("option",{value:D.id,children:D.name},D.id))]})}),a.jsxs("form",{onSubmit:oe,className:"p-3 flex gap-2",children:[a.jsx("textarea",{value:t,onChange:D=>n(D.target.value),placeholder:"Message the agent...",disabled:G,rows:1,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm resize-none min-h-[40px] max-h-[120px] focus:outline-none focus:border-[var(--accent)]",onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),oe(D))}}),a.jsx(Q,{type:"submit",variant:"primary",icon:G?Ld:Zs,disabled:G?!1:!t.trim(),onClick:G?O:void 0,children:G?"Stop":re?"New Test":"Run"})]})]})]})}function a1(){const{agentId:e}=fa(),t=zn(),n=Wt(),[r,s]=j.useState("overview"),[i,l]=j.useState(!1),{data:o,isLoading:c}=le({queryKey:["configs",e],queryFn:()=>_n.get(e),enabled:!!e}),{data:u=[]}=le({queryKey:["tests",{agent_id:e}],queryFn:()=>Os.list({agent_id:e}),enabled:!!e}),{data:d=[]}=le({queryKey:["jobs"],queryFn:()=>Ot.list()}),f=Je({mutationFn:v=>_n.delete(v),onSuccess:()=>{n.invalidateQueries({queryKey:["configs"]}),t("/agents")}}),m=d.filter(v=>v.candidate_ids.includes(e||""));return c?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):o?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsxs("div",{className:"mb-4 flex-shrink-0",children:[a.jsx(ma,{items:[{label:"Agents",path:"/agents"},{label:o.name}]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:o.name}),o.is_auto_generated&&a.jsx(q,{variant:"info",children:"Auto-generated"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Q,{variant:"primary",icon:rs,size:"sm",onClick:()=>l(!0),children:"Optimize"}),a.jsx(Q,{variant:"secondary",icon:qc,size:"sm",onClick:()=>{confirm(`Delete agent "${o.name}"?`)&&f.mutate(o.id)},children:"Delete"})]})]}),o.description&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:o.description})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsxs("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:[a.jsxs("div",{className:"flex gap-1 mb-4 border-b border-[var(--border)] flex-shrink-0",children:[a.jsx(Nl,{active:r==="overview",onClick:()=>s("overview"),icon:a.jsx(Bm,{size:14}),children:"Overview"}),a.jsx(Nl,{active:r==="evaluate",onClick:()=>s("evaluate"),icon:a.jsx(Zs,{size:14}),children:"Evaluate"}),a.jsx(Nl,{active:r==="history",onClick:()=>s("history"),icon:a.jsx(Ag,{size:14}),badge:u.length,children:"History"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r==="overview"&&a.jsx(i1,{agent:o,recentTests:u,jobs:m}),r==="evaluate"&&a.jsx(l1,{agent:o,jobs:m}),r==="history"&&a.jsx(o1,{tests:u})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[a.jsx(Um,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),a.jsx("div",{className:"flex-1 min-h-0",children:a.jsx(np,{agent:o})})]})]}),i&&a.jsx(Zm,{agent:o,isOpen:i,onClose:()=>l(!1)})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Agent not found"})}function Nl({active:e,onClick:t,icon:n,badge:r,children:s}){return a.jsxs("button",{onClick:t,className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors ${e?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[n,s,r!==void 0&&r>0&&a.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs bg-[var(--bg-tertiary)] rounded",children:r})]})}function i1({agent:e,recentTests:t,jobs:n}){var i,l;const r=e.config,s=()=>{const o=r.tools;return typeof o=="string"?o:Array.isArray(o)?o.join(", "):o&&typeof o=="object"?Object.keys(o).join(", "):"standard"};return a.jsxs("div",{className:"space-y-4",children:[a.jsx(ur,{title:"Model",children:a.jsx("div",{className:"font-mono text-sm",children:r.model||"default"})}),a.jsx(ur,{title:"Instructions",defaultCollapsed:!r.instructions,children:r.instructions?a.jsx("pre",{className:"p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs whitespace-pre-wrap max-h-40 overflow-auto font-mono",children:r.instructions}):a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No instructions set"})}),a.jsx(ur,{title:"Tools",children:a.jsx("div",{className:"font-mono text-sm",children:s()})}),a.jsx(ur,{title:"Compaction",children:a.jsx("div",{className:"font-mono text-sm",children:!r.compaction||r.compaction.strategy==="none"?"disabled":`${r.compaction.strategy} (${((i=r.compaction.params)==null?void 0:i.head_size)||0}/${((l=r.compaction.params)==null?void 0:l.tail_size)||0})`})}),t.length>0&&a.jsx(ur,{title:`Recent Tests (${t.length})`,children:a.jsx("div",{className:"space-y-1.5",children:t.slice(0,3).map(o=>a.jsxs(Tn,{to:`/tests/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx(rp,{status:o.status}),a.jsxs("span",{className:"truncate",children:[o.prompt.slice(0,40),"..."]})]}),a.jsxs("span",{className:"text-[var(--text-secondary)] flex-shrink-0 ml-2",children:[o.duration_seconds.toFixed(1),"s"]})]},o.id))})}),n.length>0&&a.jsx(ur,{title:`Experiments (${n.length})`,children:a.jsx("div",{className:"space-y-1.5",children:n.slice(0,3).map(o=>a.jsxs(Tn,{to:`/jobs/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(q,{variant:o.status==="completed"?"success":o.status==="running"?"info":"default",children:o.status}),a.jsx("span",{children:o.name})]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(o.created_at).toLocaleDateString()})]},o.id))})})]})}function ur({title:e,children:t,defaultCollapsed:n=!1}){const[r,s]=j.useState(n);return a.jsxs("div",{className:"border-b border-[var(--border)] pb-3",children:[a.jsxs("button",{onClick:()=>s(!r),className:"flex items-center justify-between w-full text-left py-1 hover:text-[var(--accent)] transition-colors",children:[a.jsx("span",{className:"text-sm font-medium",children:e}),a.jsx("span",{className:"text-[var(--text-secondary)] text-xs",children:r?"▶":"▼"})]}),!r&&a.jsx("div",{className:"mt-2",children:t})]})}function l1({agent:e,jobs:t}){const n=zn(),r=Wt(),[s,i]=j.useState("quick"),[l,o]=j.useState(!1),{data:c=[]}=le({queryKey:["suites"],queryFn:()=>gt.listSuites()}),u=Je({mutationFn:P0.start,onSuccess:f=>{r.invalidateQueries({queryKey:["jobs"]}),o(!1),n(`/jobs/${f.id}`)},onError:()=>{o(!1)}}),d=()=>{o(!0),u.mutate({agent_id:e.id,suite_name:s,use_llm_eval:!0,parallel:4})};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:"Run this agent on a task suite to measure quality and cost."}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm",value:s,onChange:f=>i(f.target.value),disabled:l,children:c.map(f=>a.jsxs("option",{value:f.name,children:[f.name.charAt(0).toUpperCase()+f.name.slice(1)," (",f.task_count," tasks)"]},f.name))}),a.jsx(Q,{variant:"primary",icon:l?ha:Zs,onClick:d,disabled:l,loading:l,className:"w-full",children:"Evaluate"})]})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h4",{className:"text-sm font-medium",children:"Optimization Jobs"}),a.jsx(Q,{variant:"secondary",size:"sm",icon:rs,onClick:()=>n("/agents",{state:{optimizeAgent:e}}),children:"New Job"})]}),t.length===0?a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No optimization jobs yet."}):a.jsx("div",{className:"space-y-1.5",children:t.slice(0,5).map(f=>a.jsxs(Tn,{to:`/jobs/${f.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(q,{variant:f.status==="completed"?"success":f.status==="running"?"info":"default",children:f.status}),a.jsx("span",{children:f.name})]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(f.created_at).toLocaleDateString()})]},f.id))})]})]})}function o1({tests:e}){return e.length===0?a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No test history yet. Use the playground on the right to run a test."}):a.jsx("div",{className:"space-y-2",children:e.map(t=>a.jsxs(Tn,{to:`/tests/${t.id}`,className:"flex items-center justify-between p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(rp,{status:t.status}),t.score!==null&&a.jsxs("span",{className:`text-sm font-medium ${t.passed?"text-[var(--success)]":"text-[var(--error)]"}`,children:[(t.score*100).toFixed(0),"%"]})]}),a.jsx("p",{className:"text-sm truncate",children:t.prompt})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1 ml-4",children:[a.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:new Date(t.created_at).toLocaleString()}),a.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:[t.duration_seconds.toFixed(1),"s"]}),a.jsxs("span",{children:[t.tokens_total," tokens"]})]})]})]},t.id))})}function rp({status:e}){const t={completed:"success",failed:"error",running:"info",cancelled:"warning",pending:"default"};return a.jsx(q,{variant:t[e]||"default",children:e})}function c1(){const e=Wt(),[t,n]=j.useState(!1),[r,s]=j.useState(!1),[i,l]=j.useState(null),[o,c]=j.useState(new Set),u=p=>{c(h=>{const x=new Set(h);return x.has(p)?x.delete(p):x.add(p),x})},{data:d=[],isLoading:f}=le({queryKey:["tasks"],queryFn:()=>gt.list()}),m=Je({mutationFn:gt.create,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),n(!1)}}),v=Je({mutationFn:gt.importSuite,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),s(!1)}}),k=Je({mutationFn:gt.delete,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),l(null)}}),g=d.reduce((p,h)=>{const x=h.suite||"custom";return p[x]||(p[x]=[]),p[x].push(h),p},{}),b=Object.keys(g).sort((p,h)=>p==="custom"?-1:h==="custom"?1:p.localeCompare(h));return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Datasets"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Task datasets for evaluating agent configurations."})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Q,{variant:"secondary",onClick:()=>s(!0),children:"Import Suite"}),a.jsx(Q,{variant:"primary",onClick:()=>n(!0),children:"+ New Task"})]})]}),f?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):d.length===0?a.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:"No tasks yet. Create one or import a built-in suite."}):a.jsx("div",{className:"space-y-4",children:b.map(p=>{const h=g[p],x=!o.has(p);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>u(p),className:"flex items-center gap-2 py-2 hover:text-[var(--accent)] transition-colors",children:[x?a.jsx(Og,{size:16,className:"text-[var(--text-secondary)]"}):a.jsx(Xs,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium uppercase tracking-wide",children:p==="custom"?"Custom Tasks":`${p} Suite`}),a.jsx(q,{variant:p==="custom"?"default":"info",children:h.length})]}),x&&a.jsx("div",{className:"mt-2 border border-[var(--border)] rounded-lg overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:[a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Name"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Category"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Prompt"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Criteria"})]})}),a.jsx("tbody",{children:h.map(w=>a.jsxs("tr",{onClick:()=>l(w),className:"border-b border-[var(--border)] last:border-b-0 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors",children:[a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:w.name})}),a.jsx("td",{className:"px-4 py-3",children:w.category&&w.category!=="default"?a.jsx(q,{variant:"default",children:w.category}):a.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"})}),a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-[var(--text-secondary)] line-clamp-1 max-w-md",children:w.prompt})}),a.jsx("td",{className:"px-4 py-3 text-[var(--text-secondary)]",children:w.criteria.length>0?w.criteria.length:"--"})]},w.id))})]})})]},p)})}),a.jsx(u1,{task:i,onClose:()=>l(null),onDelete:p=>{confirm("Delete this task?")&&k.mutate(p)}}),a.jsx(d1,{isOpen:t,onClose:()=>n(!1),onSubmit:p=>m.mutate(p),isLoading:m.isPending}),a.jsx(f1,{isOpen:r,onClose:()=>s(!1),onSubmit:p=>v.mutate(p),isLoading:v.isPending})]})}function u1({task:e,onClose:t,onDelete:n}){const[r,s]=j.useState("prompt");if(!e)return null;const i=a.jsxs("div",{className:"flex justify-between",children:[a.jsx(Q,{variant:"ghost",onClick:()=>n(e.id),className:"text-red-500 hover:text-red-600",children:"Delete Task"}),a.jsx(Q,{variant:"secondary",onClick:t,children:"Close"})]});return a.jsx(ss,{isOpen:!!e,onClose:t,title:e.name,size:"lg",footer:i,children:a.jsxs("div",{className:"space-y-4",children:[e.category&&e.category!=="default"&&a.jsx("div",{children:a.jsx(q,{variant:"default",children:e.category})}),a.jsxs("div",{className:"flex gap-1 border-b border-[var(--border)]",children:[a.jsx("button",{onClick:()=>s("prompt"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="prompt"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Prompt"}),a.jsxs("button",{onClick:()=>s("criteria"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="criteria"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:["Eval Criteria (",e.criteria.length,")"]})]}),r==="prompt"&&a.jsx("div",{className:"p-4 bg-[var(--bg-tertiary)] rounded text-sm whitespace-pre-wrap min-h-[200px]",children:e.prompt}),r==="criteria"&&a.jsx("div",{className:"space-y-2 min-h-[200px]",children:e.criteria.length===0?a.jsx("div",{className:"text-[var(--text-secondary)] text-sm p-4",children:"No evaluation criteria defined for this task."}):e.criteria.map(l=>a.jsxs("div",{className:"p-3 bg-[var(--bg-tertiary)] rounded",children:[a.jsx("div",{className:"font-medium text-sm",children:l.name}),l.instruction&&a.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1",children:l.instruction})]},l.name))})]})})}function d1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,i]=j.useState({name:"",prompt:"",criteria:[],category:"default"}),l=()=>{i({...s,criteria:[...s.criteria,{name:"",instruction:"",weight:1}]})},o=(d,f)=>{const m=[...s.criteria];m[d]={...m[d],...f},i({...s,criteria:m})},c=d=>{i({...s,criteria:s.criteria.filter((f,m)=>m!==d)})},u=d=>{d.preventDefault(),!(!s.name.trim()||!s.prompt.trim())&&n({...s,criteria:s.criteria.filter(f=>f.name.trim()&&f.instruction.trim())})};return a.jsx(ss,{isOpen:e,onClose:t,title:"Create Task",children:a.jsxs("form",{onSubmit:u,className:"space-y-4",children:[a.jsx(pn,{label:"Name",value:s.name,onChange:d=>i({...s,name:d.target.value}),placeholder:"e.g., fizzbuzz",required:!0}),a.jsx(q0,{label:"Prompt",value:s.prompt,onChange:d=>i({...s,prompt:d.target.value}),placeholder:"The task description for the agent...",required:!0}),a.jsx(pn,{label:"Category",value:s.category,onChange:d=>i({...s,category:d.target.value}),placeholder:"e.g., coding, research"}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Evaluation Criteria"}),a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"+ Add"})]}),a.jsx("div",{className:"space-y-2",children:s.criteria.map((d,f)=>a.jsxs("div",{className:"flex gap-2 items-start",children:[a.jsx(pn,{value:d.name,onChange:m=>o(f,{name:m.target.value}),placeholder:"Name",className:"w-32"}),a.jsx(pn,{value:d.instruction,onChange:m=>o(f,{instruction:m.target.value}),placeholder:"Instruction",className:"flex-1"}),a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(f),children:"×"})]},f))})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[a.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(Q,{type:"submit",variant:"primary",disabled:r||!s.name.trim()||!s.prompt.trim(),children:r?"Creating...":"Create"})]})]})})}function f1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,i]=j.useState(""),{data:l=[],isLoading:o}=le({queryKey:["suites"],queryFn:()=>gt.listSuites(),enabled:e});return j.useEffect(()=>{l.length>0&&!s&&i(l[0].name)},[l,s]),a.jsx(ss,{isOpen:e,onClose:t,title:"Import Task Suite",children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Import a built-in task suite for evaluation."}),o?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading suites..."}):l.length===0?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"No suites available."}):a.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:l.map(c=>a.jsxs("label",{className:`flex items-center gap-3 p-3 border cursor-pointer ${s===c.name?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[a.jsx("input",{type:"radio",name:"suite",value:c.name,checked:s===c.name,onChange:()=>i(c.name),className:"accent-[var(--accent)]"}),a.jsxs("span",{className:"capitalize",children:[c.name.replace(/_/g," ")," (",c.task_count," tasks) - ",c.description]})]},c.name))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[a.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(Q,{variant:"primary",onClick:()=>n(s),disabled:r||!s,children:r?"Importing...":"Import"})]})]})})}function h1(){const e=zn(),t=Wt(),[n,r]=j.useState(!1),s=Xc(),{data:i=[],isLoading:l}=le({queryKey:["jobs",n],queryFn:()=>Ot.list({include_public:n}),refetchInterval:5e3}),o=Je({mutationFn:Ot.delete,onSuccess:()=>t.invalidateQueries({queryKey:["jobs"]})}),c={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"},u=[{key:"name",header:"Name",render:d=>a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:d.name||`Job ${d.id.slice(0,8)}`}),d.is_public&&a.jsx(Kc,{className:"w-3 h-3 ml-2 inline text-[var(--text-secondary)]"})]})},{key:"status",header:"Status",render:d=>a.jsx(q,{variant:c[d.status]||"default",children:d.status})},{key:"candidates",header:"Candidates",render:d=>a.jsx("span",{children:d.candidate_ids.length})},{key:"tasks",header:"Tasks",render:d=>a.jsx("span",{children:d.task_ids.length})},{key:"runs",header:"Runs",render:d=>a.jsxs("span",{children:[d.completed_experiments,"/",d.total_experiments]})},{key:"created",header:"Created",render:d=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(d.created_at).toLocaleDateString()}),sortable:!0,sortValue:d=>new Date(d.created_at).getTime()},{key:"actions",header:"",className:"w-12",render:d=>!d.user_id||d.user_id==="anonymous"||s&&d.created_by_name===s?a.jsx("div",{onClick:m=>m.stopPropagation(),children:a.jsx(Q,{variant:"ghost",size:"sm",icon:qc,title:"Delete",disabled:d.status==="running",onClick:()=>{confirm("Delete this job?")&&o.mutate(d.id)}})}):null}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Experiments"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"View and manage optimization experiments. Start new experiments from the Agents page."})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(bi,{label:"Show public",checked:n,onChange:d=>r(d.target.checked)}),a.jsx(Q,{variant:"secondary",onClick:()=>e("/agents"),children:"Go to Agents"})]})]}),l?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):a.jsx(Xm,{columns:u,data:i,onRowClick:d=>e(`/jobs/${d.id}`),searchable:!0,searchPlaceholder:"Search experiments",searchFilter:(d,f)=>(d.name||"").toLowerCase().includes(f.toLowerCase())||d.id.toLowerCase().includes(f.toLowerCase()),emptyMessage:"No experiments yet. Go to Agents page to start an optimization."})]})}function m1(e,t=!0){return Math.abs(e)<10?"text-[var(--text-secondary)]":(t?e<0:e>0)?"text-green-400":"text-red-400"}function p1(e){return`${e>0?"+":""}${e.toFixed(1)}%`}function sp(e,t){return t===0?0:(e-t)/t*100}function xs({label:e,values:t,baselineIndex:n,formatter:r,isLowerBetter:s=!0}){const i=t[n];return a.jsxs("tr",{className:"border-b border-[var(--border)] last:border-0",children:[a.jsx("td",{className:"py-2 pr-4 text-[var(--text-secondary)] text-sm",children:e}),t.map((l,o)=>{const c=sp(l,i),u=o===n;return a.jsxs("td",{className:"py-2 px-4 text-right",children:[a.jsx("div",{className:"font-mono",children:r(l)}),!u&&a.jsx("div",{className:`text-xs ${m1(c,s)}`,children:p1(c)}),u&&a.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"(baseline)"})]},o)})]})}function x1({runs:e,baselineRunId:t}){const n=j.useMemo(()=>{if(t){const i=e.findIndex(l=>l.id===t);if(i>=0)return i}return 0},[e,t]);if(e.length<2)return null;const r=Math.min(...e.map(i=>i.tokens_total)),s=Math.max(...e.map(i=>i.score));return a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-4",children:"Candidate Comparison"}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-[var(--border)]",children:[a.jsx("th",{className:"pb-2 pr-4 text-left text-[var(--text-secondary)] font-medium",children:"Metric"}),e.map((i,l)=>a.jsx("th",{className:"pb-2 px-4 text-right",children:a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsx("span",{className:"font-medium",children:i.candidate_name}),i.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"}),l===n&&a.jsx(q,{variant:"info",children:"Base"})]})},i.id))]})}),a.jsxs("tbody",{children:[a.jsx(xs,{label:"Total Tokens",values:e.map(i=>i.tokens_total),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(xs,{label:"Input Tokens",values:e.map(i=>i.tokens_input),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(xs,{label:"Output Tokens",values:e.map(i=>i.tokens_output),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(xs,{label:"Duration",values:e.map(i=>i.duration_seconds),baselineIndex:n,formatter:i=>`${i.toFixed(1)}s`,isLowerBetter:!0}),a.jsx(xs,{label:"Score",values:e.map(i=>i.score*100),baselineIndex:n,formatter:i=>`${i.toFixed(1)}%`,isLowerBetter:!1})]})]})}),a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[a.jsx("h4",{className:"text-sm font-medium mb-2 text-[var(--text-secondary)]",children:"Key Insights"}),a.jsxs("ul",{className:"text-sm space-y-1 text-[var(--text-secondary)]",children:[e.map(i=>{const l=sp(i.tokens_total,e[n].tokens_total);return i.tokens_total===r&&l<-5?a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-green-400",children:"✓"}),a.jsxs("span",{children:[a.jsx("strong",{children:i.candidate_name})," uses ",Math.abs(l).toFixed(0),"% fewer tokens"]})]},`token-${i.id}`):null}),e.map(i=>i.score===s&&i.passed?a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-green-400",children:"✓"}),a.jsxs("span",{children:[a.jsx("strong",{children:i.candidate_name})," achieved highest score (",(i.score*100).toFixed(0),"%)"]})]},`score-${i.id}`):null),e.filter(i=>i.is_pareto).length>0&&a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-purple-400",children:"★"}),a.jsxs("span",{children:["Optimal candidates (best tradeoff):"," ",e.filter(i=>i.is_pareto).map(i=>i.candidate_name).join(", ")]})]})]})]}),a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[a.jsx("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:"Token Efficiency"}),a.jsx("div",{className:"space-y-2",children:e.map(i=>{const l=i.tokens_total/e[n].tokens_total*100,o=i.tokens_total<=r;return a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-24 text-sm truncate",title:i.candidate_name,children:i.candidate_name}),a.jsx("div",{className:"flex-1 h-6 bg-[var(--bg-primary)] rounded overflow-hidden",children:a.jsx("div",{className:`h-full transition-all duration-300 ${o?"bg-green-500":"bg-blue-500"}`,style:{width:`${Math.min(l,100)}%`}})}),a.jsx("div",{className:"w-20 text-right font-mono text-sm",children:i.tokens_total.toLocaleString()})]},i.id)})})]})]})}function v1({summaries:e,height:t=350}){const n=j.useRef(null),[r,s]=j.useState(600),[i,l]=j.useState("tokens"),[o,c]=j.useState(null),[u,d]=j.useState({x:0,y:0});j.useEffect(()=>{const S=()=>{n.current&&s(n.current.clientWidth)};return S(),window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]);const f={top:30,right:30,bottom:50,left:60},m=r-f.left-f.right,v=t-f.top-f.bottom,k=S=>i==="tokens"?S.avg_tokens:S.avg_duration,{xScale:g,yScale:b,xTicks:p,yTicks:h,paretoLine:x}=j.useMemo(()=>{if(e.length===0||m<=0)return{xScale:()=>0,yScale:()=>0,xTicks:[],yTicks:[],paretoLine:[]};const S=e.map(k),N=e.map(P=>P.avg_score),_=Math.min(...S)*.9,F=Math.max(...S)*1.1,O=Math.min(...N,.5),B=Math.min(Math.max(...N)*1.05,1),G=P=>(P-_)/(F-_)*m,re=P=>v-(P-O)/(B-O)*v,oe=Array.from({length:5},(P,A)=>_+A/4*(F-_)),D=Array.from({length:5},(P,A)=>O+A/4*(B-O)),X=e.filter(P=>P.is_pareto).sort((P,A)=>k(P)-k(A)).map(P=>({x:G(k(P)),y:re(P.avg_score)}));return{xScale:G,yScale:re,xTicks:oe,yTicks:D,paretoLine:X}},[e,m,v,i]);if(e.length===0)return a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No data to display"});const w=S=>i==="tokens"?S>=1e6?`${(S/1e6).toFixed(1)}M`:S>=1e3?`${(S/1e3).toFixed(0)}K`:S.toFixed(0):`${S.toFixed(1)}s`,C=(S,N)=>{var F;const _=(F=n.current)==null?void 0:F.getBoundingClientRect();_&&d({x:N.clientX-_.left,y:N.clientY-_.top}),c(S)};return a.jsxs("div",{ref:n,className:"w-full relative",children:[a.jsx("div",{className:"flex justify-end mb-2",children:a.jsxs("div",{className:"inline-flex rounded border border-[var(--border)] text-xs",children:[a.jsx("button",{className:`px-3 py-1 ${i==="tokens"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("tokens"),children:"Tokens"}),a.jsx("button",{className:`px-3 py-1 ${i==="duration"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("duration"),children:"Latency"})]})}),a.jsx("svg",{width:r,height:t,className:"font-mono text-xs",children:a.jsxs("g",{transform:`translate(${f.left}, ${f.top})`,children:[p.map((S,N)=>a.jsx("line",{x1:g(S),y1:0,x2:g(S),y2:v,stroke:"var(--border)",strokeDasharray:"2,2"},`x-grid-${N}`)),h.map((S,N)=>a.jsx("line",{x1:0,y1:b(S),x2:m,y2:b(S),stroke:"var(--border)",strokeDasharray:"2,2"},`y-grid-${N}`)),x.length>1&&a.jsx("polyline",{points:x.map(S=>`${S.x},${S.y}`).join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.slice().sort((S,N)=>(S.is_pareto?1:0)-(N.is_pareto?1:0)).map(S=>{const N=g(k(S)),_=b(S.avg_score),F=S.is_pareto,O=(o==null?void 0:o.candidate_name)===S.candidate_name;return a.jsxs("g",{onMouseEnter:B=>C(S,B),onMouseLeave:()=>c(null),children:[a.jsx("circle",{cx:N,cy:_,r:O?10:F?8:6,fill:F?"var(--accent)":"transparent",stroke:O?"var(--text-primary)":F?"var(--accent)":"var(--text-secondary)",strokeWidth:O?3:2,className:"cursor-pointer transition-all"}),F&&!O&&a.jsx("text",{x:N,y:_-12,textAnchor:"middle",fill:"var(--text-primary)",fontSize:10,className:"pointer-events-none",children:S.candidate_name.replace(/^baseline_/,"").slice(0,15)})]},S.candidate_name)}),a.jsx("line",{x1:0,y1:v,x2:m,y2:v,stroke:"var(--text-secondary)"}),p.map((S,N)=>a.jsxs("g",{transform:`translate(${g(S)}, ${v})`,children:[a.jsx("line",{y2:5,stroke:"var(--text-secondary)"}),a.jsx("text",{y:20,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:10,children:w(S)})]},`x-tick-${N}`)),a.jsx("text",{x:m/2,y:v+40,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:i==="tokens"?"Tokens (cost)":"Duration (latency)"}),a.jsx("line",{x1:0,y1:0,x2:0,y2:v,stroke:"var(--text-secondary)"}),h.map((S,N)=>a.jsxs("g",{transform:`translate(0, ${b(S)})`,children:[a.jsx("line",{x2:-5,stroke:"var(--text-secondary)"}),a.jsxs("text",{x:-10,textAnchor:"end",dominantBaseline:"middle",fill:"var(--text-secondary)",fontSize:10,children:[(S*100).toFixed(0),"%"]})]},`y-tick-${N}`)),a.jsx("text",{transform:`translate(-45, ${v/2}) rotate(-90)`,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:"Score (quality)"})]})}),o&&a.jsxs("div",{className:"absolute z-10 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg shadow-lg p-3 text-sm pointer-events-none",style:{left:Math.min(u.x+15,r-200),top:u.y-10,maxWidth:220},children:[a.jsx("div",{className:"font-medium text-[var(--text-primary)] truncate mb-2",children:o.candidate_name.replace(/^baseline_/,"")}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Score:"}),a.jsxs("span",{className:"text-right font-medium",children:[(o.avg_score*100).toFixed(1),"%"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tokens:"}),a.jsxs("span",{className:"text-right",children:[(o.avg_tokens/1e3).toFixed(1),"K"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Duration:"}),a.jsxs("span",{className:"text-right",children:[o.avg_duration.toFixed(1),"s"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Pass rate:"}),a.jsxs("span",{className:"text-right",children:[o.passed_runs,"/",o.total_runs]})]}),o.is_pareto&&a.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)] text-xs text-[var(--accent)]",children:"Optimal (best tradeoff)"})]})]})}function y1(e=2e3){const[t,n]=j.useState(!1),[r,s]=j.useState(null),i=j.useCallback(async o=>{try{return await navigator.clipboard.writeText(o),n(!0),s(null),setTimeout(()=>n(!1),e),!0}catch{return s("Failed to copy to clipboard"),n(!1),!1}},[e]),l=j.useCallback(()=>{n(!1),s(null)},[]);return{copy:i,copied:t,error:r,reset:l}}function g1({isOpen:e,onClose:t,title:n,itemId:r,itemType:s,isPublic:i,createdByName:l,onTogglePublic:o}){const[c,u]=j.useState(!1),{copy:d,copied:f}=y1(),m=`${window.location.origin}/${s}s/${r}`,v=async()=>{u(!0);try{await o(!i)}finally{u(!1)}},k=()=>{d(m)};return a.jsx(ss,{isOpen:e,onClose:t,title:n,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between p-3 bg-[var(--bg-tertiary)] rounded",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[i?a.jsx(Kc,{className:"w-5 h-5 text-[var(--accent)]"}):a.jsx($m,{className:"w-5 h-5 text-[var(--text-secondary)]"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium",children:i?"Public":"Private"}),a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:i?"Anyone with the link can view":"Only you can access"})]})]}),a.jsx("button",{onClick:v,disabled:c,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${i?"bg-[var(--accent)]":"bg-[var(--border)]"} ${c?"opacity-50 cursor-not-allowed":""}`,children:a.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${i?"translate-x-6":"translate-x-1"}`})})]}),i&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Share link"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",readOnly:!0,value:m,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono"}),a.jsx(Q,{variant:"secondary",onClick:k,children:f?a.jsxs(a.Fragment,{children:[a.jsx(Tg,{className:"w-4 h-4 mr-1"}),"Copied"]}):a.jsxs(a.Fragment,{children:[a.jsx(zg,{className:"w-4 h-4 mr-1"}),"Copy"]})})]})]}),l&&a.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",a.jsx("span",{className:"text-[var(--text-primary)]",children:l})]}),a.jsx("div",{className:"text-xs text-[var(--text-secondary)] pt-2 border-t border-[var(--border)]",children:i?a.jsxs(a.Fragment,{children:[a.jsxs("p",{children:["Public ",s,"s can be viewed by anyone with the link."]}),a.jsxs("p",{className:"mt-1",children:["Only you can edit or delete this ",s,"."]})]}):a.jsxs("p",{children:["Make this ",s," public to share it with others."]})})]})})}function j1({job:e,onUpdate:t}){const[n,r]=j.useState(!1),s=async i=>{await Ot.update(e.id,{is_public:i}),t()};return a.jsxs(a.Fragment,{children:[a.jsxs(Q,{variant:"secondary",size:"sm",onClick:()=>r(!0),title:e.is_public?"Sharing settings":"Share this job",children:[a.jsx(qg,{className:"w-4 h-4 mr-1"}),e.is_public?"Shared":"Share"]}),a.jsx(g1,{isOpen:n,onClose:()=>r(!1),title:"Share Job",itemId:e.id,itemType:"job",isPublic:e.is_public,createdByName:e.created_by_name,onTogglePublic:s})]})}function w1(){const{jobId:e}=fa(),t=zn(),n=Wt(),[r,s]=j.useState(null),[i,l]=j.useState(!1),[o,c]=j.useState(null),[u,d]=j.useState([]),[f,m]=j.useState(null),[v,k]=j.useState(null),[g,b]=j.useState("results"),[p,h]=j.useState("score"),[x,w]=j.useState("desc"),[C,S]=j.useState(!1),{data:N,isLoading:_}=le({queryKey:["jobs",e],queryFn:()=>Ot.get(e),enabled:!!e,refetchInterval:i?2e3:!1}),{data:F=[]}=le({queryKey:["runs",e],queryFn:()=>$o.list({job_id:e}),enabled:!!e,refetchInterval:i?2e3:!1}),{data:O}=le({queryKey:["job-summary",e],queryFn:()=>$o.getJobSummary(e),enabled:!!e&&(N==null?void 0:N.status)==="completed"}),B=Je({mutationFn:async()=>{l(!0),d([]),m(null),k(null);for await(const R of Ot.start(e))s(R),R.current_candidate&&R.current_task&&m(T=>(T&&(T.candidate!==R.current_candidate||T.task!==R.current_task)&&d(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),{candidate:R.current_candidate,task:R.current_task})),R.event==="error"&&(k(R.message),l(!1),n.invalidateQueries({queryKey:["jobs",e]})),R.event==="complete"&&(m(T=>(T&&d(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),null)),l(!1),n.invalidateQueries({queryKey:["jobs",e]}),n.invalidateQueries({queryKey:["runs",e]}),n.invalidateQueries({queryKey:["job-summary",e]}))}}),G=Je({mutationFn:()=>Ot.cancel(e),onSuccess:()=>{l(!1),n.invalidateQueries({queryKey:["jobs",e]})}});j.useEffect(()=>{(N==null?void 0:N.status)==="running"&&l(!0)},[N==null?void 0:N.status]);const re=j.useMemo(()=>{const R=new Map;for(const T of F)R.has(T.task_name)||R.set(T.task_name,[]),R.get(T.task_name).push(T);return R},[F]),oe=j.useMemo(()=>Array.from(re.keys()),[re]);j.useEffect(()=>{!o&&oe.length>0&&c(oe[0])},[oe,o]);const D=j.useMemo(()=>{if(!(O!=null&&O.candidate_summaries))return[];let R=[...O.candidate_summaries];return C&&(R=R.filter(T=>T.is_pareto)),R.sort((T,te)=>{let pe,Se;switch(p){case"score":pe=T.avg_score,Se=te.avg_score;break;case"tokens":pe=T.avg_tokens,Se=te.avg_tokens;break;case"duration":pe=T.avg_duration,Se=te.avg_duration;break;case"pass_rate":pe=T.passed_runs/T.total_runs,Se=te.passed_runs/te.total_runs;break}return x==="desc"?Se-pe:pe-Se}),R},[O,p,x,C]),W=R=>{p===R?w(x==="desc"?"asc":"desc"):(h(R),w(R==="tokens"||R==="duration"?"asc":"desc"))},X=({label:R,sortKeyVal:T})=>a.jsx("th",{className:"pb-2 cursor-pointer hover:text-[var(--text-primary)] select-none",onClick:()=>W(T),children:a.jsxs("div",{className:"flex items-center gap-1",children:[R,p===T&&a.jsx(_g,{size:12,className:x==="asc"?"rotate-180":""})]})});if(_)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!N)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Job not found"});const P=Xc(),A=!N.user_id||N.user_id==="anonymous"||P&&N.created_by_name===P,L=N.is_public&&!A,V=()=>{n.invalidateQueries({queryKey:["jobs",e]})},ee=R=>{const T={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};return a.jsx(q,{variant:T[R]||"default",children:R})};return a.jsxs("div",{children:[a.jsx(ma,{items:[{label:"Experiments",path:"/jobs"},{label:N.name||`Job ${N.id.slice(0,8)}`}]}),a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:N.name||`Job ${N.id.slice(0,8)}`}),ee(N.status),N.is_public&&a.jsxs(q,{variant:"info",children:[a.jsx(Kc,{className:"w-3 h-3 mr-1 inline"}),"Public"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[a.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-2 py-0.5 rounded font-mono text-[var(--text-secondary)]",children:[N.id.slice(0,8),"..."]}),a.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[N.candidate_ids.length," candidates × ",N.task_ids.length," tasks = ",N.total_experiments," experiments"]}),N.is_public&&N.created_by_name&&a.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",a.jsx("span",{className:"text-[var(--text-primary)]",children:N.created_by_name})]})]})]}),a.jsxs("div",{className:"flex gap-2",children:[A&&a.jsx(j1,{job:N,onUpdate:V}),L&&a.jsx(q,{variant:"default",children:"View Only"}),A&&N.status==="pending"&&a.jsx(Q,{variant:"primary",onClick:()=>B.mutate(),disabled:B.isPending,children:B.isPending?"Starting...":"Start"}),A&&N.status==="running"&&a.jsx(Q,{variant:"danger",onClick:()=>G.mutate(),disabled:G.isPending,children:"Cancel"})]})]}),(v||N.error)&&a.jsx(ge,{className:"mb-6 border-red-500/50 bg-red-500/10",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"w-5 h-5 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-0.5",children:"!"}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-red-400",children:"Error"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:v||N.error})]})]})}),(i||r)&&a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"font-medium",children:"Progress"}),a.jsxs("span",{className:"text-[var(--accent)]",children:[(r==null?void 0:r.completed)||N.completed_experiments,"/",(r==null?void 0:r.total)||N.total_experiments]})]}),a.jsx("div",{className:"w-full bg-[var(--bg-primary)] h-2 mb-2",children:a.jsx("div",{className:"h-full bg-[var(--accent)] transition-all",style:{width:`${((r==null?void 0:r.completed)||N.completed_experiments)/((r==null?void 0:r.total)||N.total_experiments)*100}%`}})}),(r==null?void 0:r.message)&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r.message}),i&&a.jsxs("div",{className:"mt-4 border-t border-[var(--border)] pt-4",children:[(r==null?void 0:r.current_candidate)&&(r==null?void 0:r.current_task)&&a.jsxs("div",{className:"mb-3",children:[a.jsx("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:"Currently Running"}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 px-3 py-2 bg-blue-500/10 border border-blue-500/30 rounded",children:[a.jsx("div",{className:"w-2 h-2 bg-blue-400 rounded-full animate-pulse"}),a.jsx("span",{className:"font-medium",children:r.current_candidate}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{children:r.current_task})]})]}),u.length>0&&a.jsxs("div",{children:[a.jsxs("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:["Completed (",u.length,")"]}),a.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto space-y-1",children:u.map((R,T)=>a.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-500/10 border border-green-500/30 rounded text-sm",children:[a.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}),a.jsx("span",{className:"font-medium",children:R.candidate_name}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{children:R.task_name})]},`${R.candidate_name}-${R.task_name}-${T}`))})]})]})]}),(N.status==="completed"||F.length>0)&&a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-[var(--border)]",children:[a.jsxs("button",{onClick:()=>b("results"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="results"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Eg,{size:16}),"Results"]}),a.jsxs("button",{onClick:()=>b("compare"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="compare"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Ig,{size:16}),"Compare"]}),a.jsxs("button",{onClick:()=>b("runs"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="runs"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Ug,{size:16}),"Runs (",F.length,")"]})]}),g==="results"&&a.jsxs(a.Fragment,{children:[O&&O.candidate_summaries.length>1&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("div",{className:"flex items-start justify-between mb-4",children:a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium",children:"Quality vs. Cost Tradeoff"}),a.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:["Candidates on the frontier (connected line) are ",a.jsx("strong",{children:"optimal"})," - no other candidate beats them on both score AND cost."]})]})}),a.jsxs("div",{className:"mb-4 p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs text-[var(--text-secondary)]",children:[a.jsx("strong",{className:"text-[var(--text-primary)]",children:"How optimal tradeoffs are calculated:"})," A candidate is optimal if there's no other candidate that has both a higher score AND lower cost. For example, if Candidate A has 95% score at 50K tokens and Candidate B has 90% score at 40K tokens, both are optimal - A is better on score, B is better on cost. But if Candidate C has 85% score at 60K tokens, it's ",a.jsx("em",{children:"not"})," optimal because B beats it on both metrics."]}),a.jsx(v1,{summaries:O.candidate_summaries,height:350})]}),O&&a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h3",{className:"font-medium",children:"Results Summary"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C,onChange:R=>S(R.target.checked),className:"rounded border-[var(--border)]"}),"Optimal only"]})]}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-left text-[var(--text-secondary)] border-b border-[var(--border)]",children:[a.jsx("th",{className:"pb-2",children:"Candidate"}),a.jsx(X,{label:"Score",sortKeyVal:"score"}),a.jsx(X,{label:"Tokens",sortKeyVal:"tokens"}),a.jsx(X,{label:"Duration",sortKeyVal:"duration"}),a.jsx(X,{label:"Pass Rate",sortKeyVal:"pass_rate"}),a.jsx("th",{className:"pb-2",children:"Optimal"})]})}),a.jsx("tbody",{children:D.map((R,T)=>a.jsxs("tr",{className:`border-b border-[var(--border)] ${T===0?"bg-[var(--accent)]/10":""}`,children:[a.jsxs("td",{className:"py-2 font-medium",children:[T===0&&a.jsx("span",{className:"text-[var(--accent)] mr-1",children:"#1"}),R.candidate_name.replace(/^baseline_/,"")]}),a.jsxs("td",{className:"py-2",children:[(R.avg_score*100).toFixed(1),"%"]}),a.jsxs("td",{className:"py-2",children:[(R.avg_tokens/1e3).toFixed(1),"K"]}),a.jsxs("td",{className:"py-2",children:[R.avg_duration.toFixed(1),"s"]}),a.jsxs("td",{className:"py-2",children:[R.passed_runs,"/",R.total_runs]}),a.jsx("td",{className:"py-2",children:R.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})})]},R.candidate_name))})]})}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-3",children:"Click column headers to sort. The #1 ranked candidate is highlighted based on your sort criteria."})]}),!O&&a.jsx(ge,{children:a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Results will appear here after the job completes.":"No results yet. Start the job to see results."})})]}),g==="compare"&&a.jsxs(ge,{children:[a.jsx("h3",{className:"font-medium mb-4",children:"Compare Candidates by Task"}),oe.length>0?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:oe.map(R=>a.jsx("button",{onClick:()=>c(o===R?null:R),className:`px-3 py-1 text-sm rounded border transition-colors ${o===R?"bg-[var(--accent)] text-white border-[var(--accent)]":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:R},R))}),o&&re.get(o)?a.jsx(x1,{runs:re.get(o).map(R=>({id:R.id,candidate_name:R.candidate_name,tokens_input:0,tokens_output:0,tokens_total:R.tokens_total,duration_seconds:R.duration_seconds,score:R.score,passed:R.passed,is_pareto:R.is_pareto}))}):a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"Select a task above to compare how different candidates performed on it."})]}):a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Comparison data will appear here after runs complete.":"No runs yet. Start the job to compare candidates."})]}),g==="runs"&&a.jsxs(ge,{children:[a.jsx("h3",{className:"font-medium mb-4",children:"All Experiment Runs"}),F.length===0?a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Runs will appear here as they complete. See progress above for live status.":"No runs yet. Start the job to see results."}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:F.map(R=>a.jsxs("div",{className:"p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] cursor-pointer hover:border-[var(--accent-dim)] transition-colors",onClick:()=>t(`/runs/${R.id}`),children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:`text-lg font-bold ${R.passed?"text-green-400":"text-red-400"}`,children:[(R.score*100).toFixed(0),"%"]}),R.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})]}),a.jsx("div",{className:"text-sm font-medium truncate",title:R.candidate_name,children:R.candidate_name.replace(/^baseline_/,"")}),a.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:R.task_name}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:[(R.tokens_total/1e3).toFixed(1),"K tokens"]}),a.jsxs("span",{children:[R.duration_seconds.toFixed(1),"s"]})]})]},R.id))})]})]})}const xn={input:"bg-blue-500",output:"bg-emerald-500",inputText:"text-blue-400",outputText:"text-emerald-400"};function Id(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Dd({input:e,output:t,maxValue:n,height:r=24,showLabels:s=!0}){const i=e+t;if(i===0)return a.jsx("div",{className:"flex items-center gap-2 w-full",children:a.jsx("div",{className:"rounded bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`}})});const l=n>0?i/n*100:100;return a.jsxs("div",{className:"flex items-center gap-3 w-full",children:[a.jsx("div",{className:"relative rounded overflow-hidden bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`},children:a.jsxs("div",{className:"h-full flex transition-all duration-300",style:{width:`${l}%`},children:[a.jsx("div",{className:`h-full ${xn.input} transition-all`,style:{width:`${e/i*100}%`},title:`Input: ${e.toLocaleString()} tokens`}),a.jsx("div",{className:`h-full ${xn.output} transition-all`,style:{width:`${t/i*100}%`},title:`Output: ${t.toLocaleString()} tokens`})]})}),s&&a.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono text-[var(--text-secondary)] min-w-[90px] justify-end",children:[a.jsxs("span",{className:xn.inputText,children:["↑",Id(e)]}),a.jsx("span",{children:"/"}),a.jsxs("span",{className:xn.outputText,children:["↓",Id(t)]})]})]})}function Sl({label:e,value:t,color:n="default"}){const r={default:"text-[var(--text-primary)]",input:xn.inputText,output:xn.outputText}[n];return a.jsxs("div",{className:"flex-1 p-3 bg-[var(--bg-primary)] border border-[var(--border)] rounded",children:[a.jsx("div",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e}),a.jsx("div",{className:`font-mono text-lg font-bold ${r}`,children:t})]})}function ap({tokensInput:e,tokensOutput:t,tokensTotal:n,turns:r}){const s=n>0?Math.round(e/n*100):0,i=n>0?Math.round(t/n*100):0,l=j.useMemo(()=>{if(!r||r.length===0)return null;let c=0,u=0;return r.map(d=>(c+=d.input,u+=d.output,{input:c,output:u,total:c+u}))},[r]),o=l?Math.max(...l.map(c=>c.total)):n;return a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-4",children:"Token Usage"}),a.jsx("div",{className:"mb-4",children:a.jsx(Dd,{input:e,output:t,maxValue:n,height:32})}),a.jsxs("div",{className:"flex items-center gap-6 text-xs mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-3 h-3 rounded ${xn.input}`}),a.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Input (",s,"%)"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-3 h-3 rounded ${xn.output}`}),a.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Output (",i,"%)"]})]})]}),a.jsxs("div",{className:"flex gap-3 mb-4",children:[a.jsx(Sl,{label:"Input Tokens",value:e.toLocaleString(),color:"input"}),a.jsx(Sl,{label:"Output Tokens",value:t.toLocaleString(),color:"output"}),a.jsx(Sl,{label:"Total Tokens",value:n.toLocaleString()})]}),l&&l.length>1&&a.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[a.jsxs("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:["Token Accumulation (",r.length," turns)"]}),a.jsx("div",{className:"space-y-2",children:r.map((c,u)=>a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--bg-primary)] border border-[var(--border)] flex items-center justify-center text-xs font-medium",children:u+1}),a.jsx("div",{className:"flex-1",children:a.jsx(Dd,{input:l[u].input,output:l[u].output,maxValue:o,height:16})})]},u))})]}),a.jsx("div",{className:"mt-4 text-xs text-[var(--text-secondary)] border-t border-[var(--border)] pt-3",children:"Token usage affects API cost. Input tokens are typically cheaper than output tokens."})]})}function k1(){const{runId:e}=fa(),{data:t,isLoading:n}=le({queryKey:["runs",e],queryFn:()=>$o.get(e),enabled:!!e});return n?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsx(ma,{items:[{label:"Experiments",path:"/jobs"},{label:"Job",path:`/jobs/${t.job_id}`},{label:t.candidate_name}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:t.candidate_name}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{className:"text-lg",children:t.task_name}),t.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})]})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[a.jsx(Ma,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),a.jsx(Ma,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),a.jsx(Ma,{label:"Duration",value:`${t.duration_seconds.toFixed(1)}s`}),a.jsx(Ma,{label:"Status",value:t.passed?"Passed":"Failed",status:t.passed?"success":"error"})]}),a.jsx(ap,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),t.reasoning&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:t.reasoning}),t.criteria_results.length>0&&a.jsx("div",{className:"space-y-2",children:t.criteria_results.map(r=>a.jsx("div",{className:"flex items-start justify-between p-3 bg-[var(--bg-primary)] border border-[var(--border)]",children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-medium",children:r.name}),a.jsxs(q,{variant:r.passed?"success":"error",children:[(r.score*100).toFixed(0),"%"]})]}),r.reasoning&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r.reasoning})]})},r.name))})]}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created.length>0&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),a.jsx("div",{className:"space-y-1",children:t.files_created.map(r=>a.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:r},r))})]}),Object.keys(t.trace).length>0&&a.jsx(tp,{trace:t.trace})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Run not found"})}function Ma({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return a.jsxs(ge,{children:[a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),a.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function b1(){const{testId:e}=fa(),{data:t,isLoading:n}=le({queryKey:["tests",e],queryFn:()=>Os.get(e),enabled:!!e}),{data:r}=le({queryKey:["configs",t==null?void 0:t.agent_id],queryFn:()=>_n.get(t.agent_id),enabled:!!(t!=null&&t.agent_id)});if(n)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!t)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Test not found"});const s={completed:"success",failed:"error",running:"info",pending:"default",cancelled:"warning"};return a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsx(ma,{items:[{label:"Agents",path:"/agents"},...r?[{label:r.name,path:`/agents/${r.id}`}]:[],{label:`Test ${t.id.slice(0,8)}`}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:"Test Run"}),r&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"•"}),a.jsx("span",{className:"text-lg",children:r.name})]}),a.jsx(q,{variant:s[t.status]||"default",children:t.status})]}),a.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:["ID: ",t.id.slice(0,8),"..."]})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[a.jsx(za,{label:"Duration",value:`${t.duration_seconds.toFixed(2)}s`}),a.jsx(za,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),t.score!==null&&a.jsx(za,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),a.jsx(za,{label:"Status",value:t.status.charAt(0).toUpperCase()+t.status.slice(1),status:t.status==="completed"?"success":t.status==="failed"?"error":void 0})]}),a.jsx(ap,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Prompt"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)] font-mono",children:t.prompt})]}),t.error&&a.jsxs(ge,{className:"mb-6 border-red-500/30 bg-red-500/5",children:[a.jsx("h3",{className:"font-medium mb-3 text-red-400",children:"Error"}),a.jsx("pre",{className:"text-sm text-red-300 overflow-x-auto whitespace-pre-wrap",children:t.error})]}),t.reasoning&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.reasoning})]}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created&&t.files_created.length>0&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),a.jsx("div",{className:"space-y-1",children:t.files_created.map(i=>a.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:i},i))})]}),t.trace&&Object.keys(t.trace).length>0&&a.jsx(tp,{trace:t.trace}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Timestamps"}),a.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Created:"}),a.jsx("div",{className:"font-mono",children:new Date(t.created_at).toLocaleString()})]}),t.started_at&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Started:"}),a.jsx("div",{className:"font-mono",children:new Date(t.started_at).toLocaleString()})]}),t.completed_at&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Completed:"}),a.jsx("div",{className:"font-mono",children:new Date(t.completed_at).toLocaleString()})]})]})]})]})}function za({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return a.jsxs(ge,{children:[a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),a.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function N1(){const{deploymentId:e}=fa(),{data:t,isLoading:n}=le({queryKey:["deployments",e],queryFn:()=>E0.get(e),enabled:!!e}),r=t==null?void 0:t.versions.find(i=>i.id===t.current_version_id),{data:s}=le({queryKey:["configs",r==null?void 0:r.config_id],queryFn:()=>_n.get(r.config_id),enabled:!!(r!=null&&r.config_id)});return n?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsxs("div",{className:"mb-4 flex-shrink-0",children:[a.jsx(ma,{items:[{label:"Agents",path:"/agents"},{label:t.name}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Kg,{size:20,className:"text-[var(--accent)]"}),a.jsx("h2",{className:"text-xl font-bold",children:t.name}),r&&a.jsxs(q,{variant:"info",children:["v",r.version]})]}),t.description&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:t.description})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsx("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-5",children:[a.jsxs("div",{className:"flex items-center gap-4 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:["Created ",new Date(t.created_at).toLocaleDateString()]}),a.jsxs("span",{children:["Updated ",new Date(t.updated_at).toLocaleDateString()]}),a.jsxs("span",{children:[t.versions.length," version",t.versions.length!==1?"s":""]})]}),s&&a.jsxs(Tn,{to:`/agents/${s.id}`,className:"flex items-center gap-2 p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-sm",children:[a.jsx(Am,{size:14,className:"text-[var(--accent)]"}),a.jsxs("span",{children:["Agent: ",a.jsx("span",{className:"font-medium",children:s.name})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider mb-3",children:"Version History"}),t.versions.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"No versions yet."}):a.jsx("div",{className:"space-y-2",children:t.versions.map(i=>a.jsx(S1,{version:i,isActive:i.id===t.current_version_id},i.id))})]})]})}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[a.jsx(Um,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),a.jsx("div",{className:"flex-1 min-h-0",children:s?a.jsx(np,{agent:s}):a.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-secondary)] text-sm",children:r?"Loading agent configuration...":"No active version to test."})})]})]})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Deployment not found"})}function S1({version:e,isActive:t}){const n=e.config_snapshot;return a.jsxs("div",{className:`p-3 rounded-md border transition-colors ${t?"border-[var(--accent)] bg-[var(--accent-dim)]":"border-[var(--border)] bg-[var(--bg-secondary)]"}`,children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Jg,{size:12,className:"text-[var(--text-secondary)]"}),a.jsxs("span",{className:"text-sm font-medium",children:["v",e.version]}),t&&a.jsx(q,{variant:"success",children:"Active"}),a.jsx(q,{variant:e.source==="optimize"?"info":"default",children:e.source})]}),a.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)]",children:[a.jsx(Im,{size:11}),a.jsx("span",{children:new Date(e.created_at).toLocaleString()})]})]}),e.description&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e.description}),Object.keys(n).length>0&&a.jsxs("div",{className:"mt-1",children:[a.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)] mb-1",children:[a.jsx(Fg,{size:11}),a.jsx("span",{children:"Config"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-xs",children:["framework"in n&&n.framework?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Framework"}),a.jsx("span",{className:"font-mono",children:String(n.framework)})]}):null,"model"in n&&n.model?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Model"}),a.jsx("span",{className:"font-mono",children:String(n.model)})]}):null,"tools"in n&&n.tools?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tools"}),a.jsx("span",{className:"font-mono truncate",children:Array.isArray(n.tools)?n.tools.join(", "):String(n.tools)})]}):null]})]})]})}function C1(){const{authConfig:e,isLoading:t,error:n,login:r,loginWithGitHub:s,clearError:i}=Zc(),[l,o]=j.useState(""),[c,u]=j.useState("");j.useEffect(()=>{n&&i()},[l,c]);const d=async m=>{m.preventDefault(),!(!l||!c)&&await r(l,c)},f=()=>{s()};return a.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:a.jsxs("div",{className:"w-full max-w-md",children:[a.jsxs("div",{className:"text-center mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:"Flow"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:"Sign in to access the optimization dashboard"})]}),a.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] p-6 space-y-6",children:[n&&a.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[var(--error)]/10 border border-[var(--error)]/20 text-[var(--error)]",children:[a.jsx(zm,{size:18,className:"mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-sm",children:n})]}),(e==null?void 0:e.mode)==="basic"&&a.jsxs("form",{onSubmit:d,className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Username"}),a.jsxs("div",{className:"relative",children:[a.jsx(Qm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),a.jsx("input",{type:"text",value:l,onChange:m=>o(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter username",autoComplete:"username",autoFocus:!0})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Password"}),a.jsxs("div",{className:"relative",children:[a.jsx($m,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),a.jsx("input",{type:"password",value:c,onChange:m=>u(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter password",autoComplete:"current-password"})]})]}),a.jsx(Q,{type:"submit",variant:"primary",className:"w-full justify-center",loading:t,disabled:!l||!c,children:"Sign In"})]}),(e==null?void 0:e.mode)==="github"&&a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center",children:"Sign in with your GitHub account to continue"}),a.jsx(Q,{onClick:f,variant:"secondary",className:"w-full justify-center",icon:Dg,children:"Continue with GitHub"})]})]})]})})}function _1({children:e}){const{authConfig:t,isLoadingConfig:n,isAuthenticated:r,loadAuthConfig:s,handleOAuthCallback:i}=Zc();return j.useEffect(()=>{s()},[s]),j.useEffect(()=>{n||i()},[n,i]),n?a.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center",children:a.jsxs("div",{className:"text-center",children:[a.jsx(ha,{className:"w-8 h-8 animate-spin text-[var(--accent)] mx-auto mb-4"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:"Loading..."})]})}):t!=null&&t.enabled&&!r?a.jsx(C1,{}):a.jsx(a.Fragment,{children:e})}function E1(){return a.jsx(vg,{children:a.jsx(_1,{children:a.jsx(cg,{children:a.jsxs(ht,{path:"/",element:a.jsx($0,{}),children:[a.jsx(ht,{index:!0,element:a.jsx(B0,{})}),a.jsx(ht,{path:"agents",element:a.jsx(X0,{})}),a.jsx(ht,{path:"agents/:agentId",element:a.jsx(a1,{})}),a.jsx(ht,{path:"tasks",element:a.jsx(c1,{})}),a.jsx(ht,{path:"jobs",element:a.jsx(h1,{})}),a.jsx(ht,{path:"jobs/:jobId",element:a.jsx(w1,{})}),a.jsx(ht,{path:"runs/:runId",element:a.jsx(k1,{})}),a.jsx(ht,{path:"tests/:testId",element:a.jsx(b1,{})}),a.jsx(ht,{path:"deployments/:deploymentId",element:a.jsx(N1,{})})]})})})})}const Ad=localStorage.getItem("flow-theme");if(Ad)try{const{state:e}=JSON.parse(Ad);e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}catch{}const P1=new sy({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}});Cl.createRoot(document.getElementById("root")).render(a.jsx(Wo.StrictMode,{children:a.jsx(ay,{client:P1,children:a.jsx(E1,{})})})); diff --git a/src/flow/ui/ui/assets/index-CXx52KrS.js b/src/flow/ui/ui/assets/index-CXx52KrS.js new file mode 100644 index 0000000000000000000000000000000000000000..3841ea7581b54f828cc403003105a1866ecd8e2f --- /dev/null +++ b/src/flow/ui/ui/assets/index-CXx52KrS.js @@ -0,0 +1,317 @@ +var Yc=e=>{throw TypeError(e)};var Wi=(e,t,n)=>t.has(e)||Yc("Cannot "+n);var y=(e,t,n)=>(Wi(e,t,"read from private field"),n?n.call(e):t.get(e)),$=(e,t,n)=>t.has(e)?Yc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),z=(e,t,n,r)=>(Wi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),W=(e,t,n)=>(Wi(e,t,"access private method"),n);var va=(e,t,n,r)=>({set _(s){z(e,t,s,n)},get _(){return y(e,t,r)}});function np(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();function Wd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var qd={exports:{}},bi={},Gd={exports:{}},Y={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var ia=Symbol.for("react.element"),rp=Symbol.for("react.portal"),sp=Symbol.for("react.fragment"),ap=Symbol.for("react.strict_mode"),ip=Symbol.for("react.profiler"),lp=Symbol.for("react.provider"),op=Symbol.for("react.context"),cp=Symbol.for("react.forward_ref"),up=Symbol.for("react.suspense"),dp=Symbol.for("react.memo"),fp=Symbol.for("react.lazy"),Xc=Symbol.iterator;function hp(e){return e===null||typeof e!="object"?null:(e=Xc&&e[Xc]||e["@@iterator"],typeof e=="function"?e:null)}var Jd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Yd=Object.assign,Xd={};function Xr(e,t,n){this.props=e,this.context=t,this.refs=Xd,this.updater=n||Jd}Xr.prototype.isReactComponent={};Xr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Xr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Zd(){}Zd.prototype=Xr.prototype;function $o(e,t,n){this.props=e,this.context=t,this.refs=Xd,this.updater=n||Jd}var Uo=$o.prototype=new Zd;Uo.constructor=$o;Yd(Uo,Xr.prototype);Uo.isPureReactComponent=!0;var Zc=Array.isArray,ef=Object.prototype.hasOwnProperty,Bo={current:null},tf={key:!0,ref:!0,__self:!0,__source:!0};function nf(e,t,n){var r,s={},a=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(a=""+t.key),t)ef.call(t,r)&&!tf.hasOwnProperty(r)&&(s[r]=t[r]);var o=arguments.length-2;if(o===1)s.children=n;else if(1>>1,ee=P[K];if(0>>1;Ks(te,L))pes(be,te)?(P[K]=be,P[pe]=L,K=pe):(P[K]=te,P[T]=L,K=T);else if(pes(be,L))P[K]=be,P[pe]=L,K=pe;else break e}}return A}function s(P,A){var L=P.sortIndex-A.sortIndex;return L!==0?L:P.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var c=[],d=[],h=1,u=null,m=3,x=!1,k=!1,g=!1,S=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(P){for(var A=n(d);A!==null;){if(A.callback===null)r(d);else if(A.startTime<=P)r(d),A.sortIndex=A.expirationTime,t(c,A);else break;A=n(d)}}function w(P){if(g=!1,v(P),!k)if(n(c)!==null)k=!0,q(C);else{var A=n(d);A!==null&&X(w,A.startTime-P)}}function C(P,A){k=!1,g&&(g=!1,p(_),_=-1),x=!0;var L=m;try{for(v(A),u=n(c);u!==null&&(!(u.expirationTime>A)||P&&!B());){var K=u.callback;if(typeof K=="function"){u.callback=null,m=u.priorityLevel;var ee=K(u.expirationTime<=A);A=e.unstable_now(),typeof ee=="function"?u.callback=ee:u===n(c)&&r(c),v(A)}else r(c);u=n(c)}if(u!==null)var R=!0;else{var T=n(d);T!==null&&X(w,T.startTime-A),R=!1}return R}finally{u=null,m=L,x=!1}}var b=!1,N=null,_=-1,F=5,O=-1;function B(){return!(e.unstable_now()-OP||125K?(P.sortIndex=L,t(d,P),n(c)===null&&P===n(d)&&(g?(p(_),_=-1):g=!0,X(w,L-K))):(P.sortIndex=ee,t(c,P),k||x||(k=!0,q(C))),P},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(P){var A=m;return function(){var L=m;m=A;try{return P.apply(this,arguments)}finally{m=L}}}})(of);lf.exports=of;var bp=lf.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Cp=j,et=bp;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),bl=Object.prototype.hasOwnProperty,_p=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,tu={},nu={};function Ep(e){return bl.call(nu,e)?!0:bl.call(tu,e)?!1:_p.test(e)?nu[e]=!0:(tu[e]=!0,!1)}function Pp(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Tp(e,t,n,r){if(t===null||typeof t>"u"||Pp(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Be(e,t,n,r,s,a,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=l}var Oe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Oe[e]=new Be(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Oe[t]=new Be(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Oe[e]=new Be(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Oe[e]=new Be(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Oe[e]=new Be(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Oe[e]=new Be(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Oe[e]=new Be(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Oe[e]=new Be(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Oe[e]=new Be(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ko=/[\-:]([a-z])/g;function Ho(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Ko,Ho);Oe[t]=new Be(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Ko,Ho);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Ko,Ho);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!1,!1)});Oe.xlinkHref=new Be("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!0,!0)});function Wo(e,t,n,r){var s=Oe.hasOwnProperty(t)?Oe[t]:null;(s!==null?s.type!==0:r||!(2o||s[l]!==a[o]){var c=` +`+s[l].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{Ji=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?vs(e):""}function Op(e){switch(e.tag){case 5:return vs(e.type);case 16:return vs("Lazy");case 13:return vs("Suspense");case 19:return vs("SuspenseList");case 0:case 2:case 15:return e=Yi(e.type,!1),e;case 11:return e=Yi(e.type.render,!1),e;case 1:return e=Yi(e.type,!0),e;default:return""}}function Pl(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case mr:return"Fragment";case hr:return"Portal";case Cl:return"Profiler";case qo:return"StrictMode";case _l:return"Suspense";case El:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case df:return(e.displayName||"Context")+".Consumer";case uf:return(e._context.displayName||"Context")+".Provider";case Go:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Jo:return t=e.displayName||null,t!==null?t:Pl(e.type)||"Memo";case Xt:t=e._payload,e=e._init;try{return Pl(e(t))}catch{}}return null}function Lp(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Pl(t);case 8:return t===qo?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function _n(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function hf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Rp(e){var t=hf(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(l){r=""+l,a.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ga(e){e._valueTracker||(e._valueTracker=Rp(e))}function mf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=hf(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ja(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Tl(e,t){var n=t.checked;return me({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function su(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=_n(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function pf(e,t){t=t.checked,t!=null&&Wo(e,"checked",t,!1)}function Ol(e,t){pf(e,t);var n=_n(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ll(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ll(e,t.type,_n(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function au(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ll(e,t,n){(t!=="number"||Ja(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var xs=Array.isArray;function br(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=ja.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ls(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ws={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Mp=["Webkit","ms","Moz","O"];Object.keys(ws).forEach(function(e){Mp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ws[t]=ws[e]})});function gf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||ws.hasOwnProperty(e)&&ws[e]?(""+t).trim():t+"px"}function jf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=gf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var zp=me({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function zl(e,t){if(t){if(zp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function Fl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Il=null;function Yo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Dl=null,Cr=null,_r=null;function ou(e){if(e=ca(e)){if(typeof Dl!="function")throw Error(E(280));var t=e.stateNode;t&&(t=Ti(t),Dl(e.stateNode,e.type,t))}}function wf(e){Cr?_r?_r.push(e):_r=[e]:Cr=e}function kf(){if(Cr){var e=Cr,t=_r;if(_r=Cr=null,ou(e),t)for(e=0;e>>=0,e===0?32:31-(Hp(e)/Wp|0)|0}var wa=64,ka=4194304;function ys(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function ei(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,a=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~s;o!==0?r=ys(o):(a&=l,a!==0&&(r=ys(a)))}else l=n&~s,l!==0?r=ys(l):a!==0&&(r=ys(a));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,a=t&-t,s>=a||s===16&&(a&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function la(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-gt(t),e[t]=n}function Yp(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Ss),xu=" ",yu=!1;function Bf(e,t){switch(e){case"keyup":return bv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Qf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var pr=!1;function _v(e,t){switch(e){case"compositionend":return Qf(t);case"keypress":return t.which!==32?null:(yu=!0,xu);case"textInput":return e=t.data,e===xu&&yu?null:e;default:return null}}function Ev(e,t){if(pr)return e==="compositionend"||!ac&&Bf(e,t)?(e=$f(),$a=nc=fn=null,pr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ku(n)}}function Wf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Wf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function qf(){for(var e=window,t=Ja();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ja(e.document)}return t}function ic(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Iv(e){var t=qf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Wf(n.ownerDocument.documentElement,n)){if(r!==null&&ic(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,a=Math.min(r.start,s);r=r.end===void 0?a:Math.min(r.end,s),!e.extend&&a>r&&(s=r,r=a,a=s),s=Su(n,a);var l=Su(n,r);s&&l&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,vr=null,Vl=null,bs=null,Kl=!1;function Nu(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Kl||vr==null||vr!==Ja(r)||(r=vr,"selectionStart"in r&&ic(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),bs&&Ds(bs,r)||(bs=r,r=ri(Vl,"onSelect"),0gr||(e.current=Yl[gr],Yl[gr]=null,gr--)}function ie(e,t){gr++,Yl[gr]=e.current,e.current=t}var En={},Fe=On(En),We=On(!1),Zn=En;function Vr(e,t){var n=e.type.contextTypes;if(!n)return En;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},a;for(a in n)s[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function qe(e){return e=e.childContextTypes,e!=null}function ai(){ce(We),ce(Fe)}function Ou(e,t,n){if(Fe.current!==En)throw Error(E(168));ie(Fe,t),ie(We,n)}function rh(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(E(108,Lp(e)||"Unknown",s));return me({},n,r)}function ii(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||En,Zn=Fe.current,ie(Fe,e),ie(We,We.current),!0}function Lu(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=rh(e,t,Zn),r.__reactInternalMemoizedMergedChildContext=e,ce(We),ce(Fe),ie(Fe,e)):ce(We),ie(We,n)}var Rt=null,Oi=!1,dl=!1;function sh(e){Rt===null?Rt=[e]:Rt.push(e)}function Gv(e){Oi=!0,sh(e)}function Ln(){if(!dl&&Rt!==null){dl=!0;var e=0,t=ae;try{var n=Rt;for(ae=1;e>=l,s-=l,Dt=1<<32-gt(t)+s|n<_?(F=N,N=null):F=N.sibling;var O=m(p,N,v[_],w);if(O===null){N===null&&(N=F);break}e&&N&&O.alternate===null&&t(p,N),f=a(O,f,_),b===null?C=O:b.sibling=O,b=O,N=F}if(_===v.length)return n(p,N),ue&&Mn(p,_),C;if(N===null){for(;__?(F=N,N=null):F=N.sibling;var B=m(p,N,O.value,w);if(B===null){N===null&&(N=F);break}e&&N&&B.alternate===null&&t(p,N),f=a(B,f,_),b===null?C=B:b.sibling=B,b=B,N=F}if(O.done)return n(p,N),ue&&Mn(p,_),C;if(N===null){for(;!O.done;_++,O=v.next())O=u(p,O.value,w),O!==null&&(f=a(O,f,_),b===null?C=O:b.sibling=O,b=O);return ue&&Mn(p,_),C}for(N=r(p,N);!O.done;_++,O=v.next())O=x(N,p,_,O.value,w),O!==null&&(e&&O.alternate!==null&&N.delete(O.key===null?_:O.key),f=a(O,f,_),b===null?C=O:b.sibling=O,b=O);return e&&N.forEach(function(G){return t(p,G)}),ue&&Mn(p,_),C}function S(p,f,v,w){if(typeof v=="object"&&v!==null&&v.type===mr&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case ya:e:{for(var C=v.key,b=f;b!==null;){if(b.key===C){if(C=v.type,C===mr){if(b.tag===7){n(p,b.sibling),f=s(b,v.props.children),f.return=p,p=f;break e}}else if(b.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Xt&&zu(C)===b.type){n(p,b.sibling),f=s(b,v.props),f.ref=fs(p,b,v),f.return=p,p=f;break e}n(p,b);break}else t(p,b);b=b.sibling}v.type===mr?(f=Jn(v.props.children,p.mode,w,v.key),f.return=p,p=f):(w=qa(v.type,v.key,v.props,null,p.mode,w),w.ref=fs(p,f,v),w.return=p,p=w)}return l(p);case hr:e:{for(b=v.key;f!==null;){if(f.key===b)if(f.tag===4&&f.stateNode.containerInfo===v.containerInfo&&f.stateNode.implementation===v.implementation){n(p,f.sibling),f=s(f,v.children||[]),f.return=p,p=f;break e}else{n(p,f);break}else t(p,f);f=f.sibling}f=gl(v,p.mode,w),f.return=p,p=f}return l(p);case Xt:return b=v._init,S(p,f,b(v._payload),w)}if(xs(v))return k(p,f,v,w);if(ls(v))return g(p,f,v,w);Pa(p,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,f!==null&&f.tag===6?(n(p,f.sibling),f=s(f,v),f.return=p,p=f):(n(p,f),f=yl(v,p.mode,w),f.return=p,p=f),l(p)):n(p,f)}return S}var Hr=oh(!0),ch=oh(!1),ci=On(null),ui=null,kr=null,uc=null;function dc(){uc=kr=ui=null}function fc(e){var t=ci.current;ce(ci),e._currentValue=t}function eo(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Pr(e,t){ui=e,uc=kr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(He=!0),e.firstContext=null)}function ct(e){var t=e._currentValue;if(uc!==e)if(e={context:e,memoizedValue:t,next:null},kr===null){if(ui===null)throw Error(E(308));kr=e,ui.dependencies={lanes:0,firstContext:e}}else kr=kr.next=e;return t}var In=null;function hc(e){In===null?In=[e]:In.push(e)}function uh(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,hc(t)):(n.next=s.next,s.next=n),t.interleaved=n,Kt(e,r)}function Kt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Zt=!1;function mc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function dh(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function $t(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function wn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ne&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Kt(e,n)}return s=r.interleaved,s===null?(t.next=t,hc(r)):(t.next=s.next,s.next=t),r.interleaved=t,Kt(e,n)}function Ba(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Zo(e,n)}}function Fu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?s=a=l:a=a.next=l,n=n.next}while(n!==null);a===null?s=a=t:a=a.next=t}else s=a=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function di(e,t,n,r){var s=e.updateQueue;Zt=!1;var a=s.firstBaseUpdate,l=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var c=o,d=c.next;c.next=null,l===null?a=d:l.next=d,l=c;var h=e.alternate;h!==null&&(h=h.updateQueue,o=h.lastBaseUpdate,o!==l&&(o===null?h.firstBaseUpdate=d:o.next=d,h.lastBaseUpdate=c))}if(a!==null){var u=s.baseState;l=0,h=d=c=null,o=a;do{var m=o.lane,x=o.eventTime;if((r&m)===m){h!==null&&(h=h.next={eventTime:x,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var k=e,g=o;switch(m=t,x=n,g.tag){case 1:if(k=g.payload,typeof k=="function"){u=k.call(x,u,m);break e}u=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=g.payload,m=typeof k=="function"?k.call(x,u,m):k,m==null)break e;u=me({},u,m);break e;case 2:Zt=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,m=s.effects,m===null?s.effects=[o]:m.push(o))}else x={eventTime:x,lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},h===null?(d=h=x,c=u):h=h.next=x,l|=m;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;m=o,o=m.next,m.next=null,s.lastBaseUpdate=m,s.shared.pending=null}}while(!0);if(h===null&&(c=u),s.baseState=c,s.firstBaseUpdate=d,s.lastBaseUpdate=h,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else a===null&&(s.shared.lanes=0);nr|=l,e.lanes=l,e.memoizedState=u}}function Iu(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=hl.transition;hl.transition={};try{e(!1),t()}finally{ae=n,hl.transition=r}}function Eh(){return ut().memoizedState}function Zv(e,t,n){var r=Sn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ph(e))Th(t,n);else if(n=uh(e,t,n,r),n!==null){var s=$e();jt(n,e,r,s),Oh(n,t,r)}}function ex(e,t,n){var r=Sn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ph(e))Th(t,s);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var l=t.lastRenderedState,o=a(l,n);if(s.hasEagerState=!0,s.eagerState=o,wt(o,l)){var c=t.interleaved;c===null?(s.next=s,hc(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=uh(e,t,s,r),n!==null&&(s=$e(),jt(n,e,r,s),Oh(n,t,r))}}function Ph(e){var t=e.alternate;return e===fe||t!==null&&t===fe}function Th(e,t){Cs=hi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Oh(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Zo(e,n)}}var mi={readContext:ct,useCallback:Le,useContext:Le,useEffect:Le,useImperativeHandle:Le,useInsertionEffect:Le,useLayoutEffect:Le,useMemo:Le,useReducer:Le,useRef:Le,useState:Le,useDebugValue:Le,useDeferredValue:Le,useTransition:Le,useMutableSource:Le,useSyncExternalStore:Le,useId:Le,unstable_isNewReconciler:!1},tx={readContext:ct,useCallback:function(e,t){return St().memoizedState=[e,t===void 0?null:t],e},useContext:ct,useEffect:Au,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Va(4194308,4,Sh.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Va(4194308,4,e,t)},useInsertionEffect:function(e,t){return Va(4,2,e,t)},useMemo:function(e,t){var n=St();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=St();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Zv.bind(null,fe,e),[r.memoizedState,e]},useRef:function(e){var t=St();return e={current:e},t.memoizedState=e},useState:Du,useDebugValue:kc,useDeferredValue:function(e){return St().memoizedState=e},useTransition:function(){var e=Du(!1),t=e[0];return e=Xv.bind(null,e[1]),St().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=fe,s=St();if(ue){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),Ee===null)throw Error(E(349));tr&30||ph(r,t,n)}s.memoizedState=n;var a={value:n,getSnapshot:t};return s.queue=a,Au(xh.bind(null,r,a,e),[e]),r.flags|=2048,Hs(9,vh.bind(null,r,a,n,t),void 0,null),n},useId:function(){var e=St(),t=Ee.identifierPrefix;if(ue){var n=At,r=Dt;n=(r&~(1<<32-gt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Vs++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[_t]=t,e[Us]=r,Uh(e,t,!1,!1),t.stateNode=e;e:{switch(l=Fl(n,r),n){case"dialog":oe("cancel",e),oe("close",e),s=r;break;case"iframe":case"object":case"embed":oe("load",e),s=r;break;case"video":case"audio":for(s=0;sGr&&(t.flags|=128,r=!0,hs(a,!1),t.lanes=4194304)}else{if(!r)if(e=fi(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),hs(a,!0),a.tail===null&&a.tailMode==="hidden"&&!l.alternate&&!ue)return Re(t),null}else 2*je()-a.renderingStartTime>Gr&&n!==1073741824&&(t.flags|=128,r=!0,hs(a,!1),t.lanes=4194304);a.isBackwards?(l.sibling=t.child,t.child=l):(n=a.last,n!==null?n.sibling=l:t.child=l,a.last=l)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=je(),t.sibling=null,n=de.current,ie(de,r?n&1|2:n&1),t):(Re(t),null);case 22:case 23:return Ec(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ye&1073741824&&(Re(t),t.subtreeFlags&6&&(t.flags|=8192)):Re(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function cx(e,t){switch(oc(t),t.tag){case 1:return qe(t.type)&&ai(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Wr(),ce(We),ce(Fe),xc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return vc(t),null;case 13:if(ce(de),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));Kr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ce(de),null;case 4:return Wr(),null;case 10:return fc(t.type._context),null;case 22:case 23:return Ec(),null;case 24:return null;default:return null}}var Oa=!1,ze=!1,ux=typeof WeakSet=="function"?WeakSet:Set,I=null;function Sr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){xe(e,t,r)}else n.current=null}function co(e,t,n){try{n()}catch(r){xe(e,t,r)}}var Ju=!1;function dx(e,t){if(Hl=ti,e=qf(),ic(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break e}var l=0,o=-1,c=-1,d=0,h=0,u=e,m=null;t:for(;;){for(var x;u!==n||s!==0&&u.nodeType!==3||(o=l+s),u!==a||r!==0&&u.nodeType!==3||(c=l+r),u.nodeType===3&&(l+=u.nodeValue.length),(x=u.firstChild)!==null;)m=u,u=x;for(;;){if(u===e)break t;if(m===n&&++d===s&&(o=l),m===a&&++h===r&&(c=l),(x=u.nextSibling)!==null)break;u=m,m=u.parentNode}u=x}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Wl={focusedElem:e,selectionRange:n},ti=!1,I=t;I!==null;)if(t=I,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,I=e;else for(;I!==null;){t=I;try{var k=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(k!==null){var g=k.memoizedProps,S=k.memoizedState,p=t.stateNode,f=p.getSnapshotBeforeUpdate(t.elementType===t.type?g:mt(t.type,g),S);p.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var v=t.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(w){xe(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,I=e;break}I=t.return}return k=Ju,Ju=!1,k}function _s(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var a=s.destroy;s.destroy=void 0,a!==void 0&&co(t,n,a)}s=s.next}while(s!==r)}}function Mi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function uo(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Vh(e){var t=e.alternate;t!==null&&(e.alternate=null,Vh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[_t],delete t[Us],delete t[Jl],delete t[Wv],delete t[qv])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Kh(e){return e.tag===5||e.tag===3||e.tag===4}function Yu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Kh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function fo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=si));else if(r!==4&&(e=e.child,e!==null))for(fo(e,t,n),e=e.sibling;e!==null;)fo(e,t,n),e=e.sibling}function ho(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(ho(e,t,n),e=e.sibling;e!==null;)ho(e,t,n),e=e.sibling}var Pe=null,xt=!1;function Jt(e,t,n){for(n=n.child;n!==null;)Hh(e,t,n),n=n.sibling}function Hh(e,t,n){if(Pt&&typeof Pt.onCommitFiberUnmount=="function")try{Pt.onCommitFiberUnmount(Ci,n)}catch{}switch(n.tag){case 5:ze||Sr(n,t);case 6:var r=Pe,s=xt;Pe=null,Jt(e,t,n),Pe=r,xt=s,Pe!==null&&(xt?(e=Pe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Pe.removeChild(n.stateNode));break;case 18:Pe!==null&&(xt?(e=Pe,n=n.stateNode,e.nodeType===8?ul(e.parentNode,n):e.nodeType===1&&ul(e,n),Fs(e)):ul(Pe,n.stateNode));break;case 4:r=Pe,s=xt,Pe=n.stateNode.containerInfo,xt=!0,Jt(e,t,n),Pe=r,xt=s;break;case 0:case 11:case 14:case 15:if(!ze&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var a=s,l=a.destroy;a=a.tag,l!==void 0&&(a&2||a&4)&&co(n,t,l),s=s.next}while(s!==r)}Jt(e,t,n);break;case 1:if(!ze&&(Sr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){xe(n,t,o)}Jt(e,t,n);break;case 21:Jt(e,t,n);break;case 22:n.mode&1?(ze=(r=ze)||n.memoizedState!==null,Jt(e,t,n),ze=r):Jt(e,t,n);break;default:Jt(e,t,n)}}function Xu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new ux),t.forEach(function(r){var s=jx.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function ft(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=l),r&=~a}if(r=s,r=je()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*hx(r/1960))-r,10e?16:e,hn===null)var r=!1;else{if(e=hn,hn=null,xi=0,ne&6)throw Error(E(331));var s=ne;for(ne|=4,I=e.current;I!==null;){var a=I,l=a.child;if(I.flags&16){var o=a.deletions;if(o!==null){for(var c=0;cje()-Cc?Gn(e,0):bc|=n),Ge(e,t)}function em(e,t){t===0&&(e.mode&1?(t=ka,ka<<=1,!(ka&130023424)&&(ka=4194304)):t=1);var n=$e();e=Kt(e,t),e!==null&&(la(e,t,n),Ge(e,n))}function gx(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),em(e,n)}function jx(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),em(e,n)}var tm;tm=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||We.current)He=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return He=!1,lx(e,t,n);He=!!(e.flags&131072)}else He=!1,ue&&t.flags&1048576&&ah(t,oi,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ka(e,t),e=t.pendingProps;var s=Vr(t,Fe.current);Pr(t,n),s=gc(null,t,r,e,s,n);var a=jc();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,qe(r)?(a=!0,ii(t)):a=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,mc(t),s.updater=Ri,t.stateNode=s,s._reactInternals=t,no(t,r,e,n),t=ao(null,t,r,!0,a,n)):(t.tag=0,ue&&a&&lc(t),De(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ka(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=kx(r),e=mt(r,e),s){case 0:t=so(null,t,r,e,n);break e;case 1:t=Wu(null,t,r,e,n);break e;case 11:t=Ku(null,t,r,e,n);break e;case 14:t=Hu(null,t,r,mt(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),so(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Wu(e,t,r,s,n);case 3:e:{if(Dh(t),e===null)throw Error(E(387));r=t.pendingProps,a=t.memoizedState,s=a.element,dh(e,t),di(t,r,null,n);var l=t.memoizedState;if(r=l.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){s=qr(Error(E(423)),t),t=qu(e,t,r,n,s);break e}else if(r!==s){s=qr(Error(E(424)),t),t=qu(e,t,r,n,s);break e}else for(Xe=jn(t.stateNode.containerInfo.firstChild),Ze=t,ue=!0,yt=null,n=ch(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Kr(),r===s){t=Ht(e,t,n);break e}De(e,t,r,n)}t=t.child}return t;case 5:return fh(t),e===null&&Zl(t),r=t.type,s=t.pendingProps,a=e!==null?e.memoizedProps:null,l=s.children,ql(r,s)?l=null:a!==null&&ql(r,a)&&(t.flags|=32),Ih(e,t),De(e,t,l,n),t.child;case 6:return e===null&&Zl(t),null;case 13:return Ah(e,t,n);case 4:return pc(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Hr(t,null,r,n):De(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Ku(e,t,r,s,n);case 7:return De(e,t,t.pendingProps,n),t.child;case 8:return De(e,t,t.pendingProps.children,n),t.child;case 12:return De(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,a=t.memoizedProps,l=s.value,ie(ci,r._currentValue),r._currentValue=l,a!==null)if(wt(a.value,l)){if(a.children===s.children&&!We.current){t=Ht(e,t,n);break e}}else for(a=t.child,a!==null&&(a.return=t);a!==null;){var o=a.dependencies;if(o!==null){l=a.child;for(var c=o.firstContext;c!==null;){if(c.context===r){if(a.tag===1){c=$t(-1,n&-n),c.tag=2;var d=a.updateQueue;if(d!==null){d=d.shared;var h=d.pending;h===null?c.next=c:(c.next=h.next,h.next=c),d.pending=c}}a.lanes|=n,c=a.alternate,c!==null&&(c.lanes|=n),eo(a.return,n,t),o.lanes|=n;break}c=c.next}}else if(a.tag===10)l=a.type===t.type?null:a.child;else if(a.tag===18){if(l=a.return,l===null)throw Error(E(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),eo(l,n,t),l=a.sibling}else l=a.child;if(l!==null)l.return=a;else for(l=a;l!==null;){if(l===t){l=null;break}if(a=l.sibling,a!==null){a.return=l.return,l=a;break}l=l.return}a=l}De(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Pr(t,n),s=ct(s),r=r(s),t.flags|=1,De(e,t,r,n),t.child;case 14:return r=t.type,s=mt(r,t.pendingProps),s=mt(r.type,s),Hu(e,t,r,s,n);case 15:return zh(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Ka(e,t),t.tag=1,qe(r)?(e=!0,ii(t)):e=!1,Pr(t,n),Lh(t,r,s),no(t,r,s,n),ao(null,t,r,!0,e,n);case 19:return $h(e,t,n);case 22:return Fh(e,t,n)}throw Error(E(156,t.tag))};function nm(e,t){return Pf(e,t)}function wx(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function lt(e,t,n,r){return new wx(e,t,n,r)}function Tc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function kx(e){if(typeof e=="function")return Tc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Go)return 11;if(e===Jo)return 14}return 2}function Nn(e,t){var n=e.alternate;return n===null?(n=lt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function qa(e,t,n,r,s,a){var l=2;if(r=e,typeof e=="function")Tc(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case mr:return Jn(n.children,s,a,t);case qo:l=8,s|=8;break;case Cl:return e=lt(12,n,t,s|2),e.elementType=Cl,e.lanes=a,e;case _l:return e=lt(13,n,t,s),e.elementType=_l,e.lanes=a,e;case El:return e=lt(19,n,t,s),e.elementType=El,e.lanes=a,e;case ff:return Fi(n,s,a,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case uf:l=10;break e;case df:l=9;break e;case Go:l=11;break e;case Jo:l=14;break e;case Xt:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=lt(l,n,t,s),t.elementType=e,t.type=r,t.lanes=a,t}function Jn(e,t,n,r){return e=lt(7,e,r,t),e.lanes=n,e}function Fi(e,t,n,r){return e=lt(22,e,r,t),e.elementType=ff,e.lanes=n,e.stateNode={isHidden:!1},e}function yl(e,t,n){return e=lt(6,e,null,t),e.lanes=n,e}function gl(e,t,n){return t=lt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Sx(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Zi(0),this.expirationTimes=Zi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Zi(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Oc(e,t,n,r,s,a,l,o,c){return e=new Sx(e,t,n,o,c),t===1?(t=1,a===!0&&(t|=8)):t=0,a=lt(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},mc(a),e}function Nx(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(im)}catch(e){console.error(e)}}im(),af.exports=tt;var Px=af.exports,id=Px;Nl.createRoot=id.createRoot,Nl.hydrateRoot=id.hydrateRoot;var ts=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Tx={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},nn,Ao,Fd,Ox=(Fd=class{constructor(){$(this,nn,Tx);$(this,Ao,!1)}setTimeoutProvider(e){z(this,nn,e)}setTimeout(e,t){return y(this,nn).setTimeout(e,t)}clearTimeout(e){y(this,nn).clearTimeout(e)}setInterval(e,t){return y(this,nn).setInterval(e,t)}clearInterval(e){y(this,nn).clearInterval(e)}},nn=new WeakMap,Ao=new WeakMap,Fd),An=new Ox;function Lx(e){setTimeout(e,0)}var sr=typeof window>"u"||"Deno"in globalThis;function Ae(){}function Rx(e,t){return typeof e=="function"?e(t):e}function yo(e){return typeof e=="number"&&e>=0&&e!==1/0}function lm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function bn(e,t){return typeof e=="function"?e(t):e}function st(e,t){return typeof e=="function"?e(t):e}function ld(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:a,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==zc(l,t.options))return!1}else if(!qs(t.queryKey,l))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||s&&s!==t.state.fetchStatus||a&&!a(t))}function od(e,t){const{exact:n,status:r,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(ar(t.options.mutationKey)!==ar(a))return!1}else if(!qs(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function zc(e,t){return((t==null?void 0:t.queryKeyHashFn)||ar)(e)}function ar(e){return JSON.stringify(e,(t,n)=>go(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function qs(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>qs(e[n],t[n])):!1}var Mx=Object.prototype.hasOwnProperty;function om(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=cd(e)&&cd(t);if(!r&&!(go(e)&&go(t)))return t;const a=(r?e:Object.keys(e)).length,l=r?t:Object.keys(t),o=l.length,c=r?new Array(o):{};let d=0;for(let h=0;h{An.setTimeout(t,e)})}function jo(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?om(e,t):t}function Fx(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Ix(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Fc=Symbol();function cm(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Fc?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Ic(e,t){return typeof e=="function"?e(...t):!!e}function Dx(e,t,n){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),e}var $n,rn,Or,Id,Ax=(Id=class extends ts{constructor(){super();$(this,$n);$(this,rn);$(this,Or);z(this,Or,t=>{if(!sr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){y(this,rn)||this.setEventListener(y(this,Or))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,rn))==null||t.call(this),z(this,rn,void 0))}setEventListener(t){var n;z(this,Or,t),(n=y(this,rn))==null||n.call(this),z(this,rn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){y(this,$n)!==t&&(z(this,$n,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof y(this,$n)=="boolean"?y(this,$n):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},$n=new WeakMap,rn=new WeakMap,Or=new WeakMap,Id),Dc=new Ax;function wo(){let e,t;const n=new Promise((s,a)=>{e=s,t=a});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var $x=Lx;function Ux(){let e=[],t=0,n=o=>{o()},r=o=>{o()},s=$x;const a=o=>{t?e.push(o):s(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&s(()=>{r(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;t++;try{c=o()}finally{t--,t||l()}return c},batchCalls:o=>(...c)=>{a(()=>{o(...c)})},schedule:a,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{s=o}}}var Se=Ux(),Lr,sn,Rr,Dd,Bx=(Dd=class extends ts{constructor(){super();$(this,Lr,!0);$(this,sn);$(this,Rr);z(this,Rr,t=>{if(!sr&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){y(this,sn)||this.setEventListener(y(this,Rr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,sn))==null||t.call(this),z(this,sn,void 0))}setEventListener(t){var n;z(this,Rr,t),(n=y(this,sn))==null||n.call(this),z(this,sn,t(this.setOnline.bind(this)))}setOnline(t){y(this,Lr)!==t&&(z(this,Lr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return y(this,Lr)}},Lr=new WeakMap,sn=new WeakMap,Rr=new WeakMap,Dd),wi=new Bx;function Qx(e){return Math.min(1e3*2**e,3e4)}function um(e){return(e??"online")==="online"?wi.isOnline():!0}var ko=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function dm(e){let t=!1,n=0,r;const s=wo(),a=()=>s.status!=="pending",l=g=>{var S;if(!a()){const p=new ko(g);m(p),(S=e.onCancel)==null||S.call(e,p)}},o=()=>{t=!0},c=()=>{t=!1},d=()=>Dc.isFocused()&&(e.networkMode==="always"||wi.isOnline())&&e.canRun(),h=()=>um(e.networkMode)&&e.canRun(),u=g=>{a()||(r==null||r(),s.resolve(g))},m=g=>{a()||(r==null||r(),s.reject(g))},x=()=>new Promise(g=>{var S;r=p=>{(a()||d())&&g(p)},(S=e.onPause)==null||S.call(e)}).then(()=>{var g;r=void 0,a()||(g=e.onContinue)==null||g.call(e)}),k=()=>{if(a())return;let g;const S=n===0?e.initialPromise:void 0;try{g=S??e.fn()}catch(p){g=Promise.reject(p)}Promise.resolve(g).then(u).catch(p=>{var b;if(a())return;const f=e.retry??(sr?0:3),v=e.retryDelay??Qx,w=typeof v=="function"?v(n,p):v,C=f===!0||typeof f=="number"&&nd()?void 0:x()).then(()=>{t?m(p):k()})})};return{promise:s,status:()=>s.status,cancel:l,continue:()=>(r==null||r(),s),cancelRetry:o,continueRetry:c,canStart:h,start:()=>(h()?k():x().then(k),s)}}var Un,Ad,fm=(Ad=class{constructor(){$(this,Un)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),yo(this.gcTime)&&z(this,Un,An.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(sr?1/0:5*60*1e3))}clearGcTimeout(){y(this,Un)&&(An.clearTimeout(y(this,Un)),z(this,Un,void 0))}},Un=new WeakMap,Ad),Bn,Mr,rt,Qn,Ce,ta,Vn,pt,Ot,$d,Vx=($d=class extends fm{constructor(t){super();$(this,pt);$(this,Bn);$(this,Mr);$(this,rt);$(this,Qn);$(this,Ce);$(this,ta);$(this,Vn);z(this,Vn,!1),z(this,ta,t.defaultOptions),this.setOptions(t.options),this.observers=[],z(this,Qn,t.client),z(this,rt,y(this,Qn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,z(this,Bn,fd(this.options)),this.state=t.state??y(this,Bn),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=y(this,Ce))==null?void 0:t.promise}setOptions(t){if(this.options={...y(this,ta),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=fd(this.options);n.data!==void 0&&(this.setState(dd(n.data,n.dataUpdatedAt)),z(this,Bn,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&y(this,rt).remove(this)}setData(t,n){const r=jo(this.state.data,t,this.options);return W(this,pt,Ot).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){W(this,pt,Ot).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=y(this,Ce))==null?void 0:r.promise;return(s=y(this,Ce))==null||s.cancel(t),n?n.then(Ae).catch(Ae):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(y(this,Bn))}isActive(){return this.observers.some(t=>st(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Fc||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>bn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!lm(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),y(this,rt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(y(this,Ce)&&(y(this,Vn)?y(this,Ce).cancel({revert:!0}):y(this,Ce).cancelRetry()),this.scheduleGc()),y(this,rt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||W(this,pt,Ot).call(this,{type:"invalidate"})}async fetch(t,n){var c,d,h,u,m,x,k,g,S,p,f,v;if(this.state.fetchStatus!=="idle"&&((c=y(this,Ce))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(y(this,Ce))return y(this,Ce).continueRetry(),y(this,Ce).promise}if(t&&this.setOptions(t),!this.options.queryFn){const w=this.observers.find(C=>C.options.queryFn);w&&this.setOptions(w.options)}const r=new AbortController,s=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(z(this,Vn,!0),r.signal)})},a=()=>{const w=cm(this.options,n),b=(()=>{const N={client:y(this,Qn),queryKey:this.queryKey,meta:this.meta};return s(N),N})();return z(this,Vn,!1),this.options.persister?this.options.persister(w,b,this):w(b)},o=(()=>{const w={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:y(this,Qn),state:this.state,fetchFn:a};return s(w),w})();(d=this.options.behavior)==null||d.onFetch(o,this),z(this,Mr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((h=o.fetchOptions)==null?void 0:h.meta))&&W(this,pt,Ot).call(this,{type:"fetch",meta:(u=o.fetchOptions)==null?void 0:u.meta}),z(this,Ce,dm({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:w=>{w instanceof ko&&w.revert&&this.setState({...y(this,Mr),fetchStatus:"idle"}),r.abort()},onFail:(w,C)=>{W(this,pt,Ot).call(this,{type:"failed",failureCount:w,error:C})},onPause:()=>{W(this,pt,Ot).call(this,{type:"pause"})},onContinue:()=>{W(this,pt,Ot).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const w=await y(this,Ce).start();if(w===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(w),(x=(m=y(this,rt).config).onSuccess)==null||x.call(m,w,this),(g=(k=y(this,rt).config).onSettled)==null||g.call(k,w,this.state.error,this),w}catch(w){if(w instanceof ko){if(w.silent)return y(this,Ce).promise;if(w.revert){if(this.state.data===void 0)throw w;return this.state.data}}throw W(this,pt,Ot).call(this,{type:"error",error:w}),(p=(S=y(this,rt).config).onError)==null||p.call(S,w,this),(v=(f=y(this,rt).config).onSettled)==null||v.call(f,this.state.data,w,this),w}finally{this.scheduleGc()}}},Bn=new WeakMap,Mr=new WeakMap,rt=new WeakMap,Qn=new WeakMap,Ce=new WeakMap,ta=new WeakMap,Vn=new WeakMap,pt=new WeakSet,Ot=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...hm(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...dd(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return z(this,Mr,t.manual?s:void 0),s;case"error":const a=t.error;return{...r,error:a,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Se.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),y(this,rt).notify({query:this,type:"updated",action:t})})},$d);function hm(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:um(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function dd(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function fd(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Qe,Z,na,Ie,Kn,zr,Mt,an,ra,Fr,Ir,Hn,Wn,ln,Dr,se,js,So,No,bo,Co,_o,Eo,Po,mm,Ud,Kx=(Ud=class extends ts{constructor(t,n){super();$(this,se);$(this,Qe);$(this,Z);$(this,na);$(this,Ie);$(this,Kn);$(this,zr);$(this,Mt);$(this,an);$(this,ra);$(this,Fr);$(this,Ir);$(this,Hn);$(this,Wn);$(this,ln);$(this,Dr,new Set);this.options=n,z(this,Qe,t),z(this,an,null),z(this,Mt,wo()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(y(this,Z).addObserver(this),hd(y(this,Z),this.options)?W(this,se,js).call(this):this.updateResult(),W(this,se,Co).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return To(y(this,Z),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return To(y(this,Z),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,W(this,se,_o).call(this),W(this,se,Eo).call(this),y(this,Z).removeObserver(this)}setOptions(t){const n=this.options,r=y(this,Z);if(this.options=y(this,Qe).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof st(this.options.enabled,y(this,Z))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");W(this,se,Po).call(this),y(this,Z).setOptions(this.options),n._defaulted&&!ji(this.options,n)&&y(this,Qe).getQueryCache().notify({type:"observerOptionsUpdated",query:y(this,Z),observer:this});const s=this.hasListeners();s&&md(y(this,Z),r,this.options,n)&&W(this,se,js).call(this),this.updateResult(),s&&(y(this,Z)!==r||st(this.options.enabled,y(this,Z))!==st(n.enabled,y(this,Z))||bn(this.options.staleTime,y(this,Z))!==bn(n.staleTime,y(this,Z)))&&W(this,se,So).call(this);const a=W(this,se,No).call(this);s&&(y(this,Z)!==r||st(this.options.enabled,y(this,Z))!==st(n.enabled,y(this,Z))||a!==y(this,ln))&&W(this,se,bo).call(this,a)}getOptimisticResult(t){const n=y(this,Qe).getQueryCache().build(y(this,Qe),t),r=this.createResult(n,t);return Wx(this,r)&&(z(this,Ie,r),z(this,zr,this.options),z(this,Kn,y(this,Z).state)),r}getCurrentResult(){return y(this,Ie)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&y(this,Mt).status==="pending"&&y(this,Mt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){y(this,Dr).add(t)}getCurrentQuery(){return y(this,Z)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=y(this,Qe).defaultQueryOptions(t),r=y(this,Qe).getQueryCache().build(y(this,Qe),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return W(this,se,js).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),y(this,Ie)))}createResult(t,n){var F;const r=y(this,Z),s=this.options,a=y(this,Ie),l=y(this,Kn),o=y(this,zr),d=t!==r?t.state:y(this,na),{state:h}=t;let u={...h},m=!1,x;if(n._optimisticResults){const O=this.hasListeners(),B=!O&&hd(t,n),G=O&&md(t,r,n,s);(B||G)&&(u={...u,...hm(h.data,t.options)}),n._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:k,errorUpdatedAt:g,status:S}=u;x=u.data;let p=!1;if(n.placeholderData!==void 0&&x===void 0&&S==="pending"){let O;a!=null&&a.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(O=a.data,p=!0):O=typeof n.placeholderData=="function"?n.placeholderData((F=y(this,Ir))==null?void 0:F.state.data,y(this,Ir)):n.placeholderData,O!==void 0&&(S="success",x=jo(a==null?void 0:a.data,O,n),m=!0)}if(n.select&&x!==void 0&&!p)if(a&&x===(l==null?void 0:l.data)&&n.select===y(this,ra))x=y(this,Fr);else try{z(this,ra,n.select),x=n.select(x),x=jo(a==null?void 0:a.data,x,n),z(this,Fr,x),z(this,an,null)}catch(O){z(this,an,O)}y(this,an)&&(k=y(this,an),x=y(this,Fr),g=Date.now(),S="error");const f=u.fetchStatus==="fetching",v=S==="pending",w=S==="error",C=v&&f,b=x!==void 0,_={status:S,fetchStatus:u.fetchStatus,isPending:v,isSuccess:S==="success",isError:w,isInitialLoading:C,isLoading:C,data:x,dataUpdatedAt:u.dataUpdatedAt,error:k,errorUpdatedAt:g,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>d.dataUpdateCount||u.errorUpdateCount>d.errorUpdateCount,isFetching:f,isRefetching:f&&!v,isLoadingError:w&&!b,isPaused:u.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:w&&b,isStale:Ac(t,n),refetch:this.refetch,promise:y(this,Mt),isEnabled:st(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=_.data!==void 0,B=_.status==="error"&&!O,G=D=>{B?D.reject(_.error):O&&D.resolve(_.data)},re=()=>{const D=z(this,Mt,_.promise=wo());G(D)},le=y(this,Mt);switch(le.status){case"pending":t.queryHash===r.queryHash&&G(le);break;case"fulfilled":(B||_.data!==le.value)&&re();break;case"rejected":(!B||_.error!==le.reason)&&re();break}}return _}updateResult(){const t=y(this,Ie),n=this.createResult(y(this,Z),this.options);if(z(this,Kn,y(this,Z).state),z(this,zr,this.options),y(this,Kn).data!==void 0&&z(this,Ir,y(this,Z)),ji(n,t))return;z(this,Ie,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!y(this,Dr).size)return!0;const l=new Set(a??y(this,Dr));return this.options.throwOnError&&l.add("error"),Object.keys(y(this,Ie)).some(o=>{const c=o;return y(this,Ie)[c]!==t[c]&&l.has(c)})};W(this,se,mm).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&W(this,se,Co).call(this)}},Qe=new WeakMap,Z=new WeakMap,na=new WeakMap,Ie=new WeakMap,Kn=new WeakMap,zr=new WeakMap,Mt=new WeakMap,an=new WeakMap,ra=new WeakMap,Fr=new WeakMap,Ir=new WeakMap,Hn=new WeakMap,Wn=new WeakMap,ln=new WeakMap,Dr=new WeakMap,se=new WeakSet,js=function(t){W(this,se,Po).call(this);let n=y(this,Z).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Ae)),n},So=function(){W(this,se,_o).call(this);const t=bn(this.options.staleTime,y(this,Z));if(sr||y(this,Ie).isStale||!yo(t))return;const r=lm(y(this,Ie).dataUpdatedAt,t)+1;z(this,Hn,An.setTimeout(()=>{y(this,Ie).isStale||this.updateResult()},r))},No=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(y(this,Z)):this.options.refetchInterval)??!1},bo=function(t){W(this,se,Eo).call(this),z(this,ln,t),!(sr||st(this.options.enabled,y(this,Z))===!1||!yo(y(this,ln))||y(this,ln)===0)&&z(this,Wn,An.setInterval(()=>{(this.options.refetchIntervalInBackground||Dc.isFocused())&&W(this,se,js).call(this)},y(this,ln)))},Co=function(){W(this,se,So).call(this),W(this,se,bo).call(this,W(this,se,No).call(this))},_o=function(){y(this,Hn)&&(An.clearTimeout(y(this,Hn)),z(this,Hn,void 0))},Eo=function(){y(this,Wn)&&(An.clearInterval(y(this,Wn)),z(this,Wn,void 0))},Po=function(){const t=y(this,Qe).getQueryCache().build(y(this,Qe),this.options);if(t===y(this,Z))return;const n=y(this,Z);z(this,Z,t),z(this,na,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},mm=function(t){Se.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(y(this,Ie))}),y(this,Qe).getQueryCache().notify({query:y(this,Z),type:"observerResultsUpdated"})})},Ud);function Hx(e,t){return st(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function hd(e,t){return Hx(e,t)||e.state.data!==void 0&&To(e,t,t.refetchOnMount)}function To(e,t,n){if(st(t.enabled,e)!==!1&&bn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Ac(e,t)}return!1}function md(e,t,n,r){return(e!==t||st(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Ac(e,n)}function Ac(e,t){return st(t.enabled,e)!==!1&&e.isStaleByTime(bn(t.staleTime,e))}function Wx(e,t){return!ji(e.getCurrentResult(),t)}function pd(e){return{onFetch:(t,n)=>{var h,u,m,x,k;const r=t.options,s=(m=(u=(h=t.fetchOptions)==null?void 0:h.meta)==null?void 0:u.fetchMore)==null?void 0:m.direction,a=((x=t.state.data)==null?void 0:x.pages)||[],l=((k=t.state.data)==null?void 0:k.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const d=async()=>{let g=!1;const S=v=>{Dx(v,()=>t.signal,()=>g=!0)},p=cm(t.options,t.fetchOptions),f=async(v,w,C)=>{if(g)return Promise.reject();if(w==null&&v.pages.length)return Promise.resolve(v);const N=(()=>{const B={client:t.client,queryKey:t.queryKey,pageParam:w,direction:C?"backward":"forward",meta:t.options.meta};return S(B),B})(),_=await p(N),{maxPages:F}=t.options,O=C?Ix:Fx;return{pages:O(v.pages,_,F),pageParams:O(v.pageParams,w,F)}};if(s&&a.length){const v=s==="backward",w=v?qx:vd,C={pages:a,pageParams:l},b=w(r,C);o=await f(C,b,v)}else{const v=e??a.length;do{const w=c===0?l[0]??r.initialPageParam:vd(r,o);if(c>0&&w==null)break;o=await f(o,w),c++}while(c{var g,S;return(S=(g=t.options).persister)==null?void 0:S.call(g,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=d}}}function vd(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function qx(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var sa,Nt,Me,qn,bt,Yt,Bd,Gx=(Bd=class extends fm{constructor(t){super();$(this,bt);$(this,sa);$(this,Nt);$(this,Me);$(this,qn);z(this,sa,t.client),this.mutationId=t.mutationId,z(this,Me,t.mutationCache),z(this,Nt,[]),this.state=t.state||pm(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){y(this,Nt).includes(t)||(y(this,Nt).push(t),this.clearGcTimeout(),y(this,Me).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){z(this,Nt,y(this,Nt).filter(n=>n!==t)),this.scheduleGc(),y(this,Me).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){y(this,Nt).length||(this.state.status==="pending"?this.scheduleGc():y(this,Me).remove(this))}continue(){var t;return((t=y(this,qn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,d,h,u,m,x,k,g,S,p,f,v,w,C,b,N;const n=()=>{W(this,bt,Yt).call(this,{type:"continue"})},r={client:y(this,sa),meta:this.options.meta,mutationKey:this.options.mutationKey};z(this,qn,dm({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(_,F)=>{W(this,bt,Yt).call(this,{type:"failed",failureCount:_,error:F})},onPause:()=>{W(this,bt,Yt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>y(this,Me).canRun(this)}));const s=this.state.status==="pending",a=!y(this,qn).canStart();try{if(s)n();else{W(this,bt,Yt).call(this,{type:"pending",variables:t,isPaused:a}),y(this,Me).config.onMutate&&await y(this,Me).config.onMutate(t,this,r);const F=await((o=(l=this.options).onMutate)==null?void 0:o.call(l,t,r));F!==this.state.context&&W(this,bt,Yt).call(this,{type:"pending",context:F,variables:t,isPaused:a})}const _=await y(this,qn).start();return await((d=(c=y(this,Me).config).onSuccess)==null?void 0:d.call(c,_,t,this.state.context,this,r)),await((u=(h=this.options).onSuccess)==null?void 0:u.call(h,_,t,this.state.context,r)),await((x=(m=y(this,Me).config).onSettled)==null?void 0:x.call(m,_,null,this.state.variables,this.state.context,this,r)),await((g=(k=this.options).onSettled)==null?void 0:g.call(k,_,null,t,this.state.context,r)),W(this,bt,Yt).call(this,{type:"success",data:_}),_}catch(_){try{await((p=(S=y(this,Me).config).onError)==null?void 0:p.call(S,_,t,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((v=(f=this.options).onError)==null?void 0:v.call(f,_,t,this.state.context,r))}catch(F){Promise.reject(F)}try{await((C=(w=y(this,Me).config).onSettled)==null?void 0:C.call(w,void 0,_,this.state.variables,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((N=(b=this.options).onSettled)==null?void 0:N.call(b,void 0,_,t,this.state.context,r))}catch(F){Promise.reject(F)}throw W(this,bt,Yt).call(this,{type:"error",error:_}),_}finally{y(this,Me).runNext(this)}}},sa=new WeakMap,Nt=new WeakMap,Me=new WeakMap,qn=new WeakMap,bt=new WeakSet,Yt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Se.batch(()=>{y(this,Nt).forEach(r=>{r.onMutationUpdate(t)}),y(this,Me).notify({mutation:this,type:"updated",action:t})})},Bd);function pm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var zt,vt,aa,Qd,Jx=(Qd=class extends ts{constructor(t={}){super();$(this,zt);$(this,vt);$(this,aa);this.config=t,z(this,zt,new Set),z(this,vt,new Map),z(this,aa,0)}build(t,n,r){const s=new Gx({client:t,mutationCache:this,mutationId:++va(this,aa)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){y(this,zt).add(t);const n=Ma(t);if(typeof n=="string"){const r=y(this,vt).get(n);r?r.push(t):y(this,vt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(y(this,zt).delete(t)){const n=Ma(t);if(typeof n=="string"){const r=y(this,vt).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&y(this,vt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Ma(t);if(typeof n=="string"){const r=y(this,vt).get(n),s=r==null?void 0:r.find(a=>a.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=Ma(t);if(typeof n=="string"){const s=(r=y(this,vt).get(n))==null?void 0:r.find(a=>a!==t&&a.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Se.batch(()=>{y(this,zt).forEach(t=>{this.notify({type:"removed",mutation:t})}),y(this,zt).clear(),y(this,vt).clear()})}getAll(){return Array.from(y(this,zt))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>od(n,r))}findAll(t={}){return this.getAll().filter(n=>od(t,n))}notify(t){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Se.batch(()=>Promise.all(t.map(n=>n.continue().catch(Ae))))}},zt=new WeakMap,vt=new WeakMap,aa=new WeakMap,Qd);function Ma(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Ft,on,Ve,It,Bt,Ga,Oo,Vd,Yx=(Vd=class extends ts{constructor(n,r){super();$(this,Bt);$(this,Ft);$(this,on);$(this,Ve);$(this,It);z(this,Ft,n),this.setOptions(r),this.bindMethods(),W(this,Bt,Ga).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=y(this,Ft).defaultMutationOptions(n),ji(this.options,r)||y(this,Ft).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,Ve),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&ar(r.mutationKey)!==ar(this.options.mutationKey)?this.reset():((s=y(this,Ve))==null?void 0:s.state.status)==="pending"&&y(this,Ve).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=y(this,Ve))==null||n.removeObserver(this)}onMutationUpdate(n){W(this,Bt,Ga).call(this),W(this,Bt,Oo).call(this,n)}getCurrentResult(){return y(this,on)}reset(){var n;(n=y(this,Ve))==null||n.removeObserver(this),z(this,Ve,void 0),W(this,Bt,Ga).call(this),W(this,Bt,Oo).call(this)}mutate(n,r){var s;return z(this,It,r),(s=y(this,Ve))==null||s.removeObserver(this),z(this,Ve,y(this,Ft).getMutationCache().build(y(this,Ft),this.options)),y(this,Ve).addObserver(this),y(this,Ve).execute(n)}},Ft=new WeakMap,on=new WeakMap,Ve=new WeakMap,It=new WeakMap,Bt=new WeakSet,Ga=function(){var r;const n=((r=y(this,Ve))==null?void 0:r.state)??pm();z(this,on,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Oo=function(n){Se.batch(()=>{var r,s,a,l,o,c,d,h;if(y(this,It)&&this.hasListeners()){const u=y(this,on).variables,m=y(this,on).context,x={client:y(this,Ft),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(s=(r=y(this,It)).onSuccess)==null||s.call(r,n.data,u,m,x)}catch(k){Promise.reject(k)}try{(l=(a=y(this,It)).onSettled)==null||l.call(a,n.data,null,u,m,x)}catch(k){Promise.reject(k)}}else if((n==null?void 0:n.type)==="error"){try{(c=(o=y(this,It)).onError)==null||c.call(o,n.error,u,m,x)}catch(k){Promise.reject(k)}try{(h=(d=y(this,It)).onSettled)==null||h.call(d,void 0,n.error,u,m,x)}catch(k){Promise.reject(k)}}}this.listeners.forEach(u=>{u(y(this,on))})})},Vd),Ct,Kd,Xx=(Kd=class extends ts{constructor(t={}){super();$(this,Ct);this.config=t,z(this,Ct,new Map)}build(t,n,r){const s=n.queryKey,a=n.queryHash??zc(s,n);let l=this.get(a);return l||(l=new Vx({client:t,queryKey:s,queryHash:a,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(l)),l}add(t){y(this,Ct).has(t.queryHash)||(y(this,Ct).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=y(this,Ct).get(t.queryHash);n&&(t.destroy(),n===t&&y(this,Ct).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Se.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return y(this,Ct).get(t)}getAll(){return[...y(this,Ct).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>ld(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>ld(t,r)):n}notify(t){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Se.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Se.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ct=new WeakMap,Kd),ve,cn,un,Ar,$r,dn,Ur,Br,Hd,Zx=(Hd=class{constructor(e={}){$(this,ve);$(this,cn);$(this,un);$(this,Ar);$(this,$r);$(this,dn);$(this,Ur);$(this,Br);z(this,ve,e.queryCache||new Xx),z(this,cn,e.mutationCache||new Jx),z(this,un,e.defaultOptions||{}),z(this,Ar,new Map),z(this,$r,new Map),z(this,dn,0)}mount(){va(this,dn)._++,y(this,dn)===1&&(z(this,Ur,Dc.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,ve).onFocus())})),z(this,Br,wi.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,ve).onOnline())})))}unmount(){var e,t;va(this,dn)._--,y(this,dn)===0&&((e=y(this,Ur))==null||e.call(this),z(this,Ur,void 0),(t=y(this,Br))==null||t.call(this),z(this,Br,void 0))}isFetching(e){return y(this,ve).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return y(this,cn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,ve).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=y(this,ve).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(bn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return y(this,ve).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=y(this,ve).get(r.queryHash),a=s==null?void 0:s.state.data,l=Rx(t,a);if(l!==void 0)return y(this,ve).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return Se.batch(()=>y(this,ve).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,ve).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=y(this,ve);Se.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=y(this,ve);return Se.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Se.batch(()=>y(this,ve).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Ae).catch(Ae)}invalidateQueries(e,t={}){return Se.batch(()=>(y(this,ve).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Se.batch(()=>y(this,ve).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let a=s.fetch(void 0,n);return n.throwOnError||(a=a.catch(Ae)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Ae)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=y(this,ve).build(this,t);return n.isStaleByTime(bn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ae).catch(Ae)}fetchInfiniteQuery(e){return e.behavior=pd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ae).catch(Ae)}ensureInfiniteQueryData(e){return e.behavior=pd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return wi.isOnline()?y(this,cn).resumePausedMutations():Promise.resolve()}getQueryCache(){return y(this,ve)}getMutationCache(){return y(this,cn)}getDefaultOptions(){return y(this,un)}setDefaultOptions(e){z(this,un,e)}setQueryDefaults(e,t){y(this,Ar).set(ar(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...y(this,Ar).values()],n={};return t.forEach(r=>{qs(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){y(this,$r).set(ar(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...y(this,$r).values()],n={};return t.forEach(r=>{qs(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...y(this,un).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=zc(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Fc&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...y(this,un).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){y(this,ve).clear(),y(this,cn).clear()}},ve=new WeakMap,cn=new WeakMap,un=new WeakMap,Ar=new WeakMap,$r=new WeakMap,dn=new WeakMap,Ur=new WeakMap,Br=new WeakMap,Hd),vm=j.createContext(void 0),qt=e=>{const t=j.useContext(vm);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ey=({client:e,children:t})=>(j.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),i.jsx(vm.Provider,{value:e,children:t})),xm=j.createContext(!1),ty=()=>j.useContext(xm);xm.Provider;function ny(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var ry=j.createContext(ny()),sy=()=>j.useContext(ry),ay=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Ic(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},iy=e=>{j.useEffect(()=>{e.clearReset()},[e])},ly=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||Ic(n,[e.error,r])),oy=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},cy=(e,t)=>e.isLoading&&e.isFetching&&!t,uy=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,xd=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function dy(e,t,n){var m,x,k,g;const r=ty(),s=sy(),a=qt(),l=a.defaultQueryOptions(e);(x=(m=a.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||x.call(m,l);const o=a.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",oy(l),ay(l,s,o),iy(s);const c=!a.getQueryCache().get(l.queryHash),[d]=j.useState(()=>new t(a,l)),h=d.getOptimisticResult(l),u=!r&&e.subscribed!==!1;if(j.useSyncExternalStore(j.useCallback(S=>{const p=u?d.subscribe(Se.batchCalls(S)):Ae;return d.updateResult(),p},[d,u]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),j.useEffect(()=>{d.setOptions(l)},[l,d]),uy(l,h))throw xd(l,d,s);if(ly({result:h,errorResetBoundary:s,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw h.error;if((g=(k=a.getDefaultOptions().queries)==null?void 0:k._experimental_afterQuery)==null||g.call(k,l,h),l.experimental_prefetchInRender&&!sr&&cy(h,r)){const S=c?xd(l,d,s):o==null?void 0:o.promise;S==null||S.catch(Ae).finally(()=>{d.updateResult()})}return l.notifyOnChangeProps?h:d.trackResult(h)}function he(e,t){return dy(e,Kx)}function Je(e,t){const n=qt(),[r]=j.useState(()=>new Yx(n,e));j.useEffect(()=>{r.setOptions(e)},[r,e]);const s=j.useSyncExternalStore(j.useCallback(l=>r.subscribe(Se.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=j.useCallback((l,o)=>{r.mutate(l,o).catch(Ae)},[r]);if(s.error&&Ic(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}/** + * @remix-run/router v1.23.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Gs(){return Gs=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function $c(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function hy(){return Math.random().toString(36).substr(2,8)}function gd(e,t){return{usr:e.state,key:e.key,idx:t}}function Lo(e,t,n,r){return n===void 0&&(n=null),Gs({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?ns(t):t,{state:n,key:t&&t.key||r||hy()})}function ki(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function ns(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function my(e,t,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:a=!1}=r,l=s.history,o=mn.Pop,c=null,d=h();d==null&&(d=0,l.replaceState(Gs({},l.state,{idx:d}),""));function h(){return(l.state||{idx:null}).idx}function u(){o=mn.Pop;let S=h(),p=S==null?null:S-d;d=S,c&&c({action:o,location:g.location,delta:p})}function m(S,p){o=mn.Push;let f=Lo(g.location,S,p);d=h()+1;let v=gd(f,d),w=g.createHref(f);try{l.pushState(v,"",w)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;s.location.assign(w)}a&&c&&c({action:o,location:g.location,delta:1})}function x(S,p){o=mn.Replace;let f=Lo(g.location,S,p);d=h();let v=gd(f,d),w=g.createHref(f);l.replaceState(v,"",w),a&&c&&c({action:o,location:g.location,delta:0})}function k(S){let p=s.location.origin!=="null"?s.location.origin:s.location.href,f=typeof S=="string"?S:ki(S);return f=f.replace(/ $/,"%20"),ye(p,"No window.location.(origin|href) available to create URL for href: "+f),new URL(f,p)}let g={get action(){return o},get location(){return e(s,l)},listen(S){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(yd,u),c=S,()=>{s.removeEventListener(yd,u),c=null}},createHref(S){return t(s,S)},createURL:k,encodeLocation(S){let p=k(S);return{pathname:p.pathname,search:p.search,hash:p.hash}},push:m,replace:x,go(S){return l.go(S)}};return g}var jd;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(jd||(jd={}));function py(e,t,n){return n===void 0&&(n="/"),vy(e,t,n)}function vy(e,t,n,r){let s=typeof t=="string"?ns(t):t,a=Jr(s.pathname||"/",n);if(a==null)return null;let l=ym(e);xy(l);let o=null;for(let c=0;o==null&&c{let c={relativePath:o===void 0?a.path||"":o,caseSensitive:a.caseSensitive===!0,childrenIndex:l,route:a};c.relativePath.startsWith("/")&&(ye(c.relativePath.startsWith(r),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(r.length));let d=Cn([r,c.relativePath]),h=n.concat(c);a.children&&a.children.length>0&&(ye(a.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),ym(a.children,t,h,d)),!(a.path==null&&!a.index)&&t.push({path:d,score:Ny(d,a.index),routesMeta:h})};return e.forEach((a,l)=>{var o;if(a.path===""||!((o=a.path)!=null&&o.includes("?")))s(a,l);else for(let c of gm(a.path))s(a,l,c)}),t}function gm(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return s?[a,""]:[a];let l=gm(r.join("/")),o=[];return o.push(...l.map(c=>c===""?a:[a,c].join("/"))),s&&o.push(...l),o.map(c=>e.startsWith("/")&&c===""?"/":c)}function xy(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:by(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const yy=/^:[\w-]+$/,gy=3,jy=2,wy=1,ky=10,Sy=-2,wd=e=>e==="*";function Ny(e,t){let n=e.split("/"),r=n.length;return n.some(wd)&&(r+=Sy),t&&(r+=jy),n.filter(s=>!wd(s)).reduce((s,a)=>s+(yy.test(a)?gy:a===""?wy:ky),r)}function by(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function Cy(e,t,n){let{routesMeta:r}=e,s={},a="/",l=[];for(let o=0;o{let{paramName:m,isOptional:x}=h;if(m==="*"){let g=o[u]||"";l=a.slice(0,a.length-g.length).replace(/(.)\/+$/,"$1")}const k=o[u];return x&&!k?d[m]=void 0:d[m]=(k||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:l,pattern:e}}function _y(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),$c(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,c)=>(r.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function Ey(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return $c(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Jr(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const Py=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Ty=e=>Py.test(e);function Oy(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?ns(e):e,a;if(n)if(Ty(n))a=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),$c(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?a=kd(n.substring(1),"/"):a=kd(n,t)}else a=t;return{pathname:a,search:My(r),hash:zy(s)}}function kd(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function jl(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Ly(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function jm(e,t){let n=Ly(e);return t?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function wm(e,t,n,r){r===void 0&&(r=!1);let s;typeof e=="string"?s=ns(e):(s=Gs({},e),ye(!s.pathname||!s.pathname.includes("?"),jl("?","pathname","search",s)),ye(!s.pathname||!s.pathname.includes("#"),jl("#","pathname","hash",s)),ye(!s.search||!s.search.includes("#"),jl("#","search","hash",s)));let a=e===""||s.pathname==="",l=a?"/":s.pathname,o;if(l==null)o=n;else{let u=t.length-1;if(!r&&l.startsWith("..")){let m=l.split("/");for(;m[0]==="..";)m.shift(),u-=1;s.pathname=m.join("/")}o=u>=0?t[u]:"/"}let c=Oy(s,o),d=l&&l!=="/"&&l.endsWith("/"),h=(a||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||h)&&(c.pathname+="/"),c}const Cn=e=>e.join("/").replace(/\/\/+/g,"/"),Ry=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),My=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,zy=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Fy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const km=["post","put","patch","delete"];new Set(km);const Iy=["get",...km];new Set(Iy);/** + * React Router v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Js(){return Js=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),j.useCallback(function(d,h){if(h===void 0&&(h={}),!o.current)return;if(typeof d=="number"){r.go(d);return}let u=wm(d,JSON.parse(l),a,h.relative==="path");e==null&&t!=="/"&&(u.pathname=u.pathname==="/"?t:Cn([t,u.pathname])),(h.replace?r.replace:r.push)(u,h.state,h)},[t,r,l,a,e])}const $y=j.createContext(null);function Uy(e){let t=j.useContext(Gt).outlet;return t&&j.createElement($y.Provider,{value:e},t)}function fa(){let{matches:e}=j.useContext(Gt),t=e[e.length-1];return t?t.params:{}}function Qi(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=j.useContext(Rn),{matches:s}=j.useContext(Gt),{pathname:a}=rs(),l=JSON.stringify(jm(s,r.v7_relativeSplatPath));return j.useMemo(()=>wm(e,JSON.parse(l),a,n==="path"),[e,l,a,n])}function By(e,t){return Qy(e,t)}function Qy(e,t,n,r){da()||ye(!1);let{navigator:s}=j.useContext(Rn),{matches:a}=j.useContext(Gt),l=a[a.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let d=rs(),h;if(t){var u;let S=typeof t=="string"?ns(t):t;c==="/"||(u=S.pathname)!=null&&u.startsWith(c)||ye(!1),h=S}else h=d;let m=h.pathname||"/",x=m;if(c!=="/"){let S=c.replace(/^\//,"").split("/");x="/"+m.replace(/^\//,"").split("/").slice(S.length).join("/")}let k=py(e,{pathname:x}),g=qy(k&&k.map(S=>Object.assign({},S,{params:Object.assign({},o,S.params),pathname:Cn([c,s.encodeLocation?s.encodeLocation(S.pathname).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?c:Cn([c,s.encodeLocation?s.encodeLocation(S.pathnameBase).pathname:S.pathnameBase])})),a,n,r);return t&&g?j.createElement(Bi.Provider,{value:{location:Js({pathname:"/",search:"",hash:"",state:null,key:"default"},h),navigationType:mn.Pop}},g):g}function Vy(){let e=Xy(),t=Fy(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return j.createElement(j.Fragment,null,j.createElement("h2",null,"Unexpected Application Error!"),j.createElement("h3",{style:{fontStyle:"italic"}},t),n?j.createElement("pre",{style:s},n):null,null)}const Ky=j.createElement(Vy,null);class Hy extends j.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?j.createElement(Gt.Provider,{value:this.props.routeContext},j.createElement(Nm.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Wy(e){let{routeContext:t,match:n,children:r}=e,s=j.useContext(Ui);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),j.createElement(Gt.Provider,{value:t},r)}function qy(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var a;if(!n)return null;if(n.errors)e=n.matches;else if((a=r)!=null&&a.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(s=n)==null?void 0:s.errors;if(o!=null){let h=l.findIndex(u=>u.route.id&&(o==null?void 0:o[u.route.id])!==void 0);h>=0||ye(!1),l=l.slice(0,Math.min(l.length,h+1))}let c=!1,d=-1;if(n&&r&&r.v7_partialHydration)for(let h=0;h=0?l=l.slice(0,d+1):l=[l[0]];break}}}return l.reduceRight((h,u,m)=>{let x,k=!1,g=null,S=null;n&&(x=o&&u.route.id?o[u.route.id]:void 0,g=u.route.errorElement||Ky,c&&(d<0&&m===0?(eg("route-fallback"),k=!0,S=null):d===m&&(k=!0,S=u.route.hydrateFallbackElement||null)));let p=t.concat(l.slice(0,m+1)),f=()=>{let v;return x?v=g:k?v=S:u.route.Component?v=j.createElement(u.route.Component,null):u.route.element?v=u.route.element:v=h,j.createElement(Wy,{match:u,routeContext:{outlet:h,matches:p,isDataRoute:n!=null},children:v})};return n&&(u.route.ErrorBoundary||u.route.errorElement||m===0)?j.createElement(Hy,{location:n.location,revalidation:n.revalidation,component:g,error:x,children:f(),routeContext:{outlet:null,matches:p,isDataRoute:!0}}):f()},null)}var Cm=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Cm||{}),_m=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(_m||{});function Gy(e){let t=j.useContext(Ui);return t||ye(!1),t}function Jy(e){let t=j.useContext(Sm);return t||ye(!1),t}function Yy(e){let t=j.useContext(Gt);return t||ye(!1),t}function Em(e){let t=Yy(),n=t.matches[t.matches.length-1];return n.route.id||ye(!1),n.route.id}function Xy(){var e;let t=j.useContext(Nm),n=Jy(),r=Em();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function Zy(){let{router:e}=Gy(Cm.UseNavigateStable),t=Em(_m.UseNavigateStable),n=j.useRef(!1);return bm(()=>{n.current=!0}),j.useCallback(function(s,a){a===void 0&&(a={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,Js({fromRouteId:t},a)))},[e,t])}const Sd={};function eg(e,t,n){Sd[e]||(Sd[e]=!0)}function tg(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function ng(e){return Uy(e.context)}function ht(e){ye(!1)}function rg(e){let{basename:t="/",children:n=null,location:r,navigationType:s=mn.Pop,navigator:a,static:l=!1,future:o}=e;da()&&ye(!1);let c=t.replace(/^\/*/,"/"),d=j.useMemo(()=>({basename:c,navigator:a,static:l,future:Js({v7_relativeSplatPath:!1},o)}),[c,o,a,l]);typeof r=="string"&&(r=ns(r));let{pathname:h="/",search:u="",hash:m="",state:x=null,key:k="default"}=r,g=j.useMemo(()=>{let S=Jr(h,c);return S==null?null:{location:{pathname:S,search:u,hash:m,state:x,key:k},navigationType:s}},[c,h,u,m,x,k,s]);return g==null?null:j.createElement(Rn.Provider,{value:d},j.createElement(Bi.Provider,{children:n,value:g}))}function sg(e){let{children:t,location:n}=e;return By(Mo(t),n)}new Promise(()=>{});function Mo(e,t){t===void 0&&(t=[]);let n=[];return j.Children.forEach(e,(r,s)=>{if(!j.isValidElement(r))return;let a=[...t,s];if(r.type===j.Fragment){n.push.apply(n,Mo(r.props.children,a));return}r.type!==ht&&ye(!1),!r.props.index||!r.props.children||ye(!1);let l={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Mo(r.props.children,a)),n.push(l)}),n}/** + * React Router DOM v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Si(){return Si=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[s]=e[s]);return n}function ag(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ig(e,t){return e.button===0&&(!t||t==="_self")&&!ag(e)}const lg=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],og=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],cg="6";try{window.__reactRouterVersion=cg}catch{}const ug=j.createContext({isTransitioning:!1}),dg="startTransition",Nd=yp[dg];function fg(e){let{basename:t,children:n,future:r,window:s}=e,a=j.useRef();a.current==null&&(a.current=fy({window:s,v5Compat:!0}));let l=a.current,[o,c]=j.useState({action:l.action,location:l.location}),{v7_startTransition:d}=r||{},h=j.useCallback(u=>{d&&Nd?Nd(()=>c(u)):c(u)},[c,d]);return j.useLayoutEffect(()=>l.listen(h),[l,h]),j.useEffect(()=>tg(r),[r]),j.createElement(rg,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const hg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",mg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Pn=j.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:a,replace:l,state:o,target:c,to:d,preventScrollReset:h,viewTransition:u}=t,m=Pm(t,lg),{basename:x}=j.useContext(Rn),k,g=!1;if(typeof d=="string"&&mg.test(d)&&(k=d,hg))try{let v=new URL(window.location.href),w=d.startsWith("//")?new URL(v.protocol+d):new URL(d),C=Jr(w.pathname,x);w.origin===v.origin&&C!=null?d=C+w.search+w.hash:g=!0}catch{}let S=Dy(d,{relative:s}),p=vg(d,{replace:l,state:o,target:c,preventScrollReset:h,relative:s,viewTransition:u});function f(v){r&&r(v),v.defaultPrevented||p(v)}return j.createElement("a",Si({},m,{href:k||S,onClick:g||a?r:f,ref:n,target:c}))}),Tm=j.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:s=!1,className:a="",end:l=!1,style:o,to:c,viewTransition:d,children:h}=t,u=Pm(t,og),m=Qi(c,{relative:u.relative}),x=rs(),k=j.useContext(Sm),{navigator:g,basename:S}=j.useContext(Rn),p=k!=null&&xg(m)&&d===!0,f=g.encodeLocation?g.encodeLocation(m).pathname:m.pathname,v=x.pathname,w=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;s||(v=v.toLowerCase(),w=w?w.toLowerCase():null,f=f.toLowerCase()),w&&S&&(w=Jr(w,S)||w);const C=f!=="/"&&f.endsWith("/")?f.length-1:f.length;let b=v===f||!l&&v.startsWith(f)&&v.charAt(C)==="/",N=w!=null&&(w===f||!l&&w.startsWith(f)&&w.charAt(f.length)==="/"),_={isActive:b,isPending:N,isTransitioning:p},F=b?r:void 0,O;typeof a=="function"?O=a(_):O=[a,b?"active":null,N?"pending":null,p?"transitioning":null].filter(Boolean).join(" ");let B=typeof o=="function"?o(_):o;return j.createElement(Pn,Si({},u,{"aria-current":F,className:O,ref:n,style:B,to:c,viewTransition:d}),typeof h=="function"?h(_):h)});var zo;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(zo||(zo={}));var bd;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(bd||(bd={}));function pg(e){let t=j.useContext(Ui);return t||ye(!1),t}function vg(e,t){let{target:n,replace:r,state:s,preventScrollReset:a,relative:l,viewTransition:o}=t===void 0?{}:t,c=cr(),d=rs(),h=Qi(e,{relative:l});return j.useCallback(u=>{if(ig(u,n)){u.preventDefault();let m=r!==void 0?r:ki(d)===ki(h);c(e,{replace:m,state:s,preventScrollReset:a,relative:l,viewTransition:o})}},[d,c,h,r,s,n,e,a,l,o])}function xg(e,t){t===void 0&&(t={});let n=j.useContext(ug);n==null&&ye(!1);let{basename:r}=pg(zo.useViewTransitionState),s=Qi(e,{relative:t.relative});if(!n.isTransitioning)return!1;let a=Jr(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Jr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Ro(s.pathname,l)!=null||Ro(s.pathname,a)!=null}/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var yg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gg=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),V=(e,t)=>{const n=j.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:a=2,absoluteStrokeWidth:l,className:o="",children:c,...d},h)=>j.createElement("svg",{ref:h,...yg,width:s,height:s,stroke:r,strokeWidth:l?Number(a)*24/Number(s):a,className:["lucide",`lucide-${gg(e)}`,o].join(" "),...d},[...t.map(([u,m])=>j.createElement(u,m)),...Array.isArray(c)?c:[c]]));return n.displayName=`${e}`,n};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const jg=V("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Om=V("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const wg=V("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kg=V("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Sg=V("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lm=V("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ng=V("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bg=V("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ys=V("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cg=V("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _g=V("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rm=V("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Eg=V("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pg=V("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Tg=V("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cd=V("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mm=V("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Og=V("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lg=V("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rg=V("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mg=V("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Uc=V("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zg=V("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fg=V("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ha=V("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zm=V("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ig=V("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dg=V("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xs=V("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bc=V("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ag=V("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $g=V("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fm=V("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Im=V("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ug=V("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _d=V("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bg=V("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qg=V("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qc=V("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dm=V("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vg=V("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Am=V("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ma=V("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),Kg={},Ed=e=>{let t;const n=new Set,r=(h,u)=>{const m=typeof h=="function"?h(t):h;if(!Object.is(m,t)){const x=t;t=u??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(k=>k(t,x))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>d,subscribe:h=>(n.add(h),()=>n.delete(h)),destroy:()=>{(Kg?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(r,s,c);return c},Hg=e=>e?Ed(e):Ed;var $m={exports:{}},Um={},Bm={exports:{}},Qm={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Yr=j;function Wg(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var qg=typeof Object.is=="function"?Object.is:Wg,Gg=Yr.useState,Jg=Yr.useEffect,Yg=Yr.useLayoutEffect,Xg=Yr.useDebugValue;function Zg(e,t){var n=t(),r=Gg({inst:{value:n,getSnapshot:t}}),s=r[0].inst,a=r[1];return Yg(function(){s.value=n,s.getSnapshot=t,wl(s)&&a({inst:s})},[e,n,t]),Jg(function(){return wl(s)&&a({inst:s}),e(function(){wl(s)&&a({inst:s})})},[e]),Xg(n),n}function wl(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!qg(e,n)}catch{return!0}}function e0(e,t){return t()}var t0=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?e0:Zg;Qm.useSyncExternalStore=Yr.useSyncExternalStore!==void 0?Yr.useSyncExternalStore:t0;Bm.exports=Qm;var n0=Bm.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Vi=j,r0=n0;function s0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var a0=typeof Object.is=="function"?Object.is:s0,i0=r0.useSyncExternalStore,l0=Vi.useRef,o0=Vi.useEffect,c0=Vi.useMemo,u0=Vi.useDebugValue;Um.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var a=l0(null);if(a.current===null){var l={hasValue:!1,value:null};a.current=l}else l=a.current;a=c0(function(){function c(x){if(!d){if(d=!0,h=x,x=r(x),s!==void 0&&l.hasValue){var k=l.value;if(s(k,x))return u=k}return u=x}if(k=u,a0(h,x))return k;var g=r(x);return s!==void 0&&s(k,g)?(h=x,k):(h=x,u=g)}var d=!1,h,u,m=n===void 0?null:n;return[function(){return c(t())},m===null?void 0:function(){return c(m())}]},[t,n,r,s]);var o=i0(e,a[0],a[1]);return o0(function(){l.hasValue=!0,l.value=o},[o]),u0(o),o};$m.exports=Um;var d0=$m.exports;const f0=Wd(d0),Vm={},{useDebugValue:h0}=Vo,{useSyncExternalStoreWithSelector:m0}=f0;let Pd=!1;const p0=e=>e;function v0(e,t=p0,n){(Vm?"production":void 0)!=="production"&&n&&!Pd&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Pd=!0);const r=m0(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return h0(r),r}const Td=e=>{(Vm?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?Hg(e):e,n=(r,s)=>v0(t,r,s);return Object.assign(n,t),n},Ki=e=>e?Td(e):Td,Hi="/api",Vc="flow_auth_token",Kc="flow_auth_expires",Hc="flow_auth_username";function Zs(){const e=localStorage.getItem(Vc),t=localStorage.getItem(Kc);return!e||!t?null:new Date(t)<=new Date?(Yn(),null):e}function Od(e,t,n){localStorage.setItem(Vc,e),localStorage.setItem(Kc,t),localStorage.setItem(Hc,n)}function Yn(){localStorage.removeItem(Vc),localStorage.removeItem(Kc),localStorage.removeItem(Hc)}function Wc(){return localStorage.getItem(Hc)}let ir=null;function x0(e){ir=e}async function U(e,t,n=!1){const r={"Content-Type":"application/json",...t==null?void 0:t.headers};if(!n){const a=Zs();a&&(r.Authorization=`Bearer ${a}`)}const s=await fetch(`${Hi}${e}`,{...t,headers:r});if(s.status===401){Yn(),ir&&ir();const a=await s.json().catch(()=>({detail:"Not authenticated"}));throw new Error(a.detail||"Not authenticated")}if(!s.ok){const a=await s.json().catch(()=>({detail:s.statusText}));throw new Error(a.detail||"API request failed")}if(s.status!==204)return s.json()}const dr={getConfig:()=>U("/auth/config",void 0,!0),login:e=>U("/auth/login",{method:"POST",body:JSON.stringify(e)},!0),getGitHubAuthUrl:()=>`${Hi}/auth/github`,getCurrentUser:()=>U("/auth/me"),logout:()=>U("/auth/logout",{method:"POST"})},Xn={list:e=>{const t=new URLSearchParams;e!=null&&e.include_auto_generated&&t.set("include_auto_generated","true"),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return U(`/configs${n?`?${n}`:""}`)},get:e=>U(`/configs/${e}`),create:e=>U("/configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/configs/${e}`,{method:"DELETE"})},Et={list:e=>{const t=new URLSearchParams;e!=null&&e.category&&t.set("category",e.category),e!=null&&e.suite&&t.set("suite",e.suite);const n=t.toString();return U(`/tasks${n?`?${n}`:""}`)},get:e=>U(`/tasks/${e}`),create:e=>U("/tasks",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/tasks/${e}`,{method:"DELETE"}),listSuites:()=>U("/tasks/suites"),importSuite:e=>U(`/tasks/import-suite?suite_name=${encodeURIComponent(e)}`,{method:"POST"})},Ut={list:e=>{const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return U(`/jobs${n?`?${n}`:""}`)},get:e=>U(`/jobs/${e}`),create:e=>U("/jobs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/jobs/${e}`,{method:"PUT",body:JSON.stringify(t)}),start:async function*(e){var o;const t={},n=Zs();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Hi}/jobs/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Yn(),ir&&ir(),new Error("Not authenticated");if(!r.ok)throw new Error("Failed to start job");const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const a=new TextDecoder;let l="";for(;;){const{done:c,value:d}=await s.read();if(c)break;l+=a.decode(d,{stream:!0});const h=l.split(` +`);l=h.pop()||"";for(const u of h)u.startsWith("data: ")&&(yield JSON.parse(u.slice(6)))}},cancel:e=>U(`/jobs/${e}/cancel`,{method:"POST"}),delete:e=>U(`/jobs/${e}`,{method:"DELETE"})},Fo={list:e=>{const t=new URLSearchParams;e!=null&&e.job_id&&t.set("job_id",e.job_id),e!=null&&e.candidate_name&&t.set("candidate_name",e.candidate_name),e!=null&&e.task_name&&t.set("task_name",e.task_name),(e==null?void 0:e.is_pareto)!==void 0&&t.set("is_pareto",String(e.is_pareto));const n=t.toString();return U(`/runs${n?`?${n}`:""}`)},get:e=>U(`/runs/${e}`),getJobSummary:e=>U(`/runs/job/${e}/summary`)},Ts={list:e=>{const t=new URLSearchParams;e!=null&&e.agent_id&&t.set("agent_id",e.agent_id),e!=null&&e.limit&&t.set("limit",String(e.limit));const n=t.toString();return U(`/tests${n?`?${n}`:""}`)},get:e=>U(`/tests/${e}`),create:e=>U("/tests",{method:"POST",body:JSON.stringify(e)}),start:async function*(e){var o;const t={},n=Zs();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Hi}/tests/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Yn(),ir&&ir(),new Error("Not authenticated");if(!r.ok){const c=await r.json().catch(()=>({detail:"Failed to start test"}));throw new Error(c.detail||"Failed to start test")}const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const a=new TextDecoder;let l="";for(;;){const{done:c,value:d}=await s.read();if(c)break;l+=a.decode(d,{stream:!0});const h=l.split(` +`);l=h.pop()||"";for(const u of h)u.startsWith("data: ")&&(yield JSON.parse(u.slice(6)))}},cancel:e=>U(`/tests/${e}/cancel`,{method:"POST"}),delete:e=>U(`/tests/${e}`,{method:"DELETE"})},y0={list:()=>U("/llm-configs"),get:e=>U(`/llm-configs/${e}`),getDefault:()=>U("/llm-configs/default"),create:e=>U("/llm-configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/llm-configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/llm-configs/${e}`,{method:"DELETE"}),setDefault:e=>U(`/llm-configs/${e}/set-default`,{method:"POST"}),test:e=>U(`/llm-configs/${e}/test`,{method:"POST"})},g0={list:()=>U("/tools"),get:e=>U(`/tools/${e}`)},Km={getAgentSchema:()=>U("/schema/agent")},j0={list:()=>U("/deployments"),get:e=>U(`/deployments/${e}`),delete:e=>U(`/deployments/${e}`,{method:"DELETE"})},w0={start:e=>U("/evaluate",{method:"POST",body:JSON.stringify(e)})},Io={design:e=>U("/experiment/design",{method:"POST",body:JSON.stringify(e)}),importYaml:e=>U("/experiment/import-yaml",{method:"POST",body:JSON.stringify(e)}),validate:e=>U("/experiment/validate",{method:"POST",body:JSON.stringify(e)}),generateCandidates:e=>U("/experiment/generate-candidates",{method:"POST",body:JSON.stringify(e)})},qc=Ki((e,t)=>(x0(()=>{e({isAuthenticated:!1,user:null,error:"Session expired. Please log in again."})}),{authConfig:null,isLoadingConfig:!0,isAuthenticated:!1,isLoading:!1,user:null,error:null,loadAuthConfig:async()=>{e({isLoadingConfig:!0});try{const n=await dr.getConfig();if(e({authConfig:n,isLoadingConfig:!1}),n.enabled){const r=Zs(),s=Wc();if(r&&s)try{const a=await dr.getCurrentUser();e({isAuthenticated:!0,user:a})}catch{Yn(),e({isAuthenticated:!1,user:null})}}else e({isAuthenticated:!0,user:{username:"anonymous",auth_mode:"none"}})}catch(n){console.error("Failed to load auth config:",n),e({isLoadingConfig:!1,error:"Failed to connect to server"})}},login:async(n,r)=>{e({isLoading:!0,error:null});try{const s=await dr.login({username:n,password:r});return Od(s.access_token,s.expires_at,s.username),e({isAuthenticated:!0,isLoading:!1,user:{username:s.username,auth_mode:"basic"}}),!0}catch(s){return e({isLoading:!1,error:s instanceof Error?s.message:"Login failed"}),!1}},loginWithGitHub:()=>{window.location.href=dr.getGitHubAuthUrl()},handleOAuthCallback:()=>{const n=new URLSearchParams(window.location.search),r=n.get("auth_error");if(r)return e({error:r}),window.history.replaceState({},"",window.location.pathname),!0;if(n.get("auth_callback")==="true"){const s=n.get("token"),a=n.get("expires_at"),l=n.get("username");return s&&a&&l&&(Od(s,a,l),e({isAuthenticated:!0,user:{username:l,auth_mode:"github"}})),window.history.replaceState({},"",window.location.pathname),!0}return!1},logout:async()=>{try{await dr.logout()}catch{}Yn(),e({isAuthenticated:!1,user:null,error:null})},checkAuth:async()=>{const{authConfig:n}=t();if(!(n!=null&&n.enabled)){e({isAuthenticated:!0});return}if(!Zs()){e({isAuthenticated:!1,user:null});return}try{const s=await dr.getCurrentUser();e({isAuthenticated:!0,user:s})}catch{Yn(),e({isAuthenticated:!1,user:null})}},clearError:()=>e({error:null})}));function Q({variant:e="secondary",size:t="md",className:n="",icon:r,iconRight:s,loading:a=!1,children:l,disabled:o,...c}){const d="font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1.5 rounded-md",h={primary:"bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)]",secondary:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)] hover:bg-[var(--border)]",danger:"bg-[var(--error)] text-white hover:bg-red-600",ghost:"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"},u={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm"},m=t==="sm"?14:16;return i.jsxs("button",{className:`${d} ${h[e]} ${u[t]} ${n}`,disabled:o||a,...c,children:[a?i.jsx(ha,{size:m,className:"animate-spin"}):r?i.jsx(r,{size:m}):null,l,s&&!a&&i.jsx(s,{size:m})]})}const k0={};function S0(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var a;const l=c=>c===null?null:JSON.parse(c,void 0),o=(a=n.getItem(s))!=null?a:null;return o instanceof Promise?o.then(l):l(o)},setItem:(s,a)=>n.setItem(s,JSON.stringify(a,void 0)),removeItem:s=>n.removeItem(s)}}const ea=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return ea(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return ea(r)(n)}}}},N0=(e,t)=>(n,r,s)=>{let a={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:S=>S,version:0,merge:(S,p)=>({...p,...S}),...t},l=!1;const o=new Set,c=new Set;let d;try{d=a.getStorage()}catch{}if(!d)return e((...S)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...S)},r,s);const h=ea(a.serialize),u=()=>{const S=a.partialize({...r()});let p;const f=h({state:S,version:a.version}).then(v=>d.setItem(a.name,v)).catch(v=>{p=v});if(p)throw p;return f},m=s.setState;s.setState=(S,p)=>{m(S,p),u()};const x=e((...S)=>{n(...S),u()},r,s);let k;const g=()=>{var S;if(!d)return;l=!1,o.forEach(f=>f(r()));const p=((S=a.onRehydrateStorage)==null?void 0:S.call(a,r()))||void 0;return ea(d.getItem.bind(d))(a.name).then(f=>{if(f)return a.deserialize(f)}).then(f=>{if(f)if(typeof f.version=="number"&&f.version!==a.version){if(a.migrate)return a.migrate(f.state,f.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return f.state}).then(f=>{var v;return k=a.merge(f,(v=r())!=null?v:x),n(k,!0),u()}).then(()=>{p==null||p(k,void 0),l=!0,c.forEach(f=>f(k))}).catch(f=>{p==null||p(void 0,f)})};return s.persist={setOptions:S=>{a={...a,...S},S.getStorage&&(d=S.getStorage())},clearStorage:()=>{d==null||d.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>g(),hasHydrated:()=>l,onHydrate:S=>(o.add(S),()=>{o.delete(S)}),onFinishHydration:S=>(c.add(S),()=>{c.delete(S)})},g(),k||x},b0=(e,t)=>(n,r,s)=>{let a={storage:S0(()=>localStorage),partialize:g=>g,version:0,merge:(g,S)=>({...S,...g}),...t},l=!1;const o=new Set,c=new Set;let d=a.storage;if(!d)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...g)},r,s);const h=()=>{const g=a.partialize({...r()});return d.setItem(a.name,{state:g,version:a.version})},u=s.setState;s.setState=(g,S)=>{u(g,S),h()};const m=e((...g)=>{n(...g),h()},r,s);s.getInitialState=()=>m;let x;const k=()=>{var g,S;if(!d)return;l=!1,o.forEach(f=>{var v;return f((v=r())!=null?v:m)});const p=((S=a.onRehydrateStorage)==null?void 0:S.call(a,(g=r())!=null?g:m))||void 0;return ea(d.getItem.bind(d))(a.name).then(f=>{if(f)if(typeof f.version=="number"&&f.version!==a.version){if(a.migrate)return[!0,a.migrate(f.state,f.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,f.state];return[!1,void 0]}).then(f=>{var v;const[w,C]=f;if(x=a.merge(C,(v=r())!=null?v:m),n(x,!0),w)return h()}).then(()=>{p==null||p(x,void 0),x=r(),l=!0,c.forEach(f=>f(x))}).catch(f=>{p==null||p(void 0,f)})};return s.persist={setOptions:g=>{a={...a,...g},g.storage&&(d=g.storage)},clearStorage:()=>{d==null||d.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>k(),hasHydrated:()=>l,onHydrate:g=>(o.add(g),()=>{o.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},a.skipHydration||k(),x||m},C0=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((k0?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),N0(e,t)):b0(e,t),Hm=C0,_0=Ki()(Hm((e,t)=>({theme:"light",setTheme:n=>{document.documentElement.setAttribute("data-theme",n),e({theme:n})},toggleTheme:()=>{const n=t().theme==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",n),e({theme:n})}}),{name:"flow-theme",onRehydrateStorage:()=>e=>{e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}}));function E0(){const{theme:e,toggleTheme:t}=_0();return i.jsx("button",{onClick:t,className:"p-2 rounded-md text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--accent)]","aria-label":`Switch to ${e==="dark"?"light":"dark"} mode`,title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:e==="dark"?i.jsx(Bg,{size:16}):i.jsx(Dg,{size:16})})}const P0=Ki()(Hm((e,t)=>({sidebarCollapsed:!1,toggleSidebar:()=>{e({sidebarCollapsed:!t().sidebarCollapsed})},setSidebarCollapsed:n=>{e({sidebarCollapsed:n})}}),{name:"flow-layout"})),T0=[{path:"/agents",label:"Agents",icon:Sg},{path:"/jobs",label:"Experiments",icon:Og},{path:"/tasks",label:"Datasets",icon:Tg}];function O0(){const e=rs(),{sidebarCollapsed:t,toggleSidebar:n}=P0(),r=s=>s==="/agents"?e.pathname==="/"||e.pathname==="/agents"||e.pathname.startsWith("/agents/")||e.pathname.startsWith("/deployments/"):s==="/jobs"?e.pathname.startsWith("/jobs")||e.pathname.startsWith("/runs"):e.pathname.startsWith(s);return i.jsxs("aside",{className:` + flex flex-col border-r border-[var(--border)] bg-[var(--bg-secondary)] + transition-all duration-200 + ${t?"w-14":"w-56"} + `,children:[i.jsx("nav",{className:"flex-1 py-2",children:T0.map(s=>{const a=r(s.path);return i.jsxs(Tm,{to:s.path,title:t?s.label:void 0,className:` + flex items-center gap-3 px-4 py-2.5 text-sm transition-colors relative + ${a?"text-[var(--accent)] bg-[var(--accent-dim)] font-medium":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"} + `,children:[a&&i.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-r bg-[var(--accent)]"}),i.jsx(s.icon,{size:18}),!t&&i.jsx("span",{children:s.label})]},s.path)})}),i.jsx("button",{onClick:n,className:"flex items-center justify-center p-3 border-t border-[var(--border)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",title:t?"Expand sidebar":"Collapse sidebar",children:t?i.jsx(_g,{size:16}):i.jsx(Cg,{size:16})})]})}function L0(){const{authConfig:e,user:t,logout:n}=qc(),r=async()=>{await n()};return i.jsxs("div",{className:"h-screen flex flex-col",children:[i.jsx("header",{className:"border-b border-[var(--border)] bg-[var(--bg-secondary)] shrink-0",children:i.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between",children:[i.jsxs(Tm,{to:"/",className:"text-lg font-semibold text-[var(--accent)] flex items-center gap-2 hover:opacity-80",children:[i.jsx(ma,{size:20}),"Flow",i.jsx("span",{className:"text-[var(--text-secondary)] font-normal",children:"/optimize"})]}),i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(E0,{}),(e==null?void 0:e.enabled)&&t&&i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[i.jsx(Dm,{size:14}),i.jsx("span",{children:t.username})]}),i.jsx(Q,{variant:"ghost",size:"sm",icon:Ig,onClick:r,title:"Sign out",children:"Sign out"})]})]})]})}),i.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[i.jsx(O0,{}),i.jsx("main",{className:"flex-1 overflow-y-auto bg-[var(--bg-primary)]",children:i.jsx("div",{className:"p-6",children:i.jsx(ng,{})})})]})]})}const R0=["maf","miniagent","langgraph"],M0={maf:"Microsoft Agent Framework",miniagent:"MiniAgent",langgraph:"LangGraph"},z0={openai:"OpenAI",azure_openai:"Azure OpenAI",anthropic:"Anthropic",ollama:"Ollama",custom:"Custom (OpenAI-compatible)"};function J({children:e,variant:t="default"}){const n={default:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)]",success:"bg-[var(--badge-success-bg)] text-[var(--badge-success-text)] border border-[var(--badge-success-border)]",warning:"bg-[var(--badge-warning-bg)] text-[var(--badge-warning-text)] border border-[var(--badge-warning-border)]",error:"bg-[var(--badge-error-bg)] text-[var(--badge-error-text)] border border-[var(--badge-error-border)]",info:"bg-[var(--badge-info-bg)] text-[var(--badge-info-text)] border border-[var(--badge-info-border)]"};return i.jsx("span",{className:`inline-block px-2 py-0.5 text-xs font-medium rounded-md ${n[t]}`,children:e})}const F0={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"};function ss({isOpen:e,onClose:t,title:n,children:r,footer:s,size:a="md"}){return j.useEffect(()=>{const l=o=>{o.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",l),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",l),document.body.style.overflow=""}},[e,t]),e?i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[i.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),i.jsxs("div",{className:`relative bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg ${F0[a]} w-full mx-4 max-h-[80vh] flex flex-col`,children:[i.jsxs("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-b border-[var(--border)] px-4 py-3 flex items-center justify-between",children:[i.jsx("h2",{className:"font-semibold",children:n}),i.jsx("button",{onClick:t,className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"×"})]}),i.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r}),s&&i.jsx("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-t border-[var(--border)] px-4 py-3",children:s})]})]}):null}function pn({label:e,className:t="",...n}){return i.jsxs("div",{className:"space-y-1",children:[e&&i.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),i.jsx("input",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] ${t}`,...n})]})}function I0({label:e,className:t="",...n}){return i.jsxs("div",{className:"space-y-1",children:[e&&i.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),i.jsx("textarea",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] resize-y min-h-[100px] ${t}`,...n})]})}function Ni({label:e,className:t="",...n}){return i.jsxs("label",{className:`flex items-center gap-2 cursor-pointer ${t}`,children:[i.jsx("input",{type:"checkbox",className:"w-4 h-4 bg-[var(--bg-primary)] border border-[var(--border)] rounded accent-[var(--accent)]",...n}),i.jsx("span",{className:"text-sm",children:e})]})}function Wm({columns:e,data:t,onRowClick:n,searchable:r=!1,searchPlaceholder:s="Search...",searchFilter:a,emptyMessage:l="No items found",emptyIcon:o}){const[c,d]=j.useState(""),[h,u]=j.useState(null),[m,x]=j.useState("asc"),k=j.useMemo(()=>{let S=t;if(r&&c&&a&&(S=S.filter(p=>a(p,c))),h){const p=e.find(f=>f.key===h);p!=null&&p.sortValue&&(S=[...S].sort((f,v)=>{const w=p.sortValue(f),C=p.sortValue(v),b=wC?1:0;return m==="asc"?b:-b}))}return S},[t,c,a,r,h,m,e]),g=S=>{const p=e.find(f=>f.key===S);p!=null&&p.sortable&&(h===S?x(m==="asc"?"desc":"asc"):(u(S),x("asc")))};return i.jsxs("div",{children:[r&&i.jsxs("div",{className:"mb-4 relative max-w-sm",children:[i.jsx($g,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]"}),i.jsx("input",{type:"text",placeholder:s,value:c,onChange:S=>d(S.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md pl-9 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]"})]}),k.length===0?i.jsxs("div",{className:"text-center py-16 text-[var(--text-secondary)]",children:[o&&i.jsx("div",{className:"mb-3 flex justify-center",children:o}),i.jsx("p",{children:l})]}):i.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsx("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:e.map(S=>i.jsx("th",{onClick:()=>g(S.key),className:`text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider ${S.sortable?"cursor-pointer hover:text-[var(--text-primary)]":""} ${S.className||""}`,children:i.jsxs("span",{className:"inline-flex items-center gap-1",children:[S.header,S.sortable&&h===S.key&&i.jsx("span",{children:m==="asc"?"↑":"↓"})]})},S.key))})}),i.jsx("tbody",{children:k.map((S,p)=>i.jsx("tr",{onClick:()=>n==null?void 0:n(S),className:`border-b border-[var(--border)] last:border-b-0 transition-colors ${n?"cursor-pointer hover:bg-[var(--bg-tertiary)]":""}`,children:e.map(f=>i.jsx("td",{className:`px-4 py-3 ${f.className||""}`,children:f.render(S)},f.key))},p))})]})})]})}function D0({variations:e,onChange:t,strategies:n,availableStrategies:r}){const s=r??Object.keys(n),a=()=>{const d=e.map(x=>x.strategy),h=s.find(x=>!d.includes(x))||"none",u=n[h],m={strategy:h};if(u!=null&&u.params)for(const[x,k]of Object.entries(u.params))k.default!==void 0&&(m[x]=k.default);t([...e,m])},l=d=>{t(e.filter((h,u)=>u!==d))},o=(d,h)=>{t(e.map((u,m)=>m===d?{...u,...h}:u))},c=(d,h)=>{const u=n[h],m={strategy:h};if(u!=null&&u.params)for(const[x,k]of Object.entries(u.params))k.default!==void 0&&(m[x]=k.default);o(d,m)};return i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"text-sm font-medium",children:"Compaction Strategies"}),i.jsx(Q,{type:"button",variant:"ghost",size:"sm",icon:Bc,onClick:a,disabled:e.length>=s.length,children:"Add"})]}),e.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:'No compaction variations. Click "Add" to test different strategies.'}):i.jsx("div",{className:"space-y-2",children:e.map((d,h)=>{const u=n[d.strategy];return i.jsx("div",{className:"p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsxs("div",{className:"flex-1 space-y-2",children:[i.jsx("select",{className:"w-full px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:d.strategy,onChange:m=>c(h,m.target.value),children:s.map(m=>{var x;return i.jsx("option",{value:m,children:((x=n[m])==null?void 0:x.label)||m},m)})}),(u==null?void 0:u.description)&&i.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:u.description}),(u==null?void 0:u.params)&&Object.keys(u.params).length>0&&i.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:Object.entries(u.params).map(([m,x])=>i.jsx(A0,{name:m,schema:x,value:d[m],onChange:k=>o(h,{[m]:k})},m))})]}),i.jsx("button",{type:"button",onClick:()=>l(h),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:i.jsx(Am,{size:16})})]})},h)})})]})}function A0({name:e,schema:t,value:n,onChange:r}){const s=e.replace(/_/g," ");return t.type==="boolean"?i.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[i.jsx("input",{type:"checkbox",checked:!!(n??t.default),onChange:a=>r(a.target.checked),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"capitalize",children:s})]}):i.jsxs("div",{children:[i.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:s}),i.jsx("input",{type:t.type==="number"?"number":"text",className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-xs",value:String(n!==void 0?n:t.default??""),onChange:a=>{if(t.type==="number"){const l=parseFloat(a.target.value);r(isNaN(l)?t.default:l)}else r(a.target.value)},min:t.min,max:t.max,step:t.max&&t.max<=1?.1:1})]})}function $0({variations:e,onChange:t,providers:n}){const r=()=>{const o=n[0],c={provider:(o==null?void 0:o.name)||"azure_openai",model:(o==null?void 0:o.models[0])||"gpt-4o"};t([...e,c])},s=o=>{t(e.filter((c,d)=>d!==o))},a=(o,c)=>{t(e.map((d,h)=>h===o?{...d,...c}:d))},l=(o,c)=>{const d=n.find(h=>h.name===c);a(o,{provider:c,model:(d==null?void 0:d.models[0])||""})};return i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"text-sm font-medium",children:"LLM Configurations"}),i.jsx(Q,{type:"button",variant:"ghost",size:"sm",icon:Bc,onClick:r,children:"Add"})]}),e.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:`Uses agent's default LLM. Click "Add" to test different models.`}):i.jsx("div",{className:"space-y-2",children:e.map((o,c)=>{const d=n.find(h=>h.name===o.provider);return i.jsxs("div",{className:"flex items-center gap-2 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[i.jsx("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.provider,onChange:h=>l(c,h.target.value),children:n.map(h=>i.jsx("option",{value:h.name,children:h.label},h.name))}),d&&d.models.length>0?i.jsxs("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:h=>a(c,{model:h.target.value}),children:[d.models.map(h=>i.jsx("option",{value:h,children:h},h)),!d.models.includes(o.model)&&o.model&&i.jsx("option",{value:o.model,children:o.model})]}):i.jsx("input",{type:"text",className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:h=>a(c,{model:h.target.value}),placeholder:"Model ID"}),i.jsx("button",{type:"button",onClick:()=>s(c),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:i.jsx(Am,{size:16})})]},c)})})]})}const Do={compaction:[],tools:[],llm_config:[],instructions:[],instruction_strategies:[]};function U0({agentId:e,agentName:t,agentFramework:n="maf",taskSuite:r,taskCount:s,schema:a,onVariationsChange:l,parallel:o,onParallelChange:c,budget:d,onBudgetChange:h,useLlmEval:u,onUseLlmEvalChange:m}){const[x,k]=j.useState(Do),[g,S]=j.useState(!1),[p,f]=j.useState(""),[v,w]=j.useState(null),C=a.frameworks[n],b=(C==null?void 0:C.compaction_strategies)||Object.keys(a.compaction_strategies),N=a.tool_presets||[],_=a.llm_providers||[],O=(()=>{let L=1;x.compaction.length>0&&(L*=x.compaction.length),x.tools.length>0&&(L*=x.tools.length),x.llm_config.length>0&&(L*=x.llm_config.length);const K=x.instructions.length+x.instruction_strategies.reduce((ee,R)=>ee+R.max_candidates,0);return K>0&&(L*=K),Math.min(L,d)})(),B=O*s,G=L=>{k(L),l==null||l(L)},re=Je({mutationFn:L=>Io.design(L),onSuccess:L=>{f(L.yaml_content),S(!0)}}),le=Je({mutationFn:L=>Io.validate(L),onSuccess:L=>{w({valid:L.valid,errors:L.errors,warnings:L.warnings})}}),D=()=>({base_agent_id:e,task_suite:r,variations:x,parallel:o,budget:d,use_llm_eval:u}),q=()=>{re.mutate(D())},X=()=>{le.mutate(D())},P=()=>{const L=new Blob([p],{type:"text/yaml"}),K=URL.createObjectURL(L),ee=document.createElement("a");ee.href=K,ee.download=`${t}_experiment.yaml`,ee.click(),URL.revokeObjectURL(K)},A=x.compaction.length>0||x.tools.length>0||x.llm_config.length>0||x.instructions.length>0||x.instruction_strategies.length>0;return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex flex-wrap gap-2",children:[i.jsxs(J,{variant:"info",children:[O," candidates"]}),i.jsxs(J,{children:[s," tasks"]}),i.jsxs(J,{variant:B>100?"warning":"success",children:[B," total runs"]})]}),i.jsx(D0,{variations:x.compaction,onChange:L=>G({...x,compaction:L}),strategies:a.compaction_strategies,availableStrategies:b}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("label",{className:"text-sm font-medium",children:"Tool Presets"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(L=>i.jsxs("label",{className:`flex items-center gap-2 px-3 py-1.5 border rounded cursor-pointer transition-colors ${x.tools.includes(L.name)?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[i.jsx("input",{type:"checkbox",checked:x.tools.includes(L.name),onChange:K=>{const ee=K.target.checked?[...x.tools,L.name]:x.tools.filter(R=>R!==L.name);G({...x,tools:ee})},className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:L.name}),i.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",L.tools.length,")"]})]},L.name))}),x.tools.length>0&&i.jsxs("p",{className:"text-xs text-[var(--text-secondary)]",children:["Selected: ",x.tools.join(", ")]})]}),i.jsx($0,{variations:x.llm_config,onChange:L=>G({...x,llm_config:L}),providers:_}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-4 space-y-4",children:[i.jsx("h4",{className:"text-sm font-medium",children:"Execution Settings"}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(pn,{label:"Parallel Workers",type:"number",value:o,onChange:L=>c(parseInt(L.target.value)||1),min:1,max:16}),i.jsx(pn,{label:"Budget (max candidates)",type:"number",value:d,onChange:L=>h(parseInt(L.target.value)||100),min:1,max:1e3})]}),i.jsx(Ni,{label:"Use LLM evaluation",checked:u,onChange:L=>m(L.target.checked)}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] ml-6 -mt-2",children:u?"LLM-as-Judge scores task completion (0-1)":"Simple pass/fail based on task success"})]}),i.jsxs("div",{className:"flex items-center gap-2 border-t border-[var(--border)] pt-4",children:[i.jsx(Q,{variant:"secondary",size:"sm",onClick:X,loading:le.isPending,children:"Validate"}),i.jsx(Q,{variant:"secondary",size:"sm",icon:Cd,onClick:q,loading:re.isPending,children:"Export YAML"})]}),v&&i.jsxs("div",{className:`p-3 rounded border ${v.valid?"border-green-500/50 bg-green-500/10":"border-red-500/50 bg-red-500/10"}`,children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[v.valid?i.jsx(Lm,{size:16,className:"text-green-500"}):i.jsx(Om,{size:16,className:"text-red-500"}),i.jsx("span",{className:"font-medium text-sm",children:v.valid?"Configuration valid":"Configuration has issues"})]}),v.errors.length>0&&i.jsx("ul",{className:"text-sm text-red-500 list-disc ml-6",children:v.errors.map((L,K)=>i.jsx("li",{children:L},K))}),v.warnings.length>0&&i.jsx("ul",{className:"text-sm text-yellow-500 list-disc ml-6 mt-1",children:v.warnings.map((L,K)=>i.jsx("li",{children:L},K))})]}),g&&i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-lg shadow-xl max-w-2xl w-full max-h-[80vh] flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border)]",children:[i.jsx("h3",{className:"font-medium",children:"Experiment YAML"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Q,{variant:"secondary",size:"sm",icon:Cd,onClick:P,children:"Download"}),i.jsx(Q,{variant:"ghost",size:"sm",onClick:()=>S(!1),children:"Close"})]})]}),i.jsx("pre",{className:"flex-1 overflow-auto p-4 text-xs font-mono bg-[var(--bg-secondary)]",children:p})]})}),!A&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No variations selected. Only the baseline agent will be tested. Add compaction strategies, tool presets, or LLM configs to generate candidates."})]})}function qm({agent:e,isOpen:t,onClose:n}){var R;const r=cr(),s=qt(),[a,l]=j.useState("ready"),[o,c]=j.useState("quick"),[d,h]=j.useState(!1),[u,m]=j.useState([]),[x,k]=j.useState(!1),[g,S]=j.useState(Do),[p,f]=j.useState(4),[v,w]=j.useState(100),[C,b]=j.useState(!1),[N,_]=j.useState(null),{data:F=[]}=he({queryKey:["tasks"],queryFn:()=>Et.list()}),{data:O=[]}=he({queryKey:["suites"],queryFn:()=>Et.listSuites()}),{data:B}=he({queryKey:["agent-schema"],queryFn:()=>Km.getAgentSchema()}),G=O.map(T=>({value:T.name,label:T.name.charAt(0).toUpperCase()+T.name.slice(1),description:T.description,tasks:T.task_count})),re=Je({mutationFn:Et.importSuite,onSuccess:T=>{s.invalidateQueries({queryKey:["tasks"]}),m(T.map(te=>te.id))}}),le=Je({mutationFn:async T=>{const te=await Ut.create(T);return Ut.start(te.id).next(),te},onSuccess:T=>{s.invalidateQueries({queryKey:["jobs"]}),_(T.id),l("success")}}),q=x?(()=>{let T=1;g.compaction.length>0&&(T*=g.compaction.length),g.tools.length>0&&(T*=g.tools.length),g.llm_config.length>0&&(T*=g.llm_config.length);const te=g.instructions.length+g.instruction_strategies.reduce((pe,be)=>pe+be.max_candidates,0);return te>0&&(T*=te),Math.min(T,v)})():1,X=d?u.length:((R=G.find(T=>T.value===o))==null?void 0:R.tasks)||3,P=q*X,A=async()=>{l("starting");let T=u;if(!d)try{T=(await re.mutateAsync(o)).map(H=>H.id)}catch(M){console.error("Failed to import suite:",M),alert(`Failed to import task suite: ${o}`),l("ready");return}if(T.length===0){alert("No tasks selected. Please select tasks or choose a task suite."),l("ready");return}let te;if(x&&(g.compaction.length>0||g.tools.length>0||g.llm_config.length>0||g.instructions.length>0||g.instruction_strategies.length>0))try{te=(await Io.generateCandidates({base_agent_id:e.id,variations:g,budget:v})).candidate_ids}catch(M){console.error("Failed to generate candidates:",M),alert(`Failed to generate candidates: ${M instanceof Error?M.message:"Unknown error"}`),l("ready");return}else te=[e.id];const be={name:`${e.name} optimization (${te.length} candidates × ${T.length} tasks)`,candidate_ids:te,task_ids:T,parallel:p,use_llm_eval:C};le.mutate(be)},L=T=>{m(te=>te.includes(T)?te.filter(pe=>pe!==T):[...te,T])},K=()=>{l("ready"),_(null),k(!1),S(Do),n()},ee=()=>a==="success"&&N?i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsx(Q,{variant:"secondary",onClick:K,children:"Close"}),i.jsx(Q,{variant:"primary",icon:Xs,onClick:()=>{K(),r(`/jobs/${N}`)},children:"View Job"})]}):a==="starting"?null:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(Q,{variant:"secondary",onClick:n,children:"Cancel"}),i.jsxs(Q,{variant:"primary",icon:Xs,onClick:A,disabled:d&&u.length===0,children:["Start Optimization (",P," runs)"]})]});return i.jsx(ss,{isOpen:t,onClose:K,title:`Optimize: ${e.name}`,footer:ee(),size:"lg",children:a==="success"&&N?i.jsxs("div",{className:"flex flex-col items-center py-8",children:[i.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/20 flex items-center justify-center mb-4",children:i.jsx(ma,{size:24,className:"text-green-500"})}),i.jsx("h3",{className:"text-lg font-medium mb-2",children:"Job Started!"}),i.jsx("p",{className:"text-[var(--text-secondary)] text-center mb-2",children:"Optimization job is now running"}),i.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-3 py-1.5 rounded font-mono",children:["ID: ",N.slice(0,8),"..."]})]}):a==="starting"?i.jsxs("div",{className:"flex flex-col items-center py-8",children:[i.jsx(ha,{size:32,className:"animate-spin text-[var(--accent)] mb-4"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:re.isPending?"Importing tasks...":"Creating optimization job..."})]}):i.jsxs("div",{className:"space-y-5",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Task Suite"}),i.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:d?"__custom__":o,onChange:T=>{T.target.value==="__custom__"?h(!0):(h(!1),c(T.target.value))},children:[G.map(T=>i.jsxs("option",{value:T.value,children:[T.label," (",T.tasks," tasks) — ",T.description]},T.value)),F.length>0&&i.jsx("option",{value:"__custom__",children:"Custom Selection"})]})]}),d&&F.length>0&&i.jsx("div",{className:"max-h-48 overflow-y-auto border border-[var(--border)] rounded p-2 space-y-1",children:F.map(T=>i.jsxs("label",{className:"flex items-center gap-2 p-2 hover:bg-[var(--bg-tertiary)] cursor-pointer rounded",children:[i.jsx("input",{type:"checkbox",checked:u.includes(T.id),onChange:()=>L(T.id),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:T.name}),T.suite&&i.jsx(J,{children:T.suite})]},T.id))}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[i.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>k(!x),children:[i.jsx(Ys,{size:14,className:`transition-transform ${x?"rotate-90":""}`}),"Advanced Settings",x&&i.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"(experiment design, variations, execution)"})]}),x&&B&&i.jsx("div",{className:"mt-4",children:i.jsx(U0,{agentId:e.id,agentName:e.name,agentFramework:e.config.framework,taskSuite:d?void 0:o,taskCount:X,schema:B,onVariationsChange:S,parallel:p,onParallelChange:f,budget:v,onBudgetChange:w,useLlmEval:C,onUseLlmEvalChange:b})})]})]})})}function Ld(){const e=cr(),t=qt(),[n,r]=j.useState(!1),[s,a]=j.useState(null),{data:l=[],isLoading:o}=he({queryKey:["configs"],queryFn:()=>Xn.list()}),c=Je({mutationFn:Xn.create,onSuccess:()=>{t.invalidateQueries({queryKey:["configs"]}),r(!1)}}),d=Je({mutationFn:Xn.delete,onSuccess:()=>t.invalidateQueries({queryKey:["configs"]})}),h=[{key:"name",header:"Name",render:u=>i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:u.name})},{key:"framework",header:"Framework",render:u=>i.jsx(J,{children:u.config.framework||"maf"})},{key:"tools",header:"Tools",render:u=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:B0(u.config.tools)})},{key:"compaction",header:"Compaction",render:u=>{const m=u.config.compaction;return!m||m.strategy==="none"?i.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"}):m.strategy==="head_tail"?i.jsxs(J,{children:[m.params.head_size,"/",m.params.tail_size]}):i.jsx(J,{children:m.strategy})}},{key:"created",header:"Created",render:u=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(u.created_at).toLocaleDateString()}),sortable:!0,sortValue:u=>new Date(u.created_at).getTime()},{key:"actions",header:"",className:"w-40",render:u=>i.jsxs("div",{className:"flex items-center gap-2",onClick:m=>m.stopPropagation(),children:[i.jsx(Q,{variant:"primary",size:"sm",icon:ma,onClick:()=>a(u),children:"Optimize"}),i.jsx(Q,{variant:"ghost",size:"sm",icon:Qc,title:"Delete",onClick:()=>{confirm(`Delete agent "${u.name}"?`)&&d.mutate(u.id)}})]})}];return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Agents"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Define and optimize your agent configurations."})]}),i.jsx(Q,{variant:"primary",icon:Bc,onClick:()=>r(!0),children:"Create agent"})]}),o?i.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[i.jsx(ha,{size:16,className:"animate-spin"}),"Loading agents..."]}):i.jsx(Wm,{columns:h,data:l,onRowClick:u=>e(`/agents/${u.id}`),searchable:!0,searchPlaceholder:"Search agents",searchFilter:(u,m)=>u.name.toLowerCase().includes(m.toLowerCase())||(u.description||"").toLowerCase().includes(m.toLowerCase()),emptyMessage:"No agents yet. Create your first agent to start optimizing.",emptyIcon:i.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-[var(--bg-tertiary)]",children:i.jsx(Im,{size:24,className:"text-[var(--text-secondary)]"})})}),i.jsx(Q0,{isOpen:n,onClose:()=>r(!1),onSubmit:u=>c.mutate(u),isLoading:c.isPending}),s&&i.jsx(qm,{agent:s,isOpen:!!s,onClose:()=>a(null)})]})}function B0(e){return typeof e=="string"?e:Array.isArray(e)?`[${e.length}]`:e&&typeof e=="object"?`[${Object.keys(e).length}]`:"standard"}function Q0({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){var K,ee,R,T,te,pe,be;const s=["read_file","write_file","edit_file","bash","grep","think"],[a,l]=j.useState("preset"),[o,c]=j.useState({name:"",description:"",instructions:null,model:null,compaction:{strategy:"none",params:{}},tools:s,framework:"miniagent",llm_config_id:null}),[d,h]=j.useState(!1),[u,m]=j.useState("preset"),[x,k]=j.useState([...s]),[g,S]=j.useState(!1),{data:p}=he({queryKey:["agent-schema"],queryFn:()=>Km.getAgentSchema()}),{data:f=[]}=he({queryKey:["llm-configs"],queryFn:()=>y0.list()}),{data:v}=he({queryKey:["tools"],queryFn:()=>g0.list()}),w=((K=v==null?void 0:v.tools)==null?void 0:K.map(M=>M.name))??s,C=(v==null?void 0:v.presets)??{},b=Object.keys(C),N=(p==null?void 0:p.frameworks)??{},_=Object.keys(N).length>0?Object.keys(N):R0,F=o.framework||"miniagent",O=((R=(ee=p==null?void 0:p.frameworks)==null?void 0:ee[F])==null?void 0:R.compaction_strategies)??["none","head_tail"],B=(p==null?void 0:p.compaction_strategies)??{},G=(p==null?void 0:p.agent_presets)??[],re=M=>{const H=M.config,dt=H.compaction;n({name:M.name+"-agent",description:M.description,framework:H.framework||"miniagent",tools:H.tools||"standard",compaction:dt||{strategy:"none",params:{}},instructions:H.instructions||null})},le=M=>{if(M.preventDefault(),!o.name.trim())return;const H={...o};u==="custom"&&(H.tools=x),n(H)},D=((T=o.compaction)==null?void 0:T.strategy)!=="none",q=((te=o.compaction)==null?void 0:te.strategy)||"none",X=B[q],P=M=>{k(H=>H.includes(M)?H.filter(dt=>dt!==M):[...H,M])},A=M=>{const H=B[M],dt={};if(H!=null&&H.params)for(const[as,is]of Object.entries(H.params))is.default!==void 0&&(dt[as]=is.default);c({...o,compaction:{strategy:M,params:dt}})},L=a==="custom"?i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(Q,{type:"submit",form:"create-agent-form",variant:"primary",disabled:!o.name.trim(),loading:r,children:"Create Agent"})]}):i.jsx("div",{className:"flex justify-end gap-2",children:i.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"})});return i.jsxs(ss,{isOpen:e,onClose:t,title:"Create Agent",footer:L,children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b border-[var(--border)]",children:[i.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${a==="preset"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("preset"),children:"From Preset"}),i.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${a==="custom"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("custom"),children:"Custom"})]}),a==="preset"?i.jsx("div",{className:"space-y-3",children:G.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"Loading presets..."}):G.map(M=>i.jsx("button",{type:"button",className:"w-full text-left p-4 border border-[var(--border)] rounded-lg hover:border-[var(--accent)] hover:bg-[var(--accent)]/5 transition-colors",onClick:()=>re(M),disabled:r,children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("h4",{className:"font-medium",children:M.label}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:M.description}),i.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[M.tags.map(H=>i.jsx(J,{variant:"default",children:H},H)),M.suggested_datasets.length>0&&i.jsxs(J,{variant:"success",children:["datasets: ",M.suggested_datasets.join(", ")]})]})]}),i.jsx(Ys,{size:16,className:"text-[var(--text-secondary)] mt-1 flex-shrink-0"})]})},M.name))}):i.jsxs("form",{id:"create-agent-form",onSubmit:le,className:"space-y-4",children:[i.jsx(pn,{label:"Name",value:o.name,onChange:M=>c({...o,name:M.target.value}),placeholder:"e.g., my-coding-agent",required:!0}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"LLM Configuration"}),i.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.llm_config_id||"",onChange:M=>c({...o,llm_config_id:M.target.value||null}),children:[i.jsx("option",{value:"",children:"Use environment variables"}),f.map(M=>i.jsxs("option",{value:M.id,children:[M.name," (",z0[M.provider],M.model_id?` - ${M.model_id}`:"",")",M.is_default?" (default)":""]},M.id))]}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:f.length===0?"No LLM configs found. Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)":o.llm_config_id?"Uses the selected LLM configuration.":"Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Framework"}),i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.framework||"miniagent",onChange:M=>{const H=M.target.value;c({...o,framework:H,compaction:{strategy:"none",params:{}}})},children:_.map(M=>{var H;return i.jsx("option",{value:M,children:((H=N[M])==null?void 0:H.label)||M0[M]||M},M)})}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((pe=N[F])==null?void 0:pe.description)||(F==="miniagent"?"Lightweight agent with token-aware context management.":F==="langgraph"?"Graph-based workflows with state management.":"Default agent implementation.")})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(Ni,{label:"Custom instructions",checked:d,onChange:M=>{h(M.target.checked),M.target.checked||c({...o,instructions:null})}}),i.jsx(Ni,{label:"Enable compaction",checked:D,onChange:M=>{if(M.target.checked){const H=O.find(dt=>dt!=="none")||"head_tail";A(H)}else c({...o,compaction:{strategy:"none",params:{}}})}})]}),d&&i.jsx("textarea",{className:"w-full h-32 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono resize-y",value:o.instructions||"",onChange:M=>c({...o,instructions:M.target.value||null}),placeholder:"System prompt / instructions for the agent..."}),D&&i.jsxs("div",{className:"space-y-3 p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Compaction Strategy"}),i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:q,onChange:M=>A(M.target.value),children:O.filter(M=>M!=="none").map(M=>{var H;return i.jsx("option",{value:M,children:((H=B[M])==null?void 0:H.label)||M},M)})}),(X==null?void 0:X.description)&&i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:X.description})]}),(X==null?void 0:X.params)&&Object.keys(X.params).length>0&&i.jsx("div",{className:"grid grid-cols-2 gap-3",children:Object.entries(X.params).map(([M,H])=>{var is;const dt=(is=o.compaction)==null?void 0:is.params[M],as=dt!==void 0?dt:H.default;return i.jsxs("div",{children:[i.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:M.replace(/_/g," ")}),i.jsx("input",{type:"number",className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof as=="number"?as:Number(as)||0,onChange:tp=>{const Jc=parseFloat(tp.target.value);c({...o,compaction:{...o.compaction,params:{...o.compaction.params,[M]:isNaN(Jc)?typeof H.default=="number"?H.default:0:Jc}}})},min:H.min,max:H.max,step:H.max&&H.max<=1?.1:1}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:H.description})]},M)})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm font-medium",children:"Tools"}),i.jsxs("div",{className:"flex gap-4",children:[i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"radio",checked:u==="preset",onChange:()=>m("preset"),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:"Preset"})]}),i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"radio",checked:u==="custom",onChange:()=>m("custom"),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:"Custom"})]})]}),u==="preset"?i.jsxs(i.Fragment,{children:[i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof o.tools=="string"?o.tools:"standard",onChange:M=>c({...o,tools:M.target.value}),children:b.map(M=>i.jsx("option",{value:M,children:M},M))}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((be=C[typeof o.tools=="string"?o.tools:"standard"])==null?void 0:be.join(", "))??""})]}):i.jsx("div",{className:"grid grid-cols-2 gap-1 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:w.map(M=>i.jsxs("label",{className:"flex items-center gap-2 p-1 text-sm cursor-pointer hover:bg-[var(--bg-tertiary)]",children:[i.jsx("input",{type:"checkbox",checked:x.includes(M),onChange:()=>P(M),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"font-mono text-xs",children:M})]},M))})]}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[i.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>S(!g),children:[i.jsx(Ys,{size:14,className:`transition-transform ${g?"rotate-90":""}`}),"More options"]}),g&&i.jsx("div",{className:"mt-3",children:i.jsx(pn,{label:"Description (optional)",value:o.description,onChange:M=>c({...o,description:M.target.value}),placeholder:"Brief description of this agent"})})]})]})]})}function pa({items:e}){return i.jsx("nav",{className:"flex items-center gap-1.5 text-sm mb-4",children:e.map((t,n)=>{const r=n===e.length-1;return i.jsxs("span",{className:"flex items-center gap-1.5",children:[n>0&&i.jsx(Ys,{size:14,className:"text-[var(--text-secondary)]"}),t.path&&!r?i.jsx(Pn,{to:t.path,className:"text-[var(--text-secondary)] hover:text-[var(--accent)] transition-colors",children:t.label}):i.jsx("span",{className:r?"text-[var(--text-primary)] font-medium":"text-[var(--text-secondary)]",children:t.label})]},n)})})}function ge({children:e,className:t="",onClick:n,selected:r=!1,selectable:s=!1}){const a="bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",l=s?"cursor-pointer hover:border-[var(--accent-dim)] transition-colors":"",o=r?"border-[var(--accent)]":"";return i.jsx("div",{className:`${a} ${l} ${o} ${t}`,onClick:n,children:e})}function V0(e){const t=[],n=r=>r.type==="trace_span"&&typeof r.data=="object"&&r.data!==null?r.data:"span_id"in r?r:null;if(Array.isArray(e.spans)){for(const r of e.spans)if(typeof r=="object"&&r!==null){const s=n(r);s&&t.push(s)}}else if(e.span_id)t.push(e);else for(const r in e){const s=e[r];if(typeof s=="object"&&s!==null){const a=n(s);if(a)t.push(a);else if(Array.isArray(s)){for(const l of s)if(typeof l=="object"&&l!==null){const o=n(l);o&&t.push(o)}}}}return t}function Gm(e){const t=new Map,n=[];for(const s of e)t.set(s.span_id,{span:s,children:[]});for(const s of e){const a=t.get(s.span_id);s.parent_span_id&&t.has(s.parent_span_id)?t.get(s.parent_span_id).children.push(a):n.push(a)}const r=s=>{s.sort((a,l)=>(a.span.start_time||0)-(l.span.start_time||0)),s.forEach(a=>r(a.children))};return r(n),n}function K0(e){return e.includes("Agent")||e.includes("agent")?"bg-[var(--span-llm-bg)] text-[var(--span-llm-text)]":e.includes("chat")||e.includes("Chat")||e.includes("llm")?"bg-[var(--span-tool-bg)] text-[var(--span-tool-text)]":e.includes("tool")||e.includes("execute")||e.includes("bash")?"bg-[var(--span-agent-bg)] text-[var(--span-agent-text)]":"bg-[var(--span-other-bg)] text-[var(--span-other-text)]"}function H0(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(0)}ms`}function Gc({node:e,depth:t=0}){var u,m;const[n,r]=j.useState(t<2),[s,a]=j.useState(!1),{span:l}=e,o=e.children.length>0,c=(u=l.attributes)==null?void 0:u["gen_ai.usage.input_tokens"],d=(m=l.attributes)==null?void 0:m["gen_ai.usage.output_tokens"],h=c!==void 0||d!==void 0;return i.jsxs("div",{className:"relative",children:[t>0&&i.jsx("div",{className:"absolute left-0 top-0 bottom-0 border-l-2 border-[var(--border)]",style:{marginLeft:`${(t-1)*16+8}px`}}),i.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-1 hover:bg-[var(--bg-primary)] rounded transition-colors cursor-pointer",style:{paddingLeft:`${t*16}px`},onClick:()=>o?r(!n):a(!s),children:[i.jsx("div",{className:"w-4 h-4 flex items-center justify-center text-[var(--text-secondary)]",children:o?n?"▼":"▶":s?"▼":"▶"}),i.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${K0(l.operation_name)}`,children:l.operation_name.replace("ChatAgent.","").replace("invoke_agent ","")}),l.duration_ms!==void 0&&i.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:H0(l.duration_ms)}),h&&i.jsxs("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:[c!==void 0&&i.jsxs("span",{className:"text-blue-400",children:["↑",String(c)]}),c!==void 0&&d!==void 0&&i.jsx("span",{className:"mx-0.5",children:"/"}),d!==void 0&&i.jsxs("span",{className:"text-green-400",children:["↓",String(d)]})]})]}),s&&!o&&i.jsx("div",{className:"ml-4 mt-1 mb-2 p-2 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs",style:{marginLeft:`${t*16+20}px`},children:i.jsxs("div",{className:"space-y-1",children:[l.span_id&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Span ID:"}),i.jsx("span",{className:"font-mono text-xs break-all",children:l.span_id})]}),l.trace_id&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Trace ID:"}),i.jsx("span",{className:"font-mono text-xs break-all",children:l.trace_id})]}),l.status&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Status:"}),i.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs ${l.status==="OK"||l.status==="StatusCode.UNSET"?"bg-[var(--span-pass-bg)] text-[var(--span-pass-text)]":"bg-[var(--span-fail-bg)] text-[var(--span-fail-text)]"}`,children:l.status})]}),Object.keys(l.attributes||{}).length>0&&i.jsxs("div",{className:"mt-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] block mb-1",children:"Attributes:"}),i.jsx("pre",{className:"text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded p-2 overflow-auto max-h-32 whitespace-pre-wrap break-all",children:JSON.stringify(l.attributes,null,2)})]})]})}),o&&n&&i.jsx("div",{children:e.children.map((x,k)=>i.jsx(Gc,{node:x,depth:t+1},x.span.span_id||k))})]})}function Jm({trace:e}){const[t,n]=j.useState("tree"),r=j.useMemo(()=>V0(e),[e]),s=j.useMemo(()=>Gm(r),[r]);return Object.keys(e).length===0?null:i.jsxs(ge,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"font-medium",children:"Trace Data"}),i.jsxs("div",{className:"flex gap-1",children:[i.jsx("button",{onClick:()=>n("tree"),className:`px-2 py-1 text-xs rounded ${t==="tree"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Tree"}),i.jsx("button",{onClick:()=>n("raw"),className:`px-2 py-1 text-xs rounded ${t==="raw"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Raw"})]})]}),t==="tree"?r.length>0?i.jsx("div",{className:"border border-[var(--border)] rounded overflow-hidden",children:i.jsxs("div",{className:"p-2",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs(J,{variant:"default",children:[r.length," spans"]}),i.jsx("span",{children:"•"}),i.jsx("span",{children:"Click to expand details"})]}),s.map((a,l)=>i.jsx(Gc,{node:a,depth:0},a.span.span_id||l))]})}):i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No structured spans found. View raw data below."}):i.jsx("pre",{className:"text-xs bg-[var(--bg-primary)] p-3 overflow-x-auto border border-[var(--border)] max-h-96 whitespace-pre-wrap",children:JSON.stringify(e,null,2)})]})}function W0({spans:e,isLive:t=!1}){const n=j.useRef(null),r=j.useMemo(()=>Gm(e),[e]);return j.useEffect(()=>{n.current&&t&&n.current.scrollTo({top:n.current.scrollHeight,behavior:"smooth"})},[e.length,t]),i.jsxs("div",{className:"border border-[var(--border)] rounded overflow-hidden h-full flex flex-col",children:[i.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-[var(--border)] bg-[var(--bg-secondary)]",children:[i.jsxs(J,{variant:"default",children:[e.length," spans"]}),t&&i.jsx("span",{className:"animate-pulse",children:i.jsx(J,{variant:"info",children:"Live"})})]}),i.jsx("div",{ref:n,className:"flex-1 overflow-auto p-2",children:r.length>0?r.map((s,a)=>i.jsx(Gc,{node:s,depth:0},s.span.span_id||a)):i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:t?"Waiting for spans...":"No spans recorded"})})]})}function Ym({agent:e}){const[t,n]=j.useState(""),[r,s]=j.useState(null),[a,l]=j.useState("idle"),[o,c]=j.useState(null),[d,h]=j.useState(""),[u,m]=j.useState([]),[x,k]=j.useState(null),[g,S]=j.useState(null),[p,f]=j.useState([]),[v,w]=j.useState(!1),C=j.useRef(null),{data:b=[]}=he({queryKey:["tasks"],queryFn:()=>Et.list()});j.useEffect(()=>{C.current&&a==="running"&&(C.current.scrollTop=C.current.scrollHeight)},[d,a]);const N=D=>{if(s(D),D){const q=b.find(X=>X.id===D);q&&n(q.prompt)}},_=async()=>{if(t.trim()){l("running"),h(""),m([]),k(null),S(null),f([]);try{const D=await Ts.create({agent_id:e.id,prompt:t.trim(),task_id:r||void 0});c(D.id);for await(const q of Ts.start(D.id))F(q)}catch(D){S(D instanceof Error?D.message:"Test failed"),l("failed")}}},F=D=>{switch(D.event){case"started":break;case"execution":D.execution_event==="text_delta"&&D.content?h(q=>q+D.content):D.execution_event==="tool_call_start"&&D.tool_name?f(q=>[...q,{name:D.tool_name}]):D.execution_event==="tool_result"&&D.content&&f(q=>{if(q.length>0){const X=[...q];return X[X.length-1]={...X[X.length-1],content:D.content},X}return q});break;case"span":if(D.span){const q=D.span;if(q.data){const X={span_id:q.data.span_id||"",trace_id:q.data.trace_id||"",parent_span_id:q.data.parent_span_id||null,operation_name:q.data.operation_name||"",start_time:q.timestamp?new Date(q.timestamp).getTime():Date.now(),end_time:Date.now(),duration_ms:q.data.duration_ms||0,status:q.data.status||"OK",attributes:q.data.attributes||{}};m(P=>[...P,X])}}break;case"complete":l("completed"),D.result&&k(D.result);break;case"error":S(D.message),l("failed");break}},O=async()=>{if(o)try{await Ts.cancel(o)}catch{}l("idle")},B=()=>{l("idle"),c(null),h(""),m([]),k(null),S(null),f([])},G=a==="running",re=a==="completed"||a==="failed",le=D=>{D.preventDefault(),re?(B(),setTimeout(()=>_(),0)):_()};return i.jsxs("div",{className:"h-full flex flex-col border border-[var(--border)] rounded-lg overflow-hidden bg-[var(--bg-primary)]",children:[(G||re)&&i.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border)] bg-[var(--bg-secondary)] flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[G&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"animate-pulse",children:i.jsx(J,{variant:"info",children:"Running"})}),i.jsx(Q,{variant:"ghost",size:"sm",icon:_d,onClick:O,children:"Cancel"})]}),a==="completed"&&i.jsx(J,{variant:"success",children:"Completed"}),a==="failed"&&i.jsx(J,{variant:"error",children:"Failed"})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[x&&i.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Rm,{size:12}),x.duration_seconds.toFixed(2),"s"]}),i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Eg,{size:12}),x.tokens_total," tokens"]}),x.passed!==null&&(x.passed?i.jsx(Lm,{size:14,className:"text-[var(--success)]"}):i.jsx(Vg,{size:14,className:"text-[var(--error)]"}))]}),u.length>0&&i.jsxs(Q,{variant:v?"primary":"secondary",size:"sm",icon:jg,onClick:()=>w(!v),children:["Traces (",u.length,")"]}),re&&o&&i.jsx(Pn,{to:`/tests/${o}`,children:i.jsx(Q,{variant:"secondary",size:"sm",icon:Mm,children:"Details"})})]})]}),i.jsxs("div",{className:"flex-1 min-h-0 flex",children:[i.jsx("div",{ref:C,className:`flex-1 overflow-auto p-4 ${v?"border-r border-[var(--border)]":""}`,children:!G&&!re?i.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center",children:[i.jsx("div",{className:"text-lg font-medium mb-1",children:e.name}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] max-w-sm",children:"Send a message to test this agent, or select a task from the dropdown below."})]}):i.jsxs("div",{className:"space-y-3",children:[i.jsx("div",{className:"flex justify-end",children:i.jsx("div",{className:"max-w-[80%] px-3 py-2 bg-[var(--accent-dim)] text-[var(--text-primary)] rounded-lg text-sm",children:t})}),(d||G)&&i.jsx("div",{className:"px-3 py-2 text-sm whitespace-pre-wrap font-mono bg-[var(--bg-secondary)] rounded-lg border border-[var(--border)]",children:d||i.jsx("span",{className:"text-[var(--text-secondary)] animate-pulse",children:"Thinking..."})}),p.length>0&&i.jsx("div",{className:"space-y-1.5",children:p.map((D,q)=>i.jsxs("div",{className:"p-2 bg-[var(--badge-info-bg)] border border-[var(--badge-info-border)] rounded-md text-xs",children:[i.jsx(J,{variant:"info",children:D.name}),D.content&&i.jsxs("div",{className:"mt-1 text-[var(--text-secondary)] truncate max-w-full font-mono",children:[D.content.substring(0,200),D.content.length>200&&"..."]})]},q))}),g&&i.jsx("div",{className:"p-3 bg-[var(--badge-error-bg)] border border-[var(--badge-error-border)] rounded-md text-sm text-[var(--badge-error-text)]",children:g})]})}),v&&i.jsx("div",{className:"w-[350px] flex-shrink-0 overflow-auto",children:i.jsx(W0,{spans:u,isLive:G})})]}),i.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] bg-[var(--bg-secondary)]",children:[i.jsx("div",{className:"px-4 pt-2",children:i.jsxs("select",{value:r||"",onChange:D=>N(D.target.value||null),className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs text-[var(--text-secondary)]",disabled:G,children:[i.jsx("option",{value:"",children:"Custom prompt..."}),b.map(D=>i.jsx("option",{value:D.id,children:D.name},D.id))]})}),i.jsxs("form",{onSubmit:le,className:"p-3 flex gap-2",children:[i.jsx("textarea",{value:t,onChange:D=>n(D.target.value),placeholder:"Message the agent...",disabled:G,rows:1,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm resize-none min-h-[40px] max-h-[120px] focus:outline-none focus:border-[var(--accent)]",onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),le(D))}}),i.jsx(Q,{type:"submit",variant:"primary",icon:G?_d:Xs,disabled:G?!1:!t.trim(),onClick:G?O:void 0,children:G?"Stop":re?"New Test":"Run"})]})]})]})}function q0(){const{agentId:e}=fa(),t=cr(),n=qt(),[r,s]=j.useState("overview"),[a,l]=j.useState(!1),{data:o,isLoading:c}=he({queryKey:["configs",e],queryFn:()=>Xn.get(e),enabled:!!e}),{data:d=[]}=he({queryKey:["tests",{agent_id:e}],queryFn:()=>Ts.list({agent_id:e}),enabled:!!e}),{data:h=[]}=he({queryKey:["jobs"],queryFn:()=>Ut.list()}),u=Je({mutationFn:x=>Xn.delete(x),onSuccess:()=>{n.invalidateQueries({queryKey:["configs"]}),t("/agents")}}),m=h.filter(x=>x.candidate_ids.includes(e||""));return c?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):o?i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"mb-4 flex-shrink-0",children:[i.jsx(pa,{items:[{label:"Agents",path:"/agents"},{label:o.name}]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:o.name}),o.is_auto_generated&&i.jsx(J,{variant:"info",children:"Auto-generated"})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Q,{variant:"primary",icon:ma,size:"sm",onClick:()=>l(!0),children:"Optimize"}),i.jsx(Q,{variant:"secondary",icon:Qc,size:"sm",onClick:()=>{confirm(`Delete agent "${o.name}"?`)&&u.mutate(o.id)},children:"Delete"})]})]}),o.description&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:o.description})]}),i.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[i.jsxs("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:[i.jsxs("div",{className:"flex gap-1 mb-4 border-b border-[var(--border)] flex-shrink-0",children:[i.jsx(kl,{active:r==="overview",onClick:()=>s("overview"),icon:i.jsx(Im,{size:14}),children:"Overview"}),i.jsx(kl,{active:r==="evaluate",onClick:()=>s("evaluate"),icon:i.jsx(Xs,{size:14}),children:"Evaluate"}),i.jsx(kl,{active:r==="history",onClick:()=>s("history"),icon:i.jsx(zg,{size:14}),badge:d.length,children:"History"})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r==="overview"&&i.jsx(G0,{agent:o,recentTests:d,jobs:m}),r==="evaluate"&&i.jsx(J0,{agent:o,jobs:m}),r==="history"&&i.jsx(Y0,{tests:d})]})]}),i.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[i.jsx(Fm,{size:16,className:"text-[var(--text-secondary)]"}),i.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),i.jsx("div",{className:"flex-1 min-h-0",children:i.jsx(Ym,{agent:o})})]})]}),a&&i.jsx(qm,{agent:o,isOpen:a,onClose:()=>l(!1)})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Agent not found"})}function kl({active:e,onClick:t,icon:n,badge:r,children:s}){return i.jsxs("button",{onClick:t,className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors ${e?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[n,s,r!==void 0&&r>0&&i.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs bg-[var(--bg-tertiary)] rounded",children:r})]})}function G0({agent:e,recentTests:t,jobs:n}){var a,l;const r=e.config,s=()=>{const o=r.tools;return typeof o=="string"?o:Array.isArray(o)?o.join(", "):o&&typeof o=="object"?Object.keys(o).join(", "):"standard"};return i.jsxs("div",{className:"space-y-4",children:[i.jsx(fr,{title:"Model",children:i.jsx("div",{className:"font-mono text-sm",children:r.model||"default"})}),i.jsx(fr,{title:"Instructions",defaultCollapsed:!r.instructions,children:r.instructions?i.jsx("pre",{className:"p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs whitespace-pre-wrap max-h-40 overflow-auto font-mono",children:r.instructions}):i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No instructions set"})}),i.jsx(fr,{title:"Tools",children:i.jsx("div",{className:"font-mono text-sm",children:s()})}),i.jsx(fr,{title:"Compaction",children:i.jsx("div",{className:"font-mono text-sm",children:!r.compaction||r.compaction.strategy==="none"?"disabled":`${r.compaction.strategy} (${((a=r.compaction.params)==null?void 0:a.head_size)||0}/${((l=r.compaction.params)==null?void 0:l.tail_size)||0})`})}),t.length>0&&i.jsx(fr,{title:`Recent Tests (${t.length})`,children:i.jsx("div",{className:"space-y-1.5",children:t.slice(0,3).map(o=>i.jsxs(Pn,{to:`/tests/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[i.jsx(Xm,{status:o.status}),i.jsxs("span",{className:"truncate",children:[o.prompt.slice(0,40),"..."]})]}),i.jsxs("span",{className:"text-[var(--text-secondary)] flex-shrink-0 ml-2",children:[o.duration_seconds.toFixed(1),"s"]})]},o.id))})}),n.length>0&&i.jsx(fr,{title:`Experiments (${n.length})`,children:i.jsx("div",{className:"space-y-1.5",children:n.slice(0,3).map(o=>i.jsxs(Pn,{to:`/jobs/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(J,{variant:o.status==="completed"?"success":o.status==="running"?"info":"default",children:o.status}),i.jsx("span",{children:o.name})]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(o.created_at).toLocaleDateString()})]},o.id))})})]})}function fr({title:e,children:t,defaultCollapsed:n=!1}){const[r,s]=j.useState(n);return i.jsxs("div",{className:"border-b border-[var(--border)] pb-3",children:[i.jsxs("button",{onClick:()=>s(!r),className:"flex items-center justify-between w-full text-left py-1 hover:text-[var(--accent)] transition-colors",children:[i.jsx("span",{className:"text-sm font-medium",children:e}),i.jsx("span",{className:"text-[var(--text-secondary)] text-xs",children:r?"▶":"▼"})]}),!r&&i.jsx("div",{className:"mt-2",children:t})]})}function J0({agent:e,jobs:t}){const n=cr(),r=qt(),[s,a]=j.useState("quick"),[l,o]=j.useState(!1),{data:c=[]}=he({queryKey:["suites"],queryFn:()=>Et.listSuites()}),d=Je({mutationFn:w0.start,onSuccess:u=>{r.invalidateQueries({queryKey:["jobs"]}),o(!1),n(`/jobs/${u.id}`)},onError:()=>{o(!1)}}),h=()=>{o(!0),d.mutate({agent_id:e.id,suite_name:s,use_llm_eval:!0,parallel:4})};return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:"Run this agent on a task suite to measure quality and cost."}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm",value:s,onChange:u=>a(u.target.value),disabled:l,children:c.map(u=>i.jsxs("option",{value:u.name,children:[u.name.charAt(0).toUpperCase()+u.name.slice(1)," (",u.task_count," tasks)"]},u.name))}),i.jsx(Q,{variant:"primary",icon:l?ha:Xs,onClick:h,disabled:l,loading:l,className:"w-full",children:"Evaluate"})]})]}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h4",{className:"text-sm font-medium",children:"Optimization Jobs"}),i.jsx(Q,{variant:"secondary",size:"sm",icon:ma,onClick:()=>n("/agents",{state:{optimizeAgent:e}}),children:"New Job"})]}),t.length===0?i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No optimization jobs yet."}):i.jsx("div",{className:"space-y-1.5",children:t.slice(0,5).map(u=>i.jsxs(Pn,{to:`/jobs/${u.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(J,{variant:u.status==="completed"?"success":u.status==="running"?"info":"default",children:u.status}),i.jsx("span",{children:u.name})]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(u.created_at).toLocaleDateString()})]},u.id))})]})]})}function Y0({tests:e}){return e.length===0?i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No test history yet. Use the playground on the right to run a test."}):i.jsx("div",{className:"space-y-2",children:e.map(t=>i.jsxs(Pn,{to:`/tests/${t.id}`,className:"flex items-center justify-between p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(Xm,{status:t.status}),t.score!==null&&i.jsxs("span",{className:`text-sm font-medium ${t.passed?"text-[var(--success)]":"text-[var(--error)]"}`,children:[(t.score*100).toFixed(0),"%"]})]}),i.jsx("p",{className:"text-sm truncate",children:t.prompt})]}),i.jsxs("div",{className:"flex flex-col items-end gap-1 ml-4",children:[i.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:new Date(t.created_at).toLocaleString()}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:[t.duration_seconds.toFixed(1),"s"]}),i.jsxs("span",{children:[t.tokens_total," tokens"]})]})]})]},t.id))})}function Xm({status:e}){const t={completed:"success",failed:"error",running:"info",cancelled:"warning",pending:"default"};return i.jsx(J,{variant:t[e]||"default",children:e})}function X0(){const e=qt(),[t,n]=j.useState(!1),[r,s]=j.useState(!1),[a,l]=j.useState(null),[o,c]=j.useState(new Set),d=p=>{c(f=>{const v=new Set(f);return v.has(p)?v.delete(p):v.add(p),v})},{data:h=[],isLoading:u}=he({queryKey:["tasks"],queryFn:()=>Et.list()}),m=Je({mutationFn:Et.create,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),n(!1)}}),x=Je({mutationFn:Et.importSuite,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),s(!1)}}),k=Je({mutationFn:Et.delete,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),l(null)}}),g=h.reduce((p,f)=>{const v=f.suite||"custom";return p[v]||(p[v]=[]),p[v].push(f),p},{}),S=Object.keys(g).sort((p,f)=>p==="custom"?-1:f==="custom"?1:p.localeCompare(f));return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Datasets"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Task datasets for evaluating agent configurations."})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Q,{variant:"secondary",onClick:()=>s(!0),children:"Import Suite"}),i.jsx(Q,{variant:"primary",onClick:()=>n(!0),children:"+ New Task"})]})]}),u?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):h.length===0?i.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:"No tasks yet. Create one or import a built-in suite."}):i.jsx("div",{className:"space-y-4",children:S.map(p=>{const f=g[p],v=!o.has(p);return i.jsxs("div",{children:[i.jsxs("button",{onClick:()=>d(p),className:"flex items-center gap-2 py-2 hover:text-[var(--accent)] transition-colors",children:[v?i.jsx(bg,{size:16,className:"text-[var(--text-secondary)]"}):i.jsx(Ys,{size:16,className:"text-[var(--text-secondary)]"}),i.jsx("h3",{className:"text-sm font-medium uppercase tracking-wide",children:p==="custom"?"Custom Tasks":`${p} Suite`}),i.jsx(J,{variant:p==="custom"?"default":"info",children:f.length})]}),v&&i.jsx("div",{className:"mt-2 border border-[var(--border)] rounded-lg overflow-hidden",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:[i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Name"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Category"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Prompt"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Criteria"})]})}),i.jsx("tbody",{children:f.map(w=>i.jsxs("tr",{onClick:()=>l(w),className:"border-b border-[var(--border)] last:border-b-0 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors",children:[i.jsx("td",{className:"px-4 py-3",children:i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:w.name})}),i.jsx("td",{className:"px-4 py-3",children:w.category&&w.category!=="default"?i.jsx(J,{variant:"default",children:w.category}):i.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"})}),i.jsx("td",{className:"px-4 py-3",children:i.jsx("span",{className:"text-[var(--text-secondary)] line-clamp-1 max-w-md",children:w.prompt})}),i.jsx("td",{className:"px-4 py-3 text-[var(--text-secondary)]",children:w.criteria.length>0?w.criteria.length:"--"})]},w.id))})]})})]},p)})}),i.jsx(Z0,{task:a,onClose:()=>l(null),onDelete:p=>{confirm("Delete this task?")&&k.mutate(p)}}),i.jsx(e1,{isOpen:t,onClose:()=>n(!1),onSubmit:p=>m.mutate(p),isLoading:m.isPending}),i.jsx(t1,{isOpen:r,onClose:()=>s(!1),onSubmit:p=>x.mutate(p),isLoading:x.isPending})]})}function Z0({task:e,onClose:t,onDelete:n}){const[r,s]=j.useState("prompt");if(!e)return null;const a=i.jsxs("div",{className:"flex justify-between",children:[i.jsx(Q,{variant:"ghost",onClick:()=>n(e.id),className:"text-red-500 hover:text-red-600",children:"Delete Task"}),i.jsx(Q,{variant:"secondary",onClick:t,children:"Close"})]});return i.jsx(ss,{isOpen:!!e,onClose:t,title:e.name,size:"lg",footer:a,children:i.jsxs("div",{className:"space-y-4",children:[e.category&&e.category!=="default"&&i.jsx("div",{children:i.jsx(J,{variant:"default",children:e.category})}),i.jsxs("div",{className:"flex gap-1 border-b border-[var(--border)]",children:[i.jsx("button",{onClick:()=>s("prompt"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="prompt"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Prompt"}),i.jsxs("button",{onClick:()=>s("criteria"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="criteria"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:["Eval Criteria (",e.criteria.length,")"]})]}),r==="prompt"&&i.jsx("div",{className:"p-4 bg-[var(--bg-tertiary)] rounded text-sm whitespace-pre-wrap min-h-[200px]",children:e.prompt}),r==="criteria"&&i.jsx("div",{className:"space-y-2 min-h-[200px]",children:e.criteria.length===0?i.jsx("div",{className:"text-[var(--text-secondary)] text-sm p-4",children:"No evaluation criteria defined for this task."}):e.criteria.map(l=>i.jsxs("div",{className:"p-3 bg-[var(--bg-tertiary)] rounded",children:[i.jsx("div",{className:"font-medium text-sm",children:l.name}),l.instruction&&i.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1",children:l.instruction})]},l.name))})]})})}function e1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,a]=j.useState({name:"",prompt:"",criteria:[],category:"default"}),l=()=>{a({...s,criteria:[...s.criteria,{name:"",instruction:"",weight:1}]})},o=(h,u)=>{const m=[...s.criteria];m[h]={...m[h],...u},a({...s,criteria:m})},c=h=>{a({...s,criteria:s.criteria.filter((u,m)=>m!==h)})},d=h=>{h.preventDefault(),!(!s.name.trim()||!s.prompt.trim())&&n({...s,criteria:s.criteria.filter(u=>u.name.trim()&&u.instruction.trim())})};return i.jsx(ss,{isOpen:e,onClose:t,title:"Create Task",children:i.jsxs("form",{onSubmit:d,className:"space-y-4",children:[i.jsx(pn,{label:"Name",value:s.name,onChange:h=>a({...s,name:h.target.value}),placeholder:"e.g., fizzbuzz",required:!0}),i.jsx(I0,{label:"Prompt",value:s.prompt,onChange:h=>a({...s,prompt:h.target.value}),placeholder:"The task description for the agent...",required:!0}),i.jsx(pn,{label:"Category",value:s.category,onChange:h=>a({...s,category:h.target.value}),placeholder:"e.g., coding, research"}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Evaluation Criteria"}),i.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"+ Add"})]}),i.jsx("div",{className:"space-y-2",children:s.criteria.map((h,u)=>i.jsxs("div",{className:"flex gap-2 items-start",children:[i.jsx(pn,{value:h.name,onChange:m=>o(u,{name:m.target.value}),placeholder:"Name",className:"w-32"}),i.jsx(pn,{value:h.instruction,onChange:m=>o(u,{instruction:m.target.value}),placeholder:"Instruction",className:"flex-1"}),i.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(u),children:"×"})]},u))})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(Q,{type:"submit",variant:"primary",disabled:r||!s.name.trim()||!s.prompt.trim(),children:r?"Creating...":"Create"})]})]})})}function t1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,a]=j.useState(""),{data:l=[],isLoading:o}=he({queryKey:["suites"],queryFn:()=>Et.listSuites(),enabled:e});return j.useEffect(()=>{l.length>0&&!s&&a(l[0].name)},[l,s]),i.jsx(ss,{isOpen:e,onClose:t,title:"Import Task Suite",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Import a built-in task suite for evaluation."}),o?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading suites..."}):l.length===0?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"No suites available."}):i.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:l.map(c=>i.jsxs("label",{className:`flex items-center gap-3 p-3 border cursor-pointer ${s===c.name?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[i.jsx("input",{type:"radio",name:"suite",value:c.name,checked:s===c.name,onChange:()=>a(c.name),className:"accent-[var(--accent)]"}),i.jsxs("span",{className:"capitalize",children:[c.name.replace(/_/g," ")," (",c.task_count," tasks) - ",c.description]})]},c.name))}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(Q,{variant:"primary",onClick:()=>n(s),disabled:r||!s,children:r?"Importing...":"Import"})]})]})})}const n1=Ki(e=>({jobs:[],setJobs:t=>e({jobs:t})}));function r1(){const e=cr(),t=qt(),[n,r]=j.useState(!1),{setJobs:s}=n1(),a=Wc(),{data:l=[],isLoading:o}=he({queryKey:["jobs",n],queryFn:()=>Ut.list({include_public:n}),refetchInterval:5e3});j.useEffect(()=>{l.length>0&&s(l)},[l,s]);const c=Je({mutationFn:Ut.delete,onSuccess:()=>t.invalidateQueries({queryKey:["jobs"]})}),d={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"},h=[{key:"name",header:"Name",render:u=>i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:u.name||`Job ${u.id.slice(0,8)}`}),u.is_public&&i.jsx(Uc,{className:"w-3 h-3 ml-2 inline text-[var(--text-secondary)]"})]})},{key:"status",header:"Status",render:u=>i.jsx(J,{variant:d[u.status]||"default",children:u.status})},{key:"candidates",header:"Candidates",render:u=>i.jsx("span",{children:u.candidate_ids.length})},{key:"tasks",header:"Tasks",render:u=>i.jsx("span",{children:u.task_ids.length})},{key:"runs",header:"Runs",render:u=>i.jsxs("span",{children:[u.completed_experiments,"/",u.total_experiments]})},{key:"created",header:"Created",render:u=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(u.created_at).toLocaleDateString()}),sortable:!0,sortValue:u=>new Date(u.created_at).getTime()},{key:"actions",header:"",className:"w-12",render:u=>!u.user_id||u.user_id==="anonymous"||a&&u.created_by_name===a?i.jsx("div",{onClick:x=>x.stopPropagation(),children:i.jsx(Q,{variant:"ghost",size:"sm",icon:Qc,title:"Delete",disabled:u.status==="running",onClick:()=>{confirm("Delete this job?")&&c.mutate(u.id)}})}):null}];return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Experiments"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"View and manage optimization experiments. Start new experiments from the Agents page."})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Ni,{label:"Show public",checked:n,onChange:u=>r(u.target.checked)}),i.jsx(Q,{variant:"secondary",onClick:()=>e("/agents"),children:"Go to Agents"})]})]}),o?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):i.jsx(Wm,{columns:h,data:l,onRowClick:u=>e(`/jobs/${u.id}`),searchable:!0,searchPlaceholder:"Search experiments",searchFilter:(u,m)=>(u.name||"").toLowerCase().includes(m.toLowerCase())||u.id.toLowerCase().includes(m.toLowerCase()),emptyMessage:"No experiments yet. Go to Agents page to start an optimization."})]})}function s1(e,t=!0){return Math.abs(e)<10?"text-[var(--text-secondary)]":(t?e<0:e>0)?"text-green-400":"text-red-400"}function a1(e){return`${e>0?"+":""}${e.toFixed(1)}%`}function Zm(e,t){return t===0?0:(e-t)/t*100}function ps({label:e,values:t,baselineIndex:n,formatter:r,isLowerBetter:s=!0}){const a=t[n];return i.jsxs("tr",{className:"border-b border-[var(--border)] last:border-0",children:[i.jsx("td",{className:"py-2 pr-4 text-[var(--text-secondary)] text-sm",children:e}),t.map((l,o)=>{const c=Zm(l,a),d=o===n;return i.jsxs("td",{className:"py-2 px-4 text-right",children:[i.jsx("div",{className:"font-mono",children:r(l)}),!d&&i.jsx("div",{className:`text-xs ${s1(c,s)}`,children:a1(c)}),d&&i.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"(baseline)"})]},o)})]})}function i1({runs:e,baselineRunId:t}){const n=j.useMemo(()=>{if(t){const a=e.findIndex(l=>l.id===t);if(a>=0)return a}return 0},[e,t]);if(e.length<2)return null;const r=Math.min(...e.map(a=>a.tokens_total)),s=Math.max(...e.map(a=>a.score));return i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-4",children:"Candidate Comparison"}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-[var(--border)]",children:[i.jsx("th",{className:"pb-2 pr-4 text-left text-[var(--text-secondary)] font-medium",children:"Metric"}),e.map((a,l)=>i.jsx("th",{className:"pb-2 px-4 text-right",children:i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[i.jsx("span",{className:"font-medium",children:a.candidate_name}),a.is_pareto&&i.jsx(J,{variant:"success",children:"Optimal"}),l===n&&i.jsx(J,{variant:"info",children:"Base"})]})},a.id))]})}),i.jsxs("tbody",{children:[i.jsx(ps,{label:"Total Tokens",values:e.map(a=>a.tokens_total),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ps,{label:"Input Tokens",values:e.map(a=>a.tokens_input),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ps,{label:"Output Tokens",values:e.map(a=>a.tokens_output),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ps,{label:"Duration",values:e.map(a=>a.duration_seconds),baselineIndex:n,formatter:a=>`${a.toFixed(1)}s`,isLowerBetter:!0}),i.jsx(ps,{label:"Score",values:e.map(a=>a.score*100),baselineIndex:n,formatter:a=>`${a.toFixed(1)}%`,isLowerBetter:!1})]})]})}),i.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[i.jsx("h4",{className:"text-sm font-medium mb-2 text-[var(--text-secondary)]",children:"Key Insights"}),i.jsxs("ul",{className:"text-sm space-y-1 text-[var(--text-secondary)]",children:[e.map(a=>{const l=Zm(a.tokens_total,e[n].tokens_total);return a.tokens_total===r&&l<-5?i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-green-400",children:"✓"}),i.jsxs("span",{children:[i.jsx("strong",{children:a.candidate_name})," uses ",Math.abs(l).toFixed(0),"% fewer tokens"]})]},`token-${a.id}`):null}),e.map(a=>a.score===s&&a.passed?i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-green-400",children:"✓"}),i.jsxs("span",{children:[i.jsx("strong",{children:a.candidate_name})," achieved highest score (",(a.score*100).toFixed(0),"%)"]})]},`score-${a.id}`):null),e.filter(a=>a.is_pareto).length>0&&i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-purple-400",children:"★"}),i.jsxs("span",{children:["Optimal candidates (best tradeoff):"," ",e.filter(a=>a.is_pareto).map(a=>a.candidate_name).join(", ")]})]})]})]}),i.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[i.jsx("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:"Token Efficiency"}),i.jsx("div",{className:"space-y-2",children:e.map(a=>{const l=a.tokens_total/e[n].tokens_total*100,o=a.tokens_total<=r;return i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-24 text-sm truncate",title:a.candidate_name,children:a.candidate_name}),i.jsx("div",{className:"flex-1 h-6 bg-[var(--bg-primary)] rounded overflow-hidden",children:i.jsx("div",{className:`h-full transition-all duration-300 ${o?"bg-green-500":"bg-blue-500"}`,style:{width:`${Math.min(l,100)}%`}})}),i.jsx("div",{className:"w-20 text-right font-mono text-sm",children:a.tokens_total.toLocaleString()})]},a.id)})})]})]})}function l1({summaries:e,height:t=350}){const n=j.useRef(null),[r,s]=j.useState(600),[a,l]=j.useState("tokens"),[o,c]=j.useState(null),[d,h]=j.useState({x:0,y:0});j.useEffect(()=>{const b=()=>{n.current&&s(n.current.clientWidth)};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[]);const u={top:30,right:30,bottom:50,left:60},m=r-u.left-u.right,x=t-u.top-u.bottom,k=b=>a==="tokens"?b.avg_tokens:b.avg_duration,{xScale:g,yScale:S,xTicks:p,yTicks:f,paretoLine:v}=j.useMemo(()=>{if(e.length===0||m<=0)return{xScale:()=>0,yScale:()=>0,xTicks:[],yTicks:[],paretoLine:[]};const b=e.map(k),N=e.map(P=>P.avg_score),_=Math.min(...b)*.9,F=Math.max(...b)*1.1,O=Math.min(...N,.5),B=Math.min(Math.max(...N)*1.05,1),G=P=>(P-_)/(F-_)*m,re=P=>x-(P-O)/(B-O)*x,le=Array.from({length:5},(P,A)=>_+A/4*(F-_)),D=Array.from({length:5},(P,A)=>O+A/4*(B-O)),X=e.filter(P=>P.is_pareto).sort((P,A)=>k(P)-k(A)).map(P=>({x:G(k(P)),y:re(P.avg_score)}));return{xScale:G,yScale:re,xTicks:le,yTicks:D,paretoLine:X}},[e,m,x,a]);if(e.length===0)return i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No data to display"});const w=b=>a==="tokens"?b>=1e6?`${(b/1e6).toFixed(1)}M`:b>=1e3?`${(b/1e3).toFixed(0)}K`:b.toFixed(0):`${b.toFixed(1)}s`,C=(b,N)=>{var F;const _=(F=n.current)==null?void 0:F.getBoundingClientRect();_&&h({x:N.clientX-_.left,y:N.clientY-_.top}),c(b)};return i.jsxs("div",{ref:n,className:"w-full relative",children:[i.jsx("div",{className:"flex justify-end mb-2",children:i.jsxs("div",{className:"inline-flex rounded border border-[var(--border)] text-xs",children:[i.jsx("button",{className:`px-3 py-1 ${a==="tokens"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("tokens"),children:"Tokens"}),i.jsx("button",{className:`px-3 py-1 ${a==="duration"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("duration"),children:"Latency"})]})}),i.jsx("svg",{width:r,height:t,className:"font-mono text-xs",children:i.jsxs("g",{transform:`translate(${u.left}, ${u.top})`,children:[p.map((b,N)=>i.jsx("line",{x1:g(b),y1:0,x2:g(b),y2:x,stroke:"var(--border)",strokeDasharray:"2,2"},`x-grid-${N}`)),f.map((b,N)=>i.jsx("line",{x1:0,y1:S(b),x2:m,y2:S(b),stroke:"var(--border)",strokeDasharray:"2,2"},`y-grid-${N}`)),v.length>1&&i.jsx("polyline",{points:v.map(b=>`${b.x},${b.y}`).join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.slice().sort((b,N)=>(b.is_pareto?1:0)-(N.is_pareto?1:0)).map(b=>{const N=g(k(b)),_=S(b.avg_score),F=b.is_pareto,O=(o==null?void 0:o.candidate_name)===b.candidate_name;return i.jsxs("g",{onMouseEnter:B=>C(b,B),onMouseLeave:()=>c(null),children:[i.jsx("circle",{cx:N,cy:_,r:O?10:F?8:6,fill:F?"var(--accent)":"transparent",stroke:O?"var(--text-primary)":F?"var(--accent)":"var(--text-secondary)",strokeWidth:O?3:2,className:"cursor-pointer transition-all"}),F&&!O&&i.jsx("text",{x:N,y:_-12,textAnchor:"middle",fill:"var(--text-primary)",fontSize:10,className:"pointer-events-none",children:b.candidate_name.replace(/^baseline_/,"").slice(0,15)})]},b.candidate_name)}),i.jsx("line",{x1:0,y1:x,x2:m,y2:x,stroke:"var(--text-secondary)"}),p.map((b,N)=>i.jsxs("g",{transform:`translate(${g(b)}, ${x})`,children:[i.jsx("line",{y2:5,stroke:"var(--text-secondary)"}),i.jsx("text",{y:20,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:10,children:w(b)})]},`x-tick-${N}`)),i.jsx("text",{x:m/2,y:x+40,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:a==="tokens"?"Tokens (cost)":"Duration (latency)"}),i.jsx("line",{x1:0,y1:0,x2:0,y2:x,stroke:"var(--text-secondary)"}),f.map((b,N)=>i.jsxs("g",{transform:`translate(0, ${S(b)})`,children:[i.jsx("line",{x2:-5,stroke:"var(--text-secondary)"}),i.jsxs("text",{x:-10,textAnchor:"end",dominantBaseline:"middle",fill:"var(--text-secondary)",fontSize:10,children:[(b*100).toFixed(0),"%"]})]},`y-tick-${N}`)),i.jsx("text",{transform:`translate(-45, ${x/2}) rotate(-90)`,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:"Score (quality)"})]})}),o&&i.jsxs("div",{className:"absolute z-10 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg shadow-lg p-3 text-sm pointer-events-none",style:{left:Math.min(d.x+15,r-200),top:d.y-10,maxWidth:220},children:[i.jsx("div",{className:"font-medium text-[var(--text-primary)] truncate mb-2",children:o.candidate_name.replace(/^baseline_/,"")}),i.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Score:"}),i.jsxs("span",{className:"text-right font-medium",children:[(o.avg_score*100).toFixed(1),"%"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tokens:"}),i.jsxs("span",{className:"text-right",children:[(o.avg_tokens/1e3).toFixed(1),"K"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Duration:"}),i.jsxs("span",{className:"text-right",children:[o.avg_duration.toFixed(1),"s"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Pass rate:"}),i.jsxs("span",{className:"text-right",children:[o.passed_runs,"/",o.total_runs]})]}),o.is_pareto&&i.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)] text-xs text-[var(--accent)]",children:"Optimal (best tradeoff)"})]})]})}function o1(e=2e3){const[t,n]=j.useState(!1),[r,s]=j.useState(null),a=j.useCallback(async o=>{try{return await navigator.clipboard.writeText(o),n(!0),s(null),setTimeout(()=>n(!1),e),!0}catch{return s("Failed to copy to clipboard"),n(!1),!1}},[e]),l=j.useCallback(()=>{n(!1),s(null)},[]);return{copy:a,copied:t,error:r,reset:l}}function c1({isOpen:e,onClose:t,title:n,itemId:r,itemType:s,isPublic:a,createdByName:l,onTogglePublic:o}){const[c,d]=j.useState(!1),{copy:h,copied:u}=o1(),m=`${window.location.origin}/${s}s/${r}`,x=async()=>{d(!0);try{await o(!a)}finally{d(!1)}},k=()=>{h(m)};return i.jsx(ss,{isOpen:e,onClose:t,title:n,children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between p-3 bg-[var(--bg-tertiary)] rounded",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[a?i.jsx(Uc,{className:"w-5 h-5 text-[var(--accent)]"}):i.jsx(zm,{className:"w-5 h-5 text-[var(--text-secondary)]"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium",children:a?"Public":"Private"}),i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:a?"Anyone with the link can view":"Only you can access"})]})]}),i.jsx("button",{onClick:x,disabled:c,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${a?"bg-[var(--accent)]":"bg-[var(--border)]"} ${c?"opacity-50 cursor-not-allowed":""}`,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${a?"translate-x-6":"translate-x-1"}`})})]}),a&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Share link"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",readOnly:!0,value:m,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono"}),i.jsx(Q,{variant:"secondary",onClick:k,children:u?i.jsxs(i.Fragment,{children:[i.jsx(Ng,{className:"w-4 h-4 mr-1"}),"Copied"]}):i.jsxs(i.Fragment,{children:[i.jsx(Pg,{className:"w-4 h-4 mr-1"}),"Copy"]})})]})]}),l&&i.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",i.jsx("span",{className:"text-[var(--text-primary)]",children:l})]}),i.jsx("div",{className:"text-xs text-[var(--text-secondary)] pt-2 border-t border-[var(--border)]",children:a?i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Public ",s,"s can be viewed by anyone with the link."]}),i.jsxs("p",{className:"mt-1",children:["Only you can edit or delete this ",s,"."]})]}):i.jsxs("p",{children:["Make this ",s," public to share it with others."]})})]})})}function u1({job:e,onUpdate:t}){const[n,r]=j.useState(!1),s=async a=>{await Ut.update(e.id,{is_public:a}),t()};return i.jsxs(i.Fragment,{children:[i.jsxs(Q,{variant:"secondary",size:"sm",onClick:()=>r(!0),title:e.is_public?"Sharing settings":"Share this job",children:[i.jsx(Ug,{className:"w-4 h-4 mr-1"}),e.is_public?"Shared":"Share"]}),i.jsx(c1,{isOpen:n,onClose:()=>r(!1),title:"Share Job",itemId:e.id,itemType:"job",isPublic:e.is_public,createdByName:e.created_by_name,onTogglePublic:s})]})}function d1(){const{jobId:e}=fa(),t=cr(),n=qt(),[r,s]=j.useState(null),[a,l]=j.useState(!1),[o,c]=j.useState(null),[d,h]=j.useState([]),[u,m]=j.useState(null),[x,k]=j.useState(null),[g,S]=j.useState("results"),[p,f]=j.useState("score"),[v,w]=j.useState("desc"),[C,b]=j.useState(!1),{data:N,isLoading:_}=he({queryKey:["jobs",e],queryFn:()=>Ut.get(e),enabled:!!e,refetchInterval:a?2e3:!1}),{data:F=[]}=he({queryKey:["runs",e],queryFn:()=>Fo.list({job_id:e}),enabled:!!e,refetchInterval:a?2e3:!1}),{data:O}=he({queryKey:["job-summary",e],queryFn:()=>Fo.getJobSummary(e),enabled:!!e&&(N==null?void 0:N.status)==="completed"}),B=Je({mutationFn:async()=>{l(!0),h([]),m(null),k(null);for await(const R of Ut.start(e))s(R),R.current_candidate&&R.current_task&&m(T=>(T&&(T.candidate!==R.current_candidate||T.task!==R.current_task)&&h(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),{candidate:R.current_candidate,task:R.current_task})),R.event==="error"&&(k(R.message),l(!1),n.invalidateQueries({queryKey:["jobs",e]})),R.event==="complete"&&(m(T=>(T&&h(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),null)),l(!1),n.invalidateQueries({queryKey:["jobs",e]}),n.invalidateQueries({queryKey:["runs",e]}),n.invalidateQueries({queryKey:["job-summary",e]}))}}),G=Je({mutationFn:()=>Ut.cancel(e),onSuccess:()=>{l(!1),n.invalidateQueries({queryKey:["jobs",e]})}});j.useEffect(()=>{(N==null?void 0:N.status)==="running"&&l(!0)},[N==null?void 0:N.status]);const re=j.useMemo(()=>{const R=new Map;for(const T of F)R.has(T.task_name)||R.set(T.task_name,[]),R.get(T.task_name).push(T);return R},[F]),le=j.useMemo(()=>Array.from(re.keys()),[re]);j.useEffect(()=>{!o&&le.length>0&&c(le[0])},[le,o]);const D=j.useMemo(()=>{if(!(O!=null&&O.candidate_summaries))return[];let R=[...O.candidate_summaries];return C&&(R=R.filter(T=>T.is_pareto)),R.sort((T,te)=>{let pe,be;switch(p){case"score":pe=T.avg_score,be=te.avg_score;break;case"tokens":pe=T.avg_tokens,be=te.avg_tokens;break;case"duration":pe=T.avg_duration,be=te.avg_duration;break;case"pass_rate":pe=T.passed_runs/T.total_runs,be=te.passed_runs/te.total_runs;break}return v==="desc"?be-pe:pe-be}),R},[O,p,v,C]),q=R=>{p===R?w(v==="desc"?"asc":"desc"):(f(R),w(R==="tokens"||R==="duration"?"asc":"desc"))},X=({label:R,sortKeyVal:T})=>i.jsx("th",{className:"pb-2 cursor-pointer hover:text-[var(--text-primary)] select-none",onClick:()=>q(T),children:i.jsxs("div",{className:"flex items-center gap-1",children:[R,p===T&&i.jsx(wg,{size:12,className:v==="asc"?"rotate-180":""})]})});if(_)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!N)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Job not found"});const P=Wc(),A=!N.user_id||N.user_id==="anonymous"||P&&N.created_by_name===P,L=N.is_public&&!A,K=()=>{n.invalidateQueries({queryKey:["jobs",e]})},ee=R=>{const T={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};return i.jsx(J,{variant:T[R]||"default",children:R})};return i.jsxs("div",{children:[i.jsx(pa,{items:[{label:"Experiments",path:"/jobs"},{label:N.name||`Job ${N.id.slice(0,8)}`}]}),i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:N.name||`Job ${N.id.slice(0,8)}`}),ee(N.status),N.is_public&&i.jsxs(J,{variant:"info",children:[i.jsx(Uc,{className:"w-3 h-3 mr-1 inline"}),"Public"]})]}),i.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-2 py-0.5 rounded font-mono text-[var(--text-secondary)]",children:[N.id.slice(0,8),"..."]}),i.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[N.candidate_ids.length," candidates × ",N.task_ids.length," tasks = ",N.total_experiments," experiments"]}),N.is_public&&N.created_by_name&&i.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",i.jsx("span",{className:"text-[var(--text-primary)]",children:N.created_by_name})]})]})]}),i.jsxs("div",{className:"flex gap-2",children:[A&&i.jsx(u1,{job:N,onUpdate:K}),L&&i.jsx(J,{variant:"default",children:"View Only"}),A&&N.status==="pending"&&i.jsx(Q,{variant:"primary",onClick:()=>B.mutate(),disabled:B.isPending,children:B.isPending?"Starting...":"Start"}),A&&N.status==="running"&&i.jsx(Q,{variant:"danger",onClick:()=>G.mutate(),disabled:G.isPending,children:"Cancel"})]})]}),(x||N.error)&&i.jsx(ge,{className:"mb-6 border-red-500/50 bg-red-500/10",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-5 h-5 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-0.5",children:"!"}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium text-red-400",children:"Error"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:x||N.error})]})]})}),(a||r)&&i.jsxs(ge,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("span",{className:"font-medium",children:"Progress"}),i.jsxs("span",{className:"text-[var(--accent)]",children:[(r==null?void 0:r.completed)||N.completed_experiments,"/",(r==null?void 0:r.total)||N.total_experiments]})]}),i.jsx("div",{className:"w-full bg-[var(--bg-primary)] h-2 mb-2",children:i.jsx("div",{className:"h-full bg-[var(--accent)] transition-all",style:{width:`${((r==null?void 0:r.completed)||N.completed_experiments)/((r==null?void 0:r.total)||N.total_experiments)*100}%`}})}),(r==null?void 0:r.message)&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r.message}),a&&i.jsxs("div",{className:"mt-4 border-t border-[var(--border)] pt-4",children:[(r==null?void 0:r.current_candidate)&&(r==null?void 0:r.current_task)&&i.jsxs("div",{className:"mb-3",children:[i.jsx("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:"Currently Running"}),i.jsxs("div",{className:"flex items-center gap-2 mt-1 px-3 py-2 bg-blue-500/10 border border-blue-500/30 rounded",children:[i.jsx("div",{className:"w-2 h-2 bg-blue-400 rounded-full animate-pulse"}),i.jsx("span",{className:"font-medium",children:r.current_candidate}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{children:r.current_task})]})]}),d.length>0&&i.jsxs("div",{children:[i.jsxs("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:["Completed (",d.length,")"]}),i.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto space-y-1",children:d.map((R,T)=>i.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-500/10 border border-green-500/30 rounded text-sm",children:[i.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}),i.jsx("span",{className:"font-medium",children:R.candidate_name}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{children:R.task_name})]},`${R.candidate_name}-${R.task_name}-${T}`))})]})]})]}),(N.status==="completed"||F.length>0)&&i.jsxs("div",{className:"flex gap-1 mb-6 border-b border-[var(--border)]",children:[i.jsxs("button",{onClick:()=>S("results"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="results"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(kg,{size:16}),"Results"]}),i.jsxs("button",{onClick:()=>S("compare"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="compare"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(Rg,{size:16}),"Compare"]}),i.jsxs("button",{onClick:()=>S("runs"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="runs"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(Fg,{size:16}),"Runs (",F.length,")"]})]}),g==="results"&&i.jsxs(i.Fragment,{children:[O&&O.candidate_summaries.length>1&&i.jsxs(ge,{className:"mb-6",children:[i.jsx("div",{className:"flex items-start justify-between mb-4",children:i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium",children:"Quality vs. Cost Tradeoff"}),i.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:["Candidates on the frontier (connected line) are ",i.jsx("strong",{children:"optimal"})," - no other candidate beats them on both score AND cost."]})]})}),i.jsxs("div",{className:"mb-4 p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs text-[var(--text-secondary)]",children:[i.jsx("strong",{className:"text-[var(--text-primary)]",children:"How optimal tradeoffs are calculated:"})," A candidate is optimal if there's no other candidate that has both a higher score AND lower cost. For example, if Candidate A has 95% score at 50K tokens and Candidate B has 90% score at 40K tokens, both are optimal - A is better on score, B is better on cost. But if Candidate C has 85% score at 60K tokens, it's ",i.jsx("em",{children:"not"})," optimal because B beats it on both metrics."]}),i.jsx(l1,{summaries:O.candidate_summaries,height:350})]}),O&&i.jsxs(ge,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h3",{className:"font-medium",children:"Results Summary"}),i.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:C,onChange:R=>b(R.target.checked),className:"rounded border-[var(--border)]"}),"Optimal only"]})]}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"text-left text-[var(--text-secondary)] border-b border-[var(--border)]",children:[i.jsx("th",{className:"pb-2",children:"Candidate"}),i.jsx(X,{label:"Score",sortKeyVal:"score"}),i.jsx(X,{label:"Tokens",sortKeyVal:"tokens"}),i.jsx(X,{label:"Duration",sortKeyVal:"duration"}),i.jsx(X,{label:"Pass Rate",sortKeyVal:"pass_rate"}),i.jsx("th",{className:"pb-2",children:"Optimal"})]})}),i.jsx("tbody",{children:D.map((R,T)=>i.jsxs("tr",{className:`border-b border-[var(--border)] ${T===0?"bg-[var(--accent)]/10":""}`,children:[i.jsxs("td",{className:"py-2 font-medium",children:[T===0&&i.jsx("span",{className:"text-[var(--accent)] mr-1",children:"#1"}),R.candidate_name.replace(/^baseline_/,"")]}),i.jsxs("td",{className:"py-2",children:[(R.avg_score*100).toFixed(1),"%"]}),i.jsxs("td",{className:"py-2",children:[(R.avg_tokens/1e3).toFixed(1),"K"]}),i.jsxs("td",{className:"py-2",children:[R.avg_duration.toFixed(1),"s"]}),i.jsxs("td",{className:"py-2",children:[R.passed_runs,"/",R.total_runs]}),i.jsx("td",{className:"py-2",children:R.is_pareto&&i.jsx(J,{variant:"success",children:"Optimal"})})]},R.candidate_name))})]})}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-3",children:"Click column headers to sort. The #1 ranked candidate is highlighted based on your sort criteria."})]}),!O&&i.jsx(ge,{children:i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Results will appear here after the job completes.":"No results yet. Start the job to see results."})})]}),g==="compare"&&i.jsxs(ge,{children:[i.jsx("h3",{className:"font-medium mb-4",children:"Compare Candidates by Task"}),le.length>0?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:le.map(R=>i.jsx("button",{onClick:()=>c(o===R?null:R),className:`px-3 py-1 text-sm rounded border transition-colors ${o===R?"bg-[var(--accent)] text-white border-[var(--accent)]":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:R},R))}),o&&re.get(o)?i.jsx(i1,{runs:re.get(o).map(R=>({id:R.id,candidate_name:R.candidate_name,tokens_input:0,tokens_output:0,tokens_total:R.tokens_total,duration_seconds:R.duration_seconds,score:R.score,passed:R.passed,is_pareto:R.is_pareto}))}):i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"Select a task above to compare how different candidates performed on it."})]}):i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Comparison data will appear here after runs complete.":"No runs yet. Start the job to compare candidates."})]}),g==="runs"&&i.jsxs(ge,{children:[i.jsx("h3",{className:"font-medium mb-4",children:"All Experiment Runs"}),F.length===0?i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Runs will appear here as they complete. See progress above for live status.":"No runs yet. Start the job to see results."}):i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:F.map(R=>i.jsxs("div",{className:"p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] cursor-pointer hover:border-[var(--accent-dim)] transition-colors",onClick:()=>t(`/runs/${R.id}`),children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("span",{className:`text-lg font-bold ${R.passed?"text-green-400":"text-red-400"}`,children:[(R.score*100).toFixed(0),"%"]}),R.is_pareto&&i.jsx(J,{variant:"success",children:"Optimal"})]}),i.jsx("div",{className:"text-sm font-medium truncate",title:R.candidate_name,children:R.candidate_name.replace(/^baseline_/,"")}),i.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:R.task_name}),i.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:[(R.tokens_total/1e3).toFixed(1),"K tokens"]}),i.jsxs("span",{children:[R.duration_seconds.toFixed(1),"s"]})]})]},R.id))})]})]})}const vn={input:"bg-blue-500",output:"bg-emerald-500",inputText:"text-blue-400",outputText:"text-emerald-400"};function Rd(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Md({input:e,output:t,maxValue:n,height:r=24,showLabels:s=!0}){const a=e+t;if(a===0)return i.jsx("div",{className:"flex items-center gap-2 w-full",children:i.jsx("div",{className:"rounded bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`}})});const l=n>0?a/n*100:100;return i.jsxs("div",{className:"flex items-center gap-3 w-full",children:[i.jsx("div",{className:"relative rounded overflow-hidden bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`},children:i.jsxs("div",{className:"h-full flex transition-all duration-300",style:{width:`${l}%`},children:[i.jsx("div",{className:`h-full ${vn.input} transition-all`,style:{width:`${e/a*100}%`},title:`Input: ${e.toLocaleString()} tokens`}),i.jsx("div",{className:`h-full ${vn.output} transition-all`,style:{width:`${t/a*100}%`},title:`Output: ${t.toLocaleString()} tokens`})]})}),s&&i.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono text-[var(--text-secondary)] min-w-[90px] justify-end",children:[i.jsxs("span",{className:vn.inputText,children:["↑",Rd(e)]}),i.jsx("span",{children:"/"}),i.jsxs("span",{className:vn.outputText,children:["↓",Rd(t)]})]})]})}function Sl({label:e,value:t,color:n="default"}){const r={default:"text-[var(--text-primary)]",input:vn.inputText,output:vn.outputText}[n];return i.jsxs("div",{className:"flex-1 p-3 bg-[var(--bg-primary)] border border-[var(--border)] rounded",children:[i.jsx("div",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e}),i.jsx("div",{className:`font-mono text-lg font-bold ${r}`,children:t})]})}function ep({tokensInput:e,tokensOutput:t,tokensTotal:n,turns:r}){const s=n>0?Math.round(e/n*100):0,a=n>0?Math.round(t/n*100):0,l=j.useMemo(()=>{if(!r||r.length===0)return null;let c=0,d=0;return r.map(h=>(c+=h.input,d+=h.output,{input:c,output:d,total:c+d}))},[r]),o=l?Math.max(...l.map(c=>c.total)):n;return i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-4",children:"Token Usage"}),i.jsx("div",{className:"mb-4",children:i.jsx(Md,{input:e,output:t,maxValue:n,height:32})}),i.jsxs("div",{className:"flex items-center gap-6 text-xs mb-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:`w-3 h-3 rounded ${vn.input}`}),i.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Input (",s,"%)"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:`w-3 h-3 rounded ${vn.output}`}),i.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Output (",a,"%)"]})]})]}),i.jsxs("div",{className:"flex gap-3 mb-4",children:[i.jsx(Sl,{label:"Input Tokens",value:e.toLocaleString(),color:"input"}),i.jsx(Sl,{label:"Output Tokens",value:t.toLocaleString(),color:"output"}),i.jsx(Sl,{label:"Total Tokens",value:n.toLocaleString()})]}),l&&l.length>1&&i.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[i.jsxs("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:["Token Accumulation (",r.length," turns)"]}),i.jsx("div",{className:"space-y-2",children:r.map((c,d)=>i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--bg-primary)] border border-[var(--border)] flex items-center justify-center text-xs font-medium",children:d+1}),i.jsx("div",{className:"flex-1",children:i.jsx(Md,{input:l[d].input,output:l[d].output,maxValue:o,height:16})})]},d))})]}),i.jsx("div",{className:"mt-4 text-xs text-[var(--text-secondary)] border-t border-[var(--border)] pt-3",children:"Token usage affects API cost. Input tokens are typically cheaper than output tokens."})]})}function f1(){const{runId:e}=fa(),{data:t,isLoading:n}=he({queryKey:["runs",e],queryFn:()=>Fo.get(e),enabled:!!e});return n?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?i.jsxs("div",{children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(pa,{items:[{label:"Experiments",path:"/jobs"},{label:"Job",path:`/jobs/${t.job_id}`},{label:t.candidate_name}]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:t.candidate_name}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{className:"text-lg",children:t.task_name}),t.is_pareto&&i.jsx(J,{variant:"success",children:"Optimal"})]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[i.jsx(za,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),i.jsx(za,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),i.jsx(za,{label:"Duration",value:`${t.duration_seconds.toFixed(1)}s`}),i.jsx(za,{label:"Status",value:t.passed?"Passed":"Failed",status:t.passed?"success":"error"})]}),i.jsx(ep,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),t.reasoning&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:t.reasoning}),t.criteria_results.length>0&&i.jsx("div",{className:"space-y-2",children:t.criteria_results.map(r=>i.jsx("div",{className:"flex items-start justify-between p-3 bg-[var(--bg-primary)] border border-[var(--border)]",children:i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-medium",children:r.name}),i.jsxs(J,{variant:r.passed?"success":"error",children:[(r.score*100).toFixed(0),"%"]})]}),r.reasoning&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r.reasoning})]})},r.name))})]}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created.length>0&&i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),i.jsx("div",{className:"space-y-1",children:t.files_created.map(r=>i.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:r},r))})]}),Object.keys(t.trace).length>0&&i.jsx(Jm,{trace:t.trace})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Run not found"})}function za({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return i.jsxs(ge,{children:[i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),i.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function h1(){const{testId:e}=fa(),{data:t,isLoading:n}=he({queryKey:["tests",e],queryFn:()=>Ts.get(e),enabled:!!e}),{data:r}=he({queryKey:["configs",t==null?void 0:t.agent_id],queryFn:()=>Xn.get(t.agent_id),enabled:!!(t!=null&&t.agent_id)});if(n)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!t)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Test not found"});const s={completed:"success",failed:"error",running:"info",pending:"default",cancelled:"warning"};return i.jsxs("div",{children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(pa,{items:[{label:"Agents",path:"/agents"},...r?[{label:r.name,path:`/agents/${r.id}`}]:[],{label:`Test ${t.id.slice(0,8)}`}]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:"Test Run"}),r&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"•"}),i.jsx("span",{className:"text-lg",children:r.name})]}),i.jsx(J,{variant:s[t.status]||"default",children:t.status})]}),i.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:["ID: ",t.id.slice(0,8),"..."]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[i.jsx(Fa,{label:"Duration",value:`${t.duration_seconds.toFixed(2)}s`}),i.jsx(Fa,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),t.score!==null&&i.jsx(Fa,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),i.jsx(Fa,{label:"Status",value:t.status.charAt(0).toUpperCase()+t.status.slice(1),status:t.status==="completed"?"success":t.status==="failed"?"error":void 0})]}),i.jsx(ep,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Prompt"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)] font-mono",children:t.prompt})]}),t.error&&i.jsxs(ge,{className:"mb-6 border-red-500/30 bg-red-500/5",children:[i.jsx("h3",{className:"font-medium mb-3 text-red-400",children:"Error"}),i.jsx("pre",{className:"text-sm text-red-300 overflow-x-auto whitespace-pre-wrap",children:t.error})]}),t.reasoning&&i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.reasoning})]}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created&&t.files_created.length>0&&i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),i.jsx("div",{className:"space-y-1",children:t.files_created.map(a=>i.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:a},a))})]}),t.trace&&Object.keys(t.trace).length>0&&i.jsx(Jm,{trace:t.trace}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Timestamps"}),i.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Created:"}),i.jsx("div",{className:"font-mono",children:new Date(t.created_at).toLocaleString()})]}),t.started_at&&i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Started:"}),i.jsx("div",{className:"font-mono",children:new Date(t.started_at).toLocaleString()})]}),t.completed_at&&i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Completed:"}),i.jsx("div",{className:"font-mono",children:new Date(t.completed_at).toLocaleString()})]})]})]})]})}function Fa({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return i.jsxs(ge,{children:[i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),i.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function m1(){const{deploymentId:e}=fa(),{data:t,isLoading:n}=he({queryKey:["deployments",e],queryFn:()=>j0.get(e),enabled:!!e}),r=t==null?void 0:t.versions.find(a=>a.id===t.current_version_id),{data:s}=he({queryKey:["configs",r==null?void 0:r.config_id],queryFn:()=>Xn.get(r.config_id),enabled:!!(r!=null&&r.config_id)});return n?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"mb-4 flex-shrink-0",children:[i.jsx(pa,{items:[{label:"Agents",path:"/agents"},{label:t.name}]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Ag,{size:20,className:"text-[var(--accent)]"}),i.jsx("h2",{className:"text-xl font-bold",children:t.name}),r&&i.jsxs(J,{variant:"info",children:["v",r.version]})]}),t.description&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:t.description})]}),i.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[i.jsx("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:i.jsxs("div",{className:"flex-1 overflow-y-auto space-y-5",children:[i.jsxs("div",{className:"flex items-center gap-4 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:["Created ",new Date(t.created_at).toLocaleDateString()]}),i.jsxs("span",{children:["Updated ",new Date(t.updated_at).toLocaleDateString()]}),i.jsxs("span",{children:[t.versions.length," version",t.versions.length!==1?"s":""]})]}),s&&i.jsxs(Pn,{to:`/agents/${s.id}`,className:"flex items-center gap-2 p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-sm",children:[i.jsx(Mm,{size:14,className:"text-[var(--accent)]"}),i.jsxs("span",{children:["Agent: ",i.jsx("span",{className:"font-medium",children:s.name})]})]}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider mb-3",children:"Version History"}),t.versions.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"No versions yet."}):i.jsx("div",{className:"space-y-2",children:t.versions.map(a=>i.jsx(p1,{version:a,isActive:a.id===t.current_version_id},a.id))})]})]})}),i.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[i.jsx(Fm,{size:16,className:"text-[var(--text-secondary)]"}),i.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),i.jsx("div",{className:"flex-1 min-h-0",children:s?i.jsx(Ym,{agent:s}):i.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-secondary)] text-sm",children:r?"Loading agent configuration...":"No active version to test."})})]})]})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Deployment not found"})}function p1({version:e,isActive:t}){const n=e.config_snapshot;return i.jsxs("div",{className:`p-3 rounded-md border transition-colors ${t?"border-[var(--accent)] bg-[var(--accent-dim)]":"border-[var(--border)] bg-[var(--bg-secondary)]"}`,children:[i.jsxs("div",{className:"flex items-center justify-between mb-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Qg,{size:12,className:"text-[var(--text-secondary)]"}),i.jsxs("span",{className:"text-sm font-medium",children:["v",e.version]}),t&&i.jsx(J,{variant:"success",children:"Active"}),i.jsx(J,{variant:e.source==="optimize"?"info":"default",children:e.source})]}),i.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)]",children:[i.jsx(Rm,{size:11}),i.jsx("span",{children:new Date(e.created_at).toLocaleString()})]})]}),e.description&&i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e.description}),Object.keys(n).length>0&&i.jsxs("div",{className:"mt-1",children:[i.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)] mb-1",children:[i.jsx(Lg,{size:11}),i.jsx("span",{children:"Config"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-xs",children:["framework"in n&&n.framework?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Framework"}),i.jsx("span",{className:"font-mono",children:String(n.framework)})]}):null,"model"in n&&n.model?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Model"}),i.jsx("span",{className:"font-mono",children:String(n.model)})]}):null,"tools"in n&&n.tools?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tools"}),i.jsx("span",{className:"font-mono truncate",children:Array.isArray(n.tools)?n.tools.join(", "):String(n.tools)})]}):null]})]})]})}function v1(){const{authConfig:e,isLoading:t,error:n,login:r,loginWithGitHub:s,clearError:a}=qc(),[l,o]=j.useState(""),[c,d]=j.useState("");j.useEffect(()=>{n&&a()},[l,c]);const h=async m=>{m.preventDefault(),!(!l||!c)&&await r(l,c)},u=()=>{s()};return i.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:i.jsxs("div",{className:"w-full max-w-md",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:"Flow"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:"Sign in to access the optimization dashboard"})]}),i.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] p-6 space-y-6",children:[n&&i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[var(--error)]/10 border border-[var(--error)]/20 text-[var(--error)]",children:[i.jsx(Om,{size:18,className:"mt-0.5 flex-shrink-0"}),i.jsx("p",{className:"text-sm",children:n})]}),(e==null?void 0:e.mode)==="basic"&&i.jsxs("form",{onSubmit:h,className:"space-y-4",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Username"}),i.jsxs("div",{className:"relative",children:[i.jsx(Dm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),i.jsx("input",{type:"text",value:l,onChange:m=>o(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter username",autoComplete:"username",autoFocus:!0})]})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Password"}),i.jsxs("div",{className:"relative",children:[i.jsx(zm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),i.jsx("input",{type:"password",value:c,onChange:m=>d(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter password",autoComplete:"current-password"})]})]}),i.jsx(Q,{type:"submit",variant:"primary",className:"w-full justify-center",loading:t,disabled:!l||!c,children:"Sign In"})]}),(e==null?void 0:e.mode)==="github"&&i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center",children:"Sign in with your GitHub account to continue"}),i.jsx(Q,{onClick:u,variant:"secondary",className:"w-full justify-center",icon:Mg,children:"Continue with GitHub"})]})]})]})})}function x1({children:e}){const{authConfig:t,isLoadingConfig:n,isAuthenticated:r,loadAuthConfig:s,handleOAuthCallback:a}=qc();return j.useEffect(()=>{s()},[s]),j.useEffect(()=>{n||a()},[n,a]),n?i.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center",children:i.jsxs("div",{className:"text-center",children:[i.jsx(ha,{className:"w-8 h-8 animate-spin text-[var(--accent)] mx-auto mb-4"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:"Loading..."})]})}):t!=null&&t.enabled&&!r?i.jsx(v1,{}):i.jsx(i.Fragment,{children:e})}function y1(){return i.jsx(fg,{children:i.jsx(x1,{children:i.jsx(sg,{children:i.jsxs(ht,{path:"/",element:i.jsx(L0,{}),children:[i.jsx(ht,{index:!0,element:i.jsx(Ld,{})}),i.jsx(ht,{path:"agents",element:i.jsx(Ld,{})}),i.jsx(ht,{path:"agents/:agentId",element:i.jsx(q0,{})}),i.jsx(ht,{path:"tasks",element:i.jsx(X0,{})}),i.jsx(ht,{path:"jobs",element:i.jsx(r1,{})}),i.jsx(ht,{path:"jobs/:jobId",element:i.jsx(d1,{})}),i.jsx(ht,{path:"runs/:runId",element:i.jsx(f1,{})}),i.jsx(ht,{path:"tests/:testId",element:i.jsx(h1,{})}),i.jsx(ht,{path:"deployments/:deploymentId",element:i.jsx(m1,{})})]})})})})}const zd=localStorage.getItem("flow-theme");if(zd)try{const{state:e}=JSON.parse(zd);e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}catch{}const g1=new Zx({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}});Nl.createRoot(document.getElementById("root")).render(i.jsx(Vo.StrictMode,{children:i.jsx(ey,{client:g1,children:i.jsx(y1,{})})})); diff --git a/src/flow/ui/ui/assets/index-CZiSleym.js b/src/flow/ui/ui/assets/index-CZiSleym.js new file mode 100644 index 0000000000000000000000000000000000000000..92abc1ae737272ce856f719a856c5ee4cd83b17b --- /dev/null +++ b/src/flow/ui/ui/assets/index-CZiSleym.js @@ -0,0 +1,347 @@ +var ru=e=>{throw TypeError(e)};var Wi=(e,t,n)=>t.has(e)||ru("Cannot "+n);var y=(e,t,n)=>(Wi(e,t,"read from private field"),n?n.call(e):t.get(e)),$=(e,t,n)=>t.has(e)?ru("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),M=(e,t,n,r)=>(Wi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),G=(e,t,n)=>(Wi(e,t,"access private method"),n);var va=(e,t,n,r)=>({set _(s){M(e,t,s,n)},get _(){return y(e,t,r)}});function up(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();function Xd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Zd={exports:{}},Ci={},ef={exports:{}},X={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var la=Symbol.for("react.element"),dp=Symbol.for("react.portal"),fp=Symbol.for("react.fragment"),hp=Symbol.for("react.strict_mode"),mp=Symbol.for("react.profiler"),pp=Symbol.for("react.provider"),xp=Symbol.for("react.context"),vp=Symbol.for("react.forward_ref"),yp=Symbol.for("react.suspense"),gp=Symbol.for("react.memo"),jp=Symbol.for("react.lazy"),su=Symbol.iterator;function wp(e){return e===null||typeof e!="object"?null:(e=su&&e[su]||e["@@iterator"],typeof e=="function"?e:null)}var tf={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},nf=Object.assign,rf={};function es(e,t,n){this.props=e,this.context=t,this.refs=rf,this.updater=n||tf}es.prototype.isReactComponent={};es.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};es.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function sf(){}sf.prototype=es.prototype;function Ho(e,t,n){this.props=e,this.context=t,this.refs=rf,this.updater=n||tf}var qo=Ho.prototype=new sf;qo.constructor=Ho;nf(qo,es.prototype);qo.isPureReactComponent=!0;var au=Array.isArray,af=Object.prototype.hasOwnProperty,Wo={current:null},lf={key:!0,ref:!0,__self:!0,__source:!0};function of(e,t,n){var r,s={},i=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(i=""+t.key),t)af.call(t,r)&&!lf.hasOwnProperty(r)&&(s[r]=t[r]);var o=arguments.length-2;if(o===1)s.children=n;else if(1>>1,te=P[V];if(0>>1;Vs(Ce,T))kes(_e,Ce)?(P[V]=_e,P[ke]=T,V=ke):(P[V]=Ce,P[Q]=T,V=Q);else if(kes(_e,T))P[V]=_e,P[ke]=T,V=ke;else break e}}return A}function s(P,A){var T=P.sortIndex-A.sortIndex;return T!==0?T:P.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var c=[],u=[],d=1,f=null,m=3,v=!1,k=!1,w=!1,b=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,h=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(P){for(var A=n(u);A!==null;){if(A.callback===null)r(u);else if(A.startTime<=P)r(u),A.sortIndex=A.expirationTime,t(c,A);else break;A=n(u)}}function j(P){if(w=!1,x(P),!k)if(n(c)!==null)k=!0,W(C);else{var A=n(u);A!==null&&Z(j,A.startTime-P)}}function C(P,A){k=!1,w&&(w=!1,p(_),_=-1),v=!0;var T=m;try{for(x(A),f=n(c);f!==null&&(!(f.expirationTime>A)||P&&!B());){var V=f.callback;if(typeof V=="function"){f.callback=null,m=f.priorityLevel;var te=V(f.expirationTime<=A);A=e.unstable_now(),typeof te=="function"?f.callback=te:f===n(c)&&r(c),x(A)}else r(c);f=n(c)}if(f!==null)var O=!0;else{var Q=n(u);Q!==null&&Z(j,Q.startTime-A),O=!1}return O}finally{f=null,m=T,v=!1}}var S=!1,N=null,_=-1,z=5,L=-1;function B(){return!(e.unstable_now()-LP||125V?(P.sortIndex=T,t(u,P),n(c)===null&&P===n(u)&&(w?(p(_),_=-1):w=!0,Z(j,T-V))):(P.sortIndex=te,t(c,P),k||v||(k=!0,W(C))),P},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(P){var A=m;return function(){var T=m;m=A;try{return P.apply(this,arguments)}finally{m=T}}}})(hf);ff.exports=hf;var Rp=ff.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Mp=g,rt=Rp;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Pl=Object.prototype.hasOwnProperty,zp=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,lu={},ou={};function Fp(e){return Pl.call(ou,e)?!0:Pl.call(lu,e)?!1:zp.test(e)?ou[e]=!0:(lu[e]=!0,!1)}function Ip(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Dp(e,t,n,r){if(t===null||typeof t>"u"||Ip(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Ke(e,t,n,r,s,i,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=l}var Re={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Re[e]=new Ke(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Re[t]=new Ke(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Re[e]=new Ke(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Re[e]=new Ke(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Re[e]=new Ke(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Re[e]=new Ke(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Re[e]=new Ke(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Re[e]=new Ke(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Re[e]=new Ke(e,5,!1,e.toLowerCase(),null,!1,!1)});var Yo=/[\-:]([a-z])/g;function Xo(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Yo,Xo);Re[t]=new Ke(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Yo,Xo);Re[t]=new Ke(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Yo,Xo);Re[t]=new Ke(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Re[e]=new Ke(e,1,!1,e.toLowerCase(),null,!1,!1)});Re.xlinkHref=new Ke("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Re[e]=new Ke(e,1,!1,e.toLowerCase(),null,!0,!0)});function Zo(e,t,n,r){var s=Re.hasOwnProperty(t)?Re[t]:null;(s!==null?s.type!==0:r||!(2o||s[l]!==i[o]){var c=` +`+s[l].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{Yi=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?ys(e):""}function Ap(e){switch(e.tag){case 5:return ys(e.type);case 16:return ys("Lazy");case 13:return ys("Suspense");case 19:return ys("SuspenseList");case 0:case 2:case 15:return e=Xi(e.type,!1),e;case 11:return e=Xi(e.type.render,!1),e;case 1:return e=Xi(e.type,!0),e;default:return""}}function Rl(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case pr:return"Fragment";case mr:return"Portal";case Tl:return"Profiler";case ec:return"StrictMode";case Ol:return"Suspense";case Ll:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case xf:return(e.displayName||"Context")+".Consumer";case pf:return(e._context.displayName||"Context")+".Provider";case tc:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case nc:return t=e.displayName||null,t!==null?t:Rl(e.type)||"Memo";case tn:t=e._payload,e=e._init;try{return Rl(e(t))}catch{}}return null}function $p(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Rl(t);case 8:return t===ec?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function On(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function yf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Up(e){var t=yf(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(l){r=""+l,i.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ja(e){e._valueTracker||(e._valueTracker=Up(e))}function gf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=yf(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ya(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ml(e,t){var n=t.checked;return pe({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function uu(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=On(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function jf(e,t){t=t.checked,t!=null&&Zo(e,"checked",t,!1)}function zl(e,t){jf(e,t);var n=On(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Fl(e,t.type,n):t.hasOwnProperty("defaultValue")&&Fl(e,t.type,On(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function du(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Fl(e,t,n){(t!=="number"||Ya(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var gs=Array.isArray;function Cr(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=wa.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ms(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var bs={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Bp=["Webkit","ms","Moz","O"];Object.keys(bs).forEach(function(e){Bp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),bs[t]=bs[e]})});function Nf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||bs.hasOwnProperty(e)&&bs[e]?(""+t).trim():t+"px"}function Sf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=Nf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var Qp=pe({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Al(e,t){if(t){if(Qp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function $l(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ul=null;function rc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Bl=null,_r=null,Er=null;function mu(e){if(e=ua(e)){if(typeof Bl!="function")throw Error(E(280));var t=e.stateNode;t&&(t=Oi(t),Bl(e.stateNode,e.type,t))}}function Cf(e){_r?Er?Er.push(e):Er=[e]:_r=e}function _f(){if(_r){var e=_r,t=Er;if(Er=_r=null,mu(e),t)for(e=0;e>>=0,e===0?32:31-(ex(e)/tx|0)|0}var ka=64,ba=4194304;function js(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function ti(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~s;o!==0?r=js(o):(i&=l,i!==0&&(r=js(i)))}else l=n&~s,l!==0?r=js(l):i!==0&&(r=js(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function oa(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-bt(t),e[t]=n}function ax(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Ss),bu=" ",Nu=!1;function qf(e,t){switch(e){case"keyup":return Rx.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var xr=!1;function zx(e,t){switch(e){case"compositionend":return Wf(t);case"keypress":return t.which!==32?null:(Nu=!0,bu);case"textInput":return e=t.data,e===bu&&Nu?null:e;default:return null}}function Fx(e,t){if(xr)return e==="compositionend"||!dc&&qf(e,t)?(e=Kf(),Ua=oc=pn=null,xr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Eu(n)}}function Xf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Xf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Zf(){for(var e=window,t=Ya();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ya(e.document)}return t}function fc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Kx(e){var t=Zf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Xf(n.ownerDocument.documentElement,n)){if(r!==null&&fc(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=Pu(n,i);var l=Pu(n,r);s&&l&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,vr=null,Wl=null,_s=null,Gl=!1;function Tu(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Gl||vr==null||vr!==Ya(r)||(r=vr,"selectionStart"in r&&fc(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),_s&&$s(_s,r)||(_s=r,r=si(Wl,"onSelect"),0jr||(e.current=to[jr],to[jr]=null,jr--)}function le(e,t){jr++,to[jr]=e.current,e.current=t}var Ln={},De=zn(Ln),Je=zn(!1),nr=Ln;function Kr(e,t){var n=e.type.contextTypes;if(!n)return Ln;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function Ye(e){return e=e.childContextTypes,e!=null}function ii(){de(Je),de(De)}function Iu(e,t,n){if(De.current!==Ln)throw Error(E(168));le(De,t),le(Je,n)}function oh(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(E(108,$p(e)||"Unknown",s));return pe({},n,r)}function li(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ln,nr=De.current,le(De,e),le(Je,Je.current),!0}function Du(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=oh(e,t,nr),r.__reactInternalMemoizedMergedChildContext=e,de(Je),de(De),le(De,e)):de(Je),le(Je,n)}var It=null,Li=!1,fl=!1;function ch(e){It===null?It=[e]:It.push(e)}function rv(e){Li=!0,ch(e)}function Fn(){if(!fl&&It!==null){fl=!0;var e=0,t=ie;try{var n=It;for(ie=1;e>=l,s-=l,Bt=1<<32-bt(t)+s|n<_?(z=N,N=null):z=N.sibling;var L=m(p,N,x[_],j);if(L===null){N===null&&(N=z);break}e&&N&&L.alternate===null&&t(p,N),h=i(L,h,_),S===null?C=L:S.sibling=L,S=L,N=z}if(_===x.length)return n(p,N),fe&&An(p,_),C;if(N===null){for(;__?(z=N,N=null):z=N.sibling;var B=m(p,N,L.value,j);if(B===null){N===null&&(N=z);break}e&&N&&B.alternate===null&&t(p,N),h=i(B,h,_),S===null?C=B:S.sibling=B,S=B,N=z}if(L.done)return n(p,N),fe&&An(p,_),C;if(N===null){for(;!L.done;_++,L=x.next())L=f(p,L.value,j),L!==null&&(h=i(L,h,_),S===null?C=L:S.sibling=L,S=L);return fe&&An(p,_),C}for(N=r(p,N);!L.done;_++,L=x.next())L=v(N,p,_,L.value,j),L!==null&&(e&&L.alternate!==null&&N.delete(L.key===null?_:L.key),h=i(L,h,_),S===null?C=L:S.sibling=L,S=L);return e&&N.forEach(function(J){return t(p,J)}),fe&&An(p,_),C}function b(p,h,x,j){if(typeof x=="object"&&x!==null&&x.type===pr&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case ga:e:{for(var C=x.key,S=h;S!==null;){if(S.key===C){if(C=x.type,C===pr){if(S.tag===7){n(p,S.sibling),h=s(S,x.props.children),h.return=p,p=h;break e}}else if(S.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===tn&&Uu(C)===S.type){n(p,S.sibling),h=s(S,x.props),h.ref=hs(p,S,x),h.return=p,p=h;break e}n(p,S);break}else t(p,S);S=S.sibling}x.type===pr?(h=tr(x.props.children,p.mode,j,x.key),h.return=p,p=h):(j=Ga(x.type,x.key,x.props,null,p.mode,j),j.ref=hs(p,h,x),j.return=p,p=j)}return l(p);case mr:e:{for(S=x.key;h!==null;){if(h.key===S)if(h.tag===4&&h.stateNode.containerInfo===x.containerInfo&&h.stateNode.implementation===x.implementation){n(p,h.sibling),h=s(h,x.children||[]),h.return=p,p=h;break e}else{n(p,h);break}else t(p,h);h=h.sibling}h=jl(x,p.mode,j),h.return=p,p=h}return l(p);case tn:return S=x._init,b(p,h,S(x._payload),j)}if(gs(x))return k(p,h,x,j);if(os(x))return w(p,h,x,j);Ta(p,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,h!==null&&h.tag===6?(n(p,h.sibling),h=s(h,x),h.return=p,p=h):(n(p,h),h=gl(x,p.mode,j),h.return=p,p=h),l(p)):n(p,h)}return b}var qr=hh(!0),mh=hh(!1),ui=zn(null),di=null,br=null,xc=null;function vc(){xc=br=di=null}function yc(e){var t=ui.current;de(ui),e._currentValue=t}function so(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Tr(e,t){di=e,xc=br=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Ge=!0),e.firstContext=null)}function ft(e){var t=e._currentValue;if(xc!==e)if(e={context:e,memoizedValue:t,next:null},br===null){if(di===null)throw Error(E(308));br=e,di.dependencies={lanes:0,firstContext:e}}else br=br.next=e;return t}var Bn=null;function gc(e){Bn===null?Bn=[e]:Bn.push(e)}function ph(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,gc(t)):(n.next=s.next,s.next=n),t.interleaved=n,Wt(e,r)}function Wt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var nn=!1;function jc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function xh(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Vt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Nn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ne&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Wt(e,n)}return s=r.interleaved,s===null?(t.next=t,gc(r)):(t.next=s.next,s.next=t),r.interleaved=t,Wt(e,n)}function Qa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ac(e,n)}}function Bu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=l:i=i.next=l,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function fi(e,t,n,r){var s=e.updateQueue;nn=!1;var i=s.firstBaseUpdate,l=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var c=o,u=c.next;c.next=null,l===null?i=u:l.next=u,l=c;var d=e.alternate;d!==null&&(d=d.updateQueue,o=d.lastBaseUpdate,o!==l&&(o===null?d.firstBaseUpdate=u:o.next=u,d.lastBaseUpdate=c))}if(i!==null){var f=s.baseState;l=0,d=u=c=null,o=i;do{var m=o.lane,v=o.eventTime;if((r&m)===m){d!==null&&(d=d.next={eventTime:v,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var k=e,w=o;switch(m=t,v=n,w.tag){case 1:if(k=w.payload,typeof k=="function"){f=k.call(v,f,m);break e}f=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=w.payload,m=typeof k=="function"?k.call(v,f,m):k,m==null)break e;f=pe({},f,m);break e;case 2:nn=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,m=s.effects,m===null?s.effects=[o]:m.push(o))}else v={eventTime:v,lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},d===null?(u=d=v,c=f):d=d.next=v,l|=m;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;m=o,o=m.next,m.next=null,s.lastBaseUpdate=m,s.shared.pending=null}}while(!0);if(d===null&&(c=f),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=d,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);ar|=l,e.lanes=l,e.memoizedState=f}}function Qu(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ml.transition;ml.transition={};try{e(!1),t()}finally{ie=n,ml.transition=r}}function Rh(){return ht().memoizedState}function lv(e,t,n){var r=Cn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Mh(e))zh(t,n);else if(n=ph(e,t,n,r),n!==null){var s=Qe();Nt(n,e,r,s),Fh(n,t,r)}}function ov(e,t,n){var r=Cn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Mh(e))zh(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var l=t.lastRenderedState,o=i(l,n);if(s.hasEagerState=!0,s.eagerState=o,St(o,l)){var c=t.interleaved;c===null?(s.next=s,gc(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=ph(e,t,s,r),n!==null&&(s=Qe(),Nt(n,e,r,s),Fh(n,t,r))}}function Mh(e){var t=e.alternate;return e===me||t!==null&&t===me}function zh(e,t){Es=mi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Fh(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ac(e,n)}}var pi={readContext:ft,useCallback:Me,useContext:Me,useEffect:Me,useImperativeHandle:Me,useInsertionEffect:Me,useLayoutEffect:Me,useMemo:Me,useReducer:Me,useRef:Me,useState:Me,useDebugValue:Me,useDeferredValue:Me,useTransition:Me,useMutableSource:Me,useSyncExternalStore:Me,useId:Me,unstable_isNewReconciler:!1},cv={readContext:ft,useCallback:function(e,t){return _t().memoizedState=[e,t===void 0?null:t],e},useContext:ft,useEffect:Ku,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ka(4194308,4,Eh.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ka(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ka(4,2,e,t)},useMemo:function(e,t){var n=_t();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=_t();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=lv.bind(null,me,e),[r.memoizedState,e]},useRef:function(e){var t=_t();return e={current:e},t.memoizedState=e},useState:Vu,useDebugValue:Ec,useDeferredValue:function(e){return _t().memoizedState=e},useTransition:function(){var e=Vu(!1),t=e[0];return e=iv.bind(null,e[1]),_t().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=me,s=_t();if(fe){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),Te===null)throw Error(E(349));sr&30||jh(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Ku(kh.bind(null,r,i,e),[e]),r.flags|=2048,Ws(9,wh.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=_t(),t=Te.identifierPrefix;if(fe){var n=Qt,r=Bt;n=(r&~(1<<32-bt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Hs++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[Ot]=t,e[Qs]=r,Hh(e,t,!1,!1),t.stateNode=e;e:{switch(l=$l(n,r),n){case"dialog":ue("cancel",e),ue("close",e),s=r;break;case"iframe":case"object":case"embed":ue("load",e),s=r;break;case"video":case"audio":for(s=0;sJr&&(t.flags|=128,r=!0,ms(i,!1),t.lanes=4194304)}else{if(!r)if(e=hi(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ms(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!fe)return ze(t),null}else 2*je()-i.renderingStartTime>Jr&&n!==1073741824&&(t.flags|=128,r=!0,ms(i,!1),t.lanes=4194304);i.isBackwards?(l.sibling=t.child,t.child=l):(n=i.last,n!==null?n.sibling=l:t.child=l,i.last=l)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=je(),t.sibling=null,n=he.current,le(he,r?n&1|2:n&1),t):(ze(t),null);case 22:case 23:return Mc(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?et&1073741824&&(ze(t),t.subtreeFlags&6&&(t.flags|=8192)):ze(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function vv(e,t){switch(mc(t),t.tag){case 1:return Ye(t.type)&&ii(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Wr(),de(Je),de(De),bc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return kc(t),null;case 13:if(de(he),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));Hr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return de(he),null;case 4:return Wr(),null;case 10:return yc(t.type._context),null;case 22:case 23:return Mc(),null;case 24:return null;default:return null}}var La=!1,Ie=!1,yv=typeof WeakSet=="function"?WeakSet:Set,I=null;function Nr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ve(e,t,r)}else n.current=null}function mo(e,t,n){try{n()}catch(r){ve(e,t,r)}}var nd=!1;function gv(e,t){if(Jl=ni,e=Zf(),fc(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var l=0,o=-1,c=-1,u=0,d=0,f=e,m=null;t:for(;;){for(var v;f!==n||s!==0&&f.nodeType!==3||(o=l+s),f!==i||r!==0&&f.nodeType!==3||(c=l+r),f.nodeType===3&&(l+=f.nodeValue.length),(v=f.firstChild)!==null;)m=f,f=v;for(;;){if(f===e)break t;if(m===n&&++u===s&&(o=l),m===i&&++d===r&&(c=l),(v=f.nextSibling)!==null)break;f=m,m=f.parentNode}f=v}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Yl={focusedElem:e,selectionRange:n},ni=!1,I=t;I!==null;)if(t=I,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,I=e;else for(;I!==null;){t=I;try{var k=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(k!==null){var w=k.memoizedProps,b=k.memoizedState,p=t.stateNode,h=p.getSnapshotBeforeUpdate(t.elementType===t.type?w:vt(t.type,w),b);p.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(j){ve(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,I=e;break}I=t.return}return k=nd,nd=!1,k}function Ps(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&mo(t,n,i)}s=s.next}while(s!==r)}}function zi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function po(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Gh(e){var t=e.alternate;t!==null&&(e.alternate=null,Gh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ot],delete t[Qs],delete t[eo],delete t[tv],delete t[nv])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Jh(e){return e.tag===5||e.tag===3||e.tag===4}function rd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Jh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function xo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ai));else if(r!==4&&(e=e.child,e!==null))for(xo(e,t,n),e=e.sibling;e!==null;)xo(e,t,n),e=e.sibling}function vo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(vo(e,t,n),e=e.sibling;e!==null;)vo(e,t,n),e=e.sibling}var Oe=null,jt=!1;function Zt(e,t,n){for(n=n.child;n!==null;)Yh(e,t,n),n=n.sibling}function Yh(e,t,n){if(Lt&&typeof Lt.onCommitFiberUnmount=="function")try{Lt.onCommitFiberUnmount(_i,n)}catch{}switch(n.tag){case 5:Ie||Nr(n,t);case 6:var r=Oe,s=jt;Oe=null,Zt(e,t,n),Oe=r,jt=s,Oe!==null&&(jt?(e=Oe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Oe.removeChild(n.stateNode));break;case 18:Oe!==null&&(jt?(e=Oe,n=n.stateNode,e.nodeType===8?dl(e.parentNode,n):e.nodeType===1&&dl(e,n),Ds(e)):dl(Oe,n.stateNode));break;case 4:r=Oe,s=jt,Oe=n.stateNode.containerInfo,jt=!0,Zt(e,t,n),Oe=r,jt=s;break;case 0:case 11:case 14:case 15:if(!Ie&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,l=i.destroy;i=i.tag,l!==void 0&&(i&2||i&4)&&mo(n,t,l),s=s.next}while(s!==r)}Zt(e,t,n);break;case 1:if(!Ie&&(Nr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){ve(n,t,o)}Zt(e,t,n);break;case 21:Zt(e,t,n);break;case 22:n.mode&1?(Ie=(r=Ie)||n.memoizedState!==null,Zt(e,t,n),Ie=r):Zt(e,t,n);break;default:Zt(e,t,n)}}function sd(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new yv),t.forEach(function(r){var s=Ev.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function pt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=l),r&=~i}if(r=s,r=je()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*wv(r/1960))-r,10e?16:e,xn===null)var r=!1;else{if(e=xn,xn=null,yi=0,ne&6)throw Error(E(331));var s=ne;for(ne|=4,I=e.current;I!==null;){var i=I,l=i.child;if(I.flags&16){var o=i.deletions;if(o!==null){for(var c=0;cje()-Lc?er(e,0):Oc|=n),Xe(e,t)}function am(e,t){t===0&&(e.mode&1?(t=ba,ba<<=1,!(ba&130023424)&&(ba=4194304)):t=1);var n=Qe();e=Wt(e,t),e!==null&&(oa(e,t,n),Xe(e,n))}function _v(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),am(e,n)}function Ev(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),am(e,n)}var im;im=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Je.current)Ge=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Ge=!1,pv(e,t,n);Ge=!!(e.flags&131072)}else Ge=!1,fe&&t.flags&1048576&&uh(t,ci,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ha(e,t),e=t.pendingProps;var s=Kr(t,De.current);Tr(t,n),s=Sc(null,t,r,e,s,n);var i=Cc();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Ye(r)?(i=!0,li(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,jc(t),s.updater=Mi,t.stateNode=s,s._reactInternals=t,io(t,r,e,n),t=co(null,t,r,!0,i,n)):(t.tag=0,fe&&i&&hc(t),Ue(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ha(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=Tv(r),e=vt(r,e),s){case 0:t=oo(null,t,r,e,n);break e;case 1:t=Zu(null,t,r,e,n);break e;case 11:t=Yu(null,t,r,e,n);break e;case 14:t=Xu(null,t,r,vt(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:vt(r,s),oo(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:vt(r,s),Zu(e,t,r,s,n);case 3:e:{if(Qh(t),e===null)throw Error(E(387));r=t.pendingProps,i=t.memoizedState,s=i.element,xh(e,t),fi(t,r,null,n);var l=t.memoizedState;if(r=l.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=Gr(Error(E(423)),t),t=ed(e,t,r,n,s);break e}else if(r!==s){s=Gr(Error(E(424)),t),t=ed(e,t,r,n,s);break e}else for(tt=bn(t.stateNode.containerInfo.firstChild),nt=t,fe=!0,wt=null,n=mh(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Hr(),r===s){t=Gt(e,t,n);break e}Ue(e,t,r,n)}t=t.child}return t;case 5:return vh(t),e===null&&ro(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,l=s.children,Xl(r,s)?l=null:i!==null&&Xl(r,i)&&(t.flags|=32),Bh(e,t),Ue(e,t,l,n),t.child;case 6:return e===null&&ro(t),null;case 13:return Vh(e,t,n);case 4:return wc(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=qr(t,null,r,n):Ue(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:vt(r,s),Yu(e,t,r,s,n);case 7:return Ue(e,t,t.pendingProps,n),t.child;case 8:return Ue(e,t,t.pendingProps.children,n),t.child;case 12:return Ue(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,l=s.value,le(ui,r._currentValue),r._currentValue=l,i!==null)if(St(i.value,l)){if(i.children===s.children&&!Je.current){t=Gt(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var o=i.dependencies;if(o!==null){l=i.child;for(var c=o.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=Vt(-1,n&-n),c.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),so(i.return,n,t),o.lanes|=n;break}c=c.next}}else if(i.tag===10)l=i.type===t.type?null:i.child;else if(i.tag===18){if(l=i.return,l===null)throw Error(E(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),so(l,n,t),l=i.sibling}else l=i.child;if(l!==null)l.return=i;else for(l=i;l!==null;){if(l===t){l=null;break}if(i=l.sibling,i!==null){i.return=l.return,l=i;break}l=l.return}i=l}Ue(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Tr(t,n),s=ft(s),r=r(s),t.flags|=1,Ue(e,t,r,n),t.child;case 14:return r=t.type,s=vt(r,t.pendingProps),s=vt(r.type,s),Xu(e,t,r,s,n);case 15:return $h(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:vt(r,s),Ha(e,t),t.tag=1,Ye(r)?(e=!0,li(t)):e=!1,Tr(t,n),Ih(t,r,s),io(t,r,s,n),co(null,t,r,!0,e,n);case 19:return Kh(e,t,n);case 22:return Uh(e,t,n)}throw Error(E(156,t.tag))};function lm(e,t){return Mf(e,t)}function Pv(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ut(e,t,n,r){return new Pv(e,t,n,r)}function Fc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Tv(e){if(typeof e=="function")return Fc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===tc)return 11;if(e===nc)return 14}return 2}function _n(e,t){var n=e.alternate;return n===null?(n=ut(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ga(e,t,n,r,s,i){var l=2;if(r=e,typeof e=="function")Fc(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case pr:return tr(n.children,s,i,t);case ec:l=8,s|=8;break;case Tl:return e=ut(12,n,t,s|2),e.elementType=Tl,e.lanes=i,e;case Ol:return e=ut(13,n,t,s),e.elementType=Ol,e.lanes=i,e;case Ll:return e=ut(19,n,t,s),e.elementType=Ll,e.lanes=i,e;case vf:return Ii(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case pf:l=10;break e;case xf:l=9;break e;case tc:l=11;break e;case nc:l=14;break e;case tn:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=ut(l,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function tr(e,t,n,r){return e=ut(7,e,r,t),e.lanes=n,e}function Ii(e,t,n,r){return e=ut(22,e,r,t),e.elementType=vf,e.lanes=n,e.stateNode={isHidden:!1},e}function gl(e,t,n){return e=ut(6,e,null,t),e.lanes=n,e}function jl(e,t,n){return t=ut(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Ov(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=el(0),this.expirationTimes=el(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=el(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Ic(e,t,n,r,s,i,l,o,c){return e=new Ov(e,t,n,o,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=ut(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},jc(i),e}function Lv(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(dm)}catch(e){console.error(e)}}dm(),df.exports=st;var Iv=df.exports,fd=Iv;El.createRoot=fd.createRoot,El.hydrateRoot=fd.hydrateRoot;var rs=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Dv={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},an,Ko,Ud,Av=(Ud=class{constructor(){$(this,an,Dv);$(this,Ko,!1)}setTimeoutProvider(e){M(this,an,e)}setTimeout(e,t){return y(this,an).setTimeout(e,t)}clearTimeout(e){y(this,an).clearTimeout(e)}setInterval(e,t){return y(this,an).setInterval(e,t)}clearInterval(e){y(this,an).clearInterval(e)}},an=new WeakMap,Ko=new WeakMap,Ud),Vn=new Av;function $v(e){setTimeout(e,0)}var lr=typeof window>"u"||"Deno"in globalThis;function Be(){}function Uv(e,t){return typeof e=="function"?e(t):e}function ko(e){return typeof e=="number"&&e>=0&&e!==1/0}function fm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function En(e,t){return typeof e=="function"?e(t):e}function lt(e,t){return typeof e=="function"?e(t):e}function hd(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:i,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==Uc(l,t.options))return!1}else if(!Js(t.queryKey,l))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||s&&s!==t.state.fetchStatus||i&&!i(t))}function md(e,t){const{exact:n,status:r,predicate:s,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(or(t.options.mutationKey)!==or(i))return!1}else if(!Js(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function Uc(e,t){return((t==null?void 0:t.queryKeyHashFn)||or)(e)}function or(e){return JSON.stringify(e,(t,n)=>bo(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function Js(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Js(e[n],t[n])):!1}var Bv=Object.prototype.hasOwnProperty;function hm(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=pd(e)&&pd(t);if(!r&&!(bo(e)&&bo(t)))return t;const i=(r?e:Object.keys(e)).length,l=r?t:Object.keys(t),o=l.length,c=r?new Array(o):{};let u=0;for(let d=0;d{Vn.setTimeout(t,e)})}function No(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?hm(e,t):t}function Vv(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Kv(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Bc=Symbol();function mm(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Bc?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Qc(e,t){return typeof e=="function"?e(...t):!!e}function Hv(e,t,n){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),e}var Kn,ln,Lr,Bd,qv=(Bd=class extends rs{constructor(){super();$(this,Kn);$(this,ln);$(this,Lr);M(this,Lr,t=>{if(!lr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){y(this,ln)||this.setEventListener(y(this,Lr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,ln))==null||t.call(this),M(this,ln,void 0))}setEventListener(t){var n;M(this,Lr,t),(n=y(this,ln))==null||n.call(this),M(this,ln,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){y(this,Kn)!==t&&(M(this,Kn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof y(this,Kn)=="boolean"?y(this,Kn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Kn=new WeakMap,ln=new WeakMap,Lr=new WeakMap,Bd),Vc=new qv;function So(){let e,t;const n=new Promise((s,i)=>{e=s,t=i});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var Wv=$v;function Gv(){let e=[],t=0,n=o=>{o()},r=o=>{o()},s=Wv;const i=o=>{t?e.push(o):s(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&s(()=>{r(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;t++;try{c=o()}finally{t--,t||l()}return c},batchCalls:o=>(...c)=>{i(()=>{o(...c)})},schedule:i,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{s=o}}}var Ne=Gv(),Rr,on,Mr,Qd,Jv=(Qd=class extends rs{constructor(){super();$(this,Rr,!0);$(this,on);$(this,Mr);M(this,Mr,t=>{if(!lr&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){y(this,on)||this.setEventListener(y(this,Mr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,on))==null||t.call(this),M(this,on,void 0))}setEventListener(t){var n;M(this,Mr,t),(n=y(this,on))==null||n.call(this),M(this,on,t(this.setOnline.bind(this)))}setOnline(t){y(this,Rr)!==t&&(M(this,Rr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return y(this,Rr)}},Rr=new WeakMap,on=new WeakMap,Mr=new WeakMap,Qd),ki=new Jv;function Yv(e){return Math.min(1e3*2**e,3e4)}function pm(e){return(e??"online")==="online"?ki.isOnline():!0}var Co=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function xm(e){let t=!1,n=0,r;const s=So(),i=()=>s.status!=="pending",l=w=>{var b;if(!i()){const p=new Co(w);m(p),(b=e.onCancel)==null||b.call(e,p)}},o=()=>{t=!0},c=()=>{t=!1},u=()=>Vc.isFocused()&&(e.networkMode==="always"||ki.isOnline())&&e.canRun(),d=()=>pm(e.networkMode)&&e.canRun(),f=w=>{i()||(r==null||r(),s.resolve(w))},m=w=>{i()||(r==null||r(),s.reject(w))},v=()=>new Promise(w=>{var b;r=p=>{(i()||u())&&w(p)},(b=e.onPause)==null||b.call(e)}).then(()=>{var w;r=void 0,i()||(w=e.onContinue)==null||w.call(e)}),k=()=>{if(i())return;let w;const b=n===0?e.initialPromise:void 0;try{w=b??e.fn()}catch(p){w=Promise.reject(p)}Promise.resolve(w).then(f).catch(p=>{var S;if(i())return;const h=e.retry??(lr?0:3),x=e.retryDelay??Yv,j=typeof x=="function"?x(n,p):x,C=h===!0||typeof h=="number"&&nu()?void 0:v()).then(()=>{t?m(p):k()})})};return{promise:s,status:()=>s.status,cancel:l,continue:()=>(r==null||r(),s),cancelRetry:o,continueRetry:c,canStart:d,start:()=>(d()?k():v().then(k),s)}}var Hn,Vd,vm=(Vd=class{constructor(){$(this,Hn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ko(this.gcTime)&&M(this,Hn,Vn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(lr?1/0:5*60*1e3))}clearGcTimeout(){y(this,Hn)&&(Vn.clearTimeout(y(this,Hn)),M(this,Hn,void 0))}},Hn=new WeakMap,Vd),qn,zr,it,Wn,Ee,na,Gn,yt,zt,Kd,Xv=(Kd=class extends vm{constructor(t){super();$(this,yt);$(this,qn);$(this,zr);$(this,it);$(this,Wn);$(this,Ee);$(this,na);$(this,Gn);M(this,Gn,!1),M(this,na,t.defaultOptions),this.setOptions(t.options),this.observers=[],M(this,Wn,t.client),M(this,it,y(this,Wn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,M(this,qn,yd(this.options)),this.state=t.state??y(this,qn),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=y(this,Ee))==null?void 0:t.promise}setOptions(t){if(this.options={...y(this,na),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=yd(this.options);n.data!==void 0&&(this.setState(vd(n.data,n.dataUpdatedAt)),M(this,qn,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&y(this,it).remove(this)}setData(t,n){const r=No(this.state.data,t,this.options);return G(this,yt,zt).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){G(this,yt,zt).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=y(this,Ee))==null?void 0:r.promise;return(s=y(this,Ee))==null||s.cancel(t),n?n.then(Be).catch(Be):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(y(this,qn))}isActive(){return this.observers.some(t=>lt(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Bc||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>En(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!fm(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ee))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ee))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),y(this,it).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(y(this,Ee)&&(y(this,Gn)?y(this,Ee).cancel({revert:!0}):y(this,Ee).cancelRetry()),this.scheduleGc()),y(this,it).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||G(this,yt,zt).call(this,{type:"invalidate"})}async fetch(t,n){var c,u,d,f,m,v,k,w,b,p,h,x;if(this.state.fetchStatus!=="idle"&&((c=y(this,Ee))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(y(this,Ee))return y(this,Ee).continueRetry(),y(this,Ee).promise}if(t&&this.setOptions(t),!this.options.queryFn){const j=this.observers.find(C=>C.options.queryFn);j&&this.setOptions(j.options)}const r=new AbortController,s=j=>{Object.defineProperty(j,"signal",{enumerable:!0,get:()=>(M(this,Gn,!0),r.signal)})},i=()=>{const j=mm(this.options,n),S=(()=>{const N={client:y(this,Wn),queryKey:this.queryKey,meta:this.meta};return s(N),N})();return M(this,Gn,!1),this.options.persister?this.options.persister(j,S,this):j(S)},o=(()=>{const j={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:y(this,Wn),state:this.state,fetchFn:i};return s(j),j})();(u=this.options.behavior)==null||u.onFetch(o,this),M(this,zr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=o.fetchOptions)==null?void 0:d.meta))&&G(this,yt,zt).call(this,{type:"fetch",meta:(f=o.fetchOptions)==null?void 0:f.meta}),M(this,Ee,xm({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:j=>{j instanceof Co&&j.revert&&this.setState({...y(this,zr),fetchStatus:"idle"}),r.abort()},onFail:(j,C)=>{G(this,yt,zt).call(this,{type:"failed",failureCount:j,error:C})},onPause:()=>{G(this,yt,zt).call(this,{type:"pause"})},onContinue:()=>{G(this,yt,zt).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const j=await y(this,Ee).start();if(j===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(j),(v=(m=y(this,it).config).onSuccess)==null||v.call(m,j,this),(w=(k=y(this,it).config).onSettled)==null||w.call(k,j,this.state.error,this),j}catch(j){if(j instanceof Co){if(j.silent)return y(this,Ee).promise;if(j.revert){if(this.state.data===void 0)throw j;return this.state.data}}throw G(this,yt,zt).call(this,{type:"error",error:j}),(p=(b=y(this,it).config).onError)==null||p.call(b,j,this),(x=(h=y(this,it).config).onSettled)==null||x.call(h,this.state.data,j,this),j}finally{this.scheduleGc()}}},qn=new WeakMap,zr=new WeakMap,it=new WeakMap,Wn=new WeakMap,Ee=new WeakMap,na=new WeakMap,Gn=new WeakMap,yt=new WeakSet,zt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...ym(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...vd(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return M(this,zr,t.manual?s:void 0),s;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Ne.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),y(this,it).notify({query:this,type:"updated",action:t})})},Kd);function ym(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:pm(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function vd(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function yd(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var He,ee,ra,$e,Jn,Fr,Dt,cn,sa,Ir,Dr,Yn,Xn,un,Ar,ae,ks,_o,Eo,Po,To,Oo,Lo,Ro,gm,Hd,Zv=(Hd=class extends rs{constructor(t,n){super();$(this,ae);$(this,He);$(this,ee);$(this,ra);$(this,$e);$(this,Jn);$(this,Fr);$(this,Dt);$(this,cn);$(this,sa);$(this,Ir);$(this,Dr);$(this,Yn);$(this,Xn);$(this,un);$(this,Ar,new Set);this.options=n,M(this,He,t),M(this,cn,null),M(this,Dt,So()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(y(this,ee).addObserver(this),gd(y(this,ee),this.options)?G(this,ae,ks).call(this):this.updateResult(),G(this,ae,To).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Mo(y(this,ee),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Mo(y(this,ee),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,G(this,ae,Oo).call(this),G(this,ae,Lo).call(this),y(this,ee).removeObserver(this)}setOptions(t){const n=this.options,r=y(this,ee);if(this.options=y(this,He).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof lt(this.options.enabled,y(this,ee))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");G(this,ae,Ro).call(this),y(this,ee).setOptions(this.options),n._defaulted&&!wi(this.options,n)&&y(this,He).getQueryCache().notify({type:"observerOptionsUpdated",query:y(this,ee),observer:this});const s=this.hasListeners();s&&jd(y(this,ee),r,this.options,n)&&G(this,ae,ks).call(this),this.updateResult(),s&&(y(this,ee)!==r||lt(this.options.enabled,y(this,ee))!==lt(n.enabled,y(this,ee))||En(this.options.staleTime,y(this,ee))!==En(n.staleTime,y(this,ee)))&&G(this,ae,_o).call(this);const i=G(this,ae,Eo).call(this);s&&(y(this,ee)!==r||lt(this.options.enabled,y(this,ee))!==lt(n.enabled,y(this,ee))||i!==y(this,un))&&G(this,ae,Po).call(this,i)}getOptimisticResult(t){const n=y(this,He).getQueryCache().build(y(this,He),t),r=this.createResult(n,t);return ty(this,r)&&(M(this,$e,r),M(this,Fr,this.options),M(this,Jn,y(this,ee).state)),r}getCurrentResult(){return y(this,$e)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&y(this,Dt).status==="pending"&&y(this,Dt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){y(this,Ar).add(t)}getCurrentQuery(){return y(this,ee)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=y(this,He).defaultQueryOptions(t),r=y(this,He).getQueryCache().build(y(this,He),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return G(this,ae,ks).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),y(this,$e)))}createResult(t,n){var z;const r=y(this,ee),s=this.options,i=y(this,$e),l=y(this,Jn),o=y(this,Fr),u=t!==r?t.state:y(this,ra),{state:d}=t;let f={...d},m=!1,v;if(n._optimisticResults){const L=this.hasListeners(),B=!L&&gd(t,n),J=L&&jd(t,r,n,s);(B||J)&&(f={...f,...ym(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:k,errorUpdatedAt:w,status:b}=f;v=f.data;let p=!1;if(n.placeholderData!==void 0&&v===void 0&&b==="pending"){let L;i!=null&&i.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(L=i.data,p=!0):L=typeof n.placeholderData=="function"?n.placeholderData((z=y(this,Dr))==null?void 0:z.state.data,y(this,Dr)):n.placeholderData,L!==void 0&&(b="success",v=No(i==null?void 0:i.data,L,n),m=!0)}if(n.select&&v!==void 0&&!p)if(i&&v===(l==null?void 0:l.data)&&n.select===y(this,sa))v=y(this,Ir);else try{M(this,sa,n.select),v=n.select(v),v=No(i==null?void 0:i.data,v,n),M(this,Ir,v),M(this,cn,null)}catch(L){M(this,cn,L)}y(this,cn)&&(k=y(this,cn),v=y(this,Ir),w=Date.now(),b="error");const h=f.fetchStatus==="fetching",x=b==="pending",j=b==="error",C=x&&h,S=v!==void 0,_={status:b,fetchStatus:f.fetchStatus,isPending:x,isSuccess:b==="success",isError:j,isInitialLoading:C,isLoading:C,data:v,dataUpdatedAt:f.dataUpdatedAt,error:k,errorUpdatedAt:w,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:h,isRefetching:h&&!x,isLoadingError:j&&!S,isPaused:f.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:j&&S,isStale:Kc(t,n),refetch:this.refetch,promise:y(this,Dt),isEnabled:lt(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const L=_.data!==void 0,B=_.status==="error"&&!L,J=D=>{B?D.reject(_.error):L&&D.resolve(_.data)},se=()=>{const D=M(this,Dt,_.promise=So());J(D)},ce=y(this,Dt);switch(ce.status){case"pending":t.queryHash===r.queryHash&&J(ce);break;case"fulfilled":(B||_.data!==ce.value)&&se();break;case"rejected":(!B||_.error!==ce.reason)&&se();break}}return _}updateResult(){const t=y(this,$e),n=this.createResult(y(this,ee),this.options);if(M(this,Jn,y(this,ee).state),M(this,Fr,this.options),y(this,Jn).data!==void 0&&M(this,Dr,y(this,ee)),wi(n,t))return;M(this,$e,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!y(this,Ar).size)return!0;const l=new Set(i??y(this,Ar));return this.options.throwOnError&&l.add("error"),Object.keys(y(this,$e)).some(o=>{const c=o;return y(this,$e)[c]!==t[c]&&l.has(c)})};G(this,ae,gm).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&G(this,ae,To).call(this)}},He=new WeakMap,ee=new WeakMap,ra=new WeakMap,$e=new WeakMap,Jn=new WeakMap,Fr=new WeakMap,Dt=new WeakMap,cn=new WeakMap,sa=new WeakMap,Ir=new WeakMap,Dr=new WeakMap,Yn=new WeakMap,Xn=new WeakMap,un=new WeakMap,Ar=new WeakMap,ae=new WeakSet,ks=function(t){G(this,ae,Ro).call(this);let n=y(this,ee).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Be)),n},_o=function(){G(this,ae,Oo).call(this);const t=En(this.options.staleTime,y(this,ee));if(lr||y(this,$e).isStale||!ko(t))return;const r=fm(y(this,$e).dataUpdatedAt,t)+1;M(this,Yn,Vn.setTimeout(()=>{y(this,$e).isStale||this.updateResult()},r))},Eo=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(y(this,ee)):this.options.refetchInterval)??!1},Po=function(t){G(this,ae,Lo).call(this),M(this,un,t),!(lr||lt(this.options.enabled,y(this,ee))===!1||!ko(y(this,un))||y(this,un)===0)&&M(this,Xn,Vn.setInterval(()=>{(this.options.refetchIntervalInBackground||Vc.isFocused())&&G(this,ae,ks).call(this)},y(this,un)))},To=function(){G(this,ae,_o).call(this),G(this,ae,Po).call(this,G(this,ae,Eo).call(this))},Oo=function(){y(this,Yn)&&(Vn.clearTimeout(y(this,Yn)),M(this,Yn,void 0))},Lo=function(){y(this,Xn)&&(Vn.clearInterval(y(this,Xn)),M(this,Xn,void 0))},Ro=function(){const t=y(this,He).getQueryCache().build(y(this,He),this.options);if(t===y(this,ee))return;const n=y(this,ee);M(this,ee,t),M(this,ra,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},gm=function(t){Ne.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(y(this,$e))}),y(this,He).getQueryCache().notify({query:y(this,ee),type:"observerResultsUpdated"})})},Hd);function ey(e,t){return lt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function gd(e,t){return ey(e,t)||e.state.data!==void 0&&Mo(e,t,t.refetchOnMount)}function Mo(e,t,n){if(lt(t.enabled,e)!==!1&&En(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Kc(e,t)}return!1}function jd(e,t,n,r){return(e!==t||lt(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Kc(e,n)}function Kc(e,t){return lt(t.enabled,e)!==!1&&e.isStaleByTime(En(t.staleTime,e))}function ty(e,t){return!wi(e.getCurrentResult(),t)}function wd(e){return{onFetch:(t,n)=>{var d,f,m,v,k;const r=t.options,s=(m=(f=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:f.fetchMore)==null?void 0:m.direction,i=((v=t.state.data)==null?void 0:v.pages)||[],l=((k=t.state.data)==null?void 0:k.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const u=async()=>{let w=!1;const b=x=>{Hv(x,()=>t.signal,()=>w=!0)},p=mm(t.options,t.fetchOptions),h=async(x,j,C)=>{if(w)return Promise.reject();if(j==null&&x.pages.length)return Promise.resolve(x);const N=(()=>{const B={client:t.client,queryKey:t.queryKey,pageParam:j,direction:C?"backward":"forward",meta:t.options.meta};return b(B),B})(),_=await p(N),{maxPages:z}=t.options,L=C?Kv:Vv;return{pages:L(x.pages,_,z),pageParams:L(x.pageParams,j,z)}};if(s&&i.length){const x=s==="backward",j=x?ny:kd,C={pages:i,pageParams:l},S=j(r,C);o=await h(C,S,x)}else{const x=e??i.length;do{const j=c===0?l[0]??r.initialPageParam:kd(r,o);if(c>0&&j==null)break;o=await h(o,j),c++}while(c{var w,b;return(b=(w=t.options).persister)==null?void 0:b.call(w,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function kd(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function ny(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var aa,Et,Fe,Zn,Pt,en,qd,ry=(qd=class extends vm{constructor(t){super();$(this,Pt);$(this,aa);$(this,Et);$(this,Fe);$(this,Zn);M(this,aa,t.client),this.mutationId=t.mutationId,M(this,Fe,t.mutationCache),M(this,Et,[]),this.state=t.state||jm(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){y(this,Et).includes(t)||(y(this,Et).push(t),this.clearGcTimeout(),y(this,Fe).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){M(this,Et,y(this,Et).filter(n=>n!==t)),this.scheduleGc(),y(this,Fe).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){y(this,Et).length||(this.state.status==="pending"?this.scheduleGc():y(this,Fe).remove(this))}continue(){var t;return((t=y(this,Zn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,u,d,f,m,v,k,w,b,p,h,x,j,C,S,N;const n=()=>{G(this,Pt,en).call(this,{type:"continue"})},r={client:y(this,aa),meta:this.options.meta,mutationKey:this.options.mutationKey};M(this,Zn,xm({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(_,z)=>{G(this,Pt,en).call(this,{type:"failed",failureCount:_,error:z})},onPause:()=>{G(this,Pt,en).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>y(this,Fe).canRun(this)}));const s=this.state.status==="pending",i=!y(this,Zn).canStart();try{if(s)n();else{G(this,Pt,en).call(this,{type:"pending",variables:t,isPaused:i}),y(this,Fe).config.onMutate&&await y(this,Fe).config.onMutate(t,this,r);const z=await((o=(l=this.options).onMutate)==null?void 0:o.call(l,t,r));z!==this.state.context&&G(this,Pt,en).call(this,{type:"pending",context:z,variables:t,isPaused:i})}const _=await y(this,Zn).start();return await((u=(c=y(this,Fe).config).onSuccess)==null?void 0:u.call(c,_,t,this.state.context,this,r)),await((f=(d=this.options).onSuccess)==null?void 0:f.call(d,_,t,this.state.context,r)),await((v=(m=y(this,Fe).config).onSettled)==null?void 0:v.call(m,_,null,this.state.variables,this.state.context,this,r)),await((w=(k=this.options).onSettled)==null?void 0:w.call(k,_,null,t,this.state.context,r)),G(this,Pt,en).call(this,{type:"success",data:_}),_}catch(_){try{await((p=(b=y(this,Fe).config).onError)==null?void 0:p.call(b,_,t,this.state.context,this,r))}catch(z){Promise.reject(z)}try{await((x=(h=this.options).onError)==null?void 0:x.call(h,_,t,this.state.context,r))}catch(z){Promise.reject(z)}try{await((C=(j=y(this,Fe).config).onSettled)==null?void 0:C.call(j,void 0,_,this.state.variables,this.state.context,this,r))}catch(z){Promise.reject(z)}try{await((N=(S=this.options).onSettled)==null?void 0:N.call(S,void 0,_,t,this.state.context,r))}catch(z){Promise.reject(z)}throw G(this,Pt,en).call(this,{type:"error",error:_}),_}finally{y(this,Fe).runNext(this)}}},aa=new WeakMap,Et=new WeakMap,Fe=new WeakMap,Zn=new WeakMap,Pt=new WeakSet,en=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Ne.batch(()=>{y(this,Et).forEach(r=>{r.onMutationUpdate(t)}),y(this,Fe).notify({mutation:this,type:"updated",action:t})})},qd);function jm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var At,gt,ia,Wd,sy=(Wd=class extends rs{constructor(t={}){super();$(this,At);$(this,gt);$(this,ia);this.config=t,M(this,At,new Set),M(this,gt,new Map),M(this,ia,0)}build(t,n,r){const s=new ry({client:t,mutationCache:this,mutationId:++va(this,ia)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){y(this,At).add(t);const n=za(t);if(typeof n=="string"){const r=y(this,gt).get(n);r?r.push(t):y(this,gt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(y(this,At).delete(t)){const n=za(t);if(typeof n=="string"){const r=y(this,gt).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&y(this,gt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=za(t);if(typeof n=="string"){const r=y(this,gt).get(n),s=r==null?void 0:r.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=za(t);if(typeof n=="string"){const s=(r=y(this,gt).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Ne.batch(()=>{y(this,At).forEach(t=>{this.notify({type:"removed",mutation:t})}),y(this,At).clear(),y(this,gt).clear()})}getAll(){return Array.from(y(this,At))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>md(n,r))}findAll(t={}){return this.getAll().filter(n=>md(t,n))}notify(t){Ne.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Ne.batch(()=>Promise.all(t.map(n=>n.continue().catch(Be))))}},At=new WeakMap,gt=new WeakMap,ia=new WeakMap,Wd);function za(e){var t;return(t=e.options.scope)==null?void 0:t.id}var $t,dn,qe,Ut,Kt,Ja,zo,Gd,ay=(Gd=class extends rs{constructor(n,r){super();$(this,Kt);$(this,$t);$(this,dn);$(this,qe);$(this,Ut);M(this,$t,n),this.setOptions(r),this.bindMethods(),G(this,Kt,Ja).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=y(this,$t).defaultMutationOptions(n),wi(this.options,r)||y(this,$t).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,qe),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&or(r.mutationKey)!==or(this.options.mutationKey)?this.reset():((s=y(this,qe))==null?void 0:s.state.status)==="pending"&&y(this,qe).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=y(this,qe))==null||n.removeObserver(this)}onMutationUpdate(n){G(this,Kt,Ja).call(this),G(this,Kt,zo).call(this,n)}getCurrentResult(){return y(this,dn)}reset(){var n;(n=y(this,qe))==null||n.removeObserver(this),M(this,qe,void 0),G(this,Kt,Ja).call(this),G(this,Kt,zo).call(this)}mutate(n,r){var s;return M(this,Ut,r),(s=y(this,qe))==null||s.removeObserver(this),M(this,qe,y(this,$t).getMutationCache().build(y(this,$t),this.options)),y(this,qe).addObserver(this),y(this,qe).execute(n)}},$t=new WeakMap,dn=new WeakMap,qe=new WeakMap,Ut=new WeakMap,Kt=new WeakSet,Ja=function(){var r;const n=((r=y(this,qe))==null?void 0:r.state)??jm();M(this,dn,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},zo=function(n){Ne.batch(()=>{var r,s,i,l,o,c,u,d;if(y(this,Ut)&&this.hasListeners()){const f=y(this,dn).variables,m=y(this,dn).context,v={client:y(this,$t),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(s=(r=y(this,Ut)).onSuccess)==null||s.call(r,n.data,f,m,v)}catch(k){Promise.reject(k)}try{(l=(i=y(this,Ut)).onSettled)==null||l.call(i,n.data,null,f,m,v)}catch(k){Promise.reject(k)}}else if((n==null?void 0:n.type)==="error"){try{(c=(o=y(this,Ut)).onError)==null||c.call(o,n.error,f,m,v)}catch(k){Promise.reject(k)}try{(d=(u=y(this,Ut)).onSettled)==null||d.call(u,void 0,n.error,f,m,v)}catch(k){Promise.reject(k)}}}this.listeners.forEach(f=>{f(y(this,dn))})})},Gd),Tt,Jd,iy=(Jd=class extends rs{constructor(t={}){super();$(this,Tt);this.config=t,M(this,Tt,new Map)}build(t,n,r){const s=n.queryKey,i=n.queryHash??Uc(s,n);let l=this.get(i);return l||(l=new Xv({client:t,queryKey:s,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(l)),l}add(t){y(this,Tt).has(t.queryHash)||(y(this,Tt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=y(this,Tt).get(t.queryHash);n&&(t.destroy(),n===t&&y(this,Tt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Ne.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return y(this,Tt).get(t)}getAll(){return[...y(this,Tt).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>hd(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>hd(t,r)):n}notify(t){Ne.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Ne.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Ne.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Tt=new WeakMap,Jd),xe,fn,hn,$r,Ur,mn,Br,Qr,Yd,ly=(Yd=class{constructor(e={}){$(this,xe);$(this,fn);$(this,hn);$(this,$r);$(this,Ur);$(this,mn);$(this,Br);$(this,Qr);M(this,xe,e.queryCache||new iy),M(this,fn,e.mutationCache||new sy),M(this,hn,e.defaultOptions||{}),M(this,$r,new Map),M(this,Ur,new Map),M(this,mn,0)}mount(){va(this,mn)._++,y(this,mn)===1&&(M(this,Br,Vc.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,xe).onFocus())})),M(this,Qr,ki.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,xe).onOnline())})))}unmount(){var e,t;va(this,mn)._--,y(this,mn)===0&&((e=y(this,Br))==null||e.call(this),M(this,Br,void 0),(t=y(this,Qr))==null||t.call(this),M(this,Qr,void 0))}isFetching(e){return y(this,xe).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return y(this,fn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,xe).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=y(this,xe).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(En(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return y(this,xe).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=y(this,xe).get(r.queryHash),i=s==null?void 0:s.state.data,l=Uv(t,i);if(l!==void 0)return y(this,xe).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return Ne.batch(()=>y(this,xe).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,xe).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=y(this,xe);Ne.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=y(this,xe);return Ne.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Ne.batch(()=>y(this,xe).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Be).catch(Be)}invalidateQueries(e,t={}){return Ne.batch(()=>(y(this,xe).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Ne.batch(()=>y(this,xe).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let i=s.fetch(void 0,n);return n.throwOnError||(i=i.catch(Be)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Be)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=y(this,xe).build(this,t);return n.isStaleByTime(En(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Be).catch(Be)}fetchInfiniteQuery(e){return e.behavior=wd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Be).catch(Be)}ensureInfiniteQueryData(e){return e.behavior=wd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ki.isOnline()?y(this,fn).resumePausedMutations():Promise.resolve()}getQueryCache(){return y(this,xe)}getMutationCache(){return y(this,fn)}getDefaultOptions(){return y(this,hn)}setDefaultOptions(e){M(this,hn,e)}setQueryDefaults(e,t){y(this,$r).set(or(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...y(this,$r).values()],n={};return t.forEach(r=>{Js(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){y(this,Ur).set(or(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...y(this,Ur).values()],n={};return t.forEach(r=>{Js(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...y(this,hn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Uc(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Bc&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...y(this,hn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){y(this,xe).clear(),y(this,fn).clear()}},xe=new WeakMap,fn=new WeakMap,hn=new WeakMap,$r=new WeakMap,Ur=new WeakMap,mn=new WeakMap,Br=new WeakMap,Qr=new WeakMap,Yd),wm=g.createContext(void 0),Yt=e=>{const t=g.useContext(wm);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},oy=({client:e,children:t})=>(g.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),a.jsx(wm.Provider,{value:e,children:t})),km=g.createContext(!1),cy=()=>g.useContext(km);km.Provider;function uy(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var dy=g.createContext(uy()),fy=()=>g.useContext(dy),hy=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Qc(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},my=e=>{g.useEffect(()=>{e.clearReset()},[e])},py=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||Qc(n,[e.error,r])),xy=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},vy=(e,t)=>e.isLoading&&e.isFetching&&!t,yy=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,bd=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function gy(e,t,n){var m,v,k,w;const r=cy(),s=fy(),i=Yt(),l=i.defaultQueryOptions(e);(v=(m=i.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||v.call(m,l);const o=i.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",xy(l),hy(l,s,o),my(s);const c=!i.getQueryCache().get(l.queryHash),[u]=g.useState(()=>new t(i,l)),d=u.getOptimisticResult(l),f=!r&&e.subscribed!==!1;if(g.useSyncExternalStore(g.useCallback(b=>{const p=f?u.subscribe(Ne.batchCalls(b)):Be;return u.updateResult(),p},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),g.useEffect(()=>{u.setOptions(l)},[l,u]),yy(l,d))throw bd(l,u,s);if(py({result:d,errorResetBoundary:s,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw d.error;if((w=(k=i.getDefaultOptions().queries)==null?void 0:k._experimental_afterQuery)==null||w.call(k,l,d),l.experimental_prefetchInRender&&!lr&&vy(d,r)){const b=c?bd(l,u,s):o==null?void 0:o.promise;b==null||b.catch(Be).finally(()=>{u.updateResult()})}return l.notifyOnChangeProps?d:u.trackResult(d)}function oe(e,t){return gy(e,Zv)}function Ze(e,t){const n=Yt(),[r]=g.useState(()=>new ay(n,e));g.useEffect(()=>{r.setOptions(e)},[r,e]);const s=g.useSyncExternalStore(g.useCallback(l=>r.subscribe(Ne.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=g.useCallback((l,o)=>{r.mutate(l,o).catch(Be)},[r]);if(s.error&&Qc(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}/** + * @remix-run/router v1.23.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Ys(){return Ys=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function Hc(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function wy(){return Math.random().toString(36).substr(2,8)}function Sd(e,t){return{usr:e.state,key:e.key,idx:t}}function Fo(e,t,n,r){return n===void 0&&(n=null),Ys({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?ss(t):t,{state:n,key:t&&t.key||r||wy()})}function bi(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function ss(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function ky(e,t,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:i=!1}=r,l=s.history,o=vn.Pop,c=null,u=d();u==null&&(u=0,l.replaceState(Ys({},l.state,{idx:u}),""));function d(){return(l.state||{idx:null}).idx}function f(){o=vn.Pop;let b=d(),p=b==null?null:b-u;u=b,c&&c({action:o,location:w.location,delta:p})}function m(b,p){o=vn.Push;let h=Fo(w.location,b,p);u=d()+1;let x=Sd(h,u),j=w.createHref(h);try{l.pushState(x,"",j)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;s.location.assign(j)}i&&c&&c({action:o,location:w.location,delta:1})}function v(b,p){o=vn.Replace;let h=Fo(w.location,b,p);u=d();let x=Sd(h,u),j=w.createHref(h);l.replaceState(x,"",j),i&&c&&c({action:o,location:w.location,delta:0})}function k(b){let p=s.location.origin!=="null"?s.location.origin:s.location.href,h=typeof b=="string"?b:bi(b);return h=h.replace(/ $/,"%20"),ye(p,"No window.location.(origin|href) available to create URL for href: "+h),new URL(h,p)}let w={get action(){return o},get location(){return e(s,l)},listen(b){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(Nd,f),c=b,()=>{s.removeEventListener(Nd,f),c=null}},createHref(b){return t(s,b)},createURL:k,encodeLocation(b){let p=k(b);return{pathname:p.pathname,search:p.search,hash:p.hash}},push:m,replace:v,go(b){return l.go(b)}};return w}var Cd;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Cd||(Cd={}));function by(e,t,n){return n===void 0&&(n="/"),Ny(e,t,n)}function Ny(e,t,n,r){let s=typeof t=="string"?ss(t):t,i=Yr(s.pathname||"/",n);if(i==null)return null;let l=bm(e);Sy(l);let o=null;for(let c=0;o==null&&c{let c={relativePath:o===void 0?i.path||"":o,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};c.relativePath.startsWith("/")&&(ye(c.relativePath.startsWith(r),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(r.length));let u=Pn([r,c.relativePath]),d=n.concat(c);i.children&&i.children.length>0&&(ye(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),bm(i.children,t,d,u)),!(i.path==null&&!i.index)&&t.push({path:u,score:Ly(u,i.index),routesMeta:d})};return e.forEach((i,l)=>{var o;if(i.path===""||!((o=i.path)!=null&&o.includes("?")))s(i,l);else for(let c of Nm(i.path))s(i,l,c)}),t}function Nm(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return s?[i,""]:[i];let l=Nm(r.join("/")),o=[];return o.push(...l.map(c=>c===""?i:[i,c].join("/"))),s&&o.push(...l),o.map(c=>e.startsWith("/")&&c===""?"/":c)}function Sy(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ry(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const Cy=/^:[\w-]+$/,_y=3,Ey=2,Py=1,Ty=10,Oy=-2,_d=e=>e==="*";function Ly(e,t){let n=e.split("/"),r=n.length;return n.some(_d)&&(r+=Oy),t&&(r+=Ey),n.filter(s=>!_d(s)).reduce((s,i)=>s+(Cy.test(i)?_y:i===""?Py:Ty),r)}function Ry(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function My(e,t,n){let{routesMeta:r}=e,s={},i="/",l=[];for(let o=0;o{let{paramName:m,isOptional:v}=d;if(m==="*"){let w=o[f]||"";l=i.slice(0,i.length-w.length).replace(/(.)\/+$/,"$1")}const k=o[f];return v&&!k?u[m]=void 0:u[m]=(k||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:l,pattern:e}}function zy(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),Hc(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,c)=>(r.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function Fy(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Hc(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Yr(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const Iy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Dy=e=>Iy.test(e);function Ay(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?ss(e):e,i;if(n)if(Dy(n))i=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),Hc(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?i=Ed(n.substring(1),"/"):i=Ed(n,t)}else i=t;return{pathname:i,search:By(r),hash:Qy(s)}}function Ed(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function wl(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function $y(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Sm(e,t){let n=$y(e);return t?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Cm(e,t,n,r){r===void 0&&(r=!1);let s;typeof e=="string"?s=ss(e):(s=Ys({},e),ye(!s.pathname||!s.pathname.includes("?"),wl("?","pathname","search",s)),ye(!s.pathname||!s.pathname.includes("#"),wl("#","pathname","hash",s)),ye(!s.search||!s.search.includes("#"),wl("#","search","hash",s)));let i=e===""||s.pathname==="",l=i?"/":s.pathname,o;if(l==null)o=n;else{let f=t.length-1;if(!r&&l.startsWith("..")){let m=l.split("/");for(;m[0]==="..";)m.shift(),f-=1;s.pathname=m.join("/")}o=f>=0?t[f]:"/"}let c=Ay(s,o),u=l&&l!=="/"&&l.endsWith("/"),d=(i||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}const Pn=e=>e.join("/").replace(/\/\/+/g,"/"),Uy=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),By=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Qy=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Vy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const _m=["post","put","patch","delete"];new Set(_m);const Ky=["get",..._m];new Set(Ky);/** + * React Router v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Xs(){return Xs=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),g.useCallback(function(u,d){if(d===void 0&&(d={}),!o.current)return;if(typeof u=="number"){r.go(u);return}let f=Cm(u,JSON.parse(l),i,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Pn([t,f.pathname])),(d.replace?r.replace:r.push)(f,d.state,d)},[t,r,l,i,e])}const Wy=g.createContext(null);function Gy(e){let t=g.useContext(Xt).outlet;return t&&g.createElement(Wy.Provider,{value:e},t)}function ha(){let{matches:e}=g.useContext(Xt),t=e[e.length-1];return t?t.params:{}}function Vi(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=g.useContext(In),{matches:s}=g.useContext(Xt),{pathname:i}=as(),l=JSON.stringify(Sm(s,r.v7_relativeSplatPath));return g.useMemo(()=>Cm(e,JSON.parse(l),i,n==="path"),[e,l,i,n])}function Jy(e,t){return Yy(e,t)}function Yy(e,t,n,r){fa()||ye(!1);let{navigator:s}=g.useContext(In),{matches:i}=g.useContext(Xt),l=i[i.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let u=as(),d;if(t){var f;let b=typeof t=="string"?ss(t):t;c==="/"||(f=b.pathname)!=null&&f.startsWith(c)||ye(!1),d=b}else d=u;let m=d.pathname||"/",v=m;if(c!=="/"){let b=c.replace(/^\//,"").split("/");v="/"+m.replace(/^\//,"").split("/").slice(b.length).join("/")}let k=by(e,{pathname:v}),w=ng(k&&k.map(b=>Object.assign({},b,{params:Object.assign({},o,b.params),pathname:Pn([c,s.encodeLocation?s.encodeLocation(b.pathname).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?c:Pn([c,s.encodeLocation?s.encodeLocation(b.pathnameBase).pathname:b.pathnameBase])})),i,n,r);return t&&w?g.createElement(Qi.Provider,{value:{location:Xs({pathname:"/",search:"",hash:"",state:null,key:"default"},d),navigationType:vn.Pop}},w):w}function Xy(){let e=ig(),t=Vy(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return g.createElement(g.Fragment,null,g.createElement("h2",null,"Unexpected Application Error!"),g.createElement("h3",{style:{fontStyle:"italic"}},t),n?g.createElement("pre",{style:s},n):null,null)}const Zy=g.createElement(Xy,null);class eg extends g.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?g.createElement(Xt.Provider,{value:this.props.routeContext},g.createElement(Pm.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function tg(e){let{routeContext:t,match:n,children:r}=e,s=g.useContext(Bi);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),g.createElement(Xt.Provider,{value:t},r)}function ng(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(s=n)==null?void 0:s.errors;if(o!=null){let d=l.findIndex(f=>f.route.id&&(o==null?void 0:o[f.route.id])!==void 0);d>=0||ye(!1),l=l.slice(0,Math.min(l.length,d+1))}let c=!1,u=-1;if(n&&r&&r.v7_partialHydration)for(let d=0;d=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((d,f,m)=>{let v,k=!1,w=null,b=null;n&&(v=o&&f.route.id?o[f.route.id]:void 0,w=f.route.errorElement||Zy,c&&(u<0&&m===0?(og("route-fallback"),k=!0,b=null):u===m&&(k=!0,b=f.route.hydrateFallbackElement||null)));let p=t.concat(l.slice(0,m+1)),h=()=>{let x;return v?x=w:k?x=b:f.route.Component?x=g.createElement(f.route.Component,null):f.route.element?x=f.route.element:x=d,g.createElement(tg,{match:f,routeContext:{outlet:d,matches:p,isDataRoute:n!=null},children:x})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?g.createElement(eg,{location:n.location,revalidation:n.revalidation,component:w,error:v,children:h(),routeContext:{outlet:null,matches:p,isDataRoute:!0}}):h()},null)}var Om=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Om||{}),Lm=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(Lm||{});function rg(e){let t=g.useContext(Bi);return t||ye(!1),t}function sg(e){let t=g.useContext(Em);return t||ye(!1),t}function ag(e){let t=g.useContext(Xt);return t||ye(!1),t}function Rm(e){let t=ag(),n=t.matches[t.matches.length-1];return n.route.id||ye(!1),n.route.id}function ig(){var e;let t=g.useContext(Pm),n=sg(),r=Rm();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function lg(){let{router:e}=rg(Om.UseNavigateStable),t=Rm(Lm.UseNavigateStable),n=g.useRef(!1);return Tm(()=>{n.current=!0}),g.useCallback(function(s,i){i===void 0&&(i={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,Xs({fromRouteId:t},i)))},[e,t])}const Pd={};function og(e,t,n){Pd[e]||(Pd[e]=!0)}function cg(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function ug(e){return Gy(e.context)}function xt(e){ye(!1)}function dg(e){let{basename:t="/",children:n=null,location:r,navigationType:s=vn.Pop,navigator:i,static:l=!1,future:o}=e;fa()&&ye(!1);let c=t.replace(/^\/*/,"/"),u=g.useMemo(()=>({basename:c,navigator:i,static:l,future:Xs({v7_relativeSplatPath:!1},o)}),[c,o,i,l]);typeof r=="string"&&(r=ss(r));let{pathname:d="/",search:f="",hash:m="",state:v=null,key:k="default"}=r,w=g.useMemo(()=>{let b=Yr(d,c);return b==null?null:{location:{pathname:b,search:f,hash:m,state:v,key:k},navigationType:s}},[c,d,f,m,v,k,s]);return w==null?null:g.createElement(In.Provider,{value:u},g.createElement(Qi.Provider,{children:n,value:w}))}function fg(e){let{children:t,location:n}=e;return Jy(Do(t),n)}new Promise(()=>{});function Do(e,t){t===void 0&&(t=[]);let n=[];return g.Children.forEach(e,(r,s)=>{if(!g.isValidElement(r))return;let i=[...t,s];if(r.type===g.Fragment){n.push.apply(n,Do(r.props.children,i));return}r.type!==xt&&ye(!1),!r.props.index||!r.props.children||ye(!1);let l={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Do(r.props.children,i)),n.push(l)}),n}/** + * React Router DOM v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Ni(){return Ni=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[s]=e[s]);return n}function hg(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function mg(e,t){return e.button===0&&(!t||t==="_self")&&!hg(e)}const pg=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],xg=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],vg="6";try{window.__reactRouterVersion=vg}catch{}const yg=g.createContext({isTransitioning:!1}),gg="startTransition",Td=Cp[gg];function jg(e){let{basename:t,children:n,future:r,window:s}=e,i=g.useRef();i.current==null&&(i.current=jy({window:s,v5Compat:!0}));let l=i.current,[o,c]=g.useState({action:l.action,location:l.location}),{v7_startTransition:u}=r||{},d=g.useCallback(f=>{u&&Td?Td(()=>c(f)):c(f)},[c,u]);return g.useLayoutEffect(()=>l.listen(d),[l,d]),g.useEffect(()=>cg(r),[r]),g.createElement(dg,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const wg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",kg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Rn=g.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:i,replace:l,state:o,target:c,to:u,preventScrollReset:d,viewTransition:f}=t,m=Mm(t,pg),{basename:v}=g.useContext(In),k,w=!1;if(typeof u=="string"&&kg.test(u)&&(k=u,wg))try{let x=new URL(window.location.href),j=u.startsWith("//")?new URL(x.protocol+u):new URL(u),C=Yr(j.pathname,v);j.origin===x.origin&&C!=null?u=C+j.search+j.hash:w=!0}catch{}let b=Hy(u,{relative:s}),p=Ng(u,{replace:l,state:o,target:c,preventScrollReset:d,relative:s,viewTransition:f});function h(x){r&&r(x),x.defaultPrevented||p(x)}return g.createElement("a",Ni({},m,{href:k||b,onClick:w||i?r:h,ref:n,target:c}))}),zm=g.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:s=!1,className:i="",end:l=!1,style:o,to:c,viewTransition:u,children:d}=t,f=Mm(t,xg),m=Vi(c,{relative:f.relative}),v=as(),k=g.useContext(Em),{navigator:w,basename:b}=g.useContext(In),p=k!=null&&Sg(m)&&u===!0,h=w.encodeLocation?w.encodeLocation(m).pathname:m.pathname,x=v.pathname,j=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;s||(x=x.toLowerCase(),j=j?j.toLowerCase():null,h=h.toLowerCase()),j&&b&&(j=Yr(j,b)||j);const C=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let S=x===h||!l&&x.startsWith(h)&&x.charAt(C)==="/",N=j!=null&&(j===h||!l&&j.startsWith(h)&&j.charAt(h.length)==="/"),_={isActive:S,isPending:N,isTransitioning:p},z=S?r:void 0,L;typeof i=="function"?L=i(_):L=[i,S?"active":null,N?"pending":null,p?"transitioning":null].filter(Boolean).join(" ");let B=typeof o=="function"?o(_):o;return g.createElement(Rn,Ni({},f,{"aria-current":z,className:L,ref:n,style:B,to:c,viewTransition:u}),typeof d=="function"?d(_):d)});var Ao;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Ao||(Ao={}));var Od;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Od||(Od={}));function bg(e){let t=g.useContext(Bi);return t||ye(!1),t}function Ng(e,t){let{target:n,replace:r,state:s,preventScrollReset:i,relative:l,viewTransition:o}=t===void 0?{}:t,c=Dn(),u=as(),d=Vi(e,{relative:l});return g.useCallback(f=>{if(mg(f,n)){f.preventDefault();let m=r!==void 0?r:bi(u)===bi(d);c(e,{replace:m,state:s,preventScrollReset:i,relative:l,viewTransition:o})}},[u,c,d,r,s,n,e,i,l,o])}function Sg(e,t){t===void 0&&(t={});let n=g.useContext(yg);n==null&&ye(!1);let{basename:r}=bg(Ao.useViewTransitionState),s=Vi(e,{relative:t.relative});if(!n.isTransitioning)return!1;let i=Yr(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Yr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Io(s.pathname,l)!=null||Io(s.pathname,i)!=null}/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var Cg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _g=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),U=(e,t)=>{const n=g.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:l,className:o="",children:c,...u},d)=>g.createElement("svg",{ref:d,...Cg,width:s,height:s,stroke:r,strokeWidth:l?Number(i)*24/Number(s):i,className:["lucide",`lucide-${_g(e)}`,o].join(" "),...u},[...t.map(([f,m])=>g.createElement(f,m)),...Array.isArray(c)?c:[c]]));return n.displayName=`${e}`,n};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Eg=U("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fm=U("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pg=U("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Tg=U("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Og=U("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Im=U("BookOpen",[["path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z",key:"vv98re"}],["path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z",key:"1cyq3y"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $o=U("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dm=U("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lg=U("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rg=U("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Zs=U("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mg=U("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zg=U("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Am=U("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fg=U("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ig=U("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $m=U("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ld=U("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Um=U("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Uo=U("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dg=U("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ag=U("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $g=U("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qc=U("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ug=U("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bg=U("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qg=U("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ma=U("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bm=U("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vg=U("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qm=U("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Kg=U("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ea=U("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wc=U("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hg=U("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qg=U("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vm=U("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Km=U("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wg=U("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Gg=U("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rd=U("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Jg=U("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Yg=U("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Gc=U("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hm=U("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qm=U("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xg=U("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wm=U("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const is=U("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),Zg={},Md=e=>{let t;const n=new Set,r=(d,f)=>{const m=typeof d=="function"?d(t):d;if(!Object.is(m,t)){const v=t;t=f??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(k=>k(t,v))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(Zg?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(r,s,c);return c},e0=e=>e?Md(e):Md;var Gm={exports:{}},Jm={},Ym={exports:{}},Xm={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Xr=g;function t0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var n0=typeof Object.is=="function"?Object.is:t0,r0=Xr.useState,s0=Xr.useEffect,a0=Xr.useLayoutEffect,i0=Xr.useDebugValue;function l0(e,t){var n=t(),r=r0({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return a0(function(){s.value=n,s.getSnapshot=t,kl(s)&&i({inst:s})},[e,n,t]),s0(function(){return kl(s)&&i({inst:s}),e(function(){kl(s)&&i({inst:s})})},[e]),i0(n),n}function kl(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!n0(e,n)}catch{return!0}}function o0(e,t){return t()}var c0=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o0:l0;Xm.useSyncExternalStore=Xr.useSyncExternalStore!==void 0?Xr.useSyncExternalStore:c0;Ym.exports=Xm;var u0=Ym.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Ki=g,d0=u0;function f0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var h0=typeof Object.is=="function"?Object.is:f0,m0=d0.useSyncExternalStore,p0=Ki.useRef,x0=Ki.useEffect,v0=Ki.useMemo,y0=Ki.useDebugValue;Jm.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=p0(null);if(i.current===null){var l={hasValue:!1,value:null};i.current=l}else l=i.current;i=v0(function(){function c(v){if(!u){if(u=!0,d=v,v=r(v),s!==void 0&&l.hasValue){var k=l.value;if(s(k,v))return f=k}return f=v}if(k=f,h0(d,v))return k;var w=r(v);return s!==void 0&&s(k,w)?(d=v,k):(d=v,f=w)}var u=!1,d,f,m=n===void 0?null:n;return[function(){return c(t())},m===null?void 0:function(){return c(m())}]},[t,n,r,s]);var o=m0(e,i[0],i[1]);return x0(function(){l.hasValue=!0,l.value=o},[o]),y0(o),o};Gm.exports=Jm;var g0=Gm.exports;const j0=Xd(g0),Zm={},{useDebugValue:w0}=Jo,{useSyncExternalStoreWithSelector:k0}=j0;let zd=!1;const b0=e=>e;function N0(e,t=b0,n){(Zm?"production":void 0)!=="production"&&n&&!zd&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),zd=!0);const r=k0(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return w0(r),r}const Fd=e=>{(Zm?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?e0(e):e,n=(r,s)=>N0(t,r,s);return Object.assign(n,t),n},Jc=e=>e?Fd(e):Fd,Hi="/api",Yc="flow_auth_token",Xc="flow_auth_expires",Zc="flow_auth_username";function qi(){const e=localStorage.getItem(Yc),t=localStorage.getItem(Xc);return!e||!t?null:new Date(t)<=new Date?(Zr(),null):e}function Id(e,t,n){localStorage.setItem(Yc,e),localStorage.setItem(Xc,t),localStorage.setItem(Zc,n)}function Zr(){localStorage.removeItem(Yc),localStorage.removeItem(Xc),localStorage.removeItem(Zc)}function eu(){return localStorage.getItem(Zc)}let cr=null;function S0(e){cr=e}async function Y(e,t,n=!1){const r={"Content-Type":"application/json",...t==null?void 0:t.headers};if(!n){const i=qi();i&&(r.Authorization=`Bearer ${i}`)}const s=await fetch(`${Hi}${e}`,{...t,headers:r});if(s.status===401){Zr(),cr&&cr();const i=await s.json().catch(()=>({detail:"Not authenticated"}));throw new Error(i.detail||"Not authenticated")}if(!s.ok){const i=await s.json().catch(()=>({detail:s.statusText}));throw new Error(i.detail||"API request failed")}if(s.status!==204)return s.json()}const xs={getConfig:()=>Y("/auth/config",void 0,!0),login:e=>Y("/auth/login",{method:"POST",body:JSON.stringify(e)},!0),getGitHubAuthUrl:()=>`${Hi}/auth/github`,getCurrentUser:()=>Y("/auth/me"),logout:()=>Y("/auth/logout",{method:"POST"})},Tn={list:e=>{const t=new URLSearchParams;e!=null&&e.include_auto_generated&&t.set("include_auto_generated","true"),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return Y(`/configs${n?`?${n}`:""}`)},get:e=>Y(`/configs/${e}`),create:e=>Y("/configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Y(`/configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Y(`/configs/${e}`,{method:"DELETE"})},kt={list:e=>{const t=new URLSearchParams;e!=null&&e.category&&t.set("category",e.category),e!=null&&e.suite&&t.set("suite",e.suite);const n=t.toString();return Y(`/tasks${n?`?${n}`:""}`)},get:e=>Y(`/tasks/${e}`),create:e=>Y("/tasks",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Y(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Y(`/tasks/${e}`,{method:"DELETE"}),listSuites:()=>Y("/tasks/suites"),importSuite:e=>Y(`/tasks/import-suite?suite_name=${encodeURIComponent(e)}`,{method:"POST"})},Mt={list:e=>{const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return Y(`/jobs${n?`?${n}`:""}`)},get:e=>Y(`/jobs/${e}`),create:e=>Y("/jobs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Y(`/jobs/${e}`,{method:"PUT",body:JSON.stringify(t)}),start:async function*(e){var o;const t={},n=qi();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Hi}/jobs/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Zr(),cr&&cr(),new Error("Not authenticated");if(!r.ok)throw new Error("Failed to start job");const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const i=new TextDecoder;let l="";for(;;){const{done:c,value:u}=await s.read();if(c)break;l+=i.decode(u,{stream:!0});const d=l.split(` +`);l=d.pop()||"";for(const f of d)f.startsWith("data: ")&&(yield JSON.parse(f.slice(6)))}},cancel:e=>Y(`/jobs/${e}/cancel`,{method:"POST"}),delete:e=>Y(`/jobs/${e}`,{method:"DELETE"})},Bo={list:e=>{const t=new URLSearchParams;e!=null&&e.job_id&&t.set("job_id",e.job_id),e!=null&&e.candidate_name&&t.set("candidate_name",e.candidate_name),e!=null&&e.task_name&&t.set("task_name",e.task_name),(e==null?void 0:e.is_pareto)!==void 0&&t.set("is_pareto",String(e.is_pareto));const n=t.toString();return Y(`/runs${n?`?${n}`:""}`)},get:e=>Y(`/runs/${e}`),getJobSummary:e=>Y(`/runs/job/${e}/summary`)},Ls={list:e=>{const t=new URLSearchParams;e!=null&&e.agent_id&&t.set("agent_id",e.agent_id),e!=null&&e.limit&&t.set("limit",String(e.limit));const n=t.toString();return Y(`/tests${n?`?${n}`:""}`)},get:e=>Y(`/tests/${e}`),create:e=>Y("/tests",{method:"POST",body:JSON.stringify(e)}),start:async function*(e){var o;const t={},n=qi();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Hi}/tests/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Zr(),cr&&cr(),new Error("Not authenticated");if(!r.ok){const c=await r.json().catch(()=>({detail:"Failed to start test"}));throw new Error(c.detail||"Failed to start test")}const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const i=new TextDecoder;let l="";for(;;){const{done:c,value:u}=await s.read();if(c)break;l+=i.decode(u,{stream:!0});const d=l.split(` +`);l=d.pop()||"";for(const f of d)f.startsWith("data: ")&&(yield JSON.parse(f.slice(6)))}},cancel:e=>Y(`/tests/${e}/cancel`,{method:"POST"}),delete:e=>Y(`/tests/${e}`,{method:"DELETE"})},C0={list:()=>Y("/llm-configs")},_0={list:()=>Y("/tools")},ep={getAgentSchema:()=>Y("/schema/agent")},E0={get:e=>Y(`/deployments/${e}`)},P0={start:e=>Y("/evaluate",{method:"POST",body:JSON.stringify(e)})},Qo={design:e=>Y("/experiment/design",{method:"POST",body:JSON.stringify(e)}),validate:e=>Y("/experiment/validate",{method:"POST",body:JSON.stringify(e)}),generateCandidates:e=>Y("/experiment/generate-candidates",{method:"POST",body:JSON.stringify(e)})},tu=Jc(e=>(S0(()=>{e({isAuthenticated:!1,user:null,error:"Session expired. Please log in again."})}),{authConfig:null,isLoadingConfig:!0,isAuthenticated:!1,isLoading:!1,user:null,error:null,loadAuthConfig:async()=>{e({isLoadingConfig:!0});try{const t=await xs.getConfig();if(e({authConfig:t,isLoadingConfig:!1}),t.enabled){const n=qi(),r=eu();if(n&&r)try{const s=await xs.getCurrentUser();e({isAuthenticated:!0,user:s})}catch{Zr(),e({isAuthenticated:!1,user:null})}}else e({isAuthenticated:!0,user:{username:"anonymous",auth_mode:"none"}})}catch(t){console.error("Failed to load auth config:",t),e({isLoadingConfig:!1,error:"Failed to connect to server"})}},login:async(t,n)=>{e({isLoading:!0,error:null});try{const r=await xs.login({username:t,password:n});return Id(r.access_token,r.expires_at,r.username),e({isAuthenticated:!0,isLoading:!1,user:{username:r.username,auth_mode:"basic"}}),!0}catch(r){return e({isLoading:!1,error:r instanceof Error?r.message:"Login failed"}),!1}},loginWithGitHub:()=>{window.location.href=xs.getGitHubAuthUrl()},handleOAuthCallback:()=>{const t=new URLSearchParams(window.location.search),n=t.get("auth_error");if(n)return e({error:n}),window.history.replaceState({},"",window.location.pathname),!0;if(t.get("auth_callback")==="true"){const r=t.get("token"),s=t.get("expires_at"),i=t.get("username");return r&&s&&i&&(Id(r,s,i),e({isAuthenticated:!0,user:{username:i,auth_mode:"github"}})),window.history.replaceState({},"",window.location.pathname),!0}return!1},logout:async()=>{try{await xs.logout()}catch{}Zr(),e({isAuthenticated:!1,user:null,error:null})},clearError:()=>e({error:null})}));function K({variant:e="secondary",size:t="md",className:n="",icon:r,iconRight:s,loading:i=!1,children:l,disabled:o,...c}){const u="font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1.5 rounded-md",d={primary:"bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)]",secondary:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)] hover:bg-[var(--border)]",danger:"bg-[var(--error)] text-white hover:bg-red-600",ghost:"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"},f={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm"},m=t==="sm"?14:16;return a.jsxs("button",{className:`${u} ${d[e]} ${f[t]} ${n}`,disabled:o||i,...c,children:[i?a.jsx(ma,{size:m,className:"animate-spin"}):r?a.jsx(r,{size:m}):null,l,s&&!i&&a.jsx(s,{size:m})]})}const T0={};function O0(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var i;const l=c=>c===null?null:JSON.parse(c,void 0),o=(i=n.getItem(s))!=null?i:null;return o instanceof Promise?o.then(l):l(o)},setItem:(s,i)=>n.setItem(s,JSON.stringify(i,void 0)),removeItem:s=>n.removeItem(s)}}const ta=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return ta(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return ta(r)(n)}}}},L0=(e,t)=>(n,r,s)=>{let i={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:b=>b,version:0,merge:(b,p)=>({...p,...b}),...t},l=!1;const o=new Set,c=new Set;let u;try{u=i.getStorage()}catch{}if(!u)return e((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...b)},r,s);const d=ta(i.serialize),f=()=>{const b=i.partialize({...r()});let p;const h=d({state:b,version:i.version}).then(x=>u.setItem(i.name,x)).catch(x=>{p=x});if(p)throw p;return h},m=s.setState;s.setState=(b,p)=>{m(b,p),f()};const v=e((...b)=>{n(...b),f()},r,s);let k;const w=()=>{var b;if(!u)return;l=!1,o.forEach(h=>h(r()));const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,r()))||void 0;return ta(u.getItem.bind(u))(i.name).then(h=>{if(h)return i.deserialize(h)}).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==i.version){if(i.migrate)return i.migrate(h.state,h.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return h.state}).then(h=>{var x;return k=i.merge(h,(x=r())!=null?x:v),n(k,!0),f()}).then(()=>{p==null||p(k,void 0),l=!0,c.forEach(h=>h(k))}).catch(h=>{p==null||p(void 0,h)})};return s.persist={setOptions:b=>{i={...i,...b},b.getStorage&&(u=b.getStorage())},clearStorage:()=>{u==null||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>w(),hasHydrated:()=>l,onHydrate:b=>(o.add(b),()=>{o.delete(b)}),onFinishHydration:b=>(c.add(b),()=>{c.delete(b)})},w(),k||v},R0=(e,t)=>(n,r,s)=>{let i={storage:O0(()=>localStorage),partialize:w=>w,version:0,merge:(w,b)=>({...b,...w}),...t},l=!1;const o=new Set,c=new Set;let u=i.storage;if(!u)return e((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...w)},r,s);const d=()=>{const w=i.partialize({...r()});return u.setItem(i.name,{state:w,version:i.version})},f=s.setState;s.setState=(w,b)=>{f(w,b),d()};const m=e((...w)=>{n(...w),d()},r,s);s.getInitialState=()=>m;let v;const k=()=>{var w,b;if(!u)return;l=!1,o.forEach(h=>{var x;return h((x=r())!=null?x:m)});const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,(w=r())!=null?w:m))||void 0;return ta(u.getItem.bind(u))(i.name).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==i.version){if(i.migrate)return[!0,i.migrate(h.state,h.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,h.state];return[!1,void 0]}).then(h=>{var x;const[j,C]=h;if(v=i.merge(C,(x=r())!=null?x:m),n(v,!0),j)return d()}).then(()=>{p==null||p(v,void 0),v=r(),l=!0,c.forEach(h=>h(v))}).catch(h=>{p==null||p(void 0,h)})};return s.persist={setOptions:w=>{i={...i,...w},w.storage&&(u=w.storage)},clearStorage:()=>{u==null||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>k(),hasHydrated:()=>l,onHydrate:w=>(o.add(w),()=>{o.delete(w)}),onFinishHydration:w=>(c.add(w),()=>{c.delete(w)})},i.skipHydration||k(),v||m},M0=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((T0?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),L0(e,t)):R0(e,t),tp=M0,z0=Jc()(tp((e,t)=>({theme:"light",setTheme:n=>{document.documentElement.setAttribute("data-theme",n),e({theme:n})},toggleTheme:()=>{const n=t().theme==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",n),e({theme:n})}}),{name:"flow-theme",onRehydrateStorage:()=>e=>{e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}}));function F0(){const{theme:e,toggleTheme:t}=z0();return a.jsx("button",{onClick:t,className:"p-2 rounded-md text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--accent)]","aria-label":`Switch to ${e==="dark"?"light":"dark"} mode`,title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:e==="dark"?a.jsx(Jg,{size:16}):a.jsx(Kg,{size:16})})}const I0=Jc()(tp((e,t)=>({sidebarCollapsed:!1,toggleSidebar:()=>{e({sidebarCollapsed:!t().sidebarCollapsed})}}),{name:"flow-layout"})),D0=[{path:"/",label:"Overview",icon:Bg},{path:"/agents",label:"Agents",icon:$o},{path:"/jobs",label:"Experiments",icon:Uo},{path:"/tasks",label:"Datasets",icon:$m}];function A0(){const e=as(),{sidebarCollapsed:t,toggleSidebar:n}=I0(),r=s=>s==="/"?e.pathname==="/":s==="/agents"?e.pathname==="/agents"||e.pathname.startsWith("/agents/")||e.pathname.startsWith("/deployments/"):s==="/jobs"?e.pathname.startsWith("/jobs")||e.pathname.startsWith("/runs"):e.pathname.startsWith(s);return a.jsxs("aside",{className:` + flex flex-col border-r border-[var(--border)] bg-[var(--bg-secondary)] + transition-all duration-200 + ${t?"w-14":"w-56"} + `,children:[a.jsx("nav",{className:"flex-1 py-2",children:D0.map(s=>{const i=r(s.path);return a.jsxs(zm,{to:s.path,title:t?s.label:void 0,className:` + flex items-center gap-3 px-4 py-2.5 text-sm transition-colors relative + ${i?"text-[var(--accent)] bg-[var(--accent-dim)] font-medium":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"} + `,children:[i&&a.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-r bg-[var(--accent)]"}),a.jsx(s.icon,{size:18}),!t&&a.jsx("span",{children:s.label})]},s.path)})}),a.jsx("button",{onClick:n,className:"flex items-center justify-center p-3 border-t border-[var(--border)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",title:t?"Expand sidebar":"Collapse sidebar",children:t?a.jsx(zg,{size:16}):a.jsx(Mg,{size:16})})]})}function $0(){const{authConfig:e,user:t,logout:n}=tu(),r=async()=>{await n()};return a.jsxs("div",{className:"h-screen flex flex-col",children:[a.jsx("header",{className:"border-b border-[var(--border)] bg-[var(--bg-secondary)] shrink-0",children:a.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between",children:[a.jsxs(zm,{to:"/",className:"text-lg font-semibold text-[var(--accent)] flex items-center gap-2 hover:opacity-80",children:[a.jsx(is,{size:20}),"Flow",a.jsx("span",{className:"text-[var(--text-secondary)] font-normal",children:"/optimize"})]}),a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(F0,{}),(e==null?void 0:e.enabled)&&t&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[a.jsx(Hm,{size:14}),a.jsx("span",{children:t.username})]}),a.jsx(K,{variant:"ghost",size:"sm",icon:Vg,onClick:r,title:"Sign out",children:"Sign out"})]})]})]})}),a.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[a.jsx(A0,{}),a.jsx("main",{className:"flex-1 overflow-y-auto bg-[var(--bg-primary)]",children:a.jsx("div",{className:"p-6",children:a.jsx(ug,{})})})]})]})}function q({children:e,variant:t="default"}){const n={default:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)]",success:"bg-[var(--badge-success-bg)] text-[var(--badge-success-text)] border border-[var(--badge-success-border)]",warning:"bg-[var(--badge-warning-bg)] text-[var(--badge-warning-text)] border border-[var(--badge-warning-border)]",error:"bg-[var(--badge-error-bg)] text-[var(--badge-error-text)] border border-[var(--badge-error-border)]",info:"bg-[var(--badge-info-bg)] text-[var(--badge-info-text)] border border-[var(--badge-info-border)]"};return a.jsx("span",{className:`inline-block px-2 py-0.5 text-xs font-medium rounded-md ${n[t]}`,children:e})}const U0={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};function B0(){const e=Dn(),{data:t=[],isLoading:n}=oe({queryKey:["configs"],queryFn:()=>Tn.list()}),{data:r=[],isLoading:s}=oe({queryKey:["jobs"],queryFn:()=>Mt.list()}),{data:i=[],isLoading:l}=oe({queryKey:["tasks"],queryFn:()=>kt.list()}),o=[...t].sort((d,f)=>new Date(f.created_at).getTime()-new Date(d.created_at).getTime()).slice(0,5),c=[...r].sort((d,f)=>new Date(f.created_at).getTime()-new Date(d.created_at).getTime()).slice(0,5),u=i.reduce((d,f)=>{const m=f.suite||"custom";return d[m]||(d[m]=[]),d[m].push(f),d},{});return a.jsxs("div",{children:[a.jsxs("div",{className:"mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Agent Optimizer"}),a.jsx("p",{className:"text-[var(--text-secondary)] max-w-2xl",children:"Systematically optimize and improve your AI agents across key dimensions. Define agent configurations, run experiments across task datasets, and find the best tradeoffs between quality and cost."}),a.jsx("div",{className:"flex flex-wrap gap-3 mt-4 text-sm text-[var(--text-secondary)]",children:[{icon:Qm,label:"Instructions"},{icon:qm,label:"Tools"},{icon:Im,label:"Skills"},{icon:Gg,label:"Compaction"}].map((d,f,m)=>a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[a.jsx(d.icon,{size:14,className:"text-[var(--accent)]"}),d.label,fa.jsxs("div",{className:"p-4 border border-[var(--border)] rounded-lg bg-[var(--bg-secondary)]",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a.jsx("span",{className:"flex items-center justify-center w-7 h-7 rounded-full bg-[var(--accent)]/10 text-[var(--accent)] text-xs font-bold",children:d.step}),a.jsx(d.icon,{size:18,className:"text-[var(--accent)]"})]}),a.jsx("h3",{className:"font-medium text-sm",children:d.title}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:d.description})]},d.step))}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mb-6",children:[a.jsxs("div",{children:[a.jsx(bl,{title:"Recent Agents",icon:$o,count:t.length,onShowAll:()=>e("/agents")}),n?a.jsx(Nl,{}):o.length===0?a.jsx(Sl,{message:"No agents yet. Create your first agent to get started."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:o.map((d,f)=>a.jsxs("div",{onClick:()=>e(`/agents/${d.id}`),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${fe("/jobs")}),s?a.jsx(Nl,{}):c.length===0?a.jsx(Sl,{message:"No experiments yet. Start one from an agent's detail page."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:c.map((d,f)=>a.jsxs("div",{onClick:()=>e(`/jobs/${d.id}`),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${fe("/tasks")}),l?a.jsx(Nl,{}):Object.keys(u).length===0?a.jsx(Sl,{message:"No datasets yet. Import a task suite to get started."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:Object.entries(u).map(([d,f],m,v)=>a.jsx("div",{onClick:()=>e("/tasks"),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${m0&&a.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",n,")"]})]}),n>0&&a.jsxs("button",{onClick:r,className:"text-sm text-[var(--accent)] hover:underline flex items-center gap-1",children:["Show all ",a.jsx(Pg,{size:14})]})]})}function Nl(){return a.jsx("div",{className:"text-sm text-[var(--text-secondary)] mb-8",children:"Loading..."})}function Sl({message:e}){return a.jsx("div",{className:"text-sm text-[var(--text-secondary)] py-6 text-center border border-[var(--border)] rounded-lg mb-8",children:e})}const Q0=["maf","miniagent","langgraph"],V0={maf:"Microsoft Agent Framework",miniagent:"MiniAgent",langgraph:"LangGraph"},K0={openai:"OpenAI",azure_openai:"Azure OpenAI",anthropic:"Anthropic",ollama:"Ollama",custom:"Custom (OpenAI-compatible)"},H0={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"};function ls({isOpen:e,onClose:t,title:n,children:r,footer:s,size:i="md"}){return g.useEffect(()=>{const l=o=>{o.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",l),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",l),document.body.style.overflow=""}},[e,t]),e?a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),a.jsxs("div",{className:`relative bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg ${H0[i]} w-full mx-4 max-h-[80vh] flex flex-col`,children:[a.jsxs("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-b border-[var(--border)] px-4 py-3 flex items-center justify-between",children:[a.jsx("h2",{className:"font-semibold",children:n}),a.jsx("button",{onClick:t,className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"×"})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r}),s&&a.jsx("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-t border-[var(--border)] px-4 py-3",children:s})]})]}):null}function yn({label:e,className:t="",...n}){return a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),a.jsx("input",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] ${t}`,...n})]})}function q0({label:e,className:t="",...n}){return a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),a.jsx("textarea",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] resize-y min-h-[100px] ${t}`,...n})]})}function Si({label:e,className:t="",...n}){return a.jsxs("label",{className:`flex items-center gap-2 cursor-pointer ${t}`,children:[a.jsx("input",{type:"checkbox",className:"w-4 h-4 bg-[var(--bg-primary)] border border-[var(--border)] rounded accent-[var(--accent)]",...n}),a.jsx("span",{className:"text-sm",children:e})]})}function np({columns:e,data:t,onRowClick:n,searchable:r=!1,searchPlaceholder:s="Search...",searchFilter:i,emptyMessage:l="No items found",emptyIcon:o}){const[c,u]=g.useState(""),[d,f]=g.useState(null),[m,v]=g.useState("asc"),k=g.useMemo(()=>{let b=t;if(r&&c&&i&&(b=b.filter(p=>i(p,c))),d){const p=e.find(h=>h.key===d);p!=null&&p.sortValue&&(b=[...b].sort((h,x)=>{const j=p.sortValue(h),C=p.sortValue(x),S=jC?1:0;return m==="asc"?S:-S}))}return b},[t,c,i,r,d,m,e]),w=b=>{const p=e.find(h=>h.key===b);p!=null&&p.sortable&&(d===b?v(m==="asc"?"desc":"asc"):(f(b),v("asc")))};return a.jsxs("div",{children:[r&&a.jsxs("div",{className:"mb-4 relative max-w-sm",children:[a.jsx(qg,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]"}),a.jsx("input",{type:"text",placeholder:s,value:c,onChange:b=>u(b.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md pl-9 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]"})]}),k.length===0?a.jsxs("div",{className:"text-center py-16 text-[var(--text-secondary)]",children:[o&&a.jsx("div",{className:"mb-3 flex justify-center",children:o}),a.jsx("p",{children:l})]}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsx("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:e.map(b=>a.jsx("th",{onClick:()=>w(b.key),className:`text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider ${b.sortable?"cursor-pointer hover:text-[var(--text-primary)]":""} ${b.className||""}`,children:a.jsxs("span",{className:"inline-flex items-center gap-1",children:[b.header,b.sortable&&d===b.key&&a.jsx("span",{children:m==="asc"?"↑":"↓"})]})},b.key))})}),a.jsx("tbody",{children:k.map((b,p)=>a.jsx("tr",{onClick:()=>n==null?void 0:n(b),className:`border-b border-[var(--border)] last:border-b-0 transition-colors ${n?"cursor-pointer hover:bg-[var(--bg-tertiary)]":""}`,children:e.map(h=>a.jsx("td",{className:`px-4 py-3 ${h.className||""}`,children:h.render(b)},h.key))},p))})]})})]})}function W0({variations:e,onChange:t,strategies:n,availableStrategies:r}){const s=r??Object.keys(n),i=()=>{const u=e.map(v=>v.strategy),d=s.find(v=>!u.includes(v))||"none",f=n[d],m={strategy:d};if(f!=null&&f.params)for(const[v,k]of Object.entries(f.params))k.default!==void 0&&(m[v]=k.default);t([...e,m])},l=u=>{t(e.filter((d,f)=>f!==u))},o=(u,d)=>{t(e.map((f,m)=>m===u?{...f,...d}:f))},c=(u,d)=>{const f=n[d],m={strategy:d};if(f!=null&&f.params)for(const[v,k]of Object.entries(f.params))k.default!==void 0&&(m[v]=k.default);o(u,m)};return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm font-medium",children:"Compaction Strategies"}),a.jsx(K,{type:"button",variant:"ghost",size:"sm",icon:Wc,onClick:i,disabled:e.length>=s.length,children:"Add"})]}),e.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:'No compaction variations. Click "Add" to test different strategies.'}):a.jsx("div",{className:"space-y-2",children:e.map((u,d)=>{const f=n[u.strategy];return a.jsx("div",{className:"p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsx("select",{className:"w-full px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:u.strategy,onChange:m=>c(d,m.target.value),children:s.map(m=>{var v;return a.jsx("option",{value:m,children:((v=n[m])==null?void 0:v.label)||m},m)})}),(f==null?void 0:f.description)&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:f.description}),(f==null?void 0:f.params)&&Object.keys(f.params).length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:Object.entries(f.params).map(([m,v])=>a.jsx(G0,{name:m,schema:v,value:u[m],onChange:k=>o(d,{[m]:k})},m))})]}),a.jsx("button",{type:"button",onClick:()=>l(d),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:a.jsx(Wm,{size:16})})]})},d)})})]})}function G0({name:e,schema:t,value:n,onChange:r}){const s=e.replace(/_/g," ");return t.type==="boolean"?a.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[a.jsx("input",{type:"checkbox",checked:!!(n??t.default),onChange:i=>r(i.target.checked),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"capitalize",children:s})]}):a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:s}),a.jsx("input",{type:t.type==="number"?"number":"text",className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-xs",value:String(n!==void 0?n:t.default??""),onChange:i=>{if(t.type==="number"){const l=parseFloat(i.target.value);r(isNaN(l)?t.default:l)}else r(i.target.value)},min:t.min,max:t.max,step:t.max&&t.max<=1?.1:1})]})}function J0({variations:e,onChange:t,providers:n}){const r=()=>{const o=n[0],c={provider:(o==null?void 0:o.name)||"azure_openai",model:(o==null?void 0:o.models[0])||"gpt-4o"};t([...e,c])},s=o=>{t(e.filter((c,u)=>u!==o))},i=(o,c)=>{t(e.map((u,d)=>d===o?{...u,...c}:u))},l=(o,c)=>{const u=n.find(d=>d.name===c);i(o,{provider:c,model:(u==null?void 0:u.models[0])||""})};return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm font-medium",children:"LLM Configurations"}),a.jsx(K,{type:"button",variant:"ghost",size:"sm",icon:Wc,onClick:r,children:"Add"})]}),e.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:`Uses agent's default LLM. Click "Add" to test different models.`}):a.jsx("div",{className:"space-y-2",children:e.map((o,c)=>{const u=n.find(d=>d.name===o.provider);return a.jsxs("div",{className:"flex items-center gap-2 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[a.jsx("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.provider,onChange:d=>l(c,d.target.value),children:n.map(d=>a.jsx("option",{value:d.name,children:d.label},d.name))}),u&&u.models.length>0?a.jsxs("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:d=>i(c,{model:d.target.value}),children:[u.models.map(d=>a.jsx("option",{value:d,children:d},d)),!u.models.includes(o.model)&&o.model&&a.jsx("option",{value:o.model,children:o.model})]}):a.jsx("input",{type:"text",className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:d=>i(c,{model:d.target.value}),placeholder:"Model ID"}),a.jsx("button",{type:"button",onClick:()=>s(c),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:a.jsx(Wm,{size:16})})]},c)})})]})}const Vo={compaction:[],tools:[],llm_config:[],instructions:[],instruction_strategies:[]};function Y0({agentId:e,agentName:t,agentFramework:n="maf",taskSuite:r,taskCount:s,schema:i,onVariationsChange:l,parallel:o,onParallelChange:c,budget:u,onBudgetChange:d,useLlmEval:f,onUseLlmEvalChange:m}){const[v,k]=g.useState(Vo),[w,b]=g.useState(!1),[p,h]=g.useState(""),[x,j]=g.useState(null),C=i.frameworks[n],S=(C==null?void 0:C.compaction_strategies)||Object.keys(i.compaction_strategies),N=i.tool_presets||[],_=i.llm_providers||[],L=(()=>{let T=1;v.compaction.length>0&&(T*=v.compaction.length),v.tools.length>0&&(T*=v.tools.length),v.llm_config.length>0&&(T*=v.llm_config.length);const V=v.instructions.length+v.instruction_strategies.reduce((te,O)=>te+O.max_candidates,0);return V>0&&(T*=V),Math.min(T,u)})(),B=L*s,J=T=>{k(T),l==null||l(T)},se=Ze({mutationFn:T=>Qo.design(T),onSuccess:T=>{h(T.yaml_content),b(!0)}}),ce=Ze({mutationFn:T=>Qo.validate(T),onSuccess:T=>{j({valid:T.valid,errors:T.errors,warnings:T.warnings})}}),D=()=>({base_agent_id:e,task_suite:r,variations:v,parallel:o,budget:u,use_llm_eval:f}),W=()=>{se.mutate(D())},Z=()=>{ce.mutate(D())},P=()=>{const T=new Blob([p],{type:"text/yaml"}),V=URL.createObjectURL(T),te=document.createElement("a");te.href=V,te.download=`${t}_experiment.yaml`,te.click(),URL.revokeObjectURL(V)},A=v.compaction.length>0||v.tools.length>0||v.llm_config.length>0||v.instructions.length>0||v.instruction_strategies.length>0;return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsxs(q,{variant:"info",children:[L," candidates"]}),a.jsxs(q,{children:[s," tasks"]}),a.jsxs(q,{variant:B>100?"warning":"success",children:[B," total runs"]})]}),a.jsx(W0,{variations:v.compaction,onChange:T=>J({...v,compaction:T}),strategies:i.compaction_strategies,availableStrategies:S}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("label",{className:"text-sm font-medium",children:"Tool Presets"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(T=>a.jsxs("label",{className:`flex items-center gap-2 px-3 py-1.5 border rounded cursor-pointer transition-colors ${v.tools.includes(T.name)?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[a.jsx("input",{type:"checkbox",checked:v.tools.includes(T.name),onChange:V=>{const te=V.target.checked?[...v.tools,T.name]:v.tools.filter(O=>O!==T.name);J({...v,tools:te})},className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:T.name}),a.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",T.tools.length,")"]})]},T.name))}),v.tools.length>0&&a.jsxs("p",{className:"text-xs text-[var(--text-secondary)]",children:["Selected: ",v.tools.join(", ")]})]}),a.jsx(J0,{variations:v.llm_config,onChange:T=>J({...v,llm_config:T}),providers:_}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-4 space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium",children:"Execution Settings"}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(yn,{label:"Parallel Workers",type:"number",value:o,onChange:T=>c(parseInt(T.target.value)||1),min:1,max:16}),a.jsx(yn,{label:"Budget (max candidates)",type:"number",value:u,onChange:T=>d(parseInt(T.target.value)||100),min:1,max:1e3})]}),a.jsx(Si,{label:"Use LLM evaluation",checked:f,onChange:T=>m(T.target.checked)}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] ml-6 -mt-2",children:f?"LLM-as-Judge scores task completion (0-1)":"Simple pass/fail based on task success"})]}),a.jsxs("div",{className:"flex items-center gap-2 border-t border-[var(--border)] pt-4",children:[a.jsx(K,{variant:"secondary",size:"sm",onClick:Z,loading:ce.isPending,children:"Validate"}),a.jsx(K,{variant:"secondary",size:"sm",icon:Ld,onClick:W,loading:se.isPending,children:"Export YAML"})]}),x&&a.jsxs("div",{className:`p-3 rounded border ${x.valid?"border-green-500/50 bg-green-500/10":"border-red-500/50 bg-red-500/10"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[x.valid?a.jsx(Dm,{size:16,className:"text-green-500"}):a.jsx(Fm,{size:16,className:"text-red-500"}),a.jsx("span",{className:"font-medium text-sm",children:x.valid?"Configuration valid":"Configuration has issues"})]}),x.errors.length>0&&a.jsx("ul",{className:"text-sm text-red-500 list-disc ml-6",children:x.errors.map((T,V)=>a.jsx("li",{children:T},V))}),x.warnings.length>0&&a.jsx("ul",{className:"text-sm text-yellow-500 list-disc ml-6 mt-1",children:x.warnings.map((T,V)=>a.jsx("li",{children:T},V))})]}),w&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-lg shadow-xl max-w-2xl w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border)]",children:[a.jsx("h3",{className:"font-medium",children:"Experiment YAML"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(K,{variant:"secondary",size:"sm",icon:Ld,onClick:P,children:"Download"}),a.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(!1),children:"Close"})]})]}),a.jsx("pre",{className:"flex-1 overflow-auto p-4 text-xs font-mono bg-[var(--bg-secondary)]",children:p})]})}),!A&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No variations selected. Only the baseline agent will be tested. Add compaction strategies, tool presets, or LLM configs to generate candidates."})]})}const X0=[{key:"instruction",label:"Optimize Instructions",description:"LLM iteratively evaluates and rewrites agent instructions",icon:Qm},{key:"tool",label:"Optimize Tools",description:"LLM analyzes which tools help or hurt and adjusts tool config",icon:qm},{key:"skill",label:"Optimize Skills",description:"LLM generates and refines agent skill files (SKILL.md)",icon:Im}];function rp({agent:e,isOpen:t,onClose:n}){var H;const r=Dn(),s=Yt(),[i,l]=g.useState("ready"),[o,c]=g.useState("quick"),[u,d]=g.useState(!1),[f,m]=g.useState([]),[v,k]=g.useState([]),[w,b]=g.useState(5),[p,h]=g.useState(!1),[x,j]=g.useState(Vo),[C,S]=g.useState(4),[N,_]=g.useState(100),[z,L]=g.useState(!0),[B,J]=g.useState(null),{data:se=[]}=oe({queryKey:["tasks"],queryFn:()=>kt.list()}),{data:ce=[]}=oe({queryKey:["suites"],queryFn:()=>kt.listSuites()}),{data:D}=oe({queryKey:["agent-schema"],queryFn:()=>ep.getAgentSchema()}),W=ce.map(F=>({value:F.name,label:F.name.charAt(0).toUpperCase()+F.name.slice(1),description:F.description,tasks:F.task_count})),Z=Ze({mutationFn:kt.importSuite,onSuccess:F=>{s.invalidateQueries({queryKey:["tasks"]}),m(F.map(re=>re.id))}}),P=Ze({mutationFn:async F=>{const re=await Mt.create(F);return Mt.start(re.id).next(),re},onSuccess:F=>{s.invalidateQueries({queryKey:["jobs"]}),J(F.id),l("success")}}),A=()=>{let F=1;x.compaction.length>0&&(F*=x.compaction.length),x.tools.length>0&&(F*=x.tools.length),x.llm_config.length>0&&(F*=x.llm_config.length);const re=x.instructions.length+x.instruction_strategies.reduce((Ae,mt)=>Ae+mt.max_candidates,0);return re>0&&(F*=re),Math.min(F,N)},T=p&&(x.compaction.length>0||x.tools.length>0||x.llm_config.length>0||x.instructions.length>0||x.instruction_strategies.length>0),V=v.length>0&&!T,te=T?A():1,O=u?f.length:((H=W.find(F=>F.value===o))==null?void 0:H.tasks)||3,Q=V?O*v.length:te*O,Ce=async()=>{l("starting");let F=f;if(!u)try{F=(await Z.mutateAsync(o)).map(Ae=>Ae.id)}catch(re){console.error("Failed to import suite:",re),alert(`Failed to import task suite: ${o}`),l("ready");return}if(F.length===0){alert("No tasks selected. Please select tasks or choose a task suite."),l("ready");return}if(V){const re={name:`${e.name} — ${v.join(" → ")} optimization`,task_ids:F,parallel:C,use_llm_eval:z,strategies:v,strategy_config:{max_iterations:w},base_agent_id:e.id};P.mutate(re)}else{let re;if(T)try{re=(await Qo.generateCandidates({base_agent_id:e.id,variations:x,budget:N})).candidate_ids}catch(mt){console.error("Failed to generate candidates:",mt),alert(`Failed to generate candidates: ${mt instanceof Error?mt.message:"Unknown error"}`),l("ready");return}else re=[e.id];const Ae={name:`${e.name} optimization (${re.length} candidates × ${F.length} tasks)`,candidate_ids:re,task_ids:F,parallel:C,use_llm_eval:z};P.mutate(Ae)}},ke=F=>{m(re=>re.includes(F)?re.filter(Ae=>Ae!==F):[...re,F])},_e=()=>{l("ready"),J(null),h(!1),k([]),j(Vo),n()},R=()=>i==="success"&&B?a.jsxs("div",{className:"flex justify-end gap-3",children:[a.jsx(K,{variant:"secondary",onClick:_e,children:"Close"}),a.jsx(K,{variant:"primary",icon:ea,onClick:()=>{_e(),r(`/jobs/${B}`)},children:"View Job"})]}):i==="starting"?null:a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(K,{variant:"secondary",onClick:n,children:"Cancel"}),a.jsx(K,{variant:"primary",icon:ea,onClick:Ce,disabled:u&&f.length===0,children:V?`Start Optimization (${O} tasks)`:`Start Optimization (${Q} runs)`})]});return a.jsx(ls,{isOpen:t,onClose:_e,title:`Optimize: ${e.name}`,footer:R(),size:"lg",children:i==="success"&&B?a.jsxs("div",{className:"flex flex-col items-center py-8",children:[a.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/20 flex items-center justify-center mb-4",children:a.jsx(is,{size:24,className:"text-green-500"})}),a.jsx("h3",{className:"text-lg font-medium mb-2",children:"Job Started!"}),a.jsx("p",{className:"text-[var(--text-secondary)] text-center mb-2",children:V?`Running ${v.join(" → ")} optimization`:"Optimization job is now running"}),a.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-3 py-1.5 rounded font-mono",children:["ID: ",B.slice(0,8),"..."]})]}):i==="starting"?a.jsxs("div",{className:"flex flex-col items-center py-8",children:[a.jsx(ma,{size:32,className:"animate-spin text-[var(--accent)] mb-4"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:Z.isPending?"Importing tasks...":"Creating optimization job..."})]}):a.jsxs("div",{className:"space-y-5",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Task Suite"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:u?"__custom__":o,onChange:F=>{F.target.value==="__custom__"?d(!0):(d(!1),c(F.target.value))},children:[W.map(F=>a.jsxs("option",{value:F.value,children:[F.label," (",F.tasks," tasks) — ",F.description]},F.value)),se.length>0&&a.jsx("option",{value:"__custom__",children:"Custom Selection"})]})]}),u&&se.length>0&&a.jsx("div",{className:"max-h-48 overflow-y-auto border border-[var(--border)] rounded p-2 space-y-1",children:se.map(F=>a.jsxs("label",{className:"flex items-center gap-2 p-2 hover:bg-[var(--bg-tertiary)] cursor-pointer rounded",children:[a.jsx("input",{type:"checkbox",checked:f.includes(F.id),onChange:()=>ke(F.id),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:F.name}),F.suite&&a.jsx(q,{children:F.suite})]},F.id))}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Optimization Strategy"}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mb-3",children:"Select one or more strategies. Multiple strategies run as a pipeline — each stage's best agent feeds into the next. Leave all unchecked for a baseline evaluation."}),a.jsx("div",{className:"space-y-2",children:X0.map(F=>{const re=v.includes(F.key),Ae=v.indexOf(F.key);return a.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${re?"border-[var(--accent)] bg-[var(--accent)]/5":"border-[var(--border)] hover:border-[var(--text-secondary)]"}`,children:[a.jsx("input",{type:"checkbox",checked:re,onChange:()=>{k(mt=>re?mt.filter(xa=>xa!==F.key):[...mt,F.key])},className:"accent-[var(--accent)] mt-0.5"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(F.icon,{size:14,className:"text-[var(--accent)]"}),a.jsx("span",{className:"text-sm font-medium",children:F.label}),re&&v.length>1&&a.jsxs(q,{variant:"info",children:["Step ",Ae+1]})]}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:F.description})]})]},F.key)})}),v.length>1&&a.jsxs("p",{className:"text-xs text-[var(--text-secondary)] mt-2",children:["Pipeline: ",v.join(" → ")]}),v.length>0&&a.jsx("div",{className:"mt-3 pl-8",children:a.jsxs("label",{className:"text-xs text-[var(--text-secondary)] flex items-center gap-2",children:["Max iterations",a.jsx("input",{type:"number",min:1,max:20,value:w,onChange:F=>b(parseInt(F.target.value)||5),className:"w-16 px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm"})]})})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[a.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>h(!p),children:[a.jsx(Zs,{size:14,className:`transition-transform ${p?"rotate-90":""}`}),"Advanced: Grid Search",p&&a.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"(manual variation design)"})]}),p&&a.jsxs("div",{className:"mt-3",children:[T&&v.length>0&&a.jsx("div",{className:"mb-3 p-2 rounded bg-yellow-500/10 border border-yellow-500/30 text-xs text-yellow-600 dark:text-yellow-400",children:"Grid variations are set — this will override the strategy selection and run a static grid search instead."}),D&&a.jsx(Y0,{agentId:e.id,agentName:e.name,agentFramework:e.config.framework,taskSuite:u?void 0:o,taskCount:O,schema:D,onVariationsChange:j,parallel:C,onParallelChange:S,budget:N,onBudgetChange:_,useLlmEval:z,onUseLlmEvalChange:L})]})]})]})})}function Z0(){const e=Dn(),t=Yt(),[n,r]=g.useState(!1),[s,i]=g.useState(null),{data:l=[],isLoading:o}=oe({queryKey:["configs"],queryFn:()=>Tn.list()}),c=Ze({mutationFn:Tn.create,onSuccess:()=>{t.invalidateQueries({queryKey:["configs"]}),r(!1)}}),u=Ze({mutationFn:Tn.delete,onSuccess:()=>t.invalidateQueries({queryKey:["configs"]})}),d=[{key:"name",header:"Name",render:f=>a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:f.name})},{key:"framework",header:"Framework",render:f=>a.jsx(q,{children:f.config.framework||"maf"})},{key:"tools",header:"Tools",render:f=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:e1(f.config.tools)})},{key:"compaction",header:"Compaction",render:f=>{const m=f.config.compaction;return!m||m.strategy==="none"?a.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"}):m.strategy==="head_tail"?a.jsxs(q,{children:[m.params.head_size,"/",m.params.tail_size]}):a.jsx(q,{children:m.strategy})}},{key:"created",header:"Created",render:f=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(f.created_at).toLocaleDateString()}),sortable:!0,sortValue:f=>new Date(f.created_at).getTime()},{key:"actions",header:"",className:"w-40",render:f=>a.jsxs("div",{className:"flex items-center gap-2",onClick:m=>m.stopPropagation(),children:[a.jsx(K,{variant:"primary",size:"sm",icon:is,onClick:()=>i(f),children:"Optimize"}),a.jsx(K,{variant:"ghost",size:"sm",icon:Gc,title:"Delete",onClick:()=>{confirm(`Delete agent "${f.name}"?`)&&u.mutate(f.id)}})]})}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Agents"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Define and optimize your agent configurations."})]}),a.jsx(K,{variant:"primary",icon:Wc,onClick:()=>r(!0),children:"Create agent"})]}),o?a.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[a.jsx(ma,{size:16,className:"animate-spin"}),"Loading agents..."]}):a.jsx(np,{columns:d,data:l,onRowClick:f=>e(`/agents/${f.id}`),searchable:!0,searchPlaceholder:"Search agents",searchFilter:(f,m)=>f.name.toLowerCase().includes(m.toLowerCase())||(f.description||"").toLowerCase().includes(m.toLowerCase()),emptyMessage:"No agents yet. Create your first agent to start optimizing.",emptyIcon:a.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-[var(--bg-tertiary)]",children:a.jsx(Km,{size:24,className:"text-[var(--text-secondary)]"})})}),a.jsx(t1,{isOpen:n,onClose:()=>r(!1),onSubmit:f=>c.mutate(f),isLoading:c.isPending}),s&&a.jsx(rp,{agent:s,isOpen:!!s,onClose:()=>i(null)})]})}function e1(e){return typeof e=="string"?e:Array.isArray(e)?`[${e.length}]`:e&&typeof e=="object"?`[${Object.keys(e).length}]`:"standard"}function t1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){var V,te,O,Q,Ce,ke,_e;const s=["read_file","write_file","edit_file","bash","grep","think"],[i,l]=g.useState("preset"),[o,c]=g.useState({name:"",description:"",instructions:null,model:null,compaction:{strategy:"none",params:{}},tools:s,framework:"miniagent",llm_config_id:null}),[u,d]=g.useState(!1),[f,m]=g.useState("preset"),[v,k]=g.useState([...s]),[w,b]=g.useState(!1),{data:p}=oe({queryKey:["agent-schema"],queryFn:()=>ep.getAgentSchema()}),{data:h=[]}=oe({queryKey:["llm-configs"],queryFn:()=>C0.list()}),{data:x}=oe({queryKey:["tools"],queryFn:()=>_0.list()}),j=((V=x==null?void 0:x.tools)==null?void 0:V.map(R=>R.name))??s,C=(x==null?void 0:x.presets)??{},S=Object.keys(C),N=(p==null?void 0:p.frameworks)??{},_=Object.keys(N).length>0?Object.keys(N):Q0,z=o.framework||"miniagent",L=((O=(te=p==null?void 0:p.frameworks)==null?void 0:te[z])==null?void 0:O.compaction_strategies)??["none","head_tail"],B=(p==null?void 0:p.compaction_strategies)??{},J=(p==null?void 0:p.agent_presets)??[],se=R=>{const H=R.config,F=H.compaction;n({name:R.name+"-agent",description:R.description,framework:H.framework||"miniagent",tools:H.tools||"standard",compaction:F||{strategy:"none",params:{}},instructions:H.instructions||null})},ce=R=>{if(R.preventDefault(),!o.name.trim())return;const H={...o};f==="custom"&&(H.tools=v),n(H)},D=((Q=o.compaction)==null?void 0:Q.strategy)!=="none",W=((Ce=o.compaction)==null?void 0:Ce.strategy)||"none",Z=B[W],P=R=>{k(H=>H.includes(R)?H.filter(F=>F!==R):[...H,R])},A=R=>{const H=B[R],F={};if(H!=null&&H.params)for(const[re,Ae]of Object.entries(H.params))Ae.default!==void 0&&(F[re]=Ae.default);c({...o,compaction:{strategy:R,params:F}})},T=i==="custom"?a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(K,{type:"submit",form:"create-agent-form",variant:"primary",disabled:!o.name.trim(),loading:r,children:"Create Agent"})]}):a.jsx("div",{className:"flex justify-end gap-2",children:a.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"})});return a.jsxs(ls,{isOpen:e,onClose:t,title:"Create Agent",footer:T,children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b border-[var(--border)]",children:[a.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${i==="preset"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("preset"),children:"From Preset"}),a.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${i==="custom"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("custom"),children:"Custom"})]}),i==="preset"?a.jsx("div",{className:"space-y-3",children:J.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"Loading presets..."}):J.map(R=>a.jsx("button",{type:"button",className:"w-full text-left p-4 border border-[var(--border)] rounded-lg hover:border-[var(--accent)] hover:bg-[var(--accent)]/5 transition-colors",onClick:()=>se(R),disabled:r,children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("h4",{className:"font-medium",children:R.label}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:R.description}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[R.tags.map(H=>a.jsx(q,{variant:"default",children:H},H)),R.suggested_datasets.length>0&&a.jsxs(q,{variant:"success",children:["datasets: ",R.suggested_datasets.join(", ")]})]})]}),a.jsx(Zs,{size:16,className:"text-[var(--text-secondary)] mt-1 flex-shrink-0"})]})},R.name))}):a.jsxs("form",{id:"create-agent-form",onSubmit:ce,className:"space-y-4",children:[a.jsx(yn,{label:"Name",value:o.name,onChange:R=>c({...o,name:R.target.value}),placeholder:"e.g., my-coding-agent",required:!0}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"LLM Configuration"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.llm_config_id||"",onChange:R=>c({...o,llm_config_id:R.target.value||null}),children:[a.jsx("option",{value:"",children:"Use environment variables"}),h.map(R=>a.jsxs("option",{value:R.id,children:[R.name," (",K0[R.provider],R.model_id?` - ${R.model_id}`:"",")",R.is_default?" (default)":""]},R.id))]}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:h.length===0?"No LLM configs found. Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)":o.llm_config_id?"Uses the selected LLM configuration.":"Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Framework"}),a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.framework||"miniagent",onChange:R=>{const H=R.target.value;c({...o,framework:H,compaction:{strategy:"none",params:{}}})},children:_.map(R=>{var H;return a.jsx("option",{value:R,children:((H=N[R])==null?void 0:H.label)||V0[R]||R},R)})}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((ke=N[z])==null?void 0:ke.description)||(z==="miniagent"?"Lightweight agent with token-aware context management.":z==="langgraph"?"Graph-based workflows with state management.":"Default agent implementation.")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(Si,{label:"Custom instructions",checked:u,onChange:R=>{d(R.target.checked),R.target.checked||c({...o,instructions:null})}}),a.jsx(Si,{label:"Enable compaction",checked:D,onChange:R=>{if(R.target.checked){const H=L.find(F=>F!=="none")||"head_tail";A(H)}else c({...o,compaction:{strategy:"none",params:{}}})}})]}),u&&a.jsx("textarea",{className:"w-full h-32 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono resize-y",value:o.instructions||"",onChange:R=>c({...o,instructions:R.target.value||null}),placeholder:"System prompt / instructions for the agent..."}),D&&a.jsxs("div",{className:"space-y-3 p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Compaction Strategy"}),a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:W,onChange:R=>A(R.target.value),children:L.filter(R=>R!=="none").map(R=>{var H;return a.jsx("option",{value:R,children:((H=B[R])==null?void 0:H.label)||R},R)})}),(Z==null?void 0:Z.description)&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:Z.description})]}),(Z==null?void 0:Z.params)&&Object.keys(Z.params).length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-3",children:Object.entries(Z.params).map(([R,H])=>{var Ae;const F=(Ae=o.compaction)==null?void 0:Ae.params[R],re=F!==void 0?F:H.default;return a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:R.replace(/_/g," ")}),a.jsx("input",{type:"number",className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof re=="number"?re:Number(re)||0,onChange:mt=>{const xa=parseFloat(mt.target.value);c({...o,compaction:{...o.compaction,params:{...o.compaction.params,[R]:isNaN(xa)?typeof H.default=="number"?H.default:0:xa}}})},min:H.min,max:H.max,step:H.max&&H.max<=1?.1:1}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:H.description})]},R)})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm font-medium",children:"Tools"}),a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"radio",checked:f==="preset",onChange:()=>m("preset"),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:"Preset"})]}),a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"radio",checked:f==="custom",onChange:()=>m("custom"),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:"Custom"})]})]}),f==="preset"?a.jsxs(a.Fragment,{children:[a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof o.tools=="string"?o.tools:"standard",onChange:R=>c({...o,tools:R.target.value}),children:S.map(R=>a.jsx("option",{value:R,children:R},R))}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((_e=C[typeof o.tools=="string"?o.tools:"standard"])==null?void 0:_e.join(", "))??""})]}):a.jsx("div",{className:"grid grid-cols-2 gap-1 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:j.map(R=>a.jsxs("label",{className:"flex items-center gap-2 p-1 text-sm cursor-pointer hover:bg-[var(--bg-tertiary)]",children:[a.jsx("input",{type:"checkbox",checked:v.includes(R),onChange:()=>P(R),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"font-mono text-xs",children:R})]},R))})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[a.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>b(!w),children:[a.jsx(Zs,{size:14,className:`transition-transform ${w?"rotate-90":""}`}),"More options"]}),w&&a.jsx("div",{className:"mt-3",children:a.jsx(yn,{label:"Description (optional)",value:o.description,onChange:R=>c({...o,description:R.target.value}),placeholder:"Brief description of this agent"})})]})]})]})}function pa({items:e}){return a.jsx("nav",{className:"flex items-center gap-1.5 text-sm mb-4",children:e.map((t,n)=>{const r=n===e.length-1;return a.jsxs("span",{className:"flex items-center gap-1.5",children:[n>0&&a.jsx(Zs,{size:14,className:"text-[var(--text-secondary)]"}),t.path&&!r?a.jsx(Rn,{to:t.path,className:"text-[var(--text-secondary)] hover:text-[var(--accent)] transition-colors",children:t.label}):a.jsx("span",{className:r?"text-[var(--text-primary)] font-medium":"text-[var(--text-secondary)]",children:t.label})]},n)})})}function ge({children:e,className:t="",onClick:n,selected:r=!1,selectable:s=!1}){const i="bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",l=s?"cursor-pointer hover:border-[var(--accent-dim)] transition-colors":"",o=r?"border-[var(--accent)]":"";return a.jsx("div",{className:`${i} ${l} ${o} ${t}`,onClick:n,children:e})}function n1(e){const t=[],n=r=>r.type==="trace_span"&&typeof r.data=="object"&&r.data!==null?r.data:"span_id"in r?r:null;if(Array.isArray(e.spans)){for(const r of e.spans)if(typeof r=="object"&&r!==null){const s=n(r);s&&t.push(s)}}else if(e.span_id)t.push(e);else for(const r in e){const s=e[r];if(typeof s=="object"&&s!==null){const i=n(s);if(i)t.push(i);else if(Array.isArray(s)){for(const l of s)if(typeof l=="object"&&l!==null){const o=n(l);o&&t.push(o)}}}}return t}function sp(e){const t=new Map,n=[];for(const s of e)t.set(s.span_id,{span:s,children:[]});for(const s of e){const i=t.get(s.span_id);s.parent_span_id&&t.has(s.parent_span_id)?t.get(s.parent_span_id).children.push(i):n.push(i)}const r=s=>{s.sort((i,l)=>(i.span.start_time||0)-(l.span.start_time||0)),s.forEach(i=>r(i.children))};return r(n),n}function r1(e){return e.includes("Agent")||e.includes("agent")?"bg-[var(--span-llm-bg)] text-[var(--span-llm-text)]":e.includes("chat")||e.includes("Chat")||e.includes("llm")?"bg-[var(--span-tool-bg)] text-[var(--span-tool-text)]":e.includes("tool")||e.includes("execute")||e.includes("bash")?"bg-[var(--span-agent-bg)] text-[var(--span-agent-text)]":"bg-[var(--span-other-bg)] text-[var(--span-other-text)]"}function s1(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(0)}ms`}function nu({node:e,depth:t=0}){var f,m;const[n,r]=g.useState(t<2),[s,i]=g.useState(!1),{span:l}=e,o=e.children.length>0,c=(f=l.attributes)==null?void 0:f["gen_ai.usage.input_tokens"],u=(m=l.attributes)==null?void 0:m["gen_ai.usage.output_tokens"],d=c!==void 0||u!==void 0;return a.jsxs("div",{className:"relative",children:[t>0&&a.jsx("div",{className:"absolute left-0 top-0 bottom-0 border-l-2 border-[var(--border)]",style:{marginLeft:`${(t-1)*16+8}px`}}),a.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-1 hover:bg-[var(--bg-primary)] rounded transition-colors cursor-pointer",style:{paddingLeft:`${t*16}px`},onClick:()=>o?r(!n):i(!s),children:[a.jsx("div",{className:"w-4 h-4 flex items-center justify-center text-[var(--text-secondary)]",children:o?n?"▼":"▶":s?"▼":"▶"}),a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${r1(l.operation_name)}`,children:l.operation_name.replace("ChatAgent.","").replace("invoke_agent ","")}),l.duration_ms!==void 0&&a.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:s1(l.duration_ms)}),d&&a.jsxs("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:[c!==void 0&&a.jsxs("span",{className:"text-blue-400",children:["↑",String(c)]}),c!==void 0&&u!==void 0&&a.jsx("span",{className:"mx-0.5",children:"/"}),u!==void 0&&a.jsxs("span",{className:"text-green-400",children:["↓",String(u)]})]})]}),s&&!o&&a.jsx("div",{className:"ml-4 mt-1 mb-2 p-2 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs",style:{marginLeft:`${t*16+20}px`},children:a.jsxs("div",{className:"space-y-1",children:[l.span_id&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Span ID:"}),a.jsx("span",{className:"font-mono text-xs break-all",children:l.span_id})]}),l.trace_id&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Trace ID:"}),a.jsx("span",{className:"font-mono text-xs break-all",children:l.trace_id})]}),l.status&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Status:"}),a.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs ${l.status==="OK"||l.status==="StatusCode.UNSET"?"bg-[var(--span-pass-bg)] text-[var(--span-pass-text)]":"bg-[var(--span-fail-bg)] text-[var(--span-fail-text)]"}`,children:l.status})]}),Object.keys(l.attributes||{}).length>0&&a.jsxs("div",{className:"mt-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] block mb-1",children:"Attributes:"}),a.jsx("pre",{className:"text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded p-2 overflow-auto max-h-32 whitespace-pre-wrap break-all",children:JSON.stringify(l.attributes,null,2)})]})]})}),o&&n&&a.jsx("div",{children:e.children.map((v,k)=>a.jsx(nu,{node:v,depth:t+1},v.span.span_id||k))})]})}function ap({trace:e}){const[t,n]=g.useState("tree"),r=g.useMemo(()=>n1(e),[e]),s=g.useMemo(()=>sp(r),[r]);return Object.keys(e).length===0?null:a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"font-medium",children:"Trace Data"}),a.jsxs("div",{className:"flex gap-1",children:[a.jsx("button",{onClick:()=>n("tree"),className:`px-2 py-1 text-xs rounded ${t==="tree"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Tree"}),a.jsx("button",{onClick:()=>n("raw"),className:`px-2 py-1 text-xs rounded ${t==="raw"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Raw"})]})]}),t==="tree"?r.length>0?a.jsx("div",{className:"border border-[var(--border)] rounded overflow-hidden",children:a.jsxs("div",{className:"p-2",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs(q,{variant:"default",children:[r.length," spans"]}),a.jsx("span",{children:"•"}),a.jsx("span",{children:"Click to expand details"})]}),s.map((i,l)=>a.jsx(nu,{node:i,depth:0},i.span.span_id||l))]})}):a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No structured spans found. View raw data below."}):a.jsx("pre",{className:"text-xs bg-[var(--bg-primary)] p-3 overflow-x-auto border border-[var(--border)] max-h-96 whitespace-pre-wrap",children:JSON.stringify(e,null,2)})]})}function a1({spans:e,isLive:t=!1}){const n=g.useRef(null),r=g.useMemo(()=>sp(e),[e]);return g.useEffect(()=>{n.current&&t&&n.current.scrollTo({top:n.current.scrollHeight,behavior:"smooth"})},[e.length,t]),a.jsxs("div",{className:"border border-[var(--border)] rounded overflow-hidden h-full flex flex-col",children:[a.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-[var(--border)] bg-[var(--bg-secondary)]",children:[a.jsxs(q,{variant:"default",children:[e.length," spans"]}),t&&a.jsx("span",{className:"animate-pulse",children:a.jsx(q,{variant:"info",children:"Live"})})]}),a.jsx("div",{ref:n,className:"flex-1 overflow-auto p-2",children:r.length>0?r.map((s,i)=>a.jsx(nu,{node:s,depth:0},s.span.span_id||i)):a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:t?"Waiting for spans...":"No spans recorded"})})]})}function ip({agent:e}){const[t,n]=g.useState(""),[r,s]=g.useState(null),[i,l]=g.useState("idle"),[o,c]=g.useState(null),[u,d]=g.useState(""),[f,m]=g.useState([]),[v,k]=g.useState(null),[w,b]=g.useState(null),[p,h]=g.useState([]),[x,j]=g.useState(!1),C=g.useRef(null),{data:S=[]}=oe({queryKey:["tasks"],queryFn:()=>kt.list()});g.useEffect(()=>{C.current&&i==="running"&&(C.current.scrollTop=C.current.scrollHeight)},[u,i]);const N=D=>{if(s(D),D){const W=S.find(Z=>Z.id===D);W&&n(W.prompt)}},_=async()=>{if(t.trim()){l("running"),d(""),m([]),k(null),b(null),h([]);try{const D=await Ls.create({agent_id:e.id,prompt:t.trim(),task_id:r||void 0});c(D.id);for await(const W of Ls.start(D.id))z(W)}catch(D){b(D instanceof Error?D.message:"Test failed"),l("failed")}}},z=D=>{switch(D.event){case"started":break;case"execution":D.execution_event==="text_delta"&&D.content?d(W=>W+D.content):D.execution_event==="tool_call_start"&&D.tool_name?h(W=>[...W,{name:D.tool_name}]):D.execution_event==="tool_result"&&D.content&&h(W=>{if(W.length>0){const Z=[...W];return Z[Z.length-1]={...Z[Z.length-1],content:D.content},Z}return W});break;case"span":if(D.span){const W=D.span;if(W.data){const Z={span_id:W.data.span_id||"",trace_id:W.data.trace_id||"",parent_span_id:W.data.parent_span_id||null,operation_name:W.data.operation_name||"",start_time:W.timestamp?new Date(W.timestamp).getTime():Date.now(),end_time:Date.now(),duration_ms:W.data.duration_ms||0,status:W.data.status||"OK",attributes:W.data.attributes||{}};m(P=>[...P,Z])}}break;case"complete":l("completed"),D.result&&k(D.result);break;case"error":b(D.message),l("failed");break}},L=async()=>{if(o)try{await Ls.cancel(o)}catch{}l("idle")},B=()=>{l("idle"),c(null),d(""),m([]),k(null),b(null),h([])},J=i==="running",se=i==="completed"||i==="failed",ce=D=>{D.preventDefault(),se?(B(),setTimeout(()=>_(),0)):_()};return a.jsxs("div",{className:"h-full flex flex-col border border-[var(--border)] rounded-lg overflow-hidden bg-[var(--bg-primary)]",children:[(J||se)&&a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border)] bg-[var(--bg-secondary)] flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[J&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"animate-pulse",children:a.jsx(q,{variant:"info",children:"Running"})}),a.jsx(K,{variant:"ghost",size:"sm",icon:Rd,onClick:L,children:"Cancel"})]}),i==="completed"&&a.jsx(q,{variant:"success",children:"Completed"}),i==="failed"&&a.jsx(q,{variant:"error",children:"Failed"})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[v&&a.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Am,{size:12}),v.duration_seconds.toFixed(2),"s"]}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Fg,{size:12}),v.tokens_total," tokens"]}),v.passed!==null&&(v.passed?a.jsx(Dm,{size:14,className:"text-[var(--success)]"}):a.jsx(Xg,{size:14,className:"text-[var(--error)]"}))]}),f.length>0&&a.jsxs(K,{variant:x?"primary":"secondary",size:"sm",icon:Eg,onClick:()=>j(!x),children:["Traces (",f.length,")"]}),se&&o&&a.jsx(Rn,{to:`/tests/${o}`,children:a.jsx(K,{variant:"secondary",size:"sm",icon:Um,children:"Details"})})]})]}),a.jsxs("div",{className:"flex-1 min-h-0 flex",children:[a.jsx("div",{ref:C,className:`flex-1 overflow-auto p-4 ${x?"border-r border-[var(--border)]":""}`,children:!J&&!se?a.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center",children:[a.jsx("div",{className:"text-lg font-medium mb-1",children:e.name}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] max-w-sm",children:"Send a message to test this agent, or select a task from the dropdown below."})]}):a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"flex justify-end",children:a.jsx("div",{className:"max-w-[80%] px-3 py-2 bg-[var(--accent-dim)] text-[var(--text-primary)] rounded-lg text-sm",children:t})}),(u||J)&&a.jsx("div",{className:"px-3 py-2 text-sm whitespace-pre-wrap font-mono bg-[var(--bg-secondary)] rounded-lg border border-[var(--border)]",children:u||a.jsx("span",{className:"text-[var(--text-secondary)] animate-pulse",children:"Thinking..."})}),p.length>0&&a.jsx("div",{className:"space-y-1.5",children:p.map((D,W)=>a.jsxs("div",{className:"p-2 bg-[var(--badge-info-bg)] border border-[var(--badge-info-border)] rounded-md text-xs",children:[a.jsx(q,{variant:"info",children:D.name}),D.content&&a.jsxs("div",{className:"mt-1 text-[var(--text-secondary)] truncate max-w-full font-mono",children:[D.content.substring(0,200),D.content.length>200&&"..."]})]},W))}),w&&a.jsx("div",{className:"p-3 bg-[var(--badge-error-bg)] border border-[var(--badge-error-border)] rounded-md text-sm text-[var(--badge-error-text)]",children:w})]})}),x&&a.jsx("div",{className:"w-[350px] flex-shrink-0 overflow-auto",children:a.jsx(a1,{spans:f,isLive:J})})]}),a.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] bg-[var(--bg-secondary)]",children:[a.jsx("div",{className:"px-4 pt-2",children:a.jsxs("select",{value:r||"",onChange:D=>N(D.target.value||null),className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs text-[var(--text-secondary)]",disabled:J,children:[a.jsx("option",{value:"",children:"Custom prompt..."}),S.map(D=>a.jsx("option",{value:D.id,children:D.name},D.id))]})}),a.jsxs("form",{onSubmit:ce,className:"p-3 flex gap-2",children:[a.jsx("textarea",{value:t,onChange:D=>n(D.target.value),placeholder:"Message the agent...",disabled:J,rows:1,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm resize-none min-h-[40px] max-h-[120px] focus:outline-none focus:border-[var(--accent)]",onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),ce(D))}}),a.jsx(K,{type:"submit",variant:"primary",icon:J?Rd:ea,disabled:J?!1:!t.trim(),onClick:J?L:void 0,children:J?"Stop":se?"New Test":"Run"})]})]})]})}function i1(){const{agentId:e}=ha(),t=Dn(),n=Yt(),[r,s]=g.useState("overview"),[i,l]=g.useState(!1),{data:o,isLoading:c}=oe({queryKey:["configs",e],queryFn:()=>Tn.get(e),enabled:!!e}),{data:u=[]}=oe({queryKey:["tests",{agent_id:e}],queryFn:()=>Ls.list({agent_id:e}),enabled:!!e}),{data:d=[]}=oe({queryKey:["jobs"],queryFn:()=>Mt.list()}),f=Ze({mutationFn:v=>Tn.delete(v),onSuccess:()=>{n.invalidateQueries({queryKey:["configs"]}),t("/agents")}}),m=d.filter(v=>v.candidate_ids.includes(e||""));return c?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):o?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsxs("div",{className:"mb-4 flex-shrink-0",children:[a.jsx(pa,{items:[{label:"Agents",path:"/agents"},{label:o.name}]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:o.name}),o.is_auto_generated&&a.jsx(q,{variant:"info",children:"Auto-generated"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(K,{variant:"primary",icon:is,size:"sm",onClick:()=>l(!0),children:"Optimize"}),a.jsx(K,{variant:"secondary",icon:Gc,size:"sm",onClick:()=>{confirm(`Delete agent "${o.name}"?`)&&f.mutate(o.id)},children:"Delete"})]})]}),o.description&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:o.description})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsxs("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:[a.jsxs("div",{className:"flex gap-1 mb-4 border-b border-[var(--border)] flex-shrink-0",children:[a.jsx(Cl,{active:r==="overview",onClick:()=>s("overview"),icon:a.jsx(Km,{size:14}),children:"Overview"}),a.jsx(Cl,{active:r==="evaluate",onClick:()=>s("evaluate"),icon:a.jsx(ea,{size:14}),children:"Evaluate"}),a.jsx(Cl,{active:r==="history",onClick:()=>s("history"),icon:a.jsx(Ug,{size:14}),badge:u.length,children:"History"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r==="overview"&&a.jsx(l1,{agent:o,recentTests:u,jobs:m}),r==="evaluate"&&a.jsx(o1,{agent:o,jobs:m}),r==="history"&&a.jsx(c1,{tests:u})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[a.jsx(Vm,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),a.jsx("div",{className:"flex-1 min-h-0",children:a.jsx(ip,{agent:o})})]})]}),i&&a.jsx(rp,{agent:o,isOpen:i,onClose:()=>l(!1)})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Agent not found"})}function Cl({active:e,onClick:t,icon:n,badge:r,children:s}){return a.jsxs("button",{onClick:t,className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors ${e?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[n,s,r!==void 0&&r>0&&a.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs bg-[var(--bg-tertiary)] rounded",children:r})]})}function l1({agent:e,recentTests:t,jobs:n}){var i,l;const r=e.config,s=()=>{const o=r.tools;return typeof o=="string"?o:Array.isArray(o)?o.join(", "):o&&typeof o=="object"?Object.keys(o).join(", "):"standard"};return a.jsxs("div",{className:"space-y-4",children:[a.jsx(hr,{title:"Model",children:a.jsx("div",{className:"font-mono text-sm",children:r.model||"default"})}),a.jsx(hr,{title:"Instructions",defaultCollapsed:!r.instructions,children:r.instructions?a.jsx("pre",{className:"p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs whitespace-pre-wrap max-h-40 overflow-auto font-mono",children:r.instructions}):a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No instructions set"})}),a.jsx(hr,{title:"Tools",children:a.jsx("div",{className:"font-mono text-sm",children:s()})}),a.jsx(hr,{title:"Compaction",children:a.jsx("div",{className:"font-mono text-sm",children:!r.compaction||r.compaction.strategy==="none"?"disabled":`${r.compaction.strategy} (${((i=r.compaction.params)==null?void 0:i.head_size)||0}/${((l=r.compaction.params)==null?void 0:l.tail_size)||0})`})}),t.length>0&&a.jsx(hr,{title:`Recent Tests (${t.length})`,children:a.jsx("div",{className:"space-y-1.5",children:t.slice(0,3).map(o=>a.jsxs(Rn,{to:`/tests/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx(lp,{status:o.status}),a.jsxs("span",{className:"truncate",children:[o.prompt.slice(0,40),"..."]})]}),a.jsxs("span",{className:"text-[var(--text-secondary)] flex-shrink-0 ml-2",children:[o.duration_seconds.toFixed(1),"s"]})]},o.id))})}),n.length>0&&a.jsx(hr,{title:`Experiments (${n.length})`,children:a.jsx("div",{className:"space-y-1.5",children:n.slice(0,3).map(o=>a.jsxs(Rn,{to:`/jobs/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(q,{variant:o.status==="completed"?"success":o.status==="running"?"info":"default",children:o.status}),a.jsx("span",{children:o.name})]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(o.created_at).toLocaleDateString()})]},o.id))})})]})}function hr({title:e,children:t,defaultCollapsed:n=!1}){const[r,s]=g.useState(n);return a.jsxs("div",{className:"border-b border-[var(--border)] pb-3",children:[a.jsxs("button",{onClick:()=>s(!r),className:"flex items-center justify-between w-full text-left py-1 hover:text-[var(--accent)] transition-colors",children:[a.jsx("span",{className:"text-sm font-medium",children:e}),a.jsx("span",{className:"text-[var(--text-secondary)] text-xs",children:r?"▶":"▼"})]}),!r&&a.jsx("div",{className:"mt-2",children:t})]})}function o1({agent:e,jobs:t}){const n=Dn(),r=Yt(),[s,i]=g.useState("quick"),[l,o]=g.useState(!1),{data:c=[]}=oe({queryKey:["suites"],queryFn:()=>kt.listSuites()}),u=Ze({mutationFn:P0.start,onSuccess:f=>{r.invalidateQueries({queryKey:["jobs"]}),o(!1),n(`/jobs/${f.id}`)},onError:()=>{o(!1)}}),d=()=>{o(!0),u.mutate({agent_id:e.id,suite_name:s,use_llm_eval:!0,parallel:4})};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:"Run this agent on a task suite to measure quality and cost."}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm",value:s,onChange:f=>i(f.target.value),disabled:l,children:c.map(f=>a.jsxs("option",{value:f.name,children:[f.name.charAt(0).toUpperCase()+f.name.slice(1)," (",f.task_count," tasks)"]},f.name))}),a.jsx(K,{variant:"primary",icon:l?ma:ea,onClick:d,disabled:l,loading:l,className:"w-full",children:"Evaluate"})]})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h4",{className:"text-sm font-medium",children:"Optimization Jobs"}),a.jsx(K,{variant:"secondary",size:"sm",icon:is,onClick:()=>n("/agents",{state:{optimizeAgent:e}}),children:"New Job"})]}),t.length===0?a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No optimization jobs yet."}):a.jsx("div",{className:"space-y-1.5",children:t.slice(0,5).map(f=>a.jsxs(Rn,{to:`/jobs/${f.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(q,{variant:f.status==="completed"?"success":f.status==="running"?"info":"default",children:f.status}),a.jsx("span",{children:f.name})]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(f.created_at).toLocaleDateString()})]},f.id))})]})]})}function c1({tests:e}){return e.length===0?a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No test history yet. Use the playground on the right to run a test."}):a.jsx("div",{className:"space-y-2",children:e.map(t=>a.jsxs(Rn,{to:`/tests/${t.id}`,className:"flex items-center justify-between p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(lp,{status:t.status}),t.score!==null&&a.jsxs("span",{className:`text-sm font-medium ${t.passed?"text-[var(--success)]":"text-[var(--error)]"}`,children:[(t.score*100).toFixed(0),"%"]})]}),a.jsx("p",{className:"text-sm truncate",children:t.prompt})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1 ml-4",children:[a.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:new Date(t.created_at).toLocaleString()}),a.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:[t.duration_seconds.toFixed(1),"s"]}),a.jsxs("span",{children:[t.tokens_total," tokens"]})]})]})]},t.id))})}function lp({status:e}){const t={completed:"success",failed:"error",running:"info",cancelled:"warning",pending:"default"};return a.jsx(q,{variant:t[e]||"default",children:e})}function u1(){const e=Yt(),[t,n]=g.useState(!1),[r,s]=g.useState(!1),[i,l]=g.useState(null),[o,c]=g.useState(new Set),u=p=>{c(h=>{const x=new Set(h);return x.has(p)?x.delete(p):x.add(p),x})},{data:d=[],isLoading:f}=oe({queryKey:["tasks"],queryFn:()=>kt.list()}),m=Ze({mutationFn:kt.create,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),n(!1)}}),v=Ze({mutationFn:kt.importSuite,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),s(!1)}}),k=Ze({mutationFn:kt.delete,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),l(null)}}),w=d.reduce((p,h)=>{const x=h.suite||"custom";return p[x]||(p[x]=[]),p[x].push(h),p},{}),b=Object.keys(w).sort((p,h)=>p==="custom"?-1:h==="custom"?1:p.localeCompare(h));return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Datasets"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Task datasets for evaluating agent configurations."})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(K,{variant:"secondary",onClick:()=>s(!0),children:"Import Suite"}),a.jsx(K,{variant:"primary",onClick:()=>n(!0),children:"+ New Task"})]})]}),f?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):d.length===0?a.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:"No tasks yet. Create one or import a built-in suite."}):a.jsx("div",{className:"space-y-4",children:b.map(p=>{const h=w[p],x=!o.has(p);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>u(p),className:"flex items-center gap-2 py-2 hover:text-[var(--accent)] transition-colors",children:[x?a.jsx(Rg,{size:16,className:"text-[var(--text-secondary)]"}):a.jsx(Zs,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium uppercase tracking-wide",children:p==="custom"?"Custom Tasks":`${p} Suite`}),a.jsx(q,{variant:p==="custom"?"default":"info",children:h.length})]}),x&&a.jsx("div",{className:"mt-2 border border-[var(--border)] rounded-lg overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:[a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Name"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Category"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Prompt"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Criteria"})]})}),a.jsx("tbody",{children:h.map(j=>a.jsxs("tr",{onClick:()=>l(j),className:"border-b border-[var(--border)] last:border-b-0 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors",children:[a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:j.name})}),a.jsx("td",{className:"px-4 py-3",children:j.category&&j.category!=="default"?a.jsx(q,{variant:"default",children:j.category}):a.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"})}),a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-[var(--text-secondary)] line-clamp-1 max-w-md",children:j.prompt})}),a.jsx("td",{className:"px-4 py-3 text-[var(--text-secondary)]",children:j.criteria.length>0?j.criteria.length:"--"})]},j.id))})]})})]},p)})}),a.jsx(d1,{task:i,onClose:()=>l(null),onDelete:p=>{confirm("Delete this task?")&&k.mutate(p)}}),a.jsx(f1,{isOpen:t,onClose:()=>n(!1),onSubmit:p=>m.mutate(p),isLoading:m.isPending}),a.jsx(h1,{isOpen:r,onClose:()=>s(!1),onSubmit:p=>v.mutate(p),isLoading:v.isPending})]})}function d1({task:e,onClose:t,onDelete:n}){const[r,s]=g.useState("prompt");if(!e)return null;const i=a.jsxs("div",{className:"flex justify-between",children:[a.jsx(K,{variant:"ghost",onClick:()=>n(e.id),className:"text-red-500 hover:text-red-600",children:"Delete Task"}),a.jsx(K,{variant:"secondary",onClick:t,children:"Close"})]});return a.jsx(ls,{isOpen:!!e,onClose:t,title:e.name,size:"lg",footer:i,children:a.jsxs("div",{className:"space-y-4",children:[e.category&&e.category!=="default"&&a.jsx("div",{children:a.jsx(q,{variant:"default",children:e.category})}),a.jsxs("div",{className:"flex gap-1 border-b border-[var(--border)]",children:[a.jsx("button",{onClick:()=>s("prompt"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="prompt"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Prompt"}),a.jsxs("button",{onClick:()=>s("criteria"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="criteria"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:["Eval Criteria (",e.criteria.length,")"]})]}),r==="prompt"&&a.jsx("div",{className:"p-4 bg-[var(--bg-tertiary)] rounded text-sm whitespace-pre-wrap min-h-[200px]",children:e.prompt}),r==="criteria"&&a.jsx("div",{className:"space-y-2 min-h-[200px]",children:e.criteria.length===0?a.jsx("div",{className:"text-[var(--text-secondary)] text-sm p-4",children:"No evaluation criteria defined for this task."}):e.criteria.map(l=>a.jsxs("div",{className:"p-3 bg-[var(--bg-tertiary)] rounded",children:[a.jsx("div",{className:"font-medium text-sm",children:l.name}),l.instruction&&a.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1",children:l.instruction})]},l.name))})]})})}function f1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,i]=g.useState({name:"",prompt:"",criteria:[],category:"default"}),l=()=>{i({...s,criteria:[...s.criteria,{name:"",instruction:"",weight:1}]})},o=(d,f)=>{const m=[...s.criteria];m[d]={...m[d],...f},i({...s,criteria:m})},c=d=>{i({...s,criteria:s.criteria.filter((f,m)=>m!==d)})},u=d=>{d.preventDefault(),!(!s.name.trim()||!s.prompt.trim())&&n({...s,criteria:s.criteria.filter(f=>f.name.trim()&&f.instruction.trim())})};return a.jsx(ls,{isOpen:e,onClose:t,title:"Create Task",children:a.jsxs("form",{onSubmit:u,className:"space-y-4",children:[a.jsx(yn,{label:"Name",value:s.name,onChange:d=>i({...s,name:d.target.value}),placeholder:"e.g., fizzbuzz",required:!0}),a.jsx(q0,{label:"Prompt",value:s.prompt,onChange:d=>i({...s,prompt:d.target.value}),placeholder:"The task description for the agent...",required:!0}),a.jsx(yn,{label:"Category",value:s.category,onChange:d=>i({...s,category:d.target.value}),placeholder:"e.g., coding, research"}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Evaluation Criteria"}),a.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"+ Add"})]}),a.jsx("div",{className:"space-y-2",children:s.criteria.map((d,f)=>a.jsxs("div",{className:"flex gap-2 items-start",children:[a.jsx(yn,{value:d.name,onChange:m=>o(f,{name:m.target.value}),placeholder:"Name",className:"w-32"}),a.jsx(yn,{value:d.instruction,onChange:m=>o(f,{instruction:m.target.value}),placeholder:"Instruction",className:"flex-1"}),a.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(f),children:"×"})]},f))})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[a.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(K,{type:"submit",variant:"primary",disabled:r||!s.name.trim()||!s.prompt.trim(),children:r?"Creating...":"Create"})]})]})})}function h1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,i]=g.useState(""),{data:l=[],isLoading:o}=oe({queryKey:["suites"],queryFn:()=>kt.listSuites(),enabled:e});return g.useEffect(()=>{l.length>0&&!s&&i(l[0].name)},[l,s]),a.jsx(ls,{isOpen:e,onClose:t,title:"Import Task Suite",children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Import a built-in task suite for evaluation."}),o?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading suites..."}):l.length===0?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"No suites available."}):a.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:l.map(c=>a.jsxs("label",{className:`flex items-center gap-3 p-3 border cursor-pointer ${s===c.name?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[a.jsx("input",{type:"radio",name:"suite",value:c.name,checked:s===c.name,onChange:()=>i(c.name),className:"accent-[var(--accent)]"}),a.jsxs("span",{className:"capitalize",children:[c.name.replace(/_/g," ")," (",c.task_count," tasks) - ",c.description]})]},c.name))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[a.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(K,{variant:"primary",onClick:()=>n(s),disabled:r||!s,children:r?"Importing...":"Import"})]})]})})}function m1(){const e=Dn(),t=Yt(),[n,r]=g.useState(!1),s=eu(),{data:i=[],isLoading:l}=oe({queryKey:["jobs",n],queryFn:()=>Mt.list({include_public:n}),refetchInterval:5e3}),o=Ze({mutationFn:Mt.delete,onSuccess:()=>t.invalidateQueries({queryKey:["jobs"]})}),c={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"},u=[{key:"name",header:"Name",render:d=>a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:d.name||`Job ${d.id.slice(0,8)}`}),d.is_public&&a.jsx(qc,{className:"w-3 h-3 ml-2 inline text-[var(--text-secondary)]"})]})},{key:"status",header:"Status",render:d=>a.jsx(q,{variant:c[d.status]||"default",children:d.status})},{key:"candidates",header:"Candidates",render:d=>a.jsx("span",{children:d.candidate_ids.length})},{key:"tasks",header:"Tasks",render:d=>a.jsx("span",{children:d.task_ids.length})},{key:"runs",header:"Runs",render:d=>a.jsxs("span",{children:[d.completed_experiments,"/",d.total_experiments]})},{key:"created",header:"Created",render:d=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(d.created_at).toLocaleDateString()}),sortable:!0,sortValue:d=>new Date(d.created_at).getTime()},{key:"actions",header:"",className:"w-12",render:d=>!d.user_id||d.user_id==="anonymous"||s&&d.created_by_name===s?a.jsx("div",{onClick:m=>m.stopPropagation(),children:a.jsx(K,{variant:"ghost",size:"sm",icon:Gc,title:"Delete",disabled:d.status==="running",onClick:()=>{confirm("Delete this job?")&&o.mutate(d.id)}})}):null}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Experiments"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"View and manage optimization experiments. Start new experiments from the Agents page."})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Si,{label:"Show public",checked:n,onChange:d=>r(d.target.checked)}),a.jsx(K,{variant:"secondary",onClick:()=>e("/agents"),children:"Go to Agents"})]})]}),l?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):a.jsx(np,{columns:u,data:i,onRowClick:d=>e(`/jobs/${d.id}`),searchable:!0,searchPlaceholder:"Search experiments",searchFilter:(d,f)=>(d.name||"").toLowerCase().includes(f.toLowerCase())||d.id.toLowerCase().includes(f.toLowerCase()),emptyMessage:"No experiments yet. Go to Agents page to start an optimization."})]})}function p1(e,t=!0){return Math.abs(e)<10?"text-[var(--text-secondary)]":(t?e<0:e>0)?"text-green-400":"text-red-400"}function x1(e){return`${e>0?"+":""}${e.toFixed(1)}%`}function op(e,t){return t===0?0:(e-t)/t*100}function vs({label:e,values:t,baselineIndex:n,formatter:r,isLowerBetter:s=!0}){const i=t[n];return a.jsxs("tr",{className:"border-b border-[var(--border)] last:border-0",children:[a.jsx("td",{className:"py-2 pr-4 text-[var(--text-secondary)] text-sm",children:e}),t.map((l,o)=>{const c=op(l,i),u=o===n;return a.jsxs("td",{className:"py-2 px-4 text-right",children:[a.jsx("div",{className:"font-mono",children:r(l)}),!u&&a.jsx("div",{className:`text-xs ${p1(c,s)}`,children:x1(c)}),u&&a.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"(baseline)"})]},o)})]})}function v1({runs:e,baselineRunId:t}){const n=g.useMemo(()=>{if(t){const i=e.findIndex(l=>l.id===t);if(i>=0)return i}return 0},[e,t]);if(e.length<2)return null;const r=Math.min(...e.map(i=>i.tokens_total)),s=Math.max(...e.map(i=>i.score));return a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-4",children:"Candidate Comparison"}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-[var(--border)]",children:[a.jsx("th",{className:"pb-2 pr-4 text-left text-[var(--text-secondary)] font-medium",children:"Metric"}),e.map((i,l)=>a.jsx("th",{className:"pb-2 px-4 text-right",children:a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsx("span",{className:"font-medium",children:i.candidate_name}),i.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"}),l===n&&a.jsx(q,{variant:"info",children:"Base"})]})},i.id))]})}),a.jsxs("tbody",{children:[a.jsx(vs,{label:"Total Tokens",values:e.map(i=>i.tokens_total),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(vs,{label:"Input Tokens",values:e.map(i=>i.tokens_input),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(vs,{label:"Output Tokens",values:e.map(i=>i.tokens_output),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(vs,{label:"Duration",values:e.map(i=>i.duration_seconds),baselineIndex:n,formatter:i=>`${i.toFixed(1)}s`,isLowerBetter:!0}),a.jsx(vs,{label:"Score",values:e.map(i=>i.score*100),baselineIndex:n,formatter:i=>`${i.toFixed(1)}%`,isLowerBetter:!1})]})]})}),a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[a.jsx("h4",{className:"text-sm font-medium mb-2 text-[var(--text-secondary)]",children:"Key Insights"}),a.jsxs("ul",{className:"text-sm space-y-1 text-[var(--text-secondary)]",children:[e.map(i=>{const l=op(i.tokens_total,e[n].tokens_total);return i.tokens_total===r&&l<-5?a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-green-400",children:"✓"}),a.jsxs("span",{children:[a.jsx("strong",{children:i.candidate_name})," uses ",Math.abs(l).toFixed(0),"% fewer tokens"]})]},`token-${i.id}`):null}),e.map(i=>i.score===s&&i.passed?a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-green-400",children:"✓"}),a.jsxs("span",{children:[a.jsx("strong",{children:i.candidate_name})," achieved highest score (",(i.score*100).toFixed(0),"%)"]})]},`score-${i.id}`):null),e.filter(i=>i.is_pareto).length>0&&a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-purple-400",children:"★"}),a.jsxs("span",{children:["Optimal candidates (best tradeoff):"," ",e.filter(i=>i.is_pareto).map(i=>i.candidate_name).join(", ")]})]})]})]}),a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[a.jsx("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:"Token Efficiency"}),a.jsx("div",{className:"space-y-2",children:e.map(i=>{const l=i.tokens_total/e[n].tokens_total*100,o=i.tokens_total<=r;return a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-24 text-sm truncate",title:i.candidate_name,children:i.candidate_name}),a.jsx("div",{className:"flex-1 h-6 bg-[var(--bg-primary)] rounded overflow-hidden",children:a.jsx("div",{className:`h-full transition-all duration-300 ${o?"bg-green-500":"bg-blue-500"}`,style:{width:`${Math.min(l,100)}%`}})}),a.jsx("div",{className:"w-20 text-right font-mono text-sm",children:i.tokens_total.toLocaleString()})]},i.id)})})]})]})}function y1({summaries:e,height:t=350}){const n=g.useRef(null),[r,s]=g.useState(600),[i,l]=g.useState("tokens"),[o,c]=g.useState(null),[u,d]=g.useState({x:0,y:0});g.useEffect(()=>{const S=()=>{n.current&&s(n.current.clientWidth)};return S(),window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]);const f={top:30,right:30,bottom:50,left:60},m=r-f.left-f.right,v=t-f.top-f.bottom,k=S=>i==="tokens"?S.avg_tokens:S.avg_duration,{xScale:w,yScale:b,xTicks:p,yTicks:h,paretoLine:x}=g.useMemo(()=>{if(e.length===0||m<=0)return{xScale:()=>0,yScale:()=>0,xTicks:[],yTicks:[],paretoLine:[]};const S=e.map(k),N=e.map(P=>P.avg_score),_=Math.min(...S)*.9,z=Math.max(...S)*1.1,L=Math.min(...N,.5),B=Math.min(Math.max(...N)*1.05,1),J=P=>(P-_)/(z-_)*m,se=P=>v-(P-L)/(B-L)*v,ce=Array.from({length:5},(P,A)=>_+A/4*(z-_)),D=Array.from({length:5},(P,A)=>L+A/4*(B-L)),Z=e.filter(P=>P.is_pareto).sort((P,A)=>k(P)-k(A)).map(P=>({x:J(k(P)),y:se(P.avg_score)}));return{xScale:J,yScale:se,xTicks:ce,yTicks:D,paretoLine:Z}},[e,m,v,i]);if(e.length===0)return a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No data to display"});const j=S=>i==="tokens"?S>=1e6?`${(S/1e6).toFixed(1)}M`:S>=1e3?`${(S/1e3).toFixed(0)}K`:S.toFixed(0):`${S.toFixed(1)}s`,C=(S,N)=>{var z;const _=(z=n.current)==null?void 0:z.getBoundingClientRect();_&&d({x:N.clientX-_.left,y:N.clientY-_.top}),c(S)};return a.jsxs("div",{ref:n,className:"w-full relative",children:[a.jsx("div",{className:"flex justify-end mb-2",children:a.jsxs("div",{className:"inline-flex rounded border border-[var(--border)] text-xs",children:[a.jsx("button",{className:`px-3 py-1 ${i==="tokens"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("tokens"),children:"Tokens"}),a.jsx("button",{className:`px-3 py-1 ${i==="duration"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("duration"),children:"Latency"})]})}),a.jsx("svg",{width:r,height:t,className:"font-mono text-xs",children:a.jsxs("g",{transform:`translate(${f.left}, ${f.top})`,children:[p.map((S,N)=>a.jsx("line",{x1:w(S),y1:0,x2:w(S),y2:v,stroke:"var(--border)",strokeDasharray:"2,2"},`x-grid-${N}`)),h.map((S,N)=>a.jsx("line",{x1:0,y1:b(S),x2:m,y2:b(S),stroke:"var(--border)",strokeDasharray:"2,2"},`y-grid-${N}`)),x.length>1&&a.jsx("polyline",{points:x.map(S=>`${S.x},${S.y}`).join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.slice().sort((S,N)=>(S.is_pareto?1:0)-(N.is_pareto?1:0)).map(S=>{const N=w(k(S)),_=b(S.avg_score),z=S.is_pareto,L=(o==null?void 0:o.candidate_name)===S.candidate_name;return a.jsxs("g",{onMouseEnter:B=>C(S,B),onMouseLeave:()=>c(null),children:[a.jsx("circle",{cx:N,cy:_,r:L?10:z?8:6,fill:z?"var(--accent)":"transparent",stroke:L?"var(--text-primary)":z?"var(--accent)":"var(--text-secondary)",strokeWidth:L?3:2,className:"cursor-pointer transition-all"}),z&&!L&&a.jsx("text",{x:N,y:_-12,textAnchor:"middle",fill:"var(--text-primary)",fontSize:10,className:"pointer-events-none",children:S.candidate_name.replace(/^baseline_/,"").slice(0,15)})]},S.candidate_name)}),a.jsx("line",{x1:0,y1:v,x2:m,y2:v,stroke:"var(--text-secondary)"}),p.map((S,N)=>a.jsxs("g",{transform:`translate(${w(S)}, ${v})`,children:[a.jsx("line",{y2:5,stroke:"var(--text-secondary)"}),a.jsx("text",{y:20,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:10,children:j(S)})]},`x-tick-${N}`)),a.jsx("text",{x:m/2,y:v+40,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:i==="tokens"?"Tokens (cost)":"Duration (latency)"}),a.jsx("line",{x1:0,y1:0,x2:0,y2:v,stroke:"var(--text-secondary)"}),h.map((S,N)=>a.jsxs("g",{transform:`translate(0, ${b(S)})`,children:[a.jsx("line",{x2:-5,stroke:"var(--text-secondary)"}),a.jsxs("text",{x:-10,textAnchor:"end",dominantBaseline:"middle",fill:"var(--text-secondary)",fontSize:10,children:[(S*100).toFixed(0),"%"]})]},`y-tick-${N}`)),a.jsx("text",{transform:`translate(-45, ${v/2}) rotate(-90)`,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:"Score (quality)"})]})}),o&&a.jsxs("div",{className:"absolute z-10 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg shadow-lg p-3 text-sm pointer-events-none",style:{left:Math.min(u.x+15,r-200),top:u.y-10,maxWidth:220},children:[a.jsx("div",{className:"font-medium text-[var(--text-primary)] truncate mb-2",children:o.candidate_name.replace(/^baseline_/,"")}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Score:"}),a.jsxs("span",{className:"text-right font-medium",children:[(o.avg_score*100).toFixed(1),"%"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tokens:"}),a.jsxs("span",{className:"text-right",children:[(o.avg_tokens/1e3).toFixed(1),"K"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Duration:"}),a.jsxs("span",{className:"text-right",children:[o.avg_duration.toFixed(1),"s"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Pass rate:"}),a.jsxs("span",{className:"text-right",children:[o.passed_runs,"/",o.total_runs]})]}),o.is_pareto&&a.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)] text-xs text-[var(--accent)]",children:"Optimal (best tradeoff)"})]})]})}function g1(e=2e3){const[t,n]=g.useState(!1),[r,s]=g.useState(null),i=g.useCallback(async o=>{try{return await navigator.clipboard.writeText(o),n(!0),s(null),setTimeout(()=>n(!1),e),!0}catch{return s("Failed to copy to clipboard"),n(!1),!1}},[e]),l=g.useCallback(()=>{n(!1),s(null)},[]);return{copy:i,copied:t,error:r,reset:l}}function j1({isOpen:e,onClose:t,title:n,itemId:r,itemType:s,isPublic:i,createdByName:l,onTogglePublic:o}){const[c,u]=g.useState(!1),{copy:d,copied:f}=g1(),m=`${window.location.origin}/${s}s/${r}`,v=async()=>{u(!0);try{await o(!i)}finally{u(!1)}},k=()=>{d(m)};return a.jsx(ls,{isOpen:e,onClose:t,title:n,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between p-3 bg-[var(--bg-tertiary)] rounded",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[i?a.jsx(qc,{className:"w-5 h-5 text-[var(--accent)]"}):a.jsx(Bm,{className:"w-5 h-5 text-[var(--text-secondary)]"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium",children:i?"Public":"Private"}),a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:i?"Anyone with the link can view":"Only you can access"})]})]}),a.jsx("button",{onClick:v,disabled:c,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${i?"bg-[var(--accent)]":"bg-[var(--border)]"} ${c?"opacity-50 cursor-not-allowed":""}`,children:a.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${i?"translate-x-6":"translate-x-1"}`})})]}),i&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Share link"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",readOnly:!0,value:m,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono"}),a.jsx(K,{variant:"secondary",onClick:k,children:f?a.jsxs(a.Fragment,{children:[a.jsx(Lg,{className:"w-4 h-4 mr-1"}),"Copied"]}):a.jsxs(a.Fragment,{children:[a.jsx(Ig,{className:"w-4 h-4 mr-1"}),"Copy"]})})]})]}),l&&a.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",a.jsx("span",{className:"text-[var(--text-primary)]",children:l})]}),a.jsx("div",{className:"text-xs text-[var(--text-secondary)] pt-2 border-t border-[var(--border)]",children:i?a.jsxs(a.Fragment,{children:[a.jsxs("p",{children:["Public ",s,"s can be viewed by anyone with the link."]}),a.jsxs("p",{className:"mt-1",children:["Only you can edit or delete this ",s,"."]})]}):a.jsxs("p",{children:["Make this ",s," public to share it with others."]})})]})})}function w1({job:e,onUpdate:t}){const[n,r]=g.useState(!1),s=async i=>{await Mt.update(e.id,{is_public:i}),t()};return a.jsxs(a.Fragment,{children:[a.jsxs(K,{variant:"secondary",size:"sm",onClick:()=>r(!0),title:e.is_public?"Sharing settings":"Share this job",children:[a.jsx(Wg,{className:"w-4 h-4 mr-1"}),e.is_public?"Shared":"Share"]}),a.jsx(j1,{isOpen:n,onClose:()=>r(!1),title:"Share Job",itemId:e.id,itemType:"job",isPublic:e.is_public,createdByName:e.created_by_name,onTogglePublic:s})]})}function k1(){const{jobId:e}=ha(),t=Dn(),n=Yt(),[r,s]=g.useState(null),[i,l]=g.useState(!1),[o,c]=g.useState(null),[u,d]=g.useState([]),[f,m]=g.useState(null),[v,k]=g.useState(null),[w,b]=g.useState("results"),[p,h]=g.useState("score"),[x,j]=g.useState("desc"),[C,S]=g.useState(!1),{data:N,isLoading:_}=oe({queryKey:["jobs",e],queryFn:()=>Mt.get(e),enabled:!!e,refetchInterval:i?2e3:!1}),{data:z=[]}=oe({queryKey:["runs",e],queryFn:()=>Bo.list({job_id:e}),enabled:!!e,refetchInterval:i?2e3:!1}),{data:L}=oe({queryKey:["job-summary",e],queryFn:()=>Bo.getJobSummary(e),enabled:!!e&&(N==null?void 0:N.status)==="completed"}),B=Ze({mutationFn:async()=>{l(!0),d([]),m(null),k(null);for await(const O of Mt.start(e))s(O),O.current_candidate&&O.current_task&&m(Q=>(Q&&(Q.candidate!==O.current_candidate||Q.task!==O.current_task)&&d(Ce=>[...Ce,{candidate_name:Q.candidate,task_name:Q.task,completed_at:Date.now()}]),{candidate:O.current_candidate,task:O.current_task})),O.event==="error"&&(k(O.message),l(!1),n.invalidateQueries({queryKey:["jobs",e]})),O.event==="complete"&&(m(Q=>(Q&&d(Ce=>[...Ce,{candidate_name:Q.candidate,task_name:Q.task,completed_at:Date.now()}]),null)),l(!1),n.invalidateQueries({queryKey:["jobs",e]}),n.invalidateQueries({queryKey:["runs",e]}),n.invalidateQueries({queryKey:["job-summary",e]}))}}),J=Ze({mutationFn:()=>Mt.cancel(e),onSuccess:()=>{l(!1),n.invalidateQueries({queryKey:["jobs",e]})}});g.useEffect(()=>{(N==null?void 0:N.status)==="running"&&l(!0)},[N==null?void 0:N.status]);const se=g.useMemo(()=>{const O=new Map;for(const Q of z)O.has(Q.task_name)||O.set(Q.task_name,[]),O.get(Q.task_name).push(Q);return O},[z]),ce=g.useMemo(()=>Array.from(se.keys()),[se]);g.useEffect(()=>{!o&&ce.length>0&&c(ce[0])},[ce,o]);const D=g.useMemo(()=>{if(!(L!=null&&L.candidate_summaries))return[];let O=[...L.candidate_summaries];return C&&(O=O.filter(Q=>Q.is_pareto)),O.sort((Q,Ce)=>{let ke,_e;switch(p){case"score":ke=Q.avg_score,_e=Ce.avg_score;break;case"tokens":ke=Q.avg_tokens,_e=Ce.avg_tokens;break;case"duration":ke=Q.avg_duration,_e=Ce.avg_duration;break;case"pass_rate":ke=Q.passed_runs/Q.total_runs,_e=Ce.passed_runs/Ce.total_runs;break}return x==="desc"?_e-ke:ke-_e}),O},[L,p,x,C]),W=O=>{p===O?j(x==="desc"?"asc":"desc"):(h(O),j(O==="tokens"||O==="duration"?"asc":"desc"))},Z=({label:O,sortKeyVal:Q})=>a.jsx("th",{className:"pb-2 cursor-pointer hover:text-[var(--text-primary)] select-none",onClick:()=>W(Q),children:a.jsxs("div",{className:"flex items-center gap-1",children:[O,p===Q&&a.jsx(Tg,{size:12,className:x==="asc"?"rotate-180":""})]})});if(_)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!N)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Job not found"});const P=eu(),A=!N.user_id||N.user_id==="anonymous"||P&&N.created_by_name===P,T=N.is_public&&!A,V=()=>{n.invalidateQueries({queryKey:["jobs",e]})},te=O=>{const Q={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};return a.jsx(q,{variant:Q[O]||"default",children:O})};return a.jsxs("div",{children:[a.jsx(pa,{items:[{label:"Experiments",path:"/jobs"},{label:N.name||`Job ${N.id.slice(0,8)}`}]}),a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:N.name||`Job ${N.id.slice(0,8)}`}),te(N.status),N.is_public&&a.jsxs(q,{variant:"info",children:[a.jsx(qc,{className:"w-3 h-3 mr-1 inline"}),"Public"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[a.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-2 py-0.5 rounded font-mono text-[var(--text-secondary)]",children:[N.id.slice(0,8),"..."]}),a.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[N.candidate_ids.length," candidates × ",N.task_ids.length," tasks = ",N.total_experiments," experiments"]}),N.is_public&&N.created_by_name&&a.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",a.jsx("span",{className:"text-[var(--text-primary)]",children:N.created_by_name})]})]})]}),a.jsxs("div",{className:"flex gap-2",children:[A&&a.jsx(w1,{job:N,onUpdate:V}),T&&a.jsx(q,{variant:"default",children:"View Only"}),A&&N.status==="pending"&&a.jsx(K,{variant:"primary",onClick:()=>B.mutate(),disabled:B.isPending,children:B.isPending?"Starting...":"Start"}),A&&N.status==="running"&&a.jsx(K,{variant:"danger",onClick:()=>J.mutate(),disabled:J.isPending,children:"Cancel"})]})]}),(v||N.error)&&a.jsx(ge,{className:"mb-6 border-red-500/50 bg-red-500/10",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"w-5 h-5 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-0.5",children:"!"}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-red-400",children:"Error"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:v||N.error})]})]})}),(i||r)&&a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"font-medium",children:"Progress"}),a.jsxs("span",{className:"text-[var(--accent)]",children:[(r==null?void 0:r.completed)||N.completed_experiments,"/",(r==null?void 0:r.total)||N.total_experiments]})]}),a.jsx("div",{className:"w-full bg-[var(--bg-primary)] h-2 mb-2",children:a.jsx("div",{className:"h-full bg-[var(--accent)] transition-all",style:{width:`${((r==null?void 0:r.completed)||N.completed_experiments)/((r==null?void 0:r.total)||N.total_experiments)*100}%`}})}),(r==null?void 0:r.message)&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r.message}),i&&a.jsxs("div",{className:"mt-4 border-t border-[var(--border)] pt-4",children:[(r==null?void 0:r.current_candidate)&&(r==null?void 0:r.current_task)&&a.jsxs("div",{className:"mb-3",children:[a.jsx("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:"Currently Running"}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 px-3 py-2 bg-blue-500/10 border border-blue-500/30 rounded",children:[a.jsx("div",{className:"w-2 h-2 bg-blue-400 rounded-full animate-pulse"}),a.jsx("span",{className:"font-medium",children:r.current_candidate}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{children:r.current_task})]})]}),u.length>0&&a.jsxs("div",{children:[a.jsxs("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:["Completed (",u.length,")"]}),a.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto space-y-1",children:u.map((O,Q)=>a.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-500/10 border border-green-500/30 rounded text-sm",children:[a.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}),a.jsx("span",{className:"font-medium",children:O.candidate_name}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{children:O.task_name})]},`${O.candidate_name}-${O.task_name}-${Q}`))})]})]})]}),(N.status==="completed"||z.length>0)&&a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-[var(--border)]",children:[a.jsxs("button",{onClick:()=>b("results"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${w==="results"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Og,{size:16}),"Results"]}),a.jsxs("button",{onClick:()=>b("compare"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${w==="compare"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Ag,{size:16}),"Compare"]}),a.jsxs("button",{onClick:()=>b("runs"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${w==="runs"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Qg,{size:16}),"Runs (",z.length,")"]})]}),w==="results"&&a.jsxs(a.Fragment,{children:[L&&L.candidate_summaries.length>1&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("div",{className:"flex items-start justify-between mb-4",children:a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium",children:"Quality vs. Cost Tradeoff"}),a.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:["Candidates on the frontier (connected line) are ",a.jsx("strong",{children:"optimal"})," - no other candidate beats them on both score AND cost."]})]})}),a.jsxs("div",{className:"mb-4 p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs text-[var(--text-secondary)]",children:[a.jsx("strong",{className:"text-[var(--text-primary)]",children:"How optimal tradeoffs are calculated:"})," A candidate is optimal if there's no other candidate that has both a higher score AND lower cost. For example, if Candidate A has 95% score at 50K tokens and Candidate B has 90% score at 40K tokens, both are optimal - A is better on score, B is better on cost. But if Candidate C has 85% score at 60K tokens, it's ",a.jsx("em",{children:"not"})," optimal because B beats it on both metrics."]}),a.jsx(y1,{summaries:L.candidate_summaries,height:350})]}),L&&a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h3",{className:"font-medium",children:"Results Summary"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C,onChange:O=>S(O.target.checked),className:"rounded border-[var(--border)]"}),"Optimal only"]})]}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-left text-[var(--text-secondary)] border-b border-[var(--border)]",children:[a.jsx("th",{className:"pb-2",children:"Candidate"}),a.jsx(Z,{label:"Score",sortKeyVal:"score"}),a.jsx(Z,{label:"Tokens",sortKeyVal:"tokens"}),a.jsx(Z,{label:"Duration",sortKeyVal:"duration"}),a.jsx(Z,{label:"Pass Rate",sortKeyVal:"pass_rate"}),a.jsx("th",{className:"pb-2",children:"Optimal"})]})}),a.jsx("tbody",{children:D.map((O,Q)=>a.jsxs("tr",{className:`border-b border-[var(--border)] ${Q===0?"bg-[var(--accent)]/10":""}`,children:[a.jsxs("td",{className:"py-2 font-medium",children:[Q===0&&a.jsx("span",{className:"text-[var(--accent)] mr-1",children:"#1"}),O.candidate_name.replace(/^baseline_/,"")]}),a.jsxs("td",{className:"py-2",children:[(O.avg_score*100).toFixed(1),"%"]}),a.jsxs("td",{className:"py-2",children:[(O.avg_tokens/1e3).toFixed(1),"K"]}),a.jsxs("td",{className:"py-2",children:[O.avg_duration.toFixed(1),"s"]}),a.jsxs("td",{className:"py-2",children:[O.passed_runs,"/",O.total_runs]}),a.jsx("td",{className:"py-2",children:O.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})})]},O.candidate_name))})]})}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-3",children:"Click column headers to sort. The #1 ranked candidate is highlighted based on your sort criteria."})]}),!L&&a.jsx(ge,{children:a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Results will appear here after the job completes.":"No results yet. Start the job to see results."})})]}),w==="compare"&&a.jsxs(ge,{children:[a.jsx("h3",{className:"font-medium mb-4",children:"Compare Candidates by Task"}),ce.length>0?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:ce.map(O=>a.jsx("button",{onClick:()=>c(o===O?null:O),className:`px-3 py-1 text-sm rounded border transition-colors ${o===O?"bg-[var(--accent)] text-white border-[var(--accent)]":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:O},O))}),o&&se.get(o)?a.jsx(v1,{runs:se.get(o).map(O=>({id:O.id,candidate_name:O.candidate_name,tokens_input:0,tokens_output:0,tokens_total:O.tokens_total,duration_seconds:O.duration_seconds,score:O.score,passed:O.passed,is_pareto:O.is_pareto}))}):a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"Select a task above to compare how different candidates performed on it."})]}):a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Comparison data will appear here after runs complete.":"No runs yet. Start the job to compare candidates."})]}),w==="runs"&&a.jsxs(ge,{children:[a.jsx("h3",{className:"font-medium mb-4",children:"All Experiment Runs"}),z.length===0?a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Runs will appear here as they complete. See progress above for live status.":"No runs yet. Start the job to see results."}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:z.map(O=>a.jsxs("div",{className:"p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] cursor-pointer hover:border-[var(--accent-dim)] transition-colors",onClick:()=>t(`/runs/${O.id}`),children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:`text-lg font-bold ${O.passed?"text-green-400":"text-red-400"}`,children:[(O.score*100).toFixed(0),"%"]}),O.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})]}),a.jsx("div",{className:"text-sm font-medium truncate",title:O.candidate_name,children:O.candidate_name.replace(/^baseline_/,"")}),a.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:O.task_name}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:[(O.tokens_total/1e3).toFixed(1),"K tokens"]}),a.jsxs("span",{children:[O.duration_seconds.toFixed(1),"s"]})]})]},O.id))})]})]})}const gn={input:"bg-blue-500",output:"bg-emerald-500",inputText:"text-blue-400",outputText:"text-emerald-400"};function Dd(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ad({input:e,output:t,maxValue:n,height:r=24,showLabels:s=!0}){const i=e+t;if(i===0)return a.jsx("div",{className:"flex items-center gap-2 w-full",children:a.jsx("div",{className:"rounded bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`}})});const l=n>0?i/n*100:100;return a.jsxs("div",{className:"flex items-center gap-3 w-full",children:[a.jsx("div",{className:"relative rounded overflow-hidden bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`},children:a.jsxs("div",{className:"h-full flex transition-all duration-300",style:{width:`${l}%`},children:[a.jsx("div",{className:`h-full ${gn.input} transition-all`,style:{width:`${e/i*100}%`},title:`Input: ${e.toLocaleString()} tokens`}),a.jsx("div",{className:`h-full ${gn.output} transition-all`,style:{width:`${t/i*100}%`},title:`Output: ${t.toLocaleString()} tokens`})]})}),s&&a.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono text-[var(--text-secondary)] min-w-[90px] justify-end",children:[a.jsxs("span",{className:gn.inputText,children:["↑",Dd(e)]}),a.jsx("span",{children:"/"}),a.jsxs("span",{className:gn.outputText,children:["↓",Dd(t)]})]})]})}function _l({label:e,value:t,color:n="default"}){const r={default:"text-[var(--text-primary)]",input:gn.inputText,output:gn.outputText}[n];return a.jsxs("div",{className:"flex-1 p-3 bg-[var(--bg-primary)] border border-[var(--border)] rounded",children:[a.jsx("div",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e}),a.jsx("div",{className:`font-mono text-lg font-bold ${r}`,children:t})]})}function cp({tokensInput:e,tokensOutput:t,tokensTotal:n,turns:r}){const s=n>0?Math.round(e/n*100):0,i=n>0?Math.round(t/n*100):0,l=g.useMemo(()=>{if(!r||r.length===0)return null;let c=0,u=0;return r.map(d=>(c+=d.input,u+=d.output,{input:c,output:u,total:c+u}))},[r]),o=l?Math.max(...l.map(c=>c.total)):n;return a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-4",children:"Token Usage"}),a.jsx("div",{className:"mb-4",children:a.jsx(Ad,{input:e,output:t,maxValue:n,height:32})}),a.jsxs("div",{className:"flex items-center gap-6 text-xs mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-3 h-3 rounded ${gn.input}`}),a.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Input (",s,"%)"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-3 h-3 rounded ${gn.output}`}),a.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Output (",i,"%)"]})]})]}),a.jsxs("div",{className:"flex gap-3 mb-4",children:[a.jsx(_l,{label:"Input Tokens",value:e.toLocaleString(),color:"input"}),a.jsx(_l,{label:"Output Tokens",value:t.toLocaleString(),color:"output"}),a.jsx(_l,{label:"Total Tokens",value:n.toLocaleString()})]}),l&&l.length>1&&a.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[a.jsxs("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:["Token Accumulation (",r.length," turns)"]}),a.jsx("div",{className:"space-y-2",children:r.map((c,u)=>a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--bg-primary)] border border-[var(--border)] flex items-center justify-center text-xs font-medium",children:u+1}),a.jsx("div",{className:"flex-1",children:a.jsx(Ad,{input:l[u].input,output:l[u].output,maxValue:o,height:16})})]},u))})]}),a.jsx("div",{className:"mt-4 text-xs text-[var(--text-secondary)] border-t border-[var(--border)] pt-3",children:"Token usage affects API cost. Input tokens are typically cheaper than output tokens."})]})}function b1(){const{runId:e}=ha(),{data:t,isLoading:n}=oe({queryKey:["runs",e],queryFn:()=>Bo.get(e),enabled:!!e});return n?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsx(pa,{items:[{label:"Experiments",path:"/jobs"},{label:"Job",path:`/jobs/${t.job_id}`},{label:t.candidate_name}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:t.candidate_name}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{className:"text-lg",children:t.task_name}),t.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})]})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[a.jsx(Fa,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),a.jsx(Fa,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),a.jsx(Fa,{label:"Duration",value:`${t.duration_seconds.toFixed(1)}s`}),a.jsx(Fa,{label:"Status",value:t.passed?"Passed":"Failed",status:t.passed?"success":"error"})]}),a.jsx(cp,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),t.reasoning&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:t.reasoning}),t.criteria_results.length>0&&a.jsx("div",{className:"space-y-2",children:t.criteria_results.map(r=>a.jsx("div",{className:"flex items-start justify-between p-3 bg-[var(--bg-primary)] border border-[var(--border)]",children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-medium",children:r.name}),a.jsxs(q,{variant:r.passed?"success":"error",children:[(r.score*100).toFixed(0),"%"]})]}),r.reasoning&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r.reasoning})]})},r.name))})]}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created.length>0&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),a.jsx("div",{className:"space-y-1",children:t.files_created.map(r=>a.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:r},r))})]}),Object.keys(t.trace).length>0&&a.jsx(ap,{trace:t.trace})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Run not found"})}function Fa({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return a.jsxs(ge,{children:[a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),a.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function N1(){const{testId:e}=ha(),{data:t,isLoading:n}=oe({queryKey:["tests",e],queryFn:()=>Ls.get(e),enabled:!!e}),{data:r}=oe({queryKey:["configs",t==null?void 0:t.agent_id],queryFn:()=>Tn.get(t.agent_id),enabled:!!(t!=null&&t.agent_id)});if(n)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!t)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Test not found"});const s={completed:"success",failed:"error",running:"info",pending:"default",cancelled:"warning"};return a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsx(pa,{items:[{label:"Agents",path:"/agents"},...r?[{label:r.name,path:`/agents/${r.id}`}]:[],{label:`Test ${t.id.slice(0,8)}`}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:"Test Run"}),r&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"•"}),a.jsx("span",{className:"text-lg",children:r.name})]}),a.jsx(q,{variant:s[t.status]||"default",children:t.status})]}),a.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:["ID: ",t.id.slice(0,8),"..."]})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[a.jsx(Ia,{label:"Duration",value:`${t.duration_seconds.toFixed(2)}s`}),a.jsx(Ia,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),t.score!==null&&a.jsx(Ia,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),a.jsx(Ia,{label:"Status",value:t.status.charAt(0).toUpperCase()+t.status.slice(1),status:t.status==="completed"?"success":t.status==="failed"?"error":void 0})]}),a.jsx(cp,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Prompt"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)] font-mono",children:t.prompt})]}),t.error&&a.jsxs(ge,{className:"mb-6 border-red-500/30 bg-red-500/5",children:[a.jsx("h3",{className:"font-medium mb-3 text-red-400",children:"Error"}),a.jsx("pre",{className:"text-sm text-red-300 overflow-x-auto whitespace-pre-wrap",children:t.error})]}),t.reasoning&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.reasoning})]}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created&&t.files_created.length>0&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),a.jsx("div",{className:"space-y-1",children:t.files_created.map(i=>a.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:i},i))})]}),t.trace&&Object.keys(t.trace).length>0&&a.jsx(ap,{trace:t.trace}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Timestamps"}),a.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Created:"}),a.jsx("div",{className:"font-mono",children:new Date(t.created_at).toLocaleString()})]}),t.started_at&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Started:"}),a.jsx("div",{className:"font-mono",children:new Date(t.started_at).toLocaleString()})]}),t.completed_at&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Completed:"}),a.jsx("div",{className:"font-mono",children:new Date(t.completed_at).toLocaleString()})]})]})]})]})}function Ia({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return a.jsxs(ge,{children:[a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),a.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function S1(){const{deploymentId:e}=ha(),{data:t,isLoading:n}=oe({queryKey:["deployments",e],queryFn:()=>E0.get(e),enabled:!!e}),r=t==null?void 0:t.versions.find(i=>i.id===t.current_version_id),{data:s}=oe({queryKey:["configs",r==null?void 0:r.config_id],queryFn:()=>Tn.get(r.config_id),enabled:!!(r!=null&&r.config_id)});return n?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsxs("div",{className:"mb-4 flex-shrink-0",children:[a.jsx(pa,{items:[{label:"Agents",path:"/agents"},{label:t.name}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Hg,{size:20,className:"text-[var(--accent)]"}),a.jsx("h2",{className:"text-xl font-bold",children:t.name}),r&&a.jsxs(q,{variant:"info",children:["v",r.version]})]}),t.description&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:t.description})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsx("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-5",children:[a.jsxs("div",{className:"flex items-center gap-4 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:["Created ",new Date(t.created_at).toLocaleDateString()]}),a.jsxs("span",{children:["Updated ",new Date(t.updated_at).toLocaleDateString()]}),a.jsxs("span",{children:[t.versions.length," version",t.versions.length!==1?"s":""]})]}),s&&a.jsxs(Rn,{to:`/agents/${s.id}`,className:"flex items-center gap-2 p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-sm",children:[a.jsx(Um,{size:14,className:"text-[var(--accent)]"}),a.jsxs("span",{children:["Agent: ",a.jsx("span",{className:"font-medium",children:s.name})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider mb-3",children:"Version History"}),t.versions.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"No versions yet."}):a.jsx("div",{className:"space-y-2",children:t.versions.map(i=>a.jsx(C1,{version:i,isActive:i.id===t.current_version_id},i.id))})]})]})}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[a.jsx(Vm,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),a.jsx("div",{className:"flex-1 min-h-0",children:s?a.jsx(ip,{agent:s}):a.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-secondary)] text-sm",children:r?"Loading agent configuration...":"No active version to test."})})]})]})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Deployment not found"})}function C1({version:e,isActive:t}){const n=e.config_snapshot;return a.jsxs("div",{className:`p-3 rounded-md border transition-colors ${t?"border-[var(--accent)] bg-[var(--accent-dim)]":"border-[var(--border)] bg-[var(--bg-secondary)]"}`,children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Yg,{size:12,className:"text-[var(--text-secondary)]"}),a.jsxs("span",{className:"text-sm font-medium",children:["v",e.version]}),t&&a.jsx(q,{variant:"success",children:"Active"}),a.jsx(q,{variant:e.source==="optimize"?"info":"default",children:e.source})]}),a.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)]",children:[a.jsx(Am,{size:11}),a.jsx("span",{children:new Date(e.created_at).toLocaleString()})]})]}),e.description&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e.description}),Object.keys(n).length>0&&a.jsxs("div",{className:"mt-1",children:[a.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)] mb-1",children:[a.jsx(Dg,{size:11}),a.jsx("span",{children:"Config"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-xs",children:["framework"in n&&n.framework?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Framework"}),a.jsx("span",{className:"font-mono",children:String(n.framework)})]}):null,"model"in n&&n.model?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Model"}),a.jsx("span",{className:"font-mono",children:String(n.model)})]}):null,"tools"in n&&n.tools?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tools"}),a.jsx("span",{className:"font-mono truncate",children:Array.isArray(n.tools)?n.tools.join(", "):String(n.tools)})]}):null]})]})]})}function _1(){const{authConfig:e,isLoading:t,error:n,login:r,loginWithGitHub:s,clearError:i}=tu(),[l,o]=g.useState(""),[c,u]=g.useState("");g.useEffect(()=>{n&&i()},[l,c]);const d=async m=>{m.preventDefault(),!(!l||!c)&&await r(l,c)},f=()=>{s()};return a.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:a.jsxs("div",{className:"w-full max-w-md",children:[a.jsxs("div",{className:"text-center mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:"Flow"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:"Sign in to access the optimization dashboard"})]}),a.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] p-6 space-y-6",children:[n&&a.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[var(--error)]/10 border border-[var(--error)]/20 text-[var(--error)]",children:[a.jsx(Fm,{size:18,className:"mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-sm",children:n})]}),(e==null?void 0:e.mode)==="basic"&&a.jsxs("form",{onSubmit:d,className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Username"}),a.jsxs("div",{className:"relative",children:[a.jsx(Hm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),a.jsx("input",{type:"text",value:l,onChange:m=>o(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter username",autoComplete:"username",autoFocus:!0})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Password"}),a.jsxs("div",{className:"relative",children:[a.jsx(Bm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),a.jsx("input",{type:"password",value:c,onChange:m=>u(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter password",autoComplete:"current-password"})]})]}),a.jsx(K,{type:"submit",variant:"primary",className:"w-full justify-center",loading:t,disabled:!l||!c,children:"Sign In"})]}),(e==null?void 0:e.mode)==="github"&&a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center",children:"Sign in with your GitHub account to continue"}),a.jsx(K,{onClick:f,variant:"secondary",className:"w-full justify-center",icon:$g,children:"Continue with GitHub"})]})]})]})})}function E1({children:e}){const{authConfig:t,isLoadingConfig:n,isAuthenticated:r,loadAuthConfig:s,handleOAuthCallback:i}=tu();return g.useEffect(()=>{s()},[s]),g.useEffect(()=>{n||i()},[n,i]),n?a.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center",children:a.jsxs("div",{className:"text-center",children:[a.jsx(ma,{className:"w-8 h-8 animate-spin text-[var(--accent)] mx-auto mb-4"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:"Loading..."})]})}):t!=null&&t.enabled&&!r?a.jsx(_1,{}):a.jsx(a.Fragment,{children:e})}function P1(){return a.jsx(jg,{children:a.jsx(E1,{children:a.jsx(fg,{children:a.jsxs(xt,{path:"/",element:a.jsx($0,{}),children:[a.jsx(xt,{index:!0,element:a.jsx(B0,{})}),a.jsx(xt,{path:"agents",element:a.jsx(Z0,{})}),a.jsx(xt,{path:"agents/:agentId",element:a.jsx(i1,{})}),a.jsx(xt,{path:"tasks",element:a.jsx(u1,{})}),a.jsx(xt,{path:"jobs",element:a.jsx(m1,{})}),a.jsx(xt,{path:"jobs/:jobId",element:a.jsx(k1,{})}),a.jsx(xt,{path:"runs/:runId",element:a.jsx(b1,{})}),a.jsx(xt,{path:"tests/:testId",element:a.jsx(N1,{})}),a.jsx(xt,{path:"deployments/:deploymentId",element:a.jsx(S1,{})})]})})})})}const $d=localStorage.getItem("flow-theme");if($d)try{const{state:e}=JSON.parse($d);e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}catch{}const T1=new ly({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}});El.createRoot(document.getElementById("root")).render(a.jsx(Jo.StrictMode,{children:a.jsx(oy,{client:T1,children:a.jsx(P1,{})})})); diff --git a/src/flow/ui/ui/assets/index-CdtxeOkT.js b/src/flow/ui/ui/assets/index-CdtxeOkT.js new file mode 100644 index 0000000000000000000000000000000000000000..db8b149947fff78115b27f1734fa51f13aec6304 --- /dev/null +++ b/src/flow/ui/ui/assets/index-CdtxeOkT.js @@ -0,0 +1,317 @@ +var Yc=e=>{throw TypeError(e)};var Wi=(e,t,n)=>t.has(e)||Yc("Cannot "+n);var y=(e,t,n)=>(Wi(e,t,"read from private field"),n?n.call(e):t.get(e)),$=(e,t,n)=>t.has(e)?Yc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),z=(e,t,n,r)=>(Wi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),W=(e,t,n)=>(Wi(e,t,"access private method"),n);var pa=(e,t,n,r)=>({set _(s){z(e,t,s,n)},get _(){return y(e,t,r)}});function tp(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();function Wd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var qd={exports:{}},Ni={},Gd={exports:{}},Y={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var ia=Symbol.for("react.element"),np=Symbol.for("react.portal"),rp=Symbol.for("react.fragment"),sp=Symbol.for("react.strict_mode"),ap=Symbol.for("react.profiler"),ip=Symbol.for("react.provider"),lp=Symbol.for("react.context"),op=Symbol.for("react.forward_ref"),cp=Symbol.for("react.suspense"),up=Symbol.for("react.memo"),dp=Symbol.for("react.lazy"),Xc=Symbol.iterator;function fp(e){return e===null||typeof e!="object"?null:(e=Xc&&e[Xc]||e["@@iterator"],typeof e=="function"?e:null)}var Jd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Yd=Object.assign,Xd={};function Xr(e,t,n){this.props=e,this.context=t,this.refs=Xd,this.updater=n||Jd}Xr.prototype.isReactComponent={};Xr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Xr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Zd(){}Zd.prototype=Xr.prototype;function $o(e,t,n){this.props=e,this.context=t,this.refs=Xd,this.updater=n||Jd}var Uo=$o.prototype=new Zd;Uo.constructor=$o;Yd(Uo,Xr.prototype);Uo.isPureReactComponent=!0;var Zc=Array.isArray,ef=Object.prototype.hasOwnProperty,Bo={current:null},tf={key:!0,ref:!0,__self:!0,__source:!0};function nf(e,t,n){var r,s={},a=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(a=""+t.key),t)ef.call(t,r)&&!tf.hasOwnProperty(r)&&(s[r]=t[r]);var o=arguments.length-2;if(o===1)s.children=n;else if(1>>1,ee=P[V];if(0>>1;Vs(te,L))pes(be,te)?(P[V]=be,P[pe]=L,V=pe):(P[V]=te,P[T]=L,V=T);else if(pes(be,L))P[V]=be,P[pe]=L,V=pe;else break e}}return A}function s(P,A){var L=P.sortIndex-A.sortIndex;return L!==0?L:P.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var c=[],d=[],h=1,u=null,p=3,x=!1,k=!1,g=!1,S=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(P){for(var A=n(d);A!==null;){if(A.callback===null)r(d);else if(A.startTime<=P)r(d),A.sortIndex=A.expirationTime,t(c,A);else break;A=n(d)}}function w(P){if(g=!1,v(P),!k)if(n(c)!==null)k=!0,q(C);else{var A=n(d);A!==null&&X(w,A.startTime-P)}}function C(P,A){k=!1,g&&(g=!1,m(_),_=-1),x=!0;var L=p;try{for(v(A),u=n(c);u!==null&&(!(u.expirationTime>A)||P&&!B());){var V=u.callback;if(typeof V=="function"){u.callback=null,p=u.priorityLevel;var ee=V(u.expirationTime<=A);A=e.unstable_now(),typeof ee=="function"?u.callback=ee:u===n(c)&&r(c),v(A)}else r(c);u=n(c)}if(u!==null)var R=!0;else{var T=n(d);T!==null&&X(w,T.startTime-A),R=!1}return R}finally{u=null,p=L,x=!1}}var b=!1,N=null,_=-1,F=5,O=-1;function B(){return!(e.unstable_now()-OP||125V?(P.sortIndex=L,t(d,P),n(c)===null&&P===n(d)&&(g?(m(_),_=-1):g=!0,X(w,L-V))):(P.sortIndex=ee,t(c,P),k||x||(k=!0,q(C))),P},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(P){var A=p;return function(){var L=p;p=A;try{return P.apply(this,arguments)}finally{p=L}}}})(of);lf.exports=of;var Np=lf.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var bp=j,et=Np;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),bl=Object.prototype.hasOwnProperty,Cp=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,tu={},nu={};function _p(e){return bl.call(nu,e)?!0:bl.call(tu,e)?!1:Cp.test(e)?nu[e]=!0:(tu[e]=!0,!1)}function Ep(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Pp(e,t,n,r){if(t===null||typeof t>"u"||Ep(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Be(e,t,n,r,s,a,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=l}var Oe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Oe[e]=new Be(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Oe[t]=new Be(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Oe[e]=new Be(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Oe[e]=new Be(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Oe[e]=new Be(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Oe[e]=new Be(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Oe[e]=new Be(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Oe[e]=new Be(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Oe[e]=new Be(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ko=/[\-:]([a-z])/g;function Ho(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Ko,Ho);Oe[t]=new Be(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Ko,Ho);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Ko,Ho);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!1,!1)});Oe.xlinkHref=new Be("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!0,!0)});function Wo(e,t,n,r){var s=Oe.hasOwnProperty(t)?Oe[t]:null;(s!==null?s.type!==0:r||!(2o||s[l]!==a[o]){var c=` +`+s[l].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{Ji=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?vs(e):""}function Tp(e){switch(e.tag){case 5:return vs(e.type);case 16:return vs("Lazy");case 13:return vs("Suspense");case 19:return vs("SuspenseList");case 0:case 2:case 15:return e=Yi(e.type,!1),e;case 11:return e=Yi(e.type.render,!1),e;case 1:return e=Yi(e.type,!0),e;default:return""}}function Pl(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case mr:return"Fragment";case hr:return"Portal";case Cl:return"Profiler";case qo:return"StrictMode";case _l:return"Suspense";case El:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case df:return(e.displayName||"Context")+".Consumer";case uf:return(e._context.displayName||"Context")+".Provider";case Go:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Jo:return t=e.displayName||null,t!==null?t:Pl(e.type)||"Memo";case Xt:t=e._payload,e=e._init;try{return Pl(e(t))}catch{}}return null}function Op(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Pl(t);case 8:return t===qo?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function _n(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function hf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Lp(e){var t=hf(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(l){r=""+l,a.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ya(e){e._valueTracker||(e._valueTracker=Lp(e))}function mf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=hf(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ga(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Tl(e,t){var n=t.checked;return me({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function su(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=_n(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function pf(e,t){t=t.checked,t!=null&&Wo(e,"checked",t,!1)}function Ol(e,t){pf(e,t);var n=_n(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ll(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ll(e,t.type,_n(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function au(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ll(e,t,n){(t!=="number"||Ga(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var xs=Array.isArray;function br(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=ga.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ls(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ws={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Rp=["Webkit","ms","Moz","O"];Object.keys(ws).forEach(function(e){Rp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ws[t]=ws[e]})});function gf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||ws.hasOwnProperty(e)&&ws[e]?(""+t).trim():t+"px"}function jf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=gf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var Mp=me({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function zl(e,t){if(t){if(Mp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function Fl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Il=null;function Yo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Dl=null,Cr=null,_r=null;function ou(e){if(e=ca(e)){if(typeof Dl!="function")throw Error(E(280));var t=e.stateNode;t&&(t=Pi(t),Dl(e.stateNode,e.type,t))}}function wf(e){Cr?_r?_r.push(e):_r=[e]:Cr=e}function kf(){if(Cr){var e=Cr,t=_r;if(_r=Cr=null,ou(e),t)for(e=0;e>>=0,e===0?32:31-(Kp(e)/Hp|0)|0}var ja=64,wa=4194304;function ys(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Za(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,a=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~s;o!==0?r=ys(o):(a&=l,a!==0&&(r=ys(a)))}else l=n&~s,l!==0?r=ys(l):a!==0&&(r=ys(a));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,a=t&-t,s>=a||s===16&&(a&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function la(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-gt(t),e[t]=n}function Jp(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Ss),xu=" ",yu=!1;function Bf(e,t){switch(e){case"keyup":return Nv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Qf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var pr=!1;function Cv(e,t){switch(e){case"compositionend":return Qf(t);case"keypress":return t.which!==32?null:(yu=!0,xu);case"textInput":return e=t.data,e===xu&&yu?null:e;default:return null}}function _v(e,t){if(pr)return e==="compositionend"||!ac&&Bf(e,t)?(e=$f(),Aa=nc=fn=null,pr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ku(n)}}function Wf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Wf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function qf(){for(var e=window,t=Ga();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ga(e.document)}return t}function ic(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Fv(e){var t=qf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Wf(n.ownerDocument.documentElement,n)){if(r!==null&&ic(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,a=Math.min(r.start,s);r=r.end===void 0?a:Math.min(r.end,s),!e.extend&&a>r&&(s=r,r=a,a=s),s=Su(n,a);var l=Su(n,r);s&&l&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,vr=null,Vl=null,bs=null,Kl=!1;function Nu(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Kl||vr==null||vr!==Ga(r)||(r=vr,"selectionStart"in r&&ic(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),bs&&Ds(bs,r)||(bs=r,r=ni(Vl,"onSelect"),0gr||(e.current=Yl[gr],Yl[gr]=null,gr--)}function ie(e,t){gr++,Yl[gr]=e.current,e.current=t}var En={},Fe=On(En),We=On(!1),Zn=En;function Vr(e,t){var n=e.type.contextTypes;if(!n)return En;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},a;for(a in n)s[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function qe(e){return e=e.childContextTypes,e!=null}function si(){ce(We),ce(Fe)}function Ou(e,t,n){if(Fe.current!==En)throw Error(E(168));ie(Fe,t),ie(We,n)}function rh(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(E(108,Op(e)||"Unknown",s));return me({},n,r)}function ai(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||En,Zn=Fe.current,ie(Fe,e),ie(We,We.current),!0}function Lu(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=rh(e,t,Zn),r.__reactInternalMemoizedMergedChildContext=e,ce(We),ce(Fe),ie(Fe,e)):ce(We),ie(We,n)}var Rt=null,Ti=!1,dl=!1;function sh(e){Rt===null?Rt=[e]:Rt.push(e)}function qv(e){Ti=!0,sh(e)}function Ln(){if(!dl&&Rt!==null){dl=!0;var e=0,t=ae;try{var n=Rt;for(ae=1;e>=l,s-=l,Dt=1<<32-gt(t)+s|n<_?(F=N,N=null):F=N.sibling;var O=p(m,N,v[_],w);if(O===null){N===null&&(N=F);break}e&&N&&O.alternate===null&&t(m,N),f=a(O,f,_),b===null?C=O:b.sibling=O,b=O,N=F}if(_===v.length)return n(m,N),ue&&Mn(m,_),C;if(N===null){for(;__?(F=N,N=null):F=N.sibling;var B=p(m,N,O.value,w);if(B===null){N===null&&(N=F);break}e&&N&&B.alternate===null&&t(m,N),f=a(B,f,_),b===null?C=B:b.sibling=B,b=B,N=F}if(O.done)return n(m,N),ue&&Mn(m,_),C;if(N===null){for(;!O.done;_++,O=v.next())O=u(m,O.value,w),O!==null&&(f=a(O,f,_),b===null?C=O:b.sibling=O,b=O);return ue&&Mn(m,_),C}for(N=r(m,N);!O.done;_++,O=v.next())O=x(N,m,_,O.value,w),O!==null&&(e&&O.alternate!==null&&N.delete(O.key===null?_:O.key),f=a(O,f,_),b===null?C=O:b.sibling=O,b=O);return e&&N.forEach(function(G){return t(m,G)}),ue&&Mn(m,_),C}function S(m,f,v,w){if(typeof v=="object"&&v!==null&&v.type===mr&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case xa:e:{for(var C=v.key,b=f;b!==null;){if(b.key===C){if(C=v.type,C===mr){if(b.tag===7){n(m,b.sibling),f=s(b,v.props.children),f.return=m,m=f;break e}}else if(b.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Xt&&zu(C)===b.type){n(m,b.sibling),f=s(b,v.props),f.ref=fs(m,b,v),f.return=m,m=f;break e}n(m,b);break}else t(m,b);b=b.sibling}v.type===mr?(f=Jn(v.props.children,m.mode,w,v.key),f.return=m,m=f):(w=Wa(v.type,v.key,v.props,null,m.mode,w),w.ref=fs(m,f,v),w.return=m,m=w)}return l(m);case hr:e:{for(b=v.key;f!==null;){if(f.key===b)if(f.tag===4&&f.stateNode.containerInfo===v.containerInfo&&f.stateNode.implementation===v.implementation){n(m,f.sibling),f=s(f,v.children||[]),f.return=m,m=f;break e}else{n(m,f);break}else t(m,f);f=f.sibling}f=gl(v,m.mode,w),f.return=m,m=f}return l(m);case Xt:return b=v._init,S(m,f,b(v._payload),w)}if(xs(v))return k(m,f,v,w);if(ls(v))return g(m,f,v,w);Ea(m,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,f!==null&&f.tag===6?(n(m,f.sibling),f=s(f,v),f.return=m,m=f):(n(m,f),f=yl(v,m.mode,w),f.return=m,m=f),l(m)):n(m,f)}return S}var Hr=oh(!0),ch=oh(!1),oi=On(null),ci=null,kr=null,uc=null;function dc(){uc=kr=ci=null}function fc(e){var t=oi.current;ce(oi),e._currentValue=t}function eo(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Pr(e,t){ci=e,uc=kr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(He=!0),e.firstContext=null)}function ct(e){var t=e._currentValue;if(uc!==e)if(e={context:e,memoizedValue:t,next:null},kr===null){if(ci===null)throw Error(E(308));kr=e,ci.dependencies={lanes:0,firstContext:e}}else kr=kr.next=e;return t}var In=null;function hc(e){In===null?In=[e]:In.push(e)}function uh(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,hc(t)):(n.next=s.next,s.next=n),t.interleaved=n,Kt(e,r)}function Kt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Zt=!1;function mc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function dh(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function $t(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function wn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ne&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Kt(e,n)}return s=r.interleaved,s===null?(t.next=t,hc(r)):(t.next=s.next,s.next=t),r.interleaved=t,Kt(e,n)}function Ua(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Zo(e,n)}}function Fu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?s=a=l:a=a.next=l,n=n.next}while(n!==null);a===null?s=a=t:a=a.next=t}else s=a=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ui(e,t,n,r){var s=e.updateQueue;Zt=!1;var a=s.firstBaseUpdate,l=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var c=o,d=c.next;c.next=null,l===null?a=d:l.next=d,l=c;var h=e.alternate;h!==null&&(h=h.updateQueue,o=h.lastBaseUpdate,o!==l&&(o===null?h.firstBaseUpdate=d:o.next=d,h.lastBaseUpdate=c))}if(a!==null){var u=s.baseState;l=0,h=d=c=null,o=a;do{var p=o.lane,x=o.eventTime;if((r&p)===p){h!==null&&(h=h.next={eventTime:x,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var k=e,g=o;switch(p=t,x=n,g.tag){case 1:if(k=g.payload,typeof k=="function"){u=k.call(x,u,p);break e}u=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=g.payload,p=typeof k=="function"?k.call(x,u,p):k,p==null)break e;u=me({},u,p);break e;case 2:Zt=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[o]:p.push(o))}else x={eventTime:x,lane:p,tag:o.tag,payload:o.payload,callback:o.callback,next:null},h===null?(d=h=x,c=u):h=h.next=x,l|=p;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;p=o,o=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(h===null&&(c=u),s.baseState=c,s.firstBaseUpdate=d,s.lastBaseUpdate=h,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else a===null&&(s.shared.lanes=0);nr|=l,e.lanes=l,e.memoizedState=u}}function Iu(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=hl.transition;hl.transition={};try{e(!1),t()}finally{ae=n,hl.transition=r}}function Eh(){return ut().memoizedState}function Xv(e,t,n){var r=Sn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ph(e))Th(t,n);else if(n=uh(e,t,n,r),n!==null){var s=$e();jt(n,e,r,s),Oh(n,t,r)}}function Zv(e,t,n){var r=Sn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ph(e))Th(t,s);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var l=t.lastRenderedState,o=a(l,n);if(s.hasEagerState=!0,s.eagerState=o,wt(o,l)){var c=t.interleaved;c===null?(s.next=s,hc(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=uh(e,t,s,r),n!==null&&(s=$e(),jt(n,e,r,s),Oh(n,t,r))}}function Ph(e){var t=e.alternate;return e===fe||t!==null&&t===fe}function Th(e,t){Cs=fi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Oh(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Zo(e,n)}}var hi={readContext:ct,useCallback:Le,useContext:Le,useEffect:Le,useImperativeHandle:Le,useInsertionEffect:Le,useLayoutEffect:Le,useMemo:Le,useReducer:Le,useRef:Le,useState:Le,useDebugValue:Le,useDeferredValue:Le,useTransition:Le,useMutableSource:Le,useSyncExternalStore:Le,useId:Le,unstable_isNewReconciler:!1},ex={readContext:ct,useCallback:function(e,t){return St().memoizedState=[e,t===void 0?null:t],e},useContext:ct,useEffect:Au,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Qa(4194308,4,Sh.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Qa(4194308,4,e,t)},useInsertionEffect:function(e,t){return Qa(4,2,e,t)},useMemo:function(e,t){var n=St();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=St();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Xv.bind(null,fe,e),[r.memoizedState,e]},useRef:function(e){var t=St();return e={current:e},t.memoizedState=e},useState:Du,useDebugValue:kc,useDeferredValue:function(e){return St().memoizedState=e},useTransition:function(){var e=Du(!1),t=e[0];return e=Yv.bind(null,e[1]),St().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=fe,s=St();if(ue){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),Ee===null)throw Error(E(349));tr&30||ph(r,t,n)}s.memoizedState=n;var a={value:n,getSnapshot:t};return s.queue=a,Au(xh.bind(null,r,a,e),[e]),r.flags|=2048,Hs(9,vh.bind(null,r,a,n,t),void 0,null),n},useId:function(){var e=St(),t=Ee.identifierPrefix;if(ue){var n=At,r=Dt;n=(r&~(1<<32-gt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Vs++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[_t]=t,e[Us]=r,Uh(e,t,!1,!1),t.stateNode=e;e:{switch(l=Fl(n,r),n){case"dialog":oe("cancel",e),oe("close",e),s=r;break;case"iframe":case"object":case"embed":oe("load",e),s=r;break;case"video":case"audio":for(s=0;sGr&&(t.flags|=128,r=!0,hs(a,!1),t.lanes=4194304)}else{if(!r)if(e=di(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),hs(a,!0),a.tail===null&&a.tailMode==="hidden"&&!l.alternate&&!ue)return Re(t),null}else 2*je()-a.renderingStartTime>Gr&&n!==1073741824&&(t.flags|=128,r=!0,hs(a,!1),t.lanes=4194304);a.isBackwards?(l.sibling=t.child,t.child=l):(n=a.last,n!==null?n.sibling=l:t.child=l,a.last=l)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=je(),t.sibling=null,n=de.current,ie(de,r?n&1|2:n&1),t):(Re(t),null);case 22:case 23:return Ec(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ye&1073741824&&(Re(t),t.subtreeFlags&6&&(t.flags|=8192)):Re(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function ox(e,t){switch(oc(t),t.tag){case 1:return qe(t.type)&&si(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Wr(),ce(We),ce(Fe),xc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return vc(t),null;case 13:if(ce(de),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));Kr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ce(de),null;case 4:return Wr(),null;case 10:return fc(t.type._context),null;case 22:case 23:return Ec(),null;case 24:return null;default:return null}}var Ta=!1,ze=!1,cx=typeof WeakSet=="function"?WeakSet:Set,I=null;function Sr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){xe(e,t,r)}else n.current=null}function co(e,t,n){try{n()}catch(r){xe(e,t,r)}}var Ju=!1;function ux(e,t){if(Hl=ei,e=qf(),ic(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break e}var l=0,o=-1,c=-1,d=0,h=0,u=e,p=null;t:for(;;){for(var x;u!==n||s!==0&&u.nodeType!==3||(o=l+s),u!==a||r!==0&&u.nodeType!==3||(c=l+r),u.nodeType===3&&(l+=u.nodeValue.length),(x=u.firstChild)!==null;)p=u,u=x;for(;;){if(u===e)break t;if(p===n&&++d===s&&(o=l),p===a&&++h===r&&(c=l),(x=u.nextSibling)!==null)break;u=p,p=u.parentNode}u=x}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Wl={focusedElem:e,selectionRange:n},ei=!1,I=t;I!==null;)if(t=I,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,I=e;else for(;I!==null;){t=I;try{var k=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(k!==null){var g=k.memoizedProps,S=k.memoizedState,m=t.stateNode,f=m.getSnapshotBeforeUpdate(t.elementType===t.type?g:mt(t.type,g),S);m.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var v=t.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(w){xe(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,I=e;break}I=t.return}return k=Ju,Ju=!1,k}function _s(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var a=s.destroy;s.destroy=void 0,a!==void 0&&co(t,n,a)}s=s.next}while(s!==r)}}function Ri(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function uo(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Vh(e){var t=e.alternate;t!==null&&(e.alternate=null,Vh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[_t],delete t[Us],delete t[Jl],delete t[Hv],delete t[Wv])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Kh(e){return e.tag===5||e.tag===3||e.tag===4}function Yu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Kh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function fo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ri));else if(r!==4&&(e=e.child,e!==null))for(fo(e,t,n),e=e.sibling;e!==null;)fo(e,t,n),e=e.sibling}function ho(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(ho(e,t,n),e=e.sibling;e!==null;)ho(e,t,n),e=e.sibling}var Pe=null,xt=!1;function Jt(e,t,n){for(n=n.child;n!==null;)Hh(e,t,n),n=n.sibling}function Hh(e,t,n){if(Pt&&typeof Pt.onCommitFiberUnmount=="function")try{Pt.onCommitFiberUnmount(bi,n)}catch{}switch(n.tag){case 5:ze||Sr(n,t);case 6:var r=Pe,s=xt;Pe=null,Jt(e,t,n),Pe=r,xt=s,Pe!==null&&(xt?(e=Pe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Pe.removeChild(n.stateNode));break;case 18:Pe!==null&&(xt?(e=Pe,n=n.stateNode,e.nodeType===8?ul(e.parentNode,n):e.nodeType===1&&ul(e,n),Fs(e)):ul(Pe,n.stateNode));break;case 4:r=Pe,s=xt,Pe=n.stateNode.containerInfo,xt=!0,Jt(e,t,n),Pe=r,xt=s;break;case 0:case 11:case 14:case 15:if(!ze&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var a=s,l=a.destroy;a=a.tag,l!==void 0&&(a&2||a&4)&&co(n,t,l),s=s.next}while(s!==r)}Jt(e,t,n);break;case 1:if(!ze&&(Sr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){xe(n,t,o)}Jt(e,t,n);break;case 21:Jt(e,t,n);break;case 22:n.mode&1?(ze=(r=ze)||n.memoizedState!==null,Jt(e,t,n),ze=r):Jt(e,t,n);break;default:Jt(e,t,n)}}function Xu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new cx),t.forEach(function(r){var s=gx.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function ft(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=l),r&=~a}if(r=s,r=je()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*fx(r/1960))-r,10e?16:e,hn===null)var r=!1;else{if(e=hn,hn=null,vi=0,ne&6)throw Error(E(331));var s=ne;for(ne|=4,I=e.current;I!==null;){var a=I,l=a.child;if(I.flags&16){var o=a.deletions;if(o!==null){for(var c=0;cje()-Cc?Gn(e,0):bc|=n),Ge(e,t)}function em(e,t){t===0&&(e.mode&1?(t=wa,wa<<=1,!(wa&130023424)&&(wa=4194304)):t=1);var n=$e();e=Kt(e,t),e!==null&&(la(e,t,n),Ge(e,n))}function yx(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),em(e,n)}function gx(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),em(e,n)}var tm;tm=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||We.current)He=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return He=!1,ix(e,t,n);He=!!(e.flags&131072)}else He=!1,ue&&t.flags&1048576&&ah(t,li,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Va(e,t),e=t.pendingProps;var s=Vr(t,Fe.current);Pr(t,n),s=gc(null,t,r,e,s,n);var a=jc();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,qe(r)?(a=!0,ai(t)):a=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,mc(t),s.updater=Li,t.stateNode=s,s._reactInternals=t,no(t,r,e,n),t=ao(null,t,r,!0,a,n)):(t.tag=0,ue&&a&&lc(t),De(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Va(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=wx(r),e=mt(r,e),s){case 0:t=so(null,t,r,e,n);break e;case 1:t=Wu(null,t,r,e,n);break e;case 11:t=Ku(null,t,r,e,n);break e;case 14:t=Hu(null,t,r,mt(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),so(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Wu(e,t,r,s,n);case 3:e:{if(Dh(t),e===null)throw Error(E(387));r=t.pendingProps,a=t.memoizedState,s=a.element,dh(e,t),ui(t,r,null,n);var l=t.memoizedState;if(r=l.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){s=qr(Error(E(423)),t),t=qu(e,t,r,n,s);break e}else if(r!==s){s=qr(Error(E(424)),t),t=qu(e,t,r,n,s);break e}else for(Xe=jn(t.stateNode.containerInfo.firstChild),Ze=t,ue=!0,yt=null,n=ch(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Kr(),r===s){t=Ht(e,t,n);break e}De(e,t,r,n)}t=t.child}return t;case 5:return fh(t),e===null&&Zl(t),r=t.type,s=t.pendingProps,a=e!==null?e.memoizedProps:null,l=s.children,ql(r,s)?l=null:a!==null&&ql(r,a)&&(t.flags|=32),Ih(e,t),De(e,t,l,n),t.child;case 6:return e===null&&Zl(t),null;case 13:return Ah(e,t,n);case 4:return pc(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Hr(t,null,r,n):De(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Ku(e,t,r,s,n);case 7:return De(e,t,t.pendingProps,n),t.child;case 8:return De(e,t,t.pendingProps.children,n),t.child;case 12:return De(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,a=t.memoizedProps,l=s.value,ie(oi,r._currentValue),r._currentValue=l,a!==null)if(wt(a.value,l)){if(a.children===s.children&&!We.current){t=Ht(e,t,n);break e}}else for(a=t.child,a!==null&&(a.return=t);a!==null;){var o=a.dependencies;if(o!==null){l=a.child;for(var c=o.firstContext;c!==null;){if(c.context===r){if(a.tag===1){c=$t(-1,n&-n),c.tag=2;var d=a.updateQueue;if(d!==null){d=d.shared;var h=d.pending;h===null?c.next=c:(c.next=h.next,h.next=c),d.pending=c}}a.lanes|=n,c=a.alternate,c!==null&&(c.lanes|=n),eo(a.return,n,t),o.lanes|=n;break}c=c.next}}else if(a.tag===10)l=a.type===t.type?null:a.child;else if(a.tag===18){if(l=a.return,l===null)throw Error(E(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),eo(l,n,t),l=a.sibling}else l=a.child;if(l!==null)l.return=a;else for(l=a;l!==null;){if(l===t){l=null;break}if(a=l.sibling,a!==null){a.return=l.return,l=a;break}l=l.return}a=l}De(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Pr(t,n),s=ct(s),r=r(s),t.flags|=1,De(e,t,r,n),t.child;case 14:return r=t.type,s=mt(r,t.pendingProps),s=mt(r.type,s),Hu(e,t,r,s,n);case 15:return zh(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Va(e,t),t.tag=1,qe(r)?(e=!0,ai(t)):e=!1,Pr(t,n),Lh(t,r,s),no(t,r,s,n),ao(null,t,r,!0,e,n);case 19:return $h(e,t,n);case 22:return Fh(e,t,n)}throw Error(E(156,t.tag))};function nm(e,t){return Pf(e,t)}function jx(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function lt(e,t,n,r){return new jx(e,t,n,r)}function Tc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function wx(e){if(typeof e=="function")return Tc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Go)return 11;if(e===Jo)return 14}return 2}function Nn(e,t){var n=e.alternate;return n===null?(n=lt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Wa(e,t,n,r,s,a){var l=2;if(r=e,typeof e=="function")Tc(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case mr:return Jn(n.children,s,a,t);case qo:l=8,s|=8;break;case Cl:return e=lt(12,n,t,s|2),e.elementType=Cl,e.lanes=a,e;case _l:return e=lt(13,n,t,s),e.elementType=_l,e.lanes=a,e;case El:return e=lt(19,n,t,s),e.elementType=El,e.lanes=a,e;case ff:return zi(n,s,a,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case uf:l=10;break e;case df:l=9;break e;case Go:l=11;break e;case Jo:l=14;break e;case Xt:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=lt(l,n,t,s),t.elementType=e,t.type=r,t.lanes=a,t}function Jn(e,t,n,r){return e=lt(7,e,r,t),e.lanes=n,e}function zi(e,t,n,r){return e=lt(22,e,r,t),e.elementType=ff,e.lanes=n,e.stateNode={isHidden:!1},e}function yl(e,t,n){return e=lt(6,e,null,t),e.lanes=n,e}function gl(e,t,n){return t=lt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function kx(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Zi(0),this.expirationTimes=Zi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Zi(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Oc(e,t,n,r,s,a,l,o,c){return e=new kx(e,t,n,o,c),t===1?(t=1,a===!0&&(t|=8)):t=0,a=lt(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},mc(a),e}function Sx(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(im)}catch(e){console.error(e)}}im(),af.exports=tt;var Ex=af.exports,id=Ex;Nl.createRoot=id.createRoot,Nl.hydrateRoot=id.hydrateRoot;var ts=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Px={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},nn,Ao,Fd,Tx=(Fd=class{constructor(){$(this,nn,Px);$(this,Ao,!1)}setTimeoutProvider(e){z(this,nn,e)}setTimeout(e,t){return y(this,nn).setTimeout(e,t)}clearTimeout(e){y(this,nn).clearTimeout(e)}setInterval(e,t){return y(this,nn).setInterval(e,t)}clearInterval(e){y(this,nn).clearInterval(e)}},nn=new WeakMap,Ao=new WeakMap,Fd),An=new Tx;function Ox(e){setTimeout(e,0)}var sr=typeof window>"u"||"Deno"in globalThis;function Ae(){}function Lx(e,t){return typeof e=="function"?e(t):e}function yo(e){return typeof e=="number"&&e>=0&&e!==1/0}function lm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function bn(e,t){return typeof e=="function"?e(t):e}function st(e,t){return typeof e=="function"?e(t):e}function ld(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:a,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==zc(l,t.options))return!1}else if(!qs(t.queryKey,l))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||s&&s!==t.state.fetchStatus||a&&!a(t))}function od(e,t){const{exact:n,status:r,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(ar(t.options.mutationKey)!==ar(a))return!1}else if(!qs(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function zc(e,t){return((t==null?void 0:t.queryKeyHashFn)||ar)(e)}function ar(e){return JSON.stringify(e,(t,n)=>go(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function qs(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>qs(e[n],t[n])):!1}var Rx=Object.prototype.hasOwnProperty;function om(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=cd(e)&&cd(t);if(!r&&!(go(e)&&go(t)))return t;const a=(r?e:Object.keys(e)).length,l=r?t:Object.keys(t),o=l.length,c=r?new Array(o):{};let d=0;for(let h=0;h{An.setTimeout(t,e)})}function jo(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?om(e,t):t}function zx(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Fx(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Fc=Symbol();function cm(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Fc?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Ic(e,t){return typeof e=="function"?e(...t):!!e}function Ix(e,t,n){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),e}var $n,rn,Or,Id,Dx=(Id=class extends ts{constructor(){super();$(this,$n);$(this,rn);$(this,Or);z(this,Or,t=>{if(!sr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){y(this,rn)||this.setEventListener(y(this,Or))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,rn))==null||t.call(this),z(this,rn,void 0))}setEventListener(t){var n;z(this,Or,t),(n=y(this,rn))==null||n.call(this),z(this,rn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){y(this,$n)!==t&&(z(this,$n,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof y(this,$n)=="boolean"?y(this,$n):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},$n=new WeakMap,rn=new WeakMap,Or=new WeakMap,Id),Dc=new Dx;function wo(){let e,t;const n=new Promise((s,a)=>{e=s,t=a});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var Ax=Ox;function $x(){let e=[],t=0,n=o=>{o()},r=o=>{o()},s=Ax;const a=o=>{t?e.push(o):s(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&s(()=>{r(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;t++;try{c=o()}finally{t--,t||l()}return c},batchCalls:o=>(...c)=>{a(()=>{o(...c)})},schedule:a,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{s=o}}}var Se=$x(),Lr,sn,Rr,Dd,Ux=(Dd=class extends ts{constructor(){super();$(this,Lr,!0);$(this,sn);$(this,Rr);z(this,Rr,t=>{if(!sr&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){y(this,sn)||this.setEventListener(y(this,Rr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,sn))==null||t.call(this),z(this,sn,void 0))}setEventListener(t){var n;z(this,Rr,t),(n=y(this,sn))==null||n.call(this),z(this,sn,t(this.setOnline.bind(this)))}setOnline(t){y(this,Lr)!==t&&(z(this,Lr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return y(this,Lr)}},Lr=new WeakMap,sn=new WeakMap,Rr=new WeakMap,Dd),ji=new Ux;function Bx(e){return Math.min(1e3*2**e,3e4)}function um(e){return(e??"online")==="online"?ji.isOnline():!0}var ko=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function dm(e){let t=!1,n=0,r;const s=wo(),a=()=>s.status!=="pending",l=g=>{var S;if(!a()){const m=new ko(g);p(m),(S=e.onCancel)==null||S.call(e,m)}},o=()=>{t=!0},c=()=>{t=!1},d=()=>Dc.isFocused()&&(e.networkMode==="always"||ji.isOnline())&&e.canRun(),h=()=>um(e.networkMode)&&e.canRun(),u=g=>{a()||(r==null||r(),s.resolve(g))},p=g=>{a()||(r==null||r(),s.reject(g))},x=()=>new Promise(g=>{var S;r=m=>{(a()||d())&&g(m)},(S=e.onPause)==null||S.call(e)}).then(()=>{var g;r=void 0,a()||(g=e.onContinue)==null||g.call(e)}),k=()=>{if(a())return;let g;const S=n===0?e.initialPromise:void 0;try{g=S??e.fn()}catch(m){g=Promise.reject(m)}Promise.resolve(g).then(u).catch(m=>{var b;if(a())return;const f=e.retry??(sr?0:3),v=e.retryDelay??Bx,w=typeof v=="function"?v(n,m):v,C=f===!0||typeof f=="number"&&nd()?void 0:x()).then(()=>{t?p(m):k()})})};return{promise:s,status:()=>s.status,cancel:l,continue:()=>(r==null||r(),s),cancelRetry:o,continueRetry:c,canStart:h,start:()=>(h()?k():x().then(k),s)}}var Un,Ad,fm=(Ad=class{constructor(){$(this,Un)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),yo(this.gcTime)&&z(this,Un,An.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(sr?1/0:5*60*1e3))}clearGcTimeout(){y(this,Un)&&(An.clearTimeout(y(this,Un)),z(this,Un,void 0))}},Un=new WeakMap,Ad),Bn,Mr,rt,Qn,Ce,ta,Vn,pt,Ot,$d,Qx=($d=class extends fm{constructor(t){super();$(this,pt);$(this,Bn);$(this,Mr);$(this,rt);$(this,Qn);$(this,Ce);$(this,ta);$(this,Vn);z(this,Vn,!1),z(this,ta,t.defaultOptions),this.setOptions(t.options),this.observers=[],z(this,Qn,t.client),z(this,rt,y(this,Qn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,z(this,Bn,fd(this.options)),this.state=t.state??y(this,Bn),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=y(this,Ce))==null?void 0:t.promise}setOptions(t){if(this.options={...y(this,ta),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=fd(this.options);n.data!==void 0&&(this.setState(dd(n.data,n.dataUpdatedAt)),z(this,Bn,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&y(this,rt).remove(this)}setData(t,n){const r=jo(this.state.data,t,this.options);return W(this,pt,Ot).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){W(this,pt,Ot).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=y(this,Ce))==null?void 0:r.promise;return(s=y(this,Ce))==null||s.cancel(t),n?n.then(Ae).catch(Ae):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(y(this,Bn))}isActive(){return this.observers.some(t=>st(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Fc||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>bn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!lm(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),y(this,rt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(y(this,Ce)&&(y(this,Vn)?y(this,Ce).cancel({revert:!0}):y(this,Ce).cancelRetry()),this.scheduleGc()),y(this,rt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||W(this,pt,Ot).call(this,{type:"invalidate"})}async fetch(t,n){var c,d,h,u,p,x,k,g,S,m,f,v;if(this.state.fetchStatus!=="idle"&&((c=y(this,Ce))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(y(this,Ce))return y(this,Ce).continueRetry(),y(this,Ce).promise}if(t&&this.setOptions(t),!this.options.queryFn){const w=this.observers.find(C=>C.options.queryFn);w&&this.setOptions(w.options)}const r=new AbortController,s=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(z(this,Vn,!0),r.signal)})},a=()=>{const w=cm(this.options,n),b=(()=>{const N={client:y(this,Qn),queryKey:this.queryKey,meta:this.meta};return s(N),N})();return z(this,Vn,!1),this.options.persister?this.options.persister(w,b,this):w(b)},o=(()=>{const w={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:y(this,Qn),state:this.state,fetchFn:a};return s(w),w})();(d=this.options.behavior)==null||d.onFetch(o,this),z(this,Mr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((h=o.fetchOptions)==null?void 0:h.meta))&&W(this,pt,Ot).call(this,{type:"fetch",meta:(u=o.fetchOptions)==null?void 0:u.meta}),z(this,Ce,dm({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:w=>{w instanceof ko&&w.revert&&this.setState({...y(this,Mr),fetchStatus:"idle"}),r.abort()},onFail:(w,C)=>{W(this,pt,Ot).call(this,{type:"failed",failureCount:w,error:C})},onPause:()=>{W(this,pt,Ot).call(this,{type:"pause"})},onContinue:()=>{W(this,pt,Ot).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const w=await y(this,Ce).start();if(w===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(w),(x=(p=y(this,rt).config).onSuccess)==null||x.call(p,w,this),(g=(k=y(this,rt).config).onSettled)==null||g.call(k,w,this.state.error,this),w}catch(w){if(w instanceof ko){if(w.silent)return y(this,Ce).promise;if(w.revert){if(this.state.data===void 0)throw w;return this.state.data}}throw W(this,pt,Ot).call(this,{type:"error",error:w}),(m=(S=y(this,rt).config).onError)==null||m.call(S,w,this),(v=(f=y(this,rt).config).onSettled)==null||v.call(f,this.state.data,w,this),w}finally{this.scheduleGc()}}},Bn=new WeakMap,Mr=new WeakMap,rt=new WeakMap,Qn=new WeakMap,Ce=new WeakMap,ta=new WeakMap,Vn=new WeakMap,pt=new WeakSet,Ot=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...hm(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...dd(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return z(this,Mr,t.manual?s:void 0),s;case"error":const a=t.error;return{...r,error:a,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Se.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),y(this,rt).notify({query:this,type:"updated",action:t})})},$d);function hm(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:um(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function dd(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function fd(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Qe,Z,na,Ie,Kn,zr,Mt,an,ra,Fr,Ir,Hn,Wn,ln,Dr,se,js,So,No,bo,Co,_o,Eo,Po,mm,Ud,Vx=(Ud=class extends ts{constructor(t,n){super();$(this,se);$(this,Qe);$(this,Z);$(this,na);$(this,Ie);$(this,Kn);$(this,zr);$(this,Mt);$(this,an);$(this,ra);$(this,Fr);$(this,Ir);$(this,Hn);$(this,Wn);$(this,ln);$(this,Dr,new Set);this.options=n,z(this,Qe,t),z(this,an,null),z(this,Mt,wo()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(y(this,Z).addObserver(this),hd(y(this,Z),this.options)?W(this,se,js).call(this):this.updateResult(),W(this,se,Co).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return To(y(this,Z),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return To(y(this,Z),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,W(this,se,_o).call(this),W(this,se,Eo).call(this),y(this,Z).removeObserver(this)}setOptions(t){const n=this.options,r=y(this,Z);if(this.options=y(this,Qe).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof st(this.options.enabled,y(this,Z))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");W(this,se,Po).call(this),y(this,Z).setOptions(this.options),n._defaulted&&!gi(this.options,n)&&y(this,Qe).getQueryCache().notify({type:"observerOptionsUpdated",query:y(this,Z),observer:this});const s=this.hasListeners();s&&md(y(this,Z),r,this.options,n)&&W(this,se,js).call(this),this.updateResult(),s&&(y(this,Z)!==r||st(this.options.enabled,y(this,Z))!==st(n.enabled,y(this,Z))||bn(this.options.staleTime,y(this,Z))!==bn(n.staleTime,y(this,Z)))&&W(this,se,So).call(this);const a=W(this,se,No).call(this);s&&(y(this,Z)!==r||st(this.options.enabled,y(this,Z))!==st(n.enabled,y(this,Z))||a!==y(this,ln))&&W(this,se,bo).call(this,a)}getOptimisticResult(t){const n=y(this,Qe).getQueryCache().build(y(this,Qe),t),r=this.createResult(n,t);return Hx(this,r)&&(z(this,Ie,r),z(this,zr,this.options),z(this,Kn,y(this,Z).state)),r}getCurrentResult(){return y(this,Ie)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&y(this,Mt).status==="pending"&&y(this,Mt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){y(this,Dr).add(t)}getCurrentQuery(){return y(this,Z)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=y(this,Qe).defaultQueryOptions(t),r=y(this,Qe).getQueryCache().build(y(this,Qe),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return W(this,se,js).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),y(this,Ie)))}createResult(t,n){var F;const r=y(this,Z),s=this.options,a=y(this,Ie),l=y(this,Kn),o=y(this,zr),d=t!==r?t.state:y(this,na),{state:h}=t;let u={...h},p=!1,x;if(n._optimisticResults){const O=this.hasListeners(),B=!O&&hd(t,n),G=O&&md(t,r,n,s);(B||G)&&(u={...u,...hm(h.data,t.options)}),n._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:k,errorUpdatedAt:g,status:S}=u;x=u.data;let m=!1;if(n.placeholderData!==void 0&&x===void 0&&S==="pending"){let O;a!=null&&a.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(O=a.data,m=!0):O=typeof n.placeholderData=="function"?n.placeholderData((F=y(this,Ir))==null?void 0:F.state.data,y(this,Ir)):n.placeholderData,O!==void 0&&(S="success",x=jo(a==null?void 0:a.data,O,n),p=!0)}if(n.select&&x!==void 0&&!m)if(a&&x===(l==null?void 0:l.data)&&n.select===y(this,ra))x=y(this,Fr);else try{z(this,ra,n.select),x=n.select(x),x=jo(a==null?void 0:a.data,x,n),z(this,Fr,x),z(this,an,null)}catch(O){z(this,an,O)}y(this,an)&&(k=y(this,an),x=y(this,Fr),g=Date.now(),S="error");const f=u.fetchStatus==="fetching",v=S==="pending",w=S==="error",C=v&&f,b=x!==void 0,_={status:S,fetchStatus:u.fetchStatus,isPending:v,isSuccess:S==="success",isError:w,isInitialLoading:C,isLoading:C,data:x,dataUpdatedAt:u.dataUpdatedAt,error:k,errorUpdatedAt:g,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>d.dataUpdateCount||u.errorUpdateCount>d.errorUpdateCount,isFetching:f,isRefetching:f&&!v,isLoadingError:w&&!b,isPaused:u.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:w&&b,isStale:Ac(t,n),refetch:this.refetch,promise:y(this,Mt),isEnabled:st(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=_.data!==void 0,B=_.status==="error"&&!O,G=D=>{B?D.reject(_.error):O&&D.resolve(_.data)},re=()=>{const D=z(this,Mt,_.promise=wo());G(D)},le=y(this,Mt);switch(le.status){case"pending":t.queryHash===r.queryHash&&G(le);break;case"fulfilled":(B||_.data!==le.value)&&re();break;case"rejected":(!B||_.error!==le.reason)&&re();break}}return _}updateResult(){const t=y(this,Ie),n=this.createResult(y(this,Z),this.options);if(z(this,Kn,y(this,Z).state),z(this,zr,this.options),y(this,Kn).data!==void 0&&z(this,Ir,y(this,Z)),gi(n,t))return;z(this,Ie,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!y(this,Dr).size)return!0;const l=new Set(a??y(this,Dr));return this.options.throwOnError&&l.add("error"),Object.keys(y(this,Ie)).some(o=>{const c=o;return y(this,Ie)[c]!==t[c]&&l.has(c)})};W(this,se,mm).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&W(this,se,Co).call(this)}},Qe=new WeakMap,Z=new WeakMap,na=new WeakMap,Ie=new WeakMap,Kn=new WeakMap,zr=new WeakMap,Mt=new WeakMap,an=new WeakMap,ra=new WeakMap,Fr=new WeakMap,Ir=new WeakMap,Hn=new WeakMap,Wn=new WeakMap,ln=new WeakMap,Dr=new WeakMap,se=new WeakSet,js=function(t){W(this,se,Po).call(this);let n=y(this,Z).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Ae)),n},So=function(){W(this,se,_o).call(this);const t=bn(this.options.staleTime,y(this,Z));if(sr||y(this,Ie).isStale||!yo(t))return;const r=lm(y(this,Ie).dataUpdatedAt,t)+1;z(this,Hn,An.setTimeout(()=>{y(this,Ie).isStale||this.updateResult()},r))},No=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(y(this,Z)):this.options.refetchInterval)??!1},bo=function(t){W(this,se,Eo).call(this),z(this,ln,t),!(sr||st(this.options.enabled,y(this,Z))===!1||!yo(y(this,ln))||y(this,ln)===0)&&z(this,Wn,An.setInterval(()=>{(this.options.refetchIntervalInBackground||Dc.isFocused())&&W(this,se,js).call(this)},y(this,ln)))},Co=function(){W(this,se,So).call(this),W(this,se,bo).call(this,W(this,se,No).call(this))},_o=function(){y(this,Hn)&&(An.clearTimeout(y(this,Hn)),z(this,Hn,void 0))},Eo=function(){y(this,Wn)&&(An.clearInterval(y(this,Wn)),z(this,Wn,void 0))},Po=function(){const t=y(this,Qe).getQueryCache().build(y(this,Qe),this.options);if(t===y(this,Z))return;const n=y(this,Z);z(this,Z,t),z(this,na,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},mm=function(t){Se.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(y(this,Ie))}),y(this,Qe).getQueryCache().notify({query:y(this,Z),type:"observerResultsUpdated"})})},Ud);function Kx(e,t){return st(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function hd(e,t){return Kx(e,t)||e.state.data!==void 0&&To(e,t,t.refetchOnMount)}function To(e,t,n){if(st(t.enabled,e)!==!1&&bn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Ac(e,t)}return!1}function md(e,t,n,r){return(e!==t||st(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Ac(e,n)}function Ac(e,t){return st(t.enabled,e)!==!1&&e.isStaleByTime(bn(t.staleTime,e))}function Hx(e,t){return!gi(e.getCurrentResult(),t)}function pd(e){return{onFetch:(t,n)=>{var h,u,p,x,k;const r=t.options,s=(p=(u=(h=t.fetchOptions)==null?void 0:h.meta)==null?void 0:u.fetchMore)==null?void 0:p.direction,a=((x=t.state.data)==null?void 0:x.pages)||[],l=((k=t.state.data)==null?void 0:k.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const d=async()=>{let g=!1;const S=v=>{Ix(v,()=>t.signal,()=>g=!0)},m=cm(t.options,t.fetchOptions),f=async(v,w,C)=>{if(g)return Promise.reject();if(w==null&&v.pages.length)return Promise.resolve(v);const N=(()=>{const B={client:t.client,queryKey:t.queryKey,pageParam:w,direction:C?"backward":"forward",meta:t.options.meta};return S(B),B})(),_=await m(N),{maxPages:F}=t.options,O=C?Fx:zx;return{pages:O(v.pages,_,F),pageParams:O(v.pageParams,w,F)}};if(s&&a.length){const v=s==="backward",w=v?Wx:vd,C={pages:a,pageParams:l},b=w(r,C);o=await f(C,b,v)}else{const v=e??a.length;do{const w=c===0?l[0]??r.initialPageParam:vd(r,o);if(c>0&&w==null)break;o=await f(o,w),c++}while(c{var g,S;return(S=(g=t.options).persister)==null?void 0:S.call(g,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=d}}}function vd(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Wx(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var sa,Nt,Me,qn,bt,Yt,Bd,qx=(Bd=class extends fm{constructor(t){super();$(this,bt);$(this,sa);$(this,Nt);$(this,Me);$(this,qn);z(this,sa,t.client),this.mutationId=t.mutationId,z(this,Me,t.mutationCache),z(this,Nt,[]),this.state=t.state||pm(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){y(this,Nt).includes(t)||(y(this,Nt).push(t),this.clearGcTimeout(),y(this,Me).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){z(this,Nt,y(this,Nt).filter(n=>n!==t)),this.scheduleGc(),y(this,Me).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){y(this,Nt).length||(this.state.status==="pending"?this.scheduleGc():y(this,Me).remove(this))}continue(){var t;return((t=y(this,qn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,d,h,u,p,x,k,g,S,m,f,v,w,C,b,N;const n=()=>{W(this,bt,Yt).call(this,{type:"continue"})},r={client:y(this,sa),meta:this.options.meta,mutationKey:this.options.mutationKey};z(this,qn,dm({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(_,F)=>{W(this,bt,Yt).call(this,{type:"failed",failureCount:_,error:F})},onPause:()=>{W(this,bt,Yt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>y(this,Me).canRun(this)}));const s=this.state.status==="pending",a=!y(this,qn).canStart();try{if(s)n();else{W(this,bt,Yt).call(this,{type:"pending",variables:t,isPaused:a}),y(this,Me).config.onMutate&&await y(this,Me).config.onMutate(t,this,r);const F=await((o=(l=this.options).onMutate)==null?void 0:o.call(l,t,r));F!==this.state.context&&W(this,bt,Yt).call(this,{type:"pending",context:F,variables:t,isPaused:a})}const _=await y(this,qn).start();return await((d=(c=y(this,Me).config).onSuccess)==null?void 0:d.call(c,_,t,this.state.context,this,r)),await((u=(h=this.options).onSuccess)==null?void 0:u.call(h,_,t,this.state.context,r)),await((x=(p=y(this,Me).config).onSettled)==null?void 0:x.call(p,_,null,this.state.variables,this.state.context,this,r)),await((g=(k=this.options).onSettled)==null?void 0:g.call(k,_,null,t,this.state.context,r)),W(this,bt,Yt).call(this,{type:"success",data:_}),_}catch(_){try{await((m=(S=y(this,Me).config).onError)==null?void 0:m.call(S,_,t,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((v=(f=this.options).onError)==null?void 0:v.call(f,_,t,this.state.context,r))}catch(F){Promise.reject(F)}try{await((C=(w=y(this,Me).config).onSettled)==null?void 0:C.call(w,void 0,_,this.state.variables,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((N=(b=this.options).onSettled)==null?void 0:N.call(b,void 0,_,t,this.state.context,r))}catch(F){Promise.reject(F)}throw W(this,bt,Yt).call(this,{type:"error",error:_}),_}finally{y(this,Me).runNext(this)}}},sa=new WeakMap,Nt=new WeakMap,Me=new WeakMap,qn=new WeakMap,bt=new WeakSet,Yt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Se.batch(()=>{y(this,Nt).forEach(r=>{r.onMutationUpdate(t)}),y(this,Me).notify({mutation:this,type:"updated",action:t})})},Bd);function pm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var zt,vt,aa,Qd,Gx=(Qd=class extends ts{constructor(t={}){super();$(this,zt);$(this,vt);$(this,aa);this.config=t,z(this,zt,new Set),z(this,vt,new Map),z(this,aa,0)}build(t,n,r){const s=new qx({client:t,mutationCache:this,mutationId:++pa(this,aa)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){y(this,zt).add(t);const n=Ra(t);if(typeof n=="string"){const r=y(this,vt).get(n);r?r.push(t):y(this,vt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(y(this,zt).delete(t)){const n=Ra(t);if(typeof n=="string"){const r=y(this,vt).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&y(this,vt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Ra(t);if(typeof n=="string"){const r=y(this,vt).get(n),s=r==null?void 0:r.find(a=>a.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=Ra(t);if(typeof n=="string"){const s=(r=y(this,vt).get(n))==null?void 0:r.find(a=>a!==t&&a.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Se.batch(()=>{y(this,zt).forEach(t=>{this.notify({type:"removed",mutation:t})}),y(this,zt).clear(),y(this,vt).clear()})}getAll(){return Array.from(y(this,zt))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>od(n,r))}findAll(t={}){return this.getAll().filter(n=>od(t,n))}notify(t){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Se.batch(()=>Promise.all(t.map(n=>n.continue().catch(Ae))))}},zt=new WeakMap,vt=new WeakMap,aa=new WeakMap,Qd);function Ra(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Ft,on,Ve,It,Bt,qa,Oo,Vd,Jx=(Vd=class extends ts{constructor(n,r){super();$(this,Bt);$(this,Ft);$(this,on);$(this,Ve);$(this,It);z(this,Ft,n),this.setOptions(r),this.bindMethods(),W(this,Bt,qa).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=y(this,Ft).defaultMutationOptions(n),gi(this.options,r)||y(this,Ft).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,Ve),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&ar(r.mutationKey)!==ar(this.options.mutationKey)?this.reset():((s=y(this,Ve))==null?void 0:s.state.status)==="pending"&&y(this,Ve).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=y(this,Ve))==null||n.removeObserver(this)}onMutationUpdate(n){W(this,Bt,qa).call(this),W(this,Bt,Oo).call(this,n)}getCurrentResult(){return y(this,on)}reset(){var n;(n=y(this,Ve))==null||n.removeObserver(this),z(this,Ve,void 0),W(this,Bt,qa).call(this),W(this,Bt,Oo).call(this)}mutate(n,r){var s;return z(this,It,r),(s=y(this,Ve))==null||s.removeObserver(this),z(this,Ve,y(this,Ft).getMutationCache().build(y(this,Ft),this.options)),y(this,Ve).addObserver(this),y(this,Ve).execute(n)}},Ft=new WeakMap,on=new WeakMap,Ve=new WeakMap,It=new WeakMap,Bt=new WeakSet,qa=function(){var r;const n=((r=y(this,Ve))==null?void 0:r.state)??pm();z(this,on,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Oo=function(n){Se.batch(()=>{var r,s,a,l,o,c,d,h;if(y(this,It)&&this.hasListeners()){const u=y(this,on).variables,p=y(this,on).context,x={client:y(this,Ft),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(s=(r=y(this,It)).onSuccess)==null||s.call(r,n.data,u,p,x)}catch(k){Promise.reject(k)}try{(l=(a=y(this,It)).onSettled)==null||l.call(a,n.data,null,u,p,x)}catch(k){Promise.reject(k)}}else if((n==null?void 0:n.type)==="error"){try{(c=(o=y(this,It)).onError)==null||c.call(o,n.error,u,p,x)}catch(k){Promise.reject(k)}try{(h=(d=y(this,It)).onSettled)==null||h.call(d,void 0,n.error,u,p,x)}catch(k){Promise.reject(k)}}}this.listeners.forEach(u=>{u(y(this,on))})})},Vd),Ct,Kd,Yx=(Kd=class extends ts{constructor(t={}){super();$(this,Ct);this.config=t,z(this,Ct,new Map)}build(t,n,r){const s=n.queryKey,a=n.queryHash??zc(s,n);let l=this.get(a);return l||(l=new Qx({client:t,queryKey:s,queryHash:a,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(l)),l}add(t){y(this,Ct).has(t.queryHash)||(y(this,Ct).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=y(this,Ct).get(t.queryHash);n&&(t.destroy(),n===t&&y(this,Ct).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Se.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return y(this,Ct).get(t)}getAll(){return[...y(this,Ct).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>ld(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>ld(t,r)):n}notify(t){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Se.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Se.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ct=new WeakMap,Kd),ve,cn,un,Ar,$r,dn,Ur,Br,Hd,Xx=(Hd=class{constructor(e={}){$(this,ve);$(this,cn);$(this,un);$(this,Ar);$(this,$r);$(this,dn);$(this,Ur);$(this,Br);z(this,ve,e.queryCache||new Yx),z(this,cn,e.mutationCache||new Gx),z(this,un,e.defaultOptions||{}),z(this,Ar,new Map),z(this,$r,new Map),z(this,dn,0)}mount(){pa(this,dn)._++,y(this,dn)===1&&(z(this,Ur,Dc.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,ve).onFocus())})),z(this,Br,ji.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,ve).onOnline())})))}unmount(){var e,t;pa(this,dn)._--,y(this,dn)===0&&((e=y(this,Ur))==null||e.call(this),z(this,Ur,void 0),(t=y(this,Br))==null||t.call(this),z(this,Br,void 0))}isFetching(e){return y(this,ve).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return y(this,cn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,ve).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=y(this,ve).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(bn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return y(this,ve).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=y(this,ve).get(r.queryHash),a=s==null?void 0:s.state.data,l=Lx(t,a);if(l!==void 0)return y(this,ve).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return Se.batch(()=>y(this,ve).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,ve).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=y(this,ve);Se.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=y(this,ve);return Se.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Se.batch(()=>y(this,ve).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Ae).catch(Ae)}invalidateQueries(e,t={}){return Se.batch(()=>(y(this,ve).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Se.batch(()=>y(this,ve).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let a=s.fetch(void 0,n);return n.throwOnError||(a=a.catch(Ae)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Ae)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=y(this,ve).build(this,t);return n.isStaleByTime(bn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ae).catch(Ae)}fetchInfiniteQuery(e){return e.behavior=pd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ae).catch(Ae)}ensureInfiniteQueryData(e){return e.behavior=pd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ji.isOnline()?y(this,cn).resumePausedMutations():Promise.resolve()}getQueryCache(){return y(this,ve)}getMutationCache(){return y(this,cn)}getDefaultOptions(){return y(this,un)}setDefaultOptions(e){z(this,un,e)}setQueryDefaults(e,t){y(this,Ar).set(ar(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...y(this,Ar).values()],n={};return t.forEach(r=>{qs(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){y(this,$r).set(ar(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...y(this,$r).values()],n={};return t.forEach(r=>{qs(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...y(this,un).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=zc(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Fc&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...y(this,un).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){y(this,ve).clear(),y(this,cn).clear()}},ve=new WeakMap,cn=new WeakMap,un=new WeakMap,Ar=new WeakMap,$r=new WeakMap,dn=new WeakMap,Ur=new WeakMap,Br=new WeakMap,Hd),vm=j.createContext(void 0),qt=e=>{const t=j.useContext(vm);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Zx=({client:e,children:t})=>(j.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),i.jsx(vm.Provider,{value:e,children:t})),xm=j.createContext(!1),ey=()=>j.useContext(xm);xm.Provider;function ty(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var ny=j.createContext(ty()),ry=()=>j.useContext(ny),sy=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Ic(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},ay=e=>{j.useEffect(()=>{e.clearReset()},[e])},iy=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||Ic(n,[e.error,r])),ly=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},oy=(e,t)=>e.isLoading&&e.isFetching&&!t,cy=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,xd=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function uy(e,t,n){var p,x,k,g;const r=ey(),s=ry(),a=qt(),l=a.defaultQueryOptions(e);(x=(p=a.getDefaultOptions().queries)==null?void 0:p._experimental_beforeQuery)==null||x.call(p,l);const o=a.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",ly(l),sy(l,s,o),ay(s);const c=!a.getQueryCache().get(l.queryHash),[d]=j.useState(()=>new t(a,l)),h=d.getOptimisticResult(l),u=!r&&e.subscribed!==!1;if(j.useSyncExternalStore(j.useCallback(S=>{const m=u?d.subscribe(Se.batchCalls(S)):Ae;return d.updateResult(),m},[d,u]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),j.useEffect(()=>{d.setOptions(l)},[l,d]),cy(l,h))throw xd(l,d,s);if(iy({result:h,errorResetBoundary:s,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw h.error;if((g=(k=a.getDefaultOptions().queries)==null?void 0:k._experimental_afterQuery)==null||g.call(k,l,h),l.experimental_prefetchInRender&&!sr&&oy(h,r)){const S=c?xd(l,d,s):o==null?void 0:o.promise;S==null||S.catch(Ae).finally(()=>{d.updateResult()})}return l.notifyOnChangeProps?h:d.trackResult(h)}function he(e,t){return uy(e,Vx)}function Je(e,t){const n=qt(),[r]=j.useState(()=>new Jx(n,e));j.useEffect(()=>{r.setOptions(e)},[r,e]);const s=j.useSyncExternalStore(j.useCallback(l=>r.subscribe(Se.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=j.useCallback((l,o)=>{r.mutate(l,o).catch(Ae)},[r]);if(s.error&&Ic(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}/** + * @remix-run/router v1.23.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Gs(){return Gs=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function $c(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function fy(){return Math.random().toString(36).substr(2,8)}function gd(e,t){return{usr:e.state,key:e.key,idx:t}}function Lo(e,t,n,r){return n===void 0&&(n=null),Gs({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?ns(t):t,{state:n,key:t&&t.key||r||fy()})}function wi(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function ns(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function hy(e,t,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:a=!1}=r,l=s.history,o=mn.Pop,c=null,d=h();d==null&&(d=0,l.replaceState(Gs({},l.state,{idx:d}),""));function h(){return(l.state||{idx:null}).idx}function u(){o=mn.Pop;let S=h(),m=S==null?null:S-d;d=S,c&&c({action:o,location:g.location,delta:m})}function p(S,m){o=mn.Push;let f=Lo(g.location,S,m);d=h()+1;let v=gd(f,d),w=g.createHref(f);try{l.pushState(v,"",w)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;s.location.assign(w)}a&&c&&c({action:o,location:g.location,delta:1})}function x(S,m){o=mn.Replace;let f=Lo(g.location,S,m);d=h();let v=gd(f,d),w=g.createHref(f);l.replaceState(v,"",w),a&&c&&c({action:o,location:g.location,delta:0})}function k(S){let m=s.location.origin!=="null"?s.location.origin:s.location.href,f=typeof S=="string"?S:wi(S);return f=f.replace(/ $/,"%20"),ye(m,"No window.location.(origin|href) available to create URL for href: "+f),new URL(f,m)}let g={get action(){return o},get location(){return e(s,l)},listen(S){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(yd,u),c=S,()=>{s.removeEventListener(yd,u),c=null}},createHref(S){return t(s,S)},createURL:k,encodeLocation(S){let m=k(S);return{pathname:m.pathname,search:m.search,hash:m.hash}},push:p,replace:x,go(S){return l.go(S)}};return g}var jd;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(jd||(jd={}));function my(e,t,n){return n===void 0&&(n="/"),py(e,t,n)}function py(e,t,n,r){let s=typeof t=="string"?ns(t):t,a=Jr(s.pathname||"/",n);if(a==null)return null;let l=ym(e);vy(l);let o=null;for(let c=0;o==null&&c{let c={relativePath:o===void 0?a.path||"":o,caseSensitive:a.caseSensitive===!0,childrenIndex:l,route:a};c.relativePath.startsWith("/")&&(ye(c.relativePath.startsWith(r),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(r.length));let d=Cn([r,c.relativePath]),h=n.concat(c);a.children&&a.children.length>0&&(ye(a.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),ym(a.children,t,h,d)),!(a.path==null&&!a.index)&&t.push({path:d,score:Sy(d,a.index),routesMeta:h})};return e.forEach((a,l)=>{var o;if(a.path===""||!((o=a.path)!=null&&o.includes("?")))s(a,l);else for(let c of gm(a.path))s(a,l,c)}),t}function gm(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return s?[a,""]:[a];let l=gm(r.join("/")),o=[];return o.push(...l.map(c=>c===""?a:[a,c].join("/"))),s&&o.push(...l),o.map(c=>e.startsWith("/")&&c===""?"/":c)}function vy(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ny(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const xy=/^:[\w-]+$/,yy=3,gy=2,jy=1,wy=10,ky=-2,wd=e=>e==="*";function Sy(e,t){let n=e.split("/"),r=n.length;return n.some(wd)&&(r+=ky),t&&(r+=gy),n.filter(s=>!wd(s)).reduce((s,a)=>s+(xy.test(a)?yy:a===""?jy:wy),r)}function Ny(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function by(e,t,n){let{routesMeta:r}=e,s={},a="/",l=[];for(let o=0;o{let{paramName:p,isOptional:x}=h;if(p==="*"){let g=o[u]||"";l=a.slice(0,a.length-g.length).replace(/(.)\/+$/,"$1")}const k=o[u];return x&&!k?d[p]=void 0:d[p]=(k||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:l,pattern:e}}function Cy(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),$c(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,c)=>(r.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function _y(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return $c(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Jr(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const Ey=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Py=e=>Ey.test(e);function Ty(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?ns(e):e,a;if(n)if(Py(n))a=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),$c(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?a=kd(n.substring(1),"/"):a=kd(n,t)}else a=t;return{pathname:a,search:Ry(r),hash:My(s)}}function kd(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function jl(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Oy(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function jm(e,t){let n=Oy(e);return t?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function wm(e,t,n,r){r===void 0&&(r=!1);let s;typeof e=="string"?s=ns(e):(s=Gs({},e),ye(!s.pathname||!s.pathname.includes("?"),jl("?","pathname","search",s)),ye(!s.pathname||!s.pathname.includes("#"),jl("#","pathname","hash",s)),ye(!s.search||!s.search.includes("#"),jl("#","search","hash",s)));let a=e===""||s.pathname==="",l=a?"/":s.pathname,o;if(l==null)o=n;else{let u=t.length-1;if(!r&&l.startsWith("..")){let p=l.split("/");for(;p[0]==="..";)p.shift(),u-=1;s.pathname=p.join("/")}o=u>=0?t[u]:"/"}let c=Ty(s,o),d=l&&l!=="/"&&l.endsWith("/"),h=(a||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||h)&&(c.pathname+="/"),c}const Cn=e=>e.join("/").replace(/\/\/+/g,"/"),Ly=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Ry=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,My=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function zy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const km=["post","put","patch","delete"];new Set(km);const Fy=["get",...km];new Set(Fy);/** + * React Router v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Js(){return Js=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),j.useCallback(function(d,h){if(h===void 0&&(h={}),!o.current)return;if(typeof d=="number"){r.go(d);return}let u=wm(d,JSON.parse(l),a,h.relative==="path");e==null&&t!=="/"&&(u.pathname=u.pathname==="/"?t:Cn([t,u.pathname])),(h.replace?r.replace:r.push)(u,h.state,h)},[t,r,l,a,e])}const Ay=j.createContext(null);function $y(e){let t=j.useContext(Gt).outlet;return t&&j.createElement(Ay.Provider,{value:e},t)}function fa(){let{matches:e}=j.useContext(Gt),t=e[e.length-1];return t?t.params:{}}function Bi(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=j.useContext(Rn),{matches:s}=j.useContext(Gt),{pathname:a}=rs(),l=JSON.stringify(jm(s,r.v7_relativeSplatPath));return j.useMemo(()=>wm(e,JSON.parse(l),a,n==="path"),[e,l,a,n])}function Uy(e,t){return By(e,t)}function By(e,t,n,r){da()||ye(!1);let{navigator:s}=j.useContext(Rn),{matches:a}=j.useContext(Gt),l=a[a.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let d=rs(),h;if(t){var u;let S=typeof t=="string"?ns(t):t;c==="/"||(u=S.pathname)!=null&&u.startsWith(c)||ye(!1),h=S}else h=d;let p=h.pathname||"/",x=p;if(c!=="/"){let S=c.replace(/^\//,"").split("/");x="/"+p.replace(/^\//,"").split("/").slice(S.length).join("/")}let k=my(e,{pathname:x}),g=Wy(k&&k.map(S=>Object.assign({},S,{params:Object.assign({},o,S.params),pathname:Cn([c,s.encodeLocation?s.encodeLocation(S.pathname).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?c:Cn([c,s.encodeLocation?s.encodeLocation(S.pathnameBase).pathname:S.pathnameBase])})),a,n,r);return t&&g?j.createElement(Ui.Provider,{value:{location:Js({pathname:"/",search:"",hash:"",state:null,key:"default"},h),navigationType:mn.Pop}},g):g}function Qy(){let e=Yy(),t=zy(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return j.createElement(j.Fragment,null,j.createElement("h2",null,"Unexpected Application Error!"),j.createElement("h3",{style:{fontStyle:"italic"}},t),n?j.createElement("pre",{style:s},n):null,null)}const Vy=j.createElement(Qy,null);class Ky extends j.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?j.createElement(Gt.Provider,{value:this.props.routeContext},j.createElement(Nm.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Hy(e){let{routeContext:t,match:n,children:r}=e,s=j.useContext($i);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),j.createElement(Gt.Provider,{value:t},r)}function Wy(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var a;if(!n)return null;if(n.errors)e=n.matches;else if((a=r)!=null&&a.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(s=n)==null?void 0:s.errors;if(o!=null){let h=l.findIndex(u=>u.route.id&&(o==null?void 0:o[u.route.id])!==void 0);h>=0||ye(!1),l=l.slice(0,Math.min(l.length,h+1))}let c=!1,d=-1;if(n&&r&&r.v7_partialHydration)for(let h=0;h=0?l=l.slice(0,d+1):l=[l[0]];break}}}return l.reduceRight((h,u,p)=>{let x,k=!1,g=null,S=null;n&&(x=o&&u.route.id?o[u.route.id]:void 0,g=u.route.errorElement||Vy,c&&(d<0&&p===0?(Zy("route-fallback"),k=!0,S=null):d===p&&(k=!0,S=u.route.hydrateFallbackElement||null)));let m=t.concat(l.slice(0,p+1)),f=()=>{let v;return x?v=g:k?v=S:u.route.Component?v=j.createElement(u.route.Component,null):u.route.element?v=u.route.element:v=h,j.createElement(Hy,{match:u,routeContext:{outlet:h,matches:m,isDataRoute:n!=null},children:v})};return n&&(u.route.ErrorBoundary||u.route.errorElement||p===0)?j.createElement(Ky,{location:n.location,revalidation:n.revalidation,component:g,error:x,children:f(),routeContext:{outlet:null,matches:m,isDataRoute:!0}}):f()},null)}var Cm=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Cm||{}),_m=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(_m||{});function qy(e){let t=j.useContext($i);return t||ye(!1),t}function Gy(e){let t=j.useContext(Sm);return t||ye(!1),t}function Jy(e){let t=j.useContext(Gt);return t||ye(!1),t}function Em(e){let t=Jy(),n=t.matches[t.matches.length-1];return n.route.id||ye(!1),n.route.id}function Yy(){var e;let t=j.useContext(Nm),n=Gy(),r=Em();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function Xy(){let{router:e}=qy(Cm.UseNavigateStable),t=Em(_m.UseNavigateStable),n=j.useRef(!1);return bm(()=>{n.current=!0}),j.useCallback(function(s,a){a===void 0&&(a={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,Js({fromRouteId:t},a)))},[e,t])}const Sd={};function Zy(e,t,n){Sd[e]||(Sd[e]=!0)}function eg(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function tg(e){return $y(e.context)}function ht(e){ye(!1)}function ng(e){let{basename:t="/",children:n=null,location:r,navigationType:s=mn.Pop,navigator:a,static:l=!1,future:o}=e;da()&&ye(!1);let c=t.replace(/^\/*/,"/"),d=j.useMemo(()=>({basename:c,navigator:a,static:l,future:Js({v7_relativeSplatPath:!1},o)}),[c,o,a,l]);typeof r=="string"&&(r=ns(r));let{pathname:h="/",search:u="",hash:p="",state:x=null,key:k="default"}=r,g=j.useMemo(()=>{let S=Jr(h,c);return S==null?null:{location:{pathname:S,search:u,hash:p,state:x,key:k},navigationType:s}},[c,h,u,p,x,k,s]);return g==null?null:j.createElement(Rn.Provider,{value:d},j.createElement(Ui.Provider,{children:n,value:g}))}function rg(e){let{children:t,location:n}=e;return Uy(Mo(t),n)}new Promise(()=>{});function Mo(e,t){t===void 0&&(t=[]);let n=[];return j.Children.forEach(e,(r,s)=>{if(!j.isValidElement(r))return;let a=[...t,s];if(r.type===j.Fragment){n.push.apply(n,Mo(r.props.children,a));return}r.type!==ht&&ye(!1),!r.props.index||!r.props.children||ye(!1);let l={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Mo(r.props.children,a)),n.push(l)}),n}/** + * React Router DOM v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function ki(){return ki=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[s]=e[s]);return n}function sg(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ag(e,t){return e.button===0&&(!t||t==="_self")&&!sg(e)}const ig=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],lg=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],og="6";try{window.__reactRouterVersion=og}catch{}const cg=j.createContext({isTransitioning:!1}),ug="startTransition",Nd=xp[ug];function dg(e){let{basename:t,children:n,future:r,window:s}=e,a=j.useRef();a.current==null&&(a.current=dy({window:s,v5Compat:!0}));let l=a.current,[o,c]=j.useState({action:l.action,location:l.location}),{v7_startTransition:d}=r||{},h=j.useCallback(u=>{d&&Nd?Nd(()=>c(u)):c(u)},[c,d]);return j.useLayoutEffect(()=>l.listen(h),[l,h]),j.useEffect(()=>eg(r),[r]),j.createElement(ng,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const fg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",hg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Pn=j.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:a,replace:l,state:o,target:c,to:d,preventScrollReset:h,viewTransition:u}=t,p=Pm(t,ig),{basename:x}=j.useContext(Rn),k,g=!1;if(typeof d=="string"&&hg.test(d)&&(k=d,fg))try{let v=new URL(window.location.href),w=d.startsWith("//")?new URL(v.protocol+d):new URL(d),C=Jr(w.pathname,x);w.origin===v.origin&&C!=null?d=C+w.search+w.hash:g=!0}catch{}let S=Iy(d,{relative:s}),m=pg(d,{replace:l,state:o,target:c,preventScrollReset:h,relative:s,viewTransition:u});function f(v){r&&r(v),v.defaultPrevented||m(v)}return j.createElement("a",ki({},p,{href:k||S,onClick:g||a?r:f,ref:n,target:c}))}),Tm=j.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:s=!1,className:a="",end:l=!1,style:o,to:c,viewTransition:d,children:h}=t,u=Pm(t,lg),p=Bi(c,{relative:u.relative}),x=rs(),k=j.useContext(Sm),{navigator:g,basename:S}=j.useContext(Rn),m=k!=null&&vg(p)&&d===!0,f=g.encodeLocation?g.encodeLocation(p).pathname:p.pathname,v=x.pathname,w=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;s||(v=v.toLowerCase(),w=w?w.toLowerCase():null,f=f.toLowerCase()),w&&S&&(w=Jr(w,S)||w);const C=f!=="/"&&f.endsWith("/")?f.length-1:f.length;let b=v===f||!l&&v.startsWith(f)&&v.charAt(C)==="/",N=w!=null&&(w===f||!l&&w.startsWith(f)&&w.charAt(f.length)==="/"),_={isActive:b,isPending:N,isTransitioning:m},F=b?r:void 0,O;typeof a=="function"?O=a(_):O=[a,b?"active":null,N?"pending":null,m?"transitioning":null].filter(Boolean).join(" ");let B=typeof o=="function"?o(_):o;return j.createElement(Pn,ki({},u,{"aria-current":F,className:O,ref:n,style:B,to:c,viewTransition:d}),typeof h=="function"?h(_):h)});var zo;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(zo||(zo={}));var bd;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(bd||(bd={}));function mg(e){let t=j.useContext($i);return t||ye(!1),t}function pg(e,t){let{target:n,replace:r,state:s,preventScrollReset:a,relative:l,viewTransition:o}=t===void 0?{}:t,c=cr(),d=rs(),h=Bi(e,{relative:l});return j.useCallback(u=>{if(ag(u,n)){u.preventDefault();let p=r!==void 0?r:wi(d)===wi(h);c(e,{replace:p,state:s,preventScrollReset:a,relative:l,viewTransition:o})}},[d,c,h,r,s,n,e,a,l,o])}function vg(e,t){t===void 0&&(t={});let n=j.useContext(cg);n==null&&ye(!1);let{basename:r}=mg(zo.useViewTransitionState),s=Bi(e,{relative:t.relative});if(!n.isTransitioning)return!1;let a=Jr(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Jr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Ro(s.pathname,l)!=null||Ro(s.pathname,a)!=null}/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var xg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const yg=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),Q=(e,t)=>{const n=j.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:a=2,absoluteStrokeWidth:l,className:o="",children:c,...d},h)=>j.createElement("svg",{ref:h,...xg,width:s,height:s,stroke:r,strokeWidth:l?Number(a)*24/Number(s):a,className:["lucide",`lucide-${yg(e)}`,o].join(" "),...d},[...t.map(([u,p])=>j.createElement(u,p)),...Array.isArray(c)?c:[c]]));return n.displayName=`${e}`,n};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gg=Q("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Om=Q("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const jg=Q("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const wg=Q("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kg=Q("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lm=Q("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Sg=Q("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ng=Q("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ys=Q("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bg=Q("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cg=Q("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rm=Q("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _g=Q("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Eg=Q("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pg=Q("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cd=Q("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mm=Q("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Tg=Q("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Og=Q("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lg=Q("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rg=Q("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Uc=Q("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mg=Q("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zg=Q("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ha=Q("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zm=Q("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fg=Q("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ig=Q("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xs=Q("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bc=Q("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dg=Q("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ag=Q("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fm=Q("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Im=Q("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $g=Q("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _d=Q("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ug=Q("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bg=Q("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qc=Q("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dm=Q("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qg=Q("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Am=Q("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qi=Q("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),Vg={},Ed=e=>{let t;const n=new Set,r=(h,u)=>{const p=typeof h=="function"?h(t):h;if(!Object.is(p,t)){const x=t;t=u??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(k=>k(t,x))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>d,subscribe:h=>(n.add(h),()=>n.delete(h)),destroy:()=>{(Vg?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(r,s,c);return c},Kg=e=>e?Ed(e):Ed;var $m={exports:{}},Um={},Bm={exports:{}},Qm={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Yr=j;function Hg(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Wg=typeof Object.is=="function"?Object.is:Hg,qg=Yr.useState,Gg=Yr.useEffect,Jg=Yr.useLayoutEffect,Yg=Yr.useDebugValue;function Xg(e,t){var n=t(),r=qg({inst:{value:n,getSnapshot:t}}),s=r[0].inst,a=r[1];return Jg(function(){s.value=n,s.getSnapshot=t,wl(s)&&a({inst:s})},[e,n,t]),Gg(function(){return wl(s)&&a({inst:s}),e(function(){wl(s)&&a({inst:s})})},[e]),Yg(n),n}function wl(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Wg(e,n)}catch{return!0}}function Zg(e,t){return t()}var e0=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Zg:Xg;Qm.useSyncExternalStore=Yr.useSyncExternalStore!==void 0?Yr.useSyncExternalStore:e0;Bm.exports=Qm;var t0=Bm.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Vi=j,n0=t0;function r0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var s0=typeof Object.is=="function"?Object.is:r0,a0=n0.useSyncExternalStore,i0=Vi.useRef,l0=Vi.useEffect,o0=Vi.useMemo,c0=Vi.useDebugValue;Um.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var a=i0(null);if(a.current===null){var l={hasValue:!1,value:null};a.current=l}else l=a.current;a=o0(function(){function c(x){if(!d){if(d=!0,h=x,x=r(x),s!==void 0&&l.hasValue){var k=l.value;if(s(k,x))return u=k}return u=x}if(k=u,s0(h,x))return k;var g=r(x);return s!==void 0&&s(k,g)?(h=x,k):(h=x,u=g)}var d=!1,h,u,p=n===void 0?null:n;return[function(){return c(t())},p===null?void 0:function(){return c(p())}]},[t,n,r,s]);var o=a0(e,a[0],a[1]);return l0(function(){l.hasValue=!0,l.value=o},[o]),c0(o),o};$m.exports=Um;var u0=$m.exports;const d0=Wd(u0),Vm={},{useDebugValue:f0}=Vo,{useSyncExternalStoreWithSelector:h0}=d0;let Pd=!1;const m0=e=>e;function p0(e,t=m0,n){(Vm?"production":void 0)!=="production"&&n&&!Pd&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Pd=!0);const r=h0(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return f0(r),r}const Td=e=>{(Vm?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?Kg(e):e,n=(r,s)=>p0(t,r,s);return Object.assign(n,t),n},Ki=e=>e?Td(e):Td,Hi="/api",Vc="flow_auth_token",Kc="flow_auth_expires",Hc="flow_auth_username";function Zs(){const e=localStorage.getItem(Vc),t=localStorage.getItem(Kc);return!e||!t?null:new Date(t)<=new Date?(Yn(),null):e}function Od(e,t,n){localStorage.setItem(Vc,e),localStorage.setItem(Kc,t),localStorage.setItem(Hc,n)}function Yn(){localStorage.removeItem(Vc),localStorage.removeItem(Kc),localStorage.removeItem(Hc)}function Wc(){return localStorage.getItem(Hc)}let ir=null;function v0(e){ir=e}async function U(e,t,n=!1){const r={"Content-Type":"application/json",...t==null?void 0:t.headers};if(!n){const a=Zs();a&&(r.Authorization=`Bearer ${a}`)}const s=await fetch(`${Hi}${e}`,{...t,headers:r});if(s.status===401){Yn(),ir&&ir();const a=await s.json().catch(()=>({detail:"Not authenticated"}));throw new Error(a.detail||"Not authenticated")}if(!s.ok){const a=await s.json().catch(()=>({detail:s.statusText}));throw new Error(a.detail||"API request failed")}if(s.status!==204)return s.json()}const dr={getConfig:()=>U("/auth/config",void 0,!0),login:e=>U("/auth/login",{method:"POST",body:JSON.stringify(e)},!0),getGitHubAuthUrl:()=>`${Hi}/auth/github`,getCurrentUser:()=>U("/auth/me"),logout:()=>U("/auth/logout",{method:"POST"})},Xn={list:e=>{const t=new URLSearchParams;e!=null&&e.include_auto_generated&&t.set("include_auto_generated","true"),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return U(`/configs${n?`?${n}`:""}`)},get:e=>U(`/configs/${e}`),create:e=>U("/configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/configs/${e}`,{method:"DELETE"})},Et={list:e=>{const t=new URLSearchParams;e!=null&&e.category&&t.set("category",e.category),e!=null&&e.suite&&t.set("suite",e.suite);const n=t.toString();return U(`/tasks${n?`?${n}`:""}`)},get:e=>U(`/tasks/${e}`),create:e=>U("/tasks",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/tasks/${e}`,{method:"DELETE"}),listSuites:()=>U("/tasks/suites"),importSuite:e=>U(`/tasks/import-suite?suite_name=${encodeURIComponent(e)}`,{method:"POST"})},Ut={list:e=>{const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return U(`/jobs${n?`?${n}`:""}`)},get:e=>U(`/jobs/${e}`),create:e=>U("/jobs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/jobs/${e}`,{method:"PUT",body:JSON.stringify(t)}),start:async function*(e){var o;const t={},n=Zs();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Hi}/jobs/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Yn(),ir&&ir(),new Error("Not authenticated");if(!r.ok)throw new Error("Failed to start job");const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const a=new TextDecoder;let l="";for(;;){const{done:c,value:d}=await s.read();if(c)break;l+=a.decode(d,{stream:!0});const h=l.split(` +`);l=h.pop()||"";for(const u of h)u.startsWith("data: ")&&(yield JSON.parse(u.slice(6)))}},cancel:e=>U(`/jobs/${e}/cancel`,{method:"POST"}),delete:e=>U(`/jobs/${e}`,{method:"DELETE"})},Fo={list:e=>{const t=new URLSearchParams;e!=null&&e.job_id&&t.set("job_id",e.job_id),e!=null&&e.candidate_name&&t.set("candidate_name",e.candidate_name),e!=null&&e.task_name&&t.set("task_name",e.task_name),(e==null?void 0:e.is_pareto)!==void 0&&t.set("is_pareto",String(e.is_pareto));const n=t.toString();return U(`/runs${n?`?${n}`:""}`)},get:e=>U(`/runs/${e}`),getJobSummary:e=>U(`/runs/job/${e}/summary`)},Ts={list:e=>{const t=new URLSearchParams;e!=null&&e.agent_id&&t.set("agent_id",e.agent_id),e!=null&&e.limit&&t.set("limit",String(e.limit));const n=t.toString();return U(`/tests${n?`?${n}`:""}`)},get:e=>U(`/tests/${e}`),create:e=>U("/tests",{method:"POST",body:JSON.stringify(e)}),start:async function*(e){var o;const t={},n=Zs();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Hi}/tests/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Yn(),ir&&ir(),new Error("Not authenticated");if(!r.ok){const c=await r.json().catch(()=>({detail:"Failed to start test"}));throw new Error(c.detail||"Failed to start test")}const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const a=new TextDecoder;let l="";for(;;){const{done:c,value:d}=await s.read();if(c)break;l+=a.decode(d,{stream:!0});const h=l.split(` +`);l=h.pop()||"";for(const u of h)u.startsWith("data: ")&&(yield JSON.parse(u.slice(6)))}},cancel:e=>U(`/tests/${e}/cancel`,{method:"POST"}),delete:e=>U(`/tests/${e}`,{method:"DELETE"})},x0={list:()=>U("/llm-configs"),get:e=>U(`/llm-configs/${e}`),getDefault:()=>U("/llm-configs/default"),create:e=>U("/llm-configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/llm-configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/llm-configs/${e}`,{method:"DELETE"}),setDefault:e=>U(`/llm-configs/${e}/set-default`,{method:"POST"}),test:e=>U(`/llm-configs/${e}/test`,{method:"POST"})},y0={list:()=>U("/tools"),get:e=>U(`/tools/${e}`)},Km={getAgentSchema:()=>U("/schema/agent")},g0={list:()=>U("/deployments"),get:e=>U(`/deployments/${e}`),delete:e=>U(`/deployments/${e}`,{method:"DELETE"})},j0={start:e=>U("/evaluate",{method:"POST",body:JSON.stringify(e)})},Io={design:e=>U("/experiment/design",{method:"POST",body:JSON.stringify(e)}),importYaml:e=>U("/experiment/import-yaml",{method:"POST",body:JSON.stringify(e)}),validate:e=>U("/experiment/validate",{method:"POST",body:JSON.stringify(e)}),generateCandidates:e=>U("/experiment/generate-candidates",{method:"POST",body:JSON.stringify(e)})},qc=Ki((e,t)=>(v0(()=>{e({isAuthenticated:!1,user:null,error:"Session expired. Please log in again."})}),{authConfig:null,isLoadingConfig:!0,isAuthenticated:!1,isLoading:!1,user:null,error:null,loadAuthConfig:async()=>{e({isLoadingConfig:!0});try{const n=await dr.getConfig();if(e({authConfig:n,isLoadingConfig:!1}),n.enabled){const r=Zs(),s=Wc();if(r&&s)try{const a=await dr.getCurrentUser();e({isAuthenticated:!0,user:a})}catch{Yn(),e({isAuthenticated:!1,user:null})}}else e({isAuthenticated:!0,user:{username:"anonymous",auth_mode:"none"}})}catch(n){console.error("Failed to load auth config:",n),e({isLoadingConfig:!1,error:"Failed to connect to server"})}},login:async(n,r)=>{e({isLoading:!0,error:null});try{const s=await dr.login({username:n,password:r});return Od(s.access_token,s.expires_at,s.username),e({isAuthenticated:!0,isLoading:!1,user:{username:s.username,auth_mode:"basic"}}),!0}catch(s){return e({isLoading:!1,error:s instanceof Error?s.message:"Login failed"}),!1}},loginWithGitHub:()=>{window.location.href=dr.getGitHubAuthUrl()},handleOAuthCallback:()=>{const n=new URLSearchParams(window.location.search),r=n.get("auth_error");if(r)return e({error:r}),window.history.replaceState({},"",window.location.pathname),!0;if(n.get("auth_callback")==="true"){const s=n.get("token"),a=n.get("expires_at"),l=n.get("username");return s&&a&&l&&(Od(s,a,l),e({isAuthenticated:!0,user:{username:l,auth_mode:"github"}})),window.history.replaceState({},"",window.location.pathname),!0}return!1},logout:async()=>{try{await dr.logout()}catch{}Yn(),e({isAuthenticated:!1,user:null,error:null})},checkAuth:async()=>{const{authConfig:n}=t();if(!(n!=null&&n.enabled)){e({isAuthenticated:!0});return}if(!Zs()){e({isAuthenticated:!1,user:null});return}try{const s=await dr.getCurrentUser();e({isAuthenticated:!0,user:s})}catch{Yn(),e({isAuthenticated:!1,user:null})}},clearError:()=>e({error:null})}));function K({variant:e="secondary",size:t="md",className:n="",icon:r,iconRight:s,loading:a=!1,children:l,disabled:o,...c}){const d="font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1.5 rounded-md",h={primary:"bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)]",secondary:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)] hover:bg-[var(--border)]",danger:"bg-[var(--error)] text-white hover:bg-red-600",ghost:"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"},u={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm"},p=t==="sm"?14:16;return i.jsxs("button",{className:`${d} ${h[e]} ${u[t]} ${n}`,disabled:o||a,...c,children:[a?i.jsx(ha,{size:p,className:"animate-spin"}):r?i.jsx(r,{size:p}):null,l,s&&!a&&i.jsx(s,{size:p})]})}const w0={};function k0(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var a;const l=c=>c===null?null:JSON.parse(c,void 0),o=(a=n.getItem(s))!=null?a:null;return o instanceof Promise?o.then(l):l(o)},setItem:(s,a)=>n.setItem(s,JSON.stringify(a,void 0)),removeItem:s=>n.removeItem(s)}}const ea=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return ea(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return ea(r)(n)}}}},S0=(e,t)=>(n,r,s)=>{let a={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:S=>S,version:0,merge:(S,m)=>({...m,...S}),...t},l=!1;const o=new Set,c=new Set;let d;try{d=a.getStorage()}catch{}if(!d)return e((...S)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...S)},r,s);const h=ea(a.serialize),u=()=>{const S=a.partialize({...r()});let m;const f=h({state:S,version:a.version}).then(v=>d.setItem(a.name,v)).catch(v=>{m=v});if(m)throw m;return f},p=s.setState;s.setState=(S,m)=>{p(S,m),u()};const x=e((...S)=>{n(...S),u()},r,s);let k;const g=()=>{var S;if(!d)return;l=!1,o.forEach(f=>f(r()));const m=((S=a.onRehydrateStorage)==null?void 0:S.call(a,r()))||void 0;return ea(d.getItem.bind(d))(a.name).then(f=>{if(f)return a.deserialize(f)}).then(f=>{if(f)if(typeof f.version=="number"&&f.version!==a.version){if(a.migrate)return a.migrate(f.state,f.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return f.state}).then(f=>{var v;return k=a.merge(f,(v=r())!=null?v:x),n(k,!0),u()}).then(()=>{m==null||m(k,void 0),l=!0,c.forEach(f=>f(k))}).catch(f=>{m==null||m(void 0,f)})};return s.persist={setOptions:S=>{a={...a,...S},S.getStorage&&(d=S.getStorage())},clearStorage:()=>{d==null||d.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>g(),hasHydrated:()=>l,onHydrate:S=>(o.add(S),()=>{o.delete(S)}),onFinishHydration:S=>(c.add(S),()=>{c.delete(S)})},g(),k||x},N0=(e,t)=>(n,r,s)=>{let a={storage:k0(()=>localStorage),partialize:g=>g,version:0,merge:(g,S)=>({...S,...g}),...t},l=!1;const o=new Set,c=new Set;let d=a.storage;if(!d)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...g)},r,s);const h=()=>{const g=a.partialize({...r()});return d.setItem(a.name,{state:g,version:a.version})},u=s.setState;s.setState=(g,S)=>{u(g,S),h()};const p=e((...g)=>{n(...g),h()},r,s);s.getInitialState=()=>p;let x;const k=()=>{var g,S;if(!d)return;l=!1,o.forEach(f=>{var v;return f((v=r())!=null?v:p)});const m=((S=a.onRehydrateStorage)==null?void 0:S.call(a,(g=r())!=null?g:p))||void 0;return ea(d.getItem.bind(d))(a.name).then(f=>{if(f)if(typeof f.version=="number"&&f.version!==a.version){if(a.migrate)return[!0,a.migrate(f.state,f.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,f.state];return[!1,void 0]}).then(f=>{var v;const[w,C]=f;if(x=a.merge(C,(v=r())!=null?v:p),n(x,!0),w)return h()}).then(()=>{m==null||m(x,void 0),x=r(),l=!0,c.forEach(f=>f(x))}).catch(f=>{m==null||m(void 0,f)})};return s.persist={setOptions:g=>{a={...a,...g},g.storage&&(d=g.storage)},clearStorage:()=>{d==null||d.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>k(),hasHydrated:()=>l,onHydrate:g=>(o.add(g),()=>{o.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},a.skipHydration||k(),x||p},b0=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((w0?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),S0(e,t)):N0(e,t),Hm=b0,C0=Ki()(Hm((e,t)=>({theme:"light",setTheme:n=>{document.documentElement.setAttribute("data-theme",n),e({theme:n})},toggleTheme:()=>{const n=t().theme==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",n),e({theme:n})}}),{name:"flow-theme",onRehydrateStorage:()=>e=>{e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}}));function _0(){const{theme:e,toggleTheme:t}=C0();return i.jsx("button",{onClick:t,className:"p-2 rounded-md text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--accent)]","aria-label":`Switch to ${e==="dark"?"light":"dark"} mode`,title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:e==="dark"?i.jsx(Ug,{size:16}):i.jsx(Ig,{size:16})})}const E0=Ki()(Hm((e,t)=>({sidebarCollapsed:!1,toggleSidebar:()=>{e({sidebarCollapsed:!t().sidebarCollapsed})},setSidebarCollapsed:n=>{e({sidebarCollapsed:n})}}),{name:"flow-layout"})),P0=[{path:"/agents",label:"Agents",icon:kg},{path:"/jobs",label:"Experiments",icon:Tg},{path:"/tasks",label:"Datasets",icon:Pg}];function T0(){const e=rs(),{sidebarCollapsed:t,toggleSidebar:n}=E0(),r=s=>s==="/agents"?e.pathname==="/"||e.pathname==="/agents"||e.pathname.startsWith("/agents/")||e.pathname.startsWith("/deployments/"):s==="/jobs"?e.pathname.startsWith("/jobs")||e.pathname.startsWith("/runs"):e.pathname.startsWith(s);return i.jsxs("aside",{className:` + flex flex-col border-r border-[var(--border)] bg-[var(--bg-secondary)] + transition-all duration-200 + ${t?"w-14":"w-56"} + `,children:[i.jsx("nav",{className:"flex-1 py-2",children:P0.map(s=>{const a=r(s.path);return i.jsxs(Tm,{to:s.path,title:t?s.label:void 0,className:` + flex items-center gap-3 px-4 py-2.5 text-sm transition-colors relative + ${a?"text-[var(--accent)] bg-[var(--accent-dim)] font-medium":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"} + `,children:[a&&i.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-r bg-[var(--accent)]"}),i.jsx(s.icon,{size:18}),!t&&i.jsx("span",{children:s.label})]},s.path)})}),i.jsx("button",{onClick:n,className:"flex items-center justify-center p-3 border-t border-[var(--border)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",title:t?"Expand sidebar":"Collapse sidebar",children:t?i.jsx(Cg,{size:16}):i.jsx(bg,{size:16})})]})}function O0(){const{authConfig:e,user:t,logout:n}=qc(),r=async()=>{await n()};return i.jsxs("div",{className:"h-screen flex flex-col",children:[i.jsx("header",{className:"border-b border-[var(--border)] bg-[var(--bg-secondary)] shrink-0",children:i.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between",children:[i.jsxs(Tm,{to:"/",className:"text-lg font-semibold text-[var(--accent)] flex items-center gap-2 hover:opacity-80",children:[i.jsx(Qi,{size:20}),"Flow",i.jsx("span",{className:"text-[var(--text-secondary)] font-normal",children:"/optimize"})]}),i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(_0,{}),(e==null?void 0:e.enabled)&&t&&i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[i.jsx(Dm,{size:14}),i.jsx("span",{children:t.username})]}),i.jsx(K,{variant:"ghost",size:"sm",icon:Fg,onClick:r,title:"Sign out",children:"Sign out"})]})]})]})}),i.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[i.jsx(T0,{}),i.jsx("main",{className:"flex-1 overflow-y-auto bg-[var(--bg-primary)]",children:i.jsx("div",{className:"p-6",children:i.jsx(tg,{})})})]})]})}const L0=["maf","miniagent","langgraph"],R0={maf:"Microsoft Agent Framework",miniagent:"MiniAgent",langgraph:"LangGraph"},M0={openai:"OpenAI",azure_openai:"Azure OpenAI",anthropic:"Anthropic",ollama:"Ollama",custom:"Custom (OpenAI-compatible)"};function J({children:e,variant:t="default"}){const n={default:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)]",success:"bg-[var(--badge-success-bg)] text-[var(--badge-success-text)] border border-[var(--badge-success-border)]",warning:"bg-[var(--badge-warning-bg)] text-[var(--badge-warning-text)] border border-[var(--badge-warning-border)]",error:"bg-[var(--badge-error-bg)] text-[var(--badge-error-text)] border border-[var(--badge-error-border)]",info:"bg-[var(--badge-info-bg)] text-[var(--badge-info-text)] border border-[var(--badge-info-border)]"};return i.jsx("span",{className:`inline-block px-2 py-0.5 text-xs font-medium rounded-md ${n[t]}`,children:e})}const z0={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"};function ss({isOpen:e,onClose:t,title:n,children:r,footer:s,size:a="md"}){return j.useEffect(()=>{const l=o=>{o.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",l),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",l),document.body.style.overflow=""}},[e,t]),e?i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[i.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),i.jsxs("div",{className:`relative bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg ${z0[a]} w-full mx-4 max-h-[80vh] flex flex-col`,children:[i.jsxs("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-b border-[var(--border)] px-4 py-3 flex items-center justify-between",children:[i.jsx("h2",{className:"font-semibold",children:n}),i.jsx("button",{onClick:t,className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"×"})]}),i.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r}),s&&i.jsx("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-t border-[var(--border)] px-4 py-3",children:s})]})]}):null}function pn({label:e,className:t="",...n}){return i.jsxs("div",{className:"space-y-1",children:[e&&i.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),i.jsx("input",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] ${t}`,...n})]})}function F0({label:e,className:t="",...n}){return i.jsxs("div",{className:"space-y-1",children:[e&&i.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),i.jsx("textarea",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] resize-y min-h-[100px] ${t}`,...n})]})}function Si({label:e,className:t="",...n}){return i.jsxs("label",{className:`flex items-center gap-2 cursor-pointer ${t}`,children:[i.jsx("input",{type:"checkbox",className:"w-4 h-4 bg-[var(--bg-primary)] border border-[var(--border)] rounded accent-[var(--accent)]",...n}),i.jsx("span",{className:"text-sm",children:e})]})}function Wm({columns:e,data:t,onRowClick:n,searchable:r=!1,searchPlaceholder:s="Search...",searchFilter:a,emptyMessage:l="No items found",emptyIcon:o}){const[c,d]=j.useState(""),[h,u]=j.useState(null),[p,x]=j.useState("asc"),k=j.useMemo(()=>{let S=t;if(r&&c&&a&&(S=S.filter(m=>a(m,c))),h){const m=e.find(f=>f.key===h);m!=null&&m.sortValue&&(S=[...S].sort((f,v)=>{const w=m.sortValue(f),C=m.sortValue(v),b=wC?1:0;return p==="asc"?b:-b}))}return S},[t,c,a,r,h,p,e]),g=S=>{const m=e.find(f=>f.key===S);m!=null&&m.sortable&&(h===S?x(p==="asc"?"desc":"asc"):(u(S),x("asc")))};return i.jsxs("div",{children:[r&&i.jsxs("div",{className:"mb-4 relative max-w-sm",children:[i.jsx(Ag,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]"}),i.jsx("input",{type:"text",placeholder:s,value:c,onChange:S=>d(S.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md pl-9 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]"})]}),k.length===0?i.jsxs("div",{className:"text-center py-16 text-[var(--text-secondary)]",children:[o&&i.jsx("div",{className:"mb-3 flex justify-center",children:o}),i.jsx("p",{children:l})]}):i.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsx("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:e.map(S=>i.jsx("th",{onClick:()=>g(S.key),className:`text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider ${S.sortable?"cursor-pointer hover:text-[var(--text-primary)]":""} ${S.className||""}`,children:i.jsxs("span",{className:"inline-flex items-center gap-1",children:[S.header,S.sortable&&h===S.key&&i.jsx("span",{children:p==="asc"?"↑":"↓"})]})},S.key))})}),i.jsx("tbody",{children:k.map((S,m)=>i.jsx("tr",{onClick:()=>n==null?void 0:n(S),className:`border-b border-[var(--border)] last:border-b-0 transition-colors ${n?"cursor-pointer hover:bg-[var(--bg-tertiary)]":""}`,children:e.map(f=>i.jsx("td",{className:`px-4 py-3 ${f.className||""}`,children:f.render(S)},f.key))},m))})]})})]})}function I0({variations:e,onChange:t,strategies:n,availableStrategies:r}){const s=r??Object.keys(n),a=()=>{const d=e.map(x=>x.strategy),h=s.find(x=>!d.includes(x))||"none",u=n[h],p={strategy:h};if(u!=null&&u.params)for(const[x,k]of Object.entries(u.params))k.default!==void 0&&(p[x]=k.default);t([...e,p])},l=d=>{t(e.filter((h,u)=>u!==d))},o=(d,h)=>{t(e.map((u,p)=>p===d?{...u,...h}:u))},c=(d,h)=>{const u=n[h],p={strategy:h};if(u!=null&&u.params)for(const[x,k]of Object.entries(u.params))k.default!==void 0&&(p[x]=k.default);o(d,p)};return i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"text-sm font-medium",children:"Compaction Strategies"}),i.jsx(K,{type:"button",variant:"ghost",size:"sm",icon:Bc,onClick:a,disabled:e.length>=s.length,children:"Add"})]}),e.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:'No compaction variations. Click "Add" to test different strategies.'}):i.jsx("div",{className:"space-y-2",children:e.map((d,h)=>{const u=n[d.strategy];return i.jsx("div",{className:"p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsxs("div",{className:"flex-1 space-y-2",children:[i.jsx("select",{className:"w-full px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:d.strategy,onChange:p=>c(h,p.target.value),children:s.map(p=>{var x;return i.jsx("option",{value:p,children:((x=n[p])==null?void 0:x.label)||p},p)})}),(u==null?void 0:u.description)&&i.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:u.description}),(u==null?void 0:u.params)&&Object.keys(u.params).length>0&&i.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:Object.entries(u.params).map(([p,x])=>i.jsx(D0,{name:p,schema:x,value:d[p],onChange:k=>o(h,{[p]:k})},p))})]}),i.jsx("button",{type:"button",onClick:()=>l(h),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:i.jsx(Am,{size:16})})]})},h)})})]})}function D0({name:e,schema:t,value:n,onChange:r}){const s=e.replace(/_/g," ");return t.type==="boolean"?i.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[i.jsx("input",{type:"checkbox",checked:!!(n??t.default),onChange:a=>r(a.target.checked),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"capitalize",children:s})]}):i.jsxs("div",{children:[i.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:s}),i.jsx("input",{type:t.type==="number"?"number":"text",className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-xs",value:String(n!==void 0?n:t.default??""),onChange:a=>{if(t.type==="number"){const l=parseFloat(a.target.value);r(isNaN(l)?t.default:l)}else r(a.target.value)},min:t.min,max:t.max,step:t.max&&t.max<=1?.1:1})]})}function A0({variations:e,onChange:t,providers:n}){const r=()=>{const o=n[0],c={provider:(o==null?void 0:o.name)||"azure_openai",model:(o==null?void 0:o.models[0])||"gpt-4o"};t([...e,c])},s=o=>{t(e.filter((c,d)=>d!==o))},a=(o,c)=>{t(e.map((d,h)=>h===o?{...d,...c}:d))},l=(o,c)=>{const d=n.find(h=>h.name===c);a(o,{provider:c,model:(d==null?void 0:d.models[0])||""})};return i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"text-sm font-medium",children:"LLM Configurations"}),i.jsx(K,{type:"button",variant:"ghost",size:"sm",icon:Bc,onClick:r,children:"Add"})]}),e.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:`Uses agent's default LLM. Click "Add" to test different models.`}):i.jsx("div",{className:"space-y-2",children:e.map((o,c)=>{const d=n.find(h=>h.name===o.provider);return i.jsxs("div",{className:"flex items-center gap-2 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[i.jsx("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.provider,onChange:h=>l(c,h.target.value),children:n.map(h=>i.jsx("option",{value:h.name,children:h.label},h.name))}),d&&d.models.length>0?i.jsxs("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:h=>a(c,{model:h.target.value}),children:[d.models.map(h=>i.jsx("option",{value:h,children:h},h)),!d.models.includes(o.model)&&o.model&&i.jsx("option",{value:o.model,children:o.model})]}):i.jsx("input",{type:"text",className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:h=>a(c,{model:h.target.value}),placeholder:"Model ID"}),i.jsx("button",{type:"button",onClick:()=>s(c),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:i.jsx(Am,{size:16})})]},c)})})]})}const Do={compaction:[],tools:[],llm_config:[],instructions:[],instruction_strategies:[]};function $0({agentId:e,agentName:t,agentFramework:n="maf",taskSuite:r,taskCount:s,schema:a,onVariationsChange:l,parallel:o,onParallelChange:c,budget:d,onBudgetChange:h,useLlmEval:u,onUseLlmEvalChange:p}){const[x,k]=j.useState(Do),[g,S]=j.useState(!1),[m,f]=j.useState(""),[v,w]=j.useState(null),C=a.frameworks[n],b=(C==null?void 0:C.compaction_strategies)||Object.keys(a.compaction_strategies),N=a.tool_presets||[],_=a.llm_providers||[],O=(()=>{let L=1;x.compaction.length>0&&(L*=x.compaction.length),x.tools.length>0&&(L*=x.tools.length),x.llm_config.length>0&&(L*=x.llm_config.length);const V=x.instructions.length+x.instruction_strategies.reduce((ee,R)=>ee+R.max_candidates,0);return V>0&&(L*=V),Math.min(L,d)})(),B=O*s,G=L=>{k(L),l==null||l(L)},re=Je({mutationFn:L=>Io.design(L),onSuccess:L=>{f(L.yaml_content),S(!0)}}),le=Je({mutationFn:L=>Io.validate(L),onSuccess:L=>{w({valid:L.valid,errors:L.errors,warnings:L.warnings})}}),D=()=>({base_agent_id:e,task_suite:r,variations:x,parallel:o,budget:d,use_llm_eval:u}),q=()=>{re.mutate(D())},X=()=>{le.mutate(D())},P=()=>{const L=new Blob([m],{type:"text/yaml"}),V=URL.createObjectURL(L),ee=document.createElement("a");ee.href=V,ee.download=`${t}_experiment.yaml`,ee.click(),URL.revokeObjectURL(V)},A=x.compaction.length>0||x.tools.length>0||x.llm_config.length>0||x.instructions.length>0||x.instruction_strategies.length>0;return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex flex-wrap gap-2",children:[i.jsxs(J,{variant:"info",children:[O," candidates"]}),i.jsxs(J,{children:[s," tasks"]}),i.jsxs(J,{variant:B>100?"warning":"success",children:[B," total runs"]})]}),i.jsx(I0,{variations:x.compaction,onChange:L=>G({...x,compaction:L}),strategies:a.compaction_strategies,availableStrategies:b}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("label",{className:"text-sm font-medium",children:"Tool Presets"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(L=>i.jsxs("label",{className:`flex items-center gap-2 px-3 py-1.5 border rounded cursor-pointer transition-colors ${x.tools.includes(L.name)?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[i.jsx("input",{type:"checkbox",checked:x.tools.includes(L.name),onChange:V=>{const ee=V.target.checked?[...x.tools,L.name]:x.tools.filter(R=>R!==L.name);G({...x,tools:ee})},className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:L.name}),i.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",L.tools.length,")"]})]},L.name))}),x.tools.length>0&&i.jsxs("p",{className:"text-xs text-[var(--text-secondary)]",children:["Selected: ",x.tools.join(", ")]})]}),i.jsx(A0,{variations:x.llm_config,onChange:L=>G({...x,llm_config:L}),providers:_}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-4 space-y-4",children:[i.jsx("h4",{className:"text-sm font-medium",children:"Execution Settings"}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(pn,{label:"Parallel Workers",type:"number",value:o,onChange:L=>c(parseInt(L.target.value)||1),min:1,max:16}),i.jsx(pn,{label:"Budget (max candidates)",type:"number",value:d,onChange:L=>h(parseInt(L.target.value)||100),min:1,max:1e3})]}),i.jsx(Si,{label:"Use LLM evaluation",checked:u,onChange:L=>p(L.target.checked)}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] ml-6 -mt-2",children:u?"LLM-as-Judge scores task completion (0-1)":"Simple pass/fail based on task success"})]}),i.jsxs("div",{className:"flex items-center gap-2 border-t border-[var(--border)] pt-4",children:[i.jsx(K,{variant:"secondary",size:"sm",onClick:X,loading:le.isPending,children:"Validate"}),i.jsx(K,{variant:"secondary",size:"sm",icon:Cd,onClick:q,loading:re.isPending,children:"Export YAML"})]}),v&&i.jsxs("div",{className:`p-3 rounded border ${v.valid?"border-green-500/50 bg-green-500/10":"border-red-500/50 bg-red-500/10"}`,children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[v.valid?i.jsx(Lm,{size:16,className:"text-green-500"}):i.jsx(Om,{size:16,className:"text-red-500"}),i.jsx("span",{className:"font-medium text-sm",children:v.valid?"Configuration valid":"Configuration has issues"})]}),v.errors.length>0&&i.jsx("ul",{className:"text-sm text-red-500 list-disc ml-6",children:v.errors.map((L,V)=>i.jsx("li",{children:L},V))}),v.warnings.length>0&&i.jsx("ul",{className:"text-sm text-yellow-500 list-disc ml-6 mt-1",children:v.warnings.map((L,V)=>i.jsx("li",{children:L},V))})]}),g&&i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-lg shadow-xl max-w-2xl w-full max-h-[80vh] flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border)]",children:[i.jsx("h3",{className:"font-medium",children:"Experiment YAML"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(K,{variant:"secondary",size:"sm",icon:Cd,onClick:P,children:"Download"}),i.jsx(K,{variant:"ghost",size:"sm",onClick:()=>S(!1),children:"Close"})]})]}),i.jsx("pre",{className:"flex-1 overflow-auto p-4 text-xs font-mono bg-[var(--bg-secondary)]",children:m})]})}),!A&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No variations selected. Only the baseline agent will be tested. Add compaction strategies, tool presets, or LLM configs to generate candidates."})]})}function Ld(){const e=cr(),t=qt(),[n,r]=j.useState(!1),[s,a]=j.useState(null),{data:l=[],isLoading:o}=he({queryKey:["configs"],queryFn:()=>Xn.list()}),c=Je({mutationFn:Xn.create,onSuccess:()=>{t.invalidateQueries({queryKey:["configs"]}),r(!1)}}),d=Je({mutationFn:Xn.delete,onSuccess:()=>t.invalidateQueries({queryKey:["configs"]})}),h=[{key:"name",header:"Name",render:u=>i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:u.name})},{key:"framework",header:"Framework",render:u=>i.jsx(J,{children:u.config.framework||"maf"})},{key:"tools",header:"Tools",render:u=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:U0(u.config.tools)})},{key:"compaction",header:"Compaction",render:u=>{const p=u.config.compaction;return!p||p.strategy==="none"?i.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"}):p.strategy==="head_tail"?i.jsxs(J,{children:[p.params.head_size,"/",p.params.tail_size]}):i.jsx(J,{children:p.strategy})}},{key:"created",header:"Created",render:u=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(u.created_at).toLocaleDateString()}),sortable:!0,sortValue:u=>new Date(u.created_at).getTime()},{key:"actions",header:"",className:"w-40",render:u=>i.jsxs("div",{className:"flex items-center gap-2",onClick:p=>p.stopPropagation(),children:[i.jsx(K,{variant:"primary",size:"sm",icon:Qi,onClick:()=>a(u),children:"Optimize"}),i.jsx(K,{variant:"ghost",size:"sm",icon:Qc,title:"Delete",onClick:()=>{confirm(`Delete agent "${u.name}"?`)&&d.mutate(u.id)}})]})}];return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Agents"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Define and optimize your agent configurations."})]}),i.jsx(K,{variant:"primary",icon:Bc,onClick:()=>r(!0),children:"Create agent"})]}),o?i.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[i.jsx(ha,{size:16,className:"animate-spin"}),"Loading agents..."]}):i.jsx(Wm,{columns:h,data:l,onRowClick:u=>e(`/agents/${u.id}`),searchable:!0,searchPlaceholder:"Search agents",searchFilter:(u,p)=>u.name.toLowerCase().includes(p.toLowerCase())||(u.description||"").toLowerCase().includes(p.toLowerCase()),emptyMessage:"No agents yet. Create your first agent to start optimizing.",emptyIcon:i.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-[var(--bg-tertiary)]",children:i.jsx(Im,{size:24,className:"text-[var(--text-secondary)]"})})}),i.jsx(B0,{isOpen:n,onClose:()=>r(!1),onSubmit:u=>c.mutate(u),isLoading:c.isPending}),s&&i.jsx(Q0,{agent:s,isOpen:!!s,onClose:()=>a(null)})]})}function U0(e){return typeof e=="string"?e:Array.isArray(e)?`[${e.length}]`:e&&typeof e=="object"?`[${Object.keys(e).length}]`:"standard"}function B0({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){var V,ee,R,T,te,pe,be;const s=["read_file","write_file","edit_file","bash","grep","think"],[a,l]=j.useState("preset"),[o,c]=j.useState({name:"",description:"",instructions:null,model:null,compaction:{strategy:"none",params:{}},tools:s,framework:"miniagent",llm_config_id:null}),[d,h]=j.useState(!1),[u,p]=j.useState("preset"),[x,k]=j.useState([...s]),[g,S]=j.useState(!1),{data:m}=he({queryKey:["agent-schema"],queryFn:()=>Km.getAgentSchema()}),{data:f=[]}=he({queryKey:["llm-configs"],queryFn:()=>x0.list()}),{data:v}=he({queryKey:["tools"],queryFn:()=>y0.list()}),w=((V=v==null?void 0:v.tools)==null?void 0:V.map(M=>M.name))??s,C=(v==null?void 0:v.presets)??{},b=Object.keys(C),N=(m==null?void 0:m.frameworks)??{},_=Object.keys(N).length>0?Object.keys(N):L0,F=o.framework||"miniagent",O=((R=(ee=m==null?void 0:m.frameworks)==null?void 0:ee[F])==null?void 0:R.compaction_strategies)??["none","head_tail"],B=(m==null?void 0:m.compaction_strategies)??{},G=(m==null?void 0:m.agent_presets)??[],re=M=>{const H=M.config,dt=H.compaction;n({name:M.name+"-agent",description:M.description,framework:H.framework||"miniagent",tools:H.tools||"standard",compaction:dt||{strategy:"none",params:{}},instructions:H.instructions||null})},le=M=>{if(M.preventDefault(),!o.name.trim())return;const H={...o};u==="custom"&&(H.tools=x),n(H)},D=((T=o.compaction)==null?void 0:T.strategy)!=="none",q=((te=o.compaction)==null?void 0:te.strategy)||"none",X=B[q],P=M=>{k(H=>H.includes(M)?H.filter(dt=>dt!==M):[...H,M])},A=M=>{const H=B[M],dt={};if(H!=null&&H.params)for(const[as,is]of Object.entries(H.params))is.default!==void 0&&(dt[as]=is.default);c({...o,compaction:{strategy:M,params:dt}})},L=a==="custom"?i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(K,{type:"submit",form:"create-agent-form",variant:"primary",disabled:!o.name.trim(),loading:r,children:"Create Agent"})]}):i.jsx("div",{className:"flex justify-end gap-2",children:i.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"})});return i.jsxs(ss,{isOpen:e,onClose:t,title:"Create Agent",footer:L,children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b border-[var(--border)]",children:[i.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${a==="preset"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("preset"),children:"From Preset"}),i.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${a==="custom"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("custom"),children:"Custom"})]}),a==="preset"?i.jsx("div",{className:"space-y-3",children:G.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"Loading presets..."}):G.map(M=>i.jsx("button",{type:"button",className:"w-full text-left p-4 border border-[var(--border)] rounded-lg hover:border-[var(--accent)] hover:bg-[var(--accent)]/5 transition-colors",onClick:()=>re(M),disabled:r,children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("h4",{className:"font-medium",children:M.label}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:M.description}),i.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[M.tags.map(H=>i.jsx(J,{variant:"default",children:H},H)),M.suggested_datasets.length>0&&i.jsxs(J,{variant:"success",children:["datasets: ",M.suggested_datasets.join(", ")]})]})]}),i.jsx(Ys,{size:16,className:"text-[var(--text-secondary)] mt-1 flex-shrink-0"})]})},M.name))}):i.jsxs("form",{id:"create-agent-form",onSubmit:le,className:"space-y-4",children:[i.jsx(pn,{label:"Name",value:o.name,onChange:M=>c({...o,name:M.target.value}),placeholder:"e.g., my-coding-agent",required:!0}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"LLM Configuration"}),i.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.llm_config_id||"",onChange:M=>c({...o,llm_config_id:M.target.value||null}),children:[i.jsx("option",{value:"",children:"Use environment variables"}),f.map(M=>i.jsxs("option",{value:M.id,children:[M.name," (",M0[M.provider],M.model_id?` - ${M.model_id}`:"",")",M.is_default?" (default)":""]},M.id))]}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:f.length===0?"No LLM configs found. Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)":o.llm_config_id?"Uses the selected LLM configuration.":"Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Framework"}),i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.framework||"miniagent",onChange:M=>{const H=M.target.value;c({...o,framework:H,compaction:{strategy:"none",params:{}}})},children:_.map(M=>{var H;return i.jsx("option",{value:M,children:((H=N[M])==null?void 0:H.label)||R0[M]||M},M)})}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((pe=N[F])==null?void 0:pe.description)||(F==="miniagent"?"Lightweight agent with token-aware context management.":F==="langgraph"?"Graph-based workflows with state management.":"Default agent implementation.")})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(Si,{label:"Custom instructions",checked:d,onChange:M=>{h(M.target.checked),M.target.checked||c({...o,instructions:null})}}),i.jsx(Si,{label:"Enable compaction",checked:D,onChange:M=>{if(M.target.checked){const H=O.find(dt=>dt!=="none")||"head_tail";A(H)}else c({...o,compaction:{strategy:"none",params:{}}})}})]}),d&&i.jsx("textarea",{className:"w-full h-32 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono resize-y",value:o.instructions||"",onChange:M=>c({...o,instructions:M.target.value||null}),placeholder:"System prompt / instructions for the agent..."}),D&&i.jsxs("div",{className:"space-y-3 p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Compaction Strategy"}),i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:q,onChange:M=>A(M.target.value),children:O.filter(M=>M!=="none").map(M=>{var H;return i.jsx("option",{value:M,children:((H=B[M])==null?void 0:H.label)||M},M)})}),(X==null?void 0:X.description)&&i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:X.description})]}),(X==null?void 0:X.params)&&Object.keys(X.params).length>0&&i.jsx("div",{className:"grid grid-cols-2 gap-3",children:Object.entries(X.params).map(([M,H])=>{var is;const dt=(is=o.compaction)==null?void 0:is.params[M],as=dt!==void 0?dt:H.default;return i.jsxs("div",{children:[i.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:M.replace(/_/g," ")}),i.jsx("input",{type:"number",className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof as=="number"?as:Number(as)||0,onChange:ep=>{const Jc=parseFloat(ep.target.value);c({...o,compaction:{...o.compaction,params:{...o.compaction.params,[M]:isNaN(Jc)?typeof H.default=="number"?H.default:0:Jc}}})},min:H.min,max:H.max,step:H.max&&H.max<=1?.1:1}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:H.description})]},M)})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm font-medium",children:"Tools"}),i.jsxs("div",{className:"flex gap-4",children:[i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"radio",checked:u==="preset",onChange:()=>p("preset"),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:"Preset"})]}),i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"radio",checked:u==="custom",onChange:()=>p("custom"),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:"Custom"})]})]}),u==="preset"?i.jsxs(i.Fragment,{children:[i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof o.tools=="string"?o.tools:"standard",onChange:M=>c({...o,tools:M.target.value}),children:b.map(M=>i.jsx("option",{value:M,children:M},M))}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((be=C[typeof o.tools=="string"?o.tools:"standard"])==null?void 0:be.join(", "))??""})]}):i.jsx("div",{className:"grid grid-cols-2 gap-1 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:w.map(M=>i.jsxs("label",{className:"flex items-center gap-2 p-1 text-sm cursor-pointer hover:bg-[var(--bg-tertiary)]",children:[i.jsx("input",{type:"checkbox",checked:x.includes(M),onChange:()=>P(M),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"font-mono text-xs",children:M})]},M))})]}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[i.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>S(!g),children:[i.jsx(Ys,{size:14,className:`transition-transform ${g?"rotate-90":""}`}),"More options"]}),g&&i.jsx("div",{className:"mt-3",children:i.jsx(pn,{label:"Description (optional)",value:o.description,onChange:M=>c({...o,description:M.target.value}),placeholder:"Brief description of this agent"})})]})]})]})}function Q0({agent:e,isOpen:t,onClose:n}){var R;const r=cr(),s=qt(),[a,l]=j.useState("ready"),[o,c]=j.useState("quick"),[d,h]=j.useState(!1),[u,p]=j.useState([]),[x,k]=j.useState(!1),[g,S]=j.useState(Do),[m,f]=j.useState(4),[v,w]=j.useState(100),[C,b]=j.useState(!1),[N,_]=j.useState(null),{data:F=[]}=he({queryKey:["tasks"],queryFn:()=>Et.list()}),{data:O=[]}=he({queryKey:["suites"],queryFn:()=>Et.listSuites()}),{data:B}=he({queryKey:["agent-schema"],queryFn:()=>Km.getAgentSchema()}),G=O.map(T=>({value:T.name,label:T.name.charAt(0).toUpperCase()+T.name.slice(1),description:T.description,tasks:T.task_count})),re=Je({mutationFn:Et.importSuite,onSuccess:T=>{s.invalidateQueries({queryKey:["tasks"]}),p(T.map(te=>te.id))}}),le=Je({mutationFn:async T=>{const te=await Ut.create(T);return Ut.start(te.id).next(),te},onSuccess:T=>{s.invalidateQueries({queryKey:["jobs"]}),_(T.id),l("success")}}),q=x?(()=>{let T=1;g.compaction.length>0&&(T*=g.compaction.length),g.tools.length>0&&(T*=g.tools.length),g.llm_config.length>0&&(T*=g.llm_config.length);const te=g.instructions.length+g.instruction_strategies.reduce((pe,be)=>pe+be.max_candidates,0);return te>0&&(T*=te),Math.min(T,v)})():1,X=d?u.length:((R=G.find(T=>T.value===o))==null?void 0:R.tasks)||3,P=q*X,A=async()=>{l("starting");let T=u;if(!d)try{T=(await re.mutateAsync(o)).map(H=>H.id)}catch(M){console.error("Failed to import suite:",M),alert(`Failed to import task suite: ${o}`),l("ready");return}if(T.length===0){alert("No tasks selected. Please select tasks or choose a task suite."),l("ready");return}let te;if(x&&(g.compaction.length>0||g.tools.length>0||g.llm_config.length>0||g.instructions.length>0||g.instruction_strategies.length>0))try{te=(await Io.generateCandidates({base_agent_id:e.id,variations:g,budget:v})).candidate_ids}catch(M){console.error("Failed to generate candidates:",M),alert(`Failed to generate candidates: ${M instanceof Error?M.message:"Unknown error"}`),l("ready");return}else te=[e.id];const be={name:`${e.name} optimization (${te.length} candidates × ${T.length} tasks)`,candidate_ids:te,task_ids:T,parallel:m,use_llm_eval:C};le.mutate(be)},L=T=>{p(te=>te.includes(T)?te.filter(pe=>pe!==T):[...te,T])},V=()=>{l("ready"),_(null),k(!1),S(Do),n()},ee=()=>a==="success"&&N?i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsx(K,{variant:"secondary",onClick:V,children:"Close"}),i.jsx(K,{variant:"primary",icon:Xs,onClick:()=>{V(),r(`/jobs/${N}`)},children:"View Job"})]}):a==="starting"?null:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(K,{variant:"secondary",onClick:n,children:"Cancel"}),i.jsxs(K,{variant:"primary",icon:Xs,onClick:A,disabled:d&&u.length===0,children:["Start Optimization (",P," runs)"]})]});return i.jsx(ss,{isOpen:t,onClose:V,title:`Optimize: ${e.name}`,footer:ee(),size:"lg",children:a==="success"&&N?i.jsxs("div",{className:"flex flex-col items-center py-8",children:[i.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/20 flex items-center justify-center mb-4",children:i.jsx(Qi,{size:24,className:"text-green-500"})}),i.jsx("h3",{className:"text-lg font-medium mb-2",children:"Job Started!"}),i.jsx("p",{className:"text-[var(--text-secondary)] text-center mb-2",children:"Optimization job is now running"}),i.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-3 py-1.5 rounded font-mono",children:["ID: ",N.slice(0,8),"..."]})]}):a==="starting"?i.jsxs("div",{className:"flex flex-col items-center py-8",children:[i.jsx(ha,{size:32,className:"animate-spin text-[var(--accent)] mb-4"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:re.isPending?"Importing tasks...":"Creating optimization job..."})]}):i.jsxs("div",{className:"space-y-5",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Task Suite"}),i.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:d?"__custom__":o,onChange:T=>{T.target.value==="__custom__"?h(!0):(h(!1),c(T.target.value))},children:[G.map(T=>i.jsxs("option",{value:T.value,children:[T.label," (",T.tasks," tasks) — ",T.description]},T.value)),F.length>0&&i.jsx("option",{value:"__custom__",children:"Custom Selection"})]})]}),d&&F.length>0&&i.jsx("div",{className:"max-h-48 overflow-y-auto border border-[var(--border)] rounded p-2 space-y-1",children:F.map(T=>i.jsxs("label",{className:"flex items-center gap-2 p-2 hover:bg-[var(--bg-tertiary)] cursor-pointer rounded",children:[i.jsx("input",{type:"checkbox",checked:u.includes(T.id),onChange:()=>L(T.id),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:T.name}),T.suite&&i.jsx(J,{children:T.suite})]},T.id))}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[i.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>k(!x),children:[i.jsx(Ys,{size:14,className:`transition-transform ${x?"rotate-90":""}`}),"Advanced Settings",x&&i.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"(experiment design, variations, execution)"})]}),x&&B&&i.jsx("div",{className:"mt-4",children:i.jsx($0,{agentId:e.id,agentName:e.name,agentFramework:e.config.framework,taskSuite:d?void 0:o,taskCount:X,schema:B,onVariationsChange:S,parallel:m,onParallelChange:f,budget:v,onBudgetChange:w,useLlmEval:C,onUseLlmEvalChange:b})})]})]})})}function ma({items:e}){return i.jsx("nav",{className:"flex items-center gap-1.5 text-sm mb-4",children:e.map((t,n)=>{const r=n===e.length-1;return i.jsxs("span",{className:"flex items-center gap-1.5",children:[n>0&&i.jsx(Ys,{size:14,className:"text-[var(--text-secondary)]"}),t.path&&!r?i.jsx(Pn,{to:t.path,className:"text-[var(--text-secondary)] hover:text-[var(--accent)] transition-colors",children:t.label}):i.jsx("span",{className:r?"text-[var(--text-primary)] font-medium":"text-[var(--text-secondary)]",children:t.label})]},n)})})}function ge({children:e,className:t="",onClick:n,selected:r=!1,selectable:s=!1}){const a="bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",l=s?"cursor-pointer hover:border-[var(--accent-dim)] transition-colors":"",o=r?"border-[var(--accent)]":"";return i.jsx("div",{className:`${a} ${l} ${o} ${t}`,onClick:n,children:e})}function V0(e){const t=[],n=r=>r.type==="trace_span"&&typeof r.data=="object"&&r.data!==null?r.data:"span_id"in r?r:null;if(Array.isArray(e.spans)){for(const r of e.spans)if(typeof r=="object"&&r!==null){const s=n(r);s&&t.push(s)}}else if(e.span_id)t.push(e);else for(const r in e){const s=e[r];if(typeof s=="object"&&s!==null){const a=n(s);if(a)t.push(a);else if(Array.isArray(s)){for(const l of s)if(typeof l=="object"&&l!==null){const o=n(l);o&&t.push(o)}}}}return t}function qm(e){const t=new Map,n=[];for(const s of e)t.set(s.span_id,{span:s,children:[]});for(const s of e){const a=t.get(s.span_id);s.parent_span_id&&t.has(s.parent_span_id)?t.get(s.parent_span_id).children.push(a):n.push(a)}const r=s=>{s.sort((a,l)=>(a.span.start_time||0)-(l.span.start_time||0)),s.forEach(a=>r(a.children))};return r(n),n}function K0(e){return e.includes("Agent")||e.includes("agent")?"bg-[var(--span-llm-bg)] text-[var(--span-llm-text)]":e.includes("chat")||e.includes("Chat")||e.includes("llm")?"bg-[var(--span-tool-bg)] text-[var(--span-tool-text)]":e.includes("tool")||e.includes("execute")||e.includes("bash")?"bg-[var(--span-agent-bg)] text-[var(--span-agent-text)]":"bg-[var(--span-other-bg)] text-[var(--span-other-text)]"}function H0(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(0)}ms`}function Gc({node:e,depth:t=0}){var u,p;const[n,r]=j.useState(t<2),[s,a]=j.useState(!1),{span:l}=e,o=e.children.length>0,c=(u=l.attributes)==null?void 0:u["gen_ai.usage.input_tokens"],d=(p=l.attributes)==null?void 0:p["gen_ai.usage.output_tokens"],h=c!==void 0||d!==void 0;return i.jsxs("div",{className:"relative",children:[t>0&&i.jsx("div",{className:"absolute left-0 top-0 bottom-0 border-l-2 border-[var(--border)]",style:{marginLeft:`${(t-1)*16+8}px`}}),i.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-1 hover:bg-[var(--bg-primary)] rounded transition-colors cursor-pointer",style:{paddingLeft:`${t*16}px`},onClick:()=>o?r(!n):a(!s),children:[i.jsx("div",{className:"w-4 h-4 flex items-center justify-center text-[var(--text-secondary)]",children:o?n?"▼":"▶":s?"▼":"▶"}),i.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${K0(l.operation_name)}`,children:l.operation_name.replace("ChatAgent.","").replace("invoke_agent ","")}),l.duration_ms!==void 0&&i.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:H0(l.duration_ms)}),h&&i.jsxs("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:[c!==void 0&&i.jsxs("span",{className:"text-blue-400",children:["↑",String(c)]}),c!==void 0&&d!==void 0&&i.jsx("span",{className:"mx-0.5",children:"/"}),d!==void 0&&i.jsxs("span",{className:"text-green-400",children:["↓",String(d)]})]})]}),s&&!o&&i.jsx("div",{className:"ml-4 mt-1 mb-2 p-2 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs",style:{marginLeft:`${t*16+20}px`},children:i.jsxs("div",{className:"space-y-1",children:[l.span_id&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Span ID:"}),i.jsx("span",{className:"font-mono text-xs break-all",children:l.span_id})]}),l.trace_id&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Trace ID:"}),i.jsx("span",{className:"font-mono text-xs break-all",children:l.trace_id})]}),l.status&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Status:"}),i.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs ${l.status==="OK"||l.status==="StatusCode.UNSET"?"bg-[var(--span-pass-bg)] text-[var(--span-pass-text)]":"bg-[var(--span-fail-bg)] text-[var(--span-fail-text)]"}`,children:l.status})]}),Object.keys(l.attributes||{}).length>0&&i.jsxs("div",{className:"mt-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] block mb-1",children:"Attributes:"}),i.jsx("pre",{className:"text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded p-2 overflow-auto max-h-32 whitespace-pre-wrap break-all",children:JSON.stringify(l.attributes,null,2)})]})]})}),o&&n&&i.jsx("div",{children:e.children.map((x,k)=>i.jsx(Gc,{node:x,depth:t+1},x.span.span_id||k))})]})}function Gm({trace:e}){const[t,n]=j.useState("tree"),r=j.useMemo(()=>V0(e),[e]),s=j.useMemo(()=>qm(r),[r]);return Object.keys(e).length===0?null:i.jsxs(ge,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"font-medium",children:"Trace Data"}),i.jsxs("div",{className:"flex gap-1",children:[i.jsx("button",{onClick:()=>n("tree"),className:`px-2 py-1 text-xs rounded ${t==="tree"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Tree"}),i.jsx("button",{onClick:()=>n("raw"),className:`px-2 py-1 text-xs rounded ${t==="raw"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Raw"})]})]}),t==="tree"?r.length>0?i.jsx("div",{className:"border border-[var(--border)] rounded overflow-hidden",children:i.jsxs("div",{className:"p-2",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs(J,{variant:"default",children:[r.length," spans"]}),i.jsx("span",{children:"•"}),i.jsx("span",{children:"Click to expand details"})]}),s.map((a,l)=>i.jsx(Gc,{node:a,depth:0},a.span.span_id||l))]})}):i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No structured spans found. View raw data below."}):i.jsx("pre",{className:"text-xs bg-[var(--bg-primary)] p-3 overflow-x-auto border border-[var(--border)] max-h-96 whitespace-pre-wrap",children:JSON.stringify(e,null,2)})]})}function W0({spans:e,isLive:t=!1}){const n=j.useRef(null),r=j.useMemo(()=>qm(e),[e]);return j.useEffect(()=>{n.current&&t&&n.current.scrollTo({top:n.current.scrollHeight,behavior:"smooth"})},[e.length,t]),i.jsxs("div",{className:"border border-[var(--border)] rounded overflow-hidden h-full flex flex-col",children:[i.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-[var(--border)] bg-[var(--bg-secondary)]",children:[i.jsxs(J,{variant:"default",children:[e.length," spans"]}),t&&i.jsx("span",{className:"animate-pulse",children:i.jsx(J,{variant:"info",children:"Live"})})]}),i.jsx("div",{ref:n,className:"flex-1 overflow-auto p-2",children:r.length>0?r.map((s,a)=>i.jsx(Gc,{node:s,depth:0},s.span.span_id||a)):i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:t?"Waiting for spans...":"No spans recorded"})})]})}function Jm({agent:e}){const[t,n]=j.useState(""),[r,s]=j.useState(null),[a,l]=j.useState("idle"),[o,c]=j.useState(null),[d,h]=j.useState(""),[u,p]=j.useState([]),[x,k]=j.useState(null),[g,S]=j.useState(null),[m,f]=j.useState([]),[v,w]=j.useState(!1),C=j.useRef(null),{data:b=[]}=he({queryKey:["tasks"],queryFn:()=>Et.list()});j.useEffect(()=>{C.current&&a==="running"&&(C.current.scrollTop=C.current.scrollHeight)},[d,a]);const N=D=>{if(s(D),D){const q=b.find(X=>X.id===D);q&&n(q.prompt)}},_=async()=>{if(t.trim()){l("running"),h(""),p([]),k(null),S(null),f([]);try{const D=await Ts.create({agent_id:e.id,prompt:t.trim(),task_id:r||void 0});c(D.id);for await(const q of Ts.start(D.id))F(q)}catch(D){S(D instanceof Error?D.message:"Test failed"),l("failed")}}},F=D=>{switch(D.event){case"started":break;case"execution":D.execution_event==="text_delta"&&D.content?h(q=>q+D.content):D.execution_event==="tool_call_start"&&D.tool_name?f(q=>[...q,{name:D.tool_name}]):D.execution_event==="tool_result"&&D.content&&f(q=>{if(q.length>0){const X=[...q];return X[X.length-1]={...X[X.length-1],content:D.content},X}return q});break;case"span":if(D.span){const q=D.span;if(q.data){const X={span_id:q.data.span_id||"",trace_id:q.data.trace_id||"",parent_span_id:q.data.parent_span_id||null,operation_name:q.data.operation_name||"",start_time:q.timestamp?new Date(q.timestamp).getTime():Date.now(),end_time:Date.now(),duration_ms:q.data.duration_ms||0,status:q.data.status||"OK",attributes:q.data.attributes||{}};p(P=>[...P,X])}}break;case"complete":l("completed"),D.result&&k(D.result);break;case"error":S(D.message),l("failed");break}},O=async()=>{if(o)try{await Ts.cancel(o)}catch{}l("idle")},B=()=>{l("idle"),c(null),h(""),p([]),k(null),S(null),f([])},G=a==="running",re=a==="completed"||a==="failed",le=D=>{D.preventDefault(),re?(B(),setTimeout(()=>_(),0)):_()};return i.jsxs("div",{className:"h-full flex flex-col border border-[var(--border)] rounded-lg overflow-hidden bg-[var(--bg-primary)]",children:[(G||re)&&i.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border)] bg-[var(--bg-secondary)] flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[G&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"animate-pulse",children:i.jsx(J,{variant:"info",children:"Running"})}),i.jsx(K,{variant:"ghost",size:"sm",icon:_d,onClick:O,children:"Cancel"})]}),a==="completed"&&i.jsx(J,{variant:"success",children:"Completed"}),a==="failed"&&i.jsx(J,{variant:"error",children:"Failed"})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[x&&i.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Rm,{size:12}),x.duration_seconds.toFixed(2),"s"]}),i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(_g,{size:12}),x.tokens_total," tokens"]}),x.passed!==null&&(x.passed?i.jsx(Lm,{size:14,className:"text-[var(--success)]"}):i.jsx(Qg,{size:14,className:"text-[var(--error)]"}))]}),u.length>0&&i.jsxs(K,{variant:v?"primary":"secondary",size:"sm",icon:gg,onClick:()=>w(!v),children:["Traces (",u.length,")"]}),re&&o&&i.jsx(Pn,{to:`/tests/${o}`,children:i.jsx(K,{variant:"secondary",size:"sm",icon:Mm,children:"Details"})})]})]}),i.jsxs("div",{className:"flex-1 min-h-0 flex",children:[i.jsx("div",{ref:C,className:`flex-1 overflow-auto p-4 ${v?"border-r border-[var(--border)]":""}`,children:!G&&!re?i.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center",children:[i.jsx("div",{className:"text-lg font-medium mb-1",children:e.name}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] max-w-sm",children:"Send a message to test this agent, or select a task from the dropdown below."})]}):i.jsxs("div",{className:"space-y-3",children:[i.jsx("div",{className:"flex justify-end",children:i.jsx("div",{className:"max-w-[80%] px-3 py-2 bg-[var(--accent-dim)] text-[var(--text-primary)] rounded-lg text-sm",children:t})}),(d||G)&&i.jsx("div",{className:"px-3 py-2 text-sm whitespace-pre-wrap font-mono bg-[var(--bg-secondary)] rounded-lg border border-[var(--border)]",children:d||i.jsx("span",{className:"text-[var(--text-secondary)] animate-pulse",children:"Thinking..."})}),m.length>0&&i.jsx("div",{className:"space-y-1.5",children:m.map((D,q)=>i.jsxs("div",{className:"p-2 bg-[var(--badge-info-bg)] border border-[var(--badge-info-border)] rounded-md text-xs",children:[i.jsx(J,{variant:"info",children:D.name}),D.content&&i.jsxs("div",{className:"mt-1 text-[var(--text-secondary)] truncate max-w-full font-mono",children:[D.content.substring(0,200),D.content.length>200&&"..."]})]},q))}),g&&i.jsx("div",{className:"p-3 bg-[var(--badge-error-bg)] border border-[var(--badge-error-border)] rounded-md text-sm text-[var(--badge-error-text)]",children:g})]})}),v&&i.jsx("div",{className:"w-[350px] flex-shrink-0 overflow-auto",children:i.jsx(W0,{spans:u,isLive:G})})]}),i.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] bg-[var(--bg-secondary)]",children:[i.jsx("div",{className:"px-4 pt-2",children:i.jsxs("select",{value:r||"",onChange:D=>N(D.target.value||null),className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs text-[var(--text-secondary)]",disabled:G,children:[i.jsx("option",{value:"",children:"Custom prompt..."}),b.map(D=>i.jsx("option",{value:D.id,children:D.name},D.id))]})}),i.jsxs("form",{onSubmit:le,className:"p-3 flex gap-2",children:[i.jsx("textarea",{value:t,onChange:D=>n(D.target.value),placeholder:"Message the agent...",disabled:G,rows:1,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm resize-none min-h-[40px] max-h-[120px] focus:outline-none focus:border-[var(--accent)]",onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),le(D))}}),i.jsx(K,{type:"submit",variant:"primary",icon:G?_d:Xs,disabled:G?!1:!t.trim(),onClick:G?O:void 0,children:G?"Stop":re?"New Test":"Run"})]})]})]})}function q0(){const{agentId:e}=fa(),t=cr(),n=qt(),[r,s]=j.useState("overview"),{data:a,isLoading:l}=he({queryKey:["configs",e],queryFn:()=>Xn.get(e),enabled:!!e}),{data:o=[]}=he({queryKey:["tests",{agent_id:e}],queryFn:()=>Ts.list({agent_id:e}),enabled:!!e}),{data:c=[]}=he({queryKey:["jobs"],queryFn:()=>Ut.list()}),d=Je({mutationFn:u=>Xn.delete(u),onSuccess:()=>{n.invalidateQueries({queryKey:["configs"]}),t("/agents")}}),h=c.filter(u=>u.candidate_ids.includes(e||""));return l?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):a?i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"mb-4 flex-shrink-0",children:[i.jsx(ma,{items:[{label:"Agents",path:"/agents"},{label:a.name}]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:a.name}),a.is_auto_generated&&i.jsx(J,{variant:"info",children:"Auto-generated"})]}),i.jsx("div",{className:"flex gap-2",children:i.jsx(K,{variant:"secondary",icon:Qc,size:"sm",onClick:()=>{confirm(`Delete agent "${a.name}"?`)&&d.mutate(a.id)},children:"Delete"})})]}),a.description&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:a.description})]}),i.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[i.jsxs("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:[i.jsxs("div",{className:"flex gap-1 mb-4 border-b border-[var(--border)] flex-shrink-0",children:[i.jsx(kl,{active:r==="overview",onClick:()=>s("overview"),icon:i.jsx(Im,{size:14}),children:"Overview"}),i.jsx(kl,{active:r==="evaluate",onClick:()=>s("evaluate"),icon:i.jsx(Xs,{size:14}),children:"Evaluate"}),i.jsx(kl,{active:r==="history",onClick:()=>s("history"),icon:i.jsx(Mg,{size:14}),badge:o.length,children:"History"})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r==="overview"&&i.jsx(G0,{agent:a,recentTests:o,jobs:h}),r==="evaluate"&&i.jsx(J0,{agent:a,jobs:h}),r==="history"&&i.jsx(Y0,{tests:o})]})]}),i.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[i.jsx(Fm,{size:16,className:"text-[var(--text-secondary)]"}),i.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),i.jsx("div",{className:"flex-1 min-h-0",children:i.jsx(Jm,{agent:a})})]})]})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Agent not found"})}function kl({active:e,onClick:t,icon:n,badge:r,children:s}){return i.jsxs("button",{onClick:t,className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors ${e?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[n,s,r!==void 0&&r>0&&i.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs bg-[var(--bg-tertiary)] rounded",children:r})]})}function G0({agent:e,recentTests:t,jobs:n}){var a,l;const r=e.config,s=()=>{const o=r.tools;return typeof o=="string"?o:Array.isArray(o)?o.join(", "):o&&typeof o=="object"?Object.keys(o).join(", "):"standard"};return i.jsxs("div",{className:"space-y-4",children:[i.jsx(fr,{title:"Model",children:i.jsx("div",{className:"font-mono text-sm",children:r.model||"default"})}),i.jsx(fr,{title:"Instructions",defaultCollapsed:!r.instructions,children:r.instructions?i.jsx("pre",{className:"p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs whitespace-pre-wrap max-h-40 overflow-auto font-mono",children:r.instructions}):i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No instructions set"})}),i.jsx(fr,{title:"Tools",children:i.jsx("div",{className:"font-mono text-sm",children:s()})}),i.jsx(fr,{title:"Compaction",children:i.jsx("div",{className:"font-mono text-sm",children:!r.compaction||r.compaction.strategy==="none"?"disabled":`${r.compaction.strategy} (${((a=r.compaction.params)==null?void 0:a.head_size)||0}/${((l=r.compaction.params)==null?void 0:l.tail_size)||0})`})}),t.length>0&&i.jsx(fr,{title:`Recent Tests (${t.length})`,children:i.jsx("div",{className:"space-y-1.5",children:t.slice(0,3).map(o=>i.jsxs(Pn,{to:`/tests/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[i.jsx(Ym,{status:o.status}),i.jsxs("span",{className:"truncate",children:[o.prompt.slice(0,40),"..."]})]}),i.jsxs("span",{className:"text-[var(--text-secondary)] flex-shrink-0 ml-2",children:[o.duration_seconds.toFixed(1),"s"]})]},o.id))})}),n.length>0&&i.jsx(fr,{title:`Experiments (${n.length})`,children:i.jsx("div",{className:"space-y-1.5",children:n.slice(0,3).map(o=>i.jsxs(Pn,{to:`/jobs/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(J,{variant:o.status==="completed"?"success":o.status==="running"?"info":"default",children:o.status}),i.jsx("span",{children:o.name})]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(o.created_at).toLocaleDateString()})]},o.id))})})]})}function fr({title:e,children:t,defaultCollapsed:n=!1}){const[r,s]=j.useState(n);return i.jsxs("div",{className:"border-b border-[var(--border)] pb-3",children:[i.jsxs("button",{onClick:()=>s(!r),className:"flex items-center justify-between w-full text-left py-1 hover:text-[var(--accent)] transition-colors",children:[i.jsx("span",{className:"text-sm font-medium",children:e}),i.jsx("span",{className:"text-[var(--text-secondary)] text-xs",children:r?"▶":"▼"})]}),!r&&i.jsx("div",{className:"mt-2",children:t})]})}function J0({agent:e,jobs:t}){const n=cr(),r=qt(),[s,a]=j.useState("quick"),[l,o]=j.useState(!1),{data:c=[]}=he({queryKey:["suites"],queryFn:()=>Et.listSuites()}),d=Je({mutationFn:j0.start,onSuccess:u=>{r.invalidateQueries({queryKey:["jobs"]}),o(!1),n(`/jobs/${u.id}`)},onError:()=>{o(!1)}}),h=()=>{o(!0),d.mutate({agent_id:e.id,suite_name:s,use_llm_eval:!0,parallel:4})};return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:"Run this agent on a task suite to measure quality and cost."}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm",value:s,onChange:u=>a(u.target.value),disabled:l,children:c.map(u=>i.jsxs("option",{value:u.name,children:[u.name.charAt(0).toUpperCase()+u.name.slice(1)," (",u.task_count," tasks)"]},u.name))}),i.jsx(K,{variant:"primary",icon:l?ha:Xs,onClick:h,disabled:l,loading:l,className:"w-full",children:"Evaluate"})]})]}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h4",{className:"text-sm font-medium",children:"Optimization Jobs"}),i.jsx(K,{variant:"secondary",size:"sm",icon:Qi,onClick:()=>n("/agents",{state:{optimizeAgent:e}}),children:"New Job"})]}),t.length===0?i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No optimization jobs yet."}):i.jsx("div",{className:"space-y-1.5",children:t.slice(0,5).map(u=>i.jsxs(Pn,{to:`/jobs/${u.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(J,{variant:u.status==="completed"?"success":u.status==="running"?"info":"default",children:u.status}),i.jsx("span",{children:u.name})]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(u.created_at).toLocaleDateString()})]},u.id))})]})]})}function Y0({tests:e}){return e.length===0?i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No test history yet. Use the playground on the right to run a test."}):i.jsx("div",{className:"space-y-2",children:e.map(t=>i.jsxs(Pn,{to:`/tests/${t.id}`,className:"flex items-center justify-between p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(Ym,{status:t.status}),t.score!==null&&i.jsxs("span",{className:`text-sm font-medium ${t.passed?"text-[var(--success)]":"text-[var(--error)]"}`,children:[(t.score*100).toFixed(0),"%"]})]}),i.jsx("p",{className:"text-sm truncate",children:t.prompt})]}),i.jsxs("div",{className:"flex flex-col items-end gap-1 ml-4",children:[i.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:new Date(t.created_at).toLocaleString()}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:[t.duration_seconds.toFixed(1),"s"]}),i.jsxs("span",{children:[t.tokens_total," tokens"]})]})]})]},t.id))})}function Ym({status:e}){const t={completed:"success",failed:"error",running:"info",cancelled:"warning",pending:"default"};return i.jsx(J,{variant:t[e]||"default",children:e})}function X0(){const e=qt(),[t,n]=j.useState(!1),[r,s]=j.useState(!1),[a,l]=j.useState(null),[o,c]=j.useState(new Set),d=m=>{c(f=>{const v=new Set(f);return v.has(m)?v.delete(m):v.add(m),v})},{data:h=[],isLoading:u}=he({queryKey:["tasks"],queryFn:()=>Et.list()}),p=Je({mutationFn:Et.create,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),n(!1)}}),x=Je({mutationFn:Et.importSuite,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),s(!1)}}),k=Je({mutationFn:Et.delete,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),l(null)}}),g=h.reduce((m,f)=>{const v=f.suite||"custom";return m[v]||(m[v]=[]),m[v].push(f),m},{}),S=Object.keys(g).sort((m,f)=>m==="custom"?-1:f==="custom"?1:m.localeCompare(f));return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Datasets"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Task datasets for evaluating agent configurations."})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(K,{variant:"secondary",onClick:()=>s(!0),children:"Import Suite"}),i.jsx(K,{variant:"primary",onClick:()=>n(!0),children:"+ New Task"})]})]}),u?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):h.length===0?i.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:"No tasks yet. Create one or import a built-in suite."}):i.jsx("div",{className:"space-y-4",children:S.map(m=>{const f=g[m],v=!o.has(m);return i.jsxs("div",{children:[i.jsxs("button",{onClick:()=>d(m),className:"flex items-center gap-2 py-2 hover:text-[var(--accent)] transition-colors",children:[v?i.jsx(Ng,{size:16,className:"text-[var(--text-secondary)]"}):i.jsx(Ys,{size:16,className:"text-[var(--text-secondary)]"}),i.jsx("h3",{className:"text-sm font-medium uppercase tracking-wide",children:m==="custom"?"Custom Tasks":`${m} Suite`}),i.jsx(J,{variant:m==="custom"?"default":"info",children:f.length})]}),v&&i.jsx("div",{className:"mt-2 border border-[var(--border)] rounded-lg overflow-hidden",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:[i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Name"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Category"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Prompt"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Criteria"})]})}),i.jsx("tbody",{children:f.map(w=>i.jsxs("tr",{onClick:()=>l(w),className:"border-b border-[var(--border)] last:border-b-0 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors",children:[i.jsx("td",{className:"px-4 py-3",children:i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:w.name})}),i.jsx("td",{className:"px-4 py-3",children:w.category&&w.category!=="default"?i.jsx(J,{variant:"default",children:w.category}):i.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"})}),i.jsx("td",{className:"px-4 py-3",children:i.jsx("span",{className:"text-[var(--text-secondary)] line-clamp-1 max-w-md",children:w.prompt})}),i.jsx("td",{className:"px-4 py-3 text-[var(--text-secondary)]",children:w.criteria.length>0?w.criteria.length:"--"})]},w.id))})]})})]},m)})}),i.jsx(Z0,{task:a,onClose:()=>l(null),onDelete:m=>{confirm("Delete this task?")&&k.mutate(m)}}),i.jsx(e1,{isOpen:t,onClose:()=>n(!1),onSubmit:m=>p.mutate(m),isLoading:p.isPending}),i.jsx(t1,{isOpen:r,onClose:()=>s(!1),onSubmit:m=>x.mutate(m),isLoading:x.isPending})]})}function Z0({task:e,onClose:t,onDelete:n}){const[r,s]=j.useState("prompt");if(!e)return null;const a=i.jsxs("div",{className:"flex justify-between",children:[i.jsx(K,{variant:"ghost",onClick:()=>n(e.id),className:"text-red-500 hover:text-red-600",children:"Delete Task"}),i.jsx(K,{variant:"secondary",onClick:t,children:"Close"})]});return i.jsx(ss,{isOpen:!!e,onClose:t,title:e.name,size:"lg",footer:a,children:i.jsxs("div",{className:"space-y-4",children:[e.category&&e.category!=="default"&&i.jsx("div",{children:i.jsx(J,{variant:"default",children:e.category})}),i.jsxs("div",{className:"flex gap-1 border-b border-[var(--border)]",children:[i.jsx("button",{onClick:()=>s("prompt"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="prompt"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Prompt"}),i.jsxs("button",{onClick:()=>s("criteria"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="criteria"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:["Eval Criteria (",e.criteria.length,")"]})]}),r==="prompt"&&i.jsx("div",{className:"p-4 bg-[var(--bg-tertiary)] rounded text-sm whitespace-pre-wrap min-h-[200px]",children:e.prompt}),r==="criteria"&&i.jsx("div",{className:"space-y-2 min-h-[200px]",children:e.criteria.length===0?i.jsx("div",{className:"text-[var(--text-secondary)] text-sm p-4",children:"No evaluation criteria defined for this task."}):e.criteria.map(l=>i.jsxs("div",{className:"p-3 bg-[var(--bg-tertiary)] rounded",children:[i.jsx("div",{className:"font-medium text-sm",children:l.name}),l.instruction&&i.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1",children:l.instruction})]},l.name))})]})})}function e1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,a]=j.useState({name:"",prompt:"",criteria:[],category:"default"}),l=()=>{a({...s,criteria:[...s.criteria,{name:"",instruction:"",weight:1}]})},o=(h,u)=>{const p=[...s.criteria];p[h]={...p[h],...u},a({...s,criteria:p})},c=h=>{a({...s,criteria:s.criteria.filter((u,p)=>p!==h)})},d=h=>{h.preventDefault(),!(!s.name.trim()||!s.prompt.trim())&&n({...s,criteria:s.criteria.filter(u=>u.name.trim()&&u.instruction.trim())})};return i.jsx(ss,{isOpen:e,onClose:t,title:"Create Task",children:i.jsxs("form",{onSubmit:d,className:"space-y-4",children:[i.jsx(pn,{label:"Name",value:s.name,onChange:h=>a({...s,name:h.target.value}),placeholder:"e.g., fizzbuzz",required:!0}),i.jsx(F0,{label:"Prompt",value:s.prompt,onChange:h=>a({...s,prompt:h.target.value}),placeholder:"The task description for the agent...",required:!0}),i.jsx(pn,{label:"Category",value:s.category,onChange:h=>a({...s,category:h.target.value}),placeholder:"e.g., coding, research"}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Evaluation Criteria"}),i.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"+ Add"})]}),i.jsx("div",{className:"space-y-2",children:s.criteria.map((h,u)=>i.jsxs("div",{className:"flex gap-2 items-start",children:[i.jsx(pn,{value:h.name,onChange:p=>o(u,{name:p.target.value}),placeholder:"Name",className:"w-32"}),i.jsx(pn,{value:h.instruction,onChange:p=>o(u,{instruction:p.target.value}),placeholder:"Instruction",className:"flex-1"}),i.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(u),children:"×"})]},u))})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(K,{type:"submit",variant:"primary",disabled:r||!s.name.trim()||!s.prompt.trim(),children:r?"Creating...":"Create"})]})]})})}function t1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,a]=j.useState(""),{data:l=[],isLoading:o}=he({queryKey:["suites"],queryFn:()=>Et.listSuites(),enabled:e});return j.useEffect(()=>{l.length>0&&!s&&a(l[0].name)},[l,s]),i.jsx(ss,{isOpen:e,onClose:t,title:"Import Task Suite",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Import a built-in task suite for evaluation."}),o?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading suites..."}):l.length===0?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"No suites available."}):i.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:l.map(c=>i.jsxs("label",{className:`flex items-center gap-3 p-3 border cursor-pointer ${s===c.name?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[i.jsx("input",{type:"radio",name:"suite",value:c.name,checked:s===c.name,onChange:()=>a(c.name),className:"accent-[var(--accent)]"}),i.jsxs("span",{className:"capitalize",children:[c.name.replace(/_/g," ")," (",c.task_count," tasks) - ",c.description]})]},c.name))}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(K,{variant:"primary",onClick:()=>n(s),disabled:r||!s,children:r?"Importing...":"Import"})]})]})})}const n1=Ki(e=>({jobs:[],setJobs:t=>e({jobs:t})}));function r1(){const e=cr(),t=qt(),[n,r]=j.useState(!1),{setJobs:s}=n1(),a=Wc(),{data:l=[],isLoading:o}=he({queryKey:["jobs",n],queryFn:()=>Ut.list({include_public:n}),refetchInterval:5e3});j.useEffect(()=>{l.length>0&&s(l)},[l,s]);const c=Je({mutationFn:Ut.delete,onSuccess:()=>t.invalidateQueries({queryKey:["jobs"]})}),d={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"},h=[{key:"name",header:"Name",render:u=>i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:u.name||`Job ${u.id.slice(0,8)}`}),u.is_public&&i.jsx(Uc,{className:"w-3 h-3 ml-2 inline text-[var(--text-secondary)]"})]})},{key:"status",header:"Status",render:u=>i.jsx(J,{variant:d[u.status]||"default",children:u.status})},{key:"candidates",header:"Candidates",render:u=>i.jsx("span",{children:u.candidate_ids.length})},{key:"tasks",header:"Tasks",render:u=>i.jsx("span",{children:u.task_ids.length})},{key:"runs",header:"Runs",render:u=>i.jsxs("span",{children:[u.completed_experiments,"/",u.total_experiments]})},{key:"created",header:"Created",render:u=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(u.created_at).toLocaleDateString()}),sortable:!0,sortValue:u=>new Date(u.created_at).getTime()},{key:"actions",header:"",className:"w-12",render:u=>!u.user_id||u.user_id==="anonymous"||a&&u.created_by_name===a?i.jsx("div",{onClick:x=>x.stopPropagation(),children:i.jsx(K,{variant:"ghost",size:"sm",icon:Qc,title:"Delete",disabled:u.status==="running",onClick:()=>{confirm("Delete this job?")&&c.mutate(u.id)}})}):null}];return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Experiments"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"View and manage optimization experiments. Start new experiments from the Agents page."})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Si,{label:"Show public",checked:n,onChange:u=>r(u.target.checked)}),i.jsx(K,{variant:"secondary",onClick:()=>e("/agents"),children:"Go to Agents"})]})]}),o?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):i.jsx(Wm,{columns:h,data:l,onRowClick:u=>e(`/jobs/${u.id}`),searchable:!0,searchPlaceholder:"Search experiments",searchFilter:(u,p)=>(u.name||"").toLowerCase().includes(p.toLowerCase())||u.id.toLowerCase().includes(p.toLowerCase()),emptyMessage:"No experiments yet. Go to Agents page to start an optimization."})]})}function s1(e,t=!0){return Math.abs(e)<10?"text-[var(--text-secondary)]":(t?e<0:e>0)?"text-green-400":"text-red-400"}function a1(e){return`${e>0?"+":""}${e.toFixed(1)}%`}function Xm(e,t){return t===0?0:(e-t)/t*100}function ps({label:e,values:t,baselineIndex:n,formatter:r,isLowerBetter:s=!0}){const a=t[n];return i.jsxs("tr",{className:"border-b border-[var(--border)] last:border-0",children:[i.jsx("td",{className:"py-2 pr-4 text-[var(--text-secondary)] text-sm",children:e}),t.map((l,o)=>{const c=Xm(l,a),d=o===n;return i.jsxs("td",{className:"py-2 px-4 text-right",children:[i.jsx("div",{className:"font-mono",children:r(l)}),!d&&i.jsx("div",{className:`text-xs ${s1(c,s)}`,children:a1(c)}),d&&i.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"(baseline)"})]},o)})]})}function i1({runs:e,baselineRunId:t}){const n=j.useMemo(()=>{if(t){const a=e.findIndex(l=>l.id===t);if(a>=0)return a}return 0},[e,t]);if(e.length<2)return null;const r=Math.min(...e.map(a=>a.tokens_total)),s=Math.max(...e.map(a=>a.score));return i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-4",children:"Candidate Comparison"}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-[var(--border)]",children:[i.jsx("th",{className:"pb-2 pr-4 text-left text-[var(--text-secondary)] font-medium",children:"Metric"}),e.map((a,l)=>i.jsx("th",{className:"pb-2 px-4 text-right",children:i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[i.jsx("span",{className:"font-medium",children:a.candidate_name}),a.is_pareto&&i.jsx(J,{variant:"success",children:"Optimal"}),l===n&&i.jsx(J,{variant:"info",children:"Base"})]})},a.id))]})}),i.jsxs("tbody",{children:[i.jsx(ps,{label:"Total Tokens",values:e.map(a=>a.tokens_total),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ps,{label:"Input Tokens",values:e.map(a=>a.tokens_input),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ps,{label:"Output Tokens",values:e.map(a=>a.tokens_output),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ps,{label:"Duration",values:e.map(a=>a.duration_seconds),baselineIndex:n,formatter:a=>`${a.toFixed(1)}s`,isLowerBetter:!0}),i.jsx(ps,{label:"Score",values:e.map(a=>a.score*100),baselineIndex:n,formatter:a=>`${a.toFixed(1)}%`,isLowerBetter:!1})]})]})}),i.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[i.jsx("h4",{className:"text-sm font-medium mb-2 text-[var(--text-secondary)]",children:"Key Insights"}),i.jsxs("ul",{className:"text-sm space-y-1 text-[var(--text-secondary)]",children:[e.map(a=>{const l=Xm(a.tokens_total,e[n].tokens_total);return a.tokens_total===r&&l<-5?i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-green-400",children:"✓"}),i.jsxs("span",{children:[i.jsx("strong",{children:a.candidate_name})," uses ",Math.abs(l).toFixed(0),"% fewer tokens"]})]},`token-${a.id}`):null}),e.map(a=>a.score===s&&a.passed?i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-green-400",children:"✓"}),i.jsxs("span",{children:[i.jsx("strong",{children:a.candidate_name})," achieved highest score (",(a.score*100).toFixed(0),"%)"]})]},`score-${a.id}`):null),e.filter(a=>a.is_pareto).length>0&&i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-purple-400",children:"★"}),i.jsxs("span",{children:["Optimal candidates (best tradeoff):"," ",e.filter(a=>a.is_pareto).map(a=>a.candidate_name).join(", ")]})]})]})]}),i.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[i.jsx("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:"Token Efficiency"}),i.jsx("div",{className:"space-y-2",children:e.map(a=>{const l=a.tokens_total/e[n].tokens_total*100,o=a.tokens_total<=r;return i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-24 text-sm truncate",title:a.candidate_name,children:a.candidate_name}),i.jsx("div",{className:"flex-1 h-6 bg-[var(--bg-primary)] rounded overflow-hidden",children:i.jsx("div",{className:`h-full transition-all duration-300 ${o?"bg-green-500":"bg-blue-500"}`,style:{width:`${Math.min(l,100)}%`}})}),i.jsx("div",{className:"w-20 text-right font-mono text-sm",children:a.tokens_total.toLocaleString()})]},a.id)})})]})]})}function l1({summaries:e,height:t=350}){const n=j.useRef(null),[r,s]=j.useState(600),[a,l]=j.useState("tokens"),[o,c]=j.useState(null),[d,h]=j.useState({x:0,y:0});j.useEffect(()=>{const b=()=>{n.current&&s(n.current.clientWidth)};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[]);const u={top:30,right:30,bottom:50,left:60},p=r-u.left-u.right,x=t-u.top-u.bottom,k=b=>a==="tokens"?b.avg_tokens:b.avg_duration,{xScale:g,yScale:S,xTicks:m,yTicks:f,paretoLine:v}=j.useMemo(()=>{if(e.length===0||p<=0)return{xScale:()=>0,yScale:()=>0,xTicks:[],yTicks:[],paretoLine:[]};const b=e.map(k),N=e.map(P=>P.avg_score),_=Math.min(...b)*.9,F=Math.max(...b)*1.1,O=Math.min(...N,.5),B=Math.min(Math.max(...N)*1.05,1),G=P=>(P-_)/(F-_)*p,re=P=>x-(P-O)/(B-O)*x,le=Array.from({length:5},(P,A)=>_+A/4*(F-_)),D=Array.from({length:5},(P,A)=>O+A/4*(B-O)),X=e.filter(P=>P.is_pareto).sort((P,A)=>k(P)-k(A)).map(P=>({x:G(k(P)),y:re(P.avg_score)}));return{xScale:G,yScale:re,xTicks:le,yTicks:D,paretoLine:X}},[e,p,x,a]);if(e.length===0)return i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No data to display"});const w=b=>a==="tokens"?b>=1e6?`${(b/1e6).toFixed(1)}M`:b>=1e3?`${(b/1e3).toFixed(0)}K`:b.toFixed(0):`${b.toFixed(1)}s`,C=(b,N)=>{var F;const _=(F=n.current)==null?void 0:F.getBoundingClientRect();_&&h({x:N.clientX-_.left,y:N.clientY-_.top}),c(b)};return i.jsxs("div",{ref:n,className:"w-full relative",children:[i.jsx("div",{className:"flex justify-end mb-2",children:i.jsxs("div",{className:"inline-flex rounded border border-[var(--border)] text-xs",children:[i.jsx("button",{className:`px-3 py-1 ${a==="tokens"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("tokens"),children:"Tokens"}),i.jsx("button",{className:`px-3 py-1 ${a==="duration"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("duration"),children:"Latency"})]})}),i.jsx("svg",{width:r,height:t,className:"font-mono text-xs",children:i.jsxs("g",{transform:`translate(${u.left}, ${u.top})`,children:[m.map((b,N)=>i.jsx("line",{x1:g(b),y1:0,x2:g(b),y2:x,stroke:"var(--border)",strokeDasharray:"2,2"},`x-grid-${N}`)),f.map((b,N)=>i.jsx("line",{x1:0,y1:S(b),x2:p,y2:S(b),stroke:"var(--border)",strokeDasharray:"2,2"},`y-grid-${N}`)),v.length>1&&i.jsx("polyline",{points:v.map(b=>`${b.x},${b.y}`).join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.slice().sort((b,N)=>(b.is_pareto?1:0)-(N.is_pareto?1:0)).map(b=>{const N=g(k(b)),_=S(b.avg_score),F=b.is_pareto,O=(o==null?void 0:o.candidate_name)===b.candidate_name;return i.jsxs("g",{onMouseEnter:B=>C(b,B),onMouseLeave:()=>c(null),children:[i.jsx("circle",{cx:N,cy:_,r:O?10:F?8:6,fill:F?"var(--accent)":"transparent",stroke:O?"var(--text-primary)":F?"var(--accent)":"var(--text-secondary)",strokeWidth:O?3:2,className:"cursor-pointer transition-all"}),F&&!O&&i.jsx("text",{x:N,y:_-12,textAnchor:"middle",fill:"var(--text-primary)",fontSize:10,className:"pointer-events-none",children:b.candidate_name.replace(/^baseline_/,"").slice(0,15)})]},b.candidate_name)}),i.jsx("line",{x1:0,y1:x,x2:p,y2:x,stroke:"var(--text-secondary)"}),m.map((b,N)=>i.jsxs("g",{transform:`translate(${g(b)}, ${x})`,children:[i.jsx("line",{y2:5,stroke:"var(--text-secondary)"}),i.jsx("text",{y:20,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:10,children:w(b)})]},`x-tick-${N}`)),i.jsx("text",{x:p/2,y:x+40,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:a==="tokens"?"Tokens (cost)":"Duration (latency)"}),i.jsx("line",{x1:0,y1:0,x2:0,y2:x,stroke:"var(--text-secondary)"}),f.map((b,N)=>i.jsxs("g",{transform:`translate(0, ${S(b)})`,children:[i.jsx("line",{x2:-5,stroke:"var(--text-secondary)"}),i.jsxs("text",{x:-10,textAnchor:"end",dominantBaseline:"middle",fill:"var(--text-secondary)",fontSize:10,children:[(b*100).toFixed(0),"%"]})]},`y-tick-${N}`)),i.jsx("text",{transform:`translate(-45, ${x/2}) rotate(-90)`,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:"Score (quality)"})]})}),o&&i.jsxs("div",{className:"absolute z-10 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg shadow-lg p-3 text-sm pointer-events-none",style:{left:Math.min(d.x+15,r-200),top:d.y-10,maxWidth:220},children:[i.jsx("div",{className:"font-medium text-[var(--text-primary)] truncate mb-2",children:o.candidate_name.replace(/^baseline_/,"")}),i.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Score:"}),i.jsxs("span",{className:"text-right font-medium",children:[(o.avg_score*100).toFixed(1),"%"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tokens:"}),i.jsxs("span",{className:"text-right",children:[(o.avg_tokens/1e3).toFixed(1),"K"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Duration:"}),i.jsxs("span",{className:"text-right",children:[o.avg_duration.toFixed(1),"s"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Pass rate:"}),i.jsxs("span",{className:"text-right",children:[o.passed_runs,"/",o.total_runs]})]}),o.is_pareto&&i.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)] text-xs text-[var(--accent)]",children:"Optimal (best tradeoff)"})]})]})}function o1(e=2e3){const[t,n]=j.useState(!1),[r,s]=j.useState(null),a=j.useCallback(async o=>{try{return await navigator.clipboard.writeText(o),n(!0),s(null),setTimeout(()=>n(!1),e),!0}catch{return s("Failed to copy to clipboard"),n(!1),!1}},[e]),l=j.useCallback(()=>{n(!1),s(null)},[]);return{copy:a,copied:t,error:r,reset:l}}function c1({isOpen:e,onClose:t,title:n,itemId:r,itemType:s,isPublic:a,createdByName:l,onTogglePublic:o}){const[c,d]=j.useState(!1),{copy:h,copied:u}=o1(),p=`${window.location.origin}/${s}s/${r}`,x=async()=>{d(!0);try{await o(!a)}finally{d(!1)}},k=()=>{h(p)};return i.jsx(ss,{isOpen:e,onClose:t,title:n,children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between p-3 bg-[var(--bg-tertiary)] rounded",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[a?i.jsx(Uc,{className:"w-5 h-5 text-[var(--accent)]"}):i.jsx(zm,{className:"w-5 h-5 text-[var(--text-secondary)]"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium",children:a?"Public":"Private"}),i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:a?"Anyone with the link can view":"Only you can access"})]})]}),i.jsx("button",{onClick:x,disabled:c,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${a?"bg-[var(--accent)]":"bg-[var(--border)]"} ${c?"opacity-50 cursor-not-allowed":""}`,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${a?"translate-x-6":"translate-x-1"}`})})]}),a&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Share link"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",readOnly:!0,value:p,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono"}),i.jsx(K,{variant:"secondary",onClick:k,children:u?i.jsxs(i.Fragment,{children:[i.jsx(Sg,{className:"w-4 h-4 mr-1"}),"Copied"]}):i.jsxs(i.Fragment,{children:[i.jsx(Eg,{className:"w-4 h-4 mr-1"}),"Copy"]})})]})]}),l&&i.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",i.jsx("span",{className:"text-[var(--text-primary)]",children:l})]}),i.jsx("div",{className:"text-xs text-[var(--text-secondary)] pt-2 border-t border-[var(--border)]",children:a?i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Public ",s,"s can be viewed by anyone with the link."]}),i.jsxs("p",{className:"mt-1",children:["Only you can edit or delete this ",s,"."]})]}):i.jsxs("p",{children:["Make this ",s," public to share it with others."]})})]})})}function u1({job:e,onUpdate:t}){const[n,r]=j.useState(!1),s=async a=>{await Ut.update(e.id,{is_public:a}),t()};return i.jsxs(i.Fragment,{children:[i.jsxs(K,{variant:"secondary",size:"sm",onClick:()=>r(!0),title:e.is_public?"Sharing settings":"Share this job",children:[i.jsx($g,{className:"w-4 h-4 mr-1"}),e.is_public?"Shared":"Share"]}),i.jsx(c1,{isOpen:n,onClose:()=>r(!1),title:"Share Job",itemId:e.id,itemType:"job",isPublic:e.is_public,createdByName:e.created_by_name,onTogglePublic:s})]})}function d1(){const{jobId:e}=fa(),t=cr(),n=qt(),[r,s]=j.useState(null),[a,l]=j.useState(!1),[o,c]=j.useState(null),[d,h]=j.useState([]),[u,p]=j.useState(null),[x,k]=j.useState(null),[g,S]=j.useState("results"),[m,f]=j.useState("score"),[v,w]=j.useState("desc"),[C,b]=j.useState(!1),{data:N,isLoading:_}=he({queryKey:["jobs",e],queryFn:()=>Ut.get(e),enabled:!!e,refetchInterval:a?2e3:!1}),{data:F=[]}=he({queryKey:["runs",e],queryFn:()=>Fo.list({job_id:e}),enabled:!!e,refetchInterval:a?2e3:!1}),{data:O}=he({queryKey:["job-summary",e],queryFn:()=>Fo.getJobSummary(e),enabled:!!e&&(N==null?void 0:N.status)==="completed"}),B=Je({mutationFn:async()=>{l(!0),h([]),p(null),k(null);for await(const R of Ut.start(e))s(R),R.current_candidate&&R.current_task&&p(T=>(T&&(T.candidate!==R.current_candidate||T.task!==R.current_task)&&h(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),{candidate:R.current_candidate,task:R.current_task})),R.event==="error"&&(k(R.message),l(!1),n.invalidateQueries({queryKey:["jobs",e]})),R.event==="complete"&&(p(T=>(T&&h(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),null)),l(!1),n.invalidateQueries({queryKey:["jobs",e]}),n.invalidateQueries({queryKey:["runs",e]}),n.invalidateQueries({queryKey:["job-summary",e]}))}}),G=Je({mutationFn:()=>Ut.cancel(e),onSuccess:()=>{l(!1),n.invalidateQueries({queryKey:["jobs",e]})}});j.useEffect(()=>{(N==null?void 0:N.status)==="running"&&l(!0)},[N==null?void 0:N.status]);const re=j.useMemo(()=>{const R=new Map;for(const T of F)R.has(T.task_name)||R.set(T.task_name,[]),R.get(T.task_name).push(T);return R},[F]),le=j.useMemo(()=>Array.from(re.keys()),[re]);j.useEffect(()=>{!o&&le.length>0&&c(le[0])},[le,o]);const D=j.useMemo(()=>{if(!(O!=null&&O.candidate_summaries))return[];let R=[...O.candidate_summaries];return C&&(R=R.filter(T=>T.is_pareto)),R.sort((T,te)=>{let pe,be;switch(m){case"score":pe=T.avg_score,be=te.avg_score;break;case"tokens":pe=T.avg_tokens,be=te.avg_tokens;break;case"duration":pe=T.avg_duration,be=te.avg_duration;break;case"pass_rate":pe=T.passed_runs/T.total_runs,be=te.passed_runs/te.total_runs;break}return v==="desc"?be-pe:pe-be}),R},[O,m,v,C]),q=R=>{m===R?w(v==="desc"?"asc":"desc"):(f(R),w(R==="tokens"||R==="duration"?"asc":"desc"))},X=({label:R,sortKeyVal:T})=>i.jsx("th",{className:"pb-2 cursor-pointer hover:text-[var(--text-primary)] select-none",onClick:()=>q(T),children:i.jsxs("div",{className:"flex items-center gap-1",children:[R,m===T&&i.jsx(jg,{size:12,className:v==="asc"?"rotate-180":""})]})});if(_)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!N)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Job not found"});const P=Wc(),A=!N.user_id||N.user_id==="anonymous"||P&&N.created_by_name===P,L=N.is_public&&!A,V=()=>{n.invalidateQueries({queryKey:["jobs",e]})},ee=R=>{const T={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};return i.jsx(J,{variant:T[R]||"default",children:R})};return i.jsxs("div",{children:[i.jsx(ma,{items:[{label:"Experiments",path:"/jobs"},{label:N.name||`Job ${N.id.slice(0,8)}`}]}),i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:N.name||`Job ${N.id.slice(0,8)}`}),ee(N.status),N.is_public&&i.jsxs(J,{variant:"info",children:[i.jsx(Uc,{className:"w-3 h-3 mr-1 inline"}),"Public"]})]}),i.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-2 py-0.5 rounded font-mono text-[var(--text-secondary)]",children:[N.id.slice(0,8),"..."]}),i.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[N.candidate_ids.length," candidates × ",N.task_ids.length," tasks = ",N.total_experiments," experiments"]}),N.is_public&&N.created_by_name&&i.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",i.jsx("span",{className:"text-[var(--text-primary)]",children:N.created_by_name})]})]})]}),i.jsxs("div",{className:"flex gap-2",children:[A&&i.jsx(u1,{job:N,onUpdate:V}),L&&i.jsx(J,{variant:"default",children:"View Only"}),A&&N.status==="pending"&&i.jsx(K,{variant:"primary",onClick:()=>B.mutate(),disabled:B.isPending,children:B.isPending?"Starting...":"Start"}),A&&N.status==="running"&&i.jsx(K,{variant:"danger",onClick:()=>G.mutate(),disabled:G.isPending,children:"Cancel"})]})]}),(x||N.error)&&i.jsx(ge,{className:"mb-6 border-red-500/50 bg-red-500/10",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-5 h-5 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-0.5",children:"!"}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium text-red-400",children:"Error"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:x||N.error})]})]})}),(a||r)&&i.jsxs(ge,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("span",{className:"font-medium",children:"Progress"}),i.jsxs("span",{className:"text-[var(--accent)]",children:[(r==null?void 0:r.completed)||N.completed_experiments,"/",(r==null?void 0:r.total)||N.total_experiments]})]}),i.jsx("div",{className:"w-full bg-[var(--bg-primary)] h-2 mb-2",children:i.jsx("div",{className:"h-full bg-[var(--accent)] transition-all",style:{width:`${((r==null?void 0:r.completed)||N.completed_experiments)/((r==null?void 0:r.total)||N.total_experiments)*100}%`}})}),(r==null?void 0:r.message)&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r.message}),a&&i.jsxs("div",{className:"mt-4 border-t border-[var(--border)] pt-4",children:[(r==null?void 0:r.current_candidate)&&(r==null?void 0:r.current_task)&&i.jsxs("div",{className:"mb-3",children:[i.jsx("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:"Currently Running"}),i.jsxs("div",{className:"flex items-center gap-2 mt-1 px-3 py-2 bg-blue-500/10 border border-blue-500/30 rounded",children:[i.jsx("div",{className:"w-2 h-2 bg-blue-400 rounded-full animate-pulse"}),i.jsx("span",{className:"font-medium",children:r.current_candidate}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{children:r.current_task})]})]}),d.length>0&&i.jsxs("div",{children:[i.jsxs("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:["Completed (",d.length,")"]}),i.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto space-y-1",children:d.map((R,T)=>i.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-500/10 border border-green-500/30 rounded text-sm",children:[i.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}),i.jsx("span",{className:"font-medium",children:R.candidate_name}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{children:R.task_name})]},`${R.candidate_name}-${R.task_name}-${T}`))})]})]})]}),(N.status==="completed"||F.length>0)&&i.jsxs("div",{className:"flex gap-1 mb-6 border-b border-[var(--border)]",children:[i.jsxs("button",{onClick:()=>S("results"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="results"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(wg,{size:16}),"Results"]}),i.jsxs("button",{onClick:()=>S("compare"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="compare"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(Lg,{size:16}),"Compare"]}),i.jsxs("button",{onClick:()=>S("runs"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="runs"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(zg,{size:16}),"Runs (",F.length,")"]})]}),g==="results"&&i.jsxs(i.Fragment,{children:[O&&O.candidate_summaries.length>1&&i.jsxs(ge,{className:"mb-6",children:[i.jsx("div",{className:"flex items-start justify-between mb-4",children:i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium",children:"Quality vs. Cost Tradeoff"}),i.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:["Candidates on the frontier (connected line) are ",i.jsx("strong",{children:"optimal"})," - no other candidate beats them on both score AND cost."]})]})}),i.jsxs("div",{className:"mb-4 p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs text-[var(--text-secondary)]",children:[i.jsx("strong",{className:"text-[var(--text-primary)]",children:"How optimal tradeoffs are calculated:"})," A candidate is optimal if there's no other candidate that has both a higher score AND lower cost. For example, if Candidate A has 95% score at 50K tokens and Candidate B has 90% score at 40K tokens, both are optimal - A is better on score, B is better on cost. But if Candidate C has 85% score at 60K tokens, it's ",i.jsx("em",{children:"not"})," optimal because B beats it on both metrics."]}),i.jsx(l1,{summaries:O.candidate_summaries,height:350})]}),O&&i.jsxs(ge,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h3",{className:"font-medium",children:"Results Summary"}),i.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:C,onChange:R=>b(R.target.checked),className:"rounded border-[var(--border)]"}),"Optimal only"]})]}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"text-left text-[var(--text-secondary)] border-b border-[var(--border)]",children:[i.jsx("th",{className:"pb-2",children:"Candidate"}),i.jsx(X,{label:"Score",sortKeyVal:"score"}),i.jsx(X,{label:"Tokens",sortKeyVal:"tokens"}),i.jsx(X,{label:"Duration",sortKeyVal:"duration"}),i.jsx(X,{label:"Pass Rate",sortKeyVal:"pass_rate"}),i.jsx("th",{className:"pb-2",children:"Optimal"})]})}),i.jsx("tbody",{children:D.map((R,T)=>i.jsxs("tr",{className:`border-b border-[var(--border)] ${T===0?"bg-[var(--accent)]/10":""}`,children:[i.jsxs("td",{className:"py-2 font-medium",children:[T===0&&i.jsx("span",{className:"text-[var(--accent)] mr-1",children:"#1"}),R.candidate_name.replace(/^baseline_/,"")]}),i.jsxs("td",{className:"py-2",children:[(R.avg_score*100).toFixed(1),"%"]}),i.jsxs("td",{className:"py-2",children:[(R.avg_tokens/1e3).toFixed(1),"K"]}),i.jsxs("td",{className:"py-2",children:[R.avg_duration.toFixed(1),"s"]}),i.jsxs("td",{className:"py-2",children:[R.passed_runs,"/",R.total_runs]}),i.jsx("td",{className:"py-2",children:R.is_pareto&&i.jsx(J,{variant:"success",children:"Optimal"})})]},R.candidate_name))})]})}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-3",children:"Click column headers to sort. The #1 ranked candidate is highlighted based on your sort criteria."})]}),!O&&i.jsx(ge,{children:i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Results will appear here after the job completes.":"No results yet. Start the job to see results."})})]}),g==="compare"&&i.jsxs(ge,{children:[i.jsx("h3",{className:"font-medium mb-4",children:"Compare Candidates by Task"}),le.length>0?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:le.map(R=>i.jsx("button",{onClick:()=>c(o===R?null:R),className:`px-3 py-1 text-sm rounded border transition-colors ${o===R?"bg-[var(--accent)] text-white border-[var(--accent)]":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:R},R))}),o&&re.get(o)?i.jsx(i1,{runs:re.get(o).map(R=>({id:R.id,candidate_name:R.candidate_name,tokens_input:0,tokens_output:0,tokens_total:R.tokens_total,duration_seconds:R.duration_seconds,score:R.score,passed:R.passed,is_pareto:R.is_pareto}))}):i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"Select a task above to compare how different candidates performed on it."})]}):i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Comparison data will appear here after runs complete.":"No runs yet. Start the job to compare candidates."})]}),g==="runs"&&i.jsxs(ge,{children:[i.jsx("h3",{className:"font-medium mb-4",children:"All Experiment Runs"}),F.length===0?i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Runs will appear here as they complete. See progress above for live status.":"No runs yet. Start the job to see results."}):i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:F.map(R=>i.jsxs("div",{className:"p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] cursor-pointer hover:border-[var(--accent-dim)] transition-colors",onClick:()=>t(`/runs/${R.id}`),children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("span",{className:`text-lg font-bold ${R.passed?"text-green-400":"text-red-400"}`,children:[(R.score*100).toFixed(0),"%"]}),R.is_pareto&&i.jsx(J,{variant:"success",children:"Optimal"})]}),i.jsx("div",{className:"text-sm font-medium truncate",title:R.candidate_name,children:R.candidate_name.replace(/^baseline_/,"")}),i.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:R.task_name}),i.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:[(R.tokens_total/1e3).toFixed(1),"K tokens"]}),i.jsxs("span",{children:[R.duration_seconds.toFixed(1),"s"]})]})]},R.id))})]})]})}const vn={input:"bg-blue-500",output:"bg-emerald-500",inputText:"text-blue-400",outputText:"text-emerald-400"};function Rd(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Md({input:e,output:t,maxValue:n,height:r=24,showLabels:s=!0}){const a=e+t;if(a===0)return i.jsx("div",{className:"flex items-center gap-2 w-full",children:i.jsx("div",{className:"rounded bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`}})});const l=n>0?a/n*100:100;return i.jsxs("div",{className:"flex items-center gap-3 w-full",children:[i.jsx("div",{className:"relative rounded overflow-hidden bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`},children:i.jsxs("div",{className:"h-full flex transition-all duration-300",style:{width:`${l}%`},children:[i.jsx("div",{className:`h-full ${vn.input} transition-all`,style:{width:`${e/a*100}%`},title:`Input: ${e.toLocaleString()} tokens`}),i.jsx("div",{className:`h-full ${vn.output} transition-all`,style:{width:`${t/a*100}%`},title:`Output: ${t.toLocaleString()} tokens`})]})}),s&&i.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono text-[var(--text-secondary)] min-w-[90px] justify-end",children:[i.jsxs("span",{className:vn.inputText,children:["↑",Rd(e)]}),i.jsx("span",{children:"/"}),i.jsxs("span",{className:vn.outputText,children:["↓",Rd(t)]})]})]})}function Sl({label:e,value:t,color:n="default"}){const r={default:"text-[var(--text-primary)]",input:vn.inputText,output:vn.outputText}[n];return i.jsxs("div",{className:"flex-1 p-3 bg-[var(--bg-primary)] border border-[var(--border)] rounded",children:[i.jsx("div",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e}),i.jsx("div",{className:`font-mono text-lg font-bold ${r}`,children:t})]})}function Zm({tokensInput:e,tokensOutput:t,tokensTotal:n,turns:r}){const s=n>0?Math.round(e/n*100):0,a=n>0?Math.round(t/n*100):0,l=j.useMemo(()=>{if(!r||r.length===0)return null;let c=0,d=0;return r.map(h=>(c+=h.input,d+=h.output,{input:c,output:d,total:c+d}))},[r]),o=l?Math.max(...l.map(c=>c.total)):n;return i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-4",children:"Token Usage"}),i.jsx("div",{className:"mb-4",children:i.jsx(Md,{input:e,output:t,maxValue:n,height:32})}),i.jsxs("div",{className:"flex items-center gap-6 text-xs mb-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:`w-3 h-3 rounded ${vn.input}`}),i.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Input (",s,"%)"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:`w-3 h-3 rounded ${vn.output}`}),i.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Output (",a,"%)"]})]})]}),i.jsxs("div",{className:"flex gap-3 mb-4",children:[i.jsx(Sl,{label:"Input Tokens",value:e.toLocaleString(),color:"input"}),i.jsx(Sl,{label:"Output Tokens",value:t.toLocaleString(),color:"output"}),i.jsx(Sl,{label:"Total Tokens",value:n.toLocaleString()})]}),l&&l.length>1&&i.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[i.jsxs("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:["Token Accumulation (",r.length," turns)"]}),i.jsx("div",{className:"space-y-2",children:r.map((c,d)=>i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--bg-primary)] border border-[var(--border)] flex items-center justify-center text-xs font-medium",children:d+1}),i.jsx("div",{className:"flex-1",children:i.jsx(Md,{input:l[d].input,output:l[d].output,maxValue:o,height:16})})]},d))})]}),i.jsx("div",{className:"mt-4 text-xs text-[var(--text-secondary)] border-t border-[var(--border)] pt-3",children:"Token usage affects API cost. Input tokens are typically cheaper than output tokens."})]})}function f1(){const{runId:e}=fa(),{data:t,isLoading:n}=he({queryKey:["runs",e],queryFn:()=>Fo.get(e),enabled:!!e});return n?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?i.jsxs("div",{children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(ma,{items:[{label:"Experiments",path:"/jobs"},{label:"Job",path:`/jobs/${t.job_id}`},{label:t.candidate_name}]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:t.candidate_name}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{className:"text-lg",children:t.task_name}),t.is_pareto&&i.jsx(J,{variant:"success",children:"Optimal"})]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[i.jsx(Ma,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),i.jsx(Ma,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),i.jsx(Ma,{label:"Duration",value:`${t.duration_seconds.toFixed(1)}s`}),i.jsx(Ma,{label:"Status",value:t.passed?"Passed":"Failed",status:t.passed?"success":"error"})]}),i.jsx(Zm,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),t.reasoning&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:t.reasoning}),t.criteria_results.length>0&&i.jsx("div",{className:"space-y-2",children:t.criteria_results.map(r=>i.jsx("div",{className:"flex items-start justify-between p-3 bg-[var(--bg-primary)] border border-[var(--border)]",children:i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-medium",children:r.name}),i.jsxs(J,{variant:r.passed?"success":"error",children:[(r.score*100).toFixed(0),"%"]})]}),r.reasoning&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r.reasoning})]})},r.name))})]}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created.length>0&&i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),i.jsx("div",{className:"space-y-1",children:t.files_created.map(r=>i.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:r},r))})]}),Object.keys(t.trace).length>0&&i.jsx(Gm,{trace:t.trace})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Run not found"})}function Ma({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return i.jsxs(ge,{children:[i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),i.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function h1(){const{testId:e}=fa(),{data:t,isLoading:n}=he({queryKey:["tests",e],queryFn:()=>Ts.get(e),enabled:!!e}),{data:r}=he({queryKey:["configs",t==null?void 0:t.agent_id],queryFn:()=>Xn.get(t.agent_id),enabled:!!(t!=null&&t.agent_id)});if(n)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!t)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Test not found"});const s={completed:"success",failed:"error",running:"info",pending:"default",cancelled:"warning"};return i.jsxs("div",{children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(ma,{items:[{label:"Agents",path:"/agents"},...r?[{label:r.name,path:`/agents/${r.id}`}]:[],{label:`Test ${t.id.slice(0,8)}`}]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:"Test Run"}),r&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"•"}),i.jsx("span",{className:"text-lg",children:r.name})]}),i.jsx(J,{variant:s[t.status]||"default",children:t.status})]}),i.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:["ID: ",t.id.slice(0,8),"..."]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[i.jsx(za,{label:"Duration",value:`${t.duration_seconds.toFixed(2)}s`}),i.jsx(za,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),t.score!==null&&i.jsx(za,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),i.jsx(za,{label:"Status",value:t.status.charAt(0).toUpperCase()+t.status.slice(1),status:t.status==="completed"?"success":t.status==="failed"?"error":void 0})]}),i.jsx(Zm,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Prompt"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)] font-mono",children:t.prompt})]}),t.error&&i.jsxs(ge,{className:"mb-6 border-red-500/30 bg-red-500/5",children:[i.jsx("h3",{className:"font-medium mb-3 text-red-400",children:"Error"}),i.jsx("pre",{className:"text-sm text-red-300 overflow-x-auto whitespace-pre-wrap",children:t.error})]}),t.reasoning&&i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.reasoning})]}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created&&t.files_created.length>0&&i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),i.jsx("div",{className:"space-y-1",children:t.files_created.map(a=>i.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:a},a))})]}),t.trace&&Object.keys(t.trace).length>0&&i.jsx(Gm,{trace:t.trace}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Timestamps"}),i.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Created:"}),i.jsx("div",{className:"font-mono",children:new Date(t.created_at).toLocaleString()})]}),t.started_at&&i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Started:"}),i.jsx("div",{className:"font-mono",children:new Date(t.started_at).toLocaleString()})]}),t.completed_at&&i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Completed:"}),i.jsx("div",{className:"font-mono",children:new Date(t.completed_at).toLocaleString()})]})]})]})]})}function za({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return i.jsxs(ge,{children:[i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),i.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function m1(){const{deploymentId:e}=fa(),{data:t,isLoading:n}=he({queryKey:["deployments",e],queryFn:()=>g0.get(e),enabled:!!e}),r=t==null?void 0:t.versions.find(a=>a.id===t.current_version_id),{data:s}=he({queryKey:["configs",r==null?void 0:r.config_id],queryFn:()=>Xn.get(r.config_id),enabled:!!(r!=null&&r.config_id)});return n?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"mb-4 flex-shrink-0",children:[i.jsx(ma,{items:[{label:"Agents",path:"/agents"},{label:t.name}]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Dg,{size:20,className:"text-[var(--accent)]"}),i.jsx("h2",{className:"text-xl font-bold",children:t.name}),r&&i.jsxs(J,{variant:"info",children:["v",r.version]})]}),t.description&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:t.description})]}),i.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[i.jsx("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:i.jsxs("div",{className:"flex-1 overflow-y-auto space-y-5",children:[i.jsxs("div",{className:"flex items-center gap-4 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:["Created ",new Date(t.created_at).toLocaleDateString()]}),i.jsxs("span",{children:["Updated ",new Date(t.updated_at).toLocaleDateString()]}),i.jsxs("span",{children:[t.versions.length," version",t.versions.length!==1?"s":""]})]}),s&&i.jsxs(Pn,{to:`/agents/${s.id}`,className:"flex items-center gap-2 p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-sm",children:[i.jsx(Mm,{size:14,className:"text-[var(--accent)]"}),i.jsxs("span",{children:["Agent: ",i.jsx("span",{className:"font-medium",children:s.name})]})]}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider mb-3",children:"Version History"}),t.versions.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"No versions yet."}):i.jsx("div",{className:"space-y-2",children:t.versions.map(a=>i.jsx(p1,{version:a,isActive:a.id===t.current_version_id},a.id))})]})]})}),i.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[i.jsx(Fm,{size:16,className:"text-[var(--text-secondary)]"}),i.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),i.jsx("div",{className:"flex-1 min-h-0",children:s?i.jsx(Jm,{agent:s}):i.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-secondary)] text-sm",children:r?"Loading agent configuration...":"No active version to test."})})]})]})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Deployment not found"})}function p1({version:e,isActive:t}){const n=e.config_snapshot;return i.jsxs("div",{className:`p-3 rounded-md border transition-colors ${t?"border-[var(--accent)] bg-[var(--accent-dim)]":"border-[var(--border)] bg-[var(--bg-secondary)]"}`,children:[i.jsxs("div",{className:"flex items-center justify-between mb-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Bg,{size:12,className:"text-[var(--text-secondary)]"}),i.jsxs("span",{className:"text-sm font-medium",children:["v",e.version]}),t&&i.jsx(J,{variant:"success",children:"Active"}),i.jsx(J,{variant:e.source==="optimize"?"info":"default",children:e.source})]}),i.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)]",children:[i.jsx(Rm,{size:11}),i.jsx("span",{children:new Date(e.created_at).toLocaleString()})]})]}),e.description&&i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e.description}),Object.keys(n).length>0&&i.jsxs("div",{className:"mt-1",children:[i.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)] mb-1",children:[i.jsx(Og,{size:11}),i.jsx("span",{children:"Config"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-xs",children:["framework"in n&&n.framework?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Framework"}),i.jsx("span",{className:"font-mono",children:String(n.framework)})]}):null,"model"in n&&n.model?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Model"}),i.jsx("span",{className:"font-mono",children:String(n.model)})]}):null,"tools"in n&&n.tools?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tools"}),i.jsx("span",{className:"font-mono truncate",children:Array.isArray(n.tools)?n.tools.join(", "):String(n.tools)})]}):null]})]})]})}function v1(){const{authConfig:e,isLoading:t,error:n,login:r,loginWithGitHub:s,clearError:a}=qc(),[l,o]=j.useState(""),[c,d]=j.useState("");j.useEffect(()=>{n&&a()},[l,c]);const h=async p=>{p.preventDefault(),!(!l||!c)&&await r(l,c)},u=()=>{s()};return i.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:i.jsxs("div",{className:"w-full max-w-md",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:"Flow"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:"Sign in to access the optimization dashboard"})]}),i.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] p-6 space-y-6",children:[n&&i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[var(--error)]/10 border border-[var(--error)]/20 text-[var(--error)]",children:[i.jsx(Om,{size:18,className:"mt-0.5 flex-shrink-0"}),i.jsx("p",{className:"text-sm",children:n})]}),(e==null?void 0:e.mode)==="basic"&&i.jsxs("form",{onSubmit:h,className:"space-y-4",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Username"}),i.jsxs("div",{className:"relative",children:[i.jsx(Dm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),i.jsx("input",{type:"text",value:l,onChange:p=>o(p.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter username",autoComplete:"username",autoFocus:!0})]})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Password"}),i.jsxs("div",{className:"relative",children:[i.jsx(zm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),i.jsx("input",{type:"password",value:c,onChange:p=>d(p.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter password",autoComplete:"current-password"})]})]}),i.jsx(K,{type:"submit",variant:"primary",className:"w-full justify-center",loading:t,disabled:!l||!c,children:"Sign In"})]}),(e==null?void 0:e.mode)==="github"&&i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center",children:"Sign in with your GitHub account to continue"}),i.jsx(K,{onClick:u,variant:"secondary",className:"w-full justify-center",icon:Rg,children:"Continue with GitHub"})]})]})]})})}function x1({children:e}){const{authConfig:t,isLoadingConfig:n,isAuthenticated:r,loadAuthConfig:s,handleOAuthCallback:a}=qc();return j.useEffect(()=>{s()},[s]),j.useEffect(()=>{n||a()},[n,a]),n?i.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center",children:i.jsxs("div",{className:"text-center",children:[i.jsx(ha,{className:"w-8 h-8 animate-spin text-[var(--accent)] mx-auto mb-4"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:"Loading..."})]})}):t!=null&&t.enabled&&!r?i.jsx(v1,{}):i.jsx(i.Fragment,{children:e})}function y1(){return i.jsx(dg,{children:i.jsx(x1,{children:i.jsx(rg,{children:i.jsxs(ht,{path:"/",element:i.jsx(O0,{}),children:[i.jsx(ht,{index:!0,element:i.jsx(Ld,{})}),i.jsx(ht,{path:"agents",element:i.jsx(Ld,{})}),i.jsx(ht,{path:"agents/:agentId",element:i.jsx(q0,{})}),i.jsx(ht,{path:"tasks",element:i.jsx(X0,{})}),i.jsx(ht,{path:"jobs",element:i.jsx(r1,{})}),i.jsx(ht,{path:"jobs/:jobId",element:i.jsx(d1,{})}),i.jsx(ht,{path:"runs/:runId",element:i.jsx(f1,{})}),i.jsx(ht,{path:"tests/:testId",element:i.jsx(h1,{})}),i.jsx(ht,{path:"deployments/:deploymentId",element:i.jsx(m1,{})})]})})})})}const zd=localStorage.getItem("flow-theme");if(zd)try{const{state:e}=JSON.parse(zd);e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}catch{}const g1=new Xx({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}});Nl.createRoot(document.getElementById("root")).render(i.jsx(Vo.StrictMode,{children:i.jsx(Zx,{client:g1,children:i.jsx(y1,{})})})); diff --git a/src/flow/ui/ui/assets/index-D-N1qwda.js b/src/flow/ui/ui/assets/index-D-N1qwda.js new file mode 100644 index 0000000000000000000000000000000000000000..f944202a0c2f023a38c1e60f8418c823f1886ddb --- /dev/null +++ b/src/flow/ui/ui/assets/index-D-N1qwda.js @@ -0,0 +1,292 @@ +var Ju=e=>{throw TypeError(e)};var Hi=(e,t,n)=>t.has(e)||Ju("Cannot "+n);var y=(e,t,n)=>(Hi(e,t,"read from private field"),n?n.call(e):t.get(e)),$=(e,t,n)=>t.has(e)?Ju("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),z=(e,t,n,r)=>(Hi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),W=(e,t,n)=>(Hi(e,t,"access private method"),n);var fa=(e,t,n,r)=>({set _(s){z(e,t,s,n)},get _(){return y(e,t,r)}});function Gm(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();function Kd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Hd={exports:{}},wi={},Wd={exports:{}},G={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var aa=Symbol.for("react.element"),Jm=Symbol.for("react.portal"),Ym=Symbol.for("react.fragment"),Xm=Symbol.for("react.strict_mode"),Zm=Symbol.for("react.profiler"),ep=Symbol.for("react.provider"),tp=Symbol.for("react.context"),np=Symbol.for("react.forward_ref"),rp=Symbol.for("react.suspense"),sp=Symbol.for("react.memo"),ap=Symbol.for("react.lazy"),Yu=Symbol.iterator;function ip(e){return e===null||typeof e!="object"?null:(e=Yu&&e[Yu]||e["@@iterator"],typeof e=="function"?e:null)}var qd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Gd=Object.assign,Jd={};function Yr(e,t,n){this.props=e,this.context=t,this.refs=Jd,this.updater=n||qd}Yr.prototype.isReactComponent={};Yr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Yr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Yd(){}Yd.prototype=Yr.prototype;function Ao(e,t,n){this.props=e,this.context=t,this.refs=Jd,this.updater=n||qd}var $o=Ao.prototype=new Yd;$o.constructor=Ao;Gd($o,Yr.prototype);$o.isPureReactComponent=!0;var Xu=Array.isArray,Xd=Object.prototype.hasOwnProperty,Uo={current:null},Zd={key:!0,ref:!0,__self:!0,__source:!0};function ef(e,t,n){var r,s={},a=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(a=""+t.key),t)Xd.call(t,r)&&!Zd.hasOwnProperty(r)&&(s[r]=t[r]);var o=arguments.length-2;if(o===1)s.children=n;else if(1>>1,Y=T[V];if(0>>1;Vs(X,L))hes(Ne,X)?(T[V]=Ne,T[he]=L,V=he):(T[V]=X,T[O]=L,V=O);else if(hes(Ne,L))T[V]=Ne,T[he]=L,V=he;else break e}}return A}function s(T,A){var L=T.sortIndex-A.sortIndex;return L!==0?L:T.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var u=[],c=[],h=1,d=null,p=3,x=!1,S=!1,j=!1,g=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(T){for(var A=n(c);A!==null;){if(A.callback===null)r(c);else if(A.startTime<=T)r(c),A.sortIndex=A.expirationTime,t(u,A);else break;A=n(c)}}function w(T){if(j=!1,v(T),!S)if(n(u)!==null)S=!0,Je(C);else{var A=n(c);A!==null&&ae(w,A.startTime-T)}}function C(T,A){S=!1,j&&(j=!1,m(_),_=-1),x=!0;var L=p;try{for(v(A),d=n(u);d!==null&&(!(d.expirationTime>A)||T&&!B());){var V=d.callback;if(typeof V=="function"){d.callback=null,p=d.priorityLevel;var Y=V(d.expirationTime<=A);A=e.unstable_now(),typeof Y=="function"?d.callback=Y:d===n(u)&&r(u),v(A)}else r(u);d=n(u)}if(d!==null)var R=!0;else{var O=n(c);O!==null&&ae(w,O.startTime-A),R=!1}return R}finally{d=null,p=L,x=!1}}var b=!1,N=null,_=-1,F=5,P=-1;function B(){return!(e.unstable_now()-PT||125V?(T.sortIndex=L,t(c,T),n(u)===null&&T===n(c)&&(j?(m(_),_=-1):j=!0,ae(w,L-V))):(T.sortIndex=Y,t(u,T),S||x||(S=!0,Je(C))),T},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(T){var A=p;return function(){var L=p;p=A;try{return T.apply(this,arguments)}finally{p=L}}}})(af);sf.exports=af;var yp=sf.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var gp=k,et=yp;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Nl=Object.prototype.hasOwnProperty,jp=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,ec={},tc={};function wp(e){return Nl.call(tc,e)?!0:Nl.call(ec,e)?!1:jp.test(e)?tc[e]=!0:(ec[e]=!0,!1)}function kp(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Sp(e,t,n,r){if(t===null||typeof t>"u"||kp(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Ue(e,t,n,r,s,a,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=l}var Te={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Te[e]=new Ue(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Te[t]=new Ue(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Te[e]=new Ue(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Te[e]=new Ue(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Te[e]=new Ue(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Te[e]=new Ue(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Te[e]=new Ue(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Te[e]=new Ue(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Te[e]=new Ue(e,5,!1,e.toLowerCase(),null,!1,!1)});var Vo=/[\-:]([a-z])/g;function Ko(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Vo,Ko);Te[t]=new Ue(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Vo,Ko);Te[t]=new Ue(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Vo,Ko);Te[t]=new Ue(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Te[e]=new Ue(e,1,!1,e.toLowerCase(),null,!1,!1)});Te.xlinkHref=new Ue("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Te[e]=new Ue(e,1,!1,e.toLowerCase(),null,!0,!0)});function Ho(e,t,n,r){var s=Te.hasOwnProperty(t)?Te[t]:null;(s!==null?s.type!==0:r||!(2o||s[l]!==a[o]){var u=` +`+s[l].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=l&&0<=o);break}}}finally{Gi=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?ps(e):""}function Np(e){switch(e.tag){case 5:return ps(e.type);case 16:return ps("Lazy");case 13:return ps("Suspense");case 19:return ps("SuspenseList");case 0:case 2:case 15:return e=Ji(e.type,!1),e;case 11:return e=Ji(e.type.render,!1),e;case 1:return e=Ji(e.type,!0),e;default:return""}}function El(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case dr:return"Fragment";case cr:return"Portal";case bl:return"Profiler";case Wo:return"StrictMode";case Cl:return"Suspense";case _l:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case uf:return(e.displayName||"Context")+".Consumer";case of:return(e._context.displayName||"Context")+".Provider";case qo:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Go:return t=e.displayName||null,t!==null?t:El(e.type)||"Memo";case Xt:t=e._payload,e=e._init;try{return El(e(t))}catch{}}return null}function bp(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return El(t);case 8:return t===Wo?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function _n(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function df(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Cp(e){var t=df(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(l){r=""+l,a.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function pa(e){e._valueTracker||(e._valueTracker=Cp(e))}function ff(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=df(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ha(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Pl(e,t){var n=t.checked;return fe({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function rc(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=_n(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function hf(e,t){t=t.checked,t!=null&&Ho(e,"checked",t,!1)}function Tl(e,t){hf(e,t);var n=_n(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ol(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ol(e,t.type,_n(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function sc(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ol(e,t,n){(t!=="number"||Ha(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var vs=Array.isArray;function kr(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=va.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Os(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var js={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},_p=["Webkit","ms","Moz","O"];Object.keys(js).forEach(function(e){_p.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),js[t]=js[e]})});function xf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||js.hasOwnProperty(e)&&js[e]?(""+t).trim():t+"px"}function yf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=xf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var Ep=fe({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Ml(e,t){if(t){if(Ep[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function zl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Fl=null;function Jo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Il=null,Sr=null,Nr=null;function lc(e){if(e=oa(e)){if(typeof Il!="function")throw Error(E(280));var t=e.stateNode;t&&(t=Ci(t),Il(e.stateNode,e.type,t))}}function gf(e){Sr?Nr?Nr.push(e):Nr=[e]:Sr=e}function jf(){if(Sr){var e=Sr,t=Nr;if(Nr=Sr=null,lc(e),t)for(e=0;e>>=0,e===0?32:31-(Ap(e)/$p|0)|0}var xa=64,ya=4194304;function xs(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Ja(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,a=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~s;o!==0?r=xs(o):(a&=l,a!==0&&(r=xs(a)))}else l=n&~s,l!==0?r=xs(l):a!==0&&(r=xs(a));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,a=t&-t,s>=a||s===16&&(a&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function ia(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-yt(t),e[t]=n}function Vp(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=ks),vc=" ",xc=!1;function $f(e,t){switch(e){case"keyup":return yv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Uf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var fr=!1;function jv(e,t){switch(e){case"compositionend":return Uf(t);case"keypress":return t.which!==32?null:(xc=!0,vc);case"textInput":return e=t.data,e===vc&&xc?null:e;default:return null}}function wv(e,t){if(fr)return e==="compositionend"||!su&&$f(e,t)?(e=Df(),Fa=tu=fn=null,fr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=wc(n)}}function Kf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Kf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Hf(){for(var e=window,t=Ha();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ha(e.document)}return t}function au(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Tv(e){var t=Hf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Kf(n.ownerDocument.documentElement,n)){if(r!==null&&au(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,a=Math.min(r.start,s);r=r.end===void 0?a:Math.min(r.end,s),!e.extend&&a>r&&(s=r,r=a,a=s),s=kc(n,a);var l=kc(n,r);s&&l&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,hr=null,Ql=null,Ns=null,Vl=!1;function Sc(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Vl||hr==null||hr!==Ha(r)||(r=hr,"selectionStart"in r&&au(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Ns&&Is(Ns,r)||(Ns=r,r=Za(Ql,"onSelect"),0vr||(e.current=Jl[vr],Jl[vr]=null,vr--)}function se(e,t){vr++,Jl[vr]=e.current,e.current=t}var En={},ze=Tn(En),He=Tn(!1),Yn=En;function Br(e,t){var n=e.type.contextTypes;if(!n)return En;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},a;for(a in n)s[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function We(e){return e=e.childContextTypes,e!=null}function ti(){oe(He),oe(ze)}function Tc(e,t,n){if(ze.current!==En)throw Error(E(168));se(ze,t),se(He,n)}function th(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(E(108,bp(e)||"Unknown",s));return fe({},n,r)}function ni(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||En,Yn=ze.current,se(ze,e),se(He,He.current),!0}function Oc(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=th(e,t,Yn),r.__reactInternalMemoizedMergedChildContext=e,oe(He),oe(ze),se(ze,e)):oe(He),se(He,n)}var Rt=null,_i=!1,cl=!1;function nh(e){Rt===null?Rt=[e]:Rt.push(e)}function Bv(e){_i=!0,nh(e)}function On(){if(!cl&&Rt!==null){cl=!0;var e=0,t=re;try{var n=Rt;for(re=1;e>=l,s-=l,Dt=1<<32-yt(t)+s|n<_?(F=N,N=null):F=N.sibling;var P=p(m,N,v[_],w);if(P===null){N===null&&(N=F);break}e&&N&&P.alternate===null&&t(m,N),f=a(P,f,_),b===null?C=P:b.sibling=P,b=P,N=F}if(_===v.length)return n(m,N),ue&&Rn(m,_),C;if(N===null){for(;__?(F=N,N=null):F=N.sibling;var B=p(m,N,P.value,w);if(B===null){N===null&&(N=F);break}e&&N&&B.alternate===null&&t(m,N),f=a(B,f,_),b===null?C=B:b.sibling=B,b=B,N=F}if(P.done)return n(m,N),ue&&Rn(m,_),C;if(N===null){for(;!P.done;_++,P=v.next())P=d(m,P.value,w),P!==null&&(f=a(P,f,_),b===null?C=P:b.sibling=P,b=P);return ue&&Rn(m,_),C}for(N=r(m,N);!P.done;_++,P=v.next())P=x(N,m,_,P.value,w),P!==null&&(e&&P.alternate!==null&&N.delete(P.key===null?_:P.key),f=a(P,f,_),b===null?C=P:b.sibling=P,b=P);return e&&N.forEach(function(D){return t(m,D)}),ue&&Rn(m,_),C}function g(m,f,v,w){if(typeof v=="object"&&v!==null&&v.type===dr&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case ma:e:{for(var C=v.key,b=f;b!==null;){if(b.key===C){if(C=v.type,C===dr){if(b.tag===7){n(m,b.sibling),f=s(b,v.props.children),f.return=m,m=f;break e}}else if(b.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Xt&&Mc(C)===b.type){n(m,b.sibling),f=s(b,v.props),f.ref=ds(m,b,v),f.return=m,m=f;break e}n(m,b);break}else t(m,b);b=b.sibling}v.type===dr?(f=Gn(v.props.children,m.mode,w,v.key),f.return=m,m=f):(w=Va(v.type,v.key,v.props,null,m.mode,w),w.ref=ds(m,f,v),w.return=m,m=w)}return l(m);case cr:e:{for(b=v.key;f!==null;){if(f.key===b)if(f.tag===4&&f.stateNode.containerInfo===v.containerInfo&&f.stateNode.implementation===v.implementation){n(m,f.sibling),f=s(f,v.children||[]),f.return=m,m=f;break e}else{n(m,f);break}else t(m,f);f=f.sibling}f=yl(v,m.mode,w),f.return=m,m=f}return l(m);case Xt:return b=v._init,g(m,f,b(v._payload),w)}if(vs(v))return S(m,f,v,w);if(is(v))return j(m,f,v,w);ba(m,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,f!==null&&f.tag===6?(n(m,f.sibling),f=s(f,v),f.return=m,m=f):(n(m,f),f=xl(v,m.mode,w),f.return=m,m=f),l(m)):n(m,f)}return g}var Vr=ih(!0),lh=ih(!1),ai=Tn(null),ii=null,gr=null,uu=null;function cu(){uu=gr=ii=null}function du(e){var t=ai.current;oe(ai),e._currentValue=t}function Zl(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Cr(e,t){ii=e,uu=gr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Ke=!0),e.firstContext=null)}function ut(e){var t=e._currentValue;if(uu!==e)if(e={context:e,memoizedValue:t,next:null},gr===null){if(ii===null)throw Error(E(308));gr=e,ii.dependencies={lanes:0,firstContext:e}}else gr=gr.next=e;return t}var Fn=null;function fu(e){Fn===null?Fn=[e]:Fn.push(e)}function oh(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,fu(t)):(n.next=s.next,s.next=n),t.interleaved=n,Kt(e,r)}function Kt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Zt=!1;function hu(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function uh(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function $t(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function wn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Z&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Kt(e,n)}return s=r.interleaved,s===null?(t.next=t,fu(r)):(t.next=s.next,s.next=t),r.interleaved=t,Kt(e,n)}function Da(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Xo(e,n)}}function zc(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?s=a=l:a=a.next=l,n=n.next}while(n!==null);a===null?s=a=t:a=a.next=t}else s=a=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function li(e,t,n,r){var s=e.updateQueue;Zt=!1;var a=s.firstBaseUpdate,l=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var u=o,c=u.next;u.next=null,l===null?a=c:l.next=c,l=u;var h=e.alternate;h!==null&&(h=h.updateQueue,o=h.lastBaseUpdate,o!==l&&(o===null?h.firstBaseUpdate=c:o.next=c,h.lastBaseUpdate=u))}if(a!==null){var d=s.baseState;l=0,h=c=u=null,o=a;do{var p=o.lane,x=o.eventTime;if((r&p)===p){h!==null&&(h=h.next={eventTime:x,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var S=e,j=o;switch(p=t,x=n,j.tag){case 1:if(S=j.payload,typeof S=="function"){d=S.call(x,d,p);break e}d=S;break e;case 3:S.flags=S.flags&-65537|128;case 0:if(S=j.payload,p=typeof S=="function"?S.call(x,d,p):S,p==null)break e;d=fe({},d,p);break e;case 2:Zt=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[o]:p.push(o))}else x={eventTime:x,lane:p,tag:o.tag,payload:o.payload,callback:o.callback,next:null},h===null?(c=h=x,u=d):h=h.next=x,l|=p;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;p=o,o=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(h===null&&(u=d),s.baseState=u,s.firstBaseUpdate=c,s.lastBaseUpdate=h,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else a===null&&(s.shared.lanes=0);er|=l,e.lanes=l,e.memoizedState=d}}function Fc(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=fl.transition;fl.transition={};try{e(!1),t()}finally{re=n,fl.transition=r}}function Ch(){return ct().memoizedState}function Hv(e,t,n){var r=Sn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},_h(e))Eh(t,n);else if(n=oh(e,t,n,r),n!==null){var s=Ae();gt(n,e,r,s),Ph(n,t,r)}}function Wv(e,t,n){var r=Sn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(_h(e))Eh(t,s);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var l=t.lastRenderedState,o=a(l,n);if(s.hasEagerState=!0,s.eagerState=o,jt(o,l)){var u=t.interleaved;u===null?(s.next=s,fu(t)):(s.next=u.next,u.next=s),t.interleaved=s;return}}catch{}finally{}n=oh(e,t,s,r),n!==null&&(s=Ae(),gt(n,e,r,s),Ph(n,t,r))}}function _h(e){var t=e.alternate;return e===de||t!==null&&t===de}function Eh(e,t){bs=ui=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Ph(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Xo(e,n)}}var ci={readContext:ut,useCallback:Oe,useContext:Oe,useEffect:Oe,useImperativeHandle:Oe,useInsertionEffect:Oe,useLayoutEffect:Oe,useMemo:Oe,useReducer:Oe,useRef:Oe,useState:Oe,useDebugValue:Oe,useDeferredValue:Oe,useTransition:Oe,useMutableSource:Oe,useSyncExternalStore:Oe,useId:Oe,unstable_isNewReconciler:!1},qv={readContext:ut,useCallback:function(e,t){return St().memoizedState=[e,t===void 0?null:t],e},useContext:ut,useEffect:Dc,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,$a(4194308,4,wh.bind(null,t,e),n)},useLayoutEffect:function(e,t){return $a(4194308,4,e,t)},useInsertionEffect:function(e,t){return $a(4,2,e,t)},useMemo:function(e,t){var n=St();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=St();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Hv.bind(null,de,e),[r.memoizedState,e]},useRef:function(e){var t=St();return e={current:e},t.memoizedState=e},useState:Ic,useDebugValue:wu,useDeferredValue:function(e){return St().memoizedState=e},useTransition:function(){var e=Ic(!1),t=e[0];return e=Kv.bind(null,e[1]),St().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=de,s=St();if(ue){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),_e===null)throw Error(E(349));Zn&30||hh(r,t,n)}s.memoizedState=n;var a={value:n,getSnapshot:t};return s.queue=a,Dc(ph.bind(null,r,a,e),[e]),r.flags|=2048,Ks(9,mh.bind(null,r,a,n,t),void 0,null),n},useId:function(){var e=St(),t=_e.identifierPrefix;if(ue){var n=At,r=Dt;n=(r&~(1<<32-yt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Qs++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[_t]=t,e[$s]=r,Ah(e,t,!1,!1),t.stateNode=e;e:{switch(l=zl(n,r),n){case"dialog":ie("cancel",e),ie("close",e),s=r;break;case"iframe":case"object":case"embed":ie("load",e),s=r;break;case"video":case"audio":for(s=0;sWr&&(t.flags|=128,r=!0,fs(a,!1),t.lanes=4194304)}else{if(!r)if(e=oi(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),fs(a,!0),a.tail===null&&a.tailMode==="hidden"&&!l.alternate&&!ue)return Le(t),null}else 2*xe()-a.renderingStartTime>Wr&&n!==1073741824&&(t.flags|=128,r=!0,fs(a,!1),t.lanes=4194304);a.isBackwards?(l.sibling=t.child,t.child=l):(n=a.last,n!==null?n.sibling=l:t.child=l,a.last=l)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=xe(),t.sibling=null,n=ce.current,se(ce,r?n&1|2:n&1),t):(Le(t),null);case 22:case 23:return _u(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ye&1073741824&&(Le(t),t.subtreeFlags&6&&(t.flags|=8192)):Le(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function nx(e,t){switch(lu(t),t.tag){case 1:return We(t.type)&&ti(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Kr(),oe(He),oe(ze),vu(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return pu(t),null;case 13:if(oe(ce),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));Qr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return oe(ce),null;case 4:return Kr(),null;case 10:return du(t.type._context),null;case 22:case 23:return _u(),null;case 24:return null;default:return null}}var _a=!1,Me=!1,rx=typeof WeakSet=="function"?WeakSet:Set,I=null;function jr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){pe(e,t,r)}else n.current=null}function oo(e,t,n){try{n()}catch(r){pe(e,t,r)}}var Gc=!1;function sx(e,t){if(Kl=Ya,e=Hf(),au(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break e}var l=0,o=-1,u=-1,c=0,h=0,d=e,p=null;t:for(;;){for(var x;d!==n||s!==0&&d.nodeType!==3||(o=l+s),d!==a||r!==0&&d.nodeType!==3||(u=l+r),d.nodeType===3&&(l+=d.nodeValue.length),(x=d.firstChild)!==null;)p=d,d=x;for(;;){if(d===e)break t;if(p===n&&++c===s&&(o=l),p===a&&++h===r&&(u=l),(x=d.nextSibling)!==null)break;d=p,p=d.parentNode}d=x}n=o===-1||u===-1?null:{start:o,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Hl={focusedElem:e,selectionRange:n},Ya=!1,I=t;I!==null;)if(t=I,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,I=e;else for(;I!==null;){t=I;try{var S=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(S!==null){var j=S.memoizedProps,g=S.memoizedState,m=t.stateNode,f=m.getSnapshotBeforeUpdate(t.elementType===t.type?j:ht(t.type,j),g);m.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var v=t.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(w){pe(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,I=e;break}I=t.return}return S=Gc,Gc=!1,S}function Cs(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var a=s.destroy;s.destroy=void 0,a!==void 0&&oo(t,n,a)}s=s.next}while(s!==r)}}function Ti(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function uo(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Bh(e){var t=e.alternate;t!==null&&(e.alternate=null,Bh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[_t],delete t[$s],delete t[Gl],delete t[$v],delete t[Uv])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Qh(e){return e.tag===5||e.tag===3||e.tag===4}function Jc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Qh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function co(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ei));else if(r!==4&&(e=e.child,e!==null))for(co(e,t,n),e=e.sibling;e!==null;)co(e,t,n),e=e.sibling}function fo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(fo(e,t,n),e=e.sibling;e!==null;)fo(e,t,n),e=e.sibling}var Ee=null,vt=!1;function Jt(e,t,n){for(n=n.child;n!==null;)Vh(e,t,n),n=n.sibling}function Vh(e,t,n){if(Pt&&typeof Pt.onCommitFiberUnmount=="function")try{Pt.onCommitFiberUnmount(ki,n)}catch{}switch(n.tag){case 5:Me||jr(n,t);case 6:var r=Ee,s=vt;Ee=null,Jt(e,t,n),Ee=r,vt=s,Ee!==null&&(vt?(e=Ee,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ee.removeChild(n.stateNode));break;case 18:Ee!==null&&(vt?(e=Ee,n=n.stateNode,e.nodeType===8?ul(e.parentNode,n):e.nodeType===1&&ul(e,n),zs(e)):ul(Ee,n.stateNode));break;case 4:r=Ee,s=vt,Ee=n.stateNode.containerInfo,vt=!0,Jt(e,t,n),Ee=r,vt=s;break;case 0:case 11:case 14:case 15:if(!Me&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var a=s,l=a.destroy;a=a.tag,l!==void 0&&(a&2||a&4)&&oo(n,t,l),s=s.next}while(s!==r)}Jt(e,t,n);break;case 1:if(!Me&&(jr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){pe(n,t,o)}Jt(e,t,n);break;case 21:Jt(e,t,n);break;case 22:n.mode&1?(Me=(r=Me)||n.memoizedState!==null,Jt(e,t,n),Me=r):Jt(e,t,n);break;default:Jt(e,t,n)}}function Yc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new rx),t.forEach(function(r){var s=hx.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function ft(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=l),r&=~a}if(r=s,r=xe()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*ix(r/1960))-r,10e?16:e,hn===null)var r=!1;else{if(e=hn,hn=null,hi=0,Z&6)throw Error(E(331));var s=Z;for(Z|=4,I=e.current;I!==null;){var a=I,l=a.child;if(I.flags&16){var o=a.deletions;if(o!==null){for(var u=0;uxe()-bu?qn(e,0):Nu|=n),qe(e,t)}function Xh(e,t){t===0&&(e.mode&1?(t=ya,ya<<=1,!(ya&130023424)&&(ya=4194304)):t=1);var n=Ae();e=Kt(e,t),e!==null&&(ia(e,t,n),qe(e,n))}function fx(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Xh(e,n)}function hx(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),Xh(e,n)}var Zh;Zh=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||He.current)Ke=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Ke=!1,ex(e,t,n);Ke=!!(e.flags&131072)}else Ke=!1,ue&&t.flags&1048576&&rh(t,si,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ua(e,t),e=t.pendingProps;var s=Br(t,ze.current);Cr(t,n),s=yu(null,t,r,e,s,n);var a=gu();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,We(r)?(a=!0,ni(t)):a=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,hu(t),s.updater=Pi,t.stateNode=s,s._reactInternals=t,to(t,r,e,n),t=so(null,t,r,!0,a,n)):(t.tag=0,ue&&a&&iu(t),Ie(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ua(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=px(r),e=ht(r,e),s){case 0:t=ro(null,t,r,e,n);break e;case 1:t=Hc(null,t,r,e,n);break e;case 11:t=Vc(null,t,r,e,n);break e;case 14:t=Kc(null,t,r,ht(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ht(r,s),ro(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ht(r,s),Hc(e,t,r,s,n);case 3:e:{if(Fh(t),e===null)throw Error(E(387));r=t.pendingProps,a=t.memoizedState,s=a.element,uh(e,t),li(t,r,null,n);var l=t.memoizedState;if(r=l.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){s=Hr(Error(E(423)),t),t=Wc(e,t,r,n,s);break e}else if(r!==s){s=Hr(Error(E(424)),t),t=Wc(e,t,r,n,s);break e}else for(Xe=jn(t.stateNode.containerInfo.firstChild),Ze=t,ue=!0,xt=null,n=lh(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Qr(),r===s){t=Ht(e,t,n);break e}Ie(e,t,r,n)}t=t.child}return t;case 5:return ch(t),e===null&&Xl(t),r=t.type,s=t.pendingProps,a=e!==null?e.memoizedProps:null,l=s.children,Wl(r,s)?l=null:a!==null&&Wl(r,a)&&(t.flags|=32),zh(e,t),Ie(e,t,l,n),t.child;case 6:return e===null&&Xl(t),null;case 13:return Ih(e,t,n);case 4:return mu(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Vr(t,null,r,n):Ie(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ht(r,s),Vc(e,t,r,s,n);case 7:return Ie(e,t,t.pendingProps,n),t.child;case 8:return Ie(e,t,t.pendingProps.children,n),t.child;case 12:return Ie(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,a=t.memoizedProps,l=s.value,se(ai,r._currentValue),r._currentValue=l,a!==null)if(jt(a.value,l)){if(a.children===s.children&&!He.current){t=Ht(e,t,n);break e}}else for(a=t.child,a!==null&&(a.return=t);a!==null;){var o=a.dependencies;if(o!==null){l=a.child;for(var u=o.firstContext;u!==null;){if(u.context===r){if(a.tag===1){u=$t(-1,n&-n),u.tag=2;var c=a.updateQueue;if(c!==null){c=c.shared;var h=c.pending;h===null?u.next=u:(u.next=h.next,h.next=u),c.pending=u}}a.lanes|=n,u=a.alternate,u!==null&&(u.lanes|=n),Zl(a.return,n,t),o.lanes|=n;break}u=u.next}}else if(a.tag===10)l=a.type===t.type?null:a.child;else if(a.tag===18){if(l=a.return,l===null)throw Error(E(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),Zl(l,n,t),l=a.sibling}else l=a.child;if(l!==null)l.return=a;else for(l=a;l!==null;){if(l===t){l=null;break}if(a=l.sibling,a!==null){a.return=l.return,l=a;break}l=l.return}a=l}Ie(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Cr(t,n),s=ut(s),r=r(s),t.flags|=1,Ie(e,t,r,n),t.child;case 14:return r=t.type,s=ht(r,t.pendingProps),s=ht(r.type,s),Kc(e,t,r,s,n);case 15:return Rh(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ht(r,s),Ua(e,t),t.tag=1,We(r)?(e=!0,ni(t)):e=!1,Cr(t,n),Th(t,r,s),to(t,r,s,n),so(null,t,r,!0,e,n);case 19:return Dh(e,t,n);case 22:return Mh(e,t,n)}throw Error(E(156,t.tag))};function em(e,t){return _f(e,t)}function mx(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function lt(e,t,n,r){return new mx(e,t,n,r)}function Pu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function px(e){if(typeof e=="function")return Pu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===qo)return 11;if(e===Go)return 14}return 2}function Nn(e,t){var n=e.alternate;return n===null?(n=lt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Va(e,t,n,r,s,a){var l=2;if(r=e,typeof e=="function")Pu(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case dr:return Gn(n.children,s,a,t);case Wo:l=8,s|=8;break;case bl:return e=lt(12,n,t,s|2),e.elementType=bl,e.lanes=a,e;case Cl:return e=lt(13,n,t,s),e.elementType=Cl,e.lanes=a,e;case _l:return e=lt(19,n,t,s),e.elementType=_l,e.lanes=a,e;case cf:return Li(n,s,a,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case of:l=10;break e;case uf:l=9;break e;case qo:l=11;break e;case Go:l=14;break e;case Xt:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=lt(l,n,t,s),t.elementType=e,t.type=r,t.lanes=a,t}function Gn(e,t,n,r){return e=lt(7,e,r,t),e.lanes=n,e}function Li(e,t,n,r){return e=lt(22,e,r,t),e.elementType=cf,e.lanes=n,e.stateNode={isHidden:!1},e}function xl(e,t,n){return e=lt(6,e,null,t),e.lanes=n,e}function yl(e,t,n){return t=lt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function vx(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Xi(0),this.expirationTimes=Xi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Xi(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Tu(e,t,n,r,s,a,l,o,u){return e=new vx(e,t,n,o,u),t===1?(t=1,a===!0&&(t|=8)):t=0,a=lt(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},hu(a),e}function xx(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(sm)}catch(e){console.error(e)}}sm(),rf.exports=tt;var kx=rf.exports,ad=kx;Sl.createRoot=ad.createRoot,Sl.hydrateRoot=ad.hydrateRoot;var es=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Sx={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},nn,Do,Md,Nx=(Md=class{constructor(){$(this,nn,Sx);$(this,Do,!1)}setTimeoutProvider(e){z(this,nn,e)}setTimeout(e,t){return y(this,nn).setTimeout(e,t)}clearTimeout(e){y(this,nn).clearTimeout(e)}setInterval(e,t){return y(this,nn).setInterval(e,t)}clearInterval(e){y(this,nn).clearInterval(e)}},nn=new WeakMap,Do=new WeakMap,Md),Dn=new Nx;function bx(e){setTimeout(e,0)}var nr=typeof window>"u"||"Deno"in globalThis;function De(){}function Cx(e,t){return typeof e=="function"?e(t):e}function xo(e){return typeof e=="number"&&e>=0&&e!==1/0}function am(e,t){return Math.max(e+(t||0)-Date.now(),0)}function bn(e,t){return typeof e=="function"?e(t):e}function st(e,t){return typeof e=="function"?e(t):e}function id(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:a,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==Mu(l,t.options))return!1}else if(!Ws(t.queryKey,l))return!1}if(n!=="all"){const u=t.isActive();if(n==="active"&&!u||n==="inactive"&&u)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||s&&s!==t.state.fetchStatus||a&&!a(t))}function ld(e,t){const{exact:n,status:r,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(rr(t.options.mutationKey)!==rr(a))return!1}else if(!Ws(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function Mu(e,t){return((t==null?void 0:t.queryKeyHashFn)||rr)(e)}function rr(e){return JSON.stringify(e,(t,n)=>yo(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function Ws(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Ws(e[n],t[n])):!1}var _x=Object.prototype.hasOwnProperty;function im(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=od(e)&&od(t);if(!r&&!(yo(e)&&yo(t)))return t;const a=(r?e:Object.keys(e)).length,l=r?t:Object.keys(t),o=l.length,u=r?new Array(o):{};let c=0;for(let h=0;h{Dn.setTimeout(t,e)})}function go(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?im(e,t):t}function Px(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Tx(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var zu=Symbol();function lm(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===zu?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Fu(e,t){return typeof e=="function"?e(...t):!!e}function Ox(e,t,n){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),e}var An,rn,Pr,zd,Lx=(zd=class extends es{constructor(){super();$(this,An);$(this,rn);$(this,Pr);z(this,Pr,t=>{if(!nr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){y(this,rn)||this.setEventListener(y(this,Pr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,rn))==null||t.call(this),z(this,rn,void 0))}setEventListener(t){var n;z(this,Pr,t),(n=y(this,rn))==null||n.call(this),z(this,rn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){y(this,An)!==t&&(z(this,An,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof y(this,An)=="boolean"?y(this,An):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},An=new WeakMap,rn=new WeakMap,Pr=new WeakMap,zd),Iu=new Lx;function jo(){let e,t;const n=new Promise((s,a)=>{e=s,t=a});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var Rx=bx;function Mx(){let e=[],t=0,n=o=>{o()},r=o=>{o()},s=Rx;const a=o=>{t?e.push(o):s(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&s(()=>{r(()=>{o.forEach(u=>{n(u)})})})};return{batch:o=>{let u;t++;try{u=o()}finally{t--,t||l()}return u},batchCalls:o=>(...u)=>{a(()=>{o(...u)})},schedule:a,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{s=o}}}var ke=Mx(),Tr,sn,Or,Fd,zx=(Fd=class extends es{constructor(){super();$(this,Tr,!0);$(this,sn);$(this,Or);z(this,Or,t=>{if(!nr&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){y(this,sn)||this.setEventListener(y(this,Or))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,sn))==null||t.call(this),z(this,sn,void 0))}setEventListener(t){var n;z(this,Or,t),(n=y(this,sn))==null||n.call(this),z(this,sn,t(this.setOnline.bind(this)))}setOnline(t){y(this,Tr)!==t&&(z(this,Tr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return y(this,Tr)}},Tr=new WeakMap,sn=new WeakMap,Or=new WeakMap,Fd),xi=new zx;function Fx(e){return Math.min(1e3*2**e,3e4)}function om(e){return(e??"online")==="online"?xi.isOnline():!0}var wo=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function um(e){let t=!1,n=0,r;const s=jo(),a=()=>s.status!=="pending",l=j=>{var g;if(!a()){const m=new wo(j);p(m),(g=e.onCancel)==null||g.call(e,m)}},o=()=>{t=!0},u=()=>{t=!1},c=()=>Iu.isFocused()&&(e.networkMode==="always"||xi.isOnline())&&e.canRun(),h=()=>om(e.networkMode)&&e.canRun(),d=j=>{a()||(r==null||r(),s.resolve(j))},p=j=>{a()||(r==null||r(),s.reject(j))},x=()=>new Promise(j=>{var g;r=m=>{(a()||c())&&j(m)},(g=e.onPause)==null||g.call(e)}).then(()=>{var j;r=void 0,a()||(j=e.onContinue)==null||j.call(e)}),S=()=>{if(a())return;let j;const g=n===0?e.initialPromise:void 0;try{j=g??e.fn()}catch(m){j=Promise.reject(m)}Promise.resolve(j).then(d).catch(m=>{var b;if(a())return;const f=e.retry??(nr?0:3),v=e.retryDelay??Fx,w=typeof v=="function"?v(n,m):v,C=f===!0||typeof f=="number"&&nc()?void 0:x()).then(()=>{t?p(m):S()})})};return{promise:s,status:()=>s.status,cancel:l,continue:()=>(r==null||r(),s),cancelRetry:o,continueRetry:u,canStart:h,start:()=>(h()?S():x().then(S),s)}}var $n,Id,cm=(Id=class{constructor(){$(this,$n)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),xo(this.gcTime)&&z(this,$n,Dn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(nr?1/0:5*60*1e3))}clearGcTimeout(){y(this,$n)&&(Dn.clearTimeout(y(this,$n)),z(this,$n,void 0))}},$n=new WeakMap,Id),Un,Lr,rt,Bn,be,ea,Qn,mt,Ot,Dd,Ix=(Dd=class extends cm{constructor(t){super();$(this,mt);$(this,Un);$(this,Lr);$(this,rt);$(this,Bn);$(this,be);$(this,ea);$(this,Qn);z(this,Qn,!1),z(this,ea,t.defaultOptions),this.setOptions(t.options),this.observers=[],z(this,Bn,t.client),z(this,rt,y(this,Bn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,z(this,Un,dd(this.options)),this.state=t.state??y(this,Un),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=y(this,be))==null?void 0:t.promise}setOptions(t){if(this.options={...y(this,ea),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=dd(this.options);n.data!==void 0&&(this.setState(cd(n.data,n.dataUpdatedAt)),z(this,Un,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&y(this,rt).remove(this)}setData(t,n){const r=go(this.state.data,t,this.options);return W(this,mt,Ot).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){W(this,mt,Ot).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=y(this,be))==null?void 0:r.promise;return(s=y(this,be))==null||s.cancel(t),n?n.then(De).catch(De):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(y(this,Un))}isActive(){return this.observers.some(t=>st(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===zu||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>bn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!am(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,be))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,be))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),y(this,rt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(y(this,be)&&(y(this,Qn)?y(this,be).cancel({revert:!0}):y(this,be).cancelRetry()),this.scheduleGc()),y(this,rt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||W(this,mt,Ot).call(this,{type:"invalidate"})}async fetch(t,n){var u,c,h,d,p,x,S,j,g,m,f,v;if(this.state.fetchStatus!=="idle"&&((u=y(this,be))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(y(this,be))return y(this,be).continueRetry(),y(this,be).promise}if(t&&this.setOptions(t),!this.options.queryFn){const w=this.observers.find(C=>C.options.queryFn);w&&this.setOptions(w.options)}const r=new AbortController,s=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(z(this,Qn,!0),r.signal)})},a=()=>{const w=lm(this.options,n),b=(()=>{const N={client:y(this,Bn),queryKey:this.queryKey,meta:this.meta};return s(N),N})();return z(this,Qn,!1),this.options.persister?this.options.persister(w,b,this):w(b)},o=(()=>{const w={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:y(this,Bn),state:this.state,fetchFn:a};return s(w),w})();(c=this.options.behavior)==null||c.onFetch(o,this),z(this,Lr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((h=o.fetchOptions)==null?void 0:h.meta))&&W(this,mt,Ot).call(this,{type:"fetch",meta:(d=o.fetchOptions)==null?void 0:d.meta}),z(this,be,um({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:w=>{w instanceof wo&&w.revert&&this.setState({...y(this,Lr),fetchStatus:"idle"}),r.abort()},onFail:(w,C)=>{W(this,mt,Ot).call(this,{type:"failed",failureCount:w,error:C})},onPause:()=>{W(this,mt,Ot).call(this,{type:"pause"})},onContinue:()=>{W(this,mt,Ot).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const w=await y(this,be).start();if(w===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(w),(x=(p=y(this,rt).config).onSuccess)==null||x.call(p,w,this),(j=(S=y(this,rt).config).onSettled)==null||j.call(S,w,this.state.error,this),w}catch(w){if(w instanceof wo){if(w.silent)return y(this,be).promise;if(w.revert){if(this.state.data===void 0)throw w;return this.state.data}}throw W(this,mt,Ot).call(this,{type:"error",error:w}),(m=(g=y(this,rt).config).onError)==null||m.call(g,w,this),(v=(f=y(this,rt).config).onSettled)==null||v.call(f,this.state.data,w,this),w}finally{this.scheduleGc()}}},Un=new WeakMap,Lr=new WeakMap,rt=new WeakMap,Bn=new WeakMap,be=new WeakMap,ea=new WeakMap,Qn=new WeakMap,mt=new WeakSet,Ot=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...dm(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...cd(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return z(this,Lr,t.manual?s:void 0),s;case"error":const a=t.error;return{...r,error:a,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),ke.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),y(this,rt).notify({query:this,type:"updated",action:t})})},Dd);function dm(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:om(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function cd(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function dd(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Be,J,ta,Fe,Vn,Rr,Mt,an,na,Mr,zr,Kn,Hn,ln,Fr,te,gs,ko,So,No,bo,Co,_o,Eo,fm,Ad,Dx=(Ad=class extends es{constructor(t,n){super();$(this,te);$(this,Be);$(this,J);$(this,ta);$(this,Fe);$(this,Vn);$(this,Rr);$(this,Mt);$(this,an);$(this,na);$(this,Mr);$(this,zr);$(this,Kn);$(this,Hn);$(this,ln);$(this,Fr,new Set);this.options=n,z(this,Be,t),z(this,an,null),z(this,Mt,jo()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(y(this,J).addObserver(this),fd(y(this,J),this.options)?W(this,te,gs).call(this):this.updateResult(),W(this,te,bo).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Po(y(this,J),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Po(y(this,J),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,W(this,te,Co).call(this),W(this,te,_o).call(this),y(this,J).removeObserver(this)}setOptions(t){const n=this.options,r=y(this,J);if(this.options=y(this,Be).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof st(this.options.enabled,y(this,J))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");W(this,te,Eo).call(this),y(this,J).setOptions(this.options),n._defaulted&&!vi(this.options,n)&&y(this,Be).getQueryCache().notify({type:"observerOptionsUpdated",query:y(this,J),observer:this});const s=this.hasListeners();s&&hd(y(this,J),r,this.options,n)&&W(this,te,gs).call(this),this.updateResult(),s&&(y(this,J)!==r||st(this.options.enabled,y(this,J))!==st(n.enabled,y(this,J))||bn(this.options.staleTime,y(this,J))!==bn(n.staleTime,y(this,J)))&&W(this,te,ko).call(this);const a=W(this,te,So).call(this);s&&(y(this,J)!==r||st(this.options.enabled,y(this,J))!==st(n.enabled,y(this,J))||a!==y(this,ln))&&W(this,te,No).call(this,a)}getOptimisticResult(t){const n=y(this,Be).getQueryCache().build(y(this,Be),t),r=this.createResult(n,t);return $x(this,r)&&(z(this,Fe,r),z(this,Rr,this.options),z(this,Vn,y(this,J).state)),r}getCurrentResult(){return y(this,Fe)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&y(this,Mt).status==="pending"&&y(this,Mt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){y(this,Fr).add(t)}getCurrentQuery(){return y(this,J)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=y(this,Be).defaultQueryOptions(t),r=y(this,Be).getQueryCache().build(y(this,Be),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return W(this,te,gs).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),y(this,Fe)))}createResult(t,n){var F;const r=y(this,J),s=this.options,a=y(this,Fe),l=y(this,Vn),o=y(this,Rr),c=t!==r?t.state:y(this,ta),{state:h}=t;let d={...h},p=!1,x;if(n._optimisticResults){const P=this.hasListeners(),B=!P&&fd(t,n),D=P&&hd(t,r,n,s);(B||D)&&(d={...d,...dm(h.data,t.options)}),n._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:S,errorUpdatedAt:j,status:g}=d;x=d.data;let m=!1;if(n.placeholderData!==void 0&&x===void 0&&g==="pending"){let P;a!=null&&a.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(P=a.data,m=!0):P=typeof n.placeholderData=="function"?n.placeholderData((F=y(this,zr))==null?void 0:F.state.data,y(this,zr)):n.placeholderData,P!==void 0&&(g="success",x=go(a==null?void 0:a.data,P,n),p=!0)}if(n.select&&x!==void 0&&!m)if(a&&x===(l==null?void 0:l.data)&&n.select===y(this,na))x=y(this,Mr);else try{z(this,na,n.select),x=n.select(x),x=go(a==null?void 0:a.data,x,n),z(this,Mr,x),z(this,an,null)}catch(P){z(this,an,P)}y(this,an)&&(S=y(this,an),x=y(this,Mr),j=Date.now(),g="error");const f=d.fetchStatus==="fetching",v=g==="pending",w=g==="error",C=v&&f,b=x!==void 0,_={status:g,fetchStatus:d.fetchStatus,isPending:v,isSuccess:g==="success",isError:w,isInitialLoading:C,isLoading:C,data:x,dataUpdatedAt:d.dataUpdatedAt,error:S,errorUpdatedAt:j,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:d.dataUpdateCount>0||d.errorUpdateCount>0,isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:f,isRefetching:f&&!v,isLoadingError:w&&!b,isPaused:d.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:w&&b,isStale:Du(t,n),refetch:this.refetch,promise:y(this,Mt),isEnabled:st(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const P=_.data!==void 0,B=_.status==="error"&&!P,D=je=>{B?je.reject(_.error):P&&je.resolve(_.data)},U=()=>{const je=z(this,Mt,_.promise=jo());D(je)},ne=y(this,Mt);switch(ne.status){case"pending":t.queryHash===r.queryHash&&D(ne);break;case"fulfilled":(B||_.data!==ne.value)&&U();break;case"rejected":(!B||_.error!==ne.reason)&&U();break}}return _}updateResult(){const t=y(this,Fe),n=this.createResult(y(this,J),this.options);if(z(this,Vn,y(this,J).state),z(this,Rr,this.options),y(this,Vn).data!==void 0&&z(this,zr,y(this,J)),vi(n,t))return;z(this,Fe,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!y(this,Fr).size)return!0;const l=new Set(a??y(this,Fr));return this.options.throwOnError&&l.add("error"),Object.keys(y(this,Fe)).some(o=>{const u=o;return y(this,Fe)[u]!==t[u]&&l.has(u)})};W(this,te,fm).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&W(this,te,bo).call(this)}},Be=new WeakMap,J=new WeakMap,ta=new WeakMap,Fe=new WeakMap,Vn=new WeakMap,Rr=new WeakMap,Mt=new WeakMap,an=new WeakMap,na=new WeakMap,Mr=new WeakMap,zr=new WeakMap,Kn=new WeakMap,Hn=new WeakMap,ln=new WeakMap,Fr=new WeakMap,te=new WeakSet,gs=function(t){W(this,te,Eo).call(this);let n=y(this,J).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(De)),n},ko=function(){W(this,te,Co).call(this);const t=bn(this.options.staleTime,y(this,J));if(nr||y(this,Fe).isStale||!xo(t))return;const r=am(y(this,Fe).dataUpdatedAt,t)+1;z(this,Kn,Dn.setTimeout(()=>{y(this,Fe).isStale||this.updateResult()},r))},So=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(y(this,J)):this.options.refetchInterval)??!1},No=function(t){W(this,te,_o).call(this),z(this,ln,t),!(nr||st(this.options.enabled,y(this,J))===!1||!xo(y(this,ln))||y(this,ln)===0)&&z(this,Hn,Dn.setInterval(()=>{(this.options.refetchIntervalInBackground||Iu.isFocused())&&W(this,te,gs).call(this)},y(this,ln)))},bo=function(){W(this,te,ko).call(this),W(this,te,No).call(this,W(this,te,So).call(this))},Co=function(){y(this,Kn)&&(Dn.clearTimeout(y(this,Kn)),z(this,Kn,void 0))},_o=function(){y(this,Hn)&&(Dn.clearInterval(y(this,Hn)),z(this,Hn,void 0))},Eo=function(){const t=y(this,Be).getQueryCache().build(y(this,Be),this.options);if(t===y(this,J))return;const n=y(this,J);z(this,J,t),z(this,ta,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},fm=function(t){ke.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(y(this,Fe))}),y(this,Be).getQueryCache().notify({query:y(this,J),type:"observerResultsUpdated"})})},Ad);function Ax(e,t){return st(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function fd(e,t){return Ax(e,t)||e.state.data!==void 0&&Po(e,t,t.refetchOnMount)}function Po(e,t,n){if(st(t.enabled,e)!==!1&&bn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Du(e,t)}return!1}function hd(e,t,n,r){return(e!==t||st(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Du(e,n)}function Du(e,t){return st(t.enabled,e)!==!1&&e.isStaleByTime(bn(t.staleTime,e))}function $x(e,t){return!vi(e.getCurrentResult(),t)}function md(e){return{onFetch:(t,n)=>{var h,d,p,x,S;const r=t.options,s=(p=(d=(h=t.fetchOptions)==null?void 0:h.meta)==null?void 0:d.fetchMore)==null?void 0:p.direction,a=((x=t.state.data)==null?void 0:x.pages)||[],l=((S=t.state.data)==null?void 0:S.pageParams)||[];let o={pages:[],pageParams:[]},u=0;const c=async()=>{let j=!1;const g=v=>{Ox(v,()=>t.signal,()=>j=!0)},m=lm(t.options,t.fetchOptions),f=async(v,w,C)=>{if(j)return Promise.reject();if(w==null&&v.pages.length)return Promise.resolve(v);const N=(()=>{const B={client:t.client,queryKey:t.queryKey,pageParam:w,direction:C?"backward":"forward",meta:t.options.meta};return g(B),B})(),_=await m(N),{maxPages:F}=t.options,P=C?Tx:Px;return{pages:P(v.pages,_,F),pageParams:P(v.pageParams,w,F)}};if(s&&a.length){const v=s==="backward",w=v?Ux:pd,C={pages:a,pageParams:l},b=w(r,C);o=await f(C,b,v)}else{const v=e??a.length;do{const w=u===0?l[0]??r.initialPageParam:pd(r,o);if(u>0&&w==null)break;o=await f(o,w),u++}while(u{var j,g;return(g=(j=t.options).persister)==null?void 0:g.call(j,c,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=c}}}function pd(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Ux(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var ra,Nt,Re,Wn,bt,Yt,$d,Bx=($d=class extends cm{constructor(t){super();$(this,bt);$(this,ra);$(this,Nt);$(this,Re);$(this,Wn);z(this,ra,t.client),this.mutationId=t.mutationId,z(this,Re,t.mutationCache),z(this,Nt,[]),this.state=t.state||hm(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){y(this,Nt).includes(t)||(y(this,Nt).push(t),this.clearGcTimeout(),y(this,Re).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){z(this,Nt,y(this,Nt).filter(n=>n!==t)),this.scheduleGc(),y(this,Re).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){y(this,Nt).length||(this.state.status==="pending"?this.scheduleGc():y(this,Re).remove(this))}continue(){var t;return((t=y(this,Wn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,u,c,h,d,p,x,S,j,g,m,f,v,w,C,b,N;const n=()=>{W(this,bt,Yt).call(this,{type:"continue"})},r={client:y(this,ra),meta:this.options.meta,mutationKey:this.options.mutationKey};z(this,Wn,um({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(_,F)=>{W(this,bt,Yt).call(this,{type:"failed",failureCount:_,error:F})},onPause:()=>{W(this,bt,Yt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>y(this,Re).canRun(this)}));const s=this.state.status==="pending",a=!y(this,Wn).canStart();try{if(s)n();else{W(this,bt,Yt).call(this,{type:"pending",variables:t,isPaused:a}),y(this,Re).config.onMutate&&await y(this,Re).config.onMutate(t,this,r);const F=await((o=(l=this.options).onMutate)==null?void 0:o.call(l,t,r));F!==this.state.context&&W(this,bt,Yt).call(this,{type:"pending",context:F,variables:t,isPaused:a})}const _=await y(this,Wn).start();return await((c=(u=y(this,Re).config).onSuccess)==null?void 0:c.call(u,_,t,this.state.context,this,r)),await((d=(h=this.options).onSuccess)==null?void 0:d.call(h,_,t,this.state.context,r)),await((x=(p=y(this,Re).config).onSettled)==null?void 0:x.call(p,_,null,this.state.variables,this.state.context,this,r)),await((j=(S=this.options).onSettled)==null?void 0:j.call(S,_,null,t,this.state.context,r)),W(this,bt,Yt).call(this,{type:"success",data:_}),_}catch(_){try{await((m=(g=y(this,Re).config).onError)==null?void 0:m.call(g,_,t,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((v=(f=this.options).onError)==null?void 0:v.call(f,_,t,this.state.context,r))}catch(F){Promise.reject(F)}try{await((C=(w=y(this,Re).config).onSettled)==null?void 0:C.call(w,void 0,_,this.state.variables,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((N=(b=this.options).onSettled)==null?void 0:N.call(b,void 0,_,t,this.state.context,r))}catch(F){Promise.reject(F)}throw W(this,bt,Yt).call(this,{type:"error",error:_}),_}finally{y(this,Re).runNext(this)}}},ra=new WeakMap,Nt=new WeakMap,Re=new WeakMap,Wn=new WeakMap,bt=new WeakSet,Yt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),ke.batch(()=>{y(this,Nt).forEach(r=>{r.onMutationUpdate(t)}),y(this,Re).notify({mutation:this,type:"updated",action:t})})},$d);function hm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var zt,pt,sa,Ud,Qx=(Ud=class extends es{constructor(t={}){super();$(this,zt);$(this,pt);$(this,sa);this.config=t,z(this,zt,new Set),z(this,pt,new Map),z(this,sa,0)}build(t,n,r){const s=new Bx({client:t,mutationCache:this,mutationId:++fa(this,sa)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){y(this,zt).add(t);const n=Ta(t);if(typeof n=="string"){const r=y(this,pt).get(n);r?r.push(t):y(this,pt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(y(this,zt).delete(t)){const n=Ta(t);if(typeof n=="string"){const r=y(this,pt).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&y(this,pt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Ta(t);if(typeof n=="string"){const r=y(this,pt).get(n),s=r==null?void 0:r.find(a=>a.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=Ta(t);if(typeof n=="string"){const s=(r=y(this,pt).get(n))==null?void 0:r.find(a=>a!==t&&a.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){ke.batch(()=>{y(this,zt).forEach(t=>{this.notify({type:"removed",mutation:t})}),y(this,zt).clear(),y(this,pt).clear()})}getAll(){return Array.from(y(this,zt))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>ld(n,r))}findAll(t={}){return this.getAll().filter(n=>ld(t,n))}notify(t){ke.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return ke.batch(()=>Promise.all(t.map(n=>n.continue().catch(De))))}},zt=new WeakMap,pt=new WeakMap,sa=new WeakMap,Ud);function Ta(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Ft,on,Qe,It,Bt,Ka,To,Bd,Vx=(Bd=class extends es{constructor(n,r){super();$(this,Bt);$(this,Ft);$(this,on);$(this,Qe);$(this,It);z(this,Ft,n),this.setOptions(r),this.bindMethods(),W(this,Bt,Ka).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=y(this,Ft).defaultMutationOptions(n),vi(this.options,r)||y(this,Ft).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,Qe),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&rr(r.mutationKey)!==rr(this.options.mutationKey)?this.reset():((s=y(this,Qe))==null?void 0:s.state.status)==="pending"&&y(this,Qe).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=y(this,Qe))==null||n.removeObserver(this)}onMutationUpdate(n){W(this,Bt,Ka).call(this),W(this,Bt,To).call(this,n)}getCurrentResult(){return y(this,on)}reset(){var n;(n=y(this,Qe))==null||n.removeObserver(this),z(this,Qe,void 0),W(this,Bt,Ka).call(this),W(this,Bt,To).call(this)}mutate(n,r){var s;return z(this,It,r),(s=y(this,Qe))==null||s.removeObserver(this),z(this,Qe,y(this,Ft).getMutationCache().build(y(this,Ft),this.options)),y(this,Qe).addObserver(this),y(this,Qe).execute(n)}},Ft=new WeakMap,on=new WeakMap,Qe=new WeakMap,It=new WeakMap,Bt=new WeakSet,Ka=function(){var r;const n=((r=y(this,Qe))==null?void 0:r.state)??hm();z(this,on,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},To=function(n){ke.batch(()=>{var r,s,a,l,o,u,c,h;if(y(this,It)&&this.hasListeners()){const d=y(this,on).variables,p=y(this,on).context,x={client:y(this,Ft),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(s=(r=y(this,It)).onSuccess)==null||s.call(r,n.data,d,p,x)}catch(S){Promise.reject(S)}try{(l=(a=y(this,It)).onSettled)==null||l.call(a,n.data,null,d,p,x)}catch(S){Promise.reject(S)}}else if((n==null?void 0:n.type)==="error"){try{(u=(o=y(this,It)).onError)==null||u.call(o,n.error,d,p,x)}catch(S){Promise.reject(S)}try{(h=(c=y(this,It)).onSettled)==null||h.call(c,void 0,n.error,d,p,x)}catch(S){Promise.reject(S)}}}this.listeners.forEach(d=>{d(y(this,on))})})},Bd),Ct,Qd,Kx=(Qd=class extends es{constructor(t={}){super();$(this,Ct);this.config=t,z(this,Ct,new Map)}build(t,n,r){const s=n.queryKey,a=n.queryHash??Mu(s,n);let l=this.get(a);return l||(l=new Ix({client:t,queryKey:s,queryHash:a,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(l)),l}add(t){y(this,Ct).has(t.queryHash)||(y(this,Ct).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=y(this,Ct).get(t.queryHash);n&&(t.destroy(),n===t&&y(this,Ct).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){ke.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return y(this,Ct).get(t)}getAll(){return[...y(this,Ct).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>id(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>id(t,r)):n}notify(t){ke.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){ke.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){ke.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ct=new WeakMap,Qd),me,un,cn,Ir,Dr,dn,Ar,$r,Vd,Hx=(Vd=class{constructor(e={}){$(this,me);$(this,un);$(this,cn);$(this,Ir);$(this,Dr);$(this,dn);$(this,Ar);$(this,$r);z(this,me,e.queryCache||new Kx),z(this,un,e.mutationCache||new Qx),z(this,cn,e.defaultOptions||{}),z(this,Ir,new Map),z(this,Dr,new Map),z(this,dn,0)}mount(){fa(this,dn)._++,y(this,dn)===1&&(z(this,Ar,Iu.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,me).onFocus())})),z(this,$r,xi.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,me).onOnline())})))}unmount(){var e,t;fa(this,dn)._--,y(this,dn)===0&&((e=y(this,Ar))==null||e.call(this),z(this,Ar,void 0),(t=y(this,$r))==null||t.call(this),z(this,$r,void 0))}isFetching(e){return y(this,me).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return y(this,un).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,me).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=y(this,me).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(bn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return y(this,me).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=y(this,me).get(r.queryHash),a=s==null?void 0:s.state.data,l=Cx(t,a);if(l!==void 0)return y(this,me).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return ke.batch(()=>y(this,me).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,me).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=y(this,me);ke.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=y(this,me);return ke.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=ke.batch(()=>y(this,me).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(De).catch(De)}invalidateQueries(e,t={}){return ke.batch(()=>(y(this,me).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=ke.batch(()=>y(this,me).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let a=s.fetch(void 0,n);return n.throwOnError||(a=a.catch(De)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(De)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=y(this,me).build(this,t);return n.isStaleByTime(bn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(De).catch(De)}fetchInfiniteQuery(e){return e.behavior=md(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(De).catch(De)}ensureInfiniteQueryData(e){return e.behavior=md(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return xi.isOnline()?y(this,un).resumePausedMutations():Promise.resolve()}getQueryCache(){return y(this,me)}getMutationCache(){return y(this,un)}getDefaultOptions(){return y(this,cn)}setDefaultOptions(e){z(this,cn,e)}setQueryDefaults(e,t){y(this,Ir).set(rr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...y(this,Ir).values()],n={};return t.forEach(r=>{Ws(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){y(this,Dr).set(rr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...y(this,Dr).values()],n={};return t.forEach(r=>{Ws(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...y(this,cn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Mu(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===zu&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...y(this,cn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){y(this,me).clear(),y(this,un).clear()}},me=new WeakMap,un=new WeakMap,cn=new WeakMap,Ir=new WeakMap,Dr=new WeakMap,dn=new WeakMap,Ar=new WeakMap,$r=new WeakMap,Vd),mm=k.createContext(void 0),qt=e=>{const t=k.useContext(mm);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Wx=({client:e,children:t})=>(k.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),i.jsx(mm.Provider,{value:e,children:t})),pm=k.createContext(!1),qx=()=>k.useContext(pm);pm.Provider;function Gx(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Jx=k.createContext(Gx()),Yx=()=>k.useContext(Jx),Xx=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Fu(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},Zx=e=>{k.useEffect(()=>{e.clearReset()},[e])},ey=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||Fu(n,[e.error,r])),ty=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},ny=(e,t)=>e.isLoading&&e.isFetching&&!t,ry=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,vd=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function sy(e,t,n){var p,x,S,j;const r=qx(),s=Yx(),a=qt(),l=a.defaultQueryOptions(e);(x=(p=a.getDefaultOptions().queries)==null?void 0:p._experimental_beforeQuery)==null||x.call(p,l);const o=a.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",ty(l),Xx(l,s,o),Zx(s);const u=!a.getQueryCache().get(l.queryHash),[c]=k.useState(()=>new t(a,l)),h=c.getOptimisticResult(l),d=!r&&e.subscribed!==!1;if(k.useSyncExternalStore(k.useCallback(g=>{const m=d?c.subscribe(ke.batchCalls(g)):De;return c.updateResult(),m},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),k.useEffect(()=>{c.setOptions(l)},[l,c]),ry(l,h))throw vd(l,c,s);if(ey({result:h,errorResetBoundary:s,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw h.error;if((j=(S=a.getDefaultOptions().queries)==null?void 0:S._experimental_afterQuery)==null||j.call(S,l,h),l.experimental_prefetchInRender&&!nr&&ny(h,r)){const g=u?vd(l,c,s):o==null?void 0:o.promise;g==null||g.catch(De).finally(()=>{c.updateResult()})}return l.notifyOnChangeProps?h:c.trackResult(h)}function ye(e,t){return sy(e,Dx)}function Ge(e,t){const n=qt(),[r]=k.useState(()=>new Vx(n,e));k.useEffect(()=>{r.setOptions(e)},[r,e]);const s=k.useSyncExternalStore(k.useCallback(l=>r.subscribe(ke.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=k.useCallback((l,o)=>{r.mutate(l,o).catch(De)},[r]);if(s.error&&Fu(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}/** + * @remix-run/router v1.23.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function qs(){return qs=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function Au(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function iy(){return Math.random().toString(36).substr(2,8)}function yd(e,t){return{usr:e.state,key:e.key,idx:t}}function Oo(e,t,n,r){return n===void 0&&(n=null),qs({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?ts(t):t,{state:n,key:t&&t.key||r||iy()})}function yi(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function ts(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function ly(e,t,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:a=!1}=r,l=s.history,o=mn.Pop,u=null,c=h();c==null&&(c=0,l.replaceState(qs({},l.state,{idx:c}),""));function h(){return(l.state||{idx:null}).idx}function d(){o=mn.Pop;let g=h(),m=g==null?null:g-c;c=g,u&&u({action:o,location:j.location,delta:m})}function p(g,m){o=mn.Push;let f=Oo(j.location,g,m);c=h()+1;let v=yd(f,c),w=j.createHref(f);try{l.pushState(v,"",w)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;s.location.assign(w)}a&&u&&u({action:o,location:j.location,delta:1})}function x(g,m){o=mn.Replace;let f=Oo(j.location,g,m);c=h();let v=yd(f,c),w=j.createHref(f);l.replaceState(v,"",w),a&&u&&u({action:o,location:j.location,delta:0})}function S(g){let m=s.location.origin!=="null"?s.location.origin:s.location.href,f=typeof g=="string"?g:yi(g);return f=f.replace(/ $/,"%20"),ve(m,"No window.location.(origin|href) available to create URL for href: "+f),new URL(f,m)}let j={get action(){return o},get location(){return e(s,l)},listen(g){if(u)throw new Error("A history only accepts one active listener");return s.addEventListener(xd,d),u=g,()=>{s.removeEventListener(xd,d),u=null}},createHref(g){return t(s,g)},createURL:S,encodeLocation(g){let m=S(g);return{pathname:m.pathname,search:m.search,hash:m.hash}},push:p,replace:x,go(g){return l.go(g)}};return j}var gd;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(gd||(gd={}));function oy(e,t,n){return n===void 0&&(n="/"),uy(e,t,n)}function uy(e,t,n,r){let s=typeof t=="string"?ts(t):t,a=qr(s.pathname||"/",n);if(a==null)return null;let l=vm(e);cy(l);let o=null;for(let u=0;o==null&&u{let u={relativePath:o===void 0?a.path||"":o,caseSensitive:a.caseSensitive===!0,childrenIndex:l,route:a};u.relativePath.startsWith("/")&&(ve(u.relativePath.startsWith(r),'Absolute route path "'+u.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),u.relativePath=u.relativePath.slice(r.length));let c=Cn([r,u.relativePath]),h=n.concat(u);a.children&&a.children.length>0&&(ve(a.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+c+'".')),vm(a.children,t,h,c)),!(a.path==null&&!a.index)&&t.push({path:c,score:xy(c,a.index),routesMeta:h})};return e.forEach((a,l)=>{var o;if(a.path===""||!((o=a.path)!=null&&o.includes("?")))s(a,l);else for(let u of xm(a.path))s(a,l,u)}),t}function xm(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return s?[a,""]:[a];let l=xm(r.join("/")),o=[];return o.push(...l.map(u=>u===""?a:[a,u].join("/"))),s&&o.push(...l),o.map(u=>e.startsWith("/")&&u===""?"/":u)}function cy(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:yy(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const dy=/^:[\w-]+$/,fy=3,hy=2,my=1,py=10,vy=-2,jd=e=>e==="*";function xy(e,t){let n=e.split("/"),r=n.length;return n.some(jd)&&(r+=vy),t&&(r+=hy),n.filter(s=>!jd(s)).reduce((s,a)=>s+(dy.test(a)?fy:a===""?my:py),r)}function yy(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function gy(e,t,n){let{routesMeta:r}=e,s={},a="/",l=[];for(let o=0;o{let{paramName:p,isOptional:x}=h;if(p==="*"){let j=o[d]||"";l=a.slice(0,a.length-j.length).replace(/(.)\/+$/,"$1")}const S=o[d];return x&&!S?c[p]=void 0:c[p]=(S||"").replace(/%2F/g,"/"),c},{}),pathname:a,pathnameBase:l,pattern:e}}function jy(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),Au(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,u)=>(r.push({paramName:o,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function wy(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Au(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function qr(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const ky=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Sy=e=>ky.test(e);function Ny(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?ts(e):e,a;if(n)if(Sy(n))a=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),Au(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?a=wd(n.substring(1),"/"):a=wd(n,t)}else a=t;return{pathname:a,search:_y(r),hash:Ey(s)}}function wd(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function gl(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function by(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function ym(e,t){let n=by(e);return t?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function gm(e,t,n,r){r===void 0&&(r=!1);let s;typeof e=="string"?s=ts(e):(s=qs({},e),ve(!s.pathname||!s.pathname.includes("?"),gl("?","pathname","search",s)),ve(!s.pathname||!s.pathname.includes("#"),gl("#","pathname","hash",s)),ve(!s.search||!s.search.includes("#"),gl("#","search","hash",s)));let a=e===""||s.pathname==="",l=a?"/":s.pathname,o;if(l==null)o=n;else{let d=t.length-1;if(!r&&l.startsWith("..")){let p=l.split("/");for(;p[0]==="..";)p.shift(),d-=1;s.pathname=p.join("/")}o=d>=0?t[d]:"/"}let u=Ny(s,o),c=l&&l!=="/"&&l.endsWith("/"),h=(a||l===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(c||h)&&(u.pathname+="/"),u}const Cn=e=>e.join("/").replace(/\/\/+/g,"/"),Cy=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),_y=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Ey=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Py(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const jm=["post","put","patch","delete"];new Set(jm);const Ty=["get",...jm];new Set(Ty);/** + * React Router v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Gs(){return Gs=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),k.useCallback(function(c,h){if(h===void 0&&(h={}),!o.current)return;if(typeof c=="number"){r.go(c);return}let d=gm(c,JSON.parse(l),a,h.relative==="path");e==null&&t!=="/"&&(d.pathname=d.pathname==="/"?t:Cn([t,d.pathname])),(h.replace?r.replace:r.push)(d,h.state,h)},[t,r,l,a,e])}const Ry=k.createContext(null);function My(e){let t=k.useContext(Gt).outlet;return t&&k.createElement(Ry.Provider,{value:e},t)}function Ai(){let{matches:e}=k.useContext(Gt),t=e[e.length-1];return t?t.params:{}}function $i(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=k.useContext(Ln),{matches:s}=k.useContext(Gt),{pathname:a}=ns(),l=JSON.stringify(ym(s,r.v7_relativeSplatPath));return k.useMemo(()=>gm(e,JSON.parse(l),a,n==="path"),[e,l,a,n])}function zy(e,t){return Fy(e,t)}function Fy(e,t,n,r){ca()||ve(!1);let{navigator:s}=k.useContext(Ln),{matches:a}=k.useContext(Gt),l=a[a.length-1],o=l?l.params:{};l&&l.pathname;let u=l?l.pathnameBase:"/";l&&l.route;let c=ns(),h;if(t){var d;let g=typeof t=="string"?ts(t):t;u==="/"||(d=g.pathname)!=null&&d.startsWith(u)||ve(!1),h=g}else h=c;let p=h.pathname||"/",x=p;if(u!=="/"){let g=u.replace(/^\//,"").split("/");x="/"+p.replace(/^\//,"").split("/").slice(g.length).join("/")}let S=oy(e,{pathname:x}),j=Uy(S&&S.map(g=>Object.assign({},g,{params:Object.assign({},o,g.params),pathname:Cn([u,s.encodeLocation?s.encodeLocation(g.pathname).pathname:g.pathname]),pathnameBase:g.pathnameBase==="/"?u:Cn([u,s.encodeLocation?s.encodeLocation(g.pathnameBase).pathname:g.pathnameBase])})),a,n,r);return t&&j?k.createElement(Di.Provider,{value:{location:Gs({pathname:"/",search:"",hash:"",state:null,key:"default"},h),navigationType:mn.Pop}},j):j}function Iy(){let e=Ky(),t=Py(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return k.createElement(k.Fragment,null,k.createElement("h2",null,"Unexpected Application Error!"),k.createElement("h3",{style:{fontStyle:"italic"}},t),n?k.createElement("pre",{style:s},n):null,null)}const Dy=k.createElement(Iy,null);class Ay extends k.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?k.createElement(Gt.Provider,{value:this.props.routeContext},k.createElement(km.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function $y(e){let{routeContext:t,match:n,children:r}=e,s=k.useContext(Ii);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),k.createElement(Gt.Provider,{value:t},r)}function Uy(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var a;if(!n)return null;if(n.errors)e=n.matches;else if((a=r)!=null&&a.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(s=n)==null?void 0:s.errors;if(o!=null){let h=l.findIndex(d=>d.route.id&&(o==null?void 0:o[d.route.id])!==void 0);h>=0||ve(!1),l=l.slice(0,Math.min(l.length,h+1))}let u=!1,c=-1;if(n&&r&&r.v7_partialHydration)for(let h=0;h=0?l=l.slice(0,c+1):l=[l[0]];break}}}return l.reduceRight((h,d,p)=>{let x,S=!1,j=null,g=null;n&&(x=o&&d.route.id?o[d.route.id]:void 0,j=d.route.errorElement||Dy,u&&(c<0&&p===0?(Wy("route-fallback"),S=!0,g=null):c===p&&(S=!0,g=d.route.hydrateFallbackElement||null)));let m=t.concat(l.slice(0,p+1)),f=()=>{let v;return x?v=j:S?v=g:d.route.Component?v=k.createElement(d.route.Component,null):d.route.element?v=d.route.element:v=h,k.createElement($y,{match:d,routeContext:{outlet:h,matches:m,isDataRoute:n!=null},children:v})};return n&&(d.route.ErrorBoundary||d.route.errorElement||p===0)?k.createElement(Ay,{location:n.location,revalidation:n.revalidation,component:j,error:x,children:f(),routeContext:{outlet:null,matches:m,isDataRoute:!0}}):f()},null)}var Nm=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Nm||{}),bm=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(bm||{});function By(e){let t=k.useContext(Ii);return t||ve(!1),t}function Qy(e){let t=k.useContext(wm);return t||ve(!1),t}function Vy(e){let t=k.useContext(Gt);return t||ve(!1),t}function Cm(e){let t=Vy(),n=t.matches[t.matches.length-1];return n.route.id||ve(!1),n.route.id}function Ky(){var e;let t=k.useContext(km),n=Qy(),r=Cm();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function Hy(){let{router:e}=By(Nm.UseNavigateStable),t=Cm(bm.UseNavigateStable),n=k.useRef(!1);return Sm(()=>{n.current=!0}),k.useCallback(function(s,a){a===void 0&&(a={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,Gs({fromRouteId:t},a)))},[e,t])}const kd={};function Wy(e,t,n){kd[e]||(kd[e]=!0)}function qy(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function Gy(e){return My(e.context)}function kt(e){ve(!1)}function Jy(e){let{basename:t="/",children:n=null,location:r,navigationType:s=mn.Pop,navigator:a,static:l=!1,future:o}=e;ca()&&ve(!1);let u=t.replace(/^\/*/,"/"),c=k.useMemo(()=>({basename:u,navigator:a,static:l,future:Gs({v7_relativeSplatPath:!1},o)}),[u,o,a,l]);typeof r=="string"&&(r=ts(r));let{pathname:h="/",search:d="",hash:p="",state:x=null,key:S="default"}=r,j=k.useMemo(()=>{let g=qr(h,u);return g==null?null:{location:{pathname:g,search:d,hash:p,state:x,key:S},navigationType:s}},[u,h,d,p,x,S,s]);return j==null?null:k.createElement(Ln.Provider,{value:c},k.createElement(Di.Provider,{children:n,value:j}))}function Yy(e){let{children:t,location:n}=e;return zy(Ro(t),n)}new Promise(()=>{});function Ro(e,t){t===void 0&&(t=[]);let n=[];return k.Children.forEach(e,(r,s)=>{if(!k.isValidElement(r))return;let a=[...t,s];if(r.type===k.Fragment){n.push.apply(n,Ro(r.props.children,a));return}r.type!==kt&&ve(!1),!r.props.index||!r.props.children||ve(!1);let l={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Ro(r.props.children,a)),n.push(l)}),n}/** + * React Router DOM v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function gi(){return gi=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[s]=e[s]);return n}function Xy(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Zy(e,t){return e.button===0&&(!t||t==="_self")&&!Xy(e)}const eg=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],tg=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],ng="6";try{window.__reactRouterVersion=ng}catch{}const rg=k.createContext({isTransitioning:!1}),sg="startTransition",Sd=dp[sg];function ag(e){let{basename:t,children:n,future:r,window:s}=e,a=k.useRef();a.current==null&&(a.current=ay({window:s,v5Compat:!0}));let l=a.current,[o,u]=k.useState({action:l.action,location:l.location}),{v7_startTransition:c}=r||{},h=k.useCallback(d=>{c&&Sd?Sd(()=>u(d)):u(d)},[u,c]);return k.useLayoutEffect(()=>l.listen(h),[l,h]),k.useEffect(()=>qy(r),[r]),k.createElement(Jy,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const ig=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",lg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Gr=k.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:a,replace:l,state:o,target:u,to:c,preventScrollReset:h,viewTransition:d}=t,p=_m(t,eg),{basename:x}=k.useContext(Ln),S,j=!1;if(typeof c=="string"&&lg.test(c)&&(S=c,ig))try{let v=new URL(window.location.href),w=c.startsWith("//")?new URL(v.protocol+c):new URL(c),C=qr(w.pathname,x);w.origin===v.origin&&C!=null?c=C+w.search+w.hash:j=!0}catch{}let g=Oy(c,{relative:s}),m=ug(c,{replace:l,state:o,target:u,preventScrollReset:h,relative:s,viewTransition:d});function f(v){r&&r(v),v.defaultPrevented||m(v)}return k.createElement("a",gi({},p,{href:S||g,onClick:j||a?r:f,ref:n,target:u}))}),Em=k.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:s=!1,className:a="",end:l=!1,style:o,to:u,viewTransition:c,children:h}=t,d=_m(t,tg),p=$i(u,{relative:d.relative}),x=ns(),S=k.useContext(wm),{navigator:j,basename:g}=k.useContext(Ln),m=S!=null&&cg(p)&&c===!0,f=j.encodeLocation?j.encodeLocation(p).pathname:p.pathname,v=x.pathname,w=S&&S.navigation&&S.navigation.location?S.navigation.location.pathname:null;s||(v=v.toLowerCase(),w=w?w.toLowerCase():null,f=f.toLowerCase()),w&&g&&(w=qr(w,g)||w);const C=f!=="/"&&f.endsWith("/")?f.length-1:f.length;let b=v===f||!l&&v.startsWith(f)&&v.charAt(C)==="/",N=w!=null&&(w===f||!l&&w.startsWith(f)&&w.charAt(f.length)==="/"),_={isActive:b,isPending:N,isTransitioning:m},F=b?r:void 0,P;typeof a=="function"?P=a(_):P=[a,b?"active":null,N?"pending":null,m?"transitioning":null].filter(Boolean).join(" ");let B=typeof o=="function"?o(_):o;return k.createElement(Gr,gi({},d,{"aria-current":F,className:P,ref:n,style:B,to:u,viewTransition:c}),typeof h=="function"?h(_):h)});var Mo;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Mo||(Mo={}));var Nd;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Nd||(Nd={}));function og(e){let t=k.useContext(Ii);return t||ve(!1),t}function ug(e,t){let{target:n,replace:r,state:s,preventScrollReset:a,relative:l,viewTransition:o}=t===void 0?{}:t,u=lr(),c=ns(),h=$i(e,{relative:l});return k.useCallback(d=>{if(Zy(d,n)){d.preventDefault();let p=r!==void 0?r:yi(c)===yi(h);u(e,{replace:p,state:s,preventScrollReset:a,relative:l,viewTransition:o})}},[c,u,h,r,s,n,e,a,l,o])}function cg(e,t){t===void 0&&(t={});let n=k.useContext(rg);n==null&&ve(!1);let{basename:r}=og(Mo.useViewTransitionState),s=$i(e,{relative:t.relative});if(!n.isTransitioning)return!1;let a=qr(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=qr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Lo(s.pathname,l)!=null||Lo(s.pathname,a)!=null}/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var dg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const fg=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),q=(e,t)=>{const n=k.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:a=2,absoluteStrokeWidth:l,className:o="",children:u,...c},h)=>k.createElement("svg",{ref:h,...dg,width:s,height:s,stroke:r,strokeWidth:l?Number(a)*24/Number(s):a,className:["lucide",`lucide-${fg(e)}`,o].join(" "),...c},[...t.map(([d,p])=>k.createElement(d,p)),...Array.isArray(u)?u:[u]]));return n.displayName=`${e}`,n};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pm=q("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const hg=q("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const mg=q("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const pg=q("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Tm=q("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const vg=q("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const xg=q("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Js=q("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const yg=q("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gg=q("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const jg=q("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const wg=q("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kg=q("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Sg=q("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bd=q("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ng=q("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bg=q("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cg=q("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _g=q("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $u=q("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Eg=q("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pg=q("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const da=q("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Om=q("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Tg=q("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Og=q("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ys=q("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Uu=q("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lg=q("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lm=q("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rg=q("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mg=q("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zg=q("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bu=q("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rm=q("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fg=q("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mm=q("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ui=q("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),Ig={},Cd=e=>{let t;const n=new Set,r=(h,d)=>{const p=typeof h=="function"?h(t):h;if(!Object.is(p,t)){const x=t;t=d??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(S=>S(t,x))}},s=()=>t,u={setState:r,getState:s,getInitialState:()=>c,subscribe:h=>(n.add(h),()=>n.delete(h)),destroy:()=>{(Ig?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},c=t=e(r,s,u);return u},Dg=e=>e?Cd(e):Cd;var zm={exports:{}},Fm={},Im={exports:{}},Dm={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Jr=k;function Ag(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var $g=typeof Object.is=="function"?Object.is:Ag,Ug=Jr.useState,Bg=Jr.useEffect,Qg=Jr.useLayoutEffect,Vg=Jr.useDebugValue;function Kg(e,t){var n=t(),r=Ug({inst:{value:n,getSnapshot:t}}),s=r[0].inst,a=r[1];return Qg(function(){s.value=n,s.getSnapshot=t,jl(s)&&a({inst:s})},[e,n,t]),Bg(function(){return jl(s)&&a({inst:s}),e(function(){jl(s)&&a({inst:s})})},[e]),Vg(n),n}function jl(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!$g(e,n)}catch{return!0}}function Hg(e,t){return t()}var Wg=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Hg:Kg;Dm.useSyncExternalStore=Jr.useSyncExternalStore!==void 0?Jr.useSyncExternalStore:Wg;Im.exports=Dm;var qg=Im.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Bi=k,Gg=qg;function Jg(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Yg=typeof Object.is=="function"?Object.is:Jg,Xg=Gg.useSyncExternalStore,Zg=Bi.useRef,e0=Bi.useEffect,t0=Bi.useMemo,n0=Bi.useDebugValue;Fm.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var a=Zg(null);if(a.current===null){var l={hasValue:!1,value:null};a.current=l}else l=a.current;a=t0(function(){function u(x){if(!c){if(c=!0,h=x,x=r(x),s!==void 0&&l.hasValue){var S=l.value;if(s(S,x))return d=S}return d=x}if(S=d,Yg(h,x))return S;var j=r(x);return s!==void 0&&s(S,j)?(h=x,S):(h=x,d=j)}var c=!1,h,d,p=n===void 0?null:n;return[function(){return u(t())},p===null?void 0:function(){return u(p())}]},[t,n,r,s]);var o=Xg(e,a[0],a[1]);return e0(function(){l.hasValue=!0,l.value=o},[o]),n0(o),o};zm.exports=Fm;var r0=zm.exports;const s0=Kd(r0),Am={},{useDebugValue:a0}=Qo,{useSyncExternalStoreWithSelector:i0}=s0;let _d=!1;const l0=e=>e;function o0(e,t=l0,n){(Am?"production":void 0)!=="production"&&n&&!_d&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),_d=!0);const r=i0(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return a0(r),r}const Ed=e=>{(Am?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?Dg(e):e,n=(r,s)=>o0(t,r,s);return Object.assign(n,t),n},Qi=e=>e?Ed(e):Ed,Vi="/api",Qu="flow_auth_token",Vu="flow_auth_expires",Ku="flow_auth_username";function Xs(){const e=localStorage.getItem(Qu),t=localStorage.getItem(Vu);return!e||!t?null:new Date(t)<=new Date?(Jn(),null):e}function Pd(e,t,n){localStorage.setItem(Qu,e),localStorage.setItem(Vu,t),localStorage.setItem(Ku,n)}function Jn(){localStorage.removeItem(Qu),localStorage.removeItem(Vu),localStorage.removeItem(Ku)}function Hu(){return localStorage.getItem(Ku)}let sr=null;function u0(e){sr=e}async function Q(e,t,n=!1){const r={"Content-Type":"application/json",...t==null?void 0:t.headers};if(!n){const a=Xs();a&&(r.Authorization=`Bearer ${a}`)}const s=await fetch(`${Vi}${e}`,{...t,headers:r});if(s.status===401){Jn(),sr&&sr();const a=await s.json().catch(()=>({detail:"Not authenticated"}));throw new Error(a.detail||"Not authenticated")}if(!s.ok){const a=await s.json().catch(()=>({detail:s.statusText}));throw new Error(a.detail||"API request failed")}if(s.status!==204)return s.json()}const ur={getConfig:()=>Q("/auth/config",void 0,!0),login:e=>Q("/auth/login",{method:"POST",body:JSON.stringify(e)},!0),getGitHubAuthUrl:()=>`${Vi}/auth/github`,getCurrentUser:()=>Q("/auth/me"),logout:()=>Q("/auth/logout",{method:"POST"})},Er={list:e=>{const t=new URLSearchParams;e!=null&&e.include_auto_generated&&t.set("include_auto_generated","true"),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return Q(`/configs${n?`?${n}`:""}`)},get:e=>Q(`/configs/${e}`),create:e=>Q("/configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Q(`/configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Q(`/configs/${e}`,{method:"DELETE"})},Et={list:e=>{const t=new URLSearchParams;e!=null&&e.category&&t.set("category",e.category),e!=null&&e.suite&&t.set("suite",e.suite);const n=t.toString();return Q(`/tasks${n?`?${n}`:""}`)},get:e=>Q(`/tasks/${e}`),create:e=>Q("/tasks",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Q(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Q(`/tasks/${e}`,{method:"DELETE"}),listSuites:()=>Q("/tasks/suites"),importSuite:e=>Q(`/tasks/import-suite?suite_name=${encodeURIComponent(e)}`,{method:"POST"})},Ut={list:e=>{const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return Q(`/jobs${n?`?${n}`:""}`)},get:e=>Q(`/jobs/${e}`),create:e=>Q("/jobs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Q(`/jobs/${e}`,{method:"PUT",body:JSON.stringify(t)}),start:async function*(e){var o;const t={},n=Xs();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Vi}/jobs/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Jn(),sr&&sr(),new Error("Not authenticated");if(!r.ok)throw new Error("Failed to start job");const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const a=new TextDecoder;let l="";for(;;){const{done:u,value:c}=await s.read();if(u)break;l+=a.decode(c,{stream:!0});const h=l.split(` +`);l=h.pop()||"";for(const d of h)d.startsWith("data: ")&&(yield JSON.parse(d.slice(6)))}},cancel:e=>Q(`/jobs/${e}/cancel`,{method:"POST"}),delete:e=>Q(`/jobs/${e}`,{method:"DELETE"})},zo={list:e=>{const t=new URLSearchParams;e!=null&&e.job_id&&t.set("job_id",e.job_id),e!=null&&e.candidate_name&&t.set("candidate_name",e.candidate_name),e!=null&&e.task_name&&t.set("task_name",e.task_name),(e==null?void 0:e.is_pareto)!==void 0&&t.set("is_pareto",String(e.is_pareto));const n=t.toString();return Q(`/runs${n?`?${n}`:""}`)},get:e=>Q(`/runs/${e}`),getJobSummary:e=>Q(`/runs/job/${e}/summary`)},Ps={list:e=>{const t=new URLSearchParams;e!=null&&e.agent_id&&t.set("agent_id",e.agent_id),e!=null&&e.limit&&t.set("limit",String(e.limit));const n=t.toString();return Q(`/tests${n?`?${n}`:""}`)},get:e=>Q(`/tests/${e}`),create:e=>Q("/tests",{method:"POST",body:JSON.stringify(e)}),start:async function*(e){var o;const t={},n=Xs();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Vi}/tests/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Jn(),sr&&sr(),new Error("Not authenticated");if(!r.ok){const u=await r.json().catch(()=>({detail:"Failed to start test"}));throw new Error(u.detail||"Failed to start test")}const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const a=new TextDecoder;let l="";for(;;){const{done:u,value:c}=await s.read();if(u)break;l+=a.decode(c,{stream:!0});const h=l.split(` +`);l=h.pop()||"";for(const d of h)d.startsWith("data: ")&&(yield JSON.parse(d.slice(6)))}},cancel:e=>Q(`/tests/${e}/cancel`,{method:"POST"}),delete:e=>Q(`/tests/${e}`,{method:"DELETE"})},c0={list:()=>Q("/llm-configs"),get:e=>Q(`/llm-configs/${e}`),getDefault:()=>Q("/llm-configs/default"),create:e=>Q("/llm-configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Q(`/llm-configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Q(`/llm-configs/${e}`,{method:"DELETE"}),setDefault:e=>Q(`/llm-configs/${e}/set-default`,{method:"POST"}),test:e=>Q(`/llm-configs/${e}/test`,{method:"POST"})},d0={list:()=>Q("/tools"),get:e=>Q(`/tools/${e}`)},$m={getAgentSchema:()=>Q("/schema/agent")},f0={start:e=>Q("/evaluate",{method:"POST",body:JSON.stringify(e)})},Fo={design:e=>Q("/experiment/design",{method:"POST",body:JSON.stringify(e)}),importYaml:e=>Q("/experiment/import-yaml",{method:"POST",body:JSON.stringify(e)}),validate:e=>Q("/experiment/validate",{method:"POST",body:JSON.stringify(e)}),generateCandidates:e=>Q("/experiment/generate-candidates",{method:"POST",body:JSON.stringify(e)})},Wu=Qi((e,t)=>(u0(()=>{e({isAuthenticated:!1,user:null,error:"Session expired. Please log in again."})}),{authConfig:null,isLoadingConfig:!0,isAuthenticated:!1,isLoading:!1,user:null,error:null,loadAuthConfig:async()=>{e({isLoadingConfig:!0});try{const n=await ur.getConfig();if(e({authConfig:n,isLoadingConfig:!1}),n.enabled){const r=Xs(),s=Hu();if(r&&s)try{const a=await ur.getCurrentUser();e({isAuthenticated:!0,user:a})}catch{Jn(),e({isAuthenticated:!1,user:null})}}else e({isAuthenticated:!0,user:{username:"anonymous",auth_mode:"none"}})}catch(n){console.error("Failed to load auth config:",n),e({isLoadingConfig:!1,error:"Failed to connect to server"})}},login:async(n,r)=>{e({isLoading:!0,error:null});try{const s=await ur.login({username:n,password:r});return Pd(s.access_token,s.expires_at,s.username),e({isAuthenticated:!0,isLoading:!1,user:{username:s.username,auth_mode:"basic"}}),!0}catch(s){return e({isLoading:!1,error:s instanceof Error?s.message:"Login failed"}),!1}},loginWithGitHub:()=>{window.location.href=ur.getGitHubAuthUrl()},handleOAuthCallback:()=>{const n=new URLSearchParams(window.location.search),r=n.get("auth_error");if(r)return e({error:r}),window.history.replaceState({},"",window.location.pathname),!0;if(n.get("auth_callback")==="true"){const s=n.get("token"),a=n.get("expires_at"),l=n.get("username");return s&&a&&l&&(Pd(s,a,l),e({isAuthenticated:!0,user:{username:l,auth_mode:"github"}})),window.history.replaceState({},"",window.location.pathname),!0}return!1},logout:async()=>{try{await ur.logout()}catch{}Jn(),e({isAuthenticated:!1,user:null,error:null})},checkAuth:async()=>{const{authConfig:n}=t();if(!(n!=null&&n.enabled)){e({isAuthenticated:!0});return}if(!Xs()){e({isAuthenticated:!1,user:null});return}try{const s=await ur.getCurrentUser();e({isAuthenticated:!0,user:s})}catch{Jn(),e({isAuthenticated:!1,user:null})}},clearError:()=>e({error:null})}));function K({variant:e="secondary",size:t="md",className:n="",icon:r,iconRight:s,loading:a=!1,children:l,disabled:o,...u}){const c="font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1.5 rounded-md",h={primary:"bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)]",secondary:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)] hover:bg-[var(--border)]",danger:"bg-[var(--error)] text-white hover:bg-red-600",ghost:"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"},d={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm"},p=t==="sm"?14:16;return i.jsxs("button",{className:`${c} ${h[e]} ${d[t]} ${n}`,disabled:o||a,...u,children:[a?i.jsx(da,{size:p,className:"animate-spin"}):r?i.jsx(r,{size:p}):null,l,s&&!a&&i.jsx(s,{size:p})]})}const h0={};function m0(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var a;const l=u=>u===null?null:JSON.parse(u,void 0),o=(a=n.getItem(s))!=null?a:null;return o instanceof Promise?o.then(l):l(o)},setItem:(s,a)=>n.setItem(s,JSON.stringify(a,void 0)),removeItem:s=>n.removeItem(s)}}const Zs=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return Zs(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return Zs(r)(n)}}}},p0=(e,t)=>(n,r,s)=>{let a={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:g=>g,version:0,merge:(g,m)=>({...m,...g}),...t},l=!1;const o=new Set,u=new Set;let c;try{c=a.getStorage()}catch{}if(!c)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...g)},r,s);const h=Zs(a.serialize),d=()=>{const g=a.partialize({...r()});let m;const f=h({state:g,version:a.version}).then(v=>c.setItem(a.name,v)).catch(v=>{m=v});if(m)throw m;return f},p=s.setState;s.setState=(g,m)=>{p(g,m),d()};const x=e((...g)=>{n(...g),d()},r,s);let S;const j=()=>{var g;if(!c)return;l=!1,o.forEach(f=>f(r()));const m=((g=a.onRehydrateStorage)==null?void 0:g.call(a,r()))||void 0;return Zs(c.getItem.bind(c))(a.name).then(f=>{if(f)return a.deserialize(f)}).then(f=>{if(f)if(typeof f.version=="number"&&f.version!==a.version){if(a.migrate)return a.migrate(f.state,f.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return f.state}).then(f=>{var v;return S=a.merge(f,(v=r())!=null?v:x),n(S,!0),d()}).then(()=>{m==null||m(S,void 0),l=!0,u.forEach(f=>f(S))}).catch(f=>{m==null||m(void 0,f)})};return s.persist={setOptions:g=>{a={...a,...g},g.getStorage&&(c=g.getStorage())},clearStorage:()=>{c==null||c.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>j(),hasHydrated:()=>l,onHydrate:g=>(o.add(g),()=>{o.delete(g)}),onFinishHydration:g=>(u.add(g),()=>{u.delete(g)})},j(),S||x},v0=(e,t)=>(n,r,s)=>{let a={storage:m0(()=>localStorage),partialize:j=>j,version:0,merge:(j,g)=>({...g,...j}),...t},l=!1;const o=new Set,u=new Set;let c=a.storage;if(!c)return e((...j)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...j)},r,s);const h=()=>{const j=a.partialize({...r()});return c.setItem(a.name,{state:j,version:a.version})},d=s.setState;s.setState=(j,g)=>{d(j,g),h()};const p=e((...j)=>{n(...j),h()},r,s);s.getInitialState=()=>p;let x;const S=()=>{var j,g;if(!c)return;l=!1,o.forEach(f=>{var v;return f((v=r())!=null?v:p)});const m=((g=a.onRehydrateStorage)==null?void 0:g.call(a,(j=r())!=null?j:p))||void 0;return Zs(c.getItem.bind(c))(a.name).then(f=>{if(f)if(typeof f.version=="number"&&f.version!==a.version){if(a.migrate)return[!0,a.migrate(f.state,f.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,f.state];return[!1,void 0]}).then(f=>{var v;const[w,C]=f;if(x=a.merge(C,(v=r())!=null?v:p),n(x,!0),w)return h()}).then(()=>{m==null||m(x,void 0),x=r(),l=!0,u.forEach(f=>f(x))}).catch(f=>{m==null||m(void 0,f)})};return s.persist={setOptions:j=>{a={...a,...j},j.storage&&(c=j.storage)},clearStorage:()=>{c==null||c.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>S(),hasHydrated:()=>l,onHydrate:j=>(o.add(j),()=>{o.delete(j)}),onFinishHydration:j=>(u.add(j),()=>{u.delete(j)})},a.skipHydration||S(),x||p},x0=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((h0?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),p0(e,t)):v0(e,t),Um=x0,y0=Qi()(Um((e,t)=>({theme:"light",setTheme:n=>{document.documentElement.setAttribute("data-theme",n),e({theme:n})},toggleTheme:()=>{const n=t().theme==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",n),e({theme:n})}}),{name:"flow-theme",onRehydrateStorage:()=>e=>{e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}}));function g0(){const{theme:e,toggleTheme:t}=y0();return i.jsx("button",{onClick:t,className:"p-2 rounded-md text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--accent)]","aria-label":`Switch to ${e==="dark"?"light":"dark"} mode`,title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:e==="dark"?i.jsx(zg,{size:16}):i.jsx(Og,{size:16})})}const j0=Qi()(Um((e,t)=>({sidebarCollapsed:!1,toggleSidebar:()=>{e({sidebarCollapsed:!t().sidebarCollapsed})},setSidebarCollapsed:n=>{e({sidebarCollapsed:n})}}),{name:"flow-layout"})),w0=[{path:"/agents",label:"Agents",icon:pg},{path:"/jobs",label:"Experiments",icon:bg},{path:"/tasks",label:"Datasets",icon:Sg}];function k0(){const e=ns(),{sidebarCollapsed:t,toggleSidebar:n}=j0(),r=s=>s==="/agents"?e.pathname==="/"||e.pathname==="/agents"||e.pathname.startsWith("/agents/"):s==="/jobs"?e.pathname.startsWith("/jobs")||e.pathname.startsWith("/runs"):e.pathname.startsWith(s);return i.jsxs("aside",{className:` + flex flex-col border-r border-[var(--border)] bg-[var(--bg-secondary)] + transition-all duration-200 + ${t?"w-14":"w-56"} + `,children:[i.jsx("nav",{className:"flex-1 py-2",children:w0.map(s=>{const a=r(s.path);return i.jsxs(Em,{to:s.path,title:t?s.label:void 0,className:` + flex items-center gap-3 px-4 py-2.5 text-sm transition-colors relative + ${a?"text-[var(--accent)] bg-[var(--accent-dim)] font-medium":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"} + `,children:[a&&i.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-r bg-[var(--accent)]"}),i.jsx(s.icon,{size:18}),!t&&i.jsx("span",{children:s.label})]},s.path)})}),i.jsx("button",{onClick:n,className:"flex items-center justify-center p-3 border-t border-[var(--border)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",title:t?"Expand sidebar":"Collapse sidebar",children:t?i.jsx(gg,{size:16}):i.jsx(yg,{size:16})})]})}function S0(){const{authConfig:e,user:t,logout:n}=Wu(),r=async()=>{await n()};return i.jsxs("div",{className:"h-screen flex flex-col",children:[i.jsx("header",{className:"border-b border-[var(--border)] bg-[var(--bg-secondary)] shrink-0",children:i.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between",children:[i.jsxs(Em,{to:"/",className:"text-lg font-semibold text-[var(--accent)] flex items-center gap-2 hover:opacity-80",children:[i.jsx(Ui,{size:20}),"Flow",i.jsx("span",{className:"text-[var(--text-secondary)] font-normal",children:"/optimize"})]}),i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(g0,{}),(e==null?void 0:e.enabled)&&t&&i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[i.jsx(Rm,{size:14}),i.jsx("span",{children:t.username})]}),i.jsx(K,{variant:"ghost",size:"sm",icon:Tg,onClick:r,title:"Sign out",children:"Sign out"})]})]})]})}),i.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[i.jsx(k0,{}),i.jsx("main",{className:"flex-1 overflow-y-auto bg-[var(--bg-primary)]",children:i.jsx("div",{className:"p-6",children:i.jsx(Gy,{})})})]})]})}const N0=["maf","miniagent","langgraph"],b0={maf:"Microsoft Agent Framework",miniagent:"MiniAgent",langgraph:"LangGraph"},C0={openai:"OpenAI",azure_openai:"Azure OpenAI",anthropic:"Anthropic",ollama:"Ollama",custom:"Custom (OpenAI-compatible)"};function ee({children:e,variant:t="default"}){const n={default:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)]",success:"bg-green-50 text-green-700 border border-green-200 dark:bg-green-900/30 dark:text-green-400 dark:border-green-800",warning:"bg-yellow-50 text-yellow-700 border border-yellow-200 dark:bg-yellow-900/30 dark:text-yellow-400 dark:border-yellow-800",error:"bg-red-50 text-red-700 border border-red-200 dark:bg-red-900/30 dark:text-red-400 dark:border-red-800",info:"bg-blue-50 text-blue-700 border border-blue-200 dark:bg-blue-900/30 dark:text-blue-400 dark:border-blue-800"};return i.jsx("span",{className:`inline-block px-2 py-0.5 text-xs font-medium rounded-md ${n[t]}`,children:e})}const _0={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"};function rs({isOpen:e,onClose:t,title:n,children:r,footer:s,size:a="md"}){return k.useEffect(()=>{const l=o=>{o.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",l),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",l),document.body.style.overflow=""}},[e,t]),e?i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[i.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),i.jsxs("div",{className:`relative bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg ${_0[a]} w-full mx-4 max-h-[80vh] flex flex-col`,children:[i.jsxs("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-b border-[var(--border)] px-4 py-3 flex items-center justify-between",children:[i.jsx("h2",{className:"font-semibold",children:n}),i.jsx("button",{onClick:t,className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"×"})]}),i.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r}),s&&i.jsx("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-t border-[var(--border)] px-4 py-3",children:s})]})]}):null}function pn({label:e,className:t="",...n}){return i.jsxs("div",{className:"space-y-1",children:[e&&i.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),i.jsx("input",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] ${t}`,...n})]})}function E0({label:e,className:t="",...n}){return i.jsxs("div",{className:"space-y-1",children:[e&&i.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),i.jsx("textarea",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] resize-y min-h-[100px] ${t}`,...n})]})}function ji({label:e,className:t="",...n}){return i.jsxs("label",{className:`flex items-center gap-2 cursor-pointer ${t}`,children:[i.jsx("input",{type:"checkbox",className:"w-4 h-4 bg-[var(--bg-primary)] border border-[var(--border)] rounded accent-[var(--accent)]",...n}),i.jsx("span",{className:"text-sm",children:e})]})}function Bm({columns:e,data:t,onRowClick:n,searchable:r=!1,searchPlaceholder:s="Search...",searchFilter:a,emptyMessage:l="No items found",emptyIcon:o}){const[u,c]=k.useState(""),[h,d]=k.useState(null),[p,x]=k.useState("asc"),S=k.useMemo(()=>{let g=t;if(r&&u&&a&&(g=g.filter(m=>a(m,u))),h){const m=e.find(f=>f.key===h);m!=null&&m.sortValue&&(g=[...g].sort((f,v)=>{const w=m.sortValue(f),C=m.sortValue(v),b=wC?1:0;return p==="asc"?b:-b}))}return g},[t,u,a,r,h,p,e]),j=g=>{const m=e.find(f=>f.key===g);m!=null&&m.sortable&&(h===g?x(p==="asc"?"desc":"asc"):(d(g),x("asc")))};return i.jsxs("div",{children:[r&&i.jsxs("div",{className:"mb-4 relative max-w-sm",children:[i.jsx(Lg,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]"}),i.jsx("input",{type:"text",placeholder:s,value:u,onChange:g=>c(g.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md pl-9 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]"})]}),S.length===0?i.jsxs("div",{className:"text-center py-16 text-[var(--text-secondary)]",children:[o&&i.jsx("div",{className:"mb-3 flex justify-center",children:o}),i.jsx("p",{children:l})]}):i.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsx("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:e.map(g=>i.jsx("th",{onClick:()=>j(g.key),className:`text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider ${g.sortable?"cursor-pointer hover:text-[var(--text-primary)]":""} ${g.className||""}`,children:i.jsxs("span",{className:"inline-flex items-center gap-1",children:[g.header,g.sortable&&h===g.key&&i.jsx("span",{children:p==="asc"?"↑":"↓"})]})},g.key))})}),i.jsx("tbody",{children:S.map((g,m)=>i.jsx("tr",{onClick:()=>n==null?void 0:n(g),className:`border-b border-[var(--border)] last:border-b-0 transition-colors ${n?"cursor-pointer hover:bg-[var(--bg-tertiary)]":""}`,children:e.map(f=>i.jsx("td",{className:`px-4 py-3 ${f.className||""}`,children:f.render(g)},f.key))},m))})]})})]})}function P0({variations:e,onChange:t,strategies:n,availableStrategies:r}){const s=r??Object.keys(n),a=()=>{const c=e.map(x=>x.strategy),h=s.find(x=>!c.includes(x))||"none",d=n[h],p={strategy:h};if(d!=null&&d.params)for(const[x,S]of Object.entries(d.params))S.default!==void 0&&(p[x]=S.default);t([...e,p])},l=c=>{t(e.filter((h,d)=>d!==c))},o=(c,h)=>{t(e.map((d,p)=>p===c?{...d,...h}:d))},u=(c,h)=>{const d=n[h],p={strategy:h};if(d!=null&&d.params)for(const[x,S]of Object.entries(d.params))S.default!==void 0&&(p[x]=S.default);o(c,p)};return i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"text-sm font-medium",children:"Compaction Strategies"}),i.jsx(K,{type:"button",variant:"ghost",size:"sm",icon:Uu,onClick:a,disabled:e.length>=s.length,children:"Add"})]}),e.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:'No compaction variations. Click "Add" to test different strategies.'}):i.jsx("div",{className:"space-y-2",children:e.map((c,h)=>{const d=n[c.strategy];return i.jsx("div",{className:"p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsxs("div",{className:"flex-1 space-y-2",children:[i.jsx("select",{className:"w-full px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:c.strategy,onChange:p=>u(h,p.target.value),children:s.map(p=>{var x;return i.jsx("option",{value:p,children:((x=n[p])==null?void 0:x.label)||p},p)})}),(d==null?void 0:d.description)&&i.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:d.description}),(d==null?void 0:d.params)&&Object.keys(d.params).length>0&&i.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:Object.entries(d.params).map(([p,x])=>i.jsx(T0,{name:p,schema:x,value:c[p],onChange:S=>o(h,{[p]:S})},p))})]}),i.jsx("button",{type:"button",onClick:()=>l(h),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:i.jsx(Mm,{size:16})})]})},h)})})]})}function T0({name:e,schema:t,value:n,onChange:r}){const s=e.replace(/_/g," ");return t.type==="boolean"?i.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[i.jsx("input",{type:"checkbox",checked:!!(n??t.default),onChange:a=>r(a.target.checked),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"capitalize",children:s})]}):i.jsxs("div",{children:[i.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:s}),i.jsx("input",{type:t.type==="number"?"number":"text",className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-xs",value:String(n!==void 0?n:t.default??""),onChange:a=>{if(t.type==="number"){const l=parseFloat(a.target.value);r(isNaN(l)?t.default:l)}else r(a.target.value)},min:t.min,max:t.max,step:t.max&&t.max<=1?.1:1})]})}function O0({variations:e,onChange:t,providers:n}){const r=()=>{const o=n[0],u={provider:(o==null?void 0:o.name)||"azure_openai",model:(o==null?void 0:o.models[0])||"gpt-4o"};t([...e,u])},s=o=>{t(e.filter((u,c)=>c!==o))},a=(o,u)=>{t(e.map((c,h)=>h===o?{...c,...u}:c))},l=(o,u)=>{const c=n.find(h=>h.name===u);a(o,{provider:u,model:(c==null?void 0:c.models[0])||""})};return i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"text-sm font-medium",children:"LLM Configurations"}),i.jsx(K,{type:"button",variant:"ghost",size:"sm",icon:Uu,onClick:r,children:"Add"})]}),e.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:`Uses agent's default LLM. Click "Add" to test different models.`}):i.jsx("div",{className:"space-y-2",children:e.map((o,u)=>{const c=n.find(h=>h.name===o.provider);return i.jsxs("div",{className:"flex items-center gap-2 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[i.jsx("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.provider,onChange:h=>l(u,h.target.value),children:n.map(h=>i.jsx("option",{value:h.name,children:h.label},h.name))}),c&&c.models.length>0?i.jsxs("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:h=>a(u,{model:h.target.value}),children:[c.models.map(h=>i.jsx("option",{value:h,children:h},h)),!c.models.includes(o.model)&&o.model&&i.jsx("option",{value:o.model,children:o.model})]}):i.jsx("input",{type:"text",className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:h=>a(u,{model:h.target.value}),placeholder:"Model ID"}),i.jsx("button",{type:"button",onClick:()=>s(u),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:i.jsx(Mm,{size:16})})]},u)})})]})}const Io={compaction:[],tools:[],llm_config:[],instructions:[],instruction_strategies:[]};function L0({agentId:e,agentName:t,agentFramework:n="maf",taskSuite:r,taskCount:s,schema:a,onVariationsChange:l,parallel:o,onParallelChange:u,budget:c,onBudgetChange:h,useLlmEval:d,onUseLlmEvalChange:p}){const[x,S]=k.useState(Io),[j,g]=k.useState(!1),[m,f]=k.useState(""),[v,w]=k.useState(null),C=a.frameworks[n],b=(C==null?void 0:C.compaction_strategies)||Object.keys(a.compaction_strategies),N=a.tool_presets||[],_=a.llm_providers||[],P=(()=>{let L=1;x.compaction.length>0&&(L*=x.compaction.length),x.tools.length>0&&(L*=x.tools.length),x.llm_config.length>0&&(L*=x.llm_config.length);const V=x.instructions.length+x.instruction_strategies.reduce((Y,R)=>Y+R.max_candidates,0);return V>0&&(L*=V),Math.min(L,c)})(),B=P*s,D=L=>{S(L),l==null||l(L)},U=Ge({mutationFn:L=>Fo.design(L),onSuccess:L=>{f(L.yaml_content),g(!0)}}),ne=Ge({mutationFn:L=>Fo.validate(L),onSuccess:L=>{w({valid:L.valid,errors:L.errors,warnings:L.warnings})}}),je=()=>({base_agent_id:e,task_suite:r,variations:x,parallel:o,budget:c,use_llm_eval:d}),Je=()=>{U.mutate(je())},ae=()=>{ne.mutate(je())},T=()=>{const L=new Blob([m],{type:"text/yaml"}),V=URL.createObjectURL(L),Y=document.createElement("a");Y.href=V,Y.download=`${t}_experiment.yaml`,Y.click(),URL.revokeObjectURL(V)},A=x.compaction.length>0||x.tools.length>0||x.llm_config.length>0||x.instructions.length>0||x.instruction_strategies.length>0;return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex flex-wrap gap-2",children:[i.jsxs(ee,{variant:"info",children:[P," candidates"]}),i.jsxs(ee,{children:[s," tasks"]}),i.jsxs(ee,{variant:B>100?"warning":"success",children:[B," total runs"]})]}),i.jsx(P0,{variations:x.compaction,onChange:L=>D({...x,compaction:L}),strategies:a.compaction_strategies,availableStrategies:b}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("label",{className:"text-sm font-medium",children:"Tool Presets"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(L=>i.jsxs("label",{className:`flex items-center gap-2 px-3 py-1.5 border rounded cursor-pointer transition-colors ${x.tools.includes(L.name)?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[i.jsx("input",{type:"checkbox",checked:x.tools.includes(L.name),onChange:V=>{const Y=V.target.checked?[...x.tools,L.name]:x.tools.filter(R=>R!==L.name);D({...x,tools:Y})},className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:L.name}),i.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",L.tools.length,")"]})]},L.name))}),x.tools.length>0&&i.jsxs("p",{className:"text-xs text-[var(--text-secondary)]",children:["Selected: ",x.tools.join(", ")]})]}),i.jsx(O0,{variations:x.llm_config,onChange:L=>D({...x,llm_config:L}),providers:_}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-4 space-y-4",children:[i.jsx("h4",{className:"text-sm font-medium",children:"Execution Settings"}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(pn,{label:"Parallel Workers",type:"number",value:o,onChange:L=>u(parseInt(L.target.value)||1),min:1,max:16}),i.jsx(pn,{label:"Budget (max candidates)",type:"number",value:c,onChange:L=>h(parseInt(L.target.value)||100),min:1,max:1e3})]}),i.jsx(ji,{label:"Use LLM evaluation",checked:d,onChange:L=>p(L.target.checked)}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] ml-6 -mt-2",children:d?"LLM-as-Judge scores task completion (0-1)":"Simple pass/fail based on task success"})]}),i.jsxs("div",{className:"flex items-center gap-2 border-t border-[var(--border)] pt-4",children:[i.jsx(K,{variant:"secondary",size:"sm",onClick:ae,loading:ne.isPending,children:"Validate"}),i.jsx(K,{variant:"secondary",size:"sm",icon:bd,onClick:Je,loading:U.isPending,children:"Export YAML"})]}),v&&i.jsxs("div",{className:`p-3 rounded border ${v.valid?"border-green-500/50 bg-green-500/10":"border-red-500/50 bg-red-500/10"}`,children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[v.valid?i.jsx(Tm,{size:16,className:"text-green-500"}):i.jsx(Pm,{size:16,className:"text-red-500"}),i.jsx("span",{className:"font-medium text-sm",children:v.valid?"Configuration valid":"Configuration has issues"})]}),v.errors.length>0&&i.jsx("ul",{className:"text-sm text-red-500 list-disc ml-6",children:v.errors.map((L,V)=>i.jsx("li",{children:L},V))}),v.warnings.length>0&&i.jsx("ul",{className:"text-sm text-yellow-500 list-disc ml-6 mt-1",children:v.warnings.map((L,V)=>i.jsx("li",{children:L},V))})]}),j&&i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-lg shadow-xl max-w-2xl w-full max-h-[80vh] flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border)]",children:[i.jsx("h3",{className:"font-medium",children:"Experiment YAML"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(K,{variant:"secondary",size:"sm",icon:bd,onClick:T,children:"Download"}),i.jsx(K,{variant:"ghost",size:"sm",onClick:()=>g(!1),children:"Close"})]})]}),i.jsx("pre",{className:"flex-1 overflow-auto p-4 text-xs font-mono bg-[var(--bg-secondary)]",children:m})]})}),!A&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No variations selected. Only the baseline agent will be tested. Add compaction strategies, tool presets, or LLM configs to generate candidates."})]})}function Td(){const e=lr(),t=qt(),[n,r]=k.useState(!1),[s,a]=k.useState(null),{data:l=[],isLoading:o}=ye({queryKey:["configs"],queryFn:()=>Er.list()}),u=Ge({mutationFn:Er.create,onSuccess:()=>{t.invalidateQueries({queryKey:["configs"]}),r(!1)}}),c=Ge({mutationFn:Er.delete,onSuccess:()=>t.invalidateQueries({queryKey:["configs"]})}),h=[{key:"name",header:"Name",render:d=>i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:d.name})},{key:"framework",header:"Framework",render:d=>i.jsx(ee,{children:d.config.framework||"maf"})},{key:"tools",header:"Tools",render:d=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:R0(d.config.tools)})},{key:"compaction",header:"Compaction",render:d=>{const p=d.config.compaction;return!p||p.strategy==="none"?i.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"}):p.strategy==="head_tail"?i.jsxs(ee,{children:[p.params.head_size,"/",p.params.tail_size]}):i.jsx(ee,{children:p.strategy})}},{key:"created",header:"Created",render:d=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(d.created_at).toLocaleDateString()}),sortable:!0,sortValue:d=>new Date(d.created_at).getTime()},{key:"actions",header:"",className:"w-24",render:d=>i.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[i.jsx(K,{variant:"ghost",size:"sm",icon:Ui,title:"Optimize",onClick:()=>a(d)}),i.jsx(K,{variant:"ghost",size:"sm",icon:Bu,title:"Delete",onClick:()=>{confirm(`Delete agent "${d.name}"?`)&&c.mutate(d.id)}})]})}];return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Agents"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Define and optimize your agent configurations."})]}),i.jsx(K,{variant:"primary",icon:Uu,onClick:()=>r(!0),children:"Create agent"})]}),o?i.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[i.jsx(da,{size:16,className:"animate-spin"}),"Loading agents..."]}):i.jsx(Bm,{columns:h,data:l,onRowClick:d=>e(`/agents/${d.id}`),searchable:!0,searchPlaceholder:"Search agents",searchFilter:(d,p)=>d.name.toLowerCase().includes(p.toLowerCase())||(d.description||"").toLowerCase().includes(p.toLowerCase()),emptyMessage:"No agents yet. Create your first agent to start optimizing.",emptyIcon:i.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-[var(--bg-tertiary)]",children:i.jsx(Lm,{size:24,className:"text-[var(--text-secondary)]"})})}),i.jsx(M0,{isOpen:n,onClose:()=>r(!1),onSubmit:d=>u.mutate(d),isLoading:u.isPending}),s&&i.jsx(z0,{agent:s,isOpen:!!s,onClose:()=>a(null)})]})}function R0(e){return typeof e=="string"?e:Array.isArray(e)?`[${e.length}]`:e&&typeof e=="object"?`[${Object.keys(e).length}]`:"standard"}function M0({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){var V,Y,R,O,X,he,Ne;const s=["read_file","write_file","edit_file","bash","grep","think"],[a,l]=k.useState("preset"),[o,u]=k.useState({name:"",description:"",instructions:null,model:null,compaction:{strategy:"none",params:{}},tools:s,framework:"miniagent",llm_config_id:null}),[c,h]=k.useState(!1),[d,p]=k.useState("preset"),[x,S]=k.useState([...s]),[j,g]=k.useState(!1),{data:m}=ye({queryKey:["agent-schema"],queryFn:()=>$m.getAgentSchema()}),{data:f=[]}=ye({queryKey:["llm-configs"],queryFn:()=>c0.list()}),{data:v}=ye({queryKey:["tools"],queryFn:()=>d0.list()}),w=((V=v==null?void 0:v.tools)==null?void 0:V.map(M=>M.name))??s,C=(v==null?void 0:v.presets)??{},b=Object.keys(C),N=(m==null?void 0:m.frameworks)??{},_=Object.keys(N).length>0?Object.keys(N):N0,F=o.framework||"miniagent",P=((R=(Y=m==null?void 0:m.frameworks)==null?void 0:Y[F])==null?void 0:R.compaction_strategies)??["none","head_tail"],B=(m==null?void 0:m.compaction_strategies)??{},D=(m==null?void 0:m.agent_presets)??[],U=M=>{const H=M.config,dt=H.compaction;n({name:M.name+"-agent",description:M.description,framework:H.framework||"miniagent",tools:H.tools||"standard",compaction:dt||{strategy:"none",params:{}},instructions:H.instructions||null})},ne=M=>{if(M.preventDefault(),!o.name.trim())return;const H={...o};d==="custom"&&(H.tools=x),n(H)},je=((O=o.compaction)==null?void 0:O.strategy)!=="none",Je=((X=o.compaction)==null?void 0:X.strategy)||"none",ae=B[Je],T=M=>{S(H=>H.includes(M)?H.filter(dt=>dt!==M):[...H,M])},A=M=>{const H=B[M],dt={};if(H!=null&&H.params)for(const[ss,as]of Object.entries(H.params))as.default!==void 0&&(dt[ss]=as.default);u({...o,compaction:{strategy:M,params:dt}})},L=a==="custom"?i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(K,{type:"submit",form:"create-agent-form",variant:"primary",disabled:!o.name.trim(),loading:r,children:"Create Agent"})]}):i.jsx("div",{className:"flex justify-end gap-2",children:i.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"})});return i.jsxs(rs,{isOpen:e,onClose:t,title:"Create Agent",footer:L,children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b border-[var(--border)]",children:[i.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${a==="preset"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("preset"),children:"From Preset"}),i.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${a==="custom"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("custom"),children:"Custom"})]}),a==="preset"?i.jsx("div",{className:"space-y-3",children:D.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"Loading presets..."}):D.map(M=>i.jsx("button",{type:"button",className:"w-full text-left p-4 border border-[var(--border)] rounded-lg hover:border-[var(--accent)] hover:bg-[var(--accent)]/5 transition-colors",onClick:()=>U(M),disabled:r,children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("h4",{className:"font-medium",children:M.label}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:M.description}),i.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[M.tags.map(H=>i.jsx(ee,{variant:"default",children:H},H)),M.suggested_datasets.length>0&&i.jsxs(ee,{variant:"success",children:["datasets: ",M.suggested_datasets.join(", ")]})]})]}),i.jsx(Js,{size:16,className:"text-[var(--text-secondary)] mt-1 flex-shrink-0"})]})},M.name))}):i.jsxs("form",{id:"create-agent-form",onSubmit:ne,className:"space-y-4",children:[i.jsx(pn,{label:"Name",value:o.name,onChange:M=>u({...o,name:M.target.value}),placeholder:"e.g., my-coding-agent",required:!0}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"LLM Configuration"}),i.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.llm_config_id||"",onChange:M=>u({...o,llm_config_id:M.target.value||null}),children:[i.jsx("option",{value:"",children:"Use environment variables"}),f.map(M=>i.jsxs("option",{value:M.id,children:[M.name," (",C0[M.provider],M.model_id?` - ${M.model_id}`:"",")",M.is_default?" (default)":""]},M.id))]}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:f.length===0?"No LLM configs found. Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)":o.llm_config_id?"Uses the selected LLM configuration.":"Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Framework"}),i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.framework||"miniagent",onChange:M=>{const H=M.target.value;u({...o,framework:H,compaction:{strategy:"none",params:{}}})},children:_.map(M=>{var H;return i.jsx("option",{value:M,children:((H=N[M])==null?void 0:H.label)||b0[M]||M},M)})}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((he=N[F])==null?void 0:he.description)||(F==="miniagent"?"Lightweight agent with token-aware context management.":F==="langgraph"?"Graph-based workflows with state management.":"Default agent implementation.")})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(ji,{label:"Custom instructions",checked:c,onChange:M=>{h(M.target.checked),M.target.checked||u({...o,instructions:null})}}),i.jsx(ji,{label:"Enable compaction",checked:je,onChange:M=>{if(M.target.checked){const H=P.find(dt=>dt!=="none")||"head_tail";A(H)}else u({...o,compaction:{strategy:"none",params:{}}})}})]}),c&&i.jsx("textarea",{className:"w-full h-32 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono resize-y",value:o.instructions||"",onChange:M=>u({...o,instructions:M.target.value||null}),placeholder:"System prompt / instructions for the agent..."}),je&&i.jsxs("div",{className:"space-y-3 p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Compaction Strategy"}),i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:Je,onChange:M=>A(M.target.value),children:P.filter(M=>M!=="none").map(M=>{var H;return i.jsx("option",{value:M,children:((H=B[M])==null?void 0:H.label)||M},M)})}),(ae==null?void 0:ae.description)&&i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:ae.description})]}),(ae==null?void 0:ae.params)&&Object.keys(ae.params).length>0&&i.jsx("div",{className:"grid grid-cols-2 gap-3",children:Object.entries(ae.params).map(([M,H])=>{var as;const dt=(as=o.compaction)==null?void 0:as.params[M],ss=dt!==void 0?dt:H.default;return i.jsxs("div",{children:[i.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:M.replace(/_/g," ")}),i.jsx("input",{type:"number",className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof ss=="number"?ss:Number(ss)||0,onChange:qm=>{const Gu=parseFloat(qm.target.value);u({...o,compaction:{...o.compaction,params:{...o.compaction.params,[M]:isNaN(Gu)?typeof H.default=="number"?H.default:0:Gu}}})},min:H.min,max:H.max,step:H.max&&H.max<=1?.1:1}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:H.description})]},M)})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm font-medium",children:"Tools"}),i.jsxs("div",{className:"flex gap-4",children:[i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"radio",checked:d==="preset",onChange:()=>p("preset"),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:"Preset"})]}),i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"radio",checked:d==="custom",onChange:()=>p("custom"),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:"Custom"})]})]}),d==="preset"?i.jsxs(i.Fragment,{children:[i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof o.tools=="string"?o.tools:"standard",onChange:M=>u({...o,tools:M.target.value}),children:b.map(M=>i.jsx("option",{value:M,children:M},M))}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((Ne=C[typeof o.tools=="string"?o.tools:"standard"])==null?void 0:Ne.join(", "))??""})]}):i.jsx("div",{className:"grid grid-cols-2 gap-1 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:w.map(M=>i.jsxs("label",{className:"flex items-center gap-2 p-1 text-sm cursor-pointer hover:bg-[var(--bg-tertiary)]",children:[i.jsx("input",{type:"checkbox",checked:x.includes(M),onChange:()=>T(M),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"font-mono text-xs",children:M})]},M))})]}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[i.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>g(!j),children:[i.jsx(Js,{size:14,className:`transition-transform ${j?"rotate-90":""}`}),"More options"]}),j&&i.jsx("div",{className:"mt-3",children:i.jsx(pn,{label:"Description (optional)",value:o.description,onChange:M=>u({...o,description:M.target.value}),placeholder:"Brief description of this agent"})})]})]})]})}function z0({agent:e,isOpen:t,onClose:n}){var R;const r=lr(),s=qt(),[a,l]=k.useState("ready"),[o,u]=k.useState("quick"),[c,h]=k.useState(!1),[d,p]=k.useState([]),[x,S]=k.useState(!1),[j,g]=k.useState(Io),[m,f]=k.useState(4),[v,w]=k.useState(100),[C,b]=k.useState(!1),[N,_]=k.useState(null),{data:F=[]}=ye({queryKey:["tasks"],queryFn:()=>Et.list()}),{data:P=[]}=ye({queryKey:["suites"],queryFn:()=>Et.listSuites()}),{data:B}=ye({queryKey:["agent-schema"],queryFn:()=>$m.getAgentSchema()}),D=P.map(O=>({value:O.name,label:O.name.charAt(0).toUpperCase()+O.name.slice(1),description:O.description,tasks:O.task_count})),U=Ge({mutationFn:Et.importSuite,onSuccess:O=>{s.invalidateQueries({queryKey:["tasks"]}),p(O.map(X=>X.id))}}),ne=Ge({mutationFn:async O=>{const X=await Ut.create(O);return Ut.start(X.id).next(),X},onSuccess:O=>{s.invalidateQueries({queryKey:["jobs"]}),_(O.id),l("success")}}),Je=x?(()=>{let O=1;j.compaction.length>0&&(O*=j.compaction.length),j.tools.length>0&&(O*=j.tools.length),j.llm_config.length>0&&(O*=j.llm_config.length);const X=j.instructions.length+j.instruction_strategies.reduce((he,Ne)=>he+Ne.max_candidates,0);return X>0&&(O*=X),Math.min(O,v)})():1,ae=c?d.length:((R=D.find(O=>O.value===o))==null?void 0:R.tasks)||3,T=Je*ae,A=async()=>{l("starting");let O=d;if(!c)try{O=(await U.mutateAsync(o)).map(H=>H.id)}catch(M){console.error("Failed to import suite:",M),alert(`Failed to import task suite: ${o}`),l("ready");return}if(O.length===0){alert("No tasks selected. Please select tasks or choose a task suite."),l("ready");return}let X;if(x&&(j.compaction.length>0||j.tools.length>0||j.llm_config.length>0||j.instructions.length>0||j.instruction_strategies.length>0))try{X=(await Fo.generateCandidates({base_agent_id:e.id,variations:j,budget:v})).candidate_ids}catch(M){console.error("Failed to generate candidates:",M),alert(`Failed to generate candidates: ${M instanceof Error?M.message:"Unknown error"}`),l("ready");return}else X=[e.id];const Ne={name:`${e.name} optimization (${X.length} candidates × ${O.length} tasks)`,candidate_ids:X,task_ids:O,parallel:m,use_llm_eval:C};ne.mutate(Ne)},L=O=>{p(X=>X.includes(O)?X.filter(he=>he!==O):[...X,O])},V=()=>{l("ready"),_(null),S(!1),g(Io),n()},Y=()=>a==="success"&&N?i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsx(K,{variant:"secondary",onClick:V,children:"Close"}),i.jsx(K,{variant:"primary",icon:Ys,onClick:()=>{V(),r(`/jobs/${N}`)},children:"View Job"})]}):a==="starting"?null:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(K,{variant:"secondary",onClick:n,children:"Cancel"}),i.jsxs(K,{variant:"primary",icon:Ys,onClick:A,disabled:c&&d.length===0,children:["Start Optimization (",T," runs)"]})]});return i.jsx(rs,{isOpen:t,onClose:V,title:`Optimize: ${e.name}`,footer:Y(),size:"lg",children:a==="success"&&N?i.jsxs("div",{className:"flex flex-col items-center py-8",children:[i.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/20 flex items-center justify-center mb-4",children:i.jsx(Ui,{size:24,className:"text-green-500"})}),i.jsx("h3",{className:"text-lg font-medium mb-2",children:"Job Started!"}),i.jsx("p",{className:"text-[var(--text-secondary)] text-center mb-2",children:"Optimization job is now running"}),i.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-3 py-1.5 rounded font-mono",children:["ID: ",N.slice(0,8),"..."]})]}):a==="starting"?i.jsxs("div",{className:"flex flex-col items-center py-8",children:[i.jsx(da,{size:32,className:"animate-spin text-[var(--accent)] mb-4"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:U.isPending?"Importing tasks...":"Creating optimization job..."})]}):i.jsxs("div",{className:"space-y-5",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Task Suite"}),i.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:c?"__custom__":o,onChange:O=>{O.target.value==="__custom__"?h(!0):(h(!1),u(O.target.value))},children:[D.map(O=>i.jsxs("option",{value:O.value,children:[O.label," (",O.tasks," tasks) — ",O.description]},O.value)),F.length>0&&i.jsx("option",{value:"__custom__",children:"Custom Selection"})]})]}),c&&F.length>0&&i.jsx("div",{className:"max-h-48 overflow-y-auto border border-[var(--border)] rounded p-2 space-y-1",children:F.map(O=>i.jsxs("label",{className:"flex items-center gap-2 p-2 hover:bg-[var(--bg-tertiary)] cursor-pointer rounded",children:[i.jsx("input",{type:"checkbox",checked:d.includes(O.id),onChange:()=>L(O.id),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:O.name}),O.suite&&i.jsx(ee,{children:O.suite})]},O.id))}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[i.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>S(!x),children:[i.jsx(Js,{size:14,className:`transition-transform ${x?"rotate-90":""}`}),"Advanced Settings",x&&i.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"(experiment design, variations, execution)"})]}),x&&B&&i.jsx("div",{className:"mt-4",children:i.jsx(L0,{agentId:e.id,agentName:e.name,agentFramework:e.config.framework,taskSuite:c?void 0:o,taskCount:ae,schema:B,onVariationsChange:g,parallel:m,onParallelChange:f,budget:v,onBudgetChange:w,useLlmEval:C,onUseLlmEvalChange:b})})]})]})})}function le({children:e,className:t="",onClick:n,selected:r=!1,selectable:s=!1}){const a="bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",l=s?"cursor-pointer hover:border-[var(--accent-dim)] transition-colors":"",o=r?"border-[var(--accent)]":"";return i.jsx("div",{className:`${a} ${l} ${o} ${t}`,onClick:n,children:e})}function Ki({items:e}){return i.jsx("nav",{className:"flex items-center gap-1.5 text-sm mb-4",children:e.map((t,n)=>{const r=n===e.length-1;return i.jsxs("span",{className:"flex items-center gap-1.5",children:[n>0&&i.jsx(Js,{size:14,className:"text-[var(--text-secondary)]"}),t.path&&!r?i.jsx(Gr,{to:t.path,className:"text-[var(--text-secondary)] hover:text-[var(--accent)] transition-colors",children:t.label}):i.jsx("span",{className:r?"text-[var(--text-primary)] font-medium":"text-[var(--text-secondary)]",children:t.label})]},n)})})}function F0(e){const t=[],n=r=>r.type==="trace_span"&&typeof r.data=="object"&&r.data!==null?r.data:"span_id"in r?r:null;if(Array.isArray(e.spans)){for(const r of e.spans)if(typeof r=="object"&&r!==null){const s=n(r);s&&t.push(s)}}else if(e.span_id)t.push(e);else for(const r in e){const s=e[r];if(typeof s=="object"&&s!==null){const a=n(s);if(a)t.push(a);else if(Array.isArray(s)){for(const l of s)if(typeof l=="object"&&l!==null){const o=n(l);o&&t.push(o)}}}}return t}function Qm(e){const t=new Map,n=[];for(const s of e)t.set(s.span_id,{span:s,children:[]});for(const s of e){const a=t.get(s.span_id);s.parent_span_id&&t.has(s.parent_span_id)?t.get(s.parent_span_id).children.push(a):n.push(a)}const r=s=>{s.sort((a,l)=>(a.span.start_time||0)-(l.span.start_time||0)),s.forEach(a=>r(a.children))};return r(n),n}function I0(e){return e.includes("Agent")||e.includes("agent")?"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200":e.includes("chat")||e.includes("Chat")||e.includes("llm")?"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200":e.includes("tool")||e.includes("execute")||e.includes("bash")?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200"}function D0(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(0)}ms`}function qu({node:e,depth:t=0}){var d,p;const[n,r]=k.useState(t<2),[s,a]=k.useState(!1),{span:l}=e,o=e.children.length>0,u=(d=l.attributes)==null?void 0:d["gen_ai.usage.input_tokens"],c=(p=l.attributes)==null?void 0:p["gen_ai.usage.output_tokens"],h=u!==void 0||c!==void 0;return i.jsxs("div",{className:"relative",children:[t>0&&i.jsx("div",{className:"absolute left-0 top-0 bottom-0 border-l-2 border-[var(--border)]",style:{marginLeft:`${(t-1)*16+8}px`}}),i.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-1 hover:bg-[var(--bg-primary)] rounded transition-colors cursor-pointer",style:{paddingLeft:`${t*16}px`},onClick:()=>o?r(!n):a(!s),children:[i.jsx("div",{className:"w-4 h-4 flex items-center justify-center text-[var(--text-secondary)]",children:o?n?"▼":"▶":s?"▼":"▶"}),i.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${I0(l.operation_name)}`,children:l.operation_name.replace("ChatAgent.","").replace("invoke_agent ","")}),l.duration_ms!==void 0&&i.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:D0(l.duration_ms)}),h&&i.jsxs("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:[u!==void 0&&i.jsxs("span",{className:"text-blue-400",children:["↑",String(u)]}),u!==void 0&&c!==void 0&&i.jsx("span",{className:"mx-0.5",children:"/"}),c!==void 0&&i.jsxs("span",{className:"text-green-400",children:["↓",String(c)]})]})]}),s&&!o&&i.jsx("div",{className:"ml-4 mt-1 mb-2 p-2 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs",style:{marginLeft:`${t*16+20}px`},children:i.jsxs("div",{className:"space-y-1",children:[l.span_id&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Span ID:"}),i.jsx("span",{className:"font-mono text-xs break-all",children:l.span_id})]}),l.trace_id&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Trace ID:"}),i.jsx("span",{className:"font-mono text-xs break-all",children:l.trace_id})]}),l.status&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Status:"}),i.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs ${l.status==="OK"||l.status==="StatusCode.UNSET"?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200"}`,children:l.status})]}),Object.keys(l.attributes||{}).length>0&&i.jsxs("div",{className:"mt-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] block mb-1",children:"Attributes:"}),i.jsx("pre",{className:"text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded p-2 overflow-auto max-h-32 whitespace-pre-wrap break-all",children:JSON.stringify(l.attributes,null,2)})]})]})}),o&&n&&i.jsx("div",{children:e.children.map((x,S)=>i.jsx(qu,{node:x,depth:t+1},x.span.span_id||S))})]})}function Vm({trace:e}){const[t,n]=k.useState("tree"),r=k.useMemo(()=>F0(e),[e]),s=k.useMemo(()=>Qm(r),[r]);return Object.keys(e).length===0?null:i.jsxs(le,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"font-medium",children:"Trace Data"}),i.jsxs("div",{className:"flex gap-1",children:[i.jsx("button",{onClick:()=>n("tree"),className:`px-2 py-1 text-xs rounded ${t==="tree"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Tree"}),i.jsx("button",{onClick:()=>n("raw"),className:`px-2 py-1 text-xs rounded ${t==="raw"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Raw"})]})]}),t==="tree"?r.length>0?i.jsx("div",{className:"border border-[var(--border)] rounded overflow-hidden",children:i.jsxs("div",{className:"p-2",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs(ee,{variant:"default",children:[r.length," spans"]}),i.jsx("span",{children:"•"}),i.jsx("span",{children:"Click to expand details"})]}),s.map((a,l)=>i.jsx(qu,{node:a,depth:0},a.span.span_id||l))]})}):i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No structured spans found. View raw data below."}):i.jsx("pre",{className:"text-xs bg-[var(--bg-primary)] p-3 overflow-x-auto border border-[var(--border)] max-h-96 whitespace-pre-wrap",children:JSON.stringify(e,null,2)})]})}function A0({spans:e,isLive:t=!1}){const n=k.useRef(null),r=k.useMemo(()=>Qm(e),[e]);return k.useEffect(()=>{n.current&&t&&n.current.scrollTo({top:n.current.scrollHeight,behavior:"smooth"})},[e.length,t]),i.jsxs("div",{className:"border border-[var(--border)] rounded overflow-hidden h-full flex flex-col",children:[i.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-[var(--border)] bg-[var(--bg-secondary)]",children:[i.jsxs(ee,{variant:"default",children:[e.length," spans"]}),t&&i.jsx("span",{className:"animate-pulse",children:i.jsx(ee,{variant:"info",children:"Live"})})]}),i.jsx("div",{ref:n,className:"flex-1 overflow-auto p-2",children:r.length>0?r.map((s,a)=>i.jsx(qu,{node:s,depth:0},s.span.span_id||a)):i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:t?"Waiting for spans...":"No spans recorded"})})]})}function $0({agent:e}){const[t,n]=k.useState(""),[r,s]=k.useState(null),[a,l]=k.useState("idle"),[o,u]=k.useState(null),[c,h]=k.useState(""),[d,p]=k.useState([]),[x,S]=k.useState(null),[j,g]=k.useState(null),[m,f]=k.useState([]),v=k.useRef(null),{data:w=[]}=ye({queryKey:["tasks"],queryFn:()=>Et.list()});k.useEffect(()=>{v.current&&a==="running"&&(v.current.scrollTop=v.current.scrollHeight)},[c,a]);const C=D=>{if(s(D),D){const U=w.find(ne=>ne.id===D);U&&n(U.prompt)}},b=async()=>{if(t.trim()){l("running"),h(""),p([]),S(null),g(null),f([]);try{const D=await Ps.create({agent_id:e.id,prompt:t.trim(),task_id:r||void 0});u(D.id);for await(const U of Ps.start(D.id))N(U)}catch(D){g(D instanceof Error?D.message:"Test failed"),l("failed")}}},N=D=>{switch(D.event){case"started":break;case"execution":D.execution_event==="text_delta"&&D.content?h(U=>U+D.content):D.execution_event==="tool_call_start"&&D.tool_name?f(U=>[...U,{name:D.tool_name}]):D.execution_event==="tool_result"&&D.content&&f(U=>{if(U.length>0){const ne=[...U];return ne[ne.length-1]={...ne[ne.length-1],content:D.content},ne}return U});break;case"span":if(D.span){const U=D.span;if(U.data){const ne={span_id:U.data.span_id||"",trace_id:U.data.trace_id||"",parent_span_id:U.data.parent_span_id||null,operation_name:U.data.operation_name||"",start_time:U.timestamp?new Date(U.timestamp).getTime():Date.now(),end_time:Date.now(),duration_ms:U.data.duration_ms||0,status:U.data.status||"OK",attributes:U.data.attributes||{}};p(je=>[...je,ne])}}break;case"complete":l("completed"),D.result&&S(D.result);break;case"error":g(D.message),l("failed");break}},_=async()=>{if(o)try{await Ps.cancel(o)}catch{}l("idle")},F=()=>{l("idle"),u(null),h(""),p([]),S(null),g(null),f([])},P=a==="running",B=a==="completed"||a==="failed";return i.jsxs("div",{className:"h-full flex flex-col",children:[!P&&!B&&i.jsxs("div",{className:"mb-4 space-y-3",children:[i.jsxs("div",{className:"flex gap-3",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("label",{className:"block text-sm font-medium mb-1",children:"Select Task (optional)"}),i.jsxs("select",{value:r||"",onChange:D=>C(D.target.value||null),className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",children:[i.jsx("option",{value:"",children:"Custom prompt..."}),w.map(D=>i.jsx("option",{value:D.id,children:D.name},D.id))]})]}),i.jsx("div",{className:"flex items-end",children:i.jsx(K,{variant:"primary",icon:Ys,onClick:b,disabled:!t.trim(),children:"Run Test"})})]}),i.jsxs("div",{children:[i.jsx("label",{className:"block text-sm font-medium mb-1",children:"Prompt"}),i.jsx("textarea",{value:t,onChange:D=>n(D.target.value),placeholder:"Enter a test prompt for the agent...",className:"w-full h-32 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono resize-none"})]})]}),(P||B)&&i.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[P&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"animate-pulse",children:i.jsx(ee,{variant:"info",children:"Running"})}),i.jsx(K,{variant:"ghost",size:"sm",icon:Mg,onClick:_,children:"Cancel"})]}),a==="completed"&&i.jsx(ee,{variant:"success",children:"Completed"}),a==="failed"&&i.jsx(ee,{variant:"error",children:"Failed"})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[x&&i.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(jg,{size:12}),x.duration_seconds.toFixed(2),"s"]}),i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(wg,{size:12}),x.tokens_total," tokens"]}),x.passed!==null&&(x.passed?i.jsx(Tm,{size:14,className:"text-green-500"}):i.jsx(Fg,{size:14,className:"text-red-500"}))]}),B&&i.jsx(K,{variant:"secondary",size:"sm",onClick:F,children:"New Test"})]})]}),i.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-4 min-h-0",children:[i.jsxs("div",{className:"flex flex-col border border-[var(--border)] rounded overflow-hidden",children:[i.jsx("div",{className:"px-3 py-2 border-b border-[var(--border)] bg-[var(--bg-secondary)] text-sm font-medium",children:"Output"}),i.jsxs("div",{ref:v,className:"flex-1 overflow-auto p-3 font-mono text-sm whitespace-pre-wrap bg-[var(--bg-primary)]",children:[c||(P?"Waiting for response...":"No output"),m.length>0&&i.jsxs("div",{className:"mt-3 space-y-2 border-t border-[var(--border)] pt-3",children:[i.jsx("div",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:"Tool Calls"}),m.map((D,U)=>i.jsxs("div",{className:"p-2 bg-green-500/10 border border-green-500/20 rounded text-xs",children:[i.jsx(ee,{variant:"success",children:D.name}),D.content&&i.jsxs("div",{className:"mt-1 text-[var(--text-secondary)] truncate max-w-full",children:[D.content.substring(0,200),D.content.length>200&&"..."]})]},U))]})]})]}),i.jsx(A0,{spans:d,isLive:P})]}),j&&i.jsx("div",{className:"mt-3 p-3 bg-red-500/10 border border-red-500/20 rounded text-sm text-red-400",children:j}),B&&o&&i.jsx("div",{className:"mt-3 flex items-center justify-end pt-3 border-t border-[var(--border)]",children:i.jsx(Gr,{to:`/tests/${o}`,children:i.jsx(K,{variant:"primary",iconRight:Ng,children:"View Full Details"})})})]})]})}function U0(){const{agentId:e}=Ai(),t=lr(),n=qt(),[r,s]=k.useState("overview"),{data:a,isLoading:l}=ye({queryKey:["configs",e],queryFn:()=>Er.get(e),enabled:!!e}),{data:o=[]}=ye({queryKey:["tests",{agent_id:e}],queryFn:()=>Ps.list({agent_id:e}),enabled:!!e}),{data:u=[]}=ye({queryKey:["jobs"],queryFn:()=>Ut.list()}),c=Ge({mutationFn:d=>Er.delete(d),onSuccess:()=>{n.invalidateQueries({queryKey:["configs"]}),t("/agents")}}),h=u.filter(d=>d.candidate_ids.includes(e||""));return l?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):a?i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(Ki,{items:[{label:"Agents",path:"/agents"},{label:a.name}]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:a.name}),a.is_auto_generated&&i.jsx(ee,{variant:"info",children:"Auto-generated"})]}),i.jsx("div",{className:"flex gap-2",children:i.jsx(K,{variant:"secondary",icon:Bu,onClick:()=>{confirm(`Delete agent "${a.name}"?`)&&c.mutate(a.id)},children:"Delete"})})]}),a.description&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:a.description})]}),i.jsxs("div",{className:"flex gap-1 mb-6 border-b border-[var(--border)]",children:[i.jsx(wl,{active:r==="overview",onClick:()=>s("overview"),icon:i.jsx(Lm,{size:16}),children:"Overview"}),i.jsx(wl,{active:r==="test",onClick:()=>s("test"),icon:i.jsx(Ys,{size:16}),children:"Test"}),i.jsx(wl,{active:r==="history",onClick:()=>s("history"),icon:i.jsx(Eg,{size:16}),badge:o.length,children:"History"})]}),i.jsxs("div",{className:"flex-1 min-h-0",children:[r==="overview"&&i.jsx(B0,{agent:a,recentTests:o,jobs:h}),r==="test"&&i.jsx($0,{agent:a}),r==="history"&&i.jsx(Q0,{tests:o})]})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Agent not found"})}function wl({active:e,onClick:t,icon:n,badge:r,children:s}){return i.jsxs("button",{onClick:t,className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${e?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[n,s,r!==void 0&&r>0&&i.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs bg-[var(--bg-tertiary)] rounded",children:r})]})}function B0({agent:e,recentTests:t,jobs:n}){var S,j;const r=lr(),s=qt(),a=e.config,[l,o]=k.useState("quick"),[u,c]=k.useState(!1),{data:h=[]}=ye({queryKey:["suites"],queryFn:()=>Et.listSuites()}),d=Ge({mutationFn:f0.start,onSuccess:g=>{s.invalidateQueries({queryKey:["jobs"]}),c(!1),r(`/jobs/${g.id}`)},onError:()=>{c(!1)}}),p=()=>{c(!0),d.mutate({agent_id:e.id,suite_name:l,use_llm_eval:!0,parallel:4})},x=()=>{const g=a.tools;return typeof g=="string"?g:Array.isArray(g)?g.join(", "):g&&typeof g=="object"?Object.keys(g).join(", "):"standard"};return i.jsxs("div",{className:"space-y-6",children:[i.jsxs(le,{children:[i.jsx("h3",{className:"font-medium mb-4",children:"Configuration"}),i.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Model:"}),i.jsx("div",{className:"font-mono",children:a.model||"default"})]}),i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Compaction:"}),i.jsx("div",{className:"font-mono",children:!a.compaction||a.compaction.strategy==="none"?"disabled":`${a.compaction.strategy} (${((S=a.compaction.params)==null?void 0:S.head_size)||0}/${((j=a.compaction.params)==null?void 0:j.tail_size)||0})`})]}),i.jsxs("div",{className:"col-span-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tools:"}),i.jsx("div",{className:"font-mono",children:x()})]}),a.instructions&&i.jsxs("div",{className:"col-span-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Instructions:"}),i.jsx("pre",{className:"mt-1 p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-xs whitespace-pre-wrap max-h-32 overflow-auto",children:a.instructions})]})]})]}),i.jsxs(le,{children:[i.jsx("h3",{className:"font-medium mb-3",children:"Evaluate"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:"Run this agent on a task suite to measure quality and cost."}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("select",{className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:l,onChange:g=>o(g.target.value),disabled:u,children:h.map(g=>i.jsxs("option",{value:g.name,children:[g.name.charAt(0).toUpperCase()+g.name.slice(1)," (",g.task_count," tasks)"]},g.name))}),i.jsx(K,{variant:"primary",icon:u?da:Ys,onClick:p,disabled:u,loading:u,children:"Evaluate"})]})]}),i.jsxs(le,{children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h3",{className:"font-medium",children:"Recent Tests"}),t.length>0&&i.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:[t.length," total"]})]}),t.length===0?i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:'No tests yet. Click the "Test" tab to run one.'}):i.jsx("div",{className:"space-y-2",children:t.slice(0,5).map(g=>i.jsxs(Gr,{to:`/tests/${g.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded hover:border-[var(--accent-dim)] transition-colors",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Km,{status:g.status}),i.jsxs("span",{className:"text-sm truncate max-w-[200px]",children:[g.prompt.slice(0,50),"..."]})]}),i.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:[g.duration_seconds.toFixed(1),"s"]}),i.jsxs("span",{children:[g.tokens_total," tok"]})]})]},g.id))})]}),i.jsxs(le,{children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h3",{className:"font-medium",children:"Optimization Jobs"}),i.jsx(K,{variant:"secondary",size:"sm",icon:Ui,onClick:()=>r("/agents",{state:{optimizeAgent:e}}),children:"New Job"})]}),n.length===0?i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No optimization jobs yet."}):i.jsx("div",{className:"space-y-2",children:n.slice(0,5).map(g=>i.jsxs(Gr,{to:`/jobs/${g.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded hover:border-[var(--accent-dim)] transition-colors",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(ee,{variant:g.status==="completed"?"success":g.status==="running"?"info":"default",children:g.status}),i.jsx("span",{className:"text-sm",children:g.name})]}),i.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:new Date(g.created_at).toLocaleDateString()})]},g.id))})]})]})}function Q0({tests:e}){return e.length===0?i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No test history yet. Run a test to see results here."}):i.jsx("div",{className:"space-y-2",children:e.map(t=>i.jsxs(Gr,{to:`/tests/${t.id}`,className:"flex items-center justify-between p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded hover:border-[var(--accent-dim)] transition-colors",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(Km,{status:t.status}),t.score!==null&&i.jsxs("span",{className:`text-sm font-medium ${t.passed?"text-green-400":"text-red-400"}`,children:[(t.score*100).toFixed(0),"%"]})]}),i.jsx("p",{className:"text-sm truncate",children:t.prompt})]}),i.jsxs("div",{className:"flex flex-col items-end gap-1 ml-4",children:[i.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:new Date(t.created_at).toLocaleString()}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:[t.duration_seconds.toFixed(1),"s"]}),i.jsx("span",{children:"•"}),i.jsxs("span",{children:[t.tokens_total," tokens"]})]})]})]},t.id))})}function Km({status:e}){const t={completed:"success",failed:"error",running:"info",cancelled:"warning",pending:"default"};return i.jsx(ee,{variant:t[e]||"default",children:e})}function V0(){const e=qt(),[t,n]=k.useState(!1),[r,s]=k.useState(!1),[a,l]=k.useState(null),[o,u]=k.useState(new Set),c=m=>{u(f=>{const v=new Set(f);return v.has(m)?v.delete(m):v.add(m),v})},{data:h=[],isLoading:d}=ye({queryKey:["tasks"],queryFn:()=>Et.list()}),p=Ge({mutationFn:Et.create,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),n(!1)}}),x=Ge({mutationFn:Et.importSuite,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),s(!1)}}),S=Ge({mutationFn:Et.delete,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),l(null)}}),j=h.reduce((m,f)=>{const v=f.suite||"custom";return m[v]||(m[v]=[]),m[v].push(f),m},{}),g=Object.keys(j).sort((m,f)=>m==="custom"?-1:f==="custom"?1:m.localeCompare(f));return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Datasets"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Task datasets for evaluating agent configurations."})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(K,{variant:"secondary",onClick:()=>s(!0),children:"Import Suite"}),i.jsx(K,{variant:"primary",onClick:()=>n(!0),children:"+ New Task"})]})]}),d?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):h.length===0?i.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:"No tasks yet. Create one or import a built-in suite."}):i.jsx("div",{className:"space-y-4",children:g.map(m=>{const f=j[m],v=!o.has(m);return i.jsxs("div",{children:[i.jsxs("button",{onClick:()=>c(m),className:"flex items-center gap-2 py-2 hover:text-[var(--accent)] transition-colors",children:[v?i.jsx(xg,{size:16,className:"text-[var(--text-secondary)]"}):i.jsx(Js,{size:16,className:"text-[var(--text-secondary)]"}),i.jsx("h3",{className:"text-sm font-medium uppercase tracking-wide",children:m==="custom"?"Custom Tasks":`${m} Suite`}),i.jsx(ee,{variant:m==="custom"?"default":"info",children:f.length})]}),v&&i.jsx("div",{className:"mt-2 border border-[var(--border)] rounded-lg overflow-hidden",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:[i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Name"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Category"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Prompt"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Criteria"})]})}),i.jsx("tbody",{children:f.map(w=>i.jsxs("tr",{onClick:()=>l(w),className:"border-b border-[var(--border)] last:border-b-0 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors",children:[i.jsx("td",{className:"px-4 py-3",children:i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:w.name})}),i.jsx("td",{className:"px-4 py-3",children:w.category&&w.category!=="default"?i.jsx(ee,{variant:"default",children:w.category}):i.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"})}),i.jsx("td",{className:"px-4 py-3",children:i.jsx("span",{className:"text-[var(--text-secondary)] line-clamp-1 max-w-md",children:w.prompt})}),i.jsx("td",{className:"px-4 py-3 text-[var(--text-secondary)]",children:w.criteria.length>0?w.criteria.length:"--"})]},w.id))})]})})]},m)})}),i.jsx(K0,{task:a,onClose:()=>l(null),onDelete:m=>{confirm("Delete this task?")&&S.mutate(m)}}),i.jsx(H0,{isOpen:t,onClose:()=>n(!1),onSubmit:m=>p.mutate(m),isLoading:p.isPending}),i.jsx(W0,{isOpen:r,onClose:()=>s(!1),onSubmit:m=>x.mutate(m),isLoading:x.isPending})]})}function K0({task:e,onClose:t,onDelete:n}){const[r,s]=k.useState("prompt");if(!e)return null;const a=i.jsxs("div",{className:"flex justify-between",children:[i.jsx(K,{variant:"ghost",onClick:()=>n(e.id),className:"text-red-500 hover:text-red-600",children:"Delete Task"}),i.jsx(K,{variant:"secondary",onClick:t,children:"Close"})]});return i.jsx(rs,{isOpen:!!e,onClose:t,title:e.name,size:"lg",footer:a,children:i.jsxs("div",{className:"space-y-4",children:[e.category&&e.category!=="default"&&i.jsx("div",{children:i.jsx(ee,{variant:"default",children:e.category})}),i.jsxs("div",{className:"flex gap-1 border-b border-[var(--border)]",children:[i.jsx("button",{onClick:()=>s("prompt"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="prompt"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Prompt"}),i.jsxs("button",{onClick:()=>s("criteria"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="criteria"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:["Eval Criteria (",e.criteria.length,")"]})]}),r==="prompt"&&i.jsx("div",{className:"p-4 bg-[var(--bg-tertiary)] rounded text-sm whitespace-pre-wrap min-h-[200px]",children:e.prompt}),r==="criteria"&&i.jsx("div",{className:"space-y-2 min-h-[200px]",children:e.criteria.length===0?i.jsx("div",{className:"text-[var(--text-secondary)] text-sm p-4",children:"No evaluation criteria defined for this task."}):e.criteria.map(l=>i.jsxs("div",{className:"p-3 bg-[var(--bg-tertiary)] rounded",children:[i.jsx("div",{className:"font-medium text-sm",children:l.name}),l.instruction&&i.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1",children:l.instruction})]},l.name))})]})})}function H0({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,a]=k.useState({name:"",prompt:"",criteria:[],category:"default"}),l=()=>{a({...s,criteria:[...s.criteria,{name:"",instruction:"",weight:1}]})},o=(h,d)=>{const p=[...s.criteria];p[h]={...p[h],...d},a({...s,criteria:p})},u=h=>{a({...s,criteria:s.criteria.filter((d,p)=>p!==h)})},c=h=>{h.preventDefault(),!(!s.name.trim()||!s.prompt.trim())&&n({...s,criteria:s.criteria.filter(d=>d.name.trim()&&d.instruction.trim())})};return i.jsx(rs,{isOpen:e,onClose:t,title:"Create Task",children:i.jsxs("form",{onSubmit:c,className:"space-y-4",children:[i.jsx(pn,{label:"Name",value:s.name,onChange:h=>a({...s,name:h.target.value}),placeholder:"e.g., fizzbuzz",required:!0}),i.jsx(E0,{label:"Prompt",value:s.prompt,onChange:h=>a({...s,prompt:h.target.value}),placeholder:"The task description for the agent...",required:!0}),i.jsx(pn,{label:"Category",value:s.category,onChange:h=>a({...s,category:h.target.value}),placeholder:"e.g., coding, research"}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Evaluation Criteria"}),i.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"+ Add"})]}),i.jsx("div",{className:"space-y-2",children:s.criteria.map((h,d)=>i.jsxs("div",{className:"flex gap-2 items-start",children:[i.jsx(pn,{value:h.name,onChange:p=>o(d,{name:p.target.value}),placeholder:"Name",className:"w-32"}),i.jsx(pn,{value:h.instruction,onChange:p=>o(d,{instruction:p.target.value}),placeholder:"Instruction",className:"flex-1"}),i.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>u(d),children:"×"})]},d))})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(K,{type:"submit",variant:"primary",disabled:r||!s.name.trim()||!s.prompt.trim(),children:r?"Creating...":"Create"})]})]})})}function W0({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,a]=k.useState(""),{data:l=[],isLoading:o}=ye({queryKey:["suites"],queryFn:()=>Et.listSuites(),enabled:e});return k.useEffect(()=>{l.length>0&&!s&&a(l[0].name)},[l,s]),i.jsx(rs,{isOpen:e,onClose:t,title:"Import Task Suite",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Import a built-in task suite for evaluation."}),o?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading suites..."}):l.length===0?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"No suites available."}):i.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:l.map(u=>i.jsxs("label",{className:`flex items-center gap-3 p-3 border cursor-pointer ${s===u.name?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[i.jsx("input",{type:"radio",name:"suite",value:u.name,checked:s===u.name,onChange:()=>a(u.name),className:"accent-[var(--accent)]"}),i.jsxs("span",{className:"capitalize",children:[u.name.replace(/_/g," ")," (",u.task_count," tasks) - ",u.description]})]},u.name))}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(K,{variant:"primary",onClick:()=>n(s),disabled:r||!s,children:r?"Importing...":"Import"})]})]})})}const q0=Qi(e=>({jobs:[],setJobs:t=>e({jobs:t})}));function G0(){const e=lr(),t=qt(),[n,r]=k.useState(!1),{setJobs:s}=q0(),a=Hu(),{data:l=[],isLoading:o}=ye({queryKey:["jobs",n],queryFn:()=>Ut.list({include_public:n}),refetchInterval:5e3});k.useEffect(()=>{l.length>0&&s(l)},[l,s]);const u=Ge({mutationFn:Ut.delete,onSuccess:()=>t.invalidateQueries({queryKey:["jobs"]})}),c={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"},h=[{key:"name",header:"Name",render:d=>i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:d.name||`Job ${d.id.slice(0,8)}`}),d.is_public&&i.jsx($u,{className:"w-3 h-3 ml-2 inline text-[var(--text-secondary)]"})]})},{key:"status",header:"Status",render:d=>i.jsx(ee,{variant:c[d.status]||"default",children:d.status})},{key:"candidates",header:"Candidates",render:d=>i.jsx("span",{children:d.candidate_ids.length})},{key:"tasks",header:"Tasks",render:d=>i.jsx("span",{children:d.task_ids.length})},{key:"runs",header:"Runs",render:d=>i.jsxs("span",{children:[d.completed_experiments,"/",d.total_experiments]})},{key:"created",header:"Created",render:d=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(d.created_at).toLocaleDateString()}),sortable:!0,sortValue:d=>new Date(d.created_at).getTime()},{key:"actions",header:"",className:"w-12",render:d=>!d.user_id||d.user_id==="anonymous"||a&&d.created_by_name===a?i.jsx("div",{onClick:x=>x.stopPropagation(),children:i.jsx(K,{variant:"ghost",size:"sm",icon:Bu,title:"Delete",disabled:d.status==="running",onClick:()=>{confirm("Delete this job?")&&u.mutate(d.id)}})}):null}];return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Experiments"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"View and manage optimization experiments. Start new experiments from the Agents page."})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(ji,{label:"Show public",checked:n,onChange:d=>r(d.target.checked)}),i.jsx(K,{variant:"secondary",onClick:()=>e("/agents"),children:"Go to Agents"})]})]}),o?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):i.jsx(Bm,{columns:h,data:l,onRowClick:d=>e(`/jobs/${d.id}`),searchable:!0,searchPlaceholder:"Search experiments",searchFilter:(d,p)=>(d.name||"").toLowerCase().includes(p.toLowerCase())||d.id.toLowerCase().includes(p.toLowerCase()),emptyMessage:"No experiments yet. Go to Agents page to start an optimization."})]})}function J0(e,t=!0){return Math.abs(e)<10?"text-[var(--text-secondary)]":(t?e<0:e>0)?"text-green-400":"text-red-400"}function Y0(e){return`${e>0?"+":""}${e.toFixed(1)}%`}function Hm(e,t){return t===0?0:(e-t)/t*100}function ms({label:e,values:t,baselineIndex:n,formatter:r,isLowerBetter:s=!0}){const a=t[n];return i.jsxs("tr",{className:"border-b border-[var(--border)] last:border-0",children:[i.jsx("td",{className:"py-2 pr-4 text-[var(--text-secondary)] text-sm",children:e}),t.map((l,o)=>{const u=Hm(l,a),c=o===n;return i.jsxs("td",{className:"py-2 px-4 text-right",children:[i.jsx("div",{className:"font-mono",children:r(l)}),!c&&i.jsx("div",{className:`text-xs ${J0(u,s)}`,children:Y0(u)}),c&&i.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"(baseline)"})]},o)})]})}function X0({runs:e,baselineRunId:t}){const n=k.useMemo(()=>{if(t){const a=e.findIndex(l=>l.id===t);if(a>=0)return a}return 0},[e,t]);if(e.length<2)return null;const r=Math.min(...e.map(a=>a.tokens_total)),s=Math.max(...e.map(a=>a.score));return i.jsxs(le,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-4",children:"Candidate Comparison"}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-[var(--border)]",children:[i.jsx("th",{className:"pb-2 pr-4 text-left text-[var(--text-secondary)] font-medium",children:"Metric"}),e.map((a,l)=>i.jsx("th",{className:"pb-2 px-4 text-right",children:i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[i.jsx("span",{className:"font-medium",children:a.candidate_name}),a.is_pareto&&i.jsx(ee,{variant:"success",children:"Optimal"}),l===n&&i.jsx(ee,{variant:"info",children:"Base"})]})},a.id))]})}),i.jsxs("tbody",{children:[i.jsx(ms,{label:"Total Tokens",values:e.map(a=>a.tokens_total),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ms,{label:"Input Tokens",values:e.map(a=>a.tokens_input),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ms,{label:"Output Tokens",values:e.map(a=>a.tokens_output),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ms,{label:"Duration",values:e.map(a=>a.duration_seconds),baselineIndex:n,formatter:a=>`${a.toFixed(1)}s`,isLowerBetter:!0}),i.jsx(ms,{label:"Score",values:e.map(a=>a.score*100),baselineIndex:n,formatter:a=>`${a.toFixed(1)}%`,isLowerBetter:!1})]})]})}),i.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[i.jsx("h4",{className:"text-sm font-medium mb-2 text-[var(--text-secondary)]",children:"Key Insights"}),i.jsxs("ul",{className:"text-sm space-y-1 text-[var(--text-secondary)]",children:[e.map(a=>{const l=Hm(a.tokens_total,e[n].tokens_total);return a.tokens_total===r&&l<-5?i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-green-400",children:"✓"}),i.jsxs("span",{children:[i.jsx("strong",{children:a.candidate_name})," uses ",Math.abs(l).toFixed(0),"% fewer tokens"]})]},`token-${a.id}`):null}),e.map(a=>a.score===s&&a.passed?i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-green-400",children:"✓"}),i.jsxs("span",{children:[i.jsx("strong",{children:a.candidate_name})," achieved highest score (",(a.score*100).toFixed(0),"%)"]})]},`score-${a.id}`):null),e.filter(a=>a.is_pareto).length>0&&i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-purple-400",children:"★"}),i.jsxs("span",{children:["Optimal candidates (best tradeoff):"," ",e.filter(a=>a.is_pareto).map(a=>a.candidate_name).join(", ")]})]})]})]}),i.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[i.jsx("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:"Token Efficiency"}),i.jsx("div",{className:"space-y-2",children:e.map(a=>{const l=a.tokens_total/e[n].tokens_total*100,o=a.tokens_total<=r;return i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-24 text-sm truncate",title:a.candidate_name,children:a.candidate_name}),i.jsx("div",{className:"flex-1 h-6 bg-[var(--bg-primary)] rounded overflow-hidden",children:i.jsx("div",{className:`h-full transition-all duration-300 ${o?"bg-green-500":"bg-blue-500"}`,style:{width:`${Math.min(l,100)}%`}})}),i.jsx("div",{className:"w-20 text-right font-mono text-sm",children:a.tokens_total.toLocaleString()})]},a.id)})})]})]})}function Z0({summaries:e,height:t=350}){const n=k.useRef(null),[r,s]=k.useState(600),[a,l]=k.useState("tokens"),[o,u]=k.useState(null),[c,h]=k.useState({x:0,y:0});k.useEffect(()=>{const b=()=>{n.current&&s(n.current.clientWidth)};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[]);const d={top:30,right:30,bottom:50,left:60},p=r-d.left-d.right,x=t-d.top-d.bottom,S=b=>a==="tokens"?b.avg_tokens:b.avg_duration,{xScale:j,yScale:g,xTicks:m,yTicks:f,paretoLine:v}=k.useMemo(()=>{if(e.length===0||p<=0)return{xScale:()=>0,yScale:()=>0,xTicks:[],yTicks:[],paretoLine:[]};const b=e.map(S),N=e.map(T=>T.avg_score),_=Math.min(...b)*.9,F=Math.max(...b)*1.1,P=Math.min(...N,.5),B=Math.min(Math.max(...N)*1.05,1),D=T=>(T-_)/(F-_)*p,U=T=>x-(T-P)/(B-P)*x,ne=Array.from({length:5},(T,A)=>_+A/4*(F-_)),je=Array.from({length:5},(T,A)=>P+A/4*(B-P)),ae=e.filter(T=>T.is_pareto).sort((T,A)=>S(T)-S(A)).map(T=>({x:D(S(T)),y:U(T.avg_score)}));return{xScale:D,yScale:U,xTicks:ne,yTicks:je,paretoLine:ae}},[e,p,x,a]);if(e.length===0)return i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No data to display"});const w=b=>a==="tokens"?b>=1e6?`${(b/1e6).toFixed(1)}M`:b>=1e3?`${(b/1e3).toFixed(0)}K`:b.toFixed(0):`${b.toFixed(1)}s`,C=(b,N)=>{var F;const _=(F=n.current)==null?void 0:F.getBoundingClientRect();_&&h({x:N.clientX-_.left,y:N.clientY-_.top}),u(b)};return i.jsxs("div",{ref:n,className:"w-full relative",children:[i.jsx("div",{className:"flex justify-end mb-2",children:i.jsxs("div",{className:"inline-flex rounded border border-[var(--border)] text-xs",children:[i.jsx("button",{className:`px-3 py-1 ${a==="tokens"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("tokens"),children:"Tokens"}),i.jsx("button",{className:`px-3 py-1 ${a==="duration"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("duration"),children:"Latency"})]})}),i.jsx("svg",{width:r,height:t,className:"font-mono text-xs",children:i.jsxs("g",{transform:`translate(${d.left}, ${d.top})`,children:[m.map((b,N)=>i.jsx("line",{x1:j(b),y1:0,x2:j(b),y2:x,stroke:"var(--border)",strokeDasharray:"2,2"},`x-grid-${N}`)),f.map((b,N)=>i.jsx("line",{x1:0,y1:g(b),x2:p,y2:g(b),stroke:"var(--border)",strokeDasharray:"2,2"},`y-grid-${N}`)),v.length>1&&i.jsx("polyline",{points:v.map(b=>`${b.x},${b.y}`).join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.slice().sort((b,N)=>(b.is_pareto?1:0)-(N.is_pareto?1:0)).map(b=>{const N=j(S(b)),_=g(b.avg_score),F=b.is_pareto,P=(o==null?void 0:o.candidate_name)===b.candidate_name;return i.jsxs("g",{onMouseEnter:B=>C(b,B),onMouseLeave:()=>u(null),children:[i.jsx("circle",{cx:N,cy:_,r:P?10:F?8:6,fill:F?"var(--accent)":"transparent",stroke:P?"var(--text-primary)":F?"var(--accent)":"var(--text-secondary)",strokeWidth:P?3:2,className:"cursor-pointer transition-all"}),F&&!P&&i.jsx("text",{x:N,y:_-12,textAnchor:"middle",fill:"var(--text-primary)",fontSize:10,className:"pointer-events-none",children:b.candidate_name.replace(/^baseline_/,"").slice(0,15)})]},b.candidate_name)}),i.jsx("line",{x1:0,y1:x,x2:p,y2:x,stroke:"var(--text-secondary)"}),m.map((b,N)=>i.jsxs("g",{transform:`translate(${j(b)}, ${x})`,children:[i.jsx("line",{y2:5,stroke:"var(--text-secondary)"}),i.jsx("text",{y:20,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:10,children:w(b)})]},`x-tick-${N}`)),i.jsx("text",{x:p/2,y:x+40,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:a==="tokens"?"Tokens (cost)":"Duration (latency)"}),i.jsx("line",{x1:0,y1:0,x2:0,y2:x,stroke:"var(--text-secondary)"}),f.map((b,N)=>i.jsxs("g",{transform:`translate(0, ${g(b)})`,children:[i.jsx("line",{x2:-5,stroke:"var(--text-secondary)"}),i.jsxs("text",{x:-10,textAnchor:"end",dominantBaseline:"middle",fill:"var(--text-secondary)",fontSize:10,children:[(b*100).toFixed(0),"%"]})]},`y-tick-${N}`)),i.jsx("text",{transform:`translate(-45, ${x/2}) rotate(-90)`,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:"Score (quality)"})]})}),o&&i.jsxs("div",{className:"absolute z-10 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg shadow-lg p-3 text-sm pointer-events-none",style:{left:Math.min(c.x+15,r-200),top:c.y-10,maxWidth:220},children:[i.jsx("div",{className:"font-medium text-[var(--text-primary)] truncate mb-2",children:o.candidate_name.replace(/^baseline_/,"")}),i.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Score:"}),i.jsxs("span",{className:"text-right font-medium",children:[(o.avg_score*100).toFixed(1),"%"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tokens:"}),i.jsxs("span",{className:"text-right",children:[(o.avg_tokens/1e3).toFixed(1),"K"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Duration:"}),i.jsxs("span",{className:"text-right",children:[o.avg_duration.toFixed(1),"s"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Pass rate:"}),i.jsxs("span",{className:"text-right",children:[o.passed_runs,"/",o.total_runs]})]}),o.is_pareto&&i.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)] text-xs text-[var(--accent)]",children:"Optimal (best tradeoff)"})]})]})}function e1(e=2e3){const[t,n]=k.useState(!1),[r,s]=k.useState(null),a=k.useCallback(async o=>{try{return await navigator.clipboard.writeText(o),n(!0),s(null),setTimeout(()=>n(!1),e),!0}catch{return s("Failed to copy to clipboard"),n(!1),!1}},[e]),l=k.useCallback(()=>{n(!1),s(null)},[]);return{copy:a,copied:t,error:r,reset:l}}function t1({isOpen:e,onClose:t,title:n,itemId:r,itemType:s,isPublic:a,createdByName:l,onTogglePublic:o}){const[u,c]=k.useState(!1),{copy:h,copied:d}=e1(),p=`${window.location.origin}/${s}s/${r}`,x=async()=>{c(!0);try{await o(!a)}finally{c(!1)}},S=()=>{h(p)};return i.jsx(rs,{isOpen:e,onClose:t,title:n,children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between p-3 bg-[var(--bg-tertiary)] rounded",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[a?i.jsx($u,{className:"w-5 h-5 text-[var(--accent)]"}):i.jsx(Om,{className:"w-5 h-5 text-[var(--text-secondary)]"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium",children:a?"Public":"Private"}),i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:a?"Anyone with the link can view":"Only you can access"})]})]}),i.jsx("button",{onClick:x,disabled:u,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${a?"bg-[var(--accent)]":"bg-[var(--border)]"} ${u?"opacity-50 cursor-not-allowed":""}`,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${a?"translate-x-6":"translate-x-1"}`})})]}),a&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Share link"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",readOnly:!0,value:p,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono"}),i.jsx(K,{variant:"secondary",onClick:S,children:d?i.jsxs(i.Fragment,{children:[i.jsx(vg,{className:"w-4 h-4 mr-1"}),"Copied"]}):i.jsxs(i.Fragment,{children:[i.jsx(kg,{className:"w-4 h-4 mr-1"}),"Copy"]})})]})]}),l&&i.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",i.jsx("span",{className:"text-[var(--text-primary)]",children:l})]}),i.jsx("div",{className:"text-xs text-[var(--text-secondary)] pt-2 border-t border-[var(--border)]",children:a?i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Public ",s,"s can be viewed by anyone with the link."]}),i.jsxs("p",{className:"mt-1",children:["Only you can edit or delete this ",s,"."]})]}):i.jsxs("p",{children:["Make this ",s," public to share it with others."]})})]})})}function n1({job:e,onUpdate:t}){const[n,r]=k.useState(!1),s=async a=>{await Ut.update(e.id,{is_public:a}),t()};return i.jsxs(i.Fragment,{children:[i.jsxs(K,{variant:"secondary",size:"sm",onClick:()=>r(!0),title:e.is_public?"Sharing settings":"Share this job",children:[i.jsx(Rg,{className:"w-4 h-4 mr-1"}),e.is_public?"Shared":"Share"]}),i.jsx(t1,{isOpen:n,onClose:()=>r(!1),title:"Share Job",itemId:e.id,itemType:"job",isPublic:e.is_public,createdByName:e.created_by_name,onTogglePublic:s})]})}function r1(){const{jobId:e}=Ai(),t=lr(),n=qt(),[r,s]=k.useState(null),[a,l]=k.useState(!1),[o,u]=k.useState(null),[c,h]=k.useState([]),[d,p]=k.useState(null),[x,S]=k.useState(null),[j,g]=k.useState("results"),[m,f]=k.useState("score"),[v,w]=k.useState("desc"),[C,b]=k.useState(!1),{data:N,isLoading:_}=ye({queryKey:["jobs",e],queryFn:()=>Ut.get(e),enabled:!!e,refetchInterval:a?2e3:!1}),{data:F=[]}=ye({queryKey:["runs",e],queryFn:()=>zo.list({job_id:e}),enabled:!!e,refetchInterval:a?2e3:!1}),{data:P}=ye({queryKey:["job-summary",e],queryFn:()=>zo.getJobSummary(e),enabled:!!e&&(N==null?void 0:N.status)==="completed"}),B=Ge({mutationFn:async()=>{l(!0),h([]),p(null),S(null);for await(const R of Ut.start(e))s(R),R.current_candidate&&R.current_task&&p(O=>(O&&(O.candidate!==R.current_candidate||O.task!==R.current_task)&&h(X=>[...X,{candidate_name:O.candidate,task_name:O.task,completed_at:Date.now()}]),{candidate:R.current_candidate,task:R.current_task})),R.event==="error"&&(S(R.message),l(!1),n.invalidateQueries({queryKey:["jobs",e]})),R.event==="complete"&&(p(O=>(O&&h(X=>[...X,{candidate_name:O.candidate,task_name:O.task,completed_at:Date.now()}]),null)),l(!1),n.invalidateQueries({queryKey:["jobs",e]}),n.invalidateQueries({queryKey:["runs",e]}),n.invalidateQueries({queryKey:["job-summary",e]}))}}),D=Ge({mutationFn:()=>Ut.cancel(e),onSuccess:()=>{l(!1),n.invalidateQueries({queryKey:["jobs",e]})}});k.useEffect(()=>{(N==null?void 0:N.status)==="running"&&l(!0)},[N==null?void 0:N.status]);const U=k.useMemo(()=>{const R=new Map;for(const O of F)R.has(O.task_name)||R.set(O.task_name,[]),R.get(O.task_name).push(O);return R},[F]),ne=k.useMemo(()=>Array.from(U.keys()),[U]),je=k.useMemo(()=>{if(!(P!=null&&P.candidate_summaries))return[];let R=[...P.candidate_summaries];return C&&(R=R.filter(O=>O.is_pareto)),R.sort((O,X)=>{let he,Ne;switch(m){case"score":he=O.avg_score,Ne=X.avg_score;break;case"tokens":he=O.avg_tokens,Ne=X.avg_tokens;break;case"duration":he=O.avg_duration,Ne=X.avg_duration;break;case"pass_rate":he=O.passed_runs/O.total_runs,Ne=X.passed_runs/X.total_runs;break}return v==="desc"?Ne-he:he-Ne}),R},[P,m,v,C]),Je=R=>{m===R?w(v==="desc"?"asc":"desc"):(f(R),w(R==="tokens"||R==="duration"?"asc":"desc"))},ae=({label:R,sortKeyVal:O})=>i.jsx("th",{className:"pb-2 cursor-pointer hover:text-[var(--text-primary)] select-none",onClick:()=>Je(O),children:i.jsxs("div",{className:"flex items-center gap-1",children:[R,m===O&&i.jsx(hg,{size:12,className:v==="asc"?"rotate-180":""})]})});if(_)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!N)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Job not found"});const T=Hu(),A=!N.user_id||N.user_id==="anonymous"||T&&N.created_by_name===T,L=N.is_public&&!A,V=()=>{n.invalidateQueries({queryKey:["jobs",e]})},Y=R=>{const O={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};return i.jsx(ee,{variant:O[R]||"default",children:R})};return i.jsxs("div",{children:[i.jsx(Ki,{items:[{label:"Experiments",path:"/jobs"},{label:N.name||`Job ${N.id.slice(0,8)}`}]}),i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:N.name||`Job ${N.id.slice(0,8)}`}),Y(N.status),N.is_public&&i.jsxs(ee,{variant:"info",children:[i.jsx($u,{className:"w-3 h-3 mr-1 inline"}),"Public"]})]}),i.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-2 py-0.5 rounded font-mono text-[var(--text-secondary)]",children:[N.id.slice(0,8),"..."]}),i.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[N.candidate_ids.length," candidates × ",N.task_ids.length," tasks = ",N.total_experiments," experiments"]}),N.is_public&&N.created_by_name&&i.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",i.jsx("span",{className:"text-[var(--text-primary)]",children:N.created_by_name})]})]})]}),i.jsxs("div",{className:"flex gap-2",children:[A&&i.jsx(n1,{job:N,onUpdate:V}),L&&i.jsx(ee,{variant:"default",children:"View Only"}),A&&N.status==="pending"&&i.jsx(K,{variant:"primary",onClick:()=>B.mutate(),disabled:B.isPending,children:B.isPending?"Starting...":"Start"}),A&&N.status==="running"&&i.jsx(K,{variant:"danger",onClick:()=>D.mutate(),disabled:D.isPending,children:"Cancel"})]})]}),(x||N.error)&&i.jsx(le,{className:"mb-6 border-red-500/50 bg-red-500/10",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-5 h-5 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-0.5",children:"!"}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium text-red-400",children:"Error"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:x||N.error})]})]})}),(a||r)&&i.jsxs(le,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("span",{className:"font-medium",children:"Progress"}),i.jsxs("span",{className:"text-[var(--accent)]",children:[(r==null?void 0:r.completed)||N.completed_experiments,"/",(r==null?void 0:r.total)||N.total_experiments]})]}),i.jsx("div",{className:"w-full bg-[var(--bg-primary)] h-2 mb-2",children:i.jsx("div",{className:"h-full bg-[var(--accent)] transition-all",style:{width:`${((r==null?void 0:r.completed)||N.completed_experiments)/((r==null?void 0:r.total)||N.total_experiments)*100}%`}})}),(r==null?void 0:r.message)&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r.message}),a&&i.jsxs("div",{className:"mt-4 border-t border-[var(--border)] pt-4",children:[(r==null?void 0:r.current_candidate)&&(r==null?void 0:r.current_task)&&i.jsxs("div",{className:"mb-3",children:[i.jsx("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:"Currently Running"}),i.jsxs("div",{className:"flex items-center gap-2 mt-1 px-3 py-2 bg-blue-500/10 border border-blue-500/30 rounded",children:[i.jsx("div",{className:"w-2 h-2 bg-blue-400 rounded-full animate-pulse"}),i.jsx("span",{className:"font-medium",children:r.current_candidate}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{children:r.current_task})]})]}),c.length>0&&i.jsxs("div",{children:[i.jsxs("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:["Completed (",c.length,")"]}),i.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto space-y-1",children:c.map((R,O)=>i.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-500/10 border border-green-500/30 rounded text-sm",children:[i.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}),i.jsx("span",{className:"font-medium",children:R.candidate_name}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{children:R.task_name})]},`${R.candidate_name}-${R.task_name}-${O}`))})]})]})]}),(N.status==="completed"||F.length>0)&&i.jsxs("div",{className:"flex gap-1 mb-6 border-b border-[var(--border)]",children:[i.jsxs("button",{onClick:()=>g("results"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${j==="results"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(mg,{size:16}),"Results"]}),i.jsxs("button",{onClick:()=>g("compare"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${j==="compare"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(Cg,{size:16}),"Compare"]}),i.jsxs("button",{onClick:()=>g("runs"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${j==="runs"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(Pg,{size:16}),"Runs (",F.length,")"]})]}),j==="results"&&i.jsxs(i.Fragment,{children:[P&&P.candidate_summaries.length>1&&i.jsxs(le,{className:"mb-6",children:[i.jsx("div",{className:"flex items-start justify-between mb-4",children:i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium",children:"Quality vs. Cost Tradeoff"}),i.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:["Candidates on the frontier (connected line) are ",i.jsx("strong",{children:"optimal"})," - no other candidate beats them on both score AND cost."]})]})}),i.jsxs("div",{className:"mb-4 p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs text-[var(--text-secondary)]",children:[i.jsx("strong",{className:"text-[var(--text-primary)]",children:"How optimal tradeoffs are calculated:"})," A candidate is optimal if there's no other candidate that has both a higher score AND lower cost. For example, if Candidate A has 95% score at 50K tokens and Candidate B has 90% score at 40K tokens, both are optimal - A is better on score, B is better on cost. But if Candidate C has 85% score at 60K tokens, it's ",i.jsx("em",{children:"not"})," optimal because B beats it on both metrics."]}),i.jsx(Z0,{summaries:P.candidate_summaries,height:350})]}),P&&i.jsxs(le,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h3",{className:"font-medium",children:"Results Summary"}),i.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:C,onChange:R=>b(R.target.checked),className:"rounded border-[var(--border)]"}),"Optimal only"]})]}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"text-left text-[var(--text-secondary)] border-b border-[var(--border)]",children:[i.jsx("th",{className:"pb-2",children:"Candidate"}),i.jsx(ae,{label:"Score",sortKeyVal:"score"}),i.jsx(ae,{label:"Tokens",sortKeyVal:"tokens"}),i.jsx(ae,{label:"Duration",sortKeyVal:"duration"}),i.jsx(ae,{label:"Pass Rate",sortKeyVal:"pass_rate"}),i.jsx("th",{className:"pb-2",children:"Optimal"})]})}),i.jsx("tbody",{children:je.map((R,O)=>i.jsxs("tr",{className:`border-b border-[var(--border)] ${O===0?"bg-[var(--accent)]/10":""}`,children:[i.jsxs("td",{className:"py-2 font-medium",children:[O===0&&i.jsx("span",{className:"text-[var(--accent)] mr-1",children:"#1"}),R.candidate_name.replace(/^baseline_/,"")]}),i.jsxs("td",{className:"py-2",children:[(R.avg_score*100).toFixed(1),"%"]}),i.jsxs("td",{className:"py-2",children:[(R.avg_tokens/1e3).toFixed(1),"K"]}),i.jsxs("td",{className:"py-2",children:[R.avg_duration.toFixed(1),"s"]}),i.jsxs("td",{className:"py-2",children:[R.passed_runs,"/",R.total_runs]}),i.jsx("td",{className:"py-2",children:R.is_pareto&&i.jsx(ee,{variant:"success",children:"Optimal"})})]},R.candidate_name))})]})}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-3",children:"Click column headers to sort. The #1 ranked candidate is highlighted based on your sort criteria."})]}),!P&&i.jsx(le,{children:i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Results will appear here after the job completes.":"No results yet. Start the job to see results."})})]}),j==="compare"&&i.jsxs(le,{children:[i.jsx("h3",{className:"font-medium mb-4",children:"Compare Candidates by Task"}),ne.length>0?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:ne.map(R=>i.jsx("button",{onClick:()=>u(o===R?null:R),className:`px-3 py-1 text-sm rounded border transition-colors ${o===R?"bg-[var(--accent)] text-white border-[var(--accent)]":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:R},R))}),o&&U.get(o)?i.jsx(X0,{runs:U.get(o).map(R=>({id:R.id,candidate_name:R.candidate_name,tokens_input:0,tokens_output:0,tokens_total:R.tokens_total,duration_seconds:R.duration_seconds,score:R.score,passed:R.passed,is_pareto:R.is_pareto}))}):i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"Select a task above to compare how different candidates performed on it."})]}):i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Comparison data will appear here after runs complete.":"No runs yet. Start the job to compare candidates."})]}),j==="runs"&&i.jsxs(le,{children:[i.jsx("h3",{className:"font-medium mb-4",children:"All Experiment Runs"}),F.length===0?i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Runs will appear here as they complete. See progress above for live status.":"No runs yet. Start the job to see results."}):i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:F.map(R=>i.jsxs("div",{className:"p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] cursor-pointer hover:border-[var(--accent-dim)] transition-colors",onClick:()=>t(`/runs/${R.id}`),children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("span",{className:`text-lg font-bold ${R.passed?"text-green-400":"text-red-400"}`,children:[(R.score*100).toFixed(0),"%"]}),R.is_pareto&&i.jsx(ee,{variant:"success",children:"Optimal"})]}),i.jsx("div",{className:"text-sm font-medium truncate",title:R.candidate_name,children:R.candidate_name.replace(/^baseline_/,"")}),i.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:R.task_name}),i.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:[(R.tokens_total/1e3).toFixed(1),"K tokens"]}),i.jsxs("span",{children:[R.duration_seconds.toFixed(1),"s"]})]})]},R.id))})]})]})}const vn={input:"bg-blue-500",output:"bg-emerald-500",inputText:"text-blue-400",outputText:"text-emerald-400"};function Od(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ld({input:e,output:t,maxValue:n,height:r=24,showLabels:s=!0}){const a=e+t;if(a===0)return i.jsx("div",{className:"flex items-center gap-2 w-full",children:i.jsx("div",{className:"rounded bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`}})});const l=n>0?a/n*100:100;return i.jsxs("div",{className:"flex items-center gap-3 w-full",children:[i.jsx("div",{className:"relative rounded overflow-hidden bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`},children:i.jsxs("div",{className:"h-full flex transition-all duration-300",style:{width:`${l}%`},children:[i.jsx("div",{className:`h-full ${vn.input} transition-all`,style:{width:`${e/a*100}%`},title:`Input: ${e.toLocaleString()} tokens`}),i.jsx("div",{className:`h-full ${vn.output} transition-all`,style:{width:`${t/a*100}%`},title:`Output: ${t.toLocaleString()} tokens`})]})}),s&&i.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono text-[var(--text-secondary)] min-w-[90px] justify-end",children:[i.jsxs("span",{className:vn.inputText,children:["↑",Od(e)]}),i.jsx("span",{children:"/"}),i.jsxs("span",{className:vn.outputText,children:["↓",Od(t)]})]})]})}function kl({label:e,value:t,color:n="default"}){const r={default:"text-[var(--text-primary)]",input:vn.inputText,output:vn.outputText}[n];return i.jsxs("div",{className:"flex-1 p-3 bg-[var(--bg-primary)] border border-[var(--border)] rounded",children:[i.jsx("div",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e}),i.jsx("div",{className:`font-mono text-lg font-bold ${r}`,children:t})]})}function Wm({tokensInput:e,tokensOutput:t,tokensTotal:n,turns:r}){const s=n>0?Math.round(e/n*100):0,a=n>0?Math.round(t/n*100):0,l=k.useMemo(()=>{if(!r||r.length===0)return null;let u=0,c=0;return r.map(h=>(u+=h.input,c+=h.output,{input:u,output:c,total:u+c}))},[r]),o=l?Math.max(...l.map(u=>u.total)):n;return i.jsxs(le,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-4",children:"Token Usage"}),i.jsx("div",{className:"mb-4",children:i.jsx(Ld,{input:e,output:t,maxValue:n,height:32})}),i.jsxs("div",{className:"flex items-center gap-6 text-xs mb-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:`w-3 h-3 rounded ${vn.input}`}),i.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Input (",s,"%)"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:`w-3 h-3 rounded ${vn.output}`}),i.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Output (",a,"%)"]})]})]}),i.jsxs("div",{className:"flex gap-3 mb-4",children:[i.jsx(kl,{label:"Input Tokens",value:e.toLocaleString(),color:"input"}),i.jsx(kl,{label:"Output Tokens",value:t.toLocaleString(),color:"output"}),i.jsx(kl,{label:"Total Tokens",value:n.toLocaleString()})]}),l&&l.length>1&&i.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[i.jsxs("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:["Token Accumulation (",r.length," turns)"]}),i.jsx("div",{className:"space-y-2",children:r.map((u,c)=>i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--bg-primary)] border border-[var(--border)] flex items-center justify-center text-xs font-medium",children:c+1}),i.jsx("div",{className:"flex-1",children:i.jsx(Ld,{input:l[c].input,output:l[c].output,maxValue:o,height:16})})]},c))})]}),i.jsx("div",{className:"mt-4 text-xs text-[var(--text-secondary)] border-t border-[var(--border)] pt-3",children:"Token usage affects API cost. Input tokens are typically cheaper than output tokens."})]})}function s1(){const{runId:e}=Ai(),{data:t,isLoading:n}=ye({queryKey:["runs",e],queryFn:()=>zo.get(e),enabled:!!e});return n?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?i.jsxs("div",{children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(Ki,{items:[{label:"Experiments",path:"/jobs"},{label:"Job",path:`/jobs/${t.job_id}`},{label:t.candidate_name}]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:t.candidate_name}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{className:"text-lg",children:t.task_name}),t.is_pareto&&i.jsx(ee,{variant:"success",children:"Optimal"})]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[i.jsx(Oa,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),i.jsx(Oa,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),i.jsx(Oa,{label:"Duration",value:`${t.duration_seconds.toFixed(1)}s`}),i.jsx(Oa,{label:"Status",value:t.passed?"Passed":"Failed",status:t.passed?"success":"error"})]}),i.jsx(Wm,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),i.jsxs(le,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),t.reasoning&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:t.reasoning}),t.criteria_results.length>0&&i.jsx("div",{className:"space-y-2",children:t.criteria_results.map(r=>i.jsx("div",{className:"flex items-start justify-between p-3 bg-[var(--bg-primary)] border border-[var(--border)]",children:i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-medium",children:r.name}),i.jsxs(ee,{variant:r.passed?"success":"error",children:[(r.score*100).toFixed(0),"%"]})]}),r.reasoning&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r.reasoning})]})},r.name))})]}),i.jsxs(le,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created.length>0&&i.jsxs(le,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),i.jsx("div",{className:"space-y-1",children:t.files_created.map(r=>i.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:r},r))})]}),Object.keys(t.trace).length>0&&i.jsx(Vm,{trace:t.trace})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Run not found"})}function Oa({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return i.jsxs(le,{children:[i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),i.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function a1(){const{testId:e}=Ai(),{data:t,isLoading:n}=ye({queryKey:["tests",e],queryFn:()=>Ps.get(e),enabled:!!e}),{data:r}=ye({queryKey:["configs",t==null?void 0:t.agent_id],queryFn:()=>Er.get(t.agent_id),enabled:!!(t!=null&&t.agent_id)});if(n)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!t)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Test not found"});const s={completed:"success",failed:"error",running:"info",pending:"default",cancelled:"warning"};return i.jsxs("div",{children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(Ki,{items:[{label:"Agents",path:"/agents"},...r?[{label:r.name,path:`/agents/${r.id}`}]:[],{label:`Test ${t.id.slice(0,8)}`}]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:"Test Run"}),r&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"•"}),i.jsx("span",{className:"text-lg",children:r.name})]}),i.jsx(ee,{variant:s[t.status]||"default",children:t.status})]}),i.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:["ID: ",t.id.slice(0,8),"..."]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[i.jsx(La,{label:"Duration",value:`${t.duration_seconds.toFixed(2)}s`}),i.jsx(La,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),t.score!==null&&i.jsx(La,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),i.jsx(La,{label:"Status",value:t.status.charAt(0).toUpperCase()+t.status.slice(1),status:t.status==="completed"?"success":t.status==="failed"?"error":void 0})]}),i.jsx(Wm,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),i.jsxs(le,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Prompt"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)] font-mono",children:t.prompt})]}),t.error&&i.jsxs(le,{className:"mb-6 border-red-500/30 bg-red-500/5",children:[i.jsx("h3",{className:"font-medium mb-3 text-red-400",children:"Error"}),i.jsx("pre",{className:"text-sm text-red-300 overflow-x-auto whitespace-pre-wrap",children:t.error})]}),t.reasoning&&i.jsxs(le,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.reasoning})]}),i.jsxs(le,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created&&t.files_created.length>0&&i.jsxs(le,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),i.jsx("div",{className:"space-y-1",children:t.files_created.map(a=>i.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:a},a))})]}),t.trace&&Object.keys(t.trace).length>0&&i.jsx(Vm,{trace:t.trace}),i.jsxs(le,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Timestamps"}),i.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Created:"}),i.jsx("div",{className:"font-mono",children:new Date(t.created_at).toLocaleString()})]}),t.started_at&&i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Started:"}),i.jsx("div",{className:"font-mono",children:new Date(t.started_at).toLocaleString()})]}),t.completed_at&&i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Completed:"}),i.jsx("div",{className:"font-mono",children:new Date(t.completed_at).toLocaleString()})]})]})]})]})}function La({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return i.jsxs(le,{children:[i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),i.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function i1(){const{authConfig:e,isLoading:t,error:n,login:r,loginWithGitHub:s,clearError:a}=Wu(),[l,o]=k.useState(""),[u,c]=k.useState("");k.useEffect(()=>{n&&a()},[l,u]);const h=async p=>{p.preventDefault(),!(!l||!u)&&await r(l,u)},d=()=>{s()};return i.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:i.jsxs("div",{className:"w-full max-w-md",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:"Flow"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:"Sign in to access the optimization dashboard"})]}),i.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] p-6 space-y-6",children:[n&&i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[var(--error)]/10 border border-[var(--error)]/20 text-[var(--error)]",children:[i.jsx(Pm,{size:18,className:"mt-0.5 flex-shrink-0"}),i.jsx("p",{className:"text-sm",children:n})]}),(e==null?void 0:e.mode)==="basic"&&i.jsxs("form",{onSubmit:h,className:"space-y-4",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Username"}),i.jsxs("div",{className:"relative",children:[i.jsx(Rm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),i.jsx("input",{type:"text",value:l,onChange:p=>o(p.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter username",autoComplete:"username",autoFocus:!0})]})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Password"}),i.jsxs("div",{className:"relative",children:[i.jsx(Om,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),i.jsx("input",{type:"password",value:u,onChange:p=>c(p.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter password",autoComplete:"current-password"})]})]}),i.jsx(K,{type:"submit",variant:"primary",className:"w-full justify-center",loading:t,disabled:!l||!u,children:"Sign In"})]}),(e==null?void 0:e.mode)==="github"&&i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center",children:"Sign in with your GitHub account to continue"}),i.jsx(K,{onClick:d,variant:"secondary",className:"w-full justify-center",icon:_g,children:"Continue with GitHub"})]})]})]})})}function l1({children:e}){const{authConfig:t,isLoadingConfig:n,isAuthenticated:r,loadAuthConfig:s,handleOAuthCallback:a}=Wu();return k.useEffect(()=>{s()},[s]),k.useEffect(()=>{n||a()},[n,a]),n?i.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center",children:i.jsxs("div",{className:"text-center",children:[i.jsx(da,{className:"w-8 h-8 animate-spin text-[var(--accent)] mx-auto mb-4"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:"Loading..."})]})}):t!=null&&t.enabled&&!r?i.jsx(i1,{}):i.jsx(i.Fragment,{children:e})}function o1(){return i.jsx(ag,{children:i.jsx(l1,{children:i.jsx(Yy,{children:i.jsxs(kt,{path:"/",element:i.jsx(S0,{}),children:[i.jsx(kt,{index:!0,element:i.jsx(Td,{})}),i.jsx(kt,{path:"agents",element:i.jsx(Td,{})}),i.jsx(kt,{path:"agents/:agentId",element:i.jsx(U0,{})}),i.jsx(kt,{path:"tasks",element:i.jsx(V0,{})}),i.jsx(kt,{path:"jobs",element:i.jsx(G0,{})}),i.jsx(kt,{path:"jobs/:jobId",element:i.jsx(r1,{})}),i.jsx(kt,{path:"runs/:runId",element:i.jsx(s1,{})}),i.jsx(kt,{path:"tests/:testId",element:i.jsx(a1,{})})]})})})})}const Rd=localStorage.getItem("flow-theme");if(Rd)try{const{state:e}=JSON.parse(Rd);e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}catch{}const u1=new Hx({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}});Sl.createRoot(document.getElementById("root")).render(i.jsx(Qo.StrictMode,{children:i.jsx(Wx,{client:u1,children:i.jsx(o1,{})})})); diff --git a/src/flow/ui/ui/assets/index-DKjKkzcl.js b/src/flow/ui/ui/assets/index-DKjKkzcl.js new file mode 100644 index 0000000000000000000000000000000000000000..6afef37cfe27d92cdbcb6af909bdc690b080805c --- /dev/null +++ b/src/flow/ui/ui/assets/index-DKjKkzcl.js @@ -0,0 +1,347 @@ +var nu=e=>{throw TypeError(e)};var qi=(e,t,n)=>t.has(e)||nu("Cannot "+n);var y=(e,t,n)=>(qi(e,t,"read from private field"),n?n.call(e):t.get(e)),$=(e,t,n)=>t.has(e)?nu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),z=(e,t,n,r)=>(qi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),q=(e,t,n)=>(qi(e,t,"access private method"),n);var xa=(e,t,n,r)=>({set _(s){z(e,t,s,n)},get _(){return y(e,t,r)}});function lp(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();function Yd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xd={exports:{}},Si={},Zd={exports:{}},Y={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var la=Symbol.for("react.element"),op=Symbol.for("react.portal"),cp=Symbol.for("react.fragment"),up=Symbol.for("react.strict_mode"),dp=Symbol.for("react.profiler"),fp=Symbol.for("react.provider"),hp=Symbol.for("react.context"),mp=Symbol.for("react.forward_ref"),pp=Symbol.for("react.suspense"),xp=Symbol.for("react.memo"),vp=Symbol.for("react.lazy"),ru=Symbol.iterator;function yp(e){return e===null||typeof e!="object"?null:(e=ru&&e[ru]||e["@@iterator"],typeof e=="function"?e:null)}var ef={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},tf=Object.assign,nf={};function Xr(e,t,n){this.props=e,this.context=t,this.refs=nf,this.updater=n||ef}Xr.prototype.isReactComponent={};Xr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Xr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function rf(){}rf.prototype=Xr.prototype;function Ko(e,t,n){this.props=e,this.context=t,this.refs=nf,this.updater=n||ef}var Ho=Ko.prototype=new rf;Ho.constructor=Ko;tf(Ho,Xr.prototype);Ho.isPureReactComponent=!0;var su=Array.isArray,sf=Object.prototype.hasOwnProperty,qo={current:null},af={key:!0,ref:!0,__self:!0,__source:!0};function lf(e,t,n){var r,s={},i=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(i=""+t.key),t)sf.call(t,r)&&!af.hasOwnProperty(r)&&(s[r]=t[r]);var o=arguments.length-2;if(o===1)s.children=n;else if(1>>1,ee=P[K];if(0>>1;Ks(te,L))pes(Se,te)?(P[K]=Se,P[pe]=L,K=pe):(P[K]=te,P[T]=L,K=T);else if(pes(Se,L))P[K]=Se,P[pe]=L,K=pe;else break e}}return A}function s(P,A){var L=P.sortIndex-A.sortIndex;return L!==0?L:P.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var c=[],d=[],f=1,u=null,m=3,v=!1,k=!1,g=!1,b=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,h=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(P){for(var A=n(d);A!==null;){if(A.callback===null)r(d);else if(A.startTime<=P)r(d),A.sortIndex=A.expirationTime,t(c,A);else break;A=n(d)}}function w(P){if(g=!1,x(P),!k)if(n(c)!==null)k=!0,G(C);else{var A=n(d);A!==null&&X(w,A.startTime-P)}}function C(P,A){k=!1,g&&(g=!1,p(_),_=-1),v=!0;var L=m;try{for(x(A),u=n(c);u!==null&&(!(u.expirationTime>A)||P&&!Q());){var K=u.callback;if(typeof K=="function"){u.callback=null,m=u.priorityLevel;var ee=K(u.expirationTime<=A);A=e.unstable_now(),typeof ee=="function"?u.callback=ee:u===n(c)&&r(c),x(A)}else r(c);u=n(c)}if(u!==null)var R=!0;else{var T=n(d);T!==null&&X(w,T.startTime-A),R=!1}return R}finally{u=null,m=L,v=!1}}var S=!1,N=null,_=-1,F=5,O=-1;function Q(){return!(e.unstable_now()-OP||125K?(P.sortIndex=L,t(d,P),n(c)===null&&P===n(d)&&(g?(p(_),_=-1):g=!0,X(w,L-K))):(P.sortIndex=ee,t(c,P),k||v||(k=!0,G(C))),P},e.unstable_shouldYield=Q,e.unstable_wrapCallback=function(P){var A=m;return function(){var L=m;m=A;try{return P.apply(this,arguments)}finally{m=L}}}})(ff);df.exports=ff;var Tp=df.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Op=j,et=Tp;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),El=Object.prototype.hasOwnProperty,Lp=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,iu={},lu={};function Rp(e){return El.call(lu,e)?!0:El.call(iu,e)?!1:Lp.test(e)?lu[e]=!0:(iu[e]=!0,!1)}function Mp(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function zp(e,t,n,r){if(t===null||typeof t>"u"||Mp(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Be(e,t,n,r,s,i,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=l}var Oe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Oe[e]=new Be(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Oe[t]=new Be(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Oe[e]=new Be(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Oe[e]=new Be(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Oe[e]=new Be(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Oe[e]=new Be(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Oe[e]=new Be(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Oe[e]=new Be(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Oe[e]=new Be(e,5,!1,e.toLowerCase(),null,!1,!1)});var Jo=/[\-:]([a-z])/g;function Yo(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Jo,Yo);Oe[t]=new Be(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Jo,Yo);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Jo,Yo);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!1,!1)});Oe.xlinkHref=new Be("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!0,!0)});function Xo(e,t,n,r){var s=Oe.hasOwnProperty(t)?Oe[t]:null;(s!==null?s.type!==0:r||!(2o||s[l]!==i[o]){var c=` +`+s[l].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{Ji=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?vs(e):""}function Fp(e){switch(e.tag){case 5:return vs(e.type);case 16:return vs("Lazy");case 13:return vs("Suspense");case 19:return vs("SuspenseList");case 0:case 2:case 15:return e=Yi(e.type,!1),e;case 11:return e=Yi(e.type.render,!1),e;case 1:return e=Yi(e.type,!0),e;default:return""}}function Ll(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case mr:return"Fragment";case hr:return"Portal";case Pl:return"Profiler";case Zo:return"StrictMode";case Tl:return"Suspense";case Ol:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case pf:return(e.displayName||"Context")+".Consumer";case mf:return(e._context.displayName||"Context")+".Provider";case ec:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case tc:return t=e.displayName||null,t!==null?t:Ll(e.type)||"Memo";case Xt:t=e._payload,e=e._init;try{return Ll(e(t))}catch{}}return null}function Ip(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ll(t);case 8:return t===Zo?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function En(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function vf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Dp(e){var t=vf(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(l){r=""+l,i.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ga(e){e._valueTracker||(e._valueTracker=Dp(e))}function yf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=vf(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ja(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Rl(e,t){var n=t.checked;return me({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function cu(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=En(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function gf(e,t){t=t.checked,t!=null&&Xo(e,"checked",t,!1)}function Ml(e,t){gf(e,t);var n=En(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?zl(e,t.type,n):t.hasOwnProperty("defaultValue")&&zl(e,t.type,En(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function uu(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function zl(e,t,n){(t!=="number"||Ja(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var ys=Array.isArray;function Sr(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=ja.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Rs(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ks={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Ap=["Webkit","ms","Moz","O"];Object.keys(ks).forEach(function(e){Ap.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ks[t]=ks[e]})});function bf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||ks.hasOwnProperty(e)&&ks[e]?(""+t).trim():t+"px"}function Nf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=bf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var $p=me({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Dl(e,t){if(t){if($p[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function Al(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var $l=null;function nc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Ul=null,Cr=null,_r=null;function hu(e){if(e=ua(e)){if(typeof Ul!="function")throw Error(E(280));var t=e.stateNode;t&&(t=Ti(t),Ul(e.stateNode,e.type,t))}}function Sf(e){Cr?_r?_r.push(e):_r=[e]:Cr=e}function Cf(){if(Cr){var e=Cr,t=_r;if(_r=Cr=null,hu(e),t)for(e=0;e>>=0,e===0?32:31-(Yp(e)/Xp|0)|0}var wa=64,ka=4194304;function gs(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function ei(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~s;o!==0?r=gs(o):(i&=l,i!==0&&(r=gs(i)))}else l=n&~s,l!==0?r=gs(l):i!==0&&(r=gs(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function oa(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-jt(t),e[t]=n}function nx(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Ns),ku=" ",bu=!1;function Hf(e,t){switch(e){case"keyup":return Tx.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function qf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var pr=!1;function Lx(e,t){switch(e){case"compositionend":return qf(t);case"keypress":return t.which!==32?null:(bu=!0,ku);case"textInput":return e=t.data,e===ku&&bu?null:e;default:return null}}function Rx(e,t){if(pr)return e==="compositionend"||!uc&&Hf(e,t)?(e=Vf(),$a=lc=fn=null,pr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=_u(n)}}function Yf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Yf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Xf(){for(var e=window,t=Ja();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ja(e.document)}return t}function dc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Bx(e){var t=Xf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Yf(n.ownerDocument.documentElement,n)){if(r!==null&&dc(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=Eu(n,i);var l=Eu(n,r);s&&l&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,xr=null,ql=null,Cs=null,Wl=!1;function Pu(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Wl||xr==null||xr!==Ja(r)||(r=xr,"selectionStart"in r&&dc(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Cs&&As(Cs,r)||(Cs=r,r=ri(ql,"onSelect"),0gr||(e.current=eo[gr],eo[gr]=null,gr--)}function ie(e,t){gr++,eo[gr]=e.current,e.current=t}var Pn={},Fe=Ln(Pn),qe=Ln(!1),er=Pn;function Vr(e,t){var n=e.type.contextTypes;if(!n)return Pn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function We(e){return e=e.childContextTypes,e!=null}function ai(){ue(qe),ue(Fe)}function Fu(e,t,n){if(Fe.current!==Pn)throw Error(E(168));ie(Fe,t),ie(qe,n)}function lh(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(E(108,Ip(e)||"Unknown",s));return me({},n,r)}function ii(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Pn,er=Fe.current,ie(Fe,e),ie(qe,qe.current),!0}function Iu(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=lh(e,t,er),r.__reactInternalMemoizedMergedChildContext=e,ue(qe),ue(Fe),ie(Fe,e)):ue(qe),ie(qe,n)}var Mt=null,Oi=!1,dl=!1;function oh(e){Mt===null?Mt=[e]:Mt.push(e)}function ev(e){Oi=!0,oh(e)}function Rn(){if(!dl&&Mt!==null){dl=!0;var e=0,t=ae;try{var n=Mt;for(ae=1;e>=l,s-=l,At=1<<32-jt(t)+s|n<_?(F=N,N=null):F=N.sibling;var O=m(p,N,x[_],w);if(O===null){N===null&&(N=F);break}e&&N&&O.alternate===null&&t(p,N),h=i(O,h,_),S===null?C=O:S.sibling=O,S=O,N=F}if(_===x.length)return n(p,N),de&&Fn(p,_),C;if(N===null){for(;__?(F=N,N=null):F=N.sibling;var Q=m(p,N,O.value,w);if(Q===null){N===null&&(N=F);break}e&&N&&Q.alternate===null&&t(p,N),h=i(Q,h,_),S===null?C=Q:S.sibling=Q,S=Q,N=F}if(O.done)return n(p,N),de&&Fn(p,_),C;if(N===null){for(;!O.done;_++,O=x.next())O=u(p,O.value,w),O!==null&&(h=i(O,h,_),S===null?C=O:S.sibling=O,S=O);return de&&Fn(p,_),C}for(N=r(p,N);!O.done;_++,O=x.next())O=v(N,p,_,O.value,w),O!==null&&(e&&O.alternate!==null&&N.delete(O.key===null?_:O.key),h=i(O,h,_),S===null?C=O:S.sibling=O,S=O);return e&&N.forEach(function(J){return t(p,J)}),de&&Fn(p,_),C}function b(p,h,x,w){if(typeof x=="object"&&x!==null&&x.type===mr&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case ya:e:{for(var C=x.key,S=h;S!==null;){if(S.key===C){if(C=x.type,C===mr){if(S.tag===7){n(p,S.sibling),h=s(S,x.props.children),h.return=p,p=h;break e}}else if(S.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Xt&&$u(C)===S.type){n(p,S.sibling),h=s(S,x.props),h.ref=hs(p,S,x),h.return=p,p=h;break e}n(p,S);break}else t(p,S);S=S.sibling}x.type===mr?(h=Xn(x.props.children,p.mode,w,x.key),h.return=p,p=h):(w=Wa(x.type,x.key,x.props,null,p.mode,w),w.ref=hs(p,h,x),w.return=p,p=w)}return l(p);case hr:e:{for(S=x.key;h!==null;){if(h.key===S)if(h.tag===4&&h.stateNode.containerInfo===x.containerInfo&&h.stateNode.implementation===x.implementation){n(p,h.sibling),h=s(h,x.children||[]),h.return=p,p=h;break e}else{n(p,h);break}else t(p,h);h=h.sibling}h=gl(x,p.mode,w),h.return=p,p=h}return l(p);case Xt:return S=x._init,b(p,h,S(x._payload),w)}if(ys(x))return k(p,h,x,w);if(os(x))return g(p,h,x,w);Pa(p,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,h!==null&&h.tag===6?(n(p,h.sibling),h=s(h,x),h.return=p,p=h):(n(p,h),h=yl(x,p.mode,w),h.return=p,p=h),l(p)):n(p,h)}return b}var Hr=fh(!0),hh=fh(!1),ci=Ln(null),ui=null,kr=null,pc=null;function xc(){pc=kr=ui=null}function vc(e){var t=ci.current;ue(ci),e._currentValue=t}function ro(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Pr(e,t){ui=e,pc=kr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(He=!0),e.firstContext=null)}function ct(e){var t=e._currentValue;if(pc!==e)if(e={context:e,memoizedValue:t,next:null},kr===null){if(ui===null)throw Error(E(308));kr=e,ui.dependencies={lanes:0,firstContext:e}}else kr=kr.next=e;return t}var An=null;function yc(e){An===null?An=[e]:An.push(e)}function mh(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,yc(t)):(n.next=s.next,s.next=n),t.interleaved=n,Kt(e,r)}function Kt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Zt=!1;function gc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ph(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ut(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function wn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ne&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Kt(e,n)}return s=r.interleaved,s===null?(t.next=t,yc(r)):(t.next=s.next,s.next=t),r.interleaved=t,Kt(e,n)}function Ba(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,sc(e,n)}}function Uu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=l:i=i.next=l,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function di(e,t,n,r){var s=e.updateQueue;Zt=!1;var i=s.firstBaseUpdate,l=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var c=o,d=c.next;c.next=null,l===null?i=d:l.next=d,l=c;var f=e.alternate;f!==null&&(f=f.updateQueue,o=f.lastBaseUpdate,o!==l&&(o===null?f.firstBaseUpdate=d:o.next=d,f.lastBaseUpdate=c))}if(i!==null){var u=s.baseState;l=0,f=d=c=null,o=i;do{var m=o.lane,v=o.eventTime;if((r&m)===m){f!==null&&(f=f.next={eventTime:v,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var k=e,g=o;switch(m=t,v=n,g.tag){case 1:if(k=g.payload,typeof k=="function"){u=k.call(v,u,m);break e}u=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=g.payload,m=typeof k=="function"?k.call(v,u,m):k,m==null)break e;u=me({},u,m);break e;case 2:Zt=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,m=s.effects,m===null?s.effects=[o]:m.push(o))}else v={eventTime:v,lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},f===null?(d=f=v,c=u):f=f.next=v,l|=m;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;m=o,o=m.next,m.next=null,s.lastBaseUpdate=m,s.shared.pending=null}}while(!0);if(f===null&&(c=u),s.baseState=c,s.firstBaseUpdate=d,s.lastBaseUpdate=f,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);rr|=l,e.lanes=l,e.memoizedState=u}}function Bu(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=hl.transition;hl.transition={};try{e(!1),t()}finally{ae=n,hl.transition=r}}function Lh(){return ut().memoizedState}function sv(e,t,n){var r=bn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Rh(e))Mh(t,n);else if(n=mh(e,t,n,r),n!==null){var s=$e();wt(n,e,r,s),zh(n,t,r)}}function av(e,t,n){var r=bn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Rh(e))Mh(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var l=t.lastRenderedState,o=i(l,n);if(s.hasEagerState=!0,s.eagerState=o,kt(o,l)){var c=t.interleaved;c===null?(s.next=s,yc(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=mh(e,t,s,r),n!==null&&(s=$e(),wt(n,e,r,s),zh(n,t,r))}}function Rh(e){var t=e.alternate;return e===he||t!==null&&t===he}function Mh(e,t){_s=hi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function zh(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,sc(e,n)}}var mi={readContext:ct,useCallback:Le,useContext:Le,useEffect:Le,useImperativeHandle:Le,useInsertionEffect:Le,useLayoutEffect:Le,useMemo:Le,useReducer:Le,useRef:Le,useState:Le,useDebugValue:Le,useDeferredValue:Le,useTransition:Le,useMutableSource:Le,useSyncExternalStore:Le,useId:Le,unstable_isNewReconciler:!1},iv={readContext:ct,useCallback:function(e,t){return Nt().memoizedState=[e,t===void 0?null:t],e},useContext:ct,useEffect:Vu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Va(4194308,4,_h.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Va(4194308,4,e,t)},useInsertionEffect:function(e,t){return Va(4,2,e,t)},useMemo:function(e,t){var n=Nt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Nt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=sv.bind(null,he,e),[r.memoizedState,e]},useRef:function(e){var t=Nt();return e={current:e},t.memoizedState=e},useState:Qu,useDebugValue:_c,useDeferredValue:function(e){return Nt().memoizedState=e},useTransition:function(){var e=Qu(!1),t=e[0];return e=rv.bind(null,e[1]),Nt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=he,s=Nt();if(de){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),Ee===null)throw Error(E(349));nr&30||gh(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Vu(wh.bind(null,r,i,e),[e]),r.flags|=2048,qs(9,jh.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Nt(),t=Ee.identifierPrefix;if(de){var n=$t,r=At;n=(r&~(1<<32-jt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Ks++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[Et]=t,e[Bs]=r,Kh(e,t,!1,!1),t.stateNode=e;e:{switch(l=Al(n,r),n){case"dialog":ce("cancel",e),ce("close",e),s=r;break;case"iframe":case"object":case"embed":ce("load",e),s=r;break;case"video":case"audio":for(s=0;sGr&&(t.flags|=128,r=!0,ms(i,!1),t.lanes=4194304)}else{if(!r)if(e=fi(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ms(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!de)return Re(t),null}else 2*je()-i.renderingStartTime>Gr&&n!==1073741824&&(t.flags|=128,r=!0,ms(i,!1),t.lanes=4194304);i.isBackwards?(l.sibling=t.child,t.child=l):(n=i.last,n!==null?n.sibling=l:t.child=l,i.last=l)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=je(),t.sibling=null,n=fe.current,ie(fe,r?n&1|2:n&1),t):(Re(t),null);case 22:case 23:return Rc(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ye&1073741824&&(Re(t),t.subtreeFlags&6&&(t.flags|=8192)):Re(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function mv(e,t){switch(hc(t),t.tag){case 1:return We(t.type)&&ai(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return qr(),ue(qe),ue(Fe),kc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return wc(t),null;case 13:if(ue(fe),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));Kr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ue(fe),null;case 4:return qr(),null;case 10:return vc(t.type._context),null;case 22:case 23:return Rc(),null;case 24:return null;default:return null}}var Oa=!1,ze=!1,pv=typeof WeakSet=="function"?WeakSet:Set,I=null;function br(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ve(e,t,r)}else n.current=null}function ho(e,t,n){try{n()}catch(r){ve(e,t,r)}}var td=!1;function xv(e,t){if(Gl=ti,e=Xf(),dc(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var l=0,o=-1,c=-1,d=0,f=0,u=e,m=null;t:for(;;){for(var v;u!==n||s!==0&&u.nodeType!==3||(o=l+s),u!==i||r!==0&&u.nodeType!==3||(c=l+r),u.nodeType===3&&(l+=u.nodeValue.length),(v=u.firstChild)!==null;)m=u,u=v;for(;;){if(u===e)break t;if(m===n&&++d===s&&(o=l),m===i&&++f===r&&(c=l),(v=u.nextSibling)!==null)break;u=m,m=u.parentNode}u=v}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Jl={focusedElem:e,selectionRange:n},ti=!1,I=t;I!==null;)if(t=I,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,I=e;else for(;I!==null;){t=I;try{var k=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(k!==null){var g=k.memoizedProps,b=k.memoizedState,p=t.stateNode,h=p.getSnapshotBeforeUpdate(t.elementType===t.type?g:mt(t.type,g),b);p.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(w){ve(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,I=e;break}I=t.return}return k=td,td=!1,k}function Es(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&ho(t,n,i)}s=s.next}while(s!==r)}}function Mi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function mo(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Wh(e){var t=e.alternate;t!==null&&(e.alternate=null,Wh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Et],delete t[Bs],delete t[Zl],delete t[Xx],delete t[Zx])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Gh(e){return e.tag===5||e.tag===3||e.tag===4}function nd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Gh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function po(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=si));else if(r!==4&&(e=e.child,e!==null))for(po(e,t,n),e=e.sibling;e!==null;)po(e,t,n),e=e.sibling}function xo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(xo(e,t,n),e=e.sibling;e!==null;)xo(e,t,n),e=e.sibling}var Pe=null,vt=!1;function Jt(e,t,n){for(n=n.child;n!==null;)Jh(e,t,n),n=n.sibling}function Jh(e,t,n){if(Pt&&typeof Pt.onCommitFiberUnmount=="function")try{Pt.onCommitFiberUnmount(Ci,n)}catch{}switch(n.tag){case 5:ze||br(n,t);case 6:var r=Pe,s=vt;Pe=null,Jt(e,t,n),Pe=r,vt=s,Pe!==null&&(vt?(e=Pe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Pe.removeChild(n.stateNode));break;case 18:Pe!==null&&(vt?(e=Pe,n=n.stateNode,e.nodeType===8?ul(e.parentNode,n):e.nodeType===1&&ul(e,n),Is(e)):ul(Pe,n.stateNode));break;case 4:r=Pe,s=vt,Pe=n.stateNode.containerInfo,vt=!0,Jt(e,t,n),Pe=r,vt=s;break;case 0:case 11:case 14:case 15:if(!ze&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,l=i.destroy;i=i.tag,l!==void 0&&(i&2||i&4)&&ho(n,t,l),s=s.next}while(s!==r)}Jt(e,t,n);break;case 1:if(!ze&&(br(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){ve(n,t,o)}Jt(e,t,n);break;case 21:Jt(e,t,n);break;case 22:n.mode&1?(ze=(r=ze)||n.memoizedState!==null,Jt(e,t,n),ze=r):Jt(e,t,n);break;default:Jt(e,t,n)}}function rd(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new pv),t.forEach(function(r){var s=Sv.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function ft(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=l),r&=~i}if(r=s,r=je()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*yv(r/1960))-r,10e?16:e,hn===null)var r=!1;else{if(e=hn,hn=null,vi=0,ne&6)throw Error(E(331));var s=ne;for(ne|=4,I=e.current;I!==null;){var i=I,l=i.child;if(I.flags&16){var o=i.deletions;if(o!==null){for(var c=0;cje()-Oc?Yn(e,0):Tc|=n),Ge(e,t)}function sm(e,t){t===0&&(e.mode&1?(t=ka,ka<<=1,!(ka&130023424)&&(ka=4194304)):t=1);var n=$e();e=Kt(e,t),e!==null&&(oa(e,t,n),Ge(e,n))}function Nv(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),sm(e,n)}function Sv(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),sm(e,n)}var am;am=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||qe.current)He=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return He=!1,fv(e,t,n);He=!!(e.flags&131072)}else He=!1,de&&t.flags&1048576&&ch(t,oi,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ka(e,t),e=t.pendingProps;var s=Vr(t,Fe.current);Pr(t,n),s=Nc(null,t,r,e,s,n);var i=Sc();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,We(r)?(i=!0,ii(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,gc(t),s.updater=Ri,t.stateNode=s,s._reactInternals=t,ao(t,r,e,n),t=oo(null,t,r,!0,i,n)):(t.tag=0,de&&i&&fc(t),De(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ka(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=_v(r),e=mt(r,e),s){case 0:t=lo(null,t,r,e,n);break e;case 1:t=Xu(null,t,r,e,n);break e;case 11:t=Ju(null,t,r,e,n);break e;case 14:t=Yu(null,t,r,mt(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),lo(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Xu(e,t,r,s,n);case 3:e:{if(Bh(t),e===null)throw Error(E(387));r=t.pendingProps,i=t.memoizedState,s=i.element,ph(e,t),di(t,r,null,n);var l=t.memoizedState;if(r=l.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=Wr(Error(E(423)),t),t=Zu(e,t,r,n,s);break e}else if(r!==s){s=Wr(Error(E(424)),t),t=Zu(e,t,r,n,s);break e}else for(Xe=jn(t.stateNode.containerInfo.firstChild),Ze=t,de=!0,yt=null,n=hh(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Kr(),r===s){t=Ht(e,t,n);break e}De(e,t,r,n)}t=t.child}return t;case 5:return xh(t),e===null&&no(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,l=s.children,Yl(r,s)?l=null:i!==null&&Yl(r,i)&&(t.flags|=32),Uh(e,t),De(e,t,l,n),t.child;case 6:return e===null&&no(t),null;case 13:return Qh(e,t,n);case 4:return jc(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Hr(t,null,r,n):De(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Ju(e,t,r,s,n);case 7:return De(e,t,t.pendingProps,n),t.child;case 8:return De(e,t,t.pendingProps.children,n),t.child;case 12:return De(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,l=s.value,ie(ci,r._currentValue),r._currentValue=l,i!==null)if(kt(i.value,l)){if(i.children===s.children&&!qe.current){t=Ht(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var o=i.dependencies;if(o!==null){l=i.child;for(var c=o.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=Ut(-1,n&-n),c.tag=2;var d=i.updateQueue;if(d!==null){d=d.shared;var f=d.pending;f===null?c.next=c:(c.next=f.next,f.next=c),d.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),ro(i.return,n,t),o.lanes|=n;break}c=c.next}}else if(i.tag===10)l=i.type===t.type?null:i.child;else if(i.tag===18){if(l=i.return,l===null)throw Error(E(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),ro(l,n,t),l=i.sibling}else l=i.child;if(l!==null)l.return=i;else for(l=i;l!==null;){if(l===t){l=null;break}if(i=l.sibling,i!==null){i.return=l.return,l=i;break}l=l.return}i=l}De(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Pr(t,n),s=ct(s),r=r(s),t.flags|=1,De(e,t,r,n),t.child;case 14:return r=t.type,s=mt(r,t.pendingProps),s=mt(r.type,s),Yu(e,t,r,s,n);case 15:return Ah(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Ka(e,t),t.tag=1,We(r)?(e=!0,ii(t)):e=!1,Pr(t,n),Fh(t,r,s),ao(t,r,s,n),oo(null,t,r,!0,e,n);case 19:return Vh(e,t,n);case 22:return $h(e,t,n)}throw Error(E(156,t.tag))};function im(e,t){return Rf(e,t)}function Cv(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function lt(e,t,n,r){return new Cv(e,t,n,r)}function zc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function _v(e){if(typeof e=="function")return zc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ec)return 11;if(e===tc)return 14}return 2}function Nn(e,t){var n=e.alternate;return n===null?(n=lt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Wa(e,t,n,r,s,i){var l=2;if(r=e,typeof e=="function")zc(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case mr:return Xn(n.children,s,i,t);case Zo:l=8,s|=8;break;case Pl:return e=lt(12,n,t,s|2),e.elementType=Pl,e.lanes=i,e;case Tl:return e=lt(13,n,t,s),e.elementType=Tl,e.lanes=i,e;case Ol:return e=lt(19,n,t,s),e.elementType=Ol,e.lanes=i,e;case xf:return Fi(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case mf:l=10;break e;case pf:l=9;break e;case ec:l=11;break e;case tc:l=14;break e;case Xt:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=lt(l,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function Xn(e,t,n,r){return e=lt(7,e,r,t),e.lanes=n,e}function Fi(e,t,n,r){return e=lt(22,e,r,t),e.elementType=xf,e.lanes=n,e.stateNode={isHidden:!1},e}function yl(e,t,n){return e=lt(6,e,null,t),e.lanes=n,e}function gl(e,t,n){return t=lt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Ev(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Zi(0),this.expirationTimes=Zi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Zi(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Fc(e,t,n,r,s,i,l,o,c){return e=new Ev(e,t,n,o,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=lt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},gc(i),e}function Pv(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(um)}catch(e){console.error(e)}}um(),uf.exports=tt;var Mv=uf.exports,dd=Mv;_l.createRoot=dd.createRoot,_l.hydrateRoot=dd.hydrateRoot;var ts=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},zv={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},nn,Vo,$d,Fv=($d=class{constructor(){$(this,nn,zv);$(this,Vo,!1)}setTimeoutProvider(e){z(this,nn,e)}setTimeout(e,t){return y(this,nn).setTimeout(e,t)}clearTimeout(e){y(this,nn).clearTimeout(e)}setInterval(e,t){return y(this,nn).setInterval(e,t)}clearInterval(e){y(this,nn).clearInterval(e)}},nn=new WeakMap,Vo=new WeakMap,$d),Un=new Fv;function Iv(e){setTimeout(e,0)}var ar=typeof window>"u"||"Deno"in globalThis;function Ae(){}function Dv(e,t){return typeof e=="function"?e(t):e}function wo(e){return typeof e=="number"&&e>=0&&e!==1/0}function dm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Sn(e,t){return typeof e=="function"?e(t):e}function st(e,t){return typeof e=="function"?e(t):e}function fd(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:i,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==$c(l,t.options))return!1}else if(!Gs(t.queryKey,l))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||s&&s!==t.state.fetchStatus||i&&!i(t))}function hd(e,t){const{exact:n,status:r,predicate:s,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(ir(t.options.mutationKey)!==ir(i))return!1}else if(!Gs(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function $c(e,t){return((t==null?void 0:t.queryKeyHashFn)||ir)(e)}function ir(e){return JSON.stringify(e,(t,n)=>ko(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function Gs(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Gs(e[n],t[n])):!1}var Av=Object.prototype.hasOwnProperty;function fm(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=md(e)&&md(t);if(!r&&!(ko(e)&&ko(t)))return t;const i=(r?e:Object.keys(e)).length,l=r?t:Object.keys(t),o=l.length,c=r?new Array(o):{};let d=0;for(let f=0;f{Un.setTimeout(t,e)})}function bo(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?fm(e,t):t}function Uv(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Bv(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Uc=Symbol();function hm(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Uc?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Bc(e,t){return typeof e=="function"?e(...t):!!e}function Qv(e,t,n){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),e}var Bn,rn,Or,Ud,Vv=(Ud=class extends ts{constructor(){super();$(this,Bn);$(this,rn);$(this,Or);z(this,Or,t=>{if(!ar&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){y(this,rn)||this.setEventListener(y(this,Or))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,rn))==null||t.call(this),z(this,rn,void 0))}setEventListener(t){var n;z(this,Or,t),(n=y(this,rn))==null||n.call(this),z(this,rn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){y(this,Bn)!==t&&(z(this,Bn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof y(this,Bn)=="boolean"?y(this,Bn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Bn=new WeakMap,rn=new WeakMap,Or=new WeakMap,Ud),Qc=new Vv;function No(){let e,t;const n=new Promise((s,i)=>{e=s,t=i});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var Kv=Iv;function Hv(){let e=[],t=0,n=o=>{o()},r=o=>{o()},s=Kv;const i=o=>{t?e.push(o):s(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&s(()=>{r(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;t++;try{c=o()}finally{t--,t||l()}return c},batchCalls:o=>(...c)=>{i(()=>{o(...c)})},schedule:i,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{s=o}}}var be=Hv(),Lr,sn,Rr,Bd,qv=(Bd=class extends ts{constructor(){super();$(this,Lr,!0);$(this,sn);$(this,Rr);z(this,Rr,t=>{if(!ar&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){y(this,sn)||this.setEventListener(y(this,Rr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,sn))==null||t.call(this),z(this,sn,void 0))}setEventListener(t){var n;z(this,Rr,t),(n=y(this,sn))==null||n.call(this),z(this,sn,t(this.setOnline.bind(this)))}setOnline(t){y(this,Lr)!==t&&(z(this,Lr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return y(this,Lr)}},Lr=new WeakMap,sn=new WeakMap,Rr=new WeakMap,Bd),wi=new qv;function Wv(e){return Math.min(1e3*2**e,3e4)}function mm(e){return(e??"online")==="online"?wi.isOnline():!0}var So=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function pm(e){let t=!1,n=0,r;const s=No(),i=()=>s.status!=="pending",l=g=>{var b;if(!i()){const p=new So(g);m(p),(b=e.onCancel)==null||b.call(e,p)}},o=()=>{t=!0},c=()=>{t=!1},d=()=>Qc.isFocused()&&(e.networkMode==="always"||wi.isOnline())&&e.canRun(),f=()=>mm(e.networkMode)&&e.canRun(),u=g=>{i()||(r==null||r(),s.resolve(g))},m=g=>{i()||(r==null||r(),s.reject(g))},v=()=>new Promise(g=>{var b;r=p=>{(i()||d())&&g(p)},(b=e.onPause)==null||b.call(e)}).then(()=>{var g;r=void 0,i()||(g=e.onContinue)==null||g.call(e)}),k=()=>{if(i())return;let g;const b=n===0?e.initialPromise:void 0;try{g=b??e.fn()}catch(p){g=Promise.reject(p)}Promise.resolve(g).then(u).catch(p=>{var S;if(i())return;const h=e.retry??(ar?0:3),x=e.retryDelay??Wv,w=typeof x=="function"?x(n,p):x,C=h===!0||typeof h=="number"&&nd()?void 0:v()).then(()=>{t?m(p):k()})})};return{promise:s,status:()=>s.status,cancel:l,continue:()=>(r==null||r(),s),cancelRetry:o,continueRetry:c,canStart:f,start:()=>(f()?k():v().then(k),s)}}var Qn,Qd,xm=(Qd=class{constructor(){$(this,Qn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),wo(this.gcTime)&&z(this,Qn,Un.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(ar?1/0:5*60*1e3))}clearGcTimeout(){y(this,Qn)&&(Un.clearTimeout(y(this,Qn)),z(this,Qn,void 0))}},Qn=new WeakMap,Qd),Vn,Mr,rt,Kn,Ce,na,Hn,pt,Lt,Vd,Gv=(Vd=class extends xm{constructor(t){super();$(this,pt);$(this,Vn);$(this,Mr);$(this,rt);$(this,Kn);$(this,Ce);$(this,na);$(this,Hn);z(this,Hn,!1),z(this,na,t.defaultOptions),this.setOptions(t.options),this.observers=[],z(this,Kn,t.client),z(this,rt,y(this,Kn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,z(this,Vn,vd(this.options)),this.state=t.state??y(this,Vn),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=y(this,Ce))==null?void 0:t.promise}setOptions(t){if(this.options={...y(this,na),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=vd(this.options);n.data!==void 0&&(this.setState(xd(n.data,n.dataUpdatedAt)),z(this,Vn,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&y(this,rt).remove(this)}setData(t,n){const r=bo(this.state.data,t,this.options);return q(this,pt,Lt).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){q(this,pt,Lt).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=y(this,Ce))==null?void 0:r.promise;return(s=y(this,Ce))==null||s.cancel(t),n?n.then(Ae).catch(Ae):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(y(this,Vn))}isActive(){return this.observers.some(t=>st(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Uc||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Sn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!dm(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),y(this,rt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(y(this,Ce)&&(y(this,Hn)?y(this,Ce).cancel({revert:!0}):y(this,Ce).cancelRetry()),this.scheduleGc()),y(this,rt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||q(this,pt,Lt).call(this,{type:"invalidate"})}async fetch(t,n){var c,d,f,u,m,v,k,g,b,p,h,x;if(this.state.fetchStatus!=="idle"&&((c=y(this,Ce))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(y(this,Ce))return y(this,Ce).continueRetry(),y(this,Ce).promise}if(t&&this.setOptions(t),!this.options.queryFn){const w=this.observers.find(C=>C.options.queryFn);w&&this.setOptions(w.options)}const r=new AbortController,s=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(z(this,Hn,!0),r.signal)})},i=()=>{const w=hm(this.options,n),S=(()=>{const N={client:y(this,Kn),queryKey:this.queryKey,meta:this.meta};return s(N),N})();return z(this,Hn,!1),this.options.persister?this.options.persister(w,S,this):w(S)},o=(()=>{const w={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:y(this,Kn),state:this.state,fetchFn:i};return s(w),w})();(d=this.options.behavior)==null||d.onFetch(o,this),z(this,Mr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((f=o.fetchOptions)==null?void 0:f.meta))&&q(this,pt,Lt).call(this,{type:"fetch",meta:(u=o.fetchOptions)==null?void 0:u.meta}),z(this,Ce,pm({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:w=>{w instanceof So&&w.revert&&this.setState({...y(this,Mr),fetchStatus:"idle"}),r.abort()},onFail:(w,C)=>{q(this,pt,Lt).call(this,{type:"failed",failureCount:w,error:C})},onPause:()=>{q(this,pt,Lt).call(this,{type:"pause"})},onContinue:()=>{q(this,pt,Lt).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const w=await y(this,Ce).start();if(w===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(w),(v=(m=y(this,rt).config).onSuccess)==null||v.call(m,w,this),(g=(k=y(this,rt).config).onSettled)==null||g.call(k,w,this.state.error,this),w}catch(w){if(w instanceof So){if(w.silent)return y(this,Ce).promise;if(w.revert){if(this.state.data===void 0)throw w;return this.state.data}}throw q(this,pt,Lt).call(this,{type:"error",error:w}),(p=(b=y(this,rt).config).onError)==null||p.call(b,w,this),(x=(h=y(this,rt).config).onSettled)==null||x.call(h,this.state.data,w,this),w}finally{this.scheduleGc()}}},Vn=new WeakMap,Mr=new WeakMap,rt=new WeakMap,Kn=new WeakMap,Ce=new WeakMap,na=new WeakMap,Hn=new WeakMap,pt=new WeakSet,Lt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...vm(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...xd(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return z(this,Mr,t.manual?s:void 0),s;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),be.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),y(this,rt).notify({query:this,type:"updated",action:t})})},Vd);function vm(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:mm(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function xd(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function vd(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Qe,Z,ra,Ie,qn,zr,zt,an,sa,Fr,Ir,Wn,Gn,ln,Dr,se,ws,Co,_o,Eo,Po,To,Oo,Lo,ym,Kd,Jv=(Kd=class extends ts{constructor(t,n){super();$(this,se);$(this,Qe);$(this,Z);$(this,ra);$(this,Ie);$(this,qn);$(this,zr);$(this,zt);$(this,an);$(this,sa);$(this,Fr);$(this,Ir);$(this,Wn);$(this,Gn);$(this,ln);$(this,Dr,new Set);this.options=n,z(this,Qe,t),z(this,an,null),z(this,zt,No()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(y(this,Z).addObserver(this),yd(y(this,Z),this.options)?q(this,se,ws).call(this):this.updateResult(),q(this,se,Po).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Ro(y(this,Z),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Ro(y(this,Z),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,q(this,se,To).call(this),q(this,se,Oo).call(this),y(this,Z).removeObserver(this)}setOptions(t){const n=this.options,r=y(this,Z);if(this.options=y(this,Qe).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof st(this.options.enabled,y(this,Z))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");q(this,se,Lo).call(this),y(this,Z).setOptions(this.options),n._defaulted&&!ji(this.options,n)&&y(this,Qe).getQueryCache().notify({type:"observerOptionsUpdated",query:y(this,Z),observer:this});const s=this.hasListeners();s&&gd(y(this,Z),r,this.options,n)&&q(this,se,ws).call(this),this.updateResult(),s&&(y(this,Z)!==r||st(this.options.enabled,y(this,Z))!==st(n.enabled,y(this,Z))||Sn(this.options.staleTime,y(this,Z))!==Sn(n.staleTime,y(this,Z)))&&q(this,se,Co).call(this);const i=q(this,se,_o).call(this);s&&(y(this,Z)!==r||st(this.options.enabled,y(this,Z))!==st(n.enabled,y(this,Z))||i!==y(this,ln))&&q(this,se,Eo).call(this,i)}getOptimisticResult(t){const n=y(this,Qe).getQueryCache().build(y(this,Qe),t),r=this.createResult(n,t);return Xv(this,r)&&(z(this,Ie,r),z(this,zr,this.options),z(this,qn,y(this,Z).state)),r}getCurrentResult(){return y(this,Ie)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&y(this,zt).status==="pending"&&y(this,zt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){y(this,Dr).add(t)}getCurrentQuery(){return y(this,Z)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=y(this,Qe).defaultQueryOptions(t),r=y(this,Qe).getQueryCache().build(y(this,Qe),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return q(this,se,ws).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),y(this,Ie)))}createResult(t,n){var F;const r=y(this,Z),s=this.options,i=y(this,Ie),l=y(this,qn),o=y(this,zr),d=t!==r?t.state:y(this,ra),{state:f}=t;let u={...f},m=!1,v;if(n._optimisticResults){const O=this.hasListeners(),Q=!O&&yd(t,n),J=O&&gd(t,r,n,s);(Q||J)&&(u={...u,...vm(f.data,t.options)}),n._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:k,errorUpdatedAt:g,status:b}=u;v=u.data;let p=!1;if(n.placeholderData!==void 0&&v===void 0&&b==="pending"){let O;i!=null&&i.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(O=i.data,p=!0):O=typeof n.placeholderData=="function"?n.placeholderData((F=y(this,Ir))==null?void 0:F.state.data,y(this,Ir)):n.placeholderData,O!==void 0&&(b="success",v=bo(i==null?void 0:i.data,O,n),m=!0)}if(n.select&&v!==void 0&&!p)if(i&&v===(l==null?void 0:l.data)&&n.select===y(this,sa))v=y(this,Fr);else try{z(this,sa,n.select),v=n.select(v),v=bo(i==null?void 0:i.data,v,n),z(this,Fr,v),z(this,an,null)}catch(O){z(this,an,O)}y(this,an)&&(k=y(this,an),v=y(this,Fr),g=Date.now(),b="error");const h=u.fetchStatus==="fetching",x=b==="pending",w=b==="error",C=x&&h,S=v!==void 0,_={status:b,fetchStatus:u.fetchStatus,isPending:x,isSuccess:b==="success",isError:w,isInitialLoading:C,isLoading:C,data:v,dataUpdatedAt:u.dataUpdatedAt,error:k,errorUpdatedAt:g,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>d.dataUpdateCount||u.errorUpdateCount>d.errorUpdateCount,isFetching:h,isRefetching:h&&!x,isLoadingError:w&&!S,isPaused:u.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:w&&S,isStale:Vc(t,n),refetch:this.refetch,promise:y(this,zt),isEnabled:st(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=_.data!==void 0,Q=_.status==="error"&&!O,J=D=>{Q?D.reject(_.error):O&&D.resolve(_.data)},re=()=>{const D=z(this,zt,_.promise=No());J(D)},oe=y(this,zt);switch(oe.status){case"pending":t.queryHash===r.queryHash&&J(oe);break;case"fulfilled":(Q||_.data!==oe.value)&&re();break;case"rejected":(!Q||_.error!==oe.reason)&&re();break}}return _}updateResult(){const t=y(this,Ie),n=this.createResult(y(this,Z),this.options);if(z(this,qn,y(this,Z).state),z(this,zr,this.options),y(this,qn).data!==void 0&&z(this,Ir,y(this,Z)),ji(n,t))return;z(this,Ie,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!y(this,Dr).size)return!0;const l=new Set(i??y(this,Dr));return this.options.throwOnError&&l.add("error"),Object.keys(y(this,Ie)).some(o=>{const c=o;return y(this,Ie)[c]!==t[c]&&l.has(c)})};q(this,se,ym).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&q(this,se,Po).call(this)}},Qe=new WeakMap,Z=new WeakMap,ra=new WeakMap,Ie=new WeakMap,qn=new WeakMap,zr=new WeakMap,zt=new WeakMap,an=new WeakMap,sa=new WeakMap,Fr=new WeakMap,Ir=new WeakMap,Wn=new WeakMap,Gn=new WeakMap,ln=new WeakMap,Dr=new WeakMap,se=new WeakSet,ws=function(t){q(this,se,Lo).call(this);let n=y(this,Z).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Ae)),n},Co=function(){q(this,se,To).call(this);const t=Sn(this.options.staleTime,y(this,Z));if(ar||y(this,Ie).isStale||!wo(t))return;const r=dm(y(this,Ie).dataUpdatedAt,t)+1;z(this,Wn,Un.setTimeout(()=>{y(this,Ie).isStale||this.updateResult()},r))},_o=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(y(this,Z)):this.options.refetchInterval)??!1},Eo=function(t){q(this,se,Oo).call(this),z(this,ln,t),!(ar||st(this.options.enabled,y(this,Z))===!1||!wo(y(this,ln))||y(this,ln)===0)&&z(this,Gn,Un.setInterval(()=>{(this.options.refetchIntervalInBackground||Qc.isFocused())&&q(this,se,ws).call(this)},y(this,ln)))},Po=function(){q(this,se,Co).call(this),q(this,se,Eo).call(this,q(this,se,_o).call(this))},To=function(){y(this,Wn)&&(Un.clearTimeout(y(this,Wn)),z(this,Wn,void 0))},Oo=function(){y(this,Gn)&&(Un.clearInterval(y(this,Gn)),z(this,Gn,void 0))},Lo=function(){const t=y(this,Qe).getQueryCache().build(y(this,Qe),this.options);if(t===y(this,Z))return;const n=y(this,Z);z(this,Z,t),z(this,ra,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},ym=function(t){be.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(y(this,Ie))}),y(this,Qe).getQueryCache().notify({query:y(this,Z),type:"observerResultsUpdated"})})},Kd);function Yv(e,t){return st(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function yd(e,t){return Yv(e,t)||e.state.data!==void 0&&Ro(e,t,t.refetchOnMount)}function Ro(e,t,n){if(st(t.enabled,e)!==!1&&Sn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Vc(e,t)}return!1}function gd(e,t,n,r){return(e!==t||st(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Vc(e,n)}function Vc(e,t){return st(t.enabled,e)!==!1&&e.isStaleByTime(Sn(t.staleTime,e))}function Xv(e,t){return!ji(e.getCurrentResult(),t)}function jd(e){return{onFetch:(t,n)=>{var f,u,m,v,k;const r=t.options,s=(m=(u=(f=t.fetchOptions)==null?void 0:f.meta)==null?void 0:u.fetchMore)==null?void 0:m.direction,i=((v=t.state.data)==null?void 0:v.pages)||[],l=((k=t.state.data)==null?void 0:k.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const d=async()=>{let g=!1;const b=x=>{Qv(x,()=>t.signal,()=>g=!0)},p=hm(t.options,t.fetchOptions),h=async(x,w,C)=>{if(g)return Promise.reject();if(w==null&&x.pages.length)return Promise.resolve(x);const N=(()=>{const Q={client:t.client,queryKey:t.queryKey,pageParam:w,direction:C?"backward":"forward",meta:t.options.meta};return b(Q),Q})(),_=await p(N),{maxPages:F}=t.options,O=C?Bv:Uv;return{pages:O(x.pages,_,F),pageParams:O(x.pageParams,w,F)}};if(s&&i.length){const x=s==="backward",w=x?Zv:wd,C={pages:i,pageParams:l},S=w(r,C);o=await h(C,S,x)}else{const x=e??i.length;do{const w=c===0?l[0]??r.initialPageParam:wd(r,o);if(c>0&&w==null)break;o=await h(o,w),c++}while(c{var g,b;return(b=(g=t.options).persister)==null?void 0:b.call(g,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=d}}}function wd(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Zv(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var aa,St,Me,Jn,Ct,Yt,Hd,ey=(Hd=class extends xm{constructor(t){super();$(this,Ct);$(this,aa);$(this,St);$(this,Me);$(this,Jn);z(this,aa,t.client),this.mutationId=t.mutationId,z(this,Me,t.mutationCache),z(this,St,[]),this.state=t.state||gm(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){y(this,St).includes(t)||(y(this,St).push(t),this.clearGcTimeout(),y(this,Me).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){z(this,St,y(this,St).filter(n=>n!==t)),this.scheduleGc(),y(this,Me).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){y(this,St).length||(this.state.status==="pending"?this.scheduleGc():y(this,Me).remove(this))}continue(){var t;return((t=y(this,Jn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,d,f,u,m,v,k,g,b,p,h,x,w,C,S,N;const n=()=>{q(this,Ct,Yt).call(this,{type:"continue"})},r={client:y(this,aa),meta:this.options.meta,mutationKey:this.options.mutationKey};z(this,Jn,pm({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(_,F)=>{q(this,Ct,Yt).call(this,{type:"failed",failureCount:_,error:F})},onPause:()=>{q(this,Ct,Yt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>y(this,Me).canRun(this)}));const s=this.state.status==="pending",i=!y(this,Jn).canStart();try{if(s)n();else{q(this,Ct,Yt).call(this,{type:"pending",variables:t,isPaused:i}),y(this,Me).config.onMutate&&await y(this,Me).config.onMutate(t,this,r);const F=await((o=(l=this.options).onMutate)==null?void 0:o.call(l,t,r));F!==this.state.context&&q(this,Ct,Yt).call(this,{type:"pending",context:F,variables:t,isPaused:i})}const _=await y(this,Jn).start();return await((d=(c=y(this,Me).config).onSuccess)==null?void 0:d.call(c,_,t,this.state.context,this,r)),await((u=(f=this.options).onSuccess)==null?void 0:u.call(f,_,t,this.state.context,r)),await((v=(m=y(this,Me).config).onSettled)==null?void 0:v.call(m,_,null,this.state.variables,this.state.context,this,r)),await((g=(k=this.options).onSettled)==null?void 0:g.call(k,_,null,t,this.state.context,r)),q(this,Ct,Yt).call(this,{type:"success",data:_}),_}catch(_){try{await((p=(b=y(this,Me).config).onError)==null?void 0:p.call(b,_,t,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((x=(h=this.options).onError)==null?void 0:x.call(h,_,t,this.state.context,r))}catch(F){Promise.reject(F)}try{await((C=(w=y(this,Me).config).onSettled)==null?void 0:C.call(w,void 0,_,this.state.variables,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((N=(S=this.options).onSettled)==null?void 0:N.call(S,void 0,_,t,this.state.context,r))}catch(F){Promise.reject(F)}throw q(this,Ct,Yt).call(this,{type:"error",error:_}),_}finally{y(this,Me).runNext(this)}}},aa=new WeakMap,St=new WeakMap,Me=new WeakMap,Jn=new WeakMap,Ct=new WeakSet,Yt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),be.batch(()=>{y(this,St).forEach(r=>{r.onMutationUpdate(t)}),y(this,Me).notify({mutation:this,type:"updated",action:t})})},Hd);function gm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ft,xt,ia,qd,ty=(qd=class extends ts{constructor(t={}){super();$(this,Ft);$(this,xt);$(this,ia);this.config=t,z(this,Ft,new Set),z(this,xt,new Map),z(this,ia,0)}build(t,n,r){const s=new ey({client:t,mutationCache:this,mutationId:++xa(this,ia)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){y(this,Ft).add(t);const n=Ma(t);if(typeof n=="string"){const r=y(this,xt).get(n);r?r.push(t):y(this,xt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(y(this,Ft).delete(t)){const n=Ma(t);if(typeof n=="string"){const r=y(this,xt).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&y(this,xt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Ma(t);if(typeof n=="string"){const r=y(this,xt).get(n),s=r==null?void 0:r.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=Ma(t);if(typeof n=="string"){const s=(r=y(this,xt).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){be.batch(()=>{y(this,Ft).forEach(t=>{this.notify({type:"removed",mutation:t})}),y(this,Ft).clear(),y(this,xt).clear()})}getAll(){return Array.from(y(this,Ft))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>hd(n,r))}findAll(t={}){return this.getAll().filter(n=>hd(t,n))}notify(t){be.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return be.batch(()=>Promise.all(t.map(n=>n.continue().catch(Ae))))}},Ft=new WeakMap,xt=new WeakMap,ia=new WeakMap,qd);function Ma(e){var t;return(t=e.options.scope)==null?void 0:t.id}var It,on,Ve,Dt,Bt,Ga,Mo,Wd,ny=(Wd=class extends ts{constructor(n,r){super();$(this,Bt);$(this,It);$(this,on);$(this,Ve);$(this,Dt);z(this,It,n),this.setOptions(r),this.bindMethods(),q(this,Bt,Ga).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=y(this,It).defaultMutationOptions(n),ji(this.options,r)||y(this,It).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,Ve),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&ir(r.mutationKey)!==ir(this.options.mutationKey)?this.reset():((s=y(this,Ve))==null?void 0:s.state.status)==="pending"&&y(this,Ve).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=y(this,Ve))==null||n.removeObserver(this)}onMutationUpdate(n){q(this,Bt,Ga).call(this),q(this,Bt,Mo).call(this,n)}getCurrentResult(){return y(this,on)}reset(){var n;(n=y(this,Ve))==null||n.removeObserver(this),z(this,Ve,void 0),q(this,Bt,Ga).call(this),q(this,Bt,Mo).call(this)}mutate(n,r){var s;return z(this,Dt,r),(s=y(this,Ve))==null||s.removeObserver(this),z(this,Ve,y(this,It).getMutationCache().build(y(this,It),this.options)),y(this,Ve).addObserver(this),y(this,Ve).execute(n)}},It=new WeakMap,on=new WeakMap,Ve=new WeakMap,Dt=new WeakMap,Bt=new WeakSet,Ga=function(){var r;const n=((r=y(this,Ve))==null?void 0:r.state)??gm();z(this,on,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Mo=function(n){be.batch(()=>{var r,s,i,l,o,c,d,f;if(y(this,Dt)&&this.hasListeners()){const u=y(this,on).variables,m=y(this,on).context,v={client:y(this,It),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(s=(r=y(this,Dt)).onSuccess)==null||s.call(r,n.data,u,m,v)}catch(k){Promise.reject(k)}try{(l=(i=y(this,Dt)).onSettled)==null||l.call(i,n.data,null,u,m,v)}catch(k){Promise.reject(k)}}else if((n==null?void 0:n.type)==="error"){try{(c=(o=y(this,Dt)).onError)==null||c.call(o,n.error,u,m,v)}catch(k){Promise.reject(k)}try{(f=(d=y(this,Dt)).onSettled)==null||f.call(d,void 0,n.error,u,m,v)}catch(k){Promise.reject(k)}}}this.listeners.forEach(u=>{u(y(this,on))})})},Wd),_t,Gd,ry=(Gd=class extends ts{constructor(t={}){super();$(this,_t);this.config=t,z(this,_t,new Map)}build(t,n,r){const s=n.queryKey,i=n.queryHash??$c(s,n);let l=this.get(i);return l||(l=new Gv({client:t,queryKey:s,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(l)),l}add(t){y(this,_t).has(t.queryHash)||(y(this,_t).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=y(this,_t).get(t.queryHash);n&&(t.destroy(),n===t&&y(this,_t).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){be.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return y(this,_t).get(t)}getAll(){return[...y(this,_t).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>fd(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>fd(t,r)):n}notify(t){be.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){be.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){be.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},_t=new WeakMap,Gd),xe,cn,un,Ar,$r,dn,Ur,Br,Jd,sy=(Jd=class{constructor(e={}){$(this,xe);$(this,cn);$(this,un);$(this,Ar);$(this,$r);$(this,dn);$(this,Ur);$(this,Br);z(this,xe,e.queryCache||new ry),z(this,cn,e.mutationCache||new ty),z(this,un,e.defaultOptions||{}),z(this,Ar,new Map),z(this,$r,new Map),z(this,dn,0)}mount(){xa(this,dn)._++,y(this,dn)===1&&(z(this,Ur,Qc.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,xe).onFocus())})),z(this,Br,wi.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,xe).onOnline())})))}unmount(){var e,t;xa(this,dn)._--,y(this,dn)===0&&((e=y(this,Ur))==null||e.call(this),z(this,Ur,void 0),(t=y(this,Br))==null||t.call(this),z(this,Br,void 0))}isFetching(e){return y(this,xe).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return y(this,cn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,xe).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=y(this,xe).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Sn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return y(this,xe).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=y(this,xe).get(r.queryHash),i=s==null?void 0:s.state.data,l=Dv(t,i);if(l!==void 0)return y(this,xe).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return be.batch(()=>y(this,xe).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,xe).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=y(this,xe);be.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=y(this,xe);return be.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=be.batch(()=>y(this,xe).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Ae).catch(Ae)}invalidateQueries(e,t={}){return be.batch(()=>(y(this,xe).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=be.batch(()=>y(this,xe).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let i=s.fetch(void 0,n);return n.throwOnError||(i=i.catch(Ae)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Ae)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=y(this,xe).build(this,t);return n.isStaleByTime(Sn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ae).catch(Ae)}fetchInfiniteQuery(e){return e.behavior=jd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ae).catch(Ae)}ensureInfiniteQueryData(e){return e.behavior=jd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return wi.isOnline()?y(this,cn).resumePausedMutations():Promise.resolve()}getQueryCache(){return y(this,xe)}getMutationCache(){return y(this,cn)}getDefaultOptions(){return y(this,un)}setDefaultOptions(e){z(this,un,e)}setQueryDefaults(e,t){y(this,Ar).set(ir(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...y(this,Ar).values()],n={};return t.forEach(r=>{Gs(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){y(this,$r).set(ir(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...y(this,$r).values()],n={};return t.forEach(r=>{Gs(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...y(this,un).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=$c(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Uc&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...y(this,un).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){y(this,xe).clear(),y(this,cn).clear()}},xe=new WeakMap,cn=new WeakMap,un=new WeakMap,Ar=new WeakMap,$r=new WeakMap,dn=new WeakMap,Ur=new WeakMap,Br=new WeakMap,Jd),jm=j.createContext(void 0),Wt=e=>{const t=j.useContext(jm);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ay=({client:e,children:t})=>(j.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),a.jsx(jm.Provider,{value:e,children:t})),wm=j.createContext(!1),iy=()=>j.useContext(wm);wm.Provider;function ly(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var oy=j.createContext(ly()),cy=()=>j.useContext(oy),uy=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Bc(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},dy=e=>{j.useEffect(()=>{e.clearReset()},[e])},fy=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||Bc(n,[e.error,r])),hy=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},my=(e,t)=>e.isLoading&&e.isFetching&&!t,py=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,kd=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function xy(e,t,n){var m,v,k,g;const r=iy(),s=cy(),i=Wt(),l=i.defaultQueryOptions(e);(v=(m=i.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||v.call(m,l);const o=i.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",hy(l),uy(l,s,o),dy(s);const c=!i.getQueryCache().get(l.queryHash),[d]=j.useState(()=>new t(i,l)),f=d.getOptimisticResult(l),u=!r&&e.subscribed!==!1;if(j.useSyncExternalStore(j.useCallback(b=>{const p=u?d.subscribe(be.batchCalls(b)):Ae;return d.updateResult(),p},[d,u]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),j.useEffect(()=>{d.setOptions(l)},[l,d]),py(l,f))throw kd(l,d,s);if(fy({result:f,errorResetBoundary:s,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw f.error;if((g=(k=i.getDefaultOptions().queries)==null?void 0:k._experimental_afterQuery)==null||g.call(k,l,f),l.experimental_prefetchInRender&&!ar&&my(f,r)){const b=c?kd(l,d,s):o==null?void 0:o.promise;b==null||b.catch(Ae).finally(()=>{d.updateResult()})}return l.notifyOnChangeProps?f:d.trackResult(f)}function le(e,t){return xy(e,Jv)}function Je(e,t){const n=Wt(),[r]=j.useState(()=>new ny(n,e));j.useEffect(()=>{r.setOptions(e)},[r,e]);const s=j.useSyncExternalStore(j.useCallback(l=>r.subscribe(be.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=j.useCallback((l,o)=>{r.mutate(l,o).catch(Ae)},[r]);if(s.error&&Bc(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}/** + * @remix-run/router v1.23.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Js(){return Js=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function Kc(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function yy(){return Math.random().toString(36).substr(2,8)}function Nd(e,t){return{usr:e.state,key:e.key,idx:t}}function zo(e,t,n,r){return n===void 0&&(n=null),Js({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?ns(t):t,{state:n,key:t&&t.key||r||yy()})}function ki(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function ns(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function gy(e,t,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:i=!1}=r,l=s.history,o=mn.Pop,c=null,d=f();d==null&&(d=0,l.replaceState(Js({},l.state,{idx:d}),""));function f(){return(l.state||{idx:null}).idx}function u(){o=mn.Pop;let b=f(),p=b==null?null:b-d;d=b,c&&c({action:o,location:g.location,delta:p})}function m(b,p){o=mn.Push;let h=zo(g.location,b,p);d=f()+1;let x=Nd(h,d),w=g.createHref(h);try{l.pushState(x,"",w)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;s.location.assign(w)}i&&c&&c({action:o,location:g.location,delta:1})}function v(b,p){o=mn.Replace;let h=zo(g.location,b,p);d=f();let x=Nd(h,d),w=g.createHref(h);l.replaceState(x,"",w),i&&c&&c({action:o,location:g.location,delta:0})}function k(b){let p=s.location.origin!=="null"?s.location.origin:s.location.href,h=typeof b=="string"?b:ki(b);return h=h.replace(/ $/,"%20"),ye(p,"No window.location.(origin|href) available to create URL for href: "+h),new URL(h,p)}let g={get action(){return o},get location(){return e(s,l)},listen(b){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(bd,u),c=b,()=>{s.removeEventListener(bd,u),c=null}},createHref(b){return t(s,b)},createURL:k,encodeLocation(b){let p=k(b);return{pathname:p.pathname,search:p.search,hash:p.hash}},push:m,replace:v,go(b){return l.go(b)}};return g}var Sd;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Sd||(Sd={}));function jy(e,t,n){return n===void 0&&(n="/"),wy(e,t,n)}function wy(e,t,n,r){let s=typeof t=="string"?ns(t):t,i=Jr(s.pathname||"/",n);if(i==null)return null;let l=km(e);ky(l);let o=null;for(let c=0;o==null&&c{let c={relativePath:o===void 0?i.path||"":o,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};c.relativePath.startsWith("/")&&(ye(c.relativePath.startsWith(r),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(r.length));let d=Cn([r,c.relativePath]),f=n.concat(c);i.children&&i.children.length>0&&(ye(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),km(i.children,t,f,d)),!(i.path==null&&!i.index)&&t.push({path:d,score:Py(d,i.index),routesMeta:f})};return e.forEach((i,l)=>{var o;if(i.path===""||!((o=i.path)!=null&&o.includes("?")))s(i,l);else for(let c of bm(i.path))s(i,l,c)}),t}function bm(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return s?[i,""]:[i];let l=bm(r.join("/")),o=[];return o.push(...l.map(c=>c===""?i:[i,c].join("/"))),s&&o.push(...l),o.map(c=>e.startsWith("/")&&c===""?"/":c)}function ky(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ty(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const by=/^:[\w-]+$/,Ny=3,Sy=2,Cy=1,_y=10,Ey=-2,Cd=e=>e==="*";function Py(e,t){let n=e.split("/"),r=n.length;return n.some(Cd)&&(r+=Ey),t&&(r+=Sy),n.filter(s=>!Cd(s)).reduce((s,i)=>s+(by.test(i)?Ny:i===""?Cy:_y),r)}function Ty(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function Oy(e,t,n){let{routesMeta:r}=e,s={},i="/",l=[];for(let o=0;o{let{paramName:m,isOptional:v}=f;if(m==="*"){let g=o[u]||"";l=i.slice(0,i.length-g.length).replace(/(.)\/+$/,"$1")}const k=o[u];return v&&!k?d[m]=void 0:d[m]=(k||"").replace(/%2F/g,"/"),d},{}),pathname:i,pathnameBase:l,pattern:e}}function Ly(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),Kc(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,c)=>(r.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function Ry(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Kc(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Jr(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const My=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,zy=e=>My.test(e);function Fy(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?ns(e):e,i;if(n)if(zy(n))i=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),Kc(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?i=_d(n.substring(1),"/"):i=_d(n,t)}else i=t;return{pathname:i,search:Ay(r),hash:$y(s)}}function _d(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function jl(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Iy(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Nm(e,t){let n=Iy(e);return t?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Sm(e,t,n,r){r===void 0&&(r=!1);let s;typeof e=="string"?s=ns(e):(s=Js({},e),ye(!s.pathname||!s.pathname.includes("?"),jl("?","pathname","search",s)),ye(!s.pathname||!s.pathname.includes("#"),jl("#","pathname","hash",s)),ye(!s.search||!s.search.includes("#"),jl("#","search","hash",s)));let i=e===""||s.pathname==="",l=i?"/":s.pathname,o;if(l==null)o=n;else{let u=t.length-1;if(!r&&l.startsWith("..")){let m=l.split("/");for(;m[0]==="..";)m.shift(),u-=1;s.pathname=m.join("/")}o=u>=0?t[u]:"/"}let c=Fy(s,o),d=l&&l!=="/"&&l.endsWith("/"),f=(i||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}const Cn=e=>e.join("/").replace(/\/\/+/g,"/"),Dy=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Ay=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,$y=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Uy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const Cm=["post","put","patch","delete"];new Set(Cm);const By=["get",...Cm];new Set(By);/** + * React Router v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Ys(){return Ys=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),j.useCallback(function(d,f){if(f===void 0&&(f={}),!o.current)return;if(typeof d=="number"){r.go(d);return}let u=Sm(d,JSON.parse(l),i,f.relative==="path");e==null&&t!=="/"&&(u.pathname=u.pathname==="/"?t:Cn([t,u.pathname])),(f.replace?r.replace:r.push)(u,f.state,f)},[t,r,l,i,e])}const Ky=j.createContext(null);function Hy(e){let t=j.useContext(Gt).outlet;return t&&j.createElement(Ky.Provider,{value:e},t)}function ha(){let{matches:e}=j.useContext(Gt),t=e[e.length-1];return t?t.params:{}}function Qi(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=j.useContext(Mn),{matches:s}=j.useContext(Gt),{pathname:i}=rs(),l=JSON.stringify(Nm(s,r.v7_relativeSplatPath));return j.useMemo(()=>Sm(e,JSON.parse(l),i,n==="path"),[e,l,i,n])}function qy(e,t){return Wy(e,t)}function Wy(e,t,n,r){fa()||ye(!1);let{navigator:s}=j.useContext(Mn),{matches:i}=j.useContext(Gt),l=i[i.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let d=rs(),f;if(t){var u;let b=typeof t=="string"?ns(t):t;c==="/"||(u=b.pathname)!=null&&u.startsWith(c)||ye(!1),f=b}else f=d;let m=f.pathname||"/",v=m;if(c!=="/"){let b=c.replace(/^\//,"").split("/");v="/"+m.replace(/^\//,"").split("/").slice(b.length).join("/")}let k=jy(e,{pathname:v}),g=Zy(k&&k.map(b=>Object.assign({},b,{params:Object.assign({},o,b.params),pathname:Cn([c,s.encodeLocation?s.encodeLocation(b.pathname).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?c:Cn([c,s.encodeLocation?s.encodeLocation(b.pathnameBase).pathname:b.pathnameBase])})),i,n,r);return t&&g?j.createElement(Bi.Provider,{value:{location:Ys({pathname:"/",search:"",hash:"",state:null,key:"default"},f),navigationType:mn.Pop}},g):g}function Gy(){let e=rg(),t=Uy(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return j.createElement(j.Fragment,null,j.createElement("h2",null,"Unexpected Application Error!"),j.createElement("h3",{style:{fontStyle:"italic"}},t),n?j.createElement("pre",{style:s},n):null,null)}const Jy=j.createElement(Gy,null);class Yy extends j.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?j.createElement(Gt.Provider,{value:this.props.routeContext},j.createElement(Em.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Xy(e){let{routeContext:t,match:n,children:r}=e,s=j.useContext(Ui);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),j.createElement(Gt.Provider,{value:t},r)}function Zy(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(s=n)==null?void 0:s.errors;if(o!=null){let f=l.findIndex(u=>u.route.id&&(o==null?void 0:o[u.route.id])!==void 0);f>=0||ye(!1),l=l.slice(0,Math.min(l.length,f+1))}let c=!1,d=-1;if(n&&r&&r.v7_partialHydration)for(let f=0;f=0?l=l.slice(0,d+1):l=[l[0]];break}}}return l.reduceRight((f,u,m)=>{let v,k=!1,g=null,b=null;n&&(v=o&&u.route.id?o[u.route.id]:void 0,g=u.route.errorElement||Jy,c&&(d<0&&m===0?(ag("route-fallback"),k=!0,b=null):d===m&&(k=!0,b=u.route.hydrateFallbackElement||null)));let p=t.concat(l.slice(0,m+1)),h=()=>{let x;return v?x=g:k?x=b:u.route.Component?x=j.createElement(u.route.Component,null):u.route.element?x=u.route.element:x=f,j.createElement(Xy,{match:u,routeContext:{outlet:f,matches:p,isDataRoute:n!=null},children:x})};return n&&(u.route.ErrorBoundary||u.route.errorElement||m===0)?j.createElement(Yy,{location:n.location,revalidation:n.revalidation,component:g,error:v,children:h(),routeContext:{outlet:null,matches:p,isDataRoute:!0}}):h()},null)}var Tm=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Tm||{}),Om=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(Om||{});function eg(e){let t=j.useContext(Ui);return t||ye(!1),t}function tg(e){let t=j.useContext(_m);return t||ye(!1),t}function ng(e){let t=j.useContext(Gt);return t||ye(!1),t}function Lm(e){let t=ng(),n=t.matches[t.matches.length-1];return n.route.id||ye(!1),n.route.id}function rg(){var e;let t=j.useContext(Em),n=tg(),r=Lm();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function sg(){let{router:e}=eg(Tm.UseNavigateStable),t=Lm(Om.UseNavigateStable),n=j.useRef(!1);return Pm(()=>{n.current=!0}),j.useCallback(function(s,i){i===void 0&&(i={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,Ys({fromRouteId:t},i)))},[e,t])}const Ed={};function ag(e,t,n){Ed[e]||(Ed[e]=!0)}function ig(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function lg(e){return Hy(e.context)}function ht(e){ye(!1)}function og(e){let{basename:t="/",children:n=null,location:r,navigationType:s=mn.Pop,navigator:i,static:l=!1,future:o}=e;fa()&&ye(!1);let c=t.replace(/^\/*/,"/"),d=j.useMemo(()=>({basename:c,navigator:i,static:l,future:Ys({v7_relativeSplatPath:!1},o)}),[c,o,i,l]);typeof r=="string"&&(r=ns(r));let{pathname:f="/",search:u="",hash:m="",state:v=null,key:k="default"}=r,g=j.useMemo(()=>{let b=Jr(f,c);return b==null?null:{location:{pathname:b,search:u,hash:m,state:v,key:k},navigationType:s}},[c,f,u,m,v,k,s]);return g==null?null:j.createElement(Mn.Provider,{value:d},j.createElement(Bi.Provider,{children:n,value:g}))}function cg(e){let{children:t,location:n}=e;return qy(Io(t),n)}new Promise(()=>{});function Io(e,t){t===void 0&&(t=[]);let n=[];return j.Children.forEach(e,(r,s)=>{if(!j.isValidElement(r))return;let i=[...t,s];if(r.type===j.Fragment){n.push.apply(n,Io(r.props.children,i));return}r.type!==ht&&ye(!1),!r.props.index||!r.props.children||ye(!1);let l={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Io(r.props.children,i)),n.push(l)}),n}/** + * React Router DOM v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function bi(){return bi=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[s]=e[s]);return n}function ug(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function dg(e,t){return e.button===0&&(!t||t==="_self")&&!ug(e)}const fg=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],hg=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],mg="6";try{window.__reactRouterVersion=mg}catch{}const pg=j.createContext({isTransitioning:!1}),xg="startTransition",Pd=bp[xg];function vg(e){let{basename:t,children:n,future:r,window:s}=e,i=j.useRef();i.current==null&&(i.current=vy({window:s,v5Compat:!0}));let l=i.current,[o,c]=j.useState({action:l.action,location:l.location}),{v7_startTransition:d}=r||{},f=j.useCallback(u=>{d&&Pd?Pd(()=>c(u)):c(u)},[c,d]);return j.useLayoutEffect(()=>l.listen(f),[l,f]),j.useEffect(()=>ig(r),[r]),j.createElement(og,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const yg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",gg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Tn=j.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:i,replace:l,state:o,target:c,to:d,preventScrollReset:f,viewTransition:u}=t,m=Rm(t,fg),{basename:v}=j.useContext(Mn),k,g=!1;if(typeof d=="string"&&gg.test(d)&&(k=d,yg))try{let x=new URL(window.location.href),w=d.startsWith("//")?new URL(x.protocol+d):new URL(d),C=Jr(w.pathname,v);w.origin===x.origin&&C!=null?d=C+w.search+w.hash:g=!0}catch{}let b=Qy(d,{relative:s}),p=wg(d,{replace:l,state:o,target:c,preventScrollReset:f,relative:s,viewTransition:u});function h(x){r&&r(x),x.defaultPrevented||p(x)}return j.createElement("a",bi({},m,{href:k||b,onClick:g||i?r:h,ref:n,target:c}))}),Mm=j.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:s=!1,className:i="",end:l=!1,style:o,to:c,viewTransition:d,children:f}=t,u=Rm(t,hg),m=Qi(c,{relative:u.relative}),v=rs(),k=j.useContext(_m),{navigator:g,basename:b}=j.useContext(Mn),p=k!=null&&kg(m)&&d===!0,h=g.encodeLocation?g.encodeLocation(m).pathname:m.pathname,x=v.pathname,w=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;s||(x=x.toLowerCase(),w=w?w.toLowerCase():null,h=h.toLowerCase()),w&&b&&(w=Jr(w,b)||w);const C=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let S=x===h||!l&&x.startsWith(h)&&x.charAt(C)==="/",N=w!=null&&(w===h||!l&&w.startsWith(h)&&w.charAt(h.length)==="/"),_={isActive:S,isPending:N,isTransitioning:p},F=S?r:void 0,O;typeof i=="function"?O=i(_):O=[i,S?"active":null,N?"pending":null,p?"transitioning":null].filter(Boolean).join(" ");let Q=typeof o=="function"?o(_):o;return j.createElement(Tn,bi({},u,{"aria-current":F,className:O,ref:n,style:Q,to:c,viewTransition:d}),typeof f=="function"?f(_):f)});var Do;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Do||(Do={}));var Td;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Td||(Td={}));function jg(e){let t=j.useContext(Ui);return t||ye(!1),t}function wg(e,t){let{target:n,replace:r,state:s,preventScrollReset:i,relative:l,viewTransition:o}=t===void 0?{}:t,c=zn(),d=rs(),f=Qi(e,{relative:l});return j.useCallback(u=>{if(dg(u,n)){u.preventDefault();let m=r!==void 0?r:ki(d)===ki(f);c(e,{replace:m,state:s,preventScrollReset:i,relative:l,viewTransition:o})}},[d,c,f,r,s,n,e,i,l,o])}function kg(e,t){t===void 0&&(t={});let n=j.useContext(pg);n==null&&ye(!1);let{basename:r}=jg(Do.useViewTransitionState),s=Qi(e,{relative:t.relative});if(!n.isTransitioning)return!1;let i=Jr(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Jr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Fo(s.pathname,l)!=null||Fo(s.pathname,i)!=null}/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var bg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ng=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),B=(e,t)=>{const n=j.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:l,className:o="",children:c,...d},f)=>j.createElement("svg",{ref:f,...bg,width:s,height:s,stroke:r,strokeWidth:l?Number(i)*24/Number(s):i,className:["lucide",`lucide-${Ng(e)}`,o].join(" "),...d},[...t.map(([u,m])=>j.createElement(u,m)),...Array.isArray(c)?c:[c]]));return n.displayName=`${e}`,n};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Sg=B("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zm=B("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cg=B("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _g=B("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Eg=B("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pg=B("BookOpen",[["path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z",key:"vv98re"}],["path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z",key:"1cyq3y"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ao=B("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fm=B("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Tg=B("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Og=B("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xs=B("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lg=B("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rg=B("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Im=B("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mg=B("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zg=B("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dm=B("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Od=B("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Am=B("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $o=B("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fg=B("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ig=B("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dg=B("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hc=B("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ag=B("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $g=B("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ug=B("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ma=B("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $m=B("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bg=B("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qg=B("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vg=B("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Zs=B("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qc=B("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Kg=B("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hg=B("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Um=B("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bm=B("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qg=B("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wg=B("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ld=B("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Gg=B("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Jg=B("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wc=B("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qm=B("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Yg=B("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xg=B("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vm=B("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ss=B("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),Zg={},Rd=e=>{let t;const n=new Set,r=(f,u)=>{const m=typeof f=="function"?f(t):f;if(!Object.is(m,t)){const v=t;t=u??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(k=>k(t,v))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>d,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(Zg?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(r,s,c);return c},e0=e=>e?Rd(e):Rd;var Km={exports:{}},Hm={},qm={exports:{}},Wm={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Yr=j;function t0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var n0=typeof Object.is=="function"?Object.is:t0,r0=Yr.useState,s0=Yr.useEffect,a0=Yr.useLayoutEffect,i0=Yr.useDebugValue;function l0(e,t){var n=t(),r=r0({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return a0(function(){s.value=n,s.getSnapshot=t,wl(s)&&i({inst:s})},[e,n,t]),s0(function(){return wl(s)&&i({inst:s}),e(function(){wl(s)&&i({inst:s})})},[e]),i0(n),n}function wl(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!n0(e,n)}catch{return!0}}function o0(e,t){return t()}var c0=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o0:l0;Wm.useSyncExternalStore=Yr.useSyncExternalStore!==void 0?Yr.useSyncExternalStore:c0;qm.exports=Wm;var u0=qm.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Vi=j,d0=u0;function f0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var h0=typeof Object.is=="function"?Object.is:f0,m0=d0.useSyncExternalStore,p0=Vi.useRef,x0=Vi.useEffect,v0=Vi.useMemo,y0=Vi.useDebugValue;Hm.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=p0(null);if(i.current===null){var l={hasValue:!1,value:null};i.current=l}else l=i.current;i=v0(function(){function c(v){if(!d){if(d=!0,f=v,v=r(v),s!==void 0&&l.hasValue){var k=l.value;if(s(k,v))return u=k}return u=v}if(k=u,h0(f,v))return k;var g=r(v);return s!==void 0&&s(k,g)?(f=v,k):(f=v,u=g)}var d=!1,f,u,m=n===void 0?null:n;return[function(){return c(t())},m===null?void 0:function(){return c(m())}]},[t,n,r,s]);var o=m0(e,i[0],i[1]);return x0(function(){l.hasValue=!0,l.value=o},[o]),y0(o),o};Km.exports=Hm;var g0=Km.exports;const j0=Yd(g0),Gm={},{useDebugValue:w0}=Go,{useSyncExternalStoreWithSelector:k0}=j0;let Md=!1;const b0=e=>e;function N0(e,t=b0,n){(Gm?"production":void 0)!=="production"&&n&&!Md&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Md=!0);const r=k0(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return w0(r),r}const zd=e=>{(Gm?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?e0(e):e,n=(r,s)=>N0(t,r,s);return Object.assign(n,t),n},Ki=e=>e?zd(e):zd,Hi="/api",Gc="flow_auth_token",Jc="flow_auth_expires",Yc="flow_auth_username";function ea(){const e=localStorage.getItem(Gc),t=localStorage.getItem(Jc);return!e||!t?null:new Date(t)<=new Date?(Zn(),null):e}function Fd(e,t,n){localStorage.setItem(Gc,e),localStorage.setItem(Jc,t),localStorage.setItem(Yc,n)}function Zn(){localStorage.removeItem(Gc),localStorage.removeItem(Jc),localStorage.removeItem(Yc)}function Xc(){return localStorage.getItem(Yc)}let lr=null;function S0(e){lr=e}async function U(e,t,n=!1){const r={"Content-Type":"application/json",...t==null?void 0:t.headers};if(!n){const i=ea();i&&(r.Authorization=`Bearer ${i}`)}const s=await fetch(`${Hi}${e}`,{...t,headers:r});if(s.status===401){Zn(),lr&&lr();const i=await s.json().catch(()=>({detail:"Not authenticated"}));throw new Error(i.detail||"Not authenticated")}if(!s.ok){const i=await s.json().catch(()=>({detail:s.statusText}));throw new Error(i.detail||"API request failed")}if(s.status!==204)return s.json()}const dr={getConfig:()=>U("/auth/config",void 0,!0),login:e=>U("/auth/login",{method:"POST",body:JSON.stringify(e)},!0),getGitHubAuthUrl:()=>`${Hi}/auth/github`,getCurrentUser:()=>U("/auth/me"),logout:()=>U("/auth/logout",{method:"POST"})},_n={list:e=>{const t=new URLSearchParams;e!=null&&e.include_auto_generated&&t.set("include_auto_generated","true"),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return U(`/configs${n?`?${n}`:""}`)},get:e=>U(`/configs/${e}`),create:e=>U("/configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/configs/${e}`,{method:"DELETE"})},gt={list:e=>{const t=new URLSearchParams;e!=null&&e.category&&t.set("category",e.category),e!=null&&e.suite&&t.set("suite",e.suite);const n=t.toString();return U(`/tasks${n?`?${n}`:""}`)},get:e=>U(`/tasks/${e}`),create:e=>U("/tasks",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/tasks/${e}`,{method:"DELETE"}),listSuites:()=>U("/tasks/suites"),importSuite:e=>U(`/tasks/import-suite?suite_name=${encodeURIComponent(e)}`,{method:"POST"})},Ot={list:e=>{const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return U(`/jobs${n?`?${n}`:""}`)},get:e=>U(`/jobs/${e}`),create:e=>U("/jobs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/jobs/${e}`,{method:"PUT",body:JSON.stringify(t)}),start:async function*(e){var o;const t={},n=ea();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Hi}/jobs/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Zn(),lr&&lr(),new Error("Not authenticated");if(!r.ok)throw new Error("Failed to start job");const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const i=new TextDecoder;let l="";for(;;){const{done:c,value:d}=await s.read();if(c)break;l+=i.decode(d,{stream:!0});const f=l.split(` +`);l=f.pop()||"";for(const u of f)u.startsWith("data: ")&&(yield JSON.parse(u.slice(6)))}},cancel:e=>U(`/jobs/${e}/cancel`,{method:"POST"}),delete:e=>U(`/jobs/${e}`,{method:"DELETE"})},Uo={list:e=>{const t=new URLSearchParams;e!=null&&e.job_id&&t.set("job_id",e.job_id),e!=null&&e.candidate_name&&t.set("candidate_name",e.candidate_name),e!=null&&e.task_name&&t.set("task_name",e.task_name),(e==null?void 0:e.is_pareto)!==void 0&&t.set("is_pareto",String(e.is_pareto));const n=t.toString();return U(`/runs${n?`?${n}`:""}`)},get:e=>U(`/runs/${e}`),getJobSummary:e=>U(`/runs/job/${e}/summary`)},Os={list:e=>{const t=new URLSearchParams;e!=null&&e.agent_id&&t.set("agent_id",e.agent_id),e!=null&&e.limit&&t.set("limit",String(e.limit));const n=t.toString();return U(`/tests${n?`?${n}`:""}`)},get:e=>U(`/tests/${e}`),create:e=>U("/tests",{method:"POST",body:JSON.stringify(e)}),start:async function*(e){var o;const t={},n=ea();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Hi}/tests/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Zn(),lr&&lr(),new Error("Not authenticated");if(!r.ok){const c=await r.json().catch(()=>({detail:"Failed to start test"}));throw new Error(c.detail||"Failed to start test")}const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const i=new TextDecoder;let l="";for(;;){const{done:c,value:d}=await s.read();if(c)break;l+=i.decode(d,{stream:!0});const f=l.split(` +`);l=f.pop()||"";for(const u of f)u.startsWith("data: ")&&(yield JSON.parse(u.slice(6)))}},cancel:e=>U(`/tests/${e}/cancel`,{method:"POST"}),delete:e=>U(`/tests/${e}`,{method:"DELETE"})},C0={list:()=>U("/llm-configs"),get:e=>U(`/llm-configs/${e}`),getDefault:()=>U("/llm-configs/default"),create:e=>U("/llm-configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/llm-configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/llm-configs/${e}`,{method:"DELETE"}),setDefault:e=>U(`/llm-configs/${e}/set-default`,{method:"POST"}),test:e=>U(`/llm-configs/${e}/test`,{method:"POST"})},_0={list:()=>U("/tools"),get:e=>U(`/tools/${e}`)},Jm={getAgentSchema:()=>U("/schema/agent")},E0={list:()=>U("/deployments"),get:e=>U(`/deployments/${e}`),delete:e=>U(`/deployments/${e}`,{method:"DELETE"})},P0={start:e=>U("/evaluate",{method:"POST",body:JSON.stringify(e)})},Bo={design:e=>U("/experiment/design",{method:"POST",body:JSON.stringify(e)}),importYaml:e=>U("/experiment/import-yaml",{method:"POST",body:JSON.stringify(e)}),validate:e=>U("/experiment/validate",{method:"POST",body:JSON.stringify(e)}),generateCandidates:e=>U("/experiment/generate-candidates",{method:"POST",body:JSON.stringify(e)})},Zc=Ki((e,t)=>(S0(()=>{e({isAuthenticated:!1,user:null,error:"Session expired. Please log in again."})}),{authConfig:null,isLoadingConfig:!0,isAuthenticated:!1,isLoading:!1,user:null,error:null,loadAuthConfig:async()=>{e({isLoadingConfig:!0});try{const n=await dr.getConfig();if(e({authConfig:n,isLoadingConfig:!1}),n.enabled){const r=ea(),s=Xc();if(r&&s)try{const i=await dr.getCurrentUser();e({isAuthenticated:!0,user:i})}catch{Zn(),e({isAuthenticated:!1,user:null})}}else e({isAuthenticated:!0,user:{username:"anonymous",auth_mode:"none"}})}catch(n){console.error("Failed to load auth config:",n),e({isLoadingConfig:!1,error:"Failed to connect to server"})}},login:async(n,r)=>{e({isLoading:!0,error:null});try{const s=await dr.login({username:n,password:r});return Fd(s.access_token,s.expires_at,s.username),e({isAuthenticated:!0,isLoading:!1,user:{username:s.username,auth_mode:"basic"}}),!0}catch(s){return e({isLoading:!1,error:s instanceof Error?s.message:"Login failed"}),!1}},loginWithGitHub:()=>{window.location.href=dr.getGitHubAuthUrl()},handleOAuthCallback:()=>{const n=new URLSearchParams(window.location.search),r=n.get("auth_error");if(r)return e({error:r}),window.history.replaceState({},"",window.location.pathname),!0;if(n.get("auth_callback")==="true"){const s=n.get("token"),i=n.get("expires_at"),l=n.get("username");return s&&i&&l&&(Fd(s,i,l),e({isAuthenticated:!0,user:{username:l,auth_mode:"github"}})),window.history.replaceState({},"",window.location.pathname),!0}return!1},logout:async()=>{try{await dr.logout()}catch{}Zn(),e({isAuthenticated:!1,user:null,error:null})},checkAuth:async()=>{const{authConfig:n}=t();if(!(n!=null&&n.enabled)){e({isAuthenticated:!0});return}if(!ea()){e({isAuthenticated:!1,user:null});return}try{const s=await dr.getCurrentUser();e({isAuthenticated:!0,user:s})}catch{Zn(),e({isAuthenticated:!1,user:null})}},clearError:()=>e({error:null})}));function V({variant:e="secondary",size:t="md",className:n="",icon:r,iconRight:s,loading:i=!1,children:l,disabled:o,...c}){const d="font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1.5 rounded-md",f={primary:"bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)]",secondary:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)] hover:bg-[var(--border)]",danger:"bg-[var(--error)] text-white hover:bg-red-600",ghost:"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"},u={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm"},m=t==="sm"?14:16;return a.jsxs("button",{className:`${d} ${f[e]} ${u[t]} ${n}`,disabled:o||i,...c,children:[i?a.jsx(ma,{size:m,className:"animate-spin"}):r?a.jsx(r,{size:m}):null,l,s&&!i&&a.jsx(s,{size:m})]})}const T0={};function O0(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var i;const l=c=>c===null?null:JSON.parse(c,void 0),o=(i=n.getItem(s))!=null?i:null;return o instanceof Promise?o.then(l):l(o)},setItem:(s,i)=>n.setItem(s,JSON.stringify(i,void 0)),removeItem:s=>n.removeItem(s)}}const ta=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return ta(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return ta(r)(n)}}}},L0=(e,t)=>(n,r,s)=>{let i={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:b=>b,version:0,merge:(b,p)=>({...p,...b}),...t},l=!1;const o=new Set,c=new Set;let d;try{d=i.getStorage()}catch{}if(!d)return e((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...b)},r,s);const f=ta(i.serialize),u=()=>{const b=i.partialize({...r()});let p;const h=f({state:b,version:i.version}).then(x=>d.setItem(i.name,x)).catch(x=>{p=x});if(p)throw p;return h},m=s.setState;s.setState=(b,p)=>{m(b,p),u()};const v=e((...b)=>{n(...b),u()},r,s);let k;const g=()=>{var b;if(!d)return;l=!1,o.forEach(h=>h(r()));const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,r()))||void 0;return ta(d.getItem.bind(d))(i.name).then(h=>{if(h)return i.deserialize(h)}).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==i.version){if(i.migrate)return i.migrate(h.state,h.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return h.state}).then(h=>{var x;return k=i.merge(h,(x=r())!=null?x:v),n(k,!0),u()}).then(()=>{p==null||p(k,void 0),l=!0,c.forEach(h=>h(k))}).catch(h=>{p==null||p(void 0,h)})};return s.persist={setOptions:b=>{i={...i,...b},b.getStorage&&(d=b.getStorage())},clearStorage:()=>{d==null||d.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>g(),hasHydrated:()=>l,onHydrate:b=>(o.add(b),()=>{o.delete(b)}),onFinishHydration:b=>(c.add(b),()=>{c.delete(b)})},g(),k||v},R0=(e,t)=>(n,r,s)=>{let i={storage:O0(()=>localStorage),partialize:g=>g,version:0,merge:(g,b)=>({...b,...g}),...t},l=!1;const o=new Set,c=new Set;let d=i.storage;if(!d)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...g)},r,s);const f=()=>{const g=i.partialize({...r()});return d.setItem(i.name,{state:g,version:i.version})},u=s.setState;s.setState=(g,b)=>{u(g,b),f()};const m=e((...g)=>{n(...g),f()},r,s);s.getInitialState=()=>m;let v;const k=()=>{var g,b;if(!d)return;l=!1,o.forEach(h=>{var x;return h((x=r())!=null?x:m)});const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,(g=r())!=null?g:m))||void 0;return ta(d.getItem.bind(d))(i.name).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==i.version){if(i.migrate)return[!0,i.migrate(h.state,h.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,h.state];return[!1,void 0]}).then(h=>{var x;const[w,C]=h;if(v=i.merge(C,(x=r())!=null?x:m),n(v,!0),w)return f()}).then(()=>{p==null||p(v,void 0),v=r(),l=!0,c.forEach(h=>h(v))}).catch(h=>{p==null||p(void 0,h)})};return s.persist={setOptions:g=>{i={...i,...g},g.storage&&(d=g.storage)},clearStorage:()=>{d==null||d.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>k(),hasHydrated:()=>l,onHydrate:g=>(o.add(g),()=>{o.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},i.skipHydration||k(),v||m},M0=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((T0?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),L0(e,t)):R0(e,t),Ym=M0,z0=Ki()(Ym((e,t)=>({theme:"light",setTheme:n=>{document.documentElement.setAttribute("data-theme",n),e({theme:n})},toggleTheme:()=>{const n=t().theme==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",n),e({theme:n})}}),{name:"flow-theme",onRehydrateStorage:()=>e=>{e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}}));function F0(){const{theme:e,toggleTheme:t}=z0();return a.jsx("button",{onClick:t,className:"p-2 rounded-md text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--accent)]","aria-label":`Switch to ${e==="dark"?"light":"dark"} mode`,title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:e==="dark"?a.jsx(Gg,{size:16}):a.jsx(Vg,{size:16})})}const I0=Ki()(Ym((e,t)=>({sidebarCollapsed:!1,toggleSidebar:()=>{e({sidebarCollapsed:!t().sidebarCollapsed})},setSidebarCollapsed:n=>{e({sidebarCollapsed:n})}}),{name:"flow-layout"})),D0=[{path:"/",label:"Overview",icon:$g},{path:"/agents",label:"Agents",icon:Ao},{path:"/jobs",label:"Experiments",icon:$o},{path:"/tasks",label:"Datasets",icon:Dm}];function A0(){const e=rs(),{sidebarCollapsed:t,toggleSidebar:n}=I0(),r=s=>s==="/"?e.pathname==="/":s==="/agents"?e.pathname==="/agents"||e.pathname.startsWith("/agents/")||e.pathname.startsWith("/deployments/"):s==="/jobs"?e.pathname.startsWith("/jobs")||e.pathname.startsWith("/runs"):e.pathname.startsWith(s);return a.jsxs("aside",{className:` + flex flex-col border-r border-[var(--border)] bg-[var(--bg-secondary)] + transition-all duration-200 + ${t?"w-14":"w-56"} + `,children:[a.jsx("nav",{className:"flex-1 py-2",children:D0.map(s=>{const i=r(s.path);return a.jsxs(Mm,{to:s.path,title:t?s.label:void 0,className:` + flex items-center gap-3 px-4 py-2.5 text-sm transition-colors relative + ${i?"text-[var(--accent)] bg-[var(--accent-dim)] font-medium":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"} + `,children:[i&&a.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-r bg-[var(--accent)]"}),a.jsx(s.icon,{size:18}),!t&&a.jsx("span",{children:s.label})]},s.path)})}),a.jsx("button",{onClick:n,className:"flex items-center justify-center p-3 border-t border-[var(--border)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",title:t?"Expand sidebar":"Collapse sidebar",children:t?a.jsx(Rg,{size:16}):a.jsx(Lg,{size:16})})]})}function $0(){const{authConfig:e,user:t,logout:n}=Zc(),r=async()=>{await n()};return a.jsxs("div",{className:"h-screen flex flex-col",children:[a.jsx("header",{className:"border-b border-[var(--border)] bg-[var(--bg-secondary)] shrink-0",children:a.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between",children:[a.jsxs(Mm,{to:"/",className:"text-lg font-semibold text-[var(--accent)] flex items-center gap-2 hover:opacity-80",children:[a.jsx(ss,{size:20}),"Flow",a.jsx("span",{className:"text-[var(--text-secondary)] font-normal",children:"/optimize"})]}),a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(F0,{}),(e==null?void 0:e.enabled)&&t&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[a.jsx(Qm,{size:14}),a.jsx("span",{children:t.username})]}),a.jsx(V,{variant:"ghost",size:"sm",icon:Bg,onClick:r,title:"Sign out",children:"Sign out"})]})]})]})}),a.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[a.jsx(A0,{}),a.jsx("main",{className:"flex-1 overflow-y-auto bg-[var(--bg-primary)]",children:a.jsx("div",{className:"p-6",children:a.jsx(lg,{})})})]})]})}function W({children:e,variant:t="default"}){const n={default:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)]",success:"bg-[var(--badge-success-bg)] text-[var(--badge-success-text)] border border-[var(--badge-success-border)]",warning:"bg-[var(--badge-warning-bg)] text-[var(--badge-warning-text)] border border-[var(--badge-warning-border)]",error:"bg-[var(--badge-error-bg)] text-[var(--badge-error-text)] border border-[var(--badge-error-border)]",info:"bg-[var(--badge-info-bg)] text-[var(--badge-info-text)] border border-[var(--badge-info-border)]"};return a.jsx("span",{className:`inline-block px-2 py-0.5 text-xs font-medium rounded-md ${n[t]}`,children:e})}const U0={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};function B0(){const e=zn(),{data:t=[],isLoading:n}=le({queryKey:["configs"],queryFn:()=>_n.list()}),{data:r=[],isLoading:s}=le({queryKey:["jobs"],queryFn:()=>Ot.list()}),{data:i=[],isLoading:l}=le({queryKey:["tasks"],queryFn:()=>gt.list()}),o=[...t].sort((f,u)=>new Date(u.created_at).getTime()-new Date(f.created_at).getTime()).slice(0,5),c=[...r].sort((f,u)=>new Date(u.created_at).getTime()-new Date(f.created_at).getTime()).slice(0,5),d=i.reduce((f,u)=>{const m=u.suite||"custom";return f[m]||(f[m]=[]),f[m].push(u),f},{});return a.jsxs("div",{children:[a.jsxs("div",{className:"mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Agent Optimizer"}),a.jsx("p",{className:"text-[var(--text-secondary)] max-w-2xl",children:"Systematically optimize and improve your AI agents across key dimensions. Define agent configurations, run experiments across task datasets, and find the best tradeoffs between quality and cost."}),a.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:[{icon:Qg,label:"Instructions"},{icon:Yg,label:"Tools"},{icon:Pg,label:"Skills"},{icon:Wg,label:"Compaction"}].map(f=>a.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md bg-[var(--bg-tertiary)] border border-[var(--border)] text-[var(--text-secondary)]",children:[a.jsx(f.icon,{size:14}),f.label]},f.label))})]}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[{step:"1",title:"Define Agents",description:"Create agent configurations with different instructions, tools, and compaction strategies.",icon:Ao},{step:"2",title:"Run Experiments",description:"Test agent variants against task datasets to measure quality and cost.",icon:$o},{step:"3",title:"Analyze Results",description:"Compare candidates on a Pareto frontier to find the best quality-cost tradeoffs.",icon:ss}].map(f=>a.jsxs("div",{className:"p-4 border border-[var(--border)] rounded-lg bg-[var(--bg-secondary)]",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a.jsx("span",{className:"flex items-center justify-center w-7 h-7 rounded-full bg-[var(--accent)]/10 text-[var(--accent)] text-xs font-bold",children:f.step}),a.jsx(f.icon,{size:18,className:"text-[var(--accent)]"})]}),a.jsx("h3",{className:"font-medium text-sm",children:f.title}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:f.description})]},f.step))}),a.jsx(kl,{title:"Recent Agents",icon:Ao,count:t.length,onShowAll:()=>e("/agents")}),n?a.jsx(bl,{}):o.length===0?a.jsx(Nl,{message:"No agents yet. Create your first agent to get started."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden mb-8",children:o.map((f,u)=>a.jsxs("div",{onClick:()=>e(`/agents/${f.id}`),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${ue("/jobs")}),s?a.jsx(bl,{}):c.length===0?a.jsx(Nl,{message:"No experiments yet. Start one from an agent's detail page."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden mb-8",children:c.map((f,u)=>a.jsxs("div",{onClick:()=>e(`/jobs/${f.id}`),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${ue("/tasks")}),l?a.jsx(bl,{}):Object.keys(d).length===0?a.jsx(Nl,{message:"No datasets yet. Import a task suite to get started."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden mb-8",children:Object.entries(d).map(([f,u],m,v)=>a.jsx("div",{onClick:()=>e("/tasks"),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${m0&&a.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",n,")"]})]}),n>0&&a.jsxs("button",{onClick:r,className:"text-sm text-[var(--accent)] hover:underline flex items-center gap-1",children:["Show all ",a.jsx(Cg,{size:14})]})]})}function bl(){return a.jsx("div",{className:"text-sm text-[var(--text-secondary)] mb-8",children:"Loading..."})}function Nl({message:e}){return a.jsx("div",{className:"text-sm text-[var(--text-secondary)] py-6 text-center border border-[var(--border)] rounded-lg mb-8",children:e})}const Q0=["maf","miniagent","langgraph"],V0={maf:"Microsoft Agent Framework",miniagent:"MiniAgent",langgraph:"LangGraph"},K0={openai:"OpenAI",azure_openai:"Azure OpenAI",anthropic:"Anthropic",ollama:"Ollama",custom:"Custom (OpenAI-compatible)"},H0={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"};function as({isOpen:e,onClose:t,title:n,children:r,footer:s,size:i="md"}){return j.useEffect(()=>{const l=o=>{o.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",l),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",l),document.body.style.overflow=""}},[e,t]),e?a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),a.jsxs("div",{className:`relative bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg ${H0[i]} w-full mx-4 max-h-[80vh] flex flex-col`,children:[a.jsxs("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-b border-[var(--border)] px-4 py-3 flex items-center justify-between",children:[a.jsx("h2",{className:"font-semibold",children:n}),a.jsx("button",{onClick:t,className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"×"})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r}),s&&a.jsx("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-t border-[var(--border)] px-4 py-3",children:s})]})]}):null}function pn({label:e,className:t="",...n}){return a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),a.jsx("input",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] ${t}`,...n})]})}function q0({label:e,className:t="",...n}){return a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),a.jsx("textarea",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] resize-y min-h-[100px] ${t}`,...n})]})}function Ni({label:e,className:t="",...n}){return a.jsxs("label",{className:`flex items-center gap-2 cursor-pointer ${t}`,children:[a.jsx("input",{type:"checkbox",className:"w-4 h-4 bg-[var(--bg-primary)] border border-[var(--border)] rounded accent-[var(--accent)]",...n}),a.jsx("span",{className:"text-sm",children:e})]})}function Xm({columns:e,data:t,onRowClick:n,searchable:r=!1,searchPlaceholder:s="Search...",searchFilter:i,emptyMessage:l="No items found",emptyIcon:o}){const[c,d]=j.useState(""),[f,u]=j.useState(null),[m,v]=j.useState("asc"),k=j.useMemo(()=>{let b=t;if(r&&c&&i&&(b=b.filter(p=>i(p,c))),f){const p=e.find(h=>h.key===f);p!=null&&p.sortValue&&(b=[...b].sort((h,x)=>{const w=p.sortValue(h),C=p.sortValue(x),S=wC?1:0;return m==="asc"?S:-S}))}return b},[t,c,i,r,f,m,e]),g=b=>{const p=e.find(h=>h.key===b);p!=null&&p.sortable&&(f===b?v(m==="asc"?"desc":"asc"):(u(b),v("asc")))};return a.jsxs("div",{children:[r&&a.jsxs("div",{className:"mb-4 relative max-w-sm",children:[a.jsx(Hg,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]"}),a.jsx("input",{type:"text",placeholder:s,value:c,onChange:b=>d(b.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md pl-9 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]"})]}),k.length===0?a.jsxs("div",{className:"text-center py-16 text-[var(--text-secondary)]",children:[o&&a.jsx("div",{className:"mb-3 flex justify-center",children:o}),a.jsx("p",{children:l})]}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsx("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:e.map(b=>a.jsx("th",{onClick:()=>g(b.key),className:`text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider ${b.sortable?"cursor-pointer hover:text-[var(--text-primary)]":""} ${b.className||""}`,children:a.jsxs("span",{className:"inline-flex items-center gap-1",children:[b.header,b.sortable&&f===b.key&&a.jsx("span",{children:m==="asc"?"↑":"↓"})]})},b.key))})}),a.jsx("tbody",{children:k.map((b,p)=>a.jsx("tr",{onClick:()=>n==null?void 0:n(b),className:`border-b border-[var(--border)] last:border-b-0 transition-colors ${n?"cursor-pointer hover:bg-[var(--bg-tertiary)]":""}`,children:e.map(h=>a.jsx("td",{className:`px-4 py-3 ${h.className||""}`,children:h.render(b)},h.key))},p))})]})})]})}function W0({variations:e,onChange:t,strategies:n,availableStrategies:r}){const s=r??Object.keys(n),i=()=>{const d=e.map(v=>v.strategy),f=s.find(v=>!d.includes(v))||"none",u=n[f],m={strategy:f};if(u!=null&&u.params)for(const[v,k]of Object.entries(u.params))k.default!==void 0&&(m[v]=k.default);t([...e,m])},l=d=>{t(e.filter((f,u)=>u!==d))},o=(d,f)=>{t(e.map((u,m)=>m===d?{...u,...f}:u))},c=(d,f)=>{const u=n[f],m={strategy:f};if(u!=null&&u.params)for(const[v,k]of Object.entries(u.params))k.default!==void 0&&(m[v]=k.default);o(d,m)};return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm font-medium",children:"Compaction Strategies"}),a.jsx(V,{type:"button",variant:"ghost",size:"sm",icon:qc,onClick:i,disabled:e.length>=s.length,children:"Add"})]}),e.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:'No compaction variations. Click "Add" to test different strategies.'}):a.jsx("div",{className:"space-y-2",children:e.map((d,f)=>{const u=n[d.strategy];return a.jsx("div",{className:"p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsx("select",{className:"w-full px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:d.strategy,onChange:m=>c(f,m.target.value),children:s.map(m=>{var v;return a.jsx("option",{value:m,children:((v=n[m])==null?void 0:v.label)||m},m)})}),(u==null?void 0:u.description)&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:u.description}),(u==null?void 0:u.params)&&Object.keys(u.params).length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:Object.entries(u.params).map(([m,v])=>a.jsx(G0,{name:m,schema:v,value:d[m],onChange:k=>o(f,{[m]:k})},m))})]}),a.jsx("button",{type:"button",onClick:()=>l(f),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:a.jsx(Vm,{size:16})})]})},f)})})]})}function G0({name:e,schema:t,value:n,onChange:r}){const s=e.replace(/_/g," ");return t.type==="boolean"?a.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[a.jsx("input",{type:"checkbox",checked:!!(n??t.default),onChange:i=>r(i.target.checked),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"capitalize",children:s})]}):a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:s}),a.jsx("input",{type:t.type==="number"?"number":"text",className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-xs",value:String(n!==void 0?n:t.default??""),onChange:i=>{if(t.type==="number"){const l=parseFloat(i.target.value);r(isNaN(l)?t.default:l)}else r(i.target.value)},min:t.min,max:t.max,step:t.max&&t.max<=1?.1:1})]})}function J0({variations:e,onChange:t,providers:n}){const r=()=>{const o=n[0],c={provider:(o==null?void 0:o.name)||"azure_openai",model:(o==null?void 0:o.models[0])||"gpt-4o"};t([...e,c])},s=o=>{t(e.filter((c,d)=>d!==o))},i=(o,c)=>{t(e.map((d,f)=>f===o?{...d,...c}:d))},l=(o,c)=>{const d=n.find(f=>f.name===c);i(o,{provider:c,model:(d==null?void 0:d.models[0])||""})};return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm font-medium",children:"LLM Configurations"}),a.jsx(V,{type:"button",variant:"ghost",size:"sm",icon:qc,onClick:r,children:"Add"})]}),e.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:`Uses agent's default LLM. Click "Add" to test different models.`}):a.jsx("div",{className:"space-y-2",children:e.map((o,c)=>{const d=n.find(f=>f.name===o.provider);return a.jsxs("div",{className:"flex items-center gap-2 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[a.jsx("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.provider,onChange:f=>l(c,f.target.value),children:n.map(f=>a.jsx("option",{value:f.name,children:f.label},f.name))}),d&&d.models.length>0?a.jsxs("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:f=>i(c,{model:f.target.value}),children:[d.models.map(f=>a.jsx("option",{value:f,children:f},f)),!d.models.includes(o.model)&&o.model&&a.jsx("option",{value:o.model,children:o.model})]}):a.jsx("input",{type:"text",className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:f=>i(c,{model:f.target.value}),placeholder:"Model ID"}),a.jsx("button",{type:"button",onClick:()=>s(c),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:a.jsx(Vm,{size:16})})]},c)})})]})}const Qo={compaction:[],tools:[],llm_config:[],instructions:[],instruction_strategies:[]};function Y0({agentId:e,agentName:t,agentFramework:n="maf",taskSuite:r,taskCount:s,schema:i,onVariationsChange:l,parallel:o,onParallelChange:c,budget:d,onBudgetChange:f,useLlmEval:u,onUseLlmEvalChange:m}){const[v,k]=j.useState(Qo),[g,b]=j.useState(!1),[p,h]=j.useState(""),[x,w]=j.useState(null),C=i.frameworks[n],S=(C==null?void 0:C.compaction_strategies)||Object.keys(i.compaction_strategies),N=i.tool_presets||[],_=i.llm_providers||[],O=(()=>{let L=1;v.compaction.length>0&&(L*=v.compaction.length),v.tools.length>0&&(L*=v.tools.length),v.llm_config.length>0&&(L*=v.llm_config.length);const K=v.instructions.length+v.instruction_strategies.reduce((ee,R)=>ee+R.max_candidates,0);return K>0&&(L*=K),Math.min(L,d)})(),Q=O*s,J=L=>{k(L),l==null||l(L)},re=Je({mutationFn:L=>Bo.design(L),onSuccess:L=>{h(L.yaml_content),b(!0)}}),oe=Je({mutationFn:L=>Bo.validate(L),onSuccess:L=>{w({valid:L.valid,errors:L.errors,warnings:L.warnings})}}),D=()=>({base_agent_id:e,task_suite:r,variations:v,parallel:o,budget:d,use_llm_eval:u}),G=()=>{re.mutate(D())},X=()=>{oe.mutate(D())},P=()=>{const L=new Blob([p],{type:"text/yaml"}),K=URL.createObjectURL(L),ee=document.createElement("a");ee.href=K,ee.download=`${t}_experiment.yaml`,ee.click(),URL.revokeObjectURL(K)},A=v.compaction.length>0||v.tools.length>0||v.llm_config.length>0||v.instructions.length>0||v.instruction_strategies.length>0;return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsxs(W,{variant:"info",children:[O," candidates"]}),a.jsxs(W,{children:[s," tasks"]}),a.jsxs(W,{variant:Q>100?"warning":"success",children:[Q," total runs"]})]}),a.jsx(W0,{variations:v.compaction,onChange:L=>J({...v,compaction:L}),strategies:i.compaction_strategies,availableStrategies:S}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("label",{className:"text-sm font-medium",children:"Tool Presets"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(L=>a.jsxs("label",{className:`flex items-center gap-2 px-3 py-1.5 border rounded cursor-pointer transition-colors ${v.tools.includes(L.name)?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[a.jsx("input",{type:"checkbox",checked:v.tools.includes(L.name),onChange:K=>{const ee=K.target.checked?[...v.tools,L.name]:v.tools.filter(R=>R!==L.name);J({...v,tools:ee})},className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:L.name}),a.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",L.tools.length,")"]})]},L.name))}),v.tools.length>0&&a.jsxs("p",{className:"text-xs text-[var(--text-secondary)]",children:["Selected: ",v.tools.join(", ")]})]}),a.jsx(J0,{variations:v.llm_config,onChange:L=>J({...v,llm_config:L}),providers:_}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-4 space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium",children:"Execution Settings"}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(pn,{label:"Parallel Workers",type:"number",value:o,onChange:L=>c(parseInt(L.target.value)||1),min:1,max:16}),a.jsx(pn,{label:"Budget (max candidates)",type:"number",value:d,onChange:L=>f(parseInt(L.target.value)||100),min:1,max:1e3})]}),a.jsx(Ni,{label:"Use LLM evaluation",checked:u,onChange:L=>m(L.target.checked)}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] ml-6 -mt-2",children:u?"LLM-as-Judge scores task completion (0-1)":"Simple pass/fail based on task success"})]}),a.jsxs("div",{className:"flex items-center gap-2 border-t border-[var(--border)] pt-4",children:[a.jsx(V,{variant:"secondary",size:"sm",onClick:X,loading:oe.isPending,children:"Validate"}),a.jsx(V,{variant:"secondary",size:"sm",icon:Od,onClick:G,loading:re.isPending,children:"Export YAML"})]}),x&&a.jsxs("div",{className:`p-3 rounded border ${x.valid?"border-green-500/50 bg-green-500/10":"border-red-500/50 bg-red-500/10"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[x.valid?a.jsx(Fm,{size:16,className:"text-green-500"}):a.jsx(zm,{size:16,className:"text-red-500"}),a.jsx("span",{className:"font-medium text-sm",children:x.valid?"Configuration valid":"Configuration has issues"})]}),x.errors.length>0&&a.jsx("ul",{className:"text-sm text-red-500 list-disc ml-6",children:x.errors.map((L,K)=>a.jsx("li",{children:L},K))}),x.warnings.length>0&&a.jsx("ul",{className:"text-sm text-yellow-500 list-disc ml-6 mt-1",children:x.warnings.map((L,K)=>a.jsx("li",{children:L},K))})]}),g&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-lg shadow-xl max-w-2xl w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border)]",children:[a.jsx("h3",{className:"font-medium",children:"Experiment YAML"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(V,{variant:"secondary",size:"sm",icon:Od,onClick:P,children:"Download"}),a.jsx(V,{variant:"ghost",size:"sm",onClick:()=>b(!1),children:"Close"})]})]}),a.jsx("pre",{className:"flex-1 overflow-auto p-4 text-xs font-mono bg-[var(--bg-secondary)]",children:p})]})}),!A&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No variations selected. Only the baseline agent will be tested. Add compaction strategies, tool presets, or LLM configs to generate candidates."})]})}function Zm({agent:e,isOpen:t,onClose:n}){var R;const r=zn(),s=Wt(),[i,l]=j.useState("ready"),[o,c]=j.useState("quick"),[d,f]=j.useState(!1),[u,m]=j.useState([]),[v,k]=j.useState(!1),[g,b]=j.useState(Qo),[p,h]=j.useState(4),[x,w]=j.useState(100),[C,S]=j.useState(!1),[N,_]=j.useState(null),{data:F=[]}=le({queryKey:["tasks"],queryFn:()=>gt.list()}),{data:O=[]}=le({queryKey:["suites"],queryFn:()=>gt.listSuites()}),{data:Q}=le({queryKey:["agent-schema"],queryFn:()=>Jm.getAgentSchema()}),J=O.map(T=>({value:T.name,label:T.name.charAt(0).toUpperCase()+T.name.slice(1),description:T.description,tasks:T.task_count})),re=Je({mutationFn:gt.importSuite,onSuccess:T=>{s.invalidateQueries({queryKey:["tasks"]}),m(T.map(te=>te.id))}}),oe=Je({mutationFn:async T=>{const te=await Ot.create(T);return Ot.start(te.id).next(),te},onSuccess:T=>{s.invalidateQueries({queryKey:["jobs"]}),_(T.id),l("success")}}),G=v?(()=>{let T=1;g.compaction.length>0&&(T*=g.compaction.length),g.tools.length>0&&(T*=g.tools.length),g.llm_config.length>0&&(T*=g.llm_config.length);const te=g.instructions.length+g.instruction_strategies.reduce((pe,Se)=>pe+Se.max_candidates,0);return te>0&&(T*=te),Math.min(T,x)})():1,X=d?u.length:((R=J.find(T=>T.value===o))==null?void 0:R.tasks)||3,P=G*X,A=async()=>{l("starting");let T=u;if(!d)try{T=(await re.mutateAsync(o)).map(H=>H.id)}catch(M){console.error("Failed to import suite:",M),alert(`Failed to import task suite: ${o}`),l("ready");return}if(T.length===0){alert("No tasks selected. Please select tasks or choose a task suite."),l("ready");return}let te;if(v&&(g.compaction.length>0||g.tools.length>0||g.llm_config.length>0||g.instructions.length>0||g.instruction_strategies.length>0))try{te=(await Bo.generateCandidates({base_agent_id:e.id,variations:g,budget:x})).candidate_ids}catch(M){console.error("Failed to generate candidates:",M),alert(`Failed to generate candidates: ${M instanceof Error?M.message:"Unknown error"}`),l("ready");return}else te=[e.id];const Se={name:`${e.name} optimization (${te.length} candidates × ${T.length} tasks)`,candidate_ids:te,task_ids:T,parallel:p,use_llm_eval:C};oe.mutate(Se)},L=T=>{m(te=>te.includes(T)?te.filter(pe=>pe!==T):[...te,T])},K=()=>{l("ready"),_(null),k(!1),b(Qo),n()},ee=()=>i==="success"&&N?a.jsxs("div",{className:"flex justify-end gap-3",children:[a.jsx(V,{variant:"secondary",onClick:K,children:"Close"}),a.jsx(V,{variant:"primary",icon:Zs,onClick:()=>{K(),r(`/jobs/${N}`)},children:"View Job"})]}):i==="starting"?null:a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(V,{variant:"secondary",onClick:n,children:"Cancel"}),a.jsxs(V,{variant:"primary",icon:Zs,onClick:A,disabled:d&&u.length===0,children:["Start Optimization (",P," runs)"]})]});return a.jsx(as,{isOpen:t,onClose:K,title:`Optimize: ${e.name}`,footer:ee(),size:"lg",children:i==="success"&&N?a.jsxs("div",{className:"flex flex-col items-center py-8",children:[a.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/20 flex items-center justify-center mb-4",children:a.jsx(ss,{size:24,className:"text-green-500"})}),a.jsx("h3",{className:"text-lg font-medium mb-2",children:"Job Started!"}),a.jsx("p",{className:"text-[var(--text-secondary)] text-center mb-2",children:"Optimization job is now running"}),a.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-3 py-1.5 rounded font-mono",children:["ID: ",N.slice(0,8),"..."]})]}):i==="starting"?a.jsxs("div",{className:"flex flex-col items-center py-8",children:[a.jsx(ma,{size:32,className:"animate-spin text-[var(--accent)] mb-4"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:re.isPending?"Importing tasks...":"Creating optimization job..."})]}):a.jsxs("div",{className:"space-y-5",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Task Suite"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:d?"__custom__":o,onChange:T=>{T.target.value==="__custom__"?f(!0):(f(!1),c(T.target.value))},children:[J.map(T=>a.jsxs("option",{value:T.value,children:[T.label," (",T.tasks," tasks) — ",T.description]},T.value)),F.length>0&&a.jsx("option",{value:"__custom__",children:"Custom Selection"})]})]}),d&&F.length>0&&a.jsx("div",{className:"max-h-48 overflow-y-auto border border-[var(--border)] rounded p-2 space-y-1",children:F.map(T=>a.jsxs("label",{className:"flex items-center gap-2 p-2 hover:bg-[var(--bg-tertiary)] cursor-pointer rounded",children:[a.jsx("input",{type:"checkbox",checked:u.includes(T.id),onChange:()=>L(T.id),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:T.name}),T.suite&&a.jsx(W,{children:T.suite})]},T.id))}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[a.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>k(!v),children:[a.jsx(Xs,{size:14,className:`transition-transform ${v?"rotate-90":""}`}),"Advanced Settings",v&&a.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"(experiment design, variations, execution)"})]}),v&&Q&&a.jsx("div",{className:"mt-4",children:a.jsx(Y0,{agentId:e.id,agentName:e.name,agentFramework:e.config.framework,taskSuite:d?void 0:o,taskCount:X,schema:Q,onVariationsChange:b,parallel:p,onParallelChange:h,budget:x,onBudgetChange:w,useLlmEval:C,onUseLlmEvalChange:S})})]})]})})}function X0(){const e=zn(),t=Wt(),[n,r]=j.useState(!1),[s,i]=j.useState(null),{data:l=[],isLoading:o}=le({queryKey:["configs"],queryFn:()=>_n.list()}),c=Je({mutationFn:_n.create,onSuccess:()=>{t.invalidateQueries({queryKey:["configs"]}),r(!1)}}),d=Je({mutationFn:_n.delete,onSuccess:()=>t.invalidateQueries({queryKey:["configs"]})}),f=[{key:"name",header:"Name",render:u=>a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:u.name})},{key:"framework",header:"Framework",render:u=>a.jsx(W,{children:u.config.framework||"maf"})},{key:"tools",header:"Tools",render:u=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:Z0(u.config.tools)})},{key:"compaction",header:"Compaction",render:u=>{const m=u.config.compaction;return!m||m.strategy==="none"?a.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"}):m.strategy==="head_tail"?a.jsxs(W,{children:[m.params.head_size,"/",m.params.tail_size]}):a.jsx(W,{children:m.strategy})}},{key:"created",header:"Created",render:u=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(u.created_at).toLocaleDateString()}),sortable:!0,sortValue:u=>new Date(u.created_at).getTime()},{key:"actions",header:"",className:"w-40",render:u=>a.jsxs("div",{className:"flex items-center gap-2",onClick:m=>m.stopPropagation(),children:[a.jsx(V,{variant:"primary",size:"sm",icon:ss,onClick:()=>i(u),children:"Optimize"}),a.jsx(V,{variant:"ghost",size:"sm",icon:Wc,title:"Delete",onClick:()=>{confirm(`Delete agent "${u.name}"?`)&&d.mutate(u.id)}})]})}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Agents"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Define and optimize your agent configurations."})]}),a.jsx(V,{variant:"primary",icon:qc,onClick:()=>r(!0),children:"Create agent"})]}),o?a.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[a.jsx(ma,{size:16,className:"animate-spin"}),"Loading agents..."]}):a.jsx(Xm,{columns:f,data:l,onRowClick:u=>e(`/agents/${u.id}`),searchable:!0,searchPlaceholder:"Search agents",searchFilter:(u,m)=>u.name.toLowerCase().includes(m.toLowerCase())||(u.description||"").toLowerCase().includes(m.toLowerCase()),emptyMessage:"No agents yet. Create your first agent to start optimizing.",emptyIcon:a.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-[var(--bg-tertiary)]",children:a.jsx(Bm,{size:24,className:"text-[var(--text-secondary)]"})})}),a.jsx(e1,{isOpen:n,onClose:()=>r(!1),onSubmit:u=>c.mutate(u),isLoading:c.isPending}),s&&a.jsx(Zm,{agent:s,isOpen:!!s,onClose:()=>i(null)})]})}function Z0(e){return typeof e=="string"?e:Array.isArray(e)?`[${e.length}]`:e&&typeof e=="object"?`[${Object.keys(e).length}]`:"standard"}function e1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){var K,ee,R,T,te,pe,Se;const s=["read_file","write_file","edit_file","bash","grep","think"],[i,l]=j.useState("preset"),[o,c]=j.useState({name:"",description:"",instructions:null,model:null,compaction:{strategy:"none",params:{}},tools:s,framework:"miniagent",llm_config_id:null}),[d,f]=j.useState(!1),[u,m]=j.useState("preset"),[v,k]=j.useState([...s]),[g,b]=j.useState(!1),{data:p}=le({queryKey:["agent-schema"],queryFn:()=>Jm.getAgentSchema()}),{data:h=[]}=le({queryKey:["llm-configs"],queryFn:()=>C0.list()}),{data:x}=le({queryKey:["tools"],queryFn:()=>_0.list()}),w=((K=x==null?void 0:x.tools)==null?void 0:K.map(M=>M.name))??s,C=(x==null?void 0:x.presets)??{},S=Object.keys(C),N=(p==null?void 0:p.frameworks)??{},_=Object.keys(N).length>0?Object.keys(N):Q0,F=o.framework||"miniagent",O=((R=(ee=p==null?void 0:p.frameworks)==null?void 0:ee[F])==null?void 0:R.compaction_strategies)??["none","head_tail"],Q=(p==null?void 0:p.compaction_strategies)??{},J=(p==null?void 0:p.agent_presets)??[],re=M=>{const H=M.config,dt=H.compaction;n({name:M.name+"-agent",description:M.description,framework:H.framework||"miniagent",tools:H.tools||"standard",compaction:dt||{strategy:"none",params:{}},instructions:H.instructions||null})},oe=M=>{if(M.preventDefault(),!o.name.trim())return;const H={...o};u==="custom"&&(H.tools=v),n(H)},D=((T=o.compaction)==null?void 0:T.strategy)!=="none",G=((te=o.compaction)==null?void 0:te.strategy)||"none",X=Q[G],P=M=>{k(H=>H.includes(M)?H.filter(dt=>dt!==M):[...H,M])},A=M=>{const H=Q[M],dt={};if(H!=null&&H.params)for(const[is,ls]of Object.entries(H.params))ls.default!==void 0&&(dt[is]=ls.default);c({...o,compaction:{strategy:M,params:dt}})},L=i==="custom"?a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(V,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(V,{type:"submit",form:"create-agent-form",variant:"primary",disabled:!o.name.trim(),loading:r,children:"Create Agent"})]}):a.jsx("div",{className:"flex justify-end gap-2",children:a.jsx(V,{type:"button",variant:"secondary",onClick:t,children:"Cancel"})});return a.jsxs(as,{isOpen:e,onClose:t,title:"Create Agent",footer:L,children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b border-[var(--border)]",children:[a.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${i==="preset"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("preset"),children:"From Preset"}),a.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${i==="custom"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("custom"),children:"Custom"})]}),i==="preset"?a.jsx("div",{className:"space-y-3",children:J.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"Loading presets..."}):J.map(M=>a.jsx("button",{type:"button",className:"w-full text-left p-4 border border-[var(--border)] rounded-lg hover:border-[var(--accent)] hover:bg-[var(--accent)]/5 transition-colors",onClick:()=>re(M),disabled:r,children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("h4",{className:"font-medium",children:M.label}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:M.description}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[M.tags.map(H=>a.jsx(W,{variant:"default",children:H},H)),M.suggested_datasets.length>0&&a.jsxs(W,{variant:"success",children:["datasets: ",M.suggested_datasets.join(", ")]})]})]}),a.jsx(Xs,{size:16,className:"text-[var(--text-secondary)] mt-1 flex-shrink-0"})]})},M.name))}):a.jsxs("form",{id:"create-agent-form",onSubmit:oe,className:"space-y-4",children:[a.jsx(pn,{label:"Name",value:o.name,onChange:M=>c({...o,name:M.target.value}),placeholder:"e.g., my-coding-agent",required:!0}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"LLM Configuration"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.llm_config_id||"",onChange:M=>c({...o,llm_config_id:M.target.value||null}),children:[a.jsx("option",{value:"",children:"Use environment variables"}),h.map(M=>a.jsxs("option",{value:M.id,children:[M.name," (",K0[M.provider],M.model_id?` - ${M.model_id}`:"",")",M.is_default?" (default)":""]},M.id))]}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:h.length===0?"No LLM configs found. Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)":o.llm_config_id?"Uses the selected LLM configuration.":"Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Framework"}),a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.framework||"miniagent",onChange:M=>{const H=M.target.value;c({...o,framework:H,compaction:{strategy:"none",params:{}}})},children:_.map(M=>{var H;return a.jsx("option",{value:M,children:((H=N[M])==null?void 0:H.label)||V0[M]||M},M)})}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((pe=N[F])==null?void 0:pe.description)||(F==="miniagent"?"Lightweight agent with token-aware context management.":F==="langgraph"?"Graph-based workflows with state management.":"Default agent implementation.")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(Ni,{label:"Custom instructions",checked:d,onChange:M=>{f(M.target.checked),M.target.checked||c({...o,instructions:null})}}),a.jsx(Ni,{label:"Enable compaction",checked:D,onChange:M=>{if(M.target.checked){const H=O.find(dt=>dt!=="none")||"head_tail";A(H)}else c({...o,compaction:{strategy:"none",params:{}}})}})]}),d&&a.jsx("textarea",{className:"w-full h-32 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono resize-y",value:o.instructions||"",onChange:M=>c({...o,instructions:M.target.value||null}),placeholder:"System prompt / instructions for the agent..."}),D&&a.jsxs("div",{className:"space-y-3 p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Compaction Strategy"}),a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:G,onChange:M=>A(M.target.value),children:O.filter(M=>M!=="none").map(M=>{var H;return a.jsx("option",{value:M,children:((H=Q[M])==null?void 0:H.label)||M},M)})}),(X==null?void 0:X.description)&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:X.description})]}),(X==null?void 0:X.params)&&Object.keys(X.params).length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-3",children:Object.entries(X.params).map(([M,H])=>{var ls;const dt=(ls=o.compaction)==null?void 0:ls.params[M],is=dt!==void 0?dt:H.default;return a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:M.replace(/_/g," ")}),a.jsx("input",{type:"number",className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof is=="number"?is:Number(is)||0,onChange:ip=>{const tu=parseFloat(ip.target.value);c({...o,compaction:{...o.compaction,params:{...o.compaction.params,[M]:isNaN(tu)?typeof H.default=="number"?H.default:0:tu}}})},min:H.min,max:H.max,step:H.max&&H.max<=1?.1:1}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:H.description})]},M)})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm font-medium",children:"Tools"}),a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"radio",checked:u==="preset",onChange:()=>m("preset"),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:"Preset"})]}),a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"radio",checked:u==="custom",onChange:()=>m("custom"),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:"Custom"})]})]}),u==="preset"?a.jsxs(a.Fragment,{children:[a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof o.tools=="string"?o.tools:"standard",onChange:M=>c({...o,tools:M.target.value}),children:S.map(M=>a.jsx("option",{value:M,children:M},M))}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((Se=C[typeof o.tools=="string"?o.tools:"standard"])==null?void 0:Se.join(", "))??""})]}):a.jsx("div",{className:"grid grid-cols-2 gap-1 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:w.map(M=>a.jsxs("label",{className:"flex items-center gap-2 p-1 text-sm cursor-pointer hover:bg-[var(--bg-tertiary)]",children:[a.jsx("input",{type:"checkbox",checked:v.includes(M),onChange:()=>P(M),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"font-mono text-xs",children:M})]},M))})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[a.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>b(!g),children:[a.jsx(Xs,{size:14,className:`transition-transform ${g?"rotate-90":""}`}),"More options"]}),g&&a.jsx("div",{className:"mt-3",children:a.jsx(pn,{label:"Description (optional)",value:o.description,onChange:M=>c({...o,description:M.target.value}),placeholder:"Brief description of this agent"})})]})]})]})}function pa({items:e}){return a.jsx("nav",{className:"flex items-center gap-1.5 text-sm mb-4",children:e.map((t,n)=>{const r=n===e.length-1;return a.jsxs("span",{className:"flex items-center gap-1.5",children:[n>0&&a.jsx(Xs,{size:14,className:"text-[var(--text-secondary)]"}),t.path&&!r?a.jsx(Tn,{to:t.path,className:"text-[var(--text-secondary)] hover:text-[var(--accent)] transition-colors",children:t.label}):a.jsx("span",{className:r?"text-[var(--text-primary)] font-medium":"text-[var(--text-secondary)]",children:t.label})]},n)})})}function ge({children:e,className:t="",onClick:n,selected:r=!1,selectable:s=!1}){const i="bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",l=s?"cursor-pointer hover:border-[var(--accent-dim)] transition-colors":"",o=r?"border-[var(--accent)]":"";return a.jsx("div",{className:`${i} ${l} ${o} ${t}`,onClick:n,children:e})}function t1(e){const t=[],n=r=>r.type==="trace_span"&&typeof r.data=="object"&&r.data!==null?r.data:"span_id"in r?r:null;if(Array.isArray(e.spans)){for(const r of e.spans)if(typeof r=="object"&&r!==null){const s=n(r);s&&t.push(s)}}else if(e.span_id)t.push(e);else for(const r in e){const s=e[r];if(typeof s=="object"&&s!==null){const i=n(s);if(i)t.push(i);else if(Array.isArray(s)){for(const l of s)if(typeof l=="object"&&l!==null){const o=n(l);o&&t.push(o)}}}}return t}function ep(e){const t=new Map,n=[];for(const s of e)t.set(s.span_id,{span:s,children:[]});for(const s of e){const i=t.get(s.span_id);s.parent_span_id&&t.has(s.parent_span_id)?t.get(s.parent_span_id).children.push(i):n.push(i)}const r=s=>{s.sort((i,l)=>(i.span.start_time||0)-(l.span.start_time||0)),s.forEach(i=>r(i.children))};return r(n),n}function n1(e){return e.includes("Agent")||e.includes("agent")?"bg-[var(--span-llm-bg)] text-[var(--span-llm-text)]":e.includes("chat")||e.includes("Chat")||e.includes("llm")?"bg-[var(--span-tool-bg)] text-[var(--span-tool-text)]":e.includes("tool")||e.includes("execute")||e.includes("bash")?"bg-[var(--span-agent-bg)] text-[var(--span-agent-text)]":"bg-[var(--span-other-bg)] text-[var(--span-other-text)]"}function r1(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(0)}ms`}function eu({node:e,depth:t=0}){var u,m;const[n,r]=j.useState(t<2),[s,i]=j.useState(!1),{span:l}=e,o=e.children.length>0,c=(u=l.attributes)==null?void 0:u["gen_ai.usage.input_tokens"],d=(m=l.attributes)==null?void 0:m["gen_ai.usage.output_tokens"],f=c!==void 0||d!==void 0;return a.jsxs("div",{className:"relative",children:[t>0&&a.jsx("div",{className:"absolute left-0 top-0 bottom-0 border-l-2 border-[var(--border)]",style:{marginLeft:`${(t-1)*16+8}px`}}),a.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-1 hover:bg-[var(--bg-primary)] rounded transition-colors cursor-pointer",style:{paddingLeft:`${t*16}px`},onClick:()=>o?r(!n):i(!s),children:[a.jsx("div",{className:"w-4 h-4 flex items-center justify-center text-[var(--text-secondary)]",children:o?n?"▼":"▶":s?"▼":"▶"}),a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${n1(l.operation_name)}`,children:l.operation_name.replace("ChatAgent.","").replace("invoke_agent ","")}),l.duration_ms!==void 0&&a.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:r1(l.duration_ms)}),f&&a.jsxs("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:[c!==void 0&&a.jsxs("span",{className:"text-blue-400",children:["↑",String(c)]}),c!==void 0&&d!==void 0&&a.jsx("span",{className:"mx-0.5",children:"/"}),d!==void 0&&a.jsxs("span",{className:"text-green-400",children:["↓",String(d)]})]})]}),s&&!o&&a.jsx("div",{className:"ml-4 mt-1 mb-2 p-2 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs",style:{marginLeft:`${t*16+20}px`},children:a.jsxs("div",{className:"space-y-1",children:[l.span_id&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Span ID:"}),a.jsx("span",{className:"font-mono text-xs break-all",children:l.span_id})]}),l.trace_id&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Trace ID:"}),a.jsx("span",{className:"font-mono text-xs break-all",children:l.trace_id})]}),l.status&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Status:"}),a.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs ${l.status==="OK"||l.status==="StatusCode.UNSET"?"bg-[var(--span-pass-bg)] text-[var(--span-pass-text)]":"bg-[var(--span-fail-bg)] text-[var(--span-fail-text)]"}`,children:l.status})]}),Object.keys(l.attributes||{}).length>0&&a.jsxs("div",{className:"mt-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] block mb-1",children:"Attributes:"}),a.jsx("pre",{className:"text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded p-2 overflow-auto max-h-32 whitespace-pre-wrap break-all",children:JSON.stringify(l.attributes,null,2)})]})]})}),o&&n&&a.jsx("div",{children:e.children.map((v,k)=>a.jsx(eu,{node:v,depth:t+1},v.span.span_id||k))})]})}function tp({trace:e}){const[t,n]=j.useState("tree"),r=j.useMemo(()=>t1(e),[e]),s=j.useMemo(()=>ep(r),[r]);return Object.keys(e).length===0?null:a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"font-medium",children:"Trace Data"}),a.jsxs("div",{className:"flex gap-1",children:[a.jsx("button",{onClick:()=>n("tree"),className:`px-2 py-1 text-xs rounded ${t==="tree"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Tree"}),a.jsx("button",{onClick:()=>n("raw"),className:`px-2 py-1 text-xs rounded ${t==="raw"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Raw"})]})]}),t==="tree"?r.length>0?a.jsx("div",{className:"border border-[var(--border)] rounded overflow-hidden",children:a.jsxs("div",{className:"p-2",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs(W,{variant:"default",children:[r.length," spans"]}),a.jsx("span",{children:"•"}),a.jsx("span",{children:"Click to expand details"})]}),s.map((i,l)=>a.jsx(eu,{node:i,depth:0},i.span.span_id||l))]})}):a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No structured spans found. View raw data below."}):a.jsx("pre",{className:"text-xs bg-[var(--bg-primary)] p-3 overflow-x-auto border border-[var(--border)] max-h-96 whitespace-pre-wrap",children:JSON.stringify(e,null,2)})]})}function s1({spans:e,isLive:t=!1}){const n=j.useRef(null),r=j.useMemo(()=>ep(e),[e]);return j.useEffect(()=>{n.current&&t&&n.current.scrollTo({top:n.current.scrollHeight,behavior:"smooth"})},[e.length,t]),a.jsxs("div",{className:"border border-[var(--border)] rounded overflow-hidden h-full flex flex-col",children:[a.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-[var(--border)] bg-[var(--bg-secondary)]",children:[a.jsxs(W,{variant:"default",children:[e.length," spans"]}),t&&a.jsx("span",{className:"animate-pulse",children:a.jsx(W,{variant:"info",children:"Live"})})]}),a.jsx("div",{ref:n,className:"flex-1 overflow-auto p-2",children:r.length>0?r.map((s,i)=>a.jsx(eu,{node:s,depth:0},s.span.span_id||i)):a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:t?"Waiting for spans...":"No spans recorded"})})]})}function np({agent:e}){const[t,n]=j.useState(""),[r,s]=j.useState(null),[i,l]=j.useState("idle"),[o,c]=j.useState(null),[d,f]=j.useState(""),[u,m]=j.useState([]),[v,k]=j.useState(null),[g,b]=j.useState(null),[p,h]=j.useState([]),[x,w]=j.useState(!1),C=j.useRef(null),{data:S=[]}=le({queryKey:["tasks"],queryFn:()=>gt.list()});j.useEffect(()=>{C.current&&i==="running"&&(C.current.scrollTop=C.current.scrollHeight)},[d,i]);const N=D=>{if(s(D),D){const G=S.find(X=>X.id===D);G&&n(G.prompt)}},_=async()=>{if(t.trim()){l("running"),f(""),m([]),k(null),b(null),h([]);try{const D=await Os.create({agent_id:e.id,prompt:t.trim(),task_id:r||void 0});c(D.id);for await(const G of Os.start(D.id))F(G)}catch(D){b(D instanceof Error?D.message:"Test failed"),l("failed")}}},F=D=>{switch(D.event){case"started":break;case"execution":D.execution_event==="text_delta"&&D.content?f(G=>G+D.content):D.execution_event==="tool_call_start"&&D.tool_name?h(G=>[...G,{name:D.tool_name}]):D.execution_event==="tool_result"&&D.content&&h(G=>{if(G.length>0){const X=[...G];return X[X.length-1]={...X[X.length-1],content:D.content},X}return G});break;case"span":if(D.span){const G=D.span;if(G.data){const X={span_id:G.data.span_id||"",trace_id:G.data.trace_id||"",parent_span_id:G.data.parent_span_id||null,operation_name:G.data.operation_name||"",start_time:G.timestamp?new Date(G.timestamp).getTime():Date.now(),end_time:Date.now(),duration_ms:G.data.duration_ms||0,status:G.data.status||"OK",attributes:G.data.attributes||{}};m(P=>[...P,X])}}break;case"complete":l("completed"),D.result&&k(D.result);break;case"error":b(D.message),l("failed");break}},O=async()=>{if(o)try{await Os.cancel(o)}catch{}l("idle")},Q=()=>{l("idle"),c(null),f(""),m([]),k(null),b(null),h([])},J=i==="running",re=i==="completed"||i==="failed",oe=D=>{D.preventDefault(),re?(Q(),setTimeout(()=>_(),0)):_()};return a.jsxs("div",{className:"h-full flex flex-col border border-[var(--border)] rounded-lg overflow-hidden bg-[var(--bg-primary)]",children:[(J||re)&&a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border)] bg-[var(--bg-secondary)] flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[J&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"animate-pulse",children:a.jsx(W,{variant:"info",children:"Running"})}),a.jsx(V,{variant:"ghost",size:"sm",icon:Ld,onClick:O,children:"Cancel"})]}),i==="completed"&&a.jsx(W,{variant:"success",children:"Completed"}),i==="failed"&&a.jsx(W,{variant:"error",children:"Failed"})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[v&&a.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Im,{size:12}),v.duration_seconds.toFixed(2),"s"]}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Mg,{size:12}),v.tokens_total," tokens"]}),v.passed!==null&&(v.passed?a.jsx(Fm,{size:14,className:"text-[var(--success)]"}):a.jsx(Xg,{size:14,className:"text-[var(--error)]"}))]}),u.length>0&&a.jsxs(V,{variant:x?"primary":"secondary",size:"sm",icon:Sg,onClick:()=>w(!x),children:["Traces (",u.length,")"]}),re&&o&&a.jsx(Tn,{to:`/tests/${o}`,children:a.jsx(V,{variant:"secondary",size:"sm",icon:Am,children:"Details"})})]})]}),a.jsxs("div",{className:"flex-1 min-h-0 flex",children:[a.jsx("div",{ref:C,className:`flex-1 overflow-auto p-4 ${x?"border-r border-[var(--border)]":""}`,children:!J&&!re?a.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center",children:[a.jsx("div",{className:"text-lg font-medium mb-1",children:e.name}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] max-w-sm",children:"Send a message to test this agent, or select a task from the dropdown below."})]}):a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"flex justify-end",children:a.jsx("div",{className:"max-w-[80%] px-3 py-2 bg-[var(--accent-dim)] text-[var(--text-primary)] rounded-lg text-sm",children:t})}),(d||J)&&a.jsx("div",{className:"px-3 py-2 text-sm whitespace-pre-wrap font-mono bg-[var(--bg-secondary)] rounded-lg border border-[var(--border)]",children:d||a.jsx("span",{className:"text-[var(--text-secondary)] animate-pulse",children:"Thinking..."})}),p.length>0&&a.jsx("div",{className:"space-y-1.5",children:p.map((D,G)=>a.jsxs("div",{className:"p-2 bg-[var(--badge-info-bg)] border border-[var(--badge-info-border)] rounded-md text-xs",children:[a.jsx(W,{variant:"info",children:D.name}),D.content&&a.jsxs("div",{className:"mt-1 text-[var(--text-secondary)] truncate max-w-full font-mono",children:[D.content.substring(0,200),D.content.length>200&&"..."]})]},G))}),g&&a.jsx("div",{className:"p-3 bg-[var(--badge-error-bg)] border border-[var(--badge-error-border)] rounded-md text-sm text-[var(--badge-error-text)]",children:g})]})}),x&&a.jsx("div",{className:"w-[350px] flex-shrink-0 overflow-auto",children:a.jsx(s1,{spans:u,isLive:J})})]}),a.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] bg-[var(--bg-secondary)]",children:[a.jsx("div",{className:"px-4 pt-2",children:a.jsxs("select",{value:r||"",onChange:D=>N(D.target.value||null),className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs text-[var(--text-secondary)]",disabled:J,children:[a.jsx("option",{value:"",children:"Custom prompt..."}),S.map(D=>a.jsx("option",{value:D.id,children:D.name},D.id))]})}),a.jsxs("form",{onSubmit:oe,className:"p-3 flex gap-2",children:[a.jsx("textarea",{value:t,onChange:D=>n(D.target.value),placeholder:"Message the agent...",disabled:J,rows:1,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm resize-none min-h-[40px] max-h-[120px] focus:outline-none focus:border-[var(--accent)]",onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),oe(D))}}),a.jsx(V,{type:"submit",variant:"primary",icon:J?Ld:Zs,disabled:J?!1:!t.trim(),onClick:J?O:void 0,children:J?"Stop":re?"New Test":"Run"})]})]})]})}function a1(){const{agentId:e}=ha(),t=zn(),n=Wt(),[r,s]=j.useState("overview"),[i,l]=j.useState(!1),{data:o,isLoading:c}=le({queryKey:["configs",e],queryFn:()=>_n.get(e),enabled:!!e}),{data:d=[]}=le({queryKey:["tests",{agent_id:e}],queryFn:()=>Os.list({agent_id:e}),enabled:!!e}),{data:f=[]}=le({queryKey:["jobs"],queryFn:()=>Ot.list()}),u=Je({mutationFn:v=>_n.delete(v),onSuccess:()=>{n.invalidateQueries({queryKey:["configs"]}),t("/agents")}}),m=f.filter(v=>v.candidate_ids.includes(e||""));return c?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):o?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsxs("div",{className:"mb-4 flex-shrink-0",children:[a.jsx(pa,{items:[{label:"Agents",path:"/agents"},{label:o.name}]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:o.name}),o.is_auto_generated&&a.jsx(W,{variant:"info",children:"Auto-generated"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(V,{variant:"primary",icon:ss,size:"sm",onClick:()=>l(!0),children:"Optimize"}),a.jsx(V,{variant:"secondary",icon:Wc,size:"sm",onClick:()=>{confirm(`Delete agent "${o.name}"?`)&&u.mutate(o.id)},children:"Delete"})]})]}),o.description&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:o.description})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsxs("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:[a.jsxs("div",{className:"flex gap-1 mb-4 border-b border-[var(--border)] flex-shrink-0",children:[a.jsx(Sl,{active:r==="overview",onClick:()=>s("overview"),icon:a.jsx(Bm,{size:14}),children:"Overview"}),a.jsx(Sl,{active:r==="evaluate",onClick:()=>s("evaluate"),icon:a.jsx(Zs,{size:14}),children:"Evaluate"}),a.jsx(Sl,{active:r==="history",onClick:()=>s("history"),icon:a.jsx(Ag,{size:14}),badge:d.length,children:"History"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r==="overview"&&a.jsx(i1,{agent:o,recentTests:d,jobs:m}),r==="evaluate"&&a.jsx(l1,{agent:o,jobs:m}),r==="history"&&a.jsx(o1,{tests:d})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[a.jsx(Um,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),a.jsx("div",{className:"flex-1 min-h-0",children:a.jsx(np,{agent:o})})]})]}),i&&a.jsx(Zm,{agent:o,isOpen:i,onClose:()=>l(!1)})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Agent not found"})}function Sl({active:e,onClick:t,icon:n,badge:r,children:s}){return a.jsxs("button",{onClick:t,className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors ${e?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[n,s,r!==void 0&&r>0&&a.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs bg-[var(--bg-tertiary)] rounded",children:r})]})}function i1({agent:e,recentTests:t,jobs:n}){var i,l;const r=e.config,s=()=>{const o=r.tools;return typeof o=="string"?o:Array.isArray(o)?o.join(", "):o&&typeof o=="object"?Object.keys(o).join(", "):"standard"};return a.jsxs("div",{className:"space-y-4",children:[a.jsx(fr,{title:"Model",children:a.jsx("div",{className:"font-mono text-sm",children:r.model||"default"})}),a.jsx(fr,{title:"Instructions",defaultCollapsed:!r.instructions,children:r.instructions?a.jsx("pre",{className:"p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs whitespace-pre-wrap max-h-40 overflow-auto font-mono",children:r.instructions}):a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No instructions set"})}),a.jsx(fr,{title:"Tools",children:a.jsx("div",{className:"font-mono text-sm",children:s()})}),a.jsx(fr,{title:"Compaction",children:a.jsx("div",{className:"font-mono text-sm",children:!r.compaction||r.compaction.strategy==="none"?"disabled":`${r.compaction.strategy} (${((i=r.compaction.params)==null?void 0:i.head_size)||0}/${((l=r.compaction.params)==null?void 0:l.tail_size)||0})`})}),t.length>0&&a.jsx(fr,{title:`Recent Tests (${t.length})`,children:a.jsx("div",{className:"space-y-1.5",children:t.slice(0,3).map(o=>a.jsxs(Tn,{to:`/tests/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx(rp,{status:o.status}),a.jsxs("span",{className:"truncate",children:[o.prompt.slice(0,40),"..."]})]}),a.jsxs("span",{className:"text-[var(--text-secondary)] flex-shrink-0 ml-2",children:[o.duration_seconds.toFixed(1),"s"]})]},o.id))})}),n.length>0&&a.jsx(fr,{title:`Experiments (${n.length})`,children:a.jsx("div",{className:"space-y-1.5",children:n.slice(0,3).map(o=>a.jsxs(Tn,{to:`/jobs/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(W,{variant:o.status==="completed"?"success":o.status==="running"?"info":"default",children:o.status}),a.jsx("span",{children:o.name})]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(o.created_at).toLocaleDateString()})]},o.id))})})]})}function fr({title:e,children:t,defaultCollapsed:n=!1}){const[r,s]=j.useState(n);return a.jsxs("div",{className:"border-b border-[var(--border)] pb-3",children:[a.jsxs("button",{onClick:()=>s(!r),className:"flex items-center justify-between w-full text-left py-1 hover:text-[var(--accent)] transition-colors",children:[a.jsx("span",{className:"text-sm font-medium",children:e}),a.jsx("span",{className:"text-[var(--text-secondary)] text-xs",children:r?"▶":"▼"})]}),!r&&a.jsx("div",{className:"mt-2",children:t})]})}function l1({agent:e,jobs:t}){const n=zn(),r=Wt(),[s,i]=j.useState("quick"),[l,o]=j.useState(!1),{data:c=[]}=le({queryKey:["suites"],queryFn:()=>gt.listSuites()}),d=Je({mutationFn:P0.start,onSuccess:u=>{r.invalidateQueries({queryKey:["jobs"]}),o(!1),n(`/jobs/${u.id}`)},onError:()=>{o(!1)}}),f=()=>{o(!0),d.mutate({agent_id:e.id,suite_name:s,use_llm_eval:!0,parallel:4})};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:"Run this agent on a task suite to measure quality and cost."}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm",value:s,onChange:u=>i(u.target.value),disabled:l,children:c.map(u=>a.jsxs("option",{value:u.name,children:[u.name.charAt(0).toUpperCase()+u.name.slice(1)," (",u.task_count," tasks)"]},u.name))}),a.jsx(V,{variant:"primary",icon:l?ma:Zs,onClick:f,disabled:l,loading:l,className:"w-full",children:"Evaluate"})]})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h4",{className:"text-sm font-medium",children:"Optimization Jobs"}),a.jsx(V,{variant:"secondary",size:"sm",icon:ss,onClick:()=>n("/agents",{state:{optimizeAgent:e}}),children:"New Job"})]}),t.length===0?a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No optimization jobs yet."}):a.jsx("div",{className:"space-y-1.5",children:t.slice(0,5).map(u=>a.jsxs(Tn,{to:`/jobs/${u.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(W,{variant:u.status==="completed"?"success":u.status==="running"?"info":"default",children:u.status}),a.jsx("span",{children:u.name})]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(u.created_at).toLocaleDateString()})]},u.id))})]})]})}function o1({tests:e}){return e.length===0?a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No test history yet. Use the playground on the right to run a test."}):a.jsx("div",{className:"space-y-2",children:e.map(t=>a.jsxs(Tn,{to:`/tests/${t.id}`,className:"flex items-center justify-between p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(rp,{status:t.status}),t.score!==null&&a.jsxs("span",{className:`text-sm font-medium ${t.passed?"text-[var(--success)]":"text-[var(--error)]"}`,children:[(t.score*100).toFixed(0),"%"]})]}),a.jsx("p",{className:"text-sm truncate",children:t.prompt})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1 ml-4",children:[a.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:new Date(t.created_at).toLocaleString()}),a.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:[t.duration_seconds.toFixed(1),"s"]}),a.jsxs("span",{children:[t.tokens_total," tokens"]})]})]})]},t.id))})}function rp({status:e}){const t={completed:"success",failed:"error",running:"info",cancelled:"warning",pending:"default"};return a.jsx(W,{variant:t[e]||"default",children:e})}function c1(){const e=Wt(),[t,n]=j.useState(!1),[r,s]=j.useState(!1),[i,l]=j.useState(null),[o,c]=j.useState(new Set),d=p=>{c(h=>{const x=new Set(h);return x.has(p)?x.delete(p):x.add(p),x})},{data:f=[],isLoading:u}=le({queryKey:["tasks"],queryFn:()=>gt.list()}),m=Je({mutationFn:gt.create,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),n(!1)}}),v=Je({mutationFn:gt.importSuite,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),s(!1)}}),k=Je({mutationFn:gt.delete,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),l(null)}}),g=f.reduce((p,h)=>{const x=h.suite||"custom";return p[x]||(p[x]=[]),p[x].push(h),p},{}),b=Object.keys(g).sort((p,h)=>p==="custom"?-1:h==="custom"?1:p.localeCompare(h));return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Datasets"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Task datasets for evaluating agent configurations."})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(V,{variant:"secondary",onClick:()=>s(!0),children:"Import Suite"}),a.jsx(V,{variant:"primary",onClick:()=>n(!0),children:"+ New Task"})]})]}),u?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):f.length===0?a.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:"No tasks yet. Create one or import a built-in suite."}):a.jsx("div",{className:"space-y-4",children:b.map(p=>{const h=g[p],x=!o.has(p);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>d(p),className:"flex items-center gap-2 py-2 hover:text-[var(--accent)] transition-colors",children:[x?a.jsx(Og,{size:16,className:"text-[var(--text-secondary)]"}):a.jsx(Xs,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium uppercase tracking-wide",children:p==="custom"?"Custom Tasks":`${p} Suite`}),a.jsx(W,{variant:p==="custom"?"default":"info",children:h.length})]}),x&&a.jsx("div",{className:"mt-2 border border-[var(--border)] rounded-lg overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:[a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Name"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Category"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Prompt"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Criteria"})]})}),a.jsx("tbody",{children:h.map(w=>a.jsxs("tr",{onClick:()=>l(w),className:"border-b border-[var(--border)] last:border-b-0 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors",children:[a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:w.name})}),a.jsx("td",{className:"px-4 py-3",children:w.category&&w.category!=="default"?a.jsx(W,{variant:"default",children:w.category}):a.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"})}),a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-[var(--text-secondary)] line-clamp-1 max-w-md",children:w.prompt})}),a.jsx("td",{className:"px-4 py-3 text-[var(--text-secondary)]",children:w.criteria.length>0?w.criteria.length:"--"})]},w.id))})]})})]},p)})}),a.jsx(u1,{task:i,onClose:()=>l(null),onDelete:p=>{confirm("Delete this task?")&&k.mutate(p)}}),a.jsx(d1,{isOpen:t,onClose:()=>n(!1),onSubmit:p=>m.mutate(p),isLoading:m.isPending}),a.jsx(f1,{isOpen:r,onClose:()=>s(!1),onSubmit:p=>v.mutate(p),isLoading:v.isPending})]})}function u1({task:e,onClose:t,onDelete:n}){const[r,s]=j.useState("prompt");if(!e)return null;const i=a.jsxs("div",{className:"flex justify-between",children:[a.jsx(V,{variant:"ghost",onClick:()=>n(e.id),className:"text-red-500 hover:text-red-600",children:"Delete Task"}),a.jsx(V,{variant:"secondary",onClick:t,children:"Close"})]});return a.jsx(as,{isOpen:!!e,onClose:t,title:e.name,size:"lg",footer:i,children:a.jsxs("div",{className:"space-y-4",children:[e.category&&e.category!=="default"&&a.jsx("div",{children:a.jsx(W,{variant:"default",children:e.category})}),a.jsxs("div",{className:"flex gap-1 border-b border-[var(--border)]",children:[a.jsx("button",{onClick:()=>s("prompt"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="prompt"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Prompt"}),a.jsxs("button",{onClick:()=>s("criteria"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="criteria"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:["Eval Criteria (",e.criteria.length,")"]})]}),r==="prompt"&&a.jsx("div",{className:"p-4 bg-[var(--bg-tertiary)] rounded text-sm whitespace-pre-wrap min-h-[200px]",children:e.prompt}),r==="criteria"&&a.jsx("div",{className:"space-y-2 min-h-[200px]",children:e.criteria.length===0?a.jsx("div",{className:"text-[var(--text-secondary)] text-sm p-4",children:"No evaluation criteria defined for this task."}):e.criteria.map(l=>a.jsxs("div",{className:"p-3 bg-[var(--bg-tertiary)] rounded",children:[a.jsx("div",{className:"font-medium text-sm",children:l.name}),l.instruction&&a.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1",children:l.instruction})]},l.name))})]})})}function d1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,i]=j.useState({name:"",prompt:"",criteria:[],category:"default"}),l=()=>{i({...s,criteria:[...s.criteria,{name:"",instruction:"",weight:1}]})},o=(f,u)=>{const m=[...s.criteria];m[f]={...m[f],...u},i({...s,criteria:m})},c=f=>{i({...s,criteria:s.criteria.filter((u,m)=>m!==f)})},d=f=>{f.preventDefault(),!(!s.name.trim()||!s.prompt.trim())&&n({...s,criteria:s.criteria.filter(u=>u.name.trim()&&u.instruction.trim())})};return a.jsx(as,{isOpen:e,onClose:t,title:"Create Task",children:a.jsxs("form",{onSubmit:d,className:"space-y-4",children:[a.jsx(pn,{label:"Name",value:s.name,onChange:f=>i({...s,name:f.target.value}),placeholder:"e.g., fizzbuzz",required:!0}),a.jsx(q0,{label:"Prompt",value:s.prompt,onChange:f=>i({...s,prompt:f.target.value}),placeholder:"The task description for the agent...",required:!0}),a.jsx(pn,{label:"Category",value:s.category,onChange:f=>i({...s,category:f.target.value}),placeholder:"e.g., coding, research"}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Evaluation Criteria"}),a.jsx(V,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"+ Add"})]}),a.jsx("div",{className:"space-y-2",children:s.criteria.map((f,u)=>a.jsxs("div",{className:"flex gap-2 items-start",children:[a.jsx(pn,{value:f.name,onChange:m=>o(u,{name:m.target.value}),placeholder:"Name",className:"w-32"}),a.jsx(pn,{value:f.instruction,onChange:m=>o(u,{instruction:m.target.value}),placeholder:"Instruction",className:"flex-1"}),a.jsx(V,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(u),children:"×"})]},u))})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[a.jsx(V,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(V,{type:"submit",variant:"primary",disabled:r||!s.name.trim()||!s.prompt.trim(),children:r?"Creating...":"Create"})]})]})})}function f1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,i]=j.useState(""),{data:l=[],isLoading:o}=le({queryKey:["suites"],queryFn:()=>gt.listSuites(),enabled:e});return j.useEffect(()=>{l.length>0&&!s&&i(l[0].name)},[l,s]),a.jsx(as,{isOpen:e,onClose:t,title:"Import Task Suite",children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Import a built-in task suite for evaluation."}),o?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading suites..."}):l.length===0?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"No suites available."}):a.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:l.map(c=>a.jsxs("label",{className:`flex items-center gap-3 p-3 border cursor-pointer ${s===c.name?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[a.jsx("input",{type:"radio",name:"suite",value:c.name,checked:s===c.name,onChange:()=>i(c.name),className:"accent-[var(--accent)]"}),a.jsxs("span",{className:"capitalize",children:[c.name.replace(/_/g," ")," (",c.task_count," tasks) - ",c.description]})]},c.name))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[a.jsx(V,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(V,{variant:"primary",onClick:()=>n(s),disabled:r||!s,children:r?"Importing...":"Import"})]})]})})}const h1=Ki(e=>({jobs:[],setJobs:t=>e({jobs:t})}));function m1(){const e=zn(),t=Wt(),[n,r]=j.useState(!1),{setJobs:s}=h1(),i=Xc(),{data:l=[],isLoading:o}=le({queryKey:["jobs",n],queryFn:()=>Ot.list({include_public:n}),refetchInterval:5e3});j.useEffect(()=>{l.length>0&&s(l)},[l,s]);const c=Je({mutationFn:Ot.delete,onSuccess:()=>t.invalidateQueries({queryKey:["jobs"]})}),d={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"},f=[{key:"name",header:"Name",render:u=>a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:u.name||`Job ${u.id.slice(0,8)}`}),u.is_public&&a.jsx(Hc,{className:"w-3 h-3 ml-2 inline text-[var(--text-secondary)]"})]})},{key:"status",header:"Status",render:u=>a.jsx(W,{variant:d[u.status]||"default",children:u.status})},{key:"candidates",header:"Candidates",render:u=>a.jsx("span",{children:u.candidate_ids.length})},{key:"tasks",header:"Tasks",render:u=>a.jsx("span",{children:u.task_ids.length})},{key:"runs",header:"Runs",render:u=>a.jsxs("span",{children:[u.completed_experiments,"/",u.total_experiments]})},{key:"created",header:"Created",render:u=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(u.created_at).toLocaleDateString()}),sortable:!0,sortValue:u=>new Date(u.created_at).getTime()},{key:"actions",header:"",className:"w-12",render:u=>!u.user_id||u.user_id==="anonymous"||i&&u.created_by_name===i?a.jsx("div",{onClick:v=>v.stopPropagation(),children:a.jsx(V,{variant:"ghost",size:"sm",icon:Wc,title:"Delete",disabled:u.status==="running",onClick:()=>{confirm("Delete this job?")&&c.mutate(u.id)}})}):null}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Experiments"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"View and manage optimization experiments. Start new experiments from the Agents page."})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Ni,{label:"Show public",checked:n,onChange:u=>r(u.target.checked)}),a.jsx(V,{variant:"secondary",onClick:()=>e("/agents"),children:"Go to Agents"})]})]}),o?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):a.jsx(Xm,{columns:f,data:l,onRowClick:u=>e(`/jobs/${u.id}`),searchable:!0,searchPlaceholder:"Search experiments",searchFilter:(u,m)=>(u.name||"").toLowerCase().includes(m.toLowerCase())||u.id.toLowerCase().includes(m.toLowerCase()),emptyMessage:"No experiments yet. Go to Agents page to start an optimization."})]})}function p1(e,t=!0){return Math.abs(e)<10?"text-[var(--text-secondary)]":(t?e<0:e>0)?"text-green-400":"text-red-400"}function x1(e){return`${e>0?"+":""}${e.toFixed(1)}%`}function sp(e,t){return t===0?0:(e-t)/t*100}function xs({label:e,values:t,baselineIndex:n,formatter:r,isLowerBetter:s=!0}){const i=t[n];return a.jsxs("tr",{className:"border-b border-[var(--border)] last:border-0",children:[a.jsx("td",{className:"py-2 pr-4 text-[var(--text-secondary)] text-sm",children:e}),t.map((l,o)=>{const c=sp(l,i),d=o===n;return a.jsxs("td",{className:"py-2 px-4 text-right",children:[a.jsx("div",{className:"font-mono",children:r(l)}),!d&&a.jsx("div",{className:`text-xs ${p1(c,s)}`,children:x1(c)}),d&&a.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"(baseline)"})]},o)})]})}function v1({runs:e,baselineRunId:t}){const n=j.useMemo(()=>{if(t){const i=e.findIndex(l=>l.id===t);if(i>=0)return i}return 0},[e,t]);if(e.length<2)return null;const r=Math.min(...e.map(i=>i.tokens_total)),s=Math.max(...e.map(i=>i.score));return a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-4",children:"Candidate Comparison"}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-[var(--border)]",children:[a.jsx("th",{className:"pb-2 pr-4 text-left text-[var(--text-secondary)] font-medium",children:"Metric"}),e.map((i,l)=>a.jsx("th",{className:"pb-2 px-4 text-right",children:a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsx("span",{className:"font-medium",children:i.candidate_name}),i.is_pareto&&a.jsx(W,{variant:"success",children:"Optimal"}),l===n&&a.jsx(W,{variant:"info",children:"Base"})]})},i.id))]})}),a.jsxs("tbody",{children:[a.jsx(xs,{label:"Total Tokens",values:e.map(i=>i.tokens_total),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(xs,{label:"Input Tokens",values:e.map(i=>i.tokens_input),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(xs,{label:"Output Tokens",values:e.map(i=>i.tokens_output),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(xs,{label:"Duration",values:e.map(i=>i.duration_seconds),baselineIndex:n,formatter:i=>`${i.toFixed(1)}s`,isLowerBetter:!0}),a.jsx(xs,{label:"Score",values:e.map(i=>i.score*100),baselineIndex:n,formatter:i=>`${i.toFixed(1)}%`,isLowerBetter:!1})]})]})}),a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[a.jsx("h4",{className:"text-sm font-medium mb-2 text-[var(--text-secondary)]",children:"Key Insights"}),a.jsxs("ul",{className:"text-sm space-y-1 text-[var(--text-secondary)]",children:[e.map(i=>{const l=sp(i.tokens_total,e[n].tokens_total);return i.tokens_total===r&&l<-5?a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-green-400",children:"✓"}),a.jsxs("span",{children:[a.jsx("strong",{children:i.candidate_name})," uses ",Math.abs(l).toFixed(0),"% fewer tokens"]})]},`token-${i.id}`):null}),e.map(i=>i.score===s&&i.passed?a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-green-400",children:"✓"}),a.jsxs("span",{children:[a.jsx("strong",{children:i.candidate_name})," achieved highest score (",(i.score*100).toFixed(0),"%)"]})]},`score-${i.id}`):null),e.filter(i=>i.is_pareto).length>0&&a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-purple-400",children:"★"}),a.jsxs("span",{children:["Optimal candidates (best tradeoff):"," ",e.filter(i=>i.is_pareto).map(i=>i.candidate_name).join(", ")]})]})]})]}),a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[a.jsx("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:"Token Efficiency"}),a.jsx("div",{className:"space-y-2",children:e.map(i=>{const l=i.tokens_total/e[n].tokens_total*100,o=i.tokens_total<=r;return a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-24 text-sm truncate",title:i.candidate_name,children:i.candidate_name}),a.jsx("div",{className:"flex-1 h-6 bg-[var(--bg-primary)] rounded overflow-hidden",children:a.jsx("div",{className:`h-full transition-all duration-300 ${o?"bg-green-500":"bg-blue-500"}`,style:{width:`${Math.min(l,100)}%`}})}),a.jsx("div",{className:"w-20 text-right font-mono text-sm",children:i.tokens_total.toLocaleString()})]},i.id)})})]})]})}function y1({summaries:e,height:t=350}){const n=j.useRef(null),[r,s]=j.useState(600),[i,l]=j.useState("tokens"),[o,c]=j.useState(null),[d,f]=j.useState({x:0,y:0});j.useEffect(()=>{const S=()=>{n.current&&s(n.current.clientWidth)};return S(),window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]);const u={top:30,right:30,bottom:50,left:60},m=r-u.left-u.right,v=t-u.top-u.bottom,k=S=>i==="tokens"?S.avg_tokens:S.avg_duration,{xScale:g,yScale:b,xTicks:p,yTicks:h,paretoLine:x}=j.useMemo(()=>{if(e.length===0||m<=0)return{xScale:()=>0,yScale:()=>0,xTicks:[],yTicks:[],paretoLine:[]};const S=e.map(k),N=e.map(P=>P.avg_score),_=Math.min(...S)*.9,F=Math.max(...S)*1.1,O=Math.min(...N,.5),Q=Math.min(Math.max(...N)*1.05,1),J=P=>(P-_)/(F-_)*m,re=P=>v-(P-O)/(Q-O)*v,oe=Array.from({length:5},(P,A)=>_+A/4*(F-_)),D=Array.from({length:5},(P,A)=>O+A/4*(Q-O)),X=e.filter(P=>P.is_pareto).sort((P,A)=>k(P)-k(A)).map(P=>({x:J(k(P)),y:re(P.avg_score)}));return{xScale:J,yScale:re,xTicks:oe,yTicks:D,paretoLine:X}},[e,m,v,i]);if(e.length===0)return a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No data to display"});const w=S=>i==="tokens"?S>=1e6?`${(S/1e6).toFixed(1)}M`:S>=1e3?`${(S/1e3).toFixed(0)}K`:S.toFixed(0):`${S.toFixed(1)}s`,C=(S,N)=>{var F;const _=(F=n.current)==null?void 0:F.getBoundingClientRect();_&&f({x:N.clientX-_.left,y:N.clientY-_.top}),c(S)};return a.jsxs("div",{ref:n,className:"w-full relative",children:[a.jsx("div",{className:"flex justify-end mb-2",children:a.jsxs("div",{className:"inline-flex rounded border border-[var(--border)] text-xs",children:[a.jsx("button",{className:`px-3 py-1 ${i==="tokens"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("tokens"),children:"Tokens"}),a.jsx("button",{className:`px-3 py-1 ${i==="duration"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("duration"),children:"Latency"})]})}),a.jsx("svg",{width:r,height:t,className:"font-mono text-xs",children:a.jsxs("g",{transform:`translate(${u.left}, ${u.top})`,children:[p.map((S,N)=>a.jsx("line",{x1:g(S),y1:0,x2:g(S),y2:v,stroke:"var(--border)",strokeDasharray:"2,2"},`x-grid-${N}`)),h.map((S,N)=>a.jsx("line",{x1:0,y1:b(S),x2:m,y2:b(S),stroke:"var(--border)",strokeDasharray:"2,2"},`y-grid-${N}`)),x.length>1&&a.jsx("polyline",{points:x.map(S=>`${S.x},${S.y}`).join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.slice().sort((S,N)=>(S.is_pareto?1:0)-(N.is_pareto?1:0)).map(S=>{const N=g(k(S)),_=b(S.avg_score),F=S.is_pareto,O=(o==null?void 0:o.candidate_name)===S.candidate_name;return a.jsxs("g",{onMouseEnter:Q=>C(S,Q),onMouseLeave:()=>c(null),children:[a.jsx("circle",{cx:N,cy:_,r:O?10:F?8:6,fill:F?"var(--accent)":"transparent",stroke:O?"var(--text-primary)":F?"var(--accent)":"var(--text-secondary)",strokeWidth:O?3:2,className:"cursor-pointer transition-all"}),F&&!O&&a.jsx("text",{x:N,y:_-12,textAnchor:"middle",fill:"var(--text-primary)",fontSize:10,className:"pointer-events-none",children:S.candidate_name.replace(/^baseline_/,"").slice(0,15)})]},S.candidate_name)}),a.jsx("line",{x1:0,y1:v,x2:m,y2:v,stroke:"var(--text-secondary)"}),p.map((S,N)=>a.jsxs("g",{transform:`translate(${g(S)}, ${v})`,children:[a.jsx("line",{y2:5,stroke:"var(--text-secondary)"}),a.jsx("text",{y:20,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:10,children:w(S)})]},`x-tick-${N}`)),a.jsx("text",{x:m/2,y:v+40,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:i==="tokens"?"Tokens (cost)":"Duration (latency)"}),a.jsx("line",{x1:0,y1:0,x2:0,y2:v,stroke:"var(--text-secondary)"}),h.map((S,N)=>a.jsxs("g",{transform:`translate(0, ${b(S)})`,children:[a.jsx("line",{x2:-5,stroke:"var(--text-secondary)"}),a.jsxs("text",{x:-10,textAnchor:"end",dominantBaseline:"middle",fill:"var(--text-secondary)",fontSize:10,children:[(S*100).toFixed(0),"%"]})]},`y-tick-${N}`)),a.jsx("text",{transform:`translate(-45, ${v/2}) rotate(-90)`,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:"Score (quality)"})]})}),o&&a.jsxs("div",{className:"absolute z-10 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg shadow-lg p-3 text-sm pointer-events-none",style:{left:Math.min(d.x+15,r-200),top:d.y-10,maxWidth:220},children:[a.jsx("div",{className:"font-medium text-[var(--text-primary)] truncate mb-2",children:o.candidate_name.replace(/^baseline_/,"")}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Score:"}),a.jsxs("span",{className:"text-right font-medium",children:[(o.avg_score*100).toFixed(1),"%"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tokens:"}),a.jsxs("span",{className:"text-right",children:[(o.avg_tokens/1e3).toFixed(1),"K"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Duration:"}),a.jsxs("span",{className:"text-right",children:[o.avg_duration.toFixed(1),"s"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Pass rate:"}),a.jsxs("span",{className:"text-right",children:[o.passed_runs,"/",o.total_runs]})]}),o.is_pareto&&a.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)] text-xs text-[var(--accent)]",children:"Optimal (best tradeoff)"})]})]})}function g1(e=2e3){const[t,n]=j.useState(!1),[r,s]=j.useState(null),i=j.useCallback(async o=>{try{return await navigator.clipboard.writeText(o),n(!0),s(null),setTimeout(()=>n(!1),e),!0}catch{return s("Failed to copy to clipboard"),n(!1),!1}},[e]),l=j.useCallback(()=>{n(!1),s(null)},[]);return{copy:i,copied:t,error:r,reset:l}}function j1({isOpen:e,onClose:t,title:n,itemId:r,itemType:s,isPublic:i,createdByName:l,onTogglePublic:o}){const[c,d]=j.useState(!1),{copy:f,copied:u}=g1(),m=`${window.location.origin}/${s}s/${r}`,v=async()=>{d(!0);try{await o(!i)}finally{d(!1)}},k=()=>{f(m)};return a.jsx(as,{isOpen:e,onClose:t,title:n,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between p-3 bg-[var(--bg-tertiary)] rounded",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[i?a.jsx(Hc,{className:"w-5 h-5 text-[var(--accent)]"}):a.jsx($m,{className:"w-5 h-5 text-[var(--text-secondary)]"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium",children:i?"Public":"Private"}),a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:i?"Anyone with the link can view":"Only you can access"})]})]}),a.jsx("button",{onClick:v,disabled:c,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${i?"bg-[var(--accent)]":"bg-[var(--border)]"} ${c?"opacity-50 cursor-not-allowed":""}`,children:a.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${i?"translate-x-6":"translate-x-1"}`})})]}),i&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Share link"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",readOnly:!0,value:m,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono"}),a.jsx(V,{variant:"secondary",onClick:k,children:u?a.jsxs(a.Fragment,{children:[a.jsx(Tg,{className:"w-4 h-4 mr-1"}),"Copied"]}):a.jsxs(a.Fragment,{children:[a.jsx(zg,{className:"w-4 h-4 mr-1"}),"Copy"]})})]})]}),l&&a.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",a.jsx("span",{className:"text-[var(--text-primary)]",children:l})]}),a.jsx("div",{className:"text-xs text-[var(--text-secondary)] pt-2 border-t border-[var(--border)]",children:i?a.jsxs(a.Fragment,{children:[a.jsxs("p",{children:["Public ",s,"s can be viewed by anyone with the link."]}),a.jsxs("p",{className:"mt-1",children:["Only you can edit or delete this ",s,"."]})]}):a.jsxs("p",{children:["Make this ",s," public to share it with others."]})})]})})}function w1({job:e,onUpdate:t}){const[n,r]=j.useState(!1),s=async i=>{await Ot.update(e.id,{is_public:i}),t()};return a.jsxs(a.Fragment,{children:[a.jsxs(V,{variant:"secondary",size:"sm",onClick:()=>r(!0),title:e.is_public?"Sharing settings":"Share this job",children:[a.jsx(qg,{className:"w-4 h-4 mr-1"}),e.is_public?"Shared":"Share"]}),a.jsx(j1,{isOpen:n,onClose:()=>r(!1),title:"Share Job",itemId:e.id,itemType:"job",isPublic:e.is_public,createdByName:e.created_by_name,onTogglePublic:s})]})}function k1(){const{jobId:e}=ha(),t=zn(),n=Wt(),[r,s]=j.useState(null),[i,l]=j.useState(!1),[o,c]=j.useState(null),[d,f]=j.useState([]),[u,m]=j.useState(null),[v,k]=j.useState(null),[g,b]=j.useState("results"),[p,h]=j.useState("score"),[x,w]=j.useState("desc"),[C,S]=j.useState(!1),{data:N,isLoading:_}=le({queryKey:["jobs",e],queryFn:()=>Ot.get(e),enabled:!!e,refetchInterval:i?2e3:!1}),{data:F=[]}=le({queryKey:["runs",e],queryFn:()=>Uo.list({job_id:e}),enabled:!!e,refetchInterval:i?2e3:!1}),{data:O}=le({queryKey:["job-summary",e],queryFn:()=>Uo.getJobSummary(e),enabled:!!e&&(N==null?void 0:N.status)==="completed"}),Q=Je({mutationFn:async()=>{l(!0),f([]),m(null),k(null);for await(const R of Ot.start(e))s(R),R.current_candidate&&R.current_task&&m(T=>(T&&(T.candidate!==R.current_candidate||T.task!==R.current_task)&&f(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),{candidate:R.current_candidate,task:R.current_task})),R.event==="error"&&(k(R.message),l(!1),n.invalidateQueries({queryKey:["jobs",e]})),R.event==="complete"&&(m(T=>(T&&f(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),null)),l(!1),n.invalidateQueries({queryKey:["jobs",e]}),n.invalidateQueries({queryKey:["runs",e]}),n.invalidateQueries({queryKey:["job-summary",e]}))}}),J=Je({mutationFn:()=>Ot.cancel(e),onSuccess:()=>{l(!1),n.invalidateQueries({queryKey:["jobs",e]})}});j.useEffect(()=>{(N==null?void 0:N.status)==="running"&&l(!0)},[N==null?void 0:N.status]);const re=j.useMemo(()=>{const R=new Map;for(const T of F)R.has(T.task_name)||R.set(T.task_name,[]),R.get(T.task_name).push(T);return R},[F]),oe=j.useMemo(()=>Array.from(re.keys()),[re]);j.useEffect(()=>{!o&&oe.length>0&&c(oe[0])},[oe,o]);const D=j.useMemo(()=>{if(!(O!=null&&O.candidate_summaries))return[];let R=[...O.candidate_summaries];return C&&(R=R.filter(T=>T.is_pareto)),R.sort((T,te)=>{let pe,Se;switch(p){case"score":pe=T.avg_score,Se=te.avg_score;break;case"tokens":pe=T.avg_tokens,Se=te.avg_tokens;break;case"duration":pe=T.avg_duration,Se=te.avg_duration;break;case"pass_rate":pe=T.passed_runs/T.total_runs,Se=te.passed_runs/te.total_runs;break}return x==="desc"?Se-pe:pe-Se}),R},[O,p,x,C]),G=R=>{p===R?w(x==="desc"?"asc":"desc"):(h(R),w(R==="tokens"||R==="duration"?"asc":"desc"))},X=({label:R,sortKeyVal:T})=>a.jsx("th",{className:"pb-2 cursor-pointer hover:text-[var(--text-primary)] select-none",onClick:()=>G(T),children:a.jsxs("div",{className:"flex items-center gap-1",children:[R,p===T&&a.jsx(_g,{size:12,className:x==="asc"?"rotate-180":""})]})});if(_)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!N)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Job not found"});const P=Xc(),A=!N.user_id||N.user_id==="anonymous"||P&&N.created_by_name===P,L=N.is_public&&!A,K=()=>{n.invalidateQueries({queryKey:["jobs",e]})},ee=R=>{const T={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};return a.jsx(W,{variant:T[R]||"default",children:R})};return a.jsxs("div",{children:[a.jsx(pa,{items:[{label:"Experiments",path:"/jobs"},{label:N.name||`Job ${N.id.slice(0,8)}`}]}),a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:N.name||`Job ${N.id.slice(0,8)}`}),ee(N.status),N.is_public&&a.jsxs(W,{variant:"info",children:[a.jsx(Hc,{className:"w-3 h-3 mr-1 inline"}),"Public"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[a.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-2 py-0.5 rounded font-mono text-[var(--text-secondary)]",children:[N.id.slice(0,8),"..."]}),a.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[N.candidate_ids.length," candidates × ",N.task_ids.length," tasks = ",N.total_experiments," experiments"]}),N.is_public&&N.created_by_name&&a.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",a.jsx("span",{className:"text-[var(--text-primary)]",children:N.created_by_name})]})]})]}),a.jsxs("div",{className:"flex gap-2",children:[A&&a.jsx(w1,{job:N,onUpdate:K}),L&&a.jsx(W,{variant:"default",children:"View Only"}),A&&N.status==="pending"&&a.jsx(V,{variant:"primary",onClick:()=>Q.mutate(),disabled:Q.isPending,children:Q.isPending?"Starting...":"Start"}),A&&N.status==="running"&&a.jsx(V,{variant:"danger",onClick:()=>J.mutate(),disabled:J.isPending,children:"Cancel"})]})]}),(v||N.error)&&a.jsx(ge,{className:"mb-6 border-red-500/50 bg-red-500/10",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"w-5 h-5 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-0.5",children:"!"}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-red-400",children:"Error"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:v||N.error})]})]})}),(i||r)&&a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"font-medium",children:"Progress"}),a.jsxs("span",{className:"text-[var(--accent)]",children:[(r==null?void 0:r.completed)||N.completed_experiments,"/",(r==null?void 0:r.total)||N.total_experiments]})]}),a.jsx("div",{className:"w-full bg-[var(--bg-primary)] h-2 mb-2",children:a.jsx("div",{className:"h-full bg-[var(--accent)] transition-all",style:{width:`${((r==null?void 0:r.completed)||N.completed_experiments)/((r==null?void 0:r.total)||N.total_experiments)*100}%`}})}),(r==null?void 0:r.message)&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r.message}),i&&a.jsxs("div",{className:"mt-4 border-t border-[var(--border)] pt-4",children:[(r==null?void 0:r.current_candidate)&&(r==null?void 0:r.current_task)&&a.jsxs("div",{className:"mb-3",children:[a.jsx("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:"Currently Running"}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 px-3 py-2 bg-blue-500/10 border border-blue-500/30 rounded",children:[a.jsx("div",{className:"w-2 h-2 bg-blue-400 rounded-full animate-pulse"}),a.jsx("span",{className:"font-medium",children:r.current_candidate}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{children:r.current_task})]})]}),d.length>0&&a.jsxs("div",{children:[a.jsxs("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:["Completed (",d.length,")"]}),a.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto space-y-1",children:d.map((R,T)=>a.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-500/10 border border-green-500/30 rounded text-sm",children:[a.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}),a.jsx("span",{className:"font-medium",children:R.candidate_name}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{children:R.task_name})]},`${R.candidate_name}-${R.task_name}-${T}`))})]})]})]}),(N.status==="completed"||F.length>0)&&a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-[var(--border)]",children:[a.jsxs("button",{onClick:()=>b("results"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="results"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Eg,{size:16}),"Results"]}),a.jsxs("button",{onClick:()=>b("compare"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="compare"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Ig,{size:16}),"Compare"]}),a.jsxs("button",{onClick:()=>b("runs"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="runs"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Ug,{size:16}),"Runs (",F.length,")"]})]}),g==="results"&&a.jsxs(a.Fragment,{children:[O&&O.candidate_summaries.length>1&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("div",{className:"flex items-start justify-between mb-4",children:a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium",children:"Quality vs. Cost Tradeoff"}),a.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:["Candidates on the frontier (connected line) are ",a.jsx("strong",{children:"optimal"})," - no other candidate beats them on both score AND cost."]})]})}),a.jsxs("div",{className:"mb-4 p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs text-[var(--text-secondary)]",children:[a.jsx("strong",{className:"text-[var(--text-primary)]",children:"How optimal tradeoffs are calculated:"})," A candidate is optimal if there's no other candidate that has both a higher score AND lower cost. For example, if Candidate A has 95% score at 50K tokens and Candidate B has 90% score at 40K tokens, both are optimal - A is better on score, B is better on cost. But if Candidate C has 85% score at 60K tokens, it's ",a.jsx("em",{children:"not"})," optimal because B beats it on both metrics."]}),a.jsx(y1,{summaries:O.candidate_summaries,height:350})]}),O&&a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h3",{className:"font-medium",children:"Results Summary"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C,onChange:R=>S(R.target.checked),className:"rounded border-[var(--border)]"}),"Optimal only"]})]}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-left text-[var(--text-secondary)] border-b border-[var(--border)]",children:[a.jsx("th",{className:"pb-2",children:"Candidate"}),a.jsx(X,{label:"Score",sortKeyVal:"score"}),a.jsx(X,{label:"Tokens",sortKeyVal:"tokens"}),a.jsx(X,{label:"Duration",sortKeyVal:"duration"}),a.jsx(X,{label:"Pass Rate",sortKeyVal:"pass_rate"}),a.jsx("th",{className:"pb-2",children:"Optimal"})]})}),a.jsx("tbody",{children:D.map((R,T)=>a.jsxs("tr",{className:`border-b border-[var(--border)] ${T===0?"bg-[var(--accent)]/10":""}`,children:[a.jsxs("td",{className:"py-2 font-medium",children:[T===0&&a.jsx("span",{className:"text-[var(--accent)] mr-1",children:"#1"}),R.candidate_name.replace(/^baseline_/,"")]}),a.jsxs("td",{className:"py-2",children:[(R.avg_score*100).toFixed(1),"%"]}),a.jsxs("td",{className:"py-2",children:[(R.avg_tokens/1e3).toFixed(1),"K"]}),a.jsxs("td",{className:"py-2",children:[R.avg_duration.toFixed(1),"s"]}),a.jsxs("td",{className:"py-2",children:[R.passed_runs,"/",R.total_runs]}),a.jsx("td",{className:"py-2",children:R.is_pareto&&a.jsx(W,{variant:"success",children:"Optimal"})})]},R.candidate_name))})]})}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-3",children:"Click column headers to sort. The #1 ranked candidate is highlighted based on your sort criteria."})]}),!O&&a.jsx(ge,{children:a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Results will appear here after the job completes.":"No results yet. Start the job to see results."})})]}),g==="compare"&&a.jsxs(ge,{children:[a.jsx("h3",{className:"font-medium mb-4",children:"Compare Candidates by Task"}),oe.length>0?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:oe.map(R=>a.jsx("button",{onClick:()=>c(o===R?null:R),className:`px-3 py-1 text-sm rounded border transition-colors ${o===R?"bg-[var(--accent)] text-white border-[var(--accent)]":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:R},R))}),o&&re.get(o)?a.jsx(v1,{runs:re.get(o).map(R=>({id:R.id,candidate_name:R.candidate_name,tokens_input:0,tokens_output:0,tokens_total:R.tokens_total,duration_seconds:R.duration_seconds,score:R.score,passed:R.passed,is_pareto:R.is_pareto}))}):a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"Select a task above to compare how different candidates performed on it."})]}):a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Comparison data will appear here after runs complete.":"No runs yet. Start the job to compare candidates."})]}),g==="runs"&&a.jsxs(ge,{children:[a.jsx("h3",{className:"font-medium mb-4",children:"All Experiment Runs"}),F.length===0?a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Runs will appear here as they complete. See progress above for live status.":"No runs yet. Start the job to see results."}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:F.map(R=>a.jsxs("div",{className:"p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] cursor-pointer hover:border-[var(--accent-dim)] transition-colors",onClick:()=>t(`/runs/${R.id}`),children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:`text-lg font-bold ${R.passed?"text-green-400":"text-red-400"}`,children:[(R.score*100).toFixed(0),"%"]}),R.is_pareto&&a.jsx(W,{variant:"success",children:"Optimal"})]}),a.jsx("div",{className:"text-sm font-medium truncate",title:R.candidate_name,children:R.candidate_name.replace(/^baseline_/,"")}),a.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:R.task_name}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:[(R.tokens_total/1e3).toFixed(1),"K tokens"]}),a.jsxs("span",{children:[R.duration_seconds.toFixed(1),"s"]})]})]},R.id))})]})]})}const xn={input:"bg-blue-500",output:"bg-emerald-500",inputText:"text-blue-400",outputText:"text-emerald-400"};function Id(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Dd({input:e,output:t,maxValue:n,height:r=24,showLabels:s=!0}){const i=e+t;if(i===0)return a.jsx("div",{className:"flex items-center gap-2 w-full",children:a.jsx("div",{className:"rounded bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`}})});const l=n>0?i/n*100:100;return a.jsxs("div",{className:"flex items-center gap-3 w-full",children:[a.jsx("div",{className:"relative rounded overflow-hidden bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`},children:a.jsxs("div",{className:"h-full flex transition-all duration-300",style:{width:`${l}%`},children:[a.jsx("div",{className:`h-full ${xn.input} transition-all`,style:{width:`${e/i*100}%`},title:`Input: ${e.toLocaleString()} tokens`}),a.jsx("div",{className:`h-full ${xn.output} transition-all`,style:{width:`${t/i*100}%`},title:`Output: ${t.toLocaleString()} tokens`})]})}),s&&a.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono text-[var(--text-secondary)] min-w-[90px] justify-end",children:[a.jsxs("span",{className:xn.inputText,children:["↑",Id(e)]}),a.jsx("span",{children:"/"}),a.jsxs("span",{className:xn.outputText,children:["↓",Id(t)]})]})]})}function Cl({label:e,value:t,color:n="default"}){const r={default:"text-[var(--text-primary)]",input:xn.inputText,output:xn.outputText}[n];return a.jsxs("div",{className:"flex-1 p-3 bg-[var(--bg-primary)] border border-[var(--border)] rounded",children:[a.jsx("div",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e}),a.jsx("div",{className:`font-mono text-lg font-bold ${r}`,children:t})]})}function ap({tokensInput:e,tokensOutput:t,tokensTotal:n,turns:r}){const s=n>0?Math.round(e/n*100):0,i=n>0?Math.round(t/n*100):0,l=j.useMemo(()=>{if(!r||r.length===0)return null;let c=0,d=0;return r.map(f=>(c+=f.input,d+=f.output,{input:c,output:d,total:c+d}))},[r]),o=l?Math.max(...l.map(c=>c.total)):n;return a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-4",children:"Token Usage"}),a.jsx("div",{className:"mb-4",children:a.jsx(Dd,{input:e,output:t,maxValue:n,height:32})}),a.jsxs("div",{className:"flex items-center gap-6 text-xs mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-3 h-3 rounded ${xn.input}`}),a.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Input (",s,"%)"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-3 h-3 rounded ${xn.output}`}),a.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Output (",i,"%)"]})]})]}),a.jsxs("div",{className:"flex gap-3 mb-4",children:[a.jsx(Cl,{label:"Input Tokens",value:e.toLocaleString(),color:"input"}),a.jsx(Cl,{label:"Output Tokens",value:t.toLocaleString(),color:"output"}),a.jsx(Cl,{label:"Total Tokens",value:n.toLocaleString()})]}),l&&l.length>1&&a.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[a.jsxs("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:["Token Accumulation (",r.length," turns)"]}),a.jsx("div",{className:"space-y-2",children:r.map((c,d)=>a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--bg-primary)] border border-[var(--border)] flex items-center justify-center text-xs font-medium",children:d+1}),a.jsx("div",{className:"flex-1",children:a.jsx(Dd,{input:l[d].input,output:l[d].output,maxValue:o,height:16})})]},d))})]}),a.jsx("div",{className:"mt-4 text-xs text-[var(--text-secondary)] border-t border-[var(--border)] pt-3",children:"Token usage affects API cost. Input tokens are typically cheaper than output tokens."})]})}function b1(){const{runId:e}=ha(),{data:t,isLoading:n}=le({queryKey:["runs",e],queryFn:()=>Uo.get(e),enabled:!!e});return n?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsx(pa,{items:[{label:"Experiments",path:"/jobs"},{label:"Job",path:`/jobs/${t.job_id}`},{label:t.candidate_name}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:t.candidate_name}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{className:"text-lg",children:t.task_name}),t.is_pareto&&a.jsx(W,{variant:"success",children:"Optimal"})]})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[a.jsx(za,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),a.jsx(za,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),a.jsx(za,{label:"Duration",value:`${t.duration_seconds.toFixed(1)}s`}),a.jsx(za,{label:"Status",value:t.passed?"Passed":"Failed",status:t.passed?"success":"error"})]}),a.jsx(ap,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),t.reasoning&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:t.reasoning}),t.criteria_results.length>0&&a.jsx("div",{className:"space-y-2",children:t.criteria_results.map(r=>a.jsx("div",{className:"flex items-start justify-between p-3 bg-[var(--bg-primary)] border border-[var(--border)]",children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-medium",children:r.name}),a.jsxs(W,{variant:r.passed?"success":"error",children:[(r.score*100).toFixed(0),"%"]})]}),r.reasoning&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r.reasoning})]})},r.name))})]}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created.length>0&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),a.jsx("div",{className:"space-y-1",children:t.files_created.map(r=>a.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:r},r))})]}),Object.keys(t.trace).length>0&&a.jsx(tp,{trace:t.trace})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Run not found"})}function za({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return a.jsxs(ge,{children:[a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),a.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function N1(){const{testId:e}=ha(),{data:t,isLoading:n}=le({queryKey:["tests",e],queryFn:()=>Os.get(e),enabled:!!e}),{data:r}=le({queryKey:["configs",t==null?void 0:t.agent_id],queryFn:()=>_n.get(t.agent_id),enabled:!!(t!=null&&t.agent_id)});if(n)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!t)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Test not found"});const s={completed:"success",failed:"error",running:"info",pending:"default",cancelled:"warning"};return a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsx(pa,{items:[{label:"Agents",path:"/agents"},...r?[{label:r.name,path:`/agents/${r.id}`}]:[],{label:`Test ${t.id.slice(0,8)}`}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:"Test Run"}),r&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"•"}),a.jsx("span",{className:"text-lg",children:r.name})]}),a.jsx(W,{variant:s[t.status]||"default",children:t.status})]}),a.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:["ID: ",t.id.slice(0,8),"..."]})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[a.jsx(Fa,{label:"Duration",value:`${t.duration_seconds.toFixed(2)}s`}),a.jsx(Fa,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),t.score!==null&&a.jsx(Fa,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),a.jsx(Fa,{label:"Status",value:t.status.charAt(0).toUpperCase()+t.status.slice(1),status:t.status==="completed"?"success":t.status==="failed"?"error":void 0})]}),a.jsx(ap,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Prompt"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)] font-mono",children:t.prompt})]}),t.error&&a.jsxs(ge,{className:"mb-6 border-red-500/30 bg-red-500/5",children:[a.jsx("h3",{className:"font-medium mb-3 text-red-400",children:"Error"}),a.jsx("pre",{className:"text-sm text-red-300 overflow-x-auto whitespace-pre-wrap",children:t.error})]}),t.reasoning&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.reasoning})]}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created&&t.files_created.length>0&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),a.jsx("div",{className:"space-y-1",children:t.files_created.map(i=>a.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:i},i))})]}),t.trace&&Object.keys(t.trace).length>0&&a.jsx(tp,{trace:t.trace}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Timestamps"}),a.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Created:"}),a.jsx("div",{className:"font-mono",children:new Date(t.created_at).toLocaleString()})]}),t.started_at&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Started:"}),a.jsx("div",{className:"font-mono",children:new Date(t.started_at).toLocaleString()})]}),t.completed_at&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Completed:"}),a.jsx("div",{className:"font-mono",children:new Date(t.completed_at).toLocaleString()})]})]})]})]})}function Fa({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return a.jsxs(ge,{children:[a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),a.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function S1(){const{deploymentId:e}=ha(),{data:t,isLoading:n}=le({queryKey:["deployments",e],queryFn:()=>E0.get(e),enabled:!!e}),r=t==null?void 0:t.versions.find(i=>i.id===t.current_version_id),{data:s}=le({queryKey:["configs",r==null?void 0:r.config_id],queryFn:()=>_n.get(r.config_id),enabled:!!(r!=null&&r.config_id)});return n?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsxs("div",{className:"mb-4 flex-shrink-0",children:[a.jsx(pa,{items:[{label:"Agents",path:"/agents"},{label:t.name}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Kg,{size:20,className:"text-[var(--accent)]"}),a.jsx("h2",{className:"text-xl font-bold",children:t.name}),r&&a.jsxs(W,{variant:"info",children:["v",r.version]})]}),t.description&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:t.description})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsx("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-5",children:[a.jsxs("div",{className:"flex items-center gap-4 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:["Created ",new Date(t.created_at).toLocaleDateString()]}),a.jsxs("span",{children:["Updated ",new Date(t.updated_at).toLocaleDateString()]}),a.jsxs("span",{children:[t.versions.length," version",t.versions.length!==1?"s":""]})]}),s&&a.jsxs(Tn,{to:`/agents/${s.id}`,className:"flex items-center gap-2 p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-sm",children:[a.jsx(Am,{size:14,className:"text-[var(--accent)]"}),a.jsxs("span",{children:["Agent: ",a.jsx("span",{className:"font-medium",children:s.name})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider mb-3",children:"Version History"}),t.versions.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"No versions yet."}):a.jsx("div",{className:"space-y-2",children:t.versions.map(i=>a.jsx(C1,{version:i,isActive:i.id===t.current_version_id},i.id))})]})]})}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[a.jsx(Um,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),a.jsx("div",{className:"flex-1 min-h-0",children:s?a.jsx(np,{agent:s}):a.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-secondary)] text-sm",children:r?"Loading agent configuration...":"No active version to test."})})]})]})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Deployment not found"})}function C1({version:e,isActive:t}){const n=e.config_snapshot;return a.jsxs("div",{className:`p-3 rounded-md border transition-colors ${t?"border-[var(--accent)] bg-[var(--accent-dim)]":"border-[var(--border)] bg-[var(--bg-secondary)]"}`,children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Jg,{size:12,className:"text-[var(--text-secondary)]"}),a.jsxs("span",{className:"text-sm font-medium",children:["v",e.version]}),t&&a.jsx(W,{variant:"success",children:"Active"}),a.jsx(W,{variant:e.source==="optimize"?"info":"default",children:e.source})]}),a.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)]",children:[a.jsx(Im,{size:11}),a.jsx("span",{children:new Date(e.created_at).toLocaleString()})]})]}),e.description&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e.description}),Object.keys(n).length>0&&a.jsxs("div",{className:"mt-1",children:[a.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)] mb-1",children:[a.jsx(Fg,{size:11}),a.jsx("span",{children:"Config"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-xs",children:["framework"in n&&n.framework?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Framework"}),a.jsx("span",{className:"font-mono",children:String(n.framework)})]}):null,"model"in n&&n.model?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Model"}),a.jsx("span",{className:"font-mono",children:String(n.model)})]}):null,"tools"in n&&n.tools?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tools"}),a.jsx("span",{className:"font-mono truncate",children:Array.isArray(n.tools)?n.tools.join(", "):String(n.tools)})]}):null]})]})]})}function _1(){const{authConfig:e,isLoading:t,error:n,login:r,loginWithGitHub:s,clearError:i}=Zc(),[l,o]=j.useState(""),[c,d]=j.useState("");j.useEffect(()=>{n&&i()},[l,c]);const f=async m=>{m.preventDefault(),!(!l||!c)&&await r(l,c)},u=()=>{s()};return a.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:a.jsxs("div",{className:"w-full max-w-md",children:[a.jsxs("div",{className:"text-center mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:"Flow"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:"Sign in to access the optimization dashboard"})]}),a.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] p-6 space-y-6",children:[n&&a.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[var(--error)]/10 border border-[var(--error)]/20 text-[var(--error)]",children:[a.jsx(zm,{size:18,className:"mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-sm",children:n})]}),(e==null?void 0:e.mode)==="basic"&&a.jsxs("form",{onSubmit:f,className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Username"}),a.jsxs("div",{className:"relative",children:[a.jsx(Qm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),a.jsx("input",{type:"text",value:l,onChange:m=>o(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter username",autoComplete:"username",autoFocus:!0})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Password"}),a.jsxs("div",{className:"relative",children:[a.jsx($m,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),a.jsx("input",{type:"password",value:c,onChange:m=>d(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter password",autoComplete:"current-password"})]})]}),a.jsx(V,{type:"submit",variant:"primary",className:"w-full justify-center",loading:t,disabled:!l||!c,children:"Sign In"})]}),(e==null?void 0:e.mode)==="github"&&a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center",children:"Sign in with your GitHub account to continue"}),a.jsx(V,{onClick:u,variant:"secondary",className:"w-full justify-center",icon:Dg,children:"Continue with GitHub"})]})]})]})})}function E1({children:e}){const{authConfig:t,isLoadingConfig:n,isAuthenticated:r,loadAuthConfig:s,handleOAuthCallback:i}=Zc();return j.useEffect(()=>{s()},[s]),j.useEffect(()=>{n||i()},[n,i]),n?a.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center",children:a.jsxs("div",{className:"text-center",children:[a.jsx(ma,{className:"w-8 h-8 animate-spin text-[var(--accent)] mx-auto mb-4"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:"Loading..."})]})}):t!=null&&t.enabled&&!r?a.jsx(_1,{}):a.jsx(a.Fragment,{children:e})}function P1(){return a.jsx(vg,{children:a.jsx(E1,{children:a.jsx(cg,{children:a.jsxs(ht,{path:"/",element:a.jsx($0,{}),children:[a.jsx(ht,{index:!0,element:a.jsx(B0,{})}),a.jsx(ht,{path:"agents",element:a.jsx(X0,{})}),a.jsx(ht,{path:"agents/:agentId",element:a.jsx(a1,{})}),a.jsx(ht,{path:"tasks",element:a.jsx(c1,{})}),a.jsx(ht,{path:"jobs",element:a.jsx(m1,{})}),a.jsx(ht,{path:"jobs/:jobId",element:a.jsx(k1,{})}),a.jsx(ht,{path:"runs/:runId",element:a.jsx(b1,{})}),a.jsx(ht,{path:"tests/:testId",element:a.jsx(N1,{})}),a.jsx(ht,{path:"deployments/:deploymentId",element:a.jsx(S1,{})})]})})})})}const Ad=localStorage.getItem("flow-theme");if(Ad)try{const{state:e}=JSON.parse(Ad);e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}catch{}const T1=new sy({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}});_l.createRoot(document.getElementById("root")).render(a.jsx(Go.StrictMode,{children:a.jsx(ay,{client:T1,children:a.jsx(P1,{})})})); diff --git a/src/flow/ui/ui/assets/index-DQsgx4t8.js b/src/flow/ui/ui/assets/index-DQsgx4t8.js new file mode 100644 index 0000000000000000000000000000000000000000..060523cef04d6a7bf00674ecef444e95870f16dc --- /dev/null +++ b/src/flow/ui/ui/assets/index-DQsgx4t8.js @@ -0,0 +1,347 @@ +var ru=e=>{throw TypeError(e)};var Wi=(e,t,n)=>t.has(e)||ru("Cannot "+n);var y=(e,t,n)=>(Wi(e,t,"read from private field"),n?n.call(e):t.get(e)),$=(e,t,n)=>t.has(e)?ru("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),M=(e,t,n,r)=>(Wi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),G=(e,t,n)=>(Wi(e,t,"access private method"),n);var va=(e,t,n,r)=>({set _(s){M(e,t,s,n)},get _(){return y(e,t,r)}});function up(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();function Xd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Zd={exports:{}},Ci={},ef={exports:{}},X={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var la=Symbol.for("react.element"),dp=Symbol.for("react.portal"),fp=Symbol.for("react.fragment"),hp=Symbol.for("react.strict_mode"),mp=Symbol.for("react.profiler"),pp=Symbol.for("react.provider"),xp=Symbol.for("react.context"),vp=Symbol.for("react.forward_ref"),yp=Symbol.for("react.suspense"),gp=Symbol.for("react.memo"),jp=Symbol.for("react.lazy"),su=Symbol.iterator;function wp(e){return e===null||typeof e!="object"?null:(e=su&&e[su]||e["@@iterator"],typeof e=="function"?e:null)}var tf={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},nf=Object.assign,rf={};function es(e,t,n){this.props=e,this.context=t,this.refs=rf,this.updater=n||tf}es.prototype.isReactComponent={};es.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};es.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function sf(){}sf.prototype=es.prototype;function Ho(e,t,n){this.props=e,this.context=t,this.refs=rf,this.updater=n||tf}var qo=Ho.prototype=new sf;qo.constructor=Ho;nf(qo,es.prototype);qo.isPureReactComponent=!0;var au=Array.isArray,af=Object.prototype.hasOwnProperty,Wo={current:null},lf={key:!0,ref:!0,__self:!0,__source:!0};function of(e,t,n){var r,s={},i=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(i=""+t.key),t)af.call(t,r)&&!lf.hasOwnProperty(r)&&(s[r]=t[r]);var o=arguments.length-2;if(o===1)s.children=n;else if(1>>1,te=P[V];if(0>>1;Vs(Ce,T))kes(_e,Ce)?(P[V]=_e,P[ke]=T,V=ke):(P[V]=Ce,P[Q]=T,V=Q);else if(kes(_e,T))P[V]=_e,P[ke]=T,V=ke;else break e}}return A}function s(P,A){var T=P.sortIndex-A.sortIndex;return T!==0?T:P.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var c=[],u=[],d=1,f=null,m=3,v=!1,k=!1,w=!1,b=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,h=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(P){for(var A=n(u);A!==null;){if(A.callback===null)r(u);else if(A.startTime<=P)r(u),A.sortIndex=A.expirationTime,t(c,A);else break;A=n(u)}}function j(P){if(w=!1,x(P),!k)if(n(c)!==null)k=!0,W(C);else{var A=n(u);A!==null&&Z(j,A.startTime-P)}}function C(P,A){k=!1,w&&(w=!1,p(_),_=-1),v=!0;var T=m;try{for(x(A),f=n(c);f!==null&&(!(f.expirationTime>A)||P&&!B());){var V=f.callback;if(typeof V=="function"){f.callback=null,m=f.priorityLevel;var te=V(f.expirationTime<=A);A=e.unstable_now(),typeof te=="function"?f.callback=te:f===n(c)&&r(c),x(A)}else r(c);f=n(c)}if(f!==null)var O=!0;else{var Q=n(u);Q!==null&&Z(j,Q.startTime-A),O=!1}return O}finally{f=null,m=T,v=!1}}var S=!1,N=null,_=-1,z=5,L=-1;function B(){return!(e.unstable_now()-LP||125V?(P.sortIndex=T,t(u,P),n(c)===null&&P===n(u)&&(w?(p(_),_=-1):w=!0,Z(j,T-V))):(P.sortIndex=te,t(c,P),k||v||(k=!0,W(C))),P},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(P){var A=m;return function(){var T=m;m=A;try{return P.apply(this,arguments)}finally{m=T}}}})(hf);ff.exports=hf;var Rp=ff.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Mp=g,rt=Rp;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Pl=Object.prototype.hasOwnProperty,zp=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,lu={},ou={};function Fp(e){return Pl.call(ou,e)?!0:Pl.call(lu,e)?!1:zp.test(e)?ou[e]=!0:(lu[e]=!0,!1)}function Ip(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Dp(e,t,n,r){if(t===null||typeof t>"u"||Ip(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Ke(e,t,n,r,s,i,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=l}var Me={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Me[e]=new Ke(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Me[t]=new Ke(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Me[e]=new Ke(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Me[e]=new Ke(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Me[e]=new Ke(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Me[e]=new Ke(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Me[e]=new Ke(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Me[e]=new Ke(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Me[e]=new Ke(e,5,!1,e.toLowerCase(),null,!1,!1)});var Yo=/[\-:]([a-z])/g;function Xo(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Yo,Xo);Me[t]=new Ke(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Yo,Xo);Me[t]=new Ke(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Yo,Xo);Me[t]=new Ke(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Me[e]=new Ke(e,1,!1,e.toLowerCase(),null,!1,!1)});Me.xlinkHref=new Ke("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Me[e]=new Ke(e,1,!1,e.toLowerCase(),null,!0,!0)});function Zo(e,t,n,r){var s=Me.hasOwnProperty(t)?Me[t]:null;(s!==null?s.type!==0:r||!(2o||s[l]!==i[o]){var c=` +`+s[l].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{Yi=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?ys(e):""}function Ap(e){switch(e.tag){case 5:return ys(e.type);case 16:return ys("Lazy");case 13:return ys("Suspense");case 19:return ys("SuspenseList");case 0:case 2:case 15:return e=Xi(e.type,!1),e;case 11:return e=Xi(e.type.render,!1),e;case 1:return e=Xi(e.type,!0),e;default:return""}}function Rl(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case pr:return"Fragment";case mr:return"Portal";case Tl:return"Profiler";case ec:return"StrictMode";case Ol:return"Suspense";case Ll:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case xf:return(e.displayName||"Context")+".Consumer";case pf:return(e._context.displayName||"Context")+".Provider";case tc:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case nc:return t=e.displayName||null,t!==null?t:Rl(e.type)||"Memo";case tn:t=e._payload,e=e._init;try{return Rl(e(t))}catch{}}return null}function $p(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Rl(t);case 8:return t===ec?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function On(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function yf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Up(e){var t=yf(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(l){r=""+l,i.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ja(e){e._valueTracker||(e._valueTracker=Up(e))}function gf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=yf(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ya(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ml(e,t){var n=t.checked;return pe({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function uu(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=On(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function jf(e,t){t=t.checked,t!=null&&Zo(e,"checked",t,!1)}function zl(e,t){jf(e,t);var n=On(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Fl(e,t.type,n):t.hasOwnProperty("defaultValue")&&Fl(e,t.type,On(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function du(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Fl(e,t,n){(t!=="number"||Ya(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var gs=Array.isArray;function Cr(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=wa.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ms(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var bs={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Bp=["Webkit","ms","Moz","O"];Object.keys(bs).forEach(function(e){Bp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),bs[t]=bs[e]})});function Nf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||bs.hasOwnProperty(e)&&bs[e]?(""+t).trim():t+"px"}function Sf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=Nf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var Qp=pe({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Al(e,t){if(t){if(Qp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function $l(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Ul=null;function rc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Bl=null,_r=null,Er=null;function mu(e){if(e=ua(e)){if(typeof Bl!="function")throw Error(E(280));var t=e.stateNode;t&&(t=Oi(t),Bl(e.stateNode,e.type,t))}}function Cf(e){_r?Er?Er.push(e):Er=[e]:_r=e}function _f(){if(_r){var e=_r,t=Er;if(Er=_r=null,mu(e),t)for(e=0;e>>=0,e===0?32:31-(ex(e)/tx|0)|0}var ka=64,ba=4194304;function js(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function ti(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~s;o!==0?r=js(o):(i&=l,i!==0&&(r=js(i)))}else l=n&~s,l!==0?r=js(l):i!==0&&(r=js(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function oa(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-bt(t),e[t]=n}function ax(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Ss),bu=" ",Nu=!1;function qf(e,t){switch(e){case"keyup":return Rx.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Wf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var xr=!1;function zx(e,t){switch(e){case"compositionend":return Wf(t);case"keypress":return t.which!==32?null:(Nu=!0,bu);case"textInput":return e=t.data,e===bu&&Nu?null:e;default:return null}}function Fx(e,t){if(xr)return e==="compositionend"||!dc&&qf(e,t)?(e=Kf(),Ua=oc=pn=null,xr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Eu(n)}}function Xf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Xf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Zf(){for(var e=window,t=Ya();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ya(e.document)}return t}function fc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Kx(e){var t=Zf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Xf(n.ownerDocument.documentElement,n)){if(r!==null&&fc(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=Pu(n,i);var l=Pu(n,r);s&&l&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,vr=null,Wl=null,_s=null,Gl=!1;function Tu(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Gl||vr==null||vr!==Ya(r)||(r=vr,"selectionStart"in r&&fc(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),_s&&$s(_s,r)||(_s=r,r=si(Wl,"onSelect"),0jr||(e.current=to[jr],to[jr]=null,jr--)}function le(e,t){jr++,to[jr]=e.current,e.current=t}var Ln={},Ae=zn(Ln),Je=zn(!1),nr=Ln;function Kr(e,t){var n=e.type.contextTypes;if(!n)return Ln;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function Ye(e){return e=e.childContextTypes,e!=null}function ii(){de(Je),de(Ae)}function Iu(e,t,n){if(Ae.current!==Ln)throw Error(E(168));le(Ae,t),le(Je,n)}function oh(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(E(108,$p(e)||"Unknown",s));return pe({},n,r)}function li(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ln,nr=Ae.current,le(Ae,e),le(Je,Je.current),!0}function Du(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=oh(e,t,nr),r.__reactInternalMemoizedMergedChildContext=e,de(Je),de(Ae),le(Ae,e)):de(Je),le(Je,n)}var It=null,Li=!1,fl=!1;function ch(e){It===null?It=[e]:It.push(e)}function rv(e){Li=!0,ch(e)}function Fn(){if(!fl&&It!==null){fl=!0;var e=0,t=ie;try{var n=It;for(ie=1;e>=l,s-=l,Bt=1<<32-bt(t)+s|n<_?(z=N,N=null):z=N.sibling;var L=m(p,N,x[_],j);if(L===null){N===null&&(N=z);break}e&&N&&L.alternate===null&&t(p,N),h=i(L,h,_),S===null?C=L:S.sibling=L,S=L,N=z}if(_===x.length)return n(p,N),fe&&An(p,_),C;if(N===null){for(;__?(z=N,N=null):z=N.sibling;var B=m(p,N,L.value,j);if(B===null){N===null&&(N=z);break}e&&N&&B.alternate===null&&t(p,N),h=i(B,h,_),S===null?C=B:S.sibling=B,S=B,N=z}if(L.done)return n(p,N),fe&&An(p,_),C;if(N===null){for(;!L.done;_++,L=x.next())L=f(p,L.value,j),L!==null&&(h=i(L,h,_),S===null?C=L:S.sibling=L,S=L);return fe&&An(p,_),C}for(N=r(p,N);!L.done;_++,L=x.next())L=v(N,p,_,L.value,j),L!==null&&(e&&L.alternate!==null&&N.delete(L.key===null?_:L.key),h=i(L,h,_),S===null?C=L:S.sibling=L,S=L);return e&&N.forEach(function(J){return t(p,J)}),fe&&An(p,_),C}function b(p,h,x,j){if(typeof x=="object"&&x!==null&&x.type===pr&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case ga:e:{for(var C=x.key,S=h;S!==null;){if(S.key===C){if(C=x.type,C===pr){if(S.tag===7){n(p,S.sibling),h=s(S,x.props.children),h.return=p,p=h;break e}}else if(S.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===tn&&Uu(C)===S.type){n(p,S.sibling),h=s(S,x.props),h.ref=hs(p,S,x),h.return=p,p=h;break e}n(p,S);break}else t(p,S);S=S.sibling}x.type===pr?(h=tr(x.props.children,p.mode,j,x.key),h.return=p,p=h):(j=Ga(x.type,x.key,x.props,null,p.mode,j),j.ref=hs(p,h,x),j.return=p,p=j)}return l(p);case mr:e:{for(S=x.key;h!==null;){if(h.key===S)if(h.tag===4&&h.stateNode.containerInfo===x.containerInfo&&h.stateNode.implementation===x.implementation){n(p,h.sibling),h=s(h,x.children||[]),h.return=p,p=h;break e}else{n(p,h);break}else t(p,h);h=h.sibling}h=jl(x,p.mode,j),h.return=p,p=h}return l(p);case tn:return S=x._init,b(p,h,S(x._payload),j)}if(gs(x))return k(p,h,x,j);if(os(x))return w(p,h,x,j);Ta(p,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,h!==null&&h.tag===6?(n(p,h.sibling),h=s(h,x),h.return=p,p=h):(n(p,h),h=gl(x,p.mode,j),h.return=p,p=h),l(p)):n(p,h)}return b}var qr=hh(!0),mh=hh(!1),ui=zn(null),di=null,br=null,xc=null;function vc(){xc=br=di=null}function yc(e){var t=ui.current;de(ui),e._currentValue=t}function so(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Tr(e,t){di=e,xc=br=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Ge=!0),e.firstContext=null)}function ft(e){var t=e._currentValue;if(xc!==e)if(e={context:e,memoizedValue:t,next:null},br===null){if(di===null)throw Error(E(308));br=e,di.dependencies={lanes:0,firstContext:e}}else br=br.next=e;return t}var Bn=null;function gc(e){Bn===null?Bn=[e]:Bn.push(e)}function ph(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,gc(t)):(n.next=s.next,s.next=n),t.interleaved=n,Wt(e,r)}function Wt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var nn=!1;function jc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function xh(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Vt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Nn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ne&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Wt(e,n)}return s=r.interleaved,s===null?(t.next=t,gc(r)):(t.next=s.next,s.next=t),r.interleaved=t,Wt(e,n)}function Qa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ac(e,n)}}function Bu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=l:i=i.next=l,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function fi(e,t,n,r){var s=e.updateQueue;nn=!1;var i=s.firstBaseUpdate,l=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var c=o,u=c.next;c.next=null,l===null?i=u:l.next=u,l=c;var d=e.alternate;d!==null&&(d=d.updateQueue,o=d.lastBaseUpdate,o!==l&&(o===null?d.firstBaseUpdate=u:o.next=u,d.lastBaseUpdate=c))}if(i!==null){var f=s.baseState;l=0,d=u=c=null,o=i;do{var m=o.lane,v=o.eventTime;if((r&m)===m){d!==null&&(d=d.next={eventTime:v,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var k=e,w=o;switch(m=t,v=n,w.tag){case 1:if(k=w.payload,typeof k=="function"){f=k.call(v,f,m);break e}f=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=w.payload,m=typeof k=="function"?k.call(v,f,m):k,m==null)break e;f=pe({},f,m);break e;case 2:nn=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,m=s.effects,m===null?s.effects=[o]:m.push(o))}else v={eventTime:v,lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},d===null?(u=d=v,c=f):d=d.next=v,l|=m;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;m=o,o=m.next,m.next=null,s.lastBaseUpdate=m,s.shared.pending=null}}while(!0);if(d===null&&(c=f),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=d,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);ar|=l,e.lanes=l,e.memoizedState=f}}function Qu(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=ml.transition;ml.transition={};try{e(!1),t()}finally{ie=n,ml.transition=r}}function Rh(){return ht().memoizedState}function lv(e,t,n){var r=Cn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Mh(e))zh(t,n);else if(n=ph(e,t,n,r),n!==null){var s=Qe();Nt(n,e,r,s),Fh(n,t,r)}}function ov(e,t,n){var r=Cn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Mh(e))zh(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var l=t.lastRenderedState,o=i(l,n);if(s.hasEagerState=!0,s.eagerState=o,St(o,l)){var c=t.interleaved;c===null?(s.next=s,gc(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=ph(e,t,s,r),n!==null&&(s=Qe(),Nt(n,e,r,s),Fh(n,t,r))}}function Mh(e){var t=e.alternate;return e===me||t!==null&&t===me}function zh(e,t){Es=mi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Fh(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ac(e,n)}}var pi={readContext:ft,useCallback:ze,useContext:ze,useEffect:ze,useImperativeHandle:ze,useInsertionEffect:ze,useLayoutEffect:ze,useMemo:ze,useReducer:ze,useRef:ze,useState:ze,useDebugValue:ze,useDeferredValue:ze,useTransition:ze,useMutableSource:ze,useSyncExternalStore:ze,useId:ze,unstable_isNewReconciler:!1},cv={readContext:ft,useCallback:function(e,t){return _t().memoizedState=[e,t===void 0?null:t],e},useContext:ft,useEffect:Ku,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ka(4194308,4,Eh.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ka(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ka(4,2,e,t)},useMemo:function(e,t){var n=_t();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=_t();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=lv.bind(null,me,e),[r.memoizedState,e]},useRef:function(e){var t=_t();return e={current:e},t.memoizedState=e},useState:Vu,useDebugValue:Ec,useDeferredValue:function(e){return _t().memoizedState=e},useTransition:function(){var e=Vu(!1),t=e[0];return e=iv.bind(null,e[1]),_t().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=me,s=_t();if(fe){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),Te===null)throw Error(E(349));sr&30||jh(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Ku(kh.bind(null,r,i,e),[e]),r.flags|=2048,Ws(9,wh.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=_t(),t=Te.identifierPrefix;if(fe){var n=Qt,r=Bt;n=(r&~(1<<32-bt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Hs++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[Ot]=t,e[Qs]=r,Hh(e,t,!1,!1),t.stateNode=e;e:{switch(l=$l(n,r),n){case"dialog":ue("cancel",e),ue("close",e),s=r;break;case"iframe":case"object":case"embed":ue("load",e),s=r;break;case"video":case"audio":for(s=0;sJr&&(t.flags|=128,r=!0,ms(i,!1),t.lanes=4194304)}else{if(!r)if(e=hi(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),ms(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!fe)return Fe(t),null}else 2*je()-i.renderingStartTime>Jr&&n!==1073741824&&(t.flags|=128,r=!0,ms(i,!1),t.lanes=4194304);i.isBackwards?(l.sibling=t.child,t.child=l):(n=i.last,n!==null?n.sibling=l:t.child=l,i.last=l)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=je(),t.sibling=null,n=he.current,le(he,r?n&1|2:n&1),t):(Fe(t),null);case 22:case 23:return Mc(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?et&1073741824&&(Fe(t),t.subtreeFlags&6&&(t.flags|=8192)):Fe(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function vv(e,t){switch(mc(t),t.tag){case 1:return Ye(t.type)&&ii(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Wr(),de(Je),de(Ae),bc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return kc(t),null;case 13:if(de(he),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));Hr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return de(he),null;case 4:return Wr(),null;case 10:return yc(t.type._context),null;case 22:case 23:return Mc(),null;case 24:return null;default:return null}}var La=!1,De=!1,yv=typeof WeakSet=="function"?WeakSet:Set,I=null;function Nr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ve(e,t,r)}else n.current=null}function mo(e,t,n){try{n()}catch(r){ve(e,t,r)}}var nd=!1;function gv(e,t){if(Jl=ni,e=Zf(),fc(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var l=0,o=-1,c=-1,u=0,d=0,f=e,m=null;t:for(;;){for(var v;f!==n||s!==0&&f.nodeType!==3||(o=l+s),f!==i||r!==0&&f.nodeType!==3||(c=l+r),f.nodeType===3&&(l+=f.nodeValue.length),(v=f.firstChild)!==null;)m=f,f=v;for(;;){if(f===e)break t;if(m===n&&++u===s&&(o=l),m===i&&++d===r&&(c=l),(v=f.nextSibling)!==null)break;f=m,m=f.parentNode}f=v}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Yl={focusedElem:e,selectionRange:n},ni=!1,I=t;I!==null;)if(t=I,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,I=e;else for(;I!==null;){t=I;try{var k=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(k!==null){var w=k.memoizedProps,b=k.memoizedState,p=t.stateNode,h=p.getSnapshotBeforeUpdate(t.elementType===t.type?w:vt(t.type,w),b);p.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(j){ve(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,I=e;break}I=t.return}return k=nd,nd=!1,k}function Ps(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&mo(t,n,i)}s=s.next}while(s!==r)}}function zi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function po(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Gh(e){var t=e.alternate;t!==null&&(e.alternate=null,Gh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ot],delete t[Qs],delete t[eo],delete t[tv],delete t[nv])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Jh(e){return e.tag===5||e.tag===3||e.tag===4}function rd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Jh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function xo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ai));else if(r!==4&&(e=e.child,e!==null))for(xo(e,t,n),e=e.sibling;e!==null;)xo(e,t,n),e=e.sibling}function vo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(vo(e,t,n),e=e.sibling;e!==null;)vo(e,t,n),e=e.sibling}var Le=null,jt=!1;function Zt(e,t,n){for(n=n.child;n!==null;)Yh(e,t,n),n=n.sibling}function Yh(e,t,n){if(Lt&&typeof Lt.onCommitFiberUnmount=="function")try{Lt.onCommitFiberUnmount(_i,n)}catch{}switch(n.tag){case 5:De||Nr(n,t);case 6:var r=Le,s=jt;Le=null,Zt(e,t,n),Le=r,jt=s,Le!==null&&(jt?(e=Le,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Le.removeChild(n.stateNode));break;case 18:Le!==null&&(jt?(e=Le,n=n.stateNode,e.nodeType===8?dl(e.parentNode,n):e.nodeType===1&&dl(e,n),Ds(e)):dl(Le,n.stateNode));break;case 4:r=Le,s=jt,Le=n.stateNode.containerInfo,jt=!0,Zt(e,t,n),Le=r,jt=s;break;case 0:case 11:case 14:case 15:if(!De&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,l=i.destroy;i=i.tag,l!==void 0&&(i&2||i&4)&&mo(n,t,l),s=s.next}while(s!==r)}Zt(e,t,n);break;case 1:if(!De&&(Nr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){ve(n,t,o)}Zt(e,t,n);break;case 21:Zt(e,t,n);break;case 22:n.mode&1?(De=(r=De)||n.memoizedState!==null,Zt(e,t,n),De=r):Zt(e,t,n);break;default:Zt(e,t,n)}}function sd(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new yv),t.forEach(function(r){var s=Ev.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function pt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=l),r&=~i}if(r=s,r=je()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*wv(r/1960))-r,10e?16:e,xn===null)var r=!1;else{if(e=xn,xn=null,yi=0,ne&6)throw Error(E(331));var s=ne;for(ne|=4,I=e.current;I!==null;){var i=I,l=i.child;if(I.flags&16){var o=i.deletions;if(o!==null){for(var c=0;cje()-Lc?er(e,0):Oc|=n),Xe(e,t)}function am(e,t){t===0&&(e.mode&1?(t=ba,ba<<=1,!(ba&130023424)&&(ba=4194304)):t=1);var n=Qe();e=Wt(e,t),e!==null&&(oa(e,t,n),Xe(e,n))}function _v(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),am(e,n)}function Ev(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),am(e,n)}var im;im=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Je.current)Ge=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Ge=!1,pv(e,t,n);Ge=!!(e.flags&131072)}else Ge=!1,fe&&t.flags&1048576&&uh(t,ci,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ha(e,t),e=t.pendingProps;var s=Kr(t,Ae.current);Tr(t,n),s=Sc(null,t,r,e,s,n);var i=Cc();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Ye(r)?(i=!0,li(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,jc(t),s.updater=Mi,t.stateNode=s,s._reactInternals=t,io(t,r,e,n),t=co(null,t,r,!0,i,n)):(t.tag=0,fe&&i&&hc(t),Ue(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ha(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=Tv(r),e=vt(r,e),s){case 0:t=oo(null,t,r,e,n);break e;case 1:t=Zu(null,t,r,e,n);break e;case 11:t=Yu(null,t,r,e,n);break e;case 14:t=Xu(null,t,r,vt(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:vt(r,s),oo(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:vt(r,s),Zu(e,t,r,s,n);case 3:e:{if(Qh(t),e===null)throw Error(E(387));r=t.pendingProps,i=t.memoizedState,s=i.element,xh(e,t),fi(t,r,null,n);var l=t.memoizedState;if(r=l.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=Gr(Error(E(423)),t),t=ed(e,t,r,n,s);break e}else if(r!==s){s=Gr(Error(E(424)),t),t=ed(e,t,r,n,s);break e}else for(tt=bn(t.stateNode.containerInfo.firstChild),nt=t,fe=!0,wt=null,n=mh(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Hr(),r===s){t=Gt(e,t,n);break e}Ue(e,t,r,n)}t=t.child}return t;case 5:return vh(t),e===null&&ro(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,l=s.children,Xl(r,s)?l=null:i!==null&&Xl(r,i)&&(t.flags|=32),Bh(e,t),Ue(e,t,l,n),t.child;case 6:return e===null&&ro(t),null;case 13:return Vh(e,t,n);case 4:return wc(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=qr(t,null,r,n):Ue(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:vt(r,s),Yu(e,t,r,s,n);case 7:return Ue(e,t,t.pendingProps,n),t.child;case 8:return Ue(e,t,t.pendingProps.children,n),t.child;case 12:return Ue(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,l=s.value,le(ui,r._currentValue),r._currentValue=l,i!==null)if(St(i.value,l)){if(i.children===s.children&&!Je.current){t=Gt(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var o=i.dependencies;if(o!==null){l=i.child;for(var c=o.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=Vt(-1,n&-n),c.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),so(i.return,n,t),o.lanes|=n;break}c=c.next}}else if(i.tag===10)l=i.type===t.type?null:i.child;else if(i.tag===18){if(l=i.return,l===null)throw Error(E(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),so(l,n,t),l=i.sibling}else l=i.child;if(l!==null)l.return=i;else for(l=i;l!==null;){if(l===t){l=null;break}if(i=l.sibling,i!==null){i.return=l.return,l=i;break}l=l.return}i=l}Ue(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Tr(t,n),s=ft(s),r=r(s),t.flags|=1,Ue(e,t,r,n),t.child;case 14:return r=t.type,s=vt(r,t.pendingProps),s=vt(r.type,s),Xu(e,t,r,s,n);case 15:return $h(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:vt(r,s),Ha(e,t),t.tag=1,Ye(r)?(e=!0,li(t)):e=!1,Tr(t,n),Ih(t,r,s),io(t,r,s,n),co(null,t,r,!0,e,n);case 19:return Kh(e,t,n);case 22:return Uh(e,t,n)}throw Error(E(156,t.tag))};function lm(e,t){return Mf(e,t)}function Pv(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ut(e,t,n,r){return new Pv(e,t,n,r)}function Fc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Tv(e){if(typeof e=="function")return Fc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===tc)return 11;if(e===nc)return 14}return 2}function _n(e,t){var n=e.alternate;return n===null?(n=ut(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ga(e,t,n,r,s,i){var l=2;if(r=e,typeof e=="function")Fc(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case pr:return tr(n.children,s,i,t);case ec:l=8,s|=8;break;case Tl:return e=ut(12,n,t,s|2),e.elementType=Tl,e.lanes=i,e;case Ol:return e=ut(13,n,t,s),e.elementType=Ol,e.lanes=i,e;case Ll:return e=ut(19,n,t,s),e.elementType=Ll,e.lanes=i,e;case vf:return Ii(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case pf:l=10;break e;case xf:l=9;break e;case tc:l=11;break e;case nc:l=14;break e;case tn:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=ut(l,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function tr(e,t,n,r){return e=ut(7,e,r,t),e.lanes=n,e}function Ii(e,t,n,r){return e=ut(22,e,r,t),e.elementType=vf,e.lanes=n,e.stateNode={isHidden:!1},e}function gl(e,t,n){return e=ut(6,e,null,t),e.lanes=n,e}function jl(e,t,n){return t=ut(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Ov(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=el(0),this.expirationTimes=el(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=el(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Ic(e,t,n,r,s,i,l,o,c){return e=new Ov(e,t,n,o,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=ut(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},jc(i),e}function Lv(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(dm)}catch(e){console.error(e)}}dm(),df.exports=st;var Iv=df.exports,fd=Iv;El.createRoot=fd.createRoot,El.hydrateRoot=fd.hydrateRoot;var rs=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Dv={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},an,Ko,Ud,Av=(Ud=class{constructor(){$(this,an,Dv);$(this,Ko,!1)}setTimeoutProvider(e){M(this,an,e)}setTimeout(e,t){return y(this,an).setTimeout(e,t)}clearTimeout(e){y(this,an).clearTimeout(e)}setInterval(e,t){return y(this,an).setInterval(e,t)}clearInterval(e){y(this,an).clearInterval(e)}},an=new WeakMap,Ko=new WeakMap,Ud),Vn=new Av;function $v(e){setTimeout(e,0)}var lr=typeof window>"u"||"Deno"in globalThis;function Be(){}function Uv(e,t){return typeof e=="function"?e(t):e}function ko(e){return typeof e=="number"&&e>=0&&e!==1/0}function fm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function En(e,t){return typeof e=="function"?e(t):e}function lt(e,t){return typeof e=="function"?e(t):e}function hd(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:i,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==Uc(l,t.options))return!1}else if(!Js(t.queryKey,l))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||s&&s!==t.state.fetchStatus||i&&!i(t))}function md(e,t){const{exact:n,status:r,predicate:s,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(or(t.options.mutationKey)!==or(i))return!1}else if(!Js(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function Uc(e,t){return((t==null?void 0:t.queryKeyHashFn)||or)(e)}function or(e){return JSON.stringify(e,(t,n)=>bo(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function Js(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Js(e[n],t[n])):!1}var Bv=Object.prototype.hasOwnProperty;function hm(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=pd(e)&&pd(t);if(!r&&!(bo(e)&&bo(t)))return t;const i=(r?e:Object.keys(e)).length,l=r?t:Object.keys(t),o=l.length,c=r?new Array(o):{};let u=0;for(let d=0;d{Vn.setTimeout(t,e)})}function No(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?hm(e,t):t}function Vv(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Kv(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Bc=Symbol();function mm(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Bc?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Qc(e,t){return typeof e=="function"?e(...t):!!e}function Hv(e,t,n){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),e}var Kn,ln,Lr,Bd,qv=(Bd=class extends rs{constructor(){super();$(this,Kn);$(this,ln);$(this,Lr);M(this,Lr,t=>{if(!lr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){y(this,ln)||this.setEventListener(y(this,Lr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,ln))==null||t.call(this),M(this,ln,void 0))}setEventListener(t){var n;M(this,Lr,t),(n=y(this,ln))==null||n.call(this),M(this,ln,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){y(this,Kn)!==t&&(M(this,Kn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof y(this,Kn)=="boolean"?y(this,Kn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Kn=new WeakMap,ln=new WeakMap,Lr=new WeakMap,Bd),Vc=new qv;function So(){let e,t;const n=new Promise((s,i)=>{e=s,t=i});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var Wv=$v;function Gv(){let e=[],t=0,n=o=>{o()},r=o=>{o()},s=Wv;const i=o=>{t?e.push(o):s(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&s(()=>{r(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;t++;try{c=o()}finally{t--,t||l()}return c},batchCalls:o=>(...c)=>{i(()=>{o(...c)})},schedule:i,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{s=o}}}var Ne=Gv(),Rr,on,Mr,Qd,Jv=(Qd=class extends rs{constructor(){super();$(this,Rr,!0);$(this,on);$(this,Mr);M(this,Mr,t=>{if(!lr&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){y(this,on)||this.setEventListener(y(this,Mr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,on))==null||t.call(this),M(this,on,void 0))}setEventListener(t){var n;M(this,Mr,t),(n=y(this,on))==null||n.call(this),M(this,on,t(this.setOnline.bind(this)))}setOnline(t){y(this,Rr)!==t&&(M(this,Rr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return y(this,Rr)}},Rr=new WeakMap,on=new WeakMap,Mr=new WeakMap,Qd),ki=new Jv;function Yv(e){return Math.min(1e3*2**e,3e4)}function pm(e){return(e??"online")==="online"?ki.isOnline():!0}var Co=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function xm(e){let t=!1,n=0,r;const s=So(),i=()=>s.status!=="pending",l=w=>{var b;if(!i()){const p=new Co(w);m(p),(b=e.onCancel)==null||b.call(e,p)}},o=()=>{t=!0},c=()=>{t=!1},u=()=>Vc.isFocused()&&(e.networkMode==="always"||ki.isOnline())&&e.canRun(),d=()=>pm(e.networkMode)&&e.canRun(),f=w=>{i()||(r==null||r(),s.resolve(w))},m=w=>{i()||(r==null||r(),s.reject(w))},v=()=>new Promise(w=>{var b;r=p=>{(i()||u())&&w(p)},(b=e.onPause)==null||b.call(e)}).then(()=>{var w;r=void 0,i()||(w=e.onContinue)==null||w.call(e)}),k=()=>{if(i())return;let w;const b=n===0?e.initialPromise:void 0;try{w=b??e.fn()}catch(p){w=Promise.reject(p)}Promise.resolve(w).then(f).catch(p=>{var S;if(i())return;const h=e.retry??(lr?0:3),x=e.retryDelay??Yv,j=typeof x=="function"?x(n,p):x,C=h===!0||typeof h=="number"&&nu()?void 0:v()).then(()=>{t?m(p):k()})})};return{promise:s,status:()=>s.status,cancel:l,continue:()=>(r==null||r(),s),cancelRetry:o,continueRetry:c,canStart:d,start:()=>(d()?k():v().then(k),s)}}var Hn,Vd,vm=(Vd=class{constructor(){$(this,Hn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),ko(this.gcTime)&&M(this,Hn,Vn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(lr?1/0:5*60*1e3))}clearGcTimeout(){y(this,Hn)&&(Vn.clearTimeout(y(this,Hn)),M(this,Hn,void 0))}},Hn=new WeakMap,Vd),qn,zr,it,Wn,Ee,na,Gn,yt,zt,Kd,Xv=(Kd=class extends vm{constructor(t){super();$(this,yt);$(this,qn);$(this,zr);$(this,it);$(this,Wn);$(this,Ee);$(this,na);$(this,Gn);M(this,Gn,!1),M(this,na,t.defaultOptions),this.setOptions(t.options),this.observers=[],M(this,Wn,t.client),M(this,it,y(this,Wn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,M(this,qn,yd(this.options)),this.state=t.state??y(this,qn),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=y(this,Ee))==null?void 0:t.promise}setOptions(t){if(this.options={...y(this,na),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=yd(this.options);n.data!==void 0&&(this.setState(vd(n.data,n.dataUpdatedAt)),M(this,qn,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&y(this,it).remove(this)}setData(t,n){const r=No(this.state.data,t,this.options);return G(this,yt,zt).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){G(this,yt,zt).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=y(this,Ee))==null?void 0:r.promise;return(s=y(this,Ee))==null||s.cancel(t),n?n.then(Be).catch(Be):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(y(this,qn))}isActive(){return this.observers.some(t=>lt(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Bc||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>En(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!fm(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ee))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ee))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),y(this,it).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(y(this,Ee)&&(y(this,Gn)?y(this,Ee).cancel({revert:!0}):y(this,Ee).cancelRetry()),this.scheduleGc()),y(this,it).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||G(this,yt,zt).call(this,{type:"invalidate"})}async fetch(t,n){var c,u,d,f,m,v,k,w,b,p,h,x;if(this.state.fetchStatus!=="idle"&&((c=y(this,Ee))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(y(this,Ee))return y(this,Ee).continueRetry(),y(this,Ee).promise}if(t&&this.setOptions(t),!this.options.queryFn){const j=this.observers.find(C=>C.options.queryFn);j&&this.setOptions(j.options)}const r=new AbortController,s=j=>{Object.defineProperty(j,"signal",{enumerable:!0,get:()=>(M(this,Gn,!0),r.signal)})},i=()=>{const j=mm(this.options,n),S=(()=>{const N={client:y(this,Wn),queryKey:this.queryKey,meta:this.meta};return s(N),N})();return M(this,Gn,!1),this.options.persister?this.options.persister(j,S,this):j(S)},o=(()=>{const j={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:y(this,Wn),state:this.state,fetchFn:i};return s(j),j})();(u=this.options.behavior)==null||u.onFetch(o,this),M(this,zr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=o.fetchOptions)==null?void 0:d.meta))&&G(this,yt,zt).call(this,{type:"fetch",meta:(f=o.fetchOptions)==null?void 0:f.meta}),M(this,Ee,xm({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:j=>{j instanceof Co&&j.revert&&this.setState({...y(this,zr),fetchStatus:"idle"}),r.abort()},onFail:(j,C)=>{G(this,yt,zt).call(this,{type:"failed",failureCount:j,error:C})},onPause:()=>{G(this,yt,zt).call(this,{type:"pause"})},onContinue:()=>{G(this,yt,zt).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const j=await y(this,Ee).start();if(j===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(j),(v=(m=y(this,it).config).onSuccess)==null||v.call(m,j,this),(w=(k=y(this,it).config).onSettled)==null||w.call(k,j,this.state.error,this),j}catch(j){if(j instanceof Co){if(j.silent)return y(this,Ee).promise;if(j.revert){if(this.state.data===void 0)throw j;return this.state.data}}throw G(this,yt,zt).call(this,{type:"error",error:j}),(p=(b=y(this,it).config).onError)==null||p.call(b,j,this),(x=(h=y(this,it).config).onSettled)==null||x.call(h,this.state.data,j,this),j}finally{this.scheduleGc()}}},qn=new WeakMap,zr=new WeakMap,it=new WeakMap,Wn=new WeakMap,Ee=new WeakMap,na=new WeakMap,Gn=new WeakMap,yt=new WeakSet,zt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...ym(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...vd(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return M(this,zr,t.manual?s:void 0),s;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Ne.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),y(this,it).notify({query:this,type:"updated",action:t})})},Kd);function ym(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:pm(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function vd(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function yd(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var He,ee,ra,$e,Jn,Fr,Dt,cn,sa,Ir,Dr,Yn,Xn,un,Ar,ae,ks,_o,Eo,Po,To,Oo,Lo,Ro,gm,Hd,Zv=(Hd=class extends rs{constructor(t,n){super();$(this,ae);$(this,He);$(this,ee);$(this,ra);$(this,$e);$(this,Jn);$(this,Fr);$(this,Dt);$(this,cn);$(this,sa);$(this,Ir);$(this,Dr);$(this,Yn);$(this,Xn);$(this,un);$(this,Ar,new Set);this.options=n,M(this,He,t),M(this,cn,null),M(this,Dt,So()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(y(this,ee).addObserver(this),gd(y(this,ee),this.options)?G(this,ae,ks).call(this):this.updateResult(),G(this,ae,To).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Mo(y(this,ee),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Mo(y(this,ee),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,G(this,ae,Oo).call(this),G(this,ae,Lo).call(this),y(this,ee).removeObserver(this)}setOptions(t){const n=this.options,r=y(this,ee);if(this.options=y(this,He).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof lt(this.options.enabled,y(this,ee))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");G(this,ae,Ro).call(this),y(this,ee).setOptions(this.options),n._defaulted&&!wi(this.options,n)&&y(this,He).getQueryCache().notify({type:"observerOptionsUpdated",query:y(this,ee),observer:this});const s=this.hasListeners();s&&jd(y(this,ee),r,this.options,n)&&G(this,ae,ks).call(this),this.updateResult(),s&&(y(this,ee)!==r||lt(this.options.enabled,y(this,ee))!==lt(n.enabled,y(this,ee))||En(this.options.staleTime,y(this,ee))!==En(n.staleTime,y(this,ee)))&&G(this,ae,_o).call(this);const i=G(this,ae,Eo).call(this);s&&(y(this,ee)!==r||lt(this.options.enabled,y(this,ee))!==lt(n.enabled,y(this,ee))||i!==y(this,un))&&G(this,ae,Po).call(this,i)}getOptimisticResult(t){const n=y(this,He).getQueryCache().build(y(this,He),t),r=this.createResult(n,t);return ty(this,r)&&(M(this,$e,r),M(this,Fr,this.options),M(this,Jn,y(this,ee).state)),r}getCurrentResult(){return y(this,$e)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&y(this,Dt).status==="pending"&&y(this,Dt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){y(this,Ar).add(t)}getCurrentQuery(){return y(this,ee)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=y(this,He).defaultQueryOptions(t),r=y(this,He).getQueryCache().build(y(this,He),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return G(this,ae,ks).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),y(this,$e)))}createResult(t,n){var z;const r=y(this,ee),s=this.options,i=y(this,$e),l=y(this,Jn),o=y(this,Fr),u=t!==r?t.state:y(this,ra),{state:d}=t;let f={...d},m=!1,v;if(n._optimisticResults){const L=this.hasListeners(),B=!L&&gd(t,n),J=L&&jd(t,r,n,s);(B||J)&&(f={...f,...ym(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:k,errorUpdatedAt:w,status:b}=f;v=f.data;let p=!1;if(n.placeholderData!==void 0&&v===void 0&&b==="pending"){let L;i!=null&&i.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(L=i.data,p=!0):L=typeof n.placeholderData=="function"?n.placeholderData((z=y(this,Dr))==null?void 0:z.state.data,y(this,Dr)):n.placeholderData,L!==void 0&&(b="success",v=No(i==null?void 0:i.data,L,n),m=!0)}if(n.select&&v!==void 0&&!p)if(i&&v===(l==null?void 0:l.data)&&n.select===y(this,sa))v=y(this,Ir);else try{M(this,sa,n.select),v=n.select(v),v=No(i==null?void 0:i.data,v,n),M(this,Ir,v),M(this,cn,null)}catch(L){M(this,cn,L)}y(this,cn)&&(k=y(this,cn),v=y(this,Ir),w=Date.now(),b="error");const h=f.fetchStatus==="fetching",x=b==="pending",j=b==="error",C=x&&h,S=v!==void 0,_={status:b,fetchStatus:f.fetchStatus,isPending:x,isSuccess:b==="success",isError:j,isInitialLoading:C,isLoading:C,data:v,dataUpdatedAt:f.dataUpdatedAt,error:k,errorUpdatedAt:w,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:h,isRefetching:h&&!x,isLoadingError:j&&!S,isPaused:f.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:j&&S,isStale:Kc(t,n),refetch:this.refetch,promise:y(this,Dt),isEnabled:lt(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const L=_.data!==void 0,B=_.status==="error"&&!L,J=D=>{B?D.reject(_.error):L&&D.resolve(_.data)},se=()=>{const D=M(this,Dt,_.promise=So());J(D)},ce=y(this,Dt);switch(ce.status){case"pending":t.queryHash===r.queryHash&&J(ce);break;case"fulfilled":(B||_.data!==ce.value)&&se();break;case"rejected":(!B||_.error!==ce.reason)&&se();break}}return _}updateResult(){const t=y(this,$e),n=this.createResult(y(this,ee),this.options);if(M(this,Jn,y(this,ee).state),M(this,Fr,this.options),y(this,Jn).data!==void 0&&M(this,Dr,y(this,ee)),wi(n,t))return;M(this,$e,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!y(this,Ar).size)return!0;const l=new Set(i??y(this,Ar));return this.options.throwOnError&&l.add("error"),Object.keys(y(this,$e)).some(o=>{const c=o;return y(this,$e)[c]!==t[c]&&l.has(c)})};G(this,ae,gm).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&G(this,ae,To).call(this)}},He=new WeakMap,ee=new WeakMap,ra=new WeakMap,$e=new WeakMap,Jn=new WeakMap,Fr=new WeakMap,Dt=new WeakMap,cn=new WeakMap,sa=new WeakMap,Ir=new WeakMap,Dr=new WeakMap,Yn=new WeakMap,Xn=new WeakMap,un=new WeakMap,Ar=new WeakMap,ae=new WeakSet,ks=function(t){G(this,ae,Ro).call(this);let n=y(this,ee).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Be)),n},_o=function(){G(this,ae,Oo).call(this);const t=En(this.options.staleTime,y(this,ee));if(lr||y(this,$e).isStale||!ko(t))return;const r=fm(y(this,$e).dataUpdatedAt,t)+1;M(this,Yn,Vn.setTimeout(()=>{y(this,$e).isStale||this.updateResult()},r))},Eo=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(y(this,ee)):this.options.refetchInterval)??!1},Po=function(t){G(this,ae,Lo).call(this),M(this,un,t),!(lr||lt(this.options.enabled,y(this,ee))===!1||!ko(y(this,un))||y(this,un)===0)&&M(this,Xn,Vn.setInterval(()=>{(this.options.refetchIntervalInBackground||Vc.isFocused())&&G(this,ae,ks).call(this)},y(this,un)))},To=function(){G(this,ae,_o).call(this),G(this,ae,Po).call(this,G(this,ae,Eo).call(this))},Oo=function(){y(this,Yn)&&(Vn.clearTimeout(y(this,Yn)),M(this,Yn,void 0))},Lo=function(){y(this,Xn)&&(Vn.clearInterval(y(this,Xn)),M(this,Xn,void 0))},Ro=function(){const t=y(this,He).getQueryCache().build(y(this,He),this.options);if(t===y(this,ee))return;const n=y(this,ee);M(this,ee,t),M(this,ra,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},gm=function(t){Ne.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(y(this,$e))}),y(this,He).getQueryCache().notify({query:y(this,ee),type:"observerResultsUpdated"})})},Hd);function ey(e,t){return lt(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function gd(e,t){return ey(e,t)||e.state.data!==void 0&&Mo(e,t,t.refetchOnMount)}function Mo(e,t,n){if(lt(t.enabled,e)!==!1&&En(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Kc(e,t)}return!1}function jd(e,t,n,r){return(e!==t||lt(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Kc(e,n)}function Kc(e,t){return lt(t.enabled,e)!==!1&&e.isStaleByTime(En(t.staleTime,e))}function ty(e,t){return!wi(e.getCurrentResult(),t)}function wd(e){return{onFetch:(t,n)=>{var d,f,m,v,k;const r=t.options,s=(m=(f=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:f.fetchMore)==null?void 0:m.direction,i=((v=t.state.data)==null?void 0:v.pages)||[],l=((k=t.state.data)==null?void 0:k.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const u=async()=>{let w=!1;const b=x=>{Hv(x,()=>t.signal,()=>w=!0)},p=mm(t.options,t.fetchOptions),h=async(x,j,C)=>{if(w)return Promise.reject();if(j==null&&x.pages.length)return Promise.resolve(x);const N=(()=>{const B={client:t.client,queryKey:t.queryKey,pageParam:j,direction:C?"backward":"forward",meta:t.options.meta};return b(B),B})(),_=await p(N),{maxPages:z}=t.options,L=C?Kv:Vv;return{pages:L(x.pages,_,z),pageParams:L(x.pageParams,j,z)}};if(s&&i.length){const x=s==="backward",j=x?ny:kd,C={pages:i,pageParams:l},S=j(r,C);o=await h(C,S,x)}else{const x=e??i.length;do{const j=c===0?l[0]??r.initialPageParam:kd(r,o);if(c>0&&j==null)break;o=await h(o,j),c++}while(c{var w,b;return(b=(w=t.options).persister)==null?void 0:b.call(w,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function kd(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function ny(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var aa,Et,Ie,Zn,Pt,en,qd,ry=(qd=class extends vm{constructor(t){super();$(this,Pt);$(this,aa);$(this,Et);$(this,Ie);$(this,Zn);M(this,aa,t.client),this.mutationId=t.mutationId,M(this,Ie,t.mutationCache),M(this,Et,[]),this.state=t.state||jm(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){y(this,Et).includes(t)||(y(this,Et).push(t),this.clearGcTimeout(),y(this,Ie).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){M(this,Et,y(this,Et).filter(n=>n!==t)),this.scheduleGc(),y(this,Ie).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){y(this,Et).length||(this.state.status==="pending"?this.scheduleGc():y(this,Ie).remove(this))}continue(){var t;return((t=y(this,Zn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,u,d,f,m,v,k,w,b,p,h,x,j,C,S,N;const n=()=>{G(this,Pt,en).call(this,{type:"continue"})},r={client:y(this,aa),meta:this.options.meta,mutationKey:this.options.mutationKey};M(this,Zn,xm({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(_,z)=>{G(this,Pt,en).call(this,{type:"failed",failureCount:_,error:z})},onPause:()=>{G(this,Pt,en).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>y(this,Ie).canRun(this)}));const s=this.state.status==="pending",i=!y(this,Zn).canStart();try{if(s)n();else{G(this,Pt,en).call(this,{type:"pending",variables:t,isPaused:i}),y(this,Ie).config.onMutate&&await y(this,Ie).config.onMutate(t,this,r);const z=await((o=(l=this.options).onMutate)==null?void 0:o.call(l,t,r));z!==this.state.context&&G(this,Pt,en).call(this,{type:"pending",context:z,variables:t,isPaused:i})}const _=await y(this,Zn).start();return await((u=(c=y(this,Ie).config).onSuccess)==null?void 0:u.call(c,_,t,this.state.context,this,r)),await((f=(d=this.options).onSuccess)==null?void 0:f.call(d,_,t,this.state.context,r)),await((v=(m=y(this,Ie).config).onSettled)==null?void 0:v.call(m,_,null,this.state.variables,this.state.context,this,r)),await((w=(k=this.options).onSettled)==null?void 0:w.call(k,_,null,t,this.state.context,r)),G(this,Pt,en).call(this,{type:"success",data:_}),_}catch(_){try{await((p=(b=y(this,Ie).config).onError)==null?void 0:p.call(b,_,t,this.state.context,this,r))}catch(z){Promise.reject(z)}try{await((x=(h=this.options).onError)==null?void 0:x.call(h,_,t,this.state.context,r))}catch(z){Promise.reject(z)}try{await((C=(j=y(this,Ie).config).onSettled)==null?void 0:C.call(j,void 0,_,this.state.variables,this.state.context,this,r))}catch(z){Promise.reject(z)}try{await((N=(S=this.options).onSettled)==null?void 0:N.call(S,void 0,_,t,this.state.context,r))}catch(z){Promise.reject(z)}throw G(this,Pt,en).call(this,{type:"error",error:_}),_}finally{y(this,Ie).runNext(this)}}},aa=new WeakMap,Et=new WeakMap,Ie=new WeakMap,Zn=new WeakMap,Pt=new WeakSet,en=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Ne.batch(()=>{y(this,Et).forEach(r=>{r.onMutationUpdate(t)}),y(this,Ie).notify({mutation:this,type:"updated",action:t})})},qd);function jm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var At,gt,ia,Wd,sy=(Wd=class extends rs{constructor(t={}){super();$(this,At);$(this,gt);$(this,ia);this.config=t,M(this,At,new Set),M(this,gt,new Map),M(this,ia,0)}build(t,n,r){const s=new ry({client:t,mutationCache:this,mutationId:++va(this,ia)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){y(this,At).add(t);const n=za(t);if(typeof n=="string"){const r=y(this,gt).get(n);r?r.push(t):y(this,gt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(y(this,At).delete(t)){const n=za(t);if(typeof n=="string"){const r=y(this,gt).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&y(this,gt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=za(t);if(typeof n=="string"){const r=y(this,gt).get(n),s=r==null?void 0:r.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=za(t);if(typeof n=="string"){const s=(r=y(this,gt).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Ne.batch(()=>{y(this,At).forEach(t=>{this.notify({type:"removed",mutation:t})}),y(this,At).clear(),y(this,gt).clear()})}getAll(){return Array.from(y(this,At))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>md(n,r))}findAll(t={}){return this.getAll().filter(n=>md(t,n))}notify(t){Ne.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Ne.batch(()=>Promise.all(t.map(n=>n.continue().catch(Be))))}},At=new WeakMap,gt=new WeakMap,ia=new WeakMap,Wd);function za(e){var t;return(t=e.options.scope)==null?void 0:t.id}var $t,dn,qe,Ut,Kt,Ja,zo,Gd,ay=(Gd=class extends rs{constructor(n,r){super();$(this,Kt);$(this,$t);$(this,dn);$(this,qe);$(this,Ut);M(this,$t,n),this.setOptions(r),this.bindMethods(),G(this,Kt,Ja).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=y(this,$t).defaultMutationOptions(n),wi(this.options,r)||y(this,$t).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,qe),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&or(r.mutationKey)!==or(this.options.mutationKey)?this.reset():((s=y(this,qe))==null?void 0:s.state.status)==="pending"&&y(this,qe).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=y(this,qe))==null||n.removeObserver(this)}onMutationUpdate(n){G(this,Kt,Ja).call(this),G(this,Kt,zo).call(this,n)}getCurrentResult(){return y(this,dn)}reset(){var n;(n=y(this,qe))==null||n.removeObserver(this),M(this,qe,void 0),G(this,Kt,Ja).call(this),G(this,Kt,zo).call(this)}mutate(n,r){var s;return M(this,Ut,r),(s=y(this,qe))==null||s.removeObserver(this),M(this,qe,y(this,$t).getMutationCache().build(y(this,$t),this.options)),y(this,qe).addObserver(this),y(this,qe).execute(n)}},$t=new WeakMap,dn=new WeakMap,qe=new WeakMap,Ut=new WeakMap,Kt=new WeakSet,Ja=function(){var r;const n=((r=y(this,qe))==null?void 0:r.state)??jm();M(this,dn,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},zo=function(n){Ne.batch(()=>{var r,s,i,l,o,c,u,d;if(y(this,Ut)&&this.hasListeners()){const f=y(this,dn).variables,m=y(this,dn).context,v={client:y(this,$t),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(s=(r=y(this,Ut)).onSuccess)==null||s.call(r,n.data,f,m,v)}catch(k){Promise.reject(k)}try{(l=(i=y(this,Ut)).onSettled)==null||l.call(i,n.data,null,f,m,v)}catch(k){Promise.reject(k)}}else if((n==null?void 0:n.type)==="error"){try{(c=(o=y(this,Ut)).onError)==null||c.call(o,n.error,f,m,v)}catch(k){Promise.reject(k)}try{(d=(u=y(this,Ut)).onSettled)==null||d.call(u,void 0,n.error,f,m,v)}catch(k){Promise.reject(k)}}}this.listeners.forEach(f=>{f(y(this,dn))})})},Gd),Tt,Jd,iy=(Jd=class extends rs{constructor(t={}){super();$(this,Tt);this.config=t,M(this,Tt,new Map)}build(t,n,r){const s=n.queryKey,i=n.queryHash??Uc(s,n);let l=this.get(i);return l||(l=new Xv({client:t,queryKey:s,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(l)),l}add(t){y(this,Tt).has(t.queryHash)||(y(this,Tt).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=y(this,Tt).get(t.queryHash);n&&(t.destroy(),n===t&&y(this,Tt).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Ne.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return y(this,Tt).get(t)}getAll(){return[...y(this,Tt).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>hd(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>hd(t,r)):n}notify(t){Ne.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Ne.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Ne.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Tt=new WeakMap,Jd),xe,fn,hn,$r,Ur,mn,Br,Qr,Yd,ly=(Yd=class{constructor(e={}){$(this,xe);$(this,fn);$(this,hn);$(this,$r);$(this,Ur);$(this,mn);$(this,Br);$(this,Qr);M(this,xe,e.queryCache||new iy),M(this,fn,e.mutationCache||new sy),M(this,hn,e.defaultOptions||{}),M(this,$r,new Map),M(this,Ur,new Map),M(this,mn,0)}mount(){va(this,mn)._++,y(this,mn)===1&&(M(this,Br,Vc.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,xe).onFocus())})),M(this,Qr,ki.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,xe).onOnline())})))}unmount(){var e,t;va(this,mn)._--,y(this,mn)===0&&((e=y(this,Br))==null||e.call(this),M(this,Br,void 0),(t=y(this,Qr))==null||t.call(this),M(this,Qr,void 0))}isFetching(e){return y(this,xe).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return y(this,fn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,xe).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=y(this,xe).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(En(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return y(this,xe).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=y(this,xe).get(r.queryHash),i=s==null?void 0:s.state.data,l=Uv(t,i);if(l!==void 0)return y(this,xe).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return Ne.batch(()=>y(this,xe).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,xe).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=y(this,xe);Ne.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=y(this,xe);return Ne.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Ne.batch(()=>y(this,xe).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Be).catch(Be)}invalidateQueries(e,t={}){return Ne.batch(()=>(y(this,xe).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Ne.batch(()=>y(this,xe).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let i=s.fetch(void 0,n);return n.throwOnError||(i=i.catch(Be)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Be)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=y(this,xe).build(this,t);return n.isStaleByTime(En(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Be).catch(Be)}fetchInfiniteQuery(e){return e.behavior=wd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Be).catch(Be)}ensureInfiniteQueryData(e){return e.behavior=wd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ki.isOnline()?y(this,fn).resumePausedMutations():Promise.resolve()}getQueryCache(){return y(this,xe)}getMutationCache(){return y(this,fn)}getDefaultOptions(){return y(this,hn)}setDefaultOptions(e){M(this,hn,e)}setQueryDefaults(e,t){y(this,$r).set(or(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...y(this,$r).values()],n={};return t.forEach(r=>{Js(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){y(this,Ur).set(or(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...y(this,Ur).values()],n={};return t.forEach(r=>{Js(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...y(this,hn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Uc(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Bc&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...y(this,hn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){y(this,xe).clear(),y(this,fn).clear()}},xe=new WeakMap,fn=new WeakMap,hn=new WeakMap,$r=new WeakMap,Ur=new WeakMap,mn=new WeakMap,Br=new WeakMap,Qr=new WeakMap,Yd),wm=g.createContext(void 0),Yt=e=>{const t=g.useContext(wm);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},oy=({client:e,children:t})=>(g.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),a.jsx(wm.Provider,{value:e,children:t})),km=g.createContext(!1),cy=()=>g.useContext(km);km.Provider;function uy(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var dy=g.createContext(uy()),fy=()=>g.useContext(dy),hy=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Qc(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},my=e=>{g.useEffect(()=>{e.clearReset()},[e])},py=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||Qc(n,[e.error,r])),xy=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},vy=(e,t)=>e.isLoading&&e.isFetching&&!t,yy=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,bd=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function gy(e,t,n){var m,v,k,w;const r=cy(),s=fy(),i=Yt(),l=i.defaultQueryOptions(e);(v=(m=i.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||v.call(m,l);const o=i.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",xy(l),hy(l,s,o),my(s);const c=!i.getQueryCache().get(l.queryHash),[u]=g.useState(()=>new t(i,l)),d=u.getOptimisticResult(l),f=!r&&e.subscribed!==!1;if(g.useSyncExternalStore(g.useCallback(b=>{const p=f?u.subscribe(Ne.batchCalls(b)):Be;return u.updateResult(),p},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),g.useEffect(()=>{u.setOptions(l)},[l,u]),yy(l,d))throw bd(l,u,s);if(py({result:d,errorResetBoundary:s,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw d.error;if((w=(k=i.getDefaultOptions().queries)==null?void 0:k._experimental_afterQuery)==null||w.call(k,l,d),l.experimental_prefetchInRender&&!lr&&vy(d,r)){const b=c?bd(l,u,s):o==null?void 0:o.promise;b==null||b.catch(Be).finally(()=>{u.updateResult()})}return l.notifyOnChangeProps?d:u.trackResult(d)}function oe(e,t){return gy(e,Zv)}function Ze(e,t){const n=Yt(),[r]=g.useState(()=>new ay(n,e));g.useEffect(()=>{r.setOptions(e)},[r,e]);const s=g.useSyncExternalStore(g.useCallback(l=>r.subscribe(Ne.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=g.useCallback((l,o)=>{r.mutate(l,o).catch(Be)},[r]);if(s.error&&Qc(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}/** + * @remix-run/router v1.23.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Ys(){return Ys=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function Hc(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function wy(){return Math.random().toString(36).substr(2,8)}function Sd(e,t){return{usr:e.state,key:e.key,idx:t}}function Fo(e,t,n,r){return n===void 0&&(n=null),Ys({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?ss(t):t,{state:n,key:t&&t.key||r||wy()})}function bi(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function ss(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function ky(e,t,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:i=!1}=r,l=s.history,o=vn.Pop,c=null,u=d();u==null&&(u=0,l.replaceState(Ys({},l.state,{idx:u}),""));function d(){return(l.state||{idx:null}).idx}function f(){o=vn.Pop;let b=d(),p=b==null?null:b-u;u=b,c&&c({action:o,location:w.location,delta:p})}function m(b,p){o=vn.Push;let h=Fo(w.location,b,p);u=d()+1;let x=Sd(h,u),j=w.createHref(h);try{l.pushState(x,"",j)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;s.location.assign(j)}i&&c&&c({action:o,location:w.location,delta:1})}function v(b,p){o=vn.Replace;let h=Fo(w.location,b,p);u=d();let x=Sd(h,u),j=w.createHref(h);l.replaceState(x,"",j),i&&c&&c({action:o,location:w.location,delta:0})}function k(b){let p=s.location.origin!=="null"?s.location.origin:s.location.href,h=typeof b=="string"?b:bi(b);return h=h.replace(/ $/,"%20"),ye(p,"No window.location.(origin|href) available to create URL for href: "+h),new URL(h,p)}let w={get action(){return o},get location(){return e(s,l)},listen(b){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(Nd,f),c=b,()=>{s.removeEventListener(Nd,f),c=null}},createHref(b){return t(s,b)},createURL:k,encodeLocation(b){let p=k(b);return{pathname:p.pathname,search:p.search,hash:p.hash}},push:m,replace:v,go(b){return l.go(b)}};return w}var Cd;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Cd||(Cd={}));function by(e,t,n){return n===void 0&&(n="/"),Ny(e,t,n)}function Ny(e,t,n,r){let s=typeof t=="string"?ss(t):t,i=Yr(s.pathname||"/",n);if(i==null)return null;let l=bm(e);Sy(l);let o=null;for(let c=0;o==null&&c{let c={relativePath:o===void 0?i.path||"":o,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};c.relativePath.startsWith("/")&&(ye(c.relativePath.startsWith(r),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(r.length));let u=Pn([r,c.relativePath]),d=n.concat(c);i.children&&i.children.length>0&&(ye(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),bm(i.children,t,d,u)),!(i.path==null&&!i.index)&&t.push({path:u,score:Ly(u,i.index),routesMeta:d})};return e.forEach((i,l)=>{var o;if(i.path===""||!((o=i.path)!=null&&o.includes("?")))s(i,l);else for(let c of Nm(i.path))s(i,l,c)}),t}function Nm(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return s?[i,""]:[i];let l=Nm(r.join("/")),o=[];return o.push(...l.map(c=>c===""?i:[i,c].join("/"))),s&&o.push(...l),o.map(c=>e.startsWith("/")&&c===""?"/":c)}function Sy(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ry(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const Cy=/^:[\w-]+$/,_y=3,Ey=2,Py=1,Ty=10,Oy=-2,_d=e=>e==="*";function Ly(e,t){let n=e.split("/"),r=n.length;return n.some(_d)&&(r+=Oy),t&&(r+=Ey),n.filter(s=>!_d(s)).reduce((s,i)=>s+(Cy.test(i)?_y:i===""?Py:Ty),r)}function Ry(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function My(e,t,n){let{routesMeta:r}=e,s={},i="/",l=[];for(let o=0;o{let{paramName:m,isOptional:v}=d;if(m==="*"){let w=o[f]||"";l=i.slice(0,i.length-w.length).replace(/(.)\/+$/,"$1")}const k=o[f];return v&&!k?u[m]=void 0:u[m]=(k||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:l,pattern:e}}function zy(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),Hc(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,c)=>(r.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function Fy(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Hc(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Yr(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const Iy=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Dy=e=>Iy.test(e);function Ay(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?ss(e):e,i;if(n)if(Dy(n))i=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),Hc(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?i=Ed(n.substring(1),"/"):i=Ed(n,t)}else i=t;return{pathname:i,search:By(r),hash:Qy(s)}}function Ed(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function wl(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function $y(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Sm(e,t){let n=$y(e);return t?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Cm(e,t,n,r){r===void 0&&(r=!1);let s;typeof e=="string"?s=ss(e):(s=Ys({},e),ye(!s.pathname||!s.pathname.includes("?"),wl("?","pathname","search",s)),ye(!s.pathname||!s.pathname.includes("#"),wl("#","pathname","hash",s)),ye(!s.search||!s.search.includes("#"),wl("#","search","hash",s)));let i=e===""||s.pathname==="",l=i?"/":s.pathname,o;if(l==null)o=n;else{let f=t.length-1;if(!r&&l.startsWith("..")){let m=l.split("/");for(;m[0]==="..";)m.shift(),f-=1;s.pathname=m.join("/")}o=f>=0?t[f]:"/"}let c=Ay(s,o),u=l&&l!=="/"&&l.endsWith("/"),d=(i||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}const Pn=e=>e.join("/").replace(/\/\/+/g,"/"),Uy=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),By=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Qy=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Vy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const _m=["post","put","patch","delete"];new Set(_m);const Ky=["get",..._m];new Set(Ky);/** + * React Router v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Xs(){return Xs=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),g.useCallback(function(u,d){if(d===void 0&&(d={}),!o.current)return;if(typeof u=="number"){r.go(u);return}let f=Cm(u,JSON.parse(l),i,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Pn([t,f.pathname])),(d.replace?r.replace:r.push)(f,d.state,d)},[t,r,l,i,e])}const Wy=g.createContext(null);function Gy(e){let t=g.useContext(Xt).outlet;return t&&g.createElement(Wy.Provider,{value:e},t)}function ha(){let{matches:e}=g.useContext(Xt),t=e[e.length-1];return t?t.params:{}}function Vi(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=g.useContext(In),{matches:s}=g.useContext(Xt),{pathname:i}=as(),l=JSON.stringify(Sm(s,r.v7_relativeSplatPath));return g.useMemo(()=>Cm(e,JSON.parse(l),i,n==="path"),[e,l,i,n])}function Jy(e,t){return Yy(e,t)}function Yy(e,t,n,r){fa()||ye(!1);let{navigator:s}=g.useContext(In),{matches:i}=g.useContext(Xt),l=i[i.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let u=as(),d;if(t){var f;let b=typeof t=="string"?ss(t):t;c==="/"||(f=b.pathname)!=null&&f.startsWith(c)||ye(!1),d=b}else d=u;let m=d.pathname||"/",v=m;if(c!=="/"){let b=c.replace(/^\//,"").split("/");v="/"+m.replace(/^\//,"").split("/").slice(b.length).join("/")}let k=by(e,{pathname:v}),w=ng(k&&k.map(b=>Object.assign({},b,{params:Object.assign({},o,b.params),pathname:Pn([c,s.encodeLocation?s.encodeLocation(b.pathname).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?c:Pn([c,s.encodeLocation?s.encodeLocation(b.pathnameBase).pathname:b.pathnameBase])})),i,n,r);return t&&w?g.createElement(Qi.Provider,{value:{location:Xs({pathname:"/",search:"",hash:"",state:null,key:"default"},d),navigationType:vn.Pop}},w):w}function Xy(){let e=ig(),t=Vy(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return g.createElement(g.Fragment,null,g.createElement("h2",null,"Unexpected Application Error!"),g.createElement("h3",{style:{fontStyle:"italic"}},t),n?g.createElement("pre",{style:s},n):null,null)}const Zy=g.createElement(Xy,null);class eg extends g.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?g.createElement(Xt.Provider,{value:this.props.routeContext},g.createElement(Pm.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function tg(e){let{routeContext:t,match:n,children:r}=e,s=g.useContext(Bi);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),g.createElement(Xt.Provider,{value:t},r)}function ng(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(s=n)==null?void 0:s.errors;if(o!=null){let d=l.findIndex(f=>f.route.id&&(o==null?void 0:o[f.route.id])!==void 0);d>=0||ye(!1),l=l.slice(0,Math.min(l.length,d+1))}let c=!1,u=-1;if(n&&r&&r.v7_partialHydration)for(let d=0;d=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((d,f,m)=>{let v,k=!1,w=null,b=null;n&&(v=o&&f.route.id?o[f.route.id]:void 0,w=f.route.errorElement||Zy,c&&(u<0&&m===0?(og("route-fallback"),k=!0,b=null):u===m&&(k=!0,b=f.route.hydrateFallbackElement||null)));let p=t.concat(l.slice(0,m+1)),h=()=>{let x;return v?x=w:k?x=b:f.route.Component?x=g.createElement(f.route.Component,null):f.route.element?x=f.route.element:x=d,g.createElement(tg,{match:f,routeContext:{outlet:d,matches:p,isDataRoute:n!=null},children:x})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?g.createElement(eg,{location:n.location,revalidation:n.revalidation,component:w,error:v,children:h(),routeContext:{outlet:null,matches:p,isDataRoute:!0}}):h()},null)}var Om=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Om||{}),Lm=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(Lm||{});function rg(e){let t=g.useContext(Bi);return t||ye(!1),t}function sg(e){let t=g.useContext(Em);return t||ye(!1),t}function ag(e){let t=g.useContext(Xt);return t||ye(!1),t}function Rm(e){let t=ag(),n=t.matches[t.matches.length-1];return n.route.id||ye(!1),n.route.id}function ig(){var e;let t=g.useContext(Pm),n=sg(),r=Rm();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function lg(){let{router:e}=rg(Om.UseNavigateStable),t=Rm(Lm.UseNavigateStable),n=g.useRef(!1);return Tm(()=>{n.current=!0}),g.useCallback(function(s,i){i===void 0&&(i={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,Xs({fromRouteId:t},i)))},[e,t])}const Pd={};function og(e,t,n){Pd[e]||(Pd[e]=!0)}function cg(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function ug(e){return Gy(e.context)}function xt(e){ye(!1)}function dg(e){let{basename:t="/",children:n=null,location:r,navigationType:s=vn.Pop,navigator:i,static:l=!1,future:o}=e;fa()&&ye(!1);let c=t.replace(/^\/*/,"/"),u=g.useMemo(()=>({basename:c,navigator:i,static:l,future:Xs({v7_relativeSplatPath:!1},o)}),[c,o,i,l]);typeof r=="string"&&(r=ss(r));let{pathname:d="/",search:f="",hash:m="",state:v=null,key:k="default"}=r,w=g.useMemo(()=>{let b=Yr(d,c);return b==null?null:{location:{pathname:b,search:f,hash:m,state:v,key:k},navigationType:s}},[c,d,f,m,v,k,s]);return w==null?null:g.createElement(In.Provider,{value:u},g.createElement(Qi.Provider,{children:n,value:w}))}function fg(e){let{children:t,location:n}=e;return Jy(Do(t),n)}new Promise(()=>{});function Do(e,t){t===void 0&&(t=[]);let n=[];return g.Children.forEach(e,(r,s)=>{if(!g.isValidElement(r))return;let i=[...t,s];if(r.type===g.Fragment){n.push.apply(n,Do(r.props.children,i));return}r.type!==xt&&ye(!1),!r.props.index||!r.props.children||ye(!1);let l={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Do(r.props.children,i)),n.push(l)}),n}/** + * React Router DOM v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Ni(){return Ni=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[s]=e[s]);return n}function hg(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function mg(e,t){return e.button===0&&(!t||t==="_self")&&!hg(e)}const pg=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],xg=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],vg="6";try{window.__reactRouterVersion=vg}catch{}const yg=g.createContext({isTransitioning:!1}),gg="startTransition",Td=Cp[gg];function jg(e){let{basename:t,children:n,future:r,window:s}=e,i=g.useRef();i.current==null&&(i.current=jy({window:s,v5Compat:!0}));let l=i.current,[o,c]=g.useState({action:l.action,location:l.location}),{v7_startTransition:u}=r||{},d=g.useCallback(f=>{u&&Td?Td(()=>c(f)):c(f)},[c,u]);return g.useLayoutEffect(()=>l.listen(d),[l,d]),g.useEffect(()=>cg(r),[r]),g.createElement(dg,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const wg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",kg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Rn=g.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:i,replace:l,state:o,target:c,to:u,preventScrollReset:d,viewTransition:f}=t,m=Mm(t,pg),{basename:v}=g.useContext(In),k,w=!1;if(typeof u=="string"&&kg.test(u)&&(k=u,wg))try{let x=new URL(window.location.href),j=u.startsWith("//")?new URL(x.protocol+u):new URL(u),C=Yr(j.pathname,v);j.origin===x.origin&&C!=null?u=C+j.search+j.hash:w=!0}catch{}let b=Hy(u,{relative:s}),p=Ng(u,{replace:l,state:o,target:c,preventScrollReset:d,relative:s,viewTransition:f});function h(x){r&&r(x),x.defaultPrevented||p(x)}return g.createElement("a",Ni({},m,{href:k||b,onClick:w||i?r:h,ref:n,target:c}))}),zm=g.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:s=!1,className:i="",end:l=!1,style:o,to:c,viewTransition:u,children:d}=t,f=Mm(t,xg),m=Vi(c,{relative:f.relative}),v=as(),k=g.useContext(Em),{navigator:w,basename:b}=g.useContext(In),p=k!=null&&Sg(m)&&u===!0,h=w.encodeLocation?w.encodeLocation(m).pathname:m.pathname,x=v.pathname,j=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;s||(x=x.toLowerCase(),j=j?j.toLowerCase():null,h=h.toLowerCase()),j&&b&&(j=Yr(j,b)||j);const C=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let S=x===h||!l&&x.startsWith(h)&&x.charAt(C)==="/",N=j!=null&&(j===h||!l&&j.startsWith(h)&&j.charAt(h.length)==="/"),_={isActive:S,isPending:N,isTransitioning:p},z=S?r:void 0,L;typeof i=="function"?L=i(_):L=[i,S?"active":null,N?"pending":null,p?"transitioning":null].filter(Boolean).join(" ");let B=typeof o=="function"?o(_):o;return g.createElement(Rn,Ni({},f,{"aria-current":z,className:L,ref:n,style:B,to:c,viewTransition:u}),typeof d=="function"?d(_):d)});var Ao;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Ao||(Ao={}));var Od;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Od||(Od={}));function bg(e){let t=g.useContext(Bi);return t||ye(!1),t}function Ng(e,t){let{target:n,replace:r,state:s,preventScrollReset:i,relative:l,viewTransition:o}=t===void 0?{}:t,c=Dn(),u=as(),d=Vi(e,{relative:l});return g.useCallback(f=>{if(mg(f,n)){f.preventDefault();let m=r!==void 0?r:bi(u)===bi(d);c(e,{replace:m,state:s,preventScrollReset:i,relative:l,viewTransition:o})}},[u,c,d,r,s,n,e,i,l,o])}function Sg(e,t){t===void 0&&(t={});let n=g.useContext(yg);n==null&&ye(!1);let{basename:r}=bg(Ao.useViewTransitionState),s=Vi(e,{relative:t.relative});if(!n.isTransitioning)return!1;let i=Yr(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Yr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Io(s.pathname,l)!=null||Io(s.pathname,i)!=null}/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var Cg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _g=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),U=(e,t)=>{const n=g.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:l,className:o="",children:c,...u},d)=>g.createElement("svg",{ref:d,...Cg,width:s,height:s,stroke:r,strokeWidth:l?Number(i)*24/Number(s):i,className:["lucide",`lucide-${_g(e)}`,o].join(" "),...u},[...t.map(([f,m])=>g.createElement(f,m)),...Array.isArray(c)?c:[c]]));return n.displayName=`${e}`,n};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Eg=U("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fm=U("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pg=U("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Tg=U("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Og=U("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Im=U("BookOpen",[["path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z",key:"vv98re"}],["path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z",key:"1cyq3y"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $o=U("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dm=U("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lg=U("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rg=U("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Zs=U("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mg=U("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zg=U("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Am=U("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fg=U("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ig=U("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $m=U("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ld=U("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Um=U("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Uo=U("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dg=U("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ag=U("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $g=U("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qc=U("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ug=U("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bg=U("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qg=U("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ma=U("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bm=U("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vg=U("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qm=U("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Kg=U("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ea=U("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wc=U("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hg=U("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qg=U("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vm=U("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Km=U("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wg=U("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Gg=U("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rd=U("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Jg=U("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Yg=U("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Gc=U("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hm=U("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qm=U("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xg=U("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wm=U("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const is=U("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),Zg={},Md=e=>{let t;const n=new Set,r=(d,f)=>{const m=typeof d=="function"?d(t):d;if(!Object.is(m,t)){const v=t;t=f??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(k=>k(t,v))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(Zg?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(r,s,c);return c},e0=e=>e?Md(e):Md;var Gm={exports:{}},Jm={},Ym={exports:{}},Xm={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Xr=g;function t0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var n0=typeof Object.is=="function"?Object.is:t0,r0=Xr.useState,s0=Xr.useEffect,a0=Xr.useLayoutEffect,i0=Xr.useDebugValue;function l0(e,t){var n=t(),r=r0({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return a0(function(){s.value=n,s.getSnapshot=t,kl(s)&&i({inst:s})},[e,n,t]),s0(function(){return kl(s)&&i({inst:s}),e(function(){kl(s)&&i({inst:s})})},[e]),i0(n),n}function kl(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!n0(e,n)}catch{return!0}}function o0(e,t){return t()}var c0=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o0:l0;Xm.useSyncExternalStore=Xr.useSyncExternalStore!==void 0?Xr.useSyncExternalStore:c0;Ym.exports=Xm;var u0=Ym.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Ki=g,d0=u0;function f0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var h0=typeof Object.is=="function"?Object.is:f0,m0=d0.useSyncExternalStore,p0=Ki.useRef,x0=Ki.useEffect,v0=Ki.useMemo,y0=Ki.useDebugValue;Jm.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=p0(null);if(i.current===null){var l={hasValue:!1,value:null};i.current=l}else l=i.current;i=v0(function(){function c(v){if(!u){if(u=!0,d=v,v=r(v),s!==void 0&&l.hasValue){var k=l.value;if(s(k,v))return f=k}return f=v}if(k=f,h0(d,v))return k;var w=r(v);return s!==void 0&&s(k,w)?(d=v,k):(d=v,f=w)}var u=!1,d,f,m=n===void 0?null:n;return[function(){return c(t())},m===null?void 0:function(){return c(m())}]},[t,n,r,s]);var o=m0(e,i[0],i[1]);return x0(function(){l.hasValue=!0,l.value=o},[o]),y0(o),o};Gm.exports=Jm;var g0=Gm.exports;const j0=Xd(g0),Zm={},{useDebugValue:w0}=Jo,{useSyncExternalStoreWithSelector:k0}=j0;let zd=!1;const b0=e=>e;function N0(e,t=b0,n){(Zm?"production":void 0)!=="production"&&n&&!zd&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),zd=!0);const r=k0(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return w0(r),r}const Fd=e=>{(Zm?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?e0(e):e,n=(r,s)=>N0(t,r,s);return Object.assign(n,t),n},Jc=e=>e?Fd(e):Fd,Hi="/api",Yc="flow_auth_token",Xc="flow_auth_expires",Zc="flow_auth_username";function qi(){const e=localStorage.getItem(Yc),t=localStorage.getItem(Xc);return!e||!t?null:new Date(t)<=new Date?(Zr(),null):e}function Id(e,t,n){localStorage.setItem(Yc,e),localStorage.setItem(Xc,t),localStorage.setItem(Zc,n)}function Zr(){localStorage.removeItem(Yc),localStorage.removeItem(Xc),localStorage.removeItem(Zc)}function eu(){return localStorage.getItem(Zc)}let cr=null;function S0(e){cr=e}async function Y(e,t,n=!1){const r={"Content-Type":"application/json",...t==null?void 0:t.headers};if(!n){const i=qi();i&&(r.Authorization=`Bearer ${i}`)}const s=await fetch(`${Hi}${e}`,{...t,headers:r});if(s.status===401){Zr(),cr&&cr();const i=await s.json().catch(()=>({detail:"Not authenticated"}));throw new Error(i.detail||"Not authenticated")}if(!s.ok){const i=await s.json().catch(()=>({detail:s.statusText}));throw new Error(i.detail||"API request failed")}if(s.status!==204)return s.json()}const xs={getConfig:()=>Y("/auth/config",void 0,!0),login:e=>Y("/auth/login",{method:"POST",body:JSON.stringify(e)},!0),getGitHubAuthUrl:()=>`${Hi}/auth/github`,getCurrentUser:()=>Y("/auth/me"),logout:()=>Y("/auth/logout",{method:"POST"})},Tn={list:e=>{const t=new URLSearchParams;e!=null&&e.include_auto_generated&&t.set("include_auto_generated","true"),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return Y(`/configs${n?`?${n}`:""}`)},get:e=>Y(`/configs/${e}`),create:e=>Y("/configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Y(`/configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Y(`/configs/${e}`,{method:"DELETE"})},kt={list:e=>{const t=new URLSearchParams;e!=null&&e.category&&t.set("category",e.category),e!=null&&e.suite&&t.set("suite",e.suite);const n=t.toString();return Y(`/tasks${n?`?${n}`:""}`)},get:e=>Y(`/tasks/${e}`),create:e=>Y("/tasks",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Y(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>Y(`/tasks/${e}`,{method:"DELETE"}),listSuites:()=>Y("/tasks/suites"),importSuite:e=>Y(`/tasks/import-suite?suite_name=${encodeURIComponent(e)}`,{method:"POST"})},Mt={list:e=>{const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return Y(`/jobs${n?`?${n}`:""}`)},get:e=>Y(`/jobs/${e}`),create:e=>Y("/jobs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>Y(`/jobs/${e}`,{method:"PUT",body:JSON.stringify(t)}),start:async function*(e){var o;const t={},n=qi();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Hi}/jobs/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Zr(),cr&&cr(),new Error("Not authenticated");if(!r.ok)throw new Error("Failed to start job");const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const i=new TextDecoder;let l="";for(;;){const{done:c,value:u}=await s.read();if(c)break;l+=i.decode(u,{stream:!0});const d=l.split(` +`);l=d.pop()||"";for(const f of d)f.startsWith("data: ")&&(yield JSON.parse(f.slice(6)))}},cancel:e=>Y(`/jobs/${e}/cancel`,{method:"POST"}),delete:e=>Y(`/jobs/${e}`,{method:"DELETE"})},Bo={list:e=>{const t=new URLSearchParams;e!=null&&e.job_id&&t.set("job_id",e.job_id),e!=null&&e.candidate_name&&t.set("candidate_name",e.candidate_name),e!=null&&e.task_name&&t.set("task_name",e.task_name),(e==null?void 0:e.is_pareto)!==void 0&&t.set("is_pareto",String(e.is_pareto));const n=t.toString();return Y(`/runs${n?`?${n}`:""}`)},get:e=>Y(`/runs/${e}`),getJobSummary:e=>Y(`/runs/job/${e}/summary`)},Ls={list:e=>{const t=new URLSearchParams;e!=null&&e.agent_id&&t.set("agent_id",e.agent_id),e!=null&&e.limit&&t.set("limit",String(e.limit));const n=t.toString();return Y(`/tests${n?`?${n}`:""}`)},get:e=>Y(`/tests/${e}`),create:e=>Y("/tests",{method:"POST",body:JSON.stringify(e)}),start:async function*(e){var o;const t={},n=qi();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Hi}/tests/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Zr(),cr&&cr(),new Error("Not authenticated");if(!r.ok){const c=await r.json().catch(()=>({detail:"Failed to start test"}));throw new Error(c.detail||"Failed to start test")}const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const i=new TextDecoder;let l="";for(;;){const{done:c,value:u}=await s.read();if(c)break;l+=i.decode(u,{stream:!0});const d=l.split(` +`);l=d.pop()||"";for(const f of d)f.startsWith("data: ")&&(yield JSON.parse(f.slice(6)))}},cancel:e=>Y(`/tests/${e}/cancel`,{method:"POST"}),delete:e=>Y(`/tests/${e}`,{method:"DELETE"})},C0={list:()=>Y("/llm-configs")},_0={list:()=>Y("/tools")},ep={getAgentSchema:()=>Y("/schema/agent")},E0={get:e=>Y(`/deployments/${e}`)},P0={start:e=>Y("/evaluate",{method:"POST",body:JSON.stringify(e)})},Qo={design:e=>Y("/experiment/design",{method:"POST",body:JSON.stringify(e)}),validate:e=>Y("/experiment/validate",{method:"POST",body:JSON.stringify(e)}),generateCandidates:e=>Y("/experiment/generate-candidates",{method:"POST",body:JSON.stringify(e)})},tu=Jc(e=>(S0(()=>{e({isAuthenticated:!1,user:null,error:"Session expired. Please log in again."})}),{authConfig:null,isLoadingConfig:!0,isAuthenticated:!1,isLoading:!1,user:null,error:null,loadAuthConfig:async()=>{e({isLoadingConfig:!0});try{const t=await xs.getConfig();if(e({authConfig:t,isLoadingConfig:!1}),t.enabled){const n=qi(),r=eu();if(n&&r)try{const s=await xs.getCurrentUser();e({isAuthenticated:!0,user:s})}catch{Zr(),e({isAuthenticated:!1,user:null})}}else e({isAuthenticated:!0,user:{username:"anonymous",auth_mode:"none"}})}catch(t){console.error("Failed to load auth config:",t),e({isLoadingConfig:!1,error:"Failed to connect to server"})}},login:async(t,n)=>{e({isLoading:!0,error:null});try{const r=await xs.login({username:t,password:n});return Id(r.access_token,r.expires_at,r.username),e({isAuthenticated:!0,isLoading:!1,user:{username:r.username,auth_mode:"basic"}}),!0}catch(r){return e({isLoading:!1,error:r instanceof Error?r.message:"Login failed"}),!1}},loginWithGitHub:()=>{window.location.href=xs.getGitHubAuthUrl()},handleOAuthCallback:()=>{const t=new URLSearchParams(window.location.search),n=t.get("auth_error");if(n)return e({error:n}),window.history.replaceState({},"",window.location.pathname),!0;if(t.get("auth_callback")==="true"){const r=t.get("token"),s=t.get("expires_at"),i=t.get("username");return r&&s&&i&&(Id(r,s,i),e({isAuthenticated:!0,user:{username:i,auth_mode:"github"}})),window.history.replaceState({},"",window.location.pathname),!0}return!1},logout:async()=>{try{await xs.logout()}catch{}Zr(),e({isAuthenticated:!1,user:null,error:null})},clearError:()=>e({error:null})}));function K({variant:e="secondary",size:t="md",className:n="",icon:r,iconRight:s,loading:i=!1,children:l,disabled:o,...c}){const u="font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1.5 rounded-md",d={primary:"bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)]",secondary:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)] hover:bg-[var(--border)]",danger:"bg-[var(--error)] text-white hover:bg-red-600",ghost:"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"},f={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm"},m=t==="sm"?14:16;return a.jsxs("button",{className:`${u} ${d[e]} ${f[t]} ${n}`,disabled:o||i,...c,children:[i?a.jsx(ma,{size:m,className:"animate-spin"}):r?a.jsx(r,{size:m}):null,l,s&&!i&&a.jsx(s,{size:m})]})}const T0={};function O0(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var i;const l=c=>c===null?null:JSON.parse(c,void 0),o=(i=n.getItem(s))!=null?i:null;return o instanceof Promise?o.then(l):l(o)},setItem:(s,i)=>n.setItem(s,JSON.stringify(i,void 0)),removeItem:s=>n.removeItem(s)}}const ta=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return ta(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return ta(r)(n)}}}},L0=(e,t)=>(n,r,s)=>{let i={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:b=>b,version:0,merge:(b,p)=>({...p,...b}),...t},l=!1;const o=new Set,c=new Set;let u;try{u=i.getStorage()}catch{}if(!u)return e((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...b)},r,s);const d=ta(i.serialize),f=()=>{const b=i.partialize({...r()});let p;const h=d({state:b,version:i.version}).then(x=>u.setItem(i.name,x)).catch(x=>{p=x});if(p)throw p;return h},m=s.setState;s.setState=(b,p)=>{m(b,p),f()};const v=e((...b)=>{n(...b),f()},r,s);let k;const w=()=>{var b;if(!u)return;l=!1,o.forEach(h=>h(r()));const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,r()))||void 0;return ta(u.getItem.bind(u))(i.name).then(h=>{if(h)return i.deserialize(h)}).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==i.version){if(i.migrate)return i.migrate(h.state,h.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return h.state}).then(h=>{var x;return k=i.merge(h,(x=r())!=null?x:v),n(k,!0),f()}).then(()=>{p==null||p(k,void 0),l=!0,c.forEach(h=>h(k))}).catch(h=>{p==null||p(void 0,h)})};return s.persist={setOptions:b=>{i={...i,...b},b.getStorage&&(u=b.getStorage())},clearStorage:()=>{u==null||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>w(),hasHydrated:()=>l,onHydrate:b=>(o.add(b),()=>{o.delete(b)}),onFinishHydration:b=>(c.add(b),()=>{c.delete(b)})},w(),k||v},R0=(e,t)=>(n,r,s)=>{let i={storage:O0(()=>localStorage),partialize:w=>w,version:0,merge:(w,b)=>({...b,...w}),...t},l=!1;const o=new Set,c=new Set;let u=i.storage;if(!u)return e((...w)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...w)},r,s);const d=()=>{const w=i.partialize({...r()});return u.setItem(i.name,{state:w,version:i.version})},f=s.setState;s.setState=(w,b)=>{f(w,b),d()};const m=e((...w)=>{n(...w),d()},r,s);s.getInitialState=()=>m;let v;const k=()=>{var w,b;if(!u)return;l=!1,o.forEach(h=>{var x;return h((x=r())!=null?x:m)});const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,(w=r())!=null?w:m))||void 0;return ta(u.getItem.bind(u))(i.name).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==i.version){if(i.migrate)return[!0,i.migrate(h.state,h.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,h.state];return[!1,void 0]}).then(h=>{var x;const[j,C]=h;if(v=i.merge(C,(x=r())!=null?x:m),n(v,!0),j)return d()}).then(()=>{p==null||p(v,void 0),v=r(),l=!0,c.forEach(h=>h(v))}).catch(h=>{p==null||p(void 0,h)})};return s.persist={setOptions:w=>{i={...i,...w},w.storage&&(u=w.storage)},clearStorage:()=>{u==null||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>k(),hasHydrated:()=>l,onHydrate:w=>(o.add(w),()=>{o.delete(w)}),onFinishHydration:w=>(c.add(w),()=>{c.delete(w)})},i.skipHydration||k(),v||m},M0=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((T0?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),L0(e,t)):R0(e,t),tp=M0,z0=Jc()(tp((e,t)=>({theme:"light",setTheme:n=>{document.documentElement.setAttribute("data-theme",n),e({theme:n})},toggleTheme:()=>{const n=t().theme==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",n),e({theme:n})}}),{name:"flow-theme",onRehydrateStorage:()=>e=>{e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}}));function F0(){const{theme:e,toggleTheme:t}=z0();return a.jsx("button",{onClick:t,className:"p-2 rounded-md text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--accent)]","aria-label":`Switch to ${e==="dark"?"light":"dark"} mode`,title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:e==="dark"?a.jsx(Jg,{size:16}):a.jsx(Kg,{size:16})})}const I0=Jc()(tp((e,t)=>({sidebarCollapsed:!1,toggleSidebar:()=>{e({sidebarCollapsed:!t().sidebarCollapsed})}}),{name:"flow-layout"})),D0=[{path:"/",label:"Overview",icon:Bg},{path:"/agents",label:"Agents",icon:$o},{path:"/jobs",label:"Experiments",icon:Uo},{path:"/tasks",label:"Datasets",icon:$m}];function A0(){const e=as(),{sidebarCollapsed:t,toggleSidebar:n}=I0(),r=s=>s==="/"?e.pathname==="/":s==="/agents"?e.pathname==="/agents"||e.pathname.startsWith("/agents/")||e.pathname.startsWith("/deployments/"):s==="/jobs"?e.pathname.startsWith("/jobs")||e.pathname.startsWith("/runs"):e.pathname.startsWith(s);return a.jsxs("aside",{className:` + flex flex-col border-r border-[var(--border)] bg-[var(--bg-secondary)] + transition-all duration-200 + ${t?"w-14":"w-56"} + `,children:[a.jsx("nav",{className:"flex-1 py-2",children:D0.map(s=>{const i=r(s.path);return a.jsxs(zm,{to:s.path,title:t?s.label:void 0,className:` + flex items-center gap-3 px-4 py-2.5 text-sm transition-colors relative + ${i?"text-[var(--accent)] bg-[var(--accent-dim)] font-medium":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"} + `,children:[i&&a.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-r bg-[var(--accent)]"}),a.jsx(s.icon,{size:18}),!t&&a.jsx("span",{children:s.label})]},s.path)})}),a.jsx("button",{onClick:n,className:"flex items-center justify-center p-3 border-t border-[var(--border)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",title:t?"Expand sidebar":"Collapse sidebar",children:t?a.jsx(zg,{size:16}):a.jsx(Mg,{size:16})})]})}function $0(){const{authConfig:e,user:t,logout:n}=tu(),r=async()=>{await n()};return a.jsxs("div",{className:"h-screen flex flex-col",children:[a.jsx("header",{className:"border-b border-[var(--border)] bg-[var(--bg-secondary)] shrink-0",children:a.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between",children:[a.jsxs(zm,{to:"/",className:"text-lg font-semibold text-[var(--accent)] flex items-center gap-2 hover:opacity-80",children:[a.jsx(is,{size:20}),"Flow",a.jsx("span",{className:"text-[var(--text-secondary)] font-normal",children:"/optimize"})]}),a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(F0,{}),(e==null?void 0:e.enabled)&&t&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[a.jsx(Hm,{size:14}),a.jsx("span",{children:t.username})]}),a.jsx(K,{variant:"ghost",size:"sm",icon:Vg,onClick:r,title:"Sign out",children:"Sign out"})]})]})]})}),a.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[a.jsx(A0,{}),a.jsx("main",{className:"flex-1 overflow-y-auto bg-[var(--bg-primary)]",children:a.jsx("div",{className:"p-6",children:a.jsx(ug,{})})})]})]})}function q({children:e,variant:t="default"}){const n={default:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)]",success:"bg-[var(--badge-success-bg)] text-[var(--badge-success-text)] border border-[var(--badge-success-border)]",warning:"bg-[var(--badge-warning-bg)] text-[var(--badge-warning-text)] border border-[var(--badge-warning-border)]",error:"bg-[var(--badge-error-bg)] text-[var(--badge-error-text)] border border-[var(--badge-error-border)]",info:"bg-[var(--badge-info-bg)] text-[var(--badge-info-text)] border border-[var(--badge-info-border)]"};return a.jsx("span",{className:`inline-block px-2 py-0.5 text-xs font-medium rounded-md ${n[t]}`,children:e})}const U0={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};function B0(){const e=Dn(),{data:t=[],isLoading:n}=oe({queryKey:["configs"],queryFn:()=>Tn.list()}),{data:r=[],isLoading:s}=oe({queryKey:["jobs"],queryFn:()=>Mt.list()}),{data:i=[],isLoading:l}=oe({queryKey:["tasks"],queryFn:()=>kt.list()}),o=[...t].sort((d,f)=>new Date(f.created_at).getTime()-new Date(d.created_at).getTime()).slice(0,5),c=[...r].sort((d,f)=>new Date(f.created_at).getTime()-new Date(d.created_at).getTime()).slice(0,5),u=i.reduce((d,f)=>{const m=f.suite||"custom";return d[m]||(d[m]=[]),d[m].push(f),d},{});return a.jsxs("div",{children:[a.jsxs("div",{className:"mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Agent Optimizer"}),a.jsx("p",{className:"text-[var(--text-secondary)] max-w-2xl",children:"Systematically optimize and improve your AI agents across key dimensions. Define agent configurations, run experiments across task datasets, and find the best tradeoffs between quality and cost."}),a.jsx("div",{className:"flex flex-wrap gap-3 mt-4 text-sm text-[var(--text-secondary)]",children:[{icon:Qm,label:"Instructions"},{icon:qm,label:"Tools"},{icon:Im,label:"Skills"},{icon:Gg,label:"Compaction"}].map((d,f,m)=>a.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[a.jsx(d.icon,{size:14,className:"text-[var(--accent)]"}),d.label,fa.jsxs("div",{className:"p-4 border border-[var(--border)] rounded-lg bg-[var(--bg-secondary)]",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a.jsx("span",{className:"flex items-center justify-center w-7 h-7 rounded-full bg-[var(--accent)]/10 text-[var(--accent)] text-xs font-bold",children:d.step}),a.jsx(d.icon,{size:18,className:"text-[var(--accent)]"})]}),a.jsx("h3",{className:"font-medium text-sm",children:d.title}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:d.description})]},d.step))}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mb-6",children:[a.jsxs("div",{children:[a.jsx(bl,{title:"Recent Agents",icon:$o,count:t.length,onShowAll:()=>e("/agents")}),n?a.jsx(Nl,{}):o.length===0?a.jsx(Sl,{message:"No agents yet. Create your first agent to get started."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:o.map((d,f)=>a.jsxs("div",{onClick:()=>e(`/agents/${d.id}`),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${fe("/jobs")}),s?a.jsx(Nl,{}):c.length===0?a.jsx(Sl,{message:"No experiments yet. Start one from an agent's detail page."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:c.map((d,f)=>a.jsxs("div",{onClick:()=>e(`/jobs/${d.id}`),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${fe("/tasks")}),l?a.jsx(Nl,{}):Object.keys(u).length===0?a.jsx(Sl,{message:"No datasets yet. Import a task suite to get started."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:Object.entries(u).map(([d,f],m,v)=>a.jsx("div",{onClick:()=>e("/tasks"),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${m0&&a.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",n,")"]})]}),n>0&&a.jsxs("button",{onClick:r,className:"text-sm text-[var(--accent)] hover:underline flex items-center gap-1",children:["Show all ",a.jsx(Pg,{size:14})]})]})}function Nl(){return a.jsx("div",{className:"text-sm text-[var(--text-secondary)] mb-8",children:"Loading..."})}function Sl({message:e}){return a.jsx("div",{className:"text-sm text-[var(--text-secondary)] py-6 text-center border border-[var(--border)] rounded-lg mb-8",children:e})}const Q0=["maf","miniagent","langgraph"],V0={maf:"Microsoft Agent Framework",miniagent:"MiniAgent",langgraph:"LangGraph"},K0={openai:"OpenAI",azure_openai:"Azure OpenAI",anthropic:"Anthropic",ollama:"Ollama",custom:"Custom (OpenAI-compatible)"},H0={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"};function ls({isOpen:e,onClose:t,title:n,children:r,footer:s,size:i="md"}){return g.useEffect(()=>{const l=o=>{o.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",l),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",l),document.body.style.overflow=""}},[e,t]),e?a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),a.jsxs("div",{className:`relative bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg ${H0[i]} w-full mx-4 max-h-[80vh] flex flex-col`,children:[a.jsxs("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-b border-[var(--border)] px-4 py-3 flex items-center justify-between",children:[a.jsx("h2",{className:"font-semibold",children:n}),a.jsx("button",{onClick:t,className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"×"})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r}),s&&a.jsx("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-t border-[var(--border)] px-4 py-3",children:s})]})]}):null}function yn({label:e,className:t="",...n}){return a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),a.jsx("input",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] ${t}`,...n})]})}function q0({label:e,className:t="",...n}){return a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),a.jsx("textarea",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] resize-y min-h-[100px] ${t}`,...n})]})}function Si({label:e,className:t="",...n}){return a.jsxs("label",{className:`flex items-center gap-2 cursor-pointer ${t}`,children:[a.jsx("input",{type:"checkbox",className:"w-4 h-4 bg-[var(--bg-primary)] border border-[var(--border)] rounded accent-[var(--accent)]",...n}),a.jsx("span",{className:"text-sm",children:e})]})}function np({columns:e,data:t,onRowClick:n,searchable:r=!1,searchPlaceholder:s="Search...",searchFilter:i,emptyMessage:l="No items found",emptyIcon:o}){const[c,u]=g.useState(""),[d,f]=g.useState(null),[m,v]=g.useState("asc"),k=g.useMemo(()=>{let b=t;if(r&&c&&i&&(b=b.filter(p=>i(p,c))),d){const p=e.find(h=>h.key===d);p!=null&&p.sortValue&&(b=[...b].sort((h,x)=>{const j=p.sortValue(h),C=p.sortValue(x),S=jC?1:0;return m==="asc"?S:-S}))}return b},[t,c,i,r,d,m,e]),w=b=>{const p=e.find(h=>h.key===b);p!=null&&p.sortable&&(d===b?v(m==="asc"?"desc":"asc"):(f(b),v("asc")))};return a.jsxs("div",{children:[r&&a.jsxs("div",{className:"mb-4 relative max-w-sm",children:[a.jsx(qg,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]"}),a.jsx("input",{type:"text",placeholder:s,value:c,onChange:b=>u(b.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md pl-9 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]"})]}),k.length===0?a.jsxs("div",{className:"text-center py-16 text-[var(--text-secondary)]",children:[o&&a.jsx("div",{className:"mb-3 flex justify-center",children:o}),a.jsx("p",{children:l})]}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsx("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:e.map(b=>a.jsx("th",{onClick:()=>w(b.key),className:`text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider ${b.sortable?"cursor-pointer hover:text-[var(--text-primary)]":""} ${b.className||""}`,children:a.jsxs("span",{className:"inline-flex items-center gap-1",children:[b.header,b.sortable&&d===b.key&&a.jsx("span",{children:m==="asc"?"↑":"↓"})]})},b.key))})}),a.jsx("tbody",{children:k.map((b,p)=>a.jsx("tr",{onClick:()=>n==null?void 0:n(b),className:`border-b border-[var(--border)] last:border-b-0 transition-colors ${n?"cursor-pointer hover:bg-[var(--bg-tertiary)]":""}`,children:e.map(h=>a.jsx("td",{className:`px-4 py-3 ${h.className||""}`,children:h.render(b)},h.key))},p))})]})})]})}function W0({variations:e,onChange:t,strategies:n,availableStrategies:r}){const s=r??Object.keys(n),i=()=>{const u=e.map(v=>v.strategy),d=s.find(v=>!u.includes(v))||"none",f=n[d],m={strategy:d};if(f!=null&&f.params)for(const[v,k]of Object.entries(f.params))k.default!==void 0&&(m[v]=k.default);t([...e,m])},l=u=>{t(e.filter((d,f)=>f!==u))},o=(u,d)=>{t(e.map((f,m)=>m===u?{...f,...d}:f))},c=(u,d)=>{const f=n[d],m={strategy:d};if(f!=null&&f.params)for(const[v,k]of Object.entries(f.params))k.default!==void 0&&(m[v]=k.default);o(u,m)};return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm font-medium",children:"Compaction Strategies"}),a.jsx(K,{type:"button",variant:"ghost",size:"sm",icon:Wc,onClick:i,disabled:e.length>=s.length,children:"Add"})]}),e.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:'No compaction variations. Click "Add" to test different strategies.'}):a.jsx("div",{className:"space-y-2",children:e.map((u,d)=>{const f=n[u.strategy];return a.jsx("div",{className:"p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsx("select",{className:"w-full px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:u.strategy,onChange:m=>c(d,m.target.value),children:s.map(m=>{var v;return a.jsx("option",{value:m,children:((v=n[m])==null?void 0:v.label)||m},m)})}),(f==null?void 0:f.description)&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:f.description}),(f==null?void 0:f.params)&&Object.keys(f.params).length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:Object.entries(f.params).map(([m,v])=>a.jsx(G0,{name:m,schema:v,value:u[m],onChange:k=>o(d,{[m]:k})},m))})]}),a.jsx("button",{type:"button",onClick:()=>l(d),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:a.jsx(Wm,{size:16})})]})},d)})})]})}function G0({name:e,schema:t,value:n,onChange:r}){const s=e.replace(/_/g," ");return t.type==="boolean"?a.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[a.jsx("input",{type:"checkbox",checked:!!(n??t.default),onChange:i=>r(i.target.checked),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"capitalize",children:s})]}):a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:s}),a.jsx("input",{type:t.type==="number"?"number":"text",className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-xs",value:String(n!==void 0?n:t.default??""),onChange:i=>{if(t.type==="number"){const l=parseFloat(i.target.value);r(isNaN(l)?t.default:l)}else r(i.target.value)},min:t.min,max:t.max,step:t.max&&t.max<=1?.1:1})]})}function J0({variations:e,onChange:t,providers:n}){const r=()=>{const o=n[0],c={provider:(o==null?void 0:o.name)||"azure_openai",model:(o==null?void 0:o.models[0])||"gpt-4o"};t([...e,c])},s=o=>{t(e.filter((c,u)=>u!==o))},i=(o,c)=>{t(e.map((u,d)=>d===o?{...u,...c}:u))},l=(o,c)=>{const u=n.find(d=>d.name===c);i(o,{provider:c,model:(u==null?void 0:u.models[0])||""})};return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm font-medium",children:"LLM Configurations"}),a.jsx(K,{type:"button",variant:"ghost",size:"sm",icon:Wc,onClick:r,children:"Add"})]}),e.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:`Uses agent's default LLM. Click "Add" to test different models.`}):a.jsx("div",{className:"space-y-2",children:e.map((o,c)=>{const u=n.find(d=>d.name===o.provider);return a.jsxs("div",{className:"flex items-center gap-2 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[a.jsx("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.provider,onChange:d=>l(c,d.target.value),children:n.map(d=>a.jsx("option",{value:d.name,children:d.label},d.name))}),u&&u.models.length>0?a.jsxs("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:d=>i(c,{model:d.target.value}),children:[u.models.map(d=>a.jsx("option",{value:d,children:d},d)),!u.models.includes(o.model)&&o.model&&a.jsx("option",{value:o.model,children:o.model})]}):a.jsx("input",{type:"text",className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:d=>i(c,{model:d.target.value}),placeholder:"Model ID"}),a.jsx("button",{type:"button",onClick:()=>s(c),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:a.jsx(Wm,{size:16})})]},c)})})]})}const Vo={compaction:[],tools:[],llm_config:[],instructions:[],instruction_strategies:[]};function Y0({agentId:e,agentName:t,agentFramework:n="maf",taskSuite:r,taskCount:s,schema:i,onVariationsChange:l,parallel:o,onParallelChange:c,budget:u,onBudgetChange:d,useLlmEval:f,onUseLlmEvalChange:m}){const[v,k]=g.useState(Vo),[w,b]=g.useState(!1),[p,h]=g.useState(""),[x,j]=g.useState(null),C=i.frameworks[n],S=(C==null?void 0:C.compaction_strategies)||Object.keys(i.compaction_strategies),N=i.tool_presets||[],_=i.llm_providers||[],L=(()=>{let T=1;v.compaction.length>0&&(T*=v.compaction.length),v.tools.length>0&&(T*=v.tools.length),v.llm_config.length>0&&(T*=v.llm_config.length);const V=v.instructions.length+v.instruction_strategies.reduce((te,O)=>te+O.max_candidates,0);return V>0&&(T*=V),Math.min(T,u)})(),B=L*s,J=T=>{k(T),l==null||l(T)},se=Ze({mutationFn:T=>Qo.design(T),onSuccess:T=>{h(T.yaml_content),b(!0)}}),ce=Ze({mutationFn:T=>Qo.validate(T),onSuccess:T=>{j({valid:T.valid,errors:T.errors,warnings:T.warnings})}}),D=()=>({base_agent_id:e,task_suite:r,variations:v,parallel:o,budget:u,use_llm_eval:f}),W=()=>{se.mutate(D())},Z=()=>{ce.mutate(D())},P=()=>{const T=new Blob([p],{type:"text/yaml"}),V=URL.createObjectURL(T),te=document.createElement("a");te.href=V,te.download=`${t}_experiment.yaml`,te.click(),URL.revokeObjectURL(V)},A=v.compaction.length>0||v.tools.length>0||v.llm_config.length>0||v.instructions.length>0||v.instruction_strategies.length>0;return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsxs(q,{variant:"info",children:[L," candidates"]}),a.jsxs(q,{children:[s," tasks"]}),a.jsxs(q,{variant:B>100?"warning":"success",children:[B," total runs"]})]}),a.jsx(W0,{variations:v.compaction,onChange:T=>J({...v,compaction:T}),strategies:i.compaction_strategies,availableStrategies:S}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("label",{className:"text-sm font-medium",children:"Tool Presets"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(T=>a.jsxs("label",{className:`flex items-center gap-2 px-3 py-1.5 border rounded cursor-pointer transition-colors ${v.tools.includes(T.name)?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[a.jsx("input",{type:"checkbox",checked:v.tools.includes(T.name),onChange:V=>{const te=V.target.checked?[...v.tools,T.name]:v.tools.filter(O=>O!==T.name);J({...v,tools:te})},className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:T.name}),a.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",T.tools.length,")"]})]},T.name))}),v.tools.length>0&&a.jsxs("p",{className:"text-xs text-[var(--text-secondary)]",children:["Selected: ",v.tools.join(", ")]})]}),a.jsx(J0,{variations:v.llm_config,onChange:T=>J({...v,llm_config:T}),providers:_}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-4 space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium",children:"Execution Settings"}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(yn,{label:"Parallel Workers",type:"number",value:o,onChange:T=>c(parseInt(T.target.value)||1),min:1,max:16}),a.jsx(yn,{label:"Budget (max candidates)",type:"number",value:u,onChange:T=>d(parseInt(T.target.value)||100),min:1,max:1e3})]}),a.jsx(Si,{label:"Use LLM evaluation",checked:f,onChange:T=>m(T.target.checked)}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] ml-6 -mt-2",children:f?"LLM-as-Judge scores task completion (0-1)":"Simple pass/fail based on task success"})]}),a.jsxs("div",{className:"flex items-center gap-2 border-t border-[var(--border)] pt-4",children:[a.jsx(K,{variant:"secondary",size:"sm",onClick:Z,loading:ce.isPending,children:"Validate"}),a.jsx(K,{variant:"secondary",size:"sm",icon:Ld,onClick:W,loading:se.isPending,children:"Export YAML"})]}),x&&a.jsxs("div",{className:`p-3 rounded border ${x.valid?"border-green-500/50 bg-green-500/10":"border-red-500/50 bg-red-500/10"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[x.valid?a.jsx(Dm,{size:16,className:"text-green-500"}):a.jsx(Fm,{size:16,className:"text-red-500"}),a.jsx("span",{className:"font-medium text-sm",children:x.valid?"Configuration valid":"Configuration has issues"})]}),x.errors.length>0&&a.jsx("ul",{className:"text-sm text-red-500 list-disc ml-6",children:x.errors.map((T,V)=>a.jsx("li",{children:T},V))}),x.warnings.length>0&&a.jsx("ul",{className:"text-sm text-yellow-500 list-disc ml-6 mt-1",children:x.warnings.map((T,V)=>a.jsx("li",{children:T},V))})]}),w&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-lg shadow-xl max-w-2xl w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border)]",children:[a.jsx("h3",{className:"font-medium",children:"Experiment YAML"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(K,{variant:"secondary",size:"sm",icon:Ld,onClick:P,children:"Download"}),a.jsx(K,{variant:"ghost",size:"sm",onClick:()=>b(!1),children:"Close"})]})]}),a.jsx("pre",{className:"flex-1 overflow-auto p-4 text-xs font-mono bg-[var(--bg-secondary)]",children:p})]})}),!A&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No variations selected. Only the baseline agent will be tested. Add compaction strategies, tool presets, or LLM configs to generate candidates."})]})}const X0=[{key:"instruction",label:"Optimize Instructions",description:"LLM iteratively evaluates and rewrites agent instructions",icon:Qm},{key:"tool",label:"Optimize Tools",description:"LLM analyzes which tools help or hurt and adjusts tool config",icon:qm},{key:"skill",label:"Optimize Skills",description:"LLM generates and refines agent skill files (SKILL.md)",icon:Im}];function rp({agent:e,isOpen:t,onClose:n}){var H;const r=Dn(),s=Yt(),[i,l]=g.useState("ready"),[o,c]=g.useState("quick"),[u,d]=g.useState(!1),[f,m]=g.useState([]),[v,k]=g.useState([]),[w,b]=g.useState(5),[p,h]=g.useState(!1),[x,j]=g.useState(Vo),[C,S]=g.useState(4),[N,_]=g.useState(100),[z,L]=g.useState(!1),[B,J]=g.useState(null),{data:se=[]}=oe({queryKey:["tasks"],queryFn:()=>kt.list()}),{data:ce=[]}=oe({queryKey:["suites"],queryFn:()=>kt.listSuites()}),{data:D}=oe({queryKey:["agent-schema"],queryFn:()=>ep.getAgentSchema()}),W=ce.map(F=>({value:F.name,label:F.name.charAt(0).toUpperCase()+F.name.slice(1),description:F.description,tasks:F.task_count})),Z=Ze({mutationFn:kt.importSuite,onSuccess:F=>{s.invalidateQueries({queryKey:["tasks"]}),m(F.map(re=>re.id))}}),P=Ze({mutationFn:async F=>{const re=await Mt.create(F);return Mt.start(re.id).next(),re},onSuccess:F=>{s.invalidateQueries({queryKey:["jobs"]}),J(F.id),l("success")}}),A=()=>{let F=1;x.compaction.length>0&&(F*=x.compaction.length),x.tools.length>0&&(F*=x.tools.length),x.llm_config.length>0&&(F*=x.llm_config.length);const re=x.instructions.length+x.instruction_strategies.reduce((Oe,mt)=>Oe+mt.max_candidates,0);return re>0&&(F*=re),Math.min(F,N)},T=p&&(x.compaction.length>0||x.tools.length>0||x.llm_config.length>0||x.instructions.length>0||x.instruction_strategies.length>0),V=v.length>0&&!T,te=T?A():1,O=u?f.length:((H=W.find(F=>F.value===o))==null?void 0:H.tasks)||3,Q=V?O*v.length:te*O,Ce=async()=>{l("starting");let F=f;if(!u)try{F=(await Z.mutateAsync(o)).map(Oe=>Oe.id)}catch(re){console.error("Failed to import suite:",re),alert(`Failed to import task suite: ${o}`),l("ready");return}if(F.length===0){alert("No tasks selected. Please select tasks or choose a task suite."),l("ready");return}if(V){const re=v.join(","),Oe={name:`${e.name} — ${v.join(" → ")} optimization`,task_ids:F,parallel:C,use_llm_eval:z,strategy:re,strategy_config:{max_iterations:w},base_agent_id:e.id};P.mutate(Oe)}else{let re;if(T)try{re=(await Qo.generateCandidates({base_agent_id:e.id,variations:x,budget:N})).candidate_ids}catch(mt){console.error("Failed to generate candidates:",mt),alert(`Failed to generate candidates: ${mt instanceof Error?mt.message:"Unknown error"}`),l("ready");return}else re=[e.id];const Oe={name:`${e.name} optimization (${re.length} candidates × ${F.length} tasks)`,candidate_ids:re,task_ids:F,parallel:C,use_llm_eval:z};P.mutate(Oe)}},ke=F=>{m(re=>re.includes(F)?re.filter(Oe=>Oe!==F):[...re,F])},_e=()=>{l("ready"),J(null),h(!1),k([]),j(Vo),n()},R=()=>i==="success"&&B?a.jsxs("div",{className:"flex justify-end gap-3",children:[a.jsx(K,{variant:"secondary",onClick:_e,children:"Close"}),a.jsx(K,{variant:"primary",icon:ea,onClick:()=>{_e(),r(`/jobs/${B}`)},children:"View Job"})]}):i==="starting"?null:a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(K,{variant:"secondary",onClick:n,children:"Cancel"}),a.jsx(K,{variant:"primary",icon:ea,onClick:Ce,disabled:u&&f.length===0,children:V?`Start Optimization (${O} tasks)`:`Start Optimization (${Q} runs)`})]});return a.jsx(ls,{isOpen:t,onClose:_e,title:`Optimize: ${e.name}`,footer:R(),size:"lg",children:i==="success"&&B?a.jsxs("div",{className:"flex flex-col items-center py-8",children:[a.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/20 flex items-center justify-center mb-4",children:a.jsx(is,{size:24,className:"text-green-500"})}),a.jsx("h3",{className:"text-lg font-medium mb-2",children:"Job Started!"}),a.jsx("p",{className:"text-[var(--text-secondary)] text-center mb-2",children:V?`Running ${v.join(" → ")} optimization`:"Optimization job is now running"}),a.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-3 py-1.5 rounded font-mono",children:["ID: ",B.slice(0,8),"..."]})]}):i==="starting"?a.jsxs("div",{className:"flex flex-col items-center py-8",children:[a.jsx(ma,{size:32,className:"animate-spin text-[var(--accent)] mb-4"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:Z.isPending?"Importing tasks...":"Creating optimization job..."})]}):a.jsxs("div",{className:"space-y-5",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Task Suite"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:u?"__custom__":o,onChange:F=>{F.target.value==="__custom__"?d(!0):(d(!1),c(F.target.value))},children:[W.map(F=>a.jsxs("option",{value:F.value,children:[F.label," (",F.tasks," tasks) — ",F.description]},F.value)),se.length>0&&a.jsx("option",{value:"__custom__",children:"Custom Selection"})]})]}),u&&se.length>0&&a.jsx("div",{className:"max-h-48 overflow-y-auto border border-[var(--border)] rounded p-2 space-y-1",children:se.map(F=>a.jsxs("label",{className:"flex items-center gap-2 p-2 hover:bg-[var(--bg-tertiary)] cursor-pointer rounded",children:[a.jsx("input",{type:"checkbox",checked:f.includes(F.id),onChange:()=>ke(F.id),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:F.name}),F.suite&&a.jsx(q,{children:F.suite})]},F.id))}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Optimization Strategy"}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mb-3",children:"Select one or more strategies. Multiple strategies run as a pipeline — each stage's best agent feeds into the next. Leave all unchecked for a baseline evaluation."}),a.jsx("div",{className:"space-y-2",children:X0.map(F=>{const re=v.includes(F.key),Oe=v.indexOf(F.key);return a.jsxs("label",{className:`flex items-start gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${re?"border-[var(--accent)] bg-[var(--accent)]/5":"border-[var(--border)] hover:border-[var(--text-secondary)]"}`,children:[a.jsx("input",{type:"checkbox",checked:re,onChange:()=>{k(mt=>re?mt.filter(xa=>xa!==F.key):[...mt,F.key])},className:"accent-[var(--accent)] mt-0.5"}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(F.icon,{size:14,className:"text-[var(--accent)]"}),a.jsx("span",{className:"text-sm font-medium",children:F.label}),re&&v.length>1&&a.jsxs(q,{variant:"info",children:["Step ",Oe+1]})]}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:F.description})]})]},F.key)})}),v.length>1&&a.jsxs("p",{className:"text-xs text-[var(--text-secondary)] mt-2",children:["Pipeline: ",v.join(" → ")]}),v.length>0&&a.jsx("div",{className:"mt-3 pl-8",children:a.jsxs("label",{className:"text-xs text-[var(--text-secondary)] flex items-center gap-2",children:["Max iterations",a.jsx("input",{type:"number",min:1,max:20,value:w,onChange:F=>b(parseInt(F.target.value)||5),className:"w-16 px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm"})]})})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[a.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>h(!p),children:[a.jsx(Zs,{size:14,className:`transition-transform ${p?"rotate-90":""}`}),"Advanced: Grid Search",p&&a.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"(manual variation design)"})]}),p&&a.jsxs("div",{className:"mt-3",children:[T&&v.length>0&&a.jsx("div",{className:"mb-3 p-2 rounded bg-yellow-500/10 border border-yellow-500/30 text-xs text-yellow-600 dark:text-yellow-400",children:"Grid variations are set — this will override the strategy selection and run a static grid search instead."}),D&&a.jsx(Y0,{agentId:e.id,agentName:e.name,agentFramework:e.config.framework,taskSuite:u?void 0:o,taskCount:O,schema:D,onVariationsChange:j,parallel:C,onParallelChange:S,budget:N,onBudgetChange:_,useLlmEval:z,onUseLlmEvalChange:L})]})]})]})})}function Z0(){const e=Dn(),t=Yt(),[n,r]=g.useState(!1),[s,i]=g.useState(null),{data:l=[],isLoading:o}=oe({queryKey:["configs"],queryFn:()=>Tn.list()}),c=Ze({mutationFn:Tn.create,onSuccess:()=>{t.invalidateQueries({queryKey:["configs"]}),r(!1)}}),u=Ze({mutationFn:Tn.delete,onSuccess:()=>t.invalidateQueries({queryKey:["configs"]})}),d=[{key:"name",header:"Name",render:f=>a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:f.name})},{key:"framework",header:"Framework",render:f=>a.jsx(q,{children:f.config.framework||"maf"})},{key:"tools",header:"Tools",render:f=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:e1(f.config.tools)})},{key:"compaction",header:"Compaction",render:f=>{const m=f.config.compaction;return!m||m.strategy==="none"?a.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"}):m.strategy==="head_tail"?a.jsxs(q,{children:[m.params.head_size,"/",m.params.tail_size]}):a.jsx(q,{children:m.strategy})}},{key:"created",header:"Created",render:f=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(f.created_at).toLocaleDateString()}),sortable:!0,sortValue:f=>new Date(f.created_at).getTime()},{key:"actions",header:"",className:"w-40",render:f=>a.jsxs("div",{className:"flex items-center gap-2",onClick:m=>m.stopPropagation(),children:[a.jsx(K,{variant:"primary",size:"sm",icon:is,onClick:()=>i(f),children:"Optimize"}),a.jsx(K,{variant:"ghost",size:"sm",icon:Gc,title:"Delete",onClick:()=>{confirm(`Delete agent "${f.name}"?`)&&u.mutate(f.id)}})]})}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Agents"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Define and optimize your agent configurations."})]}),a.jsx(K,{variant:"primary",icon:Wc,onClick:()=>r(!0),children:"Create agent"})]}),o?a.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[a.jsx(ma,{size:16,className:"animate-spin"}),"Loading agents..."]}):a.jsx(np,{columns:d,data:l,onRowClick:f=>e(`/agents/${f.id}`),searchable:!0,searchPlaceholder:"Search agents",searchFilter:(f,m)=>f.name.toLowerCase().includes(m.toLowerCase())||(f.description||"").toLowerCase().includes(m.toLowerCase()),emptyMessage:"No agents yet. Create your first agent to start optimizing.",emptyIcon:a.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-[var(--bg-tertiary)]",children:a.jsx(Km,{size:24,className:"text-[var(--text-secondary)]"})})}),a.jsx(t1,{isOpen:n,onClose:()=>r(!1),onSubmit:f=>c.mutate(f),isLoading:c.isPending}),s&&a.jsx(rp,{agent:s,isOpen:!!s,onClose:()=>i(null)})]})}function e1(e){return typeof e=="string"?e:Array.isArray(e)?`[${e.length}]`:e&&typeof e=="object"?`[${Object.keys(e).length}]`:"standard"}function t1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){var V,te,O,Q,Ce,ke,_e;const s=["read_file","write_file","edit_file","bash","grep","think"],[i,l]=g.useState("preset"),[o,c]=g.useState({name:"",description:"",instructions:null,model:null,compaction:{strategy:"none",params:{}},tools:s,framework:"miniagent",llm_config_id:null}),[u,d]=g.useState(!1),[f,m]=g.useState("preset"),[v,k]=g.useState([...s]),[w,b]=g.useState(!1),{data:p}=oe({queryKey:["agent-schema"],queryFn:()=>ep.getAgentSchema()}),{data:h=[]}=oe({queryKey:["llm-configs"],queryFn:()=>C0.list()}),{data:x}=oe({queryKey:["tools"],queryFn:()=>_0.list()}),j=((V=x==null?void 0:x.tools)==null?void 0:V.map(R=>R.name))??s,C=(x==null?void 0:x.presets)??{},S=Object.keys(C),N=(p==null?void 0:p.frameworks)??{},_=Object.keys(N).length>0?Object.keys(N):Q0,z=o.framework||"miniagent",L=((O=(te=p==null?void 0:p.frameworks)==null?void 0:te[z])==null?void 0:O.compaction_strategies)??["none","head_tail"],B=(p==null?void 0:p.compaction_strategies)??{},J=(p==null?void 0:p.agent_presets)??[],se=R=>{const H=R.config,F=H.compaction;n({name:R.name+"-agent",description:R.description,framework:H.framework||"miniagent",tools:H.tools||"standard",compaction:F||{strategy:"none",params:{}},instructions:H.instructions||null})},ce=R=>{if(R.preventDefault(),!o.name.trim())return;const H={...o};f==="custom"&&(H.tools=v),n(H)},D=((Q=o.compaction)==null?void 0:Q.strategy)!=="none",W=((Ce=o.compaction)==null?void 0:Ce.strategy)||"none",Z=B[W],P=R=>{k(H=>H.includes(R)?H.filter(F=>F!==R):[...H,R])},A=R=>{const H=B[R],F={};if(H!=null&&H.params)for(const[re,Oe]of Object.entries(H.params))Oe.default!==void 0&&(F[re]=Oe.default);c({...o,compaction:{strategy:R,params:F}})},T=i==="custom"?a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(K,{type:"submit",form:"create-agent-form",variant:"primary",disabled:!o.name.trim(),loading:r,children:"Create Agent"})]}):a.jsx("div",{className:"flex justify-end gap-2",children:a.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"})});return a.jsxs(ls,{isOpen:e,onClose:t,title:"Create Agent",footer:T,children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b border-[var(--border)]",children:[a.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${i==="preset"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("preset"),children:"From Preset"}),a.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${i==="custom"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("custom"),children:"Custom"})]}),i==="preset"?a.jsx("div",{className:"space-y-3",children:J.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"Loading presets..."}):J.map(R=>a.jsx("button",{type:"button",className:"w-full text-left p-4 border border-[var(--border)] rounded-lg hover:border-[var(--accent)] hover:bg-[var(--accent)]/5 transition-colors",onClick:()=>se(R),disabled:r,children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("h4",{className:"font-medium",children:R.label}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:R.description}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[R.tags.map(H=>a.jsx(q,{variant:"default",children:H},H)),R.suggested_datasets.length>0&&a.jsxs(q,{variant:"success",children:["datasets: ",R.suggested_datasets.join(", ")]})]})]}),a.jsx(Zs,{size:16,className:"text-[var(--text-secondary)] mt-1 flex-shrink-0"})]})},R.name))}):a.jsxs("form",{id:"create-agent-form",onSubmit:ce,className:"space-y-4",children:[a.jsx(yn,{label:"Name",value:o.name,onChange:R=>c({...o,name:R.target.value}),placeholder:"e.g., my-coding-agent",required:!0}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"LLM Configuration"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.llm_config_id||"",onChange:R=>c({...o,llm_config_id:R.target.value||null}),children:[a.jsx("option",{value:"",children:"Use environment variables"}),h.map(R=>a.jsxs("option",{value:R.id,children:[R.name," (",K0[R.provider],R.model_id?` - ${R.model_id}`:"",")",R.is_default?" (default)":""]},R.id))]}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:h.length===0?"No LLM configs found. Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)":o.llm_config_id?"Uses the selected LLM configuration.":"Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Framework"}),a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.framework||"miniagent",onChange:R=>{const H=R.target.value;c({...o,framework:H,compaction:{strategy:"none",params:{}}})},children:_.map(R=>{var H;return a.jsx("option",{value:R,children:((H=N[R])==null?void 0:H.label)||V0[R]||R},R)})}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((ke=N[z])==null?void 0:ke.description)||(z==="miniagent"?"Lightweight agent with token-aware context management.":z==="langgraph"?"Graph-based workflows with state management.":"Default agent implementation.")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(Si,{label:"Custom instructions",checked:u,onChange:R=>{d(R.target.checked),R.target.checked||c({...o,instructions:null})}}),a.jsx(Si,{label:"Enable compaction",checked:D,onChange:R=>{if(R.target.checked){const H=L.find(F=>F!=="none")||"head_tail";A(H)}else c({...o,compaction:{strategy:"none",params:{}}})}})]}),u&&a.jsx("textarea",{className:"w-full h-32 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono resize-y",value:o.instructions||"",onChange:R=>c({...o,instructions:R.target.value||null}),placeholder:"System prompt / instructions for the agent..."}),D&&a.jsxs("div",{className:"space-y-3 p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Compaction Strategy"}),a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:W,onChange:R=>A(R.target.value),children:L.filter(R=>R!=="none").map(R=>{var H;return a.jsx("option",{value:R,children:((H=B[R])==null?void 0:H.label)||R},R)})}),(Z==null?void 0:Z.description)&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:Z.description})]}),(Z==null?void 0:Z.params)&&Object.keys(Z.params).length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-3",children:Object.entries(Z.params).map(([R,H])=>{var Oe;const F=(Oe=o.compaction)==null?void 0:Oe.params[R],re=F!==void 0?F:H.default;return a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:R.replace(/_/g," ")}),a.jsx("input",{type:"number",className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof re=="number"?re:Number(re)||0,onChange:mt=>{const xa=parseFloat(mt.target.value);c({...o,compaction:{...o.compaction,params:{...o.compaction.params,[R]:isNaN(xa)?typeof H.default=="number"?H.default:0:xa}}})},min:H.min,max:H.max,step:H.max&&H.max<=1?.1:1}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:H.description})]},R)})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm font-medium",children:"Tools"}),a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"radio",checked:f==="preset",onChange:()=>m("preset"),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:"Preset"})]}),a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"radio",checked:f==="custom",onChange:()=>m("custom"),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:"Custom"})]})]}),f==="preset"?a.jsxs(a.Fragment,{children:[a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof o.tools=="string"?o.tools:"standard",onChange:R=>c({...o,tools:R.target.value}),children:S.map(R=>a.jsx("option",{value:R,children:R},R))}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((_e=C[typeof o.tools=="string"?o.tools:"standard"])==null?void 0:_e.join(", "))??""})]}):a.jsx("div",{className:"grid grid-cols-2 gap-1 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:j.map(R=>a.jsxs("label",{className:"flex items-center gap-2 p-1 text-sm cursor-pointer hover:bg-[var(--bg-tertiary)]",children:[a.jsx("input",{type:"checkbox",checked:v.includes(R),onChange:()=>P(R),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"font-mono text-xs",children:R})]},R))})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[a.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>b(!w),children:[a.jsx(Zs,{size:14,className:`transition-transform ${w?"rotate-90":""}`}),"More options"]}),w&&a.jsx("div",{className:"mt-3",children:a.jsx(yn,{label:"Description (optional)",value:o.description,onChange:R=>c({...o,description:R.target.value}),placeholder:"Brief description of this agent"})})]})]})]})}function pa({items:e}){return a.jsx("nav",{className:"flex items-center gap-1.5 text-sm mb-4",children:e.map((t,n)=>{const r=n===e.length-1;return a.jsxs("span",{className:"flex items-center gap-1.5",children:[n>0&&a.jsx(Zs,{size:14,className:"text-[var(--text-secondary)]"}),t.path&&!r?a.jsx(Rn,{to:t.path,className:"text-[var(--text-secondary)] hover:text-[var(--accent)] transition-colors",children:t.label}):a.jsx("span",{className:r?"text-[var(--text-primary)] font-medium":"text-[var(--text-secondary)]",children:t.label})]},n)})})}function ge({children:e,className:t="",onClick:n,selected:r=!1,selectable:s=!1}){const i="bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",l=s?"cursor-pointer hover:border-[var(--accent-dim)] transition-colors":"",o=r?"border-[var(--accent)]":"";return a.jsx("div",{className:`${i} ${l} ${o} ${t}`,onClick:n,children:e})}function n1(e){const t=[],n=r=>r.type==="trace_span"&&typeof r.data=="object"&&r.data!==null?r.data:"span_id"in r?r:null;if(Array.isArray(e.spans)){for(const r of e.spans)if(typeof r=="object"&&r!==null){const s=n(r);s&&t.push(s)}}else if(e.span_id)t.push(e);else for(const r in e){const s=e[r];if(typeof s=="object"&&s!==null){const i=n(s);if(i)t.push(i);else if(Array.isArray(s)){for(const l of s)if(typeof l=="object"&&l!==null){const o=n(l);o&&t.push(o)}}}}return t}function sp(e){const t=new Map,n=[];for(const s of e)t.set(s.span_id,{span:s,children:[]});for(const s of e){const i=t.get(s.span_id);s.parent_span_id&&t.has(s.parent_span_id)?t.get(s.parent_span_id).children.push(i):n.push(i)}const r=s=>{s.sort((i,l)=>(i.span.start_time||0)-(l.span.start_time||0)),s.forEach(i=>r(i.children))};return r(n),n}function r1(e){return e.includes("Agent")||e.includes("agent")?"bg-[var(--span-llm-bg)] text-[var(--span-llm-text)]":e.includes("chat")||e.includes("Chat")||e.includes("llm")?"bg-[var(--span-tool-bg)] text-[var(--span-tool-text)]":e.includes("tool")||e.includes("execute")||e.includes("bash")?"bg-[var(--span-agent-bg)] text-[var(--span-agent-text)]":"bg-[var(--span-other-bg)] text-[var(--span-other-text)]"}function s1(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(0)}ms`}function nu({node:e,depth:t=0}){var f,m;const[n,r]=g.useState(t<2),[s,i]=g.useState(!1),{span:l}=e,o=e.children.length>0,c=(f=l.attributes)==null?void 0:f["gen_ai.usage.input_tokens"],u=(m=l.attributes)==null?void 0:m["gen_ai.usage.output_tokens"],d=c!==void 0||u!==void 0;return a.jsxs("div",{className:"relative",children:[t>0&&a.jsx("div",{className:"absolute left-0 top-0 bottom-0 border-l-2 border-[var(--border)]",style:{marginLeft:`${(t-1)*16+8}px`}}),a.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-1 hover:bg-[var(--bg-primary)] rounded transition-colors cursor-pointer",style:{paddingLeft:`${t*16}px`},onClick:()=>o?r(!n):i(!s),children:[a.jsx("div",{className:"w-4 h-4 flex items-center justify-center text-[var(--text-secondary)]",children:o?n?"▼":"▶":s?"▼":"▶"}),a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${r1(l.operation_name)}`,children:l.operation_name.replace("ChatAgent.","").replace("invoke_agent ","")}),l.duration_ms!==void 0&&a.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:s1(l.duration_ms)}),d&&a.jsxs("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:[c!==void 0&&a.jsxs("span",{className:"text-blue-400",children:["↑",String(c)]}),c!==void 0&&u!==void 0&&a.jsx("span",{className:"mx-0.5",children:"/"}),u!==void 0&&a.jsxs("span",{className:"text-green-400",children:["↓",String(u)]})]})]}),s&&!o&&a.jsx("div",{className:"ml-4 mt-1 mb-2 p-2 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs",style:{marginLeft:`${t*16+20}px`},children:a.jsxs("div",{className:"space-y-1",children:[l.span_id&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Span ID:"}),a.jsx("span",{className:"font-mono text-xs break-all",children:l.span_id})]}),l.trace_id&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Trace ID:"}),a.jsx("span",{className:"font-mono text-xs break-all",children:l.trace_id})]}),l.status&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Status:"}),a.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs ${l.status==="OK"||l.status==="StatusCode.UNSET"?"bg-[var(--span-pass-bg)] text-[var(--span-pass-text)]":"bg-[var(--span-fail-bg)] text-[var(--span-fail-text)]"}`,children:l.status})]}),Object.keys(l.attributes||{}).length>0&&a.jsxs("div",{className:"mt-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] block mb-1",children:"Attributes:"}),a.jsx("pre",{className:"text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded p-2 overflow-auto max-h-32 whitespace-pre-wrap break-all",children:JSON.stringify(l.attributes,null,2)})]})]})}),o&&n&&a.jsx("div",{children:e.children.map((v,k)=>a.jsx(nu,{node:v,depth:t+1},v.span.span_id||k))})]})}function ap({trace:e}){const[t,n]=g.useState("tree"),r=g.useMemo(()=>n1(e),[e]),s=g.useMemo(()=>sp(r),[r]);return Object.keys(e).length===0?null:a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"font-medium",children:"Trace Data"}),a.jsxs("div",{className:"flex gap-1",children:[a.jsx("button",{onClick:()=>n("tree"),className:`px-2 py-1 text-xs rounded ${t==="tree"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Tree"}),a.jsx("button",{onClick:()=>n("raw"),className:`px-2 py-1 text-xs rounded ${t==="raw"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Raw"})]})]}),t==="tree"?r.length>0?a.jsx("div",{className:"border border-[var(--border)] rounded overflow-hidden",children:a.jsxs("div",{className:"p-2",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs(q,{variant:"default",children:[r.length," spans"]}),a.jsx("span",{children:"•"}),a.jsx("span",{children:"Click to expand details"})]}),s.map((i,l)=>a.jsx(nu,{node:i,depth:0},i.span.span_id||l))]})}):a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No structured spans found. View raw data below."}):a.jsx("pre",{className:"text-xs bg-[var(--bg-primary)] p-3 overflow-x-auto border border-[var(--border)] max-h-96 whitespace-pre-wrap",children:JSON.stringify(e,null,2)})]})}function a1({spans:e,isLive:t=!1}){const n=g.useRef(null),r=g.useMemo(()=>sp(e),[e]);return g.useEffect(()=>{n.current&&t&&n.current.scrollTo({top:n.current.scrollHeight,behavior:"smooth"})},[e.length,t]),a.jsxs("div",{className:"border border-[var(--border)] rounded overflow-hidden h-full flex flex-col",children:[a.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-[var(--border)] bg-[var(--bg-secondary)]",children:[a.jsxs(q,{variant:"default",children:[e.length," spans"]}),t&&a.jsx("span",{className:"animate-pulse",children:a.jsx(q,{variant:"info",children:"Live"})})]}),a.jsx("div",{ref:n,className:"flex-1 overflow-auto p-2",children:r.length>0?r.map((s,i)=>a.jsx(nu,{node:s,depth:0},s.span.span_id||i)):a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:t?"Waiting for spans...":"No spans recorded"})})]})}function ip({agent:e}){const[t,n]=g.useState(""),[r,s]=g.useState(null),[i,l]=g.useState("idle"),[o,c]=g.useState(null),[u,d]=g.useState(""),[f,m]=g.useState([]),[v,k]=g.useState(null),[w,b]=g.useState(null),[p,h]=g.useState([]),[x,j]=g.useState(!1),C=g.useRef(null),{data:S=[]}=oe({queryKey:["tasks"],queryFn:()=>kt.list()});g.useEffect(()=>{C.current&&i==="running"&&(C.current.scrollTop=C.current.scrollHeight)},[u,i]);const N=D=>{if(s(D),D){const W=S.find(Z=>Z.id===D);W&&n(W.prompt)}},_=async()=>{if(t.trim()){l("running"),d(""),m([]),k(null),b(null),h([]);try{const D=await Ls.create({agent_id:e.id,prompt:t.trim(),task_id:r||void 0});c(D.id);for await(const W of Ls.start(D.id))z(W)}catch(D){b(D instanceof Error?D.message:"Test failed"),l("failed")}}},z=D=>{switch(D.event){case"started":break;case"execution":D.execution_event==="text_delta"&&D.content?d(W=>W+D.content):D.execution_event==="tool_call_start"&&D.tool_name?h(W=>[...W,{name:D.tool_name}]):D.execution_event==="tool_result"&&D.content&&h(W=>{if(W.length>0){const Z=[...W];return Z[Z.length-1]={...Z[Z.length-1],content:D.content},Z}return W});break;case"span":if(D.span){const W=D.span;if(W.data){const Z={span_id:W.data.span_id||"",trace_id:W.data.trace_id||"",parent_span_id:W.data.parent_span_id||null,operation_name:W.data.operation_name||"",start_time:W.timestamp?new Date(W.timestamp).getTime():Date.now(),end_time:Date.now(),duration_ms:W.data.duration_ms||0,status:W.data.status||"OK",attributes:W.data.attributes||{}};m(P=>[...P,Z])}}break;case"complete":l("completed"),D.result&&k(D.result);break;case"error":b(D.message),l("failed");break}},L=async()=>{if(o)try{await Ls.cancel(o)}catch{}l("idle")},B=()=>{l("idle"),c(null),d(""),m([]),k(null),b(null),h([])},J=i==="running",se=i==="completed"||i==="failed",ce=D=>{D.preventDefault(),se?(B(),setTimeout(()=>_(),0)):_()};return a.jsxs("div",{className:"h-full flex flex-col border border-[var(--border)] rounded-lg overflow-hidden bg-[var(--bg-primary)]",children:[(J||se)&&a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border)] bg-[var(--bg-secondary)] flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[J&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"animate-pulse",children:a.jsx(q,{variant:"info",children:"Running"})}),a.jsx(K,{variant:"ghost",size:"sm",icon:Rd,onClick:L,children:"Cancel"})]}),i==="completed"&&a.jsx(q,{variant:"success",children:"Completed"}),i==="failed"&&a.jsx(q,{variant:"error",children:"Failed"})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[v&&a.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Am,{size:12}),v.duration_seconds.toFixed(2),"s"]}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Fg,{size:12}),v.tokens_total," tokens"]}),v.passed!==null&&(v.passed?a.jsx(Dm,{size:14,className:"text-[var(--success)]"}):a.jsx(Xg,{size:14,className:"text-[var(--error)]"}))]}),f.length>0&&a.jsxs(K,{variant:x?"primary":"secondary",size:"sm",icon:Eg,onClick:()=>j(!x),children:["Traces (",f.length,")"]}),se&&o&&a.jsx(Rn,{to:`/tests/${o}`,children:a.jsx(K,{variant:"secondary",size:"sm",icon:Um,children:"Details"})})]})]}),a.jsxs("div",{className:"flex-1 min-h-0 flex",children:[a.jsx("div",{ref:C,className:`flex-1 overflow-auto p-4 ${x?"border-r border-[var(--border)]":""}`,children:!J&&!se?a.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center",children:[a.jsx("div",{className:"text-lg font-medium mb-1",children:e.name}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] max-w-sm",children:"Send a message to test this agent, or select a task from the dropdown below."})]}):a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"flex justify-end",children:a.jsx("div",{className:"max-w-[80%] px-3 py-2 bg-[var(--accent-dim)] text-[var(--text-primary)] rounded-lg text-sm",children:t})}),(u||J)&&a.jsx("div",{className:"px-3 py-2 text-sm whitespace-pre-wrap font-mono bg-[var(--bg-secondary)] rounded-lg border border-[var(--border)]",children:u||a.jsx("span",{className:"text-[var(--text-secondary)] animate-pulse",children:"Thinking..."})}),p.length>0&&a.jsx("div",{className:"space-y-1.5",children:p.map((D,W)=>a.jsxs("div",{className:"p-2 bg-[var(--badge-info-bg)] border border-[var(--badge-info-border)] rounded-md text-xs",children:[a.jsx(q,{variant:"info",children:D.name}),D.content&&a.jsxs("div",{className:"mt-1 text-[var(--text-secondary)] truncate max-w-full font-mono",children:[D.content.substring(0,200),D.content.length>200&&"..."]})]},W))}),w&&a.jsx("div",{className:"p-3 bg-[var(--badge-error-bg)] border border-[var(--badge-error-border)] rounded-md text-sm text-[var(--badge-error-text)]",children:w})]})}),x&&a.jsx("div",{className:"w-[350px] flex-shrink-0 overflow-auto",children:a.jsx(a1,{spans:f,isLive:J})})]}),a.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] bg-[var(--bg-secondary)]",children:[a.jsx("div",{className:"px-4 pt-2",children:a.jsxs("select",{value:r||"",onChange:D=>N(D.target.value||null),className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs text-[var(--text-secondary)]",disabled:J,children:[a.jsx("option",{value:"",children:"Custom prompt..."}),S.map(D=>a.jsx("option",{value:D.id,children:D.name},D.id))]})}),a.jsxs("form",{onSubmit:ce,className:"p-3 flex gap-2",children:[a.jsx("textarea",{value:t,onChange:D=>n(D.target.value),placeholder:"Message the agent...",disabled:J,rows:1,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm resize-none min-h-[40px] max-h-[120px] focus:outline-none focus:border-[var(--accent)]",onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),ce(D))}}),a.jsx(K,{type:"submit",variant:"primary",icon:J?Rd:ea,disabled:J?!1:!t.trim(),onClick:J?L:void 0,children:J?"Stop":se?"New Test":"Run"})]})]})]})}function i1(){const{agentId:e}=ha(),t=Dn(),n=Yt(),[r,s]=g.useState("overview"),[i,l]=g.useState(!1),{data:o,isLoading:c}=oe({queryKey:["configs",e],queryFn:()=>Tn.get(e),enabled:!!e}),{data:u=[]}=oe({queryKey:["tests",{agent_id:e}],queryFn:()=>Ls.list({agent_id:e}),enabled:!!e}),{data:d=[]}=oe({queryKey:["jobs"],queryFn:()=>Mt.list()}),f=Ze({mutationFn:v=>Tn.delete(v),onSuccess:()=>{n.invalidateQueries({queryKey:["configs"]}),t("/agents")}}),m=d.filter(v=>v.candidate_ids.includes(e||""));return c?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):o?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsxs("div",{className:"mb-4 flex-shrink-0",children:[a.jsx(pa,{items:[{label:"Agents",path:"/agents"},{label:o.name}]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:o.name}),o.is_auto_generated&&a.jsx(q,{variant:"info",children:"Auto-generated"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(K,{variant:"primary",icon:is,size:"sm",onClick:()=>l(!0),children:"Optimize"}),a.jsx(K,{variant:"secondary",icon:Gc,size:"sm",onClick:()=>{confirm(`Delete agent "${o.name}"?`)&&f.mutate(o.id)},children:"Delete"})]})]}),o.description&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:o.description})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsxs("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:[a.jsxs("div",{className:"flex gap-1 mb-4 border-b border-[var(--border)] flex-shrink-0",children:[a.jsx(Cl,{active:r==="overview",onClick:()=>s("overview"),icon:a.jsx(Km,{size:14}),children:"Overview"}),a.jsx(Cl,{active:r==="evaluate",onClick:()=>s("evaluate"),icon:a.jsx(ea,{size:14}),children:"Evaluate"}),a.jsx(Cl,{active:r==="history",onClick:()=>s("history"),icon:a.jsx(Ug,{size:14}),badge:u.length,children:"History"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r==="overview"&&a.jsx(l1,{agent:o,recentTests:u,jobs:m}),r==="evaluate"&&a.jsx(o1,{agent:o,jobs:m}),r==="history"&&a.jsx(c1,{tests:u})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[a.jsx(Vm,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),a.jsx("div",{className:"flex-1 min-h-0",children:a.jsx(ip,{agent:o})})]})]}),i&&a.jsx(rp,{agent:o,isOpen:i,onClose:()=>l(!1)})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Agent not found"})}function Cl({active:e,onClick:t,icon:n,badge:r,children:s}){return a.jsxs("button",{onClick:t,className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors ${e?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[n,s,r!==void 0&&r>0&&a.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs bg-[var(--bg-tertiary)] rounded",children:r})]})}function l1({agent:e,recentTests:t,jobs:n}){var i,l;const r=e.config,s=()=>{const o=r.tools;return typeof o=="string"?o:Array.isArray(o)?o.join(", "):o&&typeof o=="object"?Object.keys(o).join(", "):"standard"};return a.jsxs("div",{className:"space-y-4",children:[a.jsx(hr,{title:"Model",children:a.jsx("div",{className:"font-mono text-sm",children:r.model||"default"})}),a.jsx(hr,{title:"Instructions",defaultCollapsed:!r.instructions,children:r.instructions?a.jsx("pre",{className:"p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs whitespace-pre-wrap max-h-40 overflow-auto font-mono",children:r.instructions}):a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No instructions set"})}),a.jsx(hr,{title:"Tools",children:a.jsx("div",{className:"font-mono text-sm",children:s()})}),a.jsx(hr,{title:"Compaction",children:a.jsx("div",{className:"font-mono text-sm",children:!r.compaction||r.compaction.strategy==="none"?"disabled":`${r.compaction.strategy} (${((i=r.compaction.params)==null?void 0:i.head_size)||0}/${((l=r.compaction.params)==null?void 0:l.tail_size)||0})`})}),t.length>0&&a.jsx(hr,{title:`Recent Tests (${t.length})`,children:a.jsx("div",{className:"space-y-1.5",children:t.slice(0,3).map(o=>a.jsxs(Rn,{to:`/tests/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx(lp,{status:o.status}),a.jsxs("span",{className:"truncate",children:[o.prompt.slice(0,40),"..."]})]}),a.jsxs("span",{className:"text-[var(--text-secondary)] flex-shrink-0 ml-2",children:[o.duration_seconds.toFixed(1),"s"]})]},o.id))})}),n.length>0&&a.jsx(hr,{title:`Experiments (${n.length})`,children:a.jsx("div",{className:"space-y-1.5",children:n.slice(0,3).map(o=>a.jsxs(Rn,{to:`/jobs/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(q,{variant:o.status==="completed"?"success":o.status==="running"?"info":"default",children:o.status}),a.jsx("span",{children:o.name})]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(o.created_at).toLocaleDateString()})]},o.id))})})]})}function hr({title:e,children:t,defaultCollapsed:n=!1}){const[r,s]=g.useState(n);return a.jsxs("div",{className:"border-b border-[var(--border)] pb-3",children:[a.jsxs("button",{onClick:()=>s(!r),className:"flex items-center justify-between w-full text-left py-1 hover:text-[var(--accent)] transition-colors",children:[a.jsx("span",{className:"text-sm font-medium",children:e}),a.jsx("span",{className:"text-[var(--text-secondary)] text-xs",children:r?"▶":"▼"})]}),!r&&a.jsx("div",{className:"mt-2",children:t})]})}function o1({agent:e,jobs:t}){const n=Dn(),r=Yt(),[s,i]=g.useState("quick"),[l,o]=g.useState(!1),{data:c=[]}=oe({queryKey:["suites"],queryFn:()=>kt.listSuites()}),u=Ze({mutationFn:P0.start,onSuccess:f=>{r.invalidateQueries({queryKey:["jobs"]}),o(!1),n(`/jobs/${f.id}`)},onError:()=>{o(!1)}}),d=()=>{o(!0),u.mutate({agent_id:e.id,suite_name:s,use_llm_eval:!0,parallel:4})};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:"Run this agent on a task suite to measure quality and cost."}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm",value:s,onChange:f=>i(f.target.value),disabled:l,children:c.map(f=>a.jsxs("option",{value:f.name,children:[f.name.charAt(0).toUpperCase()+f.name.slice(1)," (",f.task_count," tasks)"]},f.name))}),a.jsx(K,{variant:"primary",icon:l?ma:ea,onClick:d,disabled:l,loading:l,className:"w-full",children:"Evaluate"})]})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h4",{className:"text-sm font-medium",children:"Optimization Jobs"}),a.jsx(K,{variant:"secondary",size:"sm",icon:is,onClick:()=>n("/agents",{state:{optimizeAgent:e}}),children:"New Job"})]}),t.length===0?a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No optimization jobs yet."}):a.jsx("div",{className:"space-y-1.5",children:t.slice(0,5).map(f=>a.jsxs(Rn,{to:`/jobs/${f.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(q,{variant:f.status==="completed"?"success":f.status==="running"?"info":"default",children:f.status}),a.jsx("span",{children:f.name})]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(f.created_at).toLocaleDateString()})]},f.id))})]})]})}function c1({tests:e}){return e.length===0?a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No test history yet. Use the playground on the right to run a test."}):a.jsx("div",{className:"space-y-2",children:e.map(t=>a.jsxs(Rn,{to:`/tests/${t.id}`,className:"flex items-center justify-between p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(lp,{status:t.status}),t.score!==null&&a.jsxs("span",{className:`text-sm font-medium ${t.passed?"text-[var(--success)]":"text-[var(--error)]"}`,children:[(t.score*100).toFixed(0),"%"]})]}),a.jsx("p",{className:"text-sm truncate",children:t.prompt})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1 ml-4",children:[a.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:new Date(t.created_at).toLocaleString()}),a.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:[t.duration_seconds.toFixed(1),"s"]}),a.jsxs("span",{children:[t.tokens_total," tokens"]})]})]})]},t.id))})}function lp({status:e}){const t={completed:"success",failed:"error",running:"info",cancelled:"warning",pending:"default"};return a.jsx(q,{variant:t[e]||"default",children:e})}function u1(){const e=Yt(),[t,n]=g.useState(!1),[r,s]=g.useState(!1),[i,l]=g.useState(null),[o,c]=g.useState(new Set),u=p=>{c(h=>{const x=new Set(h);return x.has(p)?x.delete(p):x.add(p),x})},{data:d=[],isLoading:f}=oe({queryKey:["tasks"],queryFn:()=>kt.list()}),m=Ze({mutationFn:kt.create,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),n(!1)}}),v=Ze({mutationFn:kt.importSuite,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),s(!1)}}),k=Ze({mutationFn:kt.delete,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),l(null)}}),w=d.reduce((p,h)=>{const x=h.suite||"custom";return p[x]||(p[x]=[]),p[x].push(h),p},{}),b=Object.keys(w).sort((p,h)=>p==="custom"?-1:h==="custom"?1:p.localeCompare(h));return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Datasets"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Task datasets for evaluating agent configurations."})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(K,{variant:"secondary",onClick:()=>s(!0),children:"Import Suite"}),a.jsx(K,{variant:"primary",onClick:()=>n(!0),children:"+ New Task"})]})]}),f?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):d.length===0?a.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:"No tasks yet. Create one or import a built-in suite."}):a.jsx("div",{className:"space-y-4",children:b.map(p=>{const h=w[p],x=!o.has(p);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>u(p),className:"flex items-center gap-2 py-2 hover:text-[var(--accent)] transition-colors",children:[x?a.jsx(Rg,{size:16,className:"text-[var(--text-secondary)]"}):a.jsx(Zs,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium uppercase tracking-wide",children:p==="custom"?"Custom Tasks":`${p} Suite`}),a.jsx(q,{variant:p==="custom"?"default":"info",children:h.length})]}),x&&a.jsx("div",{className:"mt-2 border border-[var(--border)] rounded-lg overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:[a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Name"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Category"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Prompt"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Criteria"})]})}),a.jsx("tbody",{children:h.map(j=>a.jsxs("tr",{onClick:()=>l(j),className:"border-b border-[var(--border)] last:border-b-0 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors",children:[a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:j.name})}),a.jsx("td",{className:"px-4 py-3",children:j.category&&j.category!=="default"?a.jsx(q,{variant:"default",children:j.category}):a.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"})}),a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-[var(--text-secondary)] line-clamp-1 max-w-md",children:j.prompt})}),a.jsx("td",{className:"px-4 py-3 text-[var(--text-secondary)]",children:j.criteria.length>0?j.criteria.length:"--"})]},j.id))})]})})]},p)})}),a.jsx(d1,{task:i,onClose:()=>l(null),onDelete:p=>{confirm("Delete this task?")&&k.mutate(p)}}),a.jsx(f1,{isOpen:t,onClose:()=>n(!1),onSubmit:p=>m.mutate(p),isLoading:m.isPending}),a.jsx(h1,{isOpen:r,onClose:()=>s(!1),onSubmit:p=>v.mutate(p),isLoading:v.isPending})]})}function d1({task:e,onClose:t,onDelete:n}){const[r,s]=g.useState("prompt");if(!e)return null;const i=a.jsxs("div",{className:"flex justify-between",children:[a.jsx(K,{variant:"ghost",onClick:()=>n(e.id),className:"text-red-500 hover:text-red-600",children:"Delete Task"}),a.jsx(K,{variant:"secondary",onClick:t,children:"Close"})]});return a.jsx(ls,{isOpen:!!e,onClose:t,title:e.name,size:"lg",footer:i,children:a.jsxs("div",{className:"space-y-4",children:[e.category&&e.category!=="default"&&a.jsx("div",{children:a.jsx(q,{variant:"default",children:e.category})}),a.jsxs("div",{className:"flex gap-1 border-b border-[var(--border)]",children:[a.jsx("button",{onClick:()=>s("prompt"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="prompt"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Prompt"}),a.jsxs("button",{onClick:()=>s("criteria"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="criteria"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:["Eval Criteria (",e.criteria.length,")"]})]}),r==="prompt"&&a.jsx("div",{className:"p-4 bg-[var(--bg-tertiary)] rounded text-sm whitespace-pre-wrap min-h-[200px]",children:e.prompt}),r==="criteria"&&a.jsx("div",{className:"space-y-2 min-h-[200px]",children:e.criteria.length===0?a.jsx("div",{className:"text-[var(--text-secondary)] text-sm p-4",children:"No evaluation criteria defined for this task."}):e.criteria.map(l=>a.jsxs("div",{className:"p-3 bg-[var(--bg-tertiary)] rounded",children:[a.jsx("div",{className:"font-medium text-sm",children:l.name}),l.instruction&&a.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1",children:l.instruction})]},l.name))})]})})}function f1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,i]=g.useState({name:"",prompt:"",criteria:[],category:"default"}),l=()=>{i({...s,criteria:[...s.criteria,{name:"",instruction:"",weight:1}]})},o=(d,f)=>{const m=[...s.criteria];m[d]={...m[d],...f},i({...s,criteria:m})},c=d=>{i({...s,criteria:s.criteria.filter((f,m)=>m!==d)})},u=d=>{d.preventDefault(),!(!s.name.trim()||!s.prompt.trim())&&n({...s,criteria:s.criteria.filter(f=>f.name.trim()&&f.instruction.trim())})};return a.jsx(ls,{isOpen:e,onClose:t,title:"Create Task",children:a.jsxs("form",{onSubmit:u,className:"space-y-4",children:[a.jsx(yn,{label:"Name",value:s.name,onChange:d=>i({...s,name:d.target.value}),placeholder:"e.g., fizzbuzz",required:!0}),a.jsx(q0,{label:"Prompt",value:s.prompt,onChange:d=>i({...s,prompt:d.target.value}),placeholder:"The task description for the agent...",required:!0}),a.jsx(yn,{label:"Category",value:s.category,onChange:d=>i({...s,category:d.target.value}),placeholder:"e.g., coding, research"}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Evaluation Criteria"}),a.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"+ Add"})]}),a.jsx("div",{className:"space-y-2",children:s.criteria.map((d,f)=>a.jsxs("div",{className:"flex gap-2 items-start",children:[a.jsx(yn,{value:d.name,onChange:m=>o(f,{name:m.target.value}),placeholder:"Name",className:"w-32"}),a.jsx(yn,{value:d.instruction,onChange:m=>o(f,{instruction:m.target.value}),placeholder:"Instruction",className:"flex-1"}),a.jsx(K,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(f),children:"×"})]},f))})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[a.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(K,{type:"submit",variant:"primary",disabled:r||!s.name.trim()||!s.prompt.trim(),children:r?"Creating...":"Create"})]})]})})}function h1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,i]=g.useState(""),{data:l=[],isLoading:o}=oe({queryKey:["suites"],queryFn:()=>kt.listSuites(),enabled:e});return g.useEffect(()=>{l.length>0&&!s&&i(l[0].name)},[l,s]),a.jsx(ls,{isOpen:e,onClose:t,title:"Import Task Suite",children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Import a built-in task suite for evaluation."}),o?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading suites..."}):l.length===0?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"No suites available."}):a.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:l.map(c=>a.jsxs("label",{className:`flex items-center gap-3 p-3 border cursor-pointer ${s===c.name?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[a.jsx("input",{type:"radio",name:"suite",value:c.name,checked:s===c.name,onChange:()=>i(c.name),className:"accent-[var(--accent)]"}),a.jsxs("span",{className:"capitalize",children:[c.name.replace(/_/g," ")," (",c.task_count," tasks) - ",c.description]})]},c.name))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[a.jsx(K,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(K,{variant:"primary",onClick:()=>n(s),disabled:r||!s,children:r?"Importing...":"Import"})]})]})})}function m1(){const e=Dn(),t=Yt(),[n,r]=g.useState(!1),s=eu(),{data:i=[],isLoading:l}=oe({queryKey:["jobs",n],queryFn:()=>Mt.list({include_public:n}),refetchInterval:5e3}),o=Ze({mutationFn:Mt.delete,onSuccess:()=>t.invalidateQueries({queryKey:["jobs"]})}),c={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"},u=[{key:"name",header:"Name",render:d=>a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:d.name||`Job ${d.id.slice(0,8)}`}),d.is_public&&a.jsx(qc,{className:"w-3 h-3 ml-2 inline text-[var(--text-secondary)]"})]})},{key:"status",header:"Status",render:d=>a.jsx(q,{variant:c[d.status]||"default",children:d.status})},{key:"candidates",header:"Candidates",render:d=>a.jsx("span",{children:d.candidate_ids.length})},{key:"tasks",header:"Tasks",render:d=>a.jsx("span",{children:d.task_ids.length})},{key:"runs",header:"Runs",render:d=>a.jsxs("span",{children:[d.completed_experiments,"/",d.total_experiments]})},{key:"created",header:"Created",render:d=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(d.created_at).toLocaleDateString()}),sortable:!0,sortValue:d=>new Date(d.created_at).getTime()},{key:"actions",header:"",className:"w-12",render:d=>!d.user_id||d.user_id==="anonymous"||s&&d.created_by_name===s?a.jsx("div",{onClick:m=>m.stopPropagation(),children:a.jsx(K,{variant:"ghost",size:"sm",icon:Gc,title:"Delete",disabled:d.status==="running",onClick:()=>{confirm("Delete this job?")&&o.mutate(d.id)}})}):null}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Experiments"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"View and manage optimization experiments. Start new experiments from the Agents page."})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Si,{label:"Show public",checked:n,onChange:d=>r(d.target.checked)}),a.jsx(K,{variant:"secondary",onClick:()=>e("/agents"),children:"Go to Agents"})]})]}),l?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):a.jsx(np,{columns:u,data:i,onRowClick:d=>e(`/jobs/${d.id}`),searchable:!0,searchPlaceholder:"Search experiments",searchFilter:(d,f)=>(d.name||"").toLowerCase().includes(f.toLowerCase())||d.id.toLowerCase().includes(f.toLowerCase()),emptyMessage:"No experiments yet. Go to Agents page to start an optimization."})]})}function p1(e,t=!0){return Math.abs(e)<10?"text-[var(--text-secondary)]":(t?e<0:e>0)?"text-green-400":"text-red-400"}function x1(e){return`${e>0?"+":""}${e.toFixed(1)}%`}function op(e,t){return t===0?0:(e-t)/t*100}function vs({label:e,values:t,baselineIndex:n,formatter:r,isLowerBetter:s=!0}){const i=t[n];return a.jsxs("tr",{className:"border-b border-[var(--border)] last:border-0",children:[a.jsx("td",{className:"py-2 pr-4 text-[var(--text-secondary)] text-sm",children:e}),t.map((l,o)=>{const c=op(l,i),u=o===n;return a.jsxs("td",{className:"py-2 px-4 text-right",children:[a.jsx("div",{className:"font-mono",children:r(l)}),!u&&a.jsx("div",{className:`text-xs ${p1(c,s)}`,children:x1(c)}),u&&a.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"(baseline)"})]},o)})]})}function v1({runs:e,baselineRunId:t}){const n=g.useMemo(()=>{if(t){const i=e.findIndex(l=>l.id===t);if(i>=0)return i}return 0},[e,t]);if(e.length<2)return null;const r=Math.min(...e.map(i=>i.tokens_total)),s=Math.max(...e.map(i=>i.score));return a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-4",children:"Candidate Comparison"}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-[var(--border)]",children:[a.jsx("th",{className:"pb-2 pr-4 text-left text-[var(--text-secondary)] font-medium",children:"Metric"}),e.map((i,l)=>a.jsx("th",{className:"pb-2 px-4 text-right",children:a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsx("span",{className:"font-medium",children:i.candidate_name}),i.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"}),l===n&&a.jsx(q,{variant:"info",children:"Base"})]})},i.id))]})}),a.jsxs("tbody",{children:[a.jsx(vs,{label:"Total Tokens",values:e.map(i=>i.tokens_total),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(vs,{label:"Input Tokens",values:e.map(i=>i.tokens_input),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(vs,{label:"Output Tokens",values:e.map(i=>i.tokens_output),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(vs,{label:"Duration",values:e.map(i=>i.duration_seconds),baselineIndex:n,formatter:i=>`${i.toFixed(1)}s`,isLowerBetter:!0}),a.jsx(vs,{label:"Score",values:e.map(i=>i.score*100),baselineIndex:n,formatter:i=>`${i.toFixed(1)}%`,isLowerBetter:!1})]})]})}),a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[a.jsx("h4",{className:"text-sm font-medium mb-2 text-[var(--text-secondary)]",children:"Key Insights"}),a.jsxs("ul",{className:"text-sm space-y-1 text-[var(--text-secondary)]",children:[e.map(i=>{const l=op(i.tokens_total,e[n].tokens_total);return i.tokens_total===r&&l<-5?a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-green-400",children:"✓"}),a.jsxs("span",{children:[a.jsx("strong",{children:i.candidate_name})," uses ",Math.abs(l).toFixed(0),"% fewer tokens"]})]},`token-${i.id}`):null}),e.map(i=>i.score===s&&i.passed?a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-green-400",children:"✓"}),a.jsxs("span",{children:[a.jsx("strong",{children:i.candidate_name})," achieved highest score (",(i.score*100).toFixed(0),"%)"]})]},`score-${i.id}`):null),e.filter(i=>i.is_pareto).length>0&&a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-purple-400",children:"★"}),a.jsxs("span",{children:["Optimal candidates (best tradeoff):"," ",e.filter(i=>i.is_pareto).map(i=>i.candidate_name).join(", ")]})]})]})]}),a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[a.jsx("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:"Token Efficiency"}),a.jsx("div",{className:"space-y-2",children:e.map(i=>{const l=i.tokens_total/e[n].tokens_total*100,o=i.tokens_total<=r;return a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-24 text-sm truncate",title:i.candidate_name,children:i.candidate_name}),a.jsx("div",{className:"flex-1 h-6 bg-[var(--bg-primary)] rounded overflow-hidden",children:a.jsx("div",{className:`h-full transition-all duration-300 ${o?"bg-green-500":"bg-blue-500"}`,style:{width:`${Math.min(l,100)}%`}})}),a.jsx("div",{className:"w-20 text-right font-mono text-sm",children:i.tokens_total.toLocaleString()})]},i.id)})})]})]})}function y1({summaries:e,height:t=350}){const n=g.useRef(null),[r,s]=g.useState(600),[i,l]=g.useState("tokens"),[o,c]=g.useState(null),[u,d]=g.useState({x:0,y:0});g.useEffect(()=>{const S=()=>{n.current&&s(n.current.clientWidth)};return S(),window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]);const f={top:30,right:30,bottom:50,left:60},m=r-f.left-f.right,v=t-f.top-f.bottom,k=S=>i==="tokens"?S.avg_tokens:S.avg_duration,{xScale:w,yScale:b,xTicks:p,yTicks:h,paretoLine:x}=g.useMemo(()=>{if(e.length===0||m<=0)return{xScale:()=>0,yScale:()=>0,xTicks:[],yTicks:[],paretoLine:[]};const S=e.map(k),N=e.map(P=>P.avg_score),_=Math.min(...S)*.9,z=Math.max(...S)*1.1,L=Math.min(...N,.5),B=Math.min(Math.max(...N)*1.05,1),J=P=>(P-_)/(z-_)*m,se=P=>v-(P-L)/(B-L)*v,ce=Array.from({length:5},(P,A)=>_+A/4*(z-_)),D=Array.from({length:5},(P,A)=>L+A/4*(B-L)),Z=e.filter(P=>P.is_pareto).sort((P,A)=>k(P)-k(A)).map(P=>({x:J(k(P)),y:se(P.avg_score)}));return{xScale:J,yScale:se,xTicks:ce,yTicks:D,paretoLine:Z}},[e,m,v,i]);if(e.length===0)return a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No data to display"});const j=S=>i==="tokens"?S>=1e6?`${(S/1e6).toFixed(1)}M`:S>=1e3?`${(S/1e3).toFixed(0)}K`:S.toFixed(0):`${S.toFixed(1)}s`,C=(S,N)=>{var z;const _=(z=n.current)==null?void 0:z.getBoundingClientRect();_&&d({x:N.clientX-_.left,y:N.clientY-_.top}),c(S)};return a.jsxs("div",{ref:n,className:"w-full relative",children:[a.jsx("div",{className:"flex justify-end mb-2",children:a.jsxs("div",{className:"inline-flex rounded border border-[var(--border)] text-xs",children:[a.jsx("button",{className:`px-3 py-1 ${i==="tokens"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("tokens"),children:"Tokens"}),a.jsx("button",{className:`px-3 py-1 ${i==="duration"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("duration"),children:"Latency"})]})}),a.jsx("svg",{width:r,height:t,className:"font-mono text-xs",children:a.jsxs("g",{transform:`translate(${f.left}, ${f.top})`,children:[p.map((S,N)=>a.jsx("line",{x1:w(S),y1:0,x2:w(S),y2:v,stroke:"var(--border)",strokeDasharray:"2,2"},`x-grid-${N}`)),h.map((S,N)=>a.jsx("line",{x1:0,y1:b(S),x2:m,y2:b(S),stroke:"var(--border)",strokeDasharray:"2,2"},`y-grid-${N}`)),x.length>1&&a.jsx("polyline",{points:x.map(S=>`${S.x},${S.y}`).join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.slice().sort((S,N)=>(S.is_pareto?1:0)-(N.is_pareto?1:0)).map(S=>{const N=w(k(S)),_=b(S.avg_score),z=S.is_pareto,L=(o==null?void 0:o.candidate_name)===S.candidate_name;return a.jsxs("g",{onMouseEnter:B=>C(S,B),onMouseLeave:()=>c(null),children:[a.jsx("circle",{cx:N,cy:_,r:L?10:z?8:6,fill:z?"var(--accent)":"transparent",stroke:L?"var(--text-primary)":z?"var(--accent)":"var(--text-secondary)",strokeWidth:L?3:2,className:"cursor-pointer transition-all"}),z&&!L&&a.jsx("text",{x:N,y:_-12,textAnchor:"middle",fill:"var(--text-primary)",fontSize:10,className:"pointer-events-none",children:S.candidate_name.replace(/^baseline_/,"").slice(0,15)})]},S.candidate_name)}),a.jsx("line",{x1:0,y1:v,x2:m,y2:v,stroke:"var(--text-secondary)"}),p.map((S,N)=>a.jsxs("g",{transform:`translate(${w(S)}, ${v})`,children:[a.jsx("line",{y2:5,stroke:"var(--text-secondary)"}),a.jsx("text",{y:20,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:10,children:j(S)})]},`x-tick-${N}`)),a.jsx("text",{x:m/2,y:v+40,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:i==="tokens"?"Tokens (cost)":"Duration (latency)"}),a.jsx("line",{x1:0,y1:0,x2:0,y2:v,stroke:"var(--text-secondary)"}),h.map((S,N)=>a.jsxs("g",{transform:`translate(0, ${b(S)})`,children:[a.jsx("line",{x2:-5,stroke:"var(--text-secondary)"}),a.jsxs("text",{x:-10,textAnchor:"end",dominantBaseline:"middle",fill:"var(--text-secondary)",fontSize:10,children:[(S*100).toFixed(0),"%"]})]},`y-tick-${N}`)),a.jsx("text",{transform:`translate(-45, ${v/2}) rotate(-90)`,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:"Score (quality)"})]})}),o&&a.jsxs("div",{className:"absolute z-10 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg shadow-lg p-3 text-sm pointer-events-none",style:{left:Math.min(u.x+15,r-200),top:u.y-10,maxWidth:220},children:[a.jsx("div",{className:"font-medium text-[var(--text-primary)] truncate mb-2",children:o.candidate_name.replace(/^baseline_/,"")}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Score:"}),a.jsxs("span",{className:"text-right font-medium",children:[(o.avg_score*100).toFixed(1),"%"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tokens:"}),a.jsxs("span",{className:"text-right",children:[(o.avg_tokens/1e3).toFixed(1),"K"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Duration:"}),a.jsxs("span",{className:"text-right",children:[o.avg_duration.toFixed(1),"s"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Pass rate:"}),a.jsxs("span",{className:"text-right",children:[o.passed_runs,"/",o.total_runs]})]}),o.is_pareto&&a.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)] text-xs text-[var(--accent)]",children:"Optimal (best tradeoff)"})]})]})}function g1(e=2e3){const[t,n]=g.useState(!1),[r,s]=g.useState(null),i=g.useCallback(async o=>{try{return await navigator.clipboard.writeText(o),n(!0),s(null),setTimeout(()=>n(!1),e),!0}catch{return s("Failed to copy to clipboard"),n(!1),!1}},[e]),l=g.useCallback(()=>{n(!1),s(null)},[]);return{copy:i,copied:t,error:r,reset:l}}function j1({isOpen:e,onClose:t,title:n,itemId:r,itemType:s,isPublic:i,createdByName:l,onTogglePublic:o}){const[c,u]=g.useState(!1),{copy:d,copied:f}=g1(),m=`${window.location.origin}/${s}s/${r}`,v=async()=>{u(!0);try{await o(!i)}finally{u(!1)}},k=()=>{d(m)};return a.jsx(ls,{isOpen:e,onClose:t,title:n,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between p-3 bg-[var(--bg-tertiary)] rounded",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[i?a.jsx(qc,{className:"w-5 h-5 text-[var(--accent)]"}):a.jsx(Bm,{className:"w-5 h-5 text-[var(--text-secondary)]"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium",children:i?"Public":"Private"}),a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:i?"Anyone with the link can view":"Only you can access"})]})]}),a.jsx("button",{onClick:v,disabled:c,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${i?"bg-[var(--accent)]":"bg-[var(--border)]"} ${c?"opacity-50 cursor-not-allowed":""}`,children:a.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${i?"translate-x-6":"translate-x-1"}`})})]}),i&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Share link"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",readOnly:!0,value:m,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono"}),a.jsx(K,{variant:"secondary",onClick:k,children:f?a.jsxs(a.Fragment,{children:[a.jsx(Lg,{className:"w-4 h-4 mr-1"}),"Copied"]}):a.jsxs(a.Fragment,{children:[a.jsx(Ig,{className:"w-4 h-4 mr-1"}),"Copy"]})})]})]}),l&&a.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",a.jsx("span",{className:"text-[var(--text-primary)]",children:l})]}),a.jsx("div",{className:"text-xs text-[var(--text-secondary)] pt-2 border-t border-[var(--border)]",children:i?a.jsxs(a.Fragment,{children:[a.jsxs("p",{children:["Public ",s,"s can be viewed by anyone with the link."]}),a.jsxs("p",{className:"mt-1",children:["Only you can edit or delete this ",s,"."]})]}):a.jsxs("p",{children:["Make this ",s," public to share it with others."]})})]})})}function w1({job:e,onUpdate:t}){const[n,r]=g.useState(!1),s=async i=>{await Mt.update(e.id,{is_public:i}),t()};return a.jsxs(a.Fragment,{children:[a.jsxs(K,{variant:"secondary",size:"sm",onClick:()=>r(!0),title:e.is_public?"Sharing settings":"Share this job",children:[a.jsx(Wg,{className:"w-4 h-4 mr-1"}),e.is_public?"Shared":"Share"]}),a.jsx(j1,{isOpen:n,onClose:()=>r(!1),title:"Share Job",itemId:e.id,itemType:"job",isPublic:e.is_public,createdByName:e.created_by_name,onTogglePublic:s})]})}function k1(){const{jobId:e}=ha(),t=Dn(),n=Yt(),[r,s]=g.useState(null),[i,l]=g.useState(!1),[o,c]=g.useState(null),[u,d]=g.useState([]),[f,m]=g.useState(null),[v,k]=g.useState(null),[w,b]=g.useState("results"),[p,h]=g.useState("score"),[x,j]=g.useState("desc"),[C,S]=g.useState(!1),{data:N,isLoading:_}=oe({queryKey:["jobs",e],queryFn:()=>Mt.get(e),enabled:!!e,refetchInterval:i?2e3:!1}),{data:z=[]}=oe({queryKey:["runs",e],queryFn:()=>Bo.list({job_id:e}),enabled:!!e,refetchInterval:i?2e3:!1}),{data:L}=oe({queryKey:["job-summary",e],queryFn:()=>Bo.getJobSummary(e),enabled:!!e&&(N==null?void 0:N.status)==="completed"}),B=Ze({mutationFn:async()=>{l(!0),d([]),m(null),k(null);for await(const O of Mt.start(e))s(O),O.current_candidate&&O.current_task&&m(Q=>(Q&&(Q.candidate!==O.current_candidate||Q.task!==O.current_task)&&d(Ce=>[...Ce,{candidate_name:Q.candidate,task_name:Q.task,completed_at:Date.now()}]),{candidate:O.current_candidate,task:O.current_task})),O.event==="error"&&(k(O.message),l(!1),n.invalidateQueries({queryKey:["jobs",e]})),O.event==="complete"&&(m(Q=>(Q&&d(Ce=>[...Ce,{candidate_name:Q.candidate,task_name:Q.task,completed_at:Date.now()}]),null)),l(!1),n.invalidateQueries({queryKey:["jobs",e]}),n.invalidateQueries({queryKey:["runs",e]}),n.invalidateQueries({queryKey:["job-summary",e]}))}}),J=Ze({mutationFn:()=>Mt.cancel(e),onSuccess:()=>{l(!1),n.invalidateQueries({queryKey:["jobs",e]})}});g.useEffect(()=>{(N==null?void 0:N.status)==="running"&&l(!0)},[N==null?void 0:N.status]);const se=g.useMemo(()=>{const O=new Map;for(const Q of z)O.has(Q.task_name)||O.set(Q.task_name,[]),O.get(Q.task_name).push(Q);return O},[z]),ce=g.useMemo(()=>Array.from(se.keys()),[se]);g.useEffect(()=>{!o&&ce.length>0&&c(ce[0])},[ce,o]);const D=g.useMemo(()=>{if(!(L!=null&&L.candidate_summaries))return[];let O=[...L.candidate_summaries];return C&&(O=O.filter(Q=>Q.is_pareto)),O.sort((Q,Ce)=>{let ke,_e;switch(p){case"score":ke=Q.avg_score,_e=Ce.avg_score;break;case"tokens":ke=Q.avg_tokens,_e=Ce.avg_tokens;break;case"duration":ke=Q.avg_duration,_e=Ce.avg_duration;break;case"pass_rate":ke=Q.passed_runs/Q.total_runs,_e=Ce.passed_runs/Ce.total_runs;break}return x==="desc"?_e-ke:ke-_e}),O},[L,p,x,C]),W=O=>{p===O?j(x==="desc"?"asc":"desc"):(h(O),j(O==="tokens"||O==="duration"?"asc":"desc"))},Z=({label:O,sortKeyVal:Q})=>a.jsx("th",{className:"pb-2 cursor-pointer hover:text-[var(--text-primary)] select-none",onClick:()=>W(Q),children:a.jsxs("div",{className:"flex items-center gap-1",children:[O,p===Q&&a.jsx(Tg,{size:12,className:x==="asc"?"rotate-180":""})]})});if(_)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!N)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Job not found"});const P=eu(),A=!N.user_id||N.user_id==="anonymous"||P&&N.created_by_name===P,T=N.is_public&&!A,V=()=>{n.invalidateQueries({queryKey:["jobs",e]})},te=O=>{const Q={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};return a.jsx(q,{variant:Q[O]||"default",children:O})};return a.jsxs("div",{children:[a.jsx(pa,{items:[{label:"Experiments",path:"/jobs"},{label:N.name||`Job ${N.id.slice(0,8)}`}]}),a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:N.name||`Job ${N.id.slice(0,8)}`}),te(N.status),N.is_public&&a.jsxs(q,{variant:"info",children:[a.jsx(qc,{className:"w-3 h-3 mr-1 inline"}),"Public"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[a.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-2 py-0.5 rounded font-mono text-[var(--text-secondary)]",children:[N.id.slice(0,8),"..."]}),a.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[N.candidate_ids.length," candidates × ",N.task_ids.length," tasks = ",N.total_experiments," experiments"]}),N.is_public&&N.created_by_name&&a.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",a.jsx("span",{className:"text-[var(--text-primary)]",children:N.created_by_name})]})]})]}),a.jsxs("div",{className:"flex gap-2",children:[A&&a.jsx(w1,{job:N,onUpdate:V}),T&&a.jsx(q,{variant:"default",children:"View Only"}),A&&N.status==="pending"&&a.jsx(K,{variant:"primary",onClick:()=>B.mutate(),disabled:B.isPending,children:B.isPending?"Starting...":"Start"}),A&&N.status==="running"&&a.jsx(K,{variant:"danger",onClick:()=>J.mutate(),disabled:J.isPending,children:"Cancel"})]})]}),(v||N.error)&&a.jsx(ge,{className:"mb-6 border-red-500/50 bg-red-500/10",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"w-5 h-5 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-0.5",children:"!"}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-red-400",children:"Error"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:v||N.error})]})]})}),(i||r)&&a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"font-medium",children:"Progress"}),a.jsxs("span",{className:"text-[var(--accent)]",children:[(r==null?void 0:r.completed)||N.completed_experiments,"/",(r==null?void 0:r.total)||N.total_experiments]})]}),a.jsx("div",{className:"w-full bg-[var(--bg-primary)] h-2 mb-2",children:a.jsx("div",{className:"h-full bg-[var(--accent)] transition-all",style:{width:`${((r==null?void 0:r.completed)||N.completed_experiments)/((r==null?void 0:r.total)||N.total_experiments)*100}%`}})}),(r==null?void 0:r.message)&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r.message}),i&&a.jsxs("div",{className:"mt-4 border-t border-[var(--border)] pt-4",children:[(r==null?void 0:r.current_candidate)&&(r==null?void 0:r.current_task)&&a.jsxs("div",{className:"mb-3",children:[a.jsx("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:"Currently Running"}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 px-3 py-2 bg-blue-500/10 border border-blue-500/30 rounded",children:[a.jsx("div",{className:"w-2 h-2 bg-blue-400 rounded-full animate-pulse"}),a.jsx("span",{className:"font-medium",children:r.current_candidate}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{children:r.current_task})]})]}),u.length>0&&a.jsxs("div",{children:[a.jsxs("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:["Completed (",u.length,")"]}),a.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto space-y-1",children:u.map((O,Q)=>a.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-500/10 border border-green-500/30 rounded text-sm",children:[a.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}),a.jsx("span",{className:"font-medium",children:O.candidate_name}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{children:O.task_name})]},`${O.candidate_name}-${O.task_name}-${Q}`))})]})]})]}),(N.status==="completed"||z.length>0)&&a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-[var(--border)]",children:[a.jsxs("button",{onClick:()=>b("results"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${w==="results"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Og,{size:16}),"Results"]}),a.jsxs("button",{onClick:()=>b("compare"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${w==="compare"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Ag,{size:16}),"Compare"]}),a.jsxs("button",{onClick:()=>b("runs"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${w==="runs"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Qg,{size:16}),"Runs (",z.length,")"]})]}),w==="results"&&a.jsxs(a.Fragment,{children:[L&&L.candidate_summaries.length>1&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("div",{className:"flex items-start justify-between mb-4",children:a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium",children:"Quality vs. Cost Tradeoff"}),a.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:["Candidates on the frontier (connected line) are ",a.jsx("strong",{children:"optimal"})," - no other candidate beats them on both score AND cost."]})]})}),a.jsxs("div",{className:"mb-4 p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs text-[var(--text-secondary)]",children:[a.jsx("strong",{className:"text-[var(--text-primary)]",children:"How optimal tradeoffs are calculated:"})," A candidate is optimal if there's no other candidate that has both a higher score AND lower cost. For example, if Candidate A has 95% score at 50K tokens and Candidate B has 90% score at 40K tokens, both are optimal - A is better on score, B is better on cost. But if Candidate C has 85% score at 60K tokens, it's ",a.jsx("em",{children:"not"})," optimal because B beats it on both metrics."]}),a.jsx(y1,{summaries:L.candidate_summaries,height:350})]}),L&&a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h3",{className:"font-medium",children:"Results Summary"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C,onChange:O=>S(O.target.checked),className:"rounded border-[var(--border)]"}),"Optimal only"]})]}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-left text-[var(--text-secondary)] border-b border-[var(--border)]",children:[a.jsx("th",{className:"pb-2",children:"Candidate"}),a.jsx(Z,{label:"Score",sortKeyVal:"score"}),a.jsx(Z,{label:"Tokens",sortKeyVal:"tokens"}),a.jsx(Z,{label:"Duration",sortKeyVal:"duration"}),a.jsx(Z,{label:"Pass Rate",sortKeyVal:"pass_rate"}),a.jsx("th",{className:"pb-2",children:"Optimal"})]})}),a.jsx("tbody",{children:D.map((O,Q)=>a.jsxs("tr",{className:`border-b border-[var(--border)] ${Q===0?"bg-[var(--accent)]/10":""}`,children:[a.jsxs("td",{className:"py-2 font-medium",children:[Q===0&&a.jsx("span",{className:"text-[var(--accent)] mr-1",children:"#1"}),O.candidate_name.replace(/^baseline_/,"")]}),a.jsxs("td",{className:"py-2",children:[(O.avg_score*100).toFixed(1),"%"]}),a.jsxs("td",{className:"py-2",children:[(O.avg_tokens/1e3).toFixed(1),"K"]}),a.jsxs("td",{className:"py-2",children:[O.avg_duration.toFixed(1),"s"]}),a.jsxs("td",{className:"py-2",children:[O.passed_runs,"/",O.total_runs]}),a.jsx("td",{className:"py-2",children:O.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})})]},O.candidate_name))})]})}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-3",children:"Click column headers to sort. The #1 ranked candidate is highlighted based on your sort criteria."})]}),!L&&a.jsx(ge,{children:a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Results will appear here after the job completes.":"No results yet. Start the job to see results."})})]}),w==="compare"&&a.jsxs(ge,{children:[a.jsx("h3",{className:"font-medium mb-4",children:"Compare Candidates by Task"}),ce.length>0?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:ce.map(O=>a.jsx("button",{onClick:()=>c(o===O?null:O),className:`px-3 py-1 text-sm rounded border transition-colors ${o===O?"bg-[var(--accent)] text-white border-[var(--accent)]":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:O},O))}),o&&se.get(o)?a.jsx(v1,{runs:se.get(o).map(O=>({id:O.id,candidate_name:O.candidate_name,tokens_input:0,tokens_output:0,tokens_total:O.tokens_total,duration_seconds:O.duration_seconds,score:O.score,passed:O.passed,is_pareto:O.is_pareto}))}):a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"Select a task above to compare how different candidates performed on it."})]}):a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Comparison data will appear here after runs complete.":"No runs yet. Start the job to compare candidates."})]}),w==="runs"&&a.jsxs(ge,{children:[a.jsx("h3",{className:"font-medium mb-4",children:"All Experiment Runs"}),z.length===0?a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Runs will appear here as they complete. See progress above for live status.":"No runs yet. Start the job to see results."}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:z.map(O=>a.jsxs("div",{className:"p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] cursor-pointer hover:border-[var(--accent-dim)] transition-colors",onClick:()=>t(`/runs/${O.id}`),children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:`text-lg font-bold ${O.passed?"text-green-400":"text-red-400"}`,children:[(O.score*100).toFixed(0),"%"]}),O.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})]}),a.jsx("div",{className:"text-sm font-medium truncate",title:O.candidate_name,children:O.candidate_name.replace(/^baseline_/,"")}),a.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:O.task_name}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:[(O.tokens_total/1e3).toFixed(1),"K tokens"]}),a.jsxs("span",{children:[O.duration_seconds.toFixed(1),"s"]})]})]},O.id))})]})]})}const gn={input:"bg-blue-500",output:"bg-emerald-500",inputText:"text-blue-400",outputText:"text-emerald-400"};function Dd(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ad({input:e,output:t,maxValue:n,height:r=24,showLabels:s=!0}){const i=e+t;if(i===0)return a.jsx("div",{className:"flex items-center gap-2 w-full",children:a.jsx("div",{className:"rounded bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`}})});const l=n>0?i/n*100:100;return a.jsxs("div",{className:"flex items-center gap-3 w-full",children:[a.jsx("div",{className:"relative rounded overflow-hidden bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`},children:a.jsxs("div",{className:"h-full flex transition-all duration-300",style:{width:`${l}%`},children:[a.jsx("div",{className:`h-full ${gn.input} transition-all`,style:{width:`${e/i*100}%`},title:`Input: ${e.toLocaleString()} tokens`}),a.jsx("div",{className:`h-full ${gn.output} transition-all`,style:{width:`${t/i*100}%`},title:`Output: ${t.toLocaleString()} tokens`})]})}),s&&a.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono text-[var(--text-secondary)] min-w-[90px] justify-end",children:[a.jsxs("span",{className:gn.inputText,children:["↑",Dd(e)]}),a.jsx("span",{children:"/"}),a.jsxs("span",{className:gn.outputText,children:["↓",Dd(t)]})]})]})}function _l({label:e,value:t,color:n="default"}){const r={default:"text-[var(--text-primary)]",input:gn.inputText,output:gn.outputText}[n];return a.jsxs("div",{className:"flex-1 p-3 bg-[var(--bg-primary)] border border-[var(--border)] rounded",children:[a.jsx("div",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e}),a.jsx("div",{className:`font-mono text-lg font-bold ${r}`,children:t})]})}function cp({tokensInput:e,tokensOutput:t,tokensTotal:n,turns:r}){const s=n>0?Math.round(e/n*100):0,i=n>0?Math.round(t/n*100):0,l=g.useMemo(()=>{if(!r||r.length===0)return null;let c=0,u=0;return r.map(d=>(c+=d.input,u+=d.output,{input:c,output:u,total:c+u}))},[r]),o=l?Math.max(...l.map(c=>c.total)):n;return a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-4",children:"Token Usage"}),a.jsx("div",{className:"mb-4",children:a.jsx(Ad,{input:e,output:t,maxValue:n,height:32})}),a.jsxs("div",{className:"flex items-center gap-6 text-xs mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-3 h-3 rounded ${gn.input}`}),a.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Input (",s,"%)"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-3 h-3 rounded ${gn.output}`}),a.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Output (",i,"%)"]})]})]}),a.jsxs("div",{className:"flex gap-3 mb-4",children:[a.jsx(_l,{label:"Input Tokens",value:e.toLocaleString(),color:"input"}),a.jsx(_l,{label:"Output Tokens",value:t.toLocaleString(),color:"output"}),a.jsx(_l,{label:"Total Tokens",value:n.toLocaleString()})]}),l&&l.length>1&&a.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[a.jsxs("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:["Token Accumulation (",r.length," turns)"]}),a.jsx("div",{className:"space-y-2",children:r.map((c,u)=>a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--bg-primary)] border border-[var(--border)] flex items-center justify-center text-xs font-medium",children:u+1}),a.jsx("div",{className:"flex-1",children:a.jsx(Ad,{input:l[u].input,output:l[u].output,maxValue:o,height:16})})]},u))})]}),a.jsx("div",{className:"mt-4 text-xs text-[var(--text-secondary)] border-t border-[var(--border)] pt-3",children:"Token usage affects API cost. Input tokens are typically cheaper than output tokens."})]})}function b1(){const{runId:e}=ha(),{data:t,isLoading:n}=oe({queryKey:["runs",e],queryFn:()=>Bo.get(e),enabled:!!e});return n?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsx(pa,{items:[{label:"Experiments",path:"/jobs"},{label:"Job",path:`/jobs/${t.job_id}`},{label:t.candidate_name}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:t.candidate_name}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{className:"text-lg",children:t.task_name}),t.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})]})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[a.jsx(Fa,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),a.jsx(Fa,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),a.jsx(Fa,{label:"Duration",value:`${t.duration_seconds.toFixed(1)}s`}),a.jsx(Fa,{label:"Status",value:t.passed?"Passed":"Failed",status:t.passed?"success":"error"})]}),a.jsx(cp,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),t.reasoning&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:t.reasoning}),t.criteria_results.length>0&&a.jsx("div",{className:"space-y-2",children:t.criteria_results.map(r=>a.jsx("div",{className:"flex items-start justify-between p-3 bg-[var(--bg-primary)] border border-[var(--border)]",children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-medium",children:r.name}),a.jsxs(q,{variant:r.passed?"success":"error",children:[(r.score*100).toFixed(0),"%"]})]}),r.reasoning&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r.reasoning})]})},r.name))})]}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created.length>0&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),a.jsx("div",{className:"space-y-1",children:t.files_created.map(r=>a.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:r},r))})]}),Object.keys(t.trace).length>0&&a.jsx(ap,{trace:t.trace})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Run not found"})}function Fa({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return a.jsxs(ge,{children:[a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),a.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function N1(){const{testId:e}=ha(),{data:t,isLoading:n}=oe({queryKey:["tests",e],queryFn:()=>Ls.get(e),enabled:!!e}),{data:r}=oe({queryKey:["configs",t==null?void 0:t.agent_id],queryFn:()=>Tn.get(t.agent_id),enabled:!!(t!=null&&t.agent_id)});if(n)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!t)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Test not found"});const s={completed:"success",failed:"error",running:"info",pending:"default",cancelled:"warning"};return a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsx(pa,{items:[{label:"Agents",path:"/agents"},...r?[{label:r.name,path:`/agents/${r.id}`}]:[],{label:`Test ${t.id.slice(0,8)}`}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:"Test Run"}),r&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"•"}),a.jsx("span",{className:"text-lg",children:r.name})]}),a.jsx(q,{variant:s[t.status]||"default",children:t.status})]}),a.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:["ID: ",t.id.slice(0,8),"..."]})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[a.jsx(Ia,{label:"Duration",value:`${t.duration_seconds.toFixed(2)}s`}),a.jsx(Ia,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),t.score!==null&&a.jsx(Ia,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),a.jsx(Ia,{label:"Status",value:t.status.charAt(0).toUpperCase()+t.status.slice(1),status:t.status==="completed"?"success":t.status==="failed"?"error":void 0})]}),a.jsx(cp,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Prompt"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)] font-mono",children:t.prompt})]}),t.error&&a.jsxs(ge,{className:"mb-6 border-red-500/30 bg-red-500/5",children:[a.jsx("h3",{className:"font-medium mb-3 text-red-400",children:"Error"}),a.jsx("pre",{className:"text-sm text-red-300 overflow-x-auto whitespace-pre-wrap",children:t.error})]}),t.reasoning&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.reasoning})]}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created&&t.files_created.length>0&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),a.jsx("div",{className:"space-y-1",children:t.files_created.map(i=>a.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:i},i))})]}),t.trace&&Object.keys(t.trace).length>0&&a.jsx(ap,{trace:t.trace}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Timestamps"}),a.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Created:"}),a.jsx("div",{className:"font-mono",children:new Date(t.created_at).toLocaleString()})]}),t.started_at&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Started:"}),a.jsx("div",{className:"font-mono",children:new Date(t.started_at).toLocaleString()})]}),t.completed_at&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Completed:"}),a.jsx("div",{className:"font-mono",children:new Date(t.completed_at).toLocaleString()})]})]})]})]})}function Ia({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return a.jsxs(ge,{children:[a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),a.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function S1(){const{deploymentId:e}=ha(),{data:t,isLoading:n}=oe({queryKey:["deployments",e],queryFn:()=>E0.get(e),enabled:!!e}),r=t==null?void 0:t.versions.find(i=>i.id===t.current_version_id),{data:s}=oe({queryKey:["configs",r==null?void 0:r.config_id],queryFn:()=>Tn.get(r.config_id),enabled:!!(r!=null&&r.config_id)});return n?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsxs("div",{className:"mb-4 flex-shrink-0",children:[a.jsx(pa,{items:[{label:"Agents",path:"/agents"},{label:t.name}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Hg,{size:20,className:"text-[var(--accent)]"}),a.jsx("h2",{className:"text-xl font-bold",children:t.name}),r&&a.jsxs(q,{variant:"info",children:["v",r.version]})]}),t.description&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:t.description})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsx("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-5",children:[a.jsxs("div",{className:"flex items-center gap-4 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:["Created ",new Date(t.created_at).toLocaleDateString()]}),a.jsxs("span",{children:["Updated ",new Date(t.updated_at).toLocaleDateString()]}),a.jsxs("span",{children:[t.versions.length," version",t.versions.length!==1?"s":""]})]}),s&&a.jsxs(Rn,{to:`/agents/${s.id}`,className:"flex items-center gap-2 p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-sm",children:[a.jsx(Um,{size:14,className:"text-[var(--accent)]"}),a.jsxs("span",{children:["Agent: ",a.jsx("span",{className:"font-medium",children:s.name})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider mb-3",children:"Version History"}),t.versions.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"No versions yet."}):a.jsx("div",{className:"space-y-2",children:t.versions.map(i=>a.jsx(C1,{version:i,isActive:i.id===t.current_version_id},i.id))})]})]})}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[a.jsx(Vm,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),a.jsx("div",{className:"flex-1 min-h-0",children:s?a.jsx(ip,{agent:s}):a.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-secondary)] text-sm",children:r?"Loading agent configuration...":"No active version to test."})})]})]})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Deployment not found"})}function C1({version:e,isActive:t}){const n=e.config_snapshot;return a.jsxs("div",{className:`p-3 rounded-md border transition-colors ${t?"border-[var(--accent)] bg-[var(--accent-dim)]":"border-[var(--border)] bg-[var(--bg-secondary)]"}`,children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Yg,{size:12,className:"text-[var(--text-secondary)]"}),a.jsxs("span",{className:"text-sm font-medium",children:["v",e.version]}),t&&a.jsx(q,{variant:"success",children:"Active"}),a.jsx(q,{variant:e.source==="optimize"?"info":"default",children:e.source})]}),a.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)]",children:[a.jsx(Am,{size:11}),a.jsx("span",{children:new Date(e.created_at).toLocaleString()})]})]}),e.description&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e.description}),Object.keys(n).length>0&&a.jsxs("div",{className:"mt-1",children:[a.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)] mb-1",children:[a.jsx(Dg,{size:11}),a.jsx("span",{children:"Config"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-xs",children:["framework"in n&&n.framework?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Framework"}),a.jsx("span",{className:"font-mono",children:String(n.framework)})]}):null,"model"in n&&n.model?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Model"}),a.jsx("span",{className:"font-mono",children:String(n.model)})]}):null,"tools"in n&&n.tools?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tools"}),a.jsx("span",{className:"font-mono truncate",children:Array.isArray(n.tools)?n.tools.join(", "):String(n.tools)})]}):null]})]})]})}function _1(){const{authConfig:e,isLoading:t,error:n,login:r,loginWithGitHub:s,clearError:i}=tu(),[l,o]=g.useState(""),[c,u]=g.useState("");g.useEffect(()=>{n&&i()},[l,c]);const d=async m=>{m.preventDefault(),!(!l||!c)&&await r(l,c)},f=()=>{s()};return a.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:a.jsxs("div",{className:"w-full max-w-md",children:[a.jsxs("div",{className:"text-center mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:"Flow"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:"Sign in to access the optimization dashboard"})]}),a.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] p-6 space-y-6",children:[n&&a.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[var(--error)]/10 border border-[var(--error)]/20 text-[var(--error)]",children:[a.jsx(Fm,{size:18,className:"mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-sm",children:n})]}),(e==null?void 0:e.mode)==="basic"&&a.jsxs("form",{onSubmit:d,className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Username"}),a.jsxs("div",{className:"relative",children:[a.jsx(Hm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),a.jsx("input",{type:"text",value:l,onChange:m=>o(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter username",autoComplete:"username",autoFocus:!0})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Password"}),a.jsxs("div",{className:"relative",children:[a.jsx(Bm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),a.jsx("input",{type:"password",value:c,onChange:m=>u(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter password",autoComplete:"current-password"})]})]}),a.jsx(K,{type:"submit",variant:"primary",className:"w-full justify-center",loading:t,disabled:!l||!c,children:"Sign In"})]}),(e==null?void 0:e.mode)==="github"&&a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center",children:"Sign in with your GitHub account to continue"}),a.jsx(K,{onClick:f,variant:"secondary",className:"w-full justify-center",icon:$g,children:"Continue with GitHub"})]})]})]})})}function E1({children:e}){const{authConfig:t,isLoadingConfig:n,isAuthenticated:r,loadAuthConfig:s,handleOAuthCallback:i}=tu();return g.useEffect(()=>{s()},[s]),g.useEffect(()=>{n||i()},[n,i]),n?a.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center",children:a.jsxs("div",{className:"text-center",children:[a.jsx(ma,{className:"w-8 h-8 animate-spin text-[var(--accent)] mx-auto mb-4"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:"Loading..."})]})}):t!=null&&t.enabled&&!r?a.jsx(_1,{}):a.jsx(a.Fragment,{children:e})}function P1(){return a.jsx(jg,{children:a.jsx(E1,{children:a.jsx(fg,{children:a.jsxs(xt,{path:"/",element:a.jsx($0,{}),children:[a.jsx(xt,{index:!0,element:a.jsx(B0,{})}),a.jsx(xt,{path:"agents",element:a.jsx(Z0,{})}),a.jsx(xt,{path:"agents/:agentId",element:a.jsx(i1,{})}),a.jsx(xt,{path:"tasks",element:a.jsx(u1,{})}),a.jsx(xt,{path:"jobs",element:a.jsx(m1,{})}),a.jsx(xt,{path:"jobs/:jobId",element:a.jsx(k1,{})}),a.jsx(xt,{path:"runs/:runId",element:a.jsx(b1,{})}),a.jsx(xt,{path:"tests/:testId",element:a.jsx(N1,{})}),a.jsx(xt,{path:"deployments/:deploymentId",element:a.jsx(S1,{})})]})})})})}const $d=localStorage.getItem("flow-theme");if($d)try{const{state:e}=JSON.parse($d);e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}catch{}const T1=new ly({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}});El.createRoot(document.getElementById("root")).render(a.jsx(Jo.StrictMode,{children:a.jsx(oy,{client:T1,children:a.jsx(P1,{})})})); diff --git a/src/flow/ui/ui/assets/index-DkM4ByAP.js b/src/flow/ui/ui/assets/index-DkM4ByAP.js new file mode 100644 index 0000000000000000000000000000000000000000..29d4de588d7a69908fddc6e817b5bd8a68521484 --- /dev/null +++ b/src/flow/ui/ui/assets/index-DkM4ByAP.js @@ -0,0 +1,317 @@ +var Yc=e=>{throw TypeError(e)};var Wi=(e,t,n)=>t.has(e)||Yc("Cannot "+n);var y=(e,t,n)=>(Wi(e,t,"read from private field"),n?n.call(e):t.get(e)),$=(e,t,n)=>t.has(e)?Yc("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),z=(e,t,n,r)=>(Wi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),W=(e,t,n)=>(Wi(e,t,"access private method"),n);var va=(e,t,n,r)=>({set _(s){z(e,t,s,n)},get _(){return y(e,t,r)}});function tp(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();function Wd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var qd={exports:{}},bi={},Gd={exports:{}},Y={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var ia=Symbol.for("react.element"),np=Symbol.for("react.portal"),rp=Symbol.for("react.fragment"),sp=Symbol.for("react.strict_mode"),ap=Symbol.for("react.profiler"),ip=Symbol.for("react.provider"),lp=Symbol.for("react.context"),op=Symbol.for("react.forward_ref"),cp=Symbol.for("react.suspense"),up=Symbol.for("react.memo"),dp=Symbol.for("react.lazy"),Xc=Symbol.iterator;function fp(e){return e===null||typeof e!="object"?null:(e=Xc&&e[Xc]||e["@@iterator"],typeof e=="function"?e:null)}var Jd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Yd=Object.assign,Xd={};function Xr(e,t,n){this.props=e,this.context=t,this.refs=Xd,this.updater=n||Jd}Xr.prototype.isReactComponent={};Xr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Xr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Zd(){}Zd.prototype=Xr.prototype;function $o(e,t,n){this.props=e,this.context=t,this.refs=Xd,this.updater=n||Jd}var Uo=$o.prototype=new Zd;Uo.constructor=$o;Yd(Uo,Xr.prototype);Uo.isPureReactComponent=!0;var Zc=Array.isArray,ef=Object.prototype.hasOwnProperty,Bo={current:null},tf={key:!0,ref:!0,__self:!0,__source:!0};function nf(e,t,n){var r,s={},a=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(a=""+t.key),t)ef.call(t,r)&&!tf.hasOwnProperty(r)&&(s[r]=t[r]);var o=arguments.length-2;if(o===1)s.children=n;else if(1>>1,ee=P[K];if(0>>1;Ks(te,L))pes(be,te)?(P[K]=be,P[pe]=L,K=pe):(P[K]=te,P[T]=L,K=T);else if(pes(be,L))P[K]=be,P[pe]=L,K=pe;else break e}}return A}function s(P,A){var L=P.sortIndex-A.sortIndex;return L!==0?L:P.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var c=[],d=[],h=1,u=null,p=3,x=!1,k=!1,g=!1,S=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(P){for(var A=n(d);A!==null;){if(A.callback===null)r(d);else if(A.startTime<=P)r(d),A.sortIndex=A.expirationTime,t(c,A);else break;A=n(d)}}function w(P){if(g=!1,v(P),!k)if(n(c)!==null)k=!0,q(C);else{var A=n(d);A!==null&&X(w,A.startTime-P)}}function C(P,A){k=!1,g&&(g=!1,m(_),_=-1),x=!0;var L=p;try{for(v(A),u=n(c);u!==null&&(!(u.expirationTime>A)||P&&!B());){var K=u.callback;if(typeof K=="function"){u.callback=null,p=u.priorityLevel;var ee=K(u.expirationTime<=A);A=e.unstable_now(),typeof ee=="function"?u.callback=ee:u===n(c)&&r(c),v(A)}else r(c);u=n(c)}if(u!==null)var R=!0;else{var T=n(d);T!==null&&X(w,T.startTime-A),R=!1}return R}finally{u=null,p=L,x=!1}}var b=!1,N=null,_=-1,F=5,O=-1;function B(){return!(e.unstable_now()-OP||125K?(P.sortIndex=L,t(d,P),n(c)===null&&P===n(d)&&(g?(m(_),_=-1):g=!0,X(w,L-K))):(P.sortIndex=ee,t(c,P),k||x||(k=!0,q(C))),P},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(P){var A=p;return function(){var L=p;p=A;try{return P.apply(this,arguments)}finally{p=L}}}})(of);lf.exports=of;var Np=lf.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var bp=j,et=Np;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),bl=Object.prototype.hasOwnProperty,Cp=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,tu={},nu={};function _p(e){return bl.call(nu,e)?!0:bl.call(tu,e)?!1:Cp.test(e)?nu[e]=!0:(tu[e]=!0,!1)}function Ep(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Pp(e,t,n,r){if(t===null||typeof t>"u"||Ep(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Be(e,t,n,r,s,a,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=l}var Oe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Oe[e]=new Be(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Oe[t]=new Be(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Oe[e]=new Be(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Oe[e]=new Be(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Oe[e]=new Be(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Oe[e]=new Be(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Oe[e]=new Be(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Oe[e]=new Be(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Oe[e]=new Be(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ko=/[\-:]([a-z])/g;function Ho(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Ko,Ho);Oe[t]=new Be(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Ko,Ho);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Ko,Ho);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!1,!1)});Oe.xlinkHref=new Be("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!0,!0)});function Wo(e,t,n,r){var s=Oe.hasOwnProperty(t)?Oe[t]:null;(s!==null?s.type!==0:r||!(2o||s[l]!==a[o]){var c=` +`+s[l].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{Ji=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?vs(e):""}function Tp(e){switch(e.tag){case 5:return vs(e.type);case 16:return vs("Lazy");case 13:return vs("Suspense");case 19:return vs("SuspenseList");case 0:case 2:case 15:return e=Yi(e.type,!1),e;case 11:return e=Yi(e.type.render,!1),e;case 1:return e=Yi(e.type,!0),e;default:return""}}function Pl(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case mr:return"Fragment";case hr:return"Portal";case Cl:return"Profiler";case qo:return"StrictMode";case _l:return"Suspense";case El:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case df:return(e.displayName||"Context")+".Consumer";case uf:return(e._context.displayName||"Context")+".Provider";case Go:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Jo:return t=e.displayName||null,t!==null?t:Pl(e.type)||"Memo";case Xt:t=e._payload,e=e._init;try{return Pl(e(t))}catch{}}return null}function Op(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Pl(t);case 8:return t===qo?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function _n(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function hf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Lp(e){var t=hf(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(l){r=""+l,a.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ga(e){e._valueTracker||(e._valueTracker=Lp(e))}function mf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=hf(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ja(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Tl(e,t){var n=t.checked;return me({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function su(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=_n(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function pf(e,t){t=t.checked,t!=null&&Wo(e,"checked",t,!1)}function Ol(e,t){pf(e,t);var n=_n(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ll(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ll(e,t.type,_n(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function au(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ll(e,t,n){(t!=="number"||Ja(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var xs=Array.isArray;function br(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=ja.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ls(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ws={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Rp=["Webkit","ms","Moz","O"];Object.keys(ws).forEach(function(e){Rp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ws[t]=ws[e]})});function gf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||ws.hasOwnProperty(e)&&ws[e]?(""+t).trim():t+"px"}function jf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=gf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var Mp=me({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function zl(e,t){if(t){if(Mp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function Fl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Il=null;function Yo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Dl=null,Cr=null,_r=null;function ou(e){if(e=ca(e)){if(typeof Dl!="function")throw Error(E(280));var t=e.stateNode;t&&(t=Ti(t),Dl(e.stateNode,e.type,t))}}function wf(e){Cr?_r?_r.push(e):_r=[e]:Cr=e}function kf(){if(Cr){var e=Cr,t=_r;if(_r=Cr=null,ou(e),t)for(e=0;e>>=0,e===0?32:31-(Kp(e)/Hp|0)|0}var wa=64,ka=4194304;function ys(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function ei(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,a=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~s;o!==0?r=ys(o):(a&=l,a!==0&&(r=ys(a)))}else l=n&~s,l!==0?r=ys(l):a!==0&&(r=ys(a));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,a=t&-t,s>=a||s===16&&(a&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function la(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-gt(t),e[t]=n}function Jp(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Ss),xu=" ",yu=!1;function Bf(e,t){switch(e){case"keyup":return Nv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Qf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var pr=!1;function Cv(e,t){switch(e){case"compositionend":return Qf(t);case"keypress":return t.which!==32?null:(yu=!0,xu);case"textInput":return e=t.data,e===xu&&yu?null:e;default:return null}}function _v(e,t){if(pr)return e==="compositionend"||!ac&&Bf(e,t)?(e=$f(),$a=nc=fn=null,pr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ku(n)}}function Wf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Wf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function qf(){for(var e=window,t=Ja();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ja(e.document)}return t}function ic(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Fv(e){var t=qf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Wf(n.ownerDocument.documentElement,n)){if(r!==null&&ic(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,a=Math.min(r.start,s);r=r.end===void 0?a:Math.min(r.end,s),!e.extend&&a>r&&(s=r,r=a,a=s),s=Su(n,a);var l=Su(n,r);s&&l&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,vr=null,Vl=null,bs=null,Kl=!1;function Nu(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Kl||vr==null||vr!==Ja(r)||(r=vr,"selectionStart"in r&&ic(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),bs&&Ds(bs,r)||(bs=r,r=ri(Vl,"onSelect"),0gr||(e.current=Yl[gr],Yl[gr]=null,gr--)}function ie(e,t){gr++,Yl[gr]=e.current,e.current=t}var En={},Fe=On(En),We=On(!1),Zn=En;function Vr(e,t){var n=e.type.contextTypes;if(!n)return En;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},a;for(a in n)s[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function qe(e){return e=e.childContextTypes,e!=null}function ai(){ce(We),ce(Fe)}function Ou(e,t,n){if(Fe.current!==En)throw Error(E(168));ie(Fe,t),ie(We,n)}function rh(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(E(108,Op(e)||"Unknown",s));return me({},n,r)}function ii(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||En,Zn=Fe.current,ie(Fe,e),ie(We,We.current),!0}function Lu(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=rh(e,t,Zn),r.__reactInternalMemoizedMergedChildContext=e,ce(We),ce(Fe),ie(Fe,e)):ce(We),ie(We,n)}var Rt=null,Oi=!1,dl=!1;function sh(e){Rt===null?Rt=[e]:Rt.push(e)}function qv(e){Oi=!0,sh(e)}function Ln(){if(!dl&&Rt!==null){dl=!0;var e=0,t=ae;try{var n=Rt;for(ae=1;e>=l,s-=l,Dt=1<<32-gt(t)+s|n<_?(F=N,N=null):F=N.sibling;var O=p(m,N,v[_],w);if(O===null){N===null&&(N=F);break}e&&N&&O.alternate===null&&t(m,N),f=a(O,f,_),b===null?C=O:b.sibling=O,b=O,N=F}if(_===v.length)return n(m,N),ue&&Mn(m,_),C;if(N===null){for(;__?(F=N,N=null):F=N.sibling;var B=p(m,N,O.value,w);if(B===null){N===null&&(N=F);break}e&&N&&B.alternate===null&&t(m,N),f=a(B,f,_),b===null?C=B:b.sibling=B,b=B,N=F}if(O.done)return n(m,N),ue&&Mn(m,_),C;if(N===null){for(;!O.done;_++,O=v.next())O=u(m,O.value,w),O!==null&&(f=a(O,f,_),b===null?C=O:b.sibling=O,b=O);return ue&&Mn(m,_),C}for(N=r(m,N);!O.done;_++,O=v.next())O=x(N,m,_,O.value,w),O!==null&&(e&&O.alternate!==null&&N.delete(O.key===null?_:O.key),f=a(O,f,_),b===null?C=O:b.sibling=O,b=O);return e&&N.forEach(function(G){return t(m,G)}),ue&&Mn(m,_),C}function S(m,f,v,w){if(typeof v=="object"&&v!==null&&v.type===mr&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case ya:e:{for(var C=v.key,b=f;b!==null;){if(b.key===C){if(C=v.type,C===mr){if(b.tag===7){n(m,b.sibling),f=s(b,v.props.children),f.return=m,m=f;break e}}else if(b.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Xt&&zu(C)===b.type){n(m,b.sibling),f=s(b,v.props),f.ref=fs(m,b,v),f.return=m,m=f;break e}n(m,b);break}else t(m,b);b=b.sibling}v.type===mr?(f=Jn(v.props.children,m.mode,w,v.key),f.return=m,m=f):(w=qa(v.type,v.key,v.props,null,m.mode,w),w.ref=fs(m,f,v),w.return=m,m=w)}return l(m);case hr:e:{for(b=v.key;f!==null;){if(f.key===b)if(f.tag===4&&f.stateNode.containerInfo===v.containerInfo&&f.stateNode.implementation===v.implementation){n(m,f.sibling),f=s(f,v.children||[]),f.return=m,m=f;break e}else{n(m,f);break}else t(m,f);f=f.sibling}f=gl(v,m.mode,w),f.return=m,m=f}return l(m);case Xt:return b=v._init,S(m,f,b(v._payload),w)}if(xs(v))return k(m,f,v,w);if(ls(v))return g(m,f,v,w);Pa(m,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,f!==null&&f.tag===6?(n(m,f.sibling),f=s(f,v),f.return=m,m=f):(n(m,f),f=yl(v,m.mode,w),f.return=m,m=f),l(m)):n(m,f)}return S}var Hr=oh(!0),ch=oh(!1),ci=On(null),ui=null,kr=null,uc=null;function dc(){uc=kr=ui=null}function fc(e){var t=ci.current;ce(ci),e._currentValue=t}function eo(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Pr(e,t){ui=e,uc=kr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(He=!0),e.firstContext=null)}function ct(e){var t=e._currentValue;if(uc!==e)if(e={context:e,memoizedValue:t,next:null},kr===null){if(ui===null)throw Error(E(308));kr=e,ui.dependencies={lanes:0,firstContext:e}}else kr=kr.next=e;return t}var In=null;function hc(e){In===null?In=[e]:In.push(e)}function uh(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,hc(t)):(n.next=s.next,s.next=n),t.interleaved=n,Kt(e,r)}function Kt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Zt=!1;function mc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function dh(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function $t(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function wn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ne&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Kt(e,n)}return s=r.interleaved,s===null?(t.next=t,hc(r)):(t.next=s.next,s.next=t),r.interleaved=t,Kt(e,n)}function Ba(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Zo(e,n)}}function Fu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?s=a=l:a=a.next=l,n=n.next}while(n!==null);a===null?s=a=t:a=a.next=t}else s=a=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function di(e,t,n,r){var s=e.updateQueue;Zt=!1;var a=s.firstBaseUpdate,l=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var c=o,d=c.next;c.next=null,l===null?a=d:l.next=d,l=c;var h=e.alternate;h!==null&&(h=h.updateQueue,o=h.lastBaseUpdate,o!==l&&(o===null?h.firstBaseUpdate=d:o.next=d,h.lastBaseUpdate=c))}if(a!==null){var u=s.baseState;l=0,h=d=c=null,o=a;do{var p=o.lane,x=o.eventTime;if((r&p)===p){h!==null&&(h=h.next={eventTime:x,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var k=e,g=o;switch(p=t,x=n,g.tag){case 1:if(k=g.payload,typeof k=="function"){u=k.call(x,u,p);break e}u=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=g.payload,p=typeof k=="function"?k.call(x,u,p):k,p==null)break e;u=me({},u,p);break e;case 2:Zt=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[o]:p.push(o))}else x={eventTime:x,lane:p,tag:o.tag,payload:o.payload,callback:o.callback,next:null},h===null?(d=h=x,c=u):h=h.next=x,l|=p;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;p=o,o=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(h===null&&(c=u),s.baseState=c,s.firstBaseUpdate=d,s.lastBaseUpdate=h,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else a===null&&(s.shared.lanes=0);nr|=l,e.lanes=l,e.memoizedState=u}}function Iu(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=hl.transition;hl.transition={};try{e(!1),t()}finally{ae=n,hl.transition=r}}function Eh(){return ut().memoizedState}function Xv(e,t,n){var r=Sn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ph(e))Th(t,n);else if(n=uh(e,t,n,r),n!==null){var s=$e();jt(n,e,r,s),Oh(n,t,r)}}function Zv(e,t,n){var r=Sn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ph(e))Th(t,s);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var l=t.lastRenderedState,o=a(l,n);if(s.hasEagerState=!0,s.eagerState=o,wt(o,l)){var c=t.interleaved;c===null?(s.next=s,hc(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=uh(e,t,s,r),n!==null&&(s=$e(),jt(n,e,r,s),Oh(n,t,r))}}function Ph(e){var t=e.alternate;return e===fe||t!==null&&t===fe}function Th(e,t){Cs=hi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Oh(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Zo(e,n)}}var mi={readContext:ct,useCallback:Le,useContext:Le,useEffect:Le,useImperativeHandle:Le,useInsertionEffect:Le,useLayoutEffect:Le,useMemo:Le,useReducer:Le,useRef:Le,useState:Le,useDebugValue:Le,useDeferredValue:Le,useTransition:Le,useMutableSource:Le,useSyncExternalStore:Le,useId:Le,unstable_isNewReconciler:!1},ex={readContext:ct,useCallback:function(e,t){return St().memoizedState=[e,t===void 0?null:t],e},useContext:ct,useEffect:Au,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Va(4194308,4,Sh.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Va(4194308,4,e,t)},useInsertionEffect:function(e,t){return Va(4,2,e,t)},useMemo:function(e,t){var n=St();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=St();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Xv.bind(null,fe,e),[r.memoizedState,e]},useRef:function(e){var t=St();return e={current:e},t.memoizedState=e},useState:Du,useDebugValue:kc,useDeferredValue:function(e){return St().memoizedState=e},useTransition:function(){var e=Du(!1),t=e[0];return e=Yv.bind(null,e[1]),St().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=fe,s=St();if(ue){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),Ee===null)throw Error(E(349));tr&30||ph(r,t,n)}s.memoizedState=n;var a={value:n,getSnapshot:t};return s.queue=a,Au(xh.bind(null,r,a,e),[e]),r.flags|=2048,Hs(9,vh.bind(null,r,a,n,t),void 0,null),n},useId:function(){var e=St(),t=Ee.identifierPrefix;if(ue){var n=At,r=Dt;n=(r&~(1<<32-gt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Vs++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[_t]=t,e[Us]=r,Uh(e,t,!1,!1),t.stateNode=e;e:{switch(l=Fl(n,r),n){case"dialog":oe("cancel",e),oe("close",e),s=r;break;case"iframe":case"object":case"embed":oe("load",e),s=r;break;case"video":case"audio":for(s=0;sGr&&(t.flags|=128,r=!0,hs(a,!1),t.lanes=4194304)}else{if(!r)if(e=fi(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),hs(a,!0),a.tail===null&&a.tailMode==="hidden"&&!l.alternate&&!ue)return Re(t),null}else 2*je()-a.renderingStartTime>Gr&&n!==1073741824&&(t.flags|=128,r=!0,hs(a,!1),t.lanes=4194304);a.isBackwards?(l.sibling=t.child,t.child=l):(n=a.last,n!==null?n.sibling=l:t.child=l,a.last=l)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=je(),t.sibling=null,n=de.current,ie(de,r?n&1|2:n&1),t):(Re(t),null);case 22:case 23:return Ec(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ye&1073741824&&(Re(t),t.subtreeFlags&6&&(t.flags|=8192)):Re(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function ox(e,t){switch(oc(t),t.tag){case 1:return qe(t.type)&&ai(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Wr(),ce(We),ce(Fe),xc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return vc(t),null;case 13:if(ce(de),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));Kr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ce(de),null;case 4:return Wr(),null;case 10:return fc(t.type._context),null;case 22:case 23:return Ec(),null;case 24:return null;default:return null}}var Oa=!1,ze=!1,cx=typeof WeakSet=="function"?WeakSet:Set,I=null;function Sr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){xe(e,t,r)}else n.current=null}function co(e,t,n){try{n()}catch(r){xe(e,t,r)}}var Ju=!1;function ux(e,t){if(Hl=ti,e=qf(),ic(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break e}var l=0,o=-1,c=-1,d=0,h=0,u=e,p=null;t:for(;;){for(var x;u!==n||s!==0&&u.nodeType!==3||(o=l+s),u!==a||r!==0&&u.nodeType!==3||(c=l+r),u.nodeType===3&&(l+=u.nodeValue.length),(x=u.firstChild)!==null;)p=u,u=x;for(;;){if(u===e)break t;if(p===n&&++d===s&&(o=l),p===a&&++h===r&&(c=l),(x=u.nextSibling)!==null)break;u=p,p=u.parentNode}u=x}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Wl={focusedElem:e,selectionRange:n},ti=!1,I=t;I!==null;)if(t=I,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,I=e;else for(;I!==null;){t=I;try{var k=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(k!==null){var g=k.memoizedProps,S=k.memoizedState,m=t.stateNode,f=m.getSnapshotBeforeUpdate(t.elementType===t.type?g:mt(t.type,g),S);m.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var v=t.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(w){xe(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,I=e;break}I=t.return}return k=Ju,Ju=!1,k}function _s(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var a=s.destroy;s.destroy=void 0,a!==void 0&&co(t,n,a)}s=s.next}while(s!==r)}}function Mi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function uo(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Vh(e){var t=e.alternate;t!==null&&(e.alternate=null,Vh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[_t],delete t[Us],delete t[Jl],delete t[Hv],delete t[Wv])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Kh(e){return e.tag===5||e.tag===3||e.tag===4}function Yu(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Kh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function fo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=si));else if(r!==4&&(e=e.child,e!==null))for(fo(e,t,n),e=e.sibling;e!==null;)fo(e,t,n),e=e.sibling}function ho(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(ho(e,t,n),e=e.sibling;e!==null;)ho(e,t,n),e=e.sibling}var Pe=null,xt=!1;function Jt(e,t,n){for(n=n.child;n!==null;)Hh(e,t,n),n=n.sibling}function Hh(e,t,n){if(Pt&&typeof Pt.onCommitFiberUnmount=="function")try{Pt.onCommitFiberUnmount(Ci,n)}catch{}switch(n.tag){case 5:ze||Sr(n,t);case 6:var r=Pe,s=xt;Pe=null,Jt(e,t,n),Pe=r,xt=s,Pe!==null&&(xt?(e=Pe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Pe.removeChild(n.stateNode));break;case 18:Pe!==null&&(xt?(e=Pe,n=n.stateNode,e.nodeType===8?ul(e.parentNode,n):e.nodeType===1&&ul(e,n),Fs(e)):ul(Pe,n.stateNode));break;case 4:r=Pe,s=xt,Pe=n.stateNode.containerInfo,xt=!0,Jt(e,t,n),Pe=r,xt=s;break;case 0:case 11:case 14:case 15:if(!ze&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var a=s,l=a.destroy;a=a.tag,l!==void 0&&(a&2||a&4)&&co(n,t,l),s=s.next}while(s!==r)}Jt(e,t,n);break;case 1:if(!ze&&(Sr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){xe(n,t,o)}Jt(e,t,n);break;case 21:Jt(e,t,n);break;case 22:n.mode&1?(ze=(r=ze)||n.memoizedState!==null,Jt(e,t,n),ze=r):Jt(e,t,n);break;default:Jt(e,t,n)}}function Xu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new cx),t.forEach(function(r){var s=gx.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function ft(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=l),r&=~a}if(r=s,r=je()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*fx(r/1960))-r,10e?16:e,hn===null)var r=!1;else{if(e=hn,hn=null,xi=0,ne&6)throw Error(E(331));var s=ne;for(ne|=4,I=e.current;I!==null;){var a=I,l=a.child;if(I.flags&16){var o=a.deletions;if(o!==null){for(var c=0;cje()-Cc?Gn(e,0):bc|=n),Ge(e,t)}function em(e,t){t===0&&(e.mode&1?(t=ka,ka<<=1,!(ka&130023424)&&(ka=4194304)):t=1);var n=$e();e=Kt(e,t),e!==null&&(la(e,t,n),Ge(e,n))}function yx(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),em(e,n)}function gx(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),em(e,n)}var tm;tm=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||We.current)He=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return He=!1,ix(e,t,n);He=!!(e.flags&131072)}else He=!1,ue&&t.flags&1048576&&ah(t,oi,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ka(e,t),e=t.pendingProps;var s=Vr(t,Fe.current);Pr(t,n),s=gc(null,t,r,e,s,n);var a=jc();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,qe(r)?(a=!0,ii(t)):a=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,mc(t),s.updater=Ri,t.stateNode=s,s._reactInternals=t,no(t,r,e,n),t=ao(null,t,r,!0,a,n)):(t.tag=0,ue&&a&&lc(t),De(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ka(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=wx(r),e=mt(r,e),s){case 0:t=so(null,t,r,e,n);break e;case 1:t=Wu(null,t,r,e,n);break e;case 11:t=Ku(null,t,r,e,n);break e;case 14:t=Hu(null,t,r,mt(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),so(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Wu(e,t,r,s,n);case 3:e:{if(Dh(t),e===null)throw Error(E(387));r=t.pendingProps,a=t.memoizedState,s=a.element,dh(e,t),di(t,r,null,n);var l=t.memoizedState;if(r=l.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){s=qr(Error(E(423)),t),t=qu(e,t,r,n,s);break e}else if(r!==s){s=qr(Error(E(424)),t),t=qu(e,t,r,n,s);break e}else for(Xe=jn(t.stateNode.containerInfo.firstChild),Ze=t,ue=!0,yt=null,n=ch(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Kr(),r===s){t=Ht(e,t,n);break e}De(e,t,r,n)}t=t.child}return t;case 5:return fh(t),e===null&&Zl(t),r=t.type,s=t.pendingProps,a=e!==null?e.memoizedProps:null,l=s.children,ql(r,s)?l=null:a!==null&&ql(r,a)&&(t.flags|=32),Ih(e,t),De(e,t,l,n),t.child;case 6:return e===null&&Zl(t),null;case 13:return Ah(e,t,n);case 4:return pc(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Hr(t,null,r,n):De(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Ku(e,t,r,s,n);case 7:return De(e,t,t.pendingProps,n),t.child;case 8:return De(e,t,t.pendingProps.children,n),t.child;case 12:return De(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,a=t.memoizedProps,l=s.value,ie(ci,r._currentValue),r._currentValue=l,a!==null)if(wt(a.value,l)){if(a.children===s.children&&!We.current){t=Ht(e,t,n);break e}}else for(a=t.child,a!==null&&(a.return=t);a!==null;){var o=a.dependencies;if(o!==null){l=a.child;for(var c=o.firstContext;c!==null;){if(c.context===r){if(a.tag===1){c=$t(-1,n&-n),c.tag=2;var d=a.updateQueue;if(d!==null){d=d.shared;var h=d.pending;h===null?c.next=c:(c.next=h.next,h.next=c),d.pending=c}}a.lanes|=n,c=a.alternate,c!==null&&(c.lanes|=n),eo(a.return,n,t),o.lanes|=n;break}c=c.next}}else if(a.tag===10)l=a.type===t.type?null:a.child;else if(a.tag===18){if(l=a.return,l===null)throw Error(E(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),eo(l,n,t),l=a.sibling}else l=a.child;if(l!==null)l.return=a;else for(l=a;l!==null;){if(l===t){l=null;break}if(a=l.sibling,a!==null){a.return=l.return,l=a;break}l=l.return}a=l}De(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Pr(t,n),s=ct(s),r=r(s),t.flags|=1,De(e,t,r,n),t.child;case 14:return r=t.type,s=mt(r,t.pendingProps),s=mt(r.type,s),Hu(e,t,r,s,n);case 15:return zh(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Ka(e,t),t.tag=1,qe(r)?(e=!0,ii(t)):e=!1,Pr(t,n),Lh(t,r,s),no(t,r,s,n),ao(null,t,r,!0,e,n);case 19:return $h(e,t,n);case 22:return Fh(e,t,n)}throw Error(E(156,t.tag))};function nm(e,t){return Pf(e,t)}function jx(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function lt(e,t,n,r){return new jx(e,t,n,r)}function Tc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function wx(e){if(typeof e=="function")return Tc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Go)return 11;if(e===Jo)return 14}return 2}function Nn(e,t){var n=e.alternate;return n===null?(n=lt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function qa(e,t,n,r,s,a){var l=2;if(r=e,typeof e=="function")Tc(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case mr:return Jn(n.children,s,a,t);case qo:l=8,s|=8;break;case Cl:return e=lt(12,n,t,s|2),e.elementType=Cl,e.lanes=a,e;case _l:return e=lt(13,n,t,s),e.elementType=_l,e.lanes=a,e;case El:return e=lt(19,n,t,s),e.elementType=El,e.lanes=a,e;case ff:return Fi(n,s,a,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case uf:l=10;break e;case df:l=9;break e;case Go:l=11;break e;case Jo:l=14;break e;case Xt:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=lt(l,n,t,s),t.elementType=e,t.type=r,t.lanes=a,t}function Jn(e,t,n,r){return e=lt(7,e,r,t),e.lanes=n,e}function Fi(e,t,n,r){return e=lt(22,e,r,t),e.elementType=ff,e.lanes=n,e.stateNode={isHidden:!1},e}function yl(e,t,n){return e=lt(6,e,null,t),e.lanes=n,e}function gl(e,t,n){return t=lt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function kx(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Zi(0),this.expirationTimes=Zi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Zi(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Oc(e,t,n,r,s,a,l,o,c){return e=new kx(e,t,n,o,c),t===1?(t=1,a===!0&&(t|=8)):t=0,a=lt(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},mc(a),e}function Sx(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(im)}catch(e){console.error(e)}}im(),af.exports=tt;var Ex=af.exports,id=Ex;Nl.createRoot=id.createRoot,Nl.hydrateRoot=id.hydrateRoot;var ts=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Px={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},nn,Ao,Fd,Tx=(Fd=class{constructor(){$(this,nn,Px);$(this,Ao,!1)}setTimeoutProvider(e){z(this,nn,e)}setTimeout(e,t){return y(this,nn).setTimeout(e,t)}clearTimeout(e){y(this,nn).clearTimeout(e)}setInterval(e,t){return y(this,nn).setInterval(e,t)}clearInterval(e){y(this,nn).clearInterval(e)}},nn=new WeakMap,Ao=new WeakMap,Fd),An=new Tx;function Ox(e){setTimeout(e,0)}var sr=typeof window>"u"||"Deno"in globalThis;function Ae(){}function Lx(e,t){return typeof e=="function"?e(t):e}function yo(e){return typeof e=="number"&&e>=0&&e!==1/0}function lm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function bn(e,t){return typeof e=="function"?e(t):e}function st(e,t){return typeof e=="function"?e(t):e}function ld(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:a,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==zc(l,t.options))return!1}else if(!qs(t.queryKey,l))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||s&&s!==t.state.fetchStatus||a&&!a(t))}function od(e,t){const{exact:n,status:r,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(ar(t.options.mutationKey)!==ar(a))return!1}else if(!qs(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function zc(e,t){return((t==null?void 0:t.queryKeyHashFn)||ar)(e)}function ar(e){return JSON.stringify(e,(t,n)=>go(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function qs(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>qs(e[n],t[n])):!1}var Rx=Object.prototype.hasOwnProperty;function om(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=cd(e)&&cd(t);if(!r&&!(go(e)&&go(t)))return t;const a=(r?e:Object.keys(e)).length,l=r?t:Object.keys(t),o=l.length,c=r?new Array(o):{};let d=0;for(let h=0;h{An.setTimeout(t,e)})}function jo(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?om(e,t):t}function zx(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Fx(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Fc=Symbol();function cm(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Fc?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Ic(e,t){return typeof e=="function"?e(...t):!!e}function Ix(e,t,n){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),e}var $n,rn,Or,Id,Dx=(Id=class extends ts{constructor(){super();$(this,$n);$(this,rn);$(this,Or);z(this,Or,t=>{if(!sr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){y(this,rn)||this.setEventListener(y(this,Or))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,rn))==null||t.call(this),z(this,rn,void 0))}setEventListener(t){var n;z(this,Or,t),(n=y(this,rn))==null||n.call(this),z(this,rn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){y(this,$n)!==t&&(z(this,$n,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof y(this,$n)=="boolean"?y(this,$n):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},$n=new WeakMap,rn=new WeakMap,Or=new WeakMap,Id),Dc=new Dx;function wo(){let e,t;const n=new Promise((s,a)=>{e=s,t=a});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var Ax=Ox;function $x(){let e=[],t=0,n=o=>{o()},r=o=>{o()},s=Ax;const a=o=>{t?e.push(o):s(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&s(()=>{r(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;t++;try{c=o()}finally{t--,t||l()}return c},batchCalls:o=>(...c)=>{a(()=>{o(...c)})},schedule:a,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{s=o}}}var Se=$x(),Lr,sn,Rr,Dd,Ux=(Dd=class extends ts{constructor(){super();$(this,Lr,!0);$(this,sn);$(this,Rr);z(this,Rr,t=>{if(!sr&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){y(this,sn)||this.setEventListener(y(this,Rr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,sn))==null||t.call(this),z(this,sn,void 0))}setEventListener(t){var n;z(this,Rr,t),(n=y(this,sn))==null||n.call(this),z(this,sn,t(this.setOnline.bind(this)))}setOnline(t){y(this,Lr)!==t&&(z(this,Lr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return y(this,Lr)}},Lr=new WeakMap,sn=new WeakMap,Rr=new WeakMap,Dd),wi=new Ux;function Bx(e){return Math.min(1e3*2**e,3e4)}function um(e){return(e??"online")==="online"?wi.isOnline():!0}var ko=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function dm(e){let t=!1,n=0,r;const s=wo(),a=()=>s.status!=="pending",l=g=>{var S;if(!a()){const m=new ko(g);p(m),(S=e.onCancel)==null||S.call(e,m)}},o=()=>{t=!0},c=()=>{t=!1},d=()=>Dc.isFocused()&&(e.networkMode==="always"||wi.isOnline())&&e.canRun(),h=()=>um(e.networkMode)&&e.canRun(),u=g=>{a()||(r==null||r(),s.resolve(g))},p=g=>{a()||(r==null||r(),s.reject(g))},x=()=>new Promise(g=>{var S;r=m=>{(a()||d())&&g(m)},(S=e.onPause)==null||S.call(e)}).then(()=>{var g;r=void 0,a()||(g=e.onContinue)==null||g.call(e)}),k=()=>{if(a())return;let g;const S=n===0?e.initialPromise:void 0;try{g=S??e.fn()}catch(m){g=Promise.reject(m)}Promise.resolve(g).then(u).catch(m=>{var b;if(a())return;const f=e.retry??(sr?0:3),v=e.retryDelay??Bx,w=typeof v=="function"?v(n,m):v,C=f===!0||typeof f=="number"&&nd()?void 0:x()).then(()=>{t?p(m):k()})})};return{promise:s,status:()=>s.status,cancel:l,continue:()=>(r==null||r(),s),cancelRetry:o,continueRetry:c,canStart:h,start:()=>(h()?k():x().then(k),s)}}var Un,Ad,fm=(Ad=class{constructor(){$(this,Un)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),yo(this.gcTime)&&z(this,Un,An.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(sr?1/0:5*60*1e3))}clearGcTimeout(){y(this,Un)&&(An.clearTimeout(y(this,Un)),z(this,Un,void 0))}},Un=new WeakMap,Ad),Bn,Mr,rt,Qn,Ce,ta,Vn,pt,Ot,$d,Qx=($d=class extends fm{constructor(t){super();$(this,pt);$(this,Bn);$(this,Mr);$(this,rt);$(this,Qn);$(this,Ce);$(this,ta);$(this,Vn);z(this,Vn,!1),z(this,ta,t.defaultOptions),this.setOptions(t.options),this.observers=[],z(this,Qn,t.client),z(this,rt,y(this,Qn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,z(this,Bn,fd(this.options)),this.state=t.state??y(this,Bn),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=y(this,Ce))==null?void 0:t.promise}setOptions(t){if(this.options={...y(this,ta),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=fd(this.options);n.data!==void 0&&(this.setState(dd(n.data,n.dataUpdatedAt)),z(this,Bn,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&y(this,rt).remove(this)}setData(t,n){const r=jo(this.state.data,t,this.options);return W(this,pt,Ot).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){W(this,pt,Ot).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=y(this,Ce))==null?void 0:r.promise;return(s=y(this,Ce))==null||s.cancel(t),n?n.then(Ae).catch(Ae):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(y(this,Bn))}isActive(){return this.observers.some(t=>st(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Fc||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>bn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!lm(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),y(this,rt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(y(this,Ce)&&(y(this,Vn)?y(this,Ce).cancel({revert:!0}):y(this,Ce).cancelRetry()),this.scheduleGc()),y(this,rt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||W(this,pt,Ot).call(this,{type:"invalidate"})}async fetch(t,n){var c,d,h,u,p,x,k,g,S,m,f,v;if(this.state.fetchStatus!=="idle"&&((c=y(this,Ce))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(y(this,Ce))return y(this,Ce).continueRetry(),y(this,Ce).promise}if(t&&this.setOptions(t),!this.options.queryFn){const w=this.observers.find(C=>C.options.queryFn);w&&this.setOptions(w.options)}const r=new AbortController,s=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(z(this,Vn,!0),r.signal)})},a=()=>{const w=cm(this.options,n),b=(()=>{const N={client:y(this,Qn),queryKey:this.queryKey,meta:this.meta};return s(N),N})();return z(this,Vn,!1),this.options.persister?this.options.persister(w,b,this):w(b)},o=(()=>{const w={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:y(this,Qn),state:this.state,fetchFn:a};return s(w),w})();(d=this.options.behavior)==null||d.onFetch(o,this),z(this,Mr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((h=o.fetchOptions)==null?void 0:h.meta))&&W(this,pt,Ot).call(this,{type:"fetch",meta:(u=o.fetchOptions)==null?void 0:u.meta}),z(this,Ce,dm({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:w=>{w instanceof ko&&w.revert&&this.setState({...y(this,Mr),fetchStatus:"idle"}),r.abort()},onFail:(w,C)=>{W(this,pt,Ot).call(this,{type:"failed",failureCount:w,error:C})},onPause:()=>{W(this,pt,Ot).call(this,{type:"pause"})},onContinue:()=>{W(this,pt,Ot).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const w=await y(this,Ce).start();if(w===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(w),(x=(p=y(this,rt).config).onSuccess)==null||x.call(p,w,this),(g=(k=y(this,rt).config).onSettled)==null||g.call(k,w,this.state.error,this),w}catch(w){if(w instanceof ko){if(w.silent)return y(this,Ce).promise;if(w.revert){if(this.state.data===void 0)throw w;return this.state.data}}throw W(this,pt,Ot).call(this,{type:"error",error:w}),(m=(S=y(this,rt).config).onError)==null||m.call(S,w,this),(v=(f=y(this,rt).config).onSettled)==null||v.call(f,this.state.data,w,this),w}finally{this.scheduleGc()}}},Bn=new WeakMap,Mr=new WeakMap,rt=new WeakMap,Qn=new WeakMap,Ce=new WeakMap,ta=new WeakMap,Vn=new WeakMap,pt=new WeakSet,Ot=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...hm(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...dd(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return z(this,Mr,t.manual?s:void 0),s;case"error":const a=t.error;return{...r,error:a,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Se.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),y(this,rt).notify({query:this,type:"updated",action:t})})},$d);function hm(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:um(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function dd(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function fd(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Qe,Z,na,Ie,Kn,zr,Mt,an,ra,Fr,Ir,Hn,Wn,ln,Dr,se,js,So,No,bo,Co,_o,Eo,Po,mm,Ud,Vx=(Ud=class extends ts{constructor(t,n){super();$(this,se);$(this,Qe);$(this,Z);$(this,na);$(this,Ie);$(this,Kn);$(this,zr);$(this,Mt);$(this,an);$(this,ra);$(this,Fr);$(this,Ir);$(this,Hn);$(this,Wn);$(this,ln);$(this,Dr,new Set);this.options=n,z(this,Qe,t),z(this,an,null),z(this,Mt,wo()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(y(this,Z).addObserver(this),hd(y(this,Z),this.options)?W(this,se,js).call(this):this.updateResult(),W(this,se,Co).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return To(y(this,Z),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return To(y(this,Z),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,W(this,se,_o).call(this),W(this,se,Eo).call(this),y(this,Z).removeObserver(this)}setOptions(t){const n=this.options,r=y(this,Z);if(this.options=y(this,Qe).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof st(this.options.enabled,y(this,Z))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");W(this,se,Po).call(this),y(this,Z).setOptions(this.options),n._defaulted&&!ji(this.options,n)&&y(this,Qe).getQueryCache().notify({type:"observerOptionsUpdated",query:y(this,Z),observer:this});const s=this.hasListeners();s&&md(y(this,Z),r,this.options,n)&&W(this,se,js).call(this),this.updateResult(),s&&(y(this,Z)!==r||st(this.options.enabled,y(this,Z))!==st(n.enabled,y(this,Z))||bn(this.options.staleTime,y(this,Z))!==bn(n.staleTime,y(this,Z)))&&W(this,se,So).call(this);const a=W(this,se,No).call(this);s&&(y(this,Z)!==r||st(this.options.enabled,y(this,Z))!==st(n.enabled,y(this,Z))||a!==y(this,ln))&&W(this,se,bo).call(this,a)}getOptimisticResult(t){const n=y(this,Qe).getQueryCache().build(y(this,Qe),t),r=this.createResult(n,t);return Hx(this,r)&&(z(this,Ie,r),z(this,zr,this.options),z(this,Kn,y(this,Z).state)),r}getCurrentResult(){return y(this,Ie)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&y(this,Mt).status==="pending"&&y(this,Mt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){y(this,Dr).add(t)}getCurrentQuery(){return y(this,Z)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=y(this,Qe).defaultQueryOptions(t),r=y(this,Qe).getQueryCache().build(y(this,Qe),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return W(this,se,js).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),y(this,Ie)))}createResult(t,n){var F;const r=y(this,Z),s=this.options,a=y(this,Ie),l=y(this,Kn),o=y(this,zr),d=t!==r?t.state:y(this,na),{state:h}=t;let u={...h},p=!1,x;if(n._optimisticResults){const O=this.hasListeners(),B=!O&&hd(t,n),G=O&&md(t,r,n,s);(B||G)&&(u={...u,...hm(h.data,t.options)}),n._optimisticResults==="isRestoring"&&(u.fetchStatus="idle")}let{error:k,errorUpdatedAt:g,status:S}=u;x=u.data;let m=!1;if(n.placeholderData!==void 0&&x===void 0&&S==="pending"){let O;a!=null&&a.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(O=a.data,m=!0):O=typeof n.placeholderData=="function"?n.placeholderData((F=y(this,Ir))==null?void 0:F.state.data,y(this,Ir)):n.placeholderData,O!==void 0&&(S="success",x=jo(a==null?void 0:a.data,O,n),p=!0)}if(n.select&&x!==void 0&&!m)if(a&&x===(l==null?void 0:l.data)&&n.select===y(this,ra))x=y(this,Fr);else try{z(this,ra,n.select),x=n.select(x),x=jo(a==null?void 0:a.data,x,n),z(this,Fr,x),z(this,an,null)}catch(O){z(this,an,O)}y(this,an)&&(k=y(this,an),x=y(this,Fr),g=Date.now(),S="error");const f=u.fetchStatus==="fetching",v=S==="pending",w=S==="error",C=v&&f,b=x!==void 0,_={status:S,fetchStatus:u.fetchStatus,isPending:v,isSuccess:S==="success",isError:w,isInitialLoading:C,isLoading:C,data:x,dataUpdatedAt:u.dataUpdatedAt,error:k,errorUpdatedAt:g,failureCount:u.fetchFailureCount,failureReason:u.fetchFailureReason,errorUpdateCount:u.errorUpdateCount,isFetched:u.dataUpdateCount>0||u.errorUpdateCount>0,isFetchedAfterMount:u.dataUpdateCount>d.dataUpdateCount||u.errorUpdateCount>d.errorUpdateCount,isFetching:f,isRefetching:f&&!v,isLoadingError:w&&!b,isPaused:u.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:w&&b,isStale:Ac(t,n),refetch:this.refetch,promise:y(this,Mt),isEnabled:st(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=_.data!==void 0,B=_.status==="error"&&!O,G=D=>{B?D.reject(_.error):O&&D.resolve(_.data)},re=()=>{const D=z(this,Mt,_.promise=wo());G(D)},le=y(this,Mt);switch(le.status){case"pending":t.queryHash===r.queryHash&&G(le);break;case"fulfilled":(B||_.data!==le.value)&&re();break;case"rejected":(!B||_.error!==le.reason)&&re();break}}return _}updateResult(){const t=y(this,Ie),n=this.createResult(y(this,Z),this.options);if(z(this,Kn,y(this,Z).state),z(this,zr,this.options),y(this,Kn).data!==void 0&&z(this,Ir,y(this,Z)),ji(n,t))return;z(this,Ie,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!y(this,Dr).size)return!0;const l=new Set(a??y(this,Dr));return this.options.throwOnError&&l.add("error"),Object.keys(y(this,Ie)).some(o=>{const c=o;return y(this,Ie)[c]!==t[c]&&l.has(c)})};W(this,se,mm).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&W(this,se,Co).call(this)}},Qe=new WeakMap,Z=new WeakMap,na=new WeakMap,Ie=new WeakMap,Kn=new WeakMap,zr=new WeakMap,Mt=new WeakMap,an=new WeakMap,ra=new WeakMap,Fr=new WeakMap,Ir=new WeakMap,Hn=new WeakMap,Wn=new WeakMap,ln=new WeakMap,Dr=new WeakMap,se=new WeakSet,js=function(t){W(this,se,Po).call(this);let n=y(this,Z).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Ae)),n},So=function(){W(this,se,_o).call(this);const t=bn(this.options.staleTime,y(this,Z));if(sr||y(this,Ie).isStale||!yo(t))return;const r=lm(y(this,Ie).dataUpdatedAt,t)+1;z(this,Hn,An.setTimeout(()=>{y(this,Ie).isStale||this.updateResult()},r))},No=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(y(this,Z)):this.options.refetchInterval)??!1},bo=function(t){W(this,se,Eo).call(this),z(this,ln,t),!(sr||st(this.options.enabled,y(this,Z))===!1||!yo(y(this,ln))||y(this,ln)===0)&&z(this,Wn,An.setInterval(()=>{(this.options.refetchIntervalInBackground||Dc.isFocused())&&W(this,se,js).call(this)},y(this,ln)))},Co=function(){W(this,se,So).call(this),W(this,se,bo).call(this,W(this,se,No).call(this))},_o=function(){y(this,Hn)&&(An.clearTimeout(y(this,Hn)),z(this,Hn,void 0))},Eo=function(){y(this,Wn)&&(An.clearInterval(y(this,Wn)),z(this,Wn,void 0))},Po=function(){const t=y(this,Qe).getQueryCache().build(y(this,Qe),this.options);if(t===y(this,Z))return;const n=y(this,Z);z(this,Z,t),z(this,na,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},mm=function(t){Se.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(y(this,Ie))}),y(this,Qe).getQueryCache().notify({query:y(this,Z),type:"observerResultsUpdated"})})},Ud);function Kx(e,t){return st(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function hd(e,t){return Kx(e,t)||e.state.data!==void 0&&To(e,t,t.refetchOnMount)}function To(e,t,n){if(st(t.enabled,e)!==!1&&bn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Ac(e,t)}return!1}function md(e,t,n,r){return(e!==t||st(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Ac(e,n)}function Ac(e,t){return st(t.enabled,e)!==!1&&e.isStaleByTime(bn(t.staleTime,e))}function Hx(e,t){return!ji(e.getCurrentResult(),t)}function pd(e){return{onFetch:(t,n)=>{var h,u,p,x,k;const r=t.options,s=(p=(u=(h=t.fetchOptions)==null?void 0:h.meta)==null?void 0:u.fetchMore)==null?void 0:p.direction,a=((x=t.state.data)==null?void 0:x.pages)||[],l=((k=t.state.data)==null?void 0:k.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const d=async()=>{let g=!1;const S=v=>{Ix(v,()=>t.signal,()=>g=!0)},m=cm(t.options,t.fetchOptions),f=async(v,w,C)=>{if(g)return Promise.reject();if(w==null&&v.pages.length)return Promise.resolve(v);const N=(()=>{const B={client:t.client,queryKey:t.queryKey,pageParam:w,direction:C?"backward":"forward",meta:t.options.meta};return S(B),B})(),_=await m(N),{maxPages:F}=t.options,O=C?Fx:zx;return{pages:O(v.pages,_,F),pageParams:O(v.pageParams,w,F)}};if(s&&a.length){const v=s==="backward",w=v?Wx:vd,C={pages:a,pageParams:l},b=w(r,C);o=await f(C,b,v)}else{const v=e??a.length;do{const w=c===0?l[0]??r.initialPageParam:vd(r,o);if(c>0&&w==null)break;o=await f(o,w),c++}while(c{var g,S;return(S=(g=t.options).persister)==null?void 0:S.call(g,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=d}}}function vd(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Wx(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var sa,Nt,Me,qn,bt,Yt,Bd,qx=(Bd=class extends fm{constructor(t){super();$(this,bt);$(this,sa);$(this,Nt);$(this,Me);$(this,qn);z(this,sa,t.client),this.mutationId=t.mutationId,z(this,Me,t.mutationCache),z(this,Nt,[]),this.state=t.state||pm(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){y(this,Nt).includes(t)||(y(this,Nt).push(t),this.clearGcTimeout(),y(this,Me).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){z(this,Nt,y(this,Nt).filter(n=>n!==t)),this.scheduleGc(),y(this,Me).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){y(this,Nt).length||(this.state.status==="pending"?this.scheduleGc():y(this,Me).remove(this))}continue(){var t;return((t=y(this,qn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,d,h,u,p,x,k,g,S,m,f,v,w,C,b,N;const n=()=>{W(this,bt,Yt).call(this,{type:"continue"})},r={client:y(this,sa),meta:this.options.meta,mutationKey:this.options.mutationKey};z(this,qn,dm({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(_,F)=>{W(this,bt,Yt).call(this,{type:"failed",failureCount:_,error:F})},onPause:()=>{W(this,bt,Yt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>y(this,Me).canRun(this)}));const s=this.state.status==="pending",a=!y(this,qn).canStart();try{if(s)n();else{W(this,bt,Yt).call(this,{type:"pending",variables:t,isPaused:a}),y(this,Me).config.onMutate&&await y(this,Me).config.onMutate(t,this,r);const F=await((o=(l=this.options).onMutate)==null?void 0:o.call(l,t,r));F!==this.state.context&&W(this,bt,Yt).call(this,{type:"pending",context:F,variables:t,isPaused:a})}const _=await y(this,qn).start();return await((d=(c=y(this,Me).config).onSuccess)==null?void 0:d.call(c,_,t,this.state.context,this,r)),await((u=(h=this.options).onSuccess)==null?void 0:u.call(h,_,t,this.state.context,r)),await((x=(p=y(this,Me).config).onSettled)==null?void 0:x.call(p,_,null,this.state.variables,this.state.context,this,r)),await((g=(k=this.options).onSettled)==null?void 0:g.call(k,_,null,t,this.state.context,r)),W(this,bt,Yt).call(this,{type:"success",data:_}),_}catch(_){try{await((m=(S=y(this,Me).config).onError)==null?void 0:m.call(S,_,t,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((v=(f=this.options).onError)==null?void 0:v.call(f,_,t,this.state.context,r))}catch(F){Promise.reject(F)}try{await((C=(w=y(this,Me).config).onSettled)==null?void 0:C.call(w,void 0,_,this.state.variables,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((N=(b=this.options).onSettled)==null?void 0:N.call(b,void 0,_,t,this.state.context,r))}catch(F){Promise.reject(F)}throw W(this,bt,Yt).call(this,{type:"error",error:_}),_}finally{y(this,Me).runNext(this)}}},sa=new WeakMap,Nt=new WeakMap,Me=new WeakMap,qn=new WeakMap,bt=new WeakSet,Yt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Se.batch(()=>{y(this,Nt).forEach(r=>{r.onMutationUpdate(t)}),y(this,Me).notify({mutation:this,type:"updated",action:t})})},Bd);function pm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var zt,vt,aa,Qd,Gx=(Qd=class extends ts{constructor(t={}){super();$(this,zt);$(this,vt);$(this,aa);this.config=t,z(this,zt,new Set),z(this,vt,new Map),z(this,aa,0)}build(t,n,r){const s=new qx({client:t,mutationCache:this,mutationId:++va(this,aa)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){y(this,zt).add(t);const n=Ma(t);if(typeof n=="string"){const r=y(this,vt).get(n);r?r.push(t):y(this,vt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(y(this,zt).delete(t)){const n=Ma(t);if(typeof n=="string"){const r=y(this,vt).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&y(this,vt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Ma(t);if(typeof n=="string"){const r=y(this,vt).get(n),s=r==null?void 0:r.find(a=>a.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=Ma(t);if(typeof n=="string"){const s=(r=y(this,vt).get(n))==null?void 0:r.find(a=>a!==t&&a.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Se.batch(()=>{y(this,zt).forEach(t=>{this.notify({type:"removed",mutation:t})}),y(this,zt).clear(),y(this,vt).clear()})}getAll(){return Array.from(y(this,zt))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>od(n,r))}findAll(t={}){return this.getAll().filter(n=>od(t,n))}notify(t){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Se.batch(()=>Promise.all(t.map(n=>n.continue().catch(Ae))))}},zt=new WeakMap,vt=new WeakMap,aa=new WeakMap,Qd);function Ma(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Ft,on,Ve,It,Bt,Ga,Oo,Vd,Jx=(Vd=class extends ts{constructor(n,r){super();$(this,Bt);$(this,Ft);$(this,on);$(this,Ve);$(this,It);z(this,Ft,n),this.setOptions(r),this.bindMethods(),W(this,Bt,Ga).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=y(this,Ft).defaultMutationOptions(n),ji(this.options,r)||y(this,Ft).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,Ve),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&ar(r.mutationKey)!==ar(this.options.mutationKey)?this.reset():((s=y(this,Ve))==null?void 0:s.state.status)==="pending"&&y(this,Ve).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=y(this,Ve))==null||n.removeObserver(this)}onMutationUpdate(n){W(this,Bt,Ga).call(this),W(this,Bt,Oo).call(this,n)}getCurrentResult(){return y(this,on)}reset(){var n;(n=y(this,Ve))==null||n.removeObserver(this),z(this,Ve,void 0),W(this,Bt,Ga).call(this),W(this,Bt,Oo).call(this)}mutate(n,r){var s;return z(this,It,r),(s=y(this,Ve))==null||s.removeObserver(this),z(this,Ve,y(this,Ft).getMutationCache().build(y(this,Ft),this.options)),y(this,Ve).addObserver(this),y(this,Ve).execute(n)}},Ft=new WeakMap,on=new WeakMap,Ve=new WeakMap,It=new WeakMap,Bt=new WeakSet,Ga=function(){var r;const n=((r=y(this,Ve))==null?void 0:r.state)??pm();z(this,on,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Oo=function(n){Se.batch(()=>{var r,s,a,l,o,c,d,h;if(y(this,It)&&this.hasListeners()){const u=y(this,on).variables,p=y(this,on).context,x={client:y(this,Ft),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(s=(r=y(this,It)).onSuccess)==null||s.call(r,n.data,u,p,x)}catch(k){Promise.reject(k)}try{(l=(a=y(this,It)).onSettled)==null||l.call(a,n.data,null,u,p,x)}catch(k){Promise.reject(k)}}else if((n==null?void 0:n.type)==="error"){try{(c=(o=y(this,It)).onError)==null||c.call(o,n.error,u,p,x)}catch(k){Promise.reject(k)}try{(h=(d=y(this,It)).onSettled)==null||h.call(d,void 0,n.error,u,p,x)}catch(k){Promise.reject(k)}}}this.listeners.forEach(u=>{u(y(this,on))})})},Vd),Ct,Kd,Yx=(Kd=class extends ts{constructor(t={}){super();$(this,Ct);this.config=t,z(this,Ct,new Map)}build(t,n,r){const s=n.queryKey,a=n.queryHash??zc(s,n);let l=this.get(a);return l||(l=new Qx({client:t,queryKey:s,queryHash:a,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(l)),l}add(t){y(this,Ct).has(t.queryHash)||(y(this,Ct).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=y(this,Ct).get(t.queryHash);n&&(t.destroy(),n===t&&y(this,Ct).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Se.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return y(this,Ct).get(t)}getAll(){return[...y(this,Ct).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>ld(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>ld(t,r)):n}notify(t){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Se.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Se.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ct=new WeakMap,Kd),ve,cn,un,Ar,$r,dn,Ur,Br,Hd,Xx=(Hd=class{constructor(e={}){$(this,ve);$(this,cn);$(this,un);$(this,Ar);$(this,$r);$(this,dn);$(this,Ur);$(this,Br);z(this,ve,e.queryCache||new Yx),z(this,cn,e.mutationCache||new Gx),z(this,un,e.defaultOptions||{}),z(this,Ar,new Map),z(this,$r,new Map),z(this,dn,0)}mount(){va(this,dn)._++,y(this,dn)===1&&(z(this,Ur,Dc.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,ve).onFocus())})),z(this,Br,wi.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,ve).onOnline())})))}unmount(){var e,t;va(this,dn)._--,y(this,dn)===0&&((e=y(this,Ur))==null||e.call(this),z(this,Ur,void 0),(t=y(this,Br))==null||t.call(this),z(this,Br,void 0))}isFetching(e){return y(this,ve).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return y(this,cn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,ve).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=y(this,ve).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(bn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return y(this,ve).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=y(this,ve).get(r.queryHash),a=s==null?void 0:s.state.data,l=Lx(t,a);if(l!==void 0)return y(this,ve).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return Se.batch(()=>y(this,ve).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,ve).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=y(this,ve);Se.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=y(this,ve);return Se.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Se.batch(()=>y(this,ve).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Ae).catch(Ae)}invalidateQueries(e,t={}){return Se.batch(()=>(y(this,ve).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Se.batch(()=>y(this,ve).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let a=s.fetch(void 0,n);return n.throwOnError||(a=a.catch(Ae)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Ae)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=y(this,ve).build(this,t);return n.isStaleByTime(bn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ae).catch(Ae)}fetchInfiniteQuery(e){return e.behavior=pd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ae).catch(Ae)}ensureInfiniteQueryData(e){return e.behavior=pd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return wi.isOnline()?y(this,cn).resumePausedMutations():Promise.resolve()}getQueryCache(){return y(this,ve)}getMutationCache(){return y(this,cn)}getDefaultOptions(){return y(this,un)}setDefaultOptions(e){z(this,un,e)}setQueryDefaults(e,t){y(this,Ar).set(ar(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...y(this,Ar).values()],n={};return t.forEach(r=>{qs(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){y(this,$r).set(ar(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...y(this,$r).values()],n={};return t.forEach(r=>{qs(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...y(this,un).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=zc(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Fc&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...y(this,un).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){y(this,ve).clear(),y(this,cn).clear()}},ve=new WeakMap,cn=new WeakMap,un=new WeakMap,Ar=new WeakMap,$r=new WeakMap,dn=new WeakMap,Ur=new WeakMap,Br=new WeakMap,Hd),vm=j.createContext(void 0),qt=e=>{const t=j.useContext(vm);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Zx=({client:e,children:t})=>(j.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),i.jsx(vm.Provider,{value:e,children:t})),xm=j.createContext(!1),ey=()=>j.useContext(xm);xm.Provider;function ty(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var ny=j.createContext(ty()),ry=()=>j.useContext(ny),sy=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Ic(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},ay=e=>{j.useEffect(()=>{e.clearReset()},[e])},iy=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||Ic(n,[e.error,r])),ly=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},oy=(e,t)=>e.isLoading&&e.isFetching&&!t,cy=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,xd=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function uy(e,t,n){var p,x,k,g;const r=ey(),s=ry(),a=qt(),l=a.defaultQueryOptions(e);(x=(p=a.getDefaultOptions().queries)==null?void 0:p._experimental_beforeQuery)==null||x.call(p,l);const o=a.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",ly(l),sy(l,s,o),ay(s);const c=!a.getQueryCache().get(l.queryHash),[d]=j.useState(()=>new t(a,l)),h=d.getOptimisticResult(l),u=!r&&e.subscribed!==!1;if(j.useSyncExternalStore(j.useCallback(S=>{const m=u?d.subscribe(Se.batchCalls(S)):Ae;return d.updateResult(),m},[d,u]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),j.useEffect(()=>{d.setOptions(l)},[l,d]),cy(l,h))throw xd(l,d,s);if(iy({result:h,errorResetBoundary:s,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw h.error;if((g=(k=a.getDefaultOptions().queries)==null?void 0:k._experimental_afterQuery)==null||g.call(k,l,h),l.experimental_prefetchInRender&&!sr&&oy(h,r)){const S=c?xd(l,d,s):o==null?void 0:o.promise;S==null||S.catch(Ae).finally(()=>{d.updateResult()})}return l.notifyOnChangeProps?h:d.trackResult(h)}function he(e,t){return uy(e,Vx)}function Je(e,t){const n=qt(),[r]=j.useState(()=>new Jx(n,e));j.useEffect(()=>{r.setOptions(e)},[r,e]);const s=j.useSyncExternalStore(j.useCallback(l=>r.subscribe(Se.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=j.useCallback((l,o)=>{r.mutate(l,o).catch(Ae)},[r]);if(s.error&&Ic(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}/** + * @remix-run/router v1.23.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Gs(){return Gs=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function $c(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function fy(){return Math.random().toString(36).substr(2,8)}function gd(e,t){return{usr:e.state,key:e.key,idx:t}}function Lo(e,t,n,r){return n===void 0&&(n=null),Gs({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?ns(t):t,{state:n,key:t&&t.key||r||fy()})}function ki(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function ns(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function hy(e,t,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:a=!1}=r,l=s.history,o=mn.Pop,c=null,d=h();d==null&&(d=0,l.replaceState(Gs({},l.state,{idx:d}),""));function h(){return(l.state||{idx:null}).idx}function u(){o=mn.Pop;let S=h(),m=S==null?null:S-d;d=S,c&&c({action:o,location:g.location,delta:m})}function p(S,m){o=mn.Push;let f=Lo(g.location,S,m);d=h()+1;let v=gd(f,d),w=g.createHref(f);try{l.pushState(v,"",w)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;s.location.assign(w)}a&&c&&c({action:o,location:g.location,delta:1})}function x(S,m){o=mn.Replace;let f=Lo(g.location,S,m);d=h();let v=gd(f,d),w=g.createHref(f);l.replaceState(v,"",w),a&&c&&c({action:o,location:g.location,delta:0})}function k(S){let m=s.location.origin!=="null"?s.location.origin:s.location.href,f=typeof S=="string"?S:ki(S);return f=f.replace(/ $/,"%20"),ye(m,"No window.location.(origin|href) available to create URL for href: "+f),new URL(f,m)}let g={get action(){return o},get location(){return e(s,l)},listen(S){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(yd,u),c=S,()=>{s.removeEventListener(yd,u),c=null}},createHref(S){return t(s,S)},createURL:k,encodeLocation(S){let m=k(S);return{pathname:m.pathname,search:m.search,hash:m.hash}},push:p,replace:x,go(S){return l.go(S)}};return g}var jd;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(jd||(jd={}));function my(e,t,n){return n===void 0&&(n="/"),py(e,t,n)}function py(e,t,n,r){let s=typeof t=="string"?ns(t):t,a=Jr(s.pathname||"/",n);if(a==null)return null;let l=ym(e);vy(l);let o=null;for(let c=0;o==null&&c{let c={relativePath:o===void 0?a.path||"":o,caseSensitive:a.caseSensitive===!0,childrenIndex:l,route:a};c.relativePath.startsWith("/")&&(ye(c.relativePath.startsWith(r),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(r.length));let d=Cn([r,c.relativePath]),h=n.concat(c);a.children&&a.children.length>0&&(ye(a.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),ym(a.children,t,h,d)),!(a.path==null&&!a.index)&&t.push({path:d,score:Sy(d,a.index),routesMeta:h})};return e.forEach((a,l)=>{var o;if(a.path===""||!((o=a.path)!=null&&o.includes("?")))s(a,l);else for(let c of gm(a.path))s(a,l,c)}),t}function gm(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return s?[a,""]:[a];let l=gm(r.join("/")),o=[];return o.push(...l.map(c=>c===""?a:[a,c].join("/"))),s&&o.push(...l),o.map(c=>e.startsWith("/")&&c===""?"/":c)}function vy(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ny(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const xy=/^:[\w-]+$/,yy=3,gy=2,jy=1,wy=10,ky=-2,wd=e=>e==="*";function Sy(e,t){let n=e.split("/"),r=n.length;return n.some(wd)&&(r+=ky),t&&(r+=gy),n.filter(s=>!wd(s)).reduce((s,a)=>s+(xy.test(a)?yy:a===""?jy:wy),r)}function Ny(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function by(e,t,n){let{routesMeta:r}=e,s={},a="/",l=[];for(let o=0;o{let{paramName:p,isOptional:x}=h;if(p==="*"){let g=o[u]||"";l=a.slice(0,a.length-g.length).replace(/(.)\/+$/,"$1")}const k=o[u];return x&&!k?d[p]=void 0:d[p]=(k||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:l,pattern:e}}function Cy(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),$c(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,c)=>(r.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function _y(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return $c(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Jr(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const Ey=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Py=e=>Ey.test(e);function Ty(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?ns(e):e,a;if(n)if(Py(n))a=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),$c(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?a=kd(n.substring(1),"/"):a=kd(n,t)}else a=t;return{pathname:a,search:Ry(r),hash:My(s)}}function kd(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function jl(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Oy(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function jm(e,t){let n=Oy(e);return t?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function wm(e,t,n,r){r===void 0&&(r=!1);let s;typeof e=="string"?s=ns(e):(s=Gs({},e),ye(!s.pathname||!s.pathname.includes("?"),jl("?","pathname","search",s)),ye(!s.pathname||!s.pathname.includes("#"),jl("#","pathname","hash",s)),ye(!s.search||!s.search.includes("#"),jl("#","search","hash",s)));let a=e===""||s.pathname==="",l=a?"/":s.pathname,o;if(l==null)o=n;else{let u=t.length-1;if(!r&&l.startsWith("..")){let p=l.split("/");for(;p[0]==="..";)p.shift(),u-=1;s.pathname=p.join("/")}o=u>=0?t[u]:"/"}let c=Ty(s,o),d=l&&l!=="/"&&l.endsWith("/"),h=(a||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||h)&&(c.pathname+="/"),c}const Cn=e=>e.join("/").replace(/\/\/+/g,"/"),Ly=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Ry=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,My=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function zy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const km=["post","put","patch","delete"];new Set(km);const Fy=["get",...km];new Set(Fy);/** + * React Router v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Js(){return Js=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),j.useCallback(function(d,h){if(h===void 0&&(h={}),!o.current)return;if(typeof d=="number"){r.go(d);return}let u=wm(d,JSON.parse(l),a,h.relative==="path");e==null&&t!=="/"&&(u.pathname=u.pathname==="/"?t:Cn([t,u.pathname])),(h.replace?r.replace:r.push)(u,h.state,h)},[t,r,l,a,e])}const Ay=j.createContext(null);function $y(e){let t=j.useContext(Gt).outlet;return t&&j.createElement(Ay.Provider,{value:e},t)}function fa(){let{matches:e}=j.useContext(Gt),t=e[e.length-1];return t?t.params:{}}function Qi(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=j.useContext(Rn),{matches:s}=j.useContext(Gt),{pathname:a}=rs(),l=JSON.stringify(jm(s,r.v7_relativeSplatPath));return j.useMemo(()=>wm(e,JSON.parse(l),a,n==="path"),[e,l,a,n])}function Uy(e,t){return By(e,t)}function By(e,t,n,r){da()||ye(!1);let{navigator:s}=j.useContext(Rn),{matches:a}=j.useContext(Gt),l=a[a.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let d=rs(),h;if(t){var u;let S=typeof t=="string"?ns(t):t;c==="/"||(u=S.pathname)!=null&&u.startsWith(c)||ye(!1),h=S}else h=d;let p=h.pathname||"/",x=p;if(c!=="/"){let S=c.replace(/^\//,"").split("/");x="/"+p.replace(/^\//,"").split("/").slice(S.length).join("/")}let k=my(e,{pathname:x}),g=Wy(k&&k.map(S=>Object.assign({},S,{params:Object.assign({},o,S.params),pathname:Cn([c,s.encodeLocation?s.encodeLocation(S.pathname).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?c:Cn([c,s.encodeLocation?s.encodeLocation(S.pathnameBase).pathname:S.pathnameBase])})),a,n,r);return t&&g?j.createElement(Bi.Provider,{value:{location:Js({pathname:"/",search:"",hash:"",state:null,key:"default"},h),navigationType:mn.Pop}},g):g}function Qy(){let e=Yy(),t=zy(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return j.createElement(j.Fragment,null,j.createElement("h2",null,"Unexpected Application Error!"),j.createElement("h3",{style:{fontStyle:"italic"}},t),n?j.createElement("pre",{style:s},n):null,null)}const Vy=j.createElement(Qy,null);class Ky extends j.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?j.createElement(Gt.Provider,{value:this.props.routeContext},j.createElement(Nm.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Hy(e){let{routeContext:t,match:n,children:r}=e,s=j.useContext(Ui);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),j.createElement(Gt.Provider,{value:t},r)}function Wy(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var a;if(!n)return null;if(n.errors)e=n.matches;else if((a=r)!=null&&a.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(s=n)==null?void 0:s.errors;if(o!=null){let h=l.findIndex(u=>u.route.id&&(o==null?void 0:o[u.route.id])!==void 0);h>=0||ye(!1),l=l.slice(0,Math.min(l.length,h+1))}let c=!1,d=-1;if(n&&r&&r.v7_partialHydration)for(let h=0;h=0?l=l.slice(0,d+1):l=[l[0]];break}}}return l.reduceRight((h,u,p)=>{let x,k=!1,g=null,S=null;n&&(x=o&&u.route.id?o[u.route.id]:void 0,g=u.route.errorElement||Vy,c&&(d<0&&p===0?(Zy("route-fallback"),k=!0,S=null):d===p&&(k=!0,S=u.route.hydrateFallbackElement||null)));let m=t.concat(l.slice(0,p+1)),f=()=>{let v;return x?v=g:k?v=S:u.route.Component?v=j.createElement(u.route.Component,null):u.route.element?v=u.route.element:v=h,j.createElement(Hy,{match:u,routeContext:{outlet:h,matches:m,isDataRoute:n!=null},children:v})};return n&&(u.route.ErrorBoundary||u.route.errorElement||p===0)?j.createElement(Ky,{location:n.location,revalidation:n.revalidation,component:g,error:x,children:f(),routeContext:{outlet:null,matches:m,isDataRoute:!0}}):f()},null)}var Cm=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Cm||{}),_m=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(_m||{});function qy(e){let t=j.useContext(Ui);return t||ye(!1),t}function Gy(e){let t=j.useContext(Sm);return t||ye(!1),t}function Jy(e){let t=j.useContext(Gt);return t||ye(!1),t}function Em(e){let t=Jy(),n=t.matches[t.matches.length-1];return n.route.id||ye(!1),n.route.id}function Yy(){var e;let t=j.useContext(Nm),n=Gy(),r=Em();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function Xy(){let{router:e}=qy(Cm.UseNavigateStable),t=Em(_m.UseNavigateStable),n=j.useRef(!1);return bm(()=>{n.current=!0}),j.useCallback(function(s,a){a===void 0&&(a={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,Js({fromRouteId:t},a)))},[e,t])}const Sd={};function Zy(e,t,n){Sd[e]||(Sd[e]=!0)}function eg(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function tg(e){return $y(e.context)}function ht(e){ye(!1)}function ng(e){let{basename:t="/",children:n=null,location:r,navigationType:s=mn.Pop,navigator:a,static:l=!1,future:o}=e;da()&&ye(!1);let c=t.replace(/^\/*/,"/"),d=j.useMemo(()=>({basename:c,navigator:a,static:l,future:Js({v7_relativeSplatPath:!1},o)}),[c,o,a,l]);typeof r=="string"&&(r=ns(r));let{pathname:h="/",search:u="",hash:p="",state:x=null,key:k="default"}=r,g=j.useMemo(()=>{let S=Jr(h,c);return S==null?null:{location:{pathname:S,search:u,hash:p,state:x,key:k},navigationType:s}},[c,h,u,p,x,k,s]);return g==null?null:j.createElement(Rn.Provider,{value:d},j.createElement(Bi.Provider,{children:n,value:g}))}function rg(e){let{children:t,location:n}=e;return Uy(Mo(t),n)}new Promise(()=>{});function Mo(e,t){t===void 0&&(t=[]);let n=[];return j.Children.forEach(e,(r,s)=>{if(!j.isValidElement(r))return;let a=[...t,s];if(r.type===j.Fragment){n.push.apply(n,Mo(r.props.children,a));return}r.type!==ht&&ye(!1),!r.props.index||!r.props.children||ye(!1);let l={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Mo(r.props.children,a)),n.push(l)}),n}/** + * React Router DOM v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Si(){return Si=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[s]=e[s]);return n}function sg(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ag(e,t){return e.button===0&&(!t||t==="_self")&&!sg(e)}const ig=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],lg=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],og="6";try{window.__reactRouterVersion=og}catch{}const cg=j.createContext({isTransitioning:!1}),ug="startTransition",Nd=xp[ug];function dg(e){let{basename:t,children:n,future:r,window:s}=e,a=j.useRef();a.current==null&&(a.current=dy({window:s,v5Compat:!0}));let l=a.current,[o,c]=j.useState({action:l.action,location:l.location}),{v7_startTransition:d}=r||{},h=j.useCallback(u=>{d&&Nd?Nd(()=>c(u)):c(u)},[c,d]);return j.useLayoutEffect(()=>l.listen(h),[l,h]),j.useEffect(()=>eg(r),[r]),j.createElement(ng,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const fg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",hg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Pn=j.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:a,replace:l,state:o,target:c,to:d,preventScrollReset:h,viewTransition:u}=t,p=Pm(t,ig),{basename:x}=j.useContext(Rn),k,g=!1;if(typeof d=="string"&&hg.test(d)&&(k=d,fg))try{let v=new URL(window.location.href),w=d.startsWith("//")?new URL(v.protocol+d):new URL(d),C=Jr(w.pathname,x);w.origin===v.origin&&C!=null?d=C+w.search+w.hash:g=!0}catch{}let S=Iy(d,{relative:s}),m=pg(d,{replace:l,state:o,target:c,preventScrollReset:h,relative:s,viewTransition:u});function f(v){r&&r(v),v.defaultPrevented||m(v)}return j.createElement("a",Si({},p,{href:k||S,onClick:g||a?r:f,ref:n,target:c}))}),Tm=j.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:s=!1,className:a="",end:l=!1,style:o,to:c,viewTransition:d,children:h}=t,u=Pm(t,lg),p=Qi(c,{relative:u.relative}),x=rs(),k=j.useContext(Sm),{navigator:g,basename:S}=j.useContext(Rn),m=k!=null&&vg(p)&&d===!0,f=g.encodeLocation?g.encodeLocation(p).pathname:p.pathname,v=x.pathname,w=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;s||(v=v.toLowerCase(),w=w?w.toLowerCase():null,f=f.toLowerCase()),w&&S&&(w=Jr(w,S)||w);const C=f!=="/"&&f.endsWith("/")?f.length-1:f.length;let b=v===f||!l&&v.startsWith(f)&&v.charAt(C)==="/",N=w!=null&&(w===f||!l&&w.startsWith(f)&&w.charAt(f.length)==="/"),_={isActive:b,isPending:N,isTransitioning:m},F=b?r:void 0,O;typeof a=="function"?O=a(_):O=[a,b?"active":null,N?"pending":null,m?"transitioning":null].filter(Boolean).join(" ");let B=typeof o=="function"?o(_):o;return j.createElement(Pn,Si({},u,{"aria-current":F,className:O,ref:n,style:B,to:c,viewTransition:d}),typeof h=="function"?h(_):h)});var zo;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(zo||(zo={}));var bd;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(bd||(bd={}));function mg(e){let t=j.useContext(Ui);return t||ye(!1),t}function pg(e,t){let{target:n,replace:r,state:s,preventScrollReset:a,relative:l,viewTransition:o}=t===void 0?{}:t,c=cr(),d=rs(),h=Qi(e,{relative:l});return j.useCallback(u=>{if(ag(u,n)){u.preventDefault();let p=r!==void 0?r:ki(d)===ki(h);c(e,{replace:p,state:s,preventScrollReset:a,relative:l,viewTransition:o})}},[d,c,h,r,s,n,e,a,l,o])}function vg(e,t){t===void 0&&(t={});let n=j.useContext(cg);n==null&&ye(!1);let{basename:r}=mg(zo.useViewTransitionState),s=Qi(e,{relative:t.relative});if(!n.isTransitioning)return!1;let a=Jr(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Jr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Ro(s.pathname,l)!=null||Ro(s.pathname,a)!=null}/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var xg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const yg=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),V=(e,t)=>{const n=j.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:a=2,absoluteStrokeWidth:l,className:o="",children:c,...d},h)=>j.createElement("svg",{ref:h,...xg,width:s,height:s,stroke:r,strokeWidth:l?Number(a)*24/Number(s):a,className:["lucide",`lucide-${yg(e)}`,o].join(" "),...d},[...t.map(([u,p])=>j.createElement(u,p)),...Array.isArray(c)?c:[c]]));return n.displayName=`${e}`,n};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gg=V("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Om=V("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const jg=V("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const wg=V("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kg=V("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lm=V("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Sg=V("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ng=V("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ys=V("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bg=V("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cg=V("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rm=V("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _g=V("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Eg=V("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pg=V("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cd=V("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mm=V("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Tg=V("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Og=V("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lg=V("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rg=V("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Uc=V("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mg=V("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zg=V("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ha=V("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zm=V("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fg=V("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ig=V("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xs=V("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bc=V("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dg=V("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ag=V("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fm=V("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Im=V("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $g=V("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _d=V("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ug=V("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bg=V("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qc=V("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dm=V("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qg=V("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Am=V("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ma=V("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),Vg={},Ed=e=>{let t;const n=new Set,r=(h,u)=>{const p=typeof h=="function"?h(t):h;if(!Object.is(p,t)){const x=t;t=u??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(k=>k(t,x))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>d,subscribe:h=>(n.add(h),()=>n.delete(h)),destroy:()=>{(Vg?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(r,s,c);return c},Kg=e=>e?Ed(e):Ed;var $m={exports:{}},Um={},Bm={exports:{}},Qm={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Yr=j;function Hg(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Wg=typeof Object.is=="function"?Object.is:Hg,qg=Yr.useState,Gg=Yr.useEffect,Jg=Yr.useLayoutEffect,Yg=Yr.useDebugValue;function Xg(e,t){var n=t(),r=qg({inst:{value:n,getSnapshot:t}}),s=r[0].inst,a=r[1];return Jg(function(){s.value=n,s.getSnapshot=t,wl(s)&&a({inst:s})},[e,n,t]),Gg(function(){return wl(s)&&a({inst:s}),e(function(){wl(s)&&a({inst:s})})},[e]),Yg(n),n}function wl(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Wg(e,n)}catch{return!0}}function Zg(e,t){return t()}var e0=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Zg:Xg;Qm.useSyncExternalStore=Yr.useSyncExternalStore!==void 0?Yr.useSyncExternalStore:e0;Bm.exports=Qm;var t0=Bm.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Vi=j,n0=t0;function r0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var s0=typeof Object.is=="function"?Object.is:r0,a0=n0.useSyncExternalStore,i0=Vi.useRef,l0=Vi.useEffect,o0=Vi.useMemo,c0=Vi.useDebugValue;Um.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var a=i0(null);if(a.current===null){var l={hasValue:!1,value:null};a.current=l}else l=a.current;a=o0(function(){function c(x){if(!d){if(d=!0,h=x,x=r(x),s!==void 0&&l.hasValue){var k=l.value;if(s(k,x))return u=k}return u=x}if(k=u,s0(h,x))return k;var g=r(x);return s!==void 0&&s(k,g)?(h=x,k):(h=x,u=g)}var d=!1,h,u,p=n===void 0?null:n;return[function(){return c(t())},p===null?void 0:function(){return c(p())}]},[t,n,r,s]);var o=a0(e,a[0],a[1]);return l0(function(){l.hasValue=!0,l.value=o},[o]),c0(o),o};$m.exports=Um;var u0=$m.exports;const d0=Wd(u0),Vm={},{useDebugValue:f0}=Vo,{useSyncExternalStoreWithSelector:h0}=d0;let Pd=!1;const m0=e=>e;function p0(e,t=m0,n){(Vm?"production":void 0)!=="production"&&n&&!Pd&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Pd=!0);const r=h0(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return f0(r),r}const Td=e=>{(Vm?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?Kg(e):e,n=(r,s)=>p0(t,r,s);return Object.assign(n,t),n},Ki=e=>e?Td(e):Td,Hi="/api",Vc="flow_auth_token",Kc="flow_auth_expires",Hc="flow_auth_username";function Zs(){const e=localStorage.getItem(Vc),t=localStorage.getItem(Kc);return!e||!t?null:new Date(t)<=new Date?(Yn(),null):e}function Od(e,t,n){localStorage.setItem(Vc,e),localStorage.setItem(Kc,t),localStorage.setItem(Hc,n)}function Yn(){localStorage.removeItem(Vc),localStorage.removeItem(Kc),localStorage.removeItem(Hc)}function Wc(){return localStorage.getItem(Hc)}let ir=null;function v0(e){ir=e}async function U(e,t,n=!1){const r={"Content-Type":"application/json",...t==null?void 0:t.headers};if(!n){const a=Zs();a&&(r.Authorization=`Bearer ${a}`)}const s=await fetch(`${Hi}${e}`,{...t,headers:r});if(s.status===401){Yn(),ir&&ir();const a=await s.json().catch(()=>({detail:"Not authenticated"}));throw new Error(a.detail||"Not authenticated")}if(!s.ok){const a=await s.json().catch(()=>({detail:s.statusText}));throw new Error(a.detail||"API request failed")}if(s.status!==204)return s.json()}const dr={getConfig:()=>U("/auth/config",void 0,!0),login:e=>U("/auth/login",{method:"POST",body:JSON.stringify(e)},!0),getGitHubAuthUrl:()=>`${Hi}/auth/github`,getCurrentUser:()=>U("/auth/me"),logout:()=>U("/auth/logout",{method:"POST"})},Xn={list:e=>{const t=new URLSearchParams;e!=null&&e.include_auto_generated&&t.set("include_auto_generated","true"),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return U(`/configs${n?`?${n}`:""}`)},get:e=>U(`/configs/${e}`),create:e=>U("/configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/configs/${e}`,{method:"DELETE"})},Et={list:e=>{const t=new URLSearchParams;e!=null&&e.category&&t.set("category",e.category),e!=null&&e.suite&&t.set("suite",e.suite);const n=t.toString();return U(`/tasks${n?`?${n}`:""}`)},get:e=>U(`/tasks/${e}`),create:e=>U("/tasks",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/tasks/${e}`,{method:"DELETE"}),listSuites:()=>U("/tasks/suites"),importSuite:e=>U(`/tasks/import-suite?suite_name=${encodeURIComponent(e)}`,{method:"POST"})},Ut={list:e=>{const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return U(`/jobs${n?`?${n}`:""}`)},get:e=>U(`/jobs/${e}`),create:e=>U("/jobs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/jobs/${e}`,{method:"PUT",body:JSON.stringify(t)}),start:async function*(e){var o;const t={},n=Zs();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Hi}/jobs/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Yn(),ir&&ir(),new Error("Not authenticated");if(!r.ok)throw new Error("Failed to start job");const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const a=new TextDecoder;let l="";for(;;){const{done:c,value:d}=await s.read();if(c)break;l+=a.decode(d,{stream:!0});const h=l.split(` +`);l=h.pop()||"";for(const u of h)u.startsWith("data: ")&&(yield JSON.parse(u.slice(6)))}},cancel:e=>U(`/jobs/${e}/cancel`,{method:"POST"}),delete:e=>U(`/jobs/${e}`,{method:"DELETE"})},Fo={list:e=>{const t=new URLSearchParams;e!=null&&e.job_id&&t.set("job_id",e.job_id),e!=null&&e.candidate_name&&t.set("candidate_name",e.candidate_name),e!=null&&e.task_name&&t.set("task_name",e.task_name),(e==null?void 0:e.is_pareto)!==void 0&&t.set("is_pareto",String(e.is_pareto));const n=t.toString();return U(`/runs${n?`?${n}`:""}`)},get:e=>U(`/runs/${e}`),getJobSummary:e=>U(`/runs/job/${e}/summary`)},Ts={list:e=>{const t=new URLSearchParams;e!=null&&e.agent_id&&t.set("agent_id",e.agent_id),e!=null&&e.limit&&t.set("limit",String(e.limit));const n=t.toString();return U(`/tests${n?`?${n}`:""}`)},get:e=>U(`/tests/${e}`),create:e=>U("/tests",{method:"POST",body:JSON.stringify(e)}),start:async function*(e){var o;const t={},n=Zs();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Hi}/tests/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Yn(),ir&&ir(),new Error("Not authenticated");if(!r.ok){const c=await r.json().catch(()=>({detail:"Failed to start test"}));throw new Error(c.detail||"Failed to start test")}const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const a=new TextDecoder;let l="";for(;;){const{done:c,value:d}=await s.read();if(c)break;l+=a.decode(d,{stream:!0});const h=l.split(` +`);l=h.pop()||"";for(const u of h)u.startsWith("data: ")&&(yield JSON.parse(u.slice(6)))}},cancel:e=>U(`/tests/${e}/cancel`,{method:"POST"}),delete:e=>U(`/tests/${e}`,{method:"DELETE"})},x0={list:()=>U("/llm-configs"),get:e=>U(`/llm-configs/${e}`),getDefault:()=>U("/llm-configs/default"),create:e=>U("/llm-configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/llm-configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/llm-configs/${e}`,{method:"DELETE"}),setDefault:e=>U(`/llm-configs/${e}/set-default`,{method:"POST"}),test:e=>U(`/llm-configs/${e}/test`,{method:"POST"})},y0={list:()=>U("/tools"),get:e=>U(`/tools/${e}`)},Km={getAgentSchema:()=>U("/schema/agent")},g0={list:()=>U("/deployments"),get:e=>U(`/deployments/${e}`),delete:e=>U(`/deployments/${e}`,{method:"DELETE"})},j0={start:e=>U("/evaluate",{method:"POST",body:JSON.stringify(e)})},Io={design:e=>U("/experiment/design",{method:"POST",body:JSON.stringify(e)}),importYaml:e=>U("/experiment/import-yaml",{method:"POST",body:JSON.stringify(e)}),validate:e=>U("/experiment/validate",{method:"POST",body:JSON.stringify(e)}),generateCandidates:e=>U("/experiment/generate-candidates",{method:"POST",body:JSON.stringify(e)})},qc=Ki((e,t)=>(v0(()=>{e({isAuthenticated:!1,user:null,error:"Session expired. Please log in again."})}),{authConfig:null,isLoadingConfig:!0,isAuthenticated:!1,isLoading:!1,user:null,error:null,loadAuthConfig:async()=>{e({isLoadingConfig:!0});try{const n=await dr.getConfig();if(e({authConfig:n,isLoadingConfig:!1}),n.enabled){const r=Zs(),s=Wc();if(r&&s)try{const a=await dr.getCurrentUser();e({isAuthenticated:!0,user:a})}catch{Yn(),e({isAuthenticated:!1,user:null})}}else e({isAuthenticated:!0,user:{username:"anonymous",auth_mode:"none"}})}catch(n){console.error("Failed to load auth config:",n),e({isLoadingConfig:!1,error:"Failed to connect to server"})}},login:async(n,r)=>{e({isLoading:!0,error:null});try{const s=await dr.login({username:n,password:r});return Od(s.access_token,s.expires_at,s.username),e({isAuthenticated:!0,isLoading:!1,user:{username:s.username,auth_mode:"basic"}}),!0}catch(s){return e({isLoading:!1,error:s instanceof Error?s.message:"Login failed"}),!1}},loginWithGitHub:()=>{window.location.href=dr.getGitHubAuthUrl()},handleOAuthCallback:()=>{const n=new URLSearchParams(window.location.search),r=n.get("auth_error");if(r)return e({error:r}),window.history.replaceState({},"",window.location.pathname),!0;if(n.get("auth_callback")==="true"){const s=n.get("token"),a=n.get("expires_at"),l=n.get("username");return s&&a&&l&&(Od(s,a,l),e({isAuthenticated:!0,user:{username:l,auth_mode:"github"}})),window.history.replaceState({},"",window.location.pathname),!0}return!1},logout:async()=>{try{await dr.logout()}catch{}Yn(),e({isAuthenticated:!1,user:null,error:null})},checkAuth:async()=>{const{authConfig:n}=t();if(!(n!=null&&n.enabled)){e({isAuthenticated:!0});return}if(!Zs()){e({isAuthenticated:!1,user:null});return}try{const s=await dr.getCurrentUser();e({isAuthenticated:!0,user:s})}catch{Yn(),e({isAuthenticated:!1,user:null})}},clearError:()=>e({error:null})}));function Q({variant:e="secondary",size:t="md",className:n="",icon:r,iconRight:s,loading:a=!1,children:l,disabled:o,...c}){const d="font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1.5 rounded-md",h={primary:"bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)]",secondary:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)] hover:bg-[var(--border)]",danger:"bg-[var(--error)] text-white hover:bg-red-600",ghost:"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"},u={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm"},p=t==="sm"?14:16;return i.jsxs("button",{className:`${d} ${h[e]} ${u[t]} ${n}`,disabled:o||a,...c,children:[a?i.jsx(ha,{size:p,className:"animate-spin"}):r?i.jsx(r,{size:p}):null,l,s&&!a&&i.jsx(s,{size:p})]})}const w0={};function k0(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var a;const l=c=>c===null?null:JSON.parse(c,void 0),o=(a=n.getItem(s))!=null?a:null;return o instanceof Promise?o.then(l):l(o)},setItem:(s,a)=>n.setItem(s,JSON.stringify(a,void 0)),removeItem:s=>n.removeItem(s)}}const ea=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return ea(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return ea(r)(n)}}}},S0=(e,t)=>(n,r,s)=>{let a={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:S=>S,version:0,merge:(S,m)=>({...m,...S}),...t},l=!1;const o=new Set,c=new Set;let d;try{d=a.getStorage()}catch{}if(!d)return e((...S)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...S)},r,s);const h=ea(a.serialize),u=()=>{const S=a.partialize({...r()});let m;const f=h({state:S,version:a.version}).then(v=>d.setItem(a.name,v)).catch(v=>{m=v});if(m)throw m;return f},p=s.setState;s.setState=(S,m)=>{p(S,m),u()};const x=e((...S)=>{n(...S),u()},r,s);let k;const g=()=>{var S;if(!d)return;l=!1,o.forEach(f=>f(r()));const m=((S=a.onRehydrateStorage)==null?void 0:S.call(a,r()))||void 0;return ea(d.getItem.bind(d))(a.name).then(f=>{if(f)return a.deserialize(f)}).then(f=>{if(f)if(typeof f.version=="number"&&f.version!==a.version){if(a.migrate)return a.migrate(f.state,f.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return f.state}).then(f=>{var v;return k=a.merge(f,(v=r())!=null?v:x),n(k,!0),u()}).then(()=>{m==null||m(k,void 0),l=!0,c.forEach(f=>f(k))}).catch(f=>{m==null||m(void 0,f)})};return s.persist={setOptions:S=>{a={...a,...S},S.getStorage&&(d=S.getStorage())},clearStorage:()=>{d==null||d.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>g(),hasHydrated:()=>l,onHydrate:S=>(o.add(S),()=>{o.delete(S)}),onFinishHydration:S=>(c.add(S),()=>{c.delete(S)})},g(),k||x},N0=(e,t)=>(n,r,s)=>{let a={storage:k0(()=>localStorage),partialize:g=>g,version:0,merge:(g,S)=>({...S,...g}),...t},l=!1;const o=new Set,c=new Set;let d=a.storage;if(!d)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...g)},r,s);const h=()=>{const g=a.partialize({...r()});return d.setItem(a.name,{state:g,version:a.version})},u=s.setState;s.setState=(g,S)=>{u(g,S),h()};const p=e((...g)=>{n(...g),h()},r,s);s.getInitialState=()=>p;let x;const k=()=>{var g,S;if(!d)return;l=!1,o.forEach(f=>{var v;return f((v=r())!=null?v:p)});const m=((S=a.onRehydrateStorage)==null?void 0:S.call(a,(g=r())!=null?g:p))||void 0;return ea(d.getItem.bind(d))(a.name).then(f=>{if(f)if(typeof f.version=="number"&&f.version!==a.version){if(a.migrate)return[!0,a.migrate(f.state,f.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,f.state];return[!1,void 0]}).then(f=>{var v;const[w,C]=f;if(x=a.merge(C,(v=r())!=null?v:p),n(x,!0),w)return h()}).then(()=>{m==null||m(x,void 0),x=r(),l=!0,c.forEach(f=>f(x))}).catch(f=>{m==null||m(void 0,f)})};return s.persist={setOptions:g=>{a={...a,...g},g.storage&&(d=g.storage)},clearStorage:()=>{d==null||d.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>k(),hasHydrated:()=>l,onHydrate:g=>(o.add(g),()=>{o.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},a.skipHydration||k(),x||p},b0=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((w0?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),S0(e,t)):N0(e,t),Hm=b0,C0=Ki()(Hm((e,t)=>({theme:"light",setTheme:n=>{document.documentElement.setAttribute("data-theme",n),e({theme:n})},toggleTheme:()=>{const n=t().theme==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",n),e({theme:n})}}),{name:"flow-theme",onRehydrateStorage:()=>e=>{e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}}));function _0(){const{theme:e,toggleTheme:t}=C0();return i.jsx("button",{onClick:t,className:"p-2 rounded-md text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--accent)]","aria-label":`Switch to ${e==="dark"?"light":"dark"} mode`,title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:e==="dark"?i.jsx(Ug,{size:16}):i.jsx(Ig,{size:16})})}const E0=Ki()(Hm((e,t)=>({sidebarCollapsed:!1,toggleSidebar:()=>{e({sidebarCollapsed:!t().sidebarCollapsed})},setSidebarCollapsed:n=>{e({sidebarCollapsed:n})}}),{name:"flow-layout"})),P0=[{path:"/agents",label:"Agents",icon:kg},{path:"/jobs",label:"Experiments",icon:Tg},{path:"/tasks",label:"Datasets",icon:Pg}];function T0(){const e=rs(),{sidebarCollapsed:t,toggleSidebar:n}=E0(),r=s=>s==="/agents"?e.pathname==="/"||e.pathname==="/agents"||e.pathname.startsWith("/agents/")||e.pathname.startsWith("/deployments/"):s==="/jobs"?e.pathname.startsWith("/jobs")||e.pathname.startsWith("/runs"):e.pathname.startsWith(s);return i.jsxs("aside",{className:` + flex flex-col border-r border-[var(--border)] bg-[var(--bg-secondary)] + transition-all duration-200 + ${t?"w-14":"w-56"} + `,children:[i.jsx("nav",{className:"flex-1 py-2",children:P0.map(s=>{const a=r(s.path);return i.jsxs(Tm,{to:s.path,title:t?s.label:void 0,className:` + flex items-center gap-3 px-4 py-2.5 text-sm transition-colors relative + ${a?"text-[var(--accent)] bg-[var(--accent-dim)] font-medium":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"} + `,children:[a&&i.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-r bg-[var(--accent)]"}),i.jsx(s.icon,{size:18}),!t&&i.jsx("span",{children:s.label})]},s.path)})}),i.jsx("button",{onClick:n,className:"flex items-center justify-center p-3 border-t border-[var(--border)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",title:t?"Expand sidebar":"Collapse sidebar",children:t?i.jsx(Cg,{size:16}):i.jsx(bg,{size:16})})]})}function O0(){const{authConfig:e,user:t,logout:n}=qc(),r=async()=>{await n()};return i.jsxs("div",{className:"h-screen flex flex-col",children:[i.jsx("header",{className:"border-b border-[var(--border)] bg-[var(--bg-secondary)] shrink-0",children:i.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between",children:[i.jsxs(Tm,{to:"/",className:"text-lg font-semibold text-[var(--accent)] flex items-center gap-2 hover:opacity-80",children:[i.jsx(ma,{size:20}),"Flow",i.jsx("span",{className:"text-[var(--text-secondary)] font-normal",children:"/optimize"})]}),i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(_0,{}),(e==null?void 0:e.enabled)&&t&&i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[i.jsx(Dm,{size:14}),i.jsx("span",{children:t.username})]}),i.jsx(Q,{variant:"ghost",size:"sm",icon:Fg,onClick:r,title:"Sign out",children:"Sign out"})]})]})]})}),i.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[i.jsx(T0,{}),i.jsx("main",{className:"flex-1 overflow-y-auto bg-[var(--bg-primary)]",children:i.jsx("div",{className:"p-6",children:i.jsx(tg,{})})})]})]})}const L0=["maf","miniagent","langgraph"],R0={maf:"Microsoft Agent Framework",miniagent:"MiniAgent",langgraph:"LangGraph"},M0={openai:"OpenAI",azure_openai:"Azure OpenAI",anthropic:"Anthropic",ollama:"Ollama",custom:"Custom (OpenAI-compatible)"};function J({children:e,variant:t="default"}){const n={default:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)]",success:"bg-[var(--badge-success-bg)] text-[var(--badge-success-text)] border border-[var(--badge-success-border)]",warning:"bg-[var(--badge-warning-bg)] text-[var(--badge-warning-text)] border border-[var(--badge-warning-border)]",error:"bg-[var(--badge-error-bg)] text-[var(--badge-error-text)] border border-[var(--badge-error-border)]",info:"bg-[var(--badge-info-bg)] text-[var(--badge-info-text)] border border-[var(--badge-info-border)]"};return i.jsx("span",{className:`inline-block px-2 py-0.5 text-xs font-medium rounded-md ${n[t]}`,children:e})}const z0={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"};function ss({isOpen:e,onClose:t,title:n,children:r,footer:s,size:a="md"}){return j.useEffect(()=>{const l=o=>{o.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",l),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",l),document.body.style.overflow=""}},[e,t]),e?i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[i.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),i.jsxs("div",{className:`relative bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg ${z0[a]} w-full mx-4 max-h-[80vh] flex flex-col`,children:[i.jsxs("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-b border-[var(--border)] px-4 py-3 flex items-center justify-between",children:[i.jsx("h2",{className:"font-semibold",children:n}),i.jsx("button",{onClick:t,className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"×"})]}),i.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r}),s&&i.jsx("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-t border-[var(--border)] px-4 py-3",children:s})]})]}):null}function pn({label:e,className:t="",...n}){return i.jsxs("div",{className:"space-y-1",children:[e&&i.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),i.jsx("input",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] ${t}`,...n})]})}function F0({label:e,className:t="",...n}){return i.jsxs("div",{className:"space-y-1",children:[e&&i.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),i.jsx("textarea",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] resize-y min-h-[100px] ${t}`,...n})]})}function Ni({label:e,className:t="",...n}){return i.jsxs("label",{className:`flex items-center gap-2 cursor-pointer ${t}`,children:[i.jsx("input",{type:"checkbox",className:"w-4 h-4 bg-[var(--bg-primary)] border border-[var(--border)] rounded accent-[var(--accent)]",...n}),i.jsx("span",{className:"text-sm",children:e})]})}function Wm({columns:e,data:t,onRowClick:n,searchable:r=!1,searchPlaceholder:s="Search...",searchFilter:a,emptyMessage:l="No items found",emptyIcon:o}){const[c,d]=j.useState(""),[h,u]=j.useState(null),[p,x]=j.useState("asc"),k=j.useMemo(()=>{let S=t;if(r&&c&&a&&(S=S.filter(m=>a(m,c))),h){const m=e.find(f=>f.key===h);m!=null&&m.sortValue&&(S=[...S].sort((f,v)=>{const w=m.sortValue(f),C=m.sortValue(v),b=wC?1:0;return p==="asc"?b:-b}))}return S},[t,c,a,r,h,p,e]),g=S=>{const m=e.find(f=>f.key===S);m!=null&&m.sortable&&(h===S?x(p==="asc"?"desc":"asc"):(u(S),x("asc")))};return i.jsxs("div",{children:[r&&i.jsxs("div",{className:"mb-4 relative max-w-sm",children:[i.jsx(Ag,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]"}),i.jsx("input",{type:"text",placeholder:s,value:c,onChange:S=>d(S.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md pl-9 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]"})]}),k.length===0?i.jsxs("div",{className:"text-center py-16 text-[var(--text-secondary)]",children:[o&&i.jsx("div",{className:"mb-3 flex justify-center",children:o}),i.jsx("p",{children:l})]}):i.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsx("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:e.map(S=>i.jsx("th",{onClick:()=>g(S.key),className:`text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider ${S.sortable?"cursor-pointer hover:text-[var(--text-primary)]":""} ${S.className||""}`,children:i.jsxs("span",{className:"inline-flex items-center gap-1",children:[S.header,S.sortable&&h===S.key&&i.jsx("span",{children:p==="asc"?"↑":"↓"})]})},S.key))})}),i.jsx("tbody",{children:k.map((S,m)=>i.jsx("tr",{onClick:()=>n==null?void 0:n(S),className:`border-b border-[var(--border)] last:border-b-0 transition-colors ${n?"cursor-pointer hover:bg-[var(--bg-tertiary)]":""}`,children:e.map(f=>i.jsx("td",{className:`px-4 py-3 ${f.className||""}`,children:f.render(S)},f.key))},m))})]})})]})}function I0({variations:e,onChange:t,strategies:n,availableStrategies:r}){const s=r??Object.keys(n),a=()=>{const d=e.map(x=>x.strategy),h=s.find(x=>!d.includes(x))||"none",u=n[h],p={strategy:h};if(u!=null&&u.params)for(const[x,k]of Object.entries(u.params))k.default!==void 0&&(p[x]=k.default);t([...e,p])},l=d=>{t(e.filter((h,u)=>u!==d))},o=(d,h)=>{t(e.map((u,p)=>p===d?{...u,...h}:u))},c=(d,h)=>{const u=n[h],p={strategy:h};if(u!=null&&u.params)for(const[x,k]of Object.entries(u.params))k.default!==void 0&&(p[x]=k.default);o(d,p)};return i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"text-sm font-medium",children:"Compaction Strategies"}),i.jsx(Q,{type:"button",variant:"ghost",size:"sm",icon:Bc,onClick:a,disabled:e.length>=s.length,children:"Add"})]}),e.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:'No compaction variations. Click "Add" to test different strategies.'}):i.jsx("div",{className:"space-y-2",children:e.map((d,h)=>{const u=n[d.strategy];return i.jsx("div",{className:"p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsxs("div",{className:"flex-1 space-y-2",children:[i.jsx("select",{className:"w-full px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:d.strategy,onChange:p=>c(h,p.target.value),children:s.map(p=>{var x;return i.jsx("option",{value:p,children:((x=n[p])==null?void 0:x.label)||p},p)})}),(u==null?void 0:u.description)&&i.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:u.description}),(u==null?void 0:u.params)&&Object.keys(u.params).length>0&&i.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:Object.entries(u.params).map(([p,x])=>i.jsx(D0,{name:p,schema:x,value:d[p],onChange:k=>o(h,{[p]:k})},p))})]}),i.jsx("button",{type:"button",onClick:()=>l(h),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:i.jsx(Am,{size:16})})]})},h)})})]})}function D0({name:e,schema:t,value:n,onChange:r}){const s=e.replace(/_/g," ");return t.type==="boolean"?i.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[i.jsx("input",{type:"checkbox",checked:!!(n??t.default),onChange:a=>r(a.target.checked),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"capitalize",children:s})]}):i.jsxs("div",{children:[i.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:s}),i.jsx("input",{type:t.type==="number"?"number":"text",className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-xs",value:String(n!==void 0?n:t.default??""),onChange:a=>{if(t.type==="number"){const l=parseFloat(a.target.value);r(isNaN(l)?t.default:l)}else r(a.target.value)},min:t.min,max:t.max,step:t.max&&t.max<=1?.1:1})]})}function A0({variations:e,onChange:t,providers:n}){const r=()=>{const o=n[0],c={provider:(o==null?void 0:o.name)||"azure_openai",model:(o==null?void 0:o.models[0])||"gpt-4o"};t([...e,c])},s=o=>{t(e.filter((c,d)=>d!==o))},a=(o,c)=>{t(e.map((d,h)=>h===o?{...d,...c}:d))},l=(o,c)=>{const d=n.find(h=>h.name===c);a(o,{provider:c,model:(d==null?void 0:d.models[0])||""})};return i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"text-sm font-medium",children:"LLM Configurations"}),i.jsx(Q,{type:"button",variant:"ghost",size:"sm",icon:Bc,onClick:r,children:"Add"})]}),e.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:`Uses agent's default LLM. Click "Add" to test different models.`}):i.jsx("div",{className:"space-y-2",children:e.map((o,c)=>{const d=n.find(h=>h.name===o.provider);return i.jsxs("div",{className:"flex items-center gap-2 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[i.jsx("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.provider,onChange:h=>l(c,h.target.value),children:n.map(h=>i.jsx("option",{value:h.name,children:h.label},h.name))}),d&&d.models.length>0?i.jsxs("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:h=>a(c,{model:h.target.value}),children:[d.models.map(h=>i.jsx("option",{value:h,children:h},h)),!d.models.includes(o.model)&&o.model&&i.jsx("option",{value:o.model,children:o.model})]}):i.jsx("input",{type:"text",className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:h=>a(c,{model:h.target.value}),placeholder:"Model ID"}),i.jsx("button",{type:"button",onClick:()=>s(c),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:i.jsx(Am,{size:16})})]},c)})})]})}const Do={compaction:[],tools:[],llm_config:[],instructions:[],instruction_strategies:[]};function $0({agentId:e,agentName:t,agentFramework:n="maf",taskSuite:r,taskCount:s,schema:a,onVariationsChange:l,parallel:o,onParallelChange:c,budget:d,onBudgetChange:h,useLlmEval:u,onUseLlmEvalChange:p}){const[x,k]=j.useState(Do),[g,S]=j.useState(!1),[m,f]=j.useState(""),[v,w]=j.useState(null),C=a.frameworks[n],b=(C==null?void 0:C.compaction_strategies)||Object.keys(a.compaction_strategies),N=a.tool_presets||[],_=a.llm_providers||[],O=(()=>{let L=1;x.compaction.length>0&&(L*=x.compaction.length),x.tools.length>0&&(L*=x.tools.length),x.llm_config.length>0&&(L*=x.llm_config.length);const K=x.instructions.length+x.instruction_strategies.reduce((ee,R)=>ee+R.max_candidates,0);return K>0&&(L*=K),Math.min(L,d)})(),B=O*s,G=L=>{k(L),l==null||l(L)},re=Je({mutationFn:L=>Io.design(L),onSuccess:L=>{f(L.yaml_content),S(!0)}}),le=Je({mutationFn:L=>Io.validate(L),onSuccess:L=>{w({valid:L.valid,errors:L.errors,warnings:L.warnings})}}),D=()=>({base_agent_id:e,task_suite:r,variations:x,parallel:o,budget:d,use_llm_eval:u}),q=()=>{re.mutate(D())},X=()=>{le.mutate(D())},P=()=>{const L=new Blob([m],{type:"text/yaml"}),K=URL.createObjectURL(L),ee=document.createElement("a");ee.href=K,ee.download=`${t}_experiment.yaml`,ee.click(),URL.revokeObjectURL(K)},A=x.compaction.length>0||x.tools.length>0||x.llm_config.length>0||x.instructions.length>0||x.instruction_strategies.length>0;return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex flex-wrap gap-2",children:[i.jsxs(J,{variant:"info",children:[O," candidates"]}),i.jsxs(J,{children:[s," tasks"]}),i.jsxs(J,{variant:B>100?"warning":"success",children:[B," total runs"]})]}),i.jsx(I0,{variations:x.compaction,onChange:L=>G({...x,compaction:L}),strategies:a.compaction_strategies,availableStrategies:b}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("label",{className:"text-sm font-medium",children:"Tool Presets"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(L=>i.jsxs("label",{className:`flex items-center gap-2 px-3 py-1.5 border rounded cursor-pointer transition-colors ${x.tools.includes(L.name)?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[i.jsx("input",{type:"checkbox",checked:x.tools.includes(L.name),onChange:K=>{const ee=K.target.checked?[...x.tools,L.name]:x.tools.filter(R=>R!==L.name);G({...x,tools:ee})},className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:L.name}),i.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",L.tools.length,")"]})]},L.name))}),x.tools.length>0&&i.jsxs("p",{className:"text-xs text-[var(--text-secondary)]",children:["Selected: ",x.tools.join(", ")]})]}),i.jsx(A0,{variations:x.llm_config,onChange:L=>G({...x,llm_config:L}),providers:_}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-4 space-y-4",children:[i.jsx("h4",{className:"text-sm font-medium",children:"Execution Settings"}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(pn,{label:"Parallel Workers",type:"number",value:o,onChange:L=>c(parseInt(L.target.value)||1),min:1,max:16}),i.jsx(pn,{label:"Budget (max candidates)",type:"number",value:d,onChange:L=>h(parseInt(L.target.value)||100),min:1,max:1e3})]}),i.jsx(Ni,{label:"Use LLM evaluation",checked:u,onChange:L=>p(L.target.checked)}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] ml-6 -mt-2",children:u?"LLM-as-Judge scores task completion (0-1)":"Simple pass/fail based on task success"})]}),i.jsxs("div",{className:"flex items-center gap-2 border-t border-[var(--border)] pt-4",children:[i.jsx(Q,{variant:"secondary",size:"sm",onClick:X,loading:le.isPending,children:"Validate"}),i.jsx(Q,{variant:"secondary",size:"sm",icon:Cd,onClick:q,loading:re.isPending,children:"Export YAML"})]}),v&&i.jsxs("div",{className:`p-3 rounded border ${v.valid?"border-green-500/50 bg-green-500/10":"border-red-500/50 bg-red-500/10"}`,children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[v.valid?i.jsx(Lm,{size:16,className:"text-green-500"}):i.jsx(Om,{size:16,className:"text-red-500"}),i.jsx("span",{className:"font-medium text-sm",children:v.valid?"Configuration valid":"Configuration has issues"})]}),v.errors.length>0&&i.jsx("ul",{className:"text-sm text-red-500 list-disc ml-6",children:v.errors.map((L,K)=>i.jsx("li",{children:L},K))}),v.warnings.length>0&&i.jsx("ul",{className:"text-sm text-yellow-500 list-disc ml-6 mt-1",children:v.warnings.map((L,K)=>i.jsx("li",{children:L},K))})]}),g&&i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-lg shadow-xl max-w-2xl w-full max-h-[80vh] flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border)]",children:[i.jsx("h3",{className:"font-medium",children:"Experiment YAML"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Q,{variant:"secondary",size:"sm",icon:Cd,onClick:P,children:"Download"}),i.jsx(Q,{variant:"ghost",size:"sm",onClick:()=>S(!1),children:"Close"})]})]}),i.jsx("pre",{className:"flex-1 overflow-auto p-4 text-xs font-mono bg-[var(--bg-secondary)]",children:m})]})}),!A&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No variations selected. Only the baseline agent will be tested. Add compaction strategies, tool presets, or LLM configs to generate candidates."})]})}function Ld(){const e=cr(),t=qt(),[n,r]=j.useState(!1),[s,a]=j.useState(null),{data:l=[],isLoading:o}=he({queryKey:["configs"],queryFn:()=>Xn.list()}),c=Je({mutationFn:Xn.create,onSuccess:()=>{t.invalidateQueries({queryKey:["configs"]}),r(!1)}}),d=Je({mutationFn:Xn.delete,onSuccess:()=>t.invalidateQueries({queryKey:["configs"]})}),h=[{key:"name",header:"Name",render:u=>i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:u.name})},{key:"framework",header:"Framework",render:u=>i.jsx(J,{children:u.config.framework||"maf"})},{key:"tools",header:"Tools",render:u=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:U0(u.config.tools)})},{key:"compaction",header:"Compaction",render:u=>{const p=u.config.compaction;return!p||p.strategy==="none"?i.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"}):p.strategy==="head_tail"?i.jsxs(J,{children:[p.params.head_size,"/",p.params.tail_size]}):i.jsx(J,{children:p.strategy})}},{key:"created",header:"Created",render:u=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(u.created_at).toLocaleDateString()}),sortable:!0,sortValue:u=>new Date(u.created_at).getTime()},{key:"actions",header:"",className:"w-40",render:u=>i.jsxs("div",{className:"flex items-center gap-2",onClick:p=>p.stopPropagation(),children:[i.jsx(Q,{variant:"primary",size:"sm",icon:ma,onClick:()=>a(u),children:"Optimize"}),i.jsx(Q,{variant:"ghost",size:"sm",icon:Qc,title:"Delete",onClick:()=>{confirm(`Delete agent "${u.name}"?`)&&d.mutate(u.id)}})]})}];return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Agents"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Define and optimize your agent configurations."})]}),i.jsx(Q,{variant:"primary",icon:Bc,onClick:()=>r(!0),children:"Create agent"})]}),o?i.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[i.jsx(ha,{size:16,className:"animate-spin"}),"Loading agents..."]}):i.jsx(Wm,{columns:h,data:l,onRowClick:u=>e(`/agents/${u.id}`),searchable:!0,searchPlaceholder:"Search agents",searchFilter:(u,p)=>u.name.toLowerCase().includes(p.toLowerCase())||(u.description||"").toLowerCase().includes(p.toLowerCase()),emptyMessage:"No agents yet. Create your first agent to start optimizing.",emptyIcon:i.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-[var(--bg-tertiary)]",children:i.jsx(Im,{size:24,className:"text-[var(--text-secondary)]"})})}),i.jsx(B0,{isOpen:n,onClose:()=>r(!1),onSubmit:u=>c.mutate(u),isLoading:c.isPending}),s&&i.jsx(Q0,{agent:s,isOpen:!!s,onClose:()=>a(null)})]})}function U0(e){return typeof e=="string"?e:Array.isArray(e)?`[${e.length}]`:e&&typeof e=="object"?`[${Object.keys(e).length}]`:"standard"}function B0({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){var K,ee,R,T,te,pe,be;const s=["read_file","write_file","edit_file","bash","grep","think"],[a,l]=j.useState("preset"),[o,c]=j.useState({name:"",description:"",instructions:null,model:null,compaction:{strategy:"none",params:{}},tools:s,framework:"miniagent",llm_config_id:null}),[d,h]=j.useState(!1),[u,p]=j.useState("preset"),[x,k]=j.useState([...s]),[g,S]=j.useState(!1),{data:m}=he({queryKey:["agent-schema"],queryFn:()=>Km.getAgentSchema()}),{data:f=[]}=he({queryKey:["llm-configs"],queryFn:()=>x0.list()}),{data:v}=he({queryKey:["tools"],queryFn:()=>y0.list()}),w=((K=v==null?void 0:v.tools)==null?void 0:K.map(M=>M.name))??s,C=(v==null?void 0:v.presets)??{},b=Object.keys(C),N=(m==null?void 0:m.frameworks)??{},_=Object.keys(N).length>0?Object.keys(N):L0,F=o.framework||"miniagent",O=((R=(ee=m==null?void 0:m.frameworks)==null?void 0:ee[F])==null?void 0:R.compaction_strategies)??["none","head_tail"],B=(m==null?void 0:m.compaction_strategies)??{},G=(m==null?void 0:m.agent_presets)??[],re=M=>{const H=M.config,dt=H.compaction;n({name:M.name+"-agent",description:M.description,framework:H.framework||"miniagent",tools:H.tools||"standard",compaction:dt||{strategy:"none",params:{}},instructions:H.instructions||null})},le=M=>{if(M.preventDefault(),!o.name.trim())return;const H={...o};u==="custom"&&(H.tools=x),n(H)},D=((T=o.compaction)==null?void 0:T.strategy)!=="none",q=((te=o.compaction)==null?void 0:te.strategy)||"none",X=B[q],P=M=>{k(H=>H.includes(M)?H.filter(dt=>dt!==M):[...H,M])},A=M=>{const H=B[M],dt={};if(H!=null&&H.params)for(const[as,is]of Object.entries(H.params))is.default!==void 0&&(dt[as]=is.default);c({...o,compaction:{strategy:M,params:dt}})},L=a==="custom"?i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(Q,{type:"submit",form:"create-agent-form",variant:"primary",disabled:!o.name.trim(),loading:r,children:"Create Agent"})]}):i.jsx("div",{className:"flex justify-end gap-2",children:i.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"})});return i.jsxs(ss,{isOpen:e,onClose:t,title:"Create Agent",footer:L,children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b border-[var(--border)]",children:[i.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${a==="preset"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("preset"),children:"From Preset"}),i.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${a==="custom"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("custom"),children:"Custom"})]}),a==="preset"?i.jsx("div",{className:"space-y-3",children:G.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"Loading presets..."}):G.map(M=>i.jsx("button",{type:"button",className:"w-full text-left p-4 border border-[var(--border)] rounded-lg hover:border-[var(--accent)] hover:bg-[var(--accent)]/5 transition-colors",onClick:()=>re(M),disabled:r,children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("h4",{className:"font-medium",children:M.label}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:M.description}),i.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[M.tags.map(H=>i.jsx(J,{variant:"default",children:H},H)),M.suggested_datasets.length>0&&i.jsxs(J,{variant:"success",children:["datasets: ",M.suggested_datasets.join(", ")]})]})]}),i.jsx(Ys,{size:16,className:"text-[var(--text-secondary)] mt-1 flex-shrink-0"})]})},M.name))}):i.jsxs("form",{id:"create-agent-form",onSubmit:le,className:"space-y-4",children:[i.jsx(pn,{label:"Name",value:o.name,onChange:M=>c({...o,name:M.target.value}),placeholder:"e.g., my-coding-agent",required:!0}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"LLM Configuration"}),i.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.llm_config_id||"",onChange:M=>c({...o,llm_config_id:M.target.value||null}),children:[i.jsx("option",{value:"",children:"Use environment variables"}),f.map(M=>i.jsxs("option",{value:M.id,children:[M.name," (",M0[M.provider],M.model_id?` - ${M.model_id}`:"",")",M.is_default?" (default)":""]},M.id))]}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:f.length===0?"No LLM configs found. Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)":o.llm_config_id?"Uses the selected LLM configuration.":"Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Framework"}),i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.framework||"miniagent",onChange:M=>{const H=M.target.value;c({...o,framework:H,compaction:{strategy:"none",params:{}}})},children:_.map(M=>{var H;return i.jsx("option",{value:M,children:((H=N[M])==null?void 0:H.label)||R0[M]||M},M)})}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((pe=N[F])==null?void 0:pe.description)||(F==="miniagent"?"Lightweight agent with token-aware context management.":F==="langgraph"?"Graph-based workflows with state management.":"Default agent implementation.")})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(Ni,{label:"Custom instructions",checked:d,onChange:M=>{h(M.target.checked),M.target.checked||c({...o,instructions:null})}}),i.jsx(Ni,{label:"Enable compaction",checked:D,onChange:M=>{if(M.target.checked){const H=O.find(dt=>dt!=="none")||"head_tail";A(H)}else c({...o,compaction:{strategy:"none",params:{}}})}})]}),d&&i.jsx("textarea",{className:"w-full h-32 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono resize-y",value:o.instructions||"",onChange:M=>c({...o,instructions:M.target.value||null}),placeholder:"System prompt / instructions for the agent..."}),D&&i.jsxs("div",{className:"space-y-3 p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Compaction Strategy"}),i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:q,onChange:M=>A(M.target.value),children:O.filter(M=>M!=="none").map(M=>{var H;return i.jsx("option",{value:M,children:((H=B[M])==null?void 0:H.label)||M},M)})}),(X==null?void 0:X.description)&&i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:X.description})]}),(X==null?void 0:X.params)&&Object.keys(X.params).length>0&&i.jsx("div",{className:"grid grid-cols-2 gap-3",children:Object.entries(X.params).map(([M,H])=>{var is;const dt=(is=o.compaction)==null?void 0:is.params[M],as=dt!==void 0?dt:H.default;return i.jsxs("div",{children:[i.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:M.replace(/_/g," ")}),i.jsx("input",{type:"number",className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof as=="number"?as:Number(as)||0,onChange:ep=>{const Jc=parseFloat(ep.target.value);c({...o,compaction:{...o.compaction,params:{...o.compaction.params,[M]:isNaN(Jc)?typeof H.default=="number"?H.default:0:Jc}}})},min:H.min,max:H.max,step:H.max&&H.max<=1?.1:1}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:H.description})]},M)})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm font-medium",children:"Tools"}),i.jsxs("div",{className:"flex gap-4",children:[i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"radio",checked:u==="preset",onChange:()=>p("preset"),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:"Preset"})]}),i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"radio",checked:u==="custom",onChange:()=>p("custom"),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:"Custom"})]})]}),u==="preset"?i.jsxs(i.Fragment,{children:[i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof o.tools=="string"?o.tools:"standard",onChange:M=>c({...o,tools:M.target.value}),children:b.map(M=>i.jsx("option",{value:M,children:M},M))}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((be=C[typeof o.tools=="string"?o.tools:"standard"])==null?void 0:be.join(", "))??""})]}):i.jsx("div",{className:"grid grid-cols-2 gap-1 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:w.map(M=>i.jsxs("label",{className:"flex items-center gap-2 p-1 text-sm cursor-pointer hover:bg-[var(--bg-tertiary)]",children:[i.jsx("input",{type:"checkbox",checked:x.includes(M),onChange:()=>P(M),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"font-mono text-xs",children:M})]},M))})]}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[i.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>S(!g),children:[i.jsx(Ys,{size:14,className:`transition-transform ${g?"rotate-90":""}`}),"More options"]}),g&&i.jsx("div",{className:"mt-3",children:i.jsx(pn,{label:"Description (optional)",value:o.description,onChange:M=>c({...o,description:M.target.value}),placeholder:"Brief description of this agent"})})]})]})]})}function Q0({agent:e,isOpen:t,onClose:n}){var R;const r=cr(),s=qt(),[a,l]=j.useState("ready"),[o,c]=j.useState("quick"),[d,h]=j.useState(!1),[u,p]=j.useState([]),[x,k]=j.useState(!1),[g,S]=j.useState(Do),[m,f]=j.useState(4),[v,w]=j.useState(100),[C,b]=j.useState(!1),[N,_]=j.useState(null),{data:F=[]}=he({queryKey:["tasks"],queryFn:()=>Et.list()}),{data:O=[]}=he({queryKey:["suites"],queryFn:()=>Et.listSuites()}),{data:B}=he({queryKey:["agent-schema"],queryFn:()=>Km.getAgentSchema()}),G=O.map(T=>({value:T.name,label:T.name.charAt(0).toUpperCase()+T.name.slice(1),description:T.description,tasks:T.task_count})),re=Je({mutationFn:Et.importSuite,onSuccess:T=>{s.invalidateQueries({queryKey:["tasks"]}),p(T.map(te=>te.id))}}),le=Je({mutationFn:async T=>{const te=await Ut.create(T);return Ut.start(te.id).next(),te},onSuccess:T=>{s.invalidateQueries({queryKey:["jobs"]}),_(T.id),l("success")}}),q=x?(()=>{let T=1;g.compaction.length>0&&(T*=g.compaction.length),g.tools.length>0&&(T*=g.tools.length),g.llm_config.length>0&&(T*=g.llm_config.length);const te=g.instructions.length+g.instruction_strategies.reduce((pe,be)=>pe+be.max_candidates,0);return te>0&&(T*=te),Math.min(T,v)})():1,X=d?u.length:((R=G.find(T=>T.value===o))==null?void 0:R.tasks)||3,P=q*X,A=async()=>{l("starting");let T=u;if(!d)try{T=(await re.mutateAsync(o)).map(H=>H.id)}catch(M){console.error("Failed to import suite:",M),alert(`Failed to import task suite: ${o}`),l("ready");return}if(T.length===0){alert("No tasks selected. Please select tasks or choose a task suite."),l("ready");return}let te;if(x&&(g.compaction.length>0||g.tools.length>0||g.llm_config.length>0||g.instructions.length>0||g.instruction_strategies.length>0))try{te=(await Io.generateCandidates({base_agent_id:e.id,variations:g,budget:v})).candidate_ids}catch(M){console.error("Failed to generate candidates:",M),alert(`Failed to generate candidates: ${M instanceof Error?M.message:"Unknown error"}`),l("ready");return}else te=[e.id];const be={name:`${e.name} optimization (${te.length} candidates × ${T.length} tasks)`,candidate_ids:te,task_ids:T,parallel:m,use_llm_eval:C};le.mutate(be)},L=T=>{p(te=>te.includes(T)?te.filter(pe=>pe!==T):[...te,T])},K=()=>{l("ready"),_(null),k(!1),S(Do),n()},ee=()=>a==="success"&&N?i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsx(Q,{variant:"secondary",onClick:K,children:"Close"}),i.jsx(Q,{variant:"primary",icon:Xs,onClick:()=>{K(),r(`/jobs/${N}`)},children:"View Job"})]}):a==="starting"?null:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(Q,{variant:"secondary",onClick:n,children:"Cancel"}),i.jsxs(Q,{variant:"primary",icon:Xs,onClick:A,disabled:d&&u.length===0,children:["Start Optimization (",P," runs)"]})]});return i.jsx(ss,{isOpen:t,onClose:K,title:`Optimize: ${e.name}`,footer:ee(),size:"lg",children:a==="success"&&N?i.jsxs("div",{className:"flex flex-col items-center py-8",children:[i.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/20 flex items-center justify-center mb-4",children:i.jsx(ma,{size:24,className:"text-green-500"})}),i.jsx("h3",{className:"text-lg font-medium mb-2",children:"Job Started!"}),i.jsx("p",{className:"text-[var(--text-secondary)] text-center mb-2",children:"Optimization job is now running"}),i.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-3 py-1.5 rounded font-mono",children:["ID: ",N.slice(0,8),"..."]})]}):a==="starting"?i.jsxs("div",{className:"flex flex-col items-center py-8",children:[i.jsx(ha,{size:32,className:"animate-spin text-[var(--accent)] mb-4"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:re.isPending?"Importing tasks...":"Creating optimization job..."})]}):i.jsxs("div",{className:"space-y-5",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Task Suite"}),i.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:d?"__custom__":o,onChange:T=>{T.target.value==="__custom__"?h(!0):(h(!1),c(T.target.value))},children:[G.map(T=>i.jsxs("option",{value:T.value,children:[T.label," (",T.tasks," tasks) — ",T.description]},T.value)),F.length>0&&i.jsx("option",{value:"__custom__",children:"Custom Selection"})]})]}),d&&F.length>0&&i.jsx("div",{className:"max-h-48 overflow-y-auto border border-[var(--border)] rounded p-2 space-y-1",children:F.map(T=>i.jsxs("label",{className:"flex items-center gap-2 p-2 hover:bg-[var(--bg-tertiary)] cursor-pointer rounded",children:[i.jsx("input",{type:"checkbox",checked:u.includes(T.id),onChange:()=>L(T.id),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:T.name}),T.suite&&i.jsx(J,{children:T.suite})]},T.id))}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[i.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>k(!x),children:[i.jsx(Ys,{size:14,className:`transition-transform ${x?"rotate-90":""}`}),"Advanced Settings",x&&i.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"(experiment design, variations, execution)"})]}),x&&B&&i.jsx("div",{className:"mt-4",children:i.jsx($0,{agentId:e.id,agentName:e.name,agentFramework:e.config.framework,taskSuite:d?void 0:o,taskCount:X,schema:B,onVariationsChange:S,parallel:m,onParallelChange:f,budget:v,onBudgetChange:w,useLlmEval:C,onUseLlmEvalChange:b})})]})]})})}function pa({items:e}){return i.jsx("nav",{className:"flex items-center gap-1.5 text-sm mb-4",children:e.map((t,n)=>{const r=n===e.length-1;return i.jsxs("span",{className:"flex items-center gap-1.5",children:[n>0&&i.jsx(Ys,{size:14,className:"text-[var(--text-secondary)]"}),t.path&&!r?i.jsx(Pn,{to:t.path,className:"text-[var(--text-secondary)] hover:text-[var(--accent)] transition-colors",children:t.label}):i.jsx("span",{className:r?"text-[var(--text-primary)] font-medium":"text-[var(--text-secondary)]",children:t.label})]},n)})})}function ge({children:e,className:t="",onClick:n,selected:r=!1,selectable:s=!1}){const a="bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",l=s?"cursor-pointer hover:border-[var(--accent-dim)] transition-colors":"",o=r?"border-[var(--accent)]":"";return i.jsx("div",{className:`${a} ${l} ${o} ${t}`,onClick:n,children:e})}function V0(e){const t=[],n=r=>r.type==="trace_span"&&typeof r.data=="object"&&r.data!==null?r.data:"span_id"in r?r:null;if(Array.isArray(e.spans)){for(const r of e.spans)if(typeof r=="object"&&r!==null){const s=n(r);s&&t.push(s)}}else if(e.span_id)t.push(e);else for(const r in e){const s=e[r];if(typeof s=="object"&&s!==null){const a=n(s);if(a)t.push(a);else if(Array.isArray(s)){for(const l of s)if(typeof l=="object"&&l!==null){const o=n(l);o&&t.push(o)}}}}return t}function qm(e){const t=new Map,n=[];for(const s of e)t.set(s.span_id,{span:s,children:[]});for(const s of e){const a=t.get(s.span_id);s.parent_span_id&&t.has(s.parent_span_id)?t.get(s.parent_span_id).children.push(a):n.push(a)}const r=s=>{s.sort((a,l)=>(a.span.start_time||0)-(l.span.start_time||0)),s.forEach(a=>r(a.children))};return r(n),n}function K0(e){return e.includes("Agent")||e.includes("agent")?"bg-[var(--span-llm-bg)] text-[var(--span-llm-text)]":e.includes("chat")||e.includes("Chat")||e.includes("llm")?"bg-[var(--span-tool-bg)] text-[var(--span-tool-text)]":e.includes("tool")||e.includes("execute")||e.includes("bash")?"bg-[var(--span-agent-bg)] text-[var(--span-agent-text)]":"bg-[var(--span-other-bg)] text-[var(--span-other-text)]"}function H0(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(0)}ms`}function Gc({node:e,depth:t=0}){var u,p;const[n,r]=j.useState(t<2),[s,a]=j.useState(!1),{span:l}=e,o=e.children.length>0,c=(u=l.attributes)==null?void 0:u["gen_ai.usage.input_tokens"],d=(p=l.attributes)==null?void 0:p["gen_ai.usage.output_tokens"],h=c!==void 0||d!==void 0;return i.jsxs("div",{className:"relative",children:[t>0&&i.jsx("div",{className:"absolute left-0 top-0 bottom-0 border-l-2 border-[var(--border)]",style:{marginLeft:`${(t-1)*16+8}px`}}),i.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-1 hover:bg-[var(--bg-primary)] rounded transition-colors cursor-pointer",style:{paddingLeft:`${t*16}px`},onClick:()=>o?r(!n):a(!s),children:[i.jsx("div",{className:"w-4 h-4 flex items-center justify-center text-[var(--text-secondary)]",children:o?n?"▼":"▶":s?"▼":"▶"}),i.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${K0(l.operation_name)}`,children:l.operation_name.replace("ChatAgent.","").replace("invoke_agent ","")}),l.duration_ms!==void 0&&i.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:H0(l.duration_ms)}),h&&i.jsxs("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:[c!==void 0&&i.jsxs("span",{className:"text-blue-400",children:["↑",String(c)]}),c!==void 0&&d!==void 0&&i.jsx("span",{className:"mx-0.5",children:"/"}),d!==void 0&&i.jsxs("span",{className:"text-green-400",children:["↓",String(d)]})]})]}),s&&!o&&i.jsx("div",{className:"ml-4 mt-1 mb-2 p-2 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs",style:{marginLeft:`${t*16+20}px`},children:i.jsxs("div",{className:"space-y-1",children:[l.span_id&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Span ID:"}),i.jsx("span",{className:"font-mono text-xs break-all",children:l.span_id})]}),l.trace_id&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Trace ID:"}),i.jsx("span",{className:"font-mono text-xs break-all",children:l.trace_id})]}),l.status&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Status:"}),i.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs ${l.status==="OK"||l.status==="StatusCode.UNSET"?"bg-[var(--span-pass-bg)] text-[var(--span-pass-text)]":"bg-[var(--span-fail-bg)] text-[var(--span-fail-text)]"}`,children:l.status})]}),Object.keys(l.attributes||{}).length>0&&i.jsxs("div",{className:"mt-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] block mb-1",children:"Attributes:"}),i.jsx("pre",{className:"text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded p-2 overflow-auto max-h-32 whitespace-pre-wrap break-all",children:JSON.stringify(l.attributes,null,2)})]})]})}),o&&n&&i.jsx("div",{children:e.children.map((x,k)=>i.jsx(Gc,{node:x,depth:t+1},x.span.span_id||k))})]})}function Gm({trace:e}){const[t,n]=j.useState("tree"),r=j.useMemo(()=>V0(e),[e]),s=j.useMemo(()=>qm(r),[r]);return Object.keys(e).length===0?null:i.jsxs(ge,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"font-medium",children:"Trace Data"}),i.jsxs("div",{className:"flex gap-1",children:[i.jsx("button",{onClick:()=>n("tree"),className:`px-2 py-1 text-xs rounded ${t==="tree"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Tree"}),i.jsx("button",{onClick:()=>n("raw"),className:`px-2 py-1 text-xs rounded ${t==="raw"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Raw"})]})]}),t==="tree"?r.length>0?i.jsx("div",{className:"border border-[var(--border)] rounded overflow-hidden",children:i.jsxs("div",{className:"p-2",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs(J,{variant:"default",children:[r.length," spans"]}),i.jsx("span",{children:"•"}),i.jsx("span",{children:"Click to expand details"})]}),s.map((a,l)=>i.jsx(Gc,{node:a,depth:0},a.span.span_id||l))]})}):i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No structured spans found. View raw data below."}):i.jsx("pre",{className:"text-xs bg-[var(--bg-primary)] p-3 overflow-x-auto border border-[var(--border)] max-h-96 whitespace-pre-wrap",children:JSON.stringify(e,null,2)})]})}function W0({spans:e,isLive:t=!1}){const n=j.useRef(null),r=j.useMemo(()=>qm(e),[e]);return j.useEffect(()=>{n.current&&t&&n.current.scrollTo({top:n.current.scrollHeight,behavior:"smooth"})},[e.length,t]),i.jsxs("div",{className:"border border-[var(--border)] rounded overflow-hidden h-full flex flex-col",children:[i.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-[var(--border)] bg-[var(--bg-secondary)]",children:[i.jsxs(J,{variant:"default",children:[e.length," spans"]}),t&&i.jsx("span",{className:"animate-pulse",children:i.jsx(J,{variant:"info",children:"Live"})})]}),i.jsx("div",{ref:n,className:"flex-1 overflow-auto p-2",children:r.length>0?r.map((s,a)=>i.jsx(Gc,{node:s,depth:0},s.span.span_id||a)):i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:t?"Waiting for spans...":"No spans recorded"})})]})}function Jm({agent:e}){const[t,n]=j.useState(""),[r,s]=j.useState(null),[a,l]=j.useState("idle"),[o,c]=j.useState(null),[d,h]=j.useState(""),[u,p]=j.useState([]),[x,k]=j.useState(null),[g,S]=j.useState(null),[m,f]=j.useState([]),[v,w]=j.useState(!1),C=j.useRef(null),{data:b=[]}=he({queryKey:["tasks"],queryFn:()=>Et.list()});j.useEffect(()=>{C.current&&a==="running"&&(C.current.scrollTop=C.current.scrollHeight)},[d,a]);const N=D=>{if(s(D),D){const q=b.find(X=>X.id===D);q&&n(q.prompt)}},_=async()=>{if(t.trim()){l("running"),h(""),p([]),k(null),S(null),f([]);try{const D=await Ts.create({agent_id:e.id,prompt:t.trim(),task_id:r||void 0});c(D.id);for await(const q of Ts.start(D.id))F(q)}catch(D){S(D instanceof Error?D.message:"Test failed"),l("failed")}}},F=D=>{switch(D.event){case"started":break;case"execution":D.execution_event==="text_delta"&&D.content?h(q=>q+D.content):D.execution_event==="tool_call_start"&&D.tool_name?f(q=>[...q,{name:D.tool_name}]):D.execution_event==="tool_result"&&D.content&&f(q=>{if(q.length>0){const X=[...q];return X[X.length-1]={...X[X.length-1],content:D.content},X}return q});break;case"span":if(D.span){const q=D.span;if(q.data){const X={span_id:q.data.span_id||"",trace_id:q.data.trace_id||"",parent_span_id:q.data.parent_span_id||null,operation_name:q.data.operation_name||"",start_time:q.timestamp?new Date(q.timestamp).getTime():Date.now(),end_time:Date.now(),duration_ms:q.data.duration_ms||0,status:q.data.status||"OK",attributes:q.data.attributes||{}};p(P=>[...P,X])}}break;case"complete":l("completed"),D.result&&k(D.result);break;case"error":S(D.message),l("failed");break}},O=async()=>{if(o)try{await Ts.cancel(o)}catch{}l("idle")},B=()=>{l("idle"),c(null),h(""),p([]),k(null),S(null),f([])},G=a==="running",re=a==="completed"||a==="failed",le=D=>{D.preventDefault(),re?(B(),setTimeout(()=>_(),0)):_()};return i.jsxs("div",{className:"h-full flex flex-col border border-[var(--border)] rounded-lg overflow-hidden bg-[var(--bg-primary)]",children:[(G||re)&&i.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border)] bg-[var(--bg-secondary)] flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[G&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"animate-pulse",children:i.jsx(J,{variant:"info",children:"Running"})}),i.jsx(Q,{variant:"ghost",size:"sm",icon:_d,onClick:O,children:"Cancel"})]}),a==="completed"&&i.jsx(J,{variant:"success",children:"Completed"}),a==="failed"&&i.jsx(J,{variant:"error",children:"Failed"})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[x&&i.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Rm,{size:12}),x.duration_seconds.toFixed(2),"s"]}),i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(_g,{size:12}),x.tokens_total," tokens"]}),x.passed!==null&&(x.passed?i.jsx(Lm,{size:14,className:"text-[var(--success)]"}):i.jsx(Qg,{size:14,className:"text-[var(--error)]"}))]}),u.length>0&&i.jsxs(Q,{variant:v?"primary":"secondary",size:"sm",icon:gg,onClick:()=>w(!v),children:["Traces (",u.length,")"]}),re&&o&&i.jsx(Pn,{to:`/tests/${o}`,children:i.jsx(Q,{variant:"secondary",size:"sm",icon:Mm,children:"Details"})})]})]}),i.jsxs("div",{className:"flex-1 min-h-0 flex",children:[i.jsx("div",{ref:C,className:`flex-1 overflow-auto p-4 ${v?"border-r border-[var(--border)]":""}`,children:!G&&!re?i.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center",children:[i.jsx("div",{className:"text-lg font-medium mb-1",children:e.name}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] max-w-sm",children:"Send a message to test this agent, or select a task from the dropdown below."})]}):i.jsxs("div",{className:"space-y-3",children:[i.jsx("div",{className:"flex justify-end",children:i.jsx("div",{className:"max-w-[80%] px-3 py-2 bg-[var(--accent-dim)] text-[var(--text-primary)] rounded-lg text-sm",children:t})}),(d||G)&&i.jsx("div",{className:"px-3 py-2 text-sm whitespace-pre-wrap font-mono bg-[var(--bg-secondary)] rounded-lg border border-[var(--border)]",children:d||i.jsx("span",{className:"text-[var(--text-secondary)] animate-pulse",children:"Thinking..."})}),m.length>0&&i.jsx("div",{className:"space-y-1.5",children:m.map((D,q)=>i.jsxs("div",{className:"p-2 bg-[var(--badge-info-bg)] border border-[var(--badge-info-border)] rounded-md text-xs",children:[i.jsx(J,{variant:"info",children:D.name}),D.content&&i.jsxs("div",{className:"mt-1 text-[var(--text-secondary)] truncate max-w-full font-mono",children:[D.content.substring(0,200),D.content.length>200&&"..."]})]},q))}),g&&i.jsx("div",{className:"p-3 bg-[var(--badge-error-bg)] border border-[var(--badge-error-border)] rounded-md text-sm text-[var(--badge-error-text)]",children:g})]})}),v&&i.jsx("div",{className:"w-[350px] flex-shrink-0 overflow-auto",children:i.jsx(W0,{spans:u,isLive:G})})]}),i.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] bg-[var(--bg-secondary)]",children:[i.jsx("div",{className:"px-4 pt-2",children:i.jsxs("select",{value:r||"",onChange:D=>N(D.target.value||null),className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs text-[var(--text-secondary)]",disabled:G,children:[i.jsx("option",{value:"",children:"Custom prompt..."}),b.map(D=>i.jsx("option",{value:D.id,children:D.name},D.id))]})}),i.jsxs("form",{onSubmit:le,className:"p-3 flex gap-2",children:[i.jsx("textarea",{value:t,onChange:D=>n(D.target.value),placeholder:"Message the agent...",disabled:G,rows:1,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm resize-none min-h-[40px] max-h-[120px] focus:outline-none focus:border-[var(--accent)]",onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),le(D))}}),i.jsx(Q,{type:"submit",variant:"primary",icon:G?_d:Xs,disabled:G?!1:!t.trim(),onClick:G?O:void 0,children:G?"Stop":re?"New Test":"Run"})]})]})]})}function q0(){const{agentId:e}=fa(),t=cr(),n=qt(),[r,s]=j.useState("overview"),{data:a,isLoading:l}=he({queryKey:["configs",e],queryFn:()=>Xn.get(e),enabled:!!e}),{data:o=[]}=he({queryKey:["tests",{agent_id:e}],queryFn:()=>Ts.list({agent_id:e}),enabled:!!e}),{data:c=[]}=he({queryKey:["jobs"],queryFn:()=>Ut.list()}),d=Je({mutationFn:u=>Xn.delete(u),onSuccess:()=>{n.invalidateQueries({queryKey:["configs"]}),t("/agents")}}),h=c.filter(u=>u.candidate_ids.includes(e||""));return l?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):a?i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"mb-4 flex-shrink-0",children:[i.jsx(pa,{items:[{label:"Agents",path:"/agents"},{label:a.name}]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:a.name}),a.is_auto_generated&&i.jsx(J,{variant:"info",children:"Auto-generated"})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Q,{variant:"primary",icon:ma,size:"sm",onClick:()=>s("evaluate"),children:"Optimize"}),i.jsx(Q,{variant:"secondary",icon:Qc,size:"sm",onClick:()=>{confirm(`Delete agent "${a.name}"?`)&&d.mutate(a.id)},children:"Delete"})]})]}),a.description&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:a.description})]}),i.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[i.jsxs("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:[i.jsxs("div",{className:"flex gap-1 mb-4 border-b border-[var(--border)] flex-shrink-0",children:[i.jsx(kl,{active:r==="overview",onClick:()=>s("overview"),icon:i.jsx(Im,{size:14}),children:"Overview"}),i.jsx(kl,{active:r==="evaluate",onClick:()=>s("evaluate"),icon:i.jsx(Xs,{size:14}),children:"Evaluate"}),i.jsx(kl,{active:r==="history",onClick:()=>s("history"),icon:i.jsx(Mg,{size:14}),badge:o.length,children:"History"})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r==="overview"&&i.jsx(G0,{agent:a,recentTests:o,jobs:h}),r==="evaluate"&&i.jsx(J0,{agent:a,jobs:h}),r==="history"&&i.jsx(Y0,{tests:o})]})]}),i.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[i.jsx(Fm,{size:16,className:"text-[var(--text-secondary)]"}),i.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),i.jsx("div",{className:"flex-1 min-h-0",children:i.jsx(Jm,{agent:a})})]})]})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Agent not found"})}function kl({active:e,onClick:t,icon:n,badge:r,children:s}){return i.jsxs("button",{onClick:t,className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors ${e?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[n,s,r!==void 0&&r>0&&i.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs bg-[var(--bg-tertiary)] rounded",children:r})]})}function G0({agent:e,recentTests:t,jobs:n}){var a,l;const r=e.config,s=()=>{const o=r.tools;return typeof o=="string"?o:Array.isArray(o)?o.join(", "):o&&typeof o=="object"?Object.keys(o).join(", "):"standard"};return i.jsxs("div",{className:"space-y-4",children:[i.jsx(fr,{title:"Model",children:i.jsx("div",{className:"font-mono text-sm",children:r.model||"default"})}),i.jsx(fr,{title:"Instructions",defaultCollapsed:!r.instructions,children:r.instructions?i.jsx("pre",{className:"p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs whitespace-pre-wrap max-h-40 overflow-auto font-mono",children:r.instructions}):i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No instructions set"})}),i.jsx(fr,{title:"Tools",children:i.jsx("div",{className:"font-mono text-sm",children:s()})}),i.jsx(fr,{title:"Compaction",children:i.jsx("div",{className:"font-mono text-sm",children:!r.compaction||r.compaction.strategy==="none"?"disabled":`${r.compaction.strategy} (${((a=r.compaction.params)==null?void 0:a.head_size)||0}/${((l=r.compaction.params)==null?void 0:l.tail_size)||0})`})}),t.length>0&&i.jsx(fr,{title:`Recent Tests (${t.length})`,children:i.jsx("div",{className:"space-y-1.5",children:t.slice(0,3).map(o=>i.jsxs(Pn,{to:`/tests/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[i.jsx(Ym,{status:o.status}),i.jsxs("span",{className:"truncate",children:[o.prompt.slice(0,40),"..."]})]}),i.jsxs("span",{className:"text-[var(--text-secondary)] flex-shrink-0 ml-2",children:[o.duration_seconds.toFixed(1),"s"]})]},o.id))})}),n.length>0&&i.jsx(fr,{title:`Experiments (${n.length})`,children:i.jsx("div",{className:"space-y-1.5",children:n.slice(0,3).map(o=>i.jsxs(Pn,{to:`/jobs/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(J,{variant:o.status==="completed"?"success":o.status==="running"?"info":"default",children:o.status}),i.jsx("span",{children:o.name})]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(o.created_at).toLocaleDateString()})]},o.id))})})]})}function fr({title:e,children:t,defaultCollapsed:n=!1}){const[r,s]=j.useState(n);return i.jsxs("div",{className:"border-b border-[var(--border)] pb-3",children:[i.jsxs("button",{onClick:()=>s(!r),className:"flex items-center justify-between w-full text-left py-1 hover:text-[var(--accent)] transition-colors",children:[i.jsx("span",{className:"text-sm font-medium",children:e}),i.jsx("span",{className:"text-[var(--text-secondary)] text-xs",children:r?"▶":"▼"})]}),!r&&i.jsx("div",{className:"mt-2",children:t})]})}function J0({agent:e,jobs:t}){const n=cr(),r=qt(),[s,a]=j.useState("quick"),[l,o]=j.useState(!1),{data:c=[]}=he({queryKey:["suites"],queryFn:()=>Et.listSuites()}),d=Je({mutationFn:j0.start,onSuccess:u=>{r.invalidateQueries({queryKey:["jobs"]}),o(!1),n(`/jobs/${u.id}`)},onError:()=>{o(!1)}}),h=()=>{o(!0),d.mutate({agent_id:e.id,suite_name:s,use_llm_eval:!0,parallel:4})};return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:"Run this agent on a task suite to measure quality and cost."}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm",value:s,onChange:u=>a(u.target.value),disabled:l,children:c.map(u=>i.jsxs("option",{value:u.name,children:[u.name.charAt(0).toUpperCase()+u.name.slice(1)," (",u.task_count," tasks)"]},u.name))}),i.jsx(Q,{variant:"primary",icon:l?ha:Xs,onClick:h,disabled:l,loading:l,className:"w-full",children:"Evaluate"})]})]}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h4",{className:"text-sm font-medium",children:"Optimization Jobs"}),i.jsx(Q,{variant:"secondary",size:"sm",icon:ma,onClick:()=>n("/agents",{state:{optimizeAgent:e}}),children:"New Job"})]}),t.length===0?i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No optimization jobs yet."}):i.jsx("div",{className:"space-y-1.5",children:t.slice(0,5).map(u=>i.jsxs(Pn,{to:`/jobs/${u.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(J,{variant:u.status==="completed"?"success":u.status==="running"?"info":"default",children:u.status}),i.jsx("span",{children:u.name})]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(u.created_at).toLocaleDateString()})]},u.id))})]})]})}function Y0({tests:e}){return e.length===0?i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No test history yet. Use the playground on the right to run a test."}):i.jsx("div",{className:"space-y-2",children:e.map(t=>i.jsxs(Pn,{to:`/tests/${t.id}`,className:"flex items-center justify-between p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(Ym,{status:t.status}),t.score!==null&&i.jsxs("span",{className:`text-sm font-medium ${t.passed?"text-[var(--success)]":"text-[var(--error)]"}`,children:[(t.score*100).toFixed(0),"%"]})]}),i.jsx("p",{className:"text-sm truncate",children:t.prompt})]}),i.jsxs("div",{className:"flex flex-col items-end gap-1 ml-4",children:[i.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:new Date(t.created_at).toLocaleString()}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:[t.duration_seconds.toFixed(1),"s"]}),i.jsxs("span",{children:[t.tokens_total," tokens"]})]})]})]},t.id))})}function Ym({status:e}){const t={completed:"success",failed:"error",running:"info",cancelled:"warning",pending:"default"};return i.jsx(J,{variant:t[e]||"default",children:e})}function X0(){const e=qt(),[t,n]=j.useState(!1),[r,s]=j.useState(!1),[a,l]=j.useState(null),[o,c]=j.useState(new Set),d=m=>{c(f=>{const v=new Set(f);return v.has(m)?v.delete(m):v.add(m),v})},{data:h=[],isLoading:u}=he({queryKey:["tasks"],queryFn:()=>Et.list()}),p=Je({mutationFn:Et.create,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),n(!1)}}),x=Je({mutationFn:Et.importSuite,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),s(!1)}}),k=Je({mutationFn:Et.delete,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),l(null)}}),g=h.reduce((m,f)=>{const v=f.suite||"custom";return m[v]||(m[v]=[]),m[v].push(f),m},{}),S=Object.keys(g).sort((m,f)=>m==="custom"?-1:f==="custom"?1:m.localeCompare(f));return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Datasets"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Task datasets for evaluating agent configurations."})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(Q,{variant:"secondary",onClick:()=>s(!0),children:"Import Suite"}),i.jsx(Q,{variant:"primary",onClick:()=>n(!0),children:"+ New Task"})]})]}),u?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):h.length===0?i.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:"No tasks yet. Create one or import a built-in suite."}):i.jsx("div",{className:"space-y-4",children:S.map(m=>{const f=g[m],v=!o.has(m);return i.jsxs("div",{children:[i.jsxs("button",{onClick:()=>d(m),className:"flex items-center gap-2 py-2 hover:text-[var(--accent)] transition-colors",children:[v?i.jsx(Ng,{size:16,className:"text-[var(--text-secondary)]"}):i.jsx(Ys,{size:16,className:"text-[var(--text-secondary)]"}),i.jsx("h3",{className:"text-sm font-medium uppercase tracking-wide",children:m==="custom"?"Custom Tasks":`${m} Suite`}),i.jsx(J,{variant:m==="custom"?"default":"info",children:f.length})]}),v&&i.jsx("div",{className:"mt-2 border border-[var(--border)] rounded-lg overflow-hidden",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:[i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Name"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Category"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Prompt"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Criteria"})]})}),i.jsx("tbody",{children:f.map(w=>i.jsxs("tr",{onClick:()=>l(w),className:"border-b border-[var(--border)] last:border-b-0 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors",children:[i.jsx("td",{className:"px-4 py-3",children:i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:w.name})}),i.jsx("td",{className:"px-4 py-3",children:w.category&&w.category!=="default"?i.jsx(J,{variant:"default",children:w.category}):i.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"})}),i.jsx("td",{className:"px-4 py-3",children:i.jsx("span",{className:"text-[var(--text-secondary)] line-clamp-1 max-w-md",children:w.prompt})}),i.jsx("td",{className:"px-4 py-3 text-[var(--text-secondary)]",children:w.criteria.length>0?w.criteria.length:"--"})]},w.id))})]})})]},m)})}),i.jsx(Z0,{task:a,onClose:()=>l(null),onDelete:m=>{confirm("Delete this task?")&&k.mutate(m)}}),i.jsx(e1,{isOpen:t,onClose:()=>n(!1),onSubmit:m=>p.mutate(m),isLoading:p.isPending}),i.jsx(t1,{isOpen:r,onClose:()=>s(!1),onSubmit:m=>x.mutate(m),isLoading:x.isPending})]})}function Z0({task:e,onClose:t,onDelete:n}){const[r,s]=j.useState("prompt");if(!e)return null;const a=i.jsxs("div",{className:"flex justify-between",children:[i.jsx(Q,{variant:"ghost",onClick:()=>n(e.id),className:"text-red-500 hover:text-red-600",children:"Delete Task"}),i.jsx(Q,{variant:"secondary",onClick:t,children:"Close"})]});return i.jsx(ss,{isOpen:!!e,onClose:t,title:e.name,size:"lg",footer:a,children:i.jsxs("div",{className:"space-y-4",children:[e.category&&e.category!=="default"&&i.jsx("div",{children:i.jsx(J,{variant:"default",children:e.category})}),i.jsxs("div",{className:"flex gap-1 border-b border-[var(--border)]",children:[i.jsx("button",{onClick:()=>s("prompt"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="prompt"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Prompt"}),i.jsxs("button",{onClick:()=>s("criteria"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="criteria"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:["Eval Criteria (",e.criteria.length,")"]})]}),r==="prompt"&&i.jsx("div",{className:"p-4 bg-[var(--bg-tertiary)] rounded text-sm whitespace-pre-wrap min-h-[200px]",children:e.prompt}),r==="criteria"&&i.jsx("div",{className:"space-y-2 min-h-[200px]",children:e.criteria.length===0?i.jsx("div",{className:"text-[var(--text-secondary)] text-sm p-4",children:"No evaluation criteria defined for this task."}):e.criteria.map(l=>i.jsxs("div",{className:"p-3 bg-[var(--bg-tertiary)] rounded",children:[i.jsx("div",{className:"font-medium text-sm",children:l.name}),l.instruction&&i.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1",children:l.instruction})]},l.name))})]})})}function e1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,a]=j.useState({name:"",prompt:"",criteria:[],category:"default"}),l=()=>{a({...s,criteria:[...s.criteria,{name:"",instruction:"",weight:1}]})},o=(h,u)=>{const p=[...s.criteria];p[h]={...p[h],...u},a({...s,criteria:p})},c=h=>{a({...s,criteria:s.criteria.filter((u,p)=>p!==h)})},d=h=>{h.preventDefault(),!(!s.name.trim()||!s.prompt.trim())&&n({...s,criteria:s.criteria.filter(u=>u.name.trim()&&u.instruction.trim())})};return i.jsx(ss,{isOpen:e,onClose:t,title:"Create Task",children:i.jsxs("form",{onSubmit:d,className:"space-y-4",children:[i.jsx(pn,{label:"Name",value:s.name,onChange:h=>a({...s,name:h.target.value}),placeholder:"e.g., fizzbuzz",required:!0}),i.jsx(F0,{label:"Prompt",value:s.prompt,onChange:h=>a({...s,prompt:h.target.value}),placeholder:"The task description for the agent...",required:!0}),i.jsx(pn,{label:"Category",value:s.category,onChange:h=>a({...s,category:h.target.value}),placeholder:"e.g., coding, research"}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Evaluation Criteria"}),i.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"+ Add"})]}),i.jsx("div",{className:"space-y-2",children:s.criteria.map((h,u)=>i.jsxs("div",{className:"flex gap-2 items-start",children:[i.jsx(pn,{value:h.name,onChange:p=>o(u,{name:p.target.value}),placeholder:"Name",className:"w-32"}),i.jsx(pn,{value:h.instruction,onChange:p=>o(u,{instruction:p.target.value}),placeholder:"Instruction",className:"flex-1"}),i.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(u),children:"×"})]},u))})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(Q,{type:"submit",variant:"primary",disabled:r||!s.name.trim()||!s.prompt.trim(),children:r?"Creating...":"Create"})]})]})})}function t1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,a]=j.useState(""),{data:l=[],isLoading:o}=he({queryKey:["suites"],queryFn:()=>Et.listSuites(),enabled:e});return j.useEffect(()=>{l.length>0&&!s&&a(l[0].name)},[l,s]),i.jsx(ss,{isOpen:e,onClose:t,title:"Import Task Suite",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Import a built-in task suite for evaluation."}),o?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading suites..."}):l.length===0?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"No suites available."}):i.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:l.map(c=>i.jsxs("label",{className:`flex items-center gap-3 p-3 border cursor-pointer ${s===c.name?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[i.jsx("input",{type:"radio",name:"suite",value:c.name,checked:s===c.name,onChange:()=>a(c.name),className:"accent-[var(--accent)]"}),i.jsxs("span",{className:"capitalize",children:[c.name.replace(/_/g," ")," (",c.task_count," tasks) - ",c.description]})]},c.name))}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(Q,{variant:"primary",onClick:()=>n(s),disabled:r||!s,children:r?"Importing...":"Import"})]})]})})}const n1=Ki(e=>({jobs:[],setJobs:t=>e({jobs:t})}));function r1(){const e=cr(),t=qt(),[n,r]=j.useState(!1),{setJobs:s}=n1(),a=Wc(),{data:l=[],isLoading:o}=he({queryKey:["jobs",n],queryFn:()=>Ut.list({include_public:n}),refetchInterval:5e3});j.useEffect(()=>{l.length>0&&s(l)},[l,s]);const c=Je({mutationFn:Ut.delete,onSuccess:()=>t.invalidateQueries({queryKey:["jobs"]})}),d={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"},h=[{key:"name",header:"Name",render:u=>i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:u.name||`Job ${u.id.slice(0,8)}`}),u.is_public&&i.jsx(Uc,{className:"w-3 h-3 ml-2 inline text-[var(--text-secondary)]"})]})},{key:"status",header:"Status",render:u=>i.jsx(J,{variant:d[u.status]||"default",children:u.status})},{key:"candidates",header:"Candidates",render:u=>i.jsx("span",{children:u.candidate_ids.length})},{key:"tasks",header:"Tasks",render:u=>i.jsx("span",{children:u.task_ids.length})},{key:"runs",header:"Runs",render:u=>i.jsxs("span",{children:[u.completed_experiments,"/",u.total_experiments]})},{key:"created",header:"Created",render:u=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(u.created_at).toLocaleDateString()}),sortable:!0,sortValue:u=>new Date(u.created_at).getTime()},{key:"actions",header:"",className:"w-12",render:u=>!u.user_id||u.user_id==="anonymous"||a&&u.created_by_name===a?i.jsx("div",{onClick:x=>x.stopPropagation(),children:i.jsx(Q,{variant:"ghost",size:"sm",icon:Qc,title:"Delete",disabled:u.status==="running",onClick:()=>{confirm("Delete this job?")&&c.mutate(u.id)}})}):null}];return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Experiments"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"View and manage optimization experiments. Start new experiments from the Agents page."})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Ni,{label:"Show public",checked:n,onChange:u=>r(u.target.checked)}),i.jsx(Q,{variant:"secondary",onClick:()=>e("/agents"),children:"Go to Agents"})]})]}),o?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):i.jsx(Wm,{columns:h,data:l,onRowClick:u=>e(`/jobs/${u.id}`),searchable:!0,searchPlaceholder:"Search experiments",searchFilter:(u,p)=>(u.name||"").toLowerCase().includes(p.toLowerCase())||u.id.toLowerCase().includes(p.toLowerCase()),emptyMessage:"No experiments yet. Go to Agents page to start an optimization."})]})}function s1(e,t=!0){return Math.abs(e)<10?"text-[var(--text-secondary)]":(t?e<0:e>0)?"text-green-400":"text-red-400"}function a1(e){return`${e>0?"+":""}${e.toFixed(1)}%`}function Xm(e,t){return t===0?0:(e-t)/t*100}function ps({label:e,values:t,baselineIndex:n,formatter:r,isLowerBetter:s=!0}){const a=t[n];return i.jsxs("tr",{className:"border-b border-[var(--border)] last:border-0",children:[i.jsx("td",{className:"py-2 pr-4 text-[var(--text-secondary)] text-sm",children:e}),t.map((l,o)=>{const c=Xm(l,a),d=o===n;return i.jsxs("td",{className:"py-2 px-4 text-right",children:[i.jsx("div",{className:"font-mono",children:r(l)}),!d&&i.jsx("div",{className:`text-xs ${s1(c,s)}`,children:a1(c)}),d&&i.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"(baseline)"})]},o)})]})}function i1({runs:e,baselineRunId:t}){const n=j.useMemo(()=>{if(t){const a=e.findIndex(l=>l.id===t);if(a>=0)return a}return 0},[e,t]);if(e.length<2)return null;const r=Math.min(...e.map(a=>a.tokens_total)),s=Math.max(...e.map(a=>a.score));return i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-4",children:"Candidate Comparison"}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-[var(--border)]",children:[i.jsx("th",{className:"pb-2 pr-4 text-left text-[var(--text-secondary)] font-medium",children:"Metric"}),e.map((a,l)=>i.jsx("th",{className:"pb-2 px-4 text-right",children:i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[i.jsx("span",{className:"font-medium",children:a.candidate_name}),a.is_pareto&&i.jsx(J,{variant:"success",children:"Optimal"}),l===n&&i.jsx(J,{variant:"info",children:"Base"})]})},a.id))]})}),i.jsxs("tbody",{children:[i.jsx(ps,{label:"Total Tokens",values:e.map(a=>a.tokens_total),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ps,{label:"Input Tokens",values:e.map(a=>a.tokens_input),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ps,{label:"Output Tokens",values:e.map(a=>a.tokens_output),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ps,{label:"Duration",values:e.map(a=>a.duration_seconds),baselineIndex:n,formatter:a=>`${a.toFixed(1)}s`,isLowerBetter:!0}),i.jsx(ps,{label:"Score",values:e.map(a=>a.score*100),baselineIndex:n,formatter:a=>`${a.toFixed(1)}%`,isLowerBetter:!1})]})]})}),i.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[i.jsx("h4",{className:"text-sm font-medium mb-2 text-[var(--text-secondary)]",children:"Key Insights"}),i.jsxs("ul",{className:"text-sm space-y-1 text-[var(--text-secondary)]",children:[e.map(a=>{const l=Xm(a.tokens_total,e[n].tokens_total);return a.tokens_total===r&&l<-5?i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-green-400",children:"✓"}),i.jsxs("span",{children:[i.jsx("strong",{children:a.candidate_name})," uses ",Math.abs(l).toFixed(0),"% fewer tokens"]})]},`token-${a.id}`):null}),e.map(a=>a.score===s&&a.passed?i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-green-400",children:"✓"}),i.jsxs("span",{children:[i.jsx("strong",{children:a.candidate_name})," achieved highest score (",(a.score*100).toFixed(0),"%)"]})]},`score-${a.id}`):null),e.filter(a=>a.is_pareto).length>0&&i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-purple-400",children:"★"}),i.jsxs("span",{children:["Optimal candidates (best tradeoff):"," ",e.filter(a=>a.is_pareto).map(a=>a.candidate_name).join(", ")]})]})]})]}),i.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[i.jsx("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:"Token Efficiency"}),i.jsx("div",{className:"space-y-2",children:e.map(a=>{const l=a.tokens_total/e[n].tokens_total*100,o=a.tokens_total<=r;return i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-24 text-sm truncate",title:a.candidate_name,children:a.candidate_name}),i.jsx("div",{className:"flex-1 h-6 bg-[var(--bg-primary)] rounded overflow-hidden",children:i.jsx("div",{className:`h-full transition-all duration-300 ${o?"bg-green-500":"bg-blue-500"}`,style:{width:`${Math.min(l,100)}%`}})}),i.jsx("div",{className:"w-20 text-right font-mono text-sm",children:a.tokens_total.toLocaleString()})]},a.id)})})]})]})}function l1({summaries:e,height:t=350}){const n=j.useRef(null),[r,s]=j.useState(600),[a,l]=j.useState("tokens"),[o,c]=j.useState(null),[d,h]=j.useState({x:0,y:0});j.useEffect(()=>{const b=()=>{n.current&&s(n.current.clientWidth)};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[]);const u={top:30,right:30,bottom:50,left:60},p=r-u.left-u.right,x=t-u.top-u.bottom,k=b=>a==="tokens"?b.avg_tokens:b.avg_duration,{xScale:g,yScale:S,xTicks:m,yTicks:f,paretoLine:v}=j.useMemo(()=>{if(e.length===0||p<=0)return{xScale:()=>0,yScale:()=>0,xTicks:[],yTicks:[],paretoLine:[]};const b=e.map(k),N=e.map(P=>P.avg_score),_=Math.min(...b)*.9,F=Math.max(...b)*1.1,O=Math.min(...N,.5),B=Math.min(Math.max(...N)*1.05,1),G=P=>(P-_)/(F-_)*p,re=P=>x-(P-O)/(B-O)*x,le=Array.from({length:5},(P,A)=>_+A/4*(F-_)),D=Array.from({length:5},(P,A)=>O+A/4*(B-O)),X=e.filter(P=>P.is_pareto).sort((P,A)=>k(P)-k(A)).map(P=>({x:G(k(P)),y:re(P.avg_score)}));return{xScale:G,yScale:re,xTicks:le,yTicks:D,paretoLine:X}},[e,p,x,a]);if(e.length===0)return i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No data to display"});const w=b=>a==="tokens"?b>=1e6?`${(b/1e6).toFixed(1)}M`:b>=1e3?`${(b/1e3).toFixed(0)}K`:b.toFixed(0):`${b.toFixed(1)}s`,C=(b,N)=>{var F;const _=(F=n.current)==null?void 0:F.getBoundingClientRect();_&&h({x:N.clientX-_.left,y:N.clientY-_.top}),c(b)};return i.jsxs("div",{ref:n,className:"w-full relative",children:[i.jsx("div",{className:"flex justify-end mb-2",children:i.jsxs("div",{className:"inline-flex rounded border border-[var(--border)] text-xs",children:[i.jsx("button",{className:`px-3 py-1 ${a==="tokens"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("tokens"),children:"Tokens"}),i.jsx("button",{className:`px-3 py-1 ${a==="duration"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("duration"),children:"Latency"})]})}),i.jsx("svg",{width:r,height:t,className:"font-mono text-xs",children:i.jsxs("g",{transform:`translate(${u.left}, ${u.top})`,children:[m.map((b,N)=>i.jsx("line",{x1:g(b),y1:0,x2:g(b),y2:x,stroke:"var(--border)",strokeDasharray:"2,2"},`x-grid-${N}`)),f.map((b,N)=>i.jsx("line",{x1:0,y1:S(b),x2:p,y2:S(b),stroke:"var(--border)",strokeDasharray:"2,2"},`y-grid-${N}`)),v.length>1&&i.jsx("polyline",{points:v.map(b=>`${b.x},${b.y}`).join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.slice().sort((b,N)=>(b.is_pareto?1:0)-(N.is_pareto?1:0)).map(b=>{const N=g(k(b)),_=S(b.avg_score),F=b.is_pareto,O=(o==null?void 0:o.candidate_name)===b.candidate_name;return i.jsxs("g",{onMouseEnter:B=>C(b,B),onMouseLeave:()=>c(null),children:[i.jsx("circle",{cx:N,cy:_,r:O?10:F?8:6,fill:F?"var(--accent)":"transparent",stroke:O?"var(--text-primary)":F?"var(--accent)":"var(--text-secondary)",strokeWidth:O?3:2,className:"cursor-pointer transition-all"}),F&&!O&&i.jsx("text",{x:N,y:_-12,textAnchor:"middle",fill:"var(--text-primary)",fontSize:10,className:"pointer-events-none",children:b.candidate_name.replace(/^baseline_/,"").slice(0,15)})]},b.candidate_name)}),i.jsx("line",{x1:0,y1:x,x2:p,y2:x,stroke:"var(--text-secondary)"}),m.map((b,N)=>i.jsxs("g",{transform:`translate(${g(b)}, ${x})`,children:[i.jsx("line",{y2:5,stroke:"var(--text-secondary)"}),i.jsx("text",{y:20,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:10,children:w(b)})]},`x-tick-${N}`)),i.jsx("text",{x:p/2,y:x+40,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:a==="tokens"?"Tokens (cost)":"Duration (latency)"}),i.jsx("line",{x1:0,y1:0,x2:0,y2:x,stroke:"var(--text-secondary)"}),f.map((b,N)=>i.jsxs("g",{transform:`translate(0, ${S(b)})`,children:[i.jsx("line",{x2:-5,stroke:"var(--text-secondary)"}),i.jsxs("text",{x:-10,textAnchor:"end",dominantBaseline:"middle",fill:"var(--text-secondary)",fontSize:10,children:[(b*100).toFixed(0),"%"]})]},`y-tick-${N}`)),i.jsx("text",{transform:`translate(-45, ${x/2}) rotate(-90)`,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:"Score (quality)"})]})}),o&&i.jsxs("div",{className:"absolute z-10 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg shadow-lg p-3 text-sm pointer-events-none",style:{left:Math.min(d.x+15,r-200),top:d.y-10,maxWidth:220},children:[i.jsx("div",{className:"font-medium text-[var(--text-primary)] truncate mb-2",children:o.candidate_name.replace(/^baseline_/,"")}),i.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Score:"}),i.jsxs("span",{className:"text-right font-medium",children:[(o.avg_score*100).toFixed(1),"%"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tokens:"}),i.jsxs("span",{className:"text-right",children:[(o.avg_tokens/1e3).toFixed(1),"K"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Duration:"}),i.jsxs("span",{className:"text-right",children:[o.avg_duration.toFixed(1),"s"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Pass rate:"}),i.jsxs("span",{className:"text-right",children:[o.passed_runs,"/",o.total_runs]})]}),o.is_pareto&&i.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)] text-xs text-[var(--accent)]",children:"Optimal (best tradeoff)"})]})]})}function o1(e=2e3){const[t,n]=j.useState(!1),[r,s]=j.useState(null),a=j.useCallback(async o=>{try{return await navigator.clipboard.writeText(o),n(!0),s(null),setTimeout(()=>n(!1),e),!0}catch{return s("Failed to copy to clipboard"),n(!1),!1}},[e]),l=j.useCallback(()=>{n(!1),s(null)},[]);return{copy:a,copied:t,error:r,reset:l}}function c1({isOpen:e,onClose:t,title:n,itemId:r,itemType:s,isPublic:a,createdByName:l,onTogglePublic:o}){const[c,d]=j.useState(!1),{copy:h,copied:u}=o1(),p=`${window.location.origin}/${s}s/${r}`,x=async()=>{d(!0);try{await o(!a)}finally{d(!1)}},k=()=>{h(p)};return i.jsx(ss,{isOpen:e,onClose:t,title:n,children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between p-3 bg-[var(--bg-tertiary)] rounded",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[a?i.jsx(Uc,{className:"w-5 h-5 text-[var(--accent)]"}):i.jsx(zm,{className:"w-5 h-5 text-[var(--text-secondary)]"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium",children:a?"Public":"Private"}),i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:a?"Anyone with the link can view":"Only you can access"})]})]}),i.jsx("button",{onClick:x,disabled:c,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${a?"bg-[var(--accent)]":"bg-[var(--border)]"} ${c?"opacity-50 cursor-not-allowed":""}`,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${a?"translate-x-6":"translate-x-1"}`})})]}),a&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Share link"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",readOnly:!0,value:p,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono"}),i.jsx(Q,{variant:"secondary",onClick:k,children:u?i.jsxs(i.Fragment,{children:[i.jsx(Sg,{className:"w-4 h-4 mr-1"}),"Copied"]}):i.jsxs(i.Fragment,{children:[i.jsx(Eg,{className:"w-4 h-4 mr-1"}),"Copy"]})})]})]}),l&&i.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",i.jsx("span",{className:"text-[var(--text-primary)]",children:l})]}),i.jsx("div",{className:"text-xs text-[var(--text-secondary)] pt-2 border-t border-[var(--border)]",children:a?i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Public ",s,"s can be viewed by anyone with the link."]}),i.jsxs("p",{className:"mt-1",children:["Only you can edit or delete this ",s,"."]})]}):i.jsxs("p",{children:["Make this ",s," public to share it with others."]})})]})})}function u1({job:e,onUpdate:t}){const[n,r]=j.useState(!1),s=async a=>{await Ut.update(e.id,{is_public:a}),t()};return i.jsxs(i.Fragment,{children:[i.jsxs(Q,{variant:"secondary",size:"sm",onClick:()=>r(!0),title:e.is_public?"Sharing settings":"Share this job",children:[i.jsx($g,{className:"w-4 h-4 mr-1"}),e.is_public?"Shared":"Share"]}),i.jsx(c1,{isOpen:n,onClose:()=>r(!1),title:"Share Job",itemId:e.id,itemType:"job",isPublic:e.is_public,createdByName:e.created_by_name,onTogglePublic:s})]})}function d1(){const{jobId:e}=fa(),t=cr(),n=qt(),[r,s]=j.useState(null),[a,l]=j.useState(!1),[o,c]=j.useState(null),[d,h]=j.useState([]),[u,p]=j.useState(null),[x,k]=j.useState(null),[g,S]=j.useState("results"),[m,f]=j.useState("score"),[v,w]=j.useState("desc"),[C,b]=j.useState(!1),{data:N,isLoading:_}=he({queryKey:["jobs",e],queryFn:()=>Ut.get(e),enabled:!!e,refetchInterval:a?2e3:!1}),{data:F=[]}=he({queryKey:["runs",e],queryFn:()=>Fo.list({job_id:e}),enabled:!!e,refetchInterval:a?2e3:!1}),{data:O}=he({queryKey:["job-summary",e],queryFn:()=>Fo.getJobSummary(e),enabled:!!e&&(N==null?void 0:N.status)==="completed"}),B=Je({mutationFn:async()=>{l(!0),h([]),p(null),k(null);for await(const R of Ut.start(e))s(R),R.current_candidate&&R.current_task&&p(T=>(T&&(T.candidate!==R.current_candidate||T.task!==R.current_task)&&h(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),{candidate:R.current_candidate,task:R.current_task})),R.event==="error"&&(k(R.message),l(!1),n.invalidateQueries({queryKey:["jobs",e]})),R.event==="complete"&&(p(T=>(T&&h(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),null)),l(!1),n.invalidateQueries({queryKey:["jobs",e]}),n.invalidateQueries({queryKey:["runs",e]}),n.invalidateQueries({queryKey:["job-summary",e]}))}}),G=Je({mutationFn:()=>Ut.cancel(e),onSuccess:()=>{l(!1),n.invalidateQueries({queryKey:["jobs",e]})}});j.useEffect(()=>{(N==null?void 0:N.status)==="running"&&l(!0)},[N==null?void 0:N.status]);const re=j.useMemo(()=>{const R=new Map;for(const T of F)R.has(T.task_name)||R.set(T.task_name,[]),R.get(T.task_name).push(T);return R},[F]),le=j.useMemo(()=>Array.from(re.keys()),[re]);j.useEffect(()=>{!o&&le.length>0&&c(le[0])},[le,o]);const D=j.useMemo(()=>{if(!(O!=null&&O.candidate_summaries))return[];let R=[...O.candidate_summaries];return C&&(R=R.filter(T=>T.is_pareto)),R.sort((T,te)=>{let pe,be;switch(m){case"score":pe=T.avg_score,be=te.avg_score;break;case"tokens":pe=T.avg_tokens,be=te.avg_tokens;break;case"duration":pe=T.avg_duration,be=te.avg_duration;break;case"pass_rate":pe=T.passed_runs/T.total_runs,be=te.passed_runs/te.total_runs;break}return v==="desc"?be-pe:pe-be}),R},[O,m,v,C]),q=R=>{m===R?w(v==="desc"?"asc":"desc"):(f(R),w(R==="tokens"||R==="duration"?"asc":"desc"))},X=({label:R,sortKeyVal:T})=>i.jsx("th",{className:"pb-2 cursor-pointer hover:text-[var(--text-primary)] select-none",onClick:()=>q(T),children:i.jsxs("div",{className:"flex items-center gap-1",children:[R,m===T&&i.jsx(jg,{size:12,className:v==="asc"?"rotate-180":""})]})});if(_)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!N)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Job not found"});const P=Wc(),A=!N.user_id||N.user_id==="anonymous"||P&&N.created_by_name===P,L=N.is_public&&!A,K=()=>{n.invalidateQueries({queryKey:["jobs",e]})},ee=R=>{const T={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};return i.jsx(J,{variant:T[R]||"default",children:R})};return i.jsxs("div",{children:[i.jsx(pa,{items:[{label:"Experiments",path:"/jobs"},{label:N.name||`Job ${N.id.slice(0,8)}`}]}),i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:N.name||`Job ${N.id.slice(0,8)}`}),ee(N.status),N.is_public&&i.jsxs(J,{variant:"info",children:[i.jsx(Uc,{className:"w-3 h-3 mr-1 inline"}),"Public"]})]}),i.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-2 py-0.5 rounded font-mono text-[var(--text-secondary)]",children:[N.id.slice(0,8),"..."]}),i.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[N.candidate_ids.length," candidates × ",N.task_ids.length," tasks = ",N.total_experiments," experiments"]}),N.is_public&&N.created_by_name&&i.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",i.jsx("span",{className:"text-[var(--text-primary)]",children:N.created_by_name})]})]})]}),i.jsxs("div",{className:"flex gap-2",children:[A&&i.jsx(u1,{job:N,onUpdate:K}),L&&i.jsx(J,{variant:"default",children:"View Only"}),A&&N.status==="pending"&&i.jsx(Q,{variant:"primary",onClick:()=>B.mutate(),disabled:B.isPending,children:B.isPending?"Starting...":"Start"}),A&&N.status==="running"&&i.jsx(Q,{variant:"danger",onClick:()=>G.mutate(),disabled:G.isPending,children:"Cancel"})]})]}),(x||N.error)&&i.jsx(ge,{className:"mb-6 border-red-500/50 bg-red-500/10",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-5 h-5 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-0.5",children:"!"}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium text-red-400",children:"Error"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:x||N.error})]})]})}),(a||r)&&i.jsxs(ge,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("span",{className:"font-medium",children:"Progress"}),i.jsxs("span",{className:"text-[var(--accent)]",children:[(r==null?void 0:r.completed)||N.completed_experiments,"/",(r==null?void 0:r.total)||N.total_experiments]})]}),i.jsx("div",{className:"w-full bg-[var(--bg-primary)] h-2 mb-2",children:i.jsx("div",{className:"h-full bg-[var(--accent)] transition-all",style:{width:`${((r==null?void 0:r.completed)||N.completed_experiments)/((r==null?void 0:r.total)||N.total_experiments)*100}%`}})}),(r==null?void 0:r.message)&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r.message}),a&&i.jsxs("div",{className:"mt-4 border-t border-[var(--border)] pt-4",children:[(r==null?void 0:r.current_candidate)&&(r==null?void 0:r.current_task)&&i.jsxs("div",{className:"mb-3",children:[i.jsx("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:"Currently Running"}),i.jsxs("div",{className:"flex items-center gap-2 mt-1 px-3 py-2 bg-blue-500/10 border border-blue-500/30 rounded",children:[i.jsx("div",{className:"w-2 h-2 bg-blue-400 rounded-full animate-pulse"}),i.jsx("span",{className:"font-medium",children:r.current_candidate}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{children:r.current_task})]})]}),d.length>0&&i.jsxs("div",{children:[i.jsxs("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:["Completed (",d.length,")"]}),i.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto space-y-1",children:d.map((R,T)=>i.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-500/10 border border-green-500/30 rounded text-sm",children:[i.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}),i.jsx("span",{className:"font-medium",children:R.candidate_name}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{children:R.task_name})]},`${R.candidate_name}-${R.task_name}-${T}`))})]})]})]}),(N.status==="completed"||F.length>0)&&i.jsxs("div",{className:"flex gap-1 mb-6 border-b border-[var(--border)]",children:[i.jsxs("button",{onClick:()=>S("results"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="results"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(wg,{size:16}),"Results"]}),i.jsxs("button",{onClick:()=>S("compare"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="compare"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(Lg,{size:16}),"Compare"]}),i.jsxs("button",{onClick:()=>S("runs"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="runs"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(zg,{size:16}),"Runs (",F.length,")"]})]}),g==="results"&&i.jsxs(i.Fragment,{children:[O&&O.candidate_summaries.length>1&&i.jsxs(ge,{className:"mb-6",children:[i.jsx("div",{className:"flex items-start justify-between mb-4",children:i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium",children:"Quality vs. Cost Tradeoff"}),i.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:["Candidates on the frontier (connected line) are ",i.jsx("strong",{children:"optimal"})," - no other candidate beats them on both score AND cost."]})]})}),i.jsxs("div",{className:"mb-4 p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs text-[var(--text-secondary)]",children:[i.jsx("strong",{className:"text-[var(--text-primary)]",children:"How optimal tradeoffs are calculated:"})," A candidate is optimal if there's no other candidate that has both a higher score AND lower cost. For example, if Candidate A has 95% score at 50K tokens and Candidate B has 90% score at 40K tokens, both are optimal - A is better on score, B is better on cost. But if Candidate C has 85% score at 60K tokens, it's ",i.jsx("em",{children:"not"})," optimal because B beats it on both metrics."]}),i.jsx(l1,{summaries:O.candidate_summaries,height:350})]}),O&&i.jsxs(ge,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h3",{className:"font-medium",children:"Results Summary"}),i.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:C,onChange:R=>b(R.target.checked),className:"rounded border-[var(--border)]"}),"Optimal only"]})]}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"text-left text-[var(--text-secondary)] border-b border-[var(--border)]",children:[i.jsx("th",{className:"pb-2",children:"Candidate"}),i.jsx(X,{label:"Score",sortKeyVal:"score"}),i.jsx(X,{label:"Tokens",sortKeyVal:"tokens"}),i.jsx(X,{label:"Duration",sortKeyVal:"duration"}),i.jsx(X,{label:"Pass Rate",sortKeyVal:"pass_rate"}),i.jsx("th",{className:"pb-2",children:"Optimal"})]})}),i.jsx("tbody",{children:D.map((R,T)=>i.jsxs("tr",{className:`border-b border-[var(--border)] ${T===0?"bg-[var(--accent)]/10":""}`,children:[i.jsxs("td",{className:"py-2 font-medium",children:[T===0&&i.jsx("span",{className:"text-[var(--accent)] mr-1",children:"#1"}),R.candidate_name.replace(/^baseline_/,"")]}),i.jsxs("td",{className:"py-2",children:[(R.avg_score*100).toFixed(1),"%"]}),i.jsxs("td",{className:"py-2",children:[(R.avg_tokens/1e3).toFixed(1),"K"]}),i.jsxs("td",{className:"py-2",children:[R.avg_duration.toFixed(1),"s"]}),i.jsxs("td",{className:"py-2",children:[R.passed_runs,"/",R.total_runs]}),i.jsx("td",{className:"py-2",children:R.is_pareto&&i.jsx(J,{variant:"success",children:"Optimal"})})]},R.candidate_name))})]})}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-3",children:"Click column headers to sort. The #1 ranked candidate is highlighted based on your sort criteria."})]}),!O&&i.jsx(ge,{children:i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Results will appear here after the job completes.":"No results yet. Start the job to see results."})})]}),g==="compare"&&i.jsxs(ge,{children:[i.jsx("h3",{className:"font-medium mb-4",children:"Compare Candidates by Task"}),le.length>0?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:le.map(R=>i.jsx("button",{onClick:()=>c(o===R?null:R),className:`px-3 py-1 text-sm rounded border transition-colors ${o===R?"bg-[var(--accent)] text-white border-[var(--accent)]":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:R},R))}),o&&re.get(o)?i.jsx(i1,{runs:re.get(o).map(R=>({id:R.id,candidate_name:R.candidate_name,tokens_input:0,tokens_output:0,tokens_total:R.tokens_total,duration_seconds:R.duration_seconds,score:R.score,passed:R.passed,is_pareto:R.is_pareto}))}):i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"Select a task above to compare how different candidates performed on it."})]}):i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Comparison data will appear here after runs complete.":"No runs yet. Start the job to compare candidates."})]}),g==="runs"&&i.jsxs(ge,{children:[i.jsx("h3",{className:"font-medium mb-4",children:"All Experiment Runs"}),F.length===0?i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Runs will appear here as they complete. See progress above for live status.":"No runs yet. Start the job to see results."}):i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:F.map(R=>i.jsxs("div",{className:"p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] cursor-pointer hover:border-[var(--accent-dim)] transition-colors",onClick:()=>t(`/runs/${R.id}`),children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("span",{className:`text-lg font-bold ${R.passed?"text-green-400":"text-red-400"}`,children:[(R.score*100).toFixed(0),"%"]}),R.is_pareto&&i.jsx(J,{variant:"success",children:"Optimal"})]}),i.jsx("div",{className:"text-sm font-medium truncate",title:R.candidate_name,children:R.candidate_name.replace(/^baseline_/,"")}),i.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:R.task_name}),i.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:[(R.tokens_total/1e3).toFixed(1),"K tokens"]}),i.jsxs("span",{children:[R.duration_seconds.toFixed(1),"s"]})]})]},R.id))})]})]})}const vn={input:"bg-blue-500",output:"bg-emerald-500",inputText:"text-blue-400",outputText:"text-emerald-400"};function Rd(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Md({input:e,output:t,maxValue:n,height:r=24,showLabels:s=!0}){const a=e+t;if(a===0)return i.jsx("div",{className:"flex items-center gap-2 w-full",children:i.jsx("div",{className:"rounded bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`}})});const l=n>0?a/n*100:100;return i.jsxs("div",{className:"flex items-center gap-3 w-full",children:[i.jsx("div",{className:"relative rounded overflow-hidden bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`},children:i.jsxs("div",{className:"h-full flex transition-all duration-300",style:{width:`${l}%`},children:[i.jsx("div",{className:`h-full ${vn.input} transition-all`,style:{width:`${e/a*100}%`},title:`Input: ${e.toLocaleString()} tokens`}),i.jsx("div",{className:`h-full ${vn.output} transition-all`,style:{width:`${t/a*100}%`},title:`Output: ${t.toLocaleString()} tokens`})]})}),s&&i.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono text-[var(--text-secondary)] min-w-[90px] justify-end",children:[i.jsxs("span",{className:vn.inputText,children:["↑",Rd(e)]}),i.jsx("span",{children:"/"}),i.jsxs("span",{className:vn.outputText,children:["↓",Rd(t)]})]})]})}function Sl({label:e,value:t,color:n="default"}){const r={default:"text-[var(--text-primary)]",input:vn.inputText,output:vn.outputText}[n];return i.jsxs("div",{className:"flex-1 p-3 bg-[var(--bg-primary)] border border-[var(--border)] rounded",children:[i.jsx("div",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e}),i.jsx("div",{className:`font-mono text-lg font-bold ${r}`,children:t})]})}function Zm({tokensInput:e,tokensOutput:t,tokensTotal:n,turns:r}){const s=n>0?Math.round(e/n*100):0,a=n>0?Math.round(t/n*100):0,l=j.useMemo(()=>{if(!r||r.length===0)return null;let c=0,d=0;return r.map(h=>(c+=h.input,d+=h.output,{input:c,output:d,total:c+d}))},[r]),o=l?Math.max(...l.map(c=>c.total)):n;return i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-4",children:"Token Usage"}),i.jsx("div",{className:"mb-4",children:i.jsx(Md,{input:e,output:t,maxValue:n,height:32})}),i.jsxs("div",{className:"flex items-center gap-6 text-xs mb-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:`w-3 h-3 rounded ${vn.input}`}),i.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Input (",s,"%)"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:`w-3 h-3 rounded ${vn.output}`}),i.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Output (",a,"%)"]})]})]}),i.jsxs("div",{className:"flex gap-3 mb-4",children:[i.jsx(Sl,{label:"Input Tokens",value:e.toLocaleString(),color:"input"}),i.jsx(Sl,{label:"Output Tokens",value:t.toLocaleString(),color:"output"}),i.jsx(Sl,{label:"Total Tokens",value:n.toLocaleString()})]}),l&&l.length>1&&i.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[i.jsxs("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:["Token Accumulation (",r.length," turns)"]}),i.jsx("div",{className:"space-y-2",children:r.map((c,d)=>i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--bg-primary)] border border-[var(--border)] flex items-center justify-center text-xs font-medium",children:d+1}),i.jsx("div",{className:"flex-1",children:i.jsx(Md,{input:l[d].input,output:l[d].output,maxValue:o,height:16})})]},d))})]}),i.jsx("div",{className:"mt-4 text-xs text-[var(--text-secondary)] border-t border-[var(--border)] pt-3",children:"Token usage affects API cost. Input tokens are typically cheaper than output tokens."})]})}function f1(){const{runId:e}=fa(),{data:t,isLoading:n}=he({queryKey:["runs",e],queryFn:()=>Fo.get(e),enabled:!!e});return n?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?i.jsxs("div",{children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(pa,{items:[{label:"Experiments",path:"/jobs"},{label:"Job",path:`/jobs/${t.job_id}`},{label:t.candidate_name}]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:t.candidate_name}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{className:"text-lg",children:t.task_name}),t.is_pareto&&i.jsx(J,{variant:"success",children:"Optimal"})]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[i.jsx(za,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),i.jsx(za,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),i.jsx(za,{label:"Duration",value:`${t.duration_seconds.toFixed(1)}s`}),i.jsx(za,{label:"Status",value:t.passed?"Passed":"Failed",status:t.passed?"success":"error"})]}),i.jsx(Zm,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),t.reasoning&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:t.reasoning}),t.criteria_results.length>0&&i.jsx("div",{className:"space-y-2",children:t.criteria_results.map(r=>i.jsx("div",{className:"flex items-start justify-between p-3 bg-[var(--bg-primary)] border border-[var(--border)]",children:i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-medium",children:r.name}),i.jsxs(J,{variant:r.passed?"success":"error",children:[(r.score*100).toFixed(0),"%"]})]}),r.reasoning&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r.reasoning})]})},r.name))})]}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created.length>0&&i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),i.jsx("div",{className:"space-y-1",children:t.files_created.map(r=>i.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:r},r))})]}),Object.keys(t.trace).length>0&&i.jsx(Gm,{trace:t.trace})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Run not found"})}function za({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return i.jsxs(ge,{children:[i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),i.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function h1(){const{testId:e}=fa(),{data:t,isLoading:n}=he({queryKey:["tests",e],queryFn:()=>Ts.get(e),enabled:!!e}),{data:r}=he({queryKey:["configs",t==null?void 0:t.agent_id],queryFn:()=>Xn.get(t.agent_id),enabled:!!(t!=null&&t.agent_id)});if(n)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!t)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Test not found"});const s={completed:"success",failed:"error",running:"info",pending:"default",cancelled:"warning"};return i.jsxs("div",{children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(pa,{items:[{label:"Agents",path:"/agents"},...r?[{label:r.name,path:`/agents/${r.id}`}]:[],{label:`Test ${t.id.slice(0,8)}`}]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:"Test Run"}),r&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"•"}),i.jsx("span",{className:"text-lg",children:r.name})]}),i.jsx(J,{variant:s[t.status]||"default",children:t.status})]}),i.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:["ID: ",t.id.slice(0,8),"..."]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[i.jsx(Fa,{label:"Duration",value:`${t.duration_seconds.toFixed(2)}s`}),i.jsx(Fa,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),t.score!==null&&i.jsx(Fa,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),i.jsx(Fa,{label:"Status",value:t.status.charAt(0).toUpperCase()+t.status.slice(1),status:t.status==="completed"?"success":t.status==="failed"?"error":void 0})]}),i.jsx(Zm,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Prompt"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)] font-mono",children:t.prompt})]}),t.error&&i.jsxs(ge,{className:"mb-6 border-red-500/30 bg-red-500/5",children:[i.jsx("h3",{className:"font-medium mb-3 text-red-400",children:"Error"}),i.jsx("pre",{className:"text-sm text-red-300 overflow-x-auto whitespace-pre-wrap",children:t.error})]}),t.reasoning&&i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.reasoning})]}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created&&t.files_created.length>0&&i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),i.jsx("div",{className:"space-y-1",children:t.files_created.map(a=>i.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:a},a))})]}),t.trace&&Object.keys(t.trace).length>0&&i.jsx(Gm,{trace:t.trace}),i.jsxs(ge,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Timestamps"}),i.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Created:"}),i.jsx("div",{className:"font-mono",children:new Date(t.created_at).toLocaleString()})]}),t.started_at&&i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Started:"}),i.jsx("div",{className:"font-mono",children:new Date(t.started_at).toLocaleString()})]}),t.completed_at&&i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Completed:"}),i.jsx("div",{className:"font-mono",children:new Date(t.completed_at).toLocaleString()})]})]})]})]})}function Fa({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return i.jsxs(ge,{children:[i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),i.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function m1(){const{deploymentId:e}=fa(),{data:t,isLoading:n}=he({queryKey:["deployments",e],queryFn:()=>g0.get(e),enabled:!!e}),r=t==null?void 0:t.versions.find(a=>a.id===t.current_version_id),{data:s}=he({queryKey:["configs",r==null?void 0:r.config_id],queryFn:()=>Xn.get(r.config_id),enabled:!!(r!=null&&r.config_id)});return n?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"mb-4 flex-shrink-0",children:[i.jsx(pa,{items:[{label:"Agents",path:"/agents"},{label:t.name}]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Dg,{size:20,className:"text-[var(--accent)]"}),i.jsx("h2",{className:"text-xl font-bold",children:t.name}),r&&i.jsxs(J,{variant:"info",children:["v",r.version]})]}),t.description&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:t.description})]}),i.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[i.jsx("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:i.jsxs("div",{className:"flex-1 overflow-y-auto space-y-5",children:[i.jsxs("div",{className:"flex items-center gap-4 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:["Created ",new Date(t.created_at).toLocaleDateString()]}),i.jsxs("span",{children:["Updated ",new Date(t.updated_at).toLocaleDateString()]}),i.jsxs("span",{children:[t.versions.length," version",t.versions.length!==1?"s":""]})]}),s&&i.jsxs(Pn,{to:`/agents/${s.id}`,className:"flex items-center gap-2 p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-sm",children:[i.jsx(Mm,{size:14,className:"text-[var(--accent)]"}),i.jsxs("span",{children:["Agent: ",i.jsx("span",{className:"font-medium",children:s.name})]})]}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider mb-3",children:"Version History"}),t.versions.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"No versions yet."}):i.jsx("div",{className:"space-y-2",children:t.versions.map(a=>i.jsx(p1,{version:a,isActive:a.id===t.current_version_id},a.id))})]})]})}),i.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[i.jsx(Fm,{size:16,className:"text-[var(--text-secondary)]"}),i.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),i.jsx("div",{className:"flex-1 min-h-0",children:s?i.jsx(Jm,{agent:s}):i.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-secondary)] text-sm",children:r?"Loading agent configuration...":"No active version to test."})})]})]})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Deployment not found"})}function p1({version:e,isActive:t}){const n=e.config_snapshot;return i.jsxs("div",{className:`p-3 rounded-md border transition-colors ${t?"border-[var(--accent)] bg-[var(--accent-dim)]":"border-[var(--border)] bg-[var(--bg-secondary)]"}`,children:[i.jsxs("div",{className:"flex items-center justify-between mb-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Bg,{size:12,className:"text-[var(--text-secondary)]"}),i.jsxs("span",{className:"text-sm font-medium",children:["v",e.version]}),t&&i.jsx(J,{variant:"success",children:"Active"}),i.jsx(J,{variant:e.source==="optimize"?"info":"default",children:e.source})]}),i.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)]",children:[i.jsx(Rm,{size:11}),i.jsx("span",{children:new Date(e.created_at).toLocaleString()})]})]}),e.description&&i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e.description}),Object.keys(n).length>0&&i.jsxs("div",{className:"mt-1",children:[i.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)] mb-1",children:[i.jsx(Og,{size:11}),i.jsx("span",{children:"Config"})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-xs",children:["framework"in n&&n.framework?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Framework"}),i.jsx("span",{className:"font-mono",children:String(n.framework)})]}):null,"model"in n&&n.model?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Model"}),i.jsx("span",{className:"font-mono",children:String(n.model)})]}):null,"tools"in n&&n.tools?i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tools"}),i.jsx("span",{className:"font-mono truncate",children:Array.isArray(n.tools)?n.tools.join(", "):String(n.tools)})]}):null]})]})]})}function v1(){const{authConfig:e,isLoading:t,error:n,login:r,loginWithGitHub:s,clearError:a}=qc(),[l,o]=j.useState(""),[c,d]=j.useState("");j.useEffect(()=>{n&&a()},[l,c]);const h=async p=>{p.preventDefault(),!(!l||!c)&&await r(l,c)},u=()=>{s()};return i.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:i.jsxs("div",{className:"w-full max-w-md",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:"Flow"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:"Sign in to access the optimization dashboard"})]}),i.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] p-6 space-y-6",children:[n&&i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[var(--error)]/10 border border-[var(--error)]/20 text-[var(--error)]",children:[i.jsx(Om,{size:18,className:"mt-0.5 flex-shrink-0"}),i.jsx("p",{className:"text-sm",children:n})]}),(e==null?void 0:e.mode)==="basic"&&i.jsxs("form",{onSubmit:h,className:"space-y-4",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Username"}),i.jsxs("div",{className:"relative",children:[i.jsx(Dm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),i.jsx("input",{type:"text",value:l,onChange:p=>o(p.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter username",autoComplete:"username",autoFocus:!0})]})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Password"}),i.jsxs("div",{className:"relative",children:[i.jsx(zm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),i.jsx("input",{type:"password",value:c,onChange:p=>d(p.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter password",autoComplete:"current-password"})]})]}),i.jsx(Q,{type:"submit",variant:"primary",className:"w-full justify-center",loading:t,disabled:!l||!c,children:"Sign In"})]}),(e==null?void 0:e.mode)==="github"&&i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center",children:"Sign in with your GitHub account to continue"}),i.jsx(Q,{onClick:u,variant:"secondary",className:"w-full justify-center",icon:Rg,children:"Continue with GitHub"})]})]})]})})}function x1({children:e}){const{authConfig:t,isLoadingConfig:n,isAuthenticated:r,loadAuthConfig:s,handleOAuthCallback:a}=qc();return j.useEffect(()=>{s()},[s]),j.useEffect(()=>{n||a()},[n,a]),n?i.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center",children:i.jsxs("div",{className:"text-center",children:[i.jsx(ha,{className:"w-8 h-8 animate-spin text-[var(--accent)] mx-auto mb-4"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:"Loading..."})]})}):t!=null&&t.enabled&&!r?i.jsx(v1,{}):i.jsx(i.Fragment,{children:e})}function y1(){return i.jsx(dg,{children:i.jsx(x1,{children:i.jsx(rg,{children:i.jsxs(ht,{path:"/",element:i.jsx(O0,{}),children:[i.jsx(ht,{index:!0,element:i.jsx(Ld,{})}),i.jsx(ht,{path:"agents",element:i.jsx(Ld,{})}),i.jsx(ht,{path:"agents/:agentId",element:i.jsx(q0,{})}),i.jsx(ht,{path:"tasks",element:i.jsx(X0,{})}),i.jsx(ht,{path:"jobs",element:i.jsx(r1,{})}),i.jsx(ht,{path:"jobs/:jobId",element:i.jsx(d1,{})}),i.jsx(ht,{path:"runs/:runId",element:i.jsx(f1,{})}),i.jsx(ht,{path:"tests/:testId",element:i.jsx(h1,{})}),i.jsx(ht,{path:"deployments/:deploymentId",element:i.jsx(m1,{})})]})})})})}const zd=localStorage.getItem("flow-theme");if(zd)try{const{state:e}=JSON.parse(zd);e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}catch{}const g1=new Xx({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}});Nl.createRoot(document.getElementById("root")).render(i.jsx(Vo.StrictMode,{children:i.jsx(Zx,{client:g1,children:i.jsx(y1,{})})})); diff --git a/src/flow/ui/ui/assets/index-GJ5M4KFa.css b/src/flow/ui/ui/assets/index-GJ5M4KFa.css new file mode 100644 index 0000000000000000000000000000000000000000..ec688afd42d86fc12edb2a6cebbe8a100841e1c3 --- /dev/null +++ b/src/flow/ui/ui/assets/index-GJ5M4KFa.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:Segoe UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:JetBrains Mono,ui-monospace,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.pointer-events-none{pointer-events:none}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.bottom-0{bottom:0}.bottom-1{bottom:.25rem}.left-0{left:0}.left-3{left:.75rem}.top-0{top:0}.top-1{top:.25rem}.top-1\/2{top:50%}.z-10{z-index:10}.z-50{z-index:50}.col-span-2{grid-column:span 2 / span 2}.mx-0\.5{margin-left:.125rem;margin-right:.125rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.-mb-px{margin-bottom:-1px}.-mt-2{margin-top:-.5rem}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.ml-6{margin-left:1.5rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-auto{margin-top:auto}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-1\.5{height:.375rem}.h-12{height:3rem}.h-2{height:.5rem}.h-3{height:.75rem}.h-32{height:8rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-8{height:2rem}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:8rem}.max-h-40{max-height:10rem}.max-h-48{max-height:12rem}.max-h-80{max-height:20rem}.max-h-96{max-height:24rem}.max-h-\[80vh\]{max-height:80vh}.min-h-0{min-height:0px}.min-h-\[100px\]{min-height:100px}.min-h-\[200px\]{min-height:200px}.min-h-screen{min-height:100vh}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-2{width:.5rem}.w-20{width:5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-32{width:8rem}.w-4{width:1rem}.w-5{width:1.25rem}.w-56{width:14rem}.w-6{width:1.5rem}.w-8{width:2rem}.w-\[3px\]{width:3px}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-\[90px\]{min-width:90px}.max-w-2xl{max-width:42rem}.max-w-4xl{max-width:56rem}.max-w-\[200px\]{max-width:200px}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-90{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.resize-y{resize:vertical}.resize{resize:both}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-\[var\(--accent\)\]{border-color:var(--accent)}.border-\[var\(--border\)\]{border-color:var(--border)}.border-blue-200{--tw-border-opacity: 1;border-color:rgb(191 219 254 / var(--tw-border-opacity, 1))}.border-blue-500\/30{border-color:#3b82f64d}.border-green-200{--tw-border-opacity: 1;border-color:rgb(187 247 208 / var(--tw-border-opacity, 1))}.border-green-500\/20{border-color:#22c55e33}.border-green-500\/30{border-color:#22c55e4d}.border-green-500\/50{border-color:#22c55e80}.border-red-200{--tw-border-opacity: 1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1))}.border-red-500\/20{border-color:#ef444433}.border-red-500\/30{border-color:#ef44444d}.border-red-500\/50{border-color:#ef444480}.border-transparent{border-color:transparent}.border-yellow-200{--tw-border-opacity: 1;border-color:rgb(254 240 138 / var(--tw-border-opacity, 1))}.bg-\[var\(--accent\)\]{background-color:var(--accent)}.bg-\[var\(--accent-dim\)\]{background-color:var(--accent-dim)}.bg-\[var\(--bg-primary\)\]{background-color:var(--bg-primary)}.bg-\[var\(--bg-secondary\)\]{background-color:var(--bg-secondary)}.bg-\[var\(--bg-tertiary\)\]{background-color:var(--bg-tertiary)}.bg-\[var\(--border\)\]{background-color:var(--border)}.bg-\[var\(--error\)\]{background-color:var(--error)}.bg-black\/50{background-color:#00000080}.bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(96 165 250 / var(--tw-bg-opacity, 1))}.bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-500\/10{background-color:#3b82f61a}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(16 185 129 / var(--tw-bg-opacity, 1))}.bg-green-100{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.bg-green-400{--tw-bg-opacity: 1;background-color:rgb(74 222 128 / var(--tw-bg-opacity, 1))}.bg-green-50{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-green-500\/10{background-color:#22c55e1a}.bg-green-500\/20{background-color:#22c55e33}.bg-orange-100{--tw-bg-opacity: 1;background-color:rgb(255 237 213 / var(--tw-bg-opacity, 1))}.bg-purple-100{--tw-bg-opacity: 1;background-color:rgb(243 232 255 / var(--tw-bg-opacity, 1))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-500\/10{background-color:#ef44441a}.bg-red-500\/5{background-color:#ef44440d}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.bg-yellow-50{--tw-bg-opacity: 1;background-color:rgb(254 252 232 / var(--tw-bg-opacity, 1))}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-2{padding-bottom:.5rem}.pb-3{padding-bottom:.75rem}.pl-10{padding-left:2.5rem}.pl-9{padding-left:2.25rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:JetBrains Mono,ui-monospace,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.text-\[var\(--accent\)\]{color:var(--accent)}.text-\[var\(--error\)\]{color:var(--error)}.text-\[var\(--text-primary\)\]{color:var(--text-primary)}.text-\[var\(--text-secondary\)\]{color:var(--text-secondary)}.text-\[var\(--text-tertiary\)\]{color:var(--text-tertiary)}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.text-blue-400{--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.text-blue-700{--tw-text-opacity: 1;color:rgb(29 78 216 / var(--tw-text-opacity, 1))}.text-blue-800{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.text-emerald-400{--tw-text-opacity: 1;color:rgb(52 211 153 / var(--tw-text-opacity, 1))}.text-green-400{--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-green-700{--tw-text-opacity: 1;color:rgb(21 128 61 / var(--tw-text-opacity, 1))}.text-green-800{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.text-orange-800{--tw-text-opacity: 1;color:rgb(154 52 18 / var(--tw-text-opacity, 1))}.text-purple-400{--tw-text-opacity: 1;color:rgb(192 132 252 / var(--tw-text-opacity, 1))}.text-purple-800{--tw-text-opacity: 1;color:rgb(107 33 168 / var(--tw-text-opacity, 1))}.text-red-300{--tw-text-opacity: 1;color:rgb(252 165 165 / var(--tw-text-opacity, 1))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity, 1))}.text-red-800{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.text-yellow-700{--tw-text-opacity: 1;color:rgb(161 98 7 / var(--tw-text-opacity, 1))}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}:root{--bg-primary: #ffffff;--bg-secondary: #fafafa;--bg-tertiary: #f3f4f6;--text-primary: #1b1b1b;--text-secondary: #616161;--accent: #7c3aed;--accent-hover: #6d28d9;--accent-dim: #ede9fe;--border: #e5e7eb;--error: #dc2626;--success: #16a34a}[data-theme=dark]{--bg-primary: #1a1a2e;--bg-secondary: #16162a;--bg-tertiary: #252540;--text-primary: #f0f0f5;--text-secondary: #a0a0b5;--accent: #a78bfa;--accent-hover: #8b5cf6;--accent-dim: #2d2055;--border: #2d2d45;--error: #ef4444;--success: #22c55e}*{box-sizing:border-box}body{margin:0;background-color:var(--bg-primary);color:var(--text-primary);font-family:Segoe UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-size:14px;line-height:1.6}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:var(--bg-secondary)}::-webkit-scrollbar-thumb{background:var(--border);border-radius:4px}::-webkit-scrollbar-thumb:hover{background:silver}[data-theme=dark] ::-webkit-scrollbar-thumb:hover{background:#404040}.last\:border-0:last-child{border-width:0px}.last\:border-b-0:last-child{border-bottom-width:0px}.hover\:border-\[var\(--accent\)\]:hover{border-color:var(--accent)}.hover\:border-\[var\(--accent-dim\)\]:hover{border-color:var(--accent-dim)}.hover\:bg-\[var\(--accent-hover\)\]:hover{background-color:var(--accent-hover)}.hover\:bg-\[var\(--bg-primary\)\]:hover{background-color:var(--bg-primary)}.hover\:bg-\[var\(--bg-tertiary\)\]:hover{background-color:var(--bg-tertiary)}.hover\:bg-\[var\(--border\)\]:hover{background-color:var(--border)}.hover\:bg-red-600:hover{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.hover\:text-\[var\(--accent\)\]:hover{color:var(--accent)}.hover\:text-\[var\(--error\)\]:hover{color:var(--error)}.hover\:text-\[var\(--text-primary\)\]:hover{color:var(--text-primary)}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-80:hover{opacity:.8}.focus\:border-\[var\(--accent\)\]:focus{border-color:var(--accent)}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-\[var\(--accent\)\]:focus{--tw-ring-color: var(--accent)}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}@media (min-width: 768px){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (min-width: 1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (prefers-color-scheme: dark){.dark\:border-blue-800{--tw-border-opacity: 1;border-color:rgb(30 64 175 / var(--tw-border-opacity, 1))}.dark\:border-green-800{--tw-border-opacity: 1;border-color:rgb(22 101 52 / var(--tw-border-opacity, 1))}.dark\:border-red-800{--tw-border-opacity: 1;border-color:rgb(153 27 27 / var(--tw-border-opacity, 1))}.dark\:border-yellow-800{--tw-border-opacity: 1;border-color:rgb(133 77 14 / var(--tw-border-opacity, 1))}.dark\:bg-blue-900{--tw-bg-opacity: 1;background-color:rgb(30 58 138 / var(--tw-bg-opacity, 1))}.dark\:bg-blue-900\/30{background-color:#1e3a8a4d}.dark\:bg-green-900{--tw-bg-opacity: 1;background-color:rgb(20 83 45 / var(--tw-bg-opacity, 1))}.dark\:bg-green-900\/30{background-color:#14532d4d}.dark\:bg-orange-900{--tw-bg-opacity: 1;background-color:rgb(124 45 18 / var(--tw-bg-opacity, 1))}.dark\:bg-purple-900{--tw-bg-opacity: 1;background-color:rgb(88 28 135 / var(--tw-bg-opacity, 1))}.dark\:bg-red-900{--tw-bg-opacity: 1;background-color:rgb(127 29 29 / var(--tw-bg-opacity, 1))}.dark\:bg-red-900\/30{background-color:#7f1d1d4d}.dark\:bg-yellow-900\/30{background-color:#713f124d}.dark\:text-blue-200{--tw-text-opacity: 1;color:rgb(191 219 254 / var(--tw-text-opacity, 1))}.dark\:text-blue-400{--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.dark\:text-green-200{--tw-text-opacity: 1;color:rgb(187 247 208 / var(--tw-text-opacity, 1))}.dark\:text-green-400{--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.dark\:text-orange-200{--tw-text-opacity: 1;color:rgb(254 215 170 / var(--tw-text-opacity, 1))}.dark\:text-purple-200{--tw-text-opacity: 1;color:rgb(233 213 255 / var(--tw-text-opacity, 1))}.dark\:text-red-200{--tw-text-opacity: 1;color:rgb(254 202 202 / var(--tw-text-opacity, 1))}.dark\:text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.dark\:text-yellow-400{--tw-text-opacity: 1;color:rgb(250 204 21 / var(--tw-text-opacity, 1))}} diff --git a/src/flow/ui/ui/assets/index-PvSQZWQZ.js b/src/flow/ui/ui/assets/index-PvSQZWQZ.js new file mode 100644 index 0000000000000000000000000000000000000000..1d2e54d1906a3c9f06ae0395a3577cb054cc6da1 --- /dev/null +++ b/src/flow/ui/ui/assets/index-PvSQZWQZ.js @@ -0,0 +1,302 @@ +var Yu=e=>{throw TypeError(e)};var Wi=(e,t,n)=>t.has(e)||Yu("Cannot "+n);var y=(e,t,n)=>(Wi(e,t,"read from private field"),n?n.call(e):t.get(e)),$=(e,t,n)=>t.has(e)?Yu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),z=(e,t,n,r)=>(Wi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),H=(e,t,n)=>(Wi(e,t,"access private method"),n);var ha=(e,t,n,r)=>({set _(s){z(e,t,s,n)},get _(){return y(e,t,r)}});function Ym(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const a of s)if(a.type==="childList")for(const l of a.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const a={};return s.integrity&&(a.integrity=s.integrity),s.referrerPolicy&&(a.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?a.credentials="include":s.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(s){if(s.ep)return;s.ep=!0;const a=n(s);fetch(s.href,a)}})();function Wd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var qd={exports:{}},ki={},Gd={exports:{}},J={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var ia=Symbol.for("react.element"),Xm=Symbol.for("react.portal"),Zm=Symbol.for("react.fragment"),ep=Symbol.for("react.strict_mode"),tp=Symbol.for("react.profiler"),np=Symbol.for("react.provider"),rp=Symbol.for("react.context"),sp=Symbol.for("react.forward_ref"),ap=Symbol.for("react.suspense"),ip=Symbol.for("react.memo"),lp=Symbol.for("react.lazy"),Xu=Symbol.iterator;function op(e){return e===null||typeof e!="object"?null:(e=Xu&&e[Xu]||e["@@iterator"],typeof e=="function"?e:null)}var Jd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Yd=Object.assign,Xd={};function Xr(e,t,n){this.props=e,this.context=t,this.refs=Xd,this.updater=n||Jd}Xr.prototype.isReactComponent={};Xr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Xr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Zd(){}Zd.prototype=Xr.prototype;function $o(e,t,n){this.props=e,this.context=t,this.refs=Xd,this.updater=n||Jd}var Uo=$o.prototype=new Zd;Uo.constructor=$o;Yd(Uo,Xr.prototype);Uo.isPureReactComponent=!0;var Zu=Array.isArray,ef=Object.prototype.hasOwnProperty,Bo={current:null},tf={key:!0,ref:!0,__self:!0,__source:!0};function nf(e,t,n){var r,s={},a=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(a=""+t.key),t)ef.call(t,r)&&!tf.hasOwnProperty(r)&&(s[r]=t[r]);var o=arguments.length-2;if(o===1)s.children=n;else if(1>>1,ee=P[Q];if(0>>1;Qs(te,L))mes(be,te)?(P[Q]=be,P[me]=L,Q=me):(P[Q]=te,P[T]=L,Q=T);else if(mes(be,L))P[Q]=be,P[me]=L,Q=me;else break e}}return A}function s(P,A){var L=P.sortIndex-A.sortIndex;return L!==0?L:P.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var a=performance;e.unstable_now=function(){return a.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var u=[],d=[],h=1,c=null,p=3,x=!1,k=!1,g=!1,S=typeof setTimeout=="function"?setTimeout:null,m=typeof clearTimeout=="function"?clearTimeout:null,f=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function v(P){for(var A=n(d);A!==null;){if(A.callback===null)r(d);else if(A.startTime<=P)r(d),A.sortIndex=A.expirationTime,t(u,A);else break;A=n(d)}}function j(P){if(g=!1,v(P),!k)if(n(u)!==null)k=!0,q(C);else{var A=n(d);A!==null&&Y(j,A.startTime-P)}}function C(P,A){k=!1,g&&(g=!1,m(_),_=-1),x=!0;var L=p;try{for(v(A),c=n(u);c!==null&&(!(c.expirationTime>A)||P&&!B());){var Q=c.callback;if(typeof Q=="function"){c.callback=null,p=c.priorityLevel;var ee=Q(c.expirationTime<=A);A=e.unstable_now(),typeof ee=="function"?c.callback=ee:c===n(u)&&r(u),v(A)}else r(u);c=n(u)}if(c!==null)var R=!0;else{var T=n(d);T!==null&&Y(j,T.startTime-A),R=!1}return R}finally{c=null,p=L,x=!1}}var b=!1,N=null,_=-1,F=5,O=-1;function B(){return!(e.unstable_now()-OP||125Q?(P.sortIndex=L,t(d,P),n(u)===null&&P===n(d)&&(g?(m(_),_=-1):g=!0,Y(j,L-Q))):(P.sortIndex=ee,t(u,P),k||x||(k=!0,q(C))),P},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(P){var A=p;return function(){var L=p;p=A;try{return P.apply(this,arguments)}finally{p=L}}}})(of);lf.exports=of;var jp=lf.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var wp=w,et=jp;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),bl=Object.prototype.hasOwnProperty,kp=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,tc={},nc={};function Sp(e){return bl.call(nc,e)?!0:bl.call(tc,e)?!1:kp.test(e)?nc[e]=!0:(tc[e]=!0,!1)}function Np(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function bp(e,t,n,r){if(t===null||typeof t>"u"||Np(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Be(e,t,n,r,s,a,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=a,this.removeEmptyString=l}var Oe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Oe[e]=new Be(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Oe[t]=new Be(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Oe[e]=new Be(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Oe[e]=new Be(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Oe[e]=new Be(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Oe[e]=new Be(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Oe[e]=new Be(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Oe[e]=new Be(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Oe[e]=new Be(e,5,!1,e.toLowerCase(),null,!1,!1)});var Ko=/[\-:]([a-z])/g;function Ho(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Ko,Ho);Oe[t]=new Be(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Ko,Ho);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Ko,Ho);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!1,!1)});Oe.xlinkHref=new Be("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!0,!0)});function Wo(e,t,n,r){var s=Oe.hasOwnProperty(t)?Oe[t]:null;(s!==null?s.type!==0:r||!(2o||s[l]!==a[o]){var u=` +`+s[l].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=l&&0<=o);break}}}finally{Ji=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?vs(e):""}function Cp(e){switch(e.tag){case 5:return vs(e.type);case 16:return vs("Lazy");case 13:return vs("Suspense");case 19:return vs("SuspenseList");case 0:case 2:case 15:return e=Yi(e.type,!1),e;case 11:return e=Yi(e.type.render,!1),e;case 1:return e=Yi(e.type,!0),e;default:return""}}function Pl(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case hr:return"Fragment";case fr:return"Portal";case Cl:return"Profiler";case qo:return"StrictMode";case _l:return"Suspense";case El:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case df:return(e.displayName||"Context")+".Consumer";case cf:return(e._context.displayName||"Context")+".Provider";case Go:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Jo:return t=e.displayName||null,t!==null?t:Pl(e.type)||"Memo";case Xt:t=e._payload,e=e._init;try{return Pl(e(t))}catch{}}return null}function _p(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Pl(t);case 8:return t===qo?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function _n(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function hf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Ep(e){var t=hf(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,a=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(l){r=""+l,a.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function va(e){e._valueTracker||(e._valueTracker=Ep(e))}function mf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=hf(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Wa(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Tl(e,t){var n=t.checked;return fe({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function sc(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=_n(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function pf(e,t){t=t.checked,t!=null&&Wo(e,"checked",t,!1)}function Ol(e,t){pf(e,t);var n=_n(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ll(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ll(e,t.type,_n(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function ac(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ll(e,t,n){(t!=="number"||Wa(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var xs=Array.isArray;function Nr(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=xa.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Ls(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ws={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Pp=["Webkit","ms","Moz","O"];Object.keys(ws).forEach(function(e){Pp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ws[t]=ws[e]})});function gf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||ws.hasOwnProperty(e)&&ws[e]?(""+t).trim():t+"px"}function jf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=gf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var Tp=fe({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function zl(e,t){if(t){if(Tp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function Fl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Il=null;function Yo(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Dl=null,br=null,Cr=null;function oc(e){if(e=ua(e)){if(typeof Dl!="function")throw Error(E(280));var t=e.stateNode;t&&(t=_i(t),Dl(e.stateNode,e.type,t))}}function wf(e){br?Cr?Cr.push(e):Cr=[e]:br=e}function kf(){if(br){var e=br,t=Cr;if(Cr=br=null,oc(e),t)for(e=0;e>>=0,e===0?32:31-(Up(e)/Bp|0)|0}var ya=64,ga=4194304;function ys(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Ya(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,a=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~s;o!==0?r=ys(o):(a&=l,a!==0&&(r=ys(a)))}else l=n&~s,l!==0?r=ys(l):a!==0&&(r=ys(a));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,a=t&-t,s>=a||s===16&&(a&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function la(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-yt(t),e[t]=n}function Hp(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Ss),xc=" ",yc=!1;function Bf(e,t){switch(e){case"keyup":return jv.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Qf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var mr=!1;function kv(e,t){switch(e){case"compositionend":return Qf(t);case"keypress":return t.which!==32?null:(yc=!0,xc);case"textInput":return e=t.data,e===xc&&yc?null:e;default:return null}}function Sv(e,t){if(mr)return e==="compositionend"||!au&&Bf(e,t)?(e=$f(),Ia=nu=fn=null,mr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=kc(n)}}function Wf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Wf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function qf(){for(var e=window,t=Wa();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Wa(e.document)}return t}function iu(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Lv(e){var t=qf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Wf(n.ownerDocument.documentElement,n)){if(r!==null&&iu(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,a=Math.min(r.start,s);r=r.end===void 0?a:Math.min(r.end,s),!e.extend&&a>r&&(s=r,r=a,a=s),s=Sc(n,a);var l=Sc(n,r);s&&l&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),a>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,pr=null,Vl=null,bs=null,Kl=!1;function Nc(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Kl||pr==null||pr!==Wa(r)||(r=pr,"selectionStart"in r&&iu(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),bs&&Ds(bs,r)||(bs=r,r=ei(Vl,"onSelect"),0yr||(e.current=Yl[yr],Yl[yr]=null,yr--)}function ie(e,t){yr++,Yl[yr]=e.current,e.current=t}var En={},Fe=Tn(En),We=Tn(!1),Yn=En;function Vr(e,t){var n=e.type.contextTypes;if(!n)return En;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},a;for(a in n)s[a]=t[a];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function qe(e){return e=e.childContextTypes,e!=null}function ni(){oe(We),oe(Fe)}function Oc(e,t,n){if(Fe.current!==En)throw Error(E(168));ie(Fe,t),ie(We,n)}function rh(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(E(108,_p(e)||"Unknown",s));return fe({},n,r)}function ri(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||En,Yn=Fe.current,ie(Fe,e),ie(We,We.current),!0}function Lc(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=rh(e,t,Yn),r.__reactInternalMemoizedMergedChildContext=e,oe(We),oe(Fe),ie(Fe,e)):oe(We),ie(We,n)}var Rt=null,Ei=!1,dl=!1;function sh(e){Rt===null?Rt=[e]:Rt.push(e)}function Vv(e){Ei=!0,sh(e)}function On(){if(!dl&&Rt!==null){dl=!0;var e=0,t=ae;try{var n=Rt;for(ae=1;e>=l,s-=l,Dt=1<<32-yt(t)+s|n<_?(F=N,N=null):F=N.sibling;var O=p(m,N,v[_],j);if(O===null){N===null&&(N=F);break}e&&N&&O.alternate===null&&t(m,N),f=a(O,f,_),b===null?C=O:b.sibling=O,b=O,N=F}if(_===v.length)return n(m,N),ue&&Rn(m,_),C;if(N===null){for(;__?(F=N,N=null):F=N.sibling;var B=p(m,N,O.value,j);if(B===null){N===null&&(N=F);break}e&&N&&B.alternate===null&&t(m,N),f=a(B,f,_),b===null?C=B:b.sibling=B,b=B,N=F}if(O.done)return n(m,N),ue&&Rn(m,_),C;if(N===null){for(;!O.done;_++,O=v.next())O=c(m,O.value,j),O!==null&&(f=a(O,f,_),b===null?C=O:b.sibling=O,b=O);return ue&&Rn(m,_),C}for(N=r(m,N);!O.done;_++,O=v.next())O=x(N,m,_,O.value,j),O!==null&&(e&&O.alternate!==null&&N.delete(O.key===null?_:O.key),f=a(O,f,_),b===null?C=O:b.sibling=O,b=O);return e&&N.forEach(function(G){return t(m,G)}),ue&&Rn(m,_),C}function S(m,f,v,j){if(typeof v=="object"&&v!==null&&v.type===hr&&v.key===null&&(v=v.props.children),typeof v=="object"&&v!==null){switch(v.$$typeof){case pa:e:{for(var C=v.key,b=f;b!==null;){if(b.key===C){if(C=v.type,C===hr){if(b.tag===7){n(m,b.sibling),f=s(b,v.props.children),f.return=m,m=f;break e}}else if(b.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Xt&&zc(C)===b.type){n(m,b.sibling),f=s(b,v.props),f.ref=fs(m,b,v),f.return=m,m=f;break e}n(m,b);break}else t(m,b);b=b.sibling}v.type===hr?(f=Gn(v.props.children,m.mode,j,v.key),f.return=m,m=f):(j=Ka(v.type,v.key,v.props,null,m.mode,j),j.ref=fs(m,f,v),j.return=m,m=j)}return l(m);case fr:e:{for(b=v.key;f!==null;){if(f.key===b)if(f.tag===4&&f.stateNode.containerInfo===v.containerInfo&&f.stateNode.implementation===v.implementation){n(m,f.sibling),f=s(f,v.children||[]),f.return=m,m=f;break e}else{n(m,f);break}else t(m,f);f=f.sibling}f=gl(v,m.mode,j),f.return=m,m=f}return l(m);case Xt:return b=v._init,S(m,f,b(v._payload),j)}if(xs(v))return k(m,f,v,j);if(ls(v))return g(m,f,v,j);Ca(m,v)}return typeof v=="string"&&v!==""||typeof v=="number"?(v=""+v,f!==null&&f.tag===6?(n(m,f.sibling),f=s(f,v),f.return=m,m=f):(n(m,f),f=yl(v,m.mode,j),f.return=m,m=f),l(m)):n(m,f)}return S}var Hr=oh(!0),uh=oh(!1),ii=Tn(null),li=null,wr=null,cu=null;function du(){cu=wr=li=null}function fu(e){var t=ii.current;oe(ii),e._currentValue=t}function eo(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Er(e,t){li=e,cu=wr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(He=!0),e.firstContext=null)}function ut(e){var t=e._currentValue;if(cu!==e)if(e={context:e,memoizedValue:t,next:null},wr===null){if(li===null)throw Error(E(308));wr=e,li.dependencies={lanes:0,firstContext:e}}else wr=wr.next=e;return t}var Fn=null;function hu(e){Fn===null?Fn=[e]:Fn.push(e)}function ch(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,hu(t)):(n.next=s.next,s.next=n),t.interleaved=n,Kt(e,r)}function Kt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Zt=!1;function mu(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function dh(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function $t(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function wn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ne&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Kt(e,n)}return s=r.interleaved,s===null?(t.next=t,hu(r)):(t.next=s.next,s.next=t),r.interleaved=t,Kt(e,n)}function Aa(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Zo(e,n)}}function Fc(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};a===null?s=a=l:a=a.next=l,n=n.next}while(n!==null);a===null?s=a=t:a=a.next=t}else s=a=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:a,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function oi(e,t,n,r){var s=e.updateQueue;Zt=!1;var a=s.firstBaseUpdate,l=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var u=o,d=u.next;u.next=null,l===null?a=d:l.next=d,l=u;var h=e.alternate;h!==null&&(h=h.updateQueue,o=h.lastBaseUpdate,o!==l&&(o===null?h.firstBaseUpdate=d:o.next=d,h.lastBaseUpdate=u))}if(a!==null){var c=s.baseState;l=0,h=d=u=null,o=a;do{var p=o.lane,x=o.eventTime;if((r&p)===p){h!==null&&(h=h.next={eventTime:x,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var k=e,g=o;switch(p=t,x=n,g.tag){case 1:if(k=g.payload,typeof k=="function"){c=k.call(x,c,p);break e}c=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=g.payload,p=typeof k=="function"?k.call(x,c,p):k,p==null)break e;c=fe({},c,p);break e;case 2:Zt=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[o]:p.push(o))}else x={eventTime:x,lane:p,tag:o.tag,payload:o.payload,callback:o.callback,next:null},h===null?(d=h=x,u=c):h=h.next=x,l|=p;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;p=o,o=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(h===null&&(u=c),s.baseState=u,s.firstBaseUpdate=d,s.lastBaseUpdate=h,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else a===null&&(s.shared.lanes=0);er|=l,e.lanes=l,e.memoizedState=c}}function Ic(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=hl.transition;hl.transition={};try{e(!1),t()}finally{ae=n,hl.transition=r}}function Eh(){return ct().memoizedState}function qv(e,t,n){var r=Sn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Ph(e))Th(t,n);else if(n=ch(e,t,n,r),n!==null){var s=$e();gt(n,e,r,s),Oh(n,t,r)}}function Gv(e,t,n){var r=Sn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ph(e))Th(t,s);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var l=t.lastRenderedState,o=a(l,n);if(s.hasEagerState=!0,s.eagerState=o,jt(o,l)){var u=t.interleaved;u===null?(s.next=s,hu(t)):(s.next=u.next,u.next=s),t.interleaved=s;return}}catch{}finally{}n=ch(e,t,s,r),n!==null&&(s=$e(),gt(n,e,r,s),Oh(n,t,r))}}function Ph(e){var t=e.alternate;return e===de||t!==null&&t===de}function Th(e,t){Cs=ci=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Oh(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Zo(e,n)}}var di={readContext:ut,useCallback:Le,useContext:Le,useEffect:Le,useImperativeHandle:Le,useInsertionEffect:Le,useLayoutEffect:Le,useMemo:Le,useReducer:Le,useRef:Le,useState:Le,useDebugValue:Le,useDeferredValue:Le,useTransition:Le,useMutableSource:Le,useSyncExternalStore:Le,useId:Le,unstable_isNewReconciler:!1},Jv={readContext:ut,useCallback:function(e,t){return St().memoizedState=[e,t===void 0?null:t],e},useContext:ut,useEffect:Ac,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Ua(4194308,4,Sh.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Ua(4194308,4,e,t)},useInsertionEffect:function(e,t){return Ua(4,2,e,t)},useMemo:function(e,t){var n=St();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=St();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=qv.bind(null,de,e),[r.memoizedState,e]},useRef:function(e){var t=St();return e={current:e},t.memoizedState=e},useState:Dc,useDebugValue:ku,useDeferredValue:function(e){return St().memoizedState=e},useTransition:function(){var e=Dc(!1),t=e[0];return e=Wv.bind(null,e[1]),St().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=de,s=St();if(ue){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),Ee===null)throw Error(E(349));Zn&30||ph(r,t,n)}s.memoizedState=n;var a={value:n,getSnapshot:t};return s.queue=a,Ac(xh.bind(null,r,a,e),[e]),r.flags|=2048,Hs(9,vh.bind(null,r,a,n,t),void 0,null),n},useId:function(){var e=St(),t=Ee.identifierPrefix;if(ue){var n=At,r=Dt;n=(r&~(1<<32-yt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Vs++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[_t]=t,e[Us]=r,Uh(e,t,!1,!1),t.stateNode=e;e:{switch(l=Fl(n,r),n){case"dialog":le("cancel",e),le("close",e),s=r;break;case"iframe":case"object":case"embed":le("load",e),s=r;break;case"video":case"audio":for(s=0;sGr&&(t.flags|=128,r=!0,hs(a,!1),t.lanes=4194304)}else{if(!r)if(e=ui(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),hs(a,!0),a.tail===null&&a.tailMode==="hidden"&&!l.alternate&&!ue)return Re(t),null}else 2*ge()-a.renderingStartTime>Gr&&n!==1073741824&&(t.flags|=128,r=!0,hs(a,!1),t.lanes=4194304);a.isBackwards?(l.sibling=t.child,t.child=l):(n=a.last,n!==null?n.sibling=l:t.child=l,a.last=l)}return a.tail!==null?(t=a.tail,a.rendering=t,a.tail=t.sibling,a.renderingStartTime=ge(),t.sibling=null,n=ce.current,ie(ce,r?n&1|2:n&1),t):(Re(t),null);case 22:case 23:return Eu(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ye&1073741824&&(Re(t),t.subtreeFlags&6&&(t.flags|=8192)):Re(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function sx(e,t){switch(ou(t),t.tag){case 1:return qe(t.type)&&ni(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Wr(),oe(We),oe(Fe),xu(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return vu(t),null;case 13:if(oe(ce),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));Kr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return oe(ce),null;case 4:return Wr(),null;case 10:return fu(t.type._context),null;case 22:case 23:return Eu(),null;case 24:return null;default:return null}}var Ea=!1,ze=!1,ax=typeof WeakSet=="function"?WeakSet:Set,I=null;function kr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ve(e,t,r)}else n.current=null}function uo(e,t,n){try{n()}catch(r){ve(e,t,r)}}var Jc=!1;function ix(e,t){if(Hl=Xa,e=qf(),iu(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break e}var l=0,o=-1,u=-1,d=0,h=0,c=e,p=null;t:for(;;){for(var x;c!==n||s!==0&&c.nodeType!==3||(o=l+s),c!==a||r!==0&&c.nodeType!==3||(u=l+r),c.nodeType===3&&(l+=c.nodeValue.length),(x=c.firstChild)!==null;)p=c,c=x;for(;;){if(c===e)break t;if(p===n&&++d===s&&(o=l),p===a&&++h===r&&(u=l),(x=c.nextSibling)!==null)break;c=p,p=c.parentNode}c=x}n=o===-1||u===-1?null:{start:o,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(Wl={focusedElem:e,selectionRange:n},Xa=!1,I=t;I!==null;)if(t=I,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,I=e;else for(;I!==null;){t=I;try{var k=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(k!==null){var g=k.memoizedProps,S=k.memoizedState,m=t.stateNode,f=m.getSnapshotBeforeUpdate(t.elementType===t.type?g:ht(t.type,g),S);m.__reactInternalSnapshotBeforeUpdate=f}break;case 3:var v=t.stateNode.containerInfo;v.nodeType===1?v.textContent="":v.nodeType===9&&v.documentElement&&v.removeChild(v.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(j){ve(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,I=e;break}I=t.return}return k=Jc,Jc=!1,k}function _s(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var a=s.destroy;s.destroy=void 0,a!==void 0&&uo(t,n,a)}s=s.next}while(s!==r)}}function Oi(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function co(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Vh(e){var t=e.alternate;t!==null&&(e.alternate=null,Vh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[_t],delete t[Us],delete t[Jl],delete t[Bv],delete t[Qv])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Kh(e){return e.tag===5||e.tag===3||e.tag===4}function Yc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Kh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function fo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ti));else if(r!==4&&(e=e.child,e!==null))for(fo(e,t,n),e=e.sibling;e!==null;)fo(e,t,n),e=e.sibling}function ho(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(ho(e,t,n),e=e.sibling;e!==null;)ho(e,t,n),e=e.sibling}var Pe=null,vt=!1;function Jt(e,t,n){for(n=n.child;n!==null;)Hh(e,t,n),n=n.sibling}function Hh(e,t,n){if(Pt&&typeof Pt.onCommitFiberUnmount=="function")try{Pt.onCommitFiberUnmount(Si,n)}catch{}switch(n.tag){case 5:ze||kr(n,t);case 6:var r=Pe,s=vt;Pe=null,Jt(e,t,n),Pe=r,vt=s,Pe!==null&&(vt?(e=Pe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Pe.removeChild(n.stateNode));break;case 18:Pe!==null&&(vt?(e=Pe,n=n.stateNode,e.nodeType===8?cl(e.parentNode,n):e.nodeType===1&&cl(e,n),Fs(e)):cl(Pe,n.stateNode));break;case 4:r=Pe,s=vt,Pe=n.stateNode.containerInfo,vt=!0,Jt(e,t,n),Pe=r,vt=s;break;case 0:case 11:case 14:case 15:if(!ze&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var a=s,l=a.destroy;a=a.tag,l!==void 0&&(a&2||a&4)&&uo(n,t,l),s=s.next}while(s!==r)}Jt(e,t,n);break;case 1:if(!ze&&(kr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){ve(n,t,o)}Jt(e,t,n);break;case 21:Jt(e,t,n);break;case 22:n.mode&1?(ze=(r=ze)||n.memoizedState!==null,Jt(e,t,n),ze=r):Jt(e,t,n);break;default:Jt(e,t,n)}}function Xc(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new ax),t.forEach(function(r){var s=px.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function ft(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=l),r&=~a}if(r=s,r=ge()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*ox(r/1960))-r,10e?16:e,hn===null)var r=!1;else{if(e=hn,hn=null,mi=0,ne&6)throw Error(E(331));var s=ne;for(ne|=4,I=e.current;I!==null;){var a=I,l=a.child;if(I.flags&16){var o=a.deletions;if(o!==null){for(var u=0;uge()-Cu?qn(e,0):bu|=n),Ge(e,t)}function em(e,t){t===0&&(e.mode&1?(t=ga,ga<<=1,!(ga&130023424)&&(ga=4194304)):t=1);var n=$e();e=Kt(e,t),e!==null&&(la(e,t,n),Ge(e,n))}function mx(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),em(e,n)}function px(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),em(e,n)}var tm;tm=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||We.current)He=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return He=!1,nx(e,t,n);He=!!(e.flags&131072)}else He=!1,ue&&t.flags&1048576&&ah(t,ai,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ba(e,t),e=t.pendingProps;var s=Vr(t,Fe.current);Er(t,n),s=gu(null,t,r,e,s,n);var a=ju();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,qe(r)?(a=!0,ri(t)):a=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,mu(t),s.updater=Ti,t.stateNode=s,s._reactInternals=t,no(t,r,e,n),t=ao(null,t,r,!0,a,n)):(t.tag=0,ue&&a&&lu(t),De(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ba(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=xx(r),e=ht(r,e),s){case 0:t=so(null,t,r,e,n);break e;case 1:t=Wc(null,t,r,e,n);break e;case 11:t=Kc(null,t,r,e,n);break e;case 14:t=Hc(null,t,r,ht(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ht(r,s),so(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ht(r,s),Wc(e,t,r,s,n);case 3:e:{if(Dh(t),e===null)throw Error(E(387));r=t.pendingProps,a=t.memoizedState,s=a.element,dh(e,t),oi(t,r,null,n);var l=t.memoizedState;if(r=l.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){s=qr(Error(E(423)),t),t=qc(e,t,r,n,s);break e}else if(r!==s){s=qr(Error(E(424)),t),t=qc(e,t,r,n,s);break e}else for(Xe=jn(t.stateNode.containerInfo.firstChild),Ze=t,ue=!0,xt=null,n=uh(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Kr(),r===s){t=Ht(e,t,n);break e}De(e,t,r,n)}t=t.child}return t;case 5:return fh(t),e===null&&Zl(t),r=t.type,s=t.pendingProps,a=e!==null?e.memoizedProps:null,l=s.children,ql(r,s)?l=null:a!==null&&ql(r,a)&&(t.flags|=32),Ih(e,t),De(e,t,l,n),t.child;case 6:return e===null&&Zl(t),null;case 13:return Ah(e,t,n);case 4:return pu(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Hr(t,null,r,n):De(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ht(r,s),Kc(e,t,r,s,n);case 7:return De(e,t,t.pendingProps,n),t.child;case 8:return De(e,t,t.pendingProps.children,n),t.child;case 12:return De(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,a=t.memoizedProps,l=s.value,ie(ii,r._currentValue),r._currentValue=l,a!==null)if(jt(a.value,l)){if(a.children===s.children&&!We.current){t=Ht(e,t,n);break e}}else for(a=t.child,a!==null&&(a.return=t);a!==null;){var o=a.dependencies;if(o!==null){l=a.child;for(var u=o.firstContext;u!==null;){if(u.context===r){if(a.tag===1){u=$t(-1,n&-n),u.tag=2;var d=a.updateQueue;if(d!==null){d=d.shared;var h=d.pending;h===null?u.next=u:(u.next=h.next,h.next=u),d.pending=u}}a.lanes|=n,u=a.alternate,u!==null&&(u.lanes|=n),eo(a.return,n,t),o.lanes|=n;break}u=u.next}}else if(a.tag===10)l=a.type===t.type?null:a.child;else if(a.tag===18){if(l=a.return,l===null)throw Error(E(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),eo(l,n,t),l=a.sibling}else l=a.child;if(l!==null)l.return=a;else for(l=a;l!==null;){if(l===t){l=null;break}if(a=l.sibling,a!==null){a.return=l.return,l=a;break}l=l.return}a=l}De(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,Er(t,n),s=ut(s),r=r(s),t.flags|=1,De(e,t,r,n),t.child;case 14:return r=t.type,s=ht(r,t.pendingProps),s=ht(r.type,s),Hc(e,t,r,s,n);case 15:return zh(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:ht(r,s),Ba(e,t),t.tag=1,qe(r)?(e=!0,ri(t)):e=!1,Er(t,n),Lh(t,r,s),no(t,r,s,n),ao(null,t,r,!0,e,n);case 19:return $h(e,t,n);case 22:return Fh(e,t,n)}throw Error(E(156,t.tag))};function nm(e,t){return Pf(e,t)}function vx(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function lt(e,t,n,r){return new vx(e,t,n,r)}function Tu(e){return e=e.prototype,!(!e||!e.isReactComponent)}function xx(e){if(typeof e=="function")return Tu(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Go)return 11;if(e===Jo)return 14}return 2}function Nn(e,t){var n=e.alternate;return n===null?(n=lt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Ka(e,t,n,r,s,a){var l=2;if(r=e,typeof e=="function")Tu(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case hr:return Gn(n.children,s,a,t);case qo:l=8,s|=8;break;case Cl:return e=lt(12,n,t,s|2),e.elementType=Cl,e.lanes=a,e;case _l:return e=lt(13,n,t,s),e.elementType=_l,e.lanes=a,e;case El:return e=lt(19,n,t,s),e.elementType=El,e.lanes=a,e;case ff:return Ri(n,s,a,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case cf:l=10;break e;case df:l=9;break e;case Go:l=11;break e;case Jo:l=14;break e;case Xt:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=lt(l,n,t,s),t.elementType=e,t.type=r,t.lanes=a,t}function Gn(e,t,n,r){return e=lt(7,e,r,t),e.lanes=n,e}function Ri(e,t,n,r){return e=lt(22,e,r,t),e.elementType=ff,e.lanes=n,e.stateNode={isHidden:!1},e}function yl(e,t,n){return e=lt(6,e,null,t),e.lanes=n,e}function gl(e,t,n){return t=lt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function yx(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Zi(0),this.expirationTimes=Zi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Zi(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Ou(e,t,n,r,s,a,l,o,u){return e=new yx(e,t,n,o,u),t===1?(t=1,a===!0&&(t|=8)):t=0,a=lt(3,null,null,t),e.current=a,a.stateNode=e,a.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},mu(a),e}function gx(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(im)}catch(e){console.error(e)}}im(),af.exports=tt;var Nx=af.exports,id=Nx;Nl.createRoot=id.createRoot,Nl.hydrateRoot=id.hydrateRoot;var ts=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},bx={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},nn,Ao,Fd,Cx=(Fd=class{constructor(){$(this,nn,bx);$(this,Ao,!1)}setTimeoutProvider(e){z(this,nn,e)}setTimeout(e,t){return y(this,nn).setTimeout(e,t)}clearTimeout(e){y(this,nn).clearTimeout(e)}setInterval(e,t){return y(this,nn).setInterval(e,t)}clearInterval(e){y(this,nn).clearInterval(e)}},nn=new WeakMap,Ao=new WeakMap,Fd),Dn=new Cx;function _x(e){setTimeout(e,0)}var nr=typeof window>"u"||"Deno"in globalThis;function Ae(){}function Ex(e,t){return typeof e=="function"?e(t):e}function yo(e){return typeof e=="number"&&e>=0&&e!==1/0}function lm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function bn(e,t){return typeof e=="function"?e(t):e}function st(e,t){return typeof e=="function"?e(t):e}function ld(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:a,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==zu(l,t.options))return!1}else if(!qs(t.queryKey,l))return!1}if(n!=="all"){const u=t.isActive();if(n==="active"&&!u||n==="inactive"&&u)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||s&&s!==t.state.fetchStatus||a&&!a(t))}function od(e,t){const{exact:n,status:r,predicate:s,mutationKey:a}=e;if(a){if(!t.options.mutationKey)return!1;if(n){if(rr(t.options.mutationKey)!==rr(a))return!1}else if(!qs(t.options.mutationKey,a))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function zu(e,t){return((t==null?void 0:t.queryKeyHashFn)||rr)(e)}function rr(e){return JSON.stringify(e,(t,n)=>go(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function qs(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>qs(e[n],t[n])):!1}var Px=Object.prototype.hasOwnProperty;function om(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=ud(e)&&ud(t);if(!r&&!(go(e)&&go(t)))return t;const a=(r?e:Object.keys(e)).length,l=r?t:Object.keys(t),o=l.length,u=r?new Array(o):{};let d=0;for(let h=0;h{Dn.setTimeout(t,e)})}function jo(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?om(e,t):t}function Ox(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Lx(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Fu=Symbol();function um(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Fu?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Iu(e,t){return typeof e=="function"?e(...t):!!e}function Rx(e,t,n){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),e}var An,rn,Or,Id,Mx=(Id=class extends ts{constructor(){super();$(this,An);$(this,rn);$(this,Or);z(this,Or,t=>{if(!nr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){y(this,rn)||this.setEventListener(y(this,Or))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,rn))==null||t.call(this),z(this,rn,void 0))}setEventListener(t){var n;z(this,Or,t),(n=y(this,rn))==null||n.call(this),z(this,rn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){y(this,An)!==t&&(z(this,An,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof y(this,An)=="boolean"?y(this,An):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},An=new WeakMap,rn=new WeakMap,Or=new WeakMap,Id),Du=new Mx;function wo(){let e,t;const n=new Promise((s,a)=>{e=s,t=a});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var zx=_x;function Fx(){let e=[],t=0,n=o=>{o()},r=o=>{o()},s=zx;const a=o=>{t?e.push(o):s(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&s(()=>{r(()=>{o.forEach(u=>{n(u)})})})};return{batch:o=>{let u;t++;try{u=o()}finally{t--,t||l()}return u},batchCalls:o=>(...u)=>{a(()=>{o(...u)})},schedule:a,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{s=o}}}var Se=Fx(),Lr,sn,Rr,Dd,Ix=(Dd=class extends ts{constructor(){super();$(this,Lr,!0);$(this,sn);$(this,Rr);z(this,Rr,t=>{if(!nr&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){y(this,sn)||this.setEventListener(y(this,Rr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,sn))==null||t.call(this),z(this,sn,void 0))}setEventListener(t){var n;z(this,Rr,t),(n=y(this,sn))==null||n.call(this),z(this,sn,t(this.setOnline.bind(this)))}setOnline(t){y(this,Lr)!==t&&(z(this,Lr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return y(this,Lr)}},Lr=new WeakMap,sn=new WeakMap,Rr=new WeakMap,Dd),yi=new Ix;function Dx(e){return Math.min(1e3*2**e,3e4)}function cm(e){return(e??"online")==="online"?yi.isOnline():!0}var ko=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function dm(e){let t=!1,n=0,r;const s=wo(),a=()=>s.status!=="pending",l=g=>{var S;if(!a()){const m=new ko(g);p(m),(S=e.onCancel)==null||S.call(e,m)}},o=()=>{t=!0},u=()=>{t=!1},d=()=>Du.isFocused()&&(e.networkMode==="always"||yi.isOnline())&&e.canRun(),h=()=>cm(e.networkMode)&&e.canRun(),c=g=>{a()||(r==null||r(),s.resolve(g))},p=g=>{a()||(r==null||r(),s.reject(g))},x=()=>new Promise(g=>{var S;r=m=>{(a()||d())&&g(m)},(S=e.onPause)==null||S.call(e)}).then(()=>{var g;r=void 0,a()||(g=e.onContinue)==null||g.call(e)}),k=()=>{if(a())return;let g;const S=n===0?e.initialPromise:void 0;try{g=S??e.fn()}catch(m){g=Promise.reject(m)}Promise.resolve(g).then(c).catch(m=>{var b;if(a())return;const f=e.retry??(nr?0:3),v=e.retryDelay??Dx,j=typeof v=="function"?v(n,m):v,C=f===!0||typeof f=="number"&&nd()?void 0:x()).then(()=>{t?p(m):k()})})};return{promise:s,status:()=>s.status,cancel:l,continue:()=>(r==null||r(),s),cancelRetry:o,continueRetry:u,canStart:h,start:()=>(h()?k():x().then(k),s)}}var $n,Ad,fm=(Ad=class{constructor(){$(this,$n)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),yo(this.gcTime)&&z(this,$n,Dn.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(nr?1/0:5*60*1e3))}clearGcTimeout(){y(this,$n)&&(Dn.clearTimeout(y(this,$n)),z(this,$n,void 0))}},$n=new WeakMap,Ad),Un,Mr,rt,Bn,Ce,ta,Qn,mt,Ot,$d,Ax=($d=class extends fm{constructor(t){super();$(this,mt);$(this,Un);$(this,Mr);$(this,rt);$(this,Bn);$(this,Ce);$(this,ta);$(this,Qn);z(this,Qn,!1),z(this,ta,t.defaultOptions),this.setOptions(t.options),this.observers=[],z(this,Bn,t.client),z(this,rt,y(this,Bn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,z(this,Un,fd(this.options)),this.state=t.state??y(this,Un),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=y(this,Ce))==null?void 0:t.promise}setOptions(t){if(this.options={...y(this,ta),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=fd(this.options);n.data!==void 0&&(this.setState(dd(n.data,n.dataUpdatedAt)),z(this,Un,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&y(this,rt).remove(this)}setData(t,n){const r=jo(this.state.data,t,this.options);return H(this,mt,Ot).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){H(this,mt,Ot).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=y(this,Ce))==null?void 0:r.promise;return(s=y(this,Ce))==null||s.cancel(t),n?n.then(Ae).catch(Ae):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(y(this,Un))}isActive(){return this.observers.some(t=>st(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Fu||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>bn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!lm(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),y(this,rt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(y(this,Ce)&&(y(this,Qn)?y(this,Ce).cancel({revert:!0}):y(this,Ce).cancelRetry()),this.scheduleGc()),y(this,rt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||H(this,mt,Ot).call(this,{type:"invalidate"})}async fetch(t,n){var u,d,h,c,p,x,k,g,S,m,f,v;if(this.state.fetchStatus!=="idle"&&((u=y(this,Ce))==null?void 0:u.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(y(this,Ce))return y(this,Ce).continueRetry(),y(this,Ce).promise}if(t&&this.setOptions(t),!this.options.queryFn){const j=this.observers.find(C=>C.options.queryFn);j&&this.setOptions(j.options)}const r=new AbortController,s=j=>{Object.defineProperty(j,"signal",{enumerable:!0,get:()=>(z(this,Qn,!0),r.signal)})},a=()=>{const j=um(this.options,n),b=(()=>{const N={client:y(this,Bn),queryKey:this.queryKey,meta:this.meta};return s(N),N})();return z(this,Qn,!1),this.options.persister?this.options.persister(j,b,this):j(b)},o=(()=>{const j={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:y(this,Bn),state:this.state,fetchFn:a};return s(j),j})();(d=this.options.behavior)==null||d.onFetch(o,this),z(this,Mr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((h=o.fetchOptions)==null?void 0:h.meta))&&H(this,mt,Ot).call(this,{type:"fetch",meta:(c=o.fetchOptions)==null?void 0:c.meta}),z(this,Ce,dm({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:j=>{j instanceof ko&&j.revert&&this.setState({...y(this,Mr),fetchStatus:"idle"}),r.abort()},onFail:(j,C)=>{H(this,mt,Ot).call(this,{type:"failed",failureCount:j,error:C})},onPause:()=>{H(this,mt,Ot).call(this,{type:"pause"})},onContinue:()=>{H(this,mt,Ot).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const j=await y(this,Ce).start();if(j===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(j),(x=(p=y(this,rt).config).onSuccess)==null||x.call(p,j,this),(g=(k=y(this,rt).config).onSettled)==null||g.call(k,j,this.state.error,this),j}catch(j){if(j instanceof ko){if(j.silent)return y(this,Ce).promise;if(j.revert){if(this.state.data===void 0)throw j;return this.state.data}}throw H(this,mt,Ot).call(this,{type:"error",error:j}),(m=(S=y(this,rt).config).onError)==null||m.call(S,j,this),(v=(f=y(this,rt).config).onSettled)==null||v.call(f,this.state.data,j,this),j}finally{this.scheduleGc()}}},Un=new WeakMap,Mr=new WeakMap,rt=new WeakMap,Bn=new WeakMap,Ce=new WeakMap,ta=new WeakMap,Qn=new WeakMap,mt=new WeakSet,Ot=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...hm(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...dd(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return z(this,Mr,t.manual?s:void 0),s;case"error":const a=t.error;return{...r,error:a,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:a,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Se.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),y(this,rt).notify({query:this,type:"updated",action:t})})},$d);function hm(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:cm(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function dd(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function fd(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Qe,X,na,Ie,Vn,zr,Mt,an,ra,Fr,Ir,Kn,Hn,ln,Dr,se,js,So,No,bo,Co,_o,Eo,Po,mm,Ud,$x=(Ud=class extends ts{constructor(t,n){super();$(this,se);$(this,Qe);$(this,X);$(this,na);$(this,Ie);$(this,Vn);$(this,zr);$(this,Mt);$(this,an);$(this,ra);$(this,Fr);$(this,Ir);$(this,Kn);$(this,Hn);$(this,ln);$(this,Dr,new Set);this.options=n,z(this,Qe,t),z(this,an,null),z(this,Mt,wo()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(y(this,X).addObserver(this),hd(y(this,X),this.options)?H(this,se,js).call(this):this.updateResult(),H(this,se,Co).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return To(y(this,X),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return To(y(this,X),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,H(this,se,_o).call(this),H(this,se,Eo).call(this),y(this,X).removeObserver(this)}setOptions(t){const n=this.options,r=y(this,X);if(this.options=y(this,Qe).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof st(this.options.enabled,y(this,X))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");H(this,se,Po).call(this),y(this,X).setOptions(this.options),n._defaulted&&!xi(this.options,n)&&y(this,Qe).getQueryCache().notify({type:"observerOptionsUpdated",query:y(this,X),observer:this});const s=this.hasListeners();s&&md(y(this,X),r,this.options,n)&&H(this,se,js).call(this),this.updateResult(),s&&(y(this,X)!==r||st(this.options.enabled,y(this,X))!==st(n.enabled,y(this,X))||bn(this.options.staleTime,y(this,X))!==bn(n.staleTime,y(this,X)))&&H(this,se,So).call(this);const a=H(this,se,No).call(this);s&&(y(this,X)!==r||st(this.options.enabled,y(this,X))!==st(n.enabled,y(this,X))||a!==y(this,ln))&&H(this,se,bo).call(this,a)}getOptimisticResult(t){const n=y(this,Qe).getQueryCache().build(y(this,Qe),t),r=this.createResult(n,t);return Bx(this,r)&&(z(this,Ie,r),z(this,zr,this.options),z(this,Vn,y(this,X).state)),r}getCurrentResult(){return y(this,Ie)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&y(this,Mt).status==="pending"&&y(this,Mt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){y(this,Dr).add(t)}getCurrentQuery(){return y(this,X)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=y(this,Qe).defaultQueryOptions(t),r=y(this,Qe).getQueryCache().build(y(this,Qe),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return H(this,se,js).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),y(this,Ie)))}createResult(t,n){var F;const r=y(this,X),s=this.options,a=y(this,Ie),l=y(this,Vn),o=y(this,zr),d=t!==r?t.state:y(this,na),{state:h}=t;let c={...h},p=!1,x;if(n._optimisticResults){const O=this.hasListeners(),B=!O&&hd(t,n),G=O&&md(t,r,n,s);(B||G)&&(c={...c,...hm(h.data,t.options)}),n._optimisticResults==="isRestoring"&&(c.fetchStatus="idle")}let{error:k,errorUpdatedAt:g,status:S}=c;x=c.data;let m=!1;if(n.placeholderData!==void 0&&x===void 0&&S==="pending"){let O;a!=null&&a.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(O=a.data,m=!0):O=typeof n.placeholderData=="function"?n.placeholderData((F=y(this,Ir))==null?void 0:F.state.data,y(this,Ir)):n.placeholderData,O!==void 0&&(S="success",x=jo(a==null?void 0:a.data,O,n),p=!0)}if(n.select&&x!==void 0&&!m)if(a&&x===(l==null?void 0:l.data)&&n.select===y(this,ra))x=y(this,Fr);else try{z(this,ra,n.select),x=n.select(x),x=jo(a==null?void 0:a.data,x,n),z(this,Fr,x),z(this,an,null)}catch(O){z(this,an,O)}y(this,an)&&(k=y(this,an),x=y(this,Fr),g=Date.now(),S="error");const f=c.fetchStatus==="fetching",v=S==="pending",j=S==="error",C=v&&f,b=x!==void 0,_={status:S,fetchStatus:c.fetchStatus,isPending:v,isSuccess:S==="success",isError:j,isInitialLoading:C,isLoading:C,data:x,dataUpdatedAt:c.dataUpdatedAt,error:k,errorUpdatedAt:g,failureCount:c.fetchFailureCount,failureReason:c.fetchFailureReason,errorUpdateCount:c.errorUpdateCount,isFetched:c.dataUpdateCount>0||c.errorUpdateCount>0,isFetchedAfterMount:c.dataUpdateCount>d.dataUpdateCount||c.errorUpdateCount>d.errorUpdateCount,isFetching:f,isRefetching:f&&!v,isLoadingError:j&&!b,isPaused:c.fetchStatus==="paused",isPlaceholderData:p,isRefetchError:j&&b,isStale:Au(t,n),refetch:this.refetch,promise:y(this,Mt),isEnabled:st(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=_.data!==void 0,B=_.status==="error"&&!O,G=D=>{B?D.reject(_.error):O&&D.resolve(_.data)},re=()=>{const D=z(this,Mt,_.promise=wo());G(D)},he=y(this,Mt);switch(he.status){case"pending":t.queryHash===r.queryHash&&G(he);break;case"fulfilled":(B||_.data!==he.value)&&re();break;case"rejected":(!B||_.error!==he.reason)&&re();break}}return _}updateResult(){const t=y(this,Ie),n=this.createResult(y(this,X),this.options);if(z(this,Vn,y(this,X).state),z(this,zr,this.options),y(this,Vn).data!==void 0&&z(this,Ir,y(this,X)),xi(n,t))return;z(this,Ie,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,a=typeof s=="function"?s():s;if(a==="all"||!a&&!y(this,Dr).size)return!0;const l=new Set(a??y(this,Dr));return this.options.throwOnError&&l.add("error"),Object.keys(y(this,Ie)).some(o=>{const u=o;return y(this,Ie)[u]!==t[u]&&l.has(u)})};H(this,se,mm).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&H(this,se,Co).call(this)}},Qe=new WeakMap,X=new WeakMap,na=new WeakMap,Ie=new WeakMap,Vn=new WeakMap,zr=new WeakMap,Mt=new WeakMap,an=new WeakMap,ra=new WeakMap,Fr=new WeakMap,Ir=new WeakMap,Kn=new WeakMap,Hn=new WeakMap,ln=new WeakMap,Dr=new WeakMap,se=new WeakSet,js=function(t){H(this,se,Po).call(this);let n=y(this,X).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Ae)),n},So=function(){H(this,se,_o).call(this);const t=bn(this.options.staleTime,y(this,X));if(nr||y(this,Ie).isStale||!yo(t))return;const r=lm(y(this,Ie).dataUpdatedAt,t)+1;z(this,Kn,Dn.setTimeout(()=>{y(this,Ie).isStale||this.updateResult()},r))},No=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(y(this,X)):this.options.refetchInterval)??!1},bo=function(t){H(this,se,Eo).call(this),z(this,ln,t),!(nr||st(this.options.enabled,y(this,X))===!1||!yo(y(this,ln))||y(this,ln)===0)&&z(this,Hn,Dn.setInterval(()=>{(this.options.refetchIntervalInBackground||Du.isFocused())&&H(this,se,js).call(this)},y(this,ln)))},Co=function(){H(this,se,So).call(this),H(this,se,bo).call(this,H(this,se,No).call(this))},_o=function(){y(this,Kn)&&(Dn.clearTimeout(y(this,Kn)),z(this,Kn,void 0))},Eo=function(){y(this,Hn)&&(Dn.clearInterval(y(this,Hn)),z(this,Hn,void 0))},Po=function(){const t=y(this,Qe).getQueryCache().build(y(this,Qe),this.options);if(t===y(this,X))return;const n=y(this,X);z(this,X,t),z(this,na,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},mm=function(t){Se.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(y(this,Ie))}),y(this,Qe).getQueryCache().notify({query:y(this,X),type:"observerResultsUpdated"})})},Ud);function Ux(e,t){return st(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function hd(e,t){return Ux(e,t)||e.state.data!==void 0&&To(e,t,t.refetchOnMount)}function To(e,t,n){if(st(t.enabled,e)!==!1&&bn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Au(e,t)}return!1}function md(e,t,n,r){return(e!==t||st(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Au(e,n)}function Au(e,t){return st(t.enabled,e)!==!1&&e.isStaleByTime(bn(t.staleTime,e))}function Bx(e,t){return!xi(e.getCurrentResult(),t)}function pd(e){return{onFetch:(t,n)=>{var h,c,p,x,k;const r=t.options,s=(p=(c=(h=t.fetchOptions)==null?void 0:h.meta)==null?void 0:c.fetchMore)==null?void 0:p.direction,a=((x=t.state.data)==null?void 0:x.pages)||[],l=((k=t.state.data)==null?void 0:k.pageParams)||[];let o={pages:[],pageParams:[]},u=0;const d=async()=>{let g=!1;const S=v=>{Rx(v,()=>t.signal,()=>g=!0)},m=um(t.options,t.fetchOptions),f=async(v,j,C)=>{if(g)return Promise.reject();if(j==null&&v.pages.length)return Promise.resolve(v);const N=(()=>{const B={client:t.client,queryKey:t.queryKey,pageParam:j,direction:C?"backward":"forward",meta:t.options.meta};return S(B),B})(),_=await m(N),{maxPages:F}=t.options,O=C?Lx:Ox;return{pages:O(v.pages,_,F),pageParams:O(v.pageParams,j,F)}};if(s&&a.length){const v=s==="backward",j=v?Qx:vd,C={pages:a,pageParams:l},b=j(r,C);o=await f(C,b,v)}else{const v=e??a.length;do{const j=u===0?l[0]??r.initialPageParam:vd(r,o);if(u>0&&j==null)break;o=await f(o,j),u++}while(u{var g,S;return(S=(g=t.options).persister)==null?void 0:S.call(g,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=d}}}function vd(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Qx(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var sa,Nt,Me,Wn,bt,Yt,Bd,Vx=(Bd=class extends fm{constructor(t){super();$(this,bt);$(this,sa);$(this,Nt);$(this,Me);$(this,Wn);z(this,sa,t.client),this.mutationId=t.mutationId,z(this,Me,t.mutationCache),z(this,Nt,[]),this.state=t.state||pm(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){y(this,Nt).includes(t)||(y(this,Nt).push(t),this.clearGcTimeout(),y(this,Me).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){z(this,Nt,y(this,Nt).filter(n=>n!==t)),this.scheduleGc(),y(this,Me).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){y(this,Nt).length||(this.state.status==="pending"?this.scheduleGc():y(this,Me).remove(this))}continue(){var t;return((t=y(this,Wn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,u,d,h,c,p,x,k,g,S,m,f,v,j,C,b,N;const n=()=>{H(this,bt,Yt).call(this,{type:"continue"})},r={client:y(this,sa),meta:this.options.meta,mutationKey:this.options.mutationKey};z(this,Wn,dm({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(_,F)=>{H(this,bt,Yt).call(this,{type:"failed",failureCount:_,error:F})},onPause:()=>{H(this,bt,Yt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>y(this,Me).canRun(this)}));const s=this.state.status==="pending",a=!y(this,Wn).canStart();try{if(s)n();else{H(this,bt,Yt).call(this,{type:"pending",variables:t,isPaused:a}),y(this,Me).config.onMutate&&await y(this,Me).config.onMutate(t,this,r);const F=await((o=(l=this.options).onMutate)==null?void 0:o.call(l,t,r));F!==this.state.context&&H(this,bt,Yt).call(this,{type:"pending",context:F,variables:t,isPaused:a})}const _=await y(this,Wn).start();return await((d=(u=y(this,Me).config).onSuccess)==null?void 0:d.call(u,_,t,this.state.context,this,r)),await((c=(h=this.options).onSuccess)==null?void 0:c.call(h,_,t,this.state.context,r)),await((x=(p=y(this,Me).config).onSettled)==null?void 0:x.call(p,_,null,this.state.variables,this.state.context,this,r)),await((g=(k=this.options).onSettled)==null?void 0:g.call(k,_,null,t,this.state.context,r)),H(this,bt,Yt).call(this,{type:"success",data:_}),_}catch(_){try{await((m=(S=y(this,Me).config).onError)==null?void 0:m.call(S,_,t,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((v=(f=this.options).onError)==null?void 0:v.call(f,_,t,this.state.context,r))}catch(F){Promise.reject(F)}try{await((C=(j=y(this,Me).config).onSettled)==null?void 0:C.call(j,void 0,_,this.state.variables,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((N=(b=this.options).onSettled)==null?void 0:N.call(b,void 0,_,t,this.state.context,r))}catch(F){Promise.reject(F)}throw H(this,bt,Yt).call(this,{type:"error",error:_}),_}finally{y(this,Me).runNext(this)}}},sa=new WeakMap,Nt=new WeakMap,Me=new WeakMap,Wn=new WeakMap,bt=new WeakSet,Yt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Se.batch(()=>{y(this,Nt).forEach(r=>{r.onMutationUpdate(t)}),y(this,Me).notify({mutation:this,type:"updated",action:t})})},Bd);function pm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var zt,pt,aa,Qd,Kx=(Qd=class extends ts{constructor(t={}){super();$(this,zt);$(this,pt);$(this,aa);this.config=t,z(this,zt,new Set),z(this,pt,new Map),z(this,aa,0)}build(t,n,r){const s=new Vx({client:t,mutationCache:this,mutationId:++ha(this,aa)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){y(this,zt).add(t);const n=Oa(t);if(typeof n=="string"){const r=y(this,pt).get(n);r?r.push(t):y(this,pt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(y(this,zt).delete(t)){const n=Oa(t);if(typeof n=="string"){const r=y(this,pt).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&y(this,pt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Oa(t);if(typeof n=="string"){const r=y(this,pt).get(n),s=r==null?void 0:r.find(a=>a.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=Oa(t);if(typeof n=="string"){const s=(r=y(this,pt).get(n))==null?void 0:r.find(a=>a!==t&&a.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Se.batch(()=>{y(this,zt).forEach(t=>{this.notify({type:"removed",mutation:t})}),y(this,zt).clear(),y(this,pt).clear()})}getAll(){return Array.from(y(this,zt))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>od(n,r))}findAll(t={}){return this.getAll().filter(n=>od(t,n))}notify(t){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Se.batch(()=>Promise.all(t.map(n=>n.continue().catch(Ae))))}},zt=new WeakMap,pt=new WeakMap,aa=new WeakMap,Qd);function Oa(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Ft,on,Ve,It,Bt,Ha,Oo,Vd,Hx=(Vd=class extends ts{constructor(n,r){super();$(this,Bt);$(this,Ft);$(this,on);$(this,Ve);$(this,It);z(this,Ft,n),this.setOptions(r),this.bindMethods(),H(this,Bt,Ha).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=y(this,Ft).defaultMutationOptions(n),xi(this.options,r)||y(this,Ft).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,Ve),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&rr(r.mutationKey)!==rr(this.options.mutationKey)?this.reset():((s=y(this,Ve))==null?void 0:s.state.status)==="pending"&&y(this,Ve).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=y(this,Ve))==null||n.removeObserver(this)}onMutationUpdate(n){H(this,Bt,Ha).call(this),H(this,Bt,Oo).call(this,n)}getCurrentResult(){return y(this,on)}reset(){var n;(n=y(this,Ve))==null||n.removeObserver(this),z(this,Ve,void 0),H(this,Bt,Ha).call(this),H(this,Bt,Oo).call(this)}mutate(n,r){var s;return z(this,It,r),(s=y(this,Ve))==null||s.removeObserver(this),z(this,Ve,y(this,Ft).getMutationCache().build(y(this,Ft),this.options)),y(this,Ve).addObserver(this),y(this,Ve).execute(n)}},Ft=new WeakMap,on=new WeakMap,Ve=new WeakMap,It=new WeakMap,Bt=new WeakSet,Ha=function(){var r;const n=((r=y(this,Ve))==null?void 0:r.state)??pm();z(this,on,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Oo=function(n){Se.batch(()=>{var r,s,a,l,o,u,d,h;if(y(this,It)&&this.hasListeners()){const c=y(this,on).variables,p=y(this,on).context,x={client:y(this,Ft),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(s=(r=y(this,It)).onSuccess)==null||s.call(r,n.data,c,p,x)}catch(k){Promise.reject(k)}try{(l=(a=y(this,It)).onSettled)==null||l.call(a,n.data,null,c,p,x)}catch(k){Promise.reject(k)}}else if((n==null?void 0:n.type)==="error"){try{(u=(o=y(this,It)).onError)==null||u.call(o,n.error,c,p,x)}catch(k){Promise.reject(k)}try{(h=(d=y(this,It)).onSettled)==null||h.call(d,void 0,n.error,c,p,x)}catch(k){Promise.reject(k)}}}this.listeners.forEach(c=>{c(y(this,on))})})},Vd),Ct,Kd,Wx=(Kd=class extends ts{constructor(t={}){super();$(this,Ct);this.config=t,z(this,Ct,new Map)}build(t,n,r){const s=n.queryKey,a=n.queryHash??zu(s,n);let l=this.get(a);return l||(l=new Ax({client:t,queryKey:s,queryHash:a,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(l)),l}add(t){y(this,Ct).has(t.queryHash)||(y(this,Ct).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=y(this,Ct).get(t.queryHash);n&&(t.destroy(),n===t&&y(this,Ct).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Se.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return y(this,Ct).get(t)}getAll(){return[...y(this,Ct).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>ld(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>ld(t,r)):n}notify(t){Se.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Se.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Se.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Ct=new WeakMap,Kd),pe,un,cn,Ar,$r,dn,Ur,Br,Hd,qx=(Hd=class{constructor(e={}){$(this,pe);$(this,un);$(this,cn);$(this,Ar);$(this,$r);$(this,dn);$(this,Ur);$(this,Br);z(this,pe,e.queryCache||new Wx),z(this,un,e.mutationCache||new Kx),z(this,cn,e.defaultOptions||{}),z(this,Ar,new Map),z(this,$r,new Map),z(this,dn,0)}mount(){ha(this,dn)._++,y(this,dn)===1&&(z(this,Ur,Du.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,pe).onFocus())})),z(this,Br,yi.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,pe).onOnline())})))}unmount(){var e,t;ha(this,dn)._--,y(this,dn)===0&&((e=y(this,Ur))==null||e.call(this),z(this,Ur,void 0),(t=y(this,Br))==null||t.call(this),z(this,Br,void 0))}isFetching(e){return y(this,pe).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return y(this,un).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,pe).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=y(this,pe).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(bn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return y(this,pe).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=y(this,pe).get(r.queryHash),a=s==null?void 0:s.state.data,l=Ex(t,a);if(l!==void 0)return y(this,pe).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return Se.batch(()=>y(this,pe).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,pe).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=y(this,pe);Se.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=y(this,pe);return Se.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Se.batch(()=>y(this,pe).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Ae).catch(Ae)}invalidateQueries(e,t={}){return Se.batch(()=>(y(this,pe).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Se.batch(()=>y(this,pe).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let a=s.fetch(void 0,n);return n.throwOnError||(a=a.catch(Ae)),s.state.fetchStatus==="paused"?Promise.resolve():a}));return Promise.all(r).then(Ae)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=y(this,pe).build(this,t);return n.isStaleByTime(bn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ae).catch(Ae)}fetchInfiniteQuery(e){return e.behavior=pd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ae).catch(Ae)}ensureInfiniteQueryData(e){return e.behavior=pd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return yi.isOnline()?y(this,un).resumePausedMutations():Promise.resolve()}getQueryCache(){return y(this,pe)}getMutationCache(){return y(this,un)}getDefaultOptions(){return y(this,cn)}setDefaultOptions(e){z(this,cn,e)}setQueryDefaults(e,t){y(this,Ar).set(rr(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...y(this,Ar).values()],n={};return t.forEach(r=>{qs(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){y(this,$r).set(rr(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...y(this,$r).values()],n={};return t.forEach(r=>{qs(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...y(this,cn).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=zu(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Fu&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...y(this,cn).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){y(this,pe).clear(),y(this,un).clear()}},pe=new WeakMap,un=new WeakMap,cn=new WeakMap,Ar=new WeakMap,$r=new WeakMap,dn=new WeakMap,Ur=new WeakMap,Br=new WeakMap,Hd),vm=w.createContext(void 0),qt=e=>{const t=w.useContext(vm);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Gx=({client:e,children:t})=>(w.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),i.jsx(vm.Provider,{value:e,children:t})),xm=w.createContext(!1),Jx=()=>w.useContext(xm);xm.Provider;function Yx(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var Xx=w.createContext(Yx()),Zx=()=>w.useContext(Xx),ey=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Iu(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},ty=e=>{w.useEffect(()=>{e.clearReset()},[e])},ny=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||Iu(n,[e.error,r])),ry=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},sy=(e,t)=>e.isLoading&&e.isFetching&&!t,ay=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,xd=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function iy(e,t,n){var p,x,k,g;const r=Jx(),s=Zx(),a=qt(),l=a.defaultQueryOptions(e);(x=(p=a.getDefaultOptions().queries)==null?void 0:p._experimental_beforeQuery)==null||x.call(p,l);const o=a.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",ry(l),ey(l,s,o),ty(s);const u=!a.getQueryCache().get(l.queryHash),[d]=w.useState(()=>new t(a,l)),h=d.getOptimisticResult(l),c=!r&&e.subscribed!==!1;if(w.useSyncExternalStore(w.useCallback(S=>{const m=c?d.subscribe(Se.batchCalls(S)):Ae;return d.updateResult(),m},[d,c]),()=>d.getCurrentResult(),()=>d.getCurrentResult()),w.useEffect(()=>{d.setOptions(l)},[l,d]),ay(l,h))throw xd(l,d,s);if(ny({result:h,errorResetBoundary:s,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw h.error;if((g=(k=a.getDefaultOptions().queries)==null?void 0:k._experimental_afterQuery)==null||g.call(k,l,h),l.experimental_prefetchInRender&&!nr&&sy(h,r)){const S=u?xd(l,d,s):o==null?void 0:o.promise;S==null||S.catch(Ae).finally(()=>{d.updateResult()})}return l.notifyOnChangeProps?h:d.trackResult(h)}function je(e,t){return iy(e,$x)}function Je(e,t){const n=qt(),[r]=w.useState(()=>new Hx(n,e));w.useEffect(()=>{r.setOptions(e)},[r,e]);const s=w.useSyncExternalStore(w.useCallback(l=>r.subscribe(Se.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=w.useCallback((l,o)=>{r.mutate(l,o).catch(Ae)},[r]);if(s.error&&Iu(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:a,mutateAsync:s.mutate}}/** + * @remix-run/router v1.23.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Gs(){return Gs=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function $u(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function oy(){return Math.random().toString(36).substr(2,8)}function gd(e,t){return{usr:e.state,key:e.key,idx:t}}function Lo(e,t,n,r){return n===void 0&&(n=null),Gs({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?ns(t):t,{state:n,key:t&&t.key||r||oy()})}function gi(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function ns(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function uy(e,t,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:a=!1}=r,l=s.history,o=mn.Pop,u=null,d=h();d==null&&(d=0,l.replaceState(Gs({},l.state,{idx:d}),""));function h(){return(l.state||{idx:null}).idx}function c(){o=mn.Pop;let S=h(),m=S==null?null:S-d;d=S,u&&u({action:o,location:g.location,delta:m})}function p(S,m){o=mn.Push;let f=Lo(g.location,S,m);d=h()+1;let v=gd(f,d),j=g.createHref(f);try{l.pushState(v,"",j)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;s.location.assign(j)}a&&u&&u({action:o,location:g.location,delta:1})}function x(S,m){o=mn.Replace;let f=Lo(g.location,S,m);d=h();let v=gd(f,d),j=g.createHref(f);l.replaceState(v,"",j),a&&u&&u({action:o,location:g.location,delta:0})}function k(S){let m=s.location.origin!=="null"?s.location.origin:s.location.href,f=typeof S=="string"?S:gi(S);return f=f.replace(/ $/,"%20"),xe(m,"No window.location.(origin|href) available to create URL for href: "+f),new URL(f,m)}let g={get action(){return o},get location(){return e(s,l)},listen(S){if(u)throw new Error("A history only accepts one active listener");return s.addEventListener(yd,c),u=S,()=>{s.removeEventListener(yd,c),u=null}},createHref(S){return t(s,S)},createURL:k,encodeLocation(S){let m=k(S);return{pathname:m.pathname,search:m.search,hash:m.hash}},push:p,replace:x,go(S){return l.go(S)}};return g}var jd;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(jd||(jd={}));function cy(e,t,n){return n===void 0&&(n="/"),dy(e,t,n)}function dy(e,t,n,r){let s=typeof t=="string"?ns(t):t,a=Jr(s.pathname||"/",n);if(a==null)return null;let l=ym(e);fy(l);let o=null;for(let u=0;o==null&&u{let u={relativePath:o===void 0?a.path||"":o,caseSensitive:a.caseSensitive===!0,childrenIndex:l,route:a};u.relativePath.startsWith("/")&&(xe(u.relativePath.startsWith(r),'Absolute route path "'+u.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),u.relativePath=u.relativePath.slice(r.length));let d=Cn([r,u.relativePath]),h=n.concat(u);a.children&&a.children.length>0&&(xe(a.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),ym(a.children,t,h,d)),!(a.path==null&&!a.index)&&t.push({path:d,score:gy(d,a.index),routesMeta:h})};return e.forEach((a,l)=>{var o;if(a.path===""||!((o=a.path)!=null&&o.includes("?")))s(a,l);else for(let u of gm(a.path))s(a,l,u)}),t}function gm(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),a=n.replace(/\?$/,"");if(r.length===0)return s?[a,""]:[a];let l=gm(r.join("/")),o=[];return o.push(...l.map(u=>u===""?a:[a,u].join("/"))),s&&o.push(...l),o.map(u=>e.startsWith("/")&&u===""?"/":u)}function fy(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:jy(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const hy=/^:[\w-]+$/,my=3,py=2,vy=1,xy=10,yy=-2,wd=e=>e==="*";function gy(e,t){let n=e.split("/"),r=n.length;return n.some(wd)&&(r+=yy),t&&(r+=py),n.filter(s=>!wd(s)).reduce((s,a)=>s+(hy.test(a)?my:a===""?vy:xy),r)}function jy(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function wy(e,t,n){let{routesMeta:r}=e,s={},a="/",l=[];for(let o=0;o{let{paramName:p,isOptional:x}=h;if(p==="*"){let g=o[c]||"";l=a.slice(0,a.length-g.length).replace(/(.)\/+$/,"$1")}const k=o[c];return x&&!k?d[p]=void 0:d[p]=(k||"").replace(/%2F/g,"/"),d},{}),pathname:a,pathnameBase:l,pattern:e}}function ky(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),$u(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,u)=>(r.push({paramName:o,isOptional:u!=null}),u?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function Sy(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return $u(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Jr(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const Ny=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,by=e=>Ny.test(e);function Cy(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?ns(e):e,a;if(n)if(by(n))a=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),$u(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?a=kd(n.substring(1),"/"):a=kd(n,t)}else a=t;return{pathname:a,search:Py(r),hash:Ty(s)}}function kd(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function jl(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function _y(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function jm(e,t){let n=_y(e);return t?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function wm(e,t,n,r){r===void 0&&(r=!1);let s;typeof e=="string"?s=ns(e):(s=Gs({},e),xe(!s.pathname||!s.pathname.includes("?"),jl("?","pathname","search",s)),xe(!s.pathname||!s.pathname.includes("#"),jl("#","pathname","hash",s)),xe(!s.search||!s.search.includes("#"),jl("#","search","hash",s)));let a=e===""||s.pathname==="",l=a?"/":s.pathname,o;if(l==null)o=n;else{let c=t.length-1;if(!r&&l.startsWith("..")){let p=l.split("/");for(;p[0]==="..";)p.shift(),c-=1;s.pathname=p.join("/")}o=c>=0?t[c]:"/"}let u=Cy(s,o),d=l&&l!=="/"&&l.endsWith("/"),h=(a||l===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(d||h)&&(u.pathname+="/"),u}const Cn=e=>e.join("/").replace(/\/\/+/g,"/"),Ey=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Py=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Ty=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Oy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const km=["post","put","patch","delete"];new Set(km);const Ly=["get",...km];new Set(Ly);/** + * React Router v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Js(){return Js=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),w.useCallback(function(d,h){if(h===void 0&&(h={}),!o.current)return;if(typeof d=="number"){r.go(d);return}let c=wm(d,JSON.parse(l),a,h.relative==="path");e==null&&t!=="/"&&(c.pathname=c.pathname==="/"?t:Cn([t,c.pathname])),(h.replace?r.replace:r.push)(c,h.state,h)},[t,r,l,a,e])}const zy=w.createContext(null);function Fy(e){let t=w.useContext(Gt).outlet;return t&&w.createElement(zy.Provider,{value:e},t)}function $i(){let{matches:e}=w.useContext(Gt),t=e[e.length-1];return t?t.params:{}}function Ui(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=w.useContext(Ln),{matches:s}=w.useContext(Gt),{pathname:a}=rs(),l=JSON.stringify(jm(s,r.v7_relativeSplatPath));return w.useMemo(()=>wm(e,JSON.parse(l),a,n==="path"),[e,l,a,n])}function Iy(e,t){return Dy(e,t)}function Dy(e,t,n,r){da()||xe(!1);let{navigator:s}=w.useContext(Ln),{matches:a}=w.useContext(Gt),l=a[a.length-1],o=l?l.params:{};l&&l.pathname;let u=l?l.pathnameBase:"/";l&&l.route;let d=rs(),h;if(t){var c;let S=typeof t=="string"?ns(t):t;u==="/"||(c=S.pathname)!=null&&c.startsWith(u)||xe(!1),h=S}else h=d;let p=h.pathname||"/",x=p;if(u!=="/"){let S=u.replace(/^\//,"").split("/");x="/"+p.replace(/^\//,"").split("/").slice(S.length).join("/")}let k=cy(e,{pathname:x}),g=Qy(k&&k.map(S=>Object.assign({},S,{params:Object.assign({},o,S.params),pathname:Cn([u,s.encodeLocation?s.encodeLocation(S.pathname).pathname:S.pathname]),pathnameBase:S.pathnameBase==="/"?u:Cn([u,s.encodeLocation?s.encodeLocation(S.pathnameBase).pathname:S.pathnameBase])})),a,n,r);return t&&g?w.createElement(Ai.Provider,{value:{location:Js({pathname:"/",search:"",hash:"",state:null,key:"default"},h),navigationType:mn.Pop}},g):g}function Ay(){let e=Wy(),t=Oy(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return w.createElement(w.Fragment,null,w.createElement("h2",null,"Unexpected Application Error!"),w.createElement("h3",{style:{fontStyle:"italic"}},t),n?w.createElement("pre",{style:s},n):null,null)}const $y=w.createElement(Ay,null);class Uy extends w.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?w.createElement(Gt.Provider,{value:this.props.routeContext},w.createElement(Nm.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function By(e){let{routeContext:t,match:n,children:r}=e,s=w.useContext(Di);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),w.createElement(Gt.Provider,{value:t},r)}function Qy(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var a;if(!n)return null;if(n.errors)e=n.matches;else if((a=r)!=null&&a.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(s=n)==null?void 0:s.errors;if(o!=null){let h=l.findIndex(c=>c.route.id&&(o==null?void 0:o[c.route.id])!==void 0);h>=0||xe(!1),l=l.slice(0,Math.min(l.length,h+1))}let u=!1,d=-1;if(n&&r&&r.v7_partialHydration)for(let h=0;h=0?l=l.slice(0,d+1):l=[l[0]];break}}}return l.reduceRight((h,c,p)=>{let x,k=!1,g=null,S=null;n&&(x=o&&c.route.id?o[c.route.id]:void 0,g=c.route.errorElement||$y,u&&(d<0&&p===0?(Gy("route-fallback"),k=!0,S=null):d===p&&(k=!0,S=c.route.hydrateFallbackElement||null)));let m=t.concat(l.slice(0,p+1)),f=()=>{let v;return x?v=g:k?v=S:c.route.Component?v=w.createElement(c.route.Component,null):c.route.element?v=c.route.element:v=h,w.createElement(By,{match:c,routeContext:{outlet:h,matches:m,isDataRoute:n!=null},children:v})};return n&&(c.route.ErrorBoundary||c.route.errorElement||p===0)?w.createElement(Uy,{location:n.location,revalidation:n.revalidation,component:g,error:x,children:f(),routeContext:{outlet:null,matches:m,isDataRoute:!0}}):f()},null)}var Cm=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Cm||{}),_m=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(_m||{});function Vy(e){let t=w.useContext(Di);return t||xe(!1),t}function Ky(e){let t=w.useContext(Sm);return t||xe(!1),t}function Hy(e){let t=w.useContext(Gt);return t||xe(!1),t}function Em(e){let t=Hy(),n=t.matches[t.matches.length-1];return n.route.id||xe(!1),n.route.id}function Wy(){var e;let t=w.useContext(Nm),n=Ky(),r=Em();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function qy(){let{router:e}=Vy(Cm.UseNavigateStable),t=Em(_m.UseNavigateStable),n=w.useRef(!1);return bm(()=>{n.current=!0}),w.useCallback(function(s,a){a===void 0&&(a={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,Js({fromRouteId:t},a)))},[e,t])}const Sd={};function Gy(e,t,n){Sd[e]||(Sd[e]=!0)}function Jy(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function Yy(e){return Fy(e.context)}function kt(e){xe(!1)}function Xy(e){let{basename:t="/",children:n=null,location:r,navigationType:s=mn.Pop,navigator:a,static:l=!1,future:o}=e;da()&&xe(!1);let u=t.replace(/^\/*/,"/"),d=w.useMemo(()=>({basename:u,navigator:a,static:l,future:Js({v7_relativeSplatPath:!1},o)}),[u,o,a,l]);typeof r=="string"&&(r=ns(r));let{pathname:h="/",search:c="",hash:p="",state:x=null,key:k="default"}=r,g=w.useMemo(()=>{let S=Jr(h,u);return S==null?null:{location:{pathname:S,search:c,hash:p,state:x,key:k},navigationType:s}},[u,h,c,p,x,k,s]);return g==null?null:w.createElement(Ln.Provider,{value:d},w.createElement(Ai.Provider,{children:n,value:g}))}function Zy(e){let{children:t,location:n}=e;return Iy(Mo(t),n)}new Promise(()=>{});function Mo(e,t){t===void 0&&(t=[]);let n=[];return w.Children.forEach(e,(r,s)=>{if(!w.isValidElement(r))return;let a=[...t,s];if(r.type===w.Fragment){n.push.apply(n,Mo(r.props.children,a));return}r.type!==kt&&xe(!1),!r.props.index||!r.props.children||xe(!1);let l={id:r.props.id||a.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Mo(r.props.children,a)),n.push(l)}),n}/** + * React Router DOM v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function ji(){return ji=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[s]=e[s]);return n}function eg(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function tg(e,t){return e.button===0&&(!t||t==="_self")&&!eg(e)}const ng=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],rg=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],sg="6";try{window.__reactRouterVersion=sg}catch{}const ag=w.createContext({isTransitioning:!1}),ig="startTransition",Nd=hp[ig];function lg(e){let{basename:t,children:n,future:r,window:s}=e,a=w.useRef();a.current==null&&(a.current=ly({window:s,v5Compat:!0}));let l=a.current,[o,u]=w.useState({action:l.action,location:l.location}),{v7_startTransition:d}=r||{},h=w.useCallback(c=>{d&&Nd?Nd(()=>u(c)):u(c)},[u,d]);return w.useLayoutEffect(()=>l.listen(h),[l,h]),w.useEffect(()=>Jy(r),[r]),w.createElement(Xy,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const og=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",ug=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,sr=w.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:a,replace:l,state:o,target:u,to:d,preventScrollReset:h,viewTransition:c}=t,p=Pm(t,ng),{basename:x}=w.useContext(Ln),k,g=!1;if(typeof d=="string"&&ug.test(d)&&(k=d,og))try{let v=new URL(window.location.href),j=d.startsWith("//")?new URL(v.protocol+d):new URL(d),C=Jr(j.pathname,x);j.origin===v.origin&&C!=null?d=C+j.search+j.hash:g=!0}catch{}let S=Ry(d,{relative:s}),m=dg(d,{replace:l,state:o,target:u,preventScrollReset:h,relative:s,viewTransition:c});function f(v){r&&r(v),v.defaultPrevented||m(v)}return w.createElement("a",ji({},p,{href:k||S,onClick:g||a?r:f,ref:n,target:u}))}),Tm=w.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:s=!1,className:a="",end:l=!1,style:o,to:u,viewTransition:d,children:h}=t,c=Pm(t,rg),p=Ui(u,{relative:c.relative}),x=rs(),k=w.useContext(Sm),{navigator:g,basename:S}=w.useContext(Ln),m=k!=null&&fg(p)&&d===!0,f=g.encodeLocation?g.encodeLocation(p).pathname:p.pathname,v=x.pathname,j=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;s||(v=v.toLowerCase(),j=j?j.toLowerCase():null,f=f.toLowerCase()),j&&S&&(j=Jr(j,S)||j);const C=f!=="/"&&f.endsWith("/")?f.length-1:f.length;let b=v===f||!l&&v.startsWith(f)&&v.charAt(C)==="/",N=j!=null&&(j===f||!l&&j.startsWith(f)&&j.charAt(f.length)==="/"),_={isActive:b,isPending:N,isTransitioning:m},F=b?r:void 0,O;typeof a=="function"?O=a(_):O=[a,b?"active":null,N?"pending":null,m?"transitioning":null].filter(Boolean).join(" ");let B=typeof o=="function"?o(_):o;return w.createElement(sr,ji({},c,{"aria-current":F,className:O,ref:n,style:B,to:u,viewTransition:d}),typeof h=="function"?h(_):h)});var zo;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(zo||(zo={}));var bd;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(bd||(bd={}));function cg(e){let t=w.useContext(Di);return t||xe(!1),t}function dg(e,t){let{target:n,replace:r,state:s,preventScrollReset:a,relative:l,viewTransition:o}=t===void 0?{}:t,u=or(),d=rs(),h=Ui(e,{relative:l});return w.useCallback(c=>{if(tg(c,n)){c.preventDefault();let p=r!==void 0?r:gi(d)===gi(h);u(e,{replace:p,state:s,preventScrollReset:a,relative:l,viewTransition:o})}},[d,u,h,r,s,n,e,a,l,o])}function fg(e,t){t===void 0&&(t={});let n=w.useContext(ag);n==null&&xe(!1);let{basename:r}=cg(zo.useViewTransitionState),s=Ui(e,{relative:t.relative});if(!n.isTransitioning)return!1;let a=Jr(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Jr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Ro(s.pathname,l)!=null||Ro(s.pathname,a)!=null}/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var hg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const mg=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),W=(e,t)=>{const n=w.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:a=2,absoluteStrokeWidth:l,className:o="",children:u,...d},h)=>w.createElement("svg",{ref:h,...hg,width:s,height:s,stroke:r,strokeWidth:l?Number(a)*24/Number(s):a,className:["lucide",`lucide-${mg(e)}`,o].join(" "),...d},[...t.map(([c,p])=>w.createElement(c,p)),...Array.isArray(u)?u:[u]]));return n.displayName=`${e}`,n};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const pg=W("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Om=W("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const vg=W("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const xg=W("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const yg=W("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lm=W("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const gg=W("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const jg=W("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ys=W("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const wg=W("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const kg=W("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Sg=W("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ng=W("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const bg=W("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cg=W("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cd=W("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _g=W("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Eg=W("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pg=W("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Tg=W("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Uu=W("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Og=W("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lg=W("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const fa=W("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rm=W("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rg=W("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mg=W("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xs=W("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bu=W("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zg=W("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fg=W("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mm=W("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ig=W("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _d=W("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dg=W("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qu=W("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zm=W("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ag=W("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fm=W("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bi=W("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),$g={},Ed=e=>{let t;const n=new Set,r=(h,c)=>{const p=typeof h=="function"?h(t):h;if(!Object.is(p,t)){const x=t;t=c??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(k=>k(t,x))}},s=()=>t,u={setState:r,getState:s,getInitialState:()=>d,subscribe:h=>(n.add(h),()=>n.delete(h)),destroy:()=>{($g?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(r,s,u);return u},Ug=e=>e?Ed(e):Ed;var Im={exports:{}},Dm={},Am={exports:{}},$m={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Yr=w;function Bg(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Qg=typeof Object.is=="function"?Object.is:Bg,Vg=Yr.useState,Kg=Yr.useEffect,Hg=Yr.useLayoutEffect,Wg=Yr.useDebugValue;function qg(e,t){var n=t(),r=Vg({inst:{value:n,getSnapshot:t}}),s=r[0].inst,a=r[1];return Hg(function(){s.value=n,s.getSnapshot=t,wl(s)&&a({inst:s})},[e,n,t]),Kg(function(){return wl(s)&&a({inst:s}),e(function(){wl(s)&&a({inst:s})})},[e]),Wg(n),n}function wl(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Qg(e,n)}catch{return!0}}function Gg(e,t){return t()}var Jg=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Gg:qg;$m.useSyncExternalStore=Yr.useSyncExternalStore!==void 0?Yr.useSyncExternalStore:Jg;Am.exports=$m;var Yg=Am.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Qi=w,Xg=Yg;function Zg(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var e0=typeof Object.is=="function"?Object.is:Zg,t0=Xg.useSyncExternalStore,n0=Qi.useRef,r0=Qi.useEffect,s0=Qi.useMemo,a0=Qi.useDebugValue;Dm.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var a=n0(null);if(a.current===null){var l={hasValue:!1,value:null};a.current=l}else l=a.current;a=s0(function(){function u(x){if(!d){if(d=!0,h=x,x=r(x),s!==void 0&&l.hasValue){var k=l.value;if(s(k,x))return c=k}return c=x}if(k=c,e0(h,x))return k;var g=r(x);return s!==void 0&&s(k,g)?(h=x,k):(h=x,c=g)}var d=!1,h,c,p=n===void 0?null:n;return[function(){return u(t())},p===null?void 0:function(){return u(p())}]},[t,n,r,s]);var o=t0(e,a[0],a[1]);return r0(function(){l.hasValue=!0,l.value=o},[o]),a0(o),o};Im.exports=Dm;var i0=Im.exports;const l0=Wd(i0),Um={},{useDebugValue:o0}=Vo,{useSyncExternalStoreWithSelector:u0}=l0;let Pd=!1;const c0=e=>e;function d0(e,t=c0,n){(Um?"production":void 0)!=="production"&&n&&!Pd&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Pd=!0);const r=u0(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return o0(r),r}const Td=e=>{(Um?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?Ug(e):e,n=(r,s)=>d0(t,r,s);return Object.assign(n,t),n},Vi=e=>e?Td(e):Td,Ki="/api",Vu="flow_auth_token",Ku="flow_auth_expires",Hu="flow_auth_username";function Zs(){const e=localStorage.getItem(Vu),t=localStorage.getItem(Ku);return!e||!t?null:new Date(t)<=new Date?(Jn(),null):e}function Od(e,t,n){localStorage.setItem(Vu,e),localStorage.setItem(Ku,t),localStorage.setItem(Hu,n)}function Jn(){localStorage.removeItem(Vu),localStorage.removeItem(Ku),localStorage.removeItem(Hu)}function Wu(){return localStorage.getItem(Hu)}let ar=null;function f0(e){ar=e}async function U(e,t,n=!1){const r={"Content-Type":"application/json",...t==null?void 0:t.headers};if(!n){const a=Zs();a&&(r.Authorization=`Bearer ${a}`)}const s=await fetch(`${Ki}${e}`,{...t,headers:r});if(s.status===401){Jn(),ar&&ar();const a=await s.json().catch(()=>({detail:"Not authenticated"}));throw new Error(a.detail||"Not authenticated")}if(!s.ok){const a=await s.json().catch(()=>({detail:s.statusText}));throw new Error(a.detail||"API request failed")}if(s.status!==204)return s.json()}const cr={getConfig:()=>U("/auth/config",void 0,!0),login:e=>U("/auth/login",{method:"POST",body:JSON.stringify(e)},!0),getGitHubAuthUrl:()=>`${Ki}/auth/github`,getCurrentUser:()=>U("/auth/me"),logout:()=>U("/auth/logout",{method:"POST"})},Tr={list:e=>{const t=new URLSearchParams;e!=null&&e.include_auto_generated&&t.set("include_auto_generated","true"),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return U(`/configs${n?`?${n}`:""}`)},get:e=>U(`/configs/${e}`),create:e=>U("/configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/configs/${e}`,{method:"DELETE"})},Et={list:e=>{const t=new URLSearchParams;e!=null&&e.category&&t.set("category",e.category),e!=null&&e.suite&&t.set("suite",e.suite);const n=t.toString();return U(`/tasks${n?`?${n}`:""}`)},get:e=>U(`/tasks/${e}`),create:e=>U("/tasks",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/tasks/${e}`,{method:"DELETE"}),listSuites:()=>U("/tasks/suites"),importSuite:e=>U(`/tasks/import-suite?suite_name=${encodeURIComponent(e)}`,{method:"POST"})},Ut={list:e=>{const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return U(`/jobs${n?`?${n}`:""}`)},get:e=>U(`/jobs/${e}`),create:e=>U("/jobs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/jobs/${e}`,{method:"PUT",body:JSON.stringify(t)}),start:async function*(e){var o;const t={},n=Zs();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Ki}/jobs/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Jn(),ar&&ar(),new Error("Not authenticated");if(!r.ok)throw new Error("Failed to start job");const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const a=new TextDecoder;let l="";for(;;){const{done:u,value:d}=await s.read();if(u)break;l+=a.decode(d,{stream:!0});const h=l.split(` +`);l=h.pop()||"";for(const c of h)c.startsWith("data: ")&&(yield JSON.parse(c.slice(6)))}},cancel:e=>U(`/jobs/${e}/cancel`,{method:"POST"}),delete:e=>U(`/jobs/${e}`,{method:"DELETE"})},Fo={list:e=>{const t=new URLSearchParams;e!=null&&e.job_id&&t.set("job_id",e.job_id),e!=null&&e.candidate_name&&t.set("candidate_name",e.candidate_name),e!=null&&e.task_name&&t.set("task_name",e.task_name),(e==null?void 0:e.is_pareto)!==void 0&&t.set("is_pareto",String(e.is_pareto));const n=t.toString();return U(`/runs${n?`?${n}`:""}`)},get:e=>U(`/runs/${e}`),getJobSummary:e=>U(`/runs/job/${e}/summary`)},Ts={list:e=>{const t=new URLSearchParams;e!=null&&e.agent_id&&t.set("agent_id",e.agent_id),e!=null&&e.limit&&t.set("limit",String(e.limit));const n=t.toString();return U(`/tests${n?`?${n}`:""}`)},get:e=>U(`/tests/${e}`),create:e=>U("/tests",{method:"POST",body:JSON.stringify(e)}),start:async function*(e){var o;const t={},n=Zs();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Ki}/tests/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Jn(),ar&&ar(),new Error("Not authenticated");if(!r.ok){const u=await r.json().catch(()=>({detail:"Failed to start test"}));throw new Error(u.detail||"Failed to start test")}const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const a=new TextDecoder;let l="";for(;;){const{done:u,value:d}=await s.read();if(u)break;l+=a.decode(d,{stream:!0});const h=l.split(` +`);l=h.pop()||"";for(const c of h)c.startsWith("data: ")&&(yield JSON.parse(c.slice(6)))}},cancel:e=>U(`/tests/${e}/cancel`,{method:"POST"}),delete:e=>U(`/tests/${e}`,{method:"DELETE"})},h0={list:()=>U("/llm-configs"),get:e=>U(`/llm-configs/${e}`),getDefault:()=>U("/llm-configs/default"),create:e=>U("/llm-configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>U(`/llm-configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>U(`/llm-configs/${e}`,{method:"DELETE"}),setDefault:e=>U(`/llm-configs/${e}/set-default`,{method:"POST"}),test:e=>U(`/llm-configs/${e}/test`,{method:"POST"})},m0={list:()=>U("/tools"),get:e=>U(`/tools/${e}`)},Bm={getAgentSchema:()=>U("/schema/agent")},p0={start:e=>U("/evaluate",{method:"POST",body:JSON.stringify(e)})},Io={design:e=>U("/experiment/design",{method:"POST",body:JSON.stringify(e)}),importYaml:e=>U("/experiment/import-yaml",{method:"POST",body:JSON.stringify(e)}),validate:e=>U("/experiment/validate",{method:"POST",body:JSON.stringify(e)}),generateCandidates:e=>U("/experiment/generate-candidates",{method:"POST",body:JSON.stringify(e)})},qu=Vi((e,t)=>(f0(()=>{e({isAuthenticated:!1,user:null,error:"Session expired. Please log in again."})}),{authConfig:null,isLoadingConfig:!0,isAuthenticated:!1,isLoading:!1,user:null,error:null,loadAuthConfig:async()=>{e({isLoadingConfig:!0});try{const n=await cr.getConfig();if(e({authConfig:n,isLoadingConfig:!1}),n.enabled){const r=Zs(),s=Wu();if(r&&s)try{const a=await cr.getCurrentUser();e({isAuthenticated:!0,user:a})}catch{Jn(),e({isAuthenticated:!1,user:null})}}else e({isAuthenticated:!0,user:{username:"anonymous",auth_mode:"none"}})}catch(n){console.error("Failed to load auth config:",n),e({isLoadingConfig:!1,error:"Failed to connect to server"})}},login:async(n,r)=>{e({isLoading:!0,error:null});try{const s=await cr.login({username:n,password:r});return Od(s.access_token,s.expires_at,s.username),e({isAuthenticated:!0,isLoading:!1,user:{username:s.username,auth_mode:"basic"}}),!0}catch(s){return e({isLoading:!1,error:s instanceof Error?s.message:"Login failed"}),!1}},loginWithGitHub:()=>{window.location.href=cr.getGitHubAuthUrl()},handleOAuthCallback:()=>{const n=new URLSearchParams(window.location.search),r=n.get("auth_error");if(r)return e({error:r}),window.history.replaceState({},"",window.location.pathname),!0;if(n.get("auth_callback")==="true"){const s=n.get("token"),a=n.get("expires_at"),l=n.get("username");return s&&a&&l&&(Od(s,a,l),e({isAuthenticated:!0,user:{username:l,auth_mode:"github"}})),window.history.replaceState({},"",window.location.pathname),!0}return!1},logout:async()=>{try{await cr.logout()}catch{}Jn(),e({isAuthenticated:!1,user:null,error:null})},checkAuth:async()=>{const{authConfig:n}=t();if(!(n!=null&&n.enabled)){e({isAuthenticated:!0});return}if(!Zs()){e({isAuthenticated:!1,user:null});return}try{const s=await cr.getCurrentUser();e({isAuthenticated:!0,user:s})}catch{Jn(),e({isAuthenticated:!1,user:null})}},clearError:()=>e({error:null})}));function V({variant:e="secondary",size:t="md",className:n="",icon:r,iconRight:s,loading:a=!1,children:l,disabled:o,...u}){const d="font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1.5 rounded-md",h={primary:"bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)]",secondary:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)] hover:bg-[var(--border)]",danger:"bg-[var(--error)] text-white hover:bg-red-600",ghost:"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"},c={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm"},p=t==="sm"?14:16;return i.jsxs("button",{className:`${d} ${h[e]} ${c[t]} ${n}`,disabled:o||a,...u,children:[a?i.jsx(fa,{size:p,className:"animate-spin"}):r?i.jsx(r,{size:p}):null,l,s&&!a&&i.jsx(s,{size:p})]})}const v0={};function x0(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var a;const l=u=>u===null?null:JSON.parse(u,void 0),o=(a=n.getItem(s))!=null?a:null;return o instanceof Promise?o.then(l):l(o)},setItem:(s,a)=>n.setItem(s,JSON.stringify(a,void 0)),removeItem:s=>n.removeItem(s)}}const ea=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return ea(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return ea(r)(n)}}}},y0=(e,t)=>(n,r,s)=>{let a={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:S=>S,version:0,merge:(S,m)=>({...m,...S}),...t},l=!1;const o=new Set,u=new Set;let d;try{d=a.getStorage()}catch{}if(!d)return e((...S)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...S)},r,s);const h=ea(a.serialize),c=()=>{const S=a.partialize({...r()});let m;const f=h({state:S,version:a.version}).then(v=>d.setItem(a.name,v)).catch(v=>{m=v});if(m)throw m;return f},p=s.setState;s.setState=(S,m)=>{p(S,m),c()};const x=e((...S)=>{n(...S),c()},r,s);let k;const g=()=>{var S;if(!d)return;l=!1,o.forEach(f=>f(r()));const m=((S=a.onRehydrateStorage)==null?void 0:S.call(a,r()))||void 0;return ea(d.getItem.bind(d))(a.name).then(f=>{if(f)return a.deserialize(f)}).then(f=>{if(f)if(typeof f.version=="number"&&f.version!==a.version){if(a.migrate)return a.migrate(f.state,f.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return f.state}).then(f=>{var v;return k=a.merge(f,(v=r())!=null?v:x),n(k,!0),c()}).then(()=>{m==null||m(k,void 0),l=!0,u.forEach(f=>f(k))}).catch(f=>{m==null||m(void 0,f)})};return s.persist={setOptions:S=>{a={...a,...S},S.getStorage&&(d=S.getStorage())},clearStorage:()=>{d==null||d.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>g(),hasHydrated:()=>l,onHydrate:S=>(o.add(S),()=>{o.delete(S)}),onFinishHydration:S=>(u.add(S),()=>{u.delete(S)})},g(),k||x},g0=(e,t)=>(n,r,s)=>{let a={storage:x0(()=>localStorage),partialize:g=>g,version:0,merge:(g,S)=>({...S,...g}),...t},l=!1;const o=new Set,u=new Set;let d=a.storage;if(!d)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...g)},r,s);const h=()=>{const g=a.partialize({...r()});return d.setItem(a.name,{state:g,version:a.version})},c=s.setState;s.setState=(g,S)=>{c(g,S),h()};const p=e((...g)=>{n(...g),h()},r,s);s.getInitialState=()=>p;let x;const k=()=>{var g,S;if(!d)return;l=!1,o.forEach(f=>{var v;return f((v=r())!=null?v:p)});const m=((S=a.onRehydrateStorage)==null?void 0:S.call(a,(g=r())!=null?g:p))||void 0;return ea(d.getItem.bind(d))(a.name).then(f=>{if(f)if(typeof f.version=="number"&&f.version!==a.version){if(a.migrate)return[!0,a.migrate(f.state,f.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,f.state];return[!1,void 0]}).then(f=>{var v;const[j,C]=f;if(x=a.merge(C,(v=r())!=null?v:p),n(x,!0),j)return h()}).then(()=>{m==null||m(x,void 0),x=r(),l=!0,u.forEach(f=>f(x))}).catch(f=>{m==null||m(void 0,f)})};return s.persist={setOptions:g=>{a={...a,...g},g.storage&&(d=g.storage)},clearStorage:()=>{d==null||d.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>k(),hasHydrated:()=>l,onHydrate:g=>(o.add(g),()=>{o.delete(g)}),onFinishHydration:g=>(u.add(g),()=>{u.delete(g)})},a.skipHydration||k(),x||p},j0=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((v0?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),y0(e,t)):g0(e,t),Qm=j0,w0=Vi()(Qm((e,t)=>({theme:"light",setTheme:n=>{document.documentElement.setAttribute("data-theme",n),e({theme:n})},toggleTheme:()=>{const n=t().theme==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",n),e({theme:n})}}),{name:"flow-theme",onRehydrateStorage:()=>e=>{e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}}));function k0(){const{theme:e,toggleTheme:t}=w0();return i.jsx("button",{onClick:t,className:"p-2 rounded-md text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--accent)]","aria-label":`Switch to ${e==="dark"?"light":"dark"} mode`,title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:e==="dark"?i.jsx(Dg,{size:16}):i.jsx(Mg,{size:16})})}const S0=Vi()(Qm((e,t)=>({sidebarCollapsed:!1,toggleSidebar:()=>{e({sidebarCollapsed:!t().sidebarCollapsed})},setSidebarCollapsed:n=>{e({sidebarCollapsed:n})}}),{name:"flow-layout"})),N0=[{path:"/agents",label:"Agents",icon:yg},{path:"/jobs",label:"Experiments",icon:Eg},{path:"/tasks",label:"Datasets",icon:Cg}];function b0(){const e=rs(),{sidebarCollapsed:t,toggleSidebar:n}=S0(),r=s=>s==="/agents"?e.pathname==="/"||e.pathname==="/agents"||e.pathname.startsWith("/agents/"):s==="/jobs"?e.pathname.startsWith("/jobs")||e.pathname.startsWith("/runs"):e.pathname.startsWith(s);return i.jsxs("aside",{className:` + flex flex-col border-r border-[var(--border)] bg-[var(--bg-secondary)] + transition-all duration-200 + ${t?"w-14":"w-56"} + `,children:[i.jsx("nav",{className:"flex-1 py-2",children:N0.map(s=>{const a=r(s.path);return i.jsxs(Tm,{to:s.path,title:t?s.label:void 0,className:` + flex items-center gap-3 px-4 py-2.5 text-sm transition-colors relative + ${a?"text-[var(--accent)] bg-[var(--accent-dim)] font-medium":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"} + `,children:[a&&i.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-r bg-[var(--accent)]"}),i.jsx(s.icon,{size:18}),!t&&i.jsx("span",{children:s.label})]},s.path)})}),i.jsx("button",{onClick:n,className:"flex items-center justify-center p-3 border-t border-[var(--border)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",title:t?"Expand sidebar":"Collapse sidebar",children:t?i.jsx(kg,{size:16}):i.jsx(wg,{size:16})})]})}function C0(){const{authConfig:e,user:t,logout:n}=qu(),r=async()=>{await n()};return i.jsxs("div",{className:"h-screen flex flex-col",children:[i.jsx("header",{className:"border-b border-[var(--border)] bg-[var(--bg-secondary)] shrink-0",children:i.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between",children:[i.jsxs(Tm,{to:"/",className:"text-lg font-semibold text-[var(--accent)] flex items-center gap-2 hover:opacity-80",children:[i.jsx(Bi,{size:20}),"Flow",i.jsx("span",{className:"text-[var(--text-secondary)] font-normal",children:"/optimize"})]}),i.jsxs("div",{className:"flex items-center gap-4",children:[i.jsx(k0,{}),(e==null?void 0:e.enabled)&&t&&i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[i.jsx(zm,{size:14}),i.jsx("span",{children:t.username})]}),i.jsx(V,{variant:"ghost",size:"sm",icon:Rg,onClick:r,title:"Sign out",children:"Sign out"})]})]})]})}),i.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[i.jsx(b0,{}),i.jsx("main",{className:"flex-1 overflow-y-auto bg-[var(--bg-primary)]",children:i.jsx("div",{className:"p-6",children:i.jsx(Yy,{})})})]})]})}const _0=["maf","miniagent","langgraph"],E0={maf:"Microsoft Agent Framework",miniagent:"MiniAgent",langgraph:"LangGraph"},P0={openai:"OpenAI",azure_openai:"Azure OpenAI",anthropic:"Anthropic",ollama:"Ollama",custom:"Custom (OpenAI-compatible)"};function Z({children:e,variant:t="default"}){const n={default:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)]",success:"bg-[var(--badge-success-bg)] text-[var(--badge-success-text)] border border-[var(--badge-success-border)]",warning:"bg-[var(--badge-warning-bg)] text-[var(--badge-warning-text)] border border-[var(--badge-warning-border)]",error:"bg-[var(--badge-error-bg)] text-[var(--badge-error-text)] border border-[var(--badge-error-border)]",info:"bg-[var(--badge-info-bg)] text-[var(--badge-info-text)] border border-[var(--badge-info-border)]"};return i.jsx("span",{className:`inline-block px-2 py-0.5 text-xs font-medium rounded-md ${n[t]}`,children:e})}const T0={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"};function ss({isOpen:e,onClose:t,title:n,children:r,footer:s,size:a="md"}){return w.useEffect(()=>{const l=o=>{o.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",l),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",l),document.body.style.overflow=""}},[e,t]),e?i.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[i.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),i.jsxs("div",{className:`relative bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg ${T0[a]} w-full mx-4 max-h-[80vh] flex flex-col`,children:[i.jsxs("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-b border-[var(--border)] px-4 py-3 flex items-center justify-between",children:[i.jsx("h2",{className:"font-semibold",children:n}),i.jsx("button",{onClick:t,className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"×"})]}),i.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r}),s&&i.jsx("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-t border-[var(--border)] px-4 py-3",children:s})]})]}):null}function pn({label:e,className:t="",...n}){return i.jsxs("div",{className:"space-y-1",children:[e&&i.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),i.jsx("input",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] ${t}`,...n})]})}function O0({label:e,className:t="",...n}){return i.jsxs("div",{className:"space-y-1",children:[e&&i.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),i.jsx("textarea",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] resize-y min-h-[100px] ${t}`,...n})]})}function wi({label:e,className:t="",...n}){return i.jsxs("label",{className:`flex items-center gap-2 cursor-pointer ${t}`,children:[i.jsx("input",{type:"checkbox",className:"w-4 h-4 bg-[var(--bg-primary)] border border-[var(--border)] rounded accent-[var(--accent)]",...n}),i.jsx("span",{className:"text-sm",children:e})]})}function Vm({columns:e,data:t,onRowClick:n,searchable:r=!1,searchPlaceholder:s="Search...",searchFilter:a,emptyMessage:l="No items found",emptyIcon:o}){const[u,d]=w.useState(""),[h,c]=w.useState(null),[p,x]=w.useState("asc"),k=w.useMemo(()=>{let S=t;if(r&&u&&a&&(S=S.filter(m=>a(m,u))),h){const m=e.find(f=>f.key===h);m!=null&&m.sortValue&&(S=[...S].sort((f,v)=>{const j=m.sortValue(f),C=m.sortValue(v),b=jC?1:0;return p==="asc"?b:-b}))}return S},[t,u,a,r,h,p,e]),g=S=>{const m=e.find(f=>f.key===S);m!=null&&m.sortable&&(h===S?x(p==="asc"?"desc":"asc"):(c(S),x("asc")))};return i.jsxs("div",{children:[r&&i.jsxs("div",{className:"mb-4 relative max-w-sm",children:[i.jsx(zg,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]"}),i.jsx("input",{type:"text",placeholder:s,value:u,onChange:S=>d(S.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md pl-9 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]"})]}),k.length===0?i.jsxs("div",{className:"text-center py-16 text-[var(--text-secondary)]",children:[o&&i.jsx("div",{className:"mb-3 flex justify-center",children:o}),i.jsx("p",{children:l})]}):i.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsx("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:e.map(S=>i.jsx("th",{onClick:()=>g(S.key),className:`text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider ${S.sortable?"cursor-pointer hover:text-[var(--text-primary)]":""} ${S.className||""}`,children:i.jsxs("span",{className:"inline-flex items-center gap-1",children:[S.header,S.sortable&&h===S.key&&i.jsx("span",{children:p==="asc"?"↑":"↓"})]})},S.key))})}),i.jsx("tbody",{children:k.map((S,m)=>i.jsx("tr",{onClick:()=>n==null?void 0:n(S),className:`border-b border-[var(--border)] last:border-b-0 transition-colors ${n?"cursor-pointer hover:bg-[var(--bg-tertiary)]":""}`,children:e.map(f=>i.jsx("td",{className:`px-4 py-3 ${f.className||""}`,children:f.render(S)},f.key))},m))})]})})]})}function L0({variations:e,onChange:t,strategies:n,availableStrategies:r}){const s=r??Object.keys(n),a=()=>{const d=e.map(x=>x.strategy),h=s.find(x=>!d.includes(x))||"none",c=n[h],p={strategy:h};if(c!=null&&c.params)for(const[x,k]of Object.entries(c.params))k.default!==void 0&&(p[x]=k.default);t([...e,p])},l=d=>{t(e.filter((h,c)=>c!==d))},o=(d,h)=>{t(e.map((c,p)=>p===d?{...c,...h}:c))},u=(d,h)=>{const c=n[h],p={strategy:h};if(c!=null&&c.params)for(const[x,k]of Object.entries(c.params))k.default!==void 0&&(p[x]=k.default);o(d,p)};return i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"text-sm font-medium",children:"Compaction Strategies"}),i.jsx(V,{type:"button",variant:"ghost",size:"sm",icon:Bu,onClick:a,disabled:e.length>=s.length,children:"Add"})]}),e.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:'No compaction variations. Click "Add" to test different strategies.'}):i.jsx("div",{className:"space-y-2",children:e.map((d,h)=>{const c=n[d.strategy];return i.jsx("div",{className:"p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsxs("div",{className:"flex-1 space-y-2",children:[i.jsx("select",{className:"w-full px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:d.strategy,onChange:p=>u(h,p.target.value),children:s.map(p=>{var x;return i.jsx("option",{value:p,children:((x=n[p])==null?void 0:x.label)||p},p)})}),(c==null?void 0:c.description)&&i.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:c.description}),(c==null?void 0:c.params)&&Object.keys(c.params).length>0&&i.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:Object.entries(c.params).map(([p,x])=>i.jsx(R0,{name:p,schema:x,value:d[p],onChange:k=>o(h,{[p]:k})},p))})]}),i.jsx("button",{type:"button",onClick:()=>l(h),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:i.jsx(Fm,{size:16})})]})},h)})})]})}function R0({name:e,schema:t,value:n,onChange:r}){const s=e.replace(/_/g," ");return t.type==="boolean"?i.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[i.jsx("input",{type:"checkbox",checked:!!(n??t.default),onChange:a=>r(a.target.checked),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"capitalize",children:s})]}):i.jsxs("div",{children:[i.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:s}),i.jsx("input",{type:t.type==="number"?"number":"text",className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-xs",value:String(n!==void 0?n:t.default??""),onChange:a=>{if(t.type==="number"){const l=parseFloat(a.target.value);r(isNaN(l)?t.default:l)}else r(a.target.value)},min:t.min,max:t.max,step:t.max&&t.max<=1?.1:1})]})}function M0({variations:e,onChange:t,providers:n}){const r=()=>{const o=n[0],u={provider:(o==null?void 0:o.name)||"azure_openai",model:(o==null?void 0:o.models[0])||"gpt-4o"};t([...e,u])},s=o=>{t(e.filter((u,d)=>d!==o))},a=(o,u)=>{t(e.map((d,h)=>h===o?{...d,...u}:d))},l=(o,u)=>{const d=n.find(h=>h.name===u);a(o,{provider:u,model:(d==null?void 0:d.models[0])||""})};return i.jsxs("div",{className:"space-y-3",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsx("label",{className:"text-sm font-medium",children:"LLM Configurations"}),i.jsx(V,{type:"button",variant:"ghost",size:"sm",icon:Bu,onClick:r,children:"Add"})]}),e.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:`Uses agent's default LLM. Click "Add" to test different models.`}):i.jsx("div",{className:"space-y-2",children:e.map((o,u)=>{const d=n.find(h=>h.name===o.provider);return i.jsxs("div",{className:"flex items-center gap-2 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[i.jsx("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.provider,onChange:h=>l(u,h.target.value),children:n.map(h=>i.jsx("option",{value:h.name,children:h.label},h.name))}),d&&d.models.length>0?i.jsxs("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:h=>a(u,{model:h.target.value}),children:[d.models.map(h=>i.jsx("option",{value:h,children:h},h)),!d.models.includes(o.model)&&o.model&&i.jsx("option",{value:o.model,children:o.model})]}):i.jsx("input",{type:"text",className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:h=>a(u,{model:h.target.value}),placeholder:"Model ID"}),i.jsx("button",{type:"button",onClick:()=>s(u),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:i.jsx(Fm,{size:16})})]},u)})})]})}const Do={compaction:[],tools:[],llm_config:[],instructions:[],instruction_strategies:[]};function z0({agentId:e,agentName:t,agentFramework:n="maf",taskSuite:r,taskCount:s,schema:a,onVariationsChange:l,parallel:o,onParallelChange:u,budget:d,onBudgetChange:h,useLlmEval:c,onUseLlmEvalChange:p}){const[x,k]=w.useState(Do),[g,S]=w.useState(!1),[m,f]=w.useState(""),[v,j]=w.useState(null),C=a.frameworks[n],b=(C==null?void 0:C.compaction_strategies)||Object.keys(a.compaction_strategies),N=a.tool_presets||[],_=a.llm_providers||[],O=(()=>{let L=1;x.compaction.length>0&&(L*=x.compaction.length),x.tools.length>0&&(L*=x.tools.length),x.llm_config.length>0&&(L*=x.llm_config.length);const Q=x.instructions.length+x.instruction_strategies.reduce((ee,R)=>ee+R.max_candidates,0);return Q>0&&(L*=Q),Math.min(L,d)})(),B=O*s,G=L=>{k(L),l==null||l(L)},re=Je({mutationFn:L=>Io.design(L),onSuccess:L=>{f(L.yaml_content),S(!0)}}),he=Je({mutationFn:L=>Io.validate(L),onSuccess:L=>{j({valid:L.valid,errors:L.errors,warnings:L.warnings})}}),D=()=>({base_agent_id:e,task_suite:r,variations:x,parallel:o,budget:d,use_llm_eval:c}),q=()=>{re.mutate(D())},Y=()=>{he.mutate(D())},P=()=>{const L=new Blob([m],{type:"text/yaml"}),Q=URL.createObjectURL(L),ee=document.createElement("a");ee.href=Q,ee.download=`${t}_experiment.yaml`,ee.click(),URL.revokeObjectURL(Q)},A=x.compaction.length>0||x.tools.length>0||x.llm_config.length>0||x.instructions.length>0||x.instruction_strategies.length>0;return i.jsxs("div",{className:"space-y-6",children:[i.jsxs("div",{className:"flex flex-wrap gap-2",children:[i.jsxs(Z,{variant:"info",children:[O," candidates"]}),i.jsxs(Z,{children:[s," tasks"]}),i.jsxs(Z,{variant:B>100?"warning":"success",children:[B," total runs"]})]}),i.jsx(L0,{variations:x.compaction,onChange:L=>G({...x,compaction:L}),strategies:a.compaction_strategies,availableStrategies:b}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("label",{className:"text-sm font-medium",children:"Tool Presets"}),i.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(L=>i.jsxs("label",{className:`flex items-center gap-2 px-3 py-1.5 border rounded cursor-pointer transition-colors ${x.tools.includes(L.name)?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[i.jsx("input",{type:"checkbox",checked:x.tools.includes(L.name),onChange:Q=>{const ee=Q.target.checked?[...x.tools,L.name]:x.tools.filter(R=>R!==L.name);G({...x,tools:ee})},className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:L.name}),i.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",L.tools.length,")"]})]},L.name))}),x.tools.length>0&&i.jsxs("p",{className:"text-xs text-[var(--text-secondary)]",children:["Selected: ",x.tools.join(", ")]})]}),i.jsx(M0,{variations:x.llm_config,onChange:L=>G({...x,llm_config:L}),providers:_}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-4 space-y-4",children:[i.jsx("h4",{className:"text-sm font-medium",children:"Execution Settings"}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(pn,{label:"Parallel Workers",type:"number",value:o,onChange:L=>u(parseInt(L.target.value)||1),min:1,max:16}),i.jsx(pn,{label:"Budget (max candidates)",type:"number",value:d,onChange:L=>h(parseInt(L.target.value)||100),min:1,max:1e3})]}),i.jsx(wi,{label:"Use LLM evaluation",checked:c,onChange:L=>p(L.target.checked)}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] ml-6 -mt-2",children:c?"LLM-as-Judge scores task completion (0-1)":"Simple pass/fail based on task success"})]}),i.jsxs("div",{className:"flex items-center gap-2 border-t border-[var(--border)] pt-4",children:[i.jsx(V,{variant:"secondary",size:"sm",onClick:Y,loading:he.isPending,children:"Validate"}),i.jsx(V,{variant:"secondary",size:"sm",icon:Cd,onClick:q,loading:re.isPending,children:"Export YAML"})]}),v&&i.jsxs("div",{className:`p-3 rounded border ${v.valid?"border-green-500/50 bg-green-500/10":"border-red-500/50 bg-red-500/10"}`,children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[v.valid?i.jsx(Lm,{size:16,className:"text-green-500"}):i.jsx(Om,{size:16,className:"text-red-500"}),i.jsx("span",{className:"font-medium text-sm",children:v.valid?"Configuration valid":"Configuration has issues"})]}),v.errors.length>0&&i.jsx("ul",{className:"text-sm text-red-500 list-disc ml-6",children:v.errors.map((L,Q)=>i.jsx("li",{children:L},Q))}),v.warnings.length>0&&i.jsx("ul",{className:"text-sm text-yellow-500 list-disc ml-6 mt-1",children:v.warnings.map((L,Q)=>i.jsx("li",{children:L},Q))})]}),g&&i.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:i.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-lg shadow-xl max-w-2xl w-full max-h-[80vh] flex flex-col",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border)]",children:[i.jsx("h3",{className:"font-medium",children:"Experiment YAML"}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(V,{variant:"secondary",size:"sm",icon:Cd,onClick:P,children:"Download"}),i.jsx(V,{variant:"ghost",size:"sm",onClick:()=>S(!1),children:"Close"})]})]}),i.jsx("pre",{className:"flex-1 overflow-auto p-4 text-xs font-mono bg-[var(--bg-secondary)]",children:m})]})}),!A&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No variations selected. Only the baseline agent will be tested. Add compaction strategies, tool presets, or LLM configs to generate candidates."})]})}function Ld(){const e=or(),t=qt(),[n,r]=w.useState(!1),[s,a]=w.useState(null),{data:l=[],isLoading:o}=je({queryKey:["configs"],queryFn:()=>Tr.list()}),u=Je({mutationFn:Tr.create,onSuccess:()=>{t.invalidateQueries({queryKey:["configs"]}),r(!1)}}),d=Je({mutationFn:Tr.delete,onSuccess:()=>t.invalidateQueries({queryKey:["configs"]})}),h=[{key:"name",header:"Name",render:c=>i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:c.name})},{key:"framework",header:"Framework",render:c=>i.jsx(Z,{children:c.config.framework||"maf"})},{key:"tools",header:"Tools",render:c=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:F0(c.config.tools)})},{key:"compaction",header:"Compaction",render:c=>{const p=c.config.compaction;return!p||p.strategy==="none"?i.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"}):p.strategy==="head_tail"?i.jsxs(Z,{children:[p.params.head_size,"/",p.params.tail_size]}):i.jsx(Z,{children:p.strategy})}},{key:"created",header:"Created",render:c=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(c.created_at).toLocaleDateString()}),sortable:!0,sortValue:c=>new Date(c.created_at).getTime()},{key:"actions",header:"",className:"w-24",render:c=>i.jsxs("div",{className:"flex items-center gap-1",onClick:p=>p.stopPropagation(),children:[i.jsx(V,{variant:"ghost",size:"sm",icon:Bi,title:"Optimize",onClick:()=>a(c)}),i.jsx(V,{variant:"ghost",size:"sm",icon:Qu,title:"Delete",onClick:()=>{confirm(`Delete agent "${c.name}"?`)&&d.mutate(c.id)}})]})}];return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Agents"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Define and optimize your agent configurations."})]}),i.jsx(V,{variant:"primary",icon:Bu,onClick:()=>r(!0),children:"Create agent"})]}),o?i.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[i.jsx(fa,{size:16,className:"animate-spin"}),"Loading agents..."]}):i.jsx(Vm,{columns:h,data:l,onRowClick:c=>e(`/agents/${c.id}`),searchable:!0,searchPlaceholder:"Search agents",searchFilter:(c,p)=>c.name.toLowerCase().includes(p.toLowerCase())||(c.description||"").toLowerCase().includes(p.toLowerCase()),emptyMessage:"No agents yet. Create your first agent to start optimizing.",emptyIcon:i.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-[var(--bg-tertiary)]",children:i.jsx(Mm,{size:24,className:"text-[var(--text-secondary)]"})})}),i.jsx(I0,{isOpen:n,onClose:()=>r(!1),onSubmit:c=>u.mutate(c),isLoading:u.isPending}),s&&i.jsx(D0,{agent:s,isOpen:!!s,onClose:()=>a(null)})]})}function F0(e){return typeof e=="string"?e:Array.isArray(e)?`[${e.length}]`:e&&typeof e=="object"?`[${Object.keys(e).length}]`:"standard"}function I0({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){var Q,ee,R,T,te,me,be;const s=["read_file","write_file","edit_file","bash","grep","think"],[a,l]=w.useState("preset"),[o,u]=w.useState({name:"",description:"",instructions:null,model:null,compaction:{strategy:"none",params:{}},tools:s,framework:"miniagent",llm_config_id:null}),[d,h]=w.useState(!1),[c,p]=w.useState("preset"),[x,k]=w.useState([...s]),[g,S]=w.useState(!1),{data:m}=je({queryKey:["agent-schema"],queryFn:()=>Bm.getAgentSchema()}),{data:f=[]}=je({queryKey:["llm-configs"],queryFn:()=>h0.list()}),{data:v}=je({queryKey:["tools"],queryFn:()=>m0.list()}),j=((Q=v==null?void 0:v.tools)==null?void 0:Q.map(M=>M.name))??s,C=(v==null?void 0:v.presets)??{},b=Object.keys(C),N=(m==null?void 0:m.frameworks)??{},_=Object.keys(N).length>0?Object.keys(N):_0,F=o.framework||"miniagent",O=((R=(ee=m==null?void 0:m.frameworks)==null?void 0:ee[F])==null?void 0:R.compaction_strategies)??["none","head_tail"],B=(m==null?void 0:m.compaction_strategies)??{},G=(m==null?void 0:m.agent_presets)??[],re=M=>{const K=M.config,dt=K.compaction;n({name:M.name+"-agent",description:M.description,framework:K.framework||"miniagent",tools:K.tools||"standard",compaction:dt||{strategy:"none",params:{}},instructions:K.instructions||null})},he=M=>{if(M.preventDefault(),!o.name.trim())return;const K={...o};c==="custom"&&(K.tools=x),n(K)},D=((T=o.compaction)==null?void 0:T.strategy)!=="none",q=((te=o.compaction)==null?void 0:te.strategy)||"none",Y=B[q],P=M=>{k(K=>K.includes(M)?K.filter(dt=>dt!==M):[...K,M])},A=M=>{const K=B[M],dt={};if(K!=null&&K.params)for(const[as,is]of Object.entries(K.params))is.default!==void 0&&(dt[as]=is.default);u({...o,compaction:{strategy:M,params:dt}})},L=a==="custom"?i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(V,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(V,{type:"submit",form:"create-agent-form",variant:"primary",disabled:!o.name.trim(),loading:r,children:"Create Agent"})]}):i.jsx("div",{className:"flex justify-end gap-2",children:i.jsx(V,{type:"button",variant:"secondary",onClick:t,children:"Cancel"})});return i.jsxs(ss,{isOpen:e,onClose:t,title:"Create Agent",footer:L,children:[i.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b border-[var(--border)]",children:[i.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${a==="preset"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("preset"),children:"From Preset"}),i.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${a==="custom"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("custom"),children:"Custom"})]}),a==="preset"?i.jsx("div",{className:"space-y-3",children:G.length===0?i.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"Loading presets..."}):G.map(M=>i.jsx("button",{type:"button",className:"w-full text-left p-4 border border-[var(--border)] rounded-lg hover:border-[var(--accent)] hover:bg-[var(--accent)]/5 transition-colors",onClick:()=>re(M),disabled:r,children:i.jsxs("div",{className:"flex items-start justify-between",children:[i.jsxs("div",{className:"flex-1",children:[i.jsx("h4",{className:"font-medium",children:M.label}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:M.description}),i.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[M.tags.map(K=>i.jsx(Z,{variant:"default",children:K},K)),M.suggested_datasets.length>0&&i.jsxs(Z,{variant:"success",children:["datasets: ",M.suggested_datasets.join(", ")]})]})]}),i.jsx(Ys,{size:16,className:"text-[var(--text-secondary)] mt-1 flex-shrink-0"})]})},M.name))}):i.jsxs("form",{id:"create-agent-form",onSubmit:he,className:"space-y-4",children:[i.jsx(pn,{label:"Name",value:o.name,onChange:M=>u({...o,name:M.target.value}),placeholder:"e.g., my-coding-agent",required:!0}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"LLM Configuration"}),i.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.llm_config_id||"",onChange:M=>u({...o,llm_config_id:M.target.value||null}),children:[i.jsx("option",{value:"",children:"Use environment variables"}),f.map(M=>i.jsxs("option",{value:M.id,children:[M.name," (",P0[M.provider],M.model_id?` - ${M.model_id}`:"",")",M.is_default?" (default)":""]},M.id))]}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:f.length===0?"No LLM configs found. Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)":o.llm_config_id?"Uses the selected LLM configuration.":"Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)"})]}),i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Framework"}),i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.framework||"miniagent",onChange:M=>{const K=M.target.value;u({...o,framework:K,compaction:{strategy:"none",params:{}}})},children:_.map(M=>{var K;return i.jsx("option",{value:M,children:((K=N[M])==null?void 0:K.label)||E0[M]||M},M)})}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((me=N[F])==null?void 0:me.description)||(F==="miniagent"?"Lightweight agent with token-aware context management.":F==="langgraph"?"Graph-based workflows with state management.":"Default agent implementation.")})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(wi,{label:"Custom instructions",checked:d,onChange:M=>{h(M.target.checked),M.target.checked||u({...o,instructions:null})}}),i.jsx(wi,{label:"Enable compaction",checked:D,onChange:M=>{if(M.target.checked){const K=O.find(dt=>dt!=="none")||"head_tail";A(K)}else u({...o,compaction:{strategy:"none",params:{}}})}})]}),d&&i.jsx("textarea",{className:"w-full h-32 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono resize-y",value:o.instructions||"",onChange:M=>u({...o,instructions:M.target.value||null}),placeholder:"System prompt / instructions for the agent..."}),D&&i.jsxs("div",{className:"space-y-3 p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Compaction Strategy"}),i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:q,onChange:M=>A(M.target.value),children:O.filter(M=>M!=="none").map(M=>{var K;return i.jsx("option",{value:M,children:((K=B[M])==null?void 0:K.label)||M},M)})}),(Y==null?void 0:Y.description)&&i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:Y.description})]}),(Y==null?void 0:Y.params)&&Object.keys(Y.params).length>0&&i.jsx("div",{className:"grid grid-cols-2 gap-3",children:Object.entries(Y.params).map(([M,K])=>{var is;const dt=(is=o.compaction)==null?void 0:is.params[M],as=dt!==void 0?dt:K.default;return i.jsxs("div",{children:[i.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:M.replace(/_/g," ")}),i.jsx("input",{type:"number",className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof as=="number"?as:Number(as)||0,onChange:Jm=>{const Ju=parseFloat(Jm.target.value);u({...o,compaction:{...o.compaction,params:{...o.compaction.params,[M]:isNaN(Ju)?typeof K.default=="number"?K.default:0:Ju}}})},min:K.min,max:K.max,step:K.max&&K.max<=1?.1:1}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:K.description})]},M)})})]}),i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm font-medium",children:"Tools"}),i.jsxs("div",{className:"flex gap-4",children:[i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"radio",checked:c==="preset",onChange:()=>p("preset"),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:"Preset"})]}),i.jsxs("label",{className:"flex items-center gap-2",children:[i.jsx("input",{type:"radio",checked:c==="custom",onChange:()=>p("custom"),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:"Custom"})]})]}),c==="preset"?i.jsxs(i.Fragment,{children:[i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof o.tools=="string"?o.tools:"standard",onChange:M=>u({...o,tools:M.target.value}),children:b.map(M=>i.jsx("option",{value:M,children:M},M))}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((be=C[typeof o.tools=="string"?o.tools:"standard"])==null?void 0:be.join(", "))??""})]}):i.jsx("div",{className:"grid grid-cols-2 gap-1 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:j.map(M=>i.jsxs("label",{className:"flex items-center gap-2 p-1 text-sm cursor-pointer hover:bg-[var(--bg-tertiary)]",children:[i.jsx("input",{type:"checkbox",checked:x.includes(M),onChange:()=>P(M),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"font-mono text-xs",children:M})]},M))})]}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[i.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>S(!g),children:[i.jsx(Ys,{size:14,className:`transition-transform ${g?"rotate-90":""}`}),"More options"]}),g&&i.jsx("div",{className:"mt-3",children:i.jsx(pn,{label:"Description (optional)",value:o.description,onChange:M=>u({...o,description:M.target.value}),placeholder:"Brief description of this agent"})})]})]})]})}function D0({agent:e,isOpen:t,onClose:n}){var R;const r=or(),s=qt(),[a,l]=w.useState("ready"),[o,u]=w.useState("quick"),[d,h]=w.useState(!1),[c,p]=w.useState([]),[x,k]=w.useState(!1),[g,S]=w.useState(Do),[m,f]=w.useState(4),[v,j]=w.useState(100),[C,b]=w.useState(!1),[N,_]=w.useState(null),{data:F=[]}=je({queryKey:["tasks"],queryFn:()=>Et.list()}),{data:O=[]}=je({queryKey:["suites"],queryFn:()=>Et.listSuites()}),{data:B}=je({queryKey:["agent-schema"],queryFn:()=>Bm.getAgentSchema()}),G=O.map(T=>({value:T.name,label:T.name.charAt(0).toUpperCase()+T.name.slice(1),description:T.description,tasks:T.task_count})),re=Je({mutationFn:Et.importSuite,onSuccess:T=>{s.invalidateQueries({queryKey:["tasks"]}),p(T.map(te=>te.id))}}),he=Je({mutationFn:async T=>{const te=await Ut.create(T);return Ut.start(te.id).next(),te},onSuccess:T=>{s.invalidateQueries({queryKey:["jobs"]}),_(T.id),l("success")}}),q=x?(()=>{let T=1;g.compaction.length>0&&(T*=g.compaction.length),g.tools.length>0&&(T*=g.tools.length),g.llm_config.length>0&&(T*=g.llm_config.length);const te=g.instructions.length+g.instruction_strategies.reduce((me,be)=>me+be.max_candidates,0);return te>0&&(T*=te),Math.min(T,v)})():1,Y=d?c.length:((R=G.find(T=>T.value===o))==null?void 0:R.tasks)||3,P=q*Y,A=async()=>{l("starting");let T=c;if(!d)try{T=(await re.mutateAsync(o)).map(K=>K.id)}catch(M){console.error("Failed to import suite:",M),alert(`Failed to import task suite: ${o}`),l("ready");return}if(T.length===0){alert("No tasks selected. Please select tasks or choose a task suite."),l("ready");return}let te;if(x&&(g.compaction.length>0||g.tools.length>0||g.llm_config.length>0||g.instructions.length>0||g.instruction_strategies.length>0))try{te=(await Io.generateCandidates({base_agent_id:e.id,variations:g,budget:v})).candidate_ids}catch(M){console.error("Failed to generate candidates:",M),alert(`Failed to generate candidates: ${M instanceof Error?M.message:"Unknown error"}`),l("ready");return}else te=[e.id];const be={name:`${e.name} optimization (${te.length} candidates × ${T.length} tasks)`,candidate_ids:te,task_ids:T,parallel:m,use_llm_eval:C};he.mutate(be)},L=T=>{p(te=>te.includes(T)?te.filter(me=>me!==T):[...te,T])},Q=()=>{l("ready"),_(null),k(!1),S(Do),n()},ee=()=>a==="success"&&N?i.jsxs("div",{className:"flex justify-end gap-3",children:[i.jsx(V,{variant:"secondary",onClick:Q,children:"Close"}),i.jsx(V,{variant:"primary",icon:Xs,onClick:()=>{Q(),r(`/jobs/${N}`)},children:"View Job"})]}):a==="starting"?null:i.jsxs("div",{className:"flex justify-end gap-2",children:[i.jsx(V,{variant:"secondary",onClick:n,children:"Cancel"}),i.jsxs(V,{variant:"primary",icon:Xs,onClick:A,disabled:d&&c.length===0,children:["Start Optimization (",P," runs)"]})]});return i.jsx(ss,{isOpen:t,onClose:Q,title:`Optimize: ${e.name}`,footer:ee(),size:"lg",children:a==="success"&&N?i.jsxs("div",{className:"flex flex-col items-center py-8",children:[i.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/20 flex items-center justify-center mb-4",children:i.jsx(Bi,{size:24,className:"text-green-500"})}),i.jsx("h3",{className:"text-lg font-medium mb-2",children:"Job Started!"}),i.jsx("p",{className:"text-[var(--text-secondary)] text-center mb-2",children:"Optimization job is now running"}),i.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-3 py-1.5 rounded font-mono",children:["ID: ",N.slice(0,8),"..."]})]}):a==="starting"?i.jsxs("div",{className:"flex flex-col items-center py-8",children:[i.jsx(fa,{size:32,className:"animate-spin text-[var(--accent)] mb-4"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:re.isPending?"Importing tasks...":"Creating optimization job..."})]}):i.jsxs("div",{className:"space-y-5",children:[i.jsxs("div",{children:[i.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Task Suite"}),i.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:d?"__custom__":o,onChange:T=>{T.target.value==="__custom__"?h(!0):(h(!1),u(T.target.value))},children:[G.map(T=>i.jsxs("option",{value:T.value,children:[T.label," (",T.tasks," tasks) — ",T.description]},T.value)),F.length>0&&i.jsx("option",{value:"__custom__",children:"Custom Selection"})]})]}),d&&F.length>0&&i.jsx("div",{className:"max-h-48 overflow-y-auto border border-[var(--border)] rounded p-2 space-y-1",children:F.map(T=>i.jsxs("label",{className:"flex items-center gap-2 p-2 hover:bg-[var(--bg-tertiary)] cursor-pointer rounded",children:[i.jsx("input",{type:"checkbox",checked:c.includes(T.id),onChange:()=>L(T.id),className:"accent-[var(--accent)]"}),i.jsx("span",{className:"text-sm",children:T.name}),T.suite&&i.jsx(Z,{children:T.suite})]},T.id))}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[i.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>k(!x),children:[i.jsx(Ys,{size:14,className:`transition-transform ${x?"rotate-90":""}`}),"Advanced Settings",x&&i.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"(experiment design, variations, execution)"})]}),x&&B&&i.jsx("div",{className:"mt-4",children:i.jsx(z0,{agentId:e.id,agentName:e.name,agentFramework:e.config.framework,taskSuite:d?void 0:o,taskCount:Y,schema:B,onVariationsChange:S,parallel:m,onParallelChange:f,budget:v,onBudgetChange:j,useLlmEval:C,onUseLlmEvalChange:b})})]})]})})}function Hi({items:e}){return i.jsx("nav",{className:"flex items-center gap-1.5 text-sm mb-4",children:e.map((t,n)=>{const r=n===e.length-1;return i.jsxs("span",{className:"flex items-center gap-1.5",children:[n>0&&i.jsx(Ys,{size:14,className:"text-[var(--text-secondary)]"}),t.path&&!r?i.jsx(sr,{to:t.path,className:"text-[var(--text-secondary)] hover:text-[var(--accent)] transition-colors",children:t.label}):i.jsx("span",{className:r?"text-[var(--text-primary)] font-medium":"text-[var(--text-secondary)]",children:t.label})]},n)})})}function ye({children:e,className:t="",onClick:n,selected:r=!1,selectable:s=!1}){const a="bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",l=s?"cursor-pointer hover:border-[var(--accent-dim)] transition-colors":"",o=r?"border-[var(--accent)]":"";return i.jsx("div",{className:`${a} ${l} ${o} ${t}`,onClick:n,children:e})}function A0(e){const t=[],n=r=>r.type==="trace_span"&&typeof r.data=="object"&&r.data!==null?r.data:"span_id"in r?r:null;if(Array.isArray(e.spans)){for(const r of e.spans)if(typeof r=="object"&&r!==null){const s=n(r);s&&t.push(s)}}else if(e.span_id)t.push(e);else for(const r in e){const s=e[r];if(typeof s=="object"&&s!==null){const a=n(s);if(a)t.push(a);else if(Array.isArray(s)){for(const l of s)if(typeof l=="object"&&l!==null){const o=n(l);o&&t.push(o)}}}}return t}function Km(e){const t=new Map,n=[];for(const s of e)t.set(s.span_id,{span:s,children:[]});for(const s of e){const a=t.get(s.span_id);s.parent_span_id&&t.has(s.parent_span_id)?t.get(s.parent_span_id).children.push(a):n.push(a)}const r=s=>{s.sort((a,l)=>(a.span.start_time||0)-(l.span.start_time||0)),s.forEach(a=>r(a.children))};return r(n),n}function $0(e){return e.includes("Agent")||e.includes("agent")?"bg-[var(--span-llm-bg)] text-[var(--span-llm-text)]":e.includes("chat")||e.includes("Chat")||e.includes("llm")?"bg-[var(--span-tool-bg)] text-[var(--span-tool-text)]":e.includes("tool")||e.includes("execute")||e.includes("bash")?"bg-[var(--span-agent-bg)] text-[var(--span-agent-text)]":"bg-[var(--span-other-bg)] text-[var(--span-other-text)]"}function U0(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(0)}ms`}function Gu({node:e,depth:t=0}){var c,p;const[n,r]=w.useState(t<2),[s,a]=w.useState(!1),{span:l}=e,o=e.children.length>0,u=(c=l.attributes)==null?void 0:c["gen_ai.usage.input_tokens"],d=(p=l.attributes)==null?void 0:p["gen_ai.usage.output_tokens"],h=u!==void 0||d!==void 0;return i.jsxs("div",{className:"relative",children:[t>0&&i.jsx("div",{className:"absolute left-0 top-0 bottom-0 border-l-2 border-[var(--border)]",style:{marginLeft:`${(t-1)*16+8}px`}}),i.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-1 hover:bg-[var(--bg-primary)] rounded transition-colors cursor-pointer",style:{paddingLeft:`${t*16}px`},onClick:()=>o?r(!n):a(!s),children:[i.jsx("div",{className:"w-4 h-4 flex items-center justify-center text-[var(--text-secondary)]",children:o?n?"▼":"▶":s?"▼":"▶"}),i.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${$0(l.operation_name)}`,children:l.operation_name.replace("ChatAgent.","").replace("invoke_agent ","")}),l.duration_ms!==void 0&&i.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:U0(l.duration_ms)}),h&&i.jsxs("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:[u!==void 0&&i.jsxs("span",{className:"text-blue-400",children:["↑",String(u)]}),u!==void 0&&d!==void 0&&i.jsx("span",{className:"mx-0.5",children:"/"}),d!==void 0&&i.jsxs("span",{className:"text-green-400",children:["↓",String(d)]})]})]}),s&&!o&&i.jsx("div",{className:"ml-4 mt-1 mb-2 p-2 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs",style:{marginLeft:`${t*16+20}px`},children:i.jsxs("div",{className:"space-y-1",children:[l.span_id&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Span ID:"}),i.jsx("span",{className:"font-mono text-xs break-all",children:l.span_id})]}),l.trace_id&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Trace ID:"}),i.jsx("span",{className:"font-mono text-xs break-all",children:l.trace_id})]}),l.status&&i.jsxs("div",{className:"flex gap-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Status:"}),i.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs ${l.status==="OK"||l.status==="StatusCode.UNSET"?"bg-[var(--span-pass-bg)] text-[var(--span-pass-text)]":"bg-[var(--span-fail-bg)] text-[var(--span-fail-text)]"}`,children:l.status})]}),Object.keys(l.attributes||{}).length>0&&i.jsxs("div",{className:"mt-2",children:[i.jsx("span",{className:"text-[var(--text-secondary)] block mb-1",children:"Attributes:"}),i.jsx("pre",{className:"text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded p-2 overflow-auto max-h-32 whitespace-pre-wrap break-all",children:JSON.stringify(l.attributes,null,2)})]})]})}),o&&n&&i.jsx("div",{children:e.children.map((x,k)=>i.jsx(Gu,{node:x,depth:t+1},x.span.span_id||k))})]})}function Hm({trace:e}){const[t,n]=w.useState("tree"),r=w.useMemo(()=>A0(e),[e]),s=w.useMemo(()=>Km(r),[r]);return Object.keys(e).length===0?null:i.jsxs(ye,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h3",{className:"font-medium",children:"Trace Data"}),i.jsxs("div",{className:"flex gap-1",children:[i.jsx("button",{onClick:()=>n("tree"),className:`px-2 py-1 text-xs rounded ${t==="tree"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Tree"}),i.jsx("button",{onClick:()=>n("raw"),className:`px-2 py-1 text-xs rounded ${t==="raw"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Raw"})]})]}),t==="tree"?r.length>0?i.jsx("div",{className:"border border-[var(--border)] rounded overflow-hidden",children:i.jsxs("div",{className:"p-2",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs(Z,{variant:"default",children:[r.length," spans"]}),i.jsx("span",{children:"•"}),i.jsx("span",{children:"Click to expand details"})]}),s.map((a,l)=>i.jsx(Gu,{node:a,depth:0},a.span.span_id||l))]})}):i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No structured spans found. View raw data below."}):i.jsx("pre",{className:"text-xs bg-[var(--bg-primary)] p-3 overflow-x-auto border border-[var(--border)] max-h-96 whitespace-pre-wrap",children:JSON.stringify(e,null,2)})]})}function B0({spans:e,isLive:t=!1}){const n=w.useRef(null),r=w.useMemo(()=>Km(e),[e]);return w.useEffect(()=>{n.current&&t&&n.current.scrollTo({top:n.current.scrollHeight,behavior:"smooth"})},[e.length,t]),i.jsxs("div",{className:"border border-[var(--border)] rounded overflow-hidden h-full flex flex-col",children:[i.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-[var(--border)] bg-[var(--bg-secondary)]",children:[i.jsxs(Z,{variant:"default",children:[e.length," spans"]}),t&&i.jsx("span",{className:"animate-pulse",children:i.jsx(Z,{variant:"info",children:"Live"})})]}),i.jsx("div",{ref:n,className:"flex-1 overflow-auto p-2",children:r.length>0?r.map((s,a)=>i.jsx(Gu,{node:s,depth:0},s.span.span_id||a)):i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:t?"Waiting for spans...":"No spans recorded"})})]})}function Q0({agent:e}){const[t,n]=w.useState(""),[r,s]=w.useState(null),[a,l]=w.useState("idle"),[o,u]=w.useState(null),[d,h]=w.useState(""),[c,p]=w.useState([]),[x,k]=w.useState(null),[g,S]=w.useState(null),[m,f]=w.useState([]),[v,j]=w.useState(!1),C=w.useRef(null),{data:b=[]}=je({queryKey:["tasks"],queryFn:()=>Et.list()});w.useEffect(()=>{C.current&&a==="running"&&(C.current.scrollTop=C.current.scrollHeight)},[d,a]);const N=D=>{if(s(D),D){const q=b.find(Y=>Y.id===D);q&&n(q.prompt)}},_=async()=>{if(t.trim()){l("running"),h(""),p([]),k(null),S(null),f([]);try{const D=await Ts.create({agent_id:e.id,prompt:t.trim(),task_id:r||void 0});u(D.id);for await(const q of Ts.start(D.id))F(q)}catch(D){S(D instanceof Error?D.message:"Test failed"),l("failed")}}},F=D=>{switch(D.event){case"started":break;case"execution":D.execution_event==="text_delta"&&D.content?h(q=>q+D.content):D.execution_event==="tool_call_start"&&D.tool_name?f(q=>[...q,{name:D.tool_name}]):D.execution_event==="tool_result"&&D.content&&f(q=>{if(q.length>0){const Y=[...q];return Y[Y.length-1]={...Y[Y.length-1],content:D.content},Y}return q});break;case"span":if(D.span){const q=D.span;if(q.data){const Y={span_id:q.data.span_id||"",trace_id:q.data.trace_id||"",parent_span_id:q.data.parent_span_id||null,operation_name:q.data.operation_name||"",start_time:q.timestamp?new Date(q.timestamp).getTime():Date.now(),end_time:Date.now(),duration_ms:q.data.duration_ms||0,status:q.data.status||"OK",attributes:q.data.attributes||{}};p(P=>[...P,Y])}}break;case"complete":l("completed"),D.result&&k(D.result);break;case"error":S(D.message),l("failed");break}},O=async()=>{if(o)try{await Ts.cancel(o)}catch{}l("idle")},B=()=>{l("idle"),u(null),h(""),p([]),k(null),S(null),f([])},G=a==="running",re=a==="completed"||a==="failed",he=D=>{D.preventDefault(),re?(B(),setTimeout(()=>_(),0)):_()};return i.jsxs("div",{className:"h-full flex flex-col border border-[var(--border)] rounded-lg overflow-hidden bg-[var(--bg-primary)]",children:[(G||re)&&i.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border)] bg-[var(--bg-secondary)] flex-shrink-0",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[G&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"animate-pulse",children:i.jsx(Z,{variant:"info",children:"Running"})}),i.jsx(V,{variant:"ghost",size:"sm",icon:_d,onClick:O,children:"Cancel"})]}),a==="completed"&&i.jsx(Z,{variant:"success",children:"Completed"}),a==="failed"&&i.jsx(Z,{variant:"error",children:"Failed"})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[x&&i.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Sg,{size:12}),x.duration_seconds.toFixed(2),"s"]}),i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(Ng,{size:12}),x.tokens_total," tokens"]}),x.passed!==null&&(x.passed?i.jsx(Lm,{size:14,className:"text-[var(--success)]"}):i.jsx(Ag,{size:14,className:"text-[var(--error)]"}))]}),c.length>0&&i.jsxs(V,{variant:v?"primary":"secondary",size:"sm",icon:pg,onClick:()=>j(!v),children:["Traces (",c.length,")"]}),re&&o&&i.jsx(sr,{to:`/tests/${o}`,children:i.jsx(V,{variant:"secondary",size:"sm",icon:_g,children:"Details"})})]})]}),i.jsxs("div",{className:"flex-1 min-h-0 flex",children:[i.jsx("div",{ref:C,className:`flex-1 overflow-auto p-4 ${v?"border-r border-[var(--border)]":""}`,children:!G&&!re?i.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center",children:[i.jsx("div",{className:"text-lg font-medium mb-1",children:e.name}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] max-w-sm",children:"Send a message to test this agent, or select a task from the dropdown below."})]}):i.jsxs("div",{className:"space-y-3",children:[i.jsx("div",{className:"flex justify-end",children:i.jsx("div",{className:"max-w-[80%] px-3 py-2 bg-[var(--accent-dim)] text-[var(--text-primary)] rounded-lg text-sm",children:t})}),(d||G)&&i.jsx("div",{className:"px-3 py-2 text-sm whitespace-pre-wrap font-mono bg-[var(--bg-secondary)] rounded-lg border border-[var(--border)]",children:d||i.jsx("span",{className:"text-[var(--text-secondary)] animate-pulse",children:"Thinking..."})}),m.length>0&&i.jsx("div",{className:"space-y-1.5",children:m.map((D,q)=>i.jsxs("div",{className:"p-2 bg-[var(--badge-info-bg)] border border-[var(--badge-info-border)] rounded-md text-xs",children:[i.jsx(Z,{variant:"info",children:D.name}),D.content&&i.jsxs("div",{className:"mt-1 text-[var(--text-secondary)] truncate max-w-full font-mono",children:[D.content.substring(0,200),D.content.length>200&&"..."]})]},q))}),g&&i.jsx("div",{className:"p-3 bg-[var(--badge-error-bg)] border border-[var(--badge-error-border)] rounded-md text-sm text-[var(--badge-error-text)]",children:g})]})}),v&&i.jsx("div",{className:"w-[350px] flex-shrink-0 overflow-auto",children:i.jsx(B0,{spans:c,isLive:G})})]}),i.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] bg-[var(--bg-secondary)]",children:[i.jsx("div",{className:"px-4 pt-2",children:i.jsxs("select",{value:r||"",onChange:D=>N(D.target.value||null),className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs text-[var(--text-secondary)]",disabled:G,children:[i.jsx("option",{value:"",children:"Custom prompt..."}),b.map(D=>i.jsx("option",{value:D.id,children:D.name},D.id))]})}),i.jsxs("form",{onSubmit:he,className:"p-3 flex gap-2",children:[i.jsx("textarea",{value:t,onChange:D=>n(D.target.value),placeholder:"Message the agent...",disabled:G,rows:1,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm resize-none min-h-[40px] max-h-[120px] focus:outline-none focus:border-[var(--accent)]",onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),he(D))}}),i.jsx(V,{type:"submit",variant:"primary",icon:G?_d:Xs,disabled:G?!1:!t.trim(),onClick:G?O:void 0,children:G?"Stop":re?"New Test":"Run"})]})]})]})}function V0(){const{agentId:e}=$i(),t=or(),n=qt(),[r,s]=w.useState("overview"),{data:a,isLoading:l}=je({queryKey:["configs",e],queryFn:()=>Tr.get(e),enabled:!!e}),{data:o=[]}=je({queryKey:["tests",{agent_id:e}],queryFn:()=>Ts.list({agent_id:e}),enabled:!!e}),{data:u=[]}=je({queryKey:["jobs"],queryFn:()=>Ut.list()}),d=Je({mutationFn:c=>Tr.delete(c),onSuccess:()=>{n.invalidateQueries({queryKey:["configs"]}),t("/agents")}}),h=u.filter(c=>c.candidate_ids.includes(e||""));return l?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):a?i.jsxs("div",{className:"h-full flex flex-col",children:[i.jsxs("div",{className:"mb-4 flex-shrink-0",children:[i.jsx(Hi,{items:[{label:"Agents",path:"/agents"},{label:a.name}]}),i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:a.name}),a.is_auto_generated&&i.jsx(Z,{variant:"info",children:"Auto-generated"})]}),i.jsx("div",{className:"flex gap-2",children:i.jsx(V,{variant:"secondary",icon:Qu,size:"sm",onClick:()=>{confirm(`Delete agent "${a.name}"?`)&&d.mutate(a.id)},children:"Delete"})})]}),a.description&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:a.description})]}),i.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[i.jsxs("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:[i.jsxs("div",{className:"flex gap-1 mb-4 border-b border-[var(--border)] flex-shrink-0",children:[i.jsx(kl,{active:r==="overview",onClick:()=>s("overview"),icon:i.jsx(Mm,{size:14}),children:"Overview"}),i.jsx(kl,{active:r==="evaluate",onClick:()=>s("evaluate"),icon:i.jsx(Xs,{size:14}),children:"Evaluate"}),i.jsx(kl,{active:r==="history",onClick:()=>s("history"),icon:i.jsx(Og,{size:14}),badge:o.length,children:"History"})]}),i.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r==="overview"&&i.jsx(K0,{agent:a,recentTests:o,jobs:h}),r==="evaluate"&&i.jsx(H0,{agent:a,jobs:h}),r==="history"&&i.jsx(W0,{tests:o})]})]}),i.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[i.jsx(Fg,{size:16,className:"text-[var(--text-secondary)]"}),i.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),i.jsx("div",{className:"flex-1 min-h-0",children:i.jsx(Q0,{agent:a})})]})]})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Agent not found"})}function kl({active:e,onClick:t,icon:n,badge:r,children:s}){return i.jsxs("button",{onClick:t,className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors ${e?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[n,s,r!==void 0&&r>0&&i.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs bg-[var(--bg-tertiary)] rounded",children:r})]})}function K0({agent:e,recentTests:t,jobs:n}){var a,l;const r=e.config,s=()=>{const o=r.tools;return typeof o=="string"?o:Array.isArray(o)?o.join(", "):o&&typeof o=="object"?Object.keys(o).join(", "):"standard"};return i.jsxs("div",{className:"space-y-4",children:[i.jsx(dr,{title:"Model",children:i.jsx("div",{className:"font-mono text-sm",children:r.model||"default"})}),i.jsx(dr,{title:"Instructions",defaultCollapsed:!r.instructions,children:r.instructions?i.jsx("pre",{className:"p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs whitespace-pre-wrap max-h-40 overflow-auto font-mono",children:r.instructions}):i.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No instructions set"})}),i.jsx(dr,{title:"Tools",children:i.jsx("div",{className:"font-mono text-sm",children:s()})}),i.jsx(dr,{title:"Compaction",children:i.jsx("div",{className:"font-mono text-sm",children:!r.compaction||r.compaction.strategy==="none"?"disabled":`${r.compaction.strategy} (${((a=r.compaction.params)==null?void 0:a.head_size)||0}/${((l=r.compaction.params)==null?void 0:l.tail_size)||0})`})}),t.length>0&&i.jsx(dr,{title:`Recent Tests (${t.length})`,children:i.jsx("div",{className:"space-y-1.5",children:t.slice(0,3).map(o=>i.jsxs(sr,{to:`/tests/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[i.jsx(Wm,{status:o.status}),i.jsxs("span",{className:"truncate",children:[o.prompt.slice(0,40),"..."]})]}),i.jsxs("span",{className:"text-[var(--text-secondary)] flex-shrink-0 ml-2",children:[o.duration_seconds.toFixed(1),"s"]})]},o.id))})}),n.length>0&&i.jsx(dr,{title:`Experiments (${n.length})`,children:i.jsx("div",{className:"space-y-1.5",children:n.slice(0,3).map(o=>i.jsxs(sr,{to:`/jobs/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Z,{variant:o.status==="completed"?"success":o.status==="running"?"info":"default",children:o.status}),i.jsx("span",{children:o.name})]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(o.created_at).toLocaleDateString()})]},o.id))})})]})}function dr({title:e,children:t,defaultCollapsed:n=!1}){const[r,s]=w.useState(n);return i.jsxs("div",{className:"border-b border-[var(--border)] pb-3",children:[i.jsxs("button",{onClick:()=>s(!r),className:"flex items-center justify-between w-full text-left py-1 hover:text-[var(--accent)] transition-colors",children:[i.jsx("span",{className:"text-sm font-medium",children:e}),i.jsx("span",{className:"text-[var(--text-secondary)] text-xs",children:r?"▶":"▼"})]}),!r&&i.jsx("div",{className:"mt-2",children:t})]})}function H0({agent:e,jobs:t}){const n=or(),r=qt(),[s,a]=w.useState("quick"),[l,o]=w.useState(!1),{data:u=[]}=je({queryKey:["suites"],queryFn:()=>Et.listSuites()}),d=Je({mutationFn:p0.start,onSuccess:c=>{r.invalidateQueries({queryKey:["jobs"]}),o(!1),n(`/jobs/${c.id}`)},onError:()=>{o(!1)}}),h=()=>{o(!0),d.mutate({agent_id:e.id,suite_name:s,use_llm_eval:!0,parallel:4})};return i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:"Run this agent on a task suite to measure quality and cost."}),i.jsxs("div",{className:"space-y-3",children:[i.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm",value:s,onChange:c=>a(c.target.value),disabled:l,children:u.map(c=>i.jsxs("option",{value:c.name,children:[c.name.charAt(0).toUpperCase()+c.name.slice(1)," (",c.task_count," tasks)"]},c.name))}),i.jsx(V,{variant:"primary",icon:l?fa:Xs,onClick:h,disabled:l,loading:l,className:"w-full",children:"Evaluate"})]})]}),i.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[i.jsxs("div",{className:"flex items-center justify-between mb-3",children:[i.jsx("h4",{className:"text-sm font-medium",children:"Optimization Jobs"}),i.jsx(V,{variant:"secondary",size:"sm",icon:Bi,onClick:()=>n("/agents",{state:{optimizeAgent:e}}),children:"New Job"})]}),t.length===0?i.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No optimization jobs yet."}):i.jsx("div",{className:"space-y-1.5",children:t.slice(0,5).map(c=>i.jsxs(sr,{to:`/jobs/${c.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(Z,{variant:c.status==="completed"?"success":c.status==="running"?"info":"default",children:c.status}),i.jsx("span",{children:c.name})]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(c.created_at).toLocaleDateString()})]},c.id))})]})]})}function W0({tests:e}){return e.length===0?i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No test history yet. Use the playground on the right to run a test."}):i.jsx("div",{className:"space-y-2",children:e.map(t=>i.jsxs(sr,{to:`/tests/${t.id}`,className:"flex items-center justify-between p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors",children:[i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(Wm,{status:t.status}),t.score!==null&&i.jsxs("span",{className:`text-sm font-medium ${t.passed?"text-[var(--success)]":"text-[var(--error)]"}`,children:[(t.score*100).toFixed(0),"%"]})]}),i.jsx("p",{className:"text-sm truncate",children:t.prompt})]}),i.jsxs("div",{className:"flex flex-col items-end gap-1 ml-4",children:[i.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:new Date(t.created_at).toLocaleString()}),i.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:[t.duration_seconds.toFixed(1),"s"]}),i.jsxs("span",{children:[t.tokens_total," tokens"]})]})]})]},t.id))})}function Wm({status:e}){const t={completed:"success",failed:"error",running:"info",cancelled:"warning",pending:"default"};return i.jsx(Z,{variant:t[e]||"default",children:e})}function q0(){const e=qt(),[t,n]=w.useState(!1),[r,s]=w.useState(!1),[a,l]=w.useState(null),[o,u]=w.useState(new Set),d=m=>{u(f=>{const v=new Set(f);return v.has(m)?v.delete(m):v.add(m),v})},{data:h=[],isLoading:c}=je({queryKey:["tasks"],queryFn:()=>Et.list()}),p=Je({mutationFn:Et.create,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),n(!1)}}),x=Je({mutationFn:Et.importSuite,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),s(!1)}}),k=Je({mutationFn:Et.delete,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),l(null)}}),g=h.reduce((m,f)=>{const v=f.suite||"custom";return m[v]||(m[v]=[]),m[v].push(f),m},{}),S=Object.keys(g).sort((m,f)=>m==="custom"?-1:f==="custom"?1:m.localeCompare(f));return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Datasets"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Task datasets for evaluating agent configurations."})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(V,{variant:"secondary",onClick:()=>s(!0),children:"Import Suite"}),i.jsx(V,{variant:"primary",onClick:()=>n(!0),children:"+ New Task"})]})]}),c?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):h.length===0?i.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:"No tasks yet. Create one or import a built-in suite."}):i.jsx("div",{className:"space-y-4",children:S.map(m=>{const f=g[m],v=!o.has(m);return i.jsxs("div",{children:[i.jsxs("button",{onClick:()=>d(m),className:"flex items-center gap-2 py-2 hover:text-[var(--accent)] transition-colors",children:[v?i.jsx(jg,{size:16,className:"text-[var(--text-secondary)]"}):i.jsx(Ys,{size:16,className:"text-[var(--text-secondary)]"}),i.jsx("h3",{className:"text-sm font-medium uppercase tracking-wide",children:m==="custom"?"Custom Tasks":`${m} Suite`}),i.jsx(Z,{variant:m==="custom"?"default":"info",children:f.length})]}),v&&i.jsx("div",{className:"mt-2 border border-[var(--border)] rounded-lg overflow-hidden",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:[i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Name"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Category"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Prompt"}),i.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Criteria"})]})}),i.jsx("tbody",{children:f.map(j=>i.jsxs("tr",{onClick:()=>l(j),className:"border-b border-[var(--border)] last:border-b-0 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors",children:[i.jsx("td",{className:"px-4 py-3",children:i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:j.name})}),i.jsx("td",{className:"px-4 py-3",children:j.category&&j.category!=="default"?i.jsx(Z,{variant:"default",children:j.category}):i.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"})}),i.jsx("td",{className:"px-4 py-3",children:i.jsx("span",{className:"text-[var(--text-secondary)] line-clamp-1 max-w-md",children:j.prompt})}),i.jsx("td",{className:"px-4 py-3 text-[var(--text-secondary)]",children:j.criteria.length>0?j.criteria.length:"--"})]},j.id))})]})})]},m)})}),i.jsx(G0,{task:a,onClose:()=>l(null),onDelete:m=>{confirm("Delete this task?")&&k.mutate(m)}}),i.jsx(J0,{isOpen:t,onClose:()=>n(!1),onSubmit:m=>p.mutate(m),isLoading:p.isPending}),i.jsx(Y0,{isOpen:r,onClose:()=>s(!1),onSubmit:m=>x.mutate(m),isLoading:x.isPending})]})}function G0({task:e,onClose:t,onDelete:n}){const[r,s]=w.useState("prompt");if(!e)return null;const a=i.jsxs("div",{className:"flex justify-between",children:[i.jsx(V,{variant:"ghost",onClick:()=>n(e.id),className:"text-red-500 hover:text-red-600",children:"Delete Task"}),i.jsx(V,{variant:"secondary",onClick:t,children:"Close"})]});return i.jsx(ss,{isOpen:!!e,onClose:t,title:e.name,size:"lg",footer:a,children:i.jsxs("div",{className:"space-y-4",children:[e.category&&e.category!=="default"&&i.jsx("div",{children:i.jsx(Z,{variant:"default",children:e.category})}),i.jsxs("div",{className:"flex gap-1 border-b border-[var(--border)]",children:[i.jsx("button",{onClick:()=>s("prompt"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="prompt"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Prompt"}),i.jsxs("button",{onClick:()=>s("criteria"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="criteria"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:["Eval Criteria (",e.criteria.length,")"]})]}),r==="prompt"&&i.jsx("div",{className:"p-4 bg-[var(--bg-tertiary)] rounded text-sm whitespace-pre-wrap min-h-[200px]",children:e.prompt}),r==="criteria"&&i.jsx("div",{className:"space-y-2 min-h-[200px]",children:e.criteria.length===0?i.jsx("div",{className:"text-[var(--text-secondary)] text-sm p-4",children:"No evaluation criteria defined for this task."}):e.criteria.map(l=>i.jsxs("div",{className:"p-3 bg-[var(--bg-tertiary)] rounded",children:[i.jsx("div",{className:"font-medium text-sm",children:l.name}),l.instruction&&i.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1",children:l.instruction})]},l.name))})]})})}function J0({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,a]=w.useState({name:"",prompt:"",criteria:[],category:"default"}),l=()=>{a({...s,criteria:[...s.criteria,{name:"",instruction:"",weight:1}]})},o=(h,c)=>{const p=[...s.criteria];p[h]={...p[h],...c},a({...s,criteria:p})},u=h=>{a({...s,criteria:s.criteria.filter((c,p)=>p!==h)})},d=h=>{h.preventDefault(),!(!s.name.trim()||!s.prompt.trim())&&n({...s,criteria:s.criteria.filter(c=>c.name.trim()&&c.instruction.trim())})};return i.jsx(ss,{isOpen:e,onClose:t,title:"Create Task",children:i.jsxs("form",{onSubmit:d,className:"space-y-4",children:[i.jsx(pn,{label:"Name",value:s.name,onChange:h=>a({...s,name:h.target.value}),placeholder:"e.g., fizzbuzz",required:!0}),i.jsx(O0,{label:"Prompt",value:s.prompt,onChange:h=>a({...s,prompt:h.target.value}),placeholder:"The task description for the agent...",required:!0}),i.jsx(pn,{label:"Category",value:s.category,onChange:h=>a({...s,category:h.target.value}),placeholder:"e.g., coding, research"}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Evaluation Criteria"}),i.jsx(V,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"+ Add"})]}),i.jsx("div",{className:"space-y-2",children:s.criteria.map((h,c)=>i.jsxs("div",{className:"flex gap-2 items-start",children:[i.jsx(pn,{value:h.name,onChange:p=>o(c,{name:p.target.value}),placeholder:"Name",className:"w-32"}),i.jsx(pn,{value:h.instruction,onChange:p=>o(c,{instruction:p.target.value}),placeholder:"Instruction",className:"flex-1"}),i.jsx(V,{type:"button",variant:"ghost",size:"sm",onClick:()=>u(c),children:"×"})]},c))})]}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(V,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(V,{type:"submit",variant:"primary",disabled:r||!s.name.trim()||!s.prompt.trim(),children:r?"Creating...":"Create"})]})]})})}function Y0({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,a]=w.useState(""),{data:l=[],isLoading:o}=je({queryKey:["suites"],queryFn:()=>Et.listSuites(),enabled:e});return w.useEffect(()=>{l.length>0&&!s&&a(l[0].name)},[l,s]),i.jsx(ss,{isOpen:e,onClose:t,title:"Import Task Suite",children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Import a built-in task suite for evaluation."}),o?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading suites..."}):l.length===0?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"No suites available."}):i.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:l.map(u=>i.jsxs("label",{className:`flex items-center gap-3 p-3 border cursor-pointer ${s===u.name?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[i.jsx("input",{type:"radio",name:"suite",value:u.name,checked:s===u.name,onChange:()=>a(u.name),className:"accent-[var(--accent)]"}),i.jsxs("span",{className:"capitalize",children:[u.name.replace(/_/g," ")," (",u.task_count," tasks) - ",u.description]})]},u.name))}),i.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[i.jsx(V,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),i.jsx(V,{variant:"primary",onClick:()=>n(s),disabled:r||!s,children:r?"Importing...":"Import"})]})]})})}const X0=Vi(e=>({jobs:[],setJobs:t=>e({jobs:t})}));function Z0(){const e=or(),t=qt(),[n,r]=w.useState(!1),{setJobs:s}=X0(),a=Wu(),{data:l=[],isLoading:o}=je({queryKey:["jobs",n],queryFn:()=>Ut.list({include_public:n}),refetchInterval:5e3});w.useEffect(()=>{l.length>0&&s(l)},[l,s]);const u=Je({mutationFn:Ut.delete,onSuccess:()=>t.invalidateQueries({queryKey:["jobs"]})}),d={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"},h=[{key:"name",header:"Name",render:c=>i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:c.name||`Job ${c.id.slice(0,8)}`}),c.is_public&&i.jsx(Uu,{className:"w-3 h-3 ml-2 inline text-[var(--text-secondary)]"})]})},{key:"status",header:"Status",render:c=>i.jsx(Z,{variant:d[c.status]||"default",children:c.status})},{key:"candidates",header:"Candidates",render:c=>i.jsx("span",{children:c.candidate_ids.length})},{key:"tasks",header:"Tasks",render:c=>i.jsx("span",{children:c.task_ids.length})},{key:"runs",header:"Runs",render:c=>i.jsxs("span",{children:[c.completed_experiments,"/",c.total_experiments]})},{key:"created",header:"Created",render:c=>i.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(c.created_at).toLocaleDateString()}),sortable:!0,sortValue:c=>new Date(c.created_at).getTime()},{key:"actions",header:"",className:"w-12",render:c=>!c.user_id||c.user_id==="anonymous"||a&&c.created_by_name===a?i.jsx("div",{onClick:x=>x.stopPropagation(),children:i.jsx(V,{variant:"ghost",size:"sm",icon:Qu,title:"Delete",disabled:c.status==="running",onClick:()=>{confirm("Delete this job?")&&u.mutate(c.id)}})}):null}];return i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"text-xl font-bold",children:"Experiments"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"View and manage optimization experiments. Start new experiments from the Agents page."})]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(wi,{label:"Show public",checked:n,onChange:c=>r(c.target.checked)}),i.jsx(V,{variant:"secondary",onClick:()=>e("/agents"),children:"Go to Agents"})]})]}),o?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):i.jsx(Vm,{columns:h,data:l,onRowClick:c=>e(`/jobs/${c.id}`),searchable:!0,searchPlaceholder:"Search experiments",searchFilter:(c,p)=>(c.name||"").toLowerCase().includes(p.toLowerCase())||c.id.toLowerCase().includes(p.toLowerCase()),emptyMessage:"No experiments yet. Go to Agents page to start an optimization."})]})}function e1(e,t=!0){return Math.abs(e)<10?"text-[var(--text-secondary)]":(t?e<0:e>0)?"text-green-400":"text-red-400"}function t1(e){return`${e>0?"+":""}${e.toFixed(1)}%`}function qm(e,t){return t===0?0:(e-t)/t*100}function ps({label:e,values:t,baselineIndex:n,formatter:r,isLowerBetter:s=!0}){const a=t[n];return i.jsxs("tr",{className:"border-b border-[var(--border)] last:border-0",children:[i.jsx("td",{className:"py-2 pr-4 text-[var(--text-secondary)] text-sm",children:e}),t.map((l,o)=>{const u=qm(l,a),d=o===n;return i.jsxs("td",{className:"py-2 px-4 text-right",children:[i.jsx("div",{className:"font-mono",children:r(l)}),!d&&i.jsx("div",{className:`text-xs ${e1(u,s)}`,children:t1(u)}),d&&i.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"(baseline)"})]},o)})]})}function n1({runs:e,baselineRunId:t}){const n=w.useMemo(()=>{if(t){const a=e.findIndex(l=>l.id===t);if(a>=0)return a}return 0},[e,t]);if(e.length<2)return null;const r=Math.min(...e.map(a=>a.tokens_total)),s=Math.max(...e.map(a=>a.score));return i.jsxs(ye,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-4",children:"Candidate Comparison"}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-[var(--border)]",children:[i.jsx("th",{className:"pb-2 pr-4 text-left text-[var(--text-secondary)] font-medium",children:"Metric"}),e.map((a,l)=>i.jsx("th",{className:"pb-2 px-4 text-right",children:i.jsxs("div",{className:"flex items-center justify-end gap-2",children:[i.jsx("span",{className:"font-medium",children:a.candidate_name}),a.is_pareto&&i.jsx(Z,{variant:"success",children:"Optimal"}),l===n&&i.jsx(Z,{variant:"info",children:"Base"})]})},a.id))]})}),i.jsxs("tbody",{children:[i.jsx(ps,{label:"Total Tokens",values:e.map(a=>a.tokens_total),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ps,{label:"Input Tokens",values:e.map(a=>a.tokens_input),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ps,{label:"Output Tokens",values:e.map(a=>a.tokens_output),baselineIndex:n,formatter:a=>a.toLocaleString(),isLowerBetter:!0}),i.jsx(ps,{label:"Duration",values:e.map(a=>a.duration_seconds),baselineIndex:n,formatter:a=>`${a.toFixed(1)}s`,isLowerBetter:!0}),i.jsx(ps,{label:"Score",values:e.map(a=>a.score*100),baselineIndex:n,formatter:a=>`${a.toFixed(1)}%`,isLowerBetter:!1})]})]})}),i.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[i.jsx("h4",{className:"text-sm font-medium mb-2 text-[var(--text-secondary)]",children:"Key Insights"}),i.jsxs("ul",{className:"text-sm space-y-1 text-[var(--text-secondary)]",children:[e.map(a=>{const l=qm(a.tokens_total,e[n].tokens_total);return a.tokens_total===r&&l<-5?i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-green-400",children:"✓"}),i.jsxs("span",{children:[i.jsx("strong",{children:a.candidate_name})," uses ",Math.abs(l).toFixed(0),"% fewer tokens"]})]},`token-${a.id}`):null}),e.map(a=>a.score===s&&a.passed?i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-green-400",children:"✓"}),i.jsxs("span",{children:[i.jsx("strong",{children:a.candidate_name})," achieved highest score (",(a.score*100).toFixed(0),"%)"]})]},`score-${a.id}`):null),e.filter(a=>a.is_pareto).length>0&&i.jsxs("li",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-purple-400",children:"★"}),i.jsxs("span",{children:["Optimal candidates (best tradeoff):"," ",e.filter(a=>a.is_pareto).map(a=>a.candidate_name).join(", ")]})]})]})]}),i.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[i.jsx("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:"Token Efficiency"}),i.jsx("div",{className:"space-y-2",children:e.map(a=>{const l=a.tokens_total/e[n].tokens_total*100,o=a.tokens_total<=r;return i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-24 text-sm truncate",title:a.candidate_name,children:a.candidate_name}),i.jsx("div",{className:"flex-1 h-6 bg-[var(--bg-primary)] rounded overflow-hidden",children:i.jsx("div",{className:`h-full transition-all duration-300 ${o?"bg-green-500":"bg-blue-500"}`,style:{width:`${Math.min(l,100)}%`}})}),i.jsx("div",{className:"w-20 text-right font-mono text-sm",children:a.tokens_total.toLocaleString()})]},a.id)})})]})]})}function r1({summaries:e,height:t=350}){const n=w.useRef(null),[r,s]=w.useState(600),[a,l]=w.useState("tokens"),[o,u]=w.useState(null),[d,h]=w.useState({x:0,y:0});w.useEffect(()=>{const b=()=>{n.current&&s(n.current.clientWidth)};return b(),window.addEventListener("resize",b),()=>window.removeEventListener("resize",b)},[]);const c={top:30,right:30,bottom:50,left:60},p=r-c.left-c.right,x=t-c.top-c.bottom,k=b=>a==="tokens"?b.avg_tokens:b.avg_duration,{xScale:g,yScale:S,xTicks:m,yTicks:f,paretoLine:v}=w.useMemo(()=>{if(e.length===0||p<=0)return{xScale:()=>0,yScale:()=>0,xTicks:[],yTicks:[],paretoLine:[]};const b=e.map(k),N=e.map(P=>P.avg_score),_=Math.min(...b)*.9,F=Math.max(...b)*1.1,O=Math.min(...N,.5),B=Math.min(Math.max(...N)*1.05,1),G=P=>(P-_)/(F-_)*p,re=P=>x-(P-O)/(B-O)*x,he=Array.from({length:5},(P,A)=>_+A/4*(F-_)),D=Array.from({length:5},(P,A)=>O+A/4*(B-O)),Y=e.filter(P=>P.is_pareto).sort((P,A)=>k(P)-k(A)).map(P=>({x:G(k(P)),y:re(P.avg_score)}));return{xScale:G,yScale:re,xTicks:he,yTicks:D,paretoLine:Y}},[e,p,x,a]);if(e.length===0)return i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No data to display"});const j=b=>a==="tokens"?b>=1e6?`${(b/1e6).toFixed(1)}M`:b>=1e3?`${(b/1e3).toFixed(0)}K`:b.toFixed(0):`${b.toFixed(1)}s`,C=(b,N)=>{var F;const _=(F=n.current)==null?void 0:F.getBoundingClientRect();_&&h({x:N.clientX-_.left,y:N.clientY-_.top}),u(b)};return i.jsxs("div",{ref:n,className:"w-full relative",children:[i.jsx("div",{className:"flex justify-end mb-2",children:i.jsxs("div",{className:"inline-flex rounded border border-[var(--border)] text-xs",children:[i.jsx("button",{className:`px-3 py-1 ${a==="tokens"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("tokens"),children:"Tokens"}),i.jsx("button",{className:`px-3 py-1 ${a==="duration"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("duration"),children:"Latency"})]})}),i.jsx("svg",{width:r,height:t,className:"font-mono text-xs",children:i.jsxs("g",{transform:`translate(${c.left}, ${c.top})`,children:[m.map((b,N)=>i.jsx("line",{x1:g(b),y1:0,x2:g(b),y2:x,stroke:"var(--border)",strokeDasharray:"2,2"},`x-grid-${N}`)),f.map((b,N)=>i.jsx("line",{x1:0,y1:S(b),x2:p,y2:S(b),stroke:"var(--border)",strokeDasharray:"2,2"},`y-grid-${N}`)),v.length>1&&i.jsx("polyline",{points:v.map(b=>`${b.x},${b.y}`).join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.slice().sort((b,N)=>(b.is_pareto?1:0)-(N.is_pareto?1:0)).map(b=>{const N=g(k(b)),_=S(b.avg_score),F=b.is_pareto,O=(o==null?void 0:o.candidate_name)===b.candidate_name;return i.jsxs("g",{onMouseEnter:B=>C(b,B),onMouseLeave:()=>u(null),children:[i.jsx("circle",{cx:N,cy:_,r:O?10:F?8:6,fill:F?"var(--accent)":"transparent",stroke:O?"var(--text-primary)":F?"var(--accent)":"var(--text-secondary)",strokeWidth:O?3:2,className:"cursor-pointer transition-all"}),F&&!O&&i.jsx("text",{x:N,y:_-12,textAnchor:"middle",fill:"var(--text-primary)",fontSize:10,className:"pointer-events-none",children:b.candidate_name.replace(/^baseline_/,"").slice(0,15)})]},b.candidate_name)}),i.jsx("line",{x1:0,y1:x,x2:p,y2:x,stroke:"var(--text-secondary)"}),m.map((b,N)=>i.jsxs("g",{transform:`translate(${g(b)}, ${x})`,children:[i.jsx("line",{y2:5,stroke:"var(--text-secondary)"}),i.jsx("text",{y:20,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:10,children:j(b)})]},`x-tick-${N}`)),i.jsx("text",{x:p/2,y:x+40,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:a==="tokens"?"Tokens (cost)":"Duration (latency)"}),i.jsx("line",{x1:0,y1:0,x2:0,y2:x,stroke:"var(--text-secondary)"}),f.map((b,N)=>i.jsxs("g",{transform:`translate(0, ${S(b)})`,children:[i.jsx("line",{x2:-5,stroke:"var(--text-secondary)"}),i.jsxs("text",{x:-10,textAnchor:"end",dominantBaseline:"middle",fill:"var(--text-secondary)",fontSize:10,children:[(b*100).toFixed(0),"%"]})]},`y-tick-${N}`)),i.jsx("text",{transform:`translate(-45, ${x/2}) rotate(-90)`,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:"Score (quality)"})]})}),o&&i.jsxs("div",{className:"absolute z-10 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg shadow-lg p-3 text-sm pointer-events-none",style:{left:Math.min(d.x+15,r-200),top:d.y-10,maxWidth:220},children:[i.jsx("div",{className:"font-medium text-[var(--text-primary)] truncate mb-2",children:o.candidate_name.replace(/^baseline_/,"")}),i.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Score:"}),i.jsxs("span",{className:"text-right font-medium",children:[(o.avg_score*100).toFixed(1),"%"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tokens:"}),i.jsxs("span",{className:"text-right",children:[(o.avg_tokens/1e3).toFixed(1),"K"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Duration:"}),i.jsxs("span",{className:"text-right",children:[o.avg_duration.toFixed(1),"s"]}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Pass rate:"}),i.jsxs("span",{className:"text-right",children:[o.passed_runs,"/",o.total_runs]})]}),o.is_pareto&&i.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)] text-xs text-[var(--accent)]",children:"Optimal (best tradeoff)"})]})]})}function s1(e=2e3){const[t,n]=w.useState(!1),[r,s]=w.useState(null),a=w.useCallback(async o=>{try{return await navigator.clipboard.writeText(o),n(!0),s(null),setTimeout(()=>n(!1),e),!0}catch{return s("Failed to copy to clipboard"),n(!1),!1}},[e]),l=w.useCallback(()=>{n(!1),s(null)},[]);return{copy:a,copied:t,error:r,reset:l}}function a1({isOpen:e,onClose:t,title:n,itemId:r,itemType:s,isPublic:a,createdByName:l,onTogglePublic:o}){const[u,d]=w.useState(!1),{copy:h,copied:c}=s1(),p=`${window.location.origin}/${s}s/${r}`,x=async()=>{d(!0);try{await o(!a)}finally{d(!1)}},k=()=>{h(p)};return i.jsx(ss,{isOpen:e,onClose:t,title:n,children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between p-3 bg-[var(--bg-tertiary)] rounded",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[a?i.jsx(Uu,{className:"w-5 h-5 text-[var(--accent)]"}):i.jsx(Rm,{className:"w-5 h-5 text-[var(--text-secondary)]"}),i.jsxs("div",{children:[i.jsx("div",{className:"font-medium",children:a?"Public":"Private"}),i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:a?"Anyone with the link can view":"Only you can access"})]})]}),i.jsx("button",{onClick:x,disabled:u,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${a?"bg-[var(--accent)]":"bg-[var(--border)]"} ${u?"opacity-50 cursor-not-allowed":""}`,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${a?"translate-x-6":"translate-x-1"}`})})]}),a&&i.jsxs("div",{className:"space-y-2",children:[i.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Share link"}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx("input",{type:"text",readOnly:!0,value:p,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono"}),i.jsx(V,{variant:"secondary",onClick:k,children:c?i.jsxs(i.Fragment,{children:[i.jsx(gg,{className:"w-4 h-4 mr-1"}),"Copied"]}):i.jsxs(i.Fragment,{children:[i.jsx(bg,{className:"w-4 h-4 mr-1"}),"Copy"]})})]})]}),l&&i.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",i.jsx("span",{className:"text-[var(--text-primary)]",children:l})]}),i.jsx("div",{className:"text-xs text-[var(--text-secondary)] pt-2 border-t border-[var(--border)]",children:a?i.jsxs(i.Fragment,{children:[i.jsxs("p",{children:["Public ",s,"s can be viewed by anyone with the link."]}),i.jsxs("p",{className:"mt-1",children:["Only you can edit or delete this ",s,"."]})]}):i.jsxs("p",{children:["Make this ",s," public to share it with others."]})})]})})}function i1({job:e,onUpdate:t}){const[n,r]=w.useState(!1),s=async a=>{await Ut.update(e.id,{is_public:a}),t()};return i.jsxs(i.Fragment,{children:[i.jsxs(V,{variant:"secondary",size:"sm",onClick:()=>r(!0),title:e.is_public?"Sharing settings":"Share this job",children:[i.jsx(Ig,{className:"w-4 h-4 mr-1"}),e.is_public?"Shared":"Share"]}),i.jsx(a1,{isOpen:n,onClose:()=>r(!1),title:"Share Job",itemId:e.id,itemType:"job",isPublic:e.is_public,createdByName:e.created_by_name,onTogglePublic:s})]})}function l1(){const{jobId:e}=$i(),t=or(),n=qt(),[r,s]=w.useState(null),[a,l]=w.useState(!1),[o,u]=w.useState(null),[d,h]=w.useState([]),[c,p]=w.useState(null),[x,k]=w.useState(null),[g,S]=w.useState("results"),[m,f]=w.useState("score"),[v,j]=w.useState("desc"),[C,b]=w.useState(!1),{data:N,isLoading:_}=je({queryKey:["jobs",e],queryFn:()=>Ut.get(e),enabled:!!e,refetchInterval:a?2e3:!1}),{data:F=[]}=je({queryKey:["runs",e],queryFn:()=>Fo.list({job_id:e}),enabled:!!e,refetchInterval:a?2e3:!1}),{data:O}=je({queryKey:["job-summary",e],queryFn:()=>Fo.getJobSummary(e),enabled:!!e&&(N==null?void 0:N.status)==="completed"}),B=Je({mutationFn:async()=>{l(!0),h([]),p(null),k(null);for await(const R of Ut.start(e))s(R),R.current_candidate&&R.current_task&&p(T=>(T&&(T.candidate!==R.current_candidate||T.task!==R.current_task)&&h(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),{candidate:R.current_candidate,task:R.current_task})),R.event==="error"&&(k(R.message),l(!1),n.invalidateQueries({queryKey:["jobs",e]})),R.event==="complete"&&(p(T=>(T&&h(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),null)),l(!1),n.invalidateQueries({queryKey:["jobs",e]}),n.invalidateQueries({queryKey:["runs",e]}),n.invalidateQueries({queryKey:["job-summary",e]}))}}),G=Je({mutationFn:()=>Ut.cancel(e),onSuccess:()=>{l(!1),n.invalidateQueries({queryKey:["jobs",e]})}});w.useEffect(()=>{(N==null?void 0:N.status)==="running"&&l(!0)},[N==null?void 0:N.status]);const re=w.useMemo(()=>{const R=new Map;for(const T of F)R.has(T.task_name)||R.set(T.task_name,[]),R.get(T.task_name).push(T);return R},[F]),he=w.useMemo(()=>Array.from(re.keys()),[re]),D=w.useMemo(()=>{if(!(O!=null&&O.candidate_summaries))return[];let R=[...O.candidate_summaries];return C&&(R=R.filter(T=>T.is_pareto)),R.sort((T,te)=>{let me,be;switch(m){case"score":me=T.avg_score,be=te.avg_score;break;case"tokens":me=T.avg_tokens,be=te.avg_tokens;break;case"duration":me=T.avg_duration,be=te.avg_duration;break;case"pass_rate":me=T.passed_runs/T.total_runs,be=te.passed_runs/te.total_runs;break}return v==="desc"?be-me:me-be}),R},[O,m,v,C]),q=R=>{m===R?j(v==="desc"?"asc":"desc"):(f(R),j(R==="tokens"||R==="duration"?"asc":"desc"))},Y=({label:R,sortKeyVal:T})=>i.jsx("th",{className:"pb-2 cursor-pointer hover:text-[var(--text-primary)] select-none",onClick:()=>q(T),children:i.jsxs("div",{className:"flex items-center gap-1",children:[R,m===T&&i.jsx(vg,{size:12,className:v==="asc"?"rotate-180":""})]})});if(_)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!N)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Job not found"});const P=Wu(),A=!N.user_id||N.user_id==="anonymous"||P&&N.created_by_name===P,L=N.is_public&&!A,Q=()=>{n.invalidateQueries({queryKey:["jobs",e]})},ee=R=>{const T={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};return i.jsx(Z,{variant:T[R]||"default",children:R})};return i.jsxs("div",{children:[i.jsx(Hi,{items:[{label:"Experiments",path:"/jobs"},{label:N.name||`Job ${N.id.slice(0,8)}`}]}),i.jsxs("div",{className:"flex items-center justify-between mb-6",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:N.name||`Job ${N.id.slice(0,8)}`}),ee(N.status),N.is_public&&i.jsxs(Z,{variant:"info",children:[i.jsx(Uu,{className:"w-3 h-3 mr-1 inline"}),"Public"]})]}),i.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[i.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-2 py-0.5 rounded font-mono text-[var(--text-secondary)]",children:[N.id.slice(0,8),"..."]}),i.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[N.candidate_ids.length," candidates × ",N.task_ids.length," tasks = ",N.total_experiments," experiments"]}),N.is_public&&N.created_by_name&&i.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",i.jsx("span",{className:"text-[var(--text-primary)]",children:N.created_by_name})]})]})]}),i.jsxs("div",{className:"flex gap-2",children:[A&&i.jsx(i1,{job:N,onUpdate:Q}),L&&i.jsx(Z,{variant:"default",children:"View Only"}),A&&N.status==="pending"&&i.jsx(V,{variant:"primary",onClick:()=>B.mutate(),disabled:B.isPending,children:B.isPending?"Starting...":"Start"}),A&&N.status==="running"&&i.jsx(V,{variant:"danger",onClick:()=>G.mutate(),disabled:G.isPending,children:"Cancel"})]})]}),(x||N.error)&&i.jsx(ye,{className:"mb-6 border-red-500/50 bg-red-500/10",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-5 h-5 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-0.5",children:"!"}),i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium text-red-400",children:"Error"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:x||N.error})]})]})}),(a||r)&&i.jsxs(ye,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsx("span",{className:"font-medium",children:"Progress"}),i.jsxs("span",{className:"text-[var(--accent)]",children:[(r==null?void 0:r.completed)||N.completed_experiments,"/",(r==null?void 0:r.total)||N.total_experiments]})]}),i.jsx("div",{className:"w-full bg-[var(--bg-primary)] h-2 mb-2",children:i.jsx("div",{className:"h-full bg-[var(--accent)] transition-all",style:{width:`${((r==null?void 0:r.completed)||N.completed_experiments)/((r==null?void 0:r.total)||N.total_experiments)*100}%`}})}),(r==null?void 0:r.message)&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r.message}),a&&i.jsxs("div",{className:"mt-4 border-t border-[var(--border)] pt-4",children:[(r==null?void 0:r.current_candidate)&&(r==null?void 0:r.current_task)&&i.jsxs("div",{className:"mb-3",children:[i.jsx("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:"Currently Running"}),i.jsxs("div",{className:"flex items-center gap-2 mt-1 px-3 py-2 bg-blue-500/10 border border-blue-500/30 rounded",children:[i.jsx("div",{className:"w-2 h-2 bg-blue-400 rounded-full animate-pulse"}),i.jsx("span",{className:"font-medium",children:r.current_candidate}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{children:r.current_task})]})]}),d.length>0&&i.jsxs("div",{children:[i.jsxs("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:["Completed (",d.length,")"]}),i.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto space-y-1",children:d.map((R,T)=>i.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-500/10 border border-green-500/30 rounded text-sm",children:[i.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}),i.jsx("span",{className:"font-medium",children:R.candidate_name}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{children:R.task_name})]},`${R.candidate_name}-${R.task_name}-${T}`))})]})]})]}),(N.status==="completed"||F.length>0)&&i.jsxs("div",{className:"flex gap-1 mb-6 border-b border-[var(--border)]",children:[i.jsxs("button",{onClick:()=>S("results"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="results"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(xg,{size:16}),"Results"]}),i.jsxs("button",{onClick:()=>S("compare"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="compare"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(Pg,{size:16}),"Compare"]}),i.jsxs("button",{onClick:()=>S("runs"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="runs"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[i.jsx(Lg,{size:16}),"Runs (",F.length,")"]})]}),g==="results"&&i.jsxs(i.Fragment,{children:[O&&O.candidate_summaries.length>1&&i.jsxs(ye,{className:"mb-6",children:[i.jsx("div",{className:"flex items-start justify-between mb-4",children:i.jsxs("div",{children:[i.jsx("h3",{className:"font-medium",children:"Quality vs. Cost Tradeoff"}),i.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:["Candidates on the frontier (connected line) are ",i.jsx("strong",{children:"optimal"})," - no other candidate beats them on both score AND cost."]})]})}),i.jsxs("div",{className:"mb-4 p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs text-[var(--text-secondary)]",children:[i.jsx("strong",{className:"text-[var(--text-primary)]",children:"How optimal tradeoffs are calculated:"})," A candidate is optimal if there's no other candidate that has both a higher score AND lower cost. For example, if Candidate A has 95% score at 50K tokens and Candidate B has 90% score at 40K tokens, both are optimal - A is better on score, B is better on cost. But if Candidate C has 85% score at 60K tokens, it's ",i.jsx("em",{children:"not"})," optimal because B beats it on both metrics."]}),i.jsx(r1,{summaries:O.candidate_summaries,height:350})]}),O&&i.jsxs(ye,{className:"mb-6",children:[i.jsxs("div",{className:"flex items-center justify-between mb-4",children:[i.jsx("h3",{className:"font-medium",children:"Results Summary"}),i.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:C,onChange:R=>b(R.target.checked),className:"rounded border-[var(--border)]"}),"Optimal only"]})]}),i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full text-sm",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"text-left text-[var(--text-secondary)] border-b border-[var(--border)]",children:[i.jsx("th",{className:"pb-2",children:"Candidate"}),i.jsx(Y,{label:"Score",sortKeyVal:"score"}),i.jsx(Y,{label:"Tokens",sortKeyVal:"tokens"}),i.jsx(Y,{label:"Duration",sortKeyVal:"duration"}),i.jsx(Y,{label:"Pass Rate",sortKeyVal:"pass_rate"}),i.jsx("th",{className:"pb-2",children:"Optimal"})]})}),i.jsx("tbody",{children:D.map((R,T)=>i.jsxs("tr",{className:`border-b border-[var(--border)] ${T===0?"bg-[var(--accent)]/10":""}`,children:[i.jsxs("td",{className:"py-2 font-medium",children:[T===0&&i.jsx("span",{className:"text-[var(--accent)] mr-1",children:"#1"}),R.candidate_name.replace(/^baseline_/,"")]}),i.jsxs("td",{className:"py-2",children:[(R.avg_score*100).toFixed(1),"%"]}),i.jsxs("td",{className:"py-2",children:[(R.avg_tokens/1e3).toFixed(1),"K"]}),i.jsxs("td",{className:"py-2",children:[R.avg_duration.toFixed(1),"s"]}),i.jsxs("td",{className:"py-2",children:[R.passed_runs,"/",R.total_runs]}),i.jsx("td",{className:"py-2",children:R.is_pareto&&i.jsx(Z,{variant:"success",children:"Optimal"})})]},R.candidate_name))})]})}),i.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-3",children:"Click column headers to sort. The #1 ranked candidate is highlighted based on your sort criteria."})]}),!O&&i.jsx(ye,{children:i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Results will appear here after the job completes.":"No results yet. Start the job to see results."})})]}),g==="compare"&&i.jsxs(ye,{children:[i.jsx("h3",{className:"font-medium mb-4",children:"Compare Candidates by Task"}),he.length>0?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:he.map(R=>i.jsx("button",{onClick:()=>u(o===R?null:R),className:`px-3 py-1 text-sm rounded border transition-colors ${o===R?"bg-[var(--accent)] text-white border-[var(--accent)]":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:R},R))}),o&&re.get(o)?i.jsx(n1,{runs:re.get(o).map(R=>({id:R.id,candidate_name:R.candidate_name,tokens_input:0,tokens_output:0,tokens_total:R.tokens_total,duration_seconds:R.duration_seconds,score:R.score,passed:R.passed,is_pareto:R.is_pareto}))}):i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"Select a task above to compare how different candidates performed on it."})]}):i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Comparison data will appear here after runs complete.":"No runs yet. Start the job to compare candidates."})]}),g==="runs"&&i.jsxs(ye,{children:[i.jsx("h3",{className:"font-medium mb-4",children:"All Experiment Runs"}),F.length===0?i.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:a?"Runs will appear here as they complete. See progress above for live status.":"No runs yet. Start the job to see results."}):i.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:F.map(R=>i.jsxs("div",{className:"p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] cursor-pointer hover:border-[var(--accent-dim)] transition-colors",onClick:()=>t(`/runs/${R.id}`),children:[i.jsxs("div",{className:"flex items-center justify-between mb-2",children:[i.jsxs("span",{className:`text-lg font-bold ${R.passed?"text-green-400":"text-red-400"}`,children:[(R.score*100).toFixed(0),"%"]}),R.is_pareto&&i.jsx(Z,{variant:"success",children:"Optimal"})]}),i.jsx("div",{className:"text-sm font-medium truncate",title:R.candidate_name,children:R.candidate_name.replace(/^baseline_/,"")}),i.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:R.task_name}),i.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-[var(--text-secondary)]",children:[i.jsxs("span",{children:[(R.tokens_total/1e3).toFixed(1),"K tokens"]}),i.jsxs("span",{children:[R.duration_seconds.toFixed(1),"s"]})]})]},R.id))})]})]})}const vn={input:"bg-blue-500",output:"bg-emerald-500",inputText:"text-blue-400",outputText:"text-emerald-400"};function Rd(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Md({input:e,output:t,maxValue:n,height:r=24,showLabels:s=!0}){const a=e+t;if(a===0)return i.jsx("div",{className:"flex items-center gap-2 w-full",children:i.jsx("div",{className:"rounded bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`}})});const l=n>0?a/n*100:100;return i.jsxs("div",{className:"flex items-center gap-3 w-full",children:[i.jsx("div",{className:"relative rounded overflow-hidden bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`},children:i.jsxs("div",{className:"h-full flex transition-all duration-300",style:{width:`${l}%`},children:[i.jsx("div",{className:`h-full ${vn.input} transition-all`,style:{width:`${e/a*100}%`},title:`Input: ${e.toLocaleString()} tokens`}),i.jsx("div",{className:`h-full ${vn.output} transition-all`,style:{width:`${t/a*100}%`},title:`Output: ${t.toLocaleString()} tokens`})]})}),s&&i.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono text-[var(--text-secondary)] min-w-[90px] justify-end",children:[i.jsxs("span",{className:vn.inputText,children:["↑",Rd(e)]}),i.jsx("span",{children:"/"}),i.jsxs("span",{className:vn.outputText,children:["↓",Rd(t)]})]})]})}function Sl({label:e,value:t,color:n="default"}){const r={default:"text-[var(--text-primary)]",input:vn.inputText,output:vn.outputText}[n];return i.jsxs("div",{className:"flex-1 p-3 bg-[var(--bg-primary)] border border-[var(--border)] rounded",children:[i.jsx("div",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e}),i.jsx("div",{className:`font-mono text-lg font-bold ${r}`,children:t})]})}function Gm({tokensInput:e,tokensOutput:t,tokensTotal:n,turns:r}){const s=n>0?Math.round(e/n*100):0,a=n>0?Math.round(t/n*100):0,l=w.useMemo(()=>{if(!r||r.length===0)return null;let u=0,d=0;return r.map(h=>(u+=h.input,d+=h.output,{input:u,output:d,total:u+d}))},[r]),o=l?Math.max(...l.map(u=>u.total)):n;return i.jsxs(ye,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-4",children:"Token Usage"}),i.jsx("div",{className:"mb-4",children:i.jsx(Md,{input:e,output:t,maxValue:n,height:32})}),i.jsxs("div",{className:"flex items-center gap-6 text-xs mb-4",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:`w-3 h-3 rounded ${vn.input}`}),i.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Input (",s,"%)"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:`w-3 h-3 rounded ${vn.output}`}),i.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Output (",a,"%)"]})]})]}),i.jsxs("div",{className:"flex gap-3 mb-4",children:[i.jsx(Sl,{label:"Input Tokens",value:e.toLocaleString(),color:"input"}),i.jsx(Sl,{label:"Output Tokens",value:t.toLocaleString(),color:"output"}),i.jsx(Sl,{label:"Total Tokens",value:n.toLocaleString()})]}),l&&l.length>1&&i.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[i.jsxs("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:["Token Accumulation (",r.length," turns)"]}),i.jsx("div",{className:"space-y-2",children:r.map((u,d)=>i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--bg-primary)] border border-[var(--border)] flex items-center justify-center text-xs font-medium",children:d+1}),i.jsx("div",{className:"flex-1",children:i.jsx(Md,{input:l[d].input,output:l[d].output,maxValue:o,height:16})})]},d))})]}),i.jsx("div",{className:"mt-4 text-xs text-[var(--text-secondary)] border-t border-[var(--border)] pt-3",children:"Token usage affects API cost. Input tokens are typically cheaper than output tokens."})]})}function o1(){const{runId:e}=$i(),{data:t,isLoading:n}=je({queryKey:["runs",e],queryFn:()=>Fo.get(e),enabled:!!e});return n?i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?i.jsxs("div",{children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(Hi,{items:[{label:"Experiments",path:"/jobs"},{label:"Job",path:`/jobs/${t.job_id}`},{label:t.candidate_name}]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:t.candidate_name}),i.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),i.jsx("span",{className:"text-lg",children:t.task_name}),t.is_pareto&&i.jsx(Z,{variant:"success",children:"Optimal"})]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[i.jsx(La,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),i.jsx(La,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),i.jsx(La,{label:"Duration",value:`${t.duration_seconds.toFixed(1)}s`}),i.jsx(La,{label:"Status",value:t.passed?"Passed":"Failed",status:t.passed?"success":"error"})]}),i.jsx(Gm,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),i.jsxs(ye,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),t.reasoning&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:t.reasoning}),t.criteria_results.length>0&&i.jsx("div",{className:"space-y-2",children:t.criteria_results.map(r=>i.jsx("div",{className:"flex items-start justify-between p-3 bg-[var(--bg-primary)] border border-[var(--border)]",children:i.jsxs("div",{className:"flex-1",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"font-medium",children:r.name}),i.jsxs(Z,{variant:r.passed?"success":"error",children:[(r.score*100).toFixed(0),"%"]})]}),r.reasoning&&i.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r.reasoning})]})},r.name))})]}),i.jsxs(ye,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created.length>0&&i.jsxs(ye,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),i.jsx("div",{className:"space-y-1",children:t.files_created.map(r=>i.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:r},r))})]}),Object.keys(t.trace).length>0&&i.jsx(Hm,{trace:t.trace})]}):i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Run not found"})}function La({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return i.jsxs(ye,{children:[i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),i.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function u1(){const{testId:e}=$i(),{data:t,isLoading:n}=je({queryKey:["tests",e],queryFn:()=>Ts.get(e),enabled:!!e}),{data:r}=je({queryKey:["configs",t==null?void 0:t.agent_id],queryFn:()=>Tr.get(t.agent_id),enabled:!!(t!=null&&t.agent_id)});if(n)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!t)return i.jsx("div",{className:"text-[var(--text-secondary)]",children:"Test not found"});const s={completed:"success",failed:"error",running:"info",pending:"default",cancelled:"warning"};return i.jsxs("div",{children:[i.jsxs("div",{className:"mb-6",children:[i.jsx(Hi,{items:[{label:"Agents",path:"/agents"},...r?[{label:r.name,path:`/agents/${r.id}`}]:[],{label:`Test ${t.id.slice(0,8)}`}]}),i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("h2",{className:"text-xl font-bold",children:"Test Run"}),r&&i.jsxs(i.Fragment,{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"•"}),i.jsx("span",{className:"text-lg",children:r.name})]}),i.jsx(Z,{variant:s[t.status]||"default",children:t.status})]}),i.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:["ID: ",t.id.slice(0,8),"..."]})]}),i.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[i.jsx(Ra,{label:"Duration",value:`${t.duration_seconds.toFixed(2)}s`}),i.jsx(Ra,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),t.score!==null&&i.jsx(Ra,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),i.jsx(Ra,{label:"Status",value:t.status.charAt(0).toUpperCase()+t.status.slice(1),status:t.status==="completed"?"success":t.status==="failed"?"error":void 0})]}),i.jsx(Gm,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),i.jsxs(ye,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Prompt"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)] font-mono",children:t.prompt})]}),t.error&&i.jsxs(ye,{className:"mb-6 border-red-500/30 bg-red-500/5",children:[i.jsx("h3",{className:"font-medium mb-3 text-red-400",children:"Error"}),i.jsx("pre",{className:"text-sm text-red-300 overflow-x-auto whitespace-pre-wrap",children:t.error})]}),t.reasoning&&i.jsxs(ye,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),i.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.reasoning})]}),i.jsxs(ye,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),i.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created&&t.files_created.length>0&&i.jsxs(ye,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),i.jsx("div",{className:"space-y-1",children:t.files_created.map(a=>i.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:a},a))})]}),t.trace&&Object.keys(t.trace).length>0&&i.jsx(Hm,{trace:t.trace}),i.jsxs(ye,{className:"mb-6",children:[i.jsx("h3",{className:"font-medium mb-3",children:"Timestamps"}),i.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Created:"}),i.jsx("div",{className:"font-mono",children:new Date(t.created_at).toLocaleString()})]}),t.started_at&&i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Started:"}),i.jsx("div",{className:"font-mono",children:new Date(t.started_at).toLocaleString()})]}),t.completed_at&&i.jsxs("div",{children:[i.jsx("span",{className:"text-[var(--text-secondary)]",children:"Completed:"}),i.jsx("div",{className:"font-mono",children:new Date(t.completed_at).toLocaleString()})]})]})]})]})}function Ra({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return i.jsxs(ye,{children:[i.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),i.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function c1(){const{authConfig:e,isLoading:t,error:n,login:r,loginWithGitHub:s,clearError:a}=qu(),[l,o]=w.useState(""),[u,d]=w.useState("");w.useEffect(()=>{n&&a()},[l,u]);const h=async p=>{p.preventDefault(),!(!l||!u)&&await r(l,u)},c=()=>{s()};return i.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:i.jsxs("div",{className:"w-full max-w-md",children:[i.jsxs("div",{className:"text-center mb-8",children:[i.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:"Flow"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:"Sign in to access the optimization dashboard"})]}),i.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] p-6 space-y-6",children:[n&&i.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[var(--error)]/10 border border-[var(--error)]/20 text-[var(--error)]",children:[i.jsx(Om,{size:18,className:"mt-0.5 flex-shrink-0"}),i.jsx("p",{className:"text-sm",children:n})]}),(e==null?void 0:e.mode)==="basic"&&i.jsxs("form",{onSubmit:h,className:"space-y-4",children:[i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Username"}),i.jsxs("div",{className:"relative",children:[i.jsx(zm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),i.jsx("input",{type:"text",value:l,onChange:p=>o(p.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter username",autoComplete:"username",autoFocus:!0})]})]}),i.jsxs("div",{className:"space-y-1",children:[i.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Password"}),i.jsxs("div",{className:"relative",children:[i.jsx(Rm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),i.jsx("input",{type:"password",value:u,onChange:p=>d(p.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter password",autoComplete:"current-password"})]})]}),i.jsx(V,{type:"submit",variant:"primary",className:"w-full justify-center",loading:t,disabled:!l||!u,children:"Sign In"})]}),(e==null?void 0:e.mode)==="github"&&i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center",children:"Sign in with your GitHub account to continue"}),i.jsx(V,{onClick:c,variant:"secondary",className:"w-full justify-center",icon:Tg,children:"Continue with GitHub"})]})]})]})})}function d1({children:e}){const{authConfig:t,isLoadingConfig:n,isAuthenticated:r,loadAuthConfig:s,handleOAuthCallback:a}=qu();return w.useEffect(()=>{s()},[s]),w.useEffect(()=>{n||a()},[n,a]),n?i.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center",children:i.jsxs("div",{className:"text-center",children:[i.jsx(fa,{className:"w-8 h-8 animate-spin text-[var(--accent)] mx-auto mb-4"}),i.jsx("p",{className:"text-[var(--text-secondary)]",children:"Loading..."})]})}):t!=null&&t.enabled&&!r?i.jsx(c1,{}):i.jsx(i.Fragment,{children:e})}function f1(){return i.jsx(lg,{children:i.jsx(d1,{children:i.jsx(Zy,{children:i.jsxs(kt,{path:"/",element:i.jsx(C0,{}),children:[i.jsx(kt,{index:!0,element:i.jsx(Ld,{})}),i.jsx(kt,{path:"agents",element:i.jsx(Ld,{})}),i.jsx(kt,{path:"agents/:agentId",element:i.jsx(V0,{})}),i.jsx(kt,{path:"tasks",element:i.jsx(q0,{})}),i.jsx(kt,{path:"jobs",element:i.jsx(Z0,{})}),i.jsx(kt,{path:"jobs/:jobId",element:i.jsx(l1,{})}),i.jsx(kt,{path:"runs/:runId",element:i.jsx(o1,{})}),i.jsx(kt,{path:"tests/:testId",element:i.jsx(u1,{})})]})})})})}const zd=localStorage.getItem("flow-theme");if(zd)try{const{state:e}=JSON.parse(zd);e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}catch{}const h1=new qx({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}});Nl.createRoot(document.getElementById("root")).render(i.jsx(Vo.StrictMode,{children:i.jsx(Gx,{client:h1,children:i.jsx(f1,{})})})); diff --git a/src/flow/ui/ui/assets/index-RgO0sQBD.css b/src/flow/ui/ui/assets/index-RgO0sQBD.css new file mode 100644 index 0000000000000000000000000000000000000000..d2f7d12e3b842c28124369b91ec44620696fc3d6 --- /dev/null +++ b/src/flow/ui/ui/assets/index-RgO0sQBD.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:Segoe UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:JetBrains Mono,ui-monospace,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.bottom-0{bottom:0}.bottom-1{bottom:.25rem}.left-0{left:0}.left-3{left:.75rem}.top-0{top:0}.top-1{top:.25rem}.top-1\/2{top:50%}.z-10{z-index:10}.z-50{z-index:50}.mx-0\.5{margin-left:.125rem;margin-right:.125rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.-mb-px{margin-bottom:-1px}.-mt-2{margin-top:-.5rem}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.ml-6{margin-left:1.5rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-auto{margin-top:auto}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-1\.5{height:.375rem}.h-12{height:3rem}.h-2{height:.5rem}.h-3{height:.75rem}.h-32{height:8rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:8rem}.max-h-40{max-height:10rem}.max-h-48{max-height:12rem}.max-h-80{max-height:20rem}.max-h-96{max-height:24rem}.max-h-\[120px\]{max-height:120px}.max-h-\[80vh\]{max-height:80vh}.min-h-0{min-height:0px}.min-h-\[100px\]{min-height:100px}.min-h-\[200px\]{min-height:200px}.min-h-\[40px\]{min-height:40px}.min-h-screen{min-height:100vh}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-2{width:.5rem}.w-20{width:5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-32{width:8rem}.w-4{width:1rem}.w-40{width:10rem}.w-5{width:1.25rem}.w-56{width:14rem}.w-6{width:1.5rem}.w-7{width:1.75rem}.w-8{width:2rem}.w-\[350px\]{width:350px}.w-\[3px\]{width:3px}.w-\[420px\]{width:420px}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-\[90px\]{min-width:90px}.max-w-2xl{max-width:42rem}.max-w-4xl{max-width:56rem}.max-w-\[80\%\]{max-width:80%}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-90{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.resize-y{resize:vertical}.resize{resize:both}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-\[var\(--accent\)\]{border-color:var(--accent)}.border-\[var\(--badge-error-border\)\]{border-color:var(--badge-error-border)}.border-\[var\(--badge-info-border\)\]{border-color:var(--badge-info-border)}.border-\[var\(--badge-success-border\)\]{border-color:var(--badge-success-border)}.border-\[var\(--badge-warning-border\)\]{border-color:var(--badge-warning-border)}.border-\[var\(--border\)\]{border-color:var(--border)}.border-blue-500\/30{border-color:#3b82f64d}.border-green-500\/30{border-color:#22c55e4d}.border-green-500\/50{border-color:#22c55e80}.border-red-500\/30{border-color:#ef44444d}.border-red-500\/50{border-color:#ef444480}.border-transparent{border-color:transparent}.bg-\[var\(--accent\)\]{background-color:var(--accent)}.bg-\[var\(--accent-dim\)\]{background-color:var(--accent-dim)}.bg-\[var\(--badge-error-bg\)\]{background-color:var(--badge-error-bg)}.bg-\[var\(--badge-info-bg\)\]{background-color:var(--badge-info-bg)}.bg-\[var\(--badge-success-bg\)\]{background-color:var(--badge-success-bg)}.bg-\[var\(--badge-warning-bg\)\]{background-color:var(--badge-warning-bg)}.bg-\[var\(--bg-primary\)\]{background-color:var(--bg-primary)}.bg-\[var\(--bg-secondary\)\]{background-color:var(--bg-secondary)}.bg-\[var\(--bg-tertiary\)\]{background-color:var(--bg-tertiary)}.bg-\[var\(--border\)\]{background-color:var(--border)}.bg-\[var\(--error\)\]{background-color:var(--error)}.bg-\[var\(--span-agent-bg\)\]{background-color:var(--span-agent-bg)}.bg-\[var\(--span-fail-bg\)\]{background-color:var(--span-fail-bg)}.bg-\[var\(--span-llm-bg\)\]{background-color:var(--span-llm-bg)}.bg-\[var\(--span-other-bg\)\]{background-color:var(--span-other-bg)}.bg-\[var\(--span-pass-bg\)\]{background-color:var(--span-pass-bg)}.bg-\[var\(--span-tool-bg\)\]{background-color:var(--span-tool-bg)}.bg-black\/50{background-color:#00000080}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(96 165 250 / var(--tw-bg-opacity, 1))}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-500\/10{background-color:#3b82f61a}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(16 185 129 / var(--tw-bg-opacity, 1))}.bg-green-400{--tw-bg-opacity: 1;background-color:rgb(74 222 128 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-green-500\/10{background-color:#22c55e1a}.bg-green-500\/20{background-color:#22c55e33}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-500\/10{background-color:#ef44441a}.bg-red-500\/5{background-color:#ef44440d}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-2{padding-bottom:.5rem}.pb-3{padding-bottom:.75rem}.pl-10{padding-left:2.5rem}.pl-9{padding-left:2.25rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:JetBrains Mono,ui-monospace,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.text-\[var\(--accent\)\]{color:var(--accent)}.text-\[var\(--badge-error-text\)\]{color:var(--badge-error-text)}.text-\[var\(--badge-info-text\)\]{color:var(--badge-info-text)}.text-\[var\(--badge-success-text\)\]{color:var(--badge-success-text)}.text-\[var\(--badge-warning-text\)\]{color:var(--badge-warning-text)}.text-\[var\(--error\)\]{color:var(--error)}.text-\[var\(--span-agent-text\)\]{color:var(--span-agent-text)}.text-\[var\(--span-fail-text\)\]{color:var(--span-fail-text)}.text-\[var\(--span-llm-text\)\]{color:var(--span-llm-text)}.text-\[var\(--span-other-text\)\]{color:var(--span-other-text)}.text-\[var\(--span-pass-text\)\]{color:var(--span-pass-text)}.text-\[var\(--span-tool-text\)\]{color:var(--span-tool-text)}.text-\[var\(--success\)\]{color:var(--success)}.text-\[var\(--text-primary\)\]{color:var(--text-primary)}.text-\[var\(--text-secondary\)\]{color:var(--text-secondary)}.text-\[var\(--text-tertiary\)\]{color:var(--text-tertiary)}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.text-blue-400{--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.text-emerald-400{--tw-text-opacity: 1;color:rgb(52 211 153 / var(--tw-text-opacity, 1))}.text-green-400{--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-purple-400{--tw-text-opacity: 1;color:rgb(192 132 252 / var(--tw-text-opacity, 1))}.text-red-300{--tw-text-opacity: 1;color:rgb(252 165 165 / var(--tw-text-opacity, 1))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}:root{--bg-primary: #ffffff;--bg-secondary: #fafafa;--bg-tertiary: #f3f4f6;--text-primary: #1b1b1b;--text-secondary: #616161;--accent: #7c3aed;--accent-hover: #6d28d9;--accent-dim: #ede9fe;--border: #e5e7eb;--error: #dc2626;--success: #16a34a;--badge-success-bg: #f0fdf4;--badge-success-text: #15803d;--badge-success-border: #bbf7d0;--badge-warning-bg: #fefce8;--badge-warning-text: #a16207;--badge-warning-border: #fef08a;--badge-error-bg: #fef2f2;--badge-error-text: #b91c1c;--badge-error-border: #fecaca;--badge-info-bg: #eff6ff;--badge-info-text: #1d4ed8;--badge-info-border: #bfdbfe;--span-llm-bg: #f5f3ff;--span-llm-text: #6b21a8;--span-tool-bg: #eff6ff;--span-tool-text: #1e40af;--span-agent-bg: #f0fdf4;--span-agent-text: #166534;--span-other-bg: #fff7ed;--span-other-text: #9a3412;--span-pass-bg: #f0fdf4;--span-pass-text: #166534;--span-fail-bg: #fef2f2;--span-fail-text: #991b1b}[data-theme=dark]{--bg-primary: #1a1a2e;--bg-secondary: #16162a;--bg-tertiary: #252540;--text-primary: #f0f0f5;--text-secondary: #a0a0b5;--accent: #a78bfa;--accent-hover: #8b5cf6;--accent-dim: #2d2055;--border: #2d2d45;--error: #ef4444;--success: #22c55e;--badge-success-bg: rgba(34, 197, 94, .15);--badge-success-text: #4ade80;--badge-success-border: rgba(34, 197, 94, .3);--badge-warning-bg: rgba(234, 179, 8, .15);--badge-warning-text: #fbbf24;--badge-warning-border: rgba(234, 179, 8, .3);--badge-error-bg: rgba(239, 68, 68, .15);--badge-error-text: #f87171;--badge-error-border: rgba(239, 68, 68, .3);--badge-info-bg: rgba(59, 130, 246, .15);--badge-info-text: #60a5fa;--badge-info-border: rgba(59, 130, 246, .3);--span-llm-bg: rgba(139, 92, 246, .15);--span-llm-text: #c4b5fd;--span-tool-bg: rgba(59, 130, 246, .15);--span-tool-text: #93c5fd;--span-agent-bg: rgba(34, 197, 94, .15);--span-agent-text: #86efac;--span-other-bg: rgba(249, 115, 22, .15);--span-other-text: #fdba74;--span-pass-bg: rgba(34, 197, 94, .15);--span-pass-text: #86efac;--span-fail-bg: rgba(239, 68, 68, .15);--span-fail-text: #fca5a5}*{box-sizing:border-box}body{margin:0;background-color:var(--bg-primary);color:var(--text-primary);font-family:Segoe UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-size:14px;line-height:1.6}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:var(--bg-secondary)}::-webkit-scrollbar-thumb{background:var(--border);border-radius:4px}::-webkit-scrollbar-thumb:hover{background:silver}[data-theme=dark] ::-webkit-scrollbar-thumb:hover{background:#404040}.last\:border-0:last-child{border-width:0px}.last\:border-b-0:last-child{border-bottom-width:0px}.hover\:border-\[var\(--accent\)\]:hover{border-color:var(--accent)}.hover\:border-\[var\(--accent-dim\)\]:hover{border-color:var(--accent-dim)}.hover\:bg-\[var\(--accent-hover\)\]:hover{background-color:var(--accent-hover)}.hover\:bg-\[var\(--bg-primary\)\]:hover{background-color:var(--bg-primary)}.hover\:bg-\[var\(--bg-tertiary\)\]:hover{background-color:var(--bg-tertiary)}.hover\:bg-\[var\(--border\)\]:hover{background-color:var(--border)}.hover\:bg-red-600:hover{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.hover\:text-\[var\(--accent\)\]:hover{color:var(--accent)}.hover\:text-\[var\(--error\)\]:hover{color:var(--error)}.hover\:text-\[var\(--text-primary\)\]:hover{color:var(--text-primary)}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-80:hover{opacity:.8}.focus\:border-\[var\(--accent\)\]:focus{border-color:var(--accent)}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-\[var\(--accent\)\]:focus{--tw-ring-color: var(--accent)}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}@media (min-width: 768px){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (min-width: 1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}} diff --git a/src/flow/ui/ui/assets/index-ZbKf8ELN.css b/src/flow/ui/ui/assets/index-ZbKf8ELN.css new file mode 100644 index 0000000000000000000000000000000000000000..127f1dd0ef0eb1d986cfa34be241a3112151028e --- /dev/null +++ b/src/flow/ui/ui/assets/index-ZbKf8ELN.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:Segoe UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:JetBrains Mono,ui-monospace,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.bottom-0{bottom:0}.bottom-1{bottom:.25rem}.left-0{left:0}.left-3{left:.75rem}.top-0{top:0}.top-1{top:.25rem}.top-1\/2{top:50%}.z-10{z-index:10}.z-50{z-index:50}.mx-0\.5{margin-left:.125rem;margin-right:.125rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.-mb-px{margin-bottom:-1px}.-mt-2{margin-top:-.5rem}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-4{margin-left:1rem}.ml-6{margin-left:1.5rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.mt-auto{margin-top:auto}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-1\.5{height:.375rem}.h-12{height:3rem}.h-2{height:.5rem}.h-3{height:.75rem}.h-32{height:8rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-8{height:2rem}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:8rem}.max-h-40{max-height:10rem}.max-h-48{max-height:12rem}.max-h-80{max-height:20rem}.max-h-96{max-height:24rem}.max-h-\[120px\]{max-height:120px}.max-h-\[80vh\]{max-height:80vh}.min-h-0{min-height:0px}.min-h-\[100px\]{min-height:100px}.min-h-\[200px\]{min-height:200px}.min-h-\[40px\]{min-height:40px}.min-h-screen{min-height:100vh}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-2{width:.5rem}.w-20{width:5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-32{width:8rem}.w-4{width:1rem}.w-40{width:10rem}.w-5{width:1.25rem}.w-56{width:14rem}.w-6{width:1.5rem}.w-8{width:2rem}.w-\[350px\]{width:350px}.w-\[3px\]{width:3px}.w-\[420px\]{width:420px}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-\[90px\]{min-width:90px}.max-w-2xl{max-width:42rem}.max-w-4xl{max-width:56rem}.max-w-\[80\%\]{max-width:80%}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-90{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.resize-y{resize:vertical}.resize{resize:both}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-\[var\(--accent\)\]{border-color:var(--accent)}.border-\[var\(--badge-error-border\)\]{border-color:var(--badge-error-border)}.border-\[var\(--badge-info-border\)\]{border-color:var(--badge-info-border)}.border-\[var\(--badge-success-border\)\]{border-color:var(--badge-success-border)}.border-\[var\(--badge-warning-border\)\]{border-color:var(--badge-warning-border)}.border-\[var\(--border\)\]{border-color:var(--border)}.border-blue-500\/30{border-color:#3b82f64d}.border-green-500\/30{border-color:#22c55e4d}.border-green-500\/50{border-color:#22c55e80}.border-red-500\/30{border-color:#ef44444d}.border-red-500\/50{border-color:#ef444480}.border-transparent{border-color:transparent}.bg-\[var\(--accent\)\]{background-color:var(--accent)}.bg-\[var\(--accent-dim\)\]{background-color:var(--accent-dim)}.bg-\[var\(--badge-error-bg\)\]{background-color:var(--badge-error-bg)}.bg-\[var\(--badge-info-bg\)\]{background-color:var(--badge-info-bg)}.bg-\[var\(--badge-success-bg\)\]{background-color:var(--badge-success-bg)}.bg-\[var\(--badge-warning-bg\)\]{background-color:var(--badge-warning-bg)}.bg-\[var\(--bg-primary\)\]{background-color:var(--bg-primary)}.bg-\[var\(--bg-secondary\)\]{background-color:var(--bg-secondary)}.bg-\[var\(--bg-tertiary\)\]{background-color:var(--bg-tertiary)}.bg-\[var\(--border\)\]{background-color:var(--border)}.bg-\[var\(--error\)\]{background-color:var(--error)}.bg-\[var\(--span-agent-bg\)\]{background-color:var(--span-agent-bg)}.bg-\[var\(--span-fail-bg\)\]{background-color:var(--span-fail-bg)}.bg-\[var\(--span-llm-bg\)\]{background-color:var(--span-llm-bg)}.bg-\[var\(--span-other-bg\)\]{background-color:var(--span-other-bg)}.bg-\[var\(--span-pass-bg\)\]{background-color:var(--span-pass-bg)}.bg-\[var\(--span-tool-bg\)\]{background-color:var(--span-tool-bg)}.bg-black\/50{background-color:#00000080}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(96 165 250 / var(--tw-bg-opacity, 1))}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-500\/10{background-color:#3b82f61a}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(16 185 129 / var(--tw-bg-opacity, 1))}.bg-green-400{--tw-bg-opacity: 1;background-color:rgb(74 222 128 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-green-500\/10{background-color:#22c55e1a}.bg-green-500\/20{background-color:#22c55e33}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-500\/10{background-color:#ef44441a}.bg-red-500\/5{background-color:#ef44440d}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-2{padding-bottom:.5rem}.pb-3{padding-bottom:.75rem}.pl-10{padding-left:2.5rem}.pl-9{padding-left:2.25rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:JetBrains Mono,ui-monospace,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.text-\[var\(--accent\)\]{color:var(--accent)}.text-\[var\(--badge-error-text\)\]{color:var(--badge-error-text)}.text-\[var\(--badge-info-text\)\]{color:var(--badge-info-text)}.text-\[var\(--badge-success-text\)\]{color:var(--badge-success-text)}.text-\[var\(--badge-warning-text\)\]{color:var(--badge-warning-text)}.text-\[var\(--error\)\]{color:var(--error)}.text-\[var\(--span-agent-text\)\]{color:var(--span-agent-text)}.text-\[var\(--span-fail-text\)\]{color:var(--span-fail-text)}.text-\[var\(--span-llm-text\)\]{color:var(--span-llm-text)}.text-\[var\(--span-other-text\)\]{color:var(--span-other-text)}.text-\[var\(--span-pass-text\)\]{color:var(--span-pass-text)}.text-\[var\(--span-tool-text\)\]{color:var(--span-tool-text)}.text-\[var\(--success\)\]{color:var(--success)}.text-\[var\(--text-primary\)\]{color:var(--text-primary)}.text-\[var\(--text-secondary\)\]{color:var(--text-secondary)}.text-\[var\(--text-tertiary\)\]{color:var(--text-tertiary)}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.text-blue-400{--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.text-emerald-400{--tw-text-opacity: 1;color:rgb(52 211 153 / var(--tw-text-opacity, 1))}.text-green-400{--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-purple-400{--tw-text-opacity: 1;color:rgb(192 132 252 / var(--tw-text-opacity, 1))}.text-red-300{--tw-text-opacity: 1;color:rgb(252 165 165 / var(--tw-text-opacity, 1))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}:root{--bg-primary: #ffffff;--bg-secondary: #fafafa;--bg-tertiary: #f3f4f6;--text-primary: #1b1b1b;--text-secondary: #616161;--accent: #7c3aed;--accent-hover: #6d28d9;--accent-dim: #ede9fe;--border: #e5e7eb;--error: #dc2626;--success: #16a34a;--badge-success-bg: #f0fdf4;--badge-success-text: #15803d;--badge-success-border: #bbf7d0;--badge-warning-bg: #fefce8;--badge-warning-text: #a16207;--badge-warning-border: #fef08a;--badge-error-bg: #fef2f2;--badge-error-text: #b91c1c;--badge-error-border: #fecaca;--badge-info-bg: #eff6ff;--badge-info-text: #1d4ed8;--badge-info-border: #bfdbfe;--span-llm-bg: #f5f3ff;--span-llm-text: #6b21a8;--span-tool-bg: #eff6ff;--span-tool-text: #1e40af;--span-agent-bg: #f0fdf4;--span-agent-text: #166534;--span-other-bg: #fff7ed;--span-other-text: #9a3412;--span-pass-bg: #f0fdf4;--span-pass-text: #166534;--span-fail-bg: #fef2f2;--span-fail-text: #991b1b}[data-theme=dark]{--bg-primary: #1a1a2e;--bg-secondary: #16162a;--bg-tertiary: #252540;--text-primary: #f0f0f5;--text-secondary: #a0a0b5;--accent: #a78bfa;--accent-hover: #8b5cf6;--accent-dim: #2d2055;--border: #2d2d45;--error: #ef4444;--success: #22c55e;--badge-success-bg: rgba(34, 197, 94, .15);--badge-success-text: #4ade80;--badge-success-border: rgba(34, 197, 94, .3);--badge-warning-bg: rgba(234, 179, 8, .15);--badge-warning-text: #fbbf24;--badge-warning-border: rgba(234, 179, 8, .3);--badge-error-bg: rgba(239, 68, 68, .15);--badge-error-text: #f87171;--badge-error-border: rgba(239, 68, 68, .3);--badge-info-bg: rgba(59, 130, 246, .15);--badge-info-text: #60a5fa;--badge-info-border: rgba(59, 130, 246, .3);--span-llm-bg: rgba(139, 92, 246, .15);--span-llm-text: #c4b5fd;--span-tool-bg: rgba(59, 130, 246, .15);--span-tool-text: #93c5fd;--span-agent-bg: rgba(34, 197, 94, .15);--span-agent-text: #86efac;--span-other-bg: rgba(249, 115, 22, .15);--span-other-text: #fdba74;--span-pass-bg: rgba(34, 197, 94, .15);--span-pass-text: #86efac;--span-fail-bg: rgba(239, 68, 68, .15);--span-fail-text: #fca5a5}*{box-sizing:border-box}body{margin:0;background-color:var(--bg-primary);color:var(--text-primary);font-family:Segoe UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-size:14px;line-height:1.6}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:var(--bg-secondary)}::-webkit-scrollbar-thumb{background:var(--border);border-radius:4px}::-webkit-scrollbar-thumb:hover{background:silver}[data-theme=dark] ::-webkit-scrollbar-thumb:hover{background:#404040}.last\:border-0:last-child{border-width:0px}.last\:border-b-0:last-child{border-bottom-width:0px}.hover\:border-\[var\(--accent\)\]:hover{border-color:var(--accent)}.hover\:border-\[var\(--accent-dim\)\]:hover{border-color:var(--accent-dim)}.hover\:bg-\[var\(--accent-hover\)\]:hover{background-color:var(--accent-hover)}.hover\:bg-\[var\(--bg-primary\)\]:hover{background-color:var(--bg-primary)}.hover\:bg-\[var\(--bg-tertiary\)\]:hover{background-color:var(--bg-tertiary)}.hover\:bg-\[var\(--border\)\]:hover{background-color:var(--border)}.hover\:bg-red-600:hover{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.hover\:text-\[var\(--accent\)\]:hover{color:var(--accent)}.hover\:text-\[var\(--error\)\]:hover{color:var(--error)}.hover\:text-\[var\(--text-primary\)\]:hover{color:var(--text-primary)}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-80:hover{opacity:.8}.focus\:border-\[var\(--accent\)\]:focus{border-color:var(--accent)}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-\[var\(--accent\)\]:focus{--tw-ring-color: var(--accent)}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}@media (min-width: 768px){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}@media (min-width: 1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}} diff --git a/src/flow/ui/ui/assets/index-fI1A1OAy.js b/src/flow/ui/ui/assets/index-fI1A1OAy.js new file mode 100644 index 0000000000000000000000000000000000000000..5b41e4f3a98ea3ebe30412ec068d7fc970d6f02d --- /dev/null +++ b/src/flow/ui/ui/assets/index-fI1A1OAy.js @@ -0,0 +1,347 @@ +var nu=e=>{throw TypeError(e)};var Hi=(e,t,n)=>t.has(e)||nu("Cannot "+n);var y=(e,t,n)=>(Hi(e,t,"read from private field"),n?n.call(e):t.get(e)),$=(e,t,n)=>t.has(e)?nu("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),z=(e,t,n,r)=>(Hi(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),H=(e,t,n)=>(Hi(e,t,"access private method"),n);var pa=(e,t,n,r)=>({set _(s){z(e,t,s,n)},get _(){return y(e,t,r)}});function lp(e,t){for(var n=0;nr[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();function Yd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xd={exports:{}},Ni={},Zd={exports:{}},Y={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var ia=Symbol.for("react.element"),op=Symbol.for("react.portal"),cp=Symbol.for("react.fragment"),up=Symbol.for("react.strict_mode"),dp=Symbol.for("react.profiler"),fp=Symbol.for("react.provider"),hp=Symbol.for("react.context"),mp=Symbol.for("react.forward_ref"),pp=Symbol.for("react.suspense"),xp=Symbol.for("react.memo"),vp=Symbol.for("react.lazy"),ru=Symbol.iterator;function yp(e){return e===null||typeof e!="object"?null:(e=ru&&e[ru]||e["@@iterator"],typeof e=="function"?e:null)}var ef={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},tf=Object.assign,nf={};function Yr(e,t,n){this.props=e,this.context=t,this.refs=nf,this.updater=n||ef}Yr.prototype.isReactComponent={};Yr.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};Yr.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function rf(){}rf.prototype=Yr.prototype;function Vo(e,t,n){this.props=e,this.context=t,this.refs=nf,this.updater=n||ef}var Ko=Vo.prototype=new rf;Ko.constructor=Vo;tf(Ko,Yr.prototype);Ko.isPureReactComponent=!0;var su=Array.isArray,sf=Object.prototype.hasOwnProperty,Ho={current:null},af={key:!0,ref:!0,__self:!0,__source:!0};function lf(e,t,n){var r,s={},i=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(i=""+t.key),t)sf.call(t,r)&&!af.hasOwnProperty(r)&&(s[r]=t[r]);var o=arguments.length-2;if(o===1)s.children=n;else if(1>>1,ee=P[V];if(0>>1;Vs(te,L))pes(Se,te)?(P[V]=Se,P[pe]=L,V=pe):(P[V]=te,P[T]=L,V=T);else if(pes(Se,L))P[V]=Se,P[pe]=L,V=pe;else break e}}return A}function s(P,A){var L=P.sortIndex-A.sortIndex;return L!==0?L:P.id-A.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,o=l.now();e.unstable_now=function(){return l.now()-o}}var c=[],u=[],d=1,f=null,m=3,v=!1,k=!1,g=!1,b=typeof setTimeout=="function"?setTimeout:null,p=typeof clearTimeout=="function"?clearTimeout:null,h=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(P){for(var A=n(u);A!==null;){if(A.callback===null)r(u);else if(A.startTime<=P)r(u),A.sortIndex=A.expirationTime,t(c,A);else break;A=n(u)}}function w(P){if(g=!1,x(P),!k)if(n(c)!==null)k=!0,W(C);else{var A=n(u);A!==null&&X(w,A.startTime-P)}}function C(P,A){k=!1,g&&(g=!1,p(_),_=-1),v=!0;var L=m;try{for(x(A),f=n(c);f!==null&&(!(f.expirationTime>A)||P&&!B());){var V=f.callback;if(typeof V=="function"){f.callback=null,m=f.priorityLevel;var ee=V(f.expirationTime<=A);A=e.unstable_now(),typeof ee=="function"?f.callback=ee:f===n(c)&&r(c),x(A)}else r(c);f=n(c)}if(f!==null)var R=!0;else{var T=n(u);T!==null&&X(w,T.startTime-A),R=!1}return R}finally{f=null,m=L,v=!1}}var S=!1,N=null,_=-1,F=5,O=-1;function B(){return!(e.unstable_now()-OP||125V?(P.sortIndex=L,t(u,P),n(c)===null&&P===n(u)&&(g?(p(_),_=-1):g=!0,X(w,L-V))):(P.sortIndex=ee,t(c,P),k||v||(k=!0,W(C))),P},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(P){var A=m;return function(){var L=m;m=A;try{return P.apply(this,arguments)}finally{m=L}}}})(ff);df.exports=ff;var Tp=df.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Op=j,et=Tp;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),_l=Object.prototype.hasOwnProperty,Lp=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,iu={},lu={};function Rp(e){return _l.call(lu,e)?!0:_l.call(iu,e)?!1:Lp.test(e)?lu[e]=!0:(iu[e]=!0,!1)}function Mp(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function zp(e,t,n,r){if(t===null||typeof t>"u"||Mp(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function Be(e,t,n,r,s,i,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=s,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=l}var Oe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Oe[e]=new Be(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Oe[t]=new Be(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Oe[e]=new Be(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Oe[e]=new Be(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){Oe[e]=new Be(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Oe[e]=new Be(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Oe[e]=new Be(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Oe[e]=new Be(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Oe[e]=new Be(e,5,!1,e.toLowerCase(),null,!1,!1)});var Go=/[\-:]([a-z])/g;function Jo(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Go,Jo);Oe[t]=new Be(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Go,Jo);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Go,Jo);Oe[t]=new Be(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!1,!1)});Oe.xlinkHref=new Be("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Oe[e]=new Be(e,1,!1,e.toLowerCase(),null,!0,!0)});function Yo(e,t,n,r){var s=Oe.hasOwnProperty(t)?Oe[t]:null;(s!==null?s.type!==0:r||!(2o||s[l]!==i[o]){var c=` +`+s[l].replace(" at new "," at ");return e.displayName&&c.includes("")&&(c=c.replace("",e.displayName)),c}while(1<=l&&0<=o);break}}}finally{Gi=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?vs(e):""}function Fp(e){switch(e.tag){case 5:return vs(e.type);case 16:return vs("Lazy");case 13:return vs("Suspense");case 19:return vs("SuspenseList");case 0:case 2:case 15:return e=Ji(e.type,!1),e;case 11:return e=Ji(e.type.render,!1),e;case 1:return e=Ji(e.type,!0),e;default:return""}}function Ol(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case fr:return"Fragment";case dr:return"Portal";case El:return"Profiler";case Xo:return"StrictMode";case Pl:return"Suspense";case Tl:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case pf:return(e.displayName||"Context")+".Consumer";case mf:return(e._context.displayName||"Context")+".Provider";case Zo:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ec:return t=e.displayName||null,t!==null?t:Ol(e.type)||"Memo";case Xt:t=e._payload,e=e._init;try{return Ol(e(t))}catch{}}return null}function Ip(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Ol(t);case 8:return t===Xo?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function En(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function vf(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function Dp(e){var t=vf(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var s=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(l){r=""+l,i.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function ya(e){e._valueTracker||(e._valueTracker=Dp(e))}function yf(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=vf(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Ga(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function Ll(e,t){var n=t.checked;return me({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function cu(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=En(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function gf(e,t){t=t.checked,t!=null&&Yo(e,"checked",t,!1)}function Rl(e,t){gf(e,t);var n=En(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?Ml(e,t.type,n):t.hasOwnProperty("defaultValue")&&Ml(e,t.type,En(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function uu(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function Ml(e,t,n){(t!=="number"||Ga(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var ys=Array.isArray;function br(e,t,n,r){if(e=e.options,t){t={};for(var s=0;s"+t.valueOf().toString()+"",t=ga.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Rs(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ks={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},Ap=["Webkit","ms","Moz","O"];Object.keys(ks).forEach(function(e){Ap.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),ks[t]=ks[e]})});function bf(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||ks.hasOwnProperty(e)&&ks[e]?(""+t).trim():t+"px"}function Nf(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=bf(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var $p=me({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Il(e,t){if(t){if($p[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function Dl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var Al=null;function tc(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var $l=null,Nr=null,Sr=null;function hu(e){if(e=ca(e)){if(typeof $l!="function")throw Error(E(280));var t=e.stateNode;t&&(t=Pi(t),$l(e.stateNode,e.type,t))}}function Sf(e){Nr?Sr?Sr.push(e):Sr=[e]:Nr=e}function Cf(){if(Nr){var e=Nr,t=Sr;if(Sr=Nr=null,hu(e),t)for(e=0;e>>=0,e===0?32:31-(Yp(e)/Xp|0)|0}var ja=64,wa=4194304;function gs(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Za(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,l=n&268435455;if(l!==0){var o=l&~s;o!==0?r=gs(o):(i&=l,i!==0&&(r=gs(i)))}else l=n&~s,l!==0?r=gs(l):i!==0&&(r=gs(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function la(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-jt(t),e[t]=n}function nx(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=Ns),ku=" ",bu=!1;function Hf(e,t){switch(e){case"keyup":return Tx.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function qf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var hr=!1;function Lx(e,t){switch(e){case"compositionend":return qf(t);case"keypress":return t.which!==32?null:(bu=!0,ku);case"textInput":return e=t.data,e===ku&&bu?null:e;default:return null}}function Rx(e,t){if(hr)return e==="compositionend"||!cc&&Hf(e,t)?(e=Vf(),Aa=ic=fn=null,hr=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=_u(n)}}function Yf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Yf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Xf(){for(var e=window,t=Ga();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Ga(e.document)}return t}function uc(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function Bx(e){var t=Xf(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Yf(n.ownerDocument.documentElement,n)){if(r!==null&&uc(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var s=n.textContent.length,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=Eu(n,i);var l=Eu(n,r);s&&l&&(e.rangeCount!==1||e.anchorNode!==s.node||e.anchorOffset!==s.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(s.node,s.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,mr=null,Hl=null,Cs=null,ql=!1;function Pu(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ql||mr==null||mr!==Ga(r)||(r=mr,"selectionStart"in r&&uc(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Cs&&As(Cs,r)||(Cs=r,r=ni(Hl,"onSelect"),0vr||(e.current=Zl[vr],Zl[vr]=null,vr--)}function ie(e,t){vr++,Zl[vr]=e.current,e.current=t}var Pn={},Fe=Ln(Pn),qe=Ln(!1),Zn=Pn;function Br(e,t){var n=e.type.contextTypes;if(!n)return Pn;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function We(e){return e=e.childContextTypes,e!=null}function si(){ue(qe),ue(Fe)}function Fu(e,t,n){if(Fe.current!==Pn)throw Error(E(168));ie(Fe,t),ie(qe,n)}function lh(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var s in r)if(!(s in t))throw Error(E(108,Ip(e)||"Unknown",s));return me({},n,r)}function ai(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Pn,Zn=Fe.current,ie(Fe,e),ie(qe,qe.current),!0}function Iu(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=lh(e,t,Zn),r.__reactInternalMemoizedMergedChildContext=e,ue(qe),ue(Fe),ie(Fe,e)):ue(qe),ie(qe,n)}var Mt=null,Ti=!1,ul=!1;function oh(e){Mt===null?Mt=[e]:Mt.push(e)}function ev(e){Ti=!0,oh(e)}function Rn(){if(!ul&&Mt!==null){ul=!0;var e=0,t=ae;try{var n=Mt;for(ae=1;e>=l,s-=l,At=1<<32-jt(t)+s|n<_?(F=N,N=null):F=N.sibling;var O=m(p,N,x[_],w);if(O===null){N===null&&(N=F);break}e&&N&&O.alternate===null&&t(p,N),h=i(O,h,_),S===null?C=O:S.sibling=O,S=O,N=F}if(_===x.length)return n(p,N),de&&Fn(p,_),C;if(N===null){for(;__?(F=N,N=null):F=N.sibling;var B=m(p,N,O.value,w);if(B===null){N===null&&(N=F);break}e&&N&&B.alternate===null&&t(p,N),h=i(B,h,_),S===null?C=B:S.sibling=B,S=B,N=F}if(O.done)return n(p,N),de&&Fn(p,_),C;if(N===null){for(;!O.done;_++,O=x.next())O=f(p,O.value,w),O!==null&&(h=i(O,h,_),S===null?C=O:S.sibling=O,S=O);return de&&Fn(p,_),C}for(N=r(p,N);!O.done;_++,O=x.next())O=v(N,p,_,O.value,w),O!==null&&(e&&O.alternate!==null&&N.delete(O.key===null?_:O.key),h=i(O,h,_),S===null?C=O:S.sibling=O,S=O);return e&&N.forEach(function(G){return t(p,G)}),de&&Fn(p,_),C}function b(p,h,x,w){if(typeof x=="object"&&x!==null&&x.type===fr&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case va:e:{for(var C=x.key,S=h;S!==null;){if(S.key===C){if(C=x.type,C===fr){if(S.tag===7){n(p,S.sibling),h=s(S,x.props.children),h.return=p,p=h;break e}}else if(S.elementType===C||typeof C=="object"&&C!==null&&C.$$typeof===Xt&&$u(C)===S.type){n(p,S.sibling),h=s(S,x.props),h.ref=fs(p,S,x),h.return=p,p=h;break e}n(p,S);break}else t(p,S);S=S.sibling}x.type===fr?(h=Xn(x.props.children,p.mode,w,x.key),h.return=p,p=h):(w=qa(x.type,x.key,x.props,null,p.mode,w),w.ref=fs(p,h,x),w.return=p,p=w)}return l(p);case dr:e:{for(S=x.key;h!==null;){if(h.key===S)if(h.tag===4&&h.stateNode.containerInfo===x.containerInfo&&h.stateNode.implementation===x.implementation){n(p,h.sibling),h=s(h,x.children||[]),h.return=p,p=h;break e}else{n(p,h);break}else t(p,h);h=h.sibling}h=yl(x,p.mode,w),h.return=p,p=h}return l(p);case Xt:return S=x._init,b(p,h,S(x._payload),w)}if(ys(x))return k(p,h,x,w);if(ls(x))return g(p,h,x,w);Ea(p,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,h!==null&&h.tag===6?(n(p,h.sibling),h=s(h,x),h.return=p,p=h):(n(p,h),h=vl(x,p.mode,w),h.return=p,p=h),l(p)):n(p,h)}return b}var Vr=fh(!0),hh=fh(!1),oi=Ln(null),ci=null,jr=null,mc=null;function pc(){mc=jr=ci=null}function xc(e){var t=oi.current;ue(oi),e._currentValue=t}function no(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function _r(e,t){ci=e,mc=jr=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(He=!0),e.firstContext=null)}function ct(e){var t=e._currentValue;if(mc!==e)if(e={context:e,memoizedValue:t,next:null},jr===null){if(ci===null)throw Error(E(308));jr=e,ci.dependencies={lanes:0,firstContext:e}}else jr=jr.next=e;return t}var An=null;function vc(e){An===null?An=[e]:An.push(e)}function mh(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,vc(t)):(n.next=s.next,s.next=n),t.interleaved=n,Kt(e,r)}function Kt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Zt=!1;function yc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function ph(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Ut(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function wn(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,ne&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,Kt(e,n)}return s=r.interleaved,s===null?(t.next=t,vc(r)):(t.next=s.next,s.next=t),r.interleaved=t,Kt(e,n)}function Ua(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,rc(e,n)}}function Uu(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?s=i=l:i=i.next=l,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function ui(e,t,n,r){var s=e.updateQueue;Zt=!1;var i=s.firstBaseUpdate,l=s.lastBaseUpdate,o=s.shared.pending;if(o!==null){s.shared.pending=null;var c=o,u=c.next;c.next=null,l===null?i=u:l.next=u,l=c;var d=e.alternate;d!==null&&(d=d.updateQueue,o=d.lastBaseUpdate,o!==l&&(o===null?d.firstBaseUpdate=u:o.next=u,d.lastBaseUpdate=c))}if(i!==null){var f=s.baseState;l=0,d=u=c=null,o=i;do{var m=o.lane,v=o.eventTime;if((r&m)===m){d!==null&&(d=d.next={eventTime:v,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var k=e,g=o;switch(m=t,v=n,g.tag){case 1:if(k=g.payload,typeof k=="function"){f=k.call(v,f,m);break e}f=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=g.payload,m=typeof k=="function"?k.call(v,f,m):k,m==null)break e;f=me({},f,m);break e;case 2:Zt=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,m=s.effects,m===null?s.effects=[o]:m.push(o))}else v={eventTime:v,lane:m,tag:o.tag,payload:o.payload,callback:o.callback,next:null},d===null?(u=d=v,c=f):d=d.next=v,l|=m;if(o=o.next,o===null){if(o=s.shared.pending,o===null)break;m=o,o=m.next,m.next=null,s.lastBaseUpdate=m,s.shared.pending=null}}while(!0);if(d===null&&(c=f),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=d,t=s.shared.interleaved,t!==null){s=t;do l|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);nr|=l,e.lanes=l,e.memoizedState=f}}function Bu(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=fl.transition;fl.transition={};try{e(!1),t()}finally{ae=n,fl.transition=r}}function Lh(){return ut().memoizedState}function sv(e,t,n){var r=bn(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Rh(e))Mh(t,n);else if(n=mh(e,t,n,r),n!==null){var s=$e();wt(n,e,r,s),zh(n,t,r)}}function av(e,t,n){var r=bn(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Rh(e))Mh(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var l=t.lastRenderedState,o=i(l,n);if(s.hasEagerState=!0,s.eagerState=o,kt(o,l)){var c=t.interleaved;c===null?(s.next=s,vc(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=mh(e,t,s,r),n!==null&&(s=$e(),wt(n,e,r,s),zh(n,t,r))}}function Rh(e){var t=e.alternate;return e===he||t!==null&&t===he}function Mh(e,t){_s=fi=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function zh(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,rc(e,n)}}var hi={readContext:ct,useCallback:Le,useContext:Le,useEffect:Le,useImperativeHandle:Le,useInsertionEffect:Le,useLayoutEffect:Le,useMemo:Le,useReducer:Le,useRef:Le,useState:Le,useDebugValue:Le,useDeferredValue:Le,useTransition:Le,useMutableSource:Le,useSyncExternalStore:Le,useId:Le,unstable_isNewReconciler:!1},iv={readContext:ct,useCallback:function(e,t){return Nt().memoizedState=[e,t===void 0?null:t],e},useContext:ct,useEffect:Vu,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Qa(4194308,4,_h.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Qa(4194308,4,e,t)},useInsertionEffect:function(e,t){return Qa(4,2,e,t)},useMemo:function(e,t){var n=Nt();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Nt();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=sv.bind(null,he,e),[r.memoizedState,e]},useRef:function(e){var t=Nt();return e={current:e},t.memoizedState=e},useState:Qu,useDebugValue:Cc,useDeferredValue:function(e){return Nt().memoizedState=e},useTransition:function(){var e=Qu(!1),t=e[0];return e=rv.bind(null,e[1]),Nt().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=he,s=Nt();if(de){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),Ee===null)throw Error(E(349));tr&30||gh(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Vu(wh.bind(null,r,i,e),[e]),r.flags|=2048,qs(9,jh.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Nt(),t=Ee.identifierPrefix;if(de){var n=$t,r=At;n=(r&~(1<<32-jt(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Ks++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[Et]=t,e[Bs]=r,Kh(e,t,!1,!1),t.stateNode=e;e:{switch(l=Dl(n,r),n){case"dialog":ce("cancel",e),ce("close",e),s=r;break;case"iframe":case"object":case"embed":ce("load",e),s=r;break;case"video":case"audio":for(s=0;sqr&&(t.flags|=128,r=!0,hs(i,!1),t.lanes=4194304)}else{if(!r)if(e=di(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),hs(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!de)return Re(t),null}else 2*je()-i.renderingStartTime>qr&&n!==1073741824&&(t.flags|=128,r=!0,hs(i,!1),t.lanes=4194304);i.isBackwards?(l.sibling=t.child,t.child=l):(n=i.last,n!==null?n.sibling=l:t.child=l,i.last=l)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=je(),t.sibling=null,n=fe.current,ie(fe,r?n&1|2:n&1),t):(Re(t),null);case 22:case 23:return Lc(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ye&1073741824&&(Re(t),t.subtreeFlags&6&&(t.flags|=8192)):Re(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function mv(e,t){switch(fc(t),t.tag){case 1:return We(t.type)&&si(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Kr(),ue(qe),ue(Fe),wc(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return jc(t),null;case 13:if(ue(fe),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));Qr()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ue(fe),null;case 4:return Kr(),null;case 10:return xc(t.type._context),null;case 22:case 23:return Lc(),null;case 24:return null;default:return null}}var Ta=!1,ze=!1,pv=typeof WeakSet=="function"?WeakSet:Set,I=null;function wr(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ve(e,t,r)}else n.current=null}function fo(e,t,n){try{n()}catch(r){ve(e,t,r)}}var td=!1;function xv(e,t){if(Wl=ei,e=Xf(),uc(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var s=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var l=0,o=-1,c=-1,u=0,d=0,f=e,m=null;t:for(;;){for(var v;f!==n||s!==0&&f.nodeType!==3||(o=l+s),f!==i||r!==0&&f.nodeType!==3||(c=l+r),f.nodeType===3&&(l+=f.nodeValue.length),(v=f.firstChild)!==null;)m=f,f=v;for(;;){if(f===e)break t;if(m===n&&++u===s&&(o=l),m===i&&++d===r&&(c=l),(v=f.nextSibling)!==null)break;f=m,m=f.parentNode}f=v}n=o===-1||c===-1?null:{start:o,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Gl={focusedElem:e,selectionRange:n},ei=!1,I=t;I!==null;)if(t=I,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,I=e;else for(;I!==null;){t=I;try{var k=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(k!==null){var g=k.memoizedProps,b=k.memoizedState,p=t.stateNode,h=p.getSnapshotBeforeUpdate(t.elementType===t.type?g:mt(t.type,g),b);p.__reactInternalSnapshotBeforeUpdate=h}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(w){ve(t,t.return,w)}if(e=t.sibling,e!==null){e.return=t.return,I=e;break}I=t.return}return k=td,td=!1,k}function Es(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var s=r=r.next;do{if((s.tag&e)===e){var i=s.destroy;s.destroy=void 0,i!==void 0&&fo(t,n,i)}s=s.next}while(s!==r)}}function Ri(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function ho(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function Wh(e){var t=e.alternate;t!==null&&(e.alternate=null,Wh(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Et],delete t[Bs],delete t[Xl],delete t[Xx],delete t[Zx])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Gh(e){return e.tag===5||e.tag===3||e.tag===4}function nd(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Gh(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function mo(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=ri));else if(r!==4&&(e=e.child,e!==null))for(mo(e,t,n),e=e.sibling;e!==null;)mo(e,t,n),e=e.sibling}function po(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(po(e,t,n),e=e.sibling;e!==null;)po(e,t,n),e=e.sibling}var Pe=null,vt=!1;function Jt(e,t,n){for(n=n.child;n!==null;)Jh(e,t,n),n=n.sibling}function Jh(e,t,n){if(Pt&&typeof Pt.onCommitFiberUnmount=="function")try{Pt.onCommitFiberUnmount(Si,n)}catch{}switch(n.tag){case 5:ze||wr(n,t);case 6:var r=Pe,s=vt;Pe=null,Jt(e,t,n),Pe=r,vt=s,Pe!==null&&(vt?(e=Pe,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Pe.removeChild(n.stateNode));break;case 18:Pe!==null&&(vt?(e=Pe,n=n.stateNode,e.nodeType===8?cl(e.parentNode,n):e.nodeType===1&&cl(e,n),Is(e)):cl(Pe,n.stateNode));break;case 4:r=Pe,s=vt,Pe=n.stateNode.containerInfo,vt=!0,Jt(e,t,n),Pe=r,vt=s;break;case 0:case 11:case 14:case 15:if(!ze&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,l=i.destroy;i=i.tag,l!==void 0&&(i&2||i&4)&&fo(n,t,l),s=s.next}while(s!==r)}Jt(e,t,n);break;case 1:if(!ze&&(wr(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){ve(n,t,o)}Jt(e,t,n);break;case 21:Jt(e,t,n);break;case 22:n.mode&1?(ze=(r=ze)||n.memoizedState!==null,Jt(e,t,n),ze=r):Jt(e,t,n);break;default:Jt(e,t,n)}}function rd(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new pv),t.forEach(function(r){var s=Sv.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function ft(e,t){var n=t.deletions;if(n!==null)for(var r=0;rs&&(s=l),r&=~i}if(r=s,r=je()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*yv(r/1960))-r,10e?16:e,hn===null)var r=!1;else{if(e=hn,hn=null,xi=0,ne&6)throw Error(E(331));var s=ne;for(ne|=4,I=e.current;I!==null;){var i=I,l=i.child;if(I.flags&16){var o=i.deletions;if(o!==null){for(var c=0;cje()-Tc?Yn(e,0):Pc|=n),Ge(e,t)}function sm(e,t){t===0&&(e.mode&1?(t=wa,wa<<=1,!(wa&130023424)&&(wa=4194304)):t=1);var n=$e();e=Kt(e,t),e!==null&&(la(e,t,n),Ge(e,n))}function Nv(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),sm(e,n)}function Sv(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),sm(e,n)}var am;am=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||qe.current)He=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return He=!1,fv(e,t,n);He=!!(e.flags&131072)}else He=!1,de&&t.flags&1048576&&ch(t,li,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Va(e,t),e=t.pendingProps;var s=Br(t,Fe.current);_r(t,n),s=bc(null,t,r,e,s,n);var i=Nc();return t.flags|=1,typeof s=="object"&&s!==null&&typeof s.render=="function"&&s.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,We(r)?(i=!0,ai(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,yc(t),s.updater=Li,t.stateNode=s,s._reactInternals=t,so(t,r,e,n),t=lo(null,t,r,!0,i,n)):(t.tag=0,de&&i&&dc(t),De(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Va(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=_v(r),e=mt(r,e),s){case 0:t=io(null,t,r,e,n);break e;case 1:t=Xu(null,t,r,e,n);break e;case 11:t=Ju(null,t,r,e,n);break e;case 14:t=Yu(null,t,r,mt(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),io(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Xu(e,t,r,s,n);case 3:e:{if(Bh(t),e===null)throw Error(E(387));r=t.pendingProps,i=t.memoizedState,s=i.element,ph(e,t),ui(t,r,null,n);var l=t.memoizedState;if(r=l.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=Hr(Error(E(423)),t),t=Zu(e,t,r,n,s);break e}else if(r!==s){s=Hr(Error(E(424)),t),t=Zu(e,t,r,n,s);break e}else for(Xe=jn(t.stateNode.containerInfo.firstChild),Ze=t,de=!0,yt=null,n=hh(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Qr(),r===s){t=Ht(e,t,n);break e}De(e,t,r,n)}t=t.child}return t;case 5:return xh(t),e===null&&to(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,l=s.children,Jl(r,s)?l=null:i!==null&&Jl(r,i)&&(t.flags|=32),Uh(e,t),De(e,t,l,n),t.child;case 6:return e===null&&to(t),null;case 13:return Qh(e,t,n);case 4:return gc(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Vr(t,null,r,n):De(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Ju(e,t,r,s,n);case 7:return De(e,t,t.pendingProps,n),t.child;case 8:return De(e,t,t.pendingProps.children,n),t.child;case 12:return De(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,l=s.value,ie(oi,r._currentValue),r._currentValue=l,i!==null)if(kt(i.value,l)){if(i.children===s.children&&!qe.current){t=Ht(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var o=i.dependencies;if(o!==null){l=i.child;for(var c=o.firstContext;c!==null;){if(c.context===r){if(i.tag===1){c=Ut(-1,n&-n),c.tag=2;var u=i.updateQueue;if(u!==null){u=u.shared;var d=u.pending;d===null?c.next=c:(c.next=d.next,d.next=c),u.pending=c}}i.lanes|=n,c=i.alternate,c!==null&&(c.lanes|=n),no(i.return,n,t),o.lanes|=n;break}c=c.next}}else if(i.tag===10)l=i.type===t.type?null:i.child;else if(i.tag===18){if(l=i.return,l===null)throw Error(E(341));l.lanes|=n,o=l.alternate,o!==null&&(o.lanes|=n),no(l,n,t),l=i.sibling}else l=i.child;if(l!==null)l.return=i;else for(l=i;l!==null;){if(l===t){l=null;break}if(i=l.sibling,i!==null){i.return=l.return,l=i;break}l=l.return}i=l}De(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,_r(t,n),s=ct(s),r=r(s),t.flags|=1,De(e,t,r,n),t.child;case 14:return r=t.type,s=mt(r,t.pendingProps),s=mt(r.type,s),Yu(e,t,r,s,n);case 15:return Ah(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:mt(r,s),Va(e,t),t.tag=1,We(r)?(e=!0,ai(t)):e=!1,_r(t,n),Fh(t,r,s),so(t,r,s,n),lo(null,t,r,!0,e,n);case 19:return Vh(e,t,n);case 22:return $h(e,t,n)}throw Error(E(156,t.tag))};function im(e,t){return Rf(e,t)}function Cv(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function lt(e,t,n,r){return new Cv(e,t,n,r)}function Mc(e){return e=e.prototype,!(!e||!e.isReactComponent)}function _v(e){if(typeof e=="function")return Mc(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Zo)return 11;if(e===ec)return 14}return 2}function Nn(e,t){var n=e.alternate;return n===null?(n=lt(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function qa(e,t,n,r,s,i){var l=2;if(r=e,typeof e=="function")Mc(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case fr:return Xn(n.children,s,i,t);case Xo:l=8,s|=8;break;case El:return e=lt(12,n,t,s|2),e.elementType=El,e.lanes=i,e;case Pl:return e=lt(13,n,t,s),e.elementType=Pl,e.lanes=i,e;case Tl:return e=lt(19,n,t,s),e.elementType=Tl,e.lanes=i,e;case xf:return zi(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case mf:l=10;break e;case pf:l=9;break e;case Zo:l=11;break e;case ec:l=14;break e;case Xt:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=lt(l,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function Xn(e,t,n,r){return e=lt(7,e,r,t),e.lanes=n,e}function zi(e,t,n,r){return e=lt(22,e,r,t),e.elementType=xf,e.lanes=n,e.stateNode={isHidden:!1},e}function vl(e,t,n){return e=lt(6,e,null,t),e.lanes=n,e}function yl(e,t,n){return t=lt(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Ev(e,t,n,r,s){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Xi(0),this.expirationTimes=Xi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Xi(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function zc(e,t,n,r,s,i,l,o,c){return e=new Ev(e,t,n,o,c),t===1?(t=1,i===!0&&(t|=8)):t=0,i=lt(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},yc(i),e}function Pv(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(um)}catch(e){console.error(e)}}um(),uf.exports=tt;var Mv=uf.exports,dd=Mv;Cl.createRoot=dd.createRoot,Cl.hydrateRoot=dd.hydrateRoot;var es=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},zv={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},nn,Qo,$d,Fv=($d=class{constructor(){$(this,nn,zv);$(this,Qo,!1)}setTimeoutProvider(e){z(this,nn,e)}setTimeout(e,t){return y(this,nn).setTimeout(e,t)}clearTimeout(e){y(this,nn).clearTimeout(e)}setInterval(e,t){return y(this,nn).setInterval(e,t)}clearInterval(e){y(this,nn).clearInterval(e)}},nn=new WeakMap,Qo=new WeakMap,$d),Un=new Fv;function Iv(e){setTimeout(e,0)}var sr=typeof window>"u"||"Deno"in globalThis;function Ae(){}function Dv(e,t){return typeof e=="function"?e(t):e}function jo(e){return typeof e=="number"&&e>=0&&e!==1/0}function dm(e,t){return Math.max(e+(t||0)-Date.now(),0)}function Sn(e,t){return typeof e=="function"?e(t):e}function st(e,t){return typeof e=="function"?e(t):e}function fd(e,t){const{type:n="all",exact:r,fetchStatus:s,predicate:i,queryKey:l,stale:o}=e;if(l){if(r){if(t.queryHash!==Ac(l,t.options))return!1}else if(!Gs(t.queryKey,l))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof o=="boolean"&&t.isStale()!==o||s&&s!==t.state.fetchStatus||i&&!i(t))}function hd(e,t){const{exact:n,status:r,predicate:s,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(n){if(ar(t.options.mutationKey)!==ar(i))return!1}else if(!Gs(t.options.mutationKey,i))return!1}return!(r&&t.state.status!==r||s&&!s(t))}function Ac(e,t){return((t==null?void 0:t.queryKeyHashFn)||ar)(e)}function ar(e){return JSON.stringify(e,(t,n)=>wo(n)?Object.keys(n).sort().reduce((r,s)=>(r[s]=n[s],r),{}):n)}function Gs(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Gs(e[n],t[n])):!1}var Av=Object.prototype.hasOwnProperty;function fm(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=md(e)&&md(t);if(!r&&!(wo(e)&&wo(t)))return t;const i=(r?e:Object.keys(e)).length,l=r?t:Object.keys(t),o=l.length,c=r?new Array(o):{};let u=0;for(let d=0;d{Un.setTimeout(t,e)})}function ko(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?fm(e,t):t}function Uv(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function Bv(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var $c=Symbol();function hm(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===$c?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Uc(e,t){return typeof e=="function"?e(...t):!!e}function Qv(e,t,n){let r=!1,s;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(s??(s=t()),r||(r=!0,s.aborted?n():s.addEventListener("abort",n,{once:!0})),s)}),e}var Bn,rn,Pr,Ud,Vv=(Ud=class extends es{constructor(){super();$(this,Bn);$(this,rn);$(this,Pr);z(this,Pr,t=>{if(!sr&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){y(this,rn)||this.setEventListener(y(this,Pr))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,rn))==null||t.call(this),z(this,rn,void 0))}setEventListener(t){var n;z(this,Pr,t),(n=y(this,rn))==null||n.call(this),z(this,rn,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){y(this,Bn)!==t&&(z(this,Bn,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof y(this,Bn)=="boolean"?y(this,Bn):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Bn=new WeakMap,rn=new WeakMap,Pr=new WeakMap,Ud),Bc=new Vv;function bo(){let e,t;const n=new Promise((s,i)=>{e=s,t=i});n.status="pending",n.catch(()=>{});function r(s){Object.assign(n,s),delete n.resolve,delete n.reject}return n.resolve=s=>{r({status:"fulfilled",value:s}),e(s)},n.reject=s=>{r({status:"rejected",reason:s}),t(s)},n}var Kv=Iv;function Hv(){let e=[],t=0,n=o=>{o()},r=o=>{o()},s=Kv;const i=o=>{t?e.push(o):s(()=>{n(o)})},l=()=>{const o=e;e=[],o.length&&s(()=>{r(()=>{o.forEach(c=>{n(c)})})})};return{batch:o=>{let c;t++;try{c=o()}finally{t--,t||l()}return c},batchCalls:o=>(...c)=>{i(()=>{o(...c)})},schedule:i,setNotifyFunction:o=>{n=o},setBatchNotifyFunction:o=>{r=o},setScheduler:o=>{s=o}}}var be=Hv(),Tr,sn,Or,Bd,qv=(Bd=class extends es{constructor(){super();$(this,Tr,!0);$(this,sn);$(this,Or);z(this,Or,t=>{if(!sr&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){y(this,sn)||this.setEventListener(y(this,Or))}onUnsubscribe(){var t;this.hasListeners()||((t=y(this,sn))==null||t.call(this),z(this,sn,void 0))}setEventListener(t){var n;z(this,Or,t),(n=y(this,sn))==null||n.call(this),z(this,sn,t(this.setOnline.bind(this)))}setOnline(t){y(this,Tr)!==t&&(z(this,Tr,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return y(this,Tr)}},Tr=new WeakMap,sn=new WeakMap,Or=new WeakMap,Bd),ji=new qv;function Wv(e){return Math.min(1e3*2**e,3e4)}function mm(e){return(e??"online")==="online"?ji.isOnline():!0}var No=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function pm(e){let t=!1,n=0,r;const s=bo(),i=()=>s.status!=="pending",l=g=>{var b;if(!i()){const p=new No(g);m(p),(b=e.onCancel)==null||b.call(e,p)}},o=()=>{t=!0},c=()=>{t=!1},u=()=>Bc.isFocused()&&(e.networkMode==="always"||ji.isOnline())&&e.canRun(),d=()=>mm(e.networkMode)&&e.canRun(),f=g=>{i()||(r==null||r(),s.resolve(g))},m=g=>{i()||(r==null||r(),s.reject(g))},v=()=>new Promise(g=>{var b;r=p=>{(i()||u())&&g(p)},(b=e.onPause)==null||b.call(e)}).then(()=>{var g;r=void 0,i()||(g=e.onContinue)==null||g.call(e)}),k=()=>{if(i())return;let g;const b=n===0?e.initialPromise:void 0;try{g=b??e.fn()}catch(p){g=Promise.reject(p)}Promise.resolve(g).then(f).catch(p=>{var S;if(i())return;const h=e.retry??(sr?0:3),x=e.retryDelay??Wv,w=typeof x=="function"?x(n,p):x,C=h===!0||typeof h=="number"&&nu()?void 0:v()).then(()=>{t?m(p):k()})})};return{promise:s,status:()=>s.status,cancel:l,continue:()=>(r==null||r(),s),cancelRetry:o,continueRetry:c,canStart:d,start:()=>(d()?k():v().then(k),s)}}var Qn,Qd,xm=(Qd=class{constructor(){$(this,Qn)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),jo(this.gcTime)&&z(this,Qn,Un.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(sr?1/0:5*60*1e3))}clearGcTimeout(){y(this,Qn)&&(Un.clearTimeout(y(this,Qn)),z(this,Qn,void 0))}},Qn=new WeakMap,Qd),Vn,Lr,rt,Kn,Ce,ta,Hn,pt,Lt,Vd,Gv=(Vd=class extends xm{constructor(t){super();$(this,pt);$(this,Vn);$(this,Lr);$(this,rt);$(this,Kn);$(this,Ce);$(this,ta);$(this,Hn);z(this,Hn,!1),z(this,ta,t.defaultOptions),this.setOptions(t.options),this.observers=[],z(this,Kn,t.client),z(this,rt,y(this,Kn).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,z(this,Vn,vd(this.options)),this.state=t.state??y(this,Vn),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var t;return(t=y(this,Ce))==null?void 0:t.promise}setOptions(t){if(this.options={...y(this,ta),...t},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=vd(this.options);n.data!==void 0&&(this.setState(xd(n.data,n.dataUpdatedAt)),z(this,Vn,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&y(this,rt).remove(this)}setData(t,n){const r=ko(this.state.data,t,this.options);return H(this,pt,Lt).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t,n){H(this,pt,Lt).call(this,{type:"setState",state:t,setStateOptions:n})}cancel(t){var r,s;const n=(r=y(this,Ce))==null?void 0:r.promise;return(s=y(this,Ce))==null||s.cancel(t),n?n.then(Ae).catch(Ae):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(y(this,Vn))}isActive(){return this.observers.some(t=>st(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===$c||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>Sn(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!dm(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=y(this,Ce))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),y(this,rt).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(y(this,Ce)&&(y(this,Hn)?y(this,Ce).cancel({revert:!0}):y(this,Ce).cancelRetry()),this.scheduleGc()),y(this,rt).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||H(this,pt,Lt).call(this,{type:"invalidate"})}async fetch(t,n){var c,u,d,f,m,v,k,g,b,p,h,x;if(this.state.fetchStatus!=="idle"&&((c=y(this,Ce))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(y(this,Ce))return y(this,Ce).continueRetry(),y(this,Ce).promise}if(t&&this.setOptions(t),!this.options.queryFn){const w=this.observers.find(C=>C.options.queryFn);w&&this.setOptions(w.options)}const r=new AbortController,s=w=>{Object.defineProperty(w,"signal",{enumerable:!0,get:()=>(z(this,Hn,!0),r.signal)})},i=()=>{const w=hm(this.options,n),S=(()=>{const N={client:y(this,Kn),queryKey:this.queryKey,meta:this.meta};return s(N),N})();return z(this,Hn,!1),this.options.persister?this.options.persister(w,S,this):w(S)},o=(()=>{const w={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:y(this,Kn),state:this.state,fetchFn:i};return s(w),w})();(u=this.options.behavior)==null||u.onFetch(o,this),z(this,Lr,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=o.fetchOptions)==null?void 0:d.meta))&&H(this,pt,Lt).call(this,{type:"fetch",meta:(f=o.fetchOptions)==null?void 0:f.meta}),z(this,Ce,pm({initialPromise:n==null?void 0:n.initialPromise,fn:o.fetchFn,onCancel:w=>{w instanceof No&&w.revert&&this.setState({...y(this,Lr),fetchStatus:"idle"}),r.abort()},onFail:(w,C)=>{H(this,pt,Lt).call(this,{type:"failed",failureCount:w,error:C})},onPause:()=>{H(this,pt,Lt).call(this,{type:"pause"})},onContinue:()=>{H(this,pt,Lt).call(this,{type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0}));try{const w=await y(this,Ce).start();if(w===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(w),(v=(m=y(this,rt).config).onSuccess)==null||v.call(m,w,this),(g=(k=y(this,rt).config).onSettled)==null||g.call(k,w,this.state.error,this),w}catch(w){if(w instanceof No){if(w.silent)return y(this,Ce).promise;if(w.revert){if(this.state.data===void 0)throw w;return this.state.data}}throw H(this,pt,Lt).call(this,{type:"error",error:w}),(p=(b=y(this,rt).config).onError)==null||p.call(b,w,this),(x=(h=y(this,rt).config).onSettled)==null||x.call(h,this.state.data,w,this),w}finally{this.scheduleGc()}}},Vn=new WeakMap,Lr=new WeakMap,rt=new WeakMap,Kn=new WeakMap,Ce=new WeakMap,ta=new WeakMap,Hn=new WeakMap,pt=new WeakSet,Lt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...vm(r.data,this.options),fetchMeta:t.meta??null};case"success":const s={...r,...xd(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return z(this,Lr,t.manual?s:void 0),s;case"error":const i=t.error;return{...r,error:i,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),be.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),y(this,rt).notify({query:this,type:"updated",action:t})})},Vd);function vm(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:mm(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function xd(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function vd(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Qe,Z,na,Ie,qn,Rr,zt,an,ra,Mr,zr,Wn,Gn,ln,Fr,se,ws,So,Co,_o,Eo,Po,To,Oo,ym,Kd,Jv=(Kd=class extends es{constructor(t,n){super();$(this,se);$(this,Qe);$(this,Z);$(this,na);$(this,Ie);$(this,qn);$(this,Rr);$(this,zt);$(this,an);$(this,ra);$(this,Mr);$(this,zr);$(this,Wn);$(this,Gn);$(this,ln);$(this,Fr,new Set);this.options=n,z(this,Qe,t),z(this,an,null),z(this,zt,bo()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(y(this,Z).addObserver(this),yd(y(this,Z),this.options)?H(this,se,ws).call(this):this.updateResult(),H(this,se,Eo).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return Lo(y(this,Z),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return Lo(y(this,Z),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,H(this,se,Po).call(this),H(this,se,To).call(this),y(this,Z).removeObserver(this)}setOptions(t){const n=this.options,r=y(this,Z);if(this.options=y(this,Qe).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof st(this.options.enabled,y(this,Z))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");H(this,se,Oo).call(this),y(this,Z).setOptions(this.options),n._defaulted&&!gi(this.options,n)&&y(this,Qe).getQueryCache().notify({type:"observerOptionsUpdated",query:y(this,Z),observer:this});const s=this.hasListeners();s&&gd(y(this,Z),r,this.options,n)&&H(this,se,ws).call(this),this.updateResult(),s&&(y(this,Z)!==r||st(this.options.enabled,y(this,Z))!==st(n.enabled,y(this,Z))||Sn(this.options.staleTime,y(this,Z))!==Sn(n.staleTime,y(this,Z)))&&H(this,se,So).call(this);const i=H(this,se,Co).call(this);s&&(y(this,Z)!==r||st(this.options.enabled,y(this,Z))!==st(n.enabled,y(this,Z))||i!==y(this,ln))&&H(this,se,_o).call(this,i)}getOptimisticResult(t){const n=y(this,Qe).getQueryCache().build(y(this,Qe),t),r=this.createResult(n,t);return Xv(this,r)&&(z(this,Ie,r),z(this,Rr,this.options),z(this,qn,y(this,Z).state)),r}getCurrentResult(){return y(this,Ie)}trackResult(t,n){return new Proxy(t,{get:(r,s)=>(this.trackProp(s),n==null||n(s),s==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&y(this,zt).status==="pending"&&y(this,zt).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,s))})}trackProp(t){y(this,Fr).add(t)}getCurrentQuery(){return y(this,Z)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=y(this,Qe).defaultQueryOptions(t),r=y(this,Qe).getQueryCache().build(y(this,Qe),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return H(this,se,ws).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),y(this,Ie)))}createResult(t,n){var F;const r=y(this,Z),s=this.options,i=y(this,Ie),l=y(this,qn),o=y(this,Rr),u=t!==r?t.state:y(this,na),{state:d}=t;let f={...d},m=!1,v;if(n._optimisticResults){const O=this.hasListeners(),B=!O&&yd(t,n),G=O&&gd(t,r,n,s);(B||G)&&(f={...f,...vm(d.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:k,errorUpdatedAt:g,status:b}=f;v=f.data;let p=!1;if(n.placeholderData!==void 0&&v===void 0&&b==="pending"){let O;i!=null&&i.isPlaceholderData&&n.placeholderData===(o==null?void 0:o.placeholderData)?(O=i.data,p=!0):O=typeof n.placeholderData=="function"?n.placeholderData((F=y(this,zr))==null?void 0:F.state.data,y(this,zr)):n.placeholderData,O!==void 0&&(b="success",v=ko(i==null?void 0:i.data,O,n),m=!0)}if(n.select&&v!==void 0&&!p)if(i&&v===(l==null?void 0:l.data)&&n.select===y(this,ra))v=y(this,Mr);else try{z(this,ra,n.select),v=n.select(v),v=ko(i==null?void 0:i.data,v,n),z(this,Mr,v),z(this,an,null)}catch(O){z(this,an,O)}y(this,an)&&(k=y(this,an),v=y(this,Mr),g=Date.now(),b="error");const h=f.fetchStatus==="fetching",x=b==="pending",w=b==="error",C=x&&h,S=v!==void 0,_={status:b,fetchStatus:f.fetchStatus,isPending:x,isSuccess:b==="success",isError:w,isInitialLoading:C,isLoading:C,data:v,dataUpdatedAt:f.dataUpdatedAt,error:k,errorUpdatedAt:g,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:f.dataUpdateCount>0||f.errorUpdateCount>0,isFetchedAfterMount:f.dataUpdateCount>u.dataUpdateCount||f.errorUpdateCount>u.errorUpdateCount,isFetching:h,isRefetching:h&&!x,isLoadingError:w&&!S,isPaused:f.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:w&&S,isStale:Qc(t,n),refetch:this.refetch,promise:y(this,zt),isEnabled:st(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const O=_.data!==void 0,B=_.status==="error"&&!O,G=D=>{B?D.reject(_.error):O&&D.resolve(_.data)},re=()=>{const D=z(this,zt,_.promise=bo());G(D)},oe=y(this,zt);switch(oe.status){case"pending":t.queryHash===r.queryHash&&G(oe);break;case"fulfilled":(B||_.data!==oe.value)&&re();break;case"rejected":(!B||_.error!==oe.reason)&&re();break}}return _}updateResult(){const t=y(this,Ie),n=this.createResult(y(this,Z),this.options);if(z(this,qn,y(this,Z).state),z(this,Rr,this.options),y(this,qn).data!==void 0&&z(this,zr,y(this,Z)),gi(n,t))return;z(this,Ie,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:s}=this.options,i=typeof s=="function"?s():s;if(i==="all"||!i&&!y(this,Fr).size)return!0;const l=new Set(i??y(this,Fr));return this.options.throwOnError&&l.add("error"),Object.keys(y(this,Ie)).some(o=>{const c=o;return y(this,Ie)[c]!==t[c]&&l.has(c)})};H(this,se,ym).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&H(this,se,Eo).call(this)}},Qe=new WeakMap,Z=new WeakMap,na=new WeakMap,Ie=new WeakMap,qn=new WeakMap,Rr=new WeakMap,zt=new WeakMap,an=new WeakMap,ra=new WeakMap,Mr=new WeakMap,zr=new WeakMap,Wn=new WeakMap,Gn=new WeakMap,ln=new WeakMap,Fr=new WeakMap,se=new WeakSet,ws=function(t){H(this,se,Oo).call(this);let n=y(this,Z).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Ae)),n},So=function(){H(this,se,Po).call(this);const t=Sn(this.options.staleTime,y(this,Z));if(sr||y(this,Ie).isStale||!jo(t))return;const r=dm(y(this,Ie).dataUpdatedAt,t)+1;z(this,Wn,Un.setTimeout(()=>{y(this,Ie).isStale||this.updateResult()},r))},Co=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(y(this,Z)):this.options.refetchInterval)??!1},_o=function(t){H(this,se,To).call(this),z(this,ln,t),!(sr||st(this.options.enabled,y(this,Z))===!1||!jo(y(this,ln))||y(this,ln)===0)&&z(this,Gn,Un.setInterval(()=>{(this.options.refetchIntervalInBackground||Bc.isFocused())&&H(this,se,ws).call(this)},y(this,ln)))},Eo=function(){H(this,se,So).call(this),H(this,se,_o).call(this,H(this,se,Co).call(this))},Po=function(){y(this,Wn)&&(Un.clearTimeout(y(this,Wn)),z(this,Wn,void 0))},To=function(){y(this,Gn)&&(Un.clearInterval(y(this,Gn)),z(this,Gn,void 0))},Oo=function(){const t=y(this,Qe).getQueryCache().build(y(this,Qe),this.options);if(t===y(this,Z))return;const n=y(this,Z);z(this,Z,t),z(this,na,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},ym=function(t){be.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(y(this,Ie))}),y(this,Qe).getQueryCache().notify({query:y(this,Z),type:"observerResultsUpdated"})})},Kd);function Yv(e,t){return st(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function yd(e,t){return Yv(e,t)||e.state.data!==void 0&&Lo(e,t,t.refetchOnMount)}function Lo(e,t,n){if(st(t.enabled,e)!==!1&&Sn(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Qc(e,t)}return!1}function gd(e,t,n,r){return(e!==t||st(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Qc(e,n)}function Qc(e,t){return st(t.enabled,e)!==!1&&e.isStaleByTime(Sn(t.staleTime,e))}function Xv(e,t){return!gi(e.getCurrentResult(),t)}function jd(e){return{onFetch:(t,n)=>{var d,f,m,v,k;const r=t.options,s=(m=(f=(d=t.fetchOptions)==null?void 0:d.meta)==null?void 0:f.fetchMore)==null?void 0:m.direction,i=((v=t.state.data)==null?void 0:v.pages)||[],l=((k=t.state.data)==null?void 0:k.pageParams)||[];let o={pages:[],pageParams:[]},c=0;const u=async()=>{let g=!1;const b=x=>{Qv(x,()=>t.signal,()=>g=!0)},p=hm(t.options,t.fetchOptions),h=async(x,w,C)=>{if(g)return Promise.reject();if(w==null&&x.pages.length)return Promise.resolve(x);const N=(()=>{const B={client:t.client,queryKey:t.queryKey,pageParam:w,direction:C?"backward":"forward",meta:t.options.meta};return b(B),B})(),_=await p(N),{maxPages:F}=t.options,O=C?Bv:Uv;return{pages:O(x.pages,_,F),pageParams:O(x.pageParams,w,F)}};if(s&&i.length){const x=s==="backward",w=x?Zv:wd,C={pages:i,pageParams:l},S=w(r,C);o=await h(C,S,x)}else{const x=e??i.length;do{const w=c===0?l[0]??r.initialPageParam:wd(r,o);if(c>0&&w==null)break;o=await h(o,w),c++}while(c{var g,b;return(b=(g=t.options).persister)==null?void 0:b.call(g,u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=u}}}function wd(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function Zv(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var sa,St,Me,Jn,Ct,Yt,Hd,ey=(Hd=class extends xm{constructor(t){super();$(this,Ct);$(this,sa);$(this,St);$(this,Me);$(this,Jn);z(this,sa,t.client),this.mutationId=t.mutationId,z(this,Me,t.mutationCache),z(this,St,[]),this.state=t.state||gm(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){y(this,St).includes(t)||(y(this,St).push(t),this.clearGcTimeout(),y(this,Me).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){z(this,St,y(this,St).filter(n=>n!==t)),this.scheduleGc(),y(this,Me).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){y(this,St).length||(this.state.status==="pending"?this.scheduleGc():y(this,Me).remove(this))}continue(){var t;return((t=y(this,Jn))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,o,c,u,d,f,m,v,k,g,b,p,h,x,w,C,S,N;const n=()=>{H(this,Ct,Yt).call(this,{type:"continue"})},r={client:y(this,sa),meta:this.options.meta,mutationKey:this.options.mutationKey};z(this,Jn,pm({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(_,F)=>{H(this,Ct,Yt).call(this,{type:"failed",failureCount:_,error:F})},onPause:()=>{H(this,Ct,Yt).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>y(this,Me).canRun(this)}));const s=this.state.status==="pending",i=!y(this,Jn).canStart();try{if(s)n();else{H(this,Ct,Yt).call(this,{type:"pending",variables:t,isPaused:i}),y(this,Me).config.onMutate&&await y(this,Me).config.onMutate(t,this,r);const F=await((o=(l=this.options).onMutate)==null?void 0:o.call(l,t,r));F!==this.state.context&&H(this,Ct,Yt).call(this,{type:"pending",context:F,variables:t,isPaused:i})}const _=await y(this,Jn).start();return await((u=(c=y(this,Me).config).onSuccess)==null?void 0:u.call(c,_,t,this.state.context,this,r)),await((f=(d=this.options).onSuccess)==null?void 0:f.call(d,_,t,this.state.context,r)),await((v=(m=y(this,Me).config).onSettled)==null?void 0:v.call(m,_,null,this.state.variables,this.state.context,this,r)),await((g=(k=this.options).onSettled)==null?void 0:g.call(k,_,null,t,this.state.context,r)),H(this,Ct,Yt).call(this,{type:"success",data:_}),_}catch(_){try{await((p=(b=y(this,Me).config).onError)==null?void 0:p.call(b,_,t,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((x=(h=this.options).onError)==null?void 0:x.call(h,_,t,this.state.context,r))}catch(F){Promise.reject(F)}try{await((C=(w=y(this,Me).config).onSettled)==null?void 0:C.call(w,void 0,_,this.state.variables,this.state.context,this,r))}catch(F){Promise.reject(F)}try{await((N=(S=this.options).onSettled)==null?void 0:N.call(S,void 0,_,t,this.state.context,r))}catch(F){Promise.reject(F)}throw H(this,Ct,Yt).call(this,{type:"error",error:_}),_}finally{y(this,Me).runNext(this)}}},sa=new WeakMap,St=new WeakMap,Me=new WeakMap,Jn=new WeakMap,Ct=new WeakSet,Yt=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),be.batch(()=>{y(this,St).forEach(r=>{r.onMutationUpdate(t)}),y(this,Me).notify({mutation:this,type:"updated",action:t})})},Hd);function gm(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Ft,xt,aa,qd,ty=(qd=class extends es{constructor(t={}){super();$(this,Ft);$(this,xt);$(this,aa);this.config=t,z(this,Ft,new Set),z(this,xt,new Map),z(this,aa,0)}build(t,n,r){const s=new ey({client:t,mutationCache:this,mutationId:++pa(this,aa)._,options:t.defaultMutationOptions(n),state:r});return this.add(s),s}add(t){y(this,Ft).add(t);const n=Ra(t);if(typeof n=="string"){const r=y(this,xt).get(n);r?r.push(t):y(this,xt).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(y(this,Ft).delete(t)){const n=Ra(t);if(typeof n=="string"){const r=y(this,xt).get(n);if(r)if(r.length>1){const s=r.indexOf(t);s!==-1&&r.splice(s,1)}else r[0]===t&&y(this,xt).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Ra(t);if(typeof n=="string"){const r=y(this,xt).get(n),s=r==null?void 0:r.find(i=>i.state.status==="pending");return!s||s===t}else return!0}runNext(t){var r;const n=Ra(t);if(typeof n=="string"){const s=(r=y(this,xt).get(n))==null?void 0:r.find(i=>i!==t&&i.state.isPaused);return(s==null?void 0:s.continue())??Promise.resolve()}else return Promise.resolve()}clear(){be.batch(()=>{y(this,Ft).forEach(t=>{this.notify({type:"removed",mutation:t})}),y(this,Ft).clear(),y(this,xt).clear()})}getAll(){return Array.from(y(this,Ft))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>hd(n,r))}findAll(t={}){return this.getAll().filter(n=>hd(t,n))}notify(t){be.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return be.batch(()=>Promise.all(t.map(n=>n.continue().catch(Ae))))}},Ft=new WeakMap,xt=new WeakMap,aa=new WeakMap,qd);function Ra(e){var t;return(t=e.options.scope)==null?void 0:t.id}var It,on,Ve,Dt,Bt,Wa,Ro,Wd,ny=(Wd=class extends es{constructor(n,r){super();$(this,Bt);$(this,It);$(this,on);$(this,Ve);$(this,Dt);z(this,It,n),this.setOptions(r),this.bindMethods(),H(this,Bt,Wa).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var s;const r=this.options;this.options=y(this,It).defaultMutationOptions(n),gi(this.options,r)||y(this,It).getMutationCache().notify({type:"observerOptionsUpdated",mutation:y(this,Ve),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&ar(r.mutationKey)!==ar(this.options.mutationKey)?this.reset():((s=y(this,Ve))==null?void 0:s.state.status)==="pending"&&y(this,Ve).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=y(this,Ve))==null||n.removeObserver(this)}onMutationUpdate(n){H(this,Bt,Wa).call(this),H(this,Bt,Ro).call(this,n)}getCurrentResult(){return y(this,on)}reset(){var n;(n=y(this,Ve))==null||n.removeObserver(this),z(this,Ve,void 0),H(this,Bt,Wa).call(this),H(this,Bt,Ro).call(this)}mutate(n,r){var s;return z(this,Dt,r),(s=y(this,Ve))==null||s.removeObserver(this),z(this,Ve,y(this,It).getMutationCache().build(y(this,It),this.options)),y(this,Ve).addObserver(this),y(this,Ve).execute(n)}},It=new WeakMap,on=new WeakMap,Ve=new WeakMap,Dt=new WeakMap,Bt=new WeakSet,Wa=function(){var r;const n=((r=y(this,Ve))==null?void 0:r.state)??gm();z(this,on,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},Ro=function(n){be.batch(()=>{var r,s,i,l,o,c,u,d;if(y(this,Dt)&&this.hasListeners()){const f=y(this,on).variables,m=y(this,on).context,v={client:y(this,It),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(s=(r=y(this,Dt)).onSuccess)==null||s.call(r,n.data,f,m,v)}catch(k){Promise.reject(k)}try{(l=(i=y(this,Dt)).onSettled)==null||l.call(i,n.data,null,f,m,v)}catch(k){Promise.reject(k)}}else if((n==null?void 0:n.type)==="error"){try{(c=(o=y(this,Dt)).onError)==null||c.call(o,n.error,f,m,v)}catch(k){Promise.reject(k)}try{(d=(u=y(this,Dt)).onSettled)==null||d.call(u,void 0,n.error,f,m,v)}catch(k){Promise.reject(k)}}}this.listeners.forEach(f=>{f(y(this,on))})})},Wd),_t,Gd,ry=(Gd=class extends es{constructor(t={}){super();$(this,_t);this.config=t,z(this,_t,new Map)}build(t,n,r){const s=n.queryKey,i=n.queryHash??Ac(s,n);let l=this.get(i);return l||(l=new Gv({client:t,queryKey:s,queryHash:i,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(s)}),this.add(l)),l}add(t){y(this,_t).has(t.queryHash)||(y(this,_t).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=y(this,_t).get(t.queryHash);n&&(t.destroy(),n===t&&y(this,_t).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){be.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return y(this,_t).get(t)}getAll(){return[...y(this,_t).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>fd(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>fd(t,r)):n}notify(t){be.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){be.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){be.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},_t=new WeakMap,Gd),xe,cn,un,Ir,Dr,dn,Ar,$r,Jd,sy=(Jd=class{constructor(e={}){$(this,xe);$(this,cn);$(this,un);$(this,Ir);$(this,Dr);$(this,dn);$(this,Ar);$(this,$r);z(this,xe,e.queryCache||new ry),z(this,cn,e.mutationCache||new ty),z(this,un,e.defaultOptions||{}),z(this,Ir,new Map),z(this,Dr,new Map),z(this,dn,0)}mount(){pa(this,dn)._++,y(this,dn)===1&&(z(this,Ar,Bc.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,xe).onFocus())})),z(this,$r,ji.subscribe(async e=>{e&&(await this.resumePausedMutations(),y(this,xe).onOnline())})))}unmount(){var e,t;pa(this,dn)._--,y(this,dn)===0&&((e=y(this,Ar))==null||e.call(this),z(this,Ar,void 0),(t=y(this,$r))==null||t.call(this),z(this,$r,void 0))}isFetching(e){return y(this,xe).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return y(this,cn).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,xe).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=y(this,xe).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Sn(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return y(this,xe).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),s=y(this,xe).get(r.queryHash),i=s==null?void 0:s.state.data,l=Dv(t,i);if(l!==void 0)return y(this,xe).build(this,r).setData(l,{...n,manual:!0})}setQueriesData(e,t,n){return be.batch(()=>y(this,xe).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=y(this,xe).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=y(this,xe);be.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=y(this,xe);return be.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=be.batch(()=>y(this,xe).findAll(e).map(s=>s.cancel(n)));return Promise.all(r).then(Ae).catch(Ae)}invalidateQueries(e,t={}){return be.batch(()=>(y(this,xe).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=be.batch(()=>y(this,xe).findAll(e).filter(s=>!s.isDisabled()&&!s.isStatic()).map(s=>{let i=s.fetch(void 0,n);return n.throwOnError||(i=i.catch(Ae)),s.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(r).then(Ae)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=y(this,xe).build(this,t);return n.isStaleByTime(Sn(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ae).catch(Ae)}fetchInfiniteQuery(e){return e.behavior=jd(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ae).catch(Ae)}ensureInfiniteQueryData(e){return e.behavior=jd(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ji.isOnline()?y(this,cn).resumePausedMutations():Promise.resolve()}getQueryCache(){return y(this,xe)}getMutationCache(){return y(this,cn)}getDefaultOptions(){return y(this,un)}setDefaultOptions(e){z(this,un,e)}setQueryDefaults(e,t){y(this,Ir).set(ar(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...y(this,Ir).values()],n={};return t.forEach(r=>{Gs(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){y(this,Dr).set(ar(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...y(this,Dr).values()],n={};return t.forEach(r=>{Gs(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...y(this,un).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Ac(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===$c&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...y(this,un).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){y(this,xe).clear(),y(this,cn).clear()}},xe=new WeakMap,cn=new WeakMap,un=new WeakMap,Ir=new WeakMap,Dr=new WeakMap,dn=new WeakMap,Ar=new WeakMap,$r=new WeakMap,Jd),jm=j.createContext(void 0),Wt=e=>{const t=j.useContext(jm);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},ay=({client:e,children:t})=>(j.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),a.jsx(jm.Provider,{value:e,children:t})),wm=j.createContext(!1),iy=()=>j.useContext(wm);wm.Provider;function ly(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var oy=j.createContext(ly()),cy=()=>j.useContext(oy),uy=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Uc(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},dy=e=>{j.useEffect(()=>{e.clearReset()},[e])},fy=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:s})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(s&&e.data===void 0||Uc(n,[e.error,r])),hy=e=>{if(e.suspense){const n=s=>s==="static"?s:Math.max(s??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...s)=>n(r(...s)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},my=(e,t)=>e.isLoading&&e.isFetching&&!t,py=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,kd=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function xy(e,t,n){var m,v,k,g;const r=iy(),s=cy(),i=Wt(),l=i.defaultQueryOptions(e);(v=(m=i.getDefaultOptions().queries)==null?void 0:m._experimental_beforeQuery)==null||v.call(m,l);const o=i.getQueryCache().get(l.queryHash);l._optimisticResults=r?"isRestoring":"optimistic",hy(l),uy(l,s,o),dy(s);const c=!i.getQueryCache().get(l.queryHash),[u]=j.useState(()=>new t(i,l)),d=u.getOptimisticResult(l),f=!r&&e.subscribed!==!1;if(j.useSyncExternalStore(j.useCallback(b=>{const p=f?u.subscribe(be.batchCalls(b)):Ae;return u.updateResult(),p},[u,f]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),j.useEffect(()=>{u.setOptions(l)},[l,u]),py(l,d))throw kd(l,u,s);if(fy({result:d,errorResetBoundary:s,throwOnError:l.throwOnError,query:o,suspense:l.suspense}))throw d.error;if((g=(k=i.getDefaultOptions().queries)==null?void 0:k._experimental_afterQuery)==null||g.call(k,l,d),l.experimental_prefetchInRender&&!sr&&my(d,r)){const b=c?kd(l,u,s):o==null?void 0:o.promise;b==null||b.catch(Ae).finally(()=>{u.updateResult()})}return l.notifyOnChangeProps?d:u.trackResult(d)}function le(e,t){return xy(e,Jv)}function Je(e,t){const n=Wt(),[r]=j.useState(()=>new ny(n,e));j.useEffect(()=>{r.setOptions(e)},[r,e]);const s=j.useSyncExternalStore(j.useCallback(l=>r.subscribe(be.batchCalls(l)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),i=j.useCallback((l,o)=>{r.mutate(l,o).catch(Ae)},[r]);if(s.error&&Uc(r.options.throwOnError,[s.error]))throw s.error;return{...s,mutate:i,mutateAsync:s.mutate}}/** + * @remix-run/router v1.23.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Js(){return Js=Object.assign?Object.assign.bind():function(e){for(var t=1;t"u")throw new Error(t)}function Vc(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function yy(){return Math.random().toString(36).substr(2,8)}function Nd(e,t){return{usr:e.state,key:e.key,idx:t}}function Mo(e,t,n,r){return n===void 0&&(n=null),Js({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?ts(t):t,{state:n,key:t&&t.key||r||yy()})}function wi(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function ts(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function gy(e,t,n,r){r===void 0&&(r={});let{window:s=document.defaultView,v5Compat:i=!1}=r,l=s.history,o=mn.Pop,c=null,u=d();u==null&&(u=0,l.replaceState(Js({},l.state,{idx:u}),""));function d(){return(l.state||{idx:null}).idx}function f(){o=mn.Pop;let b=d(),p=b==null?null:b-u;u=b,c&&c({action:o,location:g.location,delta:p})}function m(b,p){o=mn.Push;let h=Mo(g.location,b,p);u=d()+1;let x=Nd(h,u),w=g.createHref(h);try{l.pushState(x,"",w)}catch(C){if(C instanceof DOMException&&C.name==="DataCloneError")throw C;s.location.assign(w)}i&&c&&c({action:o,location:g.location,delta:1})}function v(b,p){o=mn.Replace;let h=Mo(g.location,b,p);u=d();let x=Nd(h,u),w=g.createHref(h);l.replaceState(x,"",w),i&&c&&c({action:o,location:g.location,delta:0})}function k(b){let p=s.location.origin!=="null"?s.location.origin:s.location.href,h=typeof b=="string"?b:wi(b);return h=h.replace(/ $/,"%20"),ye(p,"No window.location.(origin|href) available to create URL for href: "+h),new URL(h,p)}let g={get action(){return o},get location(){return e(s,l)},listen(b){if(c)throw new Error("A history only accepts one active listener");return s.addEventListener(bd,f),c=b,()=>{s.removeEventListener(bd,f),c=null}},createHref(b){return t(s,b)},createURL:k,encodeLocation(b){let p=k(b);return{pathname:p.pathname,search:p.search,hash:p.hash}},push:m,replace:v,go(b){return l.go(b)}};return g}var Sd;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Sd||(Sd={}));function jy(e,t,n){return n===void 0&&(n="/"),wy(e,t,n)}function wy(e,t,n,r){let s=typeof t=="string"?ts(t):t,i=Wr(s.pathname||"/",n);if(i==null)return null;let l=km(e);ky(l);let o=null;for(let c=0;o==null&&c{let c={relativePath:o===void 0?i.path||"":o,caseSensitive:i.caseSensitive===!0,childrenIndex:l,route:i};c.relativePath.startsWith("/")&&(ye(c.relativePath.startsWith(r),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(r.length));let u=Cn([r,c.relativePath]),d=n.concat(c);i.children&&i.children.length>0&&(ye(i.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+u+'".')),km(i.children,t,d,u)),!(i.path==null&&!i.index)&&t.push({path:u,score:Py(u,i.index),routesMeta:d})};return e.forEach((i,l)=>{var o;if(i.path===""||!((o=i.path)!=null&&o.includes("?")))s(i,l);else for(let c of bm(i.path))s(i,l,c)}),t}function bm(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,s=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return s?[i,""]:[i];let l=bm(r.join("/")),o=[];return o.push(...l.map(c=>c===""?i:[i,c].join("/"))),s&&o.push(...l),o.map(c=>e.startsWith("/")&&c===""?"/":c)}function ky(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:Ty(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const by=/^:[\w-]+$/,Ny=3,Sy=2,Cy=1,_y=10,Ey=-2,Cd=e=>e==="*";function Py(e,t){let n=e.split("/"),r=n.length;return n.some(Cd)&&(r+=Ey),t&&(r+=Sy),n.filter(s=>!Cd(s)).reduce((s,i)=>s+(by.test(i)?Ny:i===""?Cy:_y),r)}function Ty(e,t){return e.length===t.length&&e.slice(0,-1).every((r,s)=>r===t[s])?e[e.length-1]-t[t.length-1]:0}function Oy(e,t,n){let{routesMeta:r}=e,s={},i="/",l=[];for(let o=0;o{let{paramName:m,isOptional:v}=d;if(m==="*"){let g=o[f]||"";l=i.slice(0,i.length-g.length).replace(/(.)\/+$/,"$1")}const k=o[f];return v&&!k?u[m]=void 0:u[m]=(k||"").replace(/%2F/g,"/"),u},{}),pathname:i,pathnameBase:l,pattern:e}}function Ly(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),Vc(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],s="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,o,c)=>(r.push({paramName:o,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),s+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?s+="\\/*$":e!==""&&e!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,t?void 0:"i"),r]}function Ry(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Vc(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function Wr(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const My=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,zy=e=>My.test(e);function Fy(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:s=""}=typeof e=="string"?ts(e):e,i;if(n)if(zy(n))i=n;else{if(n.includes("//")){let l=n;n=n.replace(/\/\/+/g,"/"),Vc(!1,"Pathnames cannot have embedded double slashes - normalizing "+(l+" -> "+n))}n.startsWith("/")?i=_d(n.substring(1),"/"):i=_d(n,t)}else i=t;return{pathname:i,search:Ay(r),hash:$y(s)}}function _d(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(s=>{s===".."?n.length>1&&n.pop():s!=="."&&n.push(s)}),n.length>1?n.join("/"):"/"}function gl(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in and the router will parse it for you.'}function Iy(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Nm(e,t){let n=Iy(e);return t?n.map((r,s)=>s===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function Sm(e,t,n,r){r===void 0&&(r=!1);let s;typeof e=="string"?s=ts(e):(s=Js({},e),ye(!s.pathname||!s.pathname.includes("?"),gl("?","pathname","search",s)),ye(!s.pathname||!s.pathname.includes("#"),gl("#","pathname","hash",s)),ye(!s.search||!s.search.includes("#"),gl("#","search","hash",s)));let i=e===""||s.pathname==="",l=i?"/":s.pathname,o;if(l==null)o=n;else{let f=t.length-1;if(!r&&l.startsWith("..")){let m=l.split("/");for(;m[0]==="..";)m.shift(),f-=1;s.pathname=m.join("/")}o=f>=0?t[f]:"/"}let c=Fy(s,o),u=l&&l!=="/"&&l.endsWith("/"),d=(i||l===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(u||d)&&(c.pathname+="/"),c}const Cn=e=>e.join("/").replace(/\/\/+/g,"/"),Dy=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Ay=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,$y=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;function Uy(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const Cm=["post","put","patch","delete"];new Set(Cm);const By=["get",...Cm];new Set(By);/** + * React Router v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function Ys(){return Ys=Object.assign?Object.assign.bind():function(e){for(var t=1;t{o.current=!0}),j.useCallback(function(u,d){if(d===void 0&&(d={}),!o.current)return;if(typeof u=="number"){r.go(u);return}let f=Sm(u,JSON.parse(l),i,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:Cn([t,f.pathname])),(d.replace?r.replace:r.push)(f,d.state,d)},[t,r,l,i,e])}const Ky=j.createContext(null);function Hy(e){let t=j.useContext(Gt).outlet;return t&&j.createElement(Ky.Provider,{value:e},t)}function fa(){let{matches:e}=j.useContext(Gt),t=e[e.length-1];return t?t.params:{}}function Bi(e,t){let{relative:n}=t===void 0?{}:t,{future:r}=j.useContext(Mn),{matches:s}=j.useContext(Gt),{pathname:i}=ns(),l=JSON.stringify(Nm(s,r.v7_relativeSplatPath));return j.useMemo(()=>Sm(e,JSON.parse(l),i,n==="path"),[e,l,i,n])}function qy(e,t){return Wy(e,t)}function Wy(e,t,n,r){da()||ye(!1);let{navigator:s}=j.useContext(Mn),{matches:i}=j.useContext(Gt),l=i[i.length-1],o=l?l.params:{};l&&l.pathname;let c=l?l.pathnameBase:"/";l&&l.route;let u=ns(),d;if(t){var f;let b=typeof t=="string"?ts(t):t;c==="/"||(f=b.pathname)!=null&&f.startsWith(c)||ye(!1),d=b}else d=u;let m=d.pathname||"/",v=m;if(c!=="/"){let b=c.replace(/^\//,"").split("/");v="/"+m.replace(/^\//,"").split("/").slice(b.length).join("/")}let k=jy(e,{pathname:v}),g=Zy(k&&k.map(b=>Object.assign({},b,{params:Object.assign({},o,b.params),pathname:Cn([c,s.encodeLocation?s.encodeLocation(b.pathname).pathname:b.pathname]),pathnameBase:b.pathnameBase==="/"?c:Cn([c,s.encodeLocation?s.encodeLocation(b.pathnameBase).pathname:b.pathnameBase])})),i,n,r);return t&&g?j.createElement(Ui.Provider,{value:{location:Ys({pathname:"/",search:"",hash:"",state:null,key:"default"},d),navigationType:mn.Pop}},g):g}function Gy(){let e=rg(),t=Uy(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,s={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return j.createElement(j.Fragment,null,j.createElement("h2",null,"Unexpected Application Error!"),j.createElement("h3",{style:{fontStyle:"italic"}},t),n?j.createElement("pre",{style:s},n):null,null)}const Jy=j.createElement(Gy,null);class Yy extends j.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?j.createElement(Gt.Provider,{value:this.props.routeContext},j.createElement(Em.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function Xy(e){let{routeContext:t,match:n,children:r}=e,s=j.useContext($i);return s&&s.static&&s.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(s.staticContext._deepestRenderedBoundaryId=n.route.id),j.createElement(Gt.Provider,{value:t},r)}function Zy(e,t,n,r){var s;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var i;if(!n)return null;if(n.errors)e=n.matches;else if((i=r)!=null&&i.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let l=e,o=(s=n)==null?void 0:s.errors;if(o!=null){let d=l.findIndex(f=>f.route.id&&(o==null?void 0:o[f.route.id])!==void 0);d>=0||ye(!1),l=l.slice(0,Math.min(l.length,d+1))}let c=!1,u=-1;if(n&&r&&r.v7_partialHydration)for(let d=0;d=0?l=l.slice(0,u+1):l=[l[0]];break}}}return l.reduceRight((d,f,m)=>{let v,k=!1,g=null,b=null;n&&(v=o&&f.route.id?o[f.route.id]:void 0,g=f.route.errorElement||Jy,c&&(u<0&&m===0?(ag("route-fallback"),k=!0,b=null):u===m&&(k=!0,b=f.route.hydrateFallbackElement||null)));let p=t.concat(l.slice(0,m+1)),h=()=>{let x;return v?x=g:k?x=b:f.route.Component?x=j.createElement(f.route.Component,null):f.route.element?x=f.route.element:x=d,j.createElement(Xy,{match:f,routeContext:{outlet:d,matches:p,isDataRoute:n!=null},children:x})};return n&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?j.createElement(Yy,{location:n.location,revalidation:n.revalidation,component:g,error:v,children:h(),routeContext:{outlet:null,matches:p,isDataRoute:!0}}):h()},null)}var Tm=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(Tm||{}),Om=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(Om||{});function eg(e){let t=j.useContext($i);return t||ye(!1),t}function tg(e){let t=j.useContext(_m);return t||ye(!1),t}function ng(e){let t=j.useContext(Gt);return t||ye(!1),t}function Lm(e){let t=ng(),n=t.matches[t.matches.length-1];return n.route.id||ye(!1),n.route.id}function rg(){var e;let t=j.useContext(Em),n=tg(),r=Lm();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function sg(){let{router:e}=eg(Tm.UseNavigateStable),t=Lm(Om.UseNavigateStable),n=j.useRef(!1);return Pm(()=>{n.current=!0}),j.useCallback(function(s,i){i===void 0&&(i={}),n.current&&(typeof s=="number"?e.navigate(s):e.navigate(s,Ys({fromRouteId:t},i)))},[e,t])}const Ed={};function ag(e,t,n){Ed[e]||(Ed[e]=!0)}function ig(e,t){e==null||e.v7_startTransition,e==null||e.v7_relativeSplatPath}function lg(e){return Hy(e.context)}function ht(e){ye(!1)}function og(e){let{basename:t="/",children:n=null,location:r,navigationType:s=mn.Pop,navigator:i,static:l=!1,future:o}=e;da()&&ye(!1);let c=t.replace(/^\/*/,"/"),u=j.useMemo(()=>({basename:c,navigator:i,static:l,future:Ys({v7_relativeSplatPath:!1},o)}),[c,o,i,l]);typeof r=="string"&&(r=ts(r));let{pathname:d="/",search:f="",hash:m="",state:v=null,key:k="default"}=r,g=j.useMemo(()=>{let b=Wr(d,c);return b==null?null:{location:{pathname:b,search:f,hash:m,state:v,key:k},navigationType:s}},[c,d,f,m,v,k,s]);return g==null?null:j.createElement(Mn.Provider,{value:u},j.createElement(Ui.Provider,{children:n,value:g}))}function cg(e){let{children:t,location:n}=e;return qy(Fo(t),n)}new Promise(()=>{});function Fo(e,t){t===void 0&&(t=[]);let n=[];return j.Children.forEach(e,(r,s)=>{if(!j.isValidElement(r))return;let i=[...t,s];if(r.type===j.Fragment){n.push.apply(n,Fo(r.props.children,i));return}r.type!==ht&&ye(!1),!r.props.index||!r.props.children||ye(!1);let l={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,loader:r.props.loader,action:r.props.action,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Fo(r.props.children,i)),n.push(l)}),n}/** + * React Router DOM v6.30.3 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */function ki(){return ki=Object.assign?Object.assign.bind():function(e){for(var t=1;t=0)&&(n[s]=e[s]);return n}function ug(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function dg(e,t){return e.button===0&&(!t||t==="_self")&&!ug(e)}const fg=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],hg=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],mg="6";try{window.__reactRouterVersion=mg}catch{}const pg=j.createContext({isTransitioning:!1}),xg="startTransition",Pd=bp[xg];function vg(e){let{basename:t,children:n,future:r,window:s}=e,i=j.useRef();i.current==null&&(i.current=vy({window:s,v5Compat:!0}));let l=i.current,[o,c]=j.useState({action:l.action,location:l.location}),{v7_startTransition:u}=r||{},d=j.useCallback(f=>{u&&Pd?Pd(()=>c(f)):c(f)},[c,u]);return j.useLayoutEffect(()=>l.listen(d),[l,d]),j.useEffect(()=>ig(r),[r]),j.createElement(og,{basename:t,children:n,location:o.location,navigationType:o.action,navigator:l,future:r})}const yg=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",gg=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,Tn=j.forwardRef(function(t,n){let{onClick:r,relative:s,reloadDocument:i,replace:l,state:o,target:c,to:u,preventScrollReset:d,viewTransition:f}=t,m=Rm(t,fg),{basename:v}=j.useContext(Mn),k,g=!1;if(typeof u=="string"&&gg.test(u)&&(k=u,yg))try{let x=new URL(window.location.href),w=u.startsWith("//")?new URL(x.protocol+u):new URL(u),C=Wr(w.pathname,v);w.origin===x.origin&&C!=null?u=C+w.search+w.hash:g=!0}catch{}let b=Qy(u,{relative:s}),p=wg(u,{replace:l,state:o,target:c,preventScrollReset:d,relative:s,viewTransition:f});function h(x){r&&r(x),x.defaultPrevented||p(x)}return j.createElement("a",ki({},m,{href:k||b,onClick:g||i?r:h,ref:n,target:c}))}),Mm=j.forwardRef(function(t,n){let{"aria-current":r="page",caseSensitive:s=!1,className:i="",end:l=!1,style:o,to:c,viewTransition:u,children:d}=t,f=Rm(t,hg),m=Bi(c,{relative:f.relative}),v=ns(),k=j.useContext(_m),{navigator:g,basename:b}=j.useContext(Mn),p=k!=null&&kg(m)&&u===!0,h=g.encodeLocation?g.encodeLocation(m).pathname:m.pathname,x=v.pathname,w=k&&k.navigation&&k.navigation.location?k.navigation.location.pathname:null;s||(x=x.toLowerCase(),w=w?w.toLowerCase():null,h=h.toLowerCase()),w&&b&&(w=Wr(w,b)||w);const C=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let S=x===h||!l&&x.startsWith(h)&&x.charAt(C)==="/",N=w!=null&&(w===h||!l&&w.startsWith(h)&&w.charAt(h.length)==="/"),_={isActive:S,isPending:N,isTransitioning:p},F=S?r:void 0,O;typeof i=="function"?O=i(_):O=[i,S?"active":null,N?"pending":null,p?"transitioning":null].filter(Boolean).join(" ");let B=typeof o=="function"?o(_):o;return j.createElement(Tn,ki({},f,{"aria-current":F,className:O,ref:n,style:B,to:c,viewTransition:u}),typeof d=="function"?d(_):d)});var Io;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(Io||(Io={}));var Td;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(Td||(Td={}));function jg(e){let t=j.useContext($i);return t||ye(!1),t}function wg(e,t){let{target:n,replace:r,state:s,preventScrollReset:i,relative:l,viewTransition:o}=t===void 0?{}:t,c=zn(),u=ns(),d=Bi(e,{relative:l});return j.useCallback(f=>{if(dg(f,n)){f.preventDefault();let m=r!==void 0?r:wi(u)===wi(d);c(e,{replace:m,state:s,preventScrollReset:i,relative:l,viewTransition:o})}},[u,c,d,r,s,n,e,i,l,o])}function kg(e,t){t===void 0&&(t={});let n=j.useContext(pg);n==null&&ye(!1);let{basename:r}=jg(Io.useViewTransitionState),s=Bi(e,{relative:t.relative});if(!n.isTransitioning)return!1;let i=Wr(n.currentLocation.pathname,r)||n.currentLocation.pathname,l=Wr(n.nextLocation.pathname,r)||n.nextLocation.pathname;return zo(s.pathname,l)!=null||zo(s.pathname,i)!=null}/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */var bg={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ng=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase().trim(),U=(e,t)=>{const n=j.forwardRef(({color:r="currentColor",size:s=24,strokeWidth:i=2,absoluteStrokeWidth:l,className:o="",children:c,...u},d)=>j.createElement("svg",{ref:d,...bg,width:s,height:s,stroke:r,strokeWidth:l?Number(i)*24/Number(s):i,className:["lucide",`lucide-${Ng(e)}`,o].join(" "),...u},[...t.map(([f,m])=>j.createElement(f,m)),...Array.isArray(c)?c:[c]]));return n.displayName=`${e}`,n};/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Sg=U("Activity",[["path",{d:"M22 12h-4l-3 9L9 3l-3 9H2",key:"d5dnw9"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zm=U("AlertCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Cg=U("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const _g=U("ArrowUpDown",[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Eg=U("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Pg=U("BookOpen",[["path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z",key:"vv98re"}],["path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z",key:"1cyq3y"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Do=U("Bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fm=U("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Tg=U("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Og=U("ChevronDown",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xs=U("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Lg=U("ChevronsLeft",[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Rg=U("ChevronsRight",[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Im=U("Clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polyline",{points:"12 6 12 12 16 14",key:"68esgv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Mg=U("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const zg=U("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dm=U("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Od=U("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Am=U("ExternalLink",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ao=U("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Fg=U("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ig=U("GitCompare",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["path",{d:"M11 18H8a2 2 0 0 1-2-2V9",key:"19pyzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Dg=U("Github",[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Kc=U("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ag=U("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $g=U("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ug=U("List",[["line",{x1:"8",x2:"21",y1:"6",y2:"6",key:"7ey8pc"}],["line",{x1:"8",x2:"21",y1:"12",y2:"12",key:"rjfblc"}],["line",{x1:"8",x2:"21",y1:"18",y2:"18",key:"c3b1m8"}],["line",{x1:"3",x2:"3.01",y1:"6",y2:"6",key:"1g7gq3"}],["line",{x1:"3",x2:"3.01",y1:"12",y2:"12",key:"1pjlvk"}],["line",{x1:"3",x2:"3.01",y1:"18",y2:"18",key:"28t2mc"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const ha=U("Loader2",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const $m=U("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bg=U("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qg=U("MessageSquareText",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}],["path",{d:"M13 8H7",key:"14i4kc"}],["path",{d:"M17 12H7",key:"16if0g"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vg=U("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Zs=U("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hc=U("Plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Kg=U("Rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Hg=U("Search",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Um=U("Send",[["path",{d:"m22 2-7 20-4-9-9-4Z",key:"1q3vgg"}],["path",{d:"M22 2 11 13",key:"nzbqef"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Bm=U("Settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qg=U("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Wg=U("SlidersHorizontal",[["line",{x1:"21",x2:"14",y1:"4",y2:"4",key:"obuewd"}],["line",{x1:"10",x2:"3",y1:"4",y2:"4",key:"1q6298"}],["line",{x1:"21",x2:"12",y1:"12",y2:"12",key:"1iu8h1"}],["line",{x1:"8",x2:"3",y1:"12",y2:"12",key:"ntss68"}],["line",{x1:"21",x2:"16",y1:"20",y2:"20",key:"14d8ph"}],["line",{x1:"12",x2:"3",y1:"20",y2:"20",key:"m0wm8r"}],["line",{x1:"14",x2:"14",y1:"2",y2:"6",key:"14e1ph"}],["line",{x1:"8",x2:"8",y1:"10",y2:"14",key:"1i6ji0"}],["line",{x1:"16",x2:"16",y1:"18",y2:"22",key:"1lctlv"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Ld=U("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Gg=U("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Jg=U("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const qc=U("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Qm=U("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Yg=U("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Xg=U("XCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const Vm=U("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);/** + * @license lucide-react v0.330.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const rs=U("Zap",[["polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2",key:"45s27k"}]]),Zg={},Rd=e=>{let t;const n=new Set,r=(d,f)=>{const m=typeof d=="function"?d(t):d;if(!Object.is(m,t)){const v=t;t=f??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(k=>k(t,v))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>u,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(Zg?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(r,s,c);return c},e0=e=>e?Rd(e):Rd;var Km={exports:{}},Hm={},qm={exports:{}},Wm={};/** + * @license React + * use-sync-external-store-shim.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Gr=j;function t0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var n0=typeof Object.is=="function"?Object.is:t0,r0=Gr.useState,s0=Gr.useEffect,a0=Gr.useLayoutEffect,i0=Gr.useDebugValue;function l0(e,t){var n=t(),r=r0({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return a0(function(){s.value=n,s.getSnapshot=t,jl(s)&&i({inst:s})},[e,n,t]),s0(function(){return jl(s)&&i({inst:s}),e(function(){jl(s)&&i({inst:s})})},[e]),i0(n),n}function jl(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!n0(e,n)}catch{return!0}}function o0(e,t){return t()}var c0=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o0:l0;Wm.useSyncExternalStore=Gr.useSyncExternalStore!==void 0?Gr.useSyncExternalStore:c0;qm.exports=Wm;var u0=qm.exports;/** + * @license React + * use-sync-external-store-shim/with-selector.production.js + * + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Qi=j,d0=u0;function f0(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var h0=typeof Object.is=="function"?Object.is:f0,m0=d0.useSyncExternalStore,p0=Qi.useRef,x0=Qi.useEffect,v0=Qi.useMemo,y0=Qi.useDebugValue;Hm.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=p0(null);if(i.current===null){var l={hasValue:!1,value:null};i.current=l}else l=i.current;i=v0(function(){function c(v){if(!u){if(u=!0,d=v,v=r(v),s!==void 0&&l.hasValue){var k=l.value;if(s(k,v))return f=k}return f=v}if(k=f,h0(d,v))return k;var g=r(v);return s!==void 0&&s(k,g)?(d=v,k):(d=v,f=g)}var u=!1,d,f,m=n===void 0?null:n;return[function(){return c(t())},m===null?void 0:function(){return c(m())}]},[t,n,r,s]);var o=m0(e,i[0],i[1]);return x0(function(){l.hasValue=!0,l.value=o},[o]),y0(o),o};Km.exports=Hm;var g0=Km.exports;const j0=Yd(g0),Gm={},{useDebugValue:w0}=Wo,{useSyncExternalStoreWithSelector:k0}=j0;let Md=!1;const b0=e=>e;function N0(e,t=b0,n){(Gm?"production":void 0)!=="production"&&n&&!Md&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),Md=!0);const r=k0(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return w0(r),r}const zd=e=>{(Gm?"production":void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");const t=typeof e=="function"?e0(e):e,n=(r,s)=>N0(t,r,s);return Object.assign(n,t),n},Wc=e=>e?zd(e):zd,Vi="/api",Gc="flow_auth_token",Jc="flow_auth_expires",Yc="flow_auth_username";function Ki(){const e=localStorage.getItem(Gc),t=localStorage.getItem(Jc);return!e||!t?null:new Date(t)<=new Date?(Jr(),null):e}function Fd(e,t,n){localStorage.setItem(Gc,e),localStorage.setItem(Jc,t),localStorage.setItem(Yc,n)}function Jr(){localStorage.removeItem(Gc),localStorage.removeItem(Jc),localStorage.removeItem(Yc)}function Xc(){return localStorage.getItem(Yc)}let ir=null;function S0(e){ir=e}async function J(e,t,n=!1){const r={"Content-Type":"application/json",...t==null?void 0:t.headers};if(!n){const i=Ki();i&&(r.Authorization=`Bearer ${i}`)}const s=await fetch(`${Vi}${e}`,{...t,headers:r});if(s.status===401){Jr(),ir&&ir();const i=await s.json().catch(()=>({detail:"Not authenticated"}));throw new Error(i.detail||"Not authenticated")}if(!s.ok){const i=await s.json().catch(()=>({detail:s.statusText}));throw new Error(i.detail||"API request failed")}if(s.status!==204)return s.json()}const ps={getConfig:()=>J("/auth/config",void 0,!0),login:e=>J("/auth/login",{method:"POST",body:JSON.stringify(e)},!0),getGitHubAuthUrl:()=>`${Vi}/auth/github`,getCurrentUser:()=>J("/auth/me"),logout:()=>J("/auth/logout",{method:"POST"})},_n={list:e=>{const t=new URLSearchParams;e!=null&&e.include_auto_generated&&t.set("include_auto_generated","true"),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return J(`/configs${n?`?${n}`:""}`)},get:e=>J(`/configs/${e}`),create:e=>J("/configs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>J(`/configs/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>J(`/configs/${e}`,{method:"DELETE"})},gt={list:e=>{const t=new URLSearchParams;e!=null&&e.category&&t.set("category",e.category),e!=null&&e.suite&&t.set("suite",e.suite);const n=t.toString();return J(`/tasks${n?`?${n}`:""}`)},get:e=>J(`/tasks/${e}`),create:e=>J("/tasks",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>J(`/tasks/${e}`,{method:"PUT",body:JSON.stringify(t)}),delete:e=>J(`/tasks/${e}`,{method:"DELETE"}),listSuites:()=>J("/tasks/suites"),importSuite:e=>J(`/tasks/import-suite?suite_name=${encodeURIComponent(e)}`,{method:"POST"})},Ot={list:e=>{const t=new URLSearchParams;e!=null&&e.status&&t.set("status",e.status),e!=null&&e.include_public&&t.set("include_public","true");const n=t.toString();return J(`/jobs${n?`?${n}`:""}`)},get:e=>J(`/jobs/${e}`),create:e=>J("/jobs",{method:"POST",body:JSON.stringify(e)}),update:(e,t)=>J(`/jobs/${e}`,{method:"PUT",body:JSON.stringify(t)}),start:async function*(e){var o;const t={},n=Ki();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Vi}/jobs/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Jr(),ir&&ir(),new Error("Not authenticated");if(!r.ok)throw new Error("Failed to start job");const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const i=new TextDecoder;let l="";for(;;){const{done:c,value:u}=await s.read();if(c)break;l+=i.decode(u,{stream:!0});const d=l.split(` +`);l=d.pop()||"";for(const f of d)f.startsWith("data: ")&&(yield JSON.parse(f.slice(6)))}},cancel:e=>J(`/jobs/${e}/cancel`,{method:"POST"}),delete:e=>J(`/jobs/${e}`,{method:"DELETE"})},$o={list:e=>{const t=new URLSearchParams;e!=null&&e.job_id&&t.set("job_id",e.job_id),e!=null&&e.candidate_name&&t.set("candidate_name",e.candidate_name),e!=null&&e.task_name&&t.set("task_name",e.task_name),(e==null?void 0:e.is_pareto)!==void 0&&t.set("is_pareto",String(e.is_pareto));const n=t.toString();return J(`/runs${n?`?${n}`:""}`)},get:e=>J(`/runs/${e}`),getJobSummary:e=>J(`/runs/job/${e}/summary`)},Os={list:e=>{const t=new URLSearchParams;e!=null&&e.agent_id&&t.set("agent_id",e.agent_id),e!=null&&e.limit&&t.set("limit",String(e.limit));const n=t.toString();return J(`/tests${n?`?${n}`:""}`)},get:e=>J(`/tests/${e}`),create:e=>J("/tests",{method:"POST",body:JSON.stringify(e)}),start:async function*(e){var o;const t={},n=Ki();n&&(t.Authorization=`Bearer ${n}`);const r=await fetch(`${Vi}/tests/${e}/start`,{method:"POST",headers:t});if(r.status===401)throw Jr(),ir&&ir(),new Error("Not authenticated");if(!r.ok){const c=await r.json().catch(()=>({detail:"Failed to start test"}));throw new Error(c.detail||"Failed to start test")}const s=(o=r.body)==null?void 0:o.getReader();if(!s)throw new Error("No response body");const i=new TextDecoder;let l="";for(;;){const{done:c,value:u}=await s.read();if(c)break;l+=i.decode(u,{stream:!0});const d=l.split(` +`);l=d.pop()||"";for(const f of d)f.startsWith("data: ")&&(yield JSON.parse(f.slice(6)))}},cancel:e=>J(`/tests/${e}/cancel`,{method:"POST"}),delete:e=>J(`/tests/${e}`,{method:"DELETE"})},C0={list:()=>J("/llm-configs")},_0={list:()=>J("/tools")},Jm={getAgentSchema:()=>J("/schema/agent")},E0={get:e=>J(`/deployments/${e}`)},P0={start:e=>J("/evaluate",{method:"POST",body:JSON.stringify(e)})},Uo={design:e=>J("/experiment/design",{method:"POST",body:JSON.stringify(e)}),validate:e=>J("/experiment/validate",{method:"POST",body:JSON.stringify(e)}),generateCandidates:e=>J("/experiment/generate-candidates",{method:"POST",body:JSON.stringify(e)})},Zc=Wc((e,t)=>(S0(()=>{e({isAuthenticated:!1,user:null,error:"Session expired. Please log in again."})}),{authConfig:null,isLoadingConfig:!0,isAuthenticated:!1,isLoading:!1,user:null,error:null,loadAuthConfig:async()=>{e({isLoadingConfig:!0});try{const n=await ps.getConfig();if(e({authConfig:n,isLoadingConfig:!1}),n.enabled){const r=Ki(),s=Xc();if(r&&s)try{const i=await ps.getCurrentUser();e({isAuthenticated:!0,user:i})}catch{Jr(),e({isAuthenticated:!1,user:null})}}else e({isAuthenticated:!0,user:{username:"anonymous",auth_mode:"none"}})}catch(n){console.error("Failed to load auth config:",n),e({isLoadingConfig:!1,error:"Failed to connect to server"})}},login:async(n,r)=>{e({isLoading:!0,error:null});try{const s=await ps.login({username:n,password:r});return Fd(s.access_token,s.expires_at,s.username),e({isAuthenticated:!0,isLoading:!1,user:{username:s.username,auth_mode:"basic"}}),!0}catch(s){return e({isLoading:!1,error:s instanceof Error?s.message:"Login failed"}),!1}},loginWithGitHub:()=>{window.location.href=ps.getGitHubAuthUrl()},handleOAuthCallback:()=>{const n=new URLSearchParams(window.location.search),r=n.get("auth_error");if(r)return e({error:r}),window.history.replaceState({},"",window.location.pathname),!0;if(n.get("auth_callback")==="true"){const s=n.get("token"),i=n.get("expires_at"),l=n.get("username");return s&&i&&l&&(Fd(s,i,l),e({isAuthenticated:!0,user:{username:l,auth_mode:"github"}})),window.history.replaceState({},"",window.location.pathname),!0}return!1},logout:async()=>{try{await ps.logout()}catch{}Jr(),e({isAuthenticated:!1,user:null,error:null})},clearError:()=>e({error:null})}));function Q({variant:e="secondary",size:t="md",className:n="",icon:r,iconRight:s,loading:i=!1,children:l,disabled:o,...c}){const u="font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed inline-flex items-center gap-1.5 rounded-md",d={primary:"bg-[var(--accent)] text-white hover:bg-[var(--accent-hover)]",secondary:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)] hover:bg-[var(--border)]",danger:"bg-[var(--error)] text-white hover:bg-red-600",ghost:"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"},f={sm:"px-2 py-1 text-xs",md:"px-3 py-1.5 text-sm"},m=t==="sm"?14:16;return a.jsxs("button",{className:`${u} ${d[e]} ${f[t]} ${n}`,disabled:o||i,...c,children:[i?a.jsx(ha,{size:m,className:"animate-spin"}):r?a.jsx(r,{size:m}):null,l,s&&!i&&a.jsx(s,{size:m})]})}const T0={};function O0(e,t){let n;try{n=e()}catch{return}return{getItem:s=>{var i;const l=c=>c===null?null:JSON.parse(c,void 0),o=(i=n.getItem(s))!=null?i:null;return o instanceof Promise?o.then(l):l(o)},setItem:(s,i)=>n.setItem(s,JSON.stringify(i,void 0)),removeItem:s=>n.removeItem(s)}}const ea=e=>t=>{try{const n=e(t);return n instanceof Promise?n:{then(r){return ea(r)(n)},catch(r){return this}}}catch(n){return{then(r){return this},catch(r){return ea(r)(n)}}}},L0=(e,t)=>(n,r,s)=>{let i={getStorage:()=>localStorage,serialize:JSON.stringify,deserialize:JSON.parse,partialize:b=>b,version:0,merge:(b,p)=>({...p,...b}),...t},l=!1;const o=new Set,c=new Set;let u;try{u=i.getStorage()}catch{}if(!u)return e((...b)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...b)},r,s);const d=ea(i.serialize),f=()=>{const b=i.partialize({...r()});let p;const h=d({state:b,version:i.version}).then(x=>u.setItem(i.name,x)).catch(x=>{p=x});if(p)throw p;return h},m=s.setState;s.setState=(b,p)=>{m(b,p),f()};const v=e((...b)=>{n(...b),f()},r,s);let k;const g=()=>{var b;if(!u)return;l=!1,o.forEach(h=>h(r()));const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,r()))||void 0;return ea(u.getItem.bind(u))(i.name).then(h=>{if(h)return i.deserialize(h)}).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==i.version){if(i.migrate)return i.migrate(h.state,h.version);console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return h.state}).then(h=>{var x;return k=i.merge(h,(x=r())!=null?x:v),n(k,!0),f()}).then(()=>{p==null||p(k,void 0),l=!0,c.forEach(h=>h(k))}).catch(h=>{p==null||p(void 0,h)})};return s.persist={setOptions:b=>{i={...i,...b},b.getStorage&&(u=b.getStorage())},clearStorage:()=>{u==null||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>g(),hasHydrated:()=>l,onHydrate:b=>(o.add(b),()=>{o.delete(b)}),onFinishHydration:b=>(c.add(b),()=>{c.delete(b)})},g(),k||v},R0=(e,t)=>(n,r,s)=>{let i={storage:O0(()=>localStorage),partialize:g=>g,version:0,merge:(g,b)=>({...b,...g}),...t},l=!1;const o=new Set,c=new Set;let u=i.storage;if(!u)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),n(...g)},r,s);const d=()=>{const g=i.partialize({...r()});return u.setItem(i.name,{state:g,version:i.version})},f=s.setState;s.setState=(g,b)=>{f(g,b),d()};const m=e((...g)=>{n(...g),d()},r,s);s.getInitialState=()=>m;let v;const k=()=>{var g,b;if(!u)return;l=!1,o.forEach(h=>{var x;return h((x=r())!=null?x:m)});const p=((b=i.onRehydrateStorage)==null?void 0:b.call(i,(g=r())!=null?g:m))||void 0;return ea(u.getItem.bind(u))(i.name).then(h=>{if(h)if(typeof h.version=="number"&&h.version!==i.version){if(i.migrate)return[!0,i.migrate(h.state,h.version)];console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,h.state];return[!1,void 0]}).then(h=>{var x;const[w,C]=h;if(v=i.merge(C,(x=r())!=null?x:m),n(v,!0),w)return d()}).then(()=>{p==null||p(v,void 0),v=r(),l=!0,c.forEach(h=>h(v))}).catch(h=>{p==null||p(void 0,h)})};return s.persist={setOptions:g=>{i={...i,...g},g.storage&&(u=g.storage)},clearStorage:()=>{u==null||u.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>k(),hasHydrated:()=>l,onHydrate:g=>(o.add(g),()=>{o.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},i.skipHydration||k(),v||m},M0=(e,t)=>"getStorage"in t||"serialize"in t||"deserialize"in t?((T0?"production":void 0)!=="production"&&console.warn("[DEPRECATED] `getStorage`, `serialize` and `deserialize` options are deprecated. Use `storage` option instead."),L0(e,t)):R0(e,t),Ym=M0,z0=Wc()(Ym((e,t)=>({theme:"light",setTheme:n=>{document.documentElement.setAttribute("data-theme",n),e({theme:n})},toggleTheme:()=>{const n=t().theme==="dark"?"light":"dark";document.documentElement.setAttribute("data-theme",n),e({theme:n})}}),{name:"flow-theme",onRehydrateStorage:()=>e=>{e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}}));function F0(){const{theme:e,toggleTheme:t}=z0();return a.jsx("button",{onClick:t,className:"p-2 rounded-md text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors focus:outline-none focus:ring-2 focus:ring-[var(--accent)]","aria-label":`Switch to ${e==="dark"?"light":"dark"} mode`,title:`Switch to ${e==="dark"?"light":"dark"} mode`,children:e==="dark"?a.jsx(Gg,{size:16}):a.jsx(Vg,{size:16})})}const I0=Wc()(Ym((e,t)=>({sidebarCollapsed:!1,toggleSidebar:()=>{e({sidebarCollapsed:!t().sidebarCollapsed})}}),{name:"flow-layout"})),D0=[{path:"/",label:"Overview",icon:$g},{path:"/agents",label:"Agents",icon:Do},{path:"/jobs",label:"Experiments",icon:Ao},{path:"/tasks",label:"Datasets",icon:Dm}];function A0(){const e=ns(),{sidebarCollapsed:t,toggleSidebar:n}=I0(),r=s=>s==="/"?e.pathname==="/":s==="/agents"?e.pathname==="/agents"||e.pathname.startsWith("/agents/")||e.pathname.startsWith("/deployments/"):s==="/jobs"?e.pathname.startsWith("/jobs")||e.pathname.startsWith("/runs"):e.pathname.startsWith(s);return a.jsxs("aside",{className:` + flex flex-col border-r border-[var(--border)] bg-[var(--bg-secondary)] + transition-all duration-200 + ${t?"w-14":"w-56"} + `,children:[a.jsx("nav",{className:"flex-1 py-2",children:D0.map(s=>{const i=r(s.path);return a.jsxs(Mm,{to:s.path,title:t?s.label:void 0,className:` + flex items-center gap-3 px-4 py-2.5 text-sm transition-colors relative + ${i?"text-[var(--accent)] bg-[var(--accent-dim)] font-medium":"text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)]"} + `,children:[i&&a.jsx("span",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-r bg-[var(--accent)]"}),a.jsx(s.icon,{size:18}),!t&&a.jsx("span",{children:s.label})]},s.path)})}),a.jsx("button",{onClick:n,className:"flex items-center justify-center p-3 border-t border-[var(--border)] text-[var(--text-secondary)] hover:text-[var(--text-primary)] hover:bg-[var(--bg-tertiary)] transition-colors",title:t?"Expand sidebar":"Collapse sidebar",children:t?a.jsx(Rg,{size:16}):a.jsx(Lg,{size:16})})]})}function $0(){const{authConfig:e,user:t,logout:n}=Zc(),r=async()=>{await n()};return a.jsxs("div",{className:"h-screen flex flex-col",children:[a.jsx("header",{className:"border-b border-[var(--border)] bg-[var(--bg-secondary)] shrink-0",children:a.jsxs("div",{className:"px-4 py-2.5 flex items-center justify-between",children:[a.jsxs(Mm,{to:"/",className:"text-lg font-semibold text-[var(--accent)] flex items-center gap-2 hover:opacity-80",children:[a.jsx(rs,{size:20}),"Flow",a.jsx("span",{className:"text-[var(--text-secondary)] font-normal",children:"/optimize"})]}),a.jsxs("div",{className:"flex items-center gap-4",children:[a.jsx(F0,{}),(e==null?void 0:e.enabled)&&t&&a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsxs("div",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)]",children:[a.jsx(Qm,{size:14}),a.jsx("span",{children:t.username})]}),a.jsx(Q,{variant:"ghost",size:"sm",icon:Bg,onClick:r,title:"Sign out",children:"Sign out"})]})]})]})}),a.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[a.jsx(A0,{}),a.jsx("main",{className:"flex-1 overflow-y-auto bg-[var(--bg-primary)]",children:a.jsx("div",{className:"p-6",children:a.jsx(lg,{})})})]})]})}function q({children:e,variant:t="default"}){const n={default:"bg-[var(--bg-tertiary)] text-[var(--text-primary)] border border-[var(--border)]",success:"bg-[var(--badge-success-bg)] text-[var(--badge-success-text)] border border-[var(--badge-success-border)]",warning:"bg-[var(--badge-warning-bg)] text-[var(--badge-warning-text)] border border-[var(--badge-warning-border)]",error:"bg-[var(--badge-error-bg)] text-[var(--badge-error-text)] border border-[var(--badge-error-border)]",info:"bg-[var(--badge-info-bg)] text-[var(--badge-info-text)] border border-[var(--badge-info-border)]"};return a.jsx("span",{className:`inline-block px-2 py-0.5 text-xs font-medium rounded-md ${n[t]}`,children:e})}const U0={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};function B0(){const e=zn(),{data:t=[],isLoading:n}=le({queryKey:["configs"],queryFn:()=>_n.list()}),{data:r=[],isLoading:s}=le({queryKey:["jobs"],queryFn:()=>Ot.list()}),{data:i=[],isLoading:l}=le({queryKey:["tasks"],queryFn:()=>gt.list()}),o=[...t].sort((d,f)=>new Date(f.created_at).getTime()-new Date(d.created_at).getTime()).slice(0,5),c=[...r].sort((d,f)=>new Date(f.created_at).getTime()-new Date(d.created_at).getTime()).slice(0,5),u=i.reduce((d,f)=>{const m=f.suite||"custom";return d[m]||(d[m]=[]),d[m].push(f),d},{});return a.jsxs("div",{children:[a.jsxs("div",{className:"mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold mb-2",children:"Agent Optimizer"}),a.jsx("p",{className:"text-[var(--text-secondary)] max-w-2xl",children:"Systematically optimize and improve your AI agents across key dimensions. Define agent configurations, run experiments across task datasets, and find the best tradeoffs between quality and cost."}),a.jsx("div",{className:"flex flex-wrap gap-2 mt-4",children:[{icon:Qg,label:"Instructions"},{icon:Yg,label:"Tools"},{icon:Pg,label:"Skills"},{icon:Wg,label:"Compaction"}].map(d=>a.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md bg-[var(--bg-tertiary)] border border-[var(--border)] text-[var(--text-secondary)]",children:[a.jsx(d.icon,{size:14}),d.label]},d.label))})]}),a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4 mb-8",children:[{step:"1",title:"Define Agents",description:"Create agent configurations with different instructions, tools, and compaction strategies.",icon:Do},{step:"2",title:"Run Experiments",description:"Test agent variants against task datasets to measure quality and cost.",icon:Ao},{step:"3",title:"Analyze Results",description:"Compare candidates on a Pareto frontier to find the best quality-cost tradeoffs.",icon:rs}].map(d=>a.jsxs("div",{className:"p-4 border border-[var(--border)] rounded-lg bg-[var(--bg-secondary)]",children:[a.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[a.jsx("span",{className:"flex items-center justify-center w-7 h-7 rounded-full bg-[var(--accent)]/10 text-[var(--accent)] text-xs font-bold",children:d.step}),a.jsx(d.icon,{size:18,className:"text-[var(--accent)]"})]}),a.jsx("h3",{className:"font-medium text-sm",children:d.title}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:d.description})]},d.step))}),a.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mb-6",children:[a.jsxs("div",{children:[a.jsx(wl,{title:"Recent Agents",icon:Do,count:t.length,onShowAll:()=>e("/agents")}),n?a.jsx(kl,{}):o.length===0?a.jsx(bl,{message:"No agents yet. Create your first agent to get started."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:o.map((d,f)=>a.jsxs("div",{onClick:()=>e(`/agents/${d.id}`),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${fe("/jobs")}),s?a.jsx(kl,{}):c.length===0?a.jsx(bl,{message:"No experiments yet. Start one from an agent's detail page."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:c.map((d,f)=>a.jsxs("div",{onClick:()=>e(`/jobs/${d.id}`),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${fe("/tasks")}),l?a.jsx(kl,{}):Object.keys(u).length===0?a.jsx(bl,{message:"No datasets yet. Import a task suite to get started."}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:Object.entries(u).map(([d,f],m,v)=>a.jsx("div",{onClick:()=>e("/tasks"),className:`flex items-center justify-between px-4 py-3 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors ${m0&&a.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",n,")"]})]}),n>0&&a.jsxs("button",{onClick:r,className:"text-sm text-[var(--accent)] hover:underline flex items-center gap-1",children:["Show all ",a.jsx(Cg,{size:14})]})]})}function kl(){return a.jsx("div",{className:"text-sm text-[var(--text-secondary)] mb-8",children:"Loading..."})}function bl({message:e}){return a.jsx("div",{className:"text-sm text-[var(--text-secondary)] py-6 text-center border border-[var(--border)] rounded-lg mb-8",children:e})}const Q0=["maf","miniagent","langgraph"],V0={maf:"Microsoft Agent Framework",miniagent:"MiniAgent",langgraph:"LangGraph"},K0={openai:"OpenAI",azure_openai:"Azure OpenAI",anthropic:"Anthropic",ollama:"Ollama",custom:"Custom (OpenAI-compatible)"},H0={sm:"max-w-sm",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl"};function ss({isOpen:e,onClose:t,title:n,children:r,footer:s,size:i="md"}){return j.useEffect(()=>{const l=o=>{o.key==="Escape"&&t()};return e&&(document.addEventListener("keydown",l),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",l),document.body.style.overflow=""}},[e,t]),e?a.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[a.jsx("div",{className:"absolute inset-0 bg-black/50",onClick:t}),a.jsxs("div",{className:`relative bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg ${H0[i]} w-full mx-4 max-h-[80vh] flex flex-col`,children:[a.jsxs("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-b border-[var(--border)] px-4 py-3 flex items-center justify-between",children:[a.jsx("h2",{className:"font-semibold",children:n}),a.jsx("button",{onClick:t,className:"text-[var(--text-secondary)] hover:text-[var(--text-primary)]",children:"×"})]}),a.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:r}),s&&a.jsx("div",{className:"flex-shrink-0 bg-[var(--bg-secondary)] border-t border-[var(--border)] px-4 py-3",children:s})]})]}):null}function pn({label:e,className:t="",...n}){return a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),a.jsx("input",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] ${t}`,...n})]})}function q0({label:e,className:t="",...n}){return a.jsxs("div",{className:"space-y-1",children:[e&&a.jsx("label",{className:"block text-sm font-medium text-[var(--text-secondary)]",children:e}),a.jsx("textarea",{className:`w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)] resize-y min-h-[100px] ${t}`,...n})]})}function bi({label:e,className:t="",...n}){return a.jsxs("label",{className:`flex items-center gap-2 cursor-pointer ${t}`,children:[a.jsx("input",{type:"checkbox",className:"w-4 h-4 bg-[var(--bg-primary)] border border-[var(--border)] rounded accent-[var(--accent)]",...n}),a.jsx("span",{className:"text-sm",children:e})]})}function Xm({columns:e,data:t,onRowClick:n,searchable:r=!1,searchPlaceholder:s="Search...",searchFilter:i,emptyMessage:l="No items found",emptyIcon:o}){const[c,u]=j.useState(""),[d,f]=j.useState(null),[m,v]=j.useState("asc"),k=j.useMemo(()=>{let b=t;if(r&&c&&i&&(b=b.filter(p=>i(p,c))),d){const p=e.find(h=>h.key===d);p!=null&&p.sortValue&&(b=[...b].sort((h,x)=>{const w=p.sortValue(h),C=p.sortValue(x),S=wC?1:0;return m==="asc"?S:-S}))}return b},[t,c,i,r,d,m,e]),g=b=>{const p=e.find(h=>h.key===b);p!=null&&p.sortable&&(d===b?v(m==="asc"?"desc":"asc"):(f(b),v("asc")))};return a.jsxs("div",{children:[r&&a.jsxs("div",{className:"mb-4 relative max-w-sm",children:[a.jsx(Hg,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-secondary)]"}),a.jsx("input",{type:"text",placeholder:s,value:c,onChange:b=>u(b.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] rounded-md pl-9 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]"})]}),k.length===0?a.jsxs("div",{className:"text-center py-16 text-[var(--text-secondary)]",children:[o&&a.jsx("div",{className:"mb-3 flex justify-center",children:o}),a.jsx("p",{children:l})]}):a.jsx("div",{className:"border border-[var(--border)] rounded-lg overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsx("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:e.map(b=>a.jsx("th",{onClick:()=>g(b.key),className:`text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider ${b.sortable?"cursor-pointer hover:text-[var(--text-primary)]":""} ${b.className||""}`,children:a.jsxs("span",{className:"inline-flex items-center gap-1",children:[b.header,b.sortable&&d===b.key&&a.jsx("span",{children:m==="asc"?"↑":"↓"})]})},b.key))})}),a.jsx("tbody",{children:k.map((b,p)=>a.jsx("tr",{onClick:()=>n==null?void 0:n(b),className:`border-b border-[var(--border)] last:border-b-0 transition-colors ${n?"cursor-pointer hover:bg-[var(--bg-tertiary)]":""}`,children:e.map(h=>a.jsx("td",{className:`px-4 py-3 ${h.className||""}`,children:h.render(b)},h.key))},p))})]})})]})}function W0({variations:e,onChange:t,strategies:n,availableStrategies:r}){const s=r??Object.keys(n),i=()=>{const u=e.map(v=>v.strategy),d=s.find(v=>!u.includes(v))||"none",f=n[d],m={strategy:d};if(f!=null&&f.params)for(const[v,k]of Object.entries(f.params))k.default!==void 0&&(m[v]=k.default);t([...e,m])},l=u=>{t(e.filter((d,f)=>f!==u))},o=(u,d)=>{t(e.map((f,m)=>m===u?{...f,...d}:f))},c=(u,d)=>{const f=n[d],m={strategy:d};if(f!=null&&f.params)for(const[v,k]of Object.entries(f.params))k.default!==void 0&&(m[v]=k.default);o(u,m)};return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm font-medium",children:"Compaction Strategies"}),a.jsx(Q,{type:"button",variant:"ghost",size:"sm",icon:Hc,onClick:i,disabled:e.length>=s.length,children:"Add"})]}),e.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:'No compaction variations. Click "Add" to test different strategies.'}):a.jsx("div",{className:"space-y-2",children:e.map((u,d)=>{const f=n[u.strategy];return a.jsx("div",{className:"p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:a.jsxs("div",{className:"flex items-start justify-between gap-2",children:[a.jsxs("div",{className:"flex-1 space-y-2",children:[a.jsx("select",{className:"w-full px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:u.strategy,onChange:m=>c(d,m.target.value),children:s.map(m=>{var v;return a.jsx("option",{value:m,children:((v=n[m])==null?void 0:v.label)||m},m)})}),(f==null?void 0:f.description)&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)]",children:f.description}),(f==null?void 0:f.params)&&Object.keys(f.params).length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-2 mt-2",children:Object.entries(f.params).map(([m,v])=>a.jsx(G0,{name:m,schema:v,value:u[m],onChange:k=>o(d,{[m]:k})},m))})]}),a.jsx("button",{type:"button",onClick:()=>l(d),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:a.jsx(Vm,{size:16})})]})},d)})})]})}function G0({name:e,schema:t,value:n,onChange:r}){const s=e.replace(/_/g," ");return t.type==="boolean"?a.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[a.jsx("input",{type:"checkbox",checked:!!(n??t.default),onChange:i=>r(i.target.checked),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"capitalize",children:s})]}):a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:s}),a.jsx("input",{type:t.type==="number"?"number":"text",className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-xs",value:String(n!==void 0?n:t.default??""),onChange:i=>{if(t.type==="number"){const l=parseFloat(i.target.value);r(isNaN(l)?t.default:l)}else r(i.target.value)},min:t.min,max:t.max,step:t.max&&t.max<=1?.1:1})]})}function J0({variations:e,onChange:t,providers:n}){const r=()=>{const o=n[0],c={provider:(o==null?void 0:o.name)||"azure_openai",model:(o==null?void 0:o.models[0])||"gpt-4o"};t([...e,c])},s=o=>{t(e.filter((c,u)=>u!==o))},i=(o,c)=>{t(e.map((u,d)=>d===o?{...u,...c}:u))},l=(o,c)=>{const u=n.find(d=>d.name===c);i(o,{provider:c,model:(u==null?void 0:u.models[0])||""})};return a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("label",{className:"text-sm font-medium",children:"LLM Configurations"}),a.jsx(Q,{type:"button",variant:"ghost",size:"sm",icon:Hc,onClick:r,children:"Add"})]}),e.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:`Uses agent's default LLM. Click "Add" to test different models.`}):a.jsx("div",{className:"space-y-2",children:e.map((o,c)=>{const u=n.find(d=>d.name===o.provider);return a.jsxs("div",{className:"flex items-center gap-2 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[a.jsx("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.provider,onChange:d=>l(c,d.target.value),children:n.map(d=>a.jsx("option",{value:d.name,children:d.label},d.name))}),u&&u.models.length>0?a.jsxs("select",{className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:d=>i(c,{model:d.target.value}),children:[u.models.map(d=>a.jsx("option",{value:d,children:d},d)),!u.models.includes(o.model)&&o.model&&a.jsx("option",{value:o.model,children:o.model})]}):a.jsx("input",{type:"text",className:"flex-1 px-2 py-1.5 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.model,onChange:d=>i(c,{model:d.target.value}),placeholder:"Model ID"}),a.jsx("button",{type:"button",onClick:()=>s(c),className:"p-1 text-[var(--text-secondary)] hover:text-[var(--error)] transition-colors",children:a.jsx(Vm,{size:16})})]},c)})})]})}const Bo={compaction:[],tools:[],llm_config:[],instructions:[],instruction_strategies:[]};function Y0({agentId:e,agentName:t,agentFramework:n="maf",taskSuite:r,taskCount:s,schema:i,onVariationsChange:l,parallel:o,onParallelChange:c,budget:u,onBudgetChange:d,useLlmEval:f,onUseLlmEvalChange:m}){const[v,k]=j.useState(Bo),[g,b]=j.useState(!1),[p,h]=j.useState(""),[x,w]=j.useState(null),C=i.frameworks[n],S=(C==null?void 0:C.compaction_strategies)||Object.keys(i.compaction_strategies),N=i.tool_presets||[],_=i.llm_providers||[],O=(()=>{let L=1;v.compaction.length>0&&(L*=v.compaction.length),v.tools.length>0&&(L*=v.tools.length),v.llm_config.length>0&&(L*=v.llm_config.length);const V=v.instructions.length+v.instruction_strategies.reduce((ee,R)=>ee+R.max_candidates,0);return V>0&&(L*=V),Math.min(L,u)})(),B=O*s,G=L=>{k(L),l==null||l(L)},re=Je({mutationFn:L=>Uo.design(L),onSuccess:L=>{h(L.yaml_content),b(!0)}}),oe=Je({mutationFn:L=>Uo.validate(L),onSuccess:L=>{w({valid:L.valid,errors:L.errors,warnings:L.warnings})}}),D=()=>({base_agent_id:e,task_suite:r,variations:v,parallel:o,budget:u,use_llm_eval:f}),W=()=>{re.mutate(D())},X=()=>{oe.mutate(D())},P=()=>{const L=new Blob([p],{type:"text/yaml"}),V=URL.createObjectURL(L),ee=document.createElement("a");ee.href=V,ee.download=`${t}_experiment.yaml`,ee.click(),URL.revokeObjectURL(V)},A=v.compaction.length>0||v.tools.length>0||v.llm_config.length>0||v.instructions.length>0||v.instruction_strategies.length>0;return a.jsxs("div",{className:"space-y-6",children:[a.jsxs("div",{className:"flex flex-wrap gap-2",children:[a.jsxs(q,{variant:"info",children:[O," candidates"]}),a.jsxs(q,{children:[s," tasks"]}),a.jsxs(q,{variant:B>100?"warning":"success",children:[B," total runs"]})]}),a.jsx(W0,{variations:v.compaction,onChange:L=>G({...v,compaction:L}),strategies:i.compaction_strategies,availableStrategies:S}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("label",{className:"text-sm font-medium",children:"Tool Presets"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:N.map(L=>a.jsxs("label",{className:`flex items-center gap-2 px-3 py-1.5 border rounded cursor-pointer transition-colors ${v.tools.includes(L.name)?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[a.jsx("input",{type:"checkbox",checked:v.tools.includes(L.name),onChange:V=>{const ee=V.target.checked?[...v.tools,L.name]:v.tools.filter(R=>R!==L.name);G({...v,tools:ee})},className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:L.name}),a.jsxs("span",{className:"text-xs text-[var(--text-secondary)]",children:["(",L.tools.length,")"]})]},L.name))}),v.tools.length>0&&a.jsxs("p",{className:"text-xs text-[var(--text-secondary)]",children:["Selected: ",v.tools.join(", ")]})]}),a.jsx(J0,{variations:v.llm_config,onChange:L=>G({...v,llm_config:L}),providers:_}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-4 space-y-4",children:[a.jsx("h4",{className:"text-sm font-medium",children:"Execution Settings"}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(pn,{label:"Parallel Workers",type:"number",value:o,onChange:L=>c(parseInt(L.target.value)||1),min:1,max:16}),a.jsx(pn,{label:"Budget (max candidates)",type:"number",value:u,onChange:L=>d(parseInt(L.target.value)||100),min:1,max:1e3})]}),a.jsx(bi,{label:"Use LLM evaluation",checked:f,onChange:L=>m(L.target.checked)}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] ml-6 -mt-2",children:f?"LLM-as-Judge scores task completion (0-1)":"Simple pass/fail based on task success"})]}),a.jsxs("div",{className:"flex items-center gap-2 border-t border-[var(--border)] pt-4",children:[a.jsx(Q,{variant:"secondary",size:"sm",onClick:X,loading:oe.isPending,children:"Validate"}),a.jsx(Q,{variant:"secondary",size:"sm",icon:Od,onClick:W,loading:re.isPending,children:"Export YAML"})]}),x&&a.jsxs("div",{className:`p-3 rounded border ${x.valid?"border-green-500/50 bg-green-500/10":"border-red-500/50 bg-red-500/10"}`,children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[x.valid?a.jsx(Fm,{size:16,className:"text-green-500"}):a.jsx(zm,{size:16,className:"text-red-500"}),a.jsx("span",{className:"font-medium text-sm",children:x.valid?"Configuration valid":"Configuration has issues"})]}),x.errors.length>0&&a.jsx("ul",{className:"text-sm text-red-500 list-disc ml-6",children:x.errors.map((L,V)=>a.jsx("li",{children:L},V))}),x.warnings.length>0&&a.jsx("ul",{className:"text-sm text-yellow-500 list-disc ml-6 mt-1",children:x.warnings.map((L,V)=>a.jsx("li",{children:L},V))})]}),g&&a.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:a.jsxs("div",{className:"bg-[var(--bg-primary)] rounded-lg shadow-xl max-w-2xl w-full max-h-[80vh] flex flex-col",children:[a.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-[var(--border)]",children:[a.jsx("h3",{className:"font-medium",children:"Experiment YAML"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Q,{variant:"secondary",size:"sm",icon:Od,onClick:P,children:"Download"}),a.jsx(Q,{variant:"ghost",size:"sm",onClick:()=>b(!1),children:"Close"})]})]}),a.jsx("pre",{className:"flex-1 overflow-auto p-4 text-xs font-mono bg-[var(--bg-secondary)]",children:p})]})}),!A&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No variations selected. Only the baseline agent will be tested. Add compaction strategies, tool presets, or LLM configs to generate candidates."})]})}function Zm({agent:e,isOpen:t,onClose:n}){var R;const r=zn(),s=Wt(),[i,l]=j.useState("ready"),[o,c]=j.useState("quick"),[u,d]=j.useState(!1),[f,m]=j.useState([]),[v,k]=j.useState(!1),[g,b]=j.useState(Bo),[p,h]=j.useState(4),[x,w]=j.useState(100),[C,S]=j.useState(!1),[N,_]=j.useState(null),{data:F=[]}=le({queryKey:["tasks"],queryFn:()=>gt.list()}),{data:O=[]}=le({queryKey:["suites"],queryFn:()=>gt.listSuites()}),{data:B}=le({queryKey:["agent-schema"],queryFn:()=>Jm.getAgentSchema()}),G=O.map(T=>({value:T.name,label:T.name.charAt(0).toUpperCase()+T.name.slice(1),description:T.description,tasks:T.task_count})),re=Je({mutationFn:gt.importSuite,onSuccess:T=>{s.invalidateQueries({queryKey:["tasks"]}),m(T.map(te=>te.id))}}),oe=Je({mutationFn:async T=>{const te=await Ot.create(T);return Ot.start(te.id).next(),te},onSuccess:T=>{s.invalidateQueries({queryKey:["jobs"]}),_(T.id),l("success")}}),W=v?(()=>{let T=1;g.compaction.length>0&&(T*=g.compaction.length),g.tools.length>0&&(T*=g.tools.length),g.llm_config.length>0&&(T*=g.llm_config.length);const te=g.instructions.length+g.instruction_strategies.reduce((pe,Se)=>pe+Se.max_candidates,0);return te>0&&(T*=te),Math.min(T,x)})():1,X=u?f.length:((R=G.find(T=>T.value===o))==null?void 0:R.tasks)||3,P=W*X,A=async()=>{l("starting");let T=f;if(!u)try{T=(await re.mutateAsync(o)).map(K=>K.id)}catch(M){console.error("Failed to import suite:",M),alert(`Failed to import task suite: ${o}`),l("ready");return}if(T.length===0){alert("No tasks selected. Please select tasks or choose a task suite."),l("ready");return}let te;if(v&&(g.compaction.length>0||g.tools.length>0||g.llm_config.length>0||g.instructions.length>0||g.instruction_strategies.length>0))try{te=(await Uo.generateCandidates({base_agent_id:e.id,variations:g,budget:x})).candidate_ids}catch(M){console.error("Failed to generate candidates:",M),alert(`Failed to generate candidates: ${M instanceof Error?M.message:"Unknown error"}`),l("ready");return}else te=[e.id];const Se={name:`${e.name} optimization (${te.length} candidates × ${T.length} tasks)`,candidate_ids:te,task_ids:T,parallel:p,use_llm_eval:C};oe.mutate(Se)},L=T=>{m(te=>te.includes(T)?te.filter(pe=>pe!==T):[...te,T])},V=()=>{l("ready"),_(null),k(!1),b(Bo),n()},ee=()=>i==="success"&&N?a.jsxs("div",{className:"flex justify-end gap-3",children:[a.jsx(Q,{variant:"secondary",onClick:V,children:"Close"}),a.jsx(Q,{variant:"primary",icon:Zs,onClick:()=>{V(),r(`/jobs/${N}`)},children:"View Job"})]}):i==="starting"?null:a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Q,{variant:"secondary",onClick:n,children:"Cancel"}),a.jsxs(Q,{variant:"primary",icon:Zs,onClick:A,disabled:u&&f.length===0,children:["Start Optimization (",P," runs)"]})]});return a.jsx(ss,{isOpen:t,onClose:V,title:`Optimize: ${e.name}`,footer:ee(),size:"lg",children:i==="success"&&N?a.jsxs("div",{className:"flex flex-col items-center py-8",children:[a.jsx("div",{className:"w-12 h-12 rounded-full bg-green-500/20 flex items-center justify-center mb-4",children:a.jsx(rs,{size:24,className:"text-green-500"})}),a.jsx("h3",{className:"text-lg font-medium mb-2",children:"Job Started!"}),a.jsx("p",{className:"text-[var(--text-secondary)] text-center mb-2",children:"Optimization job is now running"}),a.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-3 py-1.5 rounded font-mono",children:["ID: ",N.slice(0,8),"..."]})]}):i==="starting"?a.jsxs("div",{className:"flex flex-col items-center py-8",children:[a.jsx(ha,{size:32,className:"animate-spin text-[var(--accent)] mb-4"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:re.isPending?"Importing tasks...":"Creating optimization job..."})]}):a.jsxs("div",{className:"space-y-5",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium mb-2 block",children:"Task Suite"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:u?"__custom__":o,onChange:T=>{T.target.value==="__custom__"?d(!0):(d(!1),c(T.target.value))},children:[G.map(T=>a.jsxs("option",{value:T.value,children:[T.label," (",T.tasks," tasks) — ",T.description]},T.value)),F.length>0&&a.jsx("option",{value:"__custom__",children:"Custom Selection"})]})]}),u&&F.length>0&&a.jsx("div",{className:"max-h-48 overflow-y-auto border border-[var(--border)] rounded p-2 space-y-1",children:F.map(T=>a.jsxs("label",{className:"flex items-center gap-2 p-2 hover:bg-[var(--bg-tertiary)] cursor-pointer rounded",children:[a.jsx("input",{type:"checkbox",checked:f.includes(T.id),onChange:()=>L(T.id),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:T.name}),T.suite&&a.jsx(q,{children:T.suite})]},T.id))}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[a.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>k(!v),children:[a.jsx(Xs,{size:14,className:`transition-transform ${v?"rotate-90":""}`}),"Advanced Settings",v&&a.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:"(experiment design, variations, execution)"})]}),v&&B&&a.jsx("div",{className:"mt-4",children:a.jsx(Y0,{agentId:e.id,agentName:e.name,agentFramework:e.config.framework,taskSuite:u?void 0:o,taskCount:X,schema:B,onVariationsChange:b,parallel:p,onParallelChange:h,budget:x,onBudgetChange:w,useLlmEval:C,onUseLlmEvalChange:S})})]})]})})}function X0(){const e=zn(),t=Wt(),[n,r]=j.useState(!1),[s,i]=j.useState(null),{data:l=[],isLoading:o}=le({queryKey:["configs"],queryFn:()=>_n.list()}),c=Je({mutationFn:_n.create,onSuccess:()=>{t.invalidateQueries({queryKey:["configs"]}),r(!1)}}),u=Je({mutationFn:_n.delete,onSuccess:()=>t.invalidateQueries({queryKey:["configs"]})}),d=[{key:"name",header:"Name",render:f=>a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:f.name})},{key:"framework",header:"Framework",render:f=>a.jsx(q,{children:f.config.framework||"maf"})},{key:"tools",header:"Tools",render:f=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:Z0(f.config.tools)})},{key:"compaction",header:"Compaction",render:f=>{const m=f.config.compaction;return!m||m.strategy==="none"?a.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"}):m.strategy==="head_tail"?a.jsxs(q,{children:[m.params.head_size,"/",m.params.tail_size]}):a.jsx(q,{children:m.strategy})}},{key:"created",header:"Created",render:f=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(f.created_at).toLocaleDateString()}),sortable:!0,sortValue:f=>new Date(f.created_at).getTime()},{key:"actions",header:"",className:"w-40",render:f=>a.jsxs("div",{className:"flex items-center gap-2",onClick:m=>m.stopPropagation(),children:[a.jsx(Q,{variant:"primary",size:"sm",icon:rs,onClick:()=>i(f),children:"Optimize"}),a.jsx(Q,{variant:"ghost",size:"sm",icon:qc,title:"Delete",onClick:()=>{confirm(`Delete agent "${f.name}"?`)&&u.mutate(f.id)}})]})}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Agents"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Define and optimize your agent configurations."})]}),a.jsx(Q,{variant:"primary",icon:Hc,onClick:()=>r(!0),children:"Create agent"})]}),o?a.jsxs("div",{className:"flex items-center gap-2 text-[var(--text-secondary)]",children:[a.jsx(ha,{size:16,className:"animate-spin"}),"Loading agents..."]}):a.jsx(Xm,{columns:d,data:l,onRowClick:f=>e(`/agents/${f.id}`),searchable:!0,searchPlaceholder:"Search agents",searchFilter:(f,m)=>f.name.toLowerCase().includes(m.toLowerCase())||(f.description||"").toLowerCase().includes(m.toLowerCase()),emptyMessage:"No agents yet. Create your first agent to start optimizing.",emptyIcon:a.jsx("div",{className:"inline-flex items-center justify-center w-12 h-12 rounded-full bg-[var(--bg-tertiary)]",children:a.jsx(Bm,{size:24,className:"text-[var(--text-secondary)]"})})}),a.jsx(e1,{isOpen:n,onClose:()=>r(!1),onSubmit:f=>c.mutate(f),isLoading:c.isPending}),s&&a.jsx(Zm,{agent:s,isOpen:!!s,onClose:()=>i(null)})]})}function Z0(e){return typeof e=="string"?e:Array.isArray(e)?`[${e.length}]`:e&&typeof e=="object"?`[${Object.keys(e).length}]`:"standard"}function e1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){var V,ee,R,T,te,pe,Se;const s=["read_file","write_file","edit_file","bash","grep","think"],[i,l]=j.useState("preset"),[o,c]=j.useState({name:"",description:"",instructions:null,model:null,compaction:{strategy:"none",params:{}},tools:s,framework:"miniagent",llm_config_id:null}),[u,d]=j.useState(!1),[f,m]=j.useState("preset"),[v,k]=j.useState([...s]),[g,b]=j.useState(!1),{data:p}=le({queryKey:["agent-schema"],queryFn:()=>Jm.getAgentSchema()}),{data:h=[]}=le({queryKey:["llm-configs"],queryFn:()=>C0.list()}),{data:x}=le({queryKey:["tools"],queryFn:()=>_0.list()}),w=((V=x==null?void 0:x.tools)==null?void 0:V.map(M=>M.name))??s,C=(x==null?void 0:x.presets)??{},S=Object.keys(C),N=(p==null?void 0:p.frameworks)??{},_=Object.keys(N).length>0?Object.keys(N):Q0,F=o.framework||"miniagent",O=((R=(ee=p==null?void 0:p.frameworks)==null?void 0:ee[F])==null?void 0:R.compaction_strategies)??["none","head_tail"],B=(p==null?void 0:p.compaction_strategies)??{},G=(p==null?void 0:p.agent_presets)??[],re=M=>{const K=M.config,dt=K.compaction;n({name:M.name+"-agent",description:M.description,framework:K.framework||"miniagent",tools:K.tools||"standard",compaction:dt||{strategy:"none",params:{}},instructions:K.instructions||null})},oe=M=>{if(M.preventDefault(),!o.name.trim())return;const K={...o};f==="custom"&&(K.tools=v),n(K)},D=((T=o.compaction)==null?void 0:T.strategy)!=="none",W=((te=o.compaction)==null?void 0:te.strategy)||"none",X=B[W],P=M=>{k(K=>K.includes(M)?K.filter(dt=>dt!==M):[...K,M])},A=M=>{const K=B[M],dt={};if(K!=null&&K.params)for(const[as,is]of Object.entries(K.params))is.default!==void 0&&(dt[as]=is.default);c({...o,compaction:{strategy:M,params:dt}})},L=i==="custom"?a.jsxs("div",{className:"flex justify-end gap-2",children:[a.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(Q,{type:"submit",form:"create-agent-form",variant:"primary",disabled:!o.name.trim(),loading:r,children:"Create Agent"})]}):a.jsx("div",{className:"flex justify-end gap-2",children:a.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"})});return a.jsxs(ss,{isOpen:e,onClose:t,title:"Create Agent",footer:L,children:[a.jsxs("div",{className:"flex items-center gap-3 mb-4 pb-3 border-b border-[var(--border)]",children:[a.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${i==="preset"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("preset"),children:"From Preset"}),a.jsx("button",{type:"button",className:`text-sm px-3 py-1.5 rounded transition-colors ${i==="custom"?"bg-[var(--accent)] text-white":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("custom"),children:"Custom"})]}),i==="preset"?a.jsx("div",{className:"space-y-3",children:G.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"Loading presets..."}):G.map(M=>a.jsx("button",{type:"button",className:"w-full text-left p-4 border border-[var(--border)] rounded-lg hover:border-[var(--accent)] hover:bg-[var(--accent)]/5 transition-colors",onClick:()=>re(M),disabled:r,children:a.jsxs("div",{className:"flex items-start justify-between",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx("h4",{className:"font-medium",children:M.label}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:M.description}),a.jsxs("div",{className:"flex flex-wrap gap-1.5 mt-2",children:[M.tags.map(K=>a.jsx(q,{variant:"default",children:K},K)),M.suggested_datasets.length>0&&a.jsxs(q,{variant:"success",children:["datasets: ",M.suggested_datasets.join(", ")]})]})]}),a.jsx(Xs,{size:16,className:"text-[var(--text-secondary)] mt-1 flex-shrink-0"})]})},M.name))}):a.jsxs("form",{id:"create-agent-form",onSubmit:oe,className:"space-y-4",children:[a.jsx(pn,{label:"Name",value:o.name,onChange:M=>c({...o,name:M.target.value}),placeholder:"e.g., my-coding-agent",required:!0}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"LLM Configuration"}),a.jsxs("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.llm_config_id||"",onChange:M=>c({...o,llm_config_id:M.target.value||null}),children:[a.jsx("option",{value:"",children:"Use environment variables"}),h.map(M=>a.jsxs("option",{value:M.id,children:[M.name," (",K0[M.provider],M.model_id?` - ${M.model_id}`:"",")",M.is_default?" (default)":""]},M.id))]}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:h.length===0?"No LLM configs found. Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)":o.llm_config_id?"Uses the selected LLM configuration.":"Uses environment variables (AZURE_OPENAI_ENDPOINT, OPENAI_API_KEY, etc.)"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Framework"}),a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:o.framework||"miniagent",onChange:M=>{const K=M.target.value;c({...o,framework:K,compaction:{strategy:"none",params:{}}})},children:_.map(M=>{var K;return a.jsx("option",{value:M,children:((K=N[M])==null?void 0:K.label)||V0[M]||M},M)})}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((pe=N[F])==null?void 0:pe.description)||(F==="miniagent"?"Lightweight agent with token-aware context management.":F==="langgraph"?"Graph-based workflows with state management.":"Default agent implementation.")})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[a.jsx(bi,{label:"Custom instructions",checked:u,onChange:M=>{d(M.target.checked),M.target.checked||c({...o,instructions:null})}}),a.jsx(bi,{label:"Enable compaction",checked:D,onChange:M=>{if(M.target.checked){const K=O.find(dt=>dt!=="none")||"head_tail";A(K)}else c({...o,compaction:{strategy:"none",params:{}}})}})]}),u&&a.jsx("textarea",{className:"w-full h-32 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono resize-y",value:o.instructions||"",onChange:M=>c({...o,instructions:M.target.value||null}),placeholder:"System prompt / instructions for the agent..."}),D&&a.jsxs("div",{className:"space-y-3 p-3 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:[a.jsxs("div",{children:[a.jsx("label",{className:"text-sm font-medium block mb-1.5",children:"Compaction Strategy"}),a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:W,onChange:M=>A(M.target.value),children:O.filter(M=>M!=="none").map(M=>{var K;return a.jsx("option",{value:M,children:((K=B[M])==null?void 0:K.label)||M},M)})}),(X==null?void 0:X.description)&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:X.description})]}),(X==null?void 0:X.params)&&Object.keys(X.params).length>0&&a.jsx("div",{className:"grid grid-cols-2 gap-3",children:Object.entries(X.params).map(([M,K])=>{var is;const dt=(is=o.compaction)==null?void 0:is.params[M],as=dt!==void 0?dt:K.default;return a.jsxs("div",{children:[a.jsx("label",{className:"text-xs font-medium block mb-1 capitalize",children:M.replace(/_/g," ")}),a.jsx("input",{type:"number",className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof as=="number"?as:Number(as)||0,onChange:ip=>{const tu=parseFloat(ip.target.value);c({...o,compaction:{...o.compaction,params:{...o.compaction.params,[M]:isNaN(tu)?typeof K.default=="number"?K.default:0:tu}}})},min:K.min,max:K.max,step:K.max&&K.max<=1?.1:1}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-0.5",children:K.description})]},M)})})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm font-medium",children:"Tools"}),a.jsxs("div",{className:"flex gap-4",children:[a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"radio",checked:f==="preset",onChange:()=>m("preset"),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:"Preset"})]}),a.jsxs("label",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"radio",checked:f==="custom",onChange:()=>m("custom"),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"text-sm",children:"Custom"})]})]}),f==="preset"?a.jsxs(a.Fragment,{children:[a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm",value:typeof o.tools=="string"?o.tools:"standard",onChange:M=>c({...o,tools:M.target.value}),children:S.map(M=>a.jsx("option",{value:M,children:M},M))}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-1",children:((Se=C[typeof o.tools=="string"?o.tools:"standard"])==null?void 0:Se.join(", "))??""})]}):a.jsx("div",{className:"grid grid-cols-2 gap-1 p-2 border border-[var(--border)] rounded bg-[var(--bg-secondary)]",children:w.map(M=>a.jsxs("label",{className:"flex items-center gap-2 p-1 text-sm cursor-pointer hover:bg-[var(--bg-tertiary)]",children:[a.jsx("input",{type:"checkbox",checked:v.includes(M),onChange:()=>P(M),className:"accent-[var(--accent)]"}),a.jsx("span",{className:"font-mono text-xs",children:M})]},M))})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-3",children:[a.jsxs("button",{type:"button",className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] hover:text-[var(--text-primary)] transition-colors",onClick:()=>b(!g),children:[a.jsx(Xs,{size:14,className:`transition-transform ${g?"rotate-90":""}`}),"More options"]}),g&&a.jsx("div",{className:"mt-3",children:a.jsx(pn,{label:"Description (optional)",value:o.description,onChange:M=>c({...o,description:M.target.value}),placeholder:"Brief description of this agent"})})]})]})]})}function ma({items:e}){return a.jsx("nav",{className:"flex items-center gap-1.5 text-sm mb-4",children:e.map((t,n)=>{const r=n===e.length-1;return a.jsxs("span",{className:"flex items-center gap-1.5",children:[n>0&&a.jsx(Xs,{size:14,className:"text-[var(--text-secondary)]"}),t.path&&!r?a.jsx(Tn,{to:t.path,className:"text-[var(--text-secondary)] hover:text-[var(--accent)] transition-colors",children:t.label}):a.jsx("span",{className:r?"text-[var(--text-primary)] font-medium":"text-[var(--text-secondary)]",children:t.label})]},n)})})}function ge({children:e,className:t="",onClick:n,selected:r=!1,selectable:s=!1}){const i="bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg p-4",l=s?"cursor-pointer hover:border-[var(--accent-dim)] transition-colors":"",o=r?"border-[var(--accent)]":"";return a.jsx("div",{className:`${i} ${l} ${o} ${t}`,onClick:n,children:e})}function t1(e){const t=[],n=r=>r.type==="trace_span"&&typeof r.data=="object"&&r.data!==null?r.data:"span_id"in r?r:null;if(Array.isArray(e.spans)){for(const r of e.spans)if(typeof r=="object"&&r!==null){const s=n(r);s&&t.push(s)}}else if(e.span_id)t.push(e);else for(const r in e){const s=e[r];if(typeof s=="object"&&s!==null){const i=n(s);if(i)t.push(i);else if(Array.isArray(s)){for(const l of s)if(typeof l=="object"&&l!==null){const o=n(l);o&&t.push(o)}}}}return t}function ep(e){const t=new Map,n=[];for(const s of e)t.set(s.span_id,{span:s,children:[]});for(const s of e){const i=t.get(s.span_id);s.parent_span_id&&t.has(s.parent_span_id)?t.get(s.parent_span_id).children.push(i):n.push(i)}const r=s=>{s.sort((i,l)=>(i.span.start_time||0)-(l.span.start_time||0)),s.forEach(i=>r(i.children))};return r(n),n}function n1(e){return e.includes("Agent")||e.includes("agent")?"bg-[var(--span-llm-bg)] text-[var(--span-llm-text)]":e.includes("chat")||e.includes("Chat")||e.includes("llm")?"bg-[var(--span-tool-bg)] text-[var(--span-tool-text)]":e.includes("tool")||e.includes("execute")||e.includes("bash")?"bg-[var(--span-agent-bg)] text-[var(--span-agent-text)]":"bg-[var(--span-other-bg)] text-[var(--span-other-text)]"}function r1(e){return e>=1e3?`${(e/1e3).toFixed(2)}s`:`${e.toFixed(0)}ms`}function eu({node:e,depth:t=0}){var f,m;const[n,r]=j.useState(t<2),[s,i]=j.useState(!1),{span:l}=e,o=e.children.length>0,c=(f=l.attributes)==null?void 0:f["gen_ai.usage.input_tokens"],u=(m=l.attributes)==null?void 0:m["gen_ai.usage.output_tokens"],d=c!==void 0||u!==void 0;return a.jsxs("div",{className:"relative",children:[t>0&&a.jsx("div",{className:"absolute left-0 top-0 bottom-0 border-l-2 border-[var(--border)]",style:{marginLeft:`${(t-1)*16+8}px`}}),a.jsxs("div",{className:"flex items-center gap-2 py-1.5 px-1 hover:bg-[var(--bg-primary)] rounded transition-colors cursor-pointer",style:{paddingLeft:`${t*16}px`},onClick:()=>o?r(!n):i(!s),children:[a.jsx("div",{className:"w-4 h-4 flex items-center justify-center text-[var(--text-secondary)]",children:o?n?"▼":"▶":s?"▼":"▶"}),a.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded font-medium ${n1(l.operation_name)}`,children:l.operation_name.replace("ChatAgent.","").replace("invoke_agent ","")}),l.duration_ms!==void 0&&a.jsx("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:r1(l.duration_ms)}),d&&a.jsxs("span",{className:"text-xs text-[var(--text-secondary)] font-mono",children:[c!==void 0&&a.jsxs("span",{className:"text-blue-400",children:["↑",String(c)]}),c!==void 0&&u!==void 0&&a.jsx("span",{className:"mx-0.5",children:"/"}),u!==void 0&&a.jsxs("span",{className:"text-green-400",children:["↓",String(u)]})]})]}),s&&!o&&a.jsx("div",{className:"ml-4 mt-1 mb-2 p-2 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs",style:{marginLeft:`${t*16+20}px`},children:a.jsxs("div",{className:"space-y-1",children:[l.span_id&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Span ID:"}),a.jsx("span",{className:"font-mono text-xs break-all",children:l.span_id})]}),l.trace_id&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Trace ID:"}),a.jsx("span",{className:"font-mono text-xs break-all",children:l.trace_id})]}),l.status&&a.jsxs("div",{className:"flex gap-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] w-20",children:"Status:"}),a.jsx("span",{className:`px-1.5 py-0.5 rounded text-xs ${l.status==="OK"||l.status==="StatusCode.UNSET"?"bg-[var(--span-pass-bg)] text-[var(--span-pass-text)]":"bg-[var(--span-fail-bg)] text-[var(--span-fail-text)]"}`,children:l.status})]}),Object.keys(l.attributes||{}).length>0&&a.jsxs("div",{className:"mt-2",children:[a.jsx("span",{className:"text-[var(--text-secondary)] block mb-1",children:"Attributes:"}),a.jsx("pre",{className:"text-xs bg-[var(--bg-secondary)] border border-[var(--border)] rounded p-2 overflow-auto max-h-32 whitespace-pre-wrap break-all",children:JSON.stringify(l.attributes,null,2)})]})]})}),o&&n&&a.jsx("div",{children:e.children.map((v,k)=>a.jsx(eu,{node:v,depth:t+1},v.span.span_id||k))})]})}function tp({trace:e}){const[t,n]=j.useState("tree"),r=j.useMemo(()=>t1(e),[e]),s=j.useMemo(()=>ep(r),[r]);return Object.keys(e).length===0?null:a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h3",{className:"font-medium",children:"Trace Data"}),a.jsxs("div",{className:"flex gap-1",children:[a.jsx("button",{onClick:()=>n("tree"),className:`px-2 py-1 text-xs rounded ${t==="tree"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Tree"}),a.jsx("button",{onClick:()=>n("raw"),className:`px-2 py-1 text-xs rounded ${t==="raw"?"bg-[var(--accent)] text-white":"bg-[var(--bg-primary)] text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Raw"})]})]}),t==="tree"?r.length>0?a.jsx("div",{className:"border border-[var(--border)] rounded overflow-hidden",children:a.jsxs("div",{className:"p-2",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs(q,{variant:"default",children:[r.length," spans"]}),a.jsx("span",{children:"•"}),a.jsx("span",{children:"Click to expand details"})]}),s.map((i,l)=>a.jsx(eu,{node:i,depth:0},i.span.span_id||l))]})}):a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No structured spans found. View raw data below."}):a.jsx("pre",{className:"text-xs bg-[var(--bg-primary)] p-3 overflow-x-auto border border-[var(--border)] max-h-96 whitespace-pre-wrap",children:JSON.stringify(e,null,2)})]})}function s1({spans:e,isLive:t=!1}){const n=j.useRef(null),r=j.useMemo(()=>ep(e),[e]);return j.useEffect(()=>{n.current&&t&&n.current.scrollTo({top:n.current.scrollHeight,behavior:"smooth"})},[e.length,t]),a.jsxs("div",{className:"border border-[var(--border)] rounded overflow-hidden h-full flex flex-col",children:[a.jsxs("div",{className:"flex items-center gap-2 p-2 border-b border-[var(--border)] bg-[var(--bg-secondary)]",children:[a.jsxs(q,{variant:"default",children:[e.length," spans"]}),t&&a.jsx("span",{className:"animate-pulse",children:a.jsx(q,{variant:"info",children:"Live"})})]}),a.jsx("div",{ref:n,className:"flex-1 overflow-auto p-2",children:r.length>0?r.map((s,i)=>a.jsx(eu,{node:s,depth:0},s.span.span_id||i)):a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:t?"Waiting for spans...":"No spans recorded"})})]})}function np({agent:e}){const[t,n]=j.useState(""),[r,s]=j.useState(null),[i,l]=j.useState("idle"),[o,c]=j.useState(null),[u,d]=j.useState(""),[f,m]=j.useState([]),[v,k]=j.useState(null),[g,b]=j.useState(null),[p,h]=j.useState([]),[x,w]=j.useState(!1),C=j.useRef(null),{data:S=[]}=le({queryKey:["tasks"],queryFn:()=>gt.list()});j.useEffect(()=>{C.current&&i==="running"&&(C.current.scrollTop=C.current.scrollHeight)},[u,i]);const N=D=>{if(s(D),D){const W=S.find(X=>X.id===D);W&&n(W.prompt)}},_=async()=>{if(t.trim()){l("running"),d(""),m([]),k(null),b(null),h([]);try{const D=await Os.create({agent_id:e.id,prompt:t.trim(),task_id:r||void 0});c(D.id);for await(const W of Os.start(D.id))F(W)}catch(D){b(D instanceof Error?D.message:"Test failed"),l("failed")}}},F=D=>{switch(D.event){case"started":break;case"execution":D.execution_event==="text_delta"&&D.content?d(W=>W+D.content):D.execution_event==="tool_call_start"&&D.tool_name?h(W=>[...W,{name:D.tool_name}]):D.execution_event==="tool_result"&&D.content&&h(W=>{if(W.length>0){const X=[...W];return X[X.length-1]={...X[X.length-1],content:D.content},X}return W});break;case"span":if(D.span){const W=D.span;if(W.data){const X={span_id:W.data.span_id||"",trace_id:W.data.trace_id||"",parent_span_id:W.data.parent_span_id||null,operation_name:W.data.operation_name||"",start_time:W.timestamp?new Date(W.timestamp).getTime():Date.now(),end_time:Date.now(),duration_ms:W.data.duration_ms||0,status:W.data.status||"OK",attributes:W.data.attributes||{}};m(P=>[...P,X])}}break;case"complete":l("completed"),D.result&&k(D.result);break;case"error":b(D.message),l("failed");break}},O=async()=>{if(o)try{await Os.cancel(o)}catch{}l("idle")},B=()=>{l("idle"),c(null),d(""),m([]),k(null),b(null),h([])},G=i==="running",re=i==="completed"||i==="failed",oe=D=>{D.preventDefault(),re?(B(),setTimeout(()=>_(),0)):_()};return a.jsxs("div",{className:"h-full flex flex-col border border-[var(--border)] rounded-lg overflow-hidden bg-[var(--bg-primary)]",children:[(G||re)&&a.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-[var(--border)] bg-[var(--bg-secondary)] flex-shrink-0",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[G&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"animate-pulse",children:a.jsx(q,{variant:"info",children:"Running"})}),a.jsx(Q,{variant:"ghost",size:"sm",icon:Ld,onClick:O,children:"Cancel"})]}),i==="completed"&&a.jsx(q,{variant:"success",children:"Completed"}),i==="failed"&&a.jsx(q,{variant:"error",children:"Failed"})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[v&&a.jsxs("div",{className:"flex items-center gap-3 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Im,{size:12}),v.duration_seconds.toFixed(2),"s"]}),a.jsxs("span",{className:"flex items-center gap-1",children:[a.jsx(Mg,{size:12}),v.tokens_total," tokens"]}),v.passed!==null&&(v.passed?a.jsx(Fm,{size:14,className:"text-[var(--success)]"}):a.jsx(Xg,{size:14,className:"text-[var(--error)]"}))]}),f.length>0&&a.jsxs(Q,{variant:x?"primary":"secondary",size:"sm",icon:Sg,onClick:()=>w(!x),children:["Traces (",f.length,")"]}),re&&o&&a.jsx(Tn,{to:`/tests/${o}`,children:a.jsx(Q,{variant:"secondary",size:"sm",icon:Am,children:"Details"})})]})]}),a.jsxs("div",{className:"flex-1 min-h-0 flex",children:[a.jsx("div",{ref:C,className:`flex-1 overflow-auto p-4 ${x?"border-r border-[var(--border)]":""}`,children:!G&&!re?a.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center",children:[a.jsx("div",{className:"text-lg font-medium mb-1",children:e.name}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] max-w-sm",children:"Send a message to test this agent, or select a task from the dropdown below."})]}):a.jsxs("div",{className:"space-y-3",children:[a.jsx("div",{className:"flex justify-end",children:a.jsx("div",{className:"max-w-[80%] px-3 py-2 bg-[var(--accent-dim)] text-[var(--text-primary)] rounded-lg text-sm",children:t})}),(u||G)&&a.jsx("div",{className:"px-3 py-2 text-sm whitespace-pre-wrap font-mono bg-[var(--bg-secondary)] rounded-lg border border-[var(--border)]",children:u||a.jsx("span",{className:"text-[var(--text-secondary)] animate-pulse",children:"Thinking..."})}),p.length>0&&a.jsx("div",{className:"space-y-1.5",children:p.map((D,W)=>a.jsxs("div",{className:"p-2 bg-[var(--badge-info-bg)] border border-[var(--badge-info-border)] rounded-md text-xs",children:[a.jsx(q,{variant:"info",children:D.name}),D.content&&a.jsxs("div",{className:"mt-1 text-[var(--text-secondary)] truncate max-w-full font-mono",children:[D.content.substring(0,200),D.content.length>200&&"..."]})]},W))}),g&&a.jsx("div",{className:"p-3 bg-[var(--badge-error-bg)] border border-[var(--badge-error-border)] rounded-md text-sm text-[var(--badge-error-text)]",children:g})]})}),x&&a.jsx("div",{className:"w-[350px] flex-shrink-0 overflow-auto",children:a.jsx(s1,{spans:f,isLive:G})})]}),a.jsxs("div",{className:"flex-shrink-0 border-t border-[var(--border)] bg-[var(--bg-secondary)]",children:[a.jsx("div",{className:"px-4 pt-2",children:a.jsxs("select",{value:r||"",onChange:D=>N(D.target.value||null),className:"w-full px-2 py-1 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs text-[var(--text-secondary)]",disabled:G,children:[a.jsx("option",{value:"",children:"Custom prompt..."}),S.map(D=>a.jsx("option",{value:D.id,children:D.name},D.id))]})}),a.jsxs("form",{onSubmit:oe,className:"p-3 flex gap-2",children:[a.jsx("textarea",{value:t,onChange:D=>n(D.target.value),placeholder:"Message the agent...",disabled:G,rows:1,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm resize-none min-h-[40px] max-h-[120px] focus:outline-none focus:border-[var(--accent)]",onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),oe(D))}}),a.jsx(Q,{type:"submit",variant:"primary",icon:G?Ld:Zs,disabled:G?!1:!t.trim(),onClick:G?O:void 0,children:G?"Stop":re?"New Test":"Run"})]})]})]})}function a1(){const{agentId:e}=fa(),t=zn(),n=Wt(),[r,s]=j.useState("overview"),[i,l]=j.useState(!1),{data:o,isLoading:c}=le({queryKey:["configs",e],queryFn:()=>_n.get(e),enabled:!!e}),{data:u=[]}=le({queryKey:["tests",{agent_id:e}],queryFn:()=>Os.list({agent_id:e}),enabled:!!e}),{data:d=[]}=le({queryKey:["jobs"],queryFn:()=>Ot.list()}),f=Je({mutationFn:v=>_n.delete(v),onSuccess:()=>{n.invalidateQueries({queryKey:["configs"]}),t("/agents")}}),m=d.filter(v=>v.candidate_ids.includes(e||""));return c?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):o?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsxs("div",{className:"mb-4 flex-shrink-0",children:[a.jsx(ma,{items:[{label:"Agents",path:"/agents"},{label:o.name}]}),a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:o.name}),o.is_auto_generated&&a.jsx(q,{variant:"info",children:"Auto-generated"})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Q,{variant:"primary",icon:rs,size:"sm",onClick:()=>l(!0),children:"Optimize"}),a.jsx(Q,{variant:"secondary",icon:qc,size:"sm",onClick:()=>{confirm(`Delete agent "${o.name}"?`)&&f.mutate(o.id)},children:"Delete"})]})]}),o.description&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:o.description})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsxs("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:[a.jsxs("div",{className:"flex gap-1 mb-4 border-b border-[var(--border)] flex-shrink-0",children:[a.jsx(Nl,{active:r==="overview",onClick:()=>s("overview"),icon:a.jsx(Bm,{size:14}),children:"Overview"}),a.jsx(Nl,{active:r==="evaluate",onClick:()=>s("evaluate"),icon:a.jsx(Zs,{size:14}),children:"Evaluate"}),a.jsx(Nl,{active:r==="history",onClick:()=>s("history"),icon:a.jsx(Ag,{size:14}),badge:u.length,children:"History"})]}),a.jsxs("div",{className:"flex-1 overflow-y-auto",children:[r==="overview"&&a.jsx(i1,{agent:o,recentTests:u,jobs:m}),r==="evaluate"&&a.jsx(l1,{agent:o,jobs:m}),r==="history"&&a.jsx(o1,{tests:u})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[a.jsx(Um,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),a.jsx("div",{className:"flex-1 min-h-0",children:a.jsx(np,{agent:o})})]})]}),i&&a.jsx(Zm,{agent:o,isOpen:i,onClose:()=>l(!1)})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Agent not found"})}function Nl({active:e,onClick:t,icon:n,badge:r,children:s}){return a.jsxs("button",{onClick:t,className:`flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors ${e?"border-[var(--accent)] text-[var(--text-primary)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[n,s,r!==void 0&&r>0&&a.jsx("span",{className:"ml-1 px-1.5 py-0.5 text-xs bg-[var(--bg-tertiary)] rounded",children:r})]})}function i1({agent:e,recentTests:t,jobs:n}){var i,l;const r=e.config,s=()=>{const o=r.tools;return typeof o=="string"?o:Array.isArray(o)?o.join(", "):o&&typeof o=="object"?Object.keys(o).join(", "):"standard"};return a.jsxs("div",{className:"space-y-4",children:[a.jsx(ur,{title:"Model",children:a.jsx("div",{className:"font-mono text-sm",children:r.model||"default"})}),a.jsx(ur,{title:"Instructions",defaultCollapsed:!r.instructions,children:r.instructions?a.jsx("pre",{className:"p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-xs whitespace-pre-wrap max-h-40 overflow-auto font-mono",children:r.instructions}):a.jsx("p",{className:"text-sm text-[var(--text-secondary)] italic",children:"No instructions set"})}),a.jsx(ur,{title:"Tools",children:a.jsx("div",{className:"font-mono text-sm",children:s()})}),a.jsx(ur,{title:"Compaction",children:a.jsx("div",{className:"font-mono text-sm",children:!r.compaction||r.compaction.strategy==="none"?"disabled":`${r.compaction.strategy} (${((i=r.compaction.params)==null?void 0:i.head_size)||0}/${((l=r.compaction.params)==null?void 0:l.tail_size)||0})`})}),t.length>0&&a.jsx(ur,{title:`Recent Tests (${t.length})`,children:a.jsx("div",{className:"space-y-1.5",children:t.slice(0,3).map(o=>a.jsxs(Tn,{to:`/tests/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[a.jsx(rp,{status:o.status}),a.jsxs("span",{className:"truncate",children:[o.prompt.slice(0,40),"..."]})]}),a.jsxs("span",{className:"text-[var(--text-secondary)] flex-shrink-0 ml-2",children:[o.duration_seconds.toFixed(1),"s"]})]},o.id))})}),n.length>0&&a.jsx(ur,{title:`Experiments (${n.length})`,children:a.jsx("div",{className:"space-y-1.5",children:n.slice(0,3).map(o=>a.jsxs(Tn,{to:`/jobs/${o.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(q,{variant:o.status==="completed"?"success":o.status==="running"?"info":"default",children:o.status}),a.jsx("span",{children:o.name})]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(o.created_at).toLocaleDateString()})]},o.id))})})]})}function ur({title:e,children:t,defaultCollapsed:n=!1}){const[r,s]=j.useState(n);return a.jsxs("div",{className:"border-b border-[var(--border)] pb-3",children:[a.jsxs("button",{onClick:()=>s(!r),className:"flex items-center justify-between w-full text-left py-1 hover:text-[var(--accent)] transition-colors",children:[a.jsx("span",{className:"text-sm font-medium",children:e}),a.jsx("span",{className:"text-[var(--text-secondary)] text-xs",children:r?"▶":"▼"})]}),!r&&a.jsx("div",{className:"mt-2",children:t})]})}function l1({agent:e,jobs:t}){const n=zn(),r=Wt(),[s,i]=j.useState("quick"),[l,o]=j.useState(!1),{data:c=[]}=le({queryKey:["suites"],queryFn:()=>gt.listSuites()}),u=Je({mutationFn:P0.start,onSuccess:f=>{r.invalidateQueries({queryKey:["jobs"]}),o(!1),n(`/jobs/${f.id}`)},onError:()=>{o(!1)}}),d=()=>{o(!0),u.mutate({agent_id:e.id,suite_name:s,use_llm_eval:!0,parallel:4})};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-3",children:"Run this agent on a task suite to measure quality and cost."}),a.jsxs("div",{className:"space-y-3",children:[a.jsx("select",{className:"w-full px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md text-sm",value:s,onChange:f=>i(f.target.value),disabled:l,children:c.map(f=>a.jsxs("option",{value:f.name,children:[f.name.charAt(0).toUpperCase()+f.name.slice(1)," (",f.task_count," tasks)"]},f.name))}),a.jsx(Q,{variant:"primary",icon:l?ha:Zs,onClick:d,disabled:l,loading:l,className:"w-full",children:"Evaluate"})]})]}),a.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[a.jsxs("div",{className:"flex items-center justify-between mb-3",children:[a.jsx("h4",{className:"text-sm font-medium",children:"Optimization Jobs"}),a.jsx(Q,{variant:"secondary",size:"sm",icon:rs,onClick:()=>n("/agents",{state:{optimizeAgent:e}}),children:"New Job"})]}),t.length===0?a.jsx("div",{className:"text-sm text-[var(--text-secondary)] text-center py-4",children:"No optimization jobs yet."}):a.jsx("div",{className:"space-y-1.5",children:t.slice(0,5).map(f=>a.jsxs(Tn,{to:`/jobs/${f.id}`,className:"flex items-center justify-between p-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-xs",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(q,{variant:f.status==="completed"?"success":f.status==="running"?"info":"default",children:f.status}),a.jsx("span",{children:f.name})]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(f.created_at).toLocaleDateString()})]},f.id))})]})]})}function o1({tests:e}){return e.length===0?a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No test history yet. Use the playground on the right to run a test."}):a.jsx("div",{className:"space-y-2",children:e.map(t=>a.jsxs(Tn,{to:`/tests/${t.id}`,className:"flex items-center justify-between p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors",children:[a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[a.jsx(rp,{status:t.status}),t.score!==null&&a.jsxs("span",{className:`text-sm font-medium ${t.passed?"text-[var(--success)]":"text-[var(--error)]"}`,children:[(t.score*100).toFixed(0),"%"]})]}),a.jsx("p",{className:"text-sm truncate",children:t.prompt})]}),a.jsxs("div",{className:"flex flex-col items-end gap-1 ml-4",children:[a.jsx("span",{className:"text-xs text-[var(--text-secondary)]",children:new Date(t.created_at).toLocaleString()}),a.jsxs("div",{className:"flex items-center gap-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:[t.duration_seconds.toFixed(1),"s"]}),a.jsxs("span",{children:[t.tokens_total," tokens"]})]})]})]},t.id))})}function rp({status:e}){const t={completed:"success",failed:"error",running:"info",cancelled:"warning",pending:"default"};return a.jsx(q,{variant:t[e]||"default",children:e})}function c1(){const e=Wt(),[t,n]=j.useState(!1),[r,s]=j.useState(!1),[i,l]=j.useState(null),[o,c]=j.useState(new Set),u=p=>{c(h=>{const x=new Set(h);return x.has(p)?x.delete(p):x.add(p),x})},{data:d=[],isLoading:f}=le({queryKey:["tasks"],queryFn:()=>gt.list()}),m=Je({mutationFn:gt.create,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),n(!1)}}),v=Je({mutationFn:gt.importSuite,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),s(!1)}}),k=Je({mutationFn:gt.delete,onSuccess:()=>{e.invalidateQueries({queryKey:["tasks"]}),l(null)}}),g=d.reduce((p,h)=>{const x=h.suite||"custom";return p[x]||(p[x]=[]),p[x].push(h),p},{}),b=Object.keys(g).sort((p,h)=>p==="custom"?-1:h==="custom"?1:p.localeCompare(h));return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Datasets"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"Task datasets for evaluating agent configurations."})]}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx(Q,{variant:"secondary",onClick:()=>s(!0),children:"Import Suite"}),a.jsx(Q,{variant:"primary",onClick:()=>n(!0),children:"+ New Task"})]})]}),f?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):d.length===0?a.jsx("div",{className:"text-center py-12 text-[var(--text-secondary)]",children:"No tasks yet. Create one or import a built-in suite."}):a.jsx("div",{className:"space-y-4",children:b.map(p=>{const h=g[p],x=!o.has(p);return a.jsxs("div",{children:[a.jsxs("button",{onClick:()=>u(p),className:"flex items-center gap-2 py-2 hover:text-[var(--accent)] transition-colors",children:[x?a.jsx(Og,{size:16,className:"text-[var(--text-secondary)]"}):a.jsx(Xs,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium uppercase tracking-wide",children:p==="custom"?"Custom Tasks":`${p} Suite`}),a.jsx(q,{variant:p==="custom"?"default":"info",children:h.length})]}),x&&a.jsx("div",{className:"mt-2 border border-[var(--border)] rounded-lg overflow-hidden",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-[var(--border)] bg-[var(--bg-tertiary)]",children:[a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Name"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Category"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Prompt"}),a.jsx("th",{className:"text-left px-4 py-2.5 text-xs font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Criteria"})]})}),a.jsx("tbody",{children:h.map(w=>a.jsxs("tr",{onClick:()=>l(w),className:"border-b border-[var(--border)] last:border-b-0 cursor-pointer hover:bg-[var(--bg-tertiary)] transition-colors",children:[a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:w.name})}),a.jsx("td",{className:"px-4 py-3",children:w.category&&w.category!=="default"?a.jsx(q,{variant:"default",children:w.category}):a.jsx("span",{className:"text-[var(--text-secondary)]",children:"--"})}),a.jsx("td",{className:"px-4 py-3",children:a.jsx("span",{className:"text-[var(--text-secondary)] line-clamp-1 max-w-md",children:w.prompt})}),a.jsx("td",{className:"px-4 py-3 text-[var(--text-secondary)]",children:w.criteria.length>0?w.criteria.length:"--"})]},w.id))})]})})]},p)})}),a.jsx(u1,{task:i,onClose:()=>l(null),onDelete:p=>{confirm("Delete this task?")&&k.mutate(p)}}),a.jsx(d1,{isOpen:t,onClose:()=>n(!1),onSubmit:p=>m.mutate(p),isLoading:m.isPending}),a.jsx(f1,{isOpen:r,onClose:()=>s(!1),onSubmit:p=>v.mutate(p),isLoading:v.isPending})]})}function u1({task:e,onClose:t,onDelete:n}){const[r,s]=j.useState("prompt");if(!e)return null;const i=a.jsxs("div",{className:"flex justify-between",children:[a.jsx(Q,{variant:"ghost",onClick:()=>n(e.id),className:"text-red-500 hover:text-red-600",children:"Delete Task"}),a.jsx(Q,{variant:"secondary",onClick:t,children:"Close"})]});return a.jsx(ss,{isOpen:!!e,onClose:t,title:e.name,size:"lg",footer:i,children:a.jsxs("div",{className:"space-y-4",children:[e.category&&e.category!=="default"&&a.jsx("div",{children:a.jsx(q,{variant:"default",children:e.category})}),a.jsxs("div",{className:"flex gap-1 border-b border-[var(--border)]",children:[a.jsx("button",{onClick:()=>s("prompt"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="prompt"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:"Prompt"}),a.jsxs("button",{onClick:()=>s("criteria"),className:`px-4 py-2 text-sm font-medium border-b-2 -mb-px transition-colors ${r==="criteria"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:["Eval Criteria (",e.criteria.length,")"]})]}),r==="prompt"&&a.jsx("div",{className:"p-4 bg-[var(--bg-tertiary)] rounded text-sm whitespace-pre-wrap min-h-[200px]",children:e.prompt}),r==="criteria"&&a.jsx("div",{className:"space-y-2 min-h-[200px]",children:e.criteria.length===0?a.jsx("div",{className:"text-[var(--text-secondary)] text-sm p-4",children:"No evaluation criteria defined for this task."}):e.criteria.map(l=>a.jsxs("div",{className:"p-3 bg-[var(--bg-tertiary)] rounded",children:[a.jsx("div",{className:"font-medium text-sm",children:l.name}),l.instruction&&a.jsx("div",{className:"text-sm text-[var(--text-secondary)] mt-1",children:l.instruction})]},l.name))})]})})}function d1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,i]=j.useState({name:"",prompt:"",criteria:[],category:"default"}),l=()=>{i({...s,criteria:[...s.criteria,{name:"",instruction:"",weight:1}]})},o=(d,f)=>{const m=[...s.criteria];m[d]={...m[d],...f},i({...s,criteria:m})},c=d=>{i({...s,criteria:s.criteria.filter((f,m)=>m!==d)})},u=d=>{d.preventDefault(),!(!s.name.trim()||!s.prompt.trim())&&n({...s,criteria:s.criteria.filter(f=>f.name.trim()&&f.instruction.trim())})};return a.jsx(ss,{isOpen:e,onClose:t,title:"Create Task",children:a.jsxs("form",{onSubmit:u,className:"space-y-4",children:[a.jsx(pn,{label:"Name",value:s.name,onChange:d=>i({...s,name:d.target.value}),placeholder:"e.g., fizzbuzz",required:!0}),a.jsx(q0,{label:"Prompt",value:s.prompt,onChange:d=>i({...s,prompt:d.target.value}),placeholder:"The task description for the agent...",required:!0}),a.jsx(pn,{label:"Category",value:s.category,onChange:d=>i({...s,category:d.target.value}),placeholder:"e.g., coding, research"}),a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Evaluation Criteria"}),a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:l,children:"+ Add"})]}),a.jsx("div",{className:"space-y-2",children:s.criteria.map((d,f)=>a.jsxs("div",{className:"flex gap-2 items-start",children:[a.jsx(pn,{value:d.name,onChange:m=>o(f,{name:m.target.value}),placeholder:"Name",className:"w-32"}),a.jsx(pn,{value:d.instruction,onChange:m=>o(f,{instruction:m.target.value}),placeholder:"Instruction",className:"flex-1"}),a.jsx(Q,{type:"button",variant:"ghost",size:"sm",onClick:()=>c(f),children:"×"})]},f))})]}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[a.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(Q,{type:"submit",variant:"primary",disabled:r||!s.name.trim()||!s.prompt.trim(),children:r?"Creating...":"Create"})]})]})})}function f1({isOpen:e,onClose:t,onSubmit:n,isLoading:r}){const[s,i]=j.useState(""),{data:l=[],isLoading:o}=le({queryKey:["suites"],queryFn:()=>gt.listSuites(),enabled:e});return j.useEffect(()=>{l.length>0&&!s&&i(l[0].name)},[l,s]),a.jsx(ss,{isOpen:e,onClose:t,title:"Import Task Suite",children:a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"Import a built-in task suite for evaluation."}),o?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading suites..."}):l.length===0?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"No suites available."}):a.jsx("div",{className:"space-y-2 max-h-80 overflow-y-auto",children:l.map(c=>a.jsxs("label",{className:`flex items-center gap-3 p-3 border cursor-pointer ${s===c.name?"border-[var(--accent)] bg-[var(--accent)]/10":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:[a.jsx("input",{type:"radio",name:"suite",value:c.name,checked:s===c.name,onChange:()=>i(c.name),className:"accent-[var(--accent)]"}),a.jsxs("span",{className:"capitalize",children:[c.name.replace(/_/g," ")," (",c.task_count," tasks) - ",c.description]})]},c.name))}),a.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[a.jsx(Q,{type:"button",variant:"secondary",onClick:t,children:"Cancel"}),a.jsx(Q,{variant:"primary",onClick:()=>n(s),disabled:r||!s,children:r?"Importing...":"Import"})]})]})})}function h1(){const e=zn(),t=Wt(),[n,r]=j.useState(!1),s=Xc(),{data:i=[],isLoading:l}=le({queryKey:["jobs",n],queryFn:()=>Ot.list({include_public:n}),refetchInterval:5e3}),o=Je({mutationFn:Ot.delete,onSuccess:()=>t.invalidateQueries({queryKey:["jobs"]})}),c={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"},u=[{key:"name",header:"Name",render:d=>a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--accent)] font-medium hover:underline",children:d.name||`Job ${d.id.slice(0,8)}`}),d.is_public&&a.jsx(Kc,{className:"w-3 h-3 ml-2 inline text-[var(--text-secondary)]"})]})},{key:"status",header:"Status",render:d=>a.jsx(q,{variant:c[d.status]||"default",children:d.status})},{key:"candidates",header:"Candidates",render:d=>a.jsx("span",{children:d.candidate_ids.length})},{key:"tasks",header:"Tasks",render:d=>a.jsx("span",{children:d.task_ids.length})},{key:"runs",header:"Runs",render:d=>a.jsxs("span",{children:[d.completed_experiments,"/",d.total_experiments]})},{key:"created",header:"Created",render:d=>a.jsx("span",{className:"text-[var(--text-secondary)]",children:new Date(d.created_at).toLocaleDateString()}),sortable:!0,sortValue:d=>new Date(d.created_at).getTime()},{key:"actions",header:"",className:"w-12",render:d=>!d.user_id||d.user_id==="anonymous"||s&&d.created_by_name===s?a.jsx("div",{onClick:m=>m.stopPropagation(),children:a.jsx(Q,{variant:"ghost",size:"sm",icon:qc,title:"Delete",disabled:d.status==="running",onClick:()=>{confirm("Delete this job?")&&o.mutate(d.id)}})}):null}];return a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsx("h2",{className:"text-xl font-bold",children:"Experiments"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:"View and manage optimization experiments. Start new experiments from the Agents page."})]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(bi,{label:"Show public",checked:n,onChange:d=>r(d.target.checked)}),a.jsx(Q,{variant:"secondary",onClick:()=>e("/agents"),children:"Go to Agents"})]})]}),l?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):a.jsx(Xm,{columns:u,data:i,onRowClick:d=>e(`/jobs/${d.id}`),searchable:!0,searchPlaceholder:"Search experiments",searchFilter:(d,f)=>(d.name||"").toLowerCase().includes(f.toLowerCase())||d.id.toLowerCase().includes(f.toLowerCase()),emptyMessage:"No experiments yet. Go to Agents page to start an optimization."})]})}function m1(e,t=!0){return Math.abs(e)<10?"text-[var(--text-secondary)]":(t?e<0:e>0)?"text-green-400":"text-red-400"}function p1(e){return`${e>0?"+":""}${e.toFixed(1)}%`}function sp(e,t){return t===0?0:(e-t)/t*100}function xs({label:e,values:t,baselineIndex:n,formatter:r,isLowerBetter:s=!0}){const i=t[n];return a.jsxs("tr",{className:"border-b border-[var(--border)] last:border-0",children:[a.jsx("td",{className:"py-2 pr-4 text-[var(--text-secondary)] text-sm",children:e}),t.map((l,o)=>{const c=sp(l,i),u=o===n;return a.jsxs("td",{className:"py-2 px-4 text-right",children:[a.jsx("div",{className:"font-mono",children:r(l)}),!u&&a.jsx("div",{className:`text-xs ${m1(c,s)}`,children:p1(c)}),u&&a.jsx("div",{className:"text-xs text-[var(--text-secondary)]",children:"(baseline)"})]},o)})]})}function x1({runs:e,baselineRunId:t}){const n=j.useMemo(()=>{if(t){const i=e.findIndex(l=>l.id===t);if(i>=0)return i}return 0},[e,t]);if(e.length<2)return null;const r=Math.min(...e.map(i=>i.tokens_total)),s=Math.max(...e.map(i=>i.score));return a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-4",children:"Candidate Comparison"}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"border-b border-[var(--border)]",children:[a.jsx("th",{className:"pb-2 pr-4 text-left text-[var(--text-secondary)] font-medium",children:"Metric"}),e.map((i,l)=>a.jsx("th",{className:"pb-2 px-4 text-right",children:a.jsxs("div",{className:"flex items-center justify-end gap-2",children:[a.jsx("span",{className:"font-medium",children:i.candidate_name}),i.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"}),l===n&&a.jsx(q,{variant:"info",children:"Base"})]})},i.id))]})}),a.jsxs("tbody",{children:[a.jsx(xs,{label:"Total Tokens",values:e.map(i=>i.tokens_total),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(xs,{label:"Input Tokens",values:e.map(i=>i.tokens_input),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(xs,{label:"Output Tokens",values:e.map(i=>i.tokens_output),baselineIndex:n,formatter:i=>i.toLocaleString(),isLowerBetter:!0}),a.jsx(xs,{label:"Duration",values:e.map(i=>i.duration_seconds),baselineIndex:n,formatter:i=>`${i.toFixed(1)}s`,isLowerBetter:!0}),a.jsx(xs,{label:"Score",values:e.map(i=>i.score*100),baselineIndex:n,formatter:i=>`${i.toFixed(1)}%`,isLowerBetter:!1})]})]})}),a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[a.jsx("h4",{className:"text-sm font-medium mb-2 text-[var(--text-secondary)]",children:"Key Insights"}),a.jsxs("ul",{className:"text-sm space-y-1 text-[var(--text-secondary)]",children:[e.map(i=>{const l=sp(i.tokens_total,e[n].tokens_total);return i.tokens_total===r&&l<-5?a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-green-400",children:"✓"}),a.jsxs("span",{children:[a.jsx("strong",{children:i.candidate_name})," uses ",Math.abs(l).toFixed(0),"% fewer tokens"]})]},`token-${i.id}`):null}),e.map(i=>i.score===s&&i.passed?a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-green-400",children:"✓"}),a.jsxs("span",{children:[a.jsx("strong",{children:i.candidate_name})," achieved highest score (",(i.score*100).toFixed(0),"%)"]})]},`score-${i.id}`):null),e.filter(i=>i.is_pareto).length>0&&a.jsxs("li",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"text-purple-400",children:"★"}),a.jsxs("span",{children:["Optimal candidates (best tradeoff):"," ",e.filter(i=>i.is_pareto).map(i=>i.candidate_name).join(", ")]})]})]})]}),a.jsxs("div",{className:"mt-4 pt-4 border-t border-[var(--border)]",children:[a.jsx("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:"Token Efficiency"}),a.jsx("div",{className:"space-y-2",children:e.map(i=>{const l=i.tokens_total/e[n].tokens_total*100,o=i.tokens_total<=r;return a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-24 text-sm truncate",title:i.candidate_name,children:i.candidate_name}),a.jsx("div",{className:"flex-1 h-6 bg-[var(--bg-primary)] rounded overflow-hidden",children:a.jsx("div",{className:`h-full transition-all duration-300 ${o?"bg-green-500":"bg-blue-500"}`,style:{width:`${Math.min(l,100)}%`}})}),a.jsx("div",{className:"w-20 text-right font-mono text-sm",children:i.tokens_total.toLocaleString()})]},i.id)})})]})]})}function v1({summaries:e,height:t=350}){const n=j.useRef(null),[r,s]=j.useState(600),[i,l]=j.useState("tokens"),[o,c]=j.useState(null),[u,d]=j.useState({x:0,y:0});j.useEffect(()=>{const S=()=>{n.current&&s(n.current.clientWidth)};return S(),window.addEventListener("resize",S),()=>window.removeEventListener("resize",S)},[]);const f={top:30,right:30,bottom:50,left:60},m=r-f.left-f.right,v=t-f.top-f.bottom,k=S=>i==="tokens"?S.avg_tokens:S.avg_duration,{xScale:g,yScale:b,xTicks:p,yTicks:h,paretoLine:x}=j.useMemo(()=>{if(e.length===0||m<=0)return{xScale:()=>0,yScale:()=>0,xTicks:[],yTicks:[],paretoLine:[]};const S=e.map(k),N=e.map(P=>P.avg_score),_=Math.min(...S)*.9,F=Math.max(...S)*1.1,O=Math.min(...N,.5),B=Math.min(Math.max(...N)*1.05,1),G=P=>(P-_)/(F-_)*m,re=P=>v-(P-O)/(B-O)*v,oe=Array.from({length:5},(P,A)=>_+A/4*(F-_)),D=Array.from({length:5},(P,A)=>O+A/4*(B-O)),X=e.filter(P=>P.is_pareto).sort((P,A)=>k(P)-k(A)).map(P=>({x:G(k(P)),y:re(P.avg_score)}));return{xScale:G,yScale:re,xTicks:oe,yTicks:D,paretoLine:X}},[e,m,v,i]);if(e.length===0)return a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"No data to display"});const w=S=>i==="tokens"?S>=1e6?`${(S/1e6).toFixed(1)}M`:S>=1e3?`${(S/1e3).toFixed(0)}K`:S.toFixed(0):`${S.toFixed(1)}s`,C=(S,N)=>{var F;const _=(F=n.current)==null?void 0:F.getBoundingClientRect();_&&d({x:N.clientX-_.left,y:N.clientY-_.top}),c(S)};return a.jsxs("div",{ref:n,className:"w-full relative",children:[a.jsx("div",{className:"flex justify-end mb-2",children:a.jsxs("div",{className:"inline-flex rounded border border-[var(--border)] text-xs",children:[a.jsx("button",{className:`px-3 py-1 ${i==="tokens"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("tokens"),children:"Tokens"}),a.jsx("button",{className:`px-3 py-1 ${i==="duration"?"bg-[var(--accent)] text-black":"text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,onClick:()=>l("duration"),children:"Latency"})]})}),a.jsx("svg",{width:r,height:t,className:"font-mono text-xs",children:a.jsxs("g",{transform:`translate(${f.left}, ${f.top})`,children:[p.map((S,N)=>a.jsx("line",{x1:g(S),y1:0,x2:g(S),y2:v,stroke:"var(--border)",strokeDasharray:"2,2"},`x-grid-${N}`)),h.map((S,N)=>a.jsx("line",{x1:0,y1:b(S),x2:m,y2:b(S),stroke:"var(--border)",strokeDasharray:"2,2"},`y-grid-${N}`)),x.length>1&&a.jsx("polyline",{points:x.map(S=>`${S.x},${S.y}`).join(" "),fill:"none",stroke:"var(--accent)",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),e.slice().sort((S,N)=>(S.is_pareto?1:0)-(N.is_pareto?1:0)).map(S=>{const N=g(k(S)),_=b(S.avg_score),F=S.is_pareto,O=(o==null?void 0:o.candidate_name)===S.candidate_name;return a.jsxs("g",{onMouseEnter:B=>C(S,B),onMouseLeave:()=>c(null),children:[a.jsx("circle",{cx:N,cy:_,r:O?10:F?8:6,fill:F?"var(--accent)":"transparent",stroke:O?"var(--text-primary)":F?"var(--accent)":"var(--text-secondary)",strokeWidth:O?3:2,className:"cursor-pointer transition-all"}),F&&!O&&a.jsx("text",{x:N,y:_-12,textAnchor:"middle",fill:"var(--text-primary)",fontSize:10,className:"pointer-events-none",children:S.candidate_name.replace(/^baseline_/,"").slice(0,15)})]},S.candidate_name)}),a.jsx("line",{x1:0,y1:v,x2:m,y2:v,stroke:"var(--text-secondary)"}),p.map((S,N)=>a.jsxs("g",{transform:`translate(${g(S)}, ${v})`,children:[a.jsx("line",{y2:5,stroke:"var(--text-secondary)"}),a.jsx("text",{y:20,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:10,children:w(S)})]},`x-tick-${N}`)),a.jsx("text",{x:m/2,y:v+40,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:i==="tokens"?"Tokens (cost)":"Duration (latency)"}),a.jsx("line",{x1:0,y1:0,x2:0,y2:v,stroke:"var(--text-secondary)"}),h.map((S,N)=>a.jsxs("g",{transform:`translate(0, ${b(S)})`,children:[a.jsx("line",{x2:-5,stroke:"var(--text-secondary)"}),a.jsxs("text",{x:-10,textAnchor:"end",dominantBaseline:"middle",fill:"var(--text-secondary)",fontSize:10,children:[(S*100).toFixed(0),"%"]})]},`y-tick-${N}`)),a.jsx("text",{transform:`translate(-45, ${v/2}) rotate(-90)`,textAnchor:"middle",fill:"var(--text-secondary)",fontSize:11,children:"Score (quality)"})]})}),o&&a.jsxs("div",{className:"absolute z-10 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-lg shadow-lg p-3 text-sm pointer-events-none",style:{left:Math.min(u.x+15,r-200),top:u.y-10,maxWidth:220},children:[a.jsx("div",{className:"font-medium text-[var(--text-primary)] truncate mb-2",children:o.candidate_name.replace(/^baseline_/,"")}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs",children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Score:"}),a.jsxs("span",{className:"text-right font-medium",children:[(o.avg_score*100).toFixed(1),"%"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tokens:"}),a.jsxs("span",{className:"text-right",children:[(o.avg_tokens/1e3).toFixed(1),"K"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Duration:"}),a.jsxs("span",{className:"text-right",children:[o.avg_duration.toFixed(1),"s"]}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Pass rate:"}),a.jsxs("span",{className:"text-right",children:[o.passed_runs,"/",o.total_runs]})]}),o.is_pareto&&a.jsx("div",{className:"mt-2 pt-2 border-t border-[var(--border)] text-xs text-[var(--accent)]",children:"Optimal (best tradeoff)"})]})]})}function y1(e=2e3){const[t,n]=j.useState(!1),[r,s]=j.useState(null),i=j.useCallback(async o=>{try{return await navigator.clipboard.writeText(o),n(!0),s(null),setTimeout(()=>n(!1),e),!0}catch{return s("Failed to copy to clipboard"),n(!1),!1}},[e]),l=j.useCallback(()=>{n(!1),s(null)},[]);return{copy:i,copied:t,error:r,reset:l}}function g1({isOpen:e,onClose:t,title:n,itemId:r,itemType:s,isPublic:i,createdByName:l,onTogglePublic:o}){const[c,u]=j.useState(!1),{copy:d,copied:f}=y1(),m=`${window.location.origin}/${s}s/${r}`,v=async()=>{u(!0);try{await o(!i)}finally{u(!1)}},k=()=>{d(m)};return a.jsx(ss,{isOpen:e,onClose:t,title:n,children:a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between p-3 bg-[var(--bg-tertiary)] rounded",children:[a.jsxs("div",{className:"flex items-center gap-3",children:[i?a.jsx(Kc,{className:"w-5 h-5 text-[var(--accent)]"}):a.jsx($m,{className:"w-5 h-5 text-[var(--text-secondary)]"}),a.jsxs("div",{children:[a.jsx("div",{className:"font-medium",children:i?"Public":"Private"}),a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:i?"Anyone with the link can view":"Only you can access"})]})]}),a.jsx("button",{onClick:v,disabled:c,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${i?"bg-[var(--accent)]":"bg-[var(--border)]"} ${c?"opacity-50 cursor-not-allowed":""}`,children:a.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${i?"translate-x-6":"translate-x-1"}`})})]}),i&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"text-sm text-[var(--text-secondary)]",children:"Share link"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",readOnly:!0,value:m,className:"flex-1 px-3 py-2 bg-[var(--bg-primary)] border border-[var(--border)] rounded text-sm font-mono"}),a.jsx(Q,{variant:"secondary",onClick:k,children:f?a.jsxs(a.Fragment,{children:[a.jsx(Tg,{className:"w-4 h-4 mr-1"}),"Copied"]}):a.jsxs(a.Fragment,{children:[a.jsx(zg,{className:"w-4 h-4 mr-1"}),"Copy"]})})]})]}),l&&a.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",a.jsx("span",{className:"text-[var(--text-primary)]",children:l})]}),a.jsx("div",{className:"text-xs text-[var(--text-secondary)] pt-2 border-t border-[var(--border)]",children:i?a.jsxs(a.Fragment,{children:[a.jsxs("p",{children:["Public ",s,"s can be viewed by anyone with the link."]}),a.jsxs("p",{className:"mt-1",children:["Only you can edit or delete this ",s,"."]})]}):a.jsxs("p",{children:["Make this ",s," public to share it with others."]})})]})})}function j1({job:e,onUpdate:t}){const[n,r]=j.useState(!1),s=async i=>{await Ot.update(e.id,{is_public:i}),t()};return a.jsxs(a.Fragment,{children:[a.jsxs(Q,{variant:"secondary",size:"sm",onClick:()=>r(!0),title:e.is_public?"Sharing settings":"Share this job",children:[a.jsx(qg,{className:"w-4 h-4 mr-1"}),e.is_public?"Shared":"Share"]}),a.jsx(g1,{isOpen:n,onClose:()=>r(!1),title:"Share Job",itemId:e.id,itemType:"job",isPublic:e.is_public,createdByName:e.created_by_name,onTogglePublic:s})]})}function w1(){const{jobId:e}=fa(),t=zn(),n=Wt(),[r,s]=j.useState(null),[i,l]=j.useState(!1),[o,c]=j.useState(null),[u,d]=j.useState([]),[f,m]=j.useState(null),[v,k]=j.useState(null),[g,b]=j.useState("results"),[p,h]=j.useState("score"),[x,w]=j.useState("desc"),[C,S]=j.useState(!1),{data:N,isLoading:_}=le({queryKey:["jobs",e],queryFn:()=>Ot.get(e),enabled:!!e,refetchInterval:i?2e3:!1}),{data:F=[]}=le({queryKey:["runs",e],queryFn:()=>$o.list({job_id:e}),enabled:!!e,refetchInterval:i?2e3:!1}),{data:O}=le({queryKey:["job-summary",e],queryFn:()=>$o.getJobSummary(e),enabled:!!e&&(N==null?void 0:N.status)==="completed"}),B=Je({mutationFn:async()=>{l(!0),d([]),m(null),k(null);for await(const R of Ot.start(e))s(R),R.current_candidate&&R.current_task&&m(T=>(T&&(T.candidate!==R.current_candidate||T.task!==R.current_task)&&d(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),{candidate:R.current_candidate,task:R.current_task})),R.event==="error"&&(k(R.message),l(!1),n.invalidateQueries({queryKey:["jobs",e]})),R.event==="complete"&&(m(T=>(T&&d(te=>[...te,{candidate_name:T.candidate,task_name:T.task,completed_at:Date.now()}]),null)),l(!1),n.invalidateQueries({queryKey:["jobs",e]}),n.invalidateQueries({queryKey:["runs",e]}),n.invalidateQueries({queryKey:["job-summary",e]}))}}),G=Je({mutationFn:()=>Ot.cancel(e),onSuccess:()=>{l(!1),n.invalidateQueries({queryKey:["jobs",e]})}});j.useEffect(()=>{(N==null?void 0:N.status)==="running"&&l(!0)},[N==null?void 0:N.status]);const re=j.useMemo(()=>{const R=new Map;for(const T of F)R.has(T.task_name)||R.set(T.task_name,[]),R.get(T.task_name).push(T);return R},[F]),oe=j.useMemo(()=>Array.from(re.keys()),[re]);j.useEffect(()=>{!o&&oe.length>0&&c(oe[0])},[oe,o]);const D=j.useMemo(()=>{if(!(O!=null&&O.candidate_summaries))return[];let R=[...O.candidate_summaries];return C&&(R=R.filter(T=>T.is_pareto)),R.sort((T,te)=>{let pe,Se;switch(p){case"score":pe=T.avg_score,Se=te.avg_score;break;case"tokens":pe=T.avg_tokens,Se=te.avg_tokens;break;case"duration":pe=T.avg_duration,Se=te.avg_duration;break;case"pass_rate":pe=T.passed_runs/T.total_runs,Se=te.passed_runs/te.total_runs;break}return x==="desc"?Se-pe:pe-Se}),R},[O,p,x,C]),W=R=>{p===R?w(x==="desc"?"asc":"desc"):(h(R),w(R==="tokens"||R==="duration"?"asc":"desc"))},X=({label:R,sortKeyVal:T})=>a.jsx("th",{className:"pb-2 cursor-pointer hover:text-[var(--text-primary)] select-none",onClick:()=>W(T),children:a.jsxs("div",{className:"flex items-center gap-1",children:[R,p===T&&a.jsx(_g,{size:12,className:x==="asc"?"rotate-180":""})]})});if(_)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!N)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Job not found"});const P=Xc(),A=!N.user_id||N.user_id==="anonymous"||P&&N.created_by_name===P,L=N.is_public&&!A,V=()=>{n.invalidateQueries({queryKey:["jobs",e]})},ee=R=>{const T={pending:"default",running:"info",completed:"success",failed:"error",cancelled:"warning"};return a.jsx(q,{variant:T[R]||"default",children:R})};return a.jsxs("div",{children:[a.jsx(ma,{items:[{label:"Experiments",path:"/jobs"},{label:N.name||`Job ${N.id.slice(0,8)}`}]}),a.jsxs("div",{className:"flex items-center justify-between mb-6",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:N.name||`Job ${N.id.slice(0,8)}`}),ee(N.status),N.is_public&&a.jsxs(q,{variant:"info",children:[a.jsx(Kc,{className:"w-3 h-3 mr-1 inline"}),"Public"]})]}),a.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[a.jsxs("code",{className:"text-xs bg-[var(--bg-primary)] px-2 py-0.5 rounded font-mono text-[var(--text-secondary)]",children:[N.id.slice(0,8),"..."]}),a.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:[N.candidate_ids.length," candidates × ",N.task_ids.length," tasks = ",N.total_experiments," experiments"]}),N.is_public&&N.created_by_name&&a.jsxs("span",{className:"text-sm text-[var(--text-secondary)]",children:["Created by ",a.jsx("span",{className:"text-[var(--text-primary)]",children:N.created_by_name})]})]})]}),a.jsxs("div",{className:"flex gap-2",children:[A&&a.jsx(j1,{job:N,onUpdate:V}),L&&a.jsx(q,{variant:"default",children:"View Only"}),A&&N.status==="pending"&&a.jsx(Q,{variant:"primary",onClick:()=>B.mutate(),disabled:B.isPending,children:B.isPending?"Starting...":"Start"}),A&&N.status==="running"&&a.jsx(Q,{variant:"danger",onClick:()=>G.mutate(),disabled:G.isPending,children:"Cancel"})]})]}),(v||N.error)&&a.jsx(ge,{className:"mb-6 border-red-500/50 bg-red-500/10",children:a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:"w-5 h-5 rounded-full bg-red-500 flex items-center justify-center text-white text-xs font-bold flex-shrink-0 mt-0.5",children:"!"}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-red-400",children:"Error"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:v||N.error})]})]})}),(i||r)&&a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsx("span",{className:"font-medium",children:"Progress"}),a.jsxs("span",{className:"text-[var(--accent)]",children:[(r==null?void 0:r.completed)||N.completed_experiments,"/",(r==null?void 0:r.total)||N.total_experiments]})]}),a.jsx("div",{className:"w-full bg-[var(--bg-primary)] h-2 mb-2",children:a.jsx("div",{className:"h-full bg-[var(--accent)] transition-all",style:{width:`${((r==null?void 0:r.completed)||N.completed_experiments)/((r==null?void 0:r.total)||N.total_experiments)*100}%`}})}),(r==null?void 0:r.message)&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:r.message}),i&&a.jsxs("div",{className:"mt-4 border-t border-[var(--border)] pt-4",children:[(r==null?void 0:r.current_candidate)&&(r==null?void 0:r.current_task)&&a.jsxs("div",{className:"mb-3",children:[a.jsx("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:"Currently Running"}),a.jsxs("div",{className:"flex items-center gap-2 mt-1 px-3 py-2 bg-blue-500/10 border border-blue-500/30 rounded",children:[a.jsx("div",{className:"w-2 h-2 bg-blue-400 rounded-full animate-pulse"}),a.jsx("span",{className:"font-medium",children:r.current_candidate}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{children:r.current_task})]})]}),u.length>0&&a.jsxs("div",{children:[a.jsxs("span",{className:"text-xs text-[var(--text-secondary)] uppercase tracking-wider",children:["Completed (",u.length,")"]}),a.jsx("div",{className:"mt-1 max-h-40 overflow-y-auto space-y-1",children:u.map((R,T)=>a.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-green-500/10 border border-green-500/30 rounded text-sm",children:[a.jsx("div",{className:"w-2 h-2 bg-green-400 rounded-full"}),a.jsx("span",{className:"font-medium",children:R.candidate_name}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{children:R.task_name})]},`${R.candidate_name}-${R.task_name}-${T}`))})]})]})]}),(N.status==="completed"||F.length>0)&&a.jsxs("div",{className:"flex gap-1 mb-6 border-b border-[var(--border)]",children:[a.jsxs("button",{onClick:()=>b("results"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="results"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Eg,{size:16}),"Results"]}),a.jsxs("button",{onClick:()=>b("compare"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="compare"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Ig,{size:16}),"Compare"]}),a.jsxs("button",{onClick:()=>b("runs"),className:`flex items-center gap-2 px-4 py-2 text-sm font-medium border-b-2 transition-colors ${g==="runs"?"border-[var(--accent)] text-[var(--accent)]":"border-transparent text-[var(--text-secondary)] hover:text-[var(--text-primary)]"}`,children:[a.jsx(Ug,{size:16}),"Runs (",F.length,")"]})]}),g==="results"&&a.jsxs(a.Fragment,{children:[O&&O.candidate_summaries.length>1&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("div",{className:"flex items-start justify-between mb-4",children:a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium",children:"Quality vs. Cost Tradeoff"}),a.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:["Candidates on the frontier (connected line) are ",a.jsx("strong",{children:"optimal"})," - no other candidate beats them on both score AND cost."]})]})}),a.jsxs("div",{className:"mb-4 p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] text-xs text-[var(--text-secondary)]",children:[a.jsx("strong",{className:"text-[var(--text-primary)]",children:"How optimal tradeoffs are calculated:"})," A candidate is optimal if there's no other candidate that has both a higher score AND lower cost. For example, if Candidate A has 95% score at 50K tokens and Candidate B has 90% score at 40K tokens, both are optimal - A is better on score, B is better on cost. But if Candidate C has 85% score at 60K tokens, it's ",a.jsx("em",{children:"not"})," optimal because B beats it on both metrics."]}),a.jsx(v1,{summaries:O.candidate_summaries,height:350})]}),O&&a.jsxs(ge,{className:"mb-6",children:[a.jsxs("div",{className:"flex items-center justify-between mb-4",children:[a.jsx("h3",{className:"font-medium",children:"Results Summary"}),a.jsxs("label",{className:"flex items-center gap-2 text-sm text-[var(--text-secondary)] cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:C,onChange:R=>S(R.target.checked),className:"rounded border-[var(--border)]"}),"Optimal only"]})]}),a.jsx("div",{className:"overflow-x-auto",children:a.jsxs("table",{className:"w-full text-sm",children:[a.jsx("thead",{children:a.jsxs("tr",{className:"text-left text-[var(--text-secondary)] border-b border-[var(--border)]",children:[a.jsx("th",{className:"pb-2",children:"Candidate"}),a.jsx(X,{label:"Score",sortKeyVal:"score"}),a.jsx(X,{label:"Tokens",sortKeyVal:"tokens"}),a.jsx(X,{label:"Duration",sortKeyVal:"duration"}),a.jsx(X,{label:"Pass Rate",sortKeyVal:"pass_rate"}),a.jsx("th",{className:"pb-2",children:"Optimal"})]})}),a.jsx("tbody",{children:D.map((R,T)=>a.jsxs("tr",{className:`border-b border-[var(--border)] ${T===0?"bg-[var(--accent)]/10":""}`,children:[a.jsxs("td",{className:"py-2 font-medium",children:[T===0&&a.jsx("span",{className:"text-[var(--accent)] mr-1",children:"#1"}),R.candidate_name.replace(/^baseline_/,"")]}),a.jsxs("td",{className:"py-2",children:[(R.avg_score*100).toFixed(1),"%"]}),a.jsxs("td",{className:"py-2",children:[(R.avg_tokens/1e3).toFixed(1),"K"]}),a.jsxs("td",{className:"py-2",children:[R.avg_duration.toFixed(1),"s"]}),a.jsxs("td",{className:"py-2",children:[R.passed_runs,"/",R.total_runs]}),a.jsx("td",{className:"py-2",children:R.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})})]},R.candidate_name))})]})}),a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mt-3",children:"Click column headers to sort. The #1 ranked candidate is highlighted based on your sort criteria."})]}),!O&&a.jsx(ge,{children:a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Results will appear here after the job completes.":"No results yet. Start the job to see results."})})]}),g==="compare"&&a.jsxs(ge,{children:[a.jsx("h3",{className:"font-medium mb-4",children:"Compare Candidates by Task"}),oe.length>0?a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:oe.map(R=>a.jsx("button",{onClick:()=>c(o===R?null:R),className:`px-3 py-1 text-sm rounded border transition-colors ${o===R?"bg-[var(--accent)] text-white border-[var(--accent)]":"border-[var(--border)] hover:border-[var(--accent-dim)]"}`,children:R},R))}),o&&re.get(o)?a.jsx(x1,{runs:re.get(o).map(R=>({id:R.id,candidate_name:R.candidate_name,tokens_input:0,tokens_output:0,tokens_total:R.tokens_total,duration_seconds:R.duration_seconds,score:R.score,passed:R.passed,is_pareto:R.is_pareto}))}):a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:"Select a task above to compare how different candidates performed on it."})]}):a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Comparison data will appear here after runs complete.":"No runs yet. Start the job to compare candidates."})]}),g==="runs"&&a.jsxs(ge,{children:[a.jsx("h3",{className:"font-medium mb-4",children:"All Experiment Runs"}),F.length===0?a.jsx("div",{className:"text-center py-8 text-[var(--text-secondary)]",children:i?"Runs will appear here as they complete. See progress above for live status.":"No runs yet. Start the job to see results."}):a.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:F.map(R=>a.jsxs("div",{className:"p-3 bg-[var(--bg-primary)] rounded border border-[var(--border)] cursor-pointer hover:border-[var(--accent-dim)] transition-colors",onClick:()=>t(`/runs/${R.id}`),children:[a.jsxs("div",{className:"flex items-center justify-between mb-2",children:[a.jsxs("span",{className:`text-lg font-bold ${R.passed?"text-green-400":"text-red-400"}`,children:[(R.score*100).toFixed(0),"%"]}),R.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})]}),a.jsx("div",{className:"text-sm font-medium truncate",title:R.candidate_name,children:R.candidate_name.replace(/^baseline_/,"")}),a.jsx("div",{className:"text-xs text-[var(--text-secondary)] truncate",children:R.task_name}),a.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:[(R.tokens_total/1e3).toFixed(1),"K tokens"]}),a.jsxs("span",{children:[R.duration_seconds.toFixed(1),"s"]})]})]},R.id))})]})]})}const xn={input:"bg-blue-500",output:"bg-emerald-500",inputText:"text-blue-400",outputText:"text-emerald-400"};function Id(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Dd({input:e,output:t,maxValue:n,height:r=24,showLabels:s=!0}){const i=e+t;if(i===0)return a.jsx("div",{className:"flex items-center gap-2 w-full",children:a.jsx("div",{className:"rounded bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`}})});const l=n>0?i/n*100:100;return a.jsxs("div",{className:"flex items-center gap-3 w-full",children:[a.jsx("div",{className:"relative rounded overflow-hidden bg-[var(--bg-primary)] flex-1",style:{height:`${r}px`},children:a.jsxs("div",{className:"h-full flex transition-all duration-300",style:{width:`${l}%`},children:[a.jsx("div",{className:`h-full ${xn.input} transition-all`,style:{width:`${e/i*100}%`},title:`Input: ${e.toLocaleString()} tokens`}),a.jsx("div",{className:`h-full ${xn.output} transition-all`,style:{width:`${t/i*100}%`},title:`Output: ${t.toLocaleString()} tokens`})]})}),s&&a.jsxs("div",{className:"flex items-center gap-1 text-xs font-mono text-[var(--text-secondary)] min-w-[90px] justify-end",children:[a.jsxs("span",{className:xn.inputText,children:["↑",Id(e)]}),a.jsx("span",{children:"/"}),a.jsxs("span",{className:xn.outputText,children:["↓",Id(t)]})]})]})}function Sl({label:e,value:t,color:n="default"}){const r={default:"text-[var(--text-primary)]",input:xn.inputText,output:xn.outputText}[n];return a.jsxs("div",{className:"flex-1 p-3 bg-[var(--bg-primary)] border border-[var(--border)] rounded",children:[a.jsx("div",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e}),a.jsx("div",{className:`font-mono text-lg font-bold ${r}`,children:t})]})}function ap({tokensInput:e,tokensOutput:t,tokensTotal:n,turns:r}){const s=n>0?Math.round(e/n*100):0,i=n>0?Math.round(t/n*100):0,l=j.useMemo(()=>{if(!r||r.length===0)return null;let c=0,u=0;return r.map(d=>(c+=d.input,u+=d.output,{input:c,output:u,total:c+u}))},[r]),o=l?Math.max(...l.map(c=>c.total)):n;return a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-4",children:"Token Usage"}),a.jsx("div",{className:"mb-4",children:a.jsx(Dd,{input:e,output:t,maxValue:n,height:32})}),a.jsxs("div",{className:"flex items-center gap-6 text-xs mb-4",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-3 h-3 rounded ${xn.input}`}),a.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Input (",s,"%)"]})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("div",{className:`w-3 h-3 rounded ${xn.output}`}),a.jsxs("span",{className:"text-[var(--text-secondary)]",children:["Output (",i,"%)"]})]})]}),a.jsxs("div",{className:"flex gap-3 mb-4",children:[a.jsx(Sl,{label:"Input Tokens",value:e.toLocaleString(),color:"input"}),a.jsx(Sl,{label:"Output Tokens",value:t.toLocaleString(),color:"output"}),a.jsx(Sl,{label:"Total Tokens",value:n.toLocaleString()})]}),l&&l.length>1&&a.jsxs("div",{className:"border-t border-[var(--border)] pt-4",children:[a.jsxs("h4",{className:"text-sm font-medium mb-3 text-[var(--text-secondary)]",children:["Token Accumulation (",r.length," turns)"]}),a.jsx("div",{className:"space-y-2",children:r.map((c,u)=>a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("div",{className:"w-6 h-6 rounded-full bg-[var(--bg-primary)] border border-[var(--border)] flex items-center justify-center text-xs font-medium",children:u+1}),a.jsx("div",{className:"flex-1",children:a.jsx(Dd,{input:l[u].input,output:l[u].output,maxValue:o,height:16})})]},u))})]}),a.jsx("div",{className:"mt-4 text-xs text-[var(--text-secondary)] border-t border-[var(--border)] pt-3",children:"Token usage affects API cost. Input tokens are typically cheaper than output tokens."})]})}function k1(){const{runId:e}=fa(),{data:t,isLoading:n}=le({queryKey:["runs",e],queryFn:()=>$o.get(e),enabled:!!e});return n?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsx(ma,{items:[{label:"Experiments",path:"/jobs"},{label:"Job",path:`/jobs/${t.job_id}`},{label:t.candidate_name}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:t.candidate_name}),a.jsx("span",{className:"text-[var(--text-secondary)]",children:"→"}),a.jsx("span",{className:"text-lg",children:t.task_name}),t.is_pareto&&a.jsx(q,{variant:"success",children:"Optimal"})]})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[a.jsx(Ma,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),a.jsx(Ma,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),a.jsx(Ma,{label:"Duration",value:`${t.duration_seconds.toFixed(1)}s`}),a.jsx(Ma,{label:"Status",value:t.passed?"Passed":"Failed",status:t.passed?"success":"error"})]}),a.jsx(ap,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),t.reasoning&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mb-4",children:t.reasoning}),t.criteria_results.length>0&&a.jsx("div",{className:"space-y-2",children:t.criteria_results.map(r=>a.jsx("div",{className:"flex items-start justify-between p-3 bg-[var(--bg-primary)] border border-[var(--border)]",children:a.jsxs("div",{className:"flex-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("span",{className:"font-medium",children:r.name}),a.jsxs(q,{variant:r.passed?"success":"error",children:[(r.score*100).toFixed(0),"%"]})]}),r.reasoning&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:r.reasoning})]})},r.name))})]}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created.length>0&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),a.jsx("div",{className:"space-y-1",children:t.files_created.map(r=>a.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:r},r))})]}),Object.keys(t.trace).length>0&&a.jsx(tp,{trace:t.trace})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Run not found"})}function Ma({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return a.jsxs(ge,{children:[a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),a.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function b1(){const{testId:e}=fa(),{data:t,isLoading:n}=le({queryKey:["tests",e],queryFn:()=>Os.get(e),enabled:!!e}),{data:r}=le({queryKey:["configs",t==null?void 0:t.agent_id],queryFn:()=>_n.get(t.agent_id),enabled:!!(t!=null&&t.agent_id)});if(n)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."});if(!t)return a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Test not found"});const s={completed:"success",failed:"error",running:"info",pending:"default",cancelled:"warning"};return a.jsxs("div",{children:[a.jsxs("div",{className:"mb-6",children:[a.jsx(ma,{items:[{label:"Agents",path:"/agents"},...r?[{label:r.name,path:`/agents/${r.id}`}]:[],{label:`Test ${t.id.slice(0,8)}`}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx("h2",{className:"text-xl font-bold",children:"Test Run"}),r&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"•"}),a.jsx("span",{className:"text-lg",children:r.name})]}),a.jsx(q,{variant:s[t.status]||"default",children:t.status})]}),a.jsxs("p",{className:"text-sm text-[var(--text-secondary)] mt-1 font-mono",children:["ID: ",t.id.slice(0,8),"..."]})]}),a.jsxs("div",{className:"grid grid-cols-4 gap-4 mb-6",children:[a.jsx(za,{label:"Duration",value:`${t.duration_seconds.toFixed(2)}s`}),a.jsx(za,{label:"Total Tokens",value:t.tokens_total.toLocaleString()}),t.score!==null&&a.jsx(za,{label:"Score",value:`${(t.score*100).toFixed(1)}%`,status:t.passed?"success":"error"}),a.jsx(za,{label:"Status",value:t.status.charAt(0).toUpperCase()+t.status.slice(1),status:t.status==="completed"?"success":t.status==="failed"?"error":void 0})]}),a.jsx(ap,{tokensInput:t.tokens_input,tokensOutput:t.tokens_output,tokensTotal:t.tokens_total}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Prompt"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)] font-mono",children:t.prompt})]}),t.error&&a.jsxs(ge,{className:"mb-6 border-red-500/30 bg-red-500/5",children:[a.jsx("h3",{className:"font-medium mb-3 text-red-400",children:"Error"}),a.jsx("pre",{className:"text-sm text-red-300 overflow-x-auto whitespace-pre-wrap",children:t.error})]}),t.reasoning&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Evaluation"}),a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:t.reasoning})]}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Agent Output"}),a.jsx("pre",{className:"text-sm bg-[var(--bg-primary)] p-3 overflow-x-auto whitespace-pre-wrap border border-[var(--border)]",children:t.output||"(no output)"})]}),t.files_created&&t.files_created.length>0&&a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Files Created"}),a.jsx("div",{className:"space-y-1",children:t.files_created.map(i=>a.jsx("div",{className:"text-sm font-mono text-[var(--text-secondary)]",children:i},i))})]}),t.trace&&Object.keys(t.trace).length>0&&a.jsx(tp,{trace:t.trace}),a.jsxs(ge,{className:"mb-6",children:[a.jsx("h3",{className:"font-medium mb-3",children:"Timestamps"}),a.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Created:"}),a.jsx("div",{className:"font-mono",children:new Date(t.created_at).toLocaleString()})]}),t.started_at&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Started:"}),a.jsx("div",{className:"font-mono",children:new Date(t.started_at).toLocaleString()})]}),t.completed_at&&a.jsxs("div",{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Completed:"}),a.jsx("div",{className:"font-mono",children:new Date(t.completed_at).toLocaleString()})]})]})]})]})}function za({label:e,value:t,status:n}){const r={success:"text-green-400",error:"text-red-400"};return a.jsxs(ge,{children:[a.jsx("div",{className:"text-sm text-[var(--text-secondary)]",children:e}),a.jsx("div",{className:`text-xl font-bold ${n?r[n]:""}`,children:t})]})}function N1(){const{deploymentId:e}=fa(),{data:t,isLoading:n}=le({queryKey:["deployments",e],queryFn:()=>E0.get(e),enabled:!!e}),r=t==null?void 0:t.versions.find(i=>i.id===t.current_version_id),{data:s}=le({queryKey:["configs",r==null?void 0:r.config_id],queryFn:()=>_n.get(r.config_id),enabled:!!(r!=null&&r.config_id)});return n?a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Loading..."}):t?a.jsxs("div",{className:"h-full flex flex-col",children:[a.jsxs("div",{className:"mb-4 flex-shrink-0",children:[a.jsx(ma,{items:[{label:"Agents",path:"/agents"},{label:t.name}]}),a.jsxs("div",{className:"flex items-center gap-3",children:[a.jsx(Kg,{size:20,className:"text-[var(--accent)]"}),a.jsx("h2",{className:"text-xl font-bold",children:t.name}),r&&a.jsxs(q,{variant:"info",children:["v",r.version]})]}),t.description&&a.jsx("p",{className:"text-sm text-[var(--text-secondary)] mt-1",children:t.description})]}),a.jsxs("div",{className:"flex-1 flex gap-4 min-h-0",children:[a.jsx("div",{className:"w-[420px] flex-shrink-0 flex flex-col min-h-0 border-r border-[var(--border)] pr-4",children:a.jsxs("div",{className:"flex-1 overflow-y-auto space-y-5",children:[a.jsxs("div",{className:"flex items-center gap-4 text-xs text-[var(--text-secondary)]",children:[a.jsxs("span",{children:["Created ",new Date(t.created_at).toLocaleDateString()]}),a.jsxs("span",{children:["Updated ",new Date(t.updated_at).toLocaleDateString()]}),a.jsxs("span",{children:[t.versions.length," version",t.versions.length!==1?"s":""]})]}),s&&a.jsxs(Tn,{to:`/agents/${s.id}`,className:"flex items-center gap-2 p-3 bg-[var(--bg-secondary)] border border-[var(--border)] rounded-md hover:border-[var(--accent-dim)] transition-colors text-sm",children:[a.jsx(Am,{size:14,className:"text-[var(--accent)]"}),a.jsxs("span",{children:["Agent: ",a.jsx("span",{className:"font-medium",children:s.name})]})]}),a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider mb-3",children:"Version History"}),t.versions.length===0?a.jsx("p",{className:"text-sm text-[var(--text-secondary)]",children:"No versions yet."}):a.jsx("div",{className:"space-y-2",children:t.versions.map(i=>a.jsx(S1,{version:i,isActive:i.id===t.current_version_id},i.id))})]})]})}),a.jsxs("div",{className:"flex-1 flex flex-col min-h-0 min-w-0",children:[a.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-shrink-0",children:[a.jsx(Um,{size:16,className:"text-[var(--text-secondary)]"}),a.jsx("h3",{className:"text-sm font-medium text-[var(--text-secondary)] uppercase tracking-wider",children:"Playground"})]}),a.jsx("div",{className:"flex-1 min-h-0",children:s?a.jsx(np,{agent:s}):a.jsx("div",{className:"flex items-center justify-center h-full text-[var(--text-secondary)] text-sm",children:r?"Loading agent configuration...":"No active version to test."})})]})]})]}):a.jsx("div",{className:"text-[var(--text-secondary)]",children:"Deployment not found"})}function S1({version:e,isActive:t}){const n=e.config_snapshot;return a.jsxs("div",{className:`p-3 rounded-md border transition-colors ${t?"border-[var(--accent)] bg-[var(--accent-dim)]":"border-[var(--border)] bg-[var(--bg-secondary)]"}`,children:[a.jsxs("div",{className:"flex items-center justify-between mb-1",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(Jg,{size:12,className:"text-[var(--text-secondary)]"}),a.jsxs("span",{className:"text-sm font-medium",children:["v",e.version]}),t&&a.jsx(q,{variant:"success",children:"Active"}),a.jsx(q,{variant:e.source==="optimize"?"info":"default",children:e.source})]}),a.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)]",children:[a.jsx(Im,{size:11}),a.jsx("span",{children:new Date(e.created_at).toLocaleString()})]})]}),e.description&&a.jsx("p",{className:"text-xs text-[var(--text-secondary)] mb-1",children:e.description}),Object.keys(n).length>0&&a.jsxs("div",{className:"mt-1",children:[a.jsxs("div",{className:"flex items-center gap-1 text-xs text-[var(--text-secondary)] mb-1",children:[a.jsx(Fg,{size:11}),a.jsx("span",{children:"Config"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-0.5 text-xs",children:["framework"in n&&n.framework?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Framework"}),a.jsx("span",{className:"font-mono",children:String(n.framework)})]}):null,"model"in n&&n.model?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Model"}),a.jsx("span",{className:"font-mono",children:String(n.model)})]}):null,"tools"in n&&n.tools?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"text-[var(--text-secondary)]",children:"Tools"}),a.jsx("span",{className:"font-mono truncate",children:Array.isArray(n.tools)?n.tools.join(", "):String(n.tools)})]}):null]})]})]})}function C1(){const{authConfig:e,isLoading:t,error:n,login:r,loginWithGitHub:s,clearError:i}=Zc(),[l,o]=j.useState(""),[c,u]=j.useState("");j.useEffect(()=>{n&&i()},[l,c]);const d=async m=>{m.preventDefault(),!(!l||!c)&&await r(l,c)},f=()=>{s()};return a.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center p-4",children:a.jsxs("div",{className:"w-full max-w-md",children:[a.jsxs("div",{className:"text-center mb-8",children:[a.jsx("h1",{className:"text-2xl font-bold text-[var(--text-primary)] mb-2",children:"Flow"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:"Sign in to access the optimization dashboard"})]}),a.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border)] p-6 space-y-6",children:[n&&a.jsxs("div",{className:"flex items-start gap-3 p-3 bg-[var(--error)]/10 border border-[var(--error)]/20 text-[var(--error)]",children:[a.jsx(zm,{size:18,className:"mt-0.5 flex-shrink-0"}),a.jsx("p",{className:"text-sm",children:n})]}),(e==null?void 0:e.mode)==="basic"&&a.jsxs("form",{onSubmit:d,className:"space-y-4",children:[a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Username"}),a.jsxs("div",{className:"relative",children:[a.jsx(Qm,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),a.jsx("input",{type:"text",value:l,onChange:m=>o(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter username",autoComplete:"username",autoFocus:!0})]})]}),a.jsxs("div",{className:"space-y-1",children:[a.jsx("label",{className:"block text-sm text-[var(--text-secondary)]",children:"Password"}),a.jsxs("div",{className:"relative",children:[a.jsx($m,{size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[var(--text-tertiary)]"}),a.jsx("input",{type:"password",value:c,onChange:m=>u(m.target.value),className:"w-full bg-[var(--bg-primary)] border border-[var(--border)] pl-10 pr-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]",placeholder:"Enter password",autoComplete:"current-password"})]})]}),a.jsx(Q,{type:"submit",variant:"primary",className:"w-full justify-center",loading:t,disabled:!l||!c,children:"Sign In"})]}),(e==null?void 0:e.mode)==="github"&&a.jsxs("div",{className:"space-y-4",children:[a.jsx("p",{className:"text-sm text-[var(--text-secondary)] text-center",children:"Sign in with your GitHub account to continue"}),a.jsx(Q,{onClick:f,variant:"secondary",className:"w-full justify-center",icon:Dg,children:"Continue with GitHub"})]})]})]})})}function _1({children:e}){const{authConfig:t,isLoadingConfig:n,isAuthenticated:r,loadAuthConfig:s,handleOAuthCallback:i}=Zc();return j.useEffect(()=>{s()},[s]),j.useEffect(()=>{n||i()},[n,i]),n?a.jsx("div",{className:"min-h-screen bg-[var(--bg-primary)] flex items-center justify-center",children:a.jsxs("div",{className:"text-center",children:[a.jsx(ha,{className:"w-8 h-8 animate-spin text-[var(--accent)] mx-auto mb-4"}),a.jsx("p",{className:"text-[var(--text-secondary)]",children:"Loading..."})]})}):t!=null&&t.enabled&&!r?a.jsx(C1,{}):a.jsx(a.Fragment,{children:e})}function E1(){return a.jsx(vg,{children:a.jsx(_1,{children:a.jsx(cg,{children:a.jsxs(ht,{path:"/",element:a.jsx($0,{}),children:[a.jsx(ht,{index:!0,element:a.jsx(B0,{})}),a.jsx(ht,{path:"agents",element:a.jsx(X0,{})}),a.jsx(ht,{path:"agents/:agentId",element:a.jsx(a1,{})}),a.jsx(ht,{path:"tasks",element:a.jsx(c1,{})}),a.jsx(ht,{path:"jobs",element:a.jsx(h1,{})}),a.jsx(ht,{path:"jobs/:jobId",element:a.jsx(w1,{})}),a.jsx(ht,{path:"runs/:runId",element:a.jsx(k1,{})}),a.jsx(ht,{path:"tests/:testId",element:a.jsx(b1,{})}),a.jsx(ht,{path:"deployments/:deploymentId",element:a.jsx(N1,{})})]})})})})}const Ad=localStorage.getItem("flow-theme");if(Ad)try{const{state:e}=JSON.parse(Ad);e!=null&&e.theme&&document.documentElement.setAttribute("data-theme",e.theme)}catch{}const P1=new sy({defaultOptions:{queries:{staleTime:5e3,refetchOnWindowFocus:!1}}});Cl.createRoot(document.getElementById("root")).render(a.jsx(Wo.StrictMode,{children:a.jsx(ay,{client:P1,children:a.jsx(E1,{})})})); diff --git a/src/flow/ui/ui/assets/index-tuJIApaC.css b/src/flow/ui/ui/assets/index-tuJIApaC.css new file mode 100644 index 0000000000000000000000000000000000000000..c93b3fa9b667339b8fb44cc7dac18144d2f0dc44 --- /dev/null +++ b/src/flow/ui/ui/assets/index-tuJIApaC.css @@ -0,0 +1 @@ +*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:Segoe UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:JetBrains Mono,ui-monospace,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.sticky{position:sticky}.inset-0{top:0;right:0;bottom:0;left:0}.bottom-0{bottom:0}.bottom-1{bottom:.25rem}.left-0{left:0}.left-3{left:.75rem}.top-0{top:0}.top-1{top:.25rem}.top-1\/2{top:50%}.z-10{z-index:10}.z-50{z-index:50}.mx-0\.5{margin-left:.125rem;margin-right:.125rem}.mx-4{margin-left:1rem;margin-right:1rem}.mx-auto{margin-left:auto;margin-right:auto}.-mb-px{margin-bottom:-1px}.-mt-2{margin-top:-.5rem}.mb-1{margin-bottom:.25rem}.mb-1\.5{margin-bottom:.375rem}.mb-2{margin-bottom:.5rem}.mb-3{margin-bottom:.75rem}.mb-4{margin-bottom:1rem}.mb-6{margin-bottom:1.5rem}.mb-8{margin-bottom:2rem}.ml-1{margin-left:.25rem}.ml-2{margin-left:.5rem}.ml-3{margin-left:.75rem}.ml-4{margin-left:1rem}.ml-6{margin-left:1.5rem}.mr-1{margin-right:.25rem}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.mt-2{margin-top:.5rem}.mt-3{margin-top:.75rem}.mt-4{margin-top:1rem}.line-clamp-1{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.h-12{height:3rem}.h-2{height:.5rem}.h-3{height:.75rem}.h-32{height:8rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-full{height:100%}.h-screen{height:100vh}.max-h-32{max-height:8rem}.max-h-40{max-height:10rem}.max-h-48{max-height:12rem}.max-h-80{max-height:20rem}.max-h-96{max-height:24rem}.max-h-\[120px\]{max-height:120px}.max-h-\[80vh\]{max-height:80vh}.min-h-0{min-height:0px}.min-h-\[100px\]{min-height:100px}.min-h-\[200px\]{min-height:200px}.min-h-\[40px\]{min-height:40px}.min-h-screen{min-height:100vh}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-2{width:.5rem}.w-20{width:5rem}.w-24{width:6rem}.w-3{width:.75rem}.w-32{width:8rem}.w-4{width:1rem}.w-40{width:10rem}.w-5{width:1.25rem}.w-56{width:14rem}.w-6{width:1.5rem}.w-7{width:1.75rem}.w-8{width:2rem}.w-\[350px\]{width:350px}.w-\[3px\]{width:3px}.w-\[420px\]{width:420px}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-\[90px\]{min-width:90px}.max-w-2xl{max-width:42rem}.max-w-4xl{max-width:56rem}.max-w-\[80\%\]{max-width:80%}.max-w-full{max-width:100%}.max-w-lg{max-width:32rem}.max-w-md{max-width:28rem}.max-w-sm{max-width:24rem}.flex-1{flex:1 1 0%}.flex-shrink-0,.shrink-0{flex-shrink:0}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-1{--tw-translate-x: .25rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.translate-x-6{--tw-translate-x: 1.5rem;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-90{--tw-rotate: 90deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes pulse{50%{opacity:.5}}.animate-pulse{animation:pulse 2s cubic-bezier(.4,0,.6,1) infinite}@keyframes spin{to{transform:rotate(360deg)}}.animate-spin{animation:spin 1s linear infinite}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.resize-none{resize:none}.resize-y{resize:vertical}.resize{resize:both}.list-disc{list-style-type:disc}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}.grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-start{align-items:flex-start}.items-end{align-items:flex-end}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.gap-4{gap:1rem}.gap-6{gap:1.5rem}.gap-x-4{-moz-column-gap:1rem;column-gap:1rem}.gap-y-0\.5{row-gap:.125rem}.gap-y-1{row-gap:.25rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-1\.5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.space-y-5>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.25rem * var(--tw-space-y-reverse))}.space-y-6>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-full{border-radius:9999px}.rounded-lg{border-radius:.5rem}.rounded-md{border-radius:.375rem}.rounded-r{border-top-right-radius:.25rem;border-bottom-right-radius:.25rem}.border{border-width:1px}.border-b{border-bottom-width:1px}.border-b-2{border-bottom-width:2px}.border-l-2{border-left-width:2px}.border-r{border-right-width:1px}.border-t{border-top-width:1px}.border-\[var\(--accent\)\]{border-color:var(--accent)}.border-\[var\(--badge-error-border\)\]{border-color:var(--badge-error-border)}.border-\[var\(--badge-info-border\)\]{border-color:var(--badge-info-border)}.border-\[var\(--badge-success-border\)\]{border-color:var(--badge-success-border)}.border-\[var\(--badge-warning-border\)\]{border-color:var(--badge-warning-border)}.border-\[var\(--border\)\]{border-color:var(--border)}.border-blue-500\/30{border-color:#3b82f64d}.border-green-500\/30{border-color:#22c55e4d}.border-green-500\/50{border-color:#22c55e80}.border-red-500\/30{border-color:#ef44444d}.border-red-500\/50{border-color:#ef444480}.border-transparent{border-color:transparent}.bg-\[var\(--accent\)\]{background-color:var(--accent)}.bg-\[var\(--accent-dim\)\]{background-color:var(--accent-dim)}.bg-\[var\(--badge-error-bg\)\]{background-color:var(--badge-error-bg)}.bg-\[var\(--badge-info-bg\)\]{background-color:var(--badge-info-bg)}.bg-\[var\(--badge-success-bg\)\]{background-color:var(--badge-success-bg)}.bg-\[var\(--badge-warning-bg\)\]{background-color:var(--badge-warning-bg)}.bg-\[var\(--bg-primary\)\]{background-color:var(--bg-primary)}.bg-\[var\(--bg-secondary\)\]{background-color:var(--bg-secondary)}.bg-\[var\(--bg-tertiary\)\]{background-color:var(--bg-tertiary)}.bg-\[var\(--border\)\]{background-color:var(--border)}.bg-\[var\(--error\)\]{background-color:var(--error)}.bg-\[var\(--span-agent-bg\)\]{background-color:var(--span-agent-bg)}.bg-\[var\(--span-fail-bg\)\]{background-color:var(--span-fail-bg)}.bg-\[var\(--span-llm-bg\)\]{background-color:var(--span-llm-bg)}.bg-\[var\(--span-other-bg\)\]{background-color:var(--span-other-bg)}.bg-\[var\(--span-pass-bg\)\]{background-color:var(--span-pass-bg)}.bg-\[var\(--span-tool-bg\)\]{background-color:var(--span-tool-bg)}.bg-black\/50{background-color:#00000080}.bg-blue-400{--tw-bg-opacity: 1;background-color:rgb(96 165 250 / var(--tw-bg-opacity, 1))}.bg-blue-500{--tw-bg-opacity: 1;background-color:rgb(59 130 246 / var(--tw-bg-opacity, 1))}.bg-blue-500\/10{background-color:#3b82f61a}.bg-emerald-500{--tw-bg-opacity: 1;background-color:rgb(16 185 129 / var(--tw-bg-opacity, 1))}.bg-green-400{--tw-bg-opacity: 1;background-color:rgb(74 222 128 / var(--tw-bg-opacity, 1))}.bg-green-500{--tw-bg-opacity: 1;background-color:rgb(34 197 94 / var(--tw-bg-opacity, 1))}.bg-green-500\/10{background-color:#22c55e1a}.bg-green-500\/20{background-color:#22c55e33}.bg-red-500{--tw-bg-opacity: 1;background-color:rgb(239 68 68 / var(--tw-bg-opacity, 1))}.bg-red-500\/10{background-color:#ef44441a}.bg-red-500\/5{background-color:#ef44440d}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity, 1))}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.p-6{padding:1.5rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-1\.5{padding-left:.375rem;padding-right:.375rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-1\.5{padding-top:.375rem;padding-bottom:.375rem}.py-12{padding-top:3rem;padding-bottom:3rem}.py-16{padding-top:4rem;padding-bottom:4rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.py-8{padding-top:2rem;padding-bottom:2rem}.pb-2{padding-bottom:.5rem}.pb-3{padding-bottom:.75rem}.pl-10{padding-left:2.5rem}.pl-9{padding-left:2.25rem}.pr-3{padding-right:.75rem}.pr-4{padding-right:1rem}.pt-2{padding-top:.5rem}.pt-3{padding-top:.75rem}.pt-4{padding-top:1rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-mono{font-family:JetBrains Mono,ui-monospace,monospace}.text-2xl{font-size:1.5rem;line-height:2rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-normal{font-weight:400}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.capitalize{text-transform:capitalize}.italic{font-style:italic}.tracking-wide{letter-spacing:.025em}.tracking-wider{letter-spacing:.05em}.text-\[var\(--accent\)\]{color:var(--accent)}.text-\[var\(--badge-error-text\)\]{color:var(--badge-error-text)}.text-\[var\(--badge-info-text\)\]{color:var(--badge-info-text)}.text-\[var\(--badge-success-text\)\]{color:var(--badge-success-text)}.text-\[var\(--badge-warning-text\)\]{color:var(--badge-warning-text)}.text-\[var\(--border\)\]{color:var(--border)}.text-\[var\(--error\)\]{color:var(--error)}.text-\[var\(--span-agent-text\)\]{color:var(--span-agent-text)}.text-\[var\(--span-fail-text\)\]{color:var(--span-fail-text)}.text-\[var\(--span-llm-text\)\]{color:var(--span-llm-text)}.text-\[var\(--span-other-text\)\]{color:var(--span-other-text)}.text-\[var\(--span-pass-text\)\]{color:var(--span-pass-text)}.text-\[var\(--span-tool-text\)\]{color:var(--span-tool-text)}.text-\[var\(--success\)\]{color:var(--success)}.text-\[var\(--text-primary\)\]{color:var(--text-primary)}.text-\[var\(--text-secondary\)\]{color:var(--text-secondary)}.text-\[var\(--text-tertiary\)\]{color:var(--text-tertiary)}.text-black{--tw-text-opacity: 1;color:rgb(0 0 0 / var(--tw-text-opacity, 1))}.text-blue-400{--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.text-emerald-400{--tw-text-opacity: 1;color:rgb(52 211 153 / var(--tw-text-opacity, 1))}.text-green-400{--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.text-green-500{--tw-text-opacity: 1;color:rgb(34 197 94 / var(--tw-text-opacity, 1))}.text-purple-400{--tw-text-opacity: 1;color:rgb(192 132 252 / var(--tw-text-opacity, 1))}.text-red-300{--tw-text-opacity: 1;color:rgb(252 165 165 / var(--tw-text-opacity, 1))}.text-red-400{--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.text-yellow-500{--tw-text-opacity: 1;color:rgb(234 179 8 / var(--tw-text-opacity, 1))}.accent-\[var\(--accent\)\]{accent-color:var(--accent)}.opacity-50{opacity:.5}.shadow-lg{--tw-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-xl{--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.duration-300{transition-duration:.3s}:root{--bg-primary: #ffffff;--bg-secondary: #fafafa;--bg-tertiary: #f3f4f6;--text-primary: #1b1b1b;--text-secondary: #616161;--accent: #7c3aed;--accent-hover: #6d28d9;--accent-dim: #ede9fe;--border: #e5e7eb;--error: #dc2626;--success: #16a34a;--badge-success-bg: #f0fdf4;--badge-success-text: #15803d;--badge-success-border: #bbf7d0;--badge-warning-bg: #fefce8;--badge-warning-text: #a16207;--badge-warning-border: #fef08a;--badge-error-bg: #fef2f2;--badge-error-text: #b91c1c;--badge-error-border: #fecaca;--badge-info-bg: #eff6ff;--badge-info-text: #1d4ed8;--badge-info-border: #bfdbfe;--span-llm-bg: #f5f3ff;--span-llm-text: #6b21a8;--span-tool-bg: #eff6ff;--span-tool-text: #1e40af;--span-agent-bg: #f0fdf4;--span-agent-text: #166534;--span-other-bg: #fff7ed;--span-other-text: #9a3412;--span-pass-bg: #f0fdf4;--span-pass-text: #166534;--span-fail-bg: #fef2f2;--span-fail-text: #991b1b}[data-theme=dark]{--bg-primary: #1a1a2e;--bg-secondary: #16162a;--bg-tertiary: #252540;--text-primary: #f0f0f5;--text-secondary: #a0a0b5;--accent: #a78bfa;--accent-hover: #8b5cf6;--accent-dim: #2d2055;--border: #2d2d45;--error: #ef4444;--success: #22c55e;--badge-success-bg: rgba(34, 197, 94, .15);--badge-success-text: #4ade80;--badge-success-border: rgba(34, 197, 94, .3);--badge-warning-bg: rgba(234, 179, 8, .15);--badge-warning-text: #fbbf24;--badge-warning-border: rgba(234, 179, 8, .3);--badge-error-bg: rgba(239, 68, 68, .15);--badge-error-text: #f87171;--badge-error-border: rgba(239, 68, 68, .3);--badge-info-bg: rgba(59, 130, 246, .15);--badge-info-text: #60a5fa;--badge-info-border: rgba(59, 130, 246, .3);--span-llm-bg: rgba(139, 92, 246, .15);--span-llm-text: #c4b5fd;--span-tool-bg: rgba(59, 130, 246, .15);--span-tool-text: #93c5fd;--span-agent-bg: rgba(34, 197, 94, .15);--span-agent-text: #86efac;--span-other-bg: rgba(249, 115, 22, .15);--span-other-text: #fdba74;--span-pass-bg: rgba(34, 197, 94, .15);--span-pass-text: #86efac;--span-fail-bg: rgba(239, 68, 68, .15);--span-fail-text: #fca5a5}*{box-sizing:border-box}body{margin:0;background-color:var(--bg-primary);color:var(--text-primary);font-family:Segoe UI,system-ui,-apple-system,BlinkMacSystemFont,sans-serif;font-size:14px;line-height:1.6}::-webkit-scrollbar{width:8px;height:8px}::-webkit-scrollbar-track{background:var(--bg-secondary)}::-webkit-scrollbar-thumb{background:var(--border);border-radius:4px}::-webkit-scrollbar-thumb:hover{background:silver}[data-theme=dark] ::-webkit-scrollbar-thumb:hover{background:#404040}.last\:border-0:last-child{border-width:0px}.last\:border-b-0:last-child{border-bottom-width:0px}.hover\:border-\[var\(--accent\)\]:hover{border-color:var(--accent)}.hover\:border-\[var\(--accent-dim\)\]:hover{border-color:var(--accent-dim)}.hover\:bg-\[var\(--accent-hover\)\]:hover{background-color:var(--accent-hover)}.hover\:bg-\[var\(--bg-primary\)\]:hover{background-color:var(--bg-primary)}.hover\:bg-\[var\(--bg-tertiary\)\]:hover{background-color:var(--bg-tertiary)}.hover\:bg-\[var\(--border\)\]:hover{background-color:var(--border)}.hover\:bg-red-600:hover{--tw-bg-opacity: 1;background-color:rgb(220 38 38 / var(--tw-bg-opacity, 1))}.hover\:text-\[var\(--accent\)\]:hover{color:var(--accent)}.hover\:text-\[var\(--error\)\]:hover{color:var(--error)}.hover\:text-\[var\(--text-primary\)\]:hover{color:var(--text-primary)}.hover\:text-red-600:hover{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-80:hover{opacity:.8}.focus\:border-\[var\(--accent\)\]:focus{border-color:var(--accent)}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-\[var\(--accent\)\]:focus{--tw-ring-color: var(--accent)}.disabled\:cursor-not-allowed:disabled{cursor:not-allowed}.disabled\:opacity-50:disabled{opacity:.5}@media (min-width: 768px){.md\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.md\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}}@media (min-width: 1024px){.lg\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))}} diff --git a/src/flow/ui/ui/flow.svg b/src/flow/ui/ui/flow.svg index 5a247d8a5e8c1c7b54b1bb4357dcd33d70862881..ac9a7f637fb9b616e247ca8b9ec5c79fdbeec5e9 100644 --- a/src/flow/ui/ui/flow.svg +++ b/src/flow/ui/ui/flow.svg @@ -1,4 +1,4 @@ - - + + diff --git a/src/flow/ui/ui/index.html b/src/flow/ui/ui/index.html index 34b14d54d44ea5241acea6a1881244553fff6c10..db072ae84a77d5dc564f0320ea0411a9a4e042a2 100644 --- a/src/flow/ui/ui/index.html +++ b/src/flow/ui/ui/index.html @@ -8,8 +8,8 @@ - - + +