qodalis-cli-server-plugin-admin 1.0.0b32__tar.gz → 1.0.0b33__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/PKG-INFO +1 -1
  2. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/pyproject.toml +1 -1
  3. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/cli_admin_builder.py +34 -3
  4. qodalis_cli_server_plugin_admin-1.0.0b32/qodalis_cli_admin/dashboard/assets/Badge-nmFjKF1h.js → qodalis_cli_server_plugin_admin-1.0.0b33/qodalis_cli_admin/dashboard/assets/Badge-CuP1qfDI.js +1 -1
  5. qodalis_cli_server_plugin_admin-1.0.0b32/qodalis_cli_admin/dashboard/assets/ButtonGroup-BGrKcSx4.js → qodalis_cli_server_plugin_admin-1.0.0b33/qodalis_cli_admin/dashboard/assets/ButtonGroup-DCaBJ3RQ.js +1 -1
  6. qodalis_cli_server_plugin_admin-1.0.0b32/qodalis_cli_admin/dashboard/assets/ChipList-Dbgul4Mj.js → qodalis_cli_server_plugin_admin-1.0.0b33/qodalis_cli_admin/dashboard/assets/ChipList-D8ZleiJ9.js +1 -1
  7. qodalis_cli_server_plugin_admin-1.0.0b32/qodalis_cli_admin/dashboard/assets/CommandsPage-DJ5LFCoc.js → qodalis_cli_server_plugin_admin-1.0.0b33/qodalis_cli_admin/dashboard/assets/CommandsPage-BuT7R42D.js +1 -1
  8. qodalis_cli_server_plugin_admin-1.0.0b32/qodalis_cli_admin/dashboard/assets/ConfigInput-CZN2vEwy.js → qodalis_cli_server_plugin_admin-1.0.0b33/qodalis_cli_admin/dashboard/assets/ConfigInput-B2mBPdou.js +1 -1
  9. qodalis_cli_server_plugin_admin-1.0.0b32/qodalis_cli_admin/dashboard/assets/ConfigPage-C0Ntt-kp.js → qodalis_cli_server_plugin_admin-1.0.0b33/qodalis_cli_admin/dashboard/assets/ConfigPage-DiRw8Dmm.js +2 -2
  10. qodalis_cli_server_plugin_admin-1.0.0b32/qodalis_cli_admin/dashboard/assets/DataTable-GXA3iZq9.js → qodalis_cli_server_plugin_admin-1.0.0b33/qodalis_cli_admin/dashboard/assets/DataTable-BGLeCJvI.js +1 -1
  11. qodalis_cli_server_plugin_admin-1.0.0b32/qodalis_cli_admin/dashboard/assets/EventsPage-DzwiKZps.js → qodalis_cli_server_plugin_admin-1.0.0b33/qodalis_cli_admin/dashboard/assets/EventsPage-DJe_Ega1.js +2 -2
  12. qodalis_cli_server_plugin_admin-1.0.0b32/qodalis_cli_admin/dashboard/assets/LogsPage-CuqPb5np.js → qodalis_cli_server_plugin_admin-1.0.0b33/qodalis_cli_admin/dashboard/assets/LogsPage-3mopNFyH.js +1 -1
  13. qodalis_cli_server_plugin_admin-1.0.0b33/qodalis_cli_admin/dashboard/assets/PluginDetailsPage-CuJ8qWFn.js +1 -0
  14. qodalis_cli_server_plugin_admin-1.0.0b33/qodalis_cli_admin/dashboard/assets/PluginsPage-YDK2T82n.js +3 -0
  15. qodalis_cli_server_plugin_admin-1.0.0b32/qodalis_cli_admin/dashboard/assets/TerminalPage-CWJcCMIT.js → qodalis_cli_server_plugin_admin-1.0.0b33/qodalis_cli_admin/dashboard/assets/TerminalPage-D-hC8F_9.js +1 -1
  16. qodalis_cli_server_plugin_admin-1.0.0b33/qodalis_cli_admin/dashboard/assets/index-BEViB6FO.js +65 -0
  17. qodalis_cli_server_plugin_admin-1.0.0b32/qodalis_cli_admin/dashboard/assets/pluginPath-CKVB4X1p.js → qodalis_cli_server_plugin_admin-1.0.0b33/qodalis_cli_admin/dashboard/assets/pluginPath-CrhUZOJe.js +1 -1
  18. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/dashboard/index.html +1 -1
  19. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/services/dashboard_marketplace.py +23 -5
  20. qodalis_cli_server_plugin_admin-1.0.0b33/qodalis_cli_admin/services/plugins_folder.py +93 -0
  21. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/services/server_plugin_marketplace.py +20 -4
  22. qodalis_cli_server_plugin_admin-1.0.0b32/qodalis_cli_admin/dashboard/assets/PluginDetailsPage-wDOLJ6Hy.js +0 -1
  23. qodalis_cli_server_plugin_admin-1.0.0b32/qodalis_cli_admin/dashboard/assets/PluginsPage-BJS2tecd.js +0 -3
  24. qodalis_cli_server_plugin_admin-1.0.0b32/qodalis_cli_admin/dashboard/assets/index-BquDpLoS.js +0 -65
  25. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/.gitignore +0 -0
  26. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/__init__.py +0 -0
  27. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/auth/__init__.py +0 -0
  28. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/auth/auth_controller.py +0 -0
  29. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/auth/auth_middleware.py +0 -0
  30. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/auth/jwt_service.py +0 -0
  31. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/commands/__init__.py +0 -0
  32. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/commands/admin_command.py +0 -0
  33. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/commands/admin_restart_command.py +0 -0
  34. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/commands/admin_server_plugins_command.py +0 -0
  35. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/controllers/__init__.py +0 -0
  36. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/controllers/config_controller.py +0 -0
  37. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/controllers/dashboard_marketplace_controller.py +0 -0
  38. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/controllers/logs_controller.py +0 -0
  39. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/controllers/plugins_controller.py +0 -0
  40. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/controllers/server_marketplace_controller.py +0 -0
  41. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/controllers/status_controller.py +0 -0
  42. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/controllers/ws_clients_controller.py +0 -0
  43. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/dashboard/assets/commandInfo-B_4x--N6.js +0 -0
  44. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/dashboard/assets/index-CY1WPG8S.css +0 -0
  45. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/dashboard/assets/paging-CCKbuXJo.js +0 -0
  46. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/dashboard/assets/wasm/qodalis_cli_wasm_bg.wasm +0 -0
  47. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/dashboard/qodalis-icon.svg +0 -0
  48. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/dashboard_resolver.py +0 -0
  49. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/services/__init__.py +0 -0
  50. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/services/admin_branding.py +0 -0
  51. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/services/admin_config.py +0 -0
  52. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/services/admin_config_providers.py +0 -0
  53. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/services/admin_theme.py +0 -0
  54. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/services/dashboard_plugin_config.py +0 -0
  55. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/services/log_ring_buffer.py +0 -0
  56. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/services/module_registry.py +0 -0
  57. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/services/status_history.py +0 -0
  58. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/services/system_memory.py +0 -0
  59. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/services/time_range.py +0 -0
  60. {qodalis_cli_server_plugin_admin-1.0.0b32 → qodalis_cli_server_plugin_admin-1.0.0b33}/qodalis_cli_admin/spa_static_files.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: qodalis-cli-server-plugin-admin
3
- Version: 1.0.0b32
3
+ Version: 1.0.0b33
4
4
  Summary: Admin dashboard plugin for Qodalis CLI servers
5
5
  Project-URL: Homepage, https://github.com/qodalis-solutions/cli-server-python
6
6
  Project-URL: Repository, https://github.com/qodalis-solutions/cli-server-python
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "qodalis-cli-server-plugin-admin"
7
- version = "1.0.0b32"
7
+ version = "1.0.0b33"
8
8
  description = "Admin dashboard plugin for Qodalis CLI servers"
9
9
  readme = { text = "", content-type = "text/plain" }
10
10
  license = "MIT"
@@ -3,8 +3,10 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import json
6
+ import logging
6
7
  import os
7
8
  import time
9
+ import dataclasses
8
10
  from dataclasses import dataclass, field
9
11
  from collections.abc import Mapping
10
12
  from typing import Any, Callable, Awaitable
@@ -39,6 +41,7 @@ from .services.server_plugin_marketplace import (
39
41
  ServerPluginMarketplaceOptions,
40
42
  )
41
43
  from .services.admin_config import AdminConfig
44
+ from .services.plugins_folder import DATA_DIR_HINT, QCLI_DATA_DIR_ENV, unwritable_folders_warning
42
45
  from .services.admin_config_providers import AdminAuthConfigProvider, create_logs_config_provider
43
46
  from .services.admin_branding import validate_admin_branding
44
47
  from .services.admin_theme import validate_admin_theme
@@ -47,6 +50,8 @@ from .services.module_registry import ModuleRegistry
47
50
  from .services.status_history import StatusHistory
48
51
  from .dashboard_resolver import resolve_dashboard_dir
49
52
 
53
+ logger = logging.getLogger("qcli-admin")
54
+
50
55
 
51
56
  def _package_version() -> str:
52
57
  try:
@@ -164,7 +169,8 @@ class CliAdminBuilder:
164
169
  def set_marketplace(self, options: DashboardMarketplaceOptions | Mapping[str, Any] | bool) -> CliAdminBuilder:
165
170
  """Dashboard plugins from the marketplace: ``url`` (default ``https://plugins.qodalis.com``), ``install``
166
171
  (``verified``, the default: listed versions of verified publishers only; ``listed``: any listed version;
167
- ``off``: browse only), ``dir`` (default ``./qcli-data/dashboard-plugins``, from the working directory),
172
+ ``off``: browse only), ``dir`` (default ``<data_dir>/dashboard-plugins``: the server's ``data_dir``, else
173
+ ``QCLI_DATA_DIR``, else ``./qcli-data``),
168
174
  and ``fetch`` / ``cdns`` / ``timeout`` for the HTTP client. A :class:`DashboardMarketplaceOptions` or a
169
175
  dict of its fields; ``False`` turns the marketplace off (no routes, installed plugins not loaded),
170
176
  ``True`` restores the defaults. An invalid url or policy raises :class:`ValueError` in :meth:`build`."""
@@ -337,6 +343,13 @@ class CliAdminBuilder:
337
343
  # Dashboard plugins from the marketplace: pages added and removed at runtime, served from this server
338
344
  server["event_bus"] = deps.event_bus
339
345
  marketplace: DashboardMarketplace | None = None
346
+ # Kept in the server's data directory unless the marketplace names its own folder
347
+ server_plugins = getattr(deps.builder, "server_plugins", None)
348
+ data_dir = getattr(server_plugins, "data_dir", None) or os.path.abspath(
349
+ os.environ.get(QCLI_DATA_DIR_ENV) or "qcli-data"
350
+ )
351
+ explicit_dashboard_dir = self._marketplace.dir if self._marketplace is not None else None
352
+ dashboard_folder_hint = "Set the marketplace's dir to a writable folder" if explicit_dashboard_dir else DATA_DIR_HINT
340
353
  add_extension = getattr(deps.builder, "add_dashboard_extension", None)
341
354
  remove_extension = getattr(deps.builder, "remove_dashboard_extension", None)
342
355
  if self._marketplace is not None and callable(add_extension) and callable(remove_extension):
@@ -361,7 +374,11 @@ class CliAdminBuilder:
361
374
  if callable(ready):
362
375
  await ready()
363
376
 
364
- marketplace = DashboardMarketplace(self._marketplace, DashboardMarketplaceDeps(
377
+ marketplace_options = dataclasses.replace(
378
+ self._marketplace, dir=explicit_dashboard_dir or os.path.join(data_dir, "dashboard-plugins"),
379
+ )
380
+ marketplace = DashboardMarketplace(marketplace_options, DashboardMarketplaceDeps(
381
+ folder_hint=dashboard_folder_hint,
365
382
  extension_ids=lambda: [e.id for e in getattr(deps.builder, "dashboard_extensions", None) or []],
366
383
  extensions=lambda: [
367
384
  e.to_dict() if hasattr(e, "to_dict") else dict(e)
@@ -384,8 +401,11 @@ class CliAdminBuilder:
384
401
  # Server plugins from the marketplace: Python packages installed into <data dir>/server-plugins, loaded at the
385
402
  # next start (the same marketplace options)
386
403
  server_marketplace: ServerPluginMarketplace | None = None
387
- server_plugins = getattr(deps.builder, "server_plugins", None)
404
+ server_folder_hint = DATA_DIR_HINT
388
405
  if self._marketplace is not None and server_plugins is not None and hasattr(server_plugins, "records"):
406
+ plugins_dir = os.path.abspath(server_plugins.dir)
407
+ if not plugins_dir.startswith(os.path.abspath(server_plugins.data_dir) + os.sep):
408
+ server_folder_hint = "Set server_plugins.dir to a writable folder"
389
409
 
390
410
  async def publish_server(event_type: str, data: dict[str, Any]) -> None:
391
411
  bus = server.get("event_bus")
@@ -406,11 +426,22 @@ class CliAdminBuilder:
406
426
  audit=lambda: getattr(deps.builder, "audit_sink", None),
407
427
  publish=publish_server,
408
428
  anonymous_allowed=anonymous_admin_allowed,
429
+ folder_hint=server_folder_hint,
409
430
  ))
410
431
  router.include_router(
411
432
  create_server_marketplace_router(server_marketplace, auth_dep), prefix="/server/marketplace",
412
433
  )
413
434
 
435
+ # One WARNING at startup when installing would fail: a folder that cannot be created or written
436
+ writable_folders: list[tuple[str, str]] = []
437
+ if marketplace is not None and marketplace.install != "off":
438
+ writable_folders.append((marketplace.dir, dashboard_folder_hint))
439
+ if server_marketplace is not None and server_marketplace.install != "off" and getattr(server_plugins, "enabled", False):
440
+ writable_folders.append((server_plugins.dir, server_folder_hint))
441
+ folder_warning = unwritable_folders_warning(writable_folders)
442
+ if folder_warning:
443
+ logger.warning(folder_warning)
444
+
414
445
  plugins_router = create_plugins_router(module_registry, auth_dep, deps.builder, marketplace)
415
446
  router.include_router(plugins_router)
416
447
 
@@ -1 +1 @@
1
- import{j as r}from"./index-BquDpLoS.js";const t={success:"bg-success/15 text-success border-success/30",warning:"bg-warning/15 text-warning border-warning/30",error:"bg-error/15 text-error border-error/30",info:"bg-info/15 text-info border-info/30",neutral:"bg-subtle/15 text-muted border-subtle/30"};function a({variant:e,children:s,dot:n}){return r.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[11px] font-medium border ${t[e]}`,children:[n&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current"}),s]})}export{a as B};
1
+ import{j as r}from"./index-BEViB6FO.js";const t={success:"bg-success/15 text-success border-success/30",warning:"bg-warning/15 text-warning border-warning/30",error:"bg-error/15 text-error border-error/30",info:"bg-info/15 text-info border-info/30",neutral:"bg-subtle/15 text-muted border-subtle/30"};function a({variant:e,children:s,dot:n}){return r.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[11px] font-medium border ${t[e]}`,children:[n&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-current"}),s]})}export{a as B};
@@ -1 +1 @@
1
- import{a4 as x,j as r,w as u,a9 as b}from"./index-BquDpLoS.js";const a={default:"text-text hover:bg-control-hover",primary:"text-accent hover:bg-primary/15",success:"text-success hover:bg-success/15",warning:"text-warning hover:bg-warning/15",danger:"text-error hover:bg-error/15"},i="inline-flex items-center justify-center gap-1.5 min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 px-2.5 text-xs font-medium whitespace-nowrap transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-50 disabled:cursor-not-allowed",g={always:"",sm:"sr-only sm:not-sr-only",xl:"sr-only xl:not-sr-only",never:"sr-only"};function p({items:o,label:l,labels:n="always",overflow:s=[],className:t=""}){const c=x();return o.length===0&&s.length===0?null:r.jsxs("div",{role:"group","aria-label":l,className:`inline-flex items-stretch rounded-lg border border-border/75 bg-control divide-x divide-border/75 overflow-hidden ${t}`,children:[o.map(e=>{const d=e.disabled||e.loading;return r.jsxs("button",{type:"button",onClick:e.onClick,disabled:d,"aria-busy":e.loading||void 0,"aria-pressed":e.pressed,"aria-label":e.ariaLabel??(n==="always"?void 0:e.label),title:n==="always"?void 0:e.label,className:`${i} ${a[e.tone??"default"]} ${e.pressed?"bg-primary/15":""}`,children:[e.loading?r.jsx(u,{}):e.icon&&r.jsx("span",{"aria-hidden":!0,className:"inline-flex",children:e.icon}),r.jsx("span",{className:g[n],children:e.label})]},e.key)}),s.length>0&&r.jsx(b,{items:s,label:c("moreActions"),align:"end",buttonClassName:`${i} ${a.default}`,children:r.jsxs("svg",{"aria-hidden":!0,width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:[r.jsx("circle",{cx:"5",cy:"12",r:"2"}),r.jsx("circle",{cx:"12",cy:"12",r:"2"}),r.jsx("circle",{cx:"19",cy:"12",r:"2"})]})})]})}export{p as B};
1
+ import{a4 as x,j as r,w as u,a9 as b}from"./index-BEViB6FO.js";const a={default:"text-text hover:bg-control-hover",primary:"text-accent hover:bg-primary/15",success:"text-success hover:bg-success/15",warning:"text-warning hover:bg-warning/15",danger:"text-error hover:bg-error/15"},i="inline-flex items-center justify-center gap-1.5 min-h-11 min-w-11 sm:min-h-8 sm:min-w-8 px-2.5 text-xs font-medium whitespace-nowrap transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-50 disabled:cursor-not-allowed",g={always:"",sm:"sr-only sm:not-sr-only",xl:"sr-only xl:not-sr-only",never:"sr-only"};function p({items:o,label:l,labels:n="always",overflow:s=[],className:t=""}){const c=x();return o.length===0&&s.length===0?null:r.jsxs("div",{role:"group","aria-label":l,className:`inline-flex items-stretch rounded-lg border border-border/75 bg-control divide-x divide-border/75 overflow-hidden ${t}`,children:[o.map(e=>{const d=e.disabled||e.loading;return r.jsxs("button",{type:"button",onClick:e.onClick,disabled:d,"aria-busy":e.loading||void 0,"aria-pressed":e.pressed,"aria-label":e.ariaLabel??(n==="always"?void 0:e.label),title:n==="always"?void 0:e.label,className:`${i} ${a[e.tone??"default"]} ${e.pressed?"bg-primary/15":""}`,children:[e.loading?r.jsx(u,{}):e.icon&&r.jsx("span",{"aria-hidden":!0,className:"inline-flex",children:e.icon}),r.jsx("span",{className:g[n],children:e.label})]},e.key)}),s.length>0&&r.jsx(b,{items:s,label:c("moreActions"),align:"end",buttonClassName:`${i} ${a.default}`,children:r.jsxs("svg",{"aria-hidden":!0,width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:[r.jsx("circle",{cx:"5",cy:"12",r:"2"}),r.jsx("circle",{cx:"12",cy:"12",r:"2"}),r.jsx("circle",{cx:"19",cy:"12",r:"2"})]})})]})}export{p as B};
@@ -1 +1 @@
1
- import{a4 as q,r as C,j as s,M as E}from"./index-BquDpLoS.js";const I="font-mono text-[11px] bg-control px-1.5 py-0.5 rounded",K="hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",T=n=>typeof n=="string"?{label:n}:n,w=n=>n.stopPropagation();function z({items:n,max:v=3,title:r,label:h,chipClassName:L=I,className:S="",empty:k,searchThreshold:$=10,renderLink:u}){const l=q(),[M,d]=C.useState(!1),[f,b]=C.useState(""),t=n.map(T),g=Math.max(0,v);if(t.length===0)return s.jsx("span",{className:"text-xs text-subtle",children:k??"—"});const c=t.length-g,A=c>0?t.slice(0,g):t,a=f.trim().toLowerCase(),i=a?t.filter(e=>{var o;return e.label.toLowerCase().includes(a)||(((o=e.title)==null?void 0:o.toLowerCase().includes(a))??!1)}):t,p=()=>{d(!1),b("")},y=(e,o)=>{const m=e.className??L,x=e.render??e.label;if(e.href){const N=P=>{P.stopPropagation(),o&&p()},j=`${m} ${K}`;return u?u({href:e.href,className:j,title:e.title,style:e.style,children:x,onClick:N}):s.jsx("a",{href:e.href,className:j,title:e.title,style:e.style,onClick:N,children:x})}return s.jsx("span",{className:m,title:e.title,style:e.style,children:x})};return s.jsxs("ul",{className:`flex flex-wrap items-center gap-1 ${S}`,"aria-label":h,children:[A.map((e,o)=>s.jsx("li",{className:"inline-flex max-w-full",children:y(e,!1)},e.key??`${e.label}:${o}`)),c>0&&s.jsxs("li",{className:"inline-flex",onClick:w,onKeyDown:w,children:[s.jsx("button",{type:"button",onClick:()=>d(!0),"aria-haspopup":"dialog",title:l("chipListShowAll",{count:t.length}),className:"text-[11px] font-medium text-accent px-1.5 py-0.5 rounded border border-border/75 bg-surface hover:bg-control-hover whitespace-nowrap focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",children:l("chipListMore",{count:c})}),s.jsxs(E,{open:M,onClose:p,title:r??l("chipListTitle",{count:t.length}),actions:s.jsx("button",{type:"button",onClick:p,className:"px-3 py-1.5 text-xs bg-control hover:bg-control-hover text-text rounded-lg",children:l("dialogClose")}),children:[t.length>$&&s.jsxs("div",{className:"mb-3 space-y-1",children:[s.jsx("input",{type:"search",value:f,onChange:e=>b(e.target.value),placeholder:l("selectSearch"),"aria-label":l("chipListSearch"),className:"w-full px-3 py-2 text-sm bg-control border border-border rounded-lg text-text placeholder:text-subtle focus:outline-none focus:border-primary/50"}),a&&s.jsx("p",{role:"status",className:"text-xs text-subtle",children:l("chipListMatches",{shown:i.length,total:t.length})})]}),i.length>0?s.jsx("ul",{className:"flex flex-wrap gap-1.5","aria-label":typeof r=="string"?r:h,children:i.map((e,o)=>s.jsx("li",{className:"inline-flex max-w-full break-all",children:y(e,!0)},e.key??`${e.label}:${o}`))}):s.jsx("p",{className:"text-xs text-subtle",children:l("selectNoMatches")})]})]})]})}export{z as C};
1
+ import{a4 as q,r as C,j as s,M as E}from"./index-BEViB6FO.js";const I="font-mono text-[11px] bg-control px-1.5 py-0.5 rounded",K="hover:underline focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",T=n=>typeof n=="string"?{label:n}:n,w=n=>n.stopPropagation();function z({items:n,max:v=3,title:r,label:h,chipClassName:L=I,className:S="",empty:k,searchThreshold:$=10,renderLink:u}){const l=q(),[M,d]=C.useState(!1),[f,b]=C.useState(""),t=n.map(T),g=Math.max(0,v);if(t.length===0)return s.jsx("span",{className:"text-xs text-subtle",children:k??"—"});const c=t.length-g,A=c>0?t.slice(0,g):t,a=f.trim().toLowerCase(),i=a?t.filter(e=>{var o;return e.label.toLowerCase().includes(a)||(((o=e.title)==null?void 0:o.toLowerCase().includes(a))??!1)}):t,p=()=>{d(!1),b("")},y=(e,o)=>{const m=e.className??L,x=e.render??e.label;if(e.href){const N=P=>{P.stopPropagation(),o&&p()},j=`${m} ${K}`;return u?u({href:e.href,className:j,title:e.title,style:e.style,children:x,onClick:N}):s.jsx("a",{href:e.href,className:j,title:e.title,style:e.style,onClick:N,children:x})}return s.jsx("span",{className:m,title:e.title,style:e.style,children:x})};return s.jsxs("ul",{className:`flex flex-wrap items-center gap-1 ${S}`,"aria-label":h,children:[A.map((e,o)=>s.jsx("li",{className:"inline-flex max-w-full",children:y(e,!1)},e.key??`${e.label}:${o}`)),c>0&&s.jsxs("li",{className:"inline-flex",onClick:w,onKeyDown:w,children:[s.jsx("button",{type:"button",onClick:()=>d(!0),"aria-haspopup":"dialog",title:l("chipListShowAll",{count:t.length}),className:"text-[11px] font-medium text-accent px-1.5 py-0.5 rounded border border-border/75 bg-surface hover:bg-control-hover whitespace-nowrap focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",children:l("chipListMore",{count:c})}),s.jsxs(E,{open:M,onClose:p,title:r??l("chipListTitle",{count:t.length}),actions:s.jsx("button",{type:"button",onClick:p,className:"px-3 py-1.5 text-xs bg-control hover:bg-control-hover text-text rounded-lg",children:l("dialogClose")}),children:[t.length>$&&s.jsxs("div",{className:"mb-3 space-y-1",children:[s.jsx("input",{type:"search",value:f,onChange:e=>b(e.target.value),placeholder:l("selectSearch"),"aria-label":l("chipListSearch"),className:"w-full px-3 py-2 text-sm bg-control border border-border rounded-lg text-text placeholder:text-subtle focus:outline-none focus:border-primary/50"}),a&&s.jsx("p",{role:"status",className:"text-xs text-subtle",children:l("chipListMatches",{shown:i.length,total:t.length})})]}),i.length>0?s.jsx("ul",{className:"flex flex-wrap gap-1.5","aria-label":typeof r=="string"?r:h,children:i.map((e,o)=>s.jsx("li",{className:"inline-flex max-w-full break-all",children:y(e,!0)},e.key??`${e.label}:${o}`))}):s.jsx("p",{className:"text-xs text-subtle",children:l("selectNoMatches")})]})]})]})}export{z as C};
@@ -1 +1 @@
1
- import{u as j,j as e,a as E,b as q,P as F,S as T,C as M,s as V,c as I,d as O,e as U,E as _,f as H,g as z,r as D,h as B,A as G}from"./index-BquDpLoS.js";import{C as R}from"./ChipList-Dbgul4Mj.js";import{d as J,f as K,m as Q,r as W,h as X,c as Y}from"./commandInfo-B_4x--N6.js";const k="text-[10px] text-subtle uppercase tracking-wider font-medium mb-1.5",f="px-3 py-2 text-left text-[10px] text-subtle uppercase tracking-wide font-medium";function Z({command:s,aliases:r}){const{t:l}=j();return r!=null&&r.length?e.jsx(R,{items:r.map(o=>({label:o,title:l("commands.alias")})),max:2,label:l("commands.aliases"),title:l("commands.aliasesOf",{command:s}),chipClassName:"font-mono text-[11px] px-1.5 py-0.5 rounded bg-control text-muted border border-border/75"}):null}function ee({command:s,permissions:r}){const{t:l}=j();return r!=null&&r.length?e.jsx(R,{items:r,max:2,label:l("commands.colPermissions"),title:l("commands.permissionsOf",{command:s}),chipClassName:"font-mono text-[11px] px-1.5 py-0.5 rounded bg-primary/10 text-accent border border-primary/25 whitespace-nowrap"}):e.jsx("span",{className:"text-subtle","aria-label":l("commands.noPermissions"),children:"—"})}function se({param:s}){var l,o,n;const{t:r}=j();return e.jsxs("tr",{className:"border-b border-border/50 last:border-0 align-top",children:[e.jsxs("td",{className:"px-3 py-1.5 font-mono text-xs text-accent whitespace-nowrap",children:[s.name,(l=s.aliases)!=null&&l.length?e.jsxs("span",{className:"text-subtle",children:[" (",s.aliases.join(", "),")"]}):null]}),e.jsx("td",{className:"px-3 py-1.5 text-xs text-muted",children:s.type}),e.jsxs("td",{className:"px-3 py-1.5 text-xs text-muted",children:[s.description,(o=s.examples)!=null&&o.length?e.jsxs("span",{className:"block mt-0.5 text-subtle",children:[r("commands.forExample")," ",s.examples.map((d,i)=>e.jsxs("span",{children:[i>0&&", ",e.jsx("code",{className:"font-mono text-[11px] text-accent",children:d})]},`${d}-${i}`))]}):null]}),e.jsx("td",{className:"px-3 py-1.5 text-xs",children:s.required?e.jsx("span",{className:"text-error font-medium",children:r("commands.yes")}):e.jsx("span",{className:"text-subtle",children:r("commands.no")})}),e.jsx("td",{className:"px-3 py-1.5 text-xs font-mono text-muted",children:K(s.defaultValue)}),e.jsx("td",{className:"px-3 py-1.5 text-xs",children:(n=s.allowedValues)!=null&&n.length?e.jsx("span",{className:"flex flex-wrap gap-1",children:s.allowedValues.map(d=>e.jsx("span",{className:"font-mono text-[11px] px-1.5 py-0.5 rounded bg-primary/10 text-accent border border-primary/25",children:d},d))}):e.jsx("span",{className:"text-subtle",children:r("commands.anyValue")})})]})}function te({cmd:s}){const{t:r}=j(),l=J(s.documentation);return e.jsxs(e.Fragment,{children:[l.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:k,children:r("commands.documentation")}),e.jsx("div",{className:"space-y-2 text-sm text-text max-w-3xl",children:l.map((o,n)=>e.jsx("p",{className:"whitespace-pre-line",children:o},n))})]}),s.examples&&s.examples.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:k,children:r("commands.examples")}),e.jsx("ul",{className:"bg-surface/75 border border-border/75 rounded-lg divide-y divide-border/50",children:s.examples.map((o,n)=>e.jsxs("li",{className:"px-3 py-2 flex flex-col sm:flex-row sm:items-baseline gap-x-4 gap-y-0.5",children:[e.jsx("code",{className:"font-mono text-xs text-accent whitespace-pre-wrap break-all",children:o.command}),o.description&&e.jsx("span",{className:"text-xs text-muted",children:o.description})]},`${o.command}-${n}`))})]}),s.parameters&&s.parameters.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:k,children:r("commands.parameters")}),e.jsx("div",{className:"bg-surface/75 border border-border/75 rounded-lg overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/75",children:[e.jsx("th",{className:f,children:r("commands.colName")}),e.jsx("th",{className:f,children:r("commands.colType")}),e.jsx("th",{className:f,children:r("commands.colDescription")}),e.jsx("th",{className:f,children:r("commands.colRequired")}),e.jsx("th",{className:f,children:r("commands.colDefault")}),e.jsx("th",{className:f,children:r("commands.colAllowed")})]})}),e.jsx("tbody",{children:s.parameters.map(o=>e.jsx(se,{param:o},o.name))})]})})]})]})}async function ae(){try{const s=await B();return Array.isArray(s==null?void 0:s.commands)?s:null}catch(s){if(s instanceof G&&(s.status===404||s.status===501))return null;throw s}}function A({cmd:s,depth:r=0,usage:l,search:o=""}){var N;const{t:n,formatNumber:d}=j(),i=W(s,o),[x,g]=D.useState(i),[h,b]=D.useState(i),a=X(s);i!==h&&(b(i),i&&g(!0));const p=r*16;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:`border-b border-border/50 last:border-0 ${a?"cursor-pointer hover:bg-control":""}`,onClick:()=>a&&g(!x),children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",style:{paddingLeft:`${p}px`},children:[a?e.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),g(!x)},"aria-expanded":x,className:"inline-flex items-center gap-2 rounded focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",children:[e.jsx("span",{"aria-hidden":!0,className:`text-subtle transition-transform text-xs ${x?"rotate-90":""}`,children:"▶"}),s.icon&&e.jsx("span",{"aria-hidden":!0,children:s.icon}),e.jsx("span",{className:"font-mono text-sm text-accent",children:s.command})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-[0.6rem]","aria-hidden":!0}),s.icon&&e.jsx("span",{"aria-hidden":!0,children:s.icon}),e.jsx("span",{className:"font-mono text-sm text-accent",children:s.command})]}),e.jsx(Z,{command:s.command,aliases:s.aliases})]})}),e.jsx("td",{className:"px-4 py-3 text-sm text-muted",children:s.description||"—"}),e.jsx("td",{className:"px-4 py-3 text-xs text-subtle font-mono",children:Y(s)??"—"}),e.jsx("td",{className:"px-4 py-3 text-xs text-subtle text-center",children:d(((N=s.parameters)==null?void 0:N.length)??0)}),e.jsx("td",{className:"px-4 py-3 text-xs",children:e.jsx(ee,{command:s.command,permissions:s.requiredPermissions})}),l&&r===0&&(()=>{const c=l.get(s.command.toLowerCase());return e.jsxs(e.Fragment,{children:[e.jsx("td",{className:"px-4 py-3 text-xs text-right tabular-nums text-text",children:c?d(c.executions):"—"}),e.jsx("td",{className:`px-4 py-3 text-xs text-right tabular-nums ${c!=null&&c.failures?"text-error":"text-subtle"}`,children:c?d(c.failures):"—"})]})})(),l&&r>0&&e.jsxs(e.Fragment,{children:[e.jsx("td",{}),e.jsx("td",{})]})]}),x&&a&&e.jsx("tr",{className:"border-b border-border/50",children:e.jsxs("td",{colSpan:l?7:5,className:"px-4 py-3 bg-surface/50",children:[e.jsx("div",{className:"sticky left-4 max-w-[calc(100vw-4.5rem)] md:static md:max-w-none",children:e.jsx(te,{cmd:s})}),s.processors&&s.processors.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-subtle uppercase tracking-wider font-medium mb-1.5",children:n("commands.subCommands")}),e.jsx("div",{className:"bg-surface/75 border border-border/75 rounded-lg overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/75",children:[e.jsx("th",{className:"px-3 py-2 text-left text-[10px] text-subtle uppercase tracking-wide font-medium",children:n("commands.colCommand")}),e.jsx("th",{className:"px-3 py-2 text-left text-[10px] text-subtle uppercase tracking-wide font-medium",children:n("commands.colDescription")}),e.jsx("th",{className:"px-3 py-2 text-left text-[10px] text-subtle uppercase tracking-wide font-medium",children:n("commands.colModule")}),e.jsx("th",{className:"px-3 py-2 text-left text-[10px] text-subtle uppercase tracking-wide font-medium text-center",children:n("commands.colParams")}),e.jsx("th",{className:"px-3 py-2 text-left text-[10px] text-subtle uppercase tracking-wide font-medium",children:n("commands.colPermissions")})]})}),e.jsx("tbody",{children:s.processors.map(c=>e.jsx(A,{cmd:c,depth:1,search:o},c.command))})]})})]})]})})]})}function oe(){const{data:s,loading:r,error:l,refetch:o}=E(z,[]),{data:n,loading:d,refetch:i}=E(ae,[]),[x,g]=q(),h=x.get("q")??"",b=["executions","failures"].find(t=>t===x.get("sort"))??"name",{t:a,formatNumber:p,formatDate:N,formatRelative:c}=j(),v=(t,m)=>g(w=>{const C=new URLSearchParams(w);return m?C.set(t,m):C.delete(t),C},{replace:!0}),u=n?new Map(n.commands.map(t=>[t.command.toLowerCase(),t])):void 0,P=(t,m)=>{var w;return((w=u==null?void 0:u.get(t.command.toLowerCase()))==null?void 0:w[m])??0},S=(s?s.filter(t=>Q(t,h)):[]).sort((t,m)=>b==="name"||!u?t.command.localeCompare(m.command):P(m,b)-P(t,b)||t.command.localeCompare(m.command)),y=n?n.commands.filter(t=>t.executions>0).slice(0,8):[],L=n?n.commands.reduce((t,m)=>t+m.executions,0):0,$=n?n.commands.reduce((t,m)=>t+m.failures,0):0;return e.jsxs("div",{children:[e.jsx(F,{title:a("nav.commands"),subtitle:s?a("commands.subtitle",{count:s.length}):a("common.loading"),actions:e.jsx("button",{onClick:()=>{o(),i()},className:"px-3 py-1.5 text-xs bg-control hover:bg-control-hover text-text rounded-lg transition-colors",children:a("common.refresh")})}),e.jsxs("div",{className:"p-4 sm:p-6 space-y-4",children:[d&&!n&&e.jsx(T,{height:150}),n&&e.jsx(M,{title:a("commands.usage"),note:a("commands.usageSince",{time:N(n.since)}),legend:e.jsx(I,{items:[{label:a("commands.succeeded"),color:"var(--qcli-primary)",value:p(L-$)},{label:a("commands.failed"),color:"var(--qcli-error)",value:p($)}]}),children:y.length===0?e.jsx("div",{className:"text-sm text-subtle",children:a("commands.noUsage")}):e.jsx("ul",{className:"space-y-2",children:y.map(t=>e.jsx("li",{children:e.jsxs("button",{onClick:()=>v("q",t.command),className:"w-full grid grid-cols-[minmax(80px,160px)_1fr_auto] items-center gap-3 text-xs group",title:`${t.command}: ${p(t.executions)} · ${a("commands.failed")} ${p(t.failures)} · ${V(t.avgDuration)}${t.lastExecutedAt?` · ${c(t.lastExecutedAt)}`:""}`,children:[e.jsx("span",{className:"font-mono text-left truncate text-accent group-hover:underline",children:t.command}),e.jsxs("span",{className:"flex h-3 gap-[2px]","aria-hidden":!0,children:[e.jsx("span",{className:"h-full rounded-l-sm bg-primary",style:{width:`${(t.executions-t.failures)/y[0].executions*100}%`}}),t.failures>0&&e.jsx("span",{className:"h-full rounded-r-sm bg-error",style:{width:`${t.failures/y[0].executions*100}%`}})]}),e.jsxs("span",{className:"tabular-nums text-muted text-right w-24",children:[p(t.executions),t.failures>0&&e.jsxs("span",{className:"text-error",children:[" · ",p(t.failures)]})]})]})},t.command))})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("input",{type:"search",placeholder:a("commands.searchPlaceholder"),"aria-label":a("commands.searchPlaceholder"),value:h,onChange:t=>v("q",t.target.value||null),className:"w-full max-w-sm px-3 py-2 text-sm bg-control border border-border rounded-lg text-text placeholder-subtle focus:outline-none focus:border-primary/50"}),u&&e.jsx(O,{label:a("commands.sort"),size:"md",options:[{value:"name",label:a("commands.sortName")},{value:"executions",label:a("commands.sortExecutions")},{value:"failures",label:a("commands.sortFailures")}],value:b,onChange:t=>v("sort",t==="name"?null:t)})]}),r&&!s&&e.jsx(U,{rows:8,columns:n?7:5,label:a("commands.loadingCommands")}),l&&e.jsx(_,{error:l,onRetry:o}),s&&!l&&e.jsxs("div",{className:"bg-surface border border-border rounded-xl overflow-x-auto",children:[e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/75",children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs text-subtle font-medium uppercase tracking-wide",children:a("commands.colCommand")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs text-subtle font-medium uppercase tracking-wide",children:a("commands.colDescription")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs text-subtle font-medium uppercase tracking-wide",children:a("commands.colModule")}),e.jsx("th",{className:"px-4 py-3 text-center text-xs text-subtle font-medium uppercase tracking-wide",children:a("commands.colParams")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs text-subtle font-medium uppercase tracking-wide",children:a("commands.colPermissions")}),u&&e.jsxs(e.Fragment,{children:[e.jsx("th",{className:"px-4 py-3 text-right text-xs text-subtle font-medium uppercase tracking-wide",children:a("commands.colRuns")}),e.jsx("th",{className:"px-4 py-3 text-right text-xs text-subtle font-medium uppercase tracking-wide",children:a("commands.failed")})]})]})}),e.jsx("tbody",{children:S.map(t=>e.jsx(A,{cmd:t,usage:u,search:h},t.command))})]}),S.length===0&&e.jsx(H,{message:a(h?"commands.noMatch":"commands.noCommands")})]})]})]})}export{oe as default};
1
+ import{u as j,j as e,a as E,b as q,P as F,S as T,C as M,s as V,c as I,d as O,e as U,E as _,f as H,g as z,r as D,h as B,A as G}from"./index-BEViB6FO.js";import{C as R}from"./ChipList-D8ZleiJ9.js";import{d as J,f as K,m as Q,r as W,h as X,c as Y}from"./commandInfo-B_4x--N6.js";const k="text-[10px] text-subtle uppercase tracking-wider font-medium mb-1.5",f="px-3 py-2 text-left text-[10px] text-subtle uppercase tracking-wide font-medium";function Z({command:s,aliases:r}){const{t:l}=j();return r!=null&&r.length?e.jsx(R,{items:r.map(o=>({label:o,title:l("commands.alias")})),max:2,label:l("commands.aliases"),title:l("commands.aliasesOf",{command:s}),chipClassName:"font-mono text-[11px] px-1.5 py-0.5 rounded bg-control text-muted border border-border/75"}):null}function ee({command:s,permissions:r}){const{t:l}=j();return r!=null&&r.length?e.jsx(R,{items:r,max:2,label:l("commands.colPermissions"),title:l("commands.permissionsOf",{command:s}),chipClassName:"font-mono text-[11px] px-1.5 py-0.5 rounded bg-primary/10 text-accent border border-primary/25 whitespace-nowrap"}):e.jsx("span",{className:"text-subtle","aria-label":l("commands.noPermissions"),children:"—"})}function se({param:s}){var l,o,n;const{t:r}=j();return e.jsxs("tr",{className:"border-b border-border/50 last:border-0 align-top",children:[e.jsxs("td",{className:"px-3 py-1.5 font-mono text-xs text-accent whitespace-nowrap",children:[s.name,(l=s.aliases)!=null&&l.length?e.jsxs("span",{className:"text-subtle",children:[" (",s.aliases.join(", "),")"]}):null]}),e.jsx("td",{className:"px-3 py-1.5 text-xs text-muted",children:s.type}),e.jsxs("td",{className:"px-3 py-1.5 text-xs text-muted",children:[s.description,(o=s.examples)!=null&&o.length?e.jsxs("span",{className:"block mt-0.5 text-subtle",children:[r("commands.forExample")," ",s.examples.map((d,i)=>e.jsxs("span",{children:[i>0&&", ",e.jsx("code",{className:"font-mono text-[11px] text-accent",children:d})]},`${d}-${i}`))]}):null]}),e.jsx("td",{className:"px-3 py-1.5 text-xs",children:s.required?e.jsx("span",{className:"text-error font-medium",children:r("commands.yes")}):e.jsx("span",{className:"text-subtle",children:r("commands.no")})}),e.jsx("td",{className:"px-3 py-1.5 text-xs font-mono text-muted",children:K(s.defaultValue)}),e.jsx("td",{className:"px-3 py-1.5 text-xs",children:(n=s.allowedValues)!=null&&n.length?e.jsx("span",{className:"flex flex-wrap gap-1",children:s.allowedValues.map(d=>e.jsx("span",{className:"font-mono text-[11px] px-1.5 py-0.5 rounded bg-primary/10 text-accent border border-primary/25",children:d},d))}):e.jsx("span",{className:"text-subtle",children:r("commands.anyValue")})})]})}function te({cmd:s}){const{t:r}=j(),l=J(s.documentation);return e.jsxs(e.Fragment,{children:[l.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:k,children:r("commands.documentation")}),e.jsx("div",{className:"space-y-2 text-sm text-text max-w-3xl",children:l.map((o,n)=>e.jsx("p",{className:"whitespace-pre-line",children:o},n))})]}),s.examples&&s.examples.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:k,children:r("commands.examples")}),e.jsx("ul",{className:"bg-surface/75 border border-border/75 rounded-lg divide-y divide-border/50",children:s.examples.map((o,n)=>e.jsxs("li",{className:"px-3 py-2 flex flex-col sm:flex-row sm:items-baseline gap-x-4 gap-y-0.5",children:[e.jsx("code",{className:"font-mono text-xs text-accent whitespace-pre-wrap break-all",children:o.command}),o.description&&e.jsx("span",{className:"text-xs text-muted",children:o.description})]},`${o.command}-${n}`))})]}),s.parameters&&s.parameters.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:k,children:r("commands.parameters")}),e.jsx("div",{className:"bg-surface/75 border border-border/75 rounded-lg overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/75",children:[e.jsx("th",{className:f,children:r("commands.colName")}),e.jsx("th",{className:f,children:r("commands.colType")}),e.jsx("th",{className:f,children:r("commands.colDescription")}),e.jsx("th",{className:f,children:r("commands.colRequired")}),e.jsx("th",{className:f,children:r("commands.colDefault")}),e.jsx("th",{className:f,children:r("commands.colAllowed")})]})}),e.jsx("tbody",{children:s.parameters.map(o=>e.jsx(se,{param:o},o.name))})]})})]})]})}async function ae(){try{const s=await B();return Array.isArray(s==null?void 0:s.commands)?s:null}catch(s){if(s instanceof G&&(s.status===404||s.status===501))return null;throw s}}function A({cmd:s,depth:r=0,usage:l,search:o=""}){var N;const{t:n,formatNumber:d}=j(),i=W(s,o),[x,g]=D.useState(i),[h,b]=D.useState(i),a=X(s);i!==h&&(b(i),i&&g(!0));const p=r*16;return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:`border-b border-border/50 last:border-0 ${a?"cursor-pointer hover:bg-control":""}`,onClick:()=>a&&g(!x),children:[e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",style:{paddingLeft:`${p}px`},children:[a?e.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),g(!x)},"aria-expanded":x,className:"inline-flex items-center gap-2 rounded focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",children:[e.jsx("span",{"aria-hidden":!0,className:`text-subtle transition-transform text-xs ${x?"rotate-90":""}`,children:"▶"}),s.icon&&e.jsx("span",{"aria-hidden":!0,children:s.icon}),e.jsx("span",{className:"font-mono text-sm text-accent",children:s.command})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"w-[0.6rem]","aria-hidden":!0}),s.icon&&e.jsx("span",{"aria-hidden":!0,children:s.icon}),e.jsx("span",{className:"font-mono text-sm text-accent",children:s.command})]}),e.jsx(Z,{command:s.command,aliases:s.aliases})]})}),e.jsx("td",{className:"px-4 py-3 text-sm text-muted",children:s.description||"—"}),e.jsx("td",{className:"px-4 py-3 text-xs text-subtle font-mono",children:Y(s)??"—"}),e.jsx("td",{className:"px-4 py-3 text-xs text-subtle text-center",children:d(((N=s.parameters)==null?void 0:N.length)??0)}),e.jsx("td",{className:"px-4 py-3 text-xs",children:e.jsx(ee,{command:s.command,permissions:s.requiredPermissions})}),l&&r===0&&(()=>{const c=l.get(s.command.toLowerCase());return e.jsxs(e.Fragment,{children:[e.jsx("td",{className:"px-4 py-3 text-xs text-right tabular-nums text-text",children:c?d(c.executions):"—"}),e.jsx("td",{className:`px-4 py-3 text-xs text-right tabular-nums ${c!=null&&c.failures?"text-error":"text-subtle"}`,children:c?d(c.failures):"—"})]})})(),l&&r>0&&e.jsxs(e.Fragment,{children:[e.jsx("td",{}),e.jsx("td",{})]})]}),x&&a&&e.jsx("tr",{className:"border-b border-border/50",children:e.jsxs("td",{colSpan:l?7:5,className:"px-4 py-3 bg-surface/50",children:[e.jsx("div",{className:"sticky left-4 max-w-[calc(100vw-4.5rem)] md:static md:max-w-none",children:e.jsx(te,{cmd:s})}),s.processors&&s.processors.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-subtle uppercase tracking-wider font-medium mb-1.5",children:n("commands.subCommands")}),e.jsx("div",{className:"bg-surface/75 border border-border/75 rounded-lg overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/75",children:[e.jsx("th",{className:"px-3 py-2 text-left text-[10px] text-subtle uppercase tracking-wide font-medium",children:n("commands.colCommand")}),e.jsx("th",{className:"px-3 py-2 text-left text-[10px] text-subtle uppercase tracking-wide font-medium",children:n("commands.colDescription")}),e.jsx("th",{className:"px-3 py-2 text-left text-[10px] text-subtle uppercase tracking-wide font-medium",children:n("commands.colModule")}),e.jsx("th",{className:"px-3 py-2 text-left text-[10px] text-subtle uppercase tracking-wide font-medium text-center",children:n("commands.colParams")}),e.jsx("th",{className:"px-3 py-2 text-left text-[10px] text-subtle uppercase tracking-wide font-medium",children:n("commands.colPermissions")})]})}),e.jsx("tbody",{children:s.processors.map(c=>e.jsx(A,{cmd:c,depth:1,search:o},c.command))})]})})]})]})})]})}function oe(){const{data:s,loading:r,error:l,refetch:o}=E(z,[]),{data:n,loading:d,refetch:i}=E(ae,[]),[x,g]=q(),h=x.get("q")??"",b=["executions","failures"].find(t=>t===x.get("sort"))??"name",{t:a,formatNumber:p,formatDate:N,formatRelative:c}=j(),v=(t,m)=>g(w=>{const C=new URLSearchParams(w);return m?C.set(t,m):C.delete(t),C},{replace:!0}),u=n?new Map(n.commands.map(t=>[t.command.toLowerCase(),t])):void 0,P=(t,m)=>{var w;return((w=u==null?void 0:u.get(t.command.toLowerCase()))==null?void 0:w[m])??0},S=(s?s.filter(t=>Q(t,h)):[]).sort((t,m)=>b==="name"||!u?t.command.localeCompare(m.command):P(m,b)-P(t,b)||t.command.localeCompare(m.command)),y=n?n.commands.filter(t=>t.executions>0).slice(0,8):[],L=n?n.commands.reduce((t,m)=>t+m.executions,0):0,$=n?n.commands.reduce((t,m)=>t+m.failures,0):0;return e.jsxs("div",{children:[e.jsx(F,{title:a("nav.commands"),subtitle:s?a("commands.subtitle",{count:s.length}):a("common.loading"),actions:e.jsx("button",{onClick:()=>{o(),i()},className:"px-3 py-1.5 text-xs bg-control hover:bg-control-hover text-text rounded-lg transition-colors",children:a("common.refresh")})}),e.jsxs("div",{className:"p-4 sm:p-6 space-y-4",children:[d&&!n&&e.jsx(T,{height:150}),n&&e.jsx(M,{title:a("commands.usage"),note:a("commands.usageSince",{time:N(n.since)}),legend:e.jsx(I,{items:[{label:a("commands.succeeded"),color:"var(--qcli-primary)",value:p(L-$)},{label:a("commands.failed"),color:"var(--qcli-error)",value:p($)}]}),children:y.length===0?e.jsx("div",{className:"text-sm text-subtle",children:a("commands.noUsage")}):e.jsx("ul",{className:"space-y-2",children:y.map(t=>e.jsx("li",{children:e.jsxs("button",{onClick:()=>v("q",t.command),className:"w-full grid grid-cols-[minmax(80px,160px)_1fr_auto] items-center gap-3 text-xs group",title:`${t.command}: ${p(t.executions)} · ${a("commands.failed")} ${p(t.failures)} · ${V(t.avgDuration)}${t.lastExecutedAt?` · ${c(t.lastExecutedAt)}`:""}`,children:[e.jsx("span",{className:"font-mono text-left truncate text-accent group-hover:underline",children:t.command}),e.jsxs("span",{className:"flex h-3 gap-[2px]","aria-hidden":!0,children:[e.jsx("span",{className:"h-full rounded-l-sm bg-primary",style:{width:`${(t.executions-t.failures)/y[0].executions*100}%`}}),t.failures>0&&e.jsx("span",{className:"h-full rounded-r-sm bg-error",style:{width:`${t.failures/y[0].executions*100}%`}})]}),e.jsxs("span",{className:"tabular-nums text-muted text-right w-24",children:[p(t.executions),t.failures>0&&e.jsxs("span",{className:"text-error",children:[" · ",p(t.failures)]})]})]})},t.command))})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("input",{type:"search",placeholder:a("commands.searchPlaceholder"),"aria-label":a("commands.searchPlaceholder"),value:h,onChange:t=>v("q",t.target.value||null),className:"w-full max-w-sm px-3 py-2 text-sm bg-control border border-border rounded-lg text-text placeholder-subtle focus:outline-none focus:border-primary/50"}),u&&e.jsx(O,{label:a("commands.sort"),size:"md",options:[{value:"name",label:a("commands.sortName")},{value:"executions",label:a("commands.sortExecutions")},{value:"failures",label:a("commands.sortFailures")}],value:b,onChange:t=>v("sort",t==="name"?null:t)})]}),r&&!s&&e.jsx(U,{rows:8,columns:n?7:5,label:a("commands.loadingCommands")}),l&&e.jsx(_,{error:l,onRetry:o}),s&&!l&&e.jsxs("div",{className:"bg-surface border border-border rounded-xl overflow-x-auto",children:[e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-border/75",children:[e.jsx("th",{className:"px-4 py-3 text-left text-xs text-subtle font-medium uppercase tracking-wide",children:a("commands.colCommand")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs text-subtle font-medium uppercase tracking-wide",children:a("commands.colDescription")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs text-subtle font-medium uppercase tracking-wide",children:a("commands.colModule")}),e.jsx("th",{className:"px-4 py-3 text-center text-xs text-subtle font-medium uppercase tracking-wide",children:a("commands.colParams")}),e.jsx("th",{className:"px-4 py-3 text-left text-xs text-subtle font-medium uppercase tracking-wide",children:a("commands.colPermissions")}),u&&e.jsxs(e.Fragment,{children:[e.jsx("th",{className:"px-4 py-3 text-right text-xs text-subtle font-medium uppercase tracking-wide",children:a("commands.colRuns")}),e.jsx("th",{className:"px-4 py-3 text-right text-xs text-subtle font-medium uppercase tracking-wide",children:a("commands.failed")})]})]})}),e.jsx("tbody",{children:S.map(t=>e.jsx(A,{cmd:t,usage:u,search:h},t.command))})]}),S.length===0&&e.jsx(H,{message:a(h?"commands.noMatch":"commands.noCommands")})]})]})]})}export{oe as default};
@@ -1,3 +1,3 @@
1
- import{j as a,ag as E,r as h,ah as O,u as k,d as I}from"./index-BquDpLoS.js";const D=/^(\d+)(ms|s|m|h|d)$/,y={ms:1,s:1e3,m:6e4,h:36e5,d:864e5};function M(t){if(typeof t!="string")return;const e=D.exec(t.trim());return e?Number(e[1])*y[e[2]]:void 0}function S(t){const e=Math.round(t);if(e===0)return"0s";for(const n of["d","h","m","s"])if(e%y[n]===0)return`${e/y[n]}${n}`;return`${e}ms`}function F(t,e){switch(t){case"boolean":return e===!0;case"string[]":return Array.isArray(e)?e.map(String):[];case"json":return e==null?"":JSON.stringify(e,null,2);case"secret":return"";default:return e==null?"":String(e)}}function A(t,e){switch(t){case"boolean":return{value:e===!0};case"string[]":return{value:Array.isArray(e)?e:[]};case"number":{const n=String(e).trim(),s=Number(n);return n===""||!Number.isFinite(s)?{problem:{key:"config.invalidNumber"}}:{value:s}}case"json":{const n=String(e).trim();if(n==="")return{problem:{key:"config.invalidJson"}};try{return{value:JSON.parse(n)}}catch{return{problem:{key:"config.invalidJson"}}}}default:return{value:String(e)}}}function R(t){return t==null||t===""||Array.isArray(t)&&t.length===0}function C(t,e){try{return new RegExp(t).test(e)}catch{return!0}}function J(t,e){var u,x;const n=t.validation??{};if(n.required&&R(e))return{key:"config.required"};const s=r=>n.min!==void 0&&r.length<n.min?{key:"config.minLength",params:{min:n.min}}:n.max!==void 0&&r.length>n.max?{key:"config.maxLength",params:{max:n.max}}:n.pattern!==void 0&&!C(n.pattern,r)?{key:"config.pattern",params:{pattern:n.pattern}}:null;switch(t.type){case"string":case"secret":{if(typeof e!="string"||e===""&&!n.required)return null;const r=s(e);return r||((u=n.options)!=null&&u.length&&!n.options.includes(e)?{key:"config.oneOf",params:{options:n.options.join(", ")}}:null)}case"url":{if(typeof e!="string"||e==="")return null;let r=/^[a-z][a-z0-9+.-]*:\/\//i.test(e);if(r)try{new URL(e)}catch{r=!1}return r?s(e):{key:"config.invalidUrl"}}case"number":return typeof e!="number"||!Number.isFinite(e)?{key:"config.invalidNumber"}:n.min!==void 0&&e<n.min?{key:"config.min",params:{min:n.min}}:n.max!==void 0&&e>n.max?{key:"config.max",params:{max:n.max}}:null;case"enum":{const r=n.options??[];return typeof e=="string"&&r.includes(e)?null:{key:"config.oneOf",params:{options:r.join(", ")}}}case"string[]":{if(!Array.isArray(e))return null;if(n.min!==void 0&&e.length<n.min)return{key:"config.minItems",params:{min:n.min}};if(n.max!==void 0&&e.length>n.max)return{key:"config.maxItems",params:{max:n.max}};for(const r of e){if(n.pattern!==void 0&&!C(n.pattern,r))return{key:"config.itemPattern",params:{item:r,pattern:n.pattern}};if((x=n.options)!=null&&x.length&&!n.options.includes(r))return{key:"config.itemOneOf",params:{item:r,options:n.options.join(", ")}}}return null}case"duration":{const r=M(e);return r===void 0?{key:"config.invalidDuration"}:n.min!==void 0&&r<n.min?{key:"config.min",params:{min:S(n.min)}}:n.max!==void 0&&r>n.max?{key:"config.max",params:{max:S(n.max)}}:null}default:return null}}function U(t,e){if(e.kind==="reset")return{value:null};const n=e.kind==="value"?{value:e.value}:A(t.type,e.draft);if("problem"in n)return n;const s=J(t,n.value);return s?{problem:s}:n}function $(t,e){return JSON.stringify(t??null)===JSON.stringify(e??null)}function H(t,e){if(e.kind==="reset")return t.sensitive?t.isSet===!0:!$(t.value,t.default);if(t.sensitive||t.type==="secret")return!0;const n=e.kind==="value"?{value:e.value}:A(t.type,e.draft);return!("value"in n)||!$(n.value,t.value)}function K(t){return t==null?"—":typeof t=="string"?t===""?'""':t:Array.isArray(t)&&t.every(e=>typeof e=="string")?t.length?t.join(", "):"[]":JSON.stringify(t)}function P(t,e){const n=e.trim().toLowerCase();return n?[t.key,t.label,t.description].some(s=>typeof s=="string"&&s.toLowerCase().includes(n)):!0}const Y=["string","number","boolean","string[]","json"],B=/^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$/;function _({extension:t,mount:e,props:n}){const{context:s}=E(t,"/"),u=h.useRef(null),x=h.useRef(void 0),r=h.useRef(n),[c,g]=h.useState(null);return h.useEffect(()=>{var l;r.current=n,(l=x.current)==null||l.update(n)}),h.useEffect(()=>{const l=u.current;if(!l)return;let o=!1;const m=document.createElement("div");return m.className=O,l.appendChild(m),(async()=>{var p;try{const f=await e(m,r.current,s);o?(p=f==null?void 0:f.unmount)==null||p.call(f):x.current=f}catch(f){o||g(f instanceof Error?f.message:String(f))}})(),()=>{var p,f;o=!0;try{(f=(p=x.current)==null?void 0:p.unmount)==null||f.call(p)}catch{}x.current=void 0,m.remove()}},[e,s]),c?a.jsx("div",{role:"alert",className:"text-xs text-error",children:c}):a.jsx("div",{ref:u,"data-config-editor":`${t.id}:${n.entry.editor??""}`})}function L({editor:t,props:e}){if(t.kind==="component"){const{Component:n}=t;return a.jsx(n,{...e})}return a.jsx(_,{extension:t.extension,mount:t.mount,props:e})}const T="w-full px-3 py-2 text-sm bg-control border rounded-lg text-text placeholder-subtle focus:outline-none focus:border-primary/50 disabled:opacity-50 disabled:cursor-not-allowed";function b(t,e="max-w-sm"){return`${T} ${e} ${t?"border-error/60":"border-border"}`}function V({id:t,value:e,onChange:n,disabled:s,label:u,invalid:x}){const{t:r}=k(),[c,g]=h.useState("");function l(){const o=c.trim();o&&!e.includes(o)&&n([...e,o]),g("")}return a.jsxs("div",{className:`flex flex-wrap gap-1.5 p-2 bg-control border rounded-lg min-h-[38px] max-w-xl ${x?"border-error/60":"border-border"} ${s?"opacity-50":""}`,children:[e.map(o=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-primary/20 text-accent rounded text-xs font-mono break-all",children:[o,!s&&a.jsx("button",{type:"button",onClick:()=>n(e.filter(m=>m!==o)),"aria-label":r("config.removeValue",{value:o}),title:r("config.removeValue",{value:o}),className:"text-accent hover:text-heading ml-0.5",children:"×"})]},o)),!s&&a.jsx("input",{id:t,type:"text",value:c,onChange:o=>g(o.target.value),onKeyDown:o=>{o.key==="Enter"||o.key===","?(o.preventDefault(),l()):o.key==="Backspace"&&c===""&&e.length>0&&n(e.slice(0,-1))},onBlur:l,placeholder:r("config.addValue"),"aria-label":u,className:"flex-1 bg-transparent text-xs text-text placeholder-subtle focus:outline-none min-w-[80px]"})]})}function z({id:t,entry:e,edit:n,onEdit:s,disabled:u,label:x,invalid:r}){const{t:c}=k();return(n==null?void 0:n.kind)==="reset"?a.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[a.jsx("span",{className:"text-warning",children:c("config.secretWillClear")}),a.jsx("button",{type:"button",onClick:()=>s(void 0),className:"px-2 py-1 rounded-md bg-control hover:bg-control-hover text-text",children:c("config.undo")})]}):(n==null?void 0:n.kind)==="set"?a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("input",{id:t,type:"password",autoComplete:"new-password",value:String(n.draft),disabled:u,onChange:g=>s({kind:"set",draft:g.target.value}),placeholder:c("config.newSecret"),"aria-label":x,"aria-invalid":r||void 0,autoFocus:!0,className:b(r,"max-w-xs")}),a.jsx("button",{type:"button",onClick:()=>s(void 0),className:"px-2 py-1 text-xs rounded-md bg-control hover:bg-control-hover text-text",children:c("config.cancelEdit")})]}):a.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[a.jsx("span",{className:"font-mono text-subtle",children:e.isSet?"••••••••":c("config.secretNotSet")}),!u&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",onClick:()=>s({kind:"set",draft:""}),className:"px-2 py-1 rounded-md bg-control hover:bg-control-hover text-text",children:e.isSet?c("config.replaceSecret"):c("config.setSecret")}),e.isSet&&a.jsx("button",{type:"button",onClick:()=>s({kind:"reset"}),className:"px-2 py-1 rounded-md bg-control hover:bg-error/15 text-error",children:c("config.clearSecret")})]})]})}function Z({id:t,entry:e,edit:n,onEdit:s,disabled:u,error:x,editors:r}){var N,j,w;const{t:c}=k(),g=e.label||e.key,l=!!x,o=(n==null?void 0:n.kind)==="set"?n.draft:F(e.type,(n==null?void 0:n.kind)==="reset"?e.default:e.value),m=i=>s({kind:"set",draft:i}),p={id:t,disabled:u,"aria-label":g,"aria-invalid":l||void 0},f=e.editor?r==null?void 0:r.get(e.editor):void 0;if(f&&!e.sensitive){const i=(n==null?void 0:n.kind)==="value"?n.value:(n==null?void 0:n.kind)==="reset"?e.default:e.value;return a.jsx(L,{editor:f,props:{entry:e,value:i,onChange:d=>s({kind:"value",value:d}),disabled:u,error:x}})}if(e.type==="secret"||e.sensitive)return a.jsx(z,{id:t,entry:e,edit:n,onEdit:s,disabled:u,label:g,invalid:l});switch(e.type){case"boolean":{const i=o===!0;return a.jsx("button",{...p,type:"button",role:"switch","aria-checked":i,onClick:()=>m(!i),title:c(i?"common.enabled":"common.disabled"),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:opacity-50 disabled:cursor-not-allowed ${i?"bg-primary":"bg-subtle"}`,children:a.jsx("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-on-primary transition-transform ${i?"translate-x-4":"translate-x-0.5"}`})})}case"string[]":return a.jsx(V,{id:t,value:Array.isArray(o)?o:[],onChange:m,disabled:u,label:g,invalid:l});case"enum":{const i=((N=e.validation)==null?void 0:N.options)??[],d=String(o);return a.jsx(I,{id:t,value:d||null,onChange:v=>m(v),options:[...!i.includes(d)&&d?[{value:d,label:d}]:[],...i.map(v=>({value:v,label:v}))],placeholder:c("config.chooseOption"),label:g,disabled:u,size:"md",width:"auto",className:l?"rounded-lg ring-1 ring-error/60":""})}case"number":return a.jsx("input",{...p,type:"number",inputMode:"decimal",min:(j=e.validation)==null?void 0:j.min,max:(w=e.validation)==null?void 0:w.max,value:String(o),onChange:i=>m(i.target.value),className:b(l,"max-w-[12rem]")});case"json":return a.jsx("textarea",{...p,value:String(o),onChange:i=>m(i.target.value),spellCheck:!1,rows:Math.min(12,Math.max(3,String(o).split(`
1
+ import{j as a,ag as E,r as h,ah as O,u as k,d as I}from"./index-BEViB6FO.js";const D=/^(\d+)(ms|s|m|h|d)$/,y={ms:1,s:1e3,m:6e4,h:36e5,d:864e5};function M(t){if(typeof t!="string")return;const e=D.exec(t.trim());return e?Number(e[1])*y[e[2]]:void 0}function S(t){const e=Math.round(t);if(e===0)return"0s";for(const n of["d","h","m","s"])if(e%y[n]===0)return`${e/y[n]}${n}`;return`${e}ms`}function F(t,e){switch(t){case"boolean":return e===!0;case"string[]":return Array.isArray(e)?e.map(String):[];case"json":return e==null?"":JSON.stringify(e,null,2);case"secret":return"";default:return e==null?"":String(e)}}function A(t,e){switch(t){case"boolean":return{value:e===!0};case"string[]":return{value:Array.isArray(e)?e:[]};case"number":{const n=String(e).trim(),s=Number(n);return n===""||!Number.isFinite(s)?{problem:{key:"config.invalidNumber"}}:{value:s}}case"json":{const n=String(e).trim();if(n==="")return{problem:{key:"config.invalidJson"}};try{return{value:JSON.parse(n)}}catch{return{problem:{key:"config.invalidJson"}}}}default:return{value:String(e)}}}function R(t){return t==null||t===""||Array.isArray(t)&&t.length===0}function C(t,e){try{return new RegExp(t).test(e)}catch{return!0}}function J(t,e){var u,x;const n=t.validation??{};if(n.required&&R(e))return{key:"config.required"};const s=r=>n.min!==void 0&&r.length<n.min?{key:"config.minLength",params:{min:n.min}}:n.max!==void 0&&r.length>n.max?{key:"config.maxLength",params:{max:n.max}}:n.pattern!==void 0&&!C(n.pattern,r)?{key:"config.pattern",params:{pattern:n.pattern}}:null;switch(t.type){case"string":case"secret":{if(typeof e!="string"||e===""&&!n.required)return null;const r=s(e);return r||((u=n.options)!=null&&u.length&&!n.options.includes(e)?{key:"config.oneOf",params:{options:n.options.join(", ")}}:null)}case"url":{if(typeof e!="string"||e==="")return null;let r=/^[a-z][a-z0-9+.-]*:\/\//i.test(e);if(r)try{new URL(e)}catch{r=!1}return r?s(e):{key:"config.invalidUrl"}}case"number":return typeof e!="number"||!Number.isFinite(e)?{key:"config.invalidNumber"}:n.min!==void 0&&e<n.min?{key:"config.min",params:{min:n.min}}:n.max!==void 0&&e>n.max?{key:"config.max",params:{max:n.max}}:null;case"enum":{const r=n.options??[];return typeof e=="string"&&r.includes(e)?null:{key:"config.oneOf",params:{options:r.join(", ")}}}case"string[]":{if(!Array.isArray(e))return null;if(n.min!==void 0&&e.length<n.min)return{key:"config.minItems",params:{min:n.min}};if(n.max!==void 0&&e.length>n.max)return{key:"config.maxItems",params:{max:n.max}};for(const r of e){if(n.pattern!==void 0&&!C(n.pattern,r))return{key:"config.itemPattern",params:{item:r,pattern:n.pattern}};if((x=n.options)!=null&&x.length&&!n.options.includes(r))return{key:"config.itemOneOf",params:{item:r,options:n.options.join(", ")}}}return null}case"duration":{const r=M(e);return r===void 0?{key:"config.invalidDuration"}:n.min!==void 0&&r<n.min?{key:"config.min",params:{min:S(n.min)}}:n.max!==void 0&&r>n.max?{key:"config.max",params:{max:S(n.max)}}:null}default:return null}}function U(t,e){if(e.kind==="reset")return{value:null};const n=e.kind==="value"?{value:e.value}:A(t.type,e.draft);if("problem"in n)return n;const s=J(t,n.value);return s?{problem:s}:n}function $(t,e){return JSON.stringify(t??null)===JSON.stringify(e??null)}function H(t,e){if(e.kind==="reset")return t.sensitive?t.isSet===!0:!$(t.value,t.default);if(t.sensitive||t.type==="secret")return!0;const n=e.kind==="value"?{value:e.value}:A(t.type,e.draft);return!("value"in n)||!$(n.value,t.value)}function K(t){return t==null?"—":typeof t=="string"?t===""?'""':t:Array.isArray(t)&&t.every(e=>typeof e=="string")?t.length?t.join(", "):"[]":JSON.stringify(t)}function P(t,e){const n=e.trim().toLowerCase();return n?[t.key,t.label,t.description].some(s=>typeof s=="string"&&s.toLowerCase().includes(n)):!0}const Y=["string","number","boolean","string[]","json"],B=/^[A-Za-z0-9_][A-Za-z0-9_.-]{0,127}$/;function _({extension:t,mount:e,props:n}){const{context:s}=E(t,"/"),u=h.useRef(null),x=h.useRef(void 0),r=h.useRef(n),[c,g]=h.useState(null);return h.useEffect(()=>{var l;r.current=n,(l=x.current)==null||l.update(n)}),h.useEffect(()=>{const l=u.current;if(!l)return;let o=!1;const m=document.createElement("div");return m.className=O,l.appendChild(m),(async()=>{var p;try{const f=await e(m,r.current,s);o?(p=f==null?void 0:f.unmount)==null||p.call(f):x.current=f}catch(f){o||g(f instanceof Error?f.message:String(f))}})(),()=>{var p,f;o=!0;try{(f=(p=x.current)==null?void 0:p.unmount)==null||f.call(p)}catch{}x.current=void 0,m.remove()}},[e,s]),c?a.jsx("div",{role:"alert",className:"text-xs text-error",children:c}):a.jsx("div",{ref:u,"data-config-editor":`${t.id}:${n.entry.editor??""}`})}function L({editor:t,props:e}){if(t.kind==="component"){const{Component:n}=t;return a.jsx(n,{...e})}return a.jsx(_,{extension:t.extension,mount:t.mount,props:e})}const T="w-full px-3 py-2 text-sm bg-control border rounded-lg text-text placeholder-subtle focus:outline-none focus:border-primary/50 disabled:opacity-50 disabled:cursor-not-allowed";function b(t,e="max-w-sm"){return`${T} ${e} ${t?"border-error/60":"border-border"}`}function V({id:t,value:e,onChange:n,disabled:s,label:u,invalid:x}){const{t:r}=k(),[c,g]=h.useState("");function l(){const o=c.trim();o&&!e.includes(o)&&n([...e,o]),g("")}return a.jsxs("div",{className:`flex flex-wrap gap-1.5 p-2 bg-control border rounded-lg min-h-[38px] max-w-xl ${x?"border-error/60":"border-border"} ${s?"opacity-50":""}`,children:[e.map(o=>a.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 bg-primary/20 text-accent rounded text-xs font-mono break-all",children:[o,!s&&a.jsx("button",{type:"button",onClick:()=>n(e.filter(m=>m!==o)),"aria-label":r("config.removeValue",{value:o}),title:r("config.removeValue",{value:o}),className:"text-accent hover:text-heading ml-0.5",children:"×"})]},o)),!s&&a.jsx("input",{id:t,type:"text",value:c,onChange:o=>g(o.target.value),onKeyDown:o=>{o.key==="Enter"||o.key===","?(o.preventDefault(),l()):o.key==="Backspace"&&c===""&&e.length>0&&n(e.slice(0,-1))},onBlur:l,placeholder:r("config.addValue"),"aria-label":u,className:"flex-1 bg-transparent text-xs text-text placeholder-subtle focus:outline-none min-w-[80px]"})]})}function z({id:t,entry:e,edit:n,onEdit:s,disabled:u,label:x,invalid:r}){const{t:c}=k();return(n==null?void 0:n.kind)==="reset"?a.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[a.jsx("span",{className:"text-warning",children:c("config.secretWillClear")}),a.jsx("button",{type:"button",onClick:()=>s(void 0),className:"px-2 py-1 rounded-md bg-control hover:bg-control-hover text-text",children:c("config.undo")})]}):(n==null?void 0:n.kind)==="set"?a.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[a.jsx("input",{id:t,type:"password",autoComplete:"new-password",value:String(n.draft),disabled:u,onChange:g=>s({kind:"set",draft:g.target.value}),placeholder:c("config.newSecret"),"aria-label":x,"aria-invalid":r||void 0,autoFocus:!0,className:b(r,"max-w-xs")}),a.jsx("button",{type:"button",onClick:()=>s(void 0),className:"px-2 py-1 text-xs rounded-md bg-control hover:bg-control-hover text-text",children:c("config.cancelEdit")})]}):a.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[a.jsx("span",{className:"font-mono text-subtle",children:e.isSet?"••••••••":c("config.secretNotSet")}),!u&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",onClick:()=>s({kind:"set",draft:""}),className:"px-2 py-1 rounded-md bg-control hover:bg-control-hover text-text",children:e.isSet?c("config.replaceSecret"):c("config.setSecret")}),e.isSet&&a.jsx("button",{type:"button",onClick:()=>s({kind:"reset"}),className:"px-2 py-1 rounded-md bg-control hover:bg-error/15 text-error",children:c("config.clearSecret")})]})]})}function Z({id:t,entry:e,edit:n,onEdit:s,disabled:u,error:x,editors:r}){var N,j,w;const{t:c}=k(),g=e.label||e.key,l=!!x,o=(n==null?void 0:n.kind)==="set"?n.draft:F(e.type,(n==null?void 0:n.kind)==="reset"?e.default:e.value),m=i=>s({kind:"set",draft:i}),p={id:t,disabled:u,"aria-label":g,"aria-invalid":l||void 0},f=e.editor?r==null?void 0:r.get(e.editor):void 0;if(f&&!e.sensitive){const i=(n==null?void 0:n.kind)==="value"?n.value:(n==null?void 0:n.kind)==="reset"?e.default:e.value;return a.jsx(L,{editor:f,props:{entry:e,value:i,onChange:d=>s({kind:"value",value:d}),disabled:u,error:x}})}if(e.type==="secret"||e.sensitive)return a.jsx(z,{id:t,entry:e,edit:n,onEdit:s,disabled:u,label:g,invalid:l});switch(e.type){case"boolean":{const i=o===!0;return a.jsx("button",{...p,type:"button",role:"switch","aria-checked":i,onClick:()=>m(!i),title:c(i?"common.enabled":"common.disabled"),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 disabled:opacity-50 disabled:cursor-not-allowed ${i?"bg-primary":"bg-subtle"}`,children:a.jsx("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-on-primary transition-transform ${i?"translate-x-4":"translate-x-0.5"}`})})}case"string[]":return a.jsx(V,{id:t,value:Array.isArray(o)?o:[],onChange:m,disabled:u,label:g,invalid:l});case"enum":{const i=((N=e.validation)==null?void 0:N.options)??[],d=String(o);return a.jsx(I,{id:t,value:d||null,onChange:v=>m(v),options:[...!i.includes(d)&&d?[{value:d,label:d}]:[],...i.map(v=>({value:v,label:v}))],placeholder:c("config.chooseOption"),label:g,disabled:u,size:"md",width:"auto",className:l?"rounded-lg ring-1 ring-error/60":""})}case"number":return a.jsx("input",{...p,type:"number",inputMode:"decimal",min:(j=e.validation)==null?void 0:j.min,max:(w=e.validation)==null?void 0:w.max,value:String(o),onChange:i=>m(i.target.value),className:b(l,"max-w-[12rem]")});case"json":return a.jsx("textarea",{...p,value:String(o),onChange:i=>m(i.target.value),spellCheck:!1,rows:Math.min(12,Math.max(3,String(o).split(`
2
2
  `).length)),className:`${b(l,"max-w-xl")} font-mono text-xs`});case"duration":return a.jsx("input",{...p,type:"text",value:String(o),onChange:i=>m(i.target.value),placeholder:c("config.durationHint"),className:`${b(l,"max-w-[12rem]")} font-mono`});case"url":return a.jsx("input",{...p,type:"url",inputMode:"url",value:String(o),onChange:i=>m(i.target.value),placeholder:"https://",className:`${b(l,"max-w-md")} font-mono`});default:return e.editor==="textarea"||e.editor==="code"?a.jsx("textarea",{...p,value:String(o),onChange:i=>m(i.target.value),rows:Math.min(10,Math.max(3,String(o).split(`
3
3
  `).length)),className:`${b(l,"max-w-xl")} ${e.editor==="code"?"font-mono text-xs":""}`}):a.jsx("input",{...p,type:"text",value:String(o),onChange:i=>m(i.target.value),className:b(l)})}}export{Z as C,Y as F,P as a,B as b,K as d,U as e,S as f,H as i,$ as s,F as t,J as v};
@@ -1,2 +1,2 @@
1
- import{u as I,N as qe,r as h,j as e,aa as Ae,d as Be,ab as Te,a as De,n as Fe,b as _e,P as Ve,E as ve,f as ae,a6 as ze,ac as Le,ad as Ye,ae as Ue,I as We,af as Ge,l as Qe,m as je,a2 as Je}from"./index-BquDpLoS.js";import{B as y}from"./Badge-nmFjKF1h.js";import{a as ke,i as Se,e as Ce,s as Xe,d as W,C as Ze,F as es,b as ss,t as ts}from"./ConfigInput-CZN2vEwy.js";const Ne={default:{label:"config.sourceDefault",hint:"config.sourceDefaultHint"},file:{label:"config.sourceFile",hint:"config.sourceFileHint"},environment:{label:"config.sourceEnvironment",hint:"config.sourceEnvironmentHint"},database:{label:"config.sourceDatabase",hint:"config.sourceDatabaseHint"},runtime:{label:"config.sourceRuntime",hint:"config.sourceRuntimeHint"},code:{label:"config.sourceCode",hint:"config.originCodeHint"}};function ns(s,t){return s==="file"&&(t==null?void 0:t.kind)==="configuration"?{label:"config.sourceConfiguration",hint:"config.sourceConfigurationHint"}:Ne[s]??Ne.default}function rs(s,t){return s(t.key,t.params)}function is(s){const{providerId:t,writable:r,storage:l,section:c,highlighted:f=!1,added:m,edits:g,serverErrors:K,query:C,saving:k,stale:b,conflict:u,editors:O,onEdit:M,onAddKey:R,onReload:F}=s,{t:v}=I(),{isPending:T}=qe(),N=r&&c.mutable,H=[...c.entries,...m].filter(x=>ke(x,C)),q=new Set(c.entries.map(x=>x.key)),_=h.useRef(null);return h.useEffect(()=>{var x,E;f&&((E=(x=_.current)==null?void 0:x.scrollIntoView)==null||E.call(x,{block:"start",behavior:"smooth"}))},[f]),e.jsxs("section",{ref:_,id:`cfg-section-${t}-${c.id}`,"aria-labelledby":`cfg-${t}-${c.id}`,"aria-current":f?"location":void 0,"data-highlighted":f||void 0,className:`bg-surface border rounded-xl overflow-hidden scroll-mt-4 ${f?"border-primary ring-2 ring-primary/40":"border-border"}`,children:[e.jsxs("div",{className:"px-4 sm:px-5 py-3 border-b border-border/75 flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("h3",{id:`cfg-${t}-${c.id}`,className:"text-sm font-semibold text-heading",children:c.title||c.id}),!N&&e.jsx(y,{variant:"neutral",children:v("config.readOnly")}),c.description&&e.jsx("p",{className:"basis-full text-xs text-subtle",children:c.description})]}),b&&e.jsxs("div",{role:"status",className:"px-4 sm:px-5 py-2 bg-warning/10 border-b border-warning/30 text-warning text-xs flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"flex-1 min-w-[12rem]",children:v("config.changedOnServer")}),e.jsx("button",{type:"button",onClick:F,className:"px-2 py-1 rounded-md border border-warning/40 hover:bg-warning/10",children:v("config.reload")})]}),u&&e.jsxs("div",{role:"alert",className:"px-4 sm:px-5 py-2 bg-error/[0.06] border-b border-error/30 text-error text-xs flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"flex-1 min-w-[12rem]",children:v("config.conflict")}),e.jsx("button",{type:"button",onClick:F,className:"px-2 py-1 rounded-md border border-error/40 hover:bg-error/10",children:v("config.reload")})]}),H.length===0&&c.entries.length+m.length>0&&e.jsx("div",{className:"px-5 py-4 text-xs text-subtle",children:v("config.noMatches")}),c.entries.length+m.length===0&&e.jsx("div",{className:"px-5 py-4 text-xs text-subtle",children:v("config.noEntries")}),e.jsx("div",{className:"divide-y divide-border/50",children:H.map(x=>e.jsx(os,{id:`cfg-${t}-${c.id}-${x.key}`,entry:x,storage:l,editable:N&&x.mutable,freeKey:c.allowCustomKeys&&!x.sensitive&&x.default===null,pendingRestart:x.requiresRestart&&T(Ae(t,c.id,x.key)),isNew:m.includes(x),edit:g[x.key],serverError:K[x.key],saving:k,editors:O,onEdit:E=>M(x.key,E)},x.key))}),N&&c.allowCustomKeys&&!C.trim()&&e.jsx(as,{taken:x=>q.has(x)||m.some(E=>E.key===x),disabled:k,onAdd:R})]})}function os({id:s,entry:t,storage:r,editable:l,freeKey:c,pendingRestart:f,isNew:m,edit:g,serverError:K,saving:C,editors:k,onEdit:b}){const{t:u}=I(),O=t.label||t.key,M=!!g&&(m||Se(t,g)),R=g&&M?Ce(t,g):null,v=(R&&"problem"in R?rs(u,R.problem):void 0)??K,T=ns(t.source,r),N=t.sensitive||t.type==="secret",H=l&&!N&&!m&&(g==null?void 0:g.kind)!=="reset"&&t.origin!=="code"&&(c||!Xe(t.value,t.default)||t.source!=="default"&&t.source!=="code"),q=N?!t.isSet:t.value===null||t.value===""||Array.isArray(t.value)&&t.value.length===0;return e.jsxs("div",{className:`px-4 sm:px-5 py-3 flex flex-col md:flex-row md:items-start gap-2 md:gap-6 ${M?"bg-primary/[0.04]":""}`,"data-config-key":t.key,children:[e.jsxs("div",{className:"md:w-64 shrink-0 min-w-0",children:[e.jsx("label",{htmlFor:s,className:"block text-sm text-text break-words",children:O}),O!==t.key&&e.jsx("div",{className:"text-[11px] font-mono text-subtle break-all",children:t.key}),t.description&&e.jsx("div",{className:"text-[11px] text-subtle mt-0.5",children:t.description}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[!m&&e.jsx("span",{title:u(T.hint),"data-source":t.source,className:"inline-flex",children:e.jsx(y,{variant:"neutral",children:u(T.label)})}),!m&&t.origin==="code"&&t.source!=="code"&&e.jsx("span",{title:u("config.originCodeHint"),"data-origin":"code",className:"inline-flex",children:e.jsx(y,{variant:"info",children:u("config.originCode")})}),!m&&t.origin==="setting"&&e.jsx("span",{title:u("config.originSettingHint"),"data-origin":"setting",className:"inline-flex",children:e.jsx(y,{variant:"success",children:u("config.originSetting")})}),t.required&&(q?e.jsx("span",{"data-required":"missing",className:"inline-flex",children:e.jsx(y,{variant:"warning",children:u("config.requiredMissing")})}):e.jsx("span",{"data-required":!0,className:"inline-flex",children:e.jsx(y,{variant:"neutral",children:u("config.required")})})),f?e.jsx("span",{title:u("restart.pendingBadgeHint"),"data-pending-restart":!0,className:"inline-flex",children:e.jsxs(y,{variant:"warning",children:["⟳ ",u("restart.pendingBadge")]})}):t.requiresRestart&&e.jsx(y,{variant:"neutral",children:u("config.restartBadge")}),!l&&e.jsx(y,{variant:"neutral",children:u("config.readOnly")}),N&&(t.isSet?e.jsx(y,{variant:"info",children:u("config.secretSet")}):e.jsx(y,{variant:"neutral",children:u("config.secretNotSet")})),M&&e.jsx(y,{variant:"info",children:u("config.modified")})]})]}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1.5",children:[l?(g==null?void 0:g.kind)==="reset"&&!N?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-warning",children:c?u("config.willRemove"):u("config.willReset",{value:W(t.default)})}),e.jsx("button",{type:"button",onClick:()=>b(void 0),className:"px-2 py-1 rounded-md bg-control hover:bg-control-hover text-text",children:u("config.undo")})]}):e.jsx(Ze,{id:s,entry:t,edit:g,onEdit:b,disabled:C,error:v,editors:k}):e.jsx("div",{id:s,className:"text-sm font-mono text-text break-all whitespace-pre-wrap",children:N?t.isSet?"••••••••":"—":W(t.value)}),v&&e.jsx("div",{role:"alert",className:"text-xs text-error",children:v}),l&&(H||g&&g.kind!=="reset")&&e.jsxs("div",{className:"flex flex-wrap gap-3 text-[11px]",children:[g&&!N&&e.jsx("button",{type:"button",onClick:()=>b(void 0),className:"text-subtle hover:text-text underline-offset-2 hover:underline",children:u("config.undo")}),H&&e.jsx("button",{type:"button",onClick:()=>b({kind:"reset"}),className:"text-subtle hover:text-text underline-offset-2 hover:underline",children:u(c?"config.removeKey":"config.resetToDefault")})]})]})]})}function as({taken:s,disabled:t,onAdd:r}){const{t:l}=I(),[c,f]=h.useState(""),[m,g]=h.useState("string"),[K,C]=h.useState(null);function k(){const b=c.trim();if(!ss.test(b))return C(l("config.invalidKey"));if(s(b))return C(l("config.keyExists",{key:b}));r({key:b,label:b,description:"",type:m,value:null,default:null,source:"runtime",mutable:!0,requiresRestart:!1,sensitive:!1}),f(""),C(null)}return e.jsxs("div",{className:"px-4 sm:px-5 py-3 border-t border-border/75",children:[e.jsx("div",{className:"text-xs font-medium text-muted mb-2",children:l("config.addKey")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("input",{type:"text",value:c,onChange:b=>{f(b.target.value),C(null)},onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),k())},placeholder:l("config.newKeyPlaceholder"),"aria-label":l("config.newKey"),disabled:t,className:"flex-1 min-w-[10rem] max-w-xs px-3 py-2 text-sm font-mono bg-control border border-border rounded-lg text-text placeholder-subtle focus:outline-none focus:border-primary/50"}),e.jsx(Be,{value:m,onChange:g,options:es.map(b=>({value:b,label:b})),label:l("config.newKeyType"),disabled:t,size:"md",width:"auto"}),e.jsx("button",{type:"button",onClick:k,disabled:t||!c.trim(),className:"px-3 py-2 text-sm bg-control hover:bg-control-hover text-text rounded-lg disabled:opacity-40",children:l("config.add")})]}),K&&e.jsx("div",{role:"alert",className:"mt-1.5 text-xs text-error",children:K})]})}const ls=new Set(["memory","database","redis"]);function D(s){return s.kind==="file"?/appsettings/i.test(`${s.detail} ${s.title}`)?"appsettings":"file":ls.has(s.kind)?s.kind:"custom"}function we(s,t){return s.store??(s.writable?t:null)}function cs(s){const t=new Map;for(const r of s){if(!r)continue;const l=D(r),c=l==="custom"?`custom:${r.title}`:l,f=t.get(c);f?f.persistent&&!r.persistent&&t.set(c,r):t.set(c,r)}return[...t.values()]}const ds={memory:"config.storeMemory",file:"config.storeFile",appsettings:"config.storeAppsettings",database:"config.storeDatabase",redis:"config.storeRedis"};function X(){const{t:s}=I();return t=>{const r=D(t);return r==="custom"?t.title||s("config.storeCustom"):s(ds[r])}}function le(){const{t:s}=I(),t=X();return r=>[[r.title||t(r),r.detail].filter(Boolean).join(": "),r.persistent?"":s("config.storeNotPersistent")].filter(Boolean).join(`
2
- `)}const us={memory:"M7 7h10v10H7zM9 3v4M15 3v4M9 17v4M15 17v4M3 9h4M3 15h4M17 9h4M17 15h4",file:"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8zM14 3v5h5M9 13h6M9 17h4",appsettings:"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8zM14 3v5h5M10 12c-1 0-1 .5-1 1.5S8.5 15 8 15c.5 0 1 .5 1 1.5s0 1.5 1 1.5M14 12c1 0 1 .5 1 1.5s.5 1.5 1 1.5c-.5 0-1 .5-1 1.5s0 1.5-1 1.5",database:"M4 6c0-1.7 3.6-3 8-3s8 1.3 8 3-3.6 3-8 3-8-1.3-8-3zM4 6v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",redis:"M12 3 3 7.5 12 12l9-4.5zM3 12l9 4.5 9-4.5M3 16.5 12 21l9-4.5",custom:"M21 8 12 3 3 8v8l9 5 9-5zM3 8l9 5 9-5M12 13v8"};function J({store:s,className:t="w-3.5 h-3.5"}){const r=D(s);return e.jsx("svg",{"data-store-icon":r,"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 ${t}`,children:e.jsx("path",{d:us[r]})})}function fs({store:s}){const t=X(),r=le();return e.jsxs("span",{"data-store-badge":D(s),title:r(s),className:`ml-auto inline-flex items-center ${s.persistent?"text-subtle":"text-warning"}`,children:[e.jsx(J,{store:s}),e.jsxs("span",{className:"sr-only",children:["(",t(s),")"]})]})}const xs={store:"config.storageStore",runtime:"config.storageRuntime",options:"config.storageOptions",environment:"config.storageEnvironment",configuration:"config.storageConfiguration",custom:"config.storageCustom"};function gs({defaultStore:s,stores:t}){const{t:r}=I(),l=X(),c=le(),f=s!==null&&!s.persistent;return e.jsxs("div",{role:f?"alert":"note","data-store-kind":s==null?void 0:s.kind,className:`px-4 sm:px-6 py-2 border-b text-xs flex flex-wrap items-center gap-x-4 gap-y-1 ${f?"bg-warning/10 border-warning/30 text-warning":"border-border/75 text-muted"}`,children:[s&&e.jsxs("div",{"data-default-store":!0,className:"flex flex-wrap items-center gap-x-1.5 gap-y-1 min-w-0",children:[e.jsx("span",{children:r("config.storeDefault")}),e.jsx(J,{store:s}),e.jsx("span",{className:"font-medium text-heading",children:l(s)}),s.detail&&e.jsx("span",{className:"font-mono break-all",children:s.detail}),f&&e.jsx("span",{className:"basis-full sm:basis-auto sm:ml-2 font-medium",children:r("config.storeNotPersistent")})]}),t.length>0&&e.jsxs("div",{"data-store-summary":!0,title:r("config.storesHint"),className:"flex flex-wrap items-center gap-x-1.5 gap-y-1 min-w-0",children:[e.jsx("span",{children:r("config.storesInUse")}),e.jsx("ul",{"aria-label":r("config.storesInUse"),className:"contents",children:t.map((m,g)=>e.jsxs("li",{className:"inline-flex items-center gap-1.5",children:[g>0&&e.jsx("span",{"aria-hidden":"true",className:"text-subtle",children:"·"}),e.jsxs("span",{"data-store-summary-item":D(m),title:c(m),className:`inline-flex items-center gap-1 ${m.persistent?"text-heading":"text-warning"}`,children:[e.jsx(J,{store:m}),l(m)]})]},`${D(m)}:${m.title}`))})]})]})}function ms({store:s}){const{t}=I(),r=X(),l=le();return e.jsxs("div",{role:s.persistent?void 0:"alert","data-provider-store":s.kind,className:`text-xs flex flex-wrap items-center gap-x-1.5 gap-y-1 ${s.persistent?"text-subtle":"p-2 rounded-lg bg-warning/10 border border-warning/30 text-warning"}`,children:[e.jsx("span",{children:t("config.storeSavedTo")}),e.jsxs("span",{title:l(s),className:"inline-flex items-center gap-1 font-medium text-heading",children:[e.jsx(J,{store:s}),r(s)]}),s.detail&&e.jsxs("span",{className:"font-mono break-all",children:["(",s.detail,")"]}),!s.persistent&&e.jsx("span",{className:"basis-full font-medium",children:t("config.storeNotPersistent")})]})}function ps({storage:s}){const{t}=I(),r=(s.sources??[]).filter(l=>typeof l=="string"&&l!=="");return e.jsxs("div",{"data-provider-storage":s.kind,className:"text-xs text-subtle space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{children:t("config.storageReadsFrom")}),e.jsx(y,{variant:"neutral",children:t(xs[s.kind]??"config.storageCustom")}),s.description&&e.jsx("span",{children:s.description}),r.length===1&&e.jsxs("span",{className:"font-mono",children:["(",r[0],")"]})]}),r.length>1&&e.jsxs("div",{children:[e.jsx("div",{children:t("config.storageSources")}),e.jsx("ol",{"aria-label":t("config.storageSources"),className:"mt-0.5 ml-4 list-decimal font-mono",children:r.map(l=>e.jsx("li",{children:l},l))})]})]})}const hs=new Map,ye=new Set;function bs(){const s=Te("config"),[t,r]=h.useState(0);return h.useEffect(()=>{const l=()=>r(c=>c+1);return ye.add(l),()=>{ye.delete(l)}},[]),h.useMemo(()=>{const l=new Map;hs.forEach((c,f)=>l.set(f,{kind:"component",Component:c}));for(const{extension:c,module:f}of s)for(const[m,g]of Object.entries(f.configEditors??{}))typeof g=="function"&&l.set(m,{kind:"module",extension:c,mount:g});return l},[s,t])}const B=(s,t)=>`${s}/${t}`;function vs({label:s}){return e.jsxs(Qe,{label:s,className:"p-4 sm:p-6 grid gap-6 lg:grid-cols-[14rem_1fr]",children:[e.jsx("div",{className:"space-y-2",children:Array.from({length:4},(t,r)=>e.jsx(je,{className:"h-8 w-full rounded-lg"},r))}),e.jsx("div",{className:"space-y-6",children:Array.from({length:2},(t,r)=>e.jsxs("div",{className:"bg-surface border border-border rounded-xl p-5 space-y-4",children:[e.jsx(je,{className:"h-4 w-40"}),e.jsx(Je,{lines:4})]},r))})]})}function ys(){const{t:s}=I(),{data:t,loading:r,error:l,refetch:c,refresh:f}=De(Ye,[]),m=bs(),g=Fe(),[K,C]=_e(),[k,b]=h.useState(""),[u,O]=h.useState({}),[M,R]=h.useState({}),[F,v]=h.useState({}),[T,N]=h.useState(new Set),[H,q]=h.useState(new Set),[_,x]=h.useState(!1),[E,ce]=h.useState(!1),[Z,ee]=h.useState(null),[se,te]=h.useState(null),P=h.useMemo(()=>[...(t==null?void 0:t.providers)??[]].sort((n,o)=>n.order-o.order||n.title.localeCompare(o.title)),[t]),Ee=K.get("provider"),w=P.find(n=>n.id===Ee)??P[0],V=K.get("section"),z=(t==null?void 0:t.defaultStore)??null,de=n=>we(n,z),ue=h.useMemo(()=>cs(P.map(n=>we(n,z))),[P,z]),fe=h.useRef(u);fe.current=u;const ne=h.useRef(new Set);h.useEffect(()=>{if(g)return g.subscribe("config:changed",n=>{const o=n;if(typeof o.provider!="string"||typeof o.section!="string")return;const i=B(o.provider,o.section);if(ne.current.has(i))return;const d=fe.current[i];d&&Object.keys(d).length>0?q(a=>new Set(a).add(i)):f()})},[g,f]);const re=h.useCallback(n=>{const o=i=>{if(!(n in i))return i;const d={...i};return delete d[n],d};O(o),R(o),v(o),N(i=>{const d=new Set(i);return d.delete(n),d}),q(i=>{const d=new Set(i);return d.delete(n),d})},[]),Me=h.useCallback(n=>{re(n),f()},[re,f]);function xe(n,o,i,d){const a=B(n,o);O(p=>{const j={...p[a]};return d?j[i]=d:delete j[i],{...p,[a]:j}}),d||R(p=>{var j;return(j=p[a])!=null&&j.some($=>$.key===i)?{...p,[a]:p[a].filter($=>$.key!==i)}:p}),v(p=>{var $;if(!(($=p[a])!=null&&$[i]))return p;const j={...p[a]};return delete j[i],{...p,[a]:j}}),te(null)}function Re(n,o,i){const d=B(n,o);R(a=>({...a,[d]:[...a[d]??[],i]})),xe(n,o,i.key,{kind:"set",draft:ts(i.type,null)})}const{pending:L,problems:G}=h.useMemo(()=>{const n=[];let o=0;for(const i of P)for(const d of i.sections){const a=B(i.id,d.id),p=u[a]??{},j=M[a]??[],$=[...d.entries,...j],pe={},ie=[];for(const[Q,he]of Object.entries(p)){const S=$.find(He=>He.key===Q);if(!S)continue;const oe=j.includes(S);if(!oe&&!Se(S,he))continue;const U=Ce(S,he);if("problem"in U){o++;continue}pe[Q]=U.value;const be=S.sensitive||S.type==="secret";ie.push({key:Q,label:S.label||Q,before:oe?"—":be?S.isSet?s("config.secretSet"):s("config.secretNotSet"):W(S.value),after:be?U.value===null?s("config.secretCleared"):s("config.secretReplaced"):U.value===null?oe||S.default===null?s("config.removed"):`${W(S.default)} (${s("config.defaultValue")})`:W(U.value),requiresRestart:S.requiresRestart})}ie.length>0&&n.push({provider:i,sectionId:d.id,title:`${i.title} › ${d.title||d.id}`,version:d.version,changes:pe,rows:ie})}return{pending:n,problems:o}},[P,u,M,s]),Y=L.reduce((n,o)=>n+o.rows.length,0);async function $e(){ce(!0),ee(null);let n=!1,o=!1;for(const i of L){const d=B(i.provider.id,i.sectionId);ne.current.add(d);try{const a=await Ue(i.provider.id,i.sectionId,i.changes,i.version);a!=null&&a.requiresRestart&&(n=!0),re(d)}catch(a){o=!0,a instanceof We?v(p=>({...p,[d]:a.errors})):a instanceof Ge?N(p=>new Set(p).add(d)):ee(`${i.title}: ${a instanceof Error?a.message:String(a)}`)}finally{ne.current.delete(d)}}ce(!1),x(!1),(!o||n)&&te(n?"restart":"saved"),f()}function Ke(){O({}),R({}),v({}),N(new Set),te(null),H.size>0&&(q(new Set),f())}const A=k.trim()!=="",ge=A?P.map(n=>({provider:n,sections:n.sections.filter(o=>[...o.entries,...M[B(n.id,o.id)]??[]].some(i=>ke(i,k)))})).filter(n=>n.sections.length>0):w?[{provider:w,sections:w.sections}]:[],me=!A&&V&&(w!=null&&w.sections.some(n=>n.id===V))?V:null,Pe=!A&&!!t&&!!V&&!!w&&!me,Ie=n=>L.some(o=>o.provider.id===n),Oe=L.some(n=>n.rows.some(o=>o.requiresRestart));return e.jsxs("div",{children:[e.jsx(Ve,{title:s("config.title"),subtitle:s("config.subtitle"),actions:e.jsxs("div",{className:"flex items-center gap-2",children:[(Y>0||G>0)&&e.jsx("button",{type:"button",onClick:Ke,disabled:E,className:"px-3 py-1.5 text-xs bg-control hover:bg-control-hover text-text rounded-lg transition-colors disabled:opacity-40",children:s("config.discard")}),e.jsx("button",{type:"button",onClick:()=>{ee(null),x(!0)},disabled:Y===0||G>0||E,title:G>0?s("config.fixProblems",{count:G}):void 0,className:"px-3 py-1.5 text-xs bg-primary hover:bg-primary-hover text-on-primary rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:Y>0?s("config.saveCount",{count:Y}):s("config.saveChanges")})]})}),(z||ue.length>0)&&e.jsx(gs,{defaultStore:z,stores:ue}),r&&!t?e.jsx(vs,{label:s("config.loading")}):l&&!t?e.jsx("div",{className:"p-4 sm:p-6",children:e.jsx(ve,{title:s("config.loadFailed"),error:l,onRetry:c})}):P.length===0?e.jsx("div",{className:"p-4 sm:p-6",children:e.jsx(ae,{message:s("config.noProviders")})}):e.jsxs("div",{className:"p-4 sm:p-6 grid gap-4 lg:gap-6 lg:grid-cols-[14rem_minmax(0,1fr)] items-start",children:[e.jsx("nav",{"aria-label":s("config.providers"),className:"lg:sticky lg:top-4 min-w-0",children:e.jsx("ul",{className:"flex lg:flex-col gap-1 overflow-x-auto -mx-4 px-4 sm:mx-0 sm:px-0 pb-1 lg:pb-0",children:P.map(n=>{const o=!A&&n.id===(w==null?void 0:w.id),i=de(n);return e.jsx("li",{className:"shrink-0",children:e.jsxs("button",{type:"button","aria-current":o?"page":void 0,onClick:()=>{b(""),C(d=>{const a=new URLSearchParams(d);return a.set("provider",n.id),a.delete("section"),a},{replace:!0})},className:`w-full text-left px-3 py-2 rounded-lg text-sm transition-colors flex items-center gap-2 whitespace-nowrap ${o?"bg-primary/15 text-heading":"text-muted hover:bg-control hover:text-text"}`,children:[e.jsx("span",{className:"truncate",children:n.title}),!n.writable&&e.jsxs("span",{className:"sr-only",children:["(",s("config.readOnly"),")"]}),i&&e.jsx(fs,{store:i}),Ie(n.id)&&e.jsx("span",{"aria-label":s("config.unsaved"),title:s("config.unsaved"),className:`${i?"":"ml-auto "}w-1.5 h-1.5 rounded-full bg-primary shrink-0`})]})},n.id)})})}),e.jsxs("div",{className:"space-y-4 min-w-0",children:[e.jsx("input",{type:"search",value:k,onChange:n=>b(n.target.value),placeholder:s("config.searchPlaceholder"),"aria-label":s("config.search"),className:"w-full max-w-md px-3 py-1.5 text-sm bg-control border border-border rounded-lg text-text placeholder-subtle focus:outline-none focus:border-primary/50"}),se&&e.jsx("div",{role:"status",className:`p-3 rounded-lg text-sm border ${se==="restart"?"bg-warning/10 border-warning/30 text-warning":"bg-success/10 border-success/30 text-success"}`,children:s(se==="restart"?"config.restartRequired":"config.saved")}),Z&&!_&&e.jsx(ve,{title:s("config.saveFailed"),error:Z,compact:!0}),A&&ge.length===0&&e.jsx(ae,{message:s("config.noMatches")}),Pe&&e.jsx("div",{role:"note",className:"p-3 rounded-lg text-sm border border-border bg-control/40 text-muted",children:s("config.sectionMissing",{section:V})}),ge.map(({provider:n,sections:o})=>{const i=de(n),d=n.storage&&!(i&&n.storage.kind==="store")?n.storage:null;return e.jsxs("div",{className:"space-y-4",children:[(A||n.description||i||d)&&e.jsxs("div",{className:"space-y-1",children:[A&&e.jsx("h2",{className:"text-sm font-semibold text-heading",children:n.title}),n.description&&e.jsx("p",{className:"text-xs text-subtle",children:n.description}),i&&e.jsx(ms,{store:i}),d&&e.jsx(ps,{storage:d})]}),o.length===0&&e.jsx(ae,{message:s("config.noSections")}),o.map(a=>{const p=B(n.id,a.id);return e.jsx(ze,{label:a.title||a.id,resetKeys:[a],children:e.jsx(is,{providerId:n.id,writable:n.writable,storage:n.storage,section:a,highlighted:n.id===(w==null?void 0:w.id)&&a.id===me,added:M[p]??[],edits:u[p]??{},serverErrors:F[p]??{},query:k,saving:E,stale:H.has(p),conflict:T.has(p),editors:m,onEdit:(j,$)=>xe(n.id,a.id,j,$),onAddKey:j=>Re(n.id,a.id,j),onReload:()=>Me(p)})},p)})]},n.id)})]})]}),e.jsx(Le,{open:_,size:"lg",title:s("config.confirmTitle"),message:e.jsxs("div",{className:"space-y-4 text-left",children:[e.jsx("p",{children:s("config.confirmMessage",{count:Y})}),L.map(n=>e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-semibold text-heading mb-1",children:n.title}),e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sr-only",children:e.jsxs("tr",{children:[e.jsx("th",{children:s("config.key")}),e.jsx("th",{children:s("config.before")}),e.jsx("th",{children:s("config.after")})]})}),e.jsx("tbody",{children:n.rows.map(o=>e.jsxs("tr",{className:"border-t border-border/50 align-top","data-diff-key":o.key,children:[e.jsxs("td",{className:"py-1.5 pr-3 text-text break-words w-1/3",children:[o.label,o.requiresRestart&&e.jsx("span",{className:"text-warning",children:" *"})]}),e.jsx("td",{className:"py-1.5 pr-3 font-mono text-error/90 line-through decoration-error/40 break-all",children:o.before}),e.jsx("td",{className:"py-1.5 font-mono text-success break-all",children:o.after})]},o.key))})]})]},`${n.provider.id}/${n.sectionId}`)),Oe&&e.jsxs("p",{className:"text-xs text-warning",children:["* ",s("config.restartBadge")]})]}),confirmLabel:s("config.confirmSave"),busyLabel:s("config.saving"),busy:E,error:Z,onConfirm:$e,onCancel:()=>x(!1)})]})}export{ys as default};
1
+ import{u as O,N as qe,r as h,j as e,aa as Ae,d as Be,ab as Te,a as De,n as Fe,b as _e,P as Ve,E as ve,f as ae,a6 as ze,ac as Le,ad as Ye,ae as Ue,L as We,af as Ge,l as Qe,m as je,a2 as Je}from"./index-BEViB6FO.js";import{B as y}from"./Badge-CuP1qfDI.js";import{a as ke,i as Se,e as Ce,s as Xe,d as W,C as Ze,F as es,b as ss,t as ts}from"./ConfigInput-B2mBPdou.js";const Ne={default:{label:"config.sourceDefault",hint:"config.sourceDefaultHint"},file:{label:"config.sourceFile",hint:"config.sourceFileHint"},environment:{label:"config.sourceEnvironment",hint:"config.sourceEnvironmentHint"},database:{label:"config.sourceDatabase",hint:"config.sourceDatabaseHint"},runtime:{label:"config.sourceRuntime",hint:"config.sourceRuntimeHint"},code:{label:"config.sourceCode",hint:"config.originCodeHint"}};function ns(s,t){return s==="file"&&(t==null?void 0:t.kind)==="configuration"?{label:"config.sourceConfiguration",hint:"config.sourceConfigurationHint"}:Ne[s]??Ne.default}function rs(s,t){return s(t.key,t.params)}function is(s){const{providerId:t,writable:r,storage:l,section:c,highlighted:f=!1,added:m,edits:g,serverErrors:K,query:C,saving:k,stale:b,conflict:u,editors:I,onEdit:M,onAddKey:R,onReload:F}=s,{t:v}=O(),{isPending:T}=qe(),N=r&&c.mutable,H=[...c.entries,...m].filter(x=>ke(x,C)),q=new Set(c.entries.map(x=>x.key)),_=h.useRef(null);return h.useEffect(()=>{var x,E;f&&((E=(x=_.current)==null?void 0:x.scrollIntoView)==null||E.call(x,{block:"start",behavior:"smooth"}))},[f]),e.jsxs("section",{ref:_,id:`cfg-section-${t}-${c.id}`,"aria-labelledby":`cfg-${t}-${c.id}`,"aria-current":f?"location":void 0,"data-highlighted":f||void 0,className:`bg-surface border rounded-xl overflow-hidden scroll-mt-4 ${f?"border-primary ring-2 ring-primary/40":"border-border"}`,children:[e.jsxs("div",{className:"px-4 sm:px-5 py-3 border-b border-border/75 flex flex-wrap items-center gap-x-3 gap-y-1",children:[e.jsx("h3",{id:`cfg-${t}-${c.id}`,className:"text-sm font-semibold text-heading",children:c.title||c.id}),!N&&e.jsx(y,{variant:"neutral",children:v("config.readOnly")}),c.description&&e.jsx("p",{className:"basis-full text-xs text-subtle",children:c.description})]}),b&&e.jsxs("div",{role:"status",className:"px-4 sm:px-5 py-2 bg-warning/10 border-b border-warning/30 text-warning text-xs flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"flex-1 min-w-[12rem]",children:v("config.changedOnServer")}),e.jsx("button",{type:"button",onClick:F,className:"px-2 py-1 rounded-md border border-warning/40 hover:bg-warning/10",children:v("config.reload")})]}),u&&e.jsxs("div",{role:"alert",className:"px-4 sm:px-5 py-2 bg-error/[0.06] border-b border-error/30 text-error text-xs flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"flex-1 min-w-[12rem]",children:v("config.conflict")}),e.jsx("button",{type:"button",onClick:F,className:"px-2 py-1 rounded-md border border-error/40 hover:bg-error/10",children:v("config.reload")})]}),H.length===0&&c.entries.length+m.length>0&&e.jsx("div",{className:"px-5 py-4 text-xs text-subtle",children:v("config.noMatches")}),c.entries.length+m.length===0&&e.jsx("div",{className:"px-5 py-4 text-xs text-subtle",children:v("config.noEntries")}),e.jsx("div",{className:"divide-y divide-border/50",children:H.map(x=>e.jsx(os,{id:`cfg-${t}-${c.id}-${x.key}`,entry:x,storage:l,editable:N&&x.mutable,freeKey:c.allowCustomKeys&&!x.sensitive&&x.default===null,pendingRestart:x.requiresRestart&&T(Ae(t,c.id,x.key)),isNew:m.includes(x),edit:g[x.key],serverError:K[x.key],saving:k,editors:I,onEdit:E=>M(x.key,E)},x.key))}),N&&c.allowCustomKeys&&!C.trim()&&e.jsx(as,{taken:x=>q.has(x)||m.some(E=>E.key===x),disabled:k,onAdd:R})]})}function os({id:s,entry:t,storage:r,editable:l,freeKey:c,pendingRestart:f,isNew:m,edit:g,serverError:K,saving:C,editors:k,onEdit:b}){const{t:u}=O(),I=t.label||t.key,M=!!g&&(m||Se(t,g)),R=g&&M?Ce(t,g):null,v=(R&&"problem"in R?rs(u,R.problem):void 0)??K,T=ns(t.source,r),N=t.sensitive||t.type==="secret",H=l&&!N&&!m&&(g==null?void 0:g.kind)!=="reset"&&t.origin!=="code"&&(c||!Xe(t.value,t.default)||t.source!=="default"&&t.source!=="code"),q=N?!t.isSet:t.value===null||t.value===""||Array.isArray(t.value)&&t.value.length===0;return e.jsxs("div",{className:`px-4 sm:px-5 py-3 flex flex-col md:flex-row md:items-start gap-2 md:gap-6 ${M?"bg-primary/[0.04]":""}`,"data-config-key":t.key,children:[e.jsxs("div",{className:"md:w-64 shrink-0 min-w-0",children:[e.jsx("label",{htmlFor:s,className:"block text-sm text-text break-words",children:I}),I!==t.key&&e.jsx("div",{className:"text-[11px] font-mono text-subtle break-all",children:t.key}),t.description&&e.jsx("div",{className:"text-[11px] text-subtle mt-0.5",children:t.description}),e.jsxs("div",{className:"flex flex-wrap gap-1 mt-1.5",children:[!m&&e.jsx("span",{title:u(T.hint),"data-source":t.source,className:"inline-flex",children:e.jsx(y,{variant:"neutral",children:u(T.label)})}),!m&&t.origin==="code"&&t.source!=="code"&&e.jsx("span",{title:u("config.originCodeHint"),"data-origin":"code",className:"inline-flex",children:e.jsx(y,{variant:"info",children:u("config.originCode")})}),!m&&t.origin==="setting"&&e.jsx("span",{title:u("config.originSettingHint"),"data-origin":"setting",className:"inline-flex",children:e.jsx(y,{variant:"success",children:u("config.originSetting")})}),t.required&&(q?e.jsx("span",{"data-required":"missing",className:"inline-flex",children:e.jsx(y,{variant:"warning",children:u("config.requiredMissing")})}):e.jsx("span",{"data-required":!0,className:"inline-flex",children:e.jsx(y,{variant:"neutral",children:u("config.required")})})),f?e.jsx("span",{title:u("restart.pendingBadgeHint"),"data-pending-restart":!0,className:"inline-flex",children:e.jsxs(y,{variant:"warning",children:["⟳ ",u("restart.pendingBadge")]})}):t.requiresRestart&&e.jsx(y,{variant:"neutral",children:u("config.restartBadge")}),!l&&e.jsx(y,{variant:"neutral",children:u("config.readOnly")}),N&&(t.isSet?e.jsx(y,{variant:"info",children:u("config.secretSet")}):e.jsx(y,{variant:"neutral",children:u("config.secretNotSet")})),M&&e.jsx(y,{variant:"info",children:u("config.modified")})]})]}),e.jsxs("div",{className:"flex-1 min-w-0 space-y-1.5",children:[l?(g==null?void 0:g.kind)==="reset"&&!N?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-warning",children:c?u("config.willRemove"):u("config.willReset",{value:W(t.default)})}),e.jsx("button",{type:"button",onClick:()=>b(void 0),className:"px-2 py-1 rounded-md bg-control hover:bg-control-hover text-text",children:u("config.undo")})]}):e.jsx(Ze,{id:s,entry:t,edit:g,onEdit:b,disabled:C,error:v,editors:k}):e.jsx("div",{id:s,className:"text-sm font-mono text-text break-all whitespace-pre-wrap",children:N?t.isSet?"••••••••":"—":W(t.value)}),v&&e.jsx("div",{role:"alert",className:"text-xs text-error",children:v}),l&&(H||g&&g.kind!=="reset")&&e.jsxs("div",{className:"flex flex-wrap gap-3 text-[11px]",children:[g&&!N&&e.jsx("button",{type:"button",onClick:()=>b(void 0),className:"text-subtle hover:text-text underline-offset-2 hover:underline",children:u("config.undo")}),H&&e.jsx("button",{type:"button",onClick:()=>b({kind:"reset"}),className:"text-subtle hover:text-text underline-offset-2 hover:underline",children:u(c?"config.removeKey":"config.resetToDefault")})]})]})]})}function as({taken:s,disabled:t,onAdd:r}){const{t:l}=O(),[c,f]=h.useState(""),[m,g]=h.useState("string"),[K,C]=h.useState(null);function k(){const b=c.trim();if(!ss.test(b))return C(l("config.invalidKey"));if(s(b))return C(l("config.keyExists",{key:b}));r({key:b,label:b,description:"",type:m,value:null,default:null,source:"runtime",mutable:!0,requiresRestart:!1,sensitive:!1}),f(""),C(null)}return e.jsxs("div",{className:"px-4 sm:px-5 py-3 border-t border-border/75",children:[e.jsx("div",{className:"text-xs font-medium text-muted mb-2",children:l("config.addKey")}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("input",{type:"text",value:c,onChange:b=>{f(b.target.value),C(null)},onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),k())},placeholder:l("config.newKeyPlaceholder"),"aria-label":l("config.newKey"),disabled:t,className:"flex-1 min-w-[10rem] max-w-xs px-3 py-2 text-sm font-mono bg-control border border-border rounded-lg text-text placeholder-subtle focus:outline-none focus:border-primary/50"}),e.jsx(Be,{value:m,onChange:g,options:es.map(b=>({value:b,label:b})),label:l("config.newKeyType"),disabled:t,size:"md",width:"auto"}),e.jsx("button",{type:"button",onClick:k,disabled:t||!c.trim(),className:"px-3 py-2 text-sm bg-control hover:bg-control-hover text-text rounded-lg disabled:opacity-40",children:l("config.add")})]}),K&&e.jsx("div",{role:"alert",className:"mt-1.5 text-xs text-error",children:K})]})}const ls=new Set(["memory","database","redis"]);function D(s){return s.kind==="file"?/appsettings/i.test(`${s.detail} ${s.title}`)?"appsettings":"file":ls.has(s.kind)?s.kind:"custom"}function we(s,t){return s.store??(s.writable?t:null)}function cs(s){const t=new Map;for(const r of s){if(!r)continue;const l=D(r),c=l==="custom"?`custom:${r.title}`:l,f=t.get(c);f?f.persistent&&!r.persistent&&t.set(c,r):t.set(c,r)}return[...t.values()]}const ds={memory:"config.storeMemory",file:"config.storeFile",appsettings:"config.storeAppsettings",database:"config.storeDatabase",redis:"config.storeRedis"};function X(){const{t:s}=O();return t=>{const r=D(t);return r==="custom"?t.title||s("config.storeCustom"):s(ds[r])}}function le(){const{t:s}=O(),t=X();return r=>[[r.title||t(r),r.detail].filter(Boolean).join(": "),r.persistent?"":s("config.storeNotPersistent")].filter(Boolean).join(`
2
+ `)}const us={memory:"M7 7h10v10H7zM9 3v4M15 3v4M9 17v4M15 17v4M3 9h4M3 15h4M17 9h4M17 15h4",file:"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8zM14 3v5h5M9 13h6M9 17h4",appsettings:"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8zM14 3v5h5M10 12c-1 0-1 .5-1 1.5S8.5 15 8 15c.5 0 1 .5 1 1.5s0 1.5 1 1.5M14 12c1 0 1 .5 1 1.5s.5 1.5 1 1.5c-.5 0-1 .5-1 1.5s0 1.5-1 1.5",database:"M4 6c0-1.7 3.6-3 8-3s8 1.3 8 3-3.6 3-8 3-8-1.3-8-3zM4 6v12c0 1.7 3.6 3 8 3s8-1.3 8-3V6M4 12c0 1.7 3.6 3 8 3s8-1.3 8-3",redis:"M12 3 3 7.5 12 12l9-4.5zM3 12l9 4.5 9-4.5M3 16.5 12 21l9-4.5",custom:"M21 8 12 3 3 8v8l9 5 9-5zM3 8l9 5 9-5M12 13v8"};function J({store:s,className:t="w-3.5 h-3.5"}){const r=D(s);return e.jsx("svg",{"data-store-icon":r,"aria-hidden":"true",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.75,strokeLinecap:"round",strokeLinejoin:"round",className:`shrink-0 ${t}`,children:e.jsx("path",{d:us[r]})})}function fs({store:s}){const t=X(),r=le();return e.jsxs("span",{"data-store-badge":D(s),title:r(s),className:`ml-auto inline-flex items-center ${s.persistent?"text-subtle":"text-warning"}`,children:[e.jsx(J,{store:s}),e.jsxs("span",{className:"sr-only",children:["(",t(s),")"]})]})}const xs={store:"config.storageStore",runtime:"config.storageRuntime",options:"config.storageOptions",environment:"config.storageEnvironment",configuration:"config.storageConfiguration",custom:"config.storageCustom"};function gs({defaultStore:s,stores:t}){const{t:r}=O(),l=X(),c=le(),f=s!==null&&!s.persistent;return e.jsxs("div",{role:f?"alert":"note","data-store-kind":s==null?void 0:s.kind,className:`px-4 sm:px-6 py-2 border-b text-xs flex flex-wrap items-center gap-x-4 gap-y-1 ${f?"bg-warning/10 border-warning/30 text-warning":"border-border/75 text-muted"}`,children:[s&&e.jsxs("div",{"data-default-store":!0,className:"flex flex-wrap items-center gap-x-1.5 gap-y-1 min-w-0",children:[e.jsx("span",{children:r("config.storeDefault")}),e.jsx(J,{store:s}),e.jsx("span",{className:"font-medium text-heading",children:l(s)}),s.detail&&e.jsx("span",{className:"font-mono break-all",children:s.detail}),f&&e.jsx("span",{className:"basis-full sm:basis-auto sm:ml-2 font-medium",children:r("config.storeNotPersistent")})]}),t.length>0&&e.jsxs("div",{"data-store-summary":!0,title:r("config.storesHint"),className:"flex flex-wrap items-center gap-x-1.5 gap-y-1 min-w-0",children:[e.jsx("span",{children:r("config.storesInUse")}),e.jsx("ul",{"aria-label":r("config.storesInUse"),className:"contents",children:t.map((m,g)=>e.jsxs("li",{className:"inline-flex items-center gap-1.5",children:[g>0&&e.jsx("span",{"aria-hidden":"true",className:"text-subtle",children:"·"}),e.jsxs("span",{"data-store-summary-item":D(m),title:c(m),className:`inline-flex items-center gap-1 ${m.persistent?"text-heading":"text-warning"}`,children:[e.jsx(J,{store:m}),l(m)]})]},`${D(m)}:${m.title}`))})]})]})}function ms({store:s}){const{t}=O(),r=X(),l=le();return e.jsxs("div",{role:s.persistent?void 0:"alert","data-provider-store":s.kind,className:`text-xs flex flex-wrap items-center gap-x-1.5 gap-y-1 ${s.persistent?"text-subtle":"p-2 rounded-lg bg-warning/10 border border-warning/30 text-warning"}`,children:[e.jsx("span",{children:t("config.storeSavedTo")}),e.jsxs("span",{title:l(s),className:"inline-flex items-center gap-1 font-medium text-heading",children:[e.jsx(J,{store:s}),r(s)]}),s.detail&&e.jsxs("span",{className:"font-mono break-all",children:["(",s.detail,")"]}),!s.persistent&&e.jsx("span",{className:"basis-full font-medium",children:t("config.storeNotPersistent")})]})}function ps({storage:s}){const{t}=O(),r=(s.sources??[]).filter(l=>typeof l=="string"&&l!=="");return e.jsxs("div",{"data-provider-storage":s.kind,className:"text-xs text-subtle space-y-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{children:t("config.storageReadsFrom")}),e.jsx(y,{variant:"neutral",children:t(xs[s.kind]??"config.storageCustom")}),s.description&&e.jsx("span",{children:s.description}),r.length===1&&e.jsxs("span",{className:"font-mono",children:["(",r[0],")"]})]}),r.length>1&&e.jsxs("div",{children:[e.jsx("div",{children:t("config.storageSources")}),e.jsx("ol",{"aria-label":t("config.storageSources"),className:"mt-0.5 ml-4 list-decimal font-mono",children:r.map(l=>e.jsx("li",{children:l},l))})]})]})}const hs=new Map,ye=new Set;function bs(){const s=Te("config"),[t,r]=h.useState(0);return h.useEffect(()=>{const l=()=>r(c=>c+1);return ye.add(l),()=>{ye.delete(l)}},[]),h.useMemo(()=>{const l=new Map;hs.forEach((c,f)=>l.set(f,{kind:"component",Component:c}));for(const{extension:c,module:f}of s)for(const[m,g]of Object.entries(f.configEditors??{}))typeof g=="function"&&l.set(m,{kind:"module",extension:c,mount:g});return l},[s,t])}const B=(s,t)=>`${s}/${t}`;function vs({label:s}){return e.jsxs(Qe,{label:s,className:"p-4 sm:p-6 grid gap-6 lg:grid-cols-[14rem_1fr]",children:[e.jsx("div",{className:"space-y-2",children:Array.from({length:4},(t,r)=>e.jsx(je,{className:"h-8 w-full rounded-lg"},r))}),e.jsx("div",{className:"space-y-6",children:Array.from({length:2},(t,r)=>e.jsxs("div",{className:"bg-surface border border-border rounded-xl p-5 space-y-4",children:[e.jsx(je,{className:"h-4 w-40"}),e.jsx(Je,{lines:4})]},r))})]})}function ys(){const{t:s}=O(),{data:t,loading:r,error:l,refetch:c,refresh:f}=De(Ye,[]),m=bs(),g=Fe(),[K,C]=_e(),[k,b]=h.useState(""),[u,I]=h.useState({}),[M,R]=h.useState({}),[F,v]=h.useState({}),[T,N]=h.useState(new Set),[H,q]=h.useState(new Set),[_,x]=h.useState(!1),[E,ce]=h.useState(!1),[Z,ee]=h.useState(null),[se,te]=h.useState(null),P=h.useMemo(()=>[...(t==null?void 0:t.providers)??[]].sort((n,o)=>n.order-o.order||n.title.localeCompare(o.title)),[t]),Ee=K.get("provider"),w=P.find(n=>n.id===Ee)??P[0],V=K.get("section"),z=(t==null?void 0:t.defaultStore)??null,de=n=>we(n,z),ue=h.useMemo(()=>cs(P.map(n=>we(n,z))),[P,z]),fe=h.useRef(u);fe.current=u;const ne=h.useRef(new Set);h.useEffect(()=>{if(g)return g.subscribe("config:changed",n=>{const o=n;if(typeof o.provider!="string"||typeof o.section!="string")return;const i=B(o.provider,o.section);if(ne.current.has(i))return;const d=fe.current[i];d&&Object.keys(d).length>0?q(a=>new Set(a).add(i)):f()})},[g,f]);const re=h.useCallback(n=>{const o=i=>{if(!(n in i))return i;const d={...i};return delete d[n],d};I(o),R(o),v(o),N(i=>{const d=new Set(i);return d.delete(n),d}),q(i=>{const d=new Set(i);return d.delete(n),d})},[]),Me=h.useCallback(n=>{re(n),f()},[re,f]);function xe(n,o,i,d){const a=B(n,o);I(p=>{const j={...p[a]};return d?j[i]=d:delete j[i],{...p,[a]:j}}),d||R(p=>{var j;return(j=p[a])!=null&&j.some($=>$.key===i)?{...p,[a]:p[a].filter($=>$.key!==i)}:p}),v(p=>{var $;if(!(($=p[a])!=null&&$[i]))return p;const j={...p[a]};return delete j[i],{...p,[a]:j}}),te(null)}function Re(n,o,i){const d=B(n,o);R(a=>({...a,[d]:[...a[d]??[],i]})),xe(n,o,i.key,{kind:"set",draft:ts(i.type,null)})}const{pending:L,problems:G}=h.useMemo(()=>{const n=[];let o=0;for(const i of P)for(const d of i.sections){const a=B(i.id,d.id),p=u[a]??{},j=M[a]??[],$=[...d.entries,...j],pe={},ie=[];for(const[Q,he]of Object.entries(p)){const S=$.find(He=>He.key===Q);if(!S)continue;const oe=j.includes(S);if(!oe&&!Se(S,he))continue;const U=Ce(S,he);if("problem"in U){o++;continue}pe[Q]=U.value;const be=S.sensitive||S.type==="secret";ie.push({key:Q,label:S.label||Q,before:oe?"—":be?S.isSet?s("config.secretSet"):s("config.secretNotSet"):W(S.value),after:be?U.value===null?s("config.secretCleared"):s("config.secretReplaced"):U.value===null?oe||S.default===null?s("config.removed"):`${W(S.default)} (${s("config.defaultValue")})`:W(U.value),requiresRestart:S.requiresRestart})}ie.length>0&&n.push({provider:i,sectionId:d.id,title:`${i.title} › ${d.title||d.id}`,version:d.version,changes:pe,rows:ie})}return{pending:n,problems:o}},[P,u,M,s]),Y=L.reduce((n,o)=>n+o.rows.length,0);async function $e(){ce(!0),ee(null);let n=!1,o=!1;for(const i of L){const d=B(i.provider.id,i.sectionId);ne.current.add(d);try{const a=await Ue(i.provider.id,i.sectionId,i.changes,i.version);a!=null&&a.requiresRestart&&(n=!0),re(d)}catch(a){o=!0,a instanceof We?v(p=>({...p,[d]:a.errors})):a instanceof Ge?N(p=>new Set(p).add(d)):ee(`${i.title}: ${a instanceof Error?a.message:String(a)}`)}finally{ne.current.delete(d)}}ce(!1),x(!1),(!o||n)&&te(n?"restart":"saved"),f()}function Ke(){I({}),R({}),v({}),N(new Set),te(null),H.size>0&&(q(new Set),f())}const A=k.trim()!=="",ge=A?P.map(n=>({provider:n,sections:n.sections.filter(o=>[...o.entries,...M[B(n.id,o.id)]??[]].some(i=>ke(i,k)))})).filter(n=>n.sections.length>0):w?[{provider:w,sections:w.sections}]:[],me=!A&&V&&(w!=null&&w.sections.some(n=>n.id===V))?V:null,Pe=!A&&!!t&&!!V&&!!w&&!me,Oe=n=>L.some(o=>o.provider.id===n),Ie=L.some(n=>n.rows.some(o=>o.requiresRestart));return e.jsxs("div",{children:[e.jsx(Ve,{title:s("config.title"),subtitle:s("config.subtitle"),actions:e.jsxs("div",{className:"flex items-center gap-2",children:[(Y>0||G>0)&&e.jsx("button",{type:"button",onClick:Ke,disabled:E,className:"px-3 py-1.5 text-xs bg-control hover:bg-control-hover text-text rounded-lg transition-colors disabled:opacity-40",children:s("config.discard")}),e.jsx("button",{type:"button",onClick:()=>{ee(null),x(!0)},disabled:Y===0||G>0||E,title:G>0?s("config.fixProblems",{count:G}):void 0,className:"px-3 py-1.5 text-xs bg-primary hover:bg-primary-hover text-on-primary rounded-lg transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:Y>0?s("config.saveCount",{count:Y}):s("config.saveChanges")})]})}),(z||ue.length>0)&&e.jsx(gs,{defaultStore:z,stores:ue}),r&&!t?e.jsx(vs,{label:s("config.loading")}):l&&!t?e.jsx("div",{className:"p-4 sm:p-6",children:e.jsx(ve,{title:s("config.loadFailed"),error:l,onRetry:c})}):P.length===0?e.jsx("div",{className:"p-4 sm:p-6",children:e.jsx(ae,{message:s("config.noProviders")})}):e.jsxs("div",{className:"p-4 sm:p-6 grid gap-4 lg:gap-6 lg:grid-cols-[14rem_minmax(0,1fr)] items-start",children:[e.jsx("nav",{"aria-label":s("config.providers"),className:"lg:sticky lg:top-4 min-w-0",children:e.jsx("ul",{className:"flex lg:flex-col gap-1 overflow-x-auto -mx-4 px-4 sm:mx-0 sm:px-0 pb-1 lg:pb-0",children:P.map(n=>{const o=!A&&n.id===(w==null?void 0:w.id),i=de(n);return e.jsx("li",{className:"shrink-0",children:e.jsxs("button",{type:"button","aria-current":o?"page":void 0,onClick:()=>{b(""),C(d=>{const a=new URLSearchParams(d);return a.set("provider",n.id),a.delete("section"),a},{replace:!0})},className:`w-full text-left px-3 py-2 rounded-lg text-sm transition-colors flex items-center gap-2 whitespace-nowrap ${o?"bg-primary/15 text-heading":"text-muted hover:bg-control hover:text-text"}`,children:[e.jsx("span",{className:"truncate",children:n.title}),!n.writable&&e.jsxs("span",{className:"sr-only",children:["(",s("config.readOnly"),")"]}),i&&e.jsx(fs,{store:i}),Oe(n.id)&&e.jsx("span",{"aria-label":s("config.unsaved"),title:s("config.unsaved"),className:`${i?"":"ml-auto "}w-1.5 h-1.5 rounded-full bg-primary shrink-0`})]})},n.id)})})}),e.jsxs("div",{className:"space-y-4 min-w-0",children:[e.jsx("input",{type:"search",value:k,onChange:n=>b(n.target.value),placeholder:s("config.searchPlaceholder"),"aria-label":s("config.search"),className:"w-full max-w-md px-3 py-1.5 text-sm bg-control border border-border rounded-lg text-text placeholder-subtle focus:outline-none focus:border-primary/50"}),se&&e.jsx("div",{role:"status",className:`p-3 rounded-lg text-sm border ${se==="restart"?"bg-warning/10 border-warning/30 text-warning":"bg-success/10 border-success/30 text-success"}`,children:s(se==="restart"?"config.restartRequired":"config.saved")}),Z&&!_&&e.jsx(ve,{title:s("config.saveFailed"),error:Z,compact:!0}),A&&ge.length===0&&e.jsx(ae,{message:s("config.noMatches")}),Pe&&e.jsx("div",{role:"note",className:"p-3 rounded-lg text-sm border border-border bg-control/40 text-muted",children:s("config.sectionMissing",{section:V})}),ge.map(({provider:n,sections:o})=>{const i=de(n),d=n.storage&&!(i&&n.storage.kind==="store")?n.storage:null;return e.jsxs("div",{className:"space-y-4",children:[(A||n.description||i||d)&&e.jsxs("div",{className:"space-y-1",children:[A&&e.jsx("h2",{className:"text-sm font-semibold text-heading",children:n.title}),n.description&&e.jsx("p",{className:"text-xs text-subtle",children:n.description}),i&&e.jsx(ms,{store:i}),d&&e.jsx(ps,{storage:d})]}),o.length===0&&e.jsx(ae,{message:s("config.noSections")}),o.map(a=>{const p=B(n.id,a.id);return e.jsx(ze,{label:a.title||a.id,resetKeys:[a],children:e.jsx(is,{providerId:n.id,writable:n.writable,storage:n.storage,section:a,highlighted:n.id===(w==null?void 0:w.id)&&a.id===me,added:M[p]??[],edits:u[p]??{},serverErrors:F[p]??{},query:k,saving:E,stale:H.has(p),conflict:T.has(p),editors:m,onEdit:(j,$)=>xe(n.id,a.id,j,$),onAddKey:j=>Re(n.id,a.id,j),onReload:()=>Me(p)})},p)})]},n.id)})]})]}),e.jsx(Le,{open:_,size:"lg",title:s("config.confirmTitle"),message:e.jsxs("div",{className:"space-y-4 text-left",children:[e.jsx("p",{children:s("config.confirmMessage",{count:Y})}),L.map(n=>e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-semibold text-heading mb-1",children:n.title}),e.jsxs("table",{className:"w-full text-xs",children:[e.jsx("thead",{className:"sr-only",children:e.jsxs("tr",{children:[e.jsx("th",{children:s("config.key")}),e.jsx("th",{children:s("config.before")}),e.jsx("th",{children:s("config.after")})]})}),e.jsx("tbody",{children:n.rows.map(o=>e.jsxs("tr",{className:"border-t border-border/50 align-top","data-diff-key":o.key,children:[e.jsxs("td",{className:"py-1.5 pr-3 text-text break-words w-1/3",children:[o.label,o.requiresRestart&&e.jsx("span",{className:"text-warning",children:" *"})]}),e.jsx("td",{className:"py-1.5 pr-3 font-mono text-error/90 line-through decoration-error/40 break-all",children:o.before}),e.jsx("td",{className:"py-1.5 font-mono text-success break-all",children:o.after})]},o.key))})]})]},`${n.provider.id}/${n.sectionId}`)),Ie&&e.jsxs("p",{className:"text-xs text-warning",children:["* ",s("config.restartBadge")]})]}),confirmLabel:s("config.confirmSave"),busyLabel:s("config.saving"),busy:E,error:Z,onConfirm:$e,onCancel:()=>x(!1)})]})}export{ys as default};
@@ -1 +1 @@
1
- import{i as b,j as s,a6 as h,r as g,f as j}from"./index-BquDpLoS.js";import{b as N}from"./paging-CCKbuXJo.js";function k(i,d,o){const c=o==="asc"?1:-1,x=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});return i.map((r,n)=>({row:r,index:n,value:d(r)})).sort((r,n)=>{const l=r.value===null||r.value===void 0||r.value==="",u=n.value===null||n.value===void 0||n.value==="";if(l||u)return l===u?r.index-n.index:l?1:-1;const a=typeof r.value=="number"&&typeof n.value=="number"?r.value-n.value:x.compare(String(r.value),String(n.value));return a!==0?a*c:r.index-n.index}).map(r=>r.row)}function E({columns:i,data:d,onRowClick:o,keyExtractor:c,defaultSort:x,page:r,emptyMessage:n,plain:l=!1}){const{t:u}=b(),[a,f]=g.useState(x??null),m=a?i.find(e=>e.key===a.key&&e.sortValue):void 0,v=m&&a?k(d,m.sortValue,a.direction):d,y=r?N(v,r.index,r.size):v;function p(e){f(t=>(t==null?void 0:t.key)===e?{key:e,direction:t.direction==="asc"?"desc":"asc"}:{key:e,direction:"asc"})}return s.jsxs("div",{className:l?"overflow-x-auto":"bg-surface border border-border rounded-xl overflow-x-auto",children:[s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsx("tr",{className:"border-b border-border/75",children:i.map(e=>{const t=(a==null?void 0:a.key)===e.key&&!!e.sortValue;return s.jsx("th",{"aria-sort":t?a.direction==="asc"?"ascending":"descending":void 0,className:`px-4 py-3 text-left text-xs text-subtle font-medium uppercase tracking-wide ${e.className??""}`,children:e.sortValue?s.jsxs("button",{type:"button",onClick:()=>p(e.key),title:u("sortBy",{column:e.header}),className:`inline-flex items-center gap-1 uppercase tracking-wide hover:text-text ${t?"text-text":""}`,children:[e.header,s.jsx("span",{"aria-hidden":!0,className:`text-[9px] ${t?"":"opacity-30"}`,children:t&&a.direction==="desc"?"▼":"▲"})]}):e.header},e.key)})})}),s.jsx("tbody",{children:y.map(e=>s.jsx("tr",{onClick:o?()=>o(e):void 0,onKeyDown:o?t=>{t.target!==t.currentTarget||t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),o(e))}:void 0,tabIndex:o?0:void 0,className:`border-b border-border/50 last:border-0 ${o?"cursor-pointer hover:bg-control focus-visible:bg-control focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary/60":""}`,children:i.map(t=>s.jsx("td",{className:`px-4 py-3 text-text ${t.className??""}`,children:t.render?t.render(e):String(e[t.key]??"")},t.key))},c(e)))})]}),d.length===0&&(n??s.jsx(j,{}))]})}function $(i){const{t:d}=b();return s.jsx(h,{label:d("table"),resetKeys:[i.data],children:s.jsx(E,{...i})})}export{$ as D};
1
+ import{i as b,j as s,a6 as h,r as g,f as j}from"./index-BEViB6FO.js";import{b as N}from"./paging-CCKbuXJo.js";function k(i,d,o){const c=o==="asc"?1:-1,x=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"});return i.map((r,n)=>({row:r,index:n,value:d(r)})).sort((r,n)=>{const l=r.value===null||r.value===void 0||r.value==="",u=n.value===null||n.value===void 0||n.value==="";if(l||u)return l===u?r.index-n.index:l?1:-1;const a=typeof r.value=="number"&&typeof n.value=="number"?r.value-n.value:x.compare(String(r.value),String(n.value));return a!==0?a*c:r.index-n.index}).map(r=>r.row)}function E({columns:i,data:d,onRowClick:o,keyExtractor:c,defaultSort:x,page:r,emptyMessage:n,plain:l=!1}){const{t:u}=b(),[a,f]=g.useState(x??null),m=a?i.find(e=>e.key===a.key&&e.sortValue):void 0,v=m&&a?k(d,m.sortValue,a.direction):d,y=r?N(v,r.index,r.size):v;function p(e){f(t=>(t==null?void 0:t.key)===e?{key:e,direction:t.direction==="asc"?"desc":"asc"}:{key:e,direction:"asc"})}return s.jsxs("div",{className:l?"overflow-x-auto":"bg-surface border border-border rounded-xl overflow-x-auto",children:[s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsx("tr",{className:"border-b border-border/75",children:i.map(e=>{const t=(a==null?void 0:a.key)===e.key&&!!e.sortValue;return s.jsx("th",{"aria-sort":t?a.direction==="asc"?"ascending":"descending":void 0,className:`px-4 py-3 text-left text-xs text-subtle font-medium uppercase tracking-wide ${e.className??""}`,children:e.sortValue?s.jsxs("button",{type:"button",onClick:()=>p(e.key),title:u("sortBy",{column:e.header}),className:`inline-flex items-center gap-1 uppercase tracking-wide hover:text-text ${t?"text-text":""}`,children:[e.header,s.jsx("span",{"aria-hidden":!0,className:`text-[9px] ${t?"":"opacity-30"}`,children:t&&a.direction==="desc"?"▼":"▲"})]}):e.header},e.key)})})}),s.jsx("tbody",{children:y.map(e=>s.jsx("tr",{onClick:o?()=>o(e):void 0,onKeyDown:o?t=>{t.target!==t.currentTarget||t.key!=="Enter"&&t.key!==" "||(t.preventDefault(),o(e))}:void 0,tabIndex:o?0:void 0,className:`border-b border-border/50 last:border-0 ${o?"cursor-pointer hover:bg-control focus-visible:bg-control focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary/60":""}`,children:i.map(t=>s.jsx("td",{className:`px-4 py-3 text-text ${t.className??""}`,children:t.render?t.render(e):String(e[t.key]??"")},t.key))},c(e)))})]}),d.length===0&&(n??s.jsx(j,{}))]})}function $(i){const{t:d}=b();return s.jsx(h,{label:d("table"),resetKeys:[i.data],children:s.jsx(E,{...i})})}export{$ as D};
@@ -1,2 +1,2 @@
1
- import{r,J as K,a5 as q,u as M,b as U,a as G,j as s,P as X,a6 as H,d as Y,f as V,a7 as z,a8 as Q,E as Z,e as $}from"./index-BquDpLoS.js";import{B as I}from"./Badge-nmFjKF1h.js";import{B as ee}from"./ButtonGroup-BGrKcSx4.js";import{D as te}from"./DataTable-GXA3iZq9.js";import"./paging-CCKbuXJo.js";const se=1500;function O(t,u,c){clearTimeout(t.current),t.current=setTimeout(()=>{t.current=void 0,u()},c)}function ne(t,u,c,a={}){const{filter:h,paused:o=!1,delay:p=se}=a,v=r.useRef(c),x=r.useRef(h),y=r.useRef(o),m=r.useRef(!1),i=r.useRef(void 0);r.useEffect(()=>{v.current=c,x.current=h});const l=u;r.useEffect(()=>{const E=d=>{x.current&&!x.current(d)||(y.current?m.current=!0:O(i,()=>v.current(),p))},w=l.split(`
2
- `).map(d=>t(d,E));return()=>{clearTimeout(i.current),w.forEach(d=>d())}},[l,p,t]),r.useEffect(()=>{y.current=o,o?i.current!==void 0&&(clearTimeout(i.current),i.current=void 0,m.current=!0):m.current&&(m.current=!1,O(i,()=>v.current(),p))},[o,p])}function re(t){return Array.isArray(t)?t:Array.isArray(t==null?void 0:t.clients)?t.clients:[]}async function le(){return re(await K("/api/v1/qcli/ws/clients"))}function ae(t,u,c={}){const{subscribe:a}=q();ne(a,t,u,c)}let ce=0;function oe(t){return t==="events"?"info":t==="shell"?"success":"neutral"}const R=200;function me(){const{t,formatDate:u}=M(),{subscribe:c}=q(),[a,h]=r.useState([]),[o,p]=r.useState(!1),v=r.useRef(!1),[x,y]=r.useState([]),[m,i]=U(),l=m.get("type")??"all",E=m.get("q")??"",w=(e,n)=>i(j=>{const N=new URLSearchParams(j);return n?N.set(e,n):N.delete(e),N},{replace:!0}),d=e=>w("type",e==="all"?null:e),b=r.useRef(null),[g,A]=r.useState(!0),{data:f,loading:W,error:T,refetch:L,refresh:S}=G(le,[]);r.useEffect(()=>{const e=setInterval(S,1e4);return()=>clearInterval(e)},[S]),ae("session:*",S),r.useEffect(()=>c("*",n=>{const j=n.type??"unknown",N={id:++ce,time:new Date,type:j,event:n,payload:JSON.stringify(n)},B=J=>{const C=[...J,N];return C.length>R?C.slice(C.length-R):C};v.current?y(B):h(B)}),[c]),r.useEffect(()=>{g&&b.current&&(b.current.scrollTop=b.current.scrollHeight)},[a,g]);const F=Array.from(new Set([...a.map(e=>{const n=e.type.split(":");return n[0]+(n.length>1?":*":"")}),...l!=="all"?[l]:[]]));function _(){const e=!o;v.current=e,p(e),!e&&x.length>0&&(h(n=>[...n,...x].slice(-R)),y([]))}const k=E.trim().toLowerCase(),P=a.filter(e=>k&&!e.type.toLowerCase().includes(k)&&!e.payload.toLowerCase().includes(k)?!1:l==="all"?!0:l.endsWith(":*")?e.type.startsWith(l.slice(0,-1)):e.type===l),D=[{key:"id",header:t("events.colId"),render:e=>s.jsxs("span",{className:"font-mono text-xs text-muted",children:[e.id.slice(0,12),"..."]})},{key:"type",header:t("events.colType"),sortValue:e=>e.type,render:e=>s.jsx(I,{variant:oe(e.type),children:e.type})},{key:"connectedAt",header:t("events.colConnected"),sortValue:e=>Date.parse(e.connectedAt),render:e=>s.jsx("span",{className:"text-xs text-muted",children:u(e.connectedAt,{timeStyle:"medium"})})},{key:"remoteAddress",header:t("events.colRemote"),render:e=>s.jsx("span",{className:"font-mono text-xs text-muted",children:e.remoteAddress})}];return s.jsxs("div",{children:[s.jsx(X,{title:t("nav.events"),subtitle:t("events.subtitle")}),s.jsx("div",{className:"p-4 sm:p-6",children:s.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 lg:h-[calc(100vh-12rem)]",children:[s.jsx(H,{label:t("events.liveEvents"),resetKeys:[a,l],children:s.jsxs("div",{className:"flex-[2] flex flex-col max-lg:h-[60vh] bg-surface border border-border rounded-xl overflow-hidden",children:[s.jsxs("div",{className:"px-4 py-3 border-b border-border/75 flex items-center gap-3 flex-wrap",children:[s.jsx("span",{className:"text-sm font-medium text-heading",children:t("events.liveEvents")}),s.jsx("span",{className:"text-xs text-subtle",children:t("events.shown",{shown:a.length,max:R})}),s.jsx("input",{type:"search",value:E,onChange:e=>w("q",e.target.value||null),placeholder:t("events.search"),"aria-label":t("events.search"),className:"ml-auto w-40 text-xs bg-control border border-border text-text rounded px-2 py-1 placeholder-subtle focus:outline-none"}),s.jsx(Y,{label:t("events.filterLabel"),options:[{value:"all",label:t("events.allTypes")},...F.map(e=>({value:e,label:e}))],value:l,onChange:d,onClear:l!=="all"?()=>d("all"):void 0}),s.jsx(ee,{label:t("events.liveEvents"),items:[{key:"pause",label:o?t("events.resumeHeld",{count:x.length}):t("events.pause"),tone:o?"warning":"default",pressed:o,onClick:_},{key:"scroll",label:t(g?"events.autoScrollOn":"events.autoScrollOff"),tone:g?"primary":"default",pressed:g,onClick:()=>A(!g)},{key:"clear",label:t("events.clear"),tone:"danger",onClick:()=>{h([]),y([])}}]})]}),s.jsx("div",{ref:b,onScroll:()=>{if(!b.current)return;const{scrollTop:e,scrollHeight:n,clientHeight:j}=b.current;A(n-e-j<60)},className:"flex-1 overflow-y-auto p-3 font-mono text-xs space-y-0.5",children:P.length===0?a.length>0?s.jsx(V,{className:"font-sans",message:t("events.noMatch",{count:a.length}),action:s.jsx("button",{type:"button",onClick:()=>i(e=>{const n=new URLSearchParams(e);return n.delete("type"),n.delete("q"),n},{replace:!0}),className:"text-xs text-accent hover:underline",children:t("events.clear")})}):s.jsx("div",{className:"text-subtle py-4 text-center font-sans",children:t("events.waiting")}):P.map(e=>s.jsxs("div",{className:"flex items-start gap-2 py-0.5 hover:bg-control rounded px-1",children:[s.jsxs("span",{className:"text-subtle shrink-0",children:["[",u(e.time,{timeStyle:"medium"}),"]"]}),s.jsx(I,{variant:z(e.type),children:e.type}),(()=>{const n=Q(e.event,t);return n&&s.jsx("span",{className:"text-text shrink-0 max-w-[50%] truncate",title:n,children:n})})(),s.jsx("span",{className:"text-muted truncate flex-1 text-[10px]",title:e.payload,children:e.payload})]},e.id))})]})}),s.jsx(H,{label:t("events.connectedClients"),resetKeys:[f],children:s.jsx("div",{className:"flex-1 flex flex-col max-lg:h-72",children:s.jsxs("div",{className:"bg-surface border border-border rounded-xl overflow-hidden flex flex-col h-full",children:[s.jsxs("div",{className:"px-4 py-3 border-b border-border/75 flex items-center justify-between",children:[s.jsx("span",{className:"text-sm font-medium text-heading",children:t("events.connectedClients")}),s.jsxs("div",{className:"flex items-center gap-2",children:[f&&s.jsx("span",{className:"text-xs text-subtle",children:t("events.connectedCount",{count:f.length})}),s.jsx("button",{onClick:L,className:"text-[10px] px-2 py-0.5 rounded bg-control text-muted hover:bg-control-hover transition-colors",children:t("common.refresh")})]})]}),s.jsx("div",{className:"flex-1 overflow-auto",children:T&&!f?s.jsx("div",{className:"p-3",children:s.jsx(Z,{error:T,onRetry:L,compact:!0})}):W&&!f?s.jsx($,{rows:3,columns:D.length,plain:!0}):f&&f.length>0?s.jsx(te,{columns:D,data:f,keyExtractor:e=>e.id,plain:!0}):s.jsx(V,{message:t("events.noClients")})})]})})})]})})]})}export{me as default};
1
+ import{r,z as M,a5 as q,u as U,b as z,a as G,j as s,P as J,a6 as H,d as X,f as V,a7 as Y,a8 as Q,E as Z,e as $}from"./index-BEViB6FO.js";import{B as I}from"./Badge-CuP1qfDI.js";import{B as ee}from"./ButtonGroup-DCaBJ3RQ.js";import{D as te}from"./DataTable-BGLeCJvI.js";import"./paging-CCKbuXJo.js";const se=1500;function O(t,u,c){clearTimeout(t.current),t.current=setTimeout(()=>{t.current=void 0,u()},c)}function ne(t,u,c,a={}){const{filter:h,paused:o=!1,delay:p=se}=a,v=r.useRef(c),x=r.useRef(h),y=r.useRef(o),m=r.useRef(!1),i=r.useRef(void 0);r.useEffect(()=>{v.current=c,x.current=h});const l=u;r.useEffect(()=>{const E=d=>{x.current&&!x.current(d)||(y.current?m.current=!0:O(i,()=>v.current(),p))},w=l.split(`
2
+ `).map(d=>t(d,E));return()=>{clearTimeout(i.current),w.forEach(d=>d())}},[l,p,t]),r.useEffect(()=>{y.current=o,o?i.current!==void 0&&(clearTimeout(i.current),i.current=void 0,m.current=!0):m.current&&(m.current=!1,O(i,()=>v.current(),p))},[o,p])}function re(t){return Array.isArray(t)?t:Array.isArray(t==null?void 0:t.clients)?t.clients:[]}async function le(){return re(await M("/api/v1/qcli/ws/clients"))}function ae(t,u,c={}){const{subscribe:a}=q();ne(a,t,u,c)}let ce=0;function oe(t){return t==="events"?"info":t==="shell"?"success":"neutral"}const R=200;function me(){const{t,formatDate:u}=U(),{subscribe:c}=q(),[a,h]=r.useState([]),[o,p]=r.useState(!1),v=r.useRef(!1),[x,y]=r.useState([]),[m,i]=z(),l=m.get("type")??"all",E=m.get("q")??"",w=(e,n)=>i(j=>{const N=new URLSearchParams(j);return n?N.set(e,n):N.delete(e),N},{replace:!0}),d=e=>w("type",e==="all"?null:e),b=r.useRef(null),[g,A]=r.useState(!0),{data:f,loading:W,error:T,refetch:L,refresh:S}=G(le,[]);r.useEffect(()=>{const e=setInterval(S,1e4);return()=>clearInterval(e)},[S]),ae("session:*",S),r.useEffect(()=>c("*",n=>{const j=n.type??"unknown",N={id:++ce,time:new Date,type:j,event:n,payload:JSON.stringify(n)},B=K=>{const C=[...K,N];return C.length>R?C.slice(C.length-R):C};v.current?y(B):h(B)}),[c]),r.useEffect(()=>{g&&b.current&&(b.current.scrollTop=b.current.scrollHeight)},[a,g]);const F=Array.from(new Set([...a.map(e=>{const n=e.type.split(":");return n[0]+(n.length>1?":*":"")}),...l!=="all"?[l]:[]]));function _(){const e=!o;v.current=e,p(e),!e&&x.length>0&&(h(n=>[...n,...x].slice(-R)),y([]))}const k=E.trim().toLowerCase(),P=a.filter(e=>k&&!e.type.toLowerCase().includes(k)&&!e.payload.toLowerCase().includes(k)?!1:l==="all"?!0:l.endsWith(":*")?e.type.startsWith(l.slice(0,-1)):e.type===l),D=[{key:"id",header:t("events.colId"),render:e=>s.jsxs("span",{className:"font-mono text-xs text-muted",children:[e.id.slice(0,12),"..."]})},{key:"type",header:t("events.colType"),sortValue:e=>e.type,render:e=>s.jsx(I,{variant:oe(e.type),children:e.type})},{key:"connectedAt",header:t("events.colConnected"),sortValue:e=>Date.parse(e.connectedAt),render:e=>s.jsx("span",{className:"text-xs text-muted",children:u(e.connectedAt,{timeStyle:"medium"})})},{key:"remoteAddress",header:t("events.colRemote"),render:e=>s.jsx("span",{className:"font-mono text-xs text-muted",children:e.remoteAddress})}];return s.jsxs("div",{children:[s.jsx(J,{title:t("nav.events"),subtitle:t("events.subtitle")}),s.jsx("div",{className:"p-4 sm:p-6",children:s.jsxs("div",{className:"flex flex-col lg:flex-row gap-4 lg:h-[calc(100vh-12rem)]",children:[s.jsx(H,{label:t("events.liveEvents"),resetKeys:[a,l],children:s.jsxs("div",{className:"flex-[2] flex flex-col max-lg:h-[60vh] bg-surface border border-border rounded-xl overflow-hidden",children:[s.jsxs("div",{className:"px-4 py-3 border-b border-border/75 flex items-center gap-3 flex-wrap",children:[s.jsx("span",{className:"text-sm font-medium text-heading",children:t("events.liveEvents")}),s.jsx("span",{className:"text-xs text-subtle",children:t("events.shown",{shown:a.length,max:R})}),s.jsx("input",{type:"search",value:E,onChange:e=>w("q",e.target.value||null),placeholder:t("events.search"),"aria-label":t("events.search"),className:"ml-auto w-40 text-xs bg-control border border-border text-text rounded px-2 py-1 placeholder-subtle focus:outline-none"}),s.jsx(X,{label:t("events.filterLabel"),options:[{value:"all",label:t("events.allTypes")},...F.map(e=>({value:e,label:e}))],value:l,onChange:d,onClear:l!=="all"?()=>d("all"):void 0}),s.jsx(ee,{label:t("events.liveEvents"),items:[{key:"pause",label:o?t("events.resumeHeld",{count:x.length}):t("events.pause"),tone:o?"warning":"default",pressed:o,onClick:_},{key:"scroll",label:t(g?"events.autoScrollOn":"events.autoScrollOff"),tone:g?"primary":"default",pressed:g,onClick:()=>A(!g)},{key:"clear",label:t("events.clear"),tone:"danger",onClick:()=>{h([]),y([])}}]})]}),s.jsx("div",{ref:b,onScroll:()=>{if(!b.current)return;const{scrollTop:e,scrollHeight:n,clientHeight:j}=b.current;A(n-e-j<60)},className:"flex-1 overflow-y-auto p-3 font-mono text-xs space-y-0.5",children:P.length===0?a.length>0?s.jsx(V,{className:"font-sans",message:t("events.noMatch",{count:a.length}),action:s.jsx("button",{type:"button",onClick:()=>i(e=>{const n=new URLSearchParams(e);return n.delete("type"),n.delete("q"),n},{replace:!0}),className:"text-xs text-accent hover:underline",children:t("events.clear")})}):s.jsx("div",{className:"text-subtle py-4 text-center font-sans",children:t("events.waiting")}):P.map(e=>s.jsxs("div",{className:"flex items-start gap-2 py-0.5 hover:bg-control rounded px-1",children:[s.jsxs("span",{className:"text-subtle shrink-0",children:["[",u(e.time,{timeStyle:"medium"}),"]"]}),s.jsx(I,{variant:Y(e.type),children:e.type}),(()=>{const n=Q(e.event,t);return n&&s.jsx("span",{className:"text-text shrink-0 max-w-[50%] truncate",title:n,children:n})})(),s.jsx("span",{className:"text-muted truncate flex-1 text-[10px]",title:e.payload,children:e.payload})]},e.id))})]})}),s.jsx(H,{label:t("events.connectedClients"),resetKeys:[f],children:s.jsx("div",{className:"flex-1 flex flex-col max-lg:h-72",children:s.jsxs("div",{className:"bg-surface border border-border rounded-xl overflow-hidden flex flex-col h-full",children:[s.jsxs("div",{className:"px-4 py-3 border-b border-border/75 flex items-center justify-between",children:[s.jsx("span",{className:"text-sm font-medium text-heading",children:t("events.connectedClients")}),s.jsxs("div",{className:"flex items-center gap-2",children:[f&&s.jsx("span",{className:"text-xs text-subtle",children:t("events.connectedCount",{count:f.length})}),s.jsx("button",{onClick:L,className:"text-[10px] px-2 py-0.5 rounded bg-control text-muted hover:bg-control-hover transition-colors",children:t("common.refresh")})]})]}),s.jsx("div",{className:"flex-1 overflow-auto",children:T&&!f?s.jsx("div",{className:"p-3",children:s.jsx(Z,{error:T,onRetry:L,compact:!0})}):W&&!f?s.jsx($,{rows:3,columns:D.length,plain:!0}):f&&f.length>0?s.jsx(te,{columns:D,data:f,keyExtractor:e=>e.id,plain:!0}):s.jsx(V,{message:t("events.noClients")})})]})})})]})})]})}export{me as default};
@@ -1,2 +1,2 @@
1
- import{ai as Ye,r,aj as Ze,j as t,ak as Je,al as Qe,u as Ie,am as he,an as et,ao as tt,A as st,S as rt,ap as Fe,C as at,aq as nt,c as ot,a5 as lt,b as ct,ar as it,as as ut,at as dt,au as Le,av as mt,aw as gt,ax as xt,ay as ht,az as ft,P as pt,d as ke,aA as vt,E as bt,w as jt,aB as St,aC as Ce,aD as Te,l as wt,m as z}from"./index-BquDpLoS.js";const _=44,Et=20,Me=2,yt=24,Nt=2;function Rt({columns:s,xTicks:d,formatValue:p,integer:h=!1,height:j=180,selectedKey:i=null,onSelect:u,stale:H=!1,ariaLabel:k}){const[W,N]=Ye(),[w,F]=r.useState(null),R=Math.max(0,N-_),v=j-Et,$=s.map(c=>c.segments.reduce((S,o)=>S+o.value,0)),{max:D,ticks:b}=Ze(Math.max(0,...$),h),f=s.length?R/s.length:0,E=Math.max(1,Math.min(yt,f-Me)),M=c=>v-c/D*v,L=w!==null?s[w]:void 0,V=w!==null?M($[w]):0;return t.jsxs("div",{ref:W,className:`relative select-none transition-opacity ${H?"opacity-50":""}`,onPointerLeave:()=>F(null),children:[N>0&&t.jsxs("svg",{width:N,height:j,role:"group","aria-label":k,className:"block overflow-visible",children:[b.map(c=>t.jsxs("g",{children:[t.jsx("line",{x1:_,x2:N,y1:M(c),y2:M(c),stroke:"var(--qcli-border)",strokeWidth:1,shapeRendering:"crispEdges"}),t.jsx("text",{x:_-8,y:M(c),dy:"0.32em",textAnchor:"end",className:"fill-subtle text-[10px] tabular-nums",children:p(c)})]},c)),s.map((c,S)=>{const o=_+S*f+(f-E)/2,m=i===c.key,g=i!==null&&!m;let x=v;const A=c.segments.filter(y=>y.value>0);return t.jsxs("g",{tabIndex:0,role:"button","aria-label":c.ariaLabel,"aria-pressed":u?m:void 0,className:"outline-none focus-visible:[&>rect.hit]:stroke-[var(--qcli-primary)]",style:{cursor:u?"pointer":"default"},onPointerEnter:()=>F(S),onFocus:()=>F(S),onBlur:()=>F(null),onClick:()=>u==null?void 0:u(m?null:c.key),onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),u==null||u(m?null:c.key))},children:[t.jsx("rect",{className:"hit",x:_+S*f,y:0,width:f,height:v,fill:w===S||m?"var(--qcli-control)":"transparent",stroke:"transparent",strokeWidth:1,rx:4}),A.map((y,B)=>{const Z=B===A.length-1,C=Math.max(Nt,y.value/D*v),O=Math.max(1,B>0?C-Me:C);return x-=C,t.jsx("path",{d:Je(o,x,E,O,Z),fill:y.color,opacity:g?.35:1},y.key)})]},c.key)}),t.jsx("line",{x1:_,x2:N,y1:v,y2:v,stroke:"var(--qcli-border)",strokeWidth:1,shapeRendering:"crispEdges"}),d.map(c=>t.jsx("text",{x:_+(c.index+.5)*f,y:j-4,textAnchor:"middle",className:"fill-subtle text-[10px]",children:c.label},c.index))]}),L&&t.jsx(Qe,{x:_+(w+.5)*f,y:V,width:N,title:L.title,rows:L.rows})]})}const me={DEBUG:"var(--qcli-subtle)",INFO:"var(--qcli-info)",WARN:"var(--qcli-warning)",ERROR:"var(--qcli-error)"},Lt=["ERROR","WARN","INFO","DEBUG"],kt=3e4;function Ct({filters:s,search:d,onPick:p}){const{t:h,formatDate:j,formatNumber:i}=Ie(),[u,H]=r.useState(null),[k,W]=r.useState(!1),[N,w]=r.useState(!1),[F,R]=r.useState(!1),[v,$]=r.useState(0),D=he(s.levels),{range:b,customFrom:f,customTo:E,service:M}=s;if(r.useEffect(()=>{if(b!=="live")return;const o=setInterval(()=>$(m=>m+1),kt);return()=>clearInterval(o)},[b]),r.useEffect(()=>{if(k)return;let o=!1;const m=et({range:b,customFrom:f,customTo:E});return R(!0),tt({level:D,search:d,service:M||void 0,from:new Date(m.from).toISOString(),to:new Date(m.to).toISOString(),buckets:m.buckets}).then(g=>{o||(Array.isArray(g==null?void 0:g.buckets)?(H(g),w(!1)):W(!0))}).catch(g=>{o||(g instanceof st&&(g.status===404||g.status===501)?W(!0):w(!0))}).finally(()=>{o||R(!1)}),()=>{o=!0}},[D,d,M,b,f,E,v,k]),k||!u&&N)return null;if(!u)return t.jsx(rt,{height:142,label:h("logs.volume")});const L=u.buckets.length>0&&u.bucketMs*u.buckets.length>36*36e5,V=o=>j(o,L?{weekday:"short",hour:"2-digit"}:{hour:"2-digit",minute:"2-digit"}),c=o=>`${j(o,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})} – ${j(o+u.bucketMs,{hour:"2-digit",minute:"2-digit"})}`,S=Fe.filter(o=>s.levels.has(o));return t.jsx(at,{title:h("logs.volume"),note:h("logs.volumeNote"),legend:t.jsx(ot,{items:S.map(o=>({label:o,color:me[o],value:i(u.totals[o]??0)}))}),children:t.jsx(Rt,{columns:u.buckets.map(o=>{const m=Date.parse(o.start),g=S.reduce((x,A)=>x+(o[A]??0),0);return{key:String(m),segments:Lt.filter(x=>s.levels.has(x)).map(x=>({key:x,value:o[x]??0,color:me[x]})),title:c(m),rows:[...S].reverse().map(x=>({label:x,value:i(o[x]??0),color:me[x]})),ariaLabel:h("logs.volumeColumn",{time:c(m),total:g,errors:o.ERROR??0})}}),xTicks:nt(u.buckets.length,6).map(o=>({index:o,label:V(Date.parse(u.buckets[o].start))})),formatValue:o=>i(o,{notation:"compact"}),integer:!0,height:120,onSelect:o=>{o&&p(Number(o),Number(o)+u.bucketMs)},stale:F,ariaLabel:h("logs.volume")})})}const ge={DEBUG:"text-muted",INFO:"text-info",WARN:"text-warning",ERROR:"text-error"},Tt={DEBUG:"bg-subtle/20",INFO:"bg-info/20",WARN:"bg-warning/20",ERROR:"bg-error/20"},Mt={live:"logs.rangeLive","15m":"logs.range15m","1h":"logs.range1h","24h":"logs.range24h","7d":"logs.range7d",custom:"logs.rangeCustom"},At={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"},Ot=100,Y=1e3,Ae=new WeakMap;let It=0;function Ft(s){let d=Ae.get(s);return d===void 0&&(d=++It,Ae.set(s,d)),d}const Oe=["","","","live","",""].join("\0"),Dt=300,Pt=48,xe="px-3 py-1.5 text-sm bg-control border border-border rounded-lg text-text focus:outline-none focus:border-primary/50";function _t(s,d){if(!d)return s;const p=s.toLowerCase().indexOf(d.toLowerCase());return p===-1?s:t.jsxs(t.Fragment,{children:[s.slice(0,p),t.jsx("span",{className:"bg-warning/30 text-heading",children:s.slice(p,p+d.length)}),s.slice(p+d.length)]})}function Ht(s){return s.charAt(0).toUpperCase()+s.slice(1)}function Gt(){const{t:s,formatDate:d}=Ie(),{subscribe:p}=lt(),[h,j]=r.useState([]),[i,u]=r.useState(null),[H,k]=r.useState(0),[W,N]=r.useState(!1),[w,F]=r.useState(!0),[R,v]=r.useState(null),[$,D]=ct(),[b]=r.useState(()=>it($)),[f]=r.useState(()=>$.get("at")),[E,M]=r.useState(new Set(b.levels)),[L,V]=r.useState(b.search),[c,S]=r.useState(b.search),[o,m]=r.useState(b.service),[g,x]=r.useState(b.range),[A,y]=r.useState(b.customFrom),[B,Z]=r.useState(b.customTo),C=r.useRef(null),[O,ne]=r.useState(()=>!f),[oe,De]=r.useState(!1),le=r.useRef(!1),I=r.useRef([]),[fe,ce]=r.useState(0),[Pe,_e]=r.useState(()=>new Set),[He,pe]=r.useState(null),P=i!==null&&ut(i),J={levels:E,search:L,service:o,range:g,customFrom:A,customTo:B},Q=r.useRef(J),T=r.useRef(P);r.useLayoutEffect(()=>{Q.current=J,T.current=P});const K=r.useRef(0),ve=r.useRef({}),ie=r.useRef(!1),ee=r.useRef(null),te=r.useRef(Y),ue=r.useCallback((e,n)=>{const a=Q.current;return dt({level:T.current?he(a.levels):void 0,search:T.current?a.search:void 0,service:T.current&&a.service||void 0,...T.current?n??Le(a):{},limit:Ot,offset:e})},[]),q=[he(E)??"",c,o,g,A,B].join("\0"),be=r.useRef(q);r.useLayoutEffect(()=>{be.current=q});const[je,We]=r.useState(null),Se=P&&je!==null&&je!==q&&!R,X=r.useCallback(()=>{const e=++K.current,n=T.current?be.current:Oe,a=T.current?Le(Q.current):{};ue(0,a).then(l=>{if(e!==K.current)return;const{entries:G,...ze}=l;ve.current=mt(a,G[0]),I.current=[],ce(0),j([...G].reverse()),te.current=Math.max(Y,G.length),u(ze),k(G.length),We(n),v(null)}).catch(l=>{e===K.current&&v(l instanceof Error?{message:l.message}:{key:"logs.loadFailed"})}).finally(()=>{e===K.current&&F(!1)})},[ue]);r.useEffect(()=>{X()},[X]),r.useEffect(()=>{const e=setTimeout(()=>S(L),Dt);return()=>clearTimeout(e)},[L]);const se=r.useRef(null);r.useEffect(()=>{P&&(se.current===null&&(se.current=Oe),se.current!==q&&(se.current=q,X()))},[q,P,X]);async function de(){if(ie.current)return;ie.current=!0,N(!0);const e=K.current;try{const n=await ue(H,T.current?ve.current:void 0);if(e!==K.current)return;const a=C.current;a&&(ee.current=a.scrollHeight-a.scrollTop),j(l=>{const G=[...[...n.entries].reverse(),...l];return te.current=Math.max(Y,G.length),G}),k(l=>l+n.entries.length),u(l=>l&&{...l,total:n.total,hasMore:n.hasMore}),v(null)}catch(n){v({...n instanceof Error?{message:n.message}:{key:"logs.loadMoreFailed"},more:!0})}finally{ie.current=!1,N(!1)}}r.useEffect(()=>p("log:entry",n=>{const a=n;!a.timestamp||!a.level||!a.message||T.current&&!gt(a,Q.current)||(le.current?(I.current.push(a),I.current.length>Y&&I.current.splice(0,I.current.length-Y),ce(I.current.length)):j(l=>[...l,a]),T.current||(u(l=>l&&l.total!=null?{...l,total:l.total+1}:l),k(l=>l+1)))}),[p]),r.useEffect(()=>{const e=h.length-te.current;e<=0||(j(n=>n.slice(n.length-te.current)),k(n=>Math.max(0,n-e)),u(n=>n&&{...n,hasMore:!0}))},[h]),r.useLayoutEffect(()=>{const e=C.current;e&&(ee.current!==null?(e.scrollTop=e.scrollHeight-ee.current,ee.current=null):O&&(e.scrollTop=e.scrollHeight))},[h,O]);const re=r.useMemo(()=>f?h.find(e=>e.timestamp===f)??null:null,[h,f]),we=r.useRef(!1);r.useEffect(()=>{var n,a;if(!re||we.current)return;const e=(n=C.current)==null?void 0:n.querySelector('[data-focused="true"]');e&&(we.current=!0,(a=e.scrollIntoView)==null||a.call(e,{block:"center"}))});function $e(){const e=!le.current;if(le.current=e,De(e),!e&&I.current.length>0){const n=I.current;I.current=[],ce(0),j(a=>[...a,...n])}}function Be(e){_e(n=>{const a=new Set(n);return a.has(e)?a.delete(e):a.add(e),a})}async function Ue(e){try{await navigator.clipboard.writeText(Ce(e)),pe(e),setTimeout(()=>pe(n=>n===e?null:n),1500)}catch{}}function Ge(e){M(n=>{const a=new Set(n);return a.has(e)?a.size>1&&a.delete(e):a.add(e),a})}const U=h.filter(e=>xt(e,J)),Ee=ht(J).toString();r.useEffect(()=>{D(new URLSearchParams(Ee),{replace:!0})},[Ee,D]);function Ke(e,n){x("custom"),y(Te(e)),Z(Te(n))}const ae=(i==null?void 0:i.services)??[],qe=P&&(ae.length>1||(i==null?void 0:i.persistent)===!0),ye=P,Ve=ae.length>1||new Set(h.map(e=>e.service).filter(Boolean)).size>1;function Xe(){const e=U.map(Ce).join(`
1
+ import{ai as Ye,r,aj as Ze,j as t,ak as Je,al as Qe,u as Ie,am as he,an as et,ao as tt,A as st,S as rt,ap as Fe,C as at,aq as nt,c as ot,a5 as lt,b as ct,ar as it,as as ut,at as dt,au as Le,av as mt,aw as gt,ax as xt,ay as ht,az as ft,P as pt,d as ke,aA as vt,E as bt,w as jt,aB as St,aC as Ce,aD as Te,l as wt,m as z}from"./index-BEViB6FO.js";const _=44,Et=20,Me=2,yt=24,Nt=2;function Rt({columns:s,xTicks:d,formatValue:p,integer:h=!1,height:j=180,selectedKey:i=null,onSelect:u,stale:H=!1,ariaLabel:k}){const[W,N]=Ye(),[w,F]=r.useState(null),R=Math.max(0,N-_),v=j-Et,$=s.map(c=>c.segments.reduce((S,o)=>S+o.value,0)),{max:D,ticks:b}=Ze(Math.max(0,...$),h),f=s.length?R/s.length:0,E=Math.max(1,Math.min(yt,f-Me)),M=c=>v-c/D*v,L=w!==null?s[w]:void 0,V=w!==null?M($[w]):0;return t.jsxs("div",{ref:W,className:`relative select-none transition-opacity ${H?"opacity-50":""}`,onPointerLeave:()=>F(null),children:[N>0&&t.jsxs("svg",{width:N,height:j,role:"group","aria-label":k,className:"block overflow-visible",children:[b.map(c=>t.jsxs("g",{children:[t.jsx("line",{x1:_,x2:N,y1:M(c),y2:M(c),stroke:"var(--qcli-border)",strokeWidth:1,shapeRendering:"crispEdges"}),t.jsx("text",{x:_-8,y:M(c),dy:"0.32em",textAnchor:"end",className:"fill-subtle text-[10px] tabular-nums",children:p(c)})]},c)),s.map((c,S)=>{const o=_+S*f+(f-E)/2,m=i===c.key,g=i!==null&&!m;let x=v;const A=c.segments.filter(y=>y.value>0);return t.jsxs("g",{tabIndex:0,role:"button","aria-label":c.ariaLabel,"aria-pressed":u?m:void 0,className:"outline-none focus-visible:[&>rect.hit]:stroke-[var(--qcli-primary)]",style:{cursor:u?"pointer":"default"},onPointerEnter:()=>F(S),onFocus:()=>F(S),onBlur:()=>F(null),onClick:()=>u==null?void 0:u(m?null:c.key),onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),u==null||u(m?null:c.key))},children:[t.jsx("rect",{className:"hit",x:_+S*f,y:0,width:f,height:v,fill:w===S||m?"var(--qcli-control)":"transparent",stroke:"transparent",strokeWidth:1,rx:4}),A.map((y,B)=>{const Z=B===A.length-1,C=Math.max(Nt,y.value/D*v),O=Math.max(1,B>0?C-Me:C);return x-=C,t.jsx("path",{d:Je(o,x,E,O,Z),fill:y.color,opacity:g?.35:1},y.key)})]},c.key)}),t.jsx("line",{x1:_,x2:N,y1:v,y2:v,stroke:"var(--qcli-border)",strokeWidth:1,shapeRendering:"crispEdges"}),d.map(c=>t.jsx("text",{x:_+(c.index+.5)*f,y:j-4,textAnchor:"middle",className:"fill-subtle text-[10px]",children:c.label},c.index))]}),L&&t.jsx(Qe,{x:_+(w+.5)*f,y:V,width:N,title:L.title,rows:L.rows})]})}const me={DEBUG:"var(--qcli-subtle)",INFO:"var(--qcli-info)",WARN:"var(--qcli-warning)",ERROR:"var(--qcli-error)"},Lt=["ERROR","WARN","INFO","DEBUG"],kt=3e4;function Ct({filters:s,search:d,onPick:p}){const{t:h,formatDate:j,formatNumber:i}=Ie(),[u,H]=r.useState(null),[k,W]=r.useState(!1),[N,w]=r.useState(!1),[F,R]=r.useState(!1),[v,$]=r.useState(0),D=he(s.levels),{range:b,customFrom:f,customTo:E,service:M}=s;if(r.useEffect(()=>{if(b!=="live")return;const o=setInterval(()=>$(m=>m+1),kt);return()=>clearInterval(o)},[b]),r.useEffect(()=>{if(k)return;let o=!1;const m=et({range:b,customFrom:f,customTo:E});return R(!0),tt({level:D,search:d,service:M||void 0,from:new Date(m.from).toISOString(),to:new Date(m.to).toISOString(),buckets:m.buckets}).then(g=>{o||(Array.isArray(g==null?void 0:g.buckets)?(H(g),w(!1)):W(!0))}).catch(g=>{o||(g instanceof st&&(g.status===404||g.status===501)?W(!0):w(!0))}).finally(()=>{o||R(!1)}),()=>{o=!0}},[D,d,M,b,f,E,v,k]),k||!u&&N)return null;if(!u)return t.jsx(rt,{height:142,label:h("logs.volume")});const L=u.buckets.length>0&&u.bucketMs*u.buckets.length>36*36e5,V=o=>j(o,L?{weekday:"short",hour:"2-digit"}:{hour:"2-digit",minute:"2-digit"}),c=o=>`${j(o,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})} – ${j(o+u.bucketMs,{hour:"2-digit",minute:"2-digit"})}`,S=Fe.filter(o=>s.levels.has(o));return t.jsx(at,{title:h("logs.volume"),note:h("logs.volumeNote"),legend:t.jsx(ot,{items:S.map(o=>({label:o,color:me[o],value:i(u.totals[o]??0)}))}),children:t.jsx(Rt,{columns:u.buckets.map(o=>{const m=Date.parse(o.start),g=S.reduce((x,A)=>x+(o[A]??0),0);return{key:String(m),segments:Lt.filter(x=>s.levels.has(x)).map(x=>({key:x,value:o[x]??0,color:me[x]})),title:c(m),rows:[...S].reverse().map(x=>({label:x,value:i(o[x]??0),color:me[x]})),ariaLabel:h("logs.volumeColumn",{time:c(m),total:g,errors:o.ERROR??0})}}),xTicks:nt(u.buckets.length,6).map(o=>({index:o,label:V(Date.parse(u.buckets[o].start))})),formatValue:o=>i(o,{notation:"compact"}),integer:!0,height:120,onSelect:o=>{o&&p(Number(o),Number(o)+u.bucketMs)},stale:F,ariaLabel:h("logs.volume")})})}const ge={DEBUG:"text-muted",INFO:"text-info",WARN:"text-warning",ERROR:"text-error"},Tt={DEBUG:"bg-subtle/20",INFO:"bg-info/20",WARN:"bg-warning/20",ERROR:"bg-error/20"},Mt={live:"logs.rangeLive","15m":"logs.range15m","1h":"logs.range1h","24h":"logs.range24h","7d":"logs.range7d",custom:"logs.rangeCustom"},At={year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"},Ot=100,Y=1e3,Ae=new WeakMap;let It=0;function Ft(s){let d=Ae.get(s);return d===void 0&&(d=++It,Ae.set(s,d)),d}const Oe=["","","","live","",""].join("\0"),Dt=300,Pt=48,xe="px-3 py-1.5 text-sm bg-control border border-border rounded-lg text-text focus:outline-none focus:border-primary/50";function _t(s,d){if(!d)return s;const p=s.toLowerCase().indexOf(d.toLowerCase());return p===-1?s:t.jsxs(t.Fragment,{children:[s.slice(0,p),t.jsx("span",{className:"bg-warning/30 text-heading",children:s.slice(p,p+d.length)}),s.slice(p+d.length)]})}function Ht(s){return s.charAt(0).toUpperCase()+s.slice(1)}function Gt(){const{t:s,formatDate:d}=Ie(),{subscribe:p}=lt(),[h,j]=r.useState([]),[i,u]=r.useState(null),[H,k]=r.useState(0),[W,N]=r.useState(!1),[w,F]=r.useState(!0),[R,v]=r.useState(null),[$,D]=ct(),[b]=r.useState(()=>it($)),[f]=r.useState(()=>$.get("at")),[E,M]=r.useState(new Set(b.levels)),[L,V]=r.useState(b.search),[c,S]=r.useState(b.search),[o,m]=r.useState(b.service),[g,x]=r.useState(b.range),[A,y]=r.useState(b.customFrom),[B,Z]=r.useState(b.customTo),C=r.useRef(null),[O,ne]=r.useState(()=>!f),[oe,De]=r.useState(!1),le=r.useRef(!1),I=r.useRef([]),[fe,ce]=r.useState(0),[Pe,_e]=r.useState(()=>new Set),[He,pe]=r.useState(null),P=i!==null&&ut(i),J={levels:E,search:L,service:o,range:g,customFrom:A,customTo:B},Q=r.useRef(J),T=r.useRef(P);r.useLayoutEffect(()=>{Q.current=J,T.current=P});const K=r.useRef(0),ve=r.useRef({}),ie=r.useRef(!1),ee=r.useRef(null),te=r.useRef(Y),ue=r.useCallback((e,n)=>{const a=Q.current;return dt({level:T.current?he(a.levels):void 0,search:T.current?a.search:void 0,service:T.current&&a.service||void 0,...T.current?n??Le(a):{},limit:Ot,offset:e})},[]),q=[he(E)??"",c,o,g,A,B].join("\0"),be=r.useRef(q);r.useLayoutEffect(()=>{be.current=q});const[je,We]=r.useState(null),Se=P&&je!==null&&je!==q&&!R,X=r.useCallback(()=>{const e=++K.current,n=T.current?be.current:Oe,a=T.current?Le(Q.current):{};ue(0,a).then(l=>{if(e!==K.current)return;const{entries:G,...ze}=l;ve.current=mt(a,G[0]),I.current=[],ce(0),j([...G].reverse()),te.current=Math.max(Y,G.length),u(ze),k(G.length),We(n),v(null)}).catch(l=>{e===K.current&&v(l instanceof Error?{message:l.message}:{key:"logs.loadFailed"})}).finally(()=>{e===K.current&&F(!1)})},[ue]);r.useEffect(()=>{X()},[X]),r.useEffect(()=>{const e=setTimeout(()=>S(L),Dt);return()=>clearTimeout(e)},[L]);const se=r.useRef(null);r.useEffect(()=>{P&&(se.current===null&&(se.current=Oe),se.current!==q&&(se.current=q,X()))},[q,P,X]);async function de(){if(ie.current)return;ie.current=!0,N(!0);const e=K.current;try{const n=await ue(H,T.current?ve.current:void 0);if(e!==K.current)return;const a=C.current;a&&(ee.current=a.scrollHeight-a.scrollTop),j(l=>{const G=[...[...n.entries].reverse(),...l];return te.current=Math.max(Y,G.length),G}),k(l=>l+n.entries.length),u(l=>l&&{...l,total:n.total,hasMore:n.hasMore}),v(null)}catch(n){v({...n instanceof Error?{message:n.message}:{key:"logs.loadMoreFailed"},more:!0})}finally{ie.current=!1,N(!1)}}r.useEffect(()=>p("log:entry",n=>{const a=n;!a.timestamp||!a.level||!a.message||T.current&&!gt(a,Q.current)||(le.current?(I.current.push(a),I.current.length>Y&&I.current.splice(0,I.current.length-Y),ce(I.current.length)):j(l=>[...l,a]),T.current||(u(l=>l&&l.total!=null?{...l,total:l.total+1}:l),k(l=>l+1)))}),[p]),r.useEffect(()=>{const e=h.length-te.current;e<=0||(j(n=>n.slice(n.length-te.current)),k(n=>Math.max(0,n-e)),u(n=>n&&{...n,hasMore:!0}))},[h]),r.useLayoutEffect(()=>{const e=C.current;e&&(ee.current!==null?(e.scrollTop=e.scrollHeight-ee.current,ee.current=null):O&&(e.scrollTop=e.scrollHeight))},[h,O]);const re=r.useMemo(()=>f?h.find(e=>e.timestamp===f)??null:null,[h,f]),we=r.useRef(!1);r.useEffect(()=>{var n,a;if(!re||we.current)return;const e=(n=C.current)==null?void 0:n.querySelector('[data-focused="true"]');e&&(we.current=!0,(a=e.scrollIntoView)==null||a.call(e,{block:"center"}))});function $e(){const e=!le.current;if(le.current=e,De(e),!e&&I.current.length>0){const n=I.current;I.current=[],ce(0),j(a=>[...a,...n])}}function Be(e){_e(n=>{const a=new Set(n);return a.has(e)?a.delete(e):a.add(e),a})}async function Ue(e){try{await navigator.clipboard.writeText(Ce(e)),pe(e),setTimeout(()=>pe(n=>n===e?null:n),1500)}catch{}}function Ge(e){M(n=>{const a=new Set(n);return a.has(e)?a.size>1&&a.delete(e):a.add(e),a})}const U=h.filter(e=>xt(e,J)),Ee=ht(J).toString();r.useEffect(()=>{D(new URLSearchParams(Ee),{replace:!0})},[Ee,D]);function Ke(e,n){x("custom"),y(Te(e)),Z(Te(n))}const ae=(i==null?void 0:i.services)??[],qe=P&&(ae.length>1||(i==null?void 0:i.persistent)===!0),ye=P,Ve=ae.length>1||new Set(h.map(e=>e.service).filter(Boolean)).size>1;function Xe(){const e=U.map(Ce).join(`
2
2
  `),n=new Blob([e],{type:"text/plain"}),a=URL.createObjectURL(n),l=document.createElement("a");l.href=a,l.download=`server-logs-${new Date().toISOString().slice(0,19).replace(/[:.]/g,"-")}.txt`,l.click(),URL.revokeObjectURL(a)}const Ne=i!==null&&ft(i,H),Re=i!=null&&i.store?i.persistent?s("logs.storePersistent",{store:Ht(i.store)}):s("logs.storeMemory"):null;return t.jsxs("div",{children:[t.jsx(pt,{title:s("nav.logs"),subtitle:Re?`${s("logs.shown",{count:U.length})} · ${Re}`:s("logs.shown",{count:U.length}),actions:t.jsx("div",{className:"flex items-center gap-2",children:t.jsx("button",{onClick:Xe,disabled:U.length===0,title:s("logs.exportTitle"),className:"px-3 py-1.5 text-xs bg-control hover:bg-control-hover text-text rounded-lg transition-colors disabled:opacity-40",children:s("logs.export")})})}),t.jsxs("div",{className:"p-4 sm:p-6 space-y-4",children:[P&&t.jsx(Ct,{filters:{levels:E,search:c,service:o,range:g,customFrom:A,customTo:B},search:c,onPick:Ke}),t.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[t.jsx("div",{className:"flex items-center gap-2",role:"group","aria-label":s("logs.levels"),children:Fe.map(e=>t.jsx("button",{onClick:()=>Ge(e),"aria-pressed":E.has(e),title:s(E.has(e)?"logs.hideLevel":"logs.showLevel",{level:e}),className:`px-2.5 py-1 text-xs font-medium rounded-lg border transition-colors ${E.has(e)?`${Tt[e]} ${ge[e]} border-current/30`:"bg-surface/75 text-subtle border-border/75"}`,children:e},e))}),t.jsx("input",{type:"text",placeholder:s("logs.search"),"aria-label":s("logs.search"),value:L,onChange:e=>V(e.target.value),className:`flex-1 max-w-sm placeholder-subtle ${xe}`}),qe&&t.jsx(ke,{label:s("logs.service"),options:[{value:"",label:s("logs.allServices")},...ae.map(e=>({value:e,label:e}))],value:o,onChange:m,onClear:o?()=>m(""):void 0,searchable:ae.length>8}),ye&&t.jsx(ke,{label:s("logs.range"),options:vt.map(e=>({value:e,label:s(Mt[e])})),value:g,onChange:x}),ye&&g==="custom"&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted",children:[t.jsxs("label",{className:"flex items-center gap-1",children:[s("logs.from"),t.jsx("input",{type:"datetime-local",value:A,onChange:e=>y(e.target.value),className:xe})]}),t.jsxs("label",{className:"flex items-center gap-1",children:[s("logs.to"),t.jsx("input",{type:"datetime-local",value:B,onChange:e=>Z(e.target.value),className:xe})]})]})]}),(w||Se)&&t.jsx($t,{label:s("logs.loading")}),R&&t.jsx(bt,{error:"message"in R?R.message:s(R.key),onRetry:R.more?()=>void de():X}),!w&&!Se&&t.jsxs("div",{className:"bg-surface border border-border rounded-xl overflow-hidden",children:[t.jsxs("div",{className:"px-4 py-3 border-b border-border/75 flex items-center justify-between",children:[t.jsx("span",{className:"text-sm font-medium text-heading",children:s("logs.output")}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{onClick:$e,"aria-pressed":oe,title:s("logs.pauseTitle"),className:`text-[10px] px-2 py-0.5 rounded ${oe?"bg-warning/20 text-warning":"bg-control text-muted"}`,children:oe?fe>0?s("logs.resumeHeld",{count:fe}):s("logs.resume"):s("logs.pause")}),t.jsx("button",{onClick:()=>ne(!O),"aria-pressed":O,title:s("logs.autoScrollTitle"),className:`text-[10px] px-2 py-0.5 rounded ${O?"bg-primary/20 text-accent":"bg-control text-muted"}`,children:s(O?"logs.autoScrollOn":"logs.autoScrollOff")})]})]}),t.jsxs("div",{className:"relative",children:[t.jsxs("div",{ref:C,onScroll:()=>{if(!C.current)return;const{scrollTop:e,scrollHeight:n,clientHeight:a}=C.current;ne(n-e-a<60),e<Pt&&Ne&&n>a&&de()},className:"overflow-y-auto max-h-[60vh] p-3 font-mono text-xs leading-5",children:[Ne&&t.jsx("div",{className:"flex justify-center pb-2",children:t.jsx("button",{onClick:()=>void de(),disabled:W,className:"px-3 py-1 rounded-lg bg-control hover:bg-control-hover text-[11px] font-sans text-accent transition-colors disabled:opacity-50",children:W?t.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[t.jsx(jt,{size:11}),s("common.loading")]}):(i==null?void 0:i.total)!=null?s("logs.loadOlder",{remaining:Math.max(i.total-H,0)}):s("logs.loadOlderMore")})}),U.length===0?t.jsx("div",{className:"text-subtle py-4 text-center",children:s("logs.noMatches")}):U.map(e=>t.jsxs("div",{"data-focused":e===re||void 0,className:`group flex flex-wrap sm:flex-nowrap items-start gap-2 py-0.5 rounded px-1 ${e===re?"bg-error/10 ring-1 ring-error/50":"hover:bg-control"}`,children:[t.jsx("time",{dateTime:e.timestamp,className:"text-subtle shrink-0 text-[10px]",children:d(e.timestamp,At)}),t.jsx("span",{className:`shrink-0 font-bold w-12 text-[10px] ${ge[e.level]??"text-muted"}`,children:e.level}),Ve&&e.service&&t.jsx("span",{className:"shrink-0 text-[10px] px-1 rounded bg-control text-muted max-w-[80px] sm:max-w-[120px] truncate",title:e.service,children:e.service}),e.source&&t.jsxs("span",{className:"text-subtle shrink-0 text-[10px] max-w-[80px] sm:max-w-[120px] truncate",title:e.source,children:["[",e.source,"]"]}),t.jsxs("div",{className:`flex-1 min-w-0 max-sm:min-w-[12rem] ${ge[e.level]??"text-text"}`,children:[t.jsx("span",{className:"whitespace-pre-wrap break-all",children:_t(e.message,L)}),e.exception&&(()=>{const{preview:n,hidden:a}=St(e.exception),l=a===0||Pe.has(e)!==(e===re);return t.jsxs(t.Fragment,{children:[t.jsx("pre",{className:"mt-0.5 text-[10px] text-muted whitespace-pre-wrap break-all",children:l?e.exception:n}),a>0&&t.jsx("button",{onClick:()=>Be(e),className:"text-[10px] font-sans text-accent hover:underline",children:l?s("logs.hideException"):s("logs.showException",{count:a})})]})})()]}),t.jsx("button",{onClick:()=>void Ue(e),title:s("logs.copyTitle"),className:"shrink-0 text-[10px] font-sans px-1.5 rounded bg-control text-muted hover:text-text opacity-0 group-hover:opacity-100 focus:opacity-100 transition-opacity",children:s(He===e?"logs.copied":"logs.copy")})]},Ft(e)))]}),!O&&U.length>0&&t.jsx("button",{onClick:()=>ne(!0),className:"absolute bottom-3 right-5 px-3 py-1 text-[11px] rounded-full bg-primary hover:bg-primary-hover text-on-primary shadow-lg transition-colors",children:s("logs.jumpToNewest")})]})]})]})]})}const Wt=["72%","54%","88%","64%","80%","46%","70%","60%"];function $t({label:s}){return t.jsxs(wt,{label:s,className:"bg-surface border border-border rounded-xl overflow-hidden",children:[t.jsxs("div",{className:"px-4 py-3.5 border-b border-border/75 flex justify-between",children:[t.jsx(z,{className:"h-3.5 w-20"}),t.jsx(z,{className:"h-3.5 w-28"})]}),t.jsx("div",{className:"p-3 space-y-2.5",children:Wt.map((d,p)=>t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(z,{className:"h-2.5 w-28 shrink-0"}),t.jsx(z,{className:"h-2.5 w-9 shrink-0"}),t.jsx(z,{className:"h-2.5",style:{width:d}})]},p))})]})}export{Gt as default};