claude-codex-wechat 0.1.22 → 0.1.24

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.
@@ -3,7 +3,7 @@ import { createRequire as __cjsCreateRequire } from 'node:module'; const require
3
3
 
4
4
  // src/cli.ts
5
5
  import { existsSync as existsSync10, readFileSync as readFileSync9 } from "node:fs";
6
- import { dirname as dirname13, join as join13 } from "node:path";
6
+ import { dirname as dirname9, join as join14 } from "node:path";
7
7
  import { fileURLToPath as fileURLToPath2 } from "node:url";
8
8
 
9
9
  // src/daemon/bootstrap.ts
@@ -12,7 +12,7 @@ import { networkInterfaces } from "node:os";
12
12
  // src/daemon/server.ts
13
13
  import { mkdtempSync } from "node:fs";
14
14
  import { tmpdir as tmpdir2 } from "node:os";
15
- import { dirname as dirname10, join as join9 } from "node:path";
15
+ import { dirname as dirname7, join as join11 } from "node:path";
16
16
  import Fastify from "fastify";
17
17
 
18
18
  // src/channels/platforms.ts
@@ -151,10 +151,76 @@ function normalizeWechatConfig(raw, env) {
151
151
  }
152
152
 
153
153
  // src/daemon/configPersistence.ts
154
- import { mkdir, readFile, rm, writeFile } from "node:fs/promises";
154
+ import { readFile, rm } from "node:fs/promises";
155
+ import { randomBytes as randomBytes2 } from "node:crypto";
156
+ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
157
+
158
+ // src/shared/atomicFile.ts
159
+ import { mkdirSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
160
+ import { mkdir, rename, unlink, writeFile } from "node:fs/promises";
155
161
  import { randomBytes } from "node:crypto";
156
- import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "node:fs";
157
- import { dirname } from "node:path";
162
+ import { basename, dirname, join as join2 } from "node:path";
163
+ function tempPathFor(path) {
164
+ return join2(dirname(path), `.${basename(path)}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`);
165
+ }
166
+ var RENAME_RETRY_CODES = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY"]);
167
+ var MAX_RENAME_RETRIES = 10;
168
+ function isRetriableRenameError(error) {
169
+ if (process.platform !== "win32") return false;
170
+ const code = error?.code ?? "";
171
+ return RENAME_RETRY_CODES.has(code);
172
+ }
173
+ function sleepSync(ms) {
174
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
175
+ }
176
+ function sleep(ms) {
177
+ return new Promise((resolve2) => {
178
+ setTimeout(resolve2, ms);
179
+ });
180
+ }
181
+ function writeFileAtomicSync(path, data) {
182
+ const tmp = tempPathFor(path);
183
+ mkdirSync(dirname(path), { recursive: true });
184
+ try {
185
+ writeFileSync(tmp, data, "utf8");
186
+ for (let attempt = 0; ; attempt++) {
187
+ try {
188
+ renameSync(tmp, path);
189
+ return;
190
+ } catch (error) {
191
+ if (attempt >= MAX_RENAME_RETRIES || !isRetriableRenameError(error)) throw error;
192
+ sleepSync((attempt + 1) * 10);
193
+ }
194
+ }
195
+ } catch (error) {
196
+ try {
197
+ unlinkSync(tmp);
198
+ } catch {
199
+ }
200
+ throw error;
201
+ }
202
+ }
203
+ async function writeFileAtomic(path, data) {
204
+ const tmp = tempPathFor(path);
205
+ await mkdir(dirname(path), { recursive: true });
206
+ try {
207
+ await writeFile(tmp, data, "utf8");
208
+ for (let attempt = 0; ; attempt++) {
209
+ try {
210
+ await rename(tmp, path);
211
+ return;
212
+ } catch (error) {
213
+ if (attempt >= MAX_RENAME_RETRIES || !isRetriableRenameError(error)) throw error;
214
+ await sleep((attempt + 1) * 10);
215
+ }
216
+ }
217
+ } catch (error) {
218
+ await unlink(tmp).catch(() => void 0);
219
+ throw error;
220
+ }
221
+ }
222
+
223
+ // src/daemon/configPersistence.ts
158
224
  async function persistWechatCredentialsToConfigFile(input) {
159
225
  const currentConfig = await readConfigFile(input.configPath);
160
226
  const nextConfig = {
@@ -167,9 +233,8 @@ async function persistWechatCredentialsToConfigFile(input) {
167
233
  accountId: input.accountId
168
234
  }
169
235
  };
170
- await mkdir(dirname(input.configPath), { recursive: true });
171
- await writeFile(input.configPath, `${JSON.stringify(nextConfig, null, 2)}
172
- `, "utf8");
236
+ await writeFileAtomic(input.configPath, `${JSON.stringify(nextConfig, null, 2)}
237
+ `);
173
238
  }
174
239
  async function deleteConfigFile(configPath) {
175
240
  try {
@@ -190,9 +255,8 @@ function persistUpdateStatusToConfigFile(input) {
190
255
  ...input.status.lastCheckedAt !== void 0 ? { lastCheckedAt: input.status.lastCheckedAt } : {}
191
256
  }
192
257
  };
193
- mkdirSync(dirname(input.configPath), { recursive: true });
194
- writeFileSync(input.configPath, `${JSON.stringify(nextConfig, null, 2)}
195
- `, "utf8");
258
+ writeFileAtomicSync(input.configPath, `${JSON.stringify(nextConfig, null, 2)}
259
+ `);
196
260
  }
197
261
  async function persistBridgeDefaultsToConfigFile(input) {
198
262
  const currentConfig = await readConfigFile(input.configPath);
@@ -215,9 +279,8 @@ async function persistBridgeDefaultsToConfigFile(input) {
215
279
  }
216
280
  } : {}
217
281
  };
218
- await mkdir(dirname(input.configPath), { recursive: true });
219
- await writeFile(input.configPath, `${JSON.stringify(nextConfig, null, 2)}
220
- `, "utf8");
282
+ await writeFileAtomic(input.configPath, `${JSON.stringify(nextConfig, null, 2)}
283
+ `);
221
284
  }
222
285
  function ensureRelayAuthTokenSync(input) {
223
286
  const currentConfig = readConfigFileSync(input.configPath);
@@ -225,7 +288,7 @@ function ensureRelayAuthTokenSync(input) {
225
288
  const currentRelay = isRecord(currentTunnel?.relay) ? currentTunnel.relay : void 0;
226
289
  const existing = typeof currentRelay?.authToken === "string" && currentRelay.authToken.trim() ? currentRelay.authToken.trim() : "";
227
290
  if (existing) return existing;
228
- const authToken = `clrt_${randomBytes(12).toString("hex")}`;
291
+ const authToken = `clrt_${randomBytes2(12).toString("hex")}`;
229
292
  const nextConfig = {
230
293
  ...currentConfig,
231
294
  tunnel: {
@@ -236,9 +299,8 @@ function ensureRelayAuthTokenSync(input) {
236
299
  }
237
300
  }
238
301
  };
239
- mkdirSync(dirname(input.configPath), { recursive: true });
240
- writeFileSync(input.configPath, `${JSON.stringify(nextConfig, null, 2)}
241
- `, "utf8");
302
+ writeFileAtomicSync(input.configPath, `${JSON.stringify(nextConfig, null, 2)}
303
+ `);
242
304
  return authToken;
243
305
  }
244
306
  async function persistProviderCommandsToConfigFile(input) {
@@ -248,9 +310,8 @@ async function persistProviderCommandsToConfigFile(input) {
248
310
  ...currentConfig,
249
311
  providers: normalizedProviders
250
312
  };
251
- await mkdir(dirname(input.configPath), { recursive: true });
252
- await writeFile(input.configPath, `${JSON.stringify(nextConfig, null, 2)}
253
- `, "utf8");
313
+ await writeFileAtomic(input.configPath, `${JSON.stringify(nextConfig, null, 2)}
314
+ `);
254
315
  }
255
316
  async function readConfigFile(path) {
256
317
  try {
@@ -290,8 +351,7 @@ function normalizeProvidersForPersistence(providers) {
290
351
  }
291
352
 
292
353
  // src/channels/weixin-direct/weixinStateStore.ts
293
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, writeFileSync as writeFileSync2 } from "node:fs";
294
- import { dirname as dirname2 } from "node:path";
354
+ import { existsSync as existsSync3, readFileSync as readFileSync3 } from "node:fs";
295
355
  var PUSH_QUOTA_LIMIT = 10;
296
356
  var PUSH_WINDOW_MS = 24 * 60 * 60 * 1e3;
297
357
  var FileWeixinStateStore = class {
@@ -397,16 +457,15 @@ var FileWeixinStateStore = class {
397
457
  ...state,
398
458
  bridge: { ...state.bridge ?? {}, weixinChannel: channel }
399
459
  };
400
- mkdirSync2(dirname2(this.configPath), { recursive: true });
401
- writeFileSync2(this.configPath, `${JSON.stringify(next, null, 2)}
402
- `, "utf8");
460
+ writeFileAtomicSync(this.configPath, `${JSON.stringify(next, null, 2)}
461
+ `);
403
462
  }
404
463
  };
405
464
 
406
465
  // src/providers/claude-code/nativeSessions.ts
407
466
  import { appendFile, mkdir as mkdir2, readdir, readFile as readFile2, stat, writeFile as writeFile2 } from "node:fs/promises";
408
467
  import { homedir as homedir2 } from "node:os";
409
- import { basename, dirname as dirname3, join as join2 } from "node:path";
468
+ import { basename as basename2, dirname as dirname2, join as join3 } from "node:path";
410
469
 
411
470
  // src/session/sessionBridgeTag.ts
412
471
  function buildSessionBridgeName(input) {
@@ -433,27 +492,27 @@ function parseSessionBridgeName(value) {
433
492
 
434
493
  // src/providers/claude-code/nativeSessions.ts
435
494
  function resolveClaudeConfigDir(env = process.env) {
436
- return join2(env.HOME || homedir2(), ".claude");
495
+ return join3(env.HOME || homedir2(), ".claude");
437
496
  }
438
497
  async function listRecoverableClaudeSessions(env = process.env) {
439
- const projectsDir = join2(resolveClaudeConfigDir(env), "projects");
498
+ const projectsDir = join3(resolveClaudeConfigDir(env), "projects");
440
499
  const historyIndex = await readClaudeHistoryIndex(env);
441
500
  const candidates = [];
442
501
  try {
443
502
  const projectEntries = await readdir(projectsDir, { withFileTypes: true });
444
503
  for (const entry of projectEntries) {
445
504
  if (!entry.isDirectory() || entry.isSymbolicLink()) continue;
446
- const projectDir = join2(projectsDir, String(entry.name));
505
+ const projectDir = join3(projectsDir, String(entry.name));
447
506
  const sessionEntries = await readdir(projectDir, { withFileTypes: true }).catch(() => []);
448
507
  for (const sessionEntry of sessionEntries) {
449
508
  if (!sessionEntry.isFile() || sessionEntry.isSymbolicLink()) continue;
450
509
  const fileName = String(sessionEntry.name);
451
510
  if (!fileName.endsWith(".jsonl")) continue;
452
- const filePath = join2(projectDir, fileName);
511
+ const filePath = join3(projectDir, fileName);
453
512
  const metadata = await stat(filePath).catch(() => null);
454
513
  const parsedMeta = await readClaudeSessionMetadata(filePath).catch(() => null);
455
- const historyMeta = historyIndex.get(basename(fileName, ".jsonl"));
456
- const sessionId = basename(fileName, ".jsonl");
514
+ const historyMeta = historyIndex.get(basename2(fileName, ".jsonl"));
515
+ const sessionId = basename2(fileName, ".jsonl");
457
516
  const bridgeTag = historyMeta?.bridgeTag ?? parseSessionBridgeName(parsedMeta?.sessionName);
458
517
  const cwd = parsedMeta?.cwd ?? historyMeta?.project;
459
518
  candidates.push({
@@ -475,12 +534,12 @@ async function listRecoverableClaudeSessions(env = process.env) {
475
534
  async function findRecoverableClaudeSessionPath(sessionId, env = process.env) {
476
535
  const trimmed = sessionId.trim();
477
536
  if (!trimmed || trimmed.includes("/") || trimmed.includes("\\")) return null;
478
- const projectsDir = join2(resolveClaudeConfigDir(env), "projects");
537
+ const projectsDir = join3(resolveClaudeConfigDir(env), "projects");
479
538
  try {
480
539
  const projectEntries = await readdir(projectsDir, { withFileTypes: true });
481
540
  for (const entry of projectEntries) {
482
541
  if (!entry.isDirectory() || entry.isSymbolicLink()) continue;
483
- const sessionPath = join2(projectsDir, String(entry.name), `${trimmed}.jsonl`);
542
+ const sessionPath = join3(projectsDir, String(entry.name), `${trimmed}.jsonl`);
484
543
  try {
485
544
  const metadata = await stat(sessionPath);
486
545
  if (metadata.isFile()) return sessionPath;
@@ -528,7 +587,7 @@ async function hasClaudeSessionBridgeMetadata(input) {
528
587
  }
529
588
  async function hasClaudeHistoryDisplay(input) {
530
589
  const env = input.env ?? process.env;
531
- const historyPath = join2(resolveClaudeConfigDir(env), "history.jsonl");
590
+ const historyPath = join3(resolveClaudeConfigDir(env), "history.jsonl");
532
591
  try {
533
592
  const content = await readFile2(historyPath, "utf8");
534
593
  for (const line of content.split(/\r?\n/)) {
@@ -583,7 +642,7 @@ async function readClaudeSessionMetadata(filePath) {
583
642
  return { aiTitle, lastPrompt, sessionName, cwd };
584
643
  }
585
644
  async function readClaudeHistoryIndex(env) {
586
- const historyPath = join2(resolveClaudeConfigDir(env), "history.jsonl");
645
+ const historyPath = join3(resolveClaudeConfigDir(env), "history.jsonl");
587
646
  const index = /* @__PURE__ */ new Map();
588
647
  try {
589
648
  const content = await readFile2(historyPath, "utf8");
@@ -608,7 +667,7 @@ async function readClaudeHistoryIndex(env) {
608
667
  return index;
609
668
  }
610
669
  async function upsertClaudeHistoryDisplay(input) {
611
- const historyPath = join2(resolveClaudeConfigDir(input.env), "history.jsonl");
670
+ const historyPath = join3(resolveClaudeConfigDir(input.env), "history.jsonl");
612
671
  const lines = [];
613
672
  let replaced = false;
614
673
  let changed = false;
@@ -647,7 +706,7 @@ async function upsertClaudeHistoryDisplay(input) {
647
706
  }));
648
707
  }
649
708
  if (!changed) return false;
650
- await mkdir2(dirname3(historyPath), { recursive: true });
709
+ await mkdir2(dirname2(historyPath), { recursive: true });
651
710
  await writeFile2(historyPath, `${lines.join("\n")}
652
711
  `, "utf8");
653
712
  return true;
@@ -679,7 +738,7 @@ async function normalizeClaudeSessionFileForResume(sessionPath) {
679
738
  nextLines.push(line);
680
739
  }
681
740
  if (sawSdkCliEntrypoint && !hasPermissionMode) {
682
- const sessionId = basename(sessionPath, ".jsonl");
741
+ const sessionId = basename2(sessionPath, ".jsonl");
683
742
  nextLines.unshift(JSON.stringify({
684
743
  type: "permission-mode",
685
744
  permissionMode: "bypassPermissions",
@@ -698,16 +757,16 @@ import Database from "better-sqlite3";
698
757
  import { readdir as readdir2, readFile as readFile3, stat as stat2 } from "node:fs/promises";
699
758
  import { existsSync as existsSync4 } from "node:fs";
700
759
  import { homedir as homedir3 } from "node:os";
701
- import { basename as basename2, join as join3 } from "node:path";
760
+ import { basename as basename3, join as join4 } from "node:path";
702
761
  function resolveCodexSessionsRoot(env = process.env) {
703
- return join3(env.CODEX_HOME || join3(env.HOME || homedir3(), ".codex"), "sessions");
762
+ return join4(env.CODEX_HOME || join4(env.HOME || homedir3(), ".codex"), "sessions");
704
763
  }
705
764
  function isMatchingCodexRolloutFile(name) {
706
765
  return name.startsWith("rollout-") && name.endsWith(".jsonl");
707
766
  }
708
767
  function extractCodexSessionId(name) {
709
768
  if (!isMatchingCodexRolloutFile(name)) return null;
710
- const withoutExt = basename2(name, ".jsonl");
769
+ const withoutExt = basename3(name, ".jsonl");
711
770
  const match = withoutExt.match(/^rollout-\d{4}-\d{2}-\d{2}T\d{2}-\d{2}-\d{2}-(.+)$/);
712
771
  if (!match?.[1]) return null;
713
772
  return match[1];
@@ -723,7 +782,7 @@ async function listRecoverableCodexSessions(env = process.env) {
723
782
  for (const entry of entries) {
724
783
  if (entry.isSymbolicLink()) continue;
725
784
  const name = String(entry.name);
726
- const path = join3(currentDir, name);
785
+ const path = join4(currentDir, name);
727
786
  if (entry.isDirectory()) {
728
787
  await walk(path, depth + 1);
729
788
  continue;
@@ -759,7 +818,7 @@ async function findRecoverableCodexSessionPath(sessionId, env = process.env) {
759
818
  for (const entry of entries) {
760
819
  if (entry.isSymbolicLink()) continue;
761
820
  const name = String(entry.name);
762
- const path = join3(currentDir, name);
821
+ const path = join4(currentDir, name);
763
822
  if (entry.isDirectory()) {
764
823
  const found = await walk(path, depth + 1);
765
824
  if (found) return found;
@@ -773,7 +832,7 @@ async function findRecoverableCodexSessionPath(sessionId, env = process.env) {
773
832
  return await walk(root, 0);
774
833
  }
775
834
  async function readCodexSessionIndex(env) {
776
- const indexPath = join3(env.CODEX_HOME || join3(env.HOME || homedir3(), ".codex"), "session_index.jsonl");
835
+ const indexPath = join4(env.CODEX_HOME || join4(env.HOME || homedir3(), ".codex"), "session_index.jsonl");
777
836
  const index = /* @__PURE__ */ new Map();
778
837
  try {
779
838
  const content = await readFile3(indexPath, "utf8");
@@ -796,7 +855,7 @@ async function readCodexSessionIndex(env) {
796
855
  return index;
797
856
  }
798
857
  function readCodexThreadMetadata(env) {
799
- const dbPath = join3(env.CODEX_HOME || join3(env.HOME || homedir3(), ".codex"), "state_5.sqlite");
858
+ const dbPath = join4(env.CODEX_HOME || join4(env.HOME || homedir3(), ".codex"), "state_5.sqlite");
800
859
  const metadata = /* @__PURE__ */ new Map();
801
860
  if (!existsSync4(dbPath)) return metadata;
802
861
  let db = null;
@@ -857,9 +916,9 @@ import { nanoid } from "nanoid";
857
916
  // src/providers/codex/sessionIndex.ts
858
917
  import { mkdir as mkdir3, readFile as readFile4, writeFile as writeFile3 } from "node:fs/promises";
859
918
  import { homedir as homedir4 } from "node:os";
860
- import { dirname as dirname4, join as join4 } from "node:path";
919
+ import { dirname as dirname3, join as join5 } from "node:path";
861
920
  function resolveCodexIndexPath(env = process.env) {
862
- return join4(env.CODEX_HOME || join4(env.HOME || homedir4(), ".codex"), "session_index.jsonl");
921
+ return join5(env.CODEX_HOME || join5(env.HOME || homedir4(), ".codex"), "session_index.jsonl");
863
922
  }
864
923
  async function upsertCodexSessionIndexEntry(input, env = process.env) {
865
924
  const indexPath = resolveCodexIndexPath(env);
@@ -895,7 +954,7 @@ async function upsertCodexSessionIndexEntry(input, env = process.env) {
895
954
  updated_at: input.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString()
896
955
  }));
897
956
  }
898
- await mkdir3(dirname4(indexPath), { recursive: true });
957
+ await mkdir3(dirname3(indexPath), { recursive: true });
899
958
  await writeFile3(indexPath, `${lines.join("\n")}
900
959
  `, "utf8");
901
960
  }
@@ -905,9 +964,9 @@ import Database2 from "better-sqlite3";
905
964
  import { existsSync as existsSync5 } from "node:fs";
906
965
  import { readFile as readFile5, writeFile as writeFile4 } from "node:fs/promises";
907
966
  import { homedir as homedir5 } from "node:os";
908
- import { join as join5 } from "node:path";
967
+ import { join as join6 } from "node:path";
909
968
  function resolveCodexStateDbPath(env = process.env) {
910
- return join5(env.CODEX_HOME || join5(env.HOME || homedir5(), ".codex"), "state_5.sqlite");
969
+ return join6(env.CODEX_HOME || join6(env.HOME || homedir5(), ".codex"), "state_5.sqlite");
911
970
  }
912
971
  async function syncCodexThreadForResume(input) {
913
972
  const env = input.env ?? process.env;
@@ -1570,7 +1629,7 @@ function normalizeSettings(input, defaultWorkspace) {
1570
1629
  // src/admin/fsBrowseRoutes.ts
1571
1630
  import { readdir as readdir3 } from "node:fs/promises";
1572
1631
  import { homedir as homedir7 } from "node:os";
1573
- import { dirname as dirname5, join as join6, resolve } from "node:path";
1632
+ import { dirname as dirname4, join as join7, resolve } from "node:path";
1574
1633
 
1575
1634
  // src/shared/expandTilde.ts
1576
1635
  import { homedir as homedir6 } from "node:os";
@@ -1596,8 +1655,8 @@ function registerFsBrowseRoutes(input) {
1596
1655
  reply.code(400);
1597
1656
  return { error: "cannot_read_directory", path: target };
1598
1657
  }
1599
- const entries = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) => ({ name: dirent.name, path: join6(target, dirent.name), isDirectory: true })).filter((entry) => !entry.name.startsWith(".") || isOnKeepChain(entry.path)).sort((a, b) => a.name.localeCompare(b.name));
1600
- const parent = dirname5(target);
1658
+ const entries = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) => ({ name: dirent.name, path: join7(target, dirent.name), isDirectory: true })).filter((entry) => !entry.name.startsWith(".") || isOnKeepChain(entry.path)).sort((a, b) => a.name.localeCompare(b.name));
1659
+ const parent = dirname4(target);
1601
1660
  const isRoot = parent === target;
1602
1661
  const listing = {
1603
1662
  path: target,
@@ -1778,7 +1837,7 @@ var WeixinDirectApiClient = class {
1778
1837
 
1779
1838
  // src/channels/weixin-direct/adapter.ts
1780
1839
  import { setTimeout as delay2 } from "node:timers/promises";
1781
- import { join as join7 } from "node:path";
1840
+ import { join as join8 } from "node:path";
1782
1841
 
1783
1842
  // src/channels/weixin-direct/typingController.ts
1784
1843
  var CONFIG_CACHE_TTL_MS = 24 * 60 * 60 * 1e3;
@@ -2043,7 +2102,7 @@ var WeixinDirectAdapter = class _WeixinDirectAdapter {
2043
2102
  continue;
2044
2103
  }
2045
2104
  const { ext, mimeType } = mediaExtAndMime(meta);
2046
- const destPath = join7(mediaDir, `${idPrefix}_${i}${ext}`);
2105
+ const destPath = join8(mediaDir, `${idPrefix}_${i}${ext}`);
2047
2106
  const maxBytes = meta.kind === "video" ? VIDEO_MAX_BYTES : void 0;
2048
2107
  const result = await downloader.download(meta.media ?? {}, { destPath, aeskeyOverride: meta.aeskey, maxBytes });
2049
2108
  if (result.ok) {
@@ -2103,8 +2162,8 @@ function chunkText(text, limit) {
2103
2162
  }
2104
2163
 
2105
2164
  // src/channels/weixin-direct/mediaDownloader.ts
2106
- import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "node:fs";
2107
- import { dirname as dirname6 } from "node:path";
2165
+ import { mkdirSync as mkdirSync2, writeFileSync as writeFileSync2 } from "node:fs";
2166
+ import { dirname as dirname5 } from "node:path";
2108
2167
 
2109
2168
  // src/channels/weixin-direct/mediaCrypto.ts
2110
2169
  import { createDecipheriv } from "node:crypto";
@@ -2167,8 +2226,8 @@ var WeixinMediaDownloader = class {
2167
2226
  } catch {
2168
2227
  return { ok: false, reason: "decrypt_failed" };
2169
2228
  }
2170
- mkdirSync3(dirname6(input.destPath), { recursive: true });
2171
- writeFileSync3(input.destPath, plaintext);
2229
+ mkdirSync2(dirname5(input.destPath), { recursive: true });
2230
+ writeFileSync2(input.destPath, plaintext);
2172
2231
  return { ok: true, localPath: input.destPath, bytes: plaintext.length };
2173
2232
  }
2174
2233
  };
@@ -2354,7 +2413,7 @@ import { randomUUID as randomUUID2 } from "node:crypto";
2354
2413
 
2355
2414
  // src/shared/platform.ts
2356
2415
  import { access, constants } from "node:fs/promises";
2357
- import { delimiter, join as join8 } from "node:path";
2416
+ import { delimiter, join as join9 } from "node:path";
2358
2417
  import { tmpdir } from "node:os";
2359
2418
  import { spawn } from "node:child_process";
2360
2419
  var isWindows = process.platform === "win32";
@@ -2382,7 +2441,7 @@ async function findExecutable(command) {
2382
2441
  const dirs = (process.env.PATH ?? "").split(delimiter).filter(Boolean);
2383
2442
  for (const dir of dirs) {
2384
2443
  for (const ext of extensions) {
2385
- const candidate = join8(dir, command + ext);
2444
+ const candidate = join9(dir, command + ext);
2386
2445
  if (await isExecutableFile(candidate)) return candidate;
2387
2446
  }
2388
2447
  }
@@ -2405,13 +2464,13 @@ function terminateChild(child, signal = "SIGTERM") {
2405
2464
  }
2406
2465
  }
2407
2466
  function defaultWorkspaceDir() {
2408
- return join8(tmpdir(), "project");
2467
+ return join9(tmpdir(), "project");
2409
2468
  }
2410
2469
  function useShellForCli() {
2411
2470
  return isWindows;
2412
2471
  }
2413
2472
  function statePath(filename) {
2414
- return join8(tmpdir(), filename);
2473
+ return join9(tmpdir(), filename);
2415
2474
  }
2416
2475
 
2417
2476
  // src/providers/claude-code/assistantContent.ts
@@ -3399,8 +3458,7 @@ function buildBridgeCommandHelpMarkdown(input) {
3399
3458
  }
3400
3459
 
3401
3460
  // src/session/currentConversationStore.ts
3402
- import { existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync4 } from "node:fs";
3403
- import { dirname as dirname7 } from "node:path";
3461
+ import { existsSync as existsSync6, readFileSync as readFileSync4 } from "node:fs";
3404
3462
  import { nanoid as nanoid2 } from "nanoid";
3405
3463
  var CurrentConversationStore = class {
3406
3464
  constructor(configPath, defaults) {
@@ -3482,9 +3540,8 @@ var CurrentConversationStore = class {
3482
3540
  this.writeState(state);
3483
3541
  }
3484
3542
  writeState(state) {
3485
- mkdirSync4(dirname7(this.configPath), { recursive: true });
3486
- writeFileSync4(this.configPath, `${JSON.stringify(state, null, 2)}
3487
- `, "utf8");
3543
+ writeFileAtomicSync(this.configPath, `${JSON.stringify(state, null, 2)}
3544
+ `);
3488
3545
  }
3489
3546
  };
3490
3547
 
@@ -4017,8 +4074,7 @@ function composeInboundText(content) {
4017
4074
  }
4018
4075
 
4019
4076
  // src/storage/lastProviderSessionStore.ts
4020
- import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync5, writeFileSync as writeFileSync5 } from "node:fs";
4021
- import { dirname as dirname8 } from "node:path";
4077
+ import { existsSync as existsSync7, readFileSync as readFileSync5 } from "node:fs";
4022
4078
  var LastProviderSessionStore = class {
4023
4079
  constructor(configPath) {
4024
4080
  this.configPath = configPath;
@@ -4049,15 +4105,13 @@ var LastProviderSessionStore = class {
4049
4105
  return raw && typeof raw === "object" ? raw : {};
4050
4106
  }
4051
4107
  writeState(state) {
4052
- mkdirSync5(dirname8(this.configPath), { recursive: true });
4053
- writeFileSync5(this.configPath, `${JSON.stringify(state, null, 2)}
4054
- `, "utf8");
4108
+ writeFileAtomicSync(this.configPath, `${JSON.stringify(state, null, 2)}
4109
+ `);
4055
4110
  }
4056
4111
  };
4057
4112
 
4058
4113
  // src/storage/runtimeUserStore.ts
4059
- import { mkdirSync as mkdirSync6, readFileSync as readFileSync6, writeFileSync as writeFileSync6, existsSync as existsSync8 } from "node:fs";
4060
- import { dirname as dirname9 } from "node:path";
4114
+ import { readFileSync as readFileSync6, existsSync as existsSync8 } from "node:fs";
4061
4115
  import { nanoid as nanoid3 } from "nanoid";
4062
4116
  var RuntimeUserStore = class {
4063
4117
  constructor(configPath) {
@@ -4122,9 +4176,8 @@ var RuntimeUserStore = class {
4122
4176
  return raw && typeof raw === "object" ? raw : {};
4123
4177
  }
4124
4178
  writeState(state) {
4125
- mkdirSync6(dirname9(this.configPath), { recursive: true });
4126
- writeFileSync6(this.configPath, `${JSON.stringify(state, null, 2)}
4127
- `, "utf8");
4179
+ writeFileAtomicSync(this.configPath, `${JSON.stringify(state, null, 2)}
4180
+ `);
4128
4181
  }
4129
4182
  };
4130
4183
 
@@ -4450,6 +4503,20 @@ var RelayTunnelRouter = class {
4450
4503
  }
4451
4504
  };
4452
4505
 
4506
+ // src/shared/version.ts
4507
+ import { readFileSync as readFileSync7 } from "node:fs";
4508
+ import { dirname as dirname6, join as join10 } from "node:path";
4509
+ import { fileURLToPath } from "node:url";
4510
+ function readClientVersion() {
4511
+ try {
4512
+ const here2 = dirname6(fileURLToPath(import.meta.url));
4513
+ const pkg = JSON.parse(readFileSync7(join10(here2, "..", "..", "package.json"), "utf8"));
4514
+ return typeof pkg.version === "string" && pkg.version ? pkg.version : "0.0.0";
4515
+ } catch {
4516
+ return "0.0.0";
4517
+ }
4518
+ }
4519
+
4453
4520
  // src/daemon/server.ts
4454
4521
  function readUpdateStatusBestEffort(configPath) {
4455
4522
  if (!configPath) return { ok: false };
@@ -4462,7 +4529,7 @@ function readUpdateStatusBestEffort(configPath) {
4462
4529
  function createDaemonServer(options = {}) {
4463
4530
  const app = Fastify({ logger: true });
4464
4531
  const events = new BridgeEventHub();
4465
- const configPath = options.configPath ?? process.env.BRIDGE_CONFIG ?? join9(mkdtempSync(join9(tmpdir2(), "claude-codex-wechat-")), "config.json");
4532
+ const configPath = options.configPath ?? process.env.BRIDGE_CONFIG ?? join11(mkdtempSync(join11(tmpdir2(), "claude-codex-wechat-")), "config.json");
4466
4533
  const persistedConfig = loadBridgeConfig(configPath);
4467
4534
  const bridgeDefaults = {
4468
4535
  defaultProvider: options.bridgeDefaults?.defaultProvider ?? persistedConfig.bridge?.defaultProvider ?? "claude-code",
@@ -4519,7 +4586,7 @@ function createDaemonServer(options = {}) {
4519
4586
  });
4520
4587
  }
4521
4588
  const weixinStateStore = configPath ? new FileWeixinStateStore(configPath) : void 0;
4522
- const weixinMediaDir = configPath ? join9(dirname10(configPath), "media") : void 0;
4589
+ const weixinMediaDir = configPath ? join11(dirname7(configPath), "media") : void 0;
4523
4590
  const managedWechatChannel = options.channel ? null : new ManagedWeixinDirectAdapter(options.wechat, weixinStateStore, weixinMediaDir);
4524
4591
  const channel = options.channel ?? managedWechatChannel;
4525
4592
  const weixinOutboundGate = managedWechatChannel && weixinStateStore ? new WeixinOutboundGate({
@@ -4634,6 +4701,7 @@ function createDaemonServer(options = {}) {
4634
4701
  const update = read.ok ? read.update ?? null : persistedConfig.update ?? null;
4635
4702
  return {
4636
4703
  ok: true,
4704
+ version: readClientVersion(),
4637
4705
  sessions: conversation.getCurrent() ? [conversation.getCurrent()] : [],
4638
4706
  update,
4639
4707
  preferredLocalUrl: (() => {
@@ -4750,20 +4818,6 @@ function createUpdateChecker(opts) {
4750
4818
  };
4751
4819
  }
4752
4820
 
4753
- // src/shared/version.ts
4754
- import { readFileSync as readFileSync7 } from "node:fs";
4755
- import { dirname as dirname11, join as join10 } from "node:path";
4756
- import { fileURLToPath } from "node:url";
4757
- function readClientVersion() {
4758
- try {
4759
- const here2 = dirname11(fileURLToPath(import.meta.url));
4760
- const pkg = JSON.parse(readFileSync7(join10(here2, "..", "..", "package.json"), "utf8"));
4761
- return typeof pkg.version === "string" && pkg.version ? pkg.version : "0.0.0";
4762
- } catch {
4763
- return "0.0.0";
4764
- }
4765
- }
4766
-
4767
4821
  // src/daemon/bootstrap.ts
4768
4822
  async function startDaemon(options) {
4769
4823
  const port = options.port ?? Number(process.env.BRIDGE_PORT ?? 8787);
@@ -4823,7 +4877,7 @@ async function resolveProviderCommands(providers) {
4823
4877
 
4824
4878
  // src/daemon/staticFrontend.ts
4825
4879
  import { readFileSync as readFileSync8 } from "node:fs";
4826
- import { join as join11 } from "node:path";
4880
+ import { join as join12 } from "node:path";
4827
4881
  import fastifyStatic from "@fastify/static";
4828
4882
  function attachStaticFrontend(webRoot2) {
4829
4883
  return async (app) => {
@@ -4831,7 +4885,7 @@ function attachStaticFrontend(webRoot2) {
4831
4885
  root: webRoot2,
4832
4886
  wildcard: false
4833
4887
  });
4834
- const indexHtml = readFileSync8(join11(webRoot2, "index.html"), "utf8");
4888
+ const indexHtml = readFileSync8(join12(webRoot2, "index.html"), "utf8");
4835
4889
  app.setNotFoundHandler((request, reply) => {
4836
4890
  if (request.url.startsWith("/api")) {
4837
4891
  reply.code(404).send({ error: "not_found" });
@@ -4846,7 +4900,7 @@ function attachStaticFrontend(webRoot2) {
4846
4900
  import { existsSync as existsSync9, statSync, openSync, closeSync, watchFile } from "node:fs";
4847
4901
  import { mkdir as mkdir4, readFile as readFile6, rm as rm2, writeFile as writeFile5 } from "node:fs/promises";
4848
4902
  import { homedir as homedir8 } from "node:os";
4849
- import { dirname as dirname12, join as join12 } from "node:path";
4903
+ import { dirname as dirname8, join as join13 } from "node:path";
4850
4904
  import { createReadStream } from "node:fs";
4851
4905
  import { execFile, spawn as spawn7 } from "node:child_process";
4852
4906
  import { createInterface } from "node:readline";
@@ -4855,8 +4909,8 @@ var execFileAsync = promisify(execFile);
4855
4909
  async function installService(context) {
4856
4910
  if (process.platform === "darwin") {
4857
4911
  const spec = buildLaunchdSpec(context);
4858
- await mkdir4(dirname12(spec.plistPath), { recursive: true });
4859
- await mkdir4(dirname12(spec.stdoutPath), { recursive: true });
4912
+ await mkdir4(dirname8(spec.plistPath), { recursive: true });
4913
+ await mkdir4(dirname8(spec.stdoutPath), { recursive: true });
4860
4914
  await writeFile5(spec.plistPath, renderLaunchdPlist(spec), "utf8");
4861
4915
  await runLaunchctl(["unload", spec.plistPath]).catch(() => void 0);
4862
4916
  await runLaunchctl(["load", spec.plistPath]);
@@ -4865,8 +4919,8 @@ async function installService(context) {
4865
4919
  }
4866
4920
  if (process.platform === "linux") {
4867
4921
  const spec = buildSystemdUserSpec(context);
4868
- await mkdir4(dirname12(spec.unitPath), { recursive: true });
4869
- await mkdir4(dirname12(spec.stdoutPath), { recursive: true });
4922
+ await mkdir4(dirname8(spec.unitPath), { recursive: true });
4923
+ await mkdir4(dirname8(spec.stdoutPath), { recursive: true });
4870
4924
  await writeFile5(spec.unitPath, renderSystemdUnit(spec), "utf8");
4871
4925
  await runSystemctl(["--user", "daemon-reload"]);
4872
4926
  await runSystemctl(["--user", "enable", "--now", spec.unitName]);
@@ -5033,37 +5087,37 @@ async function readServiceStatus(context) {
5033
5087
  throw new Error("service_status_not_supported_on_this_platform");
5034
5088
  }
5035
5089
  function buildLaunchdSpec(context) {
5036
- const stateDir = join12(homedir8(), ".claude-codex-wechat");
5090
+ const stateDir = join13(homedir8(), ".claude-codex-wechat");
5037
5091
  return {
5038
5092
  label: "com.claude-codex-wechat",
5039
- plistPath: join12(homedir8(), "Library", "LaunchAgents", "com.claude-codex-wechat.plist"),
5093
+ plistPath: join13(homedir8(), "Library", "LaunchAgents", "com.claude-codex-wechat.plist"),
5040
5094
  programArgs: [context.nodePath ?? process.execPath, context.cliEntrypointPath, "__daemon"],
5041
5095
  workingDirectory: homedir8(),
5042
- stdoutPath: join12(stateDir, "logs", "service.stdout.log"),
5043
- stderrPath: join12(stateDir, "logs", "service.stderr.log"),
5096
+ stdoutPath: join13(stateDir, "logs", "service.stdout.log"),
5097
+ stderrPath: join13(stateDir, "logs", "service.stderr.log"),
5044
5098
  environment: buildServiceEnvironment(context)
5045
5099
  };
5046
5100
  }
5047
5101
  function buildSystemdUserSpec(context) {
5048
- const stateDir = join12(homedir8(), ".claude-codex-wechat");
5102
+ const stateDir = join13(homedir8(), ".claude-codex-wechat");
5049
5103
  return {
5050
5104
  unitName: "claude-codex-wechat.service",
5051
- unitPath: join12(homedir8(), ".config", "systemd", "user", "claude-codex-wechat.service"),
5105
+ unitPath: join13(homedir8(), ".config", "systemd", "user", "claude-codex-wechat.service"),
5052
5106
  execStart: [context.nodePath ?? process.execPath, context.cliEntrypointPath, "__daemon"],
5053
5107
  workingDirectory: homedir8(),
5054
- stdoutPath: join12(stateDir, "logs", "service.stdout.log"),
5055
- stderrPath: join12(stateDir, "logs", "service.stderr.log"),
5108
+ stdoutPath: join13(stateDir, "logs", "service.stdout.log"),
5109
+ stderrPath: join13(stateDir, "logs", "service.stderr.log"),
5056
5110
  environment: buildServiceEnvironment(context)
5057
5111
  };
5058
5112
  }
5059
5113
  function buildProcessSpec(context) {
5060
- const stateDir = join12(homedir8(), ".claude-codex-wechat");
5114
+ const stateDir = join13(homedir8(), ".claude-codex-wechat");
5061
5115
  return {
5062
- pidPath: join12(stateDir, "service.pid"),
5116
+ pidPath: join13(stateDir, "service.pid"),
5063
5117
  command: [context.nodePath ?? process.execPath, context.cliEntrypointPath, "__daemon"],
5064
5118
  workingDirectory: homedir8(),
5065
- stdoutPath: join12(stateDir, "logs", "service.stdout.log"),
5066
- stderrPath: join12(stateDir, "logs", "service.stderr.log"),
5119
+ stdoutPath: join13(stateDir, "logs", "service.stdout.log"),
5120
+ stderrPath: join13(stateDir, "logs", "service.stderr.log"),
5067
5121
  environment: buildServiceEnvironment(context)
5068
5122
  };
5069
5123
  }
@@ -5184,7 +5238,7 @@ async function readPidFile(pidPath) {
5184
5238
  }
5185
5239
  }
5186
5240
  async function writePidFile(pidPath, pid) {
5187
- await mkdir4(dirname12(pidPath), { recursive: true });
5241
+ await mkdir4(dirname8(pidPath), { recursive: true });
5188
5242
  await writeFile5(pidPath, `${pid}
5189
5243
  `, "utf8");
5190
5244
  }
@@ -5199,7 +5253,7 @@ async function killPid(pid) {
5199
5253
  process.kill(pid, "SIGTERM");
5200
5254
  }
5201
5255
  async function spawnDetachedDaemon(spec) {
5202
- await mkdir4(dirname12(spec.stdoutPath), { recursive: true });
5256
+ await mkdir4(dirname8(spec.stdoutPath), { recursive: true });
5203
5257
  const outFd = openSync(spec.stdoutPath, "a");
5204
5258
  const errFd = openSync(spec.stderrPath, "a");
5205
5259
  try {
@@ -5285,8 +5339,8 @@ function fileSizeHint(path) {
5285
5339
  }
5286
5340
 
5287
5341
  // src/cli.ts
5288
- var here = dirname13(fileURLToPath2(import.meta.url));
5289
- var webRoot = join13(here, "..", "web");
5342
+ var here = dirname9(fileURLToPath2(import.meta.url));
5343
+ var webRoot = join14(here, "..", "web");
5290
5344
  async function main() {
5291
5345
  const command = process.argv[2];
5292
5346
  switch (command) {
@@ -9,4 +9,4 @@ Error generating stack: `+e.message+`
9
9
  `).replace(Ad,``)}function Md(e,t){return t=jd(t),jd(e)===t}function $(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Qt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Qt(e,``+r);break;case`className`:It(e,`class`,r);break;case`tabIndex`:It(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:It(e,n,r);break;case`style`:tn(e,r,o);break;case`data`:if(t!==`object`){It(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=on(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof o==`function`&&(n===`formAction`?(t!==`input`&&$(e,t,`name`,a.name,a,null),$(e,t,`formEncType`,a.formEncType,a,null),$(e,t,`formMethod`,a.formMethod,a,null),$(e,t,`formTarget`,a.formTarget,a,null)):($(e,t,`encType`,a.encType,a,null),$(e,t,`method`,a.method,a,null),$(e,t,`target`,a.target,a,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=on(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=sn);break;case`onScroll`:r!=null&&Q(`scroll`,e);break;case`onScrollEnd`:r!=null&&Q(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=on(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Q(`beforetoggle`,e),Q(`toggle`,e),Ft(e,`popover`,r);break;case`xlinkActuate`:Lt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Lt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Lt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Lt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Lt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Lt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Lt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Lt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Lt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Ft(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=rn.get(n)||n,Ft(e,n,r))}}function Nd(e,t,n,r,a,o){switch(n){case`style`:tn(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Qt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Qt(e,``+r);break;case`onScroll`:r!=null&&Q(`scroll`,e);break;case`onScrollEnd`:r!=null&&Q(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=sn);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!Ot.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[ht]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):Ft(e,n,r)}}}function Pd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Q(`error`,e),Q(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:$(e,t,o,s,n,null)}}a&&$(e,t,`srcSet`,n.srcSet,n,null),r&&$(e,t,`src`,n.src,n,null);return;case`input`:Q(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:$(e,t,r,d,n,null)}}qt(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Q(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:$(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&Yt(e,!!r,n,!0):Yt(e,!!r,t,!1);return;case`textarea`:for(s in Q(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:$(e,t,s,c,n,null)}Zt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:$(e,t,l,r,n,null)}return;case`dialog`:Q(`beforetoggle`,e),Q(`toggle`,e),Q(`cancel`,e),Q(`close`,e);break;case`iframe`:case`object`:Q(`load`,e);break;case`video`:case`audio`:for(r=0;r<_d.length;r++)Q(_d[r],e);break;case`image`:Q(`error`,e),Q(`load`,e);break;case`details`:Q(`toggle`,e);break;case`embed`:case`source`:case`link`:Q(`error`,e),Q(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:$(e,t,u,r,n,null)}return;default:if(nn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Nd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&$(e,t,c,r,n,null))}function Fd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||$(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&$(e,t,p,m,r,f)}}Kt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||$(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&$(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Yt(e,!!n,n?[]:``,!1):Yt(e,!!n,t,!0)):Yt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:$(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&$(e,t,s,a,r,o)}Xt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:$(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:$(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&$(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:$(e,t,u,p,r,m)}return;default:if(nn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Nd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Nd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&$(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||$(e,t,f,p,r,m)}function Id(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Ld(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Id(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Rd=null,zd=null;function Bd(e){return e.nodeType===9?e:e.ownerDocument}function Vd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Hd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Ud(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Wd=null;function Gd(){var e=window.event;return e&&e.type===`popstate`?e===Wd?!1:(Wd=e,!0):(Wd=null,!1)}var Kd=typeof setTimeout==`function`?setTimeout:void 0,qd=typeof clearTimeout==`function`?clearTimeout:void 0,Jd=typeof Promise==`function`?Promise:void 0,Yd=typeof queueMicrotask==`function`?queueMicrotask:Jd===void 0?Kd:function(e){return Jd.resolve(null).then(e).catch(Xd)};function Xd(e){setTimeout(function(){throw e})}function Zd(e){return e===`head`}function Qd(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Np(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)pf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,pf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[xt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&pf(e.ownerDocument.body);n=i}while(n);Np(t)}function $d(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function ef(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:ef(n),St(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function tf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[xt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=cf(e.nextSibling),e===null)break}return null}function nf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=cf(e.nextSibling),e===null))return null;return e}function rf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=cf(e.nextSibling),e===null))return null;return e}function af(e){return e.data===`$?`||e.data===`$~`}function of(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function sf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function cf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var lf=null;function uf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return cf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function df(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function ff(e,t,n){switch(t=Bd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function pf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);St(e)}var mf=new Map,hf=new Set;function gf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var _f=D.d;D.d={f:vf,r:yf,D:Sf,C:Cf,L:wf,m:Tf,X:Df,S:Ef,M:Of};function vf(){var e=_f.f(),t=bu();return e||t}function yf(e){var t=wt(e);t!==null&&t.tag===5&&t.type===`form`?ks(t):_f.r(e)}var bf=typeof document>`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Gt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),j(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Gt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Gt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Gt(n.imageSizes)+`"]`)):i+=`[href="`+Gt(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=h({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),j(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Gt(r)+`"][href="`+Gt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=h({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),j(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=Et(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=h({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);j(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=Et(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),j(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=Et(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=h({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),j(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var a=(a=ge.current)?gf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=Et(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var o=Et(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),o||Nf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=Et(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Af(e){return`href="`+Gt(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),j(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Gt(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Gt(n.href)+`"]`);if(r)return t.instance=r,j(r),r;var a=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),j(r),Pd(r,`style`,a),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Af(n.href);var o=e.querySelector(jf(a));if(o)return t.state.loading|=4,t.instance=o,j(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),j(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(o,`link`,r),t.state.loading|=4,Lf(o,n.precedence,e),t.instance=o;case`script`:return o=Pf(n.src),(a=e.querySelector(Ff(o)))?(t.instance=a,j(a),a):(r=n,(a=mf.get(o))&&(r=h({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),j(a),Pd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Rf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function zf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Bf=null;function Vf(e,t,n){if(Bf===null){var r=new Map,i=Bf=new Map;i.set(n,r)}else i=Bf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[xt]||a[mt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Hf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,j(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),j(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Kf===0&&(Kf=62500*Ld());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Jf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var Qf={$$typeof:C,Provider:null,Consumer:null,_currentValue:ue,_currentValue2:ue,_threadCount:0};function $f(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=rt(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=rt(0),this.hiddenUpdates=rt(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function ep(e,t,n,r,i,a,o,s,c,l,u,d){return e=new $f(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=hi(3,null,null,t),e.current=a,a.stateNode=e,t=pa(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Ka(a),e}function tp(e){return e?(e=pi,e):pi}function np(e,t,n,r,i,a){i=tp(i),r.context===null?r.context=i:r.pendingContext=i,r=Ja(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Ya(e,r,t),n!==null&&(hu(n,e,t),Xa(n,e,t))}function rp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ip(e,t){rp(e,t),(e=e.alternate)&&rp(e,t)}function ap(e){if(e.tag===13||e.tag===31){var t=ui(e,67108864);t!==null&&hu(t,e,67108864),ip(e,67108864)}}function op(e){if(e.tag===13||e.tag===31){var t=pu();t=lt(t);var n=ui(e,t);n!==null&&hu(n,e,t),ip(e,t)}}var sp=!0;function cp(e,t,n,r){var i=E.T;E.T=null;var a=D.p;try{D.p=2,up(e,t,n,r)}finally{D.p=a,E.T=i}}function lp(e,t,n,r){var i=E.T;E.T=null;var a=D.p;try{D.p=8,up(e,t,n,r)}finally{D.p=a,E.T=i}}function up(e,t,n,r){if(sp){var i=dp(r);if(i===null)wd(e,t,r,fp,n),Cp(e,r);else if(Tp(i,e,t,n,r))r.stopPropagation();else if(Cp(e,r),t&4&&-1<Sp.indexOf(e)){for(;i!==null;){var a=wt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=$e(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Ke(o);s.entanglements[1]|=c,o&=~c}rd(a),!(G&6)&&(tu=Pe()+500,id(0,!1))}}break;case 31:case 13:s=ui(a,2),s!==null&&hu(s,a,2),bu(),ip(a,2)}if(a=dp(r),a===null&&wd(e,t,r,fp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else wd(e,t,r,null,n)}}function dp(e){return e=ln(e),pp(e)}var fp=null;function pp(e){if(fp=null,e=Ct(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return fp=e,null}function mp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Fe()){case Ie:return 2;case Le:return 8;case Re:case ze:return 32;case Be:return 268435456;default:return 32}default:return 32}}var hp=!1,gp=null,_p=null,vp=null,yp=new Map,bp=new Map,xp=[],Sp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Cp(e,t){switch(e){case`focusin`:case`focusout`:gp=null;break;case`dragenter`:case`dragleave`:_p=null;break;case`mouseover`:case`mouseout`:vp=null;break;case`pointerover`:case`pointerout`:yp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:bp.delete(t.pointerId)}}function wp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=wt(t),t!==null&&ap(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Tp(e,t,n,r,i){switch(t){case`focusin`:return gp=wp(gp,e,t,n,r,i),!0;case`dragenter`:return _p=wp(_p,e,t,n,r,i),!0;case`mouseover`:return vp=wp(vp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return yp.set(a,wp(yp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,bp.set(a,wp(bp.get(a)||null,e,t,n,r,i)),!0}return!1}function Ep(e){var t=Ct(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,ft(e.priority,function(){op(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,ft(e.priority,function(){op(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Dp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=dp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);cn=r,n.target.dispatchEvent(r),cn=null}else return t=wt(n),t!==null&&ap(t),e.blockedOn=n,!1;t.shift()}return!0}function Op(e,t,n){Dp(e)&&n.delete(t)}function kp(){hp=!1,gp!==null&&Dp(gp)&&(gp=null),_p!==null&&Dp(_p)&&(_p=null),vp!==null&&Dp(vp)&&(vp=null),yp.forEach(Op),bp.forEach(Op)}function Ap(e,n){e.blockedOn===n&&(e.blockedOn=null,hp||(hp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,kp)))}var jp=null;function Mp(e){jp!==e&&(jp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){jp===e&&(jp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(pp(r||n)===null)continue;break}var a=wt(n);a!==null&&(e.splice(t,3),t-=3,Ds(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Np(e){function t(t){return Ap(t,e)}gp!==null&&Ap(gp,e),_p!==null&&Ap(_p,e),vp!==null&&Ap(vp,e),yp.forEach(t),bp.forEach(t);for(var n=0;n<xp.length;n++){var r=xp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<xp.length&&(n=xp[0],n.blockedOn===null);)Ep(n),n.blockedOn===null&&xp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[ht]||null;if(typeof a==`function`)o||Mp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[ht]||null)s=o.formAction;else if(pp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Mp(n)}}}function Pp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Fp(e){this._internalRoot=e}Ip.prototype.render=Fp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;np(n,pu(),e,t,null,null)},Ip.prototype.unmount=Fp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;np(e.current,2,null,e,null,null),bu(),t[gt]=null}};function Ip(e){this._internalRoot=e}Ip.prototype.unstable_scheduleHydration=function(e){if(e){var t=dt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<xp.length&&t!==0&&t<xp[n].priority;n++);xp.splice(n,0,e),n===0&&Ep(e)}};var Lp=n.version;if(Lp!==`19.2.7`)throw Error(i(527,Lp,`19.2.7`));D.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=d(t),e=e===null?null:p(e),e=e===null?null:e.stateNode,e};var Rp={bundleType:0,version:`19.2.7`,rendererPackageName:`react-dom`,currentDispatcherRef:E,reconcilerVersion:`19.2.7`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var zp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zp.isDisabled&&zp.supportsFiber)try{Ue=zp.inject(Rp),We=zp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Xs,s=Zs,c=Qs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=ep(e,1,!1,null,null,n,r,null,o,s,c,Pp),e[gt]=t.current,Sd(e),new Fp(t)}})),g=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=h()})),_=c(f()),v=g();function y(e,t){if(typeof e.__bridgeApiOrigin==`string`&&e.__bridgeApiOrigin)return e.__bridgeApiOrigin;let n=typeof t.origin==`string`&&t.origin?t.origin:``,r=(typeof t.pathname==`string`?t.pathname:``).split(`/`).filter(Boolean)[0]??``;return n?r?`${n}/${r}`:n:``}function b(){return typeof window<`u`?y(window,window.location):``}function x(e){return`${b()}${e}`}async function S(e,t){let n=await fetch(x(e),t);if(!n.ok)throw Error(`${e}_failed:${n.status}`);return await n.json()}async function C(e,t){let n=await fetch(x(e),t);if(n.status===404)return null;if(!n.ok)throw Error(`${e}_failed:${n.status}`);return await n.json()}async function w(){return await S(`/api/status`)}async function ee(){return await S(`/api/providers/status`)}async function T(){return await S(`/api/tunnel/status`)}async function te(e,t){let n=new URLSearchParams;e&&n.set(`path`,e),t&&n.set(`keep`,t);let r=n.toString();return await S(`/api/fs/list${r?`?${r}`:``}`)}async function ne(){return await S(`/api/channel/state`)}async function re(e){await S(`/api/channel/plugins/enable`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({plugin_id:`weixin`,config:{...e.baseUrl?{baseUrl:e.baseUrl}:{},credentials:{account_id:e.accountId,bot_token:e.botToken,...e.baseUrl?{baseUrl:e.baseUrl}:{}}}})})}async function ie(){await S(`/api/channel/plugins/disable`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({plugin_id:`weixin`})})}async function ae(){return await C(`/api/channel/current-session`)||((await C(`/api/channel/sessions`))?.[0]??null)}async function oe(e,t){let n=new URLSearchParams;typeof t?.limit==`number`&&t.limit>0&&n.set(`limit`,String(t.limit)),t?.cursor&&n.set(`cursor`,t.cursor);let r=n.size>0?`?${n.toString()}`:``,i=await S(`/api/channel/providers/${encodeURIComponent(e)}/recoverable-sessions${r}`);return Array.isArray(i)?{items:i,nextCursor:null}:i}async function se(e){await S(`/api/channel/sessions/attach`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})}async function ce(e){await S(`/api/channel/sessions/new`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e)})}async function le(){return await S(`/api/settings`)}var E=Object.defineProperty,D=Object.getOwnPropertySymbols,ue=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,fe=(e,t,n)=>t in e?E(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pe=(e,t)=>{for(var n in t||={})ue.call(t,n)&&fe(e,n,t[n]);if(D)for(var n of D(t))de.call(t,n)&&fe(e,n,t[n]);return e},O=(e,t)=>{var n={};for(var r in e)ue.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&D)for(var r of D(e))t.indexOf(r)<0&&de.call(e,r)&&(n[r]=e[r]);return n},k;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.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]],t.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]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(k||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(k||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(k||={});var me=k,he={L:me.QrCode.Ecc.LOW,M:me.QrCode.Ecc.MEDIUM,Q:me.QrCode.Ecc.QUARTILE,H:me.QrCode.Ecc.HIGH},ge=128,_e=`L`,ve=`#FFFFFF`,ye=`#000000`,be=!1,xe=1,Se=4,Ce=0,we=.1;function Te(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function Ee(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function De(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*we),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function Oe(e,t){return t==null?e?Se:Ce:Math.max(Math.floor(t),0)}function ke({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=_.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...me.QrSegment.makeSegments(t)),e),[]);return me.QrCode.encodeSegments(r,he[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:l,margin:u,numCells:d,calculatedImageSettings:f}=_.useMemo(()=>{let e=c.getModules(),t=Oe(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:De(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:u,cells:l,numCells:d,calculatedImageSettings:f}}var Ae=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),je=_.forwardRef(function(e,t){let n=e,{value:r,size:i=ge,level:a=_e,bgColor:o=ve,fgColor:s=ye,includeMargin:c=be,minVersion:l=xe,boostLevel:u,marginSize:d,imageSettings:f}=n,p=O(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:m}=p,h=O(p,[`style`]),g=f?.src,v=_.useRef(null),y=_.useRef(null),b=_.useCallback(e=>{v.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[x,S]=_.useState(!1),{margin:C,cells:w,numCells:ee,calculatedImageSettings:T}=ke({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:d,imageSettings:f,size:i});_.useEffect(()=>{if(v.current!=null){let e=v.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=y.current,a=T!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&T.excavation!=null&&(n=Ee(w,T.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/ee*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,ee,ee),t.fillStyle=s,Ae?t.fill(new Path2D(Te(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),T&&(t.globalAlpha=T.opacity),a&&t.drawImage(r,T.x+C,T.y+C,T.w,T.h)}}),_.useEffect(()=>{S(!1)},[g]);let te=pe({height:i,width:i},m),ne=null;return g!=null&&(ne=_.createElement(`img`,{src:g,key:g,style:{display:`none`},onLoad:()=>{S(!0)},ref:y,crossOrigin:T?.crossOrigin})),_.createElement(_.Fragment,null,_.createElement(`canvas`,pe({style:te,height:i,width:i,ref:b,role:`img`},h)),ne)});je.displayName=`QRCodeCanvas`;var Me=_.forwardRef(function(e,t){let n=e,{value:r,size:i=ge,level:a=_e,bgColor:o=ve,fgColor:s=ye,includeMargin:c=be,minVersion:l=xe,boostLevel:u,title:d,marginSize:f,imageSettings:p}=n,m=O(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:h,cells:g,numCells:v,calculatedImageSettings:y}=ke({value:r,level:a,minVersion:l,boostLevel:u,includeMargin:c,marginSize:f,imageSettings:p,size:i}),b=g,x=null;p!=null&&y!=null&&(y.excavation!=null&&(b=Ee(g,y.excavation)),x=_.createElement(`image`,{href:p.src,height:y.h,width:y.w,x:y.x+h,y:y.y+h,preserveAspectRatio:`none`,opacity:y.opacity,crossOrigin:y.crossOrigin}));let S=Te(b,h);return _.createElement(`svg`,pe({height:i,width:i,viewBox:`0 0 ${v} ${v}`,ref:t,role:`img`},m),!!d&&_.createElement(`title`,null,d),_.createElement(`path`,{fill:o,d:`M0,0 h${v}v${v}H0z`,shapeRendering:`crispEdges`}),_.createElement(`path`,{fill:s,d:S,shapeRendering:`crispEdges`}),x)});Me.displayName=`QRCodeSVG`;async function Ne(e,t){let n=e.getReader(),r;for(;!(r=await n.read()).done;)t(r.value)}function Pe(e){let t,n,r,i=!1;return function(a){t===void 0?(t=a,n=0,r=-1):t=Ie(t,a);let o=t.length,s=0;for(;n<o;){i&&=(t[n]===10&&(s=++n),!1);let a=-1;for(;n<o&&a===-1;++n)switch(t[n]){case 58:r===-1&&(r=n-s);break;case 13:i=!0;case 10:a=n;break}if(a===-1)break;e(t.subarray(s,a),r),s=n,r=-1}s===o?t=void 0:s!==0&&(t=t.subarray(s),n-=s)}}function Fe(e,t,n){let r=Le(),i=new TextDecoder;return function(a,o){if(a.length===0)n?.(r),r=Le();else if(o>0){let n=i.decode(a.subarray(0,o)),s=o+(a[o+1]===32?2:1),c=i.decode(a.subarray(s));switch(n){case`data`:r.data=r.data?r.data+`
10
10
  `+c:c;break;case`event`:r.event=c;break;case`id`:e(r.id=c);break;case`retry`:let n=parseInt(c,10);isNaN(n)||t(r.retry=n);break}}}}function Ie(e,t){let n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}function Le(){return{data:``,event:``,id:``,retry:void 0}}var Re=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n},ze=`text/event-stream`,Be=1e3,Ve=`last-event-id`;function He(e,t){var{signal:n,headers:r,onopen:i,onmessage:a,onclose:o,onerror:s,openWhenHidden:c,fetch:l}=t,u=Re(t,[`signal`,`headers`,`onopen`,`onmessage`,`onclose`,`onerror`,`openWhenHidden`,`fetch`]);return new Promise((t,d)=>{let f=Object.assign({},r);f.accept||=ze;let p;function m(){p.abort(),document.hidden||b()}c||document.addEventListener(`visibilitychange`,m);let h=Be,g=0;function _(){document.removeEventListener(`visibilitychange`,m),window.clearTimeout(g),p.abort()}n?.addEventListener(`abort`,()=>{_(),t()});let v=l??window.fetch,y=i??Ue;async function b(){p=new AbortController;try{let n=await v(e,Object.assign(Object.assign({},u),{headers:f,signal:p.signal}));await y(n),await Ne(n.body,Pe(Fe(e=>{e?f[Ve]=e:delete f[Ve]},e=>{h=e},a))),o?.(),_(),t()}catch(e){if(!p.signal.aborted)try{let t=s?.(e)??h;window.clearTimeout(g),g=window.setTimeout(b,t)}catch(e){_(),d(e)}}}b()})}function Ue(e){let t=e.headers.get(`content-type`);if(!t?.startsWith(`text/event-stream`))throw Error(`Expected content-type to be ${ze}, Actual: ${t}`)}var We=new Set,Ge=null,Ke=null,qe=500;function Je(e){for(let t of We)try{t(e)}catch{}}function Ye(){if(Ge)return;let e=new AbortController;Ge=e,He(x(`/api/bridge-events`),{method:`POST`,signal:e.signal,openWhenHidden:!0,onmessage(e){if(!e.data)return;let t;try{t=JSON.parse(e.data)}catch{return}t.type===`connected`||t.type===`ping`||Je(t)},onerror(e){throw e}}).catch(()=>{Ge===e&&(Ge=null),We.size>0&&setTimeout(Ye,2e3)})}function Xe(e){return Ke&&=(clearTimeout(Ke),null),We.add(e),Ye(),()=>{We.delete(e),We.size===0&&(Ke&&clearTimeout(Ke),Ke=setTimeout(()=>{Ke=null,!(We.size>0)&&(Ge?.abort(),Ge=null)},qe))}}var Ze=`直接发送文字即可与 AI 对话。`,Qe=[{title:`会话管理`,entries:[{command:`/help`,desc:`显示本帮助`},{command:`/status`,desc:`查看当前会话(provider、工作目录、状态)`},{command:`/new`,desc:`按当前 provider 新建会话`},{command:`/new claude|codex`,desc:`新建指定 provider 会话`},{command:`/new <目录>`,desc:`在指定目录按当前 provider 新建会话`},{command:`/new claude:<目录>`,desc:`新建指定 provider + 指定目录会话`},{command:`/stop`,desc:`中断当前正在生成的回复(会话保留)`}]},{title:`历史会话`,entries:[{command:`/sessions`,desc:`列出最近的历史会话第 1 页(按更新时间倒序)`},{command:`/sessions p2`,desc:"查看第 2 页;页码语法固定为 `p<number>`"},{command:`/sessions <关键词>`,desc:`按标题/目录筛选,第 1 页`},{command:`/sessions <关键词> p2`,desc:`查看筛选结果的第 2 页`},{command:`/resume <编号>`,desc:`按 /sessions 列表编号恢复(也可直接用会话 id)`}]}],$e=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),A=o(((e,t)=>{t.exports=$e()}))(),et=`/`;function tt(e){let t=e.split(`/`).filter(Boolean),n=[],r=``;for(let e of t)r+=`/`+e,n.push(r);return n}function nt(e){let{value:t,onChange:n,showHeader:r=!0}=e,[i,a]=(0,_.useState)({}),[o,s]=(0,_.useState)(()=>new Set),[c,l]=(0,_.useState)(()=>new Set),[u,d]=(0,_.useState)(null),f=(0,_.useRef)(null),p=(0,_.useRef)(null),m=(0,_.useRef)(!1),h=(0,_.useCallback)((e,t)=>{l(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]),g=(0,_.useCallback)(async e=>{h(e,!0);try{let n=await te(e,t||void 0);a(e=>({...e,[n.path]:n})),d(null)}catch{d(`无法读取该目录`)}finally{h(e,!1)}},[h,t]);(0,_.useEffect)(()=>{(async()=>{if(await g(et),t&&t.startsWith(`/`)){let e=tt(t);s(t=>new Set([...t,...e])),await Promise.all(e.map(e=>g(e)))}})()},[]);let v=(0,_.useCallback)(e=>{s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):(n.add(e),i[e]||g(e)),n})},[i,g]);(0,_.useEffect)(()=>{if(m.current)return;let e=f.current,t=p.current;if(!e||!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();e.scrollTop+=r.top-n.top-(e.clientHeight-t.clientHeight)/2,m.current=!0});let y=(e,r)=>{let a=o.has(e.path),s=e.path===t,l=i[e.path];return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`div`,{ref:s?p:void 0,className:`dir-tree-row d-flex align-items-center gap-1 ${s?`dir-tree-row-selected`:``}`,style:{paddingLeft:6+r*16},children:[(0,A.jsx)(`button`,{type:`button`,className:`dir-tree-chevron btn btn-sm p-0 border-0 bg-transparent d-inline-flex`,onClick:()=>v(e.path),"aria-label":a?`折叠`:`展开`,children:(0,A.jsx)(`i`,{className:`bi ${a?`bi-chevron-down`:`bi-chevron-right`}`})}),(0,A.jsxs)(`button`,{type:`button`,className:`dir-tree-name btn btn-sm p-0 border-0 bg-transparent d-inline-flex align-items-center gap-1 text-truncate`,onClick:()=>n(e.path),title:e.path,children:[(0,A.jsx)(`i`,{className:`bi ${a?`bi-folder2-open`:`bi-folder`}`}),(0,A.jsx)(`span`,{className:`text-truncate`,children:e.name})]})]}),a?c.has(e.path)?(0,A.jsx)(`div`,{className:`text-muted-soft small`,style:{paddingLeft:6+(r+1)*16},children:`加载中…`}):l?l.entries.length?l.entries.map(e=>y(e,r+1)):(0,A.jsx)(`div`,{className:`text-muted-soft small`,style:{paddingLeft:6+(r+1)*16},children:`(无子目录)`}):null:null]},e.path)},b=i[et];return(0,A.jsxs)(`div`,{className:`dir-tree w-100`,children:[r?(0,A.jsxs)(`div`,{className:`dir-tree-head d-flex align-items-center gap-2 mb-1`,children:[(0,A.jsx)(`i`,{className:`bi bi-hdd flex-shrink-0 text-muted-soft`}),(0,A.jsx)(`span`,{className:`font-monospace small text-truncate`,title:t||``,children:t||`(未选择目录)`})]}):null,(0,A.jsx)(`div`,{ref:f,className:`dir-tree-body border rounded`,style:{maxHeight:220,overflowY:`auto`,padding:4},children:u?(0,A.jsx)(`div`,{className:`text-danger small px-1`,children:u}):b?b.entries.length?b.entries.map(e=>y(e,0)):(0,A.jsx)(`div`,{className:`text-muted-soft small px-1`,children:`(无子目录)`}):(0,A.jsx)(`div`,{className:`text-muted-soft small px-1`,children:`加载中…`})})]})}var rt=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),it=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),at=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),ot=e=>{let t=at(e);return t.charAt(0).toUpperCase()+t.slice(1)},st={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},ct=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},lt=(0,_.createContext)({}),ut=()=>(0,_.useContext)(lt),dt=(0,_.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=ut()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,_.createElement)(`svg`,{ref:c,...st,width:t??l??st.width,height:t??l??st.height,stroke:e??f,strokeWidth:m,className:rt(`lucide`,p,i),...!a&&!ct(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,_.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),ft=(e,t)=>{let n=(0,_.forwardRef)(({className:n,...r},i)=>(0,_.createElement)(dt,{ref:i,iconNode:t,className:rt(`lucide-${it(ot(e))}`,`lucide-${e}`,n),...r}));return n.displayName=ot(e),n},pt=ft(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),mt=ft(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),ht=ft(`folder-open`,[[`path`,{d:`m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`,key:`usdka0`}]]);function gt(e){let{value:t,onChange:n,ariaLabel:r}=e,[i,a]=(0,_.useState)(!1),o=(0,_.useRef)(null);return(0,_.useEffect)(()=>{if(!i)return;let e=e=>{o.current&&!o.current.contains(e.target)&&a(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[i]),(0,A.jsxs)(`div`,{className:`dir-picker position-relative w-100`,ref:o,children:[(0,A.jsxs)(`button`,{type:`button`,className:`form-control form-control-sm d-flex align-items-center gap-2 text-start`,onClick:()=>a(e=>!e),title:t||``,"aria-label":r,"aria-expanded":i,children:[(0,A.jsx)(ht,{size:16,className:`text-muted-soft flex-shrink-0`}),(0,A.jsx)(`span`,{className:`font-monospace text-truncate flex-grow-1`,children:t||`选择工作目录…`}),i?(0,A.jsx)(mt,{size:16,className:`flex-shrink-0`}):(0,A.jsx)(pt,{size:16,className:`flex-shrink-0`})]}),i?(0,A.jsx)(`div`,{className:`dir-picker-pop position-absolute bg-white border rounded shadow-sm p-2`,style:{zIndex:1050,left:0,right:0,top:`100%`,marginTop:4},children:(0,A.jsx)(nt,{value:t,showHeader:!1,onChange:e=>{n(e),a(!1)}})}):null]})}var _t={minWidth:0,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`};function vt(e){return e?.enabled===!0&&e.connected===!0}function yt(e){return e?.enabled?e.connected?`已连接`:e.status===`session_timeout`?`会话超时`:e.status===`connecting`?`连接中`:e.status===`poll_error`?`轮询异常`:`未连接`:`未连接`}function bt(e){return vt(e)?`badge-solid-success`:e?.status===`session_timeout`||e?.status===`poll_error`?`badge-solid-error`:e?.status===`connecting`?`badge-soft-accent`:`badge-soft-neutral`}function xt(e){return e?.enabled?e.status===`session_timeout`?`微信 bot 会话已失效,请重新扫码登录以刷新 token。`:e.status===`poll_error`?`微信消息轮询异常,请检查网络或重新扫码登录。`:e.status===`connecting`?`微信通道正在建立轮询连接。`:null:null}function St(e){switch(e){case`running`:case`active`:return{icon:`🟢`,label:`运行中`,badgeClass:`badge-solid-success`};case`starting`:return{icon:`⏳`,label:`启动中`,badgeClass:`badge-soft-accent`};case`idle`:return{icon:`✅`,label:`就绪`,badgeClass:`badge-soft-success`};case`accepted`:return{icon:`✅`,label:`已就绪`,badgeClass:`badge-soft-success`};case`error`:case`failed`:return{icon:`❌`,label:`异常`,badgeClass:`badge-solid-error`};default:return{icon:`🟡`,label:e,badgeClass:`badge-soft-neutral`}}}function Ct(e,t=Date.now()){if(!e)return`-`;let n=t-e;if(!Number.isFinite(n))return`-`;if(n<0)return`刚刚`;let r=Math.floor(n/1e3);if(r<10)return`刚刚`;if(r<60)return`${r}秒前`;let i=Math.floor(r/60);if(i<60)return`${i}分钟前`;let a=Math.floor(i/60);if(a<24)return`${a}小时前`;let o=Math.floor(a/24);if(o<30)return`${o}天前`;let s=Math.floor(o/30);return s<12?`${s}个月前`:`${Math.floor(o/365)}年前`}function wt(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.command==`string`&&t.command?t.command:null}function Tt(e){if(!e||typeof e!=`object`)return`未知`;let t=e;return t.detected===!0?typeof t.version==`string`&&t.version?`v${t.version}`:`已检测`:t.reason===`missing_binary`?`未找到可执行文件`:t.reason===`command_failed`?`命令执行失败`:typeof t.reason==`string`&&t.reason?String(t.reason):`未知`}function Et(e){if(!e||typeof e!=`object`)return`neutral`;let t=e;return t.detected===!0?`success`:typeof t.reason==`string`&&t.reason?`warning`:`neutral`}function j(e){return e===`success`?`status-dot-success`:e===`warning`?`status-dot-warning`:`status-dot-neutral`}function Dt(e){return e?e.status===`running`||e.status===`active`?`success`:e.status===`error`||e.status===`failed`?`warning`:`neutral`:`neutral`}function Ot(e){let t=vt(e.plugin),n=t?`success`:`neutral`,r=e.loginState===`loading_qr`?`正在加载二维码...`:e.plugin?.status===`session_timeout`?`重新扫码登录`:`扫码登录`;return(0,A.jsx)(`div`,{className:`soft-card channel-strip mb-2`,children:(0,A.jsxs)(`div`,{className:`d-flex align-items-center gap-2 flex-wrap`,children:[(0,A.jsx)(`span`,{className:`status-dot ${j(n)}`}),(0,A.jsx)(`span`,{className:`fw-semibold`,children:`微信通道`}),(0,A.jsx)(`span`,{className:`badge ${bt(e.plugin)}`,children:yt(e.plugin)}),e.activeUser?(0,A.jsxs)(`span`,{className:`channel-meta d-flex align-items-center gap-1`,children:[(0,A.jsx)(`span`,{className:`text-muted-soft small`,children:`当前活跃用户`}),(0,A.jsx)(`span`,{className:`small`,style:_t,title:e.activeUser.displayName??e.activeUser.platformUserId,children:e.activeUser.displayName??e.activeUser.platformUserId})]}):null,e.activeUser&&e.quota?(0,A.jsxs)(`span`,{className:`channel-meta d-flex align-items-center gap-1`,children:[(0,A.jsx)(`span`,{className:`text-muted-soft small`,children:`推送额度`}),(0,A.jsx)(`span`,{className:`small`,title:`iLink 限制:每个 24h 窗口内 bot 最多主动推送 10 条;用户在微信回条消息即可重置窗口与额度`,children:kt(e.quota)})]}):null,e.gateway?(0,A.jsxs)(`span`,{className:`channel-meta d-flex align-items-center gap-1`,style:{minWidth:0},children:[(0,A.jsx)(`span`,{className:`text-muted-soft small`,children:`网关`}),(0,A.jsx)(`span`,{className:`font-monospace text-muted-soft small`,style:{..._t,maxWidth:220},title:e.gateway,children:e.gateway})]}):null,(0,A.jsx)(`span`,{className:`ms-auto`,children:t?(0,A.jsx)(`button`,{className:`btn btn-sm btn-outline-danger`,disabled:e.busy,onClick:e.onDisconnect,type:`button`,children:e.busy?`断开中...`:`断开连接`}):(0,A.jsx)(`button`,{className:`btn btn-sm btn-accent`,disabled:e.loginState===`loading_qr`,onClick:e.onLogin,type:`button`,children:r})})]})})}function kt(e){if(e.expired||e.windowEndsAt===0)return`已用尽 · 请在微信回条消息恢复`;let t=Math.max(0,Math.round((e.windowEndsAt-Date.now())/(3600*1e3)));return`剩 ${e.remaining}/${e.limit} · 窗口约 ${t}h`}function At(e){let[t,n]=(0,_.useState)(e.defaultCwd),r=(0,_.useRef)(!1);(0,_.useEffect)(()=>{r.current||n(e.defaultCwd)},[e.defaultCwd]);let i=()=>{let n=t.trim();n&&e.onCreate?.(n)},a=e.active&&e.session?Dt(e.session):Et(e.providerInfo),o=wt(e.providerInfo);return(0,A.jsxs)(`div`,{className:`soft-card engine-bay ${e.active?`engine-bay-active`:``}`,style:{padding:14},children:[(0,A.jsxs)(`div`,{className:`d-flex align-items-center gap-2`,children:[(0,A.jsx)(`span`,{className:`status-dot ${j(a)}`}),(0,A.jsx)(`span`,{className:`fw-semibold`,style:{fontSize:15},children:e.name}),(0,A.jsx)(`span`,{className:`badge badge-soft-accent`,children:Tt(e.providerInfo)}),e.active&&e.session?(()=>{let t=St(e.session.status);return(0,A.jsxs)(`span`,{className:`badge ${t.badgeClass} ms-auto d-inline-flex align-items-center gap-1`,children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,children:t.icon}),t.label]})})():(0,A.jsxs)(`span`,{className:`badge badge-soft-neutral ms-auto d-inline-flex align-items-center gap-1`,children:[(0,A.jsx)(`span`,{"aria-hidden":`true`,children:`💤`}),`待命`]})]}),o?(0,A.jsx)(`div`,{className:`font-monospace text-muted-soft small mt-2`,style:_t,title:o,children:o}):null,e.active&&e.session?(0,A.jsxs)(`div`,{className:`engine-session-detail mt-2 pt-2 d-flex flex-column gap-1`,children:[(0,A.jsx)(`div`,{className:`text-muted-soft small`,children:`当前会话`}),(0,A.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`text-muted-soft small flex-shrink-0`,children:`会话 ID`}),(0,A.jsx)(`span`,{className:`font-monospace small`,style:_t,title:e.session.providerSessionId??`-`,children:e.session.providerSessionId??`-`})]}),(0,A.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`text-muted-soft small flex-shrink-0`,children:`工作目录`}),(0,A.jsx)(`span`,{className:`font-monospace small`,style:_t,title:e.session.cwd,children:e.session.cwd})]}),e.session.nativeTitle??e.session.resumeTitle?(0,A.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`text-muted-soft small flex-shrink-0`,children:`标题`}),(0,A.jsx)(`span`,{className:`small`,style:_t,title:e.session.nativeTitle??e.session.resumeTitle,children:e.session.nativeTitle??e.session.resumeTitle})]}):null,(0,A.jsxs)(`div`,{className:`text-muted-soft small`,children:[`创建 `,Ct(e.session.createdAt),` · 最后活跃 `,Ct(e.session.lastActivityAt)]})]}):e.lastSession?(0,A.jsxs)(`div`,{className:`engine-session-detail mt-2 pt-2 d-flex flex-column gap-1`,children:[(0,A.jsx)(`div`,{className:`text-muted-soft small`,children:`最近会话`}),(0,A.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`text-muted-soft small flex-shrink-0`,children:`会话 ID`}),(0,A.jsx)(`span`,{className:`font-monospace small`,style:_t,title:e.lastSession.providerSessionId,children:e.lastSession.providerSessionId})]}),(0,A.jsxs)(`div`,{className:`d-flex justify-content-between align-items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`text-muted-soft small flex-shrink-0`,children:`工作目录`}),(0,A.jsx)(`span`,{className:`font-monospace small`,style:_t,title:e.lastSession.cwd,children:e.lastSession.cwd})]}),(0,A.jsxs)(`div`,{className:`text-muted-soft small`,children:[`最后活跃 `,Ct(e.lastSession.updatedAt)]})]}):null,e.canCreate?(0,A.jsxs)(`div`,{className:`engine-create mt-2 pt-2 d-flex flex-column gap-2`,children:[(0,A.jsx)(gt,{value:t,ariaLabel:`${e.name} 工作目录`,onChange:e=>{r.current=!0,n(e)}}),(0,A.jsxs)(`button`,{className:`engine-create-btn d-inline-flex align-items-center align-self-end flex-shrink-0`,disabled:e.creating||!t.trim(),onClick:i,title:e.active?`新开会话`:`新建会话`,"aria-label":e.active?`新开会话`:`新建会话`,type:`button`,children:[(0,A.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,children:[(0,A.jsx)(`path`,{d:`M6 9a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3A.5.5 0 0 1 6 9M3.854 4.146a.5.5 0 1 0-.708.708L4.793 6.5 3.146 8.146a.5.5 0 1 0 .708.708l2-2a.5.5 0 0 0 0-.708z`}),(0,A.jsx)(`path`,{d:`M2 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2zm12 1a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1z`})]}),(0,A.jsx)(`span`,{children:`新会话`})]})]}):null]})}function jt(e){let t=vt(e.plugin)&&e.currentSession?e.currentSession.providerId===`codex`?`codex`:`claude`:null,n=e.lastProviderSessions??{},r=e.canCreateSession??!1,i=e.defaultWorkspace??``;return(0,A.jsxs)(`div`,{className:`engine-bays mb-2`,children:[(0,A.jsx)(At,{name:`Claude`,providerId:`claude-code`,providerInfo:e.providerStatus?.claude,active:t===`claude`,session:t===`claude`?e.currentSession:null,lastSession:t===`claude`?null:n[`claude-code`]??null,canCreate:r,defaultCwd:t===`claude`?e.currentSession?.cwd??i:n[`claude-code`]?.cwd??i,creating:e.creatingProvider===`claude-code`,onCreate:t=>e.onCreateSession?.(`claude-code`,t)},`claude`),(0,A.jsx)(At,{name:`Codex`,providerId:`codex`,providerInfo:e.providerStatus?.codex,active:t===`codex`,session:t===`codex`?e.currentSession:null,lastSession:t===`codex`?null:n.codex??null,canCreate:r,defaultCwd:t===`codex`?e.currentSession?.cwd??i:n.codex?.cwd??i,creating:e.creatingProvider===`codex`,onCreate:t=>e.onCreateSession?.(`codex`,t)},`codex`)]})}var Mt=10,Nt=100;function Pt(e){return`'${e.replace(/'/g,`'\\''`)}'`}function Ft(e){return`"${e.replace(/"/g,`""`)}"`}function It(e){if(!e.providerResumeCommand)return null;if(!e.cwd?.trim())return e.providerResumeCommand;let t=e.cwd.trim();return/^[A-Za-z]:[\\/]/.test(t)||t.startsWith(`\\\\`)?`cd /d ${Ft(t)} && ${e.providerResumeCommand}`:`cd ${Pt(t)} && ${e.providerResumeCommand}`}function Lt(e,t=Nt){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function Rt(e){let[t,n]=(0,_.useState)(null),[r,i]=(0,_.useState)(null),[a,o]=(0,_.useState)(null),[s,c]=(0,_.useState)(null),[l,u]=(0,_.useState)(null),[d,f]=(0,_.useState)({}),[p,m]=(0,_.useState)([]),[h,g]=(0,_.useState)(null),[v,y]=(0,_.useState)(`help`),[b,S]=(0,_.useState)(`idle`),[C,w]=(0,_.useState)(null),[ee,T]=(0,_.useState)(null),[te,le]=(0,_.useState)(!1),[E,D]=(0,_.useState)(null),[ue,de]=(0,_.useState)(null),[fe,pe]=(0,_.useState)(!1),O=(0,_.useRef)(null),k=(0,_.useCallback)(async()=>{T(null);try{let e=await ne();n(e.activeUser),i(e.quota??null),u(e.settings),c(e.runtimeConfig),f(e.lastProviderSessions??{}),o(e.plugin),vt(e.plugin)?(S(`connected`),w(null)):S(e=>e===`connected`?`idle`:e)}catch(e){T(e instanceof Error?e.message:String(e))}},[]),me=(0,_.useCallback)(async e=>{try{let t=await oe(e,{limit:Mt});m(t.items),g(t.nextCursor)}catch(e){T(e instanceof Error?e.message:String(e))}},[]),he=(0,_.useCallback)(async e=>{if(!(!h||fe)){pe(!0);try{let t=await oe(e,{limit:Mt,cursor:h});m(e=>[...e,...t.items]),g(t.nextCursor)}catch(e){T(e instanceof Error?e.message:String(e))}finally{pe(!1)}}},[fe,h]),ge=(0,_.useCallback)(async t=>{try{await navigator.clipboard.writeText(t),e.onNotice?.(`已复制恢复命令`)}catch(e){T(e instanceof Error?e.message:String(e))}},[e]);(0,_.useEffect)(()=>{k()},[k]),(0,_.useEffect)(()=>{t&&(v===`claude-native`?me(`claude-code`):v===`codex-native`&&me(`codex`))},[v,t,me]),(0,_.useEffect)(()=>Xe(t=>{if(t.type===`channel.user-authorized`){n(zt(t.user)),k();return}if(t.type===`channel.current-session-changed`){ae().then(t=>e.onRefreshCurrentSession?.(t)).catch(()=>void 0);return}t.type===`channel.plugin-status-changed`&&(o(t.status),t.status.enabled&&t.status.connected?(S(`connected`),w(null)):t.status.status===`session_timeout`?(S(`idle`),w(null)):S(`idle`),t.status.enabled||(c(null),f({}),n(null)),t.status.connected||e.onRefreshCurrentSession?.(null))}),[]);let _e=async()=>{le(!0);try{await ie(),o(e=>e&&{...e,enabled:!1,connected:!1,hasToken:!1,status:`disabled`}),c(null),f({}),n(null),e.onRefreshCurrentSession?.(null),S(`idle`),w(null)}catch(e){T(e instanceof Error?e.message:String(e))}finally{le(!1)}},ve=async n=>{if(!t?.platformUserId){T(`no_active_wechat_user`);return}T(null),D(n.id);try{await se({providerId:n.providerId,providerSessionId:n.id,platformUserId:t.platformUserId,chatId:t.platformUserId,cwd:n.cwd});let r=await ae();e.onRefreshCurrentSession?.(r),await k(),e.onNotice?.(`已接入会话`)}catch(e){T(e instanceof Error?e.message:String(e))}finally{D(null)}},ye=async(n,r)=>{if(!t?.platformUserId){T(`no_active_wechat_user`);return}if(!ue){T(null),de(n);try{await ce({providerId:n,cwd:r.trim(),platformUserId:t.platformUserId,chatId:t.platformUserId});let i=await ae();e.onRefreshCurrentSession?.(i),await k();let a=n===`codex`?`Codex CLI`:`Claude Code`;e.onNotice?.(`已新建 ${a} 会话 · ${r.trim()}`)}catch(e){T(e instanceof Error?e.message:String(e))}finally{de(null)}}},be=()=>{O.current?.close(),T(null),S(`loading_qr`),w(null);let e=new EventSource(x(`/api/channel/weixin/login`));O.current=e,e.addEventListener(`qr`,e=>{w(JSON.parse(e.data).qrcodeData??null),S(`showing_qr`)}),e.addEventListener(`scanned`,()=>{S(`scanned`)}),e.addEventListener(`done`,t=>{let n=JSON.parse(t.data);if(e.close(),O.current=null,!n.accountId||!n.botToken){T(`wechat_login_missing_credentials`),S(`idle`);return}re({accountId:n.accountId,botToken:n.botToken,baseUrl:n.baseUrl}).then(async()=>{S(`connected`),w(null),await k()}).catch(e=>{T(e instanceof Error?e.message:String(e)),S(`idle`)})}),e.addEventListener(`error`,t=>{e.close(),O.current=null,T((t.data?JSON.parse(t.data):{}).message??`wechat_login_failed`),S(`idle`),w(null)}),e.onerror=()=>{e.close(),O.current=null,T(`wechat_login_failed`),S(`idle`),w(null)}},xe=p.filter(e=>v===`claude-native`?e.providerId===`claude-code`:e.providerId===`codex`),Se=!!(t&&vt(a));return(0,A.jsxs)(`section`,{children:[ee?(0,A.jsx)(`div`,{className:`alert alert-danger`,role:`alert`,children:ee}):null,(0,A.jsx)(Ot,{plugin:a,activeUser:t,quota:r,gateway:s?.baseUrl,busy:te,loginState:b,onLogin:be,onDisconnect:()=>void _e()}),(0,A.jsx)(jt,{providerStatus:e.providerStatus,plugin:a,currentSession:e.currentSession,lastProviderSessions:d,canCreateSession:Se,defaultWorkspace:l?.defaultWorkspace,creatingProvider:ue,onCreateSession:(e,t)=>void ye(e,t)}),xt(a)?(0,A.jsx)(`div`,{className:`soft-card mb-2`,children:(0,A.jsx)(`div`,{className:`card-body text-muted-soft small`,children:xt(a)})}):null,a?.lastError?(0,A.jsx)(`div`,{className:`soft-card mb-2`,children:(0,A.jsxs)(`div`,{className:`card-body text-muted-soft small`,children:[`错误:`,a.lastError]})}):null,b===`showing_qr`||b===`scanned`?(0,A.jsx)(`div`,{className:`soft-card mb-2`,children:(0,A.jsxs)(`div`,{className:`card-body p-3 text-center`,children:[C?(0,A.jsx)(`div`,{className:`border rounded p-3 bg-white d-inline-flex justify-content-center`,"data-testid":`weixin-login-qr`,children:(0,A.jsx)(Me,{value:C,size:220,marginSize:2,bgColor:`#ffffff`,fgColor:`#111827`,title:`微信登录二维码`})}):null,(0,A.jsx)(`p`,{className:`text-muted-soft small mt-3 mb-0`,children:b===`scanned`?`已扫码,等待确认...`:`请使用微信扫描二维码`})]})}):null,(0,A.jsxs)(`ul`,{className:`nav nav-accent mb-2`,children:[(0,A.jsx)(`li`,{className:`nav-item`,children:(0,A.jsx)(`button`,{type:`button`,className:`nav-link ${v===`help`?`active`:``}`,onClick:()=>y(`help`),children:`帮助说明`})}),(0,A.jsx)(`li`,{className:`nav-item`,children:(0,A.jsx)(`button`,{type:`button`,className:`nav-link ${v===`claude-native`?`active`:``}`,onClick:()=>y(`claude-native`),children:`Claude 会话`})}),(0,A.jsx)(`li`,{className:`nav-item`,children:(0,A.jsx)(`button`,{type:`button`,className:`nav-link ${v===`codex-native`?`active`:``}`,onClick:()=>y(`codex-native`),children:`Codex 会话`})})]}),(0,A.jsx)(`div`,{className:`soft-card mb-2`,children:(0,A.jsx)(`div`,{className:`card-body`,children:v===`help`?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`p`,{className:`text-muted-soft small mb-3`,children:[`微信端可发送以下命令;`,Ze]}),Qe.map(e=>(0,A.jsxs)(`div`,{className:`mb-3`,children:[(0,A.jsxs)(`div`,{className:`fw-semibold mb-1`,children:[e.title,e.note?(0,A.jsxs)(`span`,{className:`text-muted-soft small fw-normal`,children:[`(`,e.note,`)`]}):null]}),(0,A.jsx)(`ul`,{className:`list-unstyled mb-0`,children:e.entries.map(e=>(0,A.jsxs)(`li`,{className:`d-flex flex-column flex-md-row gap-md-2 mb-1`,children:[(0,A.jsx)(`code`,{className:`flex-shrink-0`,children:e.command}),(0,A.jsx)(`span`,{className:`text-muted-soft small`,children:e.desc})]},e.command))})]},e.title))]}):(0,A.jsx)(A.Fragment,{children:xe.length===0?(0,A.jsx)(`p`,{className:`mb-0`,children:`暂无可恢复会话。`}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`ul`,{className:`list-unstyled mb-0`,children:xe.map(e=>(0,A.jsx)(`li`,{className:`border rounded p-3 mb-2`,children:(()=>{let t=It(e);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`div`,{className:`fw-semibold`,title:e.title??e.id,children:Lt(e.title??e.id)}),(0,A.jsx)(`div`,{className:`small text-muted-soft`,children:e.id}),t?(0,A.jsxs)(`div`,{className:`d-flex flex-wrap align-items-center gap-2`,children:[(0,A.jsxs)(`span`,{children:[`按 ID 恢复:`,t]}),(0,A.jsx)(`button`,{className:`resume-copy-btn`,"aria-label":`复制恢复命令`,onClick:()=>void ge(t),title:`复制恢复命令`,type:`button`,children:(0,A.jsx)(`i`,{className:`bi bi-copy`,"aria-hidden":`true`})})]}):null,e.cwd?(0,A.jsx)(`div`,{className:`small text-muted-soft`,children:e.cwd}):null,e.lastActivityAt?(0,A.jsxs)(`div`,{className:`small text-muted-soft`,children:[`最后活跃 `,Ct(e.lastActivityAt)]}):null,(0,A.jsx)(`button`,{className:`btn btn-accent btn-sm mt-2`,disabled:E===e.id,onClick:()=>void ve(e),type:`button`,children:E===e.id?`接入中...`:`接入会话`})]})})()},`${e.providerId}:${e.id}`))}),h?(0,A.jsx)(`div`,{className:`recoverable-load-more-wrap`,children:(0,A.jsx)(`button`,{className:`recoverable-load-more-btn`,disabled:fe,onClick:()=>void he(v===`codex-native`?`codex`:`claude-code`),type:`button`,children:fe?`加载中...`:`加载更多`})}):null]})})})})]})}function zt(e){return{id:e.id,platform:`weixin`,platformUserId:e.platformUserId,displayName:e.display_name,role:`user`,createdAt:e.authorizedAt,updatedAt:e.lastActive}}function Bt(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(null),[i,a]=(0,_.useState)(null),[o,s]=(0,_.useState)(null),[c,l]=(0,_.useState)(null),[u,d]=(0,_.useState)(null),[f,p]=(0,_.useState)(null),[m,h]=(0,_.useState)(null),[,g]=(0,_.useState)(0);(0,_.useEffect)(()=>{if(!m)return;let e=setTimeout(()=>h(null),2500);return()=>clearTimeout(e)},[m]),(0,_.useEffect)(()=>{let e=setInterval(()=>g(e=>e+1),3e4);return()=>clearInterval(e)},[]),(0,_.useEffect)(()=>{let e=setInterval(()=>{T().then(e=>s(e)).catch(()=>void 0)},1e4);return()=>clearInterval(e)},[]);let v=(0,_.useCallback)(async()=>{p(null);try{let[e,n,r,i]=await Promise.all([w(),ee(),T(),le()]);t(e),a(n),s(r),l(i),d(e.sessions[0]??null)}catch(e){p(e instanceof Error?e.message:String(e))}},[]);(0,_.useEffect)(()=>{v()},[v]);let y=e?.preferredLocalUrl??(typeof window<`u`&&window.location?.host?`http://${window.location.host}`:`http://127.0.0.1`),b=o?.running&&o.publicUrl?o.publicUrl:y;o?.running&&o.publicUrl;let x=b,S=o?.installed||o?.running||o?.enabled?null:`未配置 Relay Server`;return(0,A.jsx)(`div`,{className:`app-bg`,children:(0,A.jsxs)(`main`,{className:`container-fluid py-4`,style:{maxWidth:1200},children:[e?.update?.updateAvailable&&e.update.latestVersion!==n?(0,A.jsxs)(`div`,{className:`alert alert-soft-warning d-flex justify-content-between align-items-start gap-3 mb-3`,role:`alert`,children:[(0,A.jsxs)(`div`,{style:{minWidth:0},children:[(0,A.jsxs)(`strong`,{children:[`发现新版 v`,e.update.latestVersion]}),e.update.currentVersion?(0,A.jsxs)(`span`,{className:`text-muted-soft`,children:[`(当前 v`,e.update.currentVersion,`)`]}):null,(0,A.jsx)(`div`,{className:`small mt-1`,children:`更新命令(更新后需重启服务生效):`}),(0,A.jsxs)(`code`,{className:`d-block mt-1`,style:{whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:[`npm install -g claude-codex-wechat@latest --registry=https://registry.npmmirror.com/`,`
11
11
  `,`claude-codex-wechat restart`]})]}),(0,A.jsxs)(`div`,{className:`d-flex gap-2 flex-shrink-0`,children:[(0,A.jsx)(`button`,{type:`button`,className:`btn btn-sm btn-outline-secondary`,onClick:()=>{navigator.clipboard?.writeText(`npm install -g claude-codex-wechat@latest --registry=https://registry.npmmirror.com/
12
- claude-codex-wechat restart`)},children:`复制`}),(0,A.jsx)(`button`,{type:`button`,className:`btn-close`,"aria-label":`关闭`,onClick:()=>r(e.update?.latestVersion??null)})]})]}):null,(0,A.jsxs)(`header`,{className:`d-flex justify-content-between align-items-center flex-wrap gap-2 mb-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h1`,{style:{margin:0,fontSize:22,fontWeight:700},children:`微信远程控制台`}),(0,A.jsx)(`p`,{className:`text-muted-soft`,style:{margin:`4px 0 0`,fontSize:13},children:`通过微信控制本地 Claude Code / Codex 会话。`})]}),(0,A.jsxs)(`div`,{className:`d-flex flex-column align-items-end gap-1`,style:{minWidth:260},children:[(0,A.jsx)(`div`,{className:`d-flex align-items-center justify-content-end gap-2`,children:(0,A.jsx)(`span`,{className:`badge ${e?.ok===!0?`badge-solid-success`:`badge-soft-accent`}`,children:e?.ok===!0?`在线`:`待确认`})}),(0,A.jsx)(`a`,{className:`font-monospace text-muted-soft`,style:{fontSize:12,maxWidth:320,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},href:x,target:`_blank`,rel:`noreferrer`,title:b,children:b})]})]}),m?(0,A.jsx)(`div`,{style:{position:`fixed`,top:16,left:`50%`,transform:`translateX(-50%)`,zIndex:1050,whiteSpace:`nowrap`},className:`alert alert-success py-2 px-3 shadow-sm`,role:`status`,children:m}):null,f?(0,A.jsx)(`div`,{className:`alert alert-danger`,role:`alert`,children:f}):null,S?(0,A.jsx)(`div`,{className:`alert alert-soft-warning py-2 px-3 mb-3`,role:`status`,children:S}):null,(0,A.jsx)(Rt,{providerStatus:i,currentSession:u,onRefreshCurrentSession:d,onNotice:h})]})})}(0,v.createRoot)(document.getElementById(`root`)).render((0,A.jsx)(Bt,{}));
12
+ claude-codex-wechat restart`)},children:`复制`}),(0,A.jsx)(`button`,{type:`button`,className:`btn-close`,"aria-label":`关闭`,onClick:()=>r(e.update?.latestVersion??null)})]})]}):null,(0,A.jsxs)(`header`,{className:`d-flex justify-content-between align-items-center flex-wrap gap-2 mb-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`h1`,{style:{margin:0,fontSize:22,fontWeight:700},className:`d-flex align-items-baseline gap-2`,children:[`微信远程控制台`,e?.version?(0,A.jsxs)(`span`,{className:`text-muted-soft font-monospace fw-normal`,style:{fontSize:12},children:[`v`,e.version]}):null]}),(0,A.jsx)(`p`,{className:`text-muted-soft`,style:{margin:`4px 0 0`,fontSize:13},children:`通过微信控制本地 Claude Code / Codex 会话。`})]}),(0,A.jsxs)(`div`,{className:`d-flex flex-column align-items-end gap-1`,style:{minWidth:260},children:[(0,A.jsx)(`div`,{className:`d-flex align-items-center justify-content-end gap-2`,children:(0,A.jsx)(`span`,{className:`badge ${e?.ok===!0?`badge-solid-success`:`badge-soft-accent`}`,children:e?.ok===!0?`在线`:`待确认`})}),(0,A.jsx)(`a`,{className:`font-monospace text-muted-soft`,style:{fontSize:12,maxWidth:320,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},href:x,target:`_blank`,rel:`noreferrer`,title:b,children:b})]})]}),m?(0,A.jsx)(`div`,{style:{position:`fixed`,top:16,left:`50%`,transform:`translateX(-50%)`,zIndex:1050,whiteSpace:`nowrap`},className:`alert alert-success py-2 px-3 shadow-sm`,role:`status`,children:m}):null,f?(0,A.jsx)(`div`,{className:`alert alert-danger`,role:`alert`,children:f}):null,S?(0,A.jsx)(`div`,{className:`alert alert-soft-warning py-2 px-3 mb-3`,role:`status`,children:S}):null,(0,A.jsx)(Rt,{providerStatus:i,currentSession:u,onRefreshCurrentSession:d,onNotice:h})]})})}(0,v.createRoot)(document.getElementById(`root`)).render((0,A.jsx)(Bt,{}));
@@ -4,7 +4,7 @@
4
4
  <meta charset="UTF-8" />
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
6
  <title>Claude Codex WeChat</title>
7
- <script type="module" crossorigin src="/assets/index-DCJsgDkK.js"></script>
7
+ <script type="module" crossorigin src="/assets/index-Cq5-20Rf.js"></script>
8
8
  <link rel="stylesheet" crossorigin href="/assets/index-Bwj6FqtM.css">
9
9
  </head>
10
10
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-codex-wechat",
3
- "version": "0.1.22",
3
+ "version": "0.1.24",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.5.0",