@rubytech/create-maxy-code 0.1.402 → 0.1.405
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.
- package/dist/__tests__/launchd-plist.test.js +13 -1
- package/dist/__tests__/neo4j-darwin-dedicated.test.js +52 -0
- package/dist/__tests__/neo4j-datadir.test.js +8 -7
- package/dist/__tests__/neo4j-teardown.test.js +17 -1
- package/dist/index.js +183 -9
- package/dist/launchd-plist.js +21 -0
- package/dist/neo4j-darwin-dedicated.js +39 -0
- package/dist/neo4j-datadir.js +9 -5
- package/dist/neo4j-teardown.js +15 -0
- package/dist/uninstall.js +34 -8
- package/package.json +1 -1
- package/payload/platform/plugins/admin/skills/platform-architecture/SKILL.md +2 -2
- package/payload/platform/plugins/web-designer/skills/web-design/references/placeholders.md +19 -2
- package/payload/platform/plugins/web-designer/skills/web-design/templates/index.html +12 -12
- package/payload/platform/scripts/check-no-esm-require.mjs +3 -0
- package/payload/premium-plugins/venture-studio/PLUGIN.md +1 -1
- package/payload/premium-plugins/venture-studio/bin/scan-private-data.sh +61 -0
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/SKILL.md +31 -32
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/business-plan-template.md +5 -5
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/competitor-analysis.md +1 -1
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/compliance-research-checklist.md +2 -2
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/data-room-structure.md +1 -1
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/deck-blueprint-template.md +38 -26
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/design-tokens-application.md +2 -2
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/internal-workings-scrub.md +6 -6
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/strategy-frameworks.md +1 -1
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/references/termsheet-template.md +17 -18
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/templates/prospectus/index.html +156 -234
- package/payload/premium-plugins/venture-studio/skills/investor-data-room/templates/prospectus/term_sheet.html +13 -13
- package/payload/premium-plugins/venture-studio/skills/zero-to-prototype/references/strategy-red-team.md +1 -1
- package/payload/server/public/assets/{AdminLoginScreens-rlk263u9.js → AdminLoginScreens-D36zz_SY.js} +1 -1
- package/payload/server/public/assets/AdminShell-DH6Lcj-d.js +1 -0
- package/payload/server/public/assets/{Checkbox-Chz6bfy-.js → Checkbox-54KtArF3.js} +1 -1
- package/payload/server/public/assets/{Transcript-Bsx-bGgY.js → Transcript-BCpiXt4J.js} +1 -1
- package/payload/server/public/assets/{admin-BnZH758N.js → admin-C0FCHcJj.js} +1 -1
- package/payload/server/public/assets/{browser-CIrfyZWe.js → browser-bKeZ5iLx.js} +1 -1
- package/payload/server/public/assets/{calendar-D6Z8Kmrn.js → calendar-BDPBArFA.js} +1 -1
- package/payload/server/public/assets/chat-Cp_1ebzU.js +1 -0
- package/payload/server/public/assets/chevron-left-S7Nk-se6.js +1 -0
- package/payload/server/public/assets/data-BshlTgIW.js +1 -0
- package/payload/server/public/assets/{graph-XZJZHzvv.js → graph-Dvru9CW9.js} +1 -1
- package/payload/server/public/assets/{graph-labels-Cabqmf35.js → graph-labels-DLhR6Rit.js} +1 -1
- package/payload/server/public/assets/{maximize-2-DPe-Noig.js → maximize-2-CyPKq7HZ.js} +1 -1
- package/payload/server/public/assets/{operator-BM_CDyCb.js → operator-Ql5iQXB-.js} +1 -1
- package/payload/server/public/assets/page-ClJOW2fk.js +32 -0
- package/payload/server/public/assets/{page-E7I5sEVt.js → page-YsTtZsn6.js} +1 -1
- package/payload/server/public/assets/{public-CrdWCSk2.js → public-BlDxwcmS.js} +1 -1
- package/payload/server/public/assets/{rotate-ccw-Dwtj0NJ7.js → rotate-ccw-DSynJPZX.js} +1 -1
- package/payload/server/public/assets/useSubAccountSwitcher-CJelLQK-.css +1 -0
- package/payload/server/public/browser.html +4 -4
- package/payload/server/public/calendar.html +5 -5
- package/payload/server/public/chat.html +9 -9
- package/payload/server/public/data.html +8 -8
- package/payload/server/public/graph.html +9 -9
- package/payload/server/public/index.html +11 -11
- package/payload/server/public/operator.html +11 -11
- package/payload/server/public/public.html +9 -9
- package/payload/server/server.js +34 -32
- package/payload/server/public/assets/AdminShell-C5vWTy2n.js +0 -1
- package/payload/server/public/assets/chat-h7SytZHx.js +0 -1
- package/payload/server/public/assets/chevron-left-DSTeS1_g.js +0 -1
- package/payload/server/public/assets/data-CL7CyX1C.js +0 -1
- package/payload/server/public/assets/page-CMIbXzSg.js +0 -32
- package/payload/server/public/assets/useSubAccountSwitcher-BH-YjP0H.css +0 -1
- /package/payload/server/public/assets/{useSubAccountSwitcher-BVCMAnWK.js → useSubAccountSwitcher-DGKQxXDD.js} +0 -0
|
@@ -5,20 +5,20 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/admin-
|
|
8
|
+
<script type="module" crossorigin src="/assets/admin-C0FCHcJj.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-CAM3fms7.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/graph-labels-
|
|
12
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminShell-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-DGKQxXDD.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/graph-labels-DLhR6Rit.js">
|
|
12
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminShell-DH6Lcj-d.js">
|
|
13
13
|
<link rel="modulepreload" crossorigin href="/assets/admin-types-hioowVct.js">
|
|
14
|
-
<link rel="modulepreload" crossorigin href="/assets/Checkbox-
|
|
15
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminLoginScreens-
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/Checkbox-54KtArF3.js">
|
|
15
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminLoginScreens-D36zz_SY.js">
|
|
16
16
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-CvXuAEud.js">
|
|
17
|
-
<link rel="modulepreload" crossorigin href="/assets/maximize-2-
|
|
18
|
-
<link rel="modulepreload" crossorigin href="/assets/Transcript-
|
|
19
|
-
<link rel="modulepreload" crossorigin href="/assets/chevron-left-
|
|
20
|
-
<link rel="modulepreload" crossorigin href="/assets/page-
|
|
21
|
-
<link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-
|
|
17
|
+
<link rel="modulepreload" crossorigin href="/assets/maximize-2-CyPKq7HZ.js">
|
|
18
|
+
<link rel="modulepreload" crossorigin href="/assets/Transcript-BCpiXt4J.js">
|
|
19
|
+
<link rel="modulepreload" crossorigin href="/assets/chevron-left-S7Nk-se6.js">
|
|
20
|
+
<link rel="modulepreload" crossorigin href="/assets/page-YsTtZsn6.js">
|
|
21
|
+
<link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-CJelLQK-.css">
|
|
22
22
|
<link rel="stylesheet" crossorigin href="/assets/AdminLoginScreens-CWMpccrR.css">
|
|
23
23
|
<link rel="stylesheet" href="/brand-defaults.css">
|
|
24
24
|
</head>
|
|
@@ -5,20 +5,20 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Operator — Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/operator-
|
|
8
|
+
<script type="module" crossorigin src="/assets/operator-Ql5iQXB-.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-CAM3fms7.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminShell-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-DGKQxXDD.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminShell-DH6Lcj-d.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/admin-types-hioowVct.js">
|
|
13
|
-
<link rel="modulepreload" crossorigin href="/assets/Checkbox-
|
|
14
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminLoginScreens-
|
|
13
|
+
<link rel="modulepreload" crossorigin href="/assets/Checkbox-54KtArF3.js">
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminLoginScreens-D36zz_SY.js">
|
|
15
15
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-CvXuAEud.js">
|
|
16
|
-
<link rel="modulepreload" crossorigin href="/assets/maximize-2-
|
|
17
|
-
<link rel="modulepreload" crossorigin href="/assets/Transcript-
|
|
18
|
-
<link rel="modulepreload" crossorigin href="/assets/chevron-left-
|
|
19
|
-
<link rel="modulepreload" crossorigin href="/assets/rotate-ccw-
|
|
20
|
-
<link rel="modulepreload" crossorigin href="/assets/page-
|
|
21
|
-
<link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-
|
|
16
|
+
<link rel="modulepreload" crossorigin href="/assets/maximize-2-CyPKq7HZ.js">
|
|
17
|
+
<link rel="modulepreload" crossorigin href="/assets/Transcript-BCpiXt4J.js">
|
|
18
|
+
<link rel="modulepreload" crossorigin href="/assets/chevron-left-S7Nk-se6.js">
|
|
19
|
+
<link rel="modulepreload" crossorigin href="/assets/rotate-ccw-DSynJPZX.js">
|
|
20
|
+
<link rel="modulepreload" crossorigin href="/assets/page-ClJOW2fk.js">
|
|
21
|
+
<link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-CJelLQK-.css">
|
|
22
22
|
<link rel="stylesheet" crossorigin href="/assets/AdminLoginScreens-CWMpccrR.css">
|
|
23
23
|
<link rel="stylesheet" href="/brand-defaults.css">
|
|
24
24
|
</head>
|
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Maxy</title>
|
|
7
7
|
<link rel="icon" href="/favicon.ico">
|
|
8
|
-
<script type="module" crossorigin src="/assets/public-
|
|
8
|
+
<script type="module" crossorigin src="/assets/public-BlDxwcmS.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/chunk-CAM3fms7.js">
|
|
10
|
-
<link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-
|
|
11
|
-
<link rel="modulepreload" crossorigin href="/assets/AdminShell-
|
|
10
|
+
<link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-DGKQxXDD.js">
|
|
11
|
+
<link rel="modulepreload" crossorigin href="/assets/AdminShell-DH6Lcj-d.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/admin-types-hioowVct.js">
|
|
13
13
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-CvXuAEud.js">
|
|
14
|
-
<link rel="modulepreload" crossorigin href="/assets/maximize-2-
|
|
15
|
-
<link rel="modulepreload" crossorigin href="/assets/Transcript-
|
|
16
|
-
<link rel="modulepreload" crossorigin href="/assets/chevron-left-
|
|
17
|
-
<link rel="modulepreload" crossorigin href="/assets/rotate-ccw-
|
|
18
|
-
<link rel="modulepreload" crossorigin href="/assets/page-
|
|
19
|
-
<link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-
|
|
14
|
+
<link rel="modulepreload" crossorigin href="/assets/maximize-2-CyPKq7HZ.js">
|
|
15
|
+
<link rel="modulepreload" crossorigin href="/assets/Transcript-BCpiXt4J.js">
|
|
16
|
+
<link rel="modulepreload" crossorigin href="/assets/chevron-left-S7Nk-se6.js">
|
|
17
|
+
<link rel="modulepreload" crossorigin href="/assets/rotate-ccw-DSynJPZX.js">
|
|
18
|
+
<link rel="modulepreload" crossorigin href="/assets/page-ClJOW2fk.js">
|
|
19
|
+
<link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-CJelLQK-.css">
|
|
20
20
|
<link rel="stylesheet" href="/brand-defaults.css">
|
|
21
21
|
</head>
|
|
22
22
|
<body class="public-surface">
|
package/payload/server/server.js
CHANGED
|
@@ -1417,7 +1417,7 @@ function webchatChannelDescriptor(key) {
|
|
|
1417
1417
|
}
|
|
1418
1418
|
|
|
1419
1419
|
// app/lib/claude-auth.ts
|
|
1420
|
-
import { readFileSync, writeFileSync } from "fs";
|
|
1420
|
+
import { readFileSync, writeFileSync, renameSync, unlinkSync } from "fs";
|
|
1421
1421
|
import { sep } from "path";
|
|
1422
1422
|
import { lock } from "proper-lockfile";
|
|
1423
1423
|
if (!CLAUDE_CREDENTIALS_FILE.startsWith(MAXY_DIR + sep)) {
|
|
@@ -1473,7 +1473,17 @@ function writeOAuthCredentials(tokens) {
|
|
|
1473
1473
|
...tokens.refreshToken != null ? { refreshToken: tokens.refreshToken } : {},
|
|
1474
1474
|
expiresAt: newExpiresAt
|
|
1475
1475
|
};
|
|
1476
|
-
|
|
1476
|
+
const tmpPath = `${CLAUDE_CREDENTIALS_FILE}.${process.pid}.tmp`;
|
|
1477
|
+
try {
|
|
1478
|
+
writeFileSync(tmpPath, JSON.stringify(fileData, null, 2), "utf-8");
|
|
1479
|
+
renameSync(tmpPath, CLAUDE_CREDENTIALS_FILE);
|
|
1480
|
+
} catch (writeErr) {
|
|
1481
|
+
try {
|
|
1482
|
+
unlinkSync(tmpPath);
|
|
1483
|
+
} catch {
|
|
1484
|
+
}
|
|
1485
|
+
throw writeErr;
|
|
1486
|
+
}
|
|
1477
1487
|
return newExpiresAt;
|
|
1478
1488
|
} catch (err) {
|
|
1479
1489
|
console.error(`[claude-auth] credential write failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
@@ -8315,6 +8325,8 @@ function parseTranscript(lines, queuedPendingSuppress = /* @__PURE__ */ new Map(
|
|
|
8315
8325
|
if (!isScheduleSource(text)) {
|
|
8316
8326
|
renderOrSuppressChannelInbound(unwrapChannel(text), ts, out, queuedPendingSuppress);
|
|
8317
8327
|
}
|
|
8328
|
+
} else if (row.isMeta === true) {
|
|
8329
|
+
out.push({ kind: "harness-internal", text, ts });
|
|
8318
8330
|
} else {
|
|
8319
8331
|
out.push({ kind: "operator-typed", text, ts });
|
|
8320
8332
|
}
|
|
@@ -9259,10 +9271,10 @@ var public_reader_default = app5;
|
|
|
9259
9271
|
// server/routes/webchat.ts
|
|
9260
9272
|
import { basename as basename7, dirname as dirname6 } from "path";
|
|
9261
9273
|
import { join as join18 } from "path";
|
|
9262
|
-
import { existsSync as existsSync10, readdirSync as readdirSync11, readFileSync as readFileSync19, renameSync as
|
|
9274
|
+
import { existsSync as existsSync10, readdirSync as readdirSync11, readFileSync as readFileSync19, renameSync as renameSync4, statSync as statSync7, writeFileSync as writeFileSync7 } from "fs";
|
|
9263
9275
|
|
|
9264
9276
|
// server/canonical-webchat-override.ts
|
|
9265
|
-
import { readFileSync as readFileSync17, writeFileSync as writeFileSync5, renameSync } from "fs";
|
|
9277
|
+
import { readFileSync as readFileSync17, writeFileSync as writeFileSync5, renameSync as renameSync2 } from "fs";
|
|
9266
9278
|
import { join as join16 } from "path";
|
|
9267
9279
|
var FILE = "canonical-webchat-session.json";
|
|
9268
9280
|
var UUID = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
|
@@ -9300,7 +9312,7 @@ function writeCanonicalOverrideId(accountDir, userId, sessionId) {
|
|
|
9300
9312
|
const path2 = canonicalOverridePath(accountDir);
|
|
9301
9313
|
const tmp = `${path2}.${process.pid}.tmp`;
|
|
9302
9314
|
writeFileSync5(tmp, JSON.stringify({ byAdmin }, null, 2), "utf8");
|
|
9303
|
-
|
|
9315
|
+
renameSync2(tmp, path2);
|
|
9304
9316
|
}
|
|
9305
9317
|
|
|
9306
9318
|
// ../lib/models/src/index.ts
|
|
@@ -9346,7 +9358,7 @@ function isNewSessionEffortLevel(value) {
|
|
|
9346
9358
|
}
|
|
9347
9359
|
|
|
9348
9360
|
// ../services/claude-session-manager/src/sidecar-store.ts
|
|
9349
|
-
import { existsSync as existsSync9, mkdirSync as mkdirSync3, readdirSync as readdirSync10, readFileSync as readFileSync18, renameSync as
|
|
9361
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync3, readdirSync as readdirSync10, readFileSync as readFileSync18, renameSync as renameSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync6 } from "fs";
|
|
9350
9362
|
import { join as join17 } from "path";
|
|
9351
9363
|
function escapeRegExp(s) {
|
|
9352
9364
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -9363,11 +9375,11 @@ function createSidecarStore(config) {
|
|
|
9363
9375
|
const tmp = `${path2}.tmp.${process.pid}`;
|
|
9364
9376
|
try {
|
|
9365
9377
|
writeFileSync6(tmp, JSON.stringify(record), "utf8");
|
|
9366
|
-
|
|
9378
|
+
renameSync3(tmp, path2);
|
|
9367
9379
|
return { ok: true };
|
|
9368
9380
|
} catch (error) {
|
|
9369
9381
|
try {
|
|
9370
|
-
if (existsSync9(tmp))
|
|
9382
|
+
if (existsSync9(tmp)) unlinkSync2(tmp);
|
|
9371
9383
|
} catch {
|
|
9372
9384
|
}
|
|
9373
9385
|
return { ok: false, error };
|
|
@@ -9424,7 +9436,7 @@ function createSidecarStore(config) {
|
|
|
9424
9436
|
const path2 = pathFor(sessionsDir, id);
|
|
9425
9437
|
try {
|
|
9426
9438
|
if (existsSync9(path2)) {
|
|
9427
|
-
|
|
9439
|
+
unlinkSync2(path2);
|
|
9428
9440
|
return { ok: true, removed: true };
|
|
9429
9441
|
}
|
|
9430
9442
|
return { ok: true, removed: false };
|
|
@@ -9974,7 +9986,7 @@ ${note}` : note;
|
|
|
9974
9986
|
else parsed.adminPermissionMode = value;
|
|
9975
9987
|
const tmp = `${accountJsonPath}.${process.pid}.tmp`;
|
|
9976
9988
|
writeFileSync7(tmp, JSON.stringify(parsed, null, 2), "utf8");
|
|
9977
|
-
|
|
9989
|
+
renameSync4(tmp, accountJsonPath);
|
|
9978
9990
|
} catch (err) {
|
|
9979
9991
|
const detail = err instanceof Error ? err.message : String(err);
|
|
9980
9992
|
console.error(`[webchat:settings] op=${op} outcome=refused value=${value} reason=write-failed detail=${detail}`);
|
|
@@ -10373,7 +10385,7 @@ var telegram_default = app7;
|
|
|
10373
10385
|
|
|
10374
10386
|
// server/routes/quickbooks.ts
|
|
10375
10387
|
import { join as join21 } from "path";
|
|
10376
|
-
import { existsSync as existsSync13, readFileSync as readFileSync22, writeFileSync as writeFileSync8, mkdirSync as mkdirSync4, rmSync, renameSync as
|
|
10388
|
+
import { existsSync as existsSync13, readFileSync as readFileSync22, writeFileSync as writeFileSync8, mkdirSync as mkdirSync4, rmSync, renameSync as renameSync5 } from "fs";
|
|
10377
10389
|
var TAG24 = "[quickbooks]";
|
|
10378
10390
|
var INTUIT_TOKEN_URL = "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer";
|
|
10379
10391
|
var STATE_RE = /^[A-Za-z0-9_-]+$/;
|
|
@@ -10392,7 +10404,7 @@ async function completeConsent(args) {
|
|
|
10392
10404
|
}
|
|
10393
10405
|
const claimFile = `${pendingPath(accountDir, state)}.claimed`;
|
|
10394
10406
|
try {
|
|
10395
|
-
|
|
10407
|
+
renameSync5(pendingPath(accountDir, state), claimFile);
|
|
10396
10408
|
} catch {
|
|
10397
10409
|
console.error(`${TAG24} op=callback state=${state} stateValid=false realmId=${realmId ?? ""}`);
|
|
10398
10410
|
return { ok: false, status: 400, message: "Invalid or unknown authorization state.", stateValid: false };
|
|
@@ -10481,20 +10493,10 @@ var quickbooks_default = app8;
|
|
|
10481
10493
|
|
|
10482
10494
|
// server/routes/onboarding.ts
|
|
10483
10495
|
import { spawn, spawnSync as spawnSync2, execFileSync as execFileSync3 } from "child_process";
|
|
10484
|
-
import { openSync as openSync3, closeSync as closeSync3, writeFileSync as writeFileSync10, writeSync, existsSync as existsSync15, readFileSync as readFileSync24, unlinkSync as
|
|
10496
|
+
import { openSync as openSync3, closeSync as closeSync3, writeFileSync as writeFileSync10, writeSync, existsSync as existsSync15, readFileSync as readFileSync24, unlinkSync as unlinkSync3, renameSync as renameSync7 } from "fs";
|
|
10485
10497
|
import { createHash as createHash3, randomUUID as randomUUID7 } from "crypto";
|
|
10486
10498
|
|
|
10487
10499
|
// app/lib/claude-spawn-env.ts
|
|
10488
|
-
var HOST_AUTH_REFRESH_TIMEOUT_MS = "30000";
|
|
10489
|
-
function hostCredsEnv(platform, credsFile) {
|
|
10490
|
-
if (platform === "darwin" && credsFile) {
|
|
10491
|
-
return {
|
|
10492
|
-
CLAUDE_CODE_HOST_CREDS_FILE: credsFile,
|
|
10493
|
-
CLAUDE_CODE_HOST_AUTH_REFRESH_TIMEOUT_MS: HOST_AUTH_REFRESH_TIMEOUT_MS
|
|
10494
|
-
};
|
|
10495
|
-
}
|
|
10496
|
-
return {};
|
|
10497
|
-
}
|
|
10498
10500
|
function claudeBin() {
|
|
10499
10501
|
return process.env.CLAUDE_BIN ?? "claude";
|
|
10500
10502
|
}
|
|
@@ -10586,7 +10588,7 @@ function readHostCredsBlob(service) {
|
|
|
10586
10588
|
}
|
|
10587
10589
|
|
|
10588
10590
|
// ../lib/admins-write/src/index.ts
|
|
10589
|
-
import { existsSync as existsSync14, readFileSync as readFileSync23, writeFileSync as writeFileSync9, renameSync as
|
|
10591
|
+
import { existsSync as existsSync14, readFileSync as readFileSync23, writeFileSync as writeFileSync9, renameSync as renameSync6, mkdirSync as mkdirSync5, readdirSync as readdirSync13, statSync as statSync8, appendFileSync as appendFileSync2 } from "fs";
|
|
10590
10592
|
import { dirname as dirname7, join as join22 } from "path";
|
|
10591
10593
|
function id8(value) {
|
|
10592
10594
|
return value.slice(0, 8);
|
|
@@ -10621,7 +10623,7 @@ function writeFileAtomic(filePath, contents, mode) {
|
|
|
10621
10623
|
mkdirSync5(dirname7(filePath), { recursive: true });
|
|
10622
10624
|
const tempPath = `${filePath}.tmp-${process.pid}-${Date.now()}`;
|
|
10623
10625
|
writeFileSync9(tempPath, contents, mode !== void 0 ? { mode } : void 0);
|
|
10624
|
-
|
|
10626
|
+
renameSync6(tempPath, filePath);
|
|
10625
10627
|
}
|
|
10626
10628
|
function writeAdminEntry(input) {
|
|
10627
10629
|
const result = { usersJsonResult: "noop", accountJsonResult: "noop" };
|
|
@@ -10818,7 +10820,7 @@ app9.post("/claude-auth", async (c) => {
|
|
|
10818
10820
|
let logoutError = null;
|
|
10819
10821
|
try {
|
|
10820
10822
|
execFileSync3(claudeBin(), ["auth", "logout"], {
|
|
10821
|
-
env: { ...process.env
|
|
10823
|
+
env: { ...process.env },
|
|
10822
10824
|
encoding: "utf-8",
|
|
10823
10825
|
timeout: 8e3
|
|
10824
10826
|
});
|
|
@@ -10866,7 +10868,7 @@ app9.post("/claude-auth", async (c) => {
|
|
|
10866
10868
|
vncLog("claude-auth", { action: "start", transport: "native", platform: "darwin" });
|
|
10867
10869
|
darwinCredsBefore = listHostCredsMdats();
|
|
10868
10870
|
const claudeProc2 = spawn(claudeBin(), ["auth", "login"], {
|
|
10869
|
-
env: { ...process.env
|
|
10871
|
+
env: { ...process.env },
|
|
10870
10872
|
stdio: ["pipe", "pipe", "pipe"]
|
|
10871
10873
|
});
|
|
10872
10874
|
claudeProc2.unref();
|
|
@@ -10885,7 +10887,7 @@ app9.post("/claude-auth", async (c) => {
|
|
|
10885
10887
|
writeFile: (blob) => {
|
|
10886
10888
|
const tmp = `${CLAUDE_CREDENTIALS_FILE}.${process.pid}.tmp`;
|
|
10887
10889
|
writeFileSync10(tmp, blob, { mode: 384 });
|
|
10888
|
-
|
|
10890
|
+
renameSync7(tmp, CLAUDE_CREDENTIALS_FILE);
|
|
10889
10891
|
},
|
|
10890
10892
|
log: (line) => console.log(line)
|
|
10891
10893
|
});
|
|
@@ -11049,7 +11051,7 @@ app9.delete("/set-pin", requireAdminSession, async (c) => {
|
|
|
11049
11051
|
}
|
|
11050
11052
|
const remaining = users.filter((u) => u.userId !== sessionUserId);
|
|
11051
11053
|
if (remaining.length === 0) {
|
|
11052
|
-
|
|
11054
|
+
unlinkSync3(USERS_FILE);
|
|
11053
11055
|
console.log(`[set-pin] cleared users.json (last entry removed): userId=${sessionUserId.slice(0, 8)}\u2026`);
|
|
11054
11056
|
} else {
|
|
11055
11057
|
writeFileSync10(USERS_FILE, JSON.stringify(remaining), { mode: 384 });
|
|
@@ -11151,7 +11153,7 @@ ${body.newPin}
|
|
|
11151
11153
|
var onboarding_default = app9;
|
|
11152
11154
|
|
|
11153
11155
|
// server/routes/client-error.ts
|
|
11154
|
-
import { appendFileSync as appendFileSync3, existsSync as existsSync16, renameSync as
|
|
11156
|
+
import { appendFileSync as appendFileSync3, existsSync as existsSync16, renameSync as renameSync8, statSync as statSync9 } from "fs";
|
|
11155
11157
|
import { join as join23 } from "path";
|
|
11156
11158
|
var CLIENT_ERRORS_LOG = join23(LOG_DIR, "client-errors.log");
|
|
11157
11159
|
var MAX_LOG_SIZE = 10 * 1024 * 1024;
|
|
@@ -11204,7 +11206,7 @@ function rotateIfNeeded() {
|
|
|
11204
11206
|
if (!existsSync16(CLIENT_ERRORS_LOG)) return;
|
|
11205
11207
|
const stats = statSync9(CLIENT_ERRORS_LOG);
|
|
11206
11208
|
if (stats.size < MAX_LOG_SIZE) return;
|
|
11207
|
-
|
|
11209
|
+
renameSync8(CLIENT_ERRORS_LOG, CLIENT_ERRORS_LOG + ".1");
|
|
11208
11210
|
} catch (err) {
|
|
11209
11211
|
console.error(`[client-error] log rotation failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
11210
11212
|
}
|
|
@@ -11684,7 +11686,7 @@ var logs_default = app13;
|
|
|
11684
11686
|
import { execFileSync as execFileSync4 } from "child_process";
|
|
11685
11687
|
var app14 = new Hono();
|
|
11686
11688
|
app14.get("/", (c) => {
|
|
11687
|
-
const claudeEnv = { ...process.env
|
|
11689
|
+
const claudeEnv = { ...process.env };
|
|
11688
11690
|
let version = "unknown";
|
|
11689
11691
|
try {
|
|
11690
11692
|
const raw = execFileSync4(claudeBin(), ["--version"], { env: claudeEnv, encoding: "utf-8", timeout: 5e3 });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./chunk-CAM3fms7.js";import{C as t,D as n,I as r,L as i,M as a,O as o,S as s,T as c,_ as l,b as u,c as d,d as f,h as p,j as m,l as h,m as g,o as ee,p as te,r as ne,s as _,t as re,u as ie,v as ae,w as oe,y as se}from"./useSubAccountSwitcher-BVCMAnWK.js";async function ce(){try{let e=await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`logout`})});return e.ok?(await e.json().catch(()=>({})))?.logged_out===!0:(console.error(`[admin-ui] claude-logout http-status=${e.status}`),!1)}catch(e){return console.error(`[admin-ui] claude-logout fetch failed: ${e instanceof Error?e.message:String(e)}`),!1}}var v=e(i(),1),y=a(),b={sm:14,md:16,lg:18},x={sm:30,md:38,lg:46};function S({variant:e=`primary`,size:t=`md`,icon:n,iconPosition:r=`leading`,loading:i=!1,fullWidth:a=!1,disabled:o=!1,type:s=`button`,onClick:c,"aria-label":l,style:u,className:d,children:f}){let p=[`btn`,`btn--${e}`,t===`md`?``:`btn--${t}`,a?`btn--full`:``,d].filter(Boolean).join(` `),m=b[t],h={...e===`send`?{width:x[t],height:x[t]}:{},...u},g=Object.keys(h).length>0;return(0,y.jsxs)(`button`,{type:s,className:p,disabled:i||o,onClick:c,"aria-label":l,style:g?h:void 0,children:[(0,y.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,y.jsx)(n,{size:m}),f,n&&r===`trailing`&&(0,y.jsx)(n,{size:m})]}),i&&(0,y.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var le=n(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),ue=n(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),de=n(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),C=n(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),w=n(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),fe=n(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),T=n(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),pe=n(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),me=n(`plus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`M12 5v14`,key:`s699le`}]]),he=n(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),E=n(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),ge=n(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),D=`maxy-shell-side-px`;function O(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function k(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-O());return Math.min(Math.max(e,248),n)}function _e(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(D);if(!e)return 264;let t=parseInt(e,10);if(!Number.isFinite(t))return console.warn(`[admin-ui] sidebar-width-parse-failed stored=${JSON.stringify(e)} fallback=264`),264;if(t>=248)return k(t)}catch{}return 264}function ve({targetSelector:e=`.platform`}){let t=(0,v.useRef)(null),[n,r]=(0,v.useState)(()=>_e()),i=(0,v.useRef)(n);(0,v.useLayoutEffect)(()=>{let t=document.querySelector(e);!t||!(t instanceof HTMLElement)||(t.style.setProperty(`--side-px`,`${n}px`),i.current=n)},[n,e]);let a=(0,v.useCallback)(()=>{r(e=>{let t=k(e);return t===e?e:t})},[]);(0,v.useEffect)(()=>{a(),window.addEventListener(`resize`,a);let t=document.querySelector(e),n=null;return t instanceof HTMLElement&&(n=new MutationObserver(a),n.observe(t,{attributes:!0,attributeFilter:[`data-artefact`,`class`]})),()=>{window.removeEventListener(`resize`,a),n?.disconnect()}},[a,e]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(k(Math.round(e.clientX)))},s=()=>{if(n.releasePointerCapture(e.pointerId),n.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),!a)return;let t=i.current;try{window.localStorage.setItem(D,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=k(264);r(e);try{window.localStorage.removeItem(D)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,y.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var A=r();function ye({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,children:a}){let o=(0,v.useRef)(null),[s,c]=(0,v.useState)({position:`fixed`,visibility:`hidden`}),l=(0,v.useCallback)(()=>{let t=e.current,n=o.current;if(!t||!n)return;let r=t.getBoundingClientRect(),i=n.getBoundingClientRect(),a=r.right-i.width;a<4&&(a=4);let s=window.innerHeight-r.bottom<i.height+8&&r.top>i.height+8?r.top-i.height:r.bottom;c({position:`fixed`,left:a,top:s,visibility:`visible`})},[e]);return(0,v.useLayoutEffect)(()=>{if(l(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>l());return o.current&&e.observe(o.current),()=>e.disconnect()},[l]),(0,v.useEffect)(()=>{let n=e=>{e.key===`Escape`&&t()},r=n=>{let r=n.target;e.current?.contains(r)||o.current?.contains(r)||t()},i=n=>{let r=e.current;r&&n.target instanceof Node&&n.target.contains(r)&&t()},a=()=>t();return document.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r),window.addEventListener(`scroll`,i,!0),window.addEventListener(`resize`,a),()=>{document.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r),window.removeEventListener(`scroll`,i,!0),window.removeEventListener(`resize`,a)}},[e,t]),(0,A.createPortal)((0,y.jsx)(`div`,{ref:o,className:n,role:r,"aria-label":i,style:s,children:a}),document.body)}function be({actions:e,disabled:t}){let[n,r]=(0,v.useState)(!1),[i,a]=(0,v.useState)(null),o=(0,v.useRef)(null),s=(0,v.useCallback)(()=>{r(!1),a(null)},[]);return(0,y.jsxs)(`div`,{className:`conv-actions`,children:[(0,y.jsx)(`button`,{ref:o,type:`button`,className:`conv-action conv-actions-overflow`,onClick:()=>r(e=>!e),disabled:t,"aria-haspopup":`menu`,"aria-expanded":n,"aria-label":`Session actions`,title:`Session actions`,children:(0,y.jsx)(se,{size:12})}),n&&(0,y.jsx)(ye,{anchorRef:o,onClose:s,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,y.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,y.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`dialog`,"aria-expanded":i===e.key,disabled:t,onClick:()=>a(t=>t===e.key?null:e.key),children:[e.icon,(0,y.jsx)(`span`,{children:e.menuLabel})]}),i===e.key&&(0,y.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,y.jsxs)(`button`,{type:`button`,role:`menuitem`,className:e.danger?`conv-action-danger`:void 0,"aria-busy":e.busy,disabled:t,onClick:t=>{e.onClick?.(t),s()},children:[e.icon,(0,y.jsx)(`span`,{children:e.menuLabel})]},e.key))})]})}var j=`claude-opus-4-8[1m]`,M=`claude-sonnet-5`,N=`claude-haiku-4-5`,P={[j]:`Opus 4.8 (1M context)`,[M]:`Sonnet 5`,[N]:`Haiku 4.5`};function F(e){return P[e]??e}var I=[j,M,N];function L(e){return e.replace(/\[1m\]$/,``)}function xe(e){return I.find(t=>L(t)===L(e))??e}var Se=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],R=[`low`,`medium`,`high`,`xhigh`];[...Se],[...R],[...R];var Ce=[j,M,N],we={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},Te=Se.map(e=>({value:e,label:we[e]??e})),Ee={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},De=R.map(e=>({value:e,label:Ee[e]??e}));function z(e){if(e){let t=Ce.find(t=>L(t)===L(e));if(t)return t}return j}function Oe({row:e,adminFetch:t,onError:n}){let[r,i]=(0,v.useState)(()=>z(e.model)),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,d]=(0,v.useState)(!1),f=(0,v.useRef)(!1);(0,v.useEffect)(()=>{i(z(e.model))},[e.model]);let p=async()=>{if(!f.current){f.current=!0,d(!0);try{let i=await t(`/api/admin/session-reseat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({fromSessionId:e.sessionId,model:r,...a?{permissionMode:a}:{},...s?{effort:s}:{}})});if(!i.ok){n(`Could not reset ${e.title} (status ${i.status})`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} status=${i.status}`),f.current=!1,d(!1);return}let o=await i.json().catch(()=>({}));o.target?window.location.assign(o.target):(n(`Reset of ${e.title} returned no target`),f.current=!1,d(!1))}catch(t){n(`Could not reset ${e.title} (network error)`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} error=${t instanceof Error?t.message:String(t)}`),f.current=!1,d(!1)}}};return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`label`,{className:`reseat-field`,children:[(0,y.jsx)(`span`,{children:`Model`}),(0,y.jsx)(`select`,{"data-kind":`model`,value:r,disabled:l,onChange:e=>i(e.target.value),children:Ce.map(e=>(0,y.jsx)(`option`,{value:e,children:F(e)},e))})]}),(0,y.jsxs)(`label`,{className:`reseat-field`,children:[(0,y.jsx)(`span`,{children:`Mode`}),(0,y.jsxs)(`select`,{"data-kind":`mode`,value:a,disabled:l,onChange:e=>o(e.target.value),children:[(0,y.jsx)(`option`,{value:``,children:`Keep current`}),Te.map(e=>(0,y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,y.jsxs)(`label`,{className:`reseat-field`,children:[(0,y.jsx)(`span`,{children:`Effort`}),(0,y.jsxs)(`select`,{"data-kind":`effort`,value:s,disabled:l,onChange:e=>c(e.target.value),children:[(0,y.jsx)(`option`,{value:``,children:`Keep current`}),De.map(e=>(0,y.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,y.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:l,"aria-busy":l,onClick:()=>void p(),children:l?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(u,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}function B(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function ke(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}async function V(e){if(navigator.clipboard)try{return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}function Ae({target:e,onConfirm:t,onCancel:n}){return e?(0,y.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,y.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete session`,children:[(0,y.jsxs)(`div`,{className:`claude-info-header`,children:[(0,y.jsx)(`span`,{children:`Delete this conversation?`}),(0,y.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[`This permanently removes the transcript. It is not moved to Archive and cannot be recovered.`,e.live&&(0,y.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,y.jsx)(S,{variant:`danger`,size:`sm`,style:{flex:1},onClick:t,children:`Delete`}),(0,y.jsx)(S,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:n,children:`Cancel`})]})]})}):null}var je=`auth-refresh-failed`;function Me({error:e,onClose:t}){if(!e)return null;let n=e.reason===je,r=n?`Claude sign-in expired`:`Session didn’t open`,i=n?`Your claude.ai login has expired. Re-authenticate to resume sessions.`:`The session did not bind within 60 seconds, so there is no live conversation to open.`;return(0,y.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,y.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,y.jsxs)(`div`,{className:`claude-info-header`,children:[(0,y.jsx)(`span`,{children:r}),(0,y.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,y.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,y.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function Ne(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,v.useState)(null);if(!t)return null;let u=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),d=u.at(-1),f=d?.peak_request_pct==null?d?.context_window?Math.round((d.input_tokens+d.cache_creation_tokens+d.cache_read_tokens)/d.context_window*100):0:Math.round(d.peak_request_pct*100),p=u.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),m=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),h=u.reduce((e,t)=>e+(t.total_cost_usd??0),0),g=r?.account?.subscriptionType,ee=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,y.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,y.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,y.jsxs)(`div`,{className:`claude-info-header`,children:[(0,y.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,y.jsx)(`span`,{children:`Claude Code`}),(0,y.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,children:[(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,y.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,y.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,y.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:ee(m.resetsAt)})]}),m.isUsingOverage&&(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,y.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,children:[(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:p>0?ke(p):`—`})]}),(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,y.jsx)(`span`,{className:`claude-info-value`,children:B(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,y.jsxs)(`div`,{className:`claude-info-row`,children:[(0,y.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,y.jsx)(`button`,{type:`button`,className:`claude-info-value claude-info-id-copy`,title:`${e} (${o?`flushed`:`pre-flush`}) — click to copy`,onClick:async()=>{l(await V(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}function Pe({open:e,onConnect:t,onClose:n}){return e?(0,y.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,y.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Claude is not connected`,children:[(0,y.jsxs)(`div`,{className:`claude-info-header`,children:[(0,y.jsx)(`span`,{children:`Claude isn’t connected`}),(0,y.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,y.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`,display:`flex`,flexDirection:`column`,gap:`10px`},children:[(0,y.jsx)(`span`,{children:`This needs Claude, which is currently disconnected. Connect to continue — the rest of the dashboard stays available either way.`}),(0,y.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:[(0,y.jsx)(S,{variant:`primary`,size:`sm`,onClick:t,children:`Connect Claude`}),(0,y.jsx)(`button`,{type:`button`,className:`claude-info-close`,style:{fontSize:`11px`},onClick:n,children:`Not now`})]})]})]})}):null}function H(e){let t=Math.round(e/6e4),n=Math.floor(t/60),r=t%60;return`${n}h ${String(r).padStart(2,`0`)}m`}function Fe(e){return e.activeMs.thinking+e.activeMs.messaging+e.activeMs.toolUse}function U(e){return e.toLocaleString(`en-GB`)}function Ie(e){return`£${e.toFixed(2)}`}function W({label:e,d:t,bold:n}){let r=n?`th`:`td`;return(0,y.jsxs)(`tr`,{className:n?`usage-total-row`:void 0,children:[(0,y.jsx)(r,{className:`usage-day`,children:e}),(0,y.jsx)(r,{children:H(Fe(t))}),(0,y.jsx)(r,{children:U(t.tokens.output)}),(0,y.jsx)(r,{children:U(t.tokens.input)}),(0,y.jsx)(r,{children:U(t.tokens.cacheWrite)}),(0,y.jsx)(r,{children:U(t.tokens.cacheRead)}),(0,y.jsx)(r,{children:Ie(t.costGBP.opus)}),(0,y.jsx)(r,{children:Ie(t.costGBP.sonnet)})]})}function Le({show:e,onClose:t,sessionId:n,summary:r,loading:i,error:a}){return e?(0,y.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,y.jsxs)(`div`,{className:`claude-info-modal usage-modal`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-label":`Session usage and cost`,children:[(0,y.jsxs)(`div`,{className:`claude-info-header`,children:[(0,y.jsxs)(`span`,{children:[`Usage & cost`,n?` · ${n.slice(0,8)}`:``]}),(0,y.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:(0,y.jsx)(g,{size:14})})]}),(0,y.jsxs)(`div`,{className:`claude-info-section usage-body`,children:[i&&(0,y.jsx)(`div`,{className:`usage-note`,children:`Computing usage…`}),!i&&a&&(0,y.jsx)(`div`,{className:`usage-note usage-error`,children:a}),!i&&!a&&r&&r.days.length===0&&(0,y.jsx)(`div`,{className:`usage-note`,children:`No usage recorded for this session yet.`}),!i&&!a&&r&&r.days.length>0&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`div`,{className:`usage-table-scroll`,children:(0,y.jsxs)(`table`,{className:`usage-table`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`th`,{className:`usage-day`,children:`Day`}),(0,y.jsx)(`th`,{children:`Active`}),(0,y.jsx)(`th`,{children:`Output tok`}),(0,y.jsx)(`th`,{children:`Input tok`}),(0,y.jsx)(`th`,{children:`Cache write`}),(0,y.jsx)(`th`,{children:`Cache read`}),(0,y.jsx)(`th`,{children:`Opus 4.8 (£)`}),(0,y.jsx)(`th`,{children:`Sonnet 4.6 (£)`})]})}),(0,y.jsxs)(`tbody`,{children:[r.days.map(e=>(0,y.jsx)(W,{label:e.date,d:e},e.date)),(0,y.jsx)(W,{label:`TOTAL (${r.days.length} d)`,d:r.totals,bold:!0})]})]})}),(0,y.jsxs)(`div`,{className:`usage-note usage-caveats`,children:[`Prices dated `,r.pricing.opusPriceDate,` · £/$ `,r.pricing.usdPerGbp,` · Sonnet tokenizer factor `,r.pricing.tokenizerFactor,`. Idle human-wait dominates the calendar span; cache-read tokens dominate cost; Sonnet is a tokenizer-adjusted estimate.`]})]})]})]})}):null}var Re=`https://claude.ai/code`,ze=200,Be=[500,1e3,1500,2e3,2500,3e3,3e3];function Ve(e,t,n){if(e&&n.target)return{kind:`navigate`,url:n.target,sameOrigin:!0};let r=n.slug??n.bridgeSessionId??null;if(e&&r)return{kind:`navigate`,url:`${Re}/${r}`,sameOrigin:!1};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function He(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function Ue(e){let{businessName:n,cacheKey:r,onConnectClaude:i,role:a,userName:u,userAvatar:f,onSelectProjects:g,onSelectPeople:re,onSelectTasks:se,onSelectAgents:ce,onCloseMobileDrawer:b,collapsed:x,selectedWhatsappId:S,onSelectWhatsappConversation:D,initialWhatsappSurface:O=!1,onSelectData:k,onCloseData:_e,initialDataSurface:ve=!1}=e,A=te(r),ye=(0,v.useCallback)(e=>({key:`reseat`,label:`Reset session ${e.title} (model, mode, effort)`,menuLabel:`Reset`,title:`Reset — move this session onto a chosen model, mode, and effort`,icon:(0,y.jsx)(he,{size:12}),panelClassName:`reseat-panel`,panel:()=>(0,y.jsx)(Oe,{row:e,adminFetch:A,onError:e=>B({message:e,failed:!0})})}),[A]),j=o.productName,M=typeof u==`string`?u:u===null?`name unavailable`:n||j,N=(M.trim().charAt(0)||`?`).toUpperCase(),[P,F]=(0,v.useState)(ve?`data`:O?`whatsapp`:`sessions`),[I,L]=(0,v.useState)([]),[xe,Se]=(0,v.useState)(!1),[R,Ce]=(0,v.useState)(null),[we,Te]=(0,v.useState)(!1),[Ee,De]=(0,v.useState)(`file`),[z,B]=(0,v.useState)(null),[ke,V]=(0,v.useState)(null),[je,Ne]=(0,v.useState)(!1),[H,Fe]=(0,v.useState)([]),[U,Ie]=(0,v.useState)(!1),[W,Re]=(0,v.useState)(null),[Ue,We]=(0,v.useState)(!1),[G,Je]=(0,v.useState)(!1),[K,Ye]=(0,v.useState)(!1),[Xe,Ze]=(0,v.useState)(null),[q,Qe]=(0,v.useState)(new Set),[$e,et]=(0,v.useState)(null),[J,tt]=(0,v.useState)(new Set),[nt,rt]=(0,v.useState)(new Set),[it,at]=(0,v.useState)(new Set),[Y,ot]=(0,v.useState)(null),[st,X]=(0,v.useState)(``),[ct,lt]=(0,v.useState)(!1),[ut,dt]=(0,v.useState)(null),[ft,pt]=(0,v.useState)(null),[mt,ht]=(0,v.useState)(!1),[gt,_t]=(0,v.useState)(null),[Z,vt]=(0,v.useState)(!1),yt=(0,v.useRef)(0),[bt,xt]=(0,v.useState)([]),[St,Ct]=(0,v.useState)(!1),[wt,Tt]=(0,v.useState)(null),[Et,Dt]=(0,v.useState)(`whatsapp`),Ot=(0,v.useCallback)(e=>{if(b(),!r){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=no-cache-key`),B({message:`Session not ready — try again`,failed:!0});return}if(!e.downloadPath){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=not-downloadable`),B({message:`${e.name} can’t be downloaded`,failed:!0});return}console.info(`[admin-ui] artefact-download id=${e.id} root=${e.downloadRoot??`data`} path=${e.downloadPath}`),ne(r,e.downloadPath,e.downloadRoot??`data`),B({message:`Downloading ${e.name}`,failed:!1})},[r,b]);(0,v.useEffect)(()=>{if(!z)return;let e=setTimeout(()=>B(null),2500);return()=>clearTimeout(e)},[z]);let kt=(0,v.useCallback)(async()=>{if(r){Te(!0),Ce(null);try{let e=await A(`/api/admin/sidebar-artefacts`);if(!e.ok)throw Error(`status ${e.status}`);L((await e.json()).artefacts??[]),Se(!0)}catch(e){let t=e instanceof Error?e.message:String(e);Ce(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{Te(!1)}}},[r,A]),Q=(0,v.useCallback)(async()=>{if(!r)return null;let e=++yt.current;We(!0),Re(null);try{let t=await A(`/api/admin/sidebar-sessions`);if(!t.ok)throw Error(`status ${t.status}`);let n=await t.json(),r=n.sessions??[];return e===yt.current?(Fe(r),Ze(n.accountId??null),Ie(!0),r):(console.info(`[admin-ui] sidebar-sessions-stale-response-dropped token=${e}`),r)}catch(t){let n=t instanceof Error?t.message:String(t);return e===yt.current&&Re(`Failed to load sessions: ${n}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${n}`),null}finally{e===yt.current&&We(!1)}},[r,A]),At=(0,v.useCallback)(async()=>{if(r){Tt(null);try{let e=await A(`/api/whatsapp-reader/conversations`);if(!e.ok)throw Error(`status ${e.status}`);xt((await e.json()).conversations??[]),Ct(!0)}catch(e){let t=e instanceof Error?e.message:String(e);Tt(`Couldn't load conversations.`),console.error(`[admin-ui] channel-convos fetch failed: ${t}`)}}},[r,A]);(0,v.useEffect)(()=>{!r||U||Q()},[r,U,Q]),(0,v.useEffect)(()=>{if(!r)return;let e=null;return At(),e=setInterval(()=>{At()},Ge),()=>{e!==null&&clearInterval(e)}},[r,At]),(0,v.useEffect)(()=>{if(!r)return;let e=null;function t(){console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=poll`),Q()}function n(){e===null&&(e=setInterval(t,Ke))}function i(){e!==null&&(clearInterval(e),e=null)}function a(){document.hidden?i():(t(),n())}return document.hidden||n(),document.addEventListener(`visibilitychange`,a),()=>{i(),document.removeEventListener(`visibilitychange`,a)}},[r,Q]);let jt=(0,v.useMemo)(()=>{let e=new Map;for(let t of _)e.set(t,[]);for(let t of bt)e.get(t.channel)?.push(t);for(let t of _)console.info(`[admin-ui] sidebar-nav surface=${t} count=${e.get(t).length}`);return e},[bt]),Mt={whatsapp:`WhatsApp`,telegram:`Telegram`,webchat:`Webchat`},Nt=()=>{D(null),F(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${xe?I.length:0} collapsed=${x}`),kt()},$=1.5,Pt=()=>{console.info(`[admin-ui] sidebar-refresh surface=artefacts`),kt()},Ft=()=>{D(null),F(`sessions`),console.info(`[admin-ui] sidebar-nav surface=sessions count=${U?H.length:0} collapsed=${x}`),U||Q()},It=()=>{console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=manual`),Q()},Lt=()=>{F(`data`),console.info(`[admin-ui] sidebar-nav surface=data collapsed=${x}`),k(),b()},Rt=e=>{_e?.(),F(`whatsapp`),Dt(e),console.info(`[admin-ui] sidebar-nav surface=${e} count=${jt.get(e)?.length??0} collapsed=${x}`)},zt=(0,v.useCallback)(async e=>{if(J.has(e.sessionId))return;tt(t=>{let n=new Set(t);return n.add(e.sessionId),n});let t=window.open(``,`_blank`);try{let n=await A(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,name:e.title||e.sessionId,...e.accountId?{targetAccountId:e.accountId}:{}})}),r=await n.json().catch(()=>({})),i=Ve(n.ok,n.status,{...r,sessionId:r.sessionId??e.sessionId});console.info(`[admin-ui] sidebar-session-resume sessionId=${e.sessionId} status=${n.status} outcome=${i.kind} slug=${r.slug??r.bridgeSessionId??`none`}`),i.kind===`navigate`?(b(),t?t.location.href=i.url:window.open(i.url,`_blank`)):(t?.close(),console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} status=${n.status} reason=${i.reason}`),V(i))}catch(n){t?.close();let r=n instanceof Error?n.message:String(n);console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} error=${r}`),V({sessionId:e.sessionId,reason:r})}finally{tt(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[A,b,J]),Bt=(0,v.useCallback)(async e=>{let t=e.slice(0,8);for(let n=1;n<=Be.length;n++){await new Promise(e=>setTimeout(e,Be[n-1]));let r=await Q();if(r&&r.some(t=>t.sessionId===e)){console.info(`[admin-ui] sidebar-new-session-converged sessionId=${t} via=retry attempts=${n}`);return}}console.error(`[admin-ui] sidebar-new-session-converge-timeout sessionId=${t}`)},[Q]),Vt=(0,v.useCallback)(async()=>{if(!Z){vt(!0);try{let e=await A(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}),t=await e.json().catch(()=>({})),n=Ve(e.ok,e.status,t);console.info(`[admin-ui] sidebar-new-session-spawned status=${e.status} outcome=${n.kind} slug=${t.slug??t.bridgeSessionId??`none`}`),n.kind===`navigate`?n.sameOrigin?window.location.assign(n.url):(window.open(n.url,`_blank`),t.sessionId?Bt(t.sessionId):console.error(`[admin-ui] sidebar-new-session-converge-skipped reason=no-session-id`)):e.status===503||n.reason===`claude-auth-dead`?(console.info(`[admin-ui] op=llm-action-blocked action=spawn reason=claude-disconnected`),Ne(!0)):(console.error(`[admin-ui] sidebar-new-session-failed status=${e.status} reason=${n.reason}`),V(n))}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-new-session-failed error=${t}`),V({sessionId:null,reason:t})}finally{vt(!1)}}},[A,Z,Bt]),Ht=(0,v.useCallback)((e,t)=>{e.stopPropagation(),et(t)},[]),Ut=(0,v.useCallback)(async(e,t)=>{e.stopPropagation(),dt(t),pt(null),_t(null),ht(!0);try{let e=await A(`/api/admin/session-usage?sessionId=${encodeURIComponent(t.sessionId)}`),n=await e.json().catch(()=>({}));e.ok?pt(n):_t(n.error??`status ${e.status}`)}catch(e){_t(e instanceof Error?e.message:String(e))}finally{ht(!1)}},[A]),Wt=(0,v.useCallback)(async e=>{if(!q.has(e.sessionId)){Qe(t=>{let n=new Set(t);return n.add(e.sessionId),n});try{let t=await A(`/api/admin/session-delete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId})});if(!t.ok){let n=await t.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} status=${t.status} error=${n.error??`unknown`}`),B({message:`Delete failed: ${n.error??`status ${t.status}`}`,failed:!0});return}let n=await t.json();console.info(`[admin-ui] sidebar-session-delete sessionId=${e.sessionId} live=${e.live} confirmed=true pidKilled=${n.pidKilled??`?`} deleted=${n.deleted??`?`}`),Fe(t=>t.filter(t=>t.sessionId!==e.sessionId)),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} error=${n}`),B({message:`Delete failed: ${n}`,failed:!0})}finally{Qe(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}}},[A,q,Q]),Gt=(0,v.useCallback)(async(e,t)=>{if(e.stopPropagation(),!nt.has(t.sessionId)){rt(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await A(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId})});if(!e.ok){let n=await e.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} status=${e.status} error=${n.error??`unknown`}`),B({message:`Stop failed: ${n.error??`status ${e.status}`}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-stop sessionId=${t.sessionId}`),Q()}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} error=${n}`),B({message:`Stop failed: ${n}`,failed:!0})}finally{rt(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[A,nt,Q]),Kt=(0,v.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!it.has(t.sessionId)){at(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await A(`/api/admin/session-archive`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId,mode:n})});if(!e.ok){let r=await e.json().catch(()=>({})),i=r.detail??r.error??`status ${e.status}`;console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} status=${e.status} error=${r.error??`unknown`}`),B({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${i}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-archive sessionId=${t.sessionId} mode=${n}`),Q()}catch(e){let r=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} error=${r}`),B({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${r}`,failed:!0})}finally{at(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[A,it,Q]),qt=(0,v.useCallback)(async e=>{let t=st.trim();if(!t){B({message:`Title can’t be empty`,failed:!0});return}if(t.length>ze){B({message:`Title too long (max ${ze})`,failed:!0});return}lt(!0);try{let n=await A(`/api/admin/session-rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,title:t})});if(!n.ok){let t=await n.json().catch(()=>({})),r=t.reason??t.error??`status ${n.status}`;console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${r}`),B({message:`Rename failed: ${r}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=ok`),ot(null),X(``),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${n}`),B({message:`Rename failed: ${n}`,failed:!0})}finally{lt(!1)}},[A,st,Q]);return(0,y.jsxs)(`aside`,{className:`side`,children:[(0,y.jsx)(`div`,{className:`side-new-session-row`,children:(0,y.jsxs)(`button`,{type:`button`,className:`side-new-session`,onClick:Vt,disabled:Z,"aria-busy":Z,children:[(0,y.jsx)(me,{size:14}),(0,y.jsx)(`span`,{children:Z?`Spawning…`:`New session`})]})}),(0,y.jsxs)(`nav`,{className:`side-nav`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),re(),b()},children:[(0,y.jsx)(ge,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`People`}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),ce(),b()},children:[(0,y.jsx)(de,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`Agents`}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),g(),b()},children:[(0,y.jsx)(C,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:m().term}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),se(),b()},children:[(0,y.jsx)(T,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row${P===`artefacts`?` active`:``}`,onClick:Nt,children:[(0,y.jsx)(s,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row${P===`sessions`?` active`:``}`,onClick:Ft,children:[(0,y.jsx)(fe,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`Sessions`}),(0,y.jsx)(`span`,{className:`kbd`})]}),(0,y.jsxs)(`button`,{type:`button`,className:`nav-row${P===`data`?` active`:``}`,onClick:Lt,children:[(0,y.jsx)(c,{size:20,strokeWidth:$}),(0,y.jsx)(`span`,{className:`label`,children:`Data`}),(0,y.jsx)(`span`,{className:`kbd`})]}),St&&_.filter(e=>jt.get(e).length>0).map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`nav-row${P===`whatsapp`&&Et===e?` active`:``}`,onClick:()=>Rt(e),children:[(0,y.jsx)(h,{channel:e,size:16}),(0,y.jsx)(`span`,{className:`label`,children:Mt[e]}),(0,y.jsx)(`span`,{className:`kbd`})]},e)),wt&&(0,y.jsx)(`div`,{className:`nav-row`,style:{color:`var(--text-tertiary)`,cursor:`default`},"aria-disabled":`true`,children:(0,y.jsx)(`span`,{className:`label`,children:wt})})]}),P===`artefacts`&&(0,y.jsxs)(`div`,{className:`side-list`,children:[(0,y.jsxs)(`div`,{className:`group-head`,children:[(0,y.jsx)(`span`,{children:`Artefacts`}),(0,y.jsxs)(`span`,{className:`group-head-meta`,children:[(0,y.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh artefacts`,"aria-label":`Refresh artefacts`,onClick:Pt,disabled:we,children:(0,y.jsx)(l,{size:12,className:we?`spinning`:void 0})}),(0,y.jsx)(`span`,{children:we?`…`:String(I.length)})]})]}),R&&(0,y.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:R}),xe&&!R&&I.length>0&&(()=>{let e=I.filter(e=>e.kind===`agent-template`).length,t=I.length-e;return(0,y.jsx)(`div`,{className:`artefact-filter-chips`,children:[{key:`all`,label:`All`,count:I.length},{key:`agent`,label:`Agents`,count:e},{key:`file`,label:`Files`,count:t}].map(e=>(0,y.jsxs)(`button`,{type:`button`,className:`artefact-filter-chip${Ee===e.key?` active`:``}`,onClick:()=>De(e.key),disabled:e.count===0&&e.key!==`all`,children:[e.label,(0,y.jsx)(`span`,{className:`artefact-filter-chip-count`,children:e.count})]},e.key))})})(),xe&&!R&&I.length===0&&(0,y.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),I.filter(e=>Ee===`all`?!0:Ee===`agent`?e.kind===`agent-template`:e.kind!==`agent-template`).map(e=>{let t=e.kind===`agent-template`,n=t?de:s,r=He(e.updatedAt),i=e.downloadPath!==null;return(0,y.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>Ot(e),disabled:!i,style:i?void 0:{cursor:`default`},title:i?`Download ${e.name}`:`${e.name} can’t be downloaded`,children:[(0,y.jsx)(n,{size:14,className:`conv-icon`,"data-kind":t?`agent`:`file`,"aria-label":t?`agent template`:`file`}),(0,y.jsxs)(`span`,{className:`conv-stack`,children:[(0,y.jsx)(`span`,{className:`conv-name-line`,children:(0,y.jsx)(`span`,{className:`conv-name`,children:e.name})}),r&&(0,y.jsx)(`span`,{className:`conv-timestamp`,children:r})]}),i&&(0,y.jsx)(oe,{size:12,className:`conv-rc-icon`,"aria-hidden":`true`})]},e.id)})]}),P===`sessions`&&(()=>{let e=H.filter(e=>G?!0:!e.isSubagent).filter(e=>K?!0:!e.archived),n=H.some(e=>e.isSubagent),r=H.some(e=>e.archived);return(0,y.jsxs)(`div`,{className:`side-list`,children:[(0,y.jsxs)(`div`,{className:`group-head`,children:[(0,y.jsx)(`span`,{children:`Sessions`}),(0,y.jsxs)(`span`,{className:`group-head-meta`,children:[(0,y.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:It,disabled:Ue,children:(0,y.jsx)(l,{size:12,className:Ue?`spinning`:void 0})}),(0,y.jsx)(`span`,{children:Ue?`…`:String(e.length)})]})]}),Xe&&(0,y.jsx)(`div`,{className:`side-account-id`,title:`This install's accountId. The first 8 characters match the truncated UUID label on the live Remote Control daemon entry in claude.ai/code.`,children:(0,y.jsx)(`code`,{children:Xe})}),(n||r)&&(0,y.jsxs)(`div`,{className:`artefact-filter-chips`,children:[n&&(0,y.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${G?` active`:``}`,"aria-pressed":G,onClick:()=>Je(e=>!e),title:G?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),r&&(0,y.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${K?` active`:``}`,"aria-pressed":K,onClick:()=>Ye(e=>!e),title:K?`Hide archived sessions`:`Show archived sessions`,children:`Archived`})]}),W&&(0,y.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:W}),U&&!W&&e.length===0&&(0,y.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),e.map(e=>{let n=He(e.startedAt),r=J.has(e.sessionId),i=q.has(e.sessionId),a=nt.has(e.sessionId),o=it.has(e.sessionId),s=r||i||a||o,c=()=>{window.location.assign(`/chat?session=${e.sessionId}`)},l=[{key:`open`,label:`Resume session ${e.title} in claude.ai/code`,menuLabel:`Resume in claude.ai/code`,title:`Resume in a fresh local Remote Control PTY`,icon:(0,y.jsx)(t,{size:12}),busy:r,onClick:()=>{zt(e)}},{key:`message`,label:`Open session ${e.title} in admin webchat`,menuLabel:`Open in webchat`,title:`Open in admin webchat (/chat) — sending resumes this session`,icon:(0,y.jsx)(pe,{size:12}),onClick:()=>{c()}},{key:`usage`,label:`Usage and cost for session ${e.title}`,menuLabel:`Usage & cost`,title:`Per-day active time, tokens, and estimated GBP cost`,icon:(0,y.jsx)(w,{size:12}),onClick:t=>{Ut(t,e)}},...e.live?[{key:`stop`,label:`Stop session ${e.title}`,menuLabel:`Stop`,title:`Stop session process (keeps the conversation, can resume later)`,icon:(0,y.jsx)(E,{size:12}),busy:a,onClick:t=>{Gt(t,e)}}]:[],e.archived?{key:`unarchive`,label:`Unarchive session ${e.title}`,menuLabel:`Unarchive`,title:`Unarchive (move back to the active list)`,icon:(0,y.jsx)(le,{size:12}),busy:o,onClick:t=>{Kt(t,e,`unarchive`)}}:{key:`archive`,label:`Archive session ${e.title}`,menuLabel:`Archive`,title:`Archive (hide from the list, keeps the conversation resumable)`,icon:(0,y.jsx)(ue,{size:12}),busy:o,onClick:t=>{Kt(t,e,`archive`)}},{key:`rename`,label:`Rename session ${e.title}`,menuLabel:`Rename`,title:`Rename this session`,icon:(0,y.jsx)(ae,{size:12}),busy:ct&&Y===e.sessionId,onClick:t=>{t.stopPropagation(),ot(e.sessionId),X(e.personName??e.title)}},{key:`delete`,label:`Delete session ${e.title}`,menuLabel:`Delete`,title:`Delete session (stops the process, removes the conversation)`,icon:(0,y.jsx)(p,{size:12}),danger:!0,busy:i,onClick:t=>{Ht(t,e)}},ye({sessionId:e.sessionId,model:e.model??null,title:e.personName??e.title})];return(0,y.jsxs)(`div`,{className:`conv conv-with-actions`,children:[(0,y.jsxs)(`div`,{className:`conv-main-static conv-main-clickable`,role:`button`,tabIndex:0,"aria-label":`Open ${e.personName??e.title} in webchat`,onClick:()=>{Y!==e.sessionId&&c()},onKeyDown:t=>{Y!==e.sessionId&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),c())},children:[(0,y.jsx)(`span`,{className:`conv-live-dot`,"data-live":e.live?`1`:`0`,"aria-label":e.live?`live session`:`ended session`}),(0,y.jsxs)(`span`,{className:`conv-stack`,children:[(0,y.jsxs)(`span`,{className:`conv-name-line`,children:[e.channel&&(0,y.jsx)(ie,{channel:e.channel,size:13}),Y===e.sessionId?(0,y.jsx)(`input`,{className:`conv-name conv-name-edit`,autoFocus:!0,value:st,disabled:ct,"aria-label":`New title for session ${e.title}`,onChange:e=>X(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),qt(e)):t.key===`Escape`&&(t.preventDefault(),ot(null),X(``))},onBlur:()=>{Y===e.sessionId&&!ct&&(ot(null),X(``))}}):(0,y.jsx)(`span`,{className:`conv-name`,title:e.personName??e.title,children:e.personName??e.title})]}),(0,y.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,y.jsx)(`code`,{className:`conv-session-id`,title:`First 8 characters of this session's id — distinguishes rows with identical auto-titles. The resume/delete buttons act on the full id.`,children:e.sessionId.slice(0,8)}),n&&(0,y.jsxs)(`span`,{children:[` · `,n]})]})]})]}),(0,y.jsx)(be,{actions:l,disabled:s})]},e.sessionId)})]})})(),P===`whatsapp`&&(0,y.jsxs)(`div`,{className:`side-list`,children:[(0,y.jsxs)(`div`,{className:`group-head`,children:[(0,y.jsx)(`span`,{children:Mt[Et]}),(0,y.jsxs)(`span`,{className:`group-head-meta`,children:[(0,y.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh conversations`,"aria-label":`Refresh conversations`,onClick:()=>{At()},children:(0,y.jsx)(l,{size:12})}),(0,y.jsx)(`span`,{children:String(jt.get(Et).length)})]})]}),jt.get(Et).map(e=>{let t=He(e.lastMessageAt),n=d(e);return(0,y.jsxs)(`div`,{className:`conv conv-with-actions${e.source===`store`?e.scope===`admin`?` conv-scope-admin`:` conv-scope-public`:``}${S===n?` active`:``}`,children:[(0,y.jsxs)(`button`,{type:`button`,className:`conv-main-static conv-main-btn`,onClick:()=>{D(e),b()},title:e.title,children:[(0,y.jsx)(h,{channel:e.channel,size:14}),(0,y.jsxs)(`span`,{className:`conv-stack`,children:[(0,y.jsx)(`span`,{className:`conv-name-line`,children:(0,y.jsx)(`span`,{className:`conv-name`,children:ee(e)})}),t&&(0,y.jsx)(`span`,{className:`conv-timestamp`,children:t})]})]}),e.source===`session`&&(0,y.jsx)(be,{actions:[ye({sessionId:e.sessionId,model:e.model,title:e.title})],disabled:!1})]},n)})]}),(0,y.jsx)(qe,{}),(0,y.jsxs)(`div`,{className:`side-foot`,children:[(0,y.jsx)(`div`,{className:`avatar`,children:f?(0,y.jsx)(`img`,{src:f,alt:M}):N}),(0,y.jsxs)(`div`,{className:`who`,children:[(0,y.jsx)(`span`,{className:`name`,children:M}),(0,y.jsx)(`span`,{className:`role`,children:a??`operator`})]})]}),z&&(0,y.jsx)(`div`,{className:`copy-toast${z.failed?` copy-toast-failed`:``}`,role:`status`,children:z.message}),(0,y.jsx)(Me,{error:ke,onClose:()=>V(null)}),(0,y.jsx)(Pe,{open:je,onConnect:()=>{Ne(!1),i?.()},onClose:()=>Ne(!1)}),(0,y.jsx)(Ae,{target:$e,onCancel:()=>et(null),onConfirm:()=>{let e=$e;et(null),e&&Wt(e)}}),(0,y.jsx)(Le,{show:ut!==null,onClose:()=>{dt(null),pt(null),_t(null)},sessionId:ut?.sessionId??null,summary:ft,loading:mt,error:gt})]})}var We=5e3,Ge=3e4,Ke=3e4;function qe(){let[e,t]=(0,v.useState)(null);if((0,v.useEffect)(()=>{let e=!1,n=null;async function r(){try{let n=await fetch(`/api/admin/system-stats`);if(!n.ok){console.error(`[admin-ui] system-stats-fetch-failed status=${n.status}`);return}let r=await n.json();e||t(r)}catch(e){console.error(`[admin-ui] system-stats-fetch-failed reason=${e instanceof Error?e.message:String(e)}`)}}function i(){n===null&&(r(),n=setInterval(()=>{r()},We))}function a(){n!==null&&(clearInterval(n),n=null)}function o(){document.hidden?a():i()}return document.hidden||i(),document.addEventListener(`visibilitychange`,o),()=>{e=!0,a(),document.removeEventListener(`visibilitychange`,o)}},[]),!e||e.platform===`darwin`)return null;let n=e.cpuPct,r=e.memUsedPct,i=n!==null&&n>=.9,a=n!==null&&n>=.98,o=r!==null&&r>=.9,s=r!==null&&r>=.98,c=i||o,l=a||s,u=e=>e===null?`—`:`${Math.round(e*100)}%`,d=e=>{if(e===null)return{width:`0%`,background:`var(--text-tertiary)`};let t=Math.min(1,Math.max(0,e)),n=Math.round(140*(1-t));return{width:`${Math.round(t*100)}%`,background:`hsl(${n}, 65%, 45%)`}},f=[`system-stats`];return c&&f.push(`system-stats--warn`),l&&f.push(`system-stats--crit`),(0,y.jsxs)(`div`,{className:f.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,y.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,y.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),(0,y.jsx)(`div`,{className:`system-stats__bar`,children:(0,y.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(n)})})]}),(0,y.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,y.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]}),(0,y.jsx)(`div`,{className:`system-stats__bar`,children:(0,y.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(r)})})]})]})}var G=`admin-sidebar-collapsed`,Je=`admin-sidebar-drawer-open`;function K(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(G)===`1`}catch{return!1}}function Ye(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(G,`1`):window.sessionStorage.removeItem(G)}catch{}}function Xe(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Je)===`1`}catch{return!1}}function Ze(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Je,`1`):window.sessionStorage.removeItem(Je)}catch{}}var q=720;function Qe(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.remoteJid??``)}&acct=${encodeURIComponent(t.accountId??``)}`}}function $e(e){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?data=1`}}function et(e,t){if(e!==`/`)return null;let n=new URLSearchParams(t),r=n.get(`wa`),i=n.get(`acct`);return!r||!i?null:{sessionId:``,projectDir:``,title:``,senderId:null,startedAt:``,channel:`whatsapp`,role:`public`,operatorName:null,whatsappName:null,lastMessageAt:null,modelGated:!1,model:null,source:`store`,accountId:i,remoteJid:r}}function J(e,t){return e===`/`?new URLSearchParams(t).has(`data`):!1}function tt(e,t){return t===`operator`&&e===`chat`||e===`dashboard`?`/`:e===`data`?`/data`:e===`graph`?`/graph`:e===`calendar`?`/calendar`:e===`chat`?`/chat`:`/browser`}function nt(e){let{cacheKey:t,businessName:n,variant:r=`admin`,onLogout:i,onDisconnect:a,disconnecting:o,claudeConnected:s,onConnectClaude:c,userName:l,userAvatar:u,role:p,onOpenConversations:h,children:g,footer:ee}=e,{subAccounts:te,activeAccountId:ne,switching:_,switchAccount:ie}=re(t),[ae,oe]=(0,v.useState)(!0);(0,v.useEffect)(()=>{if(s!==void 0||r!==`admin`)return;let e=!1,t=async()=>{try{let t=await fetch(`/api/health`);if(!t.ok)return;let n=await t.json();e||oe(n.auth_status!==`dead`&&n.auth_status!==`missing`)}catch{}};t();let n=setInterval(t,6e4);return()=>{e=!0,clearInterval(n)}},[s,r]);let se=s??ae,ce=c??(()=>{window.location.assign(`/?connect=claude`)}),[b,x]=(0,v.useState)(()=>K()),[S,le]=(0,v.useState)(()=>Xe()),[ue,de]=(0,v.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: ${q}px)`).matches),[C,w]=(0,v.useState)(()=>typeof window>`u`||J(window.location.pathname,window.location.search)?null:et(window.location.pathname,window.location.search)),[fe]=(0,v.useState)(()=>C!==null),[T,pe]=(0,v.useState)(()=>typeof window>`u`?!1:J(window.location.pathname,window.location.search)),[me]=(0,v.useState)(()=>T);(0,v.useEffect)(()=>{if(typeof window>`u`)return;let e=window.matchMedia(`(max-width: ${q}px)`),t=e=>de(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let he=(0,v.useCallback)(e=>{Ye(e),x(e)},[]),E=(0,v.useCallback)(e=>{Ze(e),le(e)},[]);(0,v.useEffect)(()=>{if(typeof window>`u`)return;let e=window.location?.pathname??``;console.info(`[admin-ui] shell-mount route=${e} variant=${r} sidebar=${r===`operator`?`none`:`present`} collapsed=${b} drawer=${S}`)},[]),(0,v.useEffect)(()=>{typeof window>`u`||!C||(console.info(`[admin-ui] wa-hydrate route=/ remoteJid=${C.remoteJid??``}`),window.history.replaceState(null,``,`/`))},[]),(0,v.useEffect)(()=>{typeof window>`u`||!T||(console.info(`[admin-ui] data-hydrate route=/`),window.history.replaceState(null,``,`/`))},[]);let ge=(0,v.useCallback)(e=>{if(pe(!1),e===null){w(null);return}let t=typeof window<`u`?window.location.pathname:`/`,n=Qe(t,e);console.info(`[admin-ui] wa-open route=${t} via=${n.via} sessionId=${e.sessionId.slice(0,8)}`),n.via===`in-place`?w(e):window.location.href=n.href},[]),D=(0,v.useCallback)(()=>{let e=typeof window<`u`?window.location.pathname:`/`,t=$e(e);if(console.info(`[admin-ui] data-open route=${e} via=${t.via}`),t.via===`navigate`){window.location.href=t.href;return}w(null),pe(!0)},[]),O=ue?S:!b,k=(0,v.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${q}px)`).matches){let e=S;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),E(!e)}else{let e=b;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),he(!e)}},[b,S,he,E]),_e=(0,v.useCallback)(e=>{let t=tt(e,r);console.info(`[admin-ui] header-menu-nav target=${e} dest=${t}`),window.location.href=t},[r]),A={collapsed:b,mobileDrawerOpen:S,sidebarOpen:O,onToggleSidebar:k,setMobileDrawerOpen:E,selectedWhatsapp:C,onClearWhatsapp:()=>w(null),dataOpen:T};return r===`operator`?(0,y.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,y.jsx)(f,{businessName:n,variant:r,onNavigate:_e,onOpenConversations:h,onToggleSidebar:k,sidebarOpen:O,onLogout:i,onDisconnect:a,disconnecting:o,cacheKey:t,subAccounts:te,activeAccountId:ne,switchingAccount:_,onSwitchAccount:ie}),(0,y.jsx)(`div`,{className:`platform platform-operator`,children:typeof g==`function`?g(A):g}),ee]}):(0,y.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,y.jsx)(f,{businessName:n,variant:r,onNavigate:_e,onOpenConversations:h,onToggleSidebar:k,sidebarOpen:O,onLogout:i,onDisconnect:a,disconnecting:o,claudeConnected:se,onConnectClaude:ce,cacheKey:t,subAccounts:te,activeAccountId:ne,switchingAccount:_,onSwitchAccount:ie}),(0,y.jsxs)(`div`,{className:`platform${S?` menu-open`:``}${b?` sidebar-collapsed`:``}`,"data-artefact":`closed`,children:[(0,y.jsx)(Ue,{businessName:n,cacheKey:t,onConnectClaude:ce,role:p??null,userName:l,userAvatar:u??null,onSelectProjects:()=>{window.location.href=`/graph?label=${m().label}`},onSelectPeople:()=>{window.location.href=`/graph?label=Person`},onSelectTasks:()=>{window.location.href=`/graph?label=Task`},onSelectAgents:()=>{window.location.href=`/graph?label=Agent`},onCloseMobileDrawer:()=>E(!1),collapsed:b,mobileDrawerOpen:S,selectedWhatsappId:C?d(C):null,onSelectWhatsappConversation:ge,initialWhatsappSurface:fe,onSelectData:D,onCloseData:()=>pe(!1),initialDataSurface:me}),!ue&&(0,y.jsx)(ve,{}),typeof g==`function`?g(A):g]}),S&&(0,y.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>E(!1)}),ee]})}export{de as _,V as a,S as b,M as c,ge as d,E as f,w as g,T as h,Ne as i,xe as l,me as m,Ve as n,N as o,he as p,Pe as r,j as s,nt as t,F as u,ue as v,ce as x,le as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{F as e,M as t}from"./useSubAccountSwitcher-BVCMAnWK.js";import"./admin-types-hioowVct.js";import"./AdminShell-C5vWTy2n.js";import{n}from"./page-CMIbXzSg.js";import"./Transcript-Bsx-bGgY.js";var r=e(),i=t();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{D as e}from"./useSubAccountSwitcher-BVCMAnWK.js";var t=e(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{F as e,M as t}from"./useSubAccountSwitcher-BVCMAnWK.js";import{t as n}from"./page-E7I5sEVt.js";import"./Transcript-Bsx-bGgY.js";import"./graph-labels-Cabqmf35.js";var r=e(),i=t();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
|