jishushell 0.0.1 โ†’ 0.4.2

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 (136) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +36 -0
  3. package/THIRD-PARTY-NOTICES +387 -0
  4. package/dist/auth.d.ts +6 -0
  5. package/dist/auth.js +88 -0
  6. package/dist/auth.js.map +1 -0
  7. package/dist/cli.d.ts +2 -0
  8. package/dist/cli.js +290 -0
  9. package/dist/cli.js.map +1 -0
  10. package/dist/config.d.ts +24 -0
  11. package/dist/config.js +226 -0
  12. package/dist/config.js.map +1 -0
  13. package/dist/constants.d.ts +3 -0
  14. package/dist/constants.js +15 -0
  15. package/dist/constants.js.map +1 -0
  16. package/dist/control.d.ts +44 -0
  17. package/dist/control.js +1359 -0
  18. package/dist/control.js.map +1 -0
  19. package/dist/crypto-shim.d.ts +1 -0
  20. package/dist/crypto-shim.js +2 -0
  21. package/dist/crypto-shim.js.map +1 -0
  22. package/dist/doctor.d.ts +46 -0
  23. package/dist/doctor.js +937 -0
  24. package/dist/doctor.js.map +1 -0
  25. package/dist/install.d.ts +27 -0
  26. package/dist/install.js +570 -0
  27. package/dist/install.js.map +1 -0
  28. package/dist/routes/auth.d.ts +4 -0
  29. package/dist/routes/auth.js +151 -0
  30. package/dist/routes/auth.js.map +1 -0
  31. package/dist/routes/instances.d.ts +2 -0
  32. package/dist/routes/instances.js +1303 -0
  33. package/dist/routes/instances.js.map +1 -0
  34. package/dist/routes/setup.d.ts +2 -0
  35. package/dist/routes/setup.js +139 -0
  36. package/dist/routes/setup.js.map +1 -0
  37. package/dist/routes/system.d.ts +2 -0
  38. package/dist/routes/system.js +102 -0
  39. package/dist/routes/system.js.map +1 -0
  40. package/dist/server.d.ts +6 -0
  41. package/dist/server.js +392 -0
  42. package/dist/server.js.map +1 -0
  43. package/dist/services/instance-manager.d.ts +67 -0
  44. package/dist/services/instance-manager.js +1319 -0
  45. package/dist/services/instance-manager.js.map +1 -0
  46. package/dist/services/llm-proxy/adapters.d.ts +3 -0
  47. package/dist/services/llm-proxy/adapters.js +309 -0
  48. package/dist/services/llm-proxy/adapters.js.map +1 -0
  49. package/dist/services/llm-proxy/circuit-breaker.d.ts +9 -0
  50. package/dist/services/llm-proxy/circuit-breaker.js +73 -0
  51. package/dist/services/llm-proxy/circuit-breaker.js.map +1 -0
  52. package/dist/services/llm-proxy/encryption.d.ts +6 -0
  53. package/dist/services/llm-proxy/encryption.js +61 -0
  54. package/dist/services/llm-proxy/encryption.js.map +1 -0
  55. package/dist/services/llm-proxy/index.d.ts +24 -0
  56. package/dist/services/llm-proxy/index.js +708 -0
  57. package/dist/services/llm-proxy/index.js.map +1 -0
  58. package/dist/services/llm-proxy/rate-limiter.d.ts +1 -0
  59. package/dist/services/llm-proxy/rate-limiter.js +39 -0
  60. package/dist/services/llm-proxy/rate-limiter.js.map +1 -0
  61. package/dist/services/llm-proxy/sse.d.ts +10 -0
  62. package/dist/services/llm-proxy/sse.js +378 -0
  63. package/dist/services/llm-proxy/sse.js.map +1 -0
  64. package/dist/services/llm-proxy/ssrf.d.ts +16 -0
  65. package/dist/services/llm-proxy/ssrf.js +185 -0
  66. package/dist/services/llm-proxy/ssrf.js.map +1 -0
  67. package/dist/services/llm-proxy/types.d.ts +52 -0
  68. package/dist/services/llm-proxy/types.js +2 -0
  69. package/dist/services/llm-proxy/types.js.map +1 -0
  70. package/dist/services/llm-proxy/usage.d.ts +12 -0
  71. package/dist/services/llm-proxy/usage.js +108 -0
  72. package/dist/services/llm-proxy/usage.js.map +1 -0
  73. package/dist/services/nomad-manager.d.ts +22 -0
  74. package/dist/services/nomad-manager.js +828 -0
  75. package/dist/services/nomad-manager.js.map +1 -0
  76. package/dist/services/plugin-installer.d.ts +22 -0
  77. package/dist/services/plugin-installer.js +102 -0
  78. package/dist/services/plugin-installer.js.map +1 -0
  79. package/dist/services/process-manager.d.ts +25 -0
  80. package/dist/services/process-manager.js +531 -0
  81. package/dist/services/process-manager.js.map +1 -0
  82. package/dist/services/setup-manager.d.ts +93 -0
  83. package/dist/services/setup-manager.js +1922 -0
  84. package/dist/services/setup-manager.js.map +1 -0
  85. package/dist/services/system-monitor.d.ts +1 -0
  86. package/dist/services/system-monitor.js +79 -0
  87. package/dist/services/system-monitor.js.map +1 -0
  88. package/dist/services/telemetry/activation.d.ts +12 -0
  89. package/dist/services/telemetry/activation.js +75 -0
  90. package/dist/services/telemetry/activation.js.map +1 -0
  91. package/dist/services/telemetry/client.d.ts +21 -0
  92. package/dist/services/telemetry/client.js +47 -0
  93. package/dist/services/telemetry/client.js.map +1 -0
  94. package/dist/services/telemetry/device-fingerprint.d.ts +18 -0
  95. package/dist/services/telemetry/device-fingerprint.js +123 -0
  96. package/dist/services/telemetry/device-fingerprint.js.map +1 -0
  97. package/dist/services/telemetry/heartbeat.d.ts +13 -0
  98. package/dist/services/telemetry/heartbeat.js +81 -0
  99. package/dist/services/telemetry/heartbeat.js.map +1 -0
  100. package/dist/services/telemetry/index.d.ts +3 -0
  101. package/dist/services/telemetry/index.js +4 -0
  102. package/dist/services/telemetry/index.js.map +1 -0
  103. package/dist/types.d.ts +51 -0
  104. package/dist/types.js +2 -0
  105. package/dist/types.js.map +1 -0
  106. package/dist/utils/safe-json.d.ts +2 -0
  107. package/dist/utils/safe-json.js +80 -0
  108. package/dist/utils/safe-json.js.map +1 -0
  109. package/dist/utils/ttl-cache.d.ts +29 -0
  110. package/dist/utils/ttl-cache.js +77 -0
  111. package/dist/utils/ttl-cache.js.map +1 -0
  112. package/install/jishu-install.sh +2920 -0
  113. package/install/jishu-uninstall.sh +811 -0
  114. package/install/post-install.sh +110 -0
  115. package/install/post-uninstall.sh +46 -0
  116. package/package.json +57 -8
  117. package/public/assets/Dashboard-CAOQDYDR.js +1 -0
  118. package/public/assets/InitPassword-CkehIkJG.js +1 -0
  119. package/public/assets/InstanceDetail-CzW2S95J.js +14 -0
  120. package/public/assets/Login-RkjzTNWg.js +1 -0
  121. package/public/assets/NewInstance-DdbErdjA.js +1 -0
  122. package/public/assets/Settings-BUD7zwv9.js +1 -0
  123. package/public/assets/Setup-RRTIERGG.js +1 -0
  124. package/public/assets/index-77Ug7feY.css +1 -0
  125. package/public/assets/index-DfRnVUQR.js +16 -0
  126. package/public/assets/providers-lBSOjUWy.js +1 -0
  127. package/public/assets/usePolling-CqQ8hrNc.js +1 -0
  128. package/public/assets/vendor-i18n-Bvxxh8Di.js +9 -0
  129. package/public/assets/vendor-react-DONn7uBV.js +59 -0
  130. package/public/index.html +15 -0
  131. package/scripts/build-image.sh +55 -0
  132. package/scripts/run.sh +310 -0
  133. package/scripts/setup-pi.sh +80 -0
  134. package/scripts/start-feishu1.js +46 -0
  135. package/index.js +0 -0
  136. package/jishushell-0.0.1.tgz +0 -0
@@ -0,0 +1,110 @@
1
+ #!/bin/bash
2
+ set -uo pipefail
3
+
4
+ # CI environments run `npm install` only to fetch deps โ€” skip post-install entirely.
5
+ if [[ "${CI:-}" == "true" || -n "${CI_PIPELINE_ID:-}" ]]; then
6
+ exit 0
7
+ fi
8
+
9
+ # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
10
+ # JishuShell Post-Install Script
11
+ #
12
+ # Executed automatically via `npm postinstall` after `npm install -g jishushell`.
13
+ # Installs all runtime dependencies (Docker, Nomad, OpenClaw) and registers the
14
+ # JishuShell service.
15
+ #
16
+ # Skips:
17
+ # โ€ข Node.js โ€” already installed (npm is running on it)
18
+ # โ€ข npm install -g jishushell โ€” npm just installed the package itself
19
+ #
20
+ # Sources jishu-install.sh for all shared functions.
21
+ # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
22
+
23
+ # When post-install.sh is triggered by npm's postinstall hook that was itself
24
+ # launched from inside jishu-install.sh (i.e. jishu-install.sh called
25
+ # `npm install -g jishushell`), all installation steps have already been run
26
+ # by the parent script. Only write the wrapper + service registration, then exit.
27
+ if [[ "${JISHU_RUNNING_IN_INSTALLER:-0}" == "1" ]]; then
28
+ echo " [post-install] Detected parent jishu-install.sh โ€” skipping redundant install steps"
29
+ JISHU_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
30
+ source "${JISHU_SCRIPT_DIR}/jishu-install.sh"
31
+ SKIP_NODE=1
32
+ SKIP_DOCKER=1
33
+ SKIP_NOMAD=1
34
+ SKIP_OPENCLAW=1
35
+ export JISHUSHELL_SKIP_NPM_INSTALL=1
36
+ detect_os
37
+ detect_arch
38
+ if [[ $EUID -eq 0 ]]; then SUDO=""; else SUDO="sudo"; fi
39
+ install_jishushell || true
40
+ install_jishushell_service || true
41
+ # Backup scripts
42
+ _jishu_install_backup="${REAL_HOME}/.jishushell/install"
43
+ mkdir -p "$_jishu_install_backup"
44
+ cp -f "${JISHU_SCRIPT_DIR}/jishu-install.sh" "${_jishu_install_backup}/jishu-install.sh" 2>/dev/null || true
45
+ cp -f "${JISHU_SCRIPT_DIR}/jishu-uninstall.sh" "${_jishu_install_backup}/jishu-uninstall.sh" 2>/dev/null || true
46
+ cp -f "${JISHU_SCRIPT_DIR}/post-uninstall.sh" "${_jishu_install_backup}/post-uninstall.sh" 2>/dev/null || true
47
+ chmod +x "${_jishu_install_backup}/jishu-uninstall.sh" "${_jishu_install_backup}/post-uninstall.sh" 2>/dev/null || true
48
+ exit 0
49
+ fi
50
+
51
+ JISHU_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
52
+ JISHU_INSTALL_SH="${JISHU_SCRIPT_DIR}/jishu-install.sh"
53
+
54
+ if [[ ! -f "$JISHU_INSTALL_SH" ]]; then
55
+ echo "ERROR: cannot find jishu-install.sh at ${JISHU_INSTALL_SH}" >&2
56
+ exit 1
57
+ fi
58
+
59
+ # Source shared functions (double-source guard is built in)
60
+ # shellcheck disable=SC1090
61
+ source "$JISHU_INSTALL_SH"
62
+
63
+ # Skip steps handled by npm
64
+ SKIP_NODE=1
65
+ export JISHUSHELL_SKIP_NPM_INSTALL=1
66
+
67
+ # Parse any extra args forwarded via npm (e.g. --dry-run, --yes, --skip-docker)
68
+ parse_args "$@"
69
+
70
+ # โ”€โ”€ Log setup โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
71
+ # npm captures lifecycle script stdout/stderr and only shows it on error.
72
+ # Writing to /dev/tty bypasses that capture so progress is visible in real time.
73
+ # The log file is always written regardless of tty availability.
74
+ mkdir -p "${REAL_HOME}/.jishushell"
75
+ LOG_FILE="${REAL_HOME}/.jishushell/post-install-$(date +%Y-%m-%d-%H-%M-%S)-$$.log"
76
+ if [[ -w /dev/tty ]] && echo -n '' > /dev/tty 2>/dev/null; then
77
+ # tee writes to $LOG_FILE; its stdout (>/dev/tty) goes straight to the terminal,
78
+ # bypassing npm's stdout capture entirely.
79
+ exec > >(tee -a "$LOG_FILE" >/dev/tty) 2>&1
80
+ else
81
+ # Non-interactive / CI: fall back to npm's stdout (visible with --foreground-scripts)
82
+ exec > >(tee -a "$LOG_FILE") 2>&1
83
+ fi
84
+
85
+ echo ""
86
+ ui_info "Log: ${LOG_FILE}"
87
+ echo ""
88
+
89
+ # โ”€โ”€ Run install steps โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
90
+ detect_os
91
+ detect_arch
92
+ check_sudo
93
+ ensure_prerequisites
94
+ run_install_components --with-jishushell || true
95
+ _rc=$?
96
+ show_summary --with-jishushell
97
+
98
+ # โ”€โ”€ Persist uninstall scripts for postuninstall lifecycle hook โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
99
+ # npm removes package files BEFORE postuninstall runs, so we keep a copy in
100
+ # ~/.jishushell/install/ that the postuninstall script can always find.
101
+ _jishu_install_backup="${REAL_HOME}/.jishushell/install"
102
+ mkdir -p "$_jishu_install_backup"
103
+ cp -f "${JISHU_SCRIPT_DIR}/jishu-install.sh" "${_jishu_install_backup}/jishu-install.sh" 2>/dev/null || true
104
+ cp -f "${JISHU_SCRIPT_DIR}/jishu-uninstall.sh" "${_jishu_install_backup}/jishu-uninstall.sh" 2>/dev/null || true
105
+ cp -f "${JISHU_SCRIPT_DIR}/post-uninstall.sh" "${_jishu_install_backup}/post-uninstall.sh" 2>/dev/null || true
106
+ chmod +x "${_jishu_install_backup}/jishu-uninstall.sh" "${_jishu_install_backup}/post-uninstall.sh" 2>/dev/null || true
107
+
108
+ echo ""
109
+ ui_info "Full log saved to: ${LOG_FILE}"
110
+ exit $_rc
@@ -0,0 +1,46 @@
1
+ #!/bin/bash
2
+ # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
3
+ # JishuShell Pre-Uninstall Script
4
+ #
5
+ # Called by npm's preuninstall lifecycle hook during `npm uninstall -g jishushell`.
6
+ # Runs BEFORE npm removes the package files.
7
+ #
8
+ # Guard: only clean up when ~/.jishushell exists (indicates a real global install).
9
+ # This makes the script safe regardless of npm_config_global being set or not.
10
+ # โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•
11
+
12
+ if [ ! -d "${HOME}/.jishushell" ]; then
13
+ exit 0
14
+ fi
15
+
16
+ _SUDO=""
17
+ if [ "$(id -u)" -ne 0 ] && command -v sudo >/dev/null 2>&1; then
18
+ _SUDO="sudo"
19
+ fi
20
+
21
+ echo "ยท JishuShell: stopping services and cleaning up..."
22
+
23
+ # โ”€โ”€ systemd (Linux) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
24
+ if command -v systemctl >/dev/null 2>&1; then
25
+ for svc in jishushell nomad; do
26
+ $_SUDO systemctl stop "$svc" 2>/dev/null || true
27
+ $_SUDO systemctl disable "$svc" 2>/dev/null || true
28
+ $_SUDO rm -f "/etc/systemd/system/${svc}.service" 2>/dev/null || true
29
+ done
30
+ $_SUDO systemctl daemon-reload 2>/dev/null || true
31
+ fi
32
+
33
+ # โ”€โ”€ launchd (macOS) โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
34
+ if [ "$(uname -s)" = "Darwin" ]; then
35
+ for label in com.jishushell.backend com.jishushell.nomad; do
36
+ launchctl unload -w "${HOME}/Library/LaunchAgents/${label}.plist" 2>/dev/null || true
37
+ rm -f "${HOME}/Library/LaunchAgents/${label}.plist" 2>/dev/null || true
38
+ done
39
+ fi
40
+
41
+ # โ”€โ”€ Remove ~/.jishushell data directory โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
42
+ if [ -d "${HOME}/.jishushell" ]; then
43
+ $_SUDO rm -rf "${HOME}/.jishushell"
44
+ echo "ยท Removed ${HOME}/.jishushell"
45
+ fi
46
+
package/package.json CHANGED
@@ -1,13 +1,62 @@
1
1
  {
2
2
  "name": "jishushell",
3
- "version": "0.0.1",
4
- "description": "OpenSource Agent Management Framework(Coming Soon)",
5
- "main": "index.js",
3
+ "version": "0.4.2",
4
+ "description": "JishuShell - Raspberry Pi server management panel",
5
+ "type": "module",
6
+ "bin": {
7
+ "jishushell": "./dist/cli.js"
8
+ },
9
+ "files": [
10
+ "dist/",
11
+ "public/",
12
+ "scripts/",
13
+ "install/",
14
+ "NOTICE",
15
+ "THIRD-PARTY-NOTICES"
16
+ ],
6
17
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
18
+ "build": "npm install && tsc && cd frontend && npm install && npm run build",
19
+ "build:backend": "npm install && tsc",
20
+ "build:frontend": "cd frontend && npm install && npm run build",
21
+ "start": "node dist/cli.js serve",
22
+ "dev": "tsc --watch",
23
+ "test": "vitest run",
24
+ "test:unit:backend": "vitest run tests/unit",
25
+ "test:integration": "vitest run tests/integration",
26
+ "test:watch": "vitest",
27
+ "test:coverage": "vitest run --coverage",
28
+ "test:ci": "npm run build:backend && vitest run --coverage && cd frontend && npm install && npm run test",
29
+ "prepublishOnly": "npm run build && chmod +x dist/cli.js",
30
+ "postinstall": "bash install/post-install.sh",
31
+ "preuninstall": "bash install/post-uninstall.sh",
32
+ "prepare": "git config core.hooksPath .githooks 2>/dev/null || true",
33
+ "build:pack": "npm run build && npm pack",
34
+ "version": "node -e \"const fs=require('fs'),p=JSON.parse(fs.readFileSync('./frontend/package.json','utf8'));p.version=JSON.parse(fs.readFileSync('./package.json','utf8')).version;fs.writeFileSync('./frontend/package.json',JSON.stringify(p,null,2)+'\\n')\" && git add frontend/package.json"
35
+ },
36
+ "engines": {
37
+ "node": ">=22"
38
+ },
39
+ "keywords": [
40
+ "raspberry-pi",
41
+ "server-panel",
42
+ "openclaw"
43
+ ],
44
+ "license": "Apache-2.0",
45
+ "dependencies": {
46
+ "@fastify/static": "^8.1.0",
47
+ "@noble/hashes": "^2.0.1",
48
+ "bcryptjs": "^2.4.3",
49
+ "fastify": "^5.2.0",
50
+ "jsonwebtoken": "^9.0.2",
51
+ "systeminformation": "^5.23.0"
8
52
  },
9
- "keywords": [],
10
- "author": "",
11
- "license": "ISC",
12
- "type": "commonjs"
53
+ "devDependencies": {
54
+ "@types/bcryptjs": "^2.4.6",
55
+ "@types/jsonwebtoken": "^9.0.7",
56
+ "@types/node": "^22.19.15",
57
+ "@vitest/coverage-v8": "^4.1.1",
58
+ "pptxgenjs": "^4.0.1",
59
+ "typescript": "^5.7.0",
60
+ "vitest": "^4.1.1"
61
+ }
13
62
  }
@@ -0,0 +1 @@
1
+ import{h as L,k as A,j as e,L as R,l as F,m as U,n as W,o as K,p as T,q as D,t as I,v as P,w as q,x as G}from"./index-DfRnVUQR.js";import{r as l,u as H}from"./vendor-react-DONn7uBV.js";import{u as z}from"./usePolling-CqQ8hrNc.js";import{u as S}from"./vendor-i18n-Bvxxh8Di.js";function J(t){if(!t)return"-";const n=Math.floor(t/86400),d=Math.floor(t%86400/3600),r=Math.floor(t%3600/60);return n>0?`${n}d ${d}h`:d>0?`${d}h ${r}m`:`${r}m`}function O({status:t}){const{t:n}=S(),r={running:{cls:"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",labelKey:"status.running"},pending:{cls:"bg-amber-500/10 text-amber-400 border border-amber-500/20",labelKey:"status.starting"},failed:{cls:"bg-red-500/10 text-red-400 border border-red-500/20",labelKey:"status.failed"},dead:{cls:"bg-red-500/10 text-red-400 border border-red-500/20",labelKey:"status.crashed"}}[t]||{cls:"bg-[var(--card)] text-muted border border-[var(--border)]",labelKey:"status.stopped"};return e.jsx("span",{className:`inline-flex items-center text-xs px-2 py-0.5 rounded-full font-medium ${r.cls}`,children:n(r.labelKey)})}function ee(){const{t}=S(["dashboard","common"]),[n,d]=l.useState([]),[r,_]=l.useState(null),[b,j]=l.useState(""),[y,v]=l.useState(""),[p,f]=l.useState(!1),[o,N]=l.useState(null),[w,k]=l.useState(!1),C=H(),{showToast:c}=L(),m=()=>{K().then(s=>{d(s),v("")}).catch(s=>v(s.message||t("common:error.loadFailed"))),T().then(_).catch(()=>{})};z(m,1e4),l.useEffect(()=>{A().then(s=>{s.hasUpdate&&N({currentVersion:s.currentVersion,latestVersion:s.latestVersion})}).catch(()=>{})},[]);const B=async()=>{if(window.confirm(t("update.confirm",{currentVersion:o==null?void 0:o.currentVersion,latestVersion:o==null?void 0:o.latestVersion}))){k(!0);try{await D(),c(t("update.started"),"success"),N(null)}catch(s){c(s.message||t("update.failed"),"error")}finally{k(!1)}}},V=async()=>{if(window.confirm(t("engine.restartConfirm"))){f(!0);try{await I(),c(t("engine.restarted"),"success"),setTimeout(m,2e3)}catch(s){c(s.message||t("engine.restartFailed"),"error")}finally{f(!1)}}},g=async(s,a,i)=>{s.stopPropagation(),j(`${i}-${a}`);try{a==="start"&&await P(i),a==="stop"&&await q(i),a==="restart"&&await G(i),c(t(`common:action.${a}Done`),"success"),setTimeout(m,1e3)}catch(h){c(h.message||t("common:error.operationFailed"),"error")}finally{j("")}},E=n.filter(s=>{var a;return((a=s.service)==null?void 0:a.status)==="running"}).length,u=!!r&&r.disk.percent>90,M=r?[{label:t("stats.runningInstances"),value:`${E} / ${n.length}`,sub:r.nomad_running?t("stats.engineRunning"):t("stats.engineStopped"),subColor:r.nomad_running?"text-emerald-400":"text-red-400",icon:e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),e.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]}),iconColor:"text-[#0066FF]",glowColor:"rgba(0,102,255,0.12)",accent:"border-l-2 border-l-[#0066FF]"},{label:t("stats.cpu"),value:`${r.cpu_percent}%`,sub:r.temperature?`${r.temperature}ยฐC`:null,icon:e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"}),e.jsx("rect",{x:"9",y:"9",width:"6",height:"6"}),e.jsx("line",{x1:"9",y1:"2",x2:"9",y2:"4"}),e.jsx("line",{x1:"15",y1:"2",x2:"15",y2:"4"}),e.jsx("line",{x1:"9",y1:"20",x2:"9",y2:"22"}),e.jsx("line",{x1:"15",y1:"20",x2:"15",y2:"22"}),e.jsx("line",{x1:"20",y1:"9",x2:"22",y2:"9"}),e.jsx("line",{x1:"20",y1:"15",x2:"22",y2:"15"}),e.jsx("line",{x1:"2",y1:"9",x2:"4",y2:"9"}),e.jsx("line",{x1:"2",y1:"15",x2:"4",y2:"15"})]}),iconColor:"text-[#0066FF]",glowColor:"rgba(0,102,255,0.12)",accent:"border-l-2 border-l-[#0066FF]",warn:r.cpu_percent>90},{label:t("stats.memory"),value:`${r.memory.percent}%`,sub:`${r.memory.used_mb}MB / ${r.memory.total_mb}MB`,icon:e.jsx("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{d:"M6 19v-8m4 8v-4m4 4v-6m4 6v-2"})}),iconColor:"text-[#00D4AA]",glowColor:"rgba(0,212,170,0.12)",accent:"border-l-2 border-l-[#00D4AA]"},{label:t("stats.disk"),value:`${r.disk.percent}%`,sub:`${r.disk.used_gb}GB / ${r.disk.total_gb}GB`,icon:e.jsxs("svg",{className:"w-4 h-4",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:[e.jsx("ellipse",{cx:"12",cy:"5",rx:"9",ry:"3"}),e.jsx("path",{d:"M3 5v14a9 3 0 0018 0V5"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"22"})]}),iconColor:u?"text-red-400":"text-[#0066FF]",glowColor:u?"rgba(239,68,68,0.12)":"rgba(0,102,255,0.12)",accent:u?"border-l-2 border-l-red-400":"border-l-2 border-l-[#0066FF]",warn:u}]:[];return e.jsxs("div",{className:"p-4 max-w-5xl mx-auto",children:[o&&e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3 bg-amber-500/10 border border-amber-500/30 rounded-lg px-4 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("svg",{className:"w-4 h-4 text-amber-400 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{d:"M12 2v6m0 0 2-2m-2 2-2-2M4.93 10.93A10 10 0 1 0 21 12"})}),e.jsxs("span",{className:"text-amber-300",children:[t("update.found"),e.jsx("span",{className:"font-mono text-amber-200 ml-1",children:o.currentVersion}),e.jsx("span",{className:"mx-1 text-amber-500",children:"โ†’"}),e.jsx("span",{className:"font-mono text-amber-200",children:o.latestVersion})]})]}),e.jsx("button",{onClick:B,disabled:w,className:"shrink-0 bg-amber-500 hover:bg-amber-400 disabled:opacity-50 text-black text-xs font-semibold px-3 py-1 rounded-md transition-colors",children:t(w?"update.upgrading":"update.upgradeNow")})]}),e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-base font-semibold text-foreground",children:t("title")}),e.jsx("p",{className:"text-xs text-muted mt-0.5",children:t("subtitle")})]}),e.jsx(R,{})]}),r&&e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-4",children:M.map(s=>e.jsxs("div",{className:`bg-[var(--card)] border border-[var(--border)] rounded-lg p-3 relative overflow-hidden hover:border-[var(--border-hover)] hover:bg-[var(--card-hover)] transition-all duration-200 ${s.accent}`,children:[e.jsx("div",{className:"absolute top-0 right-0 w-16 h-16 rounded-full opacity-60 pointer-events-none",style:{background:`radial-gradient(circle, ${s.glowColor} 0%, transparent 70%)`}}),e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("span",{className:"text-[11px] text-muted",children:s.label}),e.jsx("span",{className:`${s.iconColor} opacity-80`,children:s.icon})]}),e.jsx("div",{className:`text-lg font-semibold ${s.warn?"text-red-400":"text-foreground"}`,children:s.value}),s.sub&&e.jsx("div",{className:`text-[11px] mt-0.5 truncate ${s.subColor??"text-muted"}`,children:s.sub})]},s.label))}),e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-2.5 border-b border-[var(--border)] flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-medium text-foreground",children:t("instances.title")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>C("/instances/new"),className:"bg-[#0066FF] text-white px-3 py-1.5 rounded-md text-xs font-medium hover:bg-[#0066FF]/90 transition-all duration-200 shadow-[0_0_12px_rgba(0,102,255,0.3)]",children:t("instances.new")}),e.jsxs("button",{onClick:V,disabled:p,title:t("instances.restartEngineTitle"),className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-xs font-medium text-red-400 border border-red-500/20 bg-red-500/5 hover:bg-red-500/15 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200",children:[e.jsx(F,{className:`w-3 h-3 ${p?"animate-spin":""}`}),t(p?"instances.restarting":"instances.restartEngine")]})]})]}),y?e.jsxs("div",{className:"text-center py-12 px-4",children:[e.jsx("p",{className:"text-sm text-red-400 mb-2",children:t("instances.loadError",{error:y})}),e.jsx("button",{onClick:m,className:"text-xs text-muted hover:text-foreground underline",children:t("common:action.retry")})]}):n.length===0?e.jsxs("div",{className:"text-center py-12 px-4",children:[e.jsx("div",{className:"text-muted opacity-40 mb-3",children:e.jsxs("svg",{className:"w-8 h-8 mx-auto",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2"}),e.jsx("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),e.jsx("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}),e.jsx("p",{className:"text-sm text-muted mb-1",children:t("instances.empty")}),e.jsx("p",{className:"text-xs text-muted opacity-60",children:t("instances.emptyHint")})]}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-xs text-muted border-b border-[var(--border)]",children:[e.jsx("th",{className:"text-left font-medium px-4 py-2",children:t("table.name")}),e.jsx("th",{className:"text-left font-medium px-4 py-2",children:t("table.status")}),e.jsx("th",{className:"text-left font-medium px-4 py-2 hidden sm:table-cell",children:t("table.uptime")}),e.jsx("th",{className:"text-left font-medium px-4 py-2 hidden md:table-cell",children:t("table.memory")}),e.jsx("th",{className:"text-right font-medium px-4 py-2",children:t("table.actions")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border)]",children:n.map(s=>{var h,$;const a=((h=s.service)==null?void 0:h.status)||"stopped",i=a==="running";return e.jsxs("tr",{className:"hover:bg-[var(--card-hover)] cursor-pointer transition-colors duration-150",onClick:()=>C(`/instances/${s.id}`),children:[e.jsxs("td",{className:"px-4 py-2.5",children:[e.jsx("div",{className:"font-medium text-foreground",children:s.name}),e.jsx("div",{className:"text-xs text-muted font-mono",children:s.id})]}),e.jsx("td",{className:"px-4 py-2.5",children:e.jsx(O,{status:a})}),e.jsx("td",{className:"px-4 py-2.5 text-muted hidden sm:table-cell font-mono text-xs",children:i?J(s.service.uptime):"-"}),e.jsx("td",{className:"px-4 py-2.5 text-muted hidden md:table-cell font-mono text-xs",children:($=s.service)!=null&&$.memory_mb?`${s.service.memory_mb} MB`:"-"}),e.jsx("td",{className:"px-4 py-2.5 text-right",children:e.jsx("div",{className:"inline-flex items-center gap-1",children:i||a==="pending"?e.jsxs(e.Fragment,{children:[e.jsx("button",{title:t("common:action.restart"),onClick:x=>g(x,"restart",s.id),disabled:!!b,className:"p-1.5 rounded-md text-muted hover:text-foreground hover:bg-[var(--card-hover)] disabled:opacity-30 transition-colors duration-150",children:e.jsx(F,{className:"w-3.5 h-3.5"})}),e.jsx("button",{title:t("common:action.stop"),onClick:x=>g(x,"stop",s.id),disabled:!!b,className:"p-1.5 rounded-md text-muted hover:text-red-400 hover:bg-red-500/10 disabled:opacity-30 transition-colors duration-150",children:e.jsx(U,{className:"w-3.5 h-3.5"})})]}):e.jsx("button",{title:t("common:action.start"),onClick:x=>g(x,"start",s.id),disabled:!!b,className:"p-1.5 rounded-md text-muted hover:text-emerald-400 hover:bg-emerald-500/10 disabled:opacity-30 transition-colors duration-150",children:e.jsx(W,{className:"w-3.5 h-3.5"})})})})]},s.id)})})]})]})]})}export{ee as default};
@@ -0,0 +1 @@
1
+ import{j as e,T as j,I as v,a as w,c as N,s as y}from"./index-DfRnVUQR.js";import{r}from"./vendor-react-DONn7uBV.js";import{u as F}from"./vendor-i18n-Bvxxh8Di.js";const x="w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2.5 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200";function _({onDone:p}){const{t}=F("auth"),[s,h]=r.useState(""),[n,b]=r.useState(""),[o,f]=r.useState(!1),[l,d]=r.useState(""),[c,m]=r.useState(!1),u=s.length>=8&&s===n,g=async a=>{if(a.preventDefault(),!!u){d(""),m(!0);try{const i=await N(s);y(i.token),p()}catch(i){d(i.message||t("init.failed"))}finally{m(!1)}}};return e.jsxs("div",{className:"min-h-screen flex items-center justify-center p-4 bg-background relative overflow-hidden",children:[e.jsx("div",{className:"grid-bg absolute inset-0 pointer-events-none"}),e.jsx("div",{className:"absolute top-1/3 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[500px] h-[300px] rounded-full bg-[#0066FF]/[0.07] blur-[90px] pointer-events-none"}),e.jsxs("div",{className:"w-full max-w-sm relative z-10",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx(j,{className:"w-40 h-40 mx-auto mb-4 object-contain"}),e.jsx("p",{className:"text-sm text-muted mt-1",children:t("init.title")})]}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[l&&e.jsx("div",{className:"bg-red-500/10 border border-red-500/20 text-red-400 text-sm rounded-lg px-3 py-2.5",children:l}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("init.password")}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:o?"text":"password",value:s,onChange:a=>h(a.target.value),placeholder:t("init.passwordPlaceholder"),className:`${x} pr-10`,autoFocus:!0}),e.jsx("button",{type:"button",onClick:()=>f(!o),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted hover:text-foreground transition-colors duration-200",children:o?e.jsx(v,{}):e.jsx(w,{})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:t("init.confirm")}),e.jsx("input",{type:o?"text":"password",value:n,onChange:a=>b(a.target.value),placeholder:t("init.confirmPlaceholder"),className:x}),s&&n&&s!==n&&e.jsx("p",{className:"text-red-400 text-xs mt-1.5",children:t("init.mismatch")})]}),e.jsx("button",{type:"submit",disabled:c||!u,className:"w-full bg-[#0066FF] text-white rounded-md py-2.5 text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 disabled:cursor-not-allowed transition-all duration-200 shadow-[0_0_20px_rgba(0,102,255,0.3)] hover:shadow-[0_0_28px_rgba(0,102,255,0.45)]",children:c?e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx("span",{className:"w-3.5 h-3.5 border-2 border-white/30 border-t-white rounded-full animate-spin"}),t("init.loading")]}):t("init.submit")})]})]})]})}export{_ as default};
@@ -0,0 +1,14 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DfRnVUQR.js","assets/vendor-react-DONn7uBV.js","assets/vendor-i18n-Bvxxh8Di.js","assets/index-77Ug7feY.css"])))=>i.map(i=>d[i]);
2
+ import{j as e,y as ts,z as As,I as Is,a as Ps,_ as Rs,A as Ht,B as ss,C as rs,D as ns,E as as,F as Ls,l as ls,G as Ts,h as Ds,k as Os,H as Te,J as ct,K as $s,M as Us,N as zt,O as Wt,P as Kt,Q as _s,R as qs,S as Jt,U as Bs,V as Vt,W as Qt,X as Hs,Y as zs,q as Ws,Z as Ks,$ as Js,v as Vs,w as Qs,x as Gt,a0 as Gs,a1 as Ys}from"./index-DfRnVUQR.js";import{e as K,r as w,d as Xs,u as Zs}from"./vendor-react-DONn7uBV.js";import{u as er}from"./usePolling-CqQ8hrNc.js";import{P as He}from"./providers-lBSOjUWy.js";import{u as we,i as tr}from"./vendor-i18n-Bvxxh8Di.js";var sr=Object.defineProperty,Ke=Object.getOwnPropertySymbols,os=Object.prototype.hasOwnProperty,is=Object.prototype.propertyIsEnumerable,Yt=(r,i,o)=>i in r?sr(r,i,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[i]=o,ut=(r,i)=>{for(var o in i||(i={}))os.call(i,o)&&Yt(r,o,i[o]);if(Ke)for(var o of Ke(i))is.call(i,o)&&Yt(r,o,i[o]);return r},mt=(r,i)=>{var o={};for(var x in r)os.call(r,x)&&i.indexOf(x)<0&&(o[x]=r[x]);if(r!=null&&Ke)for(var x of Ke(r))i.indexOf(x)<0&&is.call(r,x)&&(o[x]=r[x]);return o};/**
3
+ * @license QR Code generator library (TypeScript)
4
+ * Copyright (c) Project Nayuki.
5
+ * SPDX-License-Identifier: MIT
6
+ */var Ce;(r=>{const i=class R{constructor(n,a,s,d){if(this.version=n,this.errorCorrectionLevel=a,this.modules=[],this.isFunction=[],n<R.MIN_VERSION||n>R.MAX_VERSION)throw new RangeError("Version value out of range");if(d<-1||d>7)throw new RangeError("Mask value out of range");this.size=n*4+17;let h=[];for(let g=0;g<this.size;g++)h.push(!1);for(let g=0;g<this.size;g++)this.modules.push(h.slice()),this.isFunction.push(h.slice());this.drawFunctionPatterns();const N=this.addEccAndInterleave(s);if(this.drawCodewords(N),d==-1){let g=1e9;for(let C=0;C<8;C++){this.applyMask(C),this.drawFormatBits(C);const j=this.getPenaltyScore();j<g&&(d=C,g=j),this.applyMask(C)}}t(0<=d&&d<=7),this.mask=d,this.applyMask(d),this.drawFormatBits(d),this.isFunction=[]}static encodeText(n,a){const s=r.QrSegment.makeSegments(n);return R.encodeSegments(s,a)}static encodeBinary(n,a){const s=r.QrSegment.makeBytes(n);return R.encodeSegments([s],a)}static encodeSegments(n,a,s=1,d=40,h=-1,N=!0){if(!(R.MIN_VERSION<=s&&s<=d&&d<=R.MAX_VERSION)||h<-1||h>7)throw new RangeError("Invalid value");let g,C;for(g=s;;g++){const S=R.getNumDataCodewords(g,a)*8,F=m.getTotalBits(n,g);if(F<=S){C=F;break}if(g>=d)throw new RangeError("Data too long")}for(const S of[R.Ecc.MEDIUM,R.Ecc.QUARTILE,R.Ecc.HIGH])N&&C<=R.getNumDataCodewords(g,S)*8&&(a=S);let j=[];for(const S of n){o(S.mode.modeBits,4,j),o(S.numChars,S.mode.numCharCountBits(g),j);for(const F of S.getData())j.push(F)}t(j.length==C);const $=R.getNumDataCodewords(g,a)*8;t(j.length<=$),o(0,Math.min(4,$-j.length),j),o(0,(8-j.length%8)%8,j),t(j.length%8==0);for(let S=236;j.length<$;S^=253)o(S,8,j);let L=[];for(;L.length*8<j.length;)L.push(0);return j.forEach((S,F)=>L[F>>>3]|=S<<7-(F&7)),new R(g,a,L,h)}getModule(n,a){return 0<=n&&n<this.size&&0<=a&&a<this.size&&this.modules[a][n]}getModules(){return this.modules}drawFunctionPatterns(){for(let s=0;s<this.size;s++)this.setFunctionModule(6,s,s%2==0),this.setFunctionModule(s,6,s%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const n=this.getAlignmentPatternPositions(),a=n.length;for(let s=0;s<a;s++)for(let d=0;d<a;d++)s==0&&d==0||s==0&&d==a-1||s==a-1&&d==0||this.drawAlignmentPattern(n[s],n[d]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(n){const a=this.errorCorrectionLevel.formatBits<<3|n;let s=a;for(let h=0;h<10;h++)s=s<<1^(s>>>9)*1335;const d=(a<<10|s)^21522;t(d>>>15==0);for(let h=0;h<=5;h++)this.setFunctionModule(8,h,x(d,h));this.setFunctionModule(8,7,x(d,6)),this.setFunctionModule(8,8,x(d,7)),this.setFunctionModule(7,8,x(d,8));for(let h=9;h<15;h++)this.setFunctionModule(14-h,8,x(d,h));for(let h=0;h<8;h++)this.setFunctionModule(this.size-1-h,8,x(d,h));for(let h=8;h<15;h++)this.setFunctionModule(8,this.size-15+h,x(d,h));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let n=this.version;for(let s=0;s<12;s++)n=n<<1^(n>>>11)*7973;const a=this.version<<12|n;t(a>>>18==0);for(let s=0;s<18;s++){const d=x(a,s),h=this.size-11+s%3,N=Math.floor(s/3);this.setFunctionModule(h,N,d),this.setFunctionModule(N,h,d)}}drawFinderPattern(n,a){for(let s=-4;s<=4;s++)for(let d=-4;d<=4;d++){const h=Math.max(Math.abs(d),Math.abs(s)),N=n+d,g=a+s;0<=N&&N<this.size&&0<=g&&g<this.size&&this.setFunctionModule(N,g,h!=2&&h!=4)}}drawAlignmentPattern(n,a){for(let s=-2;s<=2;s++)for(let d=-2;d<=2;d++)this.setFunctionModule(n+d,a+s,Math.max(Math.abs(d),Math.abs(s))!=1)}setFunctionModule(n,a,s){this.modules[a][n]=s,this.isFunction[a][n]=!0}addEccAndInterleave(n){const a=this.version,s=this.errorCorrectionLevel;if(n.length!=R.getNumDataCodewords(a,s))throw new RangeError("Invalid argument");const d=R.NUM_ERROR_CORRECTION_BLOCKS[s.ordinal][a],h=R.ECC_CODEWORDS_PER_BLOCK[s.ordinal][a],N=Math.floor(R.getNumRawDataModules(a)/8),g=d-N%d,C=Math.floor(N/d);let j=[];const $=R.reedSolomonComputeDivisor(h);for(let S=0,F=0;S<d;S++){let O=n.slice(F,F+C-h+(S<g?0:1));F+=O.length;const T=R.reedSolomonComputeRemainder(O,$);S<g&&O.push(0),j.push(O.concat(T))}let L=[];for(let S=0;S<j[0].length;S++)j.forEach((F,O)=>{(S!=C-h||O>=g)&&L.push(F[S])});return t(L.length==N),L}drawCodewords(n){if(n.length!=Math.floor(R.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let a=0;for(let s=this.size-1;s>=1;s-=2){s==6&&(s=5);for(let d=0;d<this.size;d++)for(let h=0;h<2;h++){const N=s-h,C=(s+1&2)==0?this.size-1-d:d;!this.isFunction[C][N]&&a<n.length*8&&(this.modules[C][N]=x(n[a>>>3],7-(a&7)),a++)}}t(a==n.length*8)}applyMask(n){if(n<0||n>7)throw new RangeError("Mask value out of range");for(let a=0;a<this.size;a++)for(let s=0;s<this.size;s++){let d;switch(n){case 0:d=(s+a)%2==0;break;case 1:d=a%2==0;break;case 2:d=s%3==0;break;case 3:d=(s+a)%3==0;break;case 4:d=(Math.floor(s/3)+Math.floor(a/2))%2==0;break;case 5:d=s*a%2+s*a%3==0;break;case 6:d=(s*a%2+s*a%3)%2==0;break;case 7:d=((s+a)%2+s*a%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[a][s]&&d&&(this.modules[a][s]=!this.modules[a][s])}}getPenaltyScore(){let n=0;for(let h=0;h<this.size;h++){let N=!1,g=0,C=[0,0,0,0,0,0,0];for(let j=0;j<this.size;j++)this.modules[h][j]==N?(g++,g==5?n+=R.PENALTY_N1:g>5&&n++):(this.finderPenaltyAddHistory(g,C),N||(n+=this.finderPenaltyCountPatterns(C)*R.PENALTY_N3),N=this.modules[h][j],g=1);n+=this.finderPenaltyTerminateAndCount(N,g,C)*R.PENALTY_N3}for(let h=0;h<this.size;h++){let N=!1,g=0,C=[0,0,0,0,0,0,0];for(let j=0;j<this.size;j++)this.modules[j][h]==N?(g++,g==5?n+=R.PENALTY_N1:g>5&&n++):(this.finderPenaltyAddHistory(g,C),N||(n+=this.finderPenaltyCountPatterns(C)*R.PENALTY_N3),N=this.modules[j][h],g=1);n+=this.finderPenaltyTerminateAndCount(N,g,C)*R.PENALTY_N3}for(let h=0;h<this.size-1;h++)for(let N=0;N<this.size-1;N++){const g=this.modules[h][N];g==this.modules[h][N+1]&&g==this.modules[h+1][N]&&g==this.modules[h+1][N+1]&&(n+=R.PENALTY_N2)}let a=0;for(const h of this.modules)a=h.reduce((N,g)=>N+(g?1:0),a);const s=this.size*this.size,d=Math.ceil(Math.abs(a*20-s*10)/s)-1;return t(0<=d&&d<=9),n+=d*R.PENALTY_N4,t(0<=n&&n<=2568888),n}getAlignmentPatternPositions(){if(this.version==1)return[];{const n=Math.floor(this.version/7)+2,a=this.version==32?26:Math.ceil((this.version*4+4)/(n*2-2))*2;let s=[6];for(let d=this.size-7;s.length<n;d-=a)s.splice(1,0,d);return s}}static getNumRawDataModules(n){if(n<R.MIN_VERSION||n>R.MAX_VERSION)throw new RangeError("Version number out of range");let a=(16*n+128)*n+64;if(n>=2){const s=Math.floor(n/7)+2;a-=(25*s-10)*s-55,n>=7&&(a-=36)}return t(208<=a&&a<=29648),a}static getNumDataCodewords(n,a){return Math.floor(R.getNumRawDataModules(n)/8)-R.ECC_CODEWORDS_PER_BLOCK[a.ordinal][n]*R.NUM_ERROR_CORRECTION_BLOCKS[a.ordinal][n]}static reedSolomonComputeDivisor(n){if(n<1||n>255)throw new RangeError("Degree out of range");let a=[];for(let d=0;d<n-1;d++)a.push(0);a.push(1);let s=1;for(let d=0;d<n;d++){for(let h=0;h<a.length;h++)a[h]=R.reedSolomonMultiply(a[h],s),h+1<a.length&&(a[h]^=a[h+1]);s=R.reedSolomonMultiply(s,2)}return a}static reedSolomonComputeRemainder(n,a){let s=a.map(d=>0);for(const d of n){const h=d^s.shift();s.push(0),a.forEach((N,g)=>s[g]^=R.reedSolomonMultiply(N,h))}return s}static reedSolomonMultiply(n,a){if(n>>>8||a>>>8)throw new RangeError("Byte out of range");let s=0;for(let d=7;d>=0;d--)s=s<<1^(s>>>7)*285,s^=(a>>>d&1)*n;return t(s>>>8==0),s}finderPenaltyCountPatterns(n){const a=n[1];t(a<=this.size*3);const s=a>0&&n[2]==a&&n[3]==a*3&&n[4]==a&&n[5]==a;return(s&&n[0]>=a*4&&n[6]>=a?1:0)+(s&&n[6]>=a*4&&n[0]>=a?1:0)}finderPenaltyTerminateAndCount(n,a,s){return n&&(this.finderPenaltyAddHistory(a,s),a=0),a+=this.size,this.finderPenaltyAddHistory(a,s),this.finderPenaltyCountPatterns(s)}finderPenaltyAddHistory(n,a){a[0]==0&&(n+=this.size),a.pop(),a.unshift(n)}};i.MIN_VERSION=1,i.MAX_VERSION=40,i.PENALTY_N1=3,i.PENALTY_N2=3,i.PENALTY_N3=40,i.PENALTY_N4=10,i.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],i.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],r.QrCode=i;function o(y,n,a){if(n<0||n>31||y>>>n)throw new RangeError("Value out of range");for(let s=n-1;s>=0;s--)a.push(y>>>s&1)}function x(y,n){return(y>>>n&1)!=0}function t(y){if(!y)throw new Error("Assertion error")}const f=class W{constructor(n,a,s){if(this.mode=n,this.numChars=a,this.bitData=s,a<0)throw new RangeError("Invalid argument");this.bitData=s.slice()}static makeBytes(n){let a=[];for(const s of n)o(s,8,a);return new W(W.Mode.BYTE,n.length,a)}static makeNumeric(n){if(!W.isNumeric(n))throw new RangeError("String contains non-numeric characters");let a=[];for(let s=0;s<n.length;){const d=Math.min(n.length-s,3);o(parseInt(n.substring(s,s+d),10),d*3+1,a),s+=d}return new W(W.Mode.NUMERIC,n.length,a)}static makeAlphanumeric(n){if(!W.isAlphanumeric(n))throw new RangeError("String contains unencodable characters in alphanumeric mode");let a=[],s;for(s=0;s+2<=n.length;s+=2){let d=W.ALPHANUMERIC_CHARSET.indexOf(n.charAt(s))*45;d+=W.ALPHANUMERIC_CHARSET.indexOf(n.charAt(s+1)),o(d,11,a)}return s<n.length&&o(W.ALPHANUMERIC_CHARSET.indexOf(n.charAt(s)),6,a),new W(W.Mode.ALPHANUMERIC,n.length,a)}static makeSegments(n){return n==""?[]:W.isNumeric(n)?[W.makeNumeric(n)]:W.isAlphanumeric(n)?[W.makeAlphanumeric(n)]:[W.makeBytes(W.toUtf8ByteArray(n))]}static makeEci(n){let a=[];if(n<0)throw new RangeError("ECI assignment value out of range");if(n<128)o(n,8,a);else if(n<16384)o(2,2,a),o(n,14,a);else if(n<1e6)o(6,3,a),o(n,21,a);else throw new RangeError("ECI assignment value out of range");return new W(W.Mode.ECI,0,a)}static isNumeric(n){return W.NUMERIC_REGEX.test(n)}static isAlphanumeric(n){return W.ALPHANUMERIC_REGEX.test(n)}getData(){return this.bitData.slice()}static getTotalBits(n,a){let s=0;for(const d of n){const h=d.mode.numCharCountBits(a);if(d.numChars>=1<<h)return 1/0;s+=4+h+d.bitData.length}return s}static toUtf8ByteArray(n){n=encodeURI(n);let a=[];for(let s=0;s<n.length;s++)n.charAt(s)!="%"?a.push(n.charCodeAt(s)):(a.push(parseInt(n.substring(s+1,s+3),16)),s+=2);return a}};f.NUMERIC_REGEX=/^[0-9]*$/,f.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,f.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let m=f;r.QrSegment=f})(Ce||(Ce={}));(r=>{(i=>{const o=class{constructor(t,f){this.ordinal=t,this.formatBits=f}};o.LOW=new o(0,1),o.MEDIUM=new o(1,0),o.QUARTILE=new o(2,3),o.HIGH=new o(3,2),i.Ecc=o})(r.QrCode||(r.QrCode={}))})(Ce||(Ce={}));(r=>{(i=>{const o=class{constructor(t,f){this.modeBits=t,this.numBitsCharCount=f}numCharCountBits(t){return this.numBitsCharCount[Math.floor((t+7)/17)]}};o.NUMERIC=new o(1,[10,12,14]),o.ALPHANUMERIC=new o(2,[9,11,13]),o.BYTE=new o(4,[8,16,16]),o.KANJI=new o(8,[8,10,12]),o.ECI=new o(7,[0,0,0]),i.Mode=o})(r.QrSegment||(r.QrSegment={}))})(Ce||(Ce={}));var Ae=Ce;/**
7
+ * @license qrcode.react
8
+ * Copyright (c) Paul O'Shannessy
9
+ * SPDX-License-Identifier: ISC
10
+ */var rr={L:Ae.QrCode.Ecc.LOW,M:Ae.QrCode.Ecc.MEDIUM,Q:Ae.QrCode.Ecc.QUARTILE,H:Ae.QrCode.Ecc.HIGH},cs=128,ds="L",us="#FFFFFF",ms="#000000",hs=!1,xs=1,nr=4,ar=0,lr=.1;function fs(r,i=0){const o=[];return r.forEach(function(x,t){let f=null;x.forEach(function(m,y){if(!m&&f!==null){o.push(`M${f+i} ${t+i}h${y-f}v1H${f+i}z`),f=null;return}if(y===x.length-1){if(!m)return;f===null?o.push(`M${y+i},${t+i} h1v1H${y+i}z`):o.push(`M${f+i},${t+i} h${y+1-f}v1H${f+i}z`);return}m&&f===null&&(f=y)})}),o.join("")}function ps(r,i){return r.slice().map((o,x)=>x<i.y||x>=i.y+i.h?o:o.map((t,f)=>f<i.x||f>=i.x+i.w?t:!1))}function or(r,i,o,x){if(x==null)return null;const t=r.length+o*2,f=Math.floor(i*lr),m=t/i,y=(x.width||f)*m,n=(x.height||f)*m,a=x.x==null?r.length/2-y/2:x.x*m,s=x.y==null?r.length/2-n/2:x.y*m,d=x.opacity==null?1:x.opacity;let h=null;if(x.excavate){let g=Math.floor(a),C=Math.floor(s),j=Math.ceil(y+a-g),$=Math.ceil(n+s-C);h={x:g,y:C,w:j,h:$}}const N=x.crossOrigin;return{x:a,y:s,h:n,w:y,excavation:h,opacity:d,crossOrigin:N}}function ir(r,i){return i!=null?Math.max(Math.floor(i),0):r?nr:ar}function gs({value:r,level:i,minVersion:o,includeMargin:x,marginSize:t,imageSettings:f,size:m,boostLevel:y}){let n=K.useMemo(()=>{const g=(Array.isArray(r)?r:[r]).reduce((C,j)=>(C.push(...Ae.QrSegment.makeSegments(j)),C),[]);return Ae.QrCode.encodeSegments(g,rr[i],o,void 0,void 0,y)},[r,i,o,y]);const{cells:a,margin:s,numCells:d,calculatedImageSettings:h}=K.useMemo(()=>{let N=n.getModules();const g=ir(x,t),C=N.length+g*2,j=or(N,m,g,f);return{cells:N,margin:g,numCells:C,calculatedImageSettings:j}},[n,m,f,x,t]);return{qrcode:n,margin:s,cells:a,numCells:d,calculatedImageSettings:h}}var cr=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),dr=K.forwardRef(function(i,o){const x=i,{value:t,size:f=cs,level:m=ds,bgColor:y=us,fgColor:n=ms,includeMargin:a=hs,minVersion:s=xs,boostLevel:d,marginSize:h,imageSettings:N}=x,C=mt(x,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:j}=C,$=mt(C,["style"]),L=N==null?void 0:N.src,S=K.useRef(null),F=K.useRef(null),O=K.useCallback(Y=>{S.current=Y,typeof o=="function"?o(Y):o&&(o.current=Y)},[o]),[T,q]=K.useState(!1),{margin:J,cells:xe,numCells:fe,calculatedImageSettings:B}=gs({value:t,level:m,minVersion:s,boostLevel:d,includeMargin:a,marginSize:h,imageSettings:N,size:f});K.useEffect(()=>{if(S.current!=null){const Y=S.current,X=Y.getContext("2d");if(!X)return;let ne=xe;const G=F.current,pe=B!=null&&G!==null&&G.complete&&G.naturalHeight!==0&&G.naturalWidth!==0;pe&&B.excavation!=null&&(ne=ps(xe,B.excavation));const oe=window.devicePixelRatio||1;Y.height=Y.width=f*oe;const ge=f/fe*oe;X.scale(ge,ge),X.fillStyle=y,X.fillRect(0,0,fe,fe),X.fillStyle=n,cr?X.fill(new Path2D(fs(ne,J))):xe.forEach(function(c,b){c.forEach(function(E,U){E&&X.fillRect(U+J,b+J,1,1)})}),B&&(X.globalAlpha=B.opacity),pe&&X.drawImage(G,B.x+J,B.y+J,B.w,B.h)}}),K.useEffect(()=>{q(!1)},[L]);const Fe=ut({height:f,width:f},j);let ee=null;return L!=null&&(ee=K.createElement("img",{src:L,key:L,style:{display:"none"},onLoad:()=>{q(!0)},ref:F,crossOrigin:B==null?void 0:B.crossOrigin})),K.createElement(K.Fragment,null,K.createElement("canvas",ut({style:Fe,height:f,width:f,ref:O,role:"img"},$)),ee)});dr.displayName="QRCodeCanvas";var Je=K.forwardRef(function(i,o){const x=i,{value:t,size:f=cs,level:m=ds,bgColor:y=us,fgColor:n=ms,includeMargin:a=hs,minVersion:s=xs,boostLevel:d,title:h,marginSize:N,imageSettings:g}=x,C=mt(x,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:j,cells:$,numCells:L,calculatedImageSettings:S}=gs({value:t,level:m,minVersion:s,boostLevel:d,includeMargin:a,marginSize:N,imageSettings:g,size:f});let F=$,O=null;g!=null&&S!=null&&(S.excavation!=null&&(F=ps($,S.excavation)),O=K.createElement("image",{href:g.src,height:S.h,width:S.w,x:S.x+j,y:S.y+j,preserveAspectRatio:"none",opacity:S.opacity,crossOrigin:S.crossOrigin}));const T=fs(F,j);return K.createElement("svg",ut({height:f,width:f,viewBox:`0 0 ${L} ${L}`,ref:o,role:"img"},C),!!h&&K.createElement("title",null,h),K.createElement("path",{fill:y,d:`M0,0 h${L}v${L}H0z`,shapeRendering:"crispEdges"}),K.createElement("path",{fill:n,d:T,shapeRendering:"crispEdges"}),O)});Je.displayName="QRCodeSVG";const Oe=[{id:"feishu",labelKey:"configForm.channel.feishu",fields:[],defaults:{connectionMode:"websocket"}},{id:"openclaw-weixin",labelKey:"configForm.channel.openclaw-weixin",fields:[],defaults:{}},{id:"telegram",labelKey:"configForm.channel.telegram",fields:[{key:"botToken",label:"Bot Token",type:"password",placeholder:"From @BotFather"}]},{id:"discord",labelKey:"configForm.channel.discord",fields:[{key:"token",label:"Bot Token",type:"password",placeholder:"From Discord Developer Portal"}]},{id:"slack",labelKey:"configForm.channel.slack",fields:[{key:"botToken",label:"Bot Token (xoxb-...)",type:"password",placeholder:"xoxb-..."},{key:"appToken",label:"App Token (xapp-...)",type:"password",placeholder:"xapp-..."}]},{id:"whatsapp",labelKey:"configForm.channel.whatsapp",fields:[],defaults:{}},{id:"msteams",labelKey:"configForm.channel.msteams",fields:[{key:"appId",label:"App ID",placeholder:"Azure App Registration ID"},{key:"appPassword",label:"App Password",type:"password",placeholder:"Azure App Secret"},{key:"tenantId",label:"Tenant ID",placeholder:"Azure AD Tenant ID"}]},{id:"signal",labelKey:"configForm.channel.signal",fields:[{key:"account",label:"Phone (E.164)",placeholder:"+8613800138000"}]},{id:"line",labelKey:"configForm.channel.line",fields:[{key:"channelAccessToken",label:"Channel Access Token",type:"password",placeholder:"From LINE Developers"},{key:"channelSecret",label:"Channel Secret",type:"password",placeholder:"LINE Channel Secret"}]},{id:"googlechat",labelKey:"configForm.channel.googlechat",fields:[{key:"serviceAccountFile",label:"Service Account JSON Path",placeholder:"/path/to/service-account.json"}]}];function he(r,i,o){const x=structuredClone(r),t=i.split(".");let f=x;for(let m=0;m<t.length-1;m++)f[t[m]]===void 0&&(f[t[m]]={}),f=f[t[m]];return f[t[t.length-1]]=o,x}const bs="w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200",ur="w-full bg-background border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors duration-200";function Q({label:r,hint:i,children:o}){return e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-muted mb-1.5",children:r}),o,i&&e.jsx("p",{className:"text-xs text-muted mt-1 opacity-60",children:i})]})}function mr({value:r,saved:i,onChange:o,placeholder:x}){const{t}=we("instance"),[f,m]=w.useState(!1),y="โ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ขโ€ข";return i&&!f&&!r?e.jsx("div",{className:"relative",children:e.jsx("input",{type:"password",value:y,readOnly:!0,onFocus:()=>m(!0),className:`${bs} cursor-text`,title:t("config.clickToEdit")})}):e.jsx(le,{value:r,onChange:o,placeholder:x,type:"password",mono:!0})}function le({value:r,onChange:i,placeholder:o,type:x="text",mono:t}){const[f,m]=w.useState(!1),y=x==="password";return e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:y&&!f?"password":"text",value:r||"",onChange:n=>i(n.target.value),placeholder:o,className:`${bs} ${t?"font-mono text-[13px]":""} ${y?"pr-9":""}`}),y&&e.jsx("button",{type:"button",onClick:()=>m(!f),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-foreground",children:f?e.jsx(Is,{className:"w-3.5 h-3.5"}):e.jsx(Ps,{className:"w-3.5 h-3.5"})})]})}function De({value:r,onChange:i,children:o}){return e.jsx("select",{value:r||"",onChange:x=>i(x.target.value),className:ur,children:o})}function Xt({checked:r,onChange:i,label:o}){return e.jsxs("label",{className:"flex items-center gap-2.5 cursor-pointer",children:[e.jsx("button",{type:"button",role:"switch","aria-checked":r,onClick:()=>i(!r),className:`w-9 h-5 rounded-full relative transition-colors duration-200 ${r?"bg-[#0066FF]":"bg-[var(--input-bg)]"}`,children:e.jsx("div",{className:`w-3.5 h-3.5 bg-white rounded-full absolute top-[3px] transition-transform duration-200 ${r?"left-[18px]":"left-[3px]"}`})}),e.jsx("span",{className:"text-sm text-muted",children:o})]})}function Zt({title:r,defaultOpen:i=!0,id:o,children:x}){const[t,f]=w.useState(i);return e.jsxs("div",{id:o,className:"bg-[var(--card)] border border-[var(--border)] rounded-xl overflow-hidden hover:border-[var(--border-hover)] transition-colors duration-200",children:[e.jsxs("button",{type:"button",onClick:()=>f(!t),className:"w-full px-4 py-3 flex items-center justify-between text-left hover:bg-[var(--card-hover)] transition-colors duration-150",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:r}),t?e.jsx(ts,{className:"w-4 h-4 text-muted"}):e.jsx(As,{className:"w-4 h-4 text-muted"})]}),t&&e.jsx("div",{className:"px-4 pb-4 space-y-4 border-t border-[var(--border)] pt-4",children:x})]})}const dt=["feishu","openclaw-weixin"],hr={feishu:"feishu",lark:"feishu","openclaw-weixin":"openclaw-weixin"};function xr({config:r,onChange:i,instanceId:o,isRunning:x=!1,pluginStatuses:t={},onInstallPlugin:f}){var pe,oe,ge;const{t:m}=we(["instance","common"]),y=(c,b)=>i(he(r,c,b)),n=((pe=r==null?void 0:r["x-jishushell"])==null?void 0:pe.proxy)||{},a=n.upstream||{},s=a.providerId||"",d=He.find(c=>c.id===s),h=a.models||[],N=d?d.models.map(c=>({id:c.id,name:c.name,contextWindow:c.contextWindow})):h.map(c=>({id:c.id,name:c.name||c.id,contextWindow:c.contextWindow})),g=a.selectedModelId||((oe=N[0])==null?void 0:oe.id)||"",C=N.find(c=>c.id===g)||N[0]||{},j=h.find(c=>c.id===g)||(C.id?C:{id:"",name:"",contextWindow:0}),$=n.proxy||{},L=c=>{var U;const b=He.find(H=>H.id===c);if(!b||a.apiKey&&!window.confirm(m("configForm.switchProviderConfirm")))return;const E=JSON.parse(JSON.stringify(r));E["x-jishushell"]||(E["x-jishushell"]={}),E["x-jishushell"].proxy||(E["x-jishushell"].proxy={}),E["x-jishushell"].proxy.upstream={providerId:b.id,baseUrl:b.baseUrl,api:b.api,authHeader:b.authHeader===!0,headers:b.headers||{},models:b.models.map(H=>({id:H.id,name:H.name,contextWindow:H.contextWindow})),selectedModelId:((U=b.models[0])==null?void 0:U.id)||"",apiKey:"",hasApiKey:!1,clearApiKey:!1},i(E)},S=c=>{y("x-jishushell.proxy.upstream.selectedModelId",c)},F=(c,b)=>{y(`x-jishushell.proxy.upstream.${c}`,b)},O=(r==null?void 0:r.channels)||{},T=Object.keys(O),q=(c,b,E)=>y(`channels.${c}.${b}`,E),J={},xe=c=>{const b=Oe.find(H=>H.id===c),E=JSON.parse(JSON.stringify(r));E.channels||(E.channels={});const U=J[c]||c;if(b){const H={enabled:!0,...b.defaults};b.fields.forEach(te=>{H[te.key]=""}),E.channels[U]=H}else E.channels[U]={enabled:!0};i(E)},fe=c=>{const b=JSON.parse(JSON.stringify(r));delete b.channels[c],i(b)},[B,Fe]=w.useState(!1),[ee,Y]=w.useState(!(a.hasApiKey&&s)),X={"moonshot-coding":"configForm.hint.moonshot-coding",volcengine:"configForm.hint.volcengine",byteplus:"configForm.hint.byteplus",openrouter:"configForm.hint.openrouter",ollama:"configForm.hint.ollama",vllm:"configForm.hint.vllm",sglang:"configForm.hint.sglang"},ne=X[s]?m(X[s]):void 0,G=[...new Set(He.map(c=>c.group))];return e.jsxs("div",{className:"space-y-4",children:[e.jsxs(Zt,{title:m("configForm.modelConfig"),children:[e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-lg p-3 text-sm text-muted",children:[e.jsx("div",{className:"font-medium text-foreground mb-1",children:m("configForm.proxyChain")}),e.jsx("p",{children:m("configForm.proxyChainDesc")}),e.jsxs("div",{className:"mt-2 text-xs text-muted opacity-60 space-y-1",children:[e.jsxs("div",{children:[m("configForm.proxyAddress")," ",e.jsx("span",{className:"font-mono",children:$.proxyBaseUrl||m("configForm.notConfigured")})]}),e.jsxs("div",{children:[m("configForm.proxyStatus")," ",$.running?m("configForm.running"):m("configForm.notRunning"),m("configForm.virtualKeyLabel")," ",$.hasVirtualKey?m("configForm.generated"):m("configForm.notGenerated")]})]})]}),!ee&&e.jsx("button",{type:"button",onClick:()=>Y(!0),className:"text-xs text-[#0066FF] hover:text-[#0066FF]/80 transition-colors",children:m("configForm.editModelConfig")}),ee&&e.jsx(Q,{label:m("configForm.upstreamProvider"),hint:m("configForm.upstreamProviderHint"),children:e.jsxs(De,{value:s,onChange:L,children:[e.jsx("option",{value:"",children:m("configForm.selectProvider")}),!d&&s&&e.jsxs("option",{value:s,children:[s," ",m("configForm.custom")]}),G.map(c=>e.jsx("optgroup",{label:m(`configForm.providerGroup.${c}`,{defaultValue:c}),children:He.filter(b=>b.group===c).map(b=>e.jsx("option",{value:b.id,children:m(`configForm.providerLabel.${b.id}`,{defaultValue:b.label})},b.id))},c))]})}),ee&&ne&&e.jsxs("div",{className:"flex items-start gap-2 bg-amber-500/10 border border-amber-500/20 rounded-lg px-3 py-2.5 text-xs text-amber-400",children:[e.jsx("span",{className:"shrink-0 mt-0.5",children:"โš "}),e.jsx("span",{children:ne})]}),ee&&!["ollama","vllm","sglang"].includes(s)&&s&&e.jsxs(e.Fragment,{children:[e.jsxs(Q,{label:m("configForm.upstreamApiKey"),hint:a.hasApiKey&&!a.clearApiKey?m("configForm.apiKeyHintSaved"):m("configForm.apiKeyHintNew"),children:[e.jsx(mr,{value:a.apiKey||"",saved:a.hasApiKey&&!a.clearApiKey,onChange:c=>{let b=he(r,"x-jishushell.proxy.upstream.apiKey",c);c&&(b=he(b,"x-jishushell.proxy.upstream.clearApiKey",!1)),i(b)},placeholder:m("configForm.enterApiKey")}),a.hasApiKey&&e.jsx("button",{type:"button",onClick:()=>{let c=he(r,"x-jishushell.proxy.upstream.apiKey","");c=he(c,"x-jishushell.proxy.upstream.clearApiKey",!a.clearApiKey),i(c)},className:`mt-2 text-xs ${a.clearApiKey?"text-red-400":"text-muted hover:text-foreground"} transition-colors`,children:a.clearApiKey?m("configForm.markedForClear"):m("configForm.clearSavedApiKey")})]}),N.length>0&&e.jsx(Q,{label:m("configForm.upstreamModel"),hint:m("configForm.upstreamModelHint"),children:e.jsx(De,{value:g,onChange:S,children:N.map(c=>e.jsxs("option",{value:c.id,children:[c.name," (",Math.round(c.contextWindow/1e3),"K)"]},c.id))})})]}),ee&&["ollama","vllm","sglang"].includes(s)&&e.jsxs("div",{className:"space-y-4 border-t border-[var(--border)] pt-4",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsx(Q,{label:"Base URL",hint:m("configForm.localServiceAddress"),children:e.jsx(le,{value:a.baseUrl||"",onChange:c=>F("baseUrl",c),placeholder:"http://127.0.0.1:11434",mono:!0})}),e.jsx(Q,{label:m("configForm.apiProtocol"),children:e.jsxs(De,{value:a.api||"openai-completions",onChange:c=>F("api",c),children:[e.jsx("option",{value:"openai-completions",children:"OpenAI Compatible"}),e.jsx("option",{value:"ollama",children:"Ollama"})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsx(Q,{label:m("configForm.modelId"),hint:m("configForm.modelIdHint"),children:e.jsx(le,{value:j.id==="default"?"":j.id,onChange:c=>{const b=[...h],E=b.findIndex(H=>H.id===g);E>=0?b[E]={...j,id:c||"default"}:b.push({id:c||"default",name:c||"default",contextWindow:j.contextWindow||0});let U=he(r,"x-jishushell.proxy.upstream.models",b);U=he(U,"x-jishushell.proxy.upstream.selectedModelId",c||"default"),i(U)},placeholder:"llama3",mono:!0})}),e.jsx(Q,{label:m("configForm.modelName"),children:e.jsx(le,{value:j.name==="default"?"":j.name||"",onChange:c=>{const b=[...h],E=b.findIndex(U=>U.id===g);E>=0?b[E]={...j,name:c||j.id}:b.push({id:j.id||"default",name:c||"default",contextWindow:j.contextWindow||0}),F("models",b)},placeholder:m("configForm.modelNamePlaceholder")})}),e.jsx(Q,{label:m("configForm.contextWindow"),children:e.jsx(le,{value:String(j.contextWindow||""),onChange:c=>{const b=[...h],E=b.findIndex(U=>U.id===g);E>=0?b[E]={...j,contextWindow:parseInt(c)||0}:b.push({id:j.id||"default",name:j.name||"default",contextWindow:parseInt(c)||0}),F("models",b)},placeholder:"128000",mono:!0})})]})]}),ee&&!["ollama","vllm","sglang"].includes(s)&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",onClick:()=>Fe(!B),className:"text-xs text-muted hover:text-foreground transition-colors",children:m(B?"configForm.collapseAdvanced":"configForm.advancedOptions")}),B&&e.jsxs("div",{className:"space-y-4 border-t border-[var(--border)] pt-4",children:[e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsx(Q,{label:m("configForm.upstreamBaseUrl"),children:e.jsx(le,{value:a.baseUrl||"",onChange:c=>F("baseUrl",c),placeholder:m("configForm.baseUrlPlaceholder"),mono:!0})}),e.jsx(Q,{label:m("configForm.upstreamApiProtocol"),children:e.jsxs(De,{value:a.api||"openai-completions",onChange:c=>F("api",c),children:[e.jsx("option",{value:"openai-completions",children:"OpenAI Compatible"}),e.jsx("option",{value:"openai-responses",children:"OpenAI Responses"}),e.jsx("option",{value:"anthropic-messages",children:"Anthropic Messages"}),e.jsx("option",{value:"google-generative-ai",children:"Google Generative AI"}),e.jsx("option",{value:"ollama",children:"Ollama"})]})})]}),s&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-4",children:[e.jsx(Q,{label:m("configForm.modelId"),children:e.jsx(le,{value:j.id,onChange:c=>{const b=[...h],E=b.findIndex(H=>H.id===g);E>=0?b[E]={...j,id:c}:b.push({...j,id:c});let U=he(r,"x-jishushell.proxy.upstream.models",b);U=he(U,"x-jishushell.proxy.upstream.selectedModelId",c),i(U)},placeholder:"model-id",mono:!0})}),e.jsx(Q,{label:m("configForm.modelName"),children:e.jsx(le,{value:j.name||"",onChange:c=>{const b=[...h],E=b.findIndex(U=>U.id===g);E>=0?b[E]={...j,name:c}:b.push({...j,name:c}),F("models",b)},placeholder:"Model Name"})}),e.jsx(Q,{label:m("configForm.contextWindow"),children:e.jsx(le,{value:String(j.contextWindow||""),onChange:c=>{const b=[...h],E=b.findIndex(U=>U.id===g);E>=0?b[E]={...j,contextWindow:parseInt(c)||0}:b.push({...j,contextWindow:parseInt(c)||0}),F("models",b)},placeholder:"200000",mono:!0})})]}),e.jsx("div",{className:"text-xs text-muted bg-[var(--card)] border border-[var(--border)] rounded-md p-3",children:m("configForm.proxyNote")})]})]})]}),e.jsxs(Zt,{title:m("configForm.imChannelConfig"),id:"im-channel-section",children:[e.jsx(Q,{label:m("configForm.sessionIsolation"),hint:m("configForm.sessionIsolationHint"),children:e.jsxs(De,{value:((ge=r==null?void 0:r.session)==null?void 0:ge.dmScope)||"main",onChange:c=>y("session.dmScope",c),children:[e.jsx("option",{value:"main",children:m("configForm.sessionMain")}),e.jsx("option",{value:"per-peer",children:m("configForm.sessionPerPeer")}),e.jsx("option",{value:"per-channel-peer",children:m("configForm.sessionPerChannelPeer")}),e.jsx("option",{value:"per-account-channel-peer",children:m("configForm.sessionPerAccountChannelPeer")})]})}),dt.map(c=>{Oe.find(z=>z.id===c);const b=m(`configForm.channel.${c}`,{defaultValue:c}),E=O[c]||{enabled:!0},U=E.enabled!==!1,H=hr[c]||c,te=t[H],P=c==="openclaw-weixin"?"#07C160":"#3370FF";return e.jsxs("div",{className:"border border-[var(--border)] rounded-lg p-4 space-y-3 bg-[var(--card)]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:b}),e.jsx("span",{className:"text-[11px] text-muted font-mono",children:c})]}),e.jsx(Xt,{checked:U,onChange:z=>{O[c]||xe(c),q(c,"enabled",z)},label:m(U?"common:label.enabled":"common:label.disabled")})]}),U&&(te==="installing"?e.jsx("div",{className:"rounded-md px-4 py-3",style:{background:`${P}10`,borderColor:`${P}30`,borderWidth:1,borderStyle:"solid"},children:e.jsxs("div",{className:"flex items-center gap-2 text-sm",style:{color:P},children:[e.jsx("div",{className:"w-4 h-4 border-2 rounded-full animate-spin",style:{borderColor:`${P}30`,borderTopColor:P}}),e.jsx("span",{children:m("configForm.pluginInstalling",{label:b})})]})}):te!=="installed"?e.jsxs("div",{className:"rounded-md px-4 py-3",style:{background:`${P}08`,borderColor:`${P}30`,borderWidth:1,borderStyle:"dashed"},children:[e.jsx("button",{onClick:()=>f==null?void 0:f(H),className:"px-4 py-2 text-white rounded-md text-xs font-medium hover:opacity-90 transition-opacity",style:{background:P},children:m("configForm.installPlugin",{label:b})}),e.jsx("p",{className:"text-xs text-muted mt-2",children:m("configForm.installPluginHint",{label:b})})]}):e.jsxs(e.Fragment,{children:[(c==="feishu"||c==="lark")&&e.jsx(fr,{instanceId:o,channelKey:c,existingAppId:E.appId,existingDomain:E.domain||c,onConfigured:()=>{o&&Rs(async()=>{const{getConfig:z}=await import("./index-DfRnVUQR.js").then(se=>se.a6);return{getConfig:z}},__vite__mapDeps([0,1,2,3])).then(({getConfig:z})=>{z(o).then(se=>{se&&i(se)})})}}),c==="openclaw-weixin"&&e.jsx(pr,{instanceId:o})]}))]},c)}),T.filter(c=>!dt.includes(c)).map(c=>{const b=O[c],E=Oe.find(P=>P.id===c),U=m(`configForm.channel.${c}`,{defaultValue:c}),H=(E==null?void 0:E.fields)||[],te=E?[]:Object.keys(b).filter(P=>P!=="enabled"&&typeof b[P]=="string");return e.jsxs("div",{className:"border border-[var(--border)] rounded-lg p-4 space-y-3 bg-[var(--card)]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:U}),E&&e.jsx("span",{className:"text-[11px] text-muted font-mono",children:c})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(Xt,{checked:b.enabled!==!1,onChange:P=>q(c,"enabled",P),label:b.enabled!==!1?m("common:label.enabled"):m("common:label.disabled")}),e.jsx("button",{onClick:()=>fe(c),className:"text-xs text-red-400 hover:text-red-300 transition-colors",children:m("configForm.remove")})]})]}),b.enabled!==!1&&H.length>0&&e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:H.map(P=>e.jsx(Q,{label:P.label,children:e.jsx(le,{value:b[P.key]||"",onChange:z=>q(c,P.key,z),placeholder:P.placeholder,type:P.type||"text",mono:!0})},P.key))}),b.enabled!==!1&&te.length>0&&e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:te.map(P=>e.jsx(Q,{label:P,children:e.jsx(le,{value:b[P]||"",onChange:z=>q(c,P,z),placeholder:P,type:P.toLowerCase().includes("secret")||P.toLowerCase().includes("token")||P.toLowerCase().includes("password")?"password":"text",mono:!0})},P))}),b.enabled!==!1&&c==="whatsapp"&&H.length===0&&e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-md px-3 py-2 text-xs text-amber-400",children:[e.jsx("p",{className:"font-medium mb-1",children:m("configForm.whatsappTitle")}),e.jsx("p",{children:m("configForm.whatsappHint")})]})]},c)}),e.jsxs("div",{className:"pt-2",children:[e.jsx("p",{className:"text-xs text-muted mb-2",children:m("configForm.addImChannel")}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Oe.filter(c=>{if(dt.includes(c.id))return!1;const b=J[c.id]||c.id;return!T.includes(b)&&!T.includes(c.id)}).map(c=>e.jsxs("button",{onClick:()=>xe(c.id),className:"px-3 py-1.5 text-xs border border-dashed rounded-md transition-colors duration-150 border-[var(--border)] text-muted hover:border-[var(--border-hover)] hover:text-foreground",children:["+ ",m(c.labelKey,{defaultValue:c.id})]},c.id))})]})]})]})}function fr({instanceId:r,channelKey:i,existingAppId:o,existingDomain:x,onConfigured:t}){const{t:f}=we(["instance","common"]);(i||x)==="lark"||f("configForm.feishu.platformFeishu");const[y,n]=w.useState(""),[a,s]=w.useState(""),[d,h]=w.useState("idle"),[N,g]=w.useState(""),[C,j]=w.useState(""),$=w.useRef(!1),L=w.useRef(!1),S=async()=>{if(r){L.current=!1,h("loading"),g(""),n("");try{let T=null;for(let q=0;q<3;q++){if(L.current)return;try{if(T=await ss(r,i),T!=null&&T.qrcodeUrl)break}catch{q<2&&await new Promise(J=>setTimeout(J,1500))}}if(L.current)return;T!=null&&T.qrcodeUrl?(n(T.qrcodeUrl),s(T.sessionKey),h("waiting"),g(f("configForm.feishu.scanHint")),F(T.sessionKey)):(h("error"),g(f("qr.getFailed")))}catch{L.current||(h("error"),g(f("qr.getFailed")))}}},F=T=>{if(!r||$.current)return;$.current=!0;const q=async()=>{if($.current)try{const J=await ns(r,T);if(J.connected){$.current=!1,h("confirmed"),g(J.message||f("qr.loginSuccess")),j(J.domain||"feishu"),n(""),t==null||t();return}if(J.status==="expired"){$.current=!1,h("error"),g(J.message||f("qr.expired"));return}setTimeout(q,3e3)}catch{$.current&&setTimeout(q,3e3)}};q()};if(w.useEffect(()=>()=>{$.current=!1},[]),d==="confirmed")return e.jsxs("div",{className:"bg-emerald-500/10 border border-emerald-500/20 rounded-md px-4 py-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-emerald-400",children:[e.jsx("span",{className:"text-lg",children:"โœ“"}),e.jsx("span",{className:"font-medium",children:N})]}),e.jsx("p",{className:"text-xs text-muted mt-1",children:f("configForm.feishu.platform",{platform:f(C==="lark"?"configForm.feishu.platformLark":"configForm.feishu.platformFeishu")})})]});if(d==="idle"||d==="error")return e.jsxs("div",{className:"bg-[var(--card-hover)] rounded-md px-4 py-3 space-y-3",children:[o&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted mb-1",children:f("configForm.feishu.added")}),e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsx("span",{className:"text-emerald-400",children:"โœ“"}),e.jsx("code",{className:"font-mono text-foreground/70",children:o}),e.jsx("span",{className:"text-muted opacity-60",children:x==="lark"?"Lark":f("configForm.feishu.platformFeishu")})]})]}),e.jsxs("div",{children:[e.jsx("button",{onClick:S,className:"px-4 py-2 bg-[#3370FF] text-white rounded-md text-xs font-medium hover:bg-[#3370FF]/90 transition-colors",children:f("configForm.feishu.addBot")}),e.jsx("p",{className:"text-xs text-muted mt-2",children:f("configForm.feishu.addBotHint")})]})]});const O=()=>{L.current=!0,$.current=!1,h("idle"),g(""),n(""),s("")};return e.jsx("div",{className:"bg-[var(--card-hover)] rounded-md px-4 py-4",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[y?e.jsx(Je,{value:y,size:192,className:"rounded-lg"}):e.jsx("div",{className:"w-48 h-48 flex items-center justify-center",children:e.jsx("div",{className:"w-6 h-6 border-2 border-[#3370FF]/30 border-t-[#3370FF] rounded-full animate-spin"})}),e.jsx("div",{className:"text-sm text-muted",children:d==="loading"?f("configForm.feishu.gettingQr"):N}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:O,className:"px-3 py-1.5 text-xs text-white bg-red-500 rounded-md hover:bg-red-500/90 transition-colors",children:f("configForm.feishu.cancel")}),e.jsx("button",{onClick:()=>{O(),setTimeout(S,100)},className:"px-3 py-1.5 text-xs text-white bg-[#0066FF] rounded-md hover:bg-[#0066FF]/90 transition-colors",children:f("configForm.feishu.refresh")})]})]})})}function pr({instanceId:r}){const{t:i,i18n:o}=we(["instance","common"]),[x,t]=w.useState(""),[f,m]=w.useState(""),[y,n]=w.useState("idle"),[a,s]=w.useState(""),[d,h]=w.useState(""),[N,g]=w.useState([]),C=w.useRef(!1),j=w.useRef(!1);w.useEffect(()=>{r&&Ht(r).then(F=>{var O;(O=F==null?void 0:F.accounts)!=null&&O.length&&g(F.accounts)}).catch(()=>{})},[r]);const $=async()=>{if(r){j.current=!1,n("loading"),s(""),t("");try{let F=null;for(let O=0;O<3;O++){if(j.current)return;try{if(F=await rs(r),F!=null&&F.qrcodeUrl)break}catch{O<2&&await new Promise(T=>setTimeout(T,1500))}}if(j.current)return;F!=null&&F.qrcodeUrl?(t(F.qrcodeUrl),m(F.sessionKey),n("waiting"),s(i("configForm.weixin.scanHint")),L(F.sessionKey)):(n("error"),s(i("qr.getFailed")))}catch{j.current||(n("error"),s(i("qr.getFailed")))}}},L=F=>{if(!r||C.current)return;C.current=!0;const O=async()=>{if(C.current)try{const T=await as(r,F);if(T.connected){C.current=!1,n("confirmed"),s(T.message||i("qr.loginSuccess")),h(T.accountId||""),t(""),r&&Ht(r).then(q=>{q!=null&&q.accounts&&g(q.accounts)}).catch(()=>{});return}if(T.status==="scaned")n("scaned"),s(T.message||i("qr.scaned"));else if(T.status==="refreshed"&&T.qrcodeUrl)t(T.qrcodeUrl),n("waiting"),s(i("qr.refreshed"));else if(T.status==="expired"){C.current=!1,n("error"),s(T.message||i("qr.expired"));return}setTimeout(O,2e3)}catch{C.current&&setTimeout(O,3e3)}};O()};if(w.useEffect(()=>()=>{C.current=!1},[]),y==="confirmed")return e.jsxs("div",{className:"bg-emerald-500/10 border border-emerald-500/20 rounded-md px-4 py-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-emerald-400",children:[e.jsx("span",{className:"text-lg",children:"โœ“"}),e.jsx("span",{className:"font-medium",children:a})]}),d&&e.jsxs("p",{className:"text-xs text-muted mt-1",children:[i("configForm.weixin.accountId")," ",e.jsx("code",{className:"font-mono",children:d})]}),e.jsx("p",{className:"text-xs text-muted mt-1",children:i("configForm.weixin.restartHint")}),e.jsx("button",{onClick:$,className:"mt-2 px-3 py-1 text-xs border border-emerald-500/30 rounded text-emerald-400 hover:bg-emerald-500/10 transition-colors",children:i("configForm.weixin.addAnother")})]});if(y==="idle"||y==="error")return e.jsxs("div",{className:"bg-[var(--card-hover)] rounded-md px-4 py-3 space-y-3",children:[N.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted mb-1.5",children:i("configForm.weixin.added")}),N.map(F=>e.jsxs("div",{className:"flex items-center gap-2 text-xs py-1",children:[e.jsx("span",{className:"text-emerald-400",children:"โœ“"}),e.jsx("code",{className:"font-mono text-foreground/70",children:F.accountId}),F.savedAt&&e.jsx("span",{className:"text-muted opacity-60",children:new Date(F.savedAt).toLocaleDateString(o.language==="zh"?"zh-CN":"en-US")})]},F.accountId))]}),e.jsxs("div",{children:[e.jsx("button",{onClick:$,className:"px-4 py-2 bg-[#07C160] text-white rounded-md text-xs font-medium hover:bg-[#07C160]/90 transition-colors",children:i("configForm.weixin.addClawBot")}),e.jsx("p",{className:"text-xs text-muted mt-2",children:i("configForm.weixin.addClawBotHint",{extra:N.length>0?i("configForm.weixin.addClawBotHintRestart"):i("configForm.weixin.addClawBotHintMulti")})})]})]});const S=()=>{j.current=!0,C.current=!1,n("idle"),s(""),t(""),m("")};return e.jsx("div",{className:"bg-[var(--card-hover)] rounded-md px-4 py-4",children:e.jsxs("div",{className:"flex flex-col items-center gap-3",children:[x?e.jsx(Je,{value:x,size:192,className:"rounded-lg"}):e.jsx("div",{className:"w-48 h-48 flex items-center justify-center",children:e.jsx("div",{className:"w-6 h-6 border-2 border-[#07C160]/30 border-t-[#07C160] rounded-full animate-spin"})}),e.jsx("div",{className:"flex items-center gap-2 text-sm",children:y==="scaned"?e.jsxs("span",{className:"text-[#07C160] font-medium",children:["๐Ÿ‘€ ",a]}):y==="loading"?e.jsx("span",{className:"text-muted",children:i("configForm.weixin.gettingQr")}):e.jsx("span",{className:"text-muted",children:a})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:S,className:"px-3 py-1.5 text-xs text-white bg-red-500 rounded-md hover:bg-red-500/90 transition-colors",children:i("configForm.weixin.cancel")}),e.jsx("button",{onClick:()=>{S(),setTimeout($,100)},className:"px-3 py-1.5 text-xs text-white bg-[#0066FF] rounded-md hover:bg-[#0066FF]/90 transition-colors",children:i("configForm.weixin.refresh")})]})]})})}const gr="im",br="ๅณๆ—ถ้€š่ฎฏ",vr="๐Ÿ’ฌ",wr=[{id:"feishu",label:"้ฃžไนฆ / Lark",desc:"้ฃžไนฆๆœบๅ™จไบบ๏ผˆWebSocket ๆจกๅผ๏ผ‰"},{id:"openclaw-weixin",label:"ๅพฎไฟก",desc:"ๅพฎไฟกๆ‰ซ็ ๆŽฅๅ…ฅ"}],jr={id:gr,label:br,emoji:vr,items:wr},yr="skills",Nr="ๅธธ็”จ Skill",kr="โšก",Cr=[{id:"hubs",label:"็ƒญ้—จHub",emoji:"๐ŸŒ",skills:[{id:"clawhub",type:"hub",label:"ClawHub",desc:"OpenClaw ๅฎ˜ๆ–น Skill ๅธ‚ๅœบ",url:"https://clawhub.ai/",installMsg:""},{id:"skillhub-tencent",type:"hub",label:"่…พ่ฎฏ SkillHub",desc:"่…พ่ฎฏๆŠ€่ƒฝไธญๅฟƒ๏ผŒๅฎ˜ๆ–นๅ‡บๅ“",url:"https://skillhub.tencent.com/",installMsg:""},{id:"skills-sh",type:"hub",label:"Skills.sh",desc:"็ฌฌไธ‰ๆ–น Skill ่šๅˆ็คพๅŒบ",url:"https://skills.sh/",installMsg:""},{id:"lobehub-skills",type:"hub",label:"LobeHub Skills",desc:"LobeHub ็คพๅŒบ Skill ๅธ‚ๅœบ",url:"https://lobehub.com/skills",installMsg:""},{id:"findskills",type:"hub",label:"FindSkills.org",desc:"ๅผ€ๆบ Skill ๆœ็ดขไธŽ่šๅˆๅนณๅฐ",url:"https://www.findskills.org/",installMsg:""},{id:"playbooks-skills",type:"hub",label:"Playbooks Skills",desc:"Playbooks ็คพๅŒบ Skill ็›ฎๅฝ•",url:"https://playbooks.com/skills",installMsg:""}]},{id:"general",label:"้€š็”จๅŸบ็ก€",emoji:"๐Ÿง ",skills:[{id:"skill-vetter",label:"Skill Vetter",desc:"ๅฎ‰ๅ…จๅฎก่ฎก Skill๏ผŒๅฎ‰่ฃ…ๅ‰ๅปบ่ฎฎๅ…ˆๅฎกๆŸฅ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/spclaudehome/skill-vetter",autoInstall:!0,slashCmd:"/skill-vetter",checkDirs:["skill-vetter","Skill Vetter","SkillVetter","vetter"]},{id:"self-improving-agent-cn",label:"Self-Improving CN Agent",desc:"่‡ชๆˆ‘ไผ˜ๅŒ–็š„ Agent๏ผŒๆŒ็ปญๆ”น่ฟ›ไปปๅŠกๆ‰ง่กŒ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/zhengxinjipai/self-improving-agent-cn",autoInstall:!0,slashCmd:"/self-improving-agent-cn",checkDirs:["self-improving-agent-cn","SelfImprovingAgentCn","self_improving_agent_cn"]},{id:"proactive-agent",label:"Proactive Agent",desc:"ไธปๅŠจๅผ Agent๏ผŒ่‡ชๅŠจๆ„Ÿ็Ÿฅๅนถๆๅ‰ๅฎŒๆˆไปปๅŠก",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/bestrocky/proactive-agent-lite",autoInstall:!0,slashCmd:"/proactive-agent",checkDirs:["proactive-agent-lite","proactive-agent","ProactiveAgent","proactive_agent"]},{id:"multi-search-engine",label:"Multi Search Engine",desc:"ๅคšๆœ็ดขๅผ•ๆ“Ž่šๅˆๆœ็ดข",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/gpyangyoujun/multi-search-engine",autoInstall:!0,slashCmd:"/multi-search-engine",checkDirs:["multi-search-engine","MultiSearchEngine","multi_search_engine"]},{id:"exa-web-search-free",label:"Exa Web Search Free",desc:"ๅ…่ดน Exa ็ฝ‘้กต่ฏญไน‰ๆœ็ดข",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/whiteknight07/exa-web-search-free",autoInstall:!0,slashCmd:"/exa-web-search-free",checkDirs:["exa-web-search-free","ExaWebSearchFree","exa_web_search_free"]},{id:"filesystem",label:"Filesystem",desc:"ๆœฌๅœฐๆ–‡ไปถ็ณป็ปŸ่ฏปๅ†™ไธŽ็ฎก็†",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/steipete/filesystem",autoInstall:!0,slashCmd:"/filesystem",checkDirs:["filesystem","steipete-filesystem"]},{id:"summarize",label:"Summarize",desc:"ๅ†…ๅฎนๆ‘˜่ฆไธŽๆ€ป็ป“ๆ็‚ผ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/steipete/summarize",autoInstall:!0,slashCmd:"/summarize",checkDirs:["summarize","steipete-summarize"]},{id:"baidu-search",label:"็™พๅบฆๆœ็ดข",desc:"็™พๅบฆๆœ็ดขๅผ•ๆ“Ž้›†ๆˆ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/ide-rea/baidu-search",autoInstall:!0,slashCmd:"/baidu-search",checkDirs:["baidu-search","BaiduSearch"]},{id:"agent-browser-clawdbot",label:"Agent Browser",desc:"AI ้ฉฑๅŠจ็š„็ฝ‘้กตๆต่งˆไธŽ่‡ชๅŠจๅŒ–ๆ“ไฝœ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/matrixy/agent-browser-clawdbot",autoInstall:!0,slashCmd:"/agent-browser-clawdbot",checkDirs:["agent-browser-clawdbot","agent-browser","AgentBrowser"]},{id:"automation-workflows",label:"Automation Workflows",desc:"่‡ชๅŠจๅŒ–ๅทฅไฝœๆต็ผ–ๆŽ’ไธŽๆ‰ง่กŒ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/jk-0001/automation-workflows",autoInstall:!0,slashCmd:"/automation-workflows",checkDirs:["automation-workflows","AutomationWorkflows"]},{id:"evolver",label:"Evolver",desc:"Agent ่‡ชๅŠจ่ฟ›ๅŒ–ไธŽ่ƒฝๅŠ›่ฟญไปฃ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/autogame-17/evolver",autoInstall:!0,slashCmd:"/evolver",checkDirs:["evolver","autogame-evolver"]}]},{id:"productivity",label:"ๅทฅไฝœๆ•ˆ็އ",emoji:"๐Ÿ’ผ",skills:[{id:"pdf-reader",label:"PDF Reader",desc:"PDF ๆ–‡ๆกฃ่ฏปๅ–ไธŽๅˆ†ๆž",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/awspace/pdf",autoInstall:!0,slashCmd:"/pdf",checkDirs:["pdf","pdf-reader","awspace-pdf"]},{id:"powerpoint-pptx",label:"PowerPoint / PPTX",desc:"PPT ๆผ”็คบๆ–‡็จฟ็”ŸๆˆไธŽ็ผ–่พ‘",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/ivangdavila/powerpoint-pptx",autoInstall:!0,slashCmd:"/powerpoint-pptx",checkDirs:["powerpoint-pptx","powerpoint","pptx"]},{id:"word-docx",label:"Word / DOCX",desc:"Word ๆ–‡ๆกฃ็”ŸๆˆไธŽ็ผ–่พ‘",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/ivangdavila/word-docx",autoInstall:!0,slashCmd:"/word-docx",checkDirs:["word-docx","word","docx"]},{id:"excel-xlsx",label:"Excel / XLSX",desc:"Excel ่กจๆ ผ็”ŸๆˆไธŽๆ•ฐๆฎๅค„็†",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/ivangdavila/excel-xlsx",autoInstall:!0,slashCmd:"/excel-xlsx",checkDirs:["excel-xlsx","excel","xlsx"]},{id:"ai-ppt-generator",label:"AI PPT Generator",desc:"AI ่‡ชๅŠจ็”Ÿๆˆ PPT ๆผ”็คบๆ–‡็จฟ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/ide-rea/ai-ppt-generator",autoInstall:!0,slashCmd:"/ai-ppt-generator",checkDirs:["ai-ppt-generator","AiPptGenerator"]},{id:"nano-banana-pro",label:"Nano Banana Pro",desc:"่ฝป้‡้ซ˜ๆ•ˆ็š„ไปปๅŠกๆ‰ง่กŒไธŽๆต็จ‹ไผ˜ๅŒ–",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/steipete/nano-banana-pro",autoInstall:!0,slashCmd:"/nano-banana-pro",checkDirs:["nano-banana-pro","NanoBananaPro"]},{id:"ppt-generator",label:"PPT Generator",desc:"PPT ๆผ”็คบๆ–‡็จฟๆ™บ่ƒฝ็”Ÿๆˆ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/wwlyzzyorg/ppt-generator",autoInstall:!0,slashCmd:"/ppt-generator",checkDirs:["ppt-generator","PptGenerator"]},{id:"marketing-mode",label:"Marketing Mode",desc:"่ฅ้”€ๆ–‡ๆกˆไธŽๆŽจๅนฟๅ†…ๅฎนๅˆ›ไฝœ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/thesethrose/marketing-mode",autoInstall:!0,slashCmd:"/marketing-mode",checkDirs:["marketing-mode","MarketingMode"]},{id:"data-analysis",label:"Data Analysis",desc:"ๆ•ฐๆฎๅˆ†ๆžไธŽๅฏ่ง†ๅŒ–ๆŠฅๅ‘Š็”Ÿๆˆ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/ivangdavila/data-analysis",autoInstall:!0,slashCmd:"/data-analysis",checkDirs:["data-analysis","DataAnalysis"]}]},{id:"life",label:"็”Ÿๆดป่พ…ๅŠฉ",emoji:"๐Ÿ ",skills:[{id:"todo-manager",label:"Todo Manager",desc:"ไปปๅŠกไธŽๅพ…ๅŠžไบ‹้กน็ฎก็†",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/aeoleader/todo-manager",autoInstall:!0,slashCmd:"/todo-manager",checkDirs:["todo-manager","todo","TodoManager"]},{id:"12306",label:"12306 ็ซ่ฝฆ็ฅจ",desc:"ๆŸฅ่ฏขไธŽ่ดญไนฐ 12306 ็ซ่ฝฆ็ฅจ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/kirorab/12306",autoInstall:!0,slashCmd:"/12306",checkDirs:["12306","kirorab-12306"]},{id:"youtube-watcher",label:"YouTube Watcher",desc:"YouTube ่ง†้ข‘ๆ‘˜่ฆไธŽๅ†…ๅฎนๅˆ†ๆž",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/michaelgathara/youtube-watcher",autoInstall:!0,slashCmd:"/youtube-watcher",checkDirs:["youtube-watcher","youtube","YoutubeWatcher"]},{id:"xiaohongshu-cn",label:"ๅฐ็บขไนฆๅŠฉๆ‰‹",desc:"ๅฐ็บขไนฆๅ†…ๅฎนๅˆ›ไฝœไธŽ่ฟ่ฅ่พ…ๅŠฉ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/guohongbin-git/xiaohongshu-cn",autoInstall:!0,slashCmd:"/xiaohongshu-cn",checkDirs:["xiaohongshu-cn","xiaohongshu","XiaohongshuCn"]},{id:"wechat-mp-cn",label:"ๅพฎไฟกๅ…ฌไผ—ๅทๅŠฉๆ‰‹",desc:"ๅพฎไฟกๅ…ฌไผ—ๅทๅ†…ๅฎนๅˆ›ไฝœไธŽๅ‘ๅธƒ่พ…ๅŠฉ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/guohongbin-git/wechat-mp-cn",autoInstall:!0,slashCmd:"/wechat-mp-cn",checkDirs:["wechat-mp-cn","wechat-mp","WechatMpCn"]},{id:"weather",label:"Weather",desc:"ๅฎžๆ—ถๅคฉๆฐ”ๆŸฅ่ฏขไธŽ้ข„ๆŠฅ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/steipete/weather",autoInstall:!0,slashCmd:"/weather",checkDirs:["weather","steipete-weather"]},{id:"stock-analysis",label:"Stock Analysis",desc:"่‚ก็ฅจ่กŒๆƒ…ๅˆ†ๆžไธŽๆŠ•่ต„ๅ‚่€ƒ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/udiedrichsen/stock-analysis",autoInstall:!0,slashCmd:"/stock-analysis",checkDirs:["stock-analysis","StockAnalysis"]},{id:"news-summary",label:"News Summary",desc:"ๆ–ฐ้—ป่ต„่ฎฏ่šๅˆไธŽๆ‘˜่ฆ็”Ÿๆˆ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/joargp/news-summary",autoInstall:!0,slashCmd:"/news-summary",checkDirs:["news-summary","NewsSummary"]}]},{id:"dev",label:"ๅผ€ๅ‘ๅทฅๅ…ท",emoji:"๐Ÿ› ๏ธ",skills:[{id:"github",label:"GitHub",desc:"GitHub ไป“ๅบ“็ฎก็†ไธŽไปฃ็ ๅไฝœ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/steipete/github",autoInstall:!0,slashCmd:"/github",checkDirs:["github","GitHub","steipete-github"]},{id:"gemini",label:"Gemini",desc:"Google Gemini ๆจกๅž‹ๆŽฅๅ…ฅไธŽ่ฐƒ็”จ",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/steipete/gemini",autoInstall:!0,slashCmd:"/gemini",checkDirs:["gemini","Gemini","steipete-gemini"]},{id:"api-gateway",label:"API Gateway",desc:"API ๆŽฅๅฃ็ฎก็†ไธŽ่ฏทๆฑ‚ไปฃ็†",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/byungkyu/api-gateway",autoInstall:!0,slashCmd:"/api-gateway",checkDirs:["api-gateway","ApiGateway"]},{id:"mcporter",label:"MCPorter",desc:"MCP ๆœๅŠกๅ™จ็ฎก็†ๅทฅๅ…ท",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/steipete/mcporter",autoInstall:!0,slashCmd:"/mcporter",checkDirs:["mcporter","MCPorter","steipete-mcporter"]},{id:"session-logs",label:"Session Logs",desc:"ไผš่ฏๆ—ฅๅฟ—่ฎฐๅฝ•ไธŽๅ›žๆ”พๅˆ†ๆž",installMsg:"ๆ นๆฎไปฅไธ‹้“พๆŽฅๅฎ‰่ฃ…skill๏ผšhttps://clawhub.ai/guogang1024/session-logs",autoInstall:!0,slashCmd:"/session-logs",checkDirs:["session-logs","SessionLogs"]}]}],ze={id:yr,label:Nr,emoji:kr,groups:Cr},Fr="mcp",Sr="ๅธธ็”จ MCP",Mr="๐Ÿ”Œ",Er=[{id:"12306-mcp",label:"12306-MCP่ฝฆ็ฅจๆŸฅ่ฏขๅทฅๅ…ท",desc:"12306-MCP่ฝฆ็ฅจๆŸฅ่ฏขๅทฅๅ…ท",mcpJson:{"12306-mcp":{command:"npx",args:["-y","12306-mcp"]}}},{id:"bing-search",label:"Bing ๆœ็ดข",desc:"ๅฟ…ๅบ”ๆœ็ดขๅผ•ๆ“Ž MCP ๆŽฅๅ…ฅ",mcpJson:{"bing-search":{command:"npx",args:["-y","bing-cn-mcp"]}}},{id:"fxbaogao-mcp",label:"ๅ‘็ŽฐๆŠฅๅ‘Š",desc:"ๅ‘็ŽฐๆŠฅๅ‘Š็ ”็ฉถๆŠฅๅ‘Šๆฃ€็ดขไธŽ้˜…่ฏป",mcpJson:{"fxbaogao-mcp":{command:"uvx",args:["fxbaogao-mcp@latest"]}}}],Ar={id:Fr,label:Sr,emoji:Mr,items:Er},Ir="slash",Pr="ๅธธ็”จ /ๅ‘ฝไปค",Rr="/",Lr=[{label:"ไผš่ฏ",items:[{id:"slash-new",label:"/new",desc:"ๅผ€ๅฏๆ–ฐไผš่ฏ",cmd:"/new",send:!0},{id:"slash-reset",label:"/reset",desc:"้‡็ฝฎๅฝ“ๅ‰ไผš่ฏ",cmd:"/reset",send:!0},{id:"slash-compact",label:"/compact",desc:"ๅŽ‹็ผฉไผš่ฏไธŠไธ‹ๆ–‡",cmd:"/compact",send:!0},{id:"slash-stop",label:"/stop",desc:"ๅœๆญขๅฝ“ๅ‰่ฟ่กŒ",cmd:"/stop",send:!0},{id:"slash-clear",label:"/clear",desc:"ๆธ…็ฉบ่Šๅคฉ่ฎฐๅฝ•",cmd:"/clear",send:!0},{id:"slash-focus",label:"/focus",desc:"ๅˆ‡ๆขไธ“ๆณจๆจกๅผ",cmd:"/focus",send:!0}]},{label:"ๆจกๅž‹",items:[{id:"slash-model",label:"/model <name>",desc:"ๆŸฅ็œ‹ๆˆ–ๅˆ‡ๆขๆจกๅž‹",cmd:"/model ",send:!1},{id:"slash-think",label:"/think <level>",desc:"่ฎพ็ฝฎๆ€่€ƒๆทฑๅบฆ",cmd:"/think ",send:!1},{id:"slash-verbose",label:"/verbose <on|off|full>",desc:"ๅˆ‡ๆข่ฏฆ็ป†่พ“ๅ‡บๆจกๅผ",cmd:"/verbose ",send:!1},{id:"slash-fast",label:"/fast <status|on|off>",desc:"ๅˆ‡ๆขๅฟซ้€Ÿๆจกๅผ",cmd:"/fast ",send:!1}]},{label:"ๅทฅๅ…ท",items:[{id:"slash-help",label:"/help",desc:"ๆŸฅ็œ‹ๅฏ็”จๅ‘ฝไปค",cmd:"/help",send:!0},{id:"slash-status",label:"/status",desc:"ๆ˜พ็คบไผš่ฏ็Šถๆ€๏ผˆagent๏ผ‰",cmd:"/status",send:!0},{id:"slash-export",label:"/export",desc:"ๅฏผๅ‡บไผš่ฏไธบ Markdown",cmd:"/export",send:!0},{id:"slash-usage",label:"/usage",desc:"ๆ˜พ็คบ Token ็”จ้‡",cmd:"/usage",send:!0}]}],Tr={id:Ir,label:Pr,emoji:Rr,groups:Lr};function Dr({gatewayLaunchUrl:r,gatewayReady:i,isRunning:o,isPending:x,iframeLoaded:t,actionLoading:f,onAction:m,onReload:y,onIframeLoad:n}){const{t:a}=we("instance");return e.jsx("div",{className:"overflow-hidden rounded-[22px] border border-[var(--border)] bg-[var(--card)] shadow-[0_18px_48px_rgba(15,23,42,0.06)]",children:e.jsxs("div",{className:"relative",style:{height:"calc(100vh - 160px)",minHeight:"500px"},children:[(!o||!i||!t)&&e.jsx("div",{className:`absolute inset-0 w-full h-full bg-[var(--card)] flex flex-col items-center justify-center z-10 transition-opacity duration-300 ${t?"opacity-0 pointer-events-none":"opacity-100"}`,children:o?i?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-5 h-5 border-2 border-[#0066FF]/30 border-t-[#0066FF] rounded-full animate-spin mb-3"}),e.jsx("div",{className:"text-sm text-foreground/60",children:a("chat.loadingChat")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-5 h-5 border-2 border-[#0066FF]/30 border-t-[#0066FF] rounded-full animate-spin mb-3"}),e.jsx("div",{className:"text-sm text-foreground/60",children:a("chat.waitingGateway")})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"text-4xl mb-4 opacity-40",children:"๐Ÿ’ฌ"}),e.jsx("div",{className:"text-sm text-foreground/60 font-medium mb-1",children:a("chat.notReady")}),e.jsx("div",{className:"text-xs text-muted mb-4",children:a("chat.startHint")}),e.jsx("button",{onClick:()=>m("start"),disabled:!!f||x,className:"px-4 py-2 bg-[#0066FF] text-white rounded-md text-xs font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:a(f==="start"||x?"action.starting":"chat.startInstance")})]})}),i&&r&&e.jsx("iframe",{id:"gateway-iframe",src:r,className:"w-full h-full",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-downloads allow-modals",allow:"microphone; camera; clipboard-write",onLoad:n})]})})}function Or({logs:r,logSearch:i,logType:o,logsEndRef:x,onSearchChange:t,onLogTypeChange:f,onRefresh:m,onCopy:y}){const{t:n}=we("instance"),a=i?r.filter(s=>s.toLowerCase().includes(i.toLowerCase())):r;return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx(Ls,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted"}),e.jsx("input",{type:"text",value:i,onChange:s=>t(s.target.value),placeholder:n("logs.searchPlaceholder"),className:"w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md pl-9 pr-3 py-1.5 text-sm text-foreground placeholder-[var(--muted)] focus:outline-none focus:ring-1 focus:ring-[#0066FF]/60 focus:border-[#0066FF]/60 transition-colors"})]}),e.jsx("div",{className:"flex items-center gap-1",children:["stderr","stdout"].map(s=>e.jsx("button",{onClick:()=>f(s),className:`px-2.5 py-1.5 text-xs rounded-md transition-colors duration-150 ${o===s?"bg-[#0066FF] text-white":"text-muted hover:bg-[var(--card-hover)]"}`,children:s},s))}),e.jsx("button",{onClick:m,className:"p-1.5 border border-[var(--border)] rounded-md text-muted hover:text-foreground hover:bg-[var(--card-hover)] transition-colors",title:n("common:action.refresh"),children:e.jsx(ls,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:y,className:"p-1.5 border border-[var(--border)] rounded-md text-muted hover:text-foreground hover:bg-[var(--card-hover)] transition-colors",title:n("common:action.copyAll"),children:e.jsx(Ts,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"bg-black/60 border border-[var(--border)] rounded-xl font-mono text-[13px] p-4 min-h-[400px] lg:min-h-[500px] overflow-auto max-h-[70vh]",children:[a.length===0?e.jsx("p",{className:"text-muted",children:n("logs.empty")}):a.map((s,d)=>{const h=/error|ERR|panic|fatal/i.test(s),N=/warn|WARN/i.test(s);return e.jsx("div",{className:`whitespace-pre-wrap break-all leading-5 ${h?"text-red-400 bg-red-950/20":N?"text-amber-400":"text-foreground opacity-70"}`,children:s},`${d}-${s.slice(0,32)}`)}),e.jsx("div",{ref:x})]})]})}function $r({usage:r,onRefresh:i}){const{t:o}=we("instance");if(!r)return e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"grid grid-cols-3 gap-3",children:[1,2,3].map(t=>e.jsx("div",{className:"h-20 bg-[var(--card)] rounded-lg"},t))}),e.jsx("div",{className:"h-60 bg-[var(--card)] rounded-lg"})]})});const x=tr.language==="zh"?"zh-CN":"en-US";return e.jsxs("div",{className:"space-y-4",children:[r.totals.totalTokens===0&&r.totals.messages>0&&e.jsx("div",{className:"bg-[var(--card)] border border-[var(--border)] text-muted text-sm rounded-lg px-4 py-3",children:o("usage.noTokenData")}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-3 gap-3",children:[{label:o("usage.messages"),value:r.totals.messages.toLocaleString()},{label:o("usage.totalTokens"),value:r.totals.totalTokens.toLocaleString()},{label:o("usage.totalCost"),value:`$${r.totals.costTotal.toFixed(4)}`}].map(t=>e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl p-4 hover:border-[var(--border-hover)] transition-colors",children:[e.jsx("div",{className:"text-xs text-muted mb-1",children:t.label}),e.jsx("div",{className:"text-2xl font-semibold text-foreground",children:t.value})]},t.label))}),e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl overflow-hidden",children:[e.jsxs("div",{className:"px-4 py-3 border-b border-[var(--border)] flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm font-medium text-foreground",children:[o("usage.sessions")," (",r.sessions.length,")"]}),e.jsx("button",{onClick:i,className:"text-xs text-muted hover:text-foreground transition-colors",children:o("common:action.refresh")})]}),r.sessions.length===0?e.jsx("p",{className:"text-muted text-sm p-4",children:o("usage.noSessions")}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-xs text-muted border-b border-[var(--border)]",children:[e.jsx("th",{className:"text-left font-medium px-4 py-2",children:o("usage.time")}),e.jsx("th",{className:"text-left font-medium px-4 py-2",children:o("usage.model")}),e.jsx("th",{className:"text-left font-medium px-4 py-2",children:o("usage.source")}),e.jsx("th",{className:"text-right font-medium px-4 py-2",children:o("usage.messagesShort")}),e.jsx("th",{className:"text-right font-medium px-4 py-2",children:o("usage.input")}),e.jsx("th",{className:"text-right font-medium px-4 py-2",children:o("usage.output")}),e.jsx("th",{className:"text-right font-medium px-4 py-2",children:o("usage.tokens")}),e.jsx("th",{className:"text-right font-medium px-4 py-2",children:o("usage.cost")})]})}),e.jsx("tbody",{className:"divide-y divide-[var(--border)]",children:r.sessions.map(t=>e.jsxs("tr",{className:"hover:bg-[var(--card-hover)] transition-colors",children:[e.jsx("td",{className:"px-4 py-2 text-muted whitespace-nowrap",children:t.lastMessage?new Date(t.lastMessage).toLocaleString(x,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"-"}),e.jsx("td",{className:"px-4 py-2 font-mono text-xs text-muted",children:t.model||"-"}),e.jsxs("td",{className:"px-4 py-2 text-muted",children:[t.channel&&e.jsx("span",{className:"inline-block bg-[var(--card-hover)] text-muted text-[11px] px-1.5 py-0.5 rounded mr-1 font-medium",children:t.channel}),e.jsx("span",{className:"text-xs text-muted opacity-60",children:t.origin?t.origin.length>20?t.origin.slice(0,20)+"...":t.origin:""})]}),e.jsx("td",{className:"px-4 py-2 text-right tabular-nums text-muted",children:t.usage.messages}),e.jsx("td",{className:"px-4 py-2 text-right font-mono text-xs tabular-nums text-muted",children:t.usage.input.toLocaleString()}),e.jsx("td",{className:"px-4 py-2 text-right font-mono text-xs tabular-nums text-muted",children:t.usage.output.toLocaleString()}),e.jsx("td",{className:"px-4 py-2 text-right font-mono text-xs tabular-nums text-muted",children:t.usage.totalTokens.toLocaleString()}),e.jsxs("td",{className:"px-4 py-2 text-right font-mono text-xs tabular-nums text-muted",children:["$",t.usage.costTotal.toFixed(4)]})]},t.key))})]})})]})]})}function Ur(r,i){if(r==null)return"-";const o=Math.floor(r/86400),x=Math.floor(r%86400/3600),t=Math.floor(r%3600/60);return o>0?i("instance:uptime.days",{d:o,h:x}):x>0?i("instance:uptime.hours",{h:x,m:t}):i("instance:uptime.minutes",{m:t})}const We=[jr,ze,Ar,Tr];function _r(r){for(const i of We){const o=t=>(t==null?void 0:t.find(f=>f.id===r))??null;if(i.groups)for(const t of i.groups){const f=o(t.items);if(f)return f}const x=o(i.items);if(x)return x}return null}function es(r,i){const o=JSON.parse(JSON.stringify(r??{})),x=Oe.find(m=>m.id===i);if(x){if(o.channels||(o.channels={}),o.plugins||(o.plugins={}),o.plugins.entries||(o.plugins.entries={}),o.channels[i])o.channels[i].enabled=!0;else{const m={enabled:!0,...x.defaults??{}};x.fields.forEach(y=>{y.key in m||(m[y.key]="")}),o.channels[i]=m}return o.plugins.entries[i]||(o.plugins.entries[i]={enabled:!0}),o}const t={"skill-vetter":{"skill-vetter":{enabled:!0}},"skill-finder":{"skill-finder":{enabled:!0}},"skill-browser":{"skill-browser":{enabled:!0}}};if(i in t)return o.skills||(o.skills={}),Object.assign(o.skills,t[i]),o;const f={};return i in f&&(o.mcp||(o.mcp={}),o.mcp.servers||(o.mcp.servers={}),Object.assign(o.mcp.servers,f[i])),o}function qr(r){var x,t,f;const i=(t=(x=r==null?void 0:r.runtime)==null?void 0:x.env)==null?void 0:t.OPENCLAW_GATEWAY_PORT;if(i)return String(i);const o=((f=r==null?void 0:r.runtime)==null?void 0:f.args)||[];for(let m=0;m<o.length;m++){if(o[m]==="--port"&&m+1<o.length)return String(o[m+1]);if(typeof o[m]=="string"&&o[m].startsWith("--port="))return String(o[m].slice(7))}return"-"}function Qr(){var Tt,Dt,Ot,$t,Ut,_t,qt;const{id:r,tab:i}=Xs(),o=Zs(),{showToast:x}=Ds(),{t}=we(["instance","common","data"]),[f,m]=w.useState(null),[y,n]=w.useState(i==="overview"?"chat":i||"chat"),[a,s]=w.useState(null),[d,h]=w.useState(!1),[N,g]=w.useState(""),[C,j]=w.useState(!1),[$,L]=w.useState(""),[S,F]=w.useState([]),[O,T]=w.useState("stderr"),[q,J]=w.useState(""),[xe,fe]=w.useState(null),[B,Fe]=w.useState(""),[ee,Y]=w.useState(!1),[X,ne]=w.useState(!1),[G,pe]=w.useState(""),[oe,ge]=w.useState(!1),[c,b]=w.useState(!1),[E,U]=w.useState(""),[H,te]=w.useState(!1),[P,z]=w.useState(!1),[se,vs]=w.useState("im"),[Ie,$e]=w.useState("general"),[D,je]=w.useState(null),[ws,Ve]=w.useState({}),[Se,Qe]=w.useState(""),[Ge,ht]=w.useState(""),[xt,ye]=w.useState(""),[Ne,ie]=w.useState({servers:[],installed:!1,loading:!1}),[V,ae]=w.useState(null),ue=w.useRef(!1),ce=w.useRef(!1),[Ye,ft]=w.useState(!1),[me,pt]=w.useState(null),[gt,bt]=w.useState(!1),Xe=w.useRef(null),Ze=w.useRef(null),[vt,wt]=w.useState(!1),[et,jt]=w.useState(null),[yt,Nt]=w.useState(!1),[kt,Ct]=w.useState(null),[Ft,Ue]=w.useState(null),St=w.useRef(r),tt=w.useRef(Ye);St.current=r,tt.current=Ye,w.useEffect(()=>{Os().then(l=>{l.hasUpdate&&pt({currentVersion:l.currentVersion,latestVersion:l.latestVersion})}).catch(()=>{})},[]);const js=async()=>{if(window.confirm(t("update.confirm",{currentVersion:me==null?void 0:me.currentVersion,latestVersion:me==null?void 0:me.latestVersion}))){bt(!0);try{await Ws(),x(t("update.started"),"success"),pt(null)}catch(l){x(l.message||t("update.failed"),"error")}finally{bt(!1)}}};w.useEffect(()=>{P&&r&&Te(r).then(je).catch(()=>{})},[P,r]),w.useEffect(()=>{P&&se==="mcp"&&r&&(ie(l=>({...l,loading:!0})),ct(r).then(l=>ie({servers:l.servers,installed:l.installed,loading:!1})).catch(()=>ie(l=>({...l,loading:!1}))))},[P,se,r]),w.useEffect(()=>{i&&n(i==="overview"?"chat":i)},[i]),w.useEffect(()=>{vt&&y==="config"&&a&&(wt(!1),j(!1),setTimeout(()=>{const l=document.getElementById("im-channel-section");l?l.scrollIntoView({behavior:"smooth",block:"start"}):window.scrollTo({top:document.body.scrollHeight,behavior:"smooth"})},200))},[vt,y,a]);const Pe=w.useCallback(()=>{const l=St.current;l&&!tt.current&&$s(l).then(m).catch(()=>{})},[x]);w.useEffect(()=>{Pe(),r&&(ne(!1),Us(r).then(u=>{const p=typeof(u==null?void 0:u.url)=="string"?u.url.trim():"";if(!p)throw new Error("No gateway launch URL returned");Fe(p)}).catch(u=>{Fe(""),x((u==null?void 0:u.message)||t("gatewayLaunchFailed"),"error")}));const l=setInterval(Pe,5e3);return()=>clearInterval(l)},[r,Pe]);const Mt=((Tt=f==null?void 0:f.service)==null?void 0:Tt.status)==="running",Et=w.useRef(!1);Et.current=ee,w.useEffect(()=>{if(!B||!Mt){Y(!1),ne(!1);return}if(Et.current)return;let l=!1,u=0;const p=60,v=()=>{l||u>=p||(u++,fetch(B,{method:"HEAD",credentials:"include"}).then(k=>{!l&&k.ok&&Y(!0)}).catch(()=>{}))};v();const I=setInterval(v,3e3);return()=>{l=!0,clearInterval(I)}},[B,Mt]);const[re,st]=w.useState({}),At=Object.values(re).includes("installing"),_e=w.useRef(new Set),rt=w.useRef(x);rt.current=x;const nt=w.useRef(t);nt.current=t,w.useEffect(()=>{if(!r||!(y==="config"||At))return;let u=!1;const p=()=>{u||zt(r).then(I=>{var M;if(u)return;const k={};for(const[A,_]of Object.entries(I.plugins))k[A]=_.status;for(const A of _e.current){const _=k[A];if(_==="installed")rt.current(nt.current(A==="feishu"?"feishu.pluginInstalled":"weixin.pluginInstalled"),"success"),_e.current.delete(A);else if(_==="failed"||_==="not_installed"){const Z=(M=I.plugins[A])==null?void 0:M.error;rt.current(nt.current(A==="feishu"?"feishu.pluginFailed":"weixin.pluginFailed")+(Z?": "+Z:""),"error"),_e.current.delete(A)}}st(k)}).catch(()=>{})};p();const v=setInterval(p,3e3);return()=>{u=!0,clearInterval(v)}},[r,y,At]),w.useEffect(()=>{P&&r&&zt(r).then(l=>{const u={};for(const[p,v]of Object.entries(l.plugins))u[p]=v.status;st(u)}).catch(()=>{})},[P,r]);const It=l=>{r&&(Ks(r,l).catch(()=>{}),st(u=>({...u,[l]:"installing"})),_e.current.add(l),x(t(l==="feishu"?"feishu.installing":"weixin.installing"),"info"))};w.useEffect(()=>{if(!d)return;const l=u=>{u.preventDefault()};return window.addEventListener("beforeunload",l),()=>window.removeEventListener("beforeunload",l)},[d]),w.useEffect(()=>{y==="config"&&r&&Wt(r).then(l=>{const u=Ze.current;Ze.current=null;const p=u?es(l,u):l;s(p),L(JSON.stringify(p,null,2)),h(!!u)}).catch(()=>{}),y==="usage"&&r&&Kt(r).then(fe).catch(()=>{})},[y,r]);const at=()=>{r&&Js(r,200,O).then(l=>{var p;F(l.lines);const u=(p=Xe.current)==null?void 0:p.parentElement;u&&u.scrollHeight-u.scrollTop-u.clientHeight<80&&setTimeout(()=>{var I;return(I=Xe.current)==null?void 0:I.scrollIntoView({behavior:"smooth"})},100)}).catch(()=>{})};er(at,3e3,y==="logs"&&!!r),w.useEffect(()=>{y==="logs"&&at()},[O]);const qe=async l=>{if(r){pe(l);try{l==="start"&&await Vs(r),l==="stop"&&await Qs(r),l==="restart"&&await Gt(r),x(t(l==="start"?"action.startHint":l==="stop"?"action.stopDone":"action.restartHint"),l==="stop"?"success":"info"),(l==="start"||l==="restart")&&o(`/instances/${r}`),setTimeout(Pe,1e3)}catch(u){x(u.message||t("common:error.operationFailed"),"error")}finally{pe("")}}},Pt=async l=>{if(!r)return;z(!1),ue.current=!1;const u=l==="feishu"?"feishu":"openclaw-weixin",p=re[u];if(p==="installing"){x(t(l==="feishu"?"feishu.waitingInstall":"weixin.waitingInstall"),"info");return}if(p!=="installed"){It(u);return}ce.current=!1,ae({type:l,qrUrl:"",sessionKey:"",status:"loading",message:t("qr.gettingQr")});try{let v=null;for(let k=0;k<3;k++){if(ce.current)return;try{if(v=l==="feishu"?await ss(r):await rs(r),v!=null&&v.qrcodeUrl)break}catch{k<2&&await new Promise(M=>setTimeout(M,1500))}}if(ce.current)return;if(!(v!=null&&v.qrcodeUrl)){ae(k=>k?{...k,status:"error",message:t("qr.getFailed")}:null);return}ae({type:l,qrUrl:v.qrcodeUrl,sessionKey:v.sessionKey,status:"waiting",message:t(l==="feishu"?"qr.scanFeishu":"qr.scanWeixin")}),ue.current=!0;const I=async k=>{if(!(!ue.current||ce.current))try{const M=l==="feishu"?await ns(r,k):await as(r,k);if(ce.current)return;if(M.connected){ue.current=!1,ae(A=>A?{...A,qrUrl:"",status:"confirmed",message:M.message||t("qr.loginSuccess")}:null);return}if(M.status==="expired"){ue.current=!1,ae(A=>A?{...A,status:"error",message:M.message||t("qr.expired")}:null);return}M.status==="refreshed"&&M.qrcodeUrl?ae(A=>A?{...A,qrUrl:M.qrcodeUrl,message:t("qr.refreshed")}:null):M.status==="scaned"&&ae(A=>A?{...A,status:"scaned",message:M.message||t("qr.scaned")}:null),setTimeout(()=>I(k),2e3)}catch{ue.current&&!ce.current&&setTimeout(()=>I(k),3e3)}};setTimeout(()=>I(v.sessionKey),2e3)}catch{ce.current||ae(v=>v?{...v,status:"error",message:t("qr.getFailed")}:null)}},ke=(l,u)=>{let p=0;const v=()=>{var I;try{const k=document.getElementById("gateway-iframe");if(!k){++p<50&&setTimeout(v,200);return}const M=k.contentDocument;if(!M||M.readyState==="loading"){++p<50&&setTimeout(v,200);return}const A=M.querySelector("openclaw-app");if(!A){++p<50&&setTimeout(v,200);return}if(u){if(!A.connected&&++p<50){setTimeout(v,200);return}A.handleSendChat(l)}else A.chatMessage=l}catch{const k=document.getElementById("gateway-iframe");(I=k==null?void 0:k.contentWindow)==null||I.postMessage({type:"jishu:inject-cmd",cmd:l,send:u},"*")}};y!=="chat"?(be("chat"),setTimeout(v,800)):setTimeout(v,100)},Be=l=>{if(z(!1),l==="feishu"||l==="openclaw-weixin"){Pt(l==="feishu"?"feishu":"weixin");return}const u=_r(l);if(u&&u.cmd!==void 0){ke(u.cmd,u.send!==!1);return}if(a!==null&&y==="config"){const p=es(a,l);s(p),L(JSON.stringify(p,null,2)),h(!0),x(t("config.presetAdded"),"info")}else Ze.current=l,be("config"),x(t("config.navigatingToConfig"),"info")},ys=l=>{s(l),L(JSON.stringify(l,null,2)),h(!0)},Ns=l=>{L(l),h(!0);try{s(JSON.parse(l)),g("")}catch{g(t("config.jsonError"))}},ks=l=>{var I,k,M;if(!l)return"{}";const u=JSON.parse(JSON.stringify(l)),p=(I=u==null?void 0:u.models)==null?void 0:I.providers;if(p&&typeof p=="object")for(const[A,_]of Object.entries(p))A.startsWith("js-")&&(_!=null&&_.apiKey)&&(_.apiKey="(proxy token, auto-managed)");const v=(M=(k=u==null?void 0:u["x-jishushell"])==null?void 0:k.proxy)==null?void 0:M.upstream;return v&&v.apiKey===""&&v.hasApiKey&&(v.apiKey="(saved, leave empty to keep, enter new value to update)"),JSON.stringify(u,null,2)},Rt=l=>{var I,k,M;const u=JSON.parse(l),p=(k=(I=u==null?void 0:u["x-jishushell"])==null?void 0:I.proxy)==null?void 0:k.upstream;(p==null?void 0:p.apiKey)==="(saved, leave empty to keep, enter new value to update)"&&delete p.apiKey;const v=(M=u==null?void 0:u.models)==null?void 0:M.providers;if(v&&typeof v=="object")for(const[A,_]of Object.entries(v))A.startsWith("js-")&&(_==null?void 0:_.apiKey)==="(proxy token, auto-managed)"&&delete _.apiKey;return u},Lt=async l=>{if(!(!r||!a)){g(""),ge(!0);try{const u=Rt(C?$:JSON.stringify(a)),p=await Gs(r,u);if(p!=null&&p.config&&(s(p.config),L(JSON.stringify(p.config,null,2))),h(!1),l)try{await Gt(r),x(t("config.savedAndRestarted"),"success"),n("chat"),o(`/instances/${r}`,{replace:!0})}catch(v){x(t("config.savedButRestartFailed",{error:v.message||""}),"error"),g(t("config.restartFailed",{error:v.message||""}))}else x(t("config.saved"),"success");setTimeout(Pe,1e3)}catch(u){g(u instanceof SyntaxError?t("config.jsonParseError",{error:u.message}):u.message||t("common:error.saveFailed"))}finally{ge(!1)}}},Cs=async()=>{var l;if(!(!r||E.trim()!==((l=f==null?void 0:f.name)==null?void 0:l.trim())||Ye)){tt.current=!0,ft(!0);try{await Ys(r),o("/",{replace:!0})}catch(u){x(u.message||t("common:error.deleteFailed"),"error"),ft(!1)}}},be=l=>{if(d&&y==="config"&&l!=="config"){if(!window.confirm(t("config.unsavedWarning")))return;h(!1)}n(l),o(`/instances/${r}/${l}`,{replace:!0})};if(!f)return e.jsx("div",{className:"p-6 max-w-5xl mx-auto",children:e.jsxs("div",{className:"animate-pulse space-y-4",children:[e.jsx("div",{className:"h-6 w-48 bg-[var(--card)] rounded"}),e.jsx("div",{className:"h-10 w-full bg-[var(--card)] rounded"}),e.jsx("div",{className:"h-40 bg-[var(--card)] rounded-lg"})]})});const Me=((Dt=f.service)==null?void 0:Dt.status)||"stopped",Re=Me==="running",Ee=Me==="pending",lt=Me==="failed"||Me==="dead",Le=Re&&ee,Fs=t(Le?"common:status.running":Re||Ee?"common:status.starting":Me==="failed"?"common:status.failed":Me==="dead"?"common:status.crashed":"common:status.stopped"),Ss=Le?"text-emerald-400":Re||Ee?"text-amber-400":lt?"text-red-400":"text-muted",Ms=Le?"bg-emerald-500 shadow-[0_0_6px_rgba(16,185,129,0.6)]":Re||Ee?"bg-amber-400 animate-pulse shadow-[0_0_6px_rgba(251,191,36,0.5)]":lt?"bg-red-500 shadow-[0_0_6px_rgba(239,68,68,0.6)]":"bg-[var(--muted)] opacity-40";return e.jsxs("div",{className:"p-6 max-w-5xl mx-auto",children:[me&&e.jsxs("div",{className:"mb-4 flex items-center justify-between gap-3 bg-amber-500/10 border border-amber-500/30 rounded-lg px-4 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx("svg",{className:"w-4 h-4 text-amber-400 shrink-0",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,children:e.jsx("path",{d:"M12 2v6m0 0 2-2m-2 2-2-2M4.93 10.93A10 10 0 1 0 21 12"})}),e.jsxs("span",{className:"text-amber-300",children:[t("update.found"),e.jsx("span",{className:"font-mono text-amber-200 ml-1",children:me.currentVersion}),e.jsx("span",{className:"mx-1 text-amber-500",children:"โ†’"}),e.jsx("span",{className:"font-mono text-amber-200",children:me.latestVersion})]})]}),e.jsx("button",{onClick:js,disabled:gt,className:"shrink-0 bg-amber-500 hover:bg-amber-400 disabled:opacity-50 text-black text-xs font-semibold px-3 py-1 rounded-md transition-colors",children:t(gt?"update.upgrading":"update.upgradeNow")})]}),e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:f.name}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:`w-2 h-2 rounded-full ${Ms}`}),e.jsx("span",{className:`text-xs font-medium ${Ss}`,children:Fs})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[y==="chat"&&e.jsxs(e.Fragment,{children:[e.jsx("a",{href:B||void 0,target:"_blank",rel:"noopener noreferrer","aria-disabled":!B,title:t("openInWindow"),className:`p-1.5 border border-[var(--border)] rounded-md transition-all duration-150 ${B?"text-muted hover:text-foreground hover:bg-[var(--card-hover)] cursor-pointer":"pointer-events-none text-muted opacity-30"}`,children:e.jsx(_s,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>{Y(!1),ne(!1)},disabled:!B,title:t("reload"),className:"p-1.5 border border-[var(--border)] rounded-md text-muted hover:text-foreground hover:bg-[var(--card-hover)] disabled:opacity-30 transition-all duration-150",children:e.jsx(ls,{className:"w-4 h-4"})})]}),e.jsxs("button",{onClick:()=>be("config"),title:t("tab.config"),className:"p-1.5 border border-[var(--border)] rounded-md text-muted hover:text-foreground hover:bg-[var(--card-hover)] transition-all duration-150 relative",children:[e.jsx(qs,{className:"w-4 h-4"}),d&&e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-1.5 h-1.5 rounded-full bg-amber-400"})]}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{onClick:()=>z(l=>!l),title:t("quickSkill"),className:"flex items-center gap-1 px-2.5 py-1.5 border border-[#0066FF]/30 rounded-md text-xs font-medium text-[#0066FF] bg-[#0066FF]/5 hover:bg-[#0066FF]/10 transition-all duration-150",children:[e.jsx("svg",{className:"w-3.5 h-3.5",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("polygon",{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"})}),e.jsx("span",{className:"hidden sm:inline",children:t("quickSkill")}),e.jsx(ts,{className:`w-3 h-3 transition-transform duration-150 ${P?"rotate-180":""}`})]}),P&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>z(!1)}),e.jsxs("div",{className:"absolute right-0 top-full mt-1 w-80 bg-background border border-[var(--border)] rounded-lg shadow-2xl z-20 overflow-hidden",children:[e.jsx("div",{className:"flex border-b border-[var(--border)]",children:["im","skills","mcp","slash"].map(l=>{const u={im:{emoji:"๐Ÿ’ฌ",label:t("quickSkill.im")},skills:{emoji:"โšก",label:t("quickSkill.skills")},mcp:{emoji:"๐Ÿ”Œ",label:t("quickSkill.mcp")},slash:{emoji:"/",label:t("quickSkill.slash")}}[l];return e.jsxs("button",{onClick:p=>{p.stopPropagation(),vs(l)},className:`flex-1 py-2 flex flex-col items-center gap-0.5 text-[10px] font-medium transition-colors border-b-2 ${se===l?"text-[#0066FF] border-[#0066FF] bg-[#0066FF]/5":"text-muted border-transparent hover:text-foreground hover:bg-[var(--card-hover)]"}`,children:[e.jsx("span",{className:"text-sm leading-none",children:u.emoji}),e.jsx("span",{children:u.label})]},l)})}),e.jsxs("div",{className:"max-h-[480px] overflow-y-auto",children:[se==="im"&&e.jsxs("div",{className:"p-3 space-y-2",children:[e.jsxs("button",{onClick:()=>Be("feishu"),className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-[#3370FF]/30 bg-[#3370FF]/5 hover:bg-[#3370FF]/10 transition-all duration-150",children:[e.jsx("img",{src:"https://s1.aigei.com/src/img/png/5a/5ad236651e0c4a6b940d2e1d2bf29749.png?imageMogr2/auto-orient/thumbnail/!282x282r/gravity/Center/crop/282x282/quality/85/%7CimageView2/2/w/282&e=2051020800&token=P7S2Xpzfz11vAkASLTkfHN7Fw-oOZBecqeJaxypL:bcW1ujPdX64WlxeEm9SpuJ5H2KY=",alt:t("channel.feishu"),className:"w-8 h-8 rounded-md flex-shrink-0",onError:l=>{l.target.style.display="none"}}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("div",{className:"text-sm font-semibold text-[#3370FF]",children:t("channel.feishu")}),e.jsx("div",{className:"text-[11px] text-muted mt-0.5",children:re.feishu==="installing"?t("quickSkill.pluginInstalling"):re.feishu!=="installed"?t("quickSkill.clickToInstall"):D!=null&&D.im.feishu?`โœ“ ${t("quickSkill.bound")}`:t("quickSkill.scanToBind")})]}),re.feishu==="installing"&&e.jsx("div",{className:"w-4 h-4 border-2 border-[#3370FF]/30 border-t-[#3370FF] rounded-full animate-spin flex-shrink-0"}),re.feishu==="installed"&&(D==null?void 0:D.im.feishu)&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-emerald-500/15 text-emerald-400 font-medium flex-shrink-0",children:t("quickSkill.bound")})]}),re.feishu==="installed"&&(D==null?void 0:D.im.feishu)&&e.jsxs("div",{className:"mx-1 mb-1 rounded-lg border border-[#3370FF]/20 bg-[#3370FF]/5 px-3 py-2 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[11px] font-semibold text-[#3370FF]",children:t("pairing.title")}),e.jsxs("button",{disabled:yt,onClick:async()=>{if(r){Nt(!0),Ue(null);try{const l=await Jt(r);jt(l.output??"")}catch{Ue(t("pairing.fetchFail"))}finally{Nt(!1)}}},className:"flex items-center gap-1 text-[10px] px-2 py-0.5 rounded bg-[#3370FF]/10 text-[#3370FF] hover:bg-[#3370FF]/20 disabled:opacity-40 transition-colors",children:[yt?e.jsx("div",{className:"w-3 h-3 border border-[#3370FF]/40 border-t-[#3370FF] rounded-full animate-spin"}):e.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),t("pairing.refresh")]})]}),Ft&&e.jsx("div",{className:"text-[10px] text-red-400",children:Ft}),et!==null&&(()=>{const l=Array.from(new Set(et.match(/[A-Z0-9]{4,16}/g)??[])).slice(0,1);return l.length===0?e.jsx("div",{className:"text-[10px] text-muted",children:et.split(`
11
+ `).find(u=>u.trim())||t("pairing.noPending")}):e.jsx("div",{className:"flex flex-wrap gap-1.5",children:l.map(u=>e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("span",{className:"font-mono text-[11px] px-1.5 py-0.5 rounded bg-[var(--bg)] border border-[var(--border)] text-foreground",children:u}),e.jsx("button",{disabled:!!kt,onClick:async()=>{if(r){Ct(u),Ue(null);try{await Bs(r,"feishu",u),x(t("pairing.approveOk",{code:u}),"success");const p=await Jt(r);jt(p.output??"")}catch(p){Ue((p==null?void 0:p.message)||t("pairing.approveFail"))}finally{Ct(null)}}},className:"text-[10px] px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20 disabled:opacity-40 transition-colors",children:t(kt===u?"pairing.approving":"pairing.approve")})]},u))})})()]}),e.jsxs("button",{onClick:()=>Be("openclaw-weixin"),className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-[#07C160]/30 bg-[#07C160]/5 hover:bg-[#07C160]/10 transition-all duration-150",children:[e.jsx("img",{src:"https://sgnewres.wechat.com/t/ofs-wechat/newsroom-web/res/_next/static/media/wechat-with-color.7a890de8.svg",alt:t("channel.weixin"),className:"w-8 h-8 rounded-md flex-shrink-0",onError:l=>{l.target.style.display="none"}}),e.jsxs("div",{className:"text-left flex-1",children:[e.jsx("div",{className:"text-sm font-semibold text-[#07C160]",children:t("channel.weixin")}),e.jsx("div",{className:"text-[11px] text-muted mt-0.5",children:re["openclaw-weixin"]==="installing"?t("quickSkill.pluginInstalling"):re["openclaw-weixin"]!=="installed"?t("quickSkill.clickToInstall"):D!=null&&D.im.weixin?`โœ“ ${t("quickSkill.bound")}`:t("quickSkill.scanToBind")})]}),re["openclaw-weixin"]==="installing"&&e.jsx("div",{className:"w-4 h-4 border-2 border-[#07C160]/30 border-t-[#07C160] rounded-full animate-spin flex-shrink-0"}),re["openclaw-weixin"]==="installed"&&(D==null?void 0:D.im.weixin)&&e.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-emerald-500/15 text-emerald-400 font-medium flex-shrink-0",children:t("quickSkill.bound")})]}),e.jsxs("button",{onClick:()=>{z(!1),be("config"),wt(!0)},className:"w-full flex items-center justify-center gap-1.5 px-4 py-2 rounded-lg text-[11px] text-muted hover:text-foreground hover:bg-[var(--card-hover)] border border-dashed border-[var(--border)] transition-all duration-150",children:[e.jsx("span",{children:t("quickSkill.moreImConfig")}),e.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2.5,children:e.jsx("path",{d:"M9 18l6-6-6-6"})})]})]}),se==="skills"&&e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"px-3 py-2 border-b border-[var(--border)]/60 flex gap-1.5 flex-shrink-0",children:[e.jsx("input",{type:"text",value:Se,onChange:l=>Qe(l.target.value),onKeyDown:l=>{l.key==="Enter"&&Se.trim()&&(z(!1),ke(`ๅฎ‰่ฃ… ${Se.trim()}`,!0),Qe(""))},placeholder:t("quickSkill.customSkillPlaceholder"),className:"flex-1 min-w-0 text-[11px] bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1 text-foreground placeholder:text-muted outline-none focus:border-[#0066FF]/60"}),e.jsx("button",{disabled:!Se.trim(),onClick:()=>{Se.trim()&&(z(!1),ke(`ๅฎ‰่ฃ… ${Se.trim()}`,!0),Qe(""))},className:"flex-shrink-0 text-[11px] px-2 py-1 rounded bg-[#0066FF]/10 text-[#0066FF] hover:bg-[#0066FF]/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:t("quickSkill.install")})]}),e.jsxs("div",{className:"flex",style:{height:"380px"},children:[e.jsxs("div",{className:"flex flex-col border-r border-[var(--border)]/60 bg-[var(--card)] flex-shrink-0",style:{width:"72px"},children:[ze.groups.map(l=>e.jsxs("button",{onMouseEnter:u=>{u.stopPropagation(),$e(l.id)},onClick:u=>{u.stopPropagation(),$e(l.id)},className:`flex flex-col items-center justify-center gap-0.5 py-3 px-1 text-center transition-colors border-l-2 flex-shrink-0 ${Ie===l.id?"border-[#0066FF] bg-[#0066FF]/5 text-foreground":"border-transparent text-muted hover:text-foreground hover:bg-[var(--card-hover)]"}`,children:[e.jsx("span",{className:"text-base leading-none",children:l.emoji}),e.jsx("span",{className:"text-[9px] font-medium leading-tight mt-0.5 whitespace-pre-wrap break-all",children:t(`data:skills.group.${l.id}`,{defaultValue:l.label})})]},l.id)),e.jsxs("button",{onMouseEnter:l=>{l.stopPropagation(),$e("installed")},onClick:l=>{l.stopPropagation(),$e("installed")},className:`flex flex-col items-center justify-center gap-0.5 py-3 px-1 text-center transition-colors border-l-2 flex-shrink-0 ${Ie==="installed"?"border-[#0066FF] bg-[#0066FF]/5 text-foreground":"border-transparent text-muted hover:text-foreground hover:bg-[var(--card-hover)]"}`,children:[e.jsx("span",{className:"text-base leading-none",children:"๐Ÿ“ฆ"}),e.jsx("span",{className:"text-[9px] font-medium leading-tight mt-0.5 whitespace-pre-wrap break-all",children:t("quickSkill.allInstalled")})]})]}),e.jsxs("div",{className:"flex-1 min-w-0 overflow-y-auto",children:[Ie==="installed"&&(()=>{if(D===null)return e.jsx("div",{className:"px-3 py-6 text-center text-[11px] text-muted",children:t("quickSkill.loading")});const l=D.installedSkillDirs??[],u={};return ze.groups.forEach(p=>{p.skills.forEach(v=>{var I;(I=v.checkDirs)==null||I.forEach(k=>{u[k.toLowerCase()]=p.label})})}),l.length===0?e.jsx("div",{className:"px-3 py-6 text-center text-[11px] text-muted",children:t("quickSkill.noInstalled")}):e.jsx(e.Fragment,{children:l.map(p=>{const v=u[p.toLowerCase()];return e.jsxs("div",{className:"w-full px-3 py-2 flex items-center gap-2 border-b border-[var(--border)]/30",children:[e.jsxs("button",{className:"flex-1 min-w-0 text-left",onClick:()=>{z(!1),ke(`/skill ${p} `,!1)},children:[e.jsx("div",{className:"text-xs font-semibold text-foreground font-mono truncate",children:p}),v&&e.jsx("div",{className:"text-[10px] text-muted mt-0.5",children:v})]}),e.jsx("span",{className:"flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded-full font-medium bg-emerald-500/15 text-emerald-400",children:t("quickSkill.installed")}),e.jsx("button",{onClick:async()=>{if(!(!r||!window.confirm(t("delete.skillConfirm",{name:p}))))try{await Vt(r,p);const I=await Te(r);je(I)}catch(I){x(I.message||t("common:error.deleteFailed"),"error")}},className:"flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded-full font-medium bg-red-500/10 text-red-400 hover:bg-red-500/20 transition-colors",children:t("common:action.delete")})]},p)})})})(),Ie!=="installed"&&(()=>{const l=ze.groups.find(v=>v.id===Ie),u=(l==null?void 0:l.skills)??[];if(u.length===0)return e.jsx("div",{className:"px-3 py-6 text-center text-[11px] text-muted",children:t("quickSkill.noSkills")});const p=((D==null?void 0:D.installedSkillDirs)??[]).map(v=>v.toLowerCase());return e.jsx(e.Fragment,{children:u.map(v=>{var A;if(v.type==="hub")return e.jsxs("div",{className:"w-full px-3 py-2 flex items-center gap-2 border-b border-[var(--border)]/30",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold text-foreground break-words",children:t(`data:skills.${v.id}.label`,{defaultValue:v.label})}),e.jsx("div",{className:"text-[10px] text-muted leading-tight mt-0.5 break-words",children:t(`data:skills.${v.id}.desc`,{defaultValue:v.desc})}),e.jsx("div",{className:"text-[9px] text-muted/60 leading-tight mt-0.5 break-all",children:v.url})]}),e.jsx("a",{href:v.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),title:"ๅœจๆ–ฐๆ ‡็ญพ้กตๆ‰“ๅผ€",className:"flex-shrink-0 text-[11px] px-1.5 py-0.5 rounded-full font-medium bg-[var(--border)] text-muted hover:bg-[#0066FF]/15 hover:text-[#0066FF] transition-colors no-underline",children:"๐Ÿ”—"})]},v.id);const I=D!==null&&v.checkDirs.some(_=>p.includes(_.toLowerCase())),k=ws[v.id]??!1,M=((A=D==null?void 0:D.installedSkillDirs)==null?void 0:A.find(_=>v.checkDirs.some(Z=>Z.toLowerCase()===_.toLowerCase())))??v.id;return e.jsxs("button",{disabled:k,onClick:()=>{if(z(!1),I)ke(`/skill ${M} `,!1);else{Ve(de=>({...de,[v.id]:!0})),ke(v.installMsg,v.autoInstall!==!1);let _=0;const Z=setInterval(async()=>{_+=5e3;try{const de=await Te(r);je(de);const ot=((de==null?void 0:de.installedSkillDirs)??[]).map(ve=>ve.toLowerCase());v.checkDirs.some(ve=>ot.includes(ve.toLowerCase()))&&(clearInterval(Z),Ve(ve=>({...ve,[v.id]:!1})))}catch{}_>=6e4&&(clearInterval(Z),Ve(de=>({...de,[v.id]:!1})))},5e3)}},className:"w-full text-left px-3 py-2 hover:bg-[var(--card-hover)] transition-colors flex items-center gap-2 disabled:opacity-60 border-b border-[var(--border)]/30",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold text-foreground break-words",children:t(`data:skills.${v.id}.label`,{defaultValue:v.label})}),e.jsx("div",{className:"text-[10px] text-muted leading-tight mt-0.5 break-words",children:t(`data:skills.${v.id}.desc`,{defaultValue:v.desc})})]}),e.jsx("span",{className:`flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded-full font-medium ${k?"bg-amber-500/15 text-amber-400":D===null?"bg-[var(--border)] text-muted":I?"bg-emerald-500/15 text-emerald-400":"bg-[#0066FF]/10 text-[#0066FF]"}`,children:k?t("quickSkill.installing"):D===null?"โ€ฆ":t(I?"quickSkill.installed":"quickSkill.install")}),I&&!k&&e.jsx("button",{onClick:async _=>{if(_.stopPropagation(),!(!r||!window.confirm(t("delete.skillConfirm",{name:M}))))try{await Vt(r,M);const Z=await Te(r);je(Z)}catch(Z){x(Z.message||t("common:error.deleteFailed"),"error")}},className:"flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded-full font-medium bg-red-500/10 text-red-400 hover:bg-red-500/20 transition-colors",children:t("common:action.delete")})]},v.id)})})})()]})]})]}),se==="mcp"&&e.jsxs("div",{className:"py-1",children:[(()=>{const l=!!(D!=null&&D.mcporterInstalled||Ne.installed),u=D===null&&Ne.loading;return e.jsxs("button",{onClick:()=>{l||(z(!1),ke("ๅฎ‰่ฃ… https://clawhub.ai/steipete/mcporter",!0))},className:"w-full text-left px-3 py-2.5 hover:bg-[var(--card-hover)] transition-colors flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold text-foreground",children:"MCPorter"}),e.jsx("div",{className:"text-[11px] text-muted leading-tight mt-0.5",children:t("quickSkill.mcporterDesc")})]}),e.jsx("span",{className:`flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded-full font-medium ${u?"bg-[var(--border)] text-muted":l?"bg-emerald-500/15 text-emerald-400":"bg-[#0066FF]/10 text-[#0066FF]"}`,children:u?"โ€ฆ":t(l?"quickSkill.installed":"quickSkill.install")})]})})(),e.jsxs("div",{className:"px-3 py-2 border-t border-[var(--border)]/40",children:[e.jsx("div",{className:"text-[10px] text-muted mb-1.5",children:t("quickSkill.mcpJsonLabel")}),e.jsx("textarea",{rows:3,value:Ge,onChange:l=>{ht(l.target.value),ye("")},placeholder:`{
12
+ "serverName": { "command": "npx", "args": [...] }
13
+ }`,className:"w-full text-[11px] font-mono bg-[var(--bg)] border border-[var(--border)] rounded px-2 py-1.5 text-foreground placeholder:text-muted/50 outline-none focus:border-[#0066FF]/60 resize-none"}),xt&&e.jsx("div",{className:"text-[10px] text-red-400 mt-1",children:xt}),e.jsx("button",{disabled:!Ge.trim()||!r,onClick:async()=>{let l;try{const u=JSON.parse(Ge.trim());if(typeof u!="object"||Array.isArray(u)||u===null)throw new Error("not-object");if(u.mcpServers&&typeof u.mcpServers=="object"&&!Array.isArray(u.mcpServers)?l=u.mcpServers:u.servers&&typeof u.servers=="object"&&!Array.isArray(u.servers)?l=u.servers:l=u,Object.keys(l).length===0)throw new Error("empty");for(const[p,v]of Object.entries(l)){if(typeof v!="object"||Array.isArray(v)||v===null)throw new Error(t("quickSkill.mcpJsonValueNotObject",{name:p}));const I=v;if(!I.command&&!I.baseUrl&&!I.url)throw new Error(t("quickSkill.mcpJsonMissingField",{name:p}))}}catch(u){const p=u==null?void 0:u.message;p==="not-object"?ye(t("quickSkill.mcpJsonNotObject")):p==="empty"?ye(t("quickSkill.mcpJsonEmpty")):p!=null&&p.startsWith('"')?ye(p):ye(t("quickSkill.mcpJsonParseFailed",{error:p||""}));return}try{const u=await Qt(r,l);ht(""),ye(""),x(t("quickSkill.mcpWritten"),"success"),je(p=>p&&{...p,mcporterServers:u.mcpServers}),ie(p=>({...p,loading:!0})),ct(r).then(p=>ie({servers:p.servers,installed:p.installed,loading:!1})).catch(()=>ie(p=>({...p,loading:!1})))}catch(u){ye(u.message||t("quickSkill.mcpWriteFailed"))}},className:"mt-1.5 w-full text-[11px] px-2 py-1 rounded bg-[#0066FF]/10 text-[#0066FF] hover:bg-[#0066FF]/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:t("quickSkill.addToConfig")})]}),(((Ot=We.find(l=>l.id==="mcp"))==null?void 0:Ot.items)??[]).map(l=>{const u=Object.keys((D==null?void 0:D.mcporterServers)??{}),p=Ne.servers.map(k=>k.name),v=l.mcpJson?Object.keys(l.mcpJson):[],I=v.length>0&&v.some(k=>u.includes(k)||p.includes(k));return e.jsxs("button",{onClick:async()=>{if(l.mcpJson&&r)try{const k=await Qt(r,l.mcpJson);x(t("quickSkill.mcpAdded",{label:l.label}),"success"),je(M=>M&&{...M,mcporterServers:k.mcpServers}),ie(M=>({...M,loading:!0})),ct(r).then(M=>ie({servers:M.servers,installed:M.installed,loading:!1})).catch(()=>ie(M=>({...M,loading:!1})))}catch(k){x(k.message||t("quickSkill.mcpAddFailed"),"error")}else Be(l.id)},className:"w-full text-left px-3 py-2.5 hover:bg-[var(--card-hover)] transition-colors border-t border-[var(--border)]/40 flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold text-foreground",children:t(`data:mcp.${l.id}.label`,{defaultValue:l.label})}),e.jsx("div",{className:"text-[11px] text-muted leading-tight mt-0.5",children:t(`data:mcp.${l.id}.desc`,{defaultValue:l.desc})})]}),l.mcpJson&&e.jsx("span",{className:`flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded-full font-medium ${I?"bg-emerald-500/15 text-emerald-400":"bg-[#0066FF]/10 text-[#0066FF]"}`,children:t(I?"quickSkill.configured":"quickSkill.oneClickConfig")})]},l.id)}),(()=>{var I;const l=(D==null?void 0:D.mcporterServers)??{},u=new Set((((I=We.find(k=>k.id==="mcp"))==null?void 0:I.items)??[]).flatMap(k=>k.mcpJson?Object.keys(k.mcpJson):[])),p=Object.keys(l).filter(k=>!u.has(k));if(p.length===0)return null;const v={};for(const k of Ne.servers)v[k.name]=k;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-3 pt-2 pb-0.5 text-[9px] font-semibold text-muted/60 uppercase tracking-widest border-t border-[var(--border)]/40 mt-1",children:t("quickSkill.mcporterConfigured")}),p.map(k=>{var ve;const M=l[k],A=v[k],_=(A==null?void 0:A.transport)??(M!=null&&M.baseUrl?`HTTP ${M.baseUrl}`:M!=null&&M.command?`${M.command} ${(M.args??[]).join(" ")}`.trim():""),Z=(A==null?void 0:A.status)==="ok",de=A?Z?"bg-emerald-500/15 text-emerald-400":"bg-red-500/15 text-red-400":(Ne.loading,"bg-[var(--border)] text-muted"),ot=Ne.loading&&!A?t("quickSkill.detecting"):A?Z?(ve=A.tools)!=null&&ve.length?t("quickSkill.statusNormalWithTools",{count:A.tools.length}):t("quickSkill.statusNormal"):A.status:t("quickSkill.configured");return e.jsxs("div",{className:"w-full px-3 py-2 flex items-center gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold text-foreground font-mono",children:k}),_&&e.jsx("div",{className:"text-[11px] text-muted leading-tight mt-0.5 truncate",children:_})]}),e.jsxs("span",{className:`flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded-full font-medium ${de} flex items-center gap-1`,children:[Ne.loading&&!A&&e.jsx("span",{className:"w-2 h-2 border border-muted/40 border-t-muted rounded-full animate-spin"}),ot]}),e.jsx("button",{onClick:async()=>{if(!(!r||!window.confirm(t("delete.mcpConfirm",{name:k}))))try{await Hs(r,k);const it=await Te(r);je(it),ie(Bt=>({...Bt,servers:Bt.servers.filter(Es=>Es.name!==k)}))}catch(it){x(it.message||t("common:error.deleteFailed"),"error")}},className:"flex-shrink-0 text-[10px] px-1.5 py-0.5 rounded-full font-medium bg-red-500/10 text-red-400 hover:bg-red-500/20 transition-colors",children:t("common:action.delete")})]},k)})]})})()]}),se==="slash"&&e.jsx("div",{className:"py-1",children:((($t=We.find(l=>l.id==="slash"))==null?void 0:$t.groups)??[]).map((l,u)=>e.jsxs("div",{children:[u>0&&e.jsx("div",{className:"border-t border-[var(--border)]/40 mx-3 my-0.5"}),e.jsx("div",{className:"px-3 pt-1.5 pb-0.5 text-[9px] font-semibold text-muted/60 uppercase tracking-widest",children:t(`data:slash.group.${l.label}`,{defaultValue:l.label})}),l.items.map(p=>e.jsxs("button",{onClick:()=>Be(p.id),className:"w-full text-left px-3 py-1 hover:bg-[var(--card-hover)] transition-colors",children:[e.jsx("div",{className:"text-xs font-medium text-foreground font-mono",children:p.label}),e.jsx("div",{className:"text-[11px] text-muted leading-tight",children:t(`data:slash.${p.id}.desc`,{defaultValue:p.desc})})]},p.id))]},l.label))})]})]})]})]}),Re||Ee?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>qe("restart"),disabled:!!G||Ee,className:"px-3 py-1.5 bg-[#0066FF] text-white rounded-md text-xs font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:t(G==="restart"?"action.restarting":"common:action.restart")}),e.jsx("button",{onClick:()=>qe("stop"),disabled:!!G,className:"px-3 py-1.5 bg-red-600 text-white rounded-md text-xs font-medium hover:bg-red-700 disabled:opacity-40 transition-all duration-200",children:t(G==="stop"?"action.stopping":"common:action.stop")})]}):e.jsx("button",{onClick:()=>qe("start"),disabled:!!G,className:"px-3 py-1.5 bg-[#0066FF] text-white rounded-md text-xs font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:t(G==="start"?"action.starting":"common:action.start")}),e.jsxs("div",{className:"relative",children:[e.jsx("button",{onClick:()=>te(!H),className:"p-1.5 border border-[var(--border)] rounded-md text-muted hover:text-foreground hover:bg-[var(--card-hover)] transition-all duration-150",children:e.jsx(zs,{className:"w-4 h-4"})}),H&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"fixed inset-0 z-10",onClick:()=>te(!1)}),e.jsxs("div",{className:"absolute right-0 top-full mt-1 w-40 bg-background border border-[var(--border)] rounded-lg shadow-2xl py-1 z-20",children:[e.jsx("button",{onClick:()=>{te(!1),be("logs")},className:"w-full text-left px-3 py-2 text-sm text-foreground hover:bg-[var(--card-hover)] transition-colors",children:t("tab.logs")}),e.jsx("button",{onClick:()=>{te(!1),be("usage")},className:"w-full text-left px-3 py-2 text-sm text-foreground hover:bg-[var(--card-hover)] transition-colors",children:t("tab.usage")}),e.jsx("div",{className:"border-t border-[var(--border)] my-1"}),e.jsx("button",{onClick:()=>{te(!1),b(!0)},className:"w-full text-left px-3 py-2 text-sm text-red-400 hover:bg-red-500/10 transition-colors",children:t("delete.title")})]})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted mb-3",children:[e.jsx("button",{onClick:()=>o("/"),className:"hover:text-foreground transition-colors",children:t("backToOverview")}),e.jsx("span",{className:"opacity-40",children:"ยท"}),e.jsxs("span",{children:["๐Ÿ“Š ",((Ut=f.service)==null?void 0:Ut.memory_mb)!=null?`${f.service.memory_mb} MB`:"-"]}),e.jsx("span",{className:"opacity-40",children:"ยท"}),e.jsxs("span",{children:["โฑ ",Ur((_t=f.service)==null?void 0:_t.uptime,t)]}),e.jsx("span",{className:"opacity-40",children:"ยท"}),e.jsxs("span",{children:["๐Ÿ”Œ ",t("port",{port:qr(f)})]})]}),lt&&e.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 text-red-400 text-sm rounded-lg px-4 py-3 flex items-center justify-between mb-3",children:[e.jsx("span",{children:t("failedHint")}),e.jsx("button",{onClick:()=>be("logs"),className:"text-red-400 underline text-sm font-medium",children:t("viewLogs")})]}),y!=="chat"&&e.jsx("button",{onClick:()=>be("chat"),className:"flex items-center gap-1 text-xs text-[#0066FF] hover:text-[#0066FF]/80 mb-3 transition-colors",children:t("backToChat")}),y==="chat"&&e.jsx(Dr,{gatewayLaunchUrl:B,gatewayReady:ee,isRunning:Le,isPending:Ee,iframeLoaded:X,actionLoading:G,onAction:qe,onReload:()=>{Y(!1),ne(!1)},onIframeLoad:()=>ne(!0)}),y==="config"&&a&&e.jsxs("div",{className:"space-y-4",children:[d&&e.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 text-amber-400 text-sm rounded-lg px-4 py-2.5 flex items-center justify-between",children:[e.jsx("span",{children:t("config.modified")}),e.jsx("button",{onClick:()=>{s(null),Wt(r).then(l=>{s(l),L(JSON.stringify(l,null,2)),h(!1)})},className:"text-xs text-amber-400 hover:underline",children:t("config.discard")})]}),N&&e.jsx("div",{className:"bg-red-500/10 border border-red-500/20 text-red-400 text-sm rounded-lg px-4 py-2.5",children:N}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>j(!1),className:`px-3 py-1.5 text-xs rounded-md transition-colors duration-150 ${C?"text-muted hover:bg-[var(--card-hover)]":"bg-[#0066FF] text-white"}`,children:t("config.form")}),e.jsx("button",{onClick:()=>{L(ks(a)),j(!0)},className:`px-3 py-1.5 text-xs rounded-md transition-colors duration-150 ${C?"bg-[#0066FF] text-white":"text-muted hover:bg-[var(--card-hover)]"}`,children:t("config.json")})]}),C?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"bg-[#0066FF]/10 border border-[#0066FF]/20 rounded-lg px-3 py-2 text-xs text-[#0066FF]/80 space-y-1",children:[e.jsx("div",{className:"font-medium text-[#0066FF]/90",children:t("config.jsonHelp")}),e.jsxs("ul",{className:"list-disc list-inside space-y-0.5",children:[e.jsx("li",{dangerouslySetInnerHTML:{__html:t("config.jsonHelp1")}}),e.jsx("li",{dangerouslySetInnerHTML:{__html:t("config.jsonHelp2")}}),e.jsx("li",{dangerouslySetInnerHTML:{__html:t("config.jsonHelp3")}})]})]}),e.jsxs("div",{className:"bg-[var(--card)] border border-[var(--border)] rounded-xl overflow-hidden",children:[e.jsx("div",{className:"border-b border-[var(--border)] px-4 py-2 flex items-center justify-between",children:e.jsx("span",{className:"text-xs font-medium text-muted",children:"openclaw.json"})}),e.jsx("textarea",{value:$,onChange:l=>Ns(l.target.value),className:"w-full font-mono text-[13px] p-4 min-h-[400px] lg:min-h-[500px] focus:outline-none resize-y text-foreground bg-transparent",spellCheck:!1})]})]}):e.jsx(xr,{config:a,onChange:ys,instanceId:r,isRunning:Le,pluginStatuses:re,onInstallPlugin:It}),e.jsxs("div",{className:"flex gap-2 sticky bottom-0 backdrop-blur-sm py-3 -mx-6 px-6 border-t border-[var(--border)] mt-4",style:{background:"color-mix(in srgb, var(--background) 85%, transparent)"},children:[e.jsx("button",{onClick:()=>Lt(!1),disabled:!d||oe,className:"px-4 py-2 border border-[var(--border)] text-muted rounded-md text-sm font-medium hover:bg-[var(--card-hover)] hover:text-foreground disabled:opacity-40 transition-all duration-200",children:t(oe?"config.saving":"config.save")}),e.jsx("button",{onClick:()=>Lt(!0),disabled:oe,className:"px-4 py-2 bg-[#0066FF] text-white rounded-md text-sm font-medium hover:bg-[#0066FF]/90 disabled:opacity-40 transition-all duration-200",children:t(oe?"config.processing":"config.saveAndRestart")})]})]}),y==="logs"&&e.jsx(Or,{logs:S,logSearch:q,logType:O,logsEndRef:Xe,onSearchChange:J,onLogTypeChange:T,onRefresh:at,onCopy:()=>{const l=q?S.filter(u=>u.toLowerCase().includes(q.toLowerCase())):S;navigator.clipboard.writeText(l.join(`
14
+ `)).then(()=>x(t("logs.copied"),"success")).catch(()=>x(t("logs.copyFailed"),"error"))}}),y==="usage"&&e.jsx($r,{usage:xe,onRefresh:()=>Kt(r).then(fe).catch(()=>{})}),V&&e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",onClick:()=>{ce.current=!0,ue.current=!1,ae(null)},children:e.jsxs("div",{className:"bg-background border border-[var(--border)] rounded-xl p-6 w-full max-w-xs shadow-2xl",onClick:l=>l.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:t(V.type==="feishu"?"qr.feishuTitle":"qr.weixinTitle")}),e.jsx("button",{onClick:()=>{ce.current=!0,ue.current=!1,ae(null)},className:"text-muted hover:text-foreground transition-colors text-lg leading-none",children:"โœ•"})]}),e.jsx("div",{className:"flex flex-col items-center gap-3",children:V.status==="confirmed"?e.jsxs("div",{className:"bg-emerald-500/10 border border-emerald-500/20 rounded-md px-4 py-5 text-center w-full",children:[e.jsx("div",{className:"text-3xl mb-2",children:"โœ“"}),e.jsx("div",{className:"text-emerald-400 font-medium text-sm",children:V.message}),e.jsx("p",{className:"text-xs text-muted mt-1",children:t("qr.credSaved")})]}):V.status==="loading"?e.jsx("div",{className:"w-48 h-48 flex items-center justify-center",children:e.jsx("div",{className:`w-8 h-8 border-2 rounded-full animate-spin ${V.type==="feishu"?"border-[#3370FF]/30 border-t-[#3370FF]":"border-[#07C160]/30 border-t-[#07C160]"}`})}):V.status==="error"?e.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-md px-4 py-4 text-center w-full",children:[e.jsx("div",{className:"text-red-400 text-sm",children:V.message}),e.jsx("button",{onClick:l=>{l.stopPropagation(),Pt(V.type)},className:`mt-3 px-4 py-1.5 text-white rounded-md text-xs font-medium transition-colors ${V.type==="feishu"?"bg-[#3370FF] hover:bg-[#3370FF]/90":"bg-[#07C160] hover:bg-[#07C160]/90"}`,children:t("qr.retry")})]}):e.jsxs(e.Fragment,{children:[V.qrUrl?e.jsx(Je,{value:V.qrUrl,size:192,className:"rounded-lg"}):e.jsx("div",{className:"w-48 h-48 flex items-center justify-center",children:e.jsx("div",{className:`w-8 h-8 border-2 rounded-full animate-spin ${V.type==="feishu"?"border-[#3370FF]/30 border-t-[#3370FF]":"border-[#07C160]/30 border-t-[#07C160]"}`})}),e.jsx("div",{className:"flex items-center gap-2 text-sm",children:V.status==="scaned"?e.jsxs("span",{className:`font-medium ${V.type==="weixin"?"text-[#07C160]":"text-[#3370FF]"}`,children:["๐Ÿ‘€ ",V.message]}):e.jsx("span",{className:"text-muted",children:V.message})})]})}),V.status==="confirmed"&&e.jsx("button",{onClick:()=>{ce.current=!0,ue.current=!1,ae(null)},className:"mt-4 w-full py-2 bg-[#0066FF] text-white rounded-md text-sm font-medium hover:bg-[#0066FF]/90 transition-colors",children:t("common:action.close")})]})}),c&&e.jsx("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center z-50 p-4",onClick:()=>b(!1),children:e.jsxs("div",{className:"bg-background border border-[var(--border)] rounded-xl p-6 w-full max-w-sm shadow-2xl",onClick:l=>l.stopPropagation(),children:[e.jsx("h3",{className:"text-base font-semibold text-foreground mb-2",children:t("delete.title")}),e.jsxs("p",{className:"text-sm text-muted mb-4",children:[t("delete.warningBefore"),e.jsx("strong",{className:"text-foreground",children:f.name}),t("delete.warningAfter")]}),e.jsx("p",{className:"text-sm text-muted mb-3",children:t("delete.confirmHint")}),e.jsx("input",{type:"text",value:E,onChange:l=>U(l.target.value),className:"w-full bg-[var(--input-bg)] border border-[var(--border)] rounded-md px-3 py-2 text-sm text-foreground mb-4 focus:outline-none focus:ring-1 focus:ring-red-500/60 focus:border-red-500/60 transition-colors",placeholder:f.name}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{b(!1),U("")},className:"flex-1 py-2 border border-[var(--border)] text-muted rounded-md text-sm font-medium hover:bg-[var(--card-hover)] hover:text-foreground transition-all duration-150",children:t("common:action.cancel")}),e.jsx("button",{onClick:Cs,disabled:E.trim()!==((qt=f.name)==null?void 0:qt.trim()),className:"flex-1 py-2 bg-red-600 text-white rounded-md text-sm font-medium hover:bg-red-700 disabled:opacity-40 transition-colors",children:t("delete.confirm")})]})]})})]})}export{Qr as default};