ccdeck 3.52.0 → 3.53.1
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/README.md +13 -4
- package/bin/cli/help.js +1 -1
- package/bin/cli/one-shot.js +3 -2
- package/bin/cli/second-start.js +2 -2
- package/bin/cli/uninstall.js +1 -1
- package/bin/codex-profile.js +21 -0
- package/bin/deck.js +4 -3
- package/dist/web/assets/{BrowserWatchModal-CRqdEVdh.js → BrowserWatchModal-ByNoan60.js} +1 -1
- package/dist/web/assets/{IntegrationModal-BDzEIGSM.js → IntegrationModal-tKQbB-JM.js} +1 -1
- package/dist/web/assets/{RadioPanel-BJlsCpnN.js → RadioPanel-yTqDyeoT.js} +1 -1
- package/dist/web/assets/{TrafficRadar-BGxw-hlO.js → TrafficRadar-Dse2YLny.js} +1 -1
- package/dist/web/assets/{UsageHistoryModal-C_WBpNIp.js → UsageHistoryModal-Cmbih6Xe.js} +1 -1
- package/dist/web/assets/{app-B53fC4gE.js → app-Dx9D4Afq.js} +96 -96
- package/dist/web/assets/{app-Co1HNGP8.css → app-xTrs4aEH.css} +1 -1
- package/dist/web/assets/{index-D9nJhUJR.js → index-BsEQrAAC.js} +1 -1
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/release-notes.json +24 -1
- package/src/server/account-routes.mjs +99 -0
- package/src/server/account-watch.mjs +1 -1
- package/src/server/cli-versions.mjs +3 -3
- package/src/server/codex-auth.mjs +51 -9
- package/src/server/codex-auto.mjs +196 -0
- package/src/server/codex-login.mjs +117 -0
- package/src/server/codex-native-account.mjs +288 -0
- package/src/server/codex-profiles.mjs +243 -0
- package/src/server/codex-quota.mjs +370 -251
- package/src/server/codex-selection.mjs +371 -0
- package/src/server/codex-terminal-runner.mjs +78 -0
- package/src/server/codex-terminal.mjs +109 -0
- package/src/server/codex-watch.mjs +38 -22
- package/src/server/depth-facts.mjs +1 -1
- package/src/server/discovery.mjs +13 -0
- package/src/server/index.mjs +19 -1
- package/src/server/installer.mjs +11 -5
- package/src/server/log-election.mjs +32 -3
- package/src/server/login-service.mjs +1 -1
- package/src/server/memory-files.mjs +2 -2
- package/src/server/pinned-build.mjs +3 -0
- package/src/server/request-gates.mjs +9 -0
- package/src/server/running-deck.mjs +12 -1
- package/src/server/session-enrichment.mjs +2 -2
- package/src/server/tool-audit.mjs +15 -1
- package/src/server/usage-routes.mjs +1 -1
package/README.md
CHANGED
|
@@ -126,7 +126,7 @@ holds the terminal the way every version before 3.20 did.
|
|
|
126
126
|
|
|
127
127
|
Sessions already working when ccdeck starts can appear with a **restored** marker. Codex recovery reads recent unfinished turns from local rollouts; an absent ending does not confirm that its process is still running. On macOS and Linux, Claude recovery verifies a busy session against its process-start identity. **Settings › General** has a separate startup-recovery switch for each provider. Earlier tool calls are not replayed. [Recovery behavior and limits](docs/features/session-recovery.md).
|
|
128
128
|
|
|
129
|
-
The panels open from the window's edges, each stripe in groups with a rule between them. The stripe on the left holds
|
|
129
|
+
The panels open from the window's edges, each stripe in groups with a rule between them. The stripe on the left holds Accounts with Account capacity and the Reset calendar, then the session list, then a control for each connected Jira, GitHub or GitLab, with Explore integrations at its foot; the one on the right holds Usage and This machine, then Usage history, Tool activity and Skill activity, then Browser Watch and Telemetry Radar, then Radio. Each shows or hides beside the canvas, and several can be open at once. Point at one, or Tab to it, and its hint names its key — `L`, `A`, `U`, `S`, `H`, `B` — while the single-key shortcuts are on; Account capacity, the Reset calendar, Tool activity, Skill activity, Telemetry Radar and Radio have none. **Search** in the top bar (⌘K or Ctrl+K, which works with the single keys off) opens any of them, a setting or a session by name. On a phone they are in a dock along the bottom, and the session list and the Claude accounts panel open as a drawer over the canvas rather than beside it: picking a session closes the list, so the session is on screen.
|
|
130
130
|
|
|
131
131
|
Two notes can appear at the bottom of the canvas: **Undo**, for a few seconds after `R` or the re-arrange button lays the canvas out again — `Ctrl+Z` (`⌘Z` on a Mac) does the same — and **Resume**, which turns auto-fit back on after you have panned or zoomed.
|
|
132
132
|
|
|
@@ -362,6 +362,14 @@ Each one fires the bundled `hook.js`, which POSTs the event JSON to the running
|
|
|
362
362
|
|
|
363
363
|
**OpenAI Codex** — Codex CLI hooks do not fire reliably on Windows, so nothing is installed at all. The server tails Codex's own rollout files at `~/.codex/sessions/YYYY/MM/DD/rollout-*.jsonl` and reconstructs the equivalent stream — session start, prompts, tool calls, token usage, model. No hook install, no trust prompt. Set `CODEX_HOME` to override the path.
|
|
364
364
|
|
|
365
|
+
To use **multiple separate Codex logins**, open **Accounts → Add Codex account**, give the profile a label, and run its copied sign-in command in a terminal. Sign-in uses the official [Codex login flow](https://learn.chatgpt.com/docs/auth); each profile keeps its own login, configuration and history. Existing logins remain in place. You can also register existing homes at startup with `CCDECK_CODEX_HOMES`, a JSON array of additional absolute directories: for example, `CCDECK_CODEX_HOMES='["/home/me/.codex-work","/home/me/.codex-personal"]' npx ccdeck` on Linux.
|
|
366
|
+
|
|
367
|
+
**Use account** saves the default for ccdeck's Codex quota and account notifications. Selection is serialized across local processes and persists across restarts. Running sessions keep their previous account; restart them to apply a different account. All configured profile session trees stay monitored independently of selection. Token renewal belongs to Codex. ccdeck never rotates managed-profile refresh tokens itself; system-store inspection uses the official Codex app-server, which may renew a login while reading quota. System-store account metadata depends on the installed CLI protocol and may not include a workspace ID. Native quota readings cover standard Codex limits; additional limits and credits are not included.
|
|
368
|
+
|
|
369
|
+
For plain `codex` commands to use this default, click **Enable terminal selection**, run the copied setup command once, then open a new terminal. Supported shells are zsh, bash and PowerShell (PowerShell 5 uses `--shell powershell5`). The installed launcher uses durable local metadata, so ccdeck can be closed. An explicit `CODEX_HOME` always takes priority. **Remove terminal selection** provides the reverse command; it removes only ccdeck's shell integration and keeps profile data. Individual launch commands remain available without terminal setup. Terminal setup applies to shell commands, not an independently launched IDE extension.
|
|
370
|
+
|
|
371
|
+
The Accounts panel shows account/workspace labels and independent quotas where available. Missing profiles remain inspectable so another account can be selected. Usage history outside the profile cards may still reflect the original home; historical sessions are never reassigned when the default changes. Migration from CC Switch currently means signing in to isolated profiles again; it does not modify CC Switch's store. Claude continues to use claude-swap.
|
|
372
|
+
|
|
365
373
|
Quota is the one thing that is not just reading. It needs a live token, so when the one in `~/.codex/auth.json` is within 90 seconds of expiring the deck refreshes it exactly as the CLI does and writes the rotated credential back — one refresh at a time, re-reading the file inside the lock, and atomically, because OpenAI's refresh tokens are single-use and a rotation that never reaches disk costs you a `codex login`. It happens only while the page is open or a quota notification is on (see [Accounts](#accounts)), and nothing else in `auth.json` is touched.
|
|
366
374
|
|
|
367
375
|
## What it touches
|
|
@@ -404,7 +412,7 @@ Step by step: [Detect browser automation while you were away](https://ccdeck.dev
|
|
|
404
412
|
|
|
405
413
|
## Accounts
|
|
406
414
|
|
|
407
|
-
The Accounts panel
|
|
415
|
+
The Accounts panel shows Claude accounts managed by [claude-swap](https://github.com/realiti4/claude-swap) and configured Codex profiles. With both CLIs on a machine, the Claude | Codex switch at the top of the panel chooses which you see; it changes the view, not the account in use. Codex profiles support adding accounts, isolated quota checks and a persistent default for new sessions. The Claude controls described below continue to use claude-swap.
|
|
408
416
|
|
|
409
417
|
The deck installs that package itself, so it installs it **bounded**: `claude-swap~=0.26`, which is `>= 0.26, == 0.*`, and when PyPI can be reached the exact version it resolved rather than the range. What `cswap --version` reports afterwards has to be that version, or the deck says so and leaves the panel dark rather than driving a copy it cannot account for — this is the tool that holds your Claude logins. The daily upgrade is bounded by the same specifier, and what it left behind is written to `~/.agents-deck/cswap-upgrade.json`.
|
|
410
418
|
|
|
@@ -500,7 +508,7 @@ Four pictures, which are also the guide the section opens from `See how it works
|
|
|
500
508
|
</tr>
|
|
501
509
|
</table>
|
|
502
510
|
|
|
503
|
-
**On each machine, in order:** open the
|
|
511
|
+
**On each machine, in order:** open the Accounts panel (`A`) on its Claude side, open **Local network**'s settings (the sliders button), and tick the logins this machine may hand out. The section is on unless somebody switched it off. The two decks find each other over a UDP beacon on port 45317 and ask each other to pair; press `accept` where it is asked, and from then on every paired deck is asked once a minute for the ticked logins this deck is missing or has expired.
|
|
504
512
|
|
|
505
513
|
**When they do not find each other** — a VPN, a guest network, two subnets — `+` at the top of the section reaches a deck by address, or with an invite the other deck minted. An invite is the route when the machine that cannot be seen is this one.
|
|
506
514
|
|
|
@@ -549,7 +557,7 @@ ccdeck <command> [options] accounts, switch, usage, sessions, open — see
|
|
|
549
557
|
--no-codex Skip Codex capture (Claude only)
|
|
550
558
|
--claude Force Claude capture even if Claude Code wasn't found
|
|
551
559
|
--no-claude Skip Claude entirely — no hooks, no claude-swap,
|
|
552
|
-
|
|
560
|
+
Codex accounts remain available (Codex only)
|
|
553
561
|
--ref <name> The ccdeck.dev page this command was copied from;
|
|
554
562
|
sent once, with the first install report
|
|
555
563
|
--uninstall Remove ccdeck's hooks from settings files, and name
|
|
@@ -647,6 +655,7 @@ Environment:
|
|
|
647
655
|
|---|---|
|
|
648
656
|
| `AGENT_DAG_PORT` | Default port, same as `-p` |
|
|
649
657
|
| `CODEX_HOME` | Override `~/.codex` |
|
|
658
|
+
| `CCDECK_CODEX_HOMES` | JSON array of additional absolute Codex home directories to monitor and list in Accounts; restart ccdeck after changing it |
|
|
650
659
|
| `AGENTS_DECK_NO_INSTALL=1` | Never install or update claude-swap / ccusage or the terminal's `ccdeck`, never ask npm about releases, never read the status pages, and never send reports or feedback |
|
|
651
660
|
| `AGENTS_DECK_NO_DOWNLOAD=1` | Never download the `uv` binary, but keep the managed installs |
|
|
652
661
|
| `AGENTS_DECK_NO_UPDATE_CHECK=1` | Don't ask npm about releases, but keep everything else |
|
package/bin/cli/help.js
CHANGED
|
@@ -71,7 +71,7 @@ Options:
|
|
|
71
71
|
--codex Force-enable Codex capture even if ~/.codex/ missing
|
|
72
72
|
--no-codex Skip Codex capture (Claude only)
|
|
73
73
|
--claude Force-enable Claude capture even if Claude Code wasn't found
|
|
74
|
-
--no-claude Skip Claude entirely: no hooks
|
|
74
|
+
--no-claude Skip Claude entirely: no hooks or claude-swap; Codex accounts remain
|
|
75
75
|
--ref <name> The site page this command was copied from (first run)
|
|
76
76
|
--uninstall Remove ${PRODUCT}'s hooks from ~/.claude/settings.json and
|
|
77
77
|
~/.codex/hooks.json, and restore any sound hooks of yours it parked.
|
package/bin/cli/one-shot.js
CHANGED
|
@@ -145,7 +145,7 @@ function printLogs(deckLogDir, { say, tone, dash, bullet }) {
|
|
|
145
145
|
*/
|
|
146
146
|
async function defaultShape(deckLogDir) {
|
|
147
147
|
const { canonicalLogPath } = await import(pathToFileURL(join(PKG_ROOT, "src/server/log-election.mjs")).href);
|
|
148
|
-
const { hasCodexInstalled, codexHomeField } = await import(pathToFileURL(join(PKG_ROOT, "src/server/installer.mjs")).href);
|
|
148
|
+
const { hasCodexInstalled, codexHomeField, codexHomesField } = await import(pathToFileURL(join(PKG_ROOT, "src/server/installer.mjs")).href);
|
|
149
149
|
const { hasClaudeInstalled } = await import(pathToFileURL(join(PKG_ROOT, "src/server/claude-dir.mjs")).href);
|
|
150
150
|
|
|
151
151
|
// The default shape, spelled the same way deck.js's boot spells it. NOT the
|
|
@@ -156,7 +156,7 @@ async function defaultShape(deckLogDir) {
|
|
|
156
156
|
const mine = {
|
|
157
157
|
workspace: "",
|
|
158
158
|
persist: canonicalLogPath(join(deckLogDir(), "events.jsonl")),
|
|
159
|
-
codex: hasCodexInstalled(),
|
|
159
|
+
codex: await hasCodexInstalled(),
|
|
160
160
|
claude: hasClaudeInstalled(),
|
|
161
161
|
};
|
|
162
162
|
// And the Codex tree, the one field of a start's shape that is not a flag. A
|
|
@@ -165,6 +165,7 @@ async function defaultShape(deckLogDir) {
|
|
|
165
165
|
// one" exactly the deck the next `ccdeck` stops (#1134). Worked out by the
|
|
166
166
|
// function the start and the discovery record use, so all three agree.
|
|
167
167
|
mine.codexHome = codexHomeField(mine.codex);
|
|
168
|
+
mine.codexHomes = await codexHomesField(mine.codex);
|
|
168
169
|
return mine;
|
|
169
170
|
}
|
|
170
171
|
|
package/bin/cli/second-start.js
CHANGED
|
@@ -34,14 +34,14 @@ import { reportIncompleteFlags, reportUnknownFlags } from "./startup.js";
|
|
|
34
34
|
* to go on and boot. Nothing here exits the process: bin/deck.js does, so every
|
|
35
35
|
* way out is one its exit handlers already cover (#980).
|
|
36
36
|
*/
|
|
37
|
-
export async function settleSecondStart({ flags, workspace, persist, wantCodex, wantClaude, codexHome, openBrowser, RESPAWN }) {
|
|
37
|
+
export async function settleSecondStart({ flags, workspace, persist, wantCodex, wantClaude, codexHome, codexHomes, openBrowser, RESPAWN }) {
|
|
38
38
|
// `--port` alone, not AGENT_DAG_PORT: the variable is how somebody RUNS a
|
|
39
39
|
// deck rather than which one they mean — the line `--stop` draws in
|
|
40
40
|
// bin/cli/one-shot.js.
|
|
41
41
|
const askedPort = flags.port != null && isPortValue(flags.port) ? Number(flags.port) : null;
|
|
42
42
|
const plan = secondStart({
|
|
43
43
|
live: await liveDecks().catch(() => []),
|
|
44
|
-
want: { workspace, persist, codex: wantCodex, claude: wantClaude, codexHome },
|
|
44
|
+
want: { workspace, persist, codex: wantCodex, claude: wantClaude, codexHome, codexHomes },
|
|
45
45
|
port: askedPort,
|
|
46
46
|
ours: PKG_VERSION,
|
|
47
47
|
fresh: flags.new === true,
|
package/bin/cli/uninstall.js
CHANGED
|
@@ -109,7 +109,7 @@ export async function uninstall(flags) {
|
|
|
109
109
|
console.error(`${PRODUCT}: your own sound hooks were NOT restored ${gDash} ${sound.message}`);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
if (hasCodexInstalled()) {
|
|
112
|
+
if (await hasCodexInstalled()) {
|
|
113
113
|
report(await uninstallHooks({ provider: "codex" }), "Codex");
|
|
114
114
|
}
|
|
115
115
|
// ── THE DECKS STILL RUNNING ────────────────────────────────────────────────
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { configureCodexTerminal } from '../src/server/codex-terminal.mjs';
|
|
3
|
+
import { isAbsolute } from 'node:path';
|
|
4
|
+
|
|
5
|
+
const [action, ...args] = process.argv.slice(2);
|
|
6
|
+
try {
|
|
7
|
+
const options = {};
|
|
8
|
+
for (let i = 0; i < args.length; i += 2) {
|
|
9
|
+
const key = { '--shell': 'shell', '--store': 'store', '--rc': 'rc' }[args[i]];
|
|
10
|
+
if (!key || !args[i + 1] || Object.hasOwn(options, key)) throw new Error('Use: codex-profile.js install|uninstall --shell zsh|bash|powershell|powershell5 [--store directory] [--rc shell-profile]');
|
|
11
|
+
options[key] = args[i + 1];
|
|
12
|
+
}
|
|
13
|
+
if (!options.shell || (options.store && !isAbsolute(options.store)) || (options.rc && !isAbsolute(options.rc))) throw new Error('Shell is required; store and profile paths must be absolute.');
|
|
14
|
+
const result = await configureCodexTerminal(action, options);
|
|
15
|
+
console.log(result.action === 'install'
|
|
16
|
+
? 'Codex account selection enabled. Open a new terminal to use it. An explicit CODEX_HOME takes priority.'
|
|
17
|
+
: 'Codex account selection removed. Open a new terminal to use the original command.');
|
|
18
|
+
} catch (error) {
|
|
19
|
+
console.error(error.message);
|
|
20
|
+
process.exitCode = 1;
|
|
21
|
+
}
|
package/bin/deck.js
CHANGED
|
@@ -208,7 +208,7 @@ const persist = flags.noPersist
|
|
|
208
208
|
// share a path still elect one writer for it.
|
|
209
209
|
: canonicalLogPath(flags.history ?? join(deckLogDir(), "events.jsonl"));
|
|
210
210
|
|
|
211
|
-
const { installHooks, keepDiscovery, removeDiscovery, hasCodexInstalled, leftoverCodexHooks, codexHomeField } =
|
|
211
|
+
const { installHooks, keepDiscovery, removeDiscovery, hasCodexInstalled, leftoverCodexHooks, codexHomeField, codexHomesField } =
|
|
212
212
|
await import(pathToFileURL(join(PKG_ROOT, "src/server/installer.mjs")).href);
|
|
213
213
|
// CODEX_SESSIONS_DIR comes along because the startup report names the directory
|
|
214
214
|
// the watcher tails, and the watcher lives in that module. Recomputing the path
|
|
@@ -237,7 +237,7 @@ const workspace = canonicalWorkspace(rawWorkspace);
|
|
|
237
237
|
// and no directory is created either way — Codex hooks are not used any more,
|
|
238
238
|
// so `--codex` only means "watch even though ~/.codex/ is not there yet",
|
|
239
239
|
// which is the right answer for a machine where Codex arrives later.
|
|
240
|
-
const wantCodex =
|
|
240
|
+
const wantCodex = !flags.noCodex && (flags.codex || await hasCodexInstalled());
|
|
241
241
|
|
|
242
242
|
// The same question for the other CLI, and the one nobody was asking. README
|
|
243
243
|
// offers "Claude Code CLI or OpenAI Codex CLI (or both)"; a Codex-only machine
|
|
@@ -267,6 +267,7 @@ const claudeArrived = RESPAWN && wantClaude && process.env.AGENTS_DECK_BOOT_HOOK
|
|
|
267
267
|
// with the other three, because the second-start question below is asked of
|
|
268
268
|
// nothing but inputs already settled. A --no-codex start reads no tree: null.
|
|
269
269
|
const codexHome = codexHomeField(wantCodex);
|
|
270
|
+
const codexHomes = await codexHomesField(wantCodex);
|
|
270
271
|
|
|
271
272
|
const WEB_DIST = join(PKG_ROOT, "dist", "web", "index.html");
|
|
272
273
|
if (!existsSync(WEB_DIST)) {
|
|
@@ -363,7 +364,7 @@ dieWithParent(() => shutdown(0));
|
|
|
363
364
|
// read alone could not close the window two starts at login fell through.
|
|
364
365
|
bootLock = await takeBootLock({ dir: deckRegistryDir() }).catch(() => null);
|
|
365
366
|
{
|
|
366
|
-
const ended = await settleSecondStart({ flags, workspace, persist, wantCodex, wantClaude, codexHome, openBrowser, RESPAWN });
|
|
367
|
+
const ended = await settleSecondStart({ flags, workspace, persist, wantCodex, wantClaude, codexHome, codexHomes, openBrowser, RESPAWN });
|
|
367
368
|
// A yield or an attach: this start ends here, having said why.
|
|
368
369
|
if (ended !== null) process.exit(ended);
|
|
369
370
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as P,j as e,b as h,a1 as Z,a2 as ee,e as V,t as I,a3 as se,g as te,a4 as ne,x as ae,a5 as ie,s as re,a6 as J,o as Q,C as le,D as ce,R as oe,i as de}from"./app-B53fC4gE.js";function he({snap:s}){const a=P();return e.jsxs("section",{className:"bw-feed",children:[e.jsxs("h4",{className:"bw-sec-head bw-head-row",children:[a("settings.bw.feed"),e.jsx("span",{className:"bw-feed-count",children:a("settings.bw.feed.count",{count:s.log.length})})]}),e.jsx("p",{className:"bw-since bw-feed-note",children:a("settings.bw.feed.note")}),e.jsx("div",{className:"bw-log","aria-live":"polite","aria-relevant":"additions",children:s.log.length===0?e.jsx("p",{className:"bw-note",children:a("settings.bw.feed.empty")}):s.log.map(t=>e.jsxs("div",{className:`bw-log-line ${t.level}${t.parts?"":" sys"}`,children:[e.jsx("span",{className:"bw-log-time",children:new Date(t.atMs).toLocaleTimeString("en-GB",{hour12:!1})}),t.parts?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bw-log-browser",children:t.parts.browser}),e.jsx("span",{className:"bw-log-profile",title:t.parts.profile,children:t.parts.profile}),e.jsxs("span",{className:"bw-log-value",children:[t.parts.value,t.parts.flagged>0&&e.jsx("span",{className:"bw-log-flag",children:a("settings.bw.feed.flagged",{count:t.parts.flagged})})]})]}):e.jsx("span",{className:"bw-log-sys",children:t.text})]},`${t.atMs}-${t.level}-${t.text}`))})]})}const D=s=>`${s.host}-${s.startMs}`;function we(s){const a=t=>new Date(t).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1});return s.count===1||s.endMs-s.startMs<6e4?a(s.startMs):`${a(s.startMs)} → ${a(s.endMs)}`}function be(s){return new Date(s).toLocaleDateString(V(),{weekday:"short",day:"numeric",month:"short"})}function _(s,a){const t=Math.round((s.endMs-s.startMs)/6e4);return t<1?"":a("settings.bw.findings.minutes",{n:t})}function ue({snap:s,dismiss:a,refreshRef:t}){const i=P(),[l,d]=h.useState(null),o=h.useRef(new Map),n=h.useRef(null);h.useEffect(()=>{var c,u;const b=n.current;!b||s.episodes.some(g=>D(g)===b.id)||(n.current=null,Z(((c=document.activeElement)==null?void 0:c.tagName)??null)&&((u=(b.next?o.current.get(b.next):void 0)??t.current)==null||u.focus()))},[s]);const r=b=>{n.current={id:D(b),next:ee(s.episodes.map(D),D(b))},a(b)},w=h.useMemo(()=>{const b=[];for(const c of s.episodes){const u=be(c.startMs),g=b[b.length-1];g&&g.label===u?g.episodes.push(c):b.push({label:u,episodes:[c]})}return b},[s]);return e.jsxs("section",{className:"bw-findings",children:[e.jsxs("h4",{className:"bw-sec-head bw-head-row",children:[i("settings.bw.findings"),s.episodes.length>0&&e.jsx("span",{className:"bw-feed-count",children:i("settings.bw.findings.count",{count:s.episodes.length})})]}),e.jsx("div",{className:"bw-eps",children:w.length===0?e.jsxs("div",{className:"bw-empty",children:[e.jsx("p",{className:"bw-empty-head",children:i("settings.bw.findings.none")}),e.jsx("p",{className:"bw-empty-note",children:i("settings.bw.findings.noneNote",{count:s.settings.quietMinutes})}),!s.settings.enabled&&e.jsx("p",{className:"bw-empty-note",children:i("settings.bw.findings.offNote")})]}):w.map(b=>e.jsxs("div",{className:"bw-day",children:[e.jsx("h4",{className:"bw-sec-head",children:b.label}),b.episodes.map(c=>{const u=D(c),g=l===u;return e.jsxs("div",{className:`bw-ep${g?" open":""}`,children:[e.jsxs("div",{className:"bw-ep-row",children:[e.jsxs("button",{className:"bw-ep-head",ref:p=>{p?o.current.set(u,p):o.current.delete(u)},onClick:()=>d(g?null:u),"aria-expanded":g,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:g?"▾":"▸"}),e.jsx("span",{className:"bw-ep-host",children:c.host}),e.jsxs("span",{className:"bw-ep-meta",children:[we(c),_(c,i)&&e.jsxs(e.Fragment,{children:[" · ",_(c,i)]}),c.provisional&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{title:i("settings.bw.findings.provisionalTip"),children:i("settings.bw.findings.provisional")})]})]}),e.jsx("span",{className:"bw-ep-count",children:i("settings.bw.findings.pages",{count:c.count})})]}),e.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>r(c),"aria-label":i("settings.bw.findings.dismissHost",{host:c.host}),title:i("settings.bw.findings.dismissTip"),children:"×"})]}),g&&e.jsx("ul",{className:"bw-urls",children:c.urls.map((p,x)=>e.jsxs("li",{children:[e.jsx("span",{className:"bw-url-time",children:new Date(p.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),e.jsx("span",{className:"bw-url",children:p.url})]},`${p.url}-${p.timeMs}-${x}`))})]},u)})]},b.label))})]})}function ge(s){const a=/^#?([0-9a-f]{6})$/i.exec((s??"").trim());if(!a)return!1;const t=parseInt(a[1],16),i=[t>>16&255,t>>8&255,t&255].map(l=>{const d=l/255;return d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4)});return .2126*i[0]+.7152*i[1]+.0722*i[2]>.5}const z=1e4,me=12e3;function fe({browsers:s,findings:a,watching:t,palette:i}){const l=P(),d=h.useRef(null),o=h.useRef(null);return o.current={browsers:s,findings:a,watching:t},h.useEffect(()=>{var g;const n=d.current;if(!n)return;const r=n.getContext("2d");if(!r)return;const w=((g=window.matchMedia)==null?void 0:g.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let b=0,c=!1;const u=()=>{var U;if(c)return;const p=o.current;if(!p)return;const{browsers:x,findings:W,watching:T}=p,m=i["--accent"]||"#7dd3fc",y=i["--line"]||"#1f2229",A=i["--text-dim"]||"#6e727c",k=ge(i["--bg"]),v=k?42:26,F=k?.85:.65,R=Date.now(),C=Math.min(window.devicePixelRatio||1,2),S=n.clientWidth,$=n.clientHeight;(n.width!==S*C||n.height!==$*C)&&(n.width=S*C,n.height=$*C),r.setTransform(C,0,0,C,0,0),r.clearRect(0,0,S,$);const f=S/2,N=$/2,M=Math.min(S,$)/2-6;r.strokeStyle=y,r.lineWidth=1,r.globalAlpha=k?1:.9;for(const j of[.4,.7,1])r.beginPath(),r.arc(f,N,M*j,0,Math.PI*2),r.stroke();r.beginPath(),r.moveTo(f-M,N),r.lineTo(f+M,N),r.moveTo(f,N-M),r.lineTo(f,N+M),r.stroke(),r.globalAlpha=1;const B=(T&&!w?R%z/z:0)*Math.PI*2-Math.PI/2;if(T){const j=(U=r.createConicGradient)==null?void 0:U.call(r,B-.85,f,N);j&&(j.addColorStop(0,"transparent"),j.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${m} ${v}%, transparent)`),j.addColorStop(1,"transparent"),r.fillStyle=j,r.beginPath(),r.moveTo(f,N),r.arc(f,N,M,B-.85,B),r.closePath(),r.fill()),r.strokeStyle=m,r.globalAlpha=F,r.beginPath(),r.moveTo(f,N),r.lineTo(f+Math.cos(B)*M,N+Math.sin(B)*M),r.stroke(),r.globalAlpha=1}x.forEach((j,E)=>{const O=E/Math.max(x.length,1)*Math.PI*2-Math.PI/2,L=j.lastReadMs===null?1:Math.min(1,(R-j.lastReadMs)/12e4),q=M*(.42+L*.5),G=f+Math.cos(O)*q,K=N+Math.sin(O)*q,Y=Math.abs((B-O+Math.PI*3)%(Math.PI*2)-Math.PI),H=T?Math.max(0,1-Y/.55):0;r.beginPath(),r.arc(G,K,3+H*1.6,0,Math.PI*2),r.fillStyle=j.running?m:A,r.globalAlpha=j.running?.55+H*.45:.35,r.fill(),r.globalAlpha=1});for(const j of W){const E=(R-j.atMs)/me;if(E<0||E>1)continue;const L=Math.max(0,x.findIndex(K=>K.key===j.browser))/Math.max(x.length,1)*Math.PI*2-Math.PI/2,q=f+Math.cos(L)*M*.6,G=N+Math.sin(L)*M*.6;r.beginPath(),r.arc(q,G,4+E*22,0,Math.PI*2),r.strokeStyle=m,r.globalAlpha=(1-E)*.8,r.lineWidth=1.5,r.stroke(),r.globalAlpha=1}b=requestAnimationFrame(u)};return u(),()=>{c=!0,cancelAnimationFrame(b)}},[i]),e.jsx("canvas",{ref:d,className:"bw-radar",role:"img","aria-label":t?l("radar.watch.watching",{count:s.length}):l("radar.watch.idle")})}function xe(s,a,t){if(s===null)return null;const i=s+a-t;return i>0?i:null}function pe(s){const a=Math.ceil(s/1e3),t=Math.floor(a/60),i=a%60;return t>0?`${t}m ${i}s`:`${i}s`}function X(s){return(s??[]).filter(a=>a.installed&&a.profiles>0)}function je(s,a=I){return!Number.isFinite(s)||s<=0?a("settings.bw.logEmpty"):se(s)}function Ne(s,a){return s.map(t=>({key:t.key,name:t.name,running:t.running,visits:a.filter(i=>i.browser===t.key).reduce((i,l)=>i+l.programVisits,0)}))}function ve(s,a,t=I){if(s===null)return null;const i=Math.max(0,Math.round((a-s)/1e3));if(i<5)return t("settings.bw.ago.now");if(i<60)return t("settings.bw.ago.sec",{n:i});const l=Math.round(i/60);return l<60?t("settings.bw.ago.min",{n:l}):t("settings.bw.ago.hr",{n:Math.round(l/60)})}function ye(s,a=I){const t=s.profiles.filter(l=>l.degraded);if(t.length>0){const l=t[0],d=t.length-1;return{kind:"unreadable",text:a(d>0?"settings.bw.trouble.unreadableMore":"settings.bw.trouble.unreadable",{browser:l.name,profile:l.profile,reason:l.reason??a("settings.bw.trouble.noReason"),more:d})}}const i=X(s.browsers);return i.length===0?{kind:"no-profiles",text:a("settings.bw.trouble.noProfiles")}:i.some(l=>l.running)?null:{kind:"none-running",text:a("settings.bw.trouble.noneRunning")}}function ke({snap:s,watching:a,palette:t}){const i=P(),[l,d]=h.useState(!1),[o,n]=h.useState(()=>Date.now());h.useEffect(()=>{const w=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(w)},[]);const r=xe(s.coverage.lastHumanMs,s.coverage.quietMs,o);return e.jsxs("section",{className:"bw-sec",children:[e.jsxs("h4",{className:"bw-sec-head",children:[i("settings.bw.overview"),e.jsx("button",{className:"bw-help",onClick:()=>d(w=>!w),"aria-expanded":l,"aria-label":i("settings.bw.overview.help"),children:"?"})]}),e.jsxs("div",{className:"bw-glance",children:[e.jsx(fe,{browsers:a.map(w=>{var b;return{key:w.key,name:w.name,running:w.running,lastReadMs:((b=s.profiles.find(c=>c.browser===w.key))==null?void 0:b.lastWrittenMs)??null}}),findings:s.episodes.slice(0,6).map(w=>({browser:w.browser??null,atMs:w.endMs})),watching:s.settings.enabled,palette:t}),e.jsx("ul",{className:"bw-counts",children:Ne(a,s.profiles).map(w=>e.jsxs("li",{children:[e.jsx("span",{className:"bw-count-n",children:te(w.visits,0)}),e.jsx("span",{className:"bw-count-of",children:w.name})]},w.key))})]}),e.jsx("p",{className:"bw-since",children:i("settings.bw.overview.since")}),s.coverage.checkedMs>0&&e.jsxs("p",{className:"bw-since",children:[i("settings.bw.overview.checked",{ago:ve(s.coverage.checkedMs,o,i)??""}),s.coverage.checks>0&&e.jsxs(e.Fragment,{children:[" · ",i("settings.bw.overview.checks",{count:s.coverage.checks})]})]}),r!==null&&e.jsx("p",{className:"bw-gate",children:i("settings.bw.overview.gate",{time:pe(r)})}),l&&e.jsxs("dl",{className:"bw-key",children:[e.jsx("dt",{children:i("settings.bw.key.sweep")}),e.jsx("dd",{children:i("settings.bw.key.sweepText")}),e.jsx("dt",{children:i("settings.bw.key.dot")}),e.jsx("dd",{children:i("settings.bw.key.dotText")}),e.jsx("dt",{children:i("settings.bw.key.ring")}),e.jsx("dd",{children:i("settings.bw.key.ringText")})]})]})}function Me({watching:s,rest:a}){const t=P(),[i,l]=h.useState(!1),[d,o]=h.useState(!1);return e.jsxs("section",{className:"bw-sec",children:[e.jsxs("h4",{className:"bw-sec-head",children:[t("settings.bw.profiles"),e.jsx("button",{className:"bw-help",onClick:()=>l(n=>!n),"aria-expanded":i,"aria-label":t("settings.bw.profiles.help"),children:"?"})]}),i&&e.jsxs("dl",{className:"bw-key",children:[e.jsx("dt",{children:t("settings.bw.key.running")}),e.jsx("dd",{children:t("settings.bw.key.runningText")}),e.jsx("dt",{children:t("settings.bw.key.connected")}),e.jsx("dd",{children:t("settings.bw.key.connectedText")})]}),e.jsx("ul",{className:"bw-profiles",children:s.map(n=>e.jsxs("li",{children:[e.jsx("span",{className:`bw-prof-dot${n.running?" on":""}`,"aria-hidden":!0}),e.jsx("span",{className:"bw-prof-name",children:n.name}),e.jsx("span",{className:"bw-prof-state",children:n.running?t("settings.bw.running"):t("settings.bw.idle")}),n.running&&n.relay.state==="live"&&e.jsx("span",{className:"bw-relay",children:t("settings.bw.relay")})]},n.key))}),a.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>o(n=>!n),"aria-expanded":d,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:d?"▾":"▸"})," ",t("settings.bw.notWatched",{count:a.length})]}),d&&e.jsx("p",{className:"bw-rest",children:t("settings.bw.notWatchedText",{names:a.map(n=>n.name).join(", ")})})]})]})}function Se({snap:s,quiet:a,setQuiet:t,save:i,access:l,setAccess:d}){const o=P();return e.jsxs("div",{className:"bw-settings",children:[e.jsxs("label",{title:o("settings.bw.quiet.tip"),children:[e.jsx("span",{children:o("settings.bw.quiet.label")}),e.jsx("select",{value:a??s.settings.quietMinutes,onChange:n=>{t(Number(n.target.value)),i({quietMinutes:Number(n.target.value)})},children:[1,5,15,30,60].map(n=>e.jsx("option",{value:n,children:o("settings.bw.minutes",{n})},n))})]}),e.jsxs("label",{children:[e.jsx("span",{children:o("settings.bw.reaction.label")}),e.jsx("select",{value:s.settings.reaction,onChange:n=>void i({reaction:n.target.value}),disabled:!s.settings.enabled,title:s.settings.enabled?o("settings.bw.reaction.hintOn"):o("settings.bw.reaction.hintOff"),children:(s.reactions??["notify"]).map(n=>e.jsx("option",{value:n,children:o(n==="notify"?"settings.bw.reaction.notify":n==="close-tab"?"settings.bw.reaction.closeTab":"settings.bw.reaction.quit")},n))})]}),e.jsxs("div",{className:"bw-settings-note",children:[e.jsxs("p",{children:[o("settings.bw.note.chrome")," ",e.jsx("strong",{children:o("settings.bw.note.usually")})]}),e.jsxs("button",{className:"bw-why",onClick:()=>d(n=>!n),"aria-expanded":l,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:l?"▾":"▸"})," ",o("settings.bw.access.toggle")]}),l&&e.jsxs("dl",{className:"bw-access",children:[e.jsx("dt",{children:o("settings.bw.access.reads")}),e.jsx("dd",{children:o("settings.bw.access.readsText",{when:new Date(s.coverage.startedMs).toLocaleString(V())})}),e.jsx("dt",{children:o("settings.bw.access.keeps")}),e.jsx("dd",{children:ne(o("settings.bw.access.keepsText",{path:"{path}",size:typeof s.coverage.logBytes=="number"?` (${je(s.coverage.logBytes)})`:""}),{path:e.jsx("code",{className:"bw-path",children:s.coverage.logPath})})}),e.jsx("dt",{children:o("settings.bw.access.sends")}),e.jsx("dd",{children:o("settings.bw.access.sendsText")}),e.jsx("dt",{children:o("settings.bw.access.never")}),e.jsx("dd",{children:o("settings.bw.access.neverText")})]})]})]})}function Pe(s,a,t){return a?{kind:"saving",word:t("settings.bw.mode.saving")}:s.settings.enabled?{kind:"on",word:t("settings.bw.mode.watching")}:{kind:"off",word:t("settings.bw.mode.paused")}}function Te({snap:s,saving:a,save:t,why:i,setWhy:l}){const d=P(),o=Pe(s,a,d);return e.jsxs("footer",{className:"bw-status",children:[e.jsx("span",{className:`bw-mode-dot${s.settings.enabled?" on":""}`,"aria-hidden":!0}),e.jsx("span",{className:"bw-mode-word",children:o.word},o.kind),e.jsx("span",{className:"bw-status-text",children:s.coverage.archived===0?s.settings.enabled?d("settings.bw.disk.none"):d("settings.bw.disk.noneOff"):d("settings.bw.disk.some",{count:s.coverage.archived})}),e.jsx("button",{className:`glyph-btn bw-gear${i?" on":""}`,onClick:()=>l(n=>!n),"aria-expanded":i,"aria-label":d("settings.bw.settings"),title:d("settings.bw.settings"),children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":!0,children:[e.jsx("circle",{cx:"7",cy:"7",r:"2.1"}),e.jsx("path",{d:"M7 1.2v1.6M7 11.2v1.6M1.2 7h1.6M11.2 7h1.6M2.9 2.9l1.1 1.1M10 10l1.1 1.1M11.1 2.9L10 4M4 10l-1.1 1.1"})]})}),e.jsxs("label",{className:"bw-switch",htmlFor:"bw-enabled",children:[e.jsx("span",{className:"bw-switch-label",id:"bw-enabled-label",children:d("settings.bw.switch")}),e.jsx("button",{id:"bw-enabled",type:"button",role:"switch","aria-checked":s.settings.enabled,"aria-labelledby":"bw-enabled-label",className:"switch",onClick:()=>void t({enabled:!s.settings.enabled}),title:s.settings.enabled?d("settings.bw.switch.on"):d("settings.bw.switch.off"),children:e.jsx("span",{className:"switch-knob"})})]})]})}function Ce({relay:s}){const a=P(),[t,i]=h.useState(!1),[l,d]=h.useState(!1),o=s.killswitch.blocked?"unblock":"block",n=s.command[o],r=h.useCallback(async()=>{await ae(n.command)&&(d(!0),window.setTimeout(()=>d(!1),1600))},[n.command]),w=s.profiles.filter(c=>{var u;return(u=c.report)==null?void 0:u.present}),b=s.profiles.filter(c=>c.report===null);return e.jsxs("section",{className:"bw-sec",children:[e.jsx("h4",{className:"bw-sec-head",children:a("shell.remote.title")}),e.jsx("p",{className:`bw-rc-verdict ${s.verdict}`,role:"status",children:s.verdict==="exposed"?a("shell.remote.exposed"):s.verdict==="protected"?a("shell.remote.protected",{path:s.hostsPath}):a("shell.remote.nothing")}),s.killswitch.foreign.length>0&&e.jsxs("p",{className:"bw-rc-foreign",children:[a("shell.remote.foreign",{path:s.hostsPath}),s.killswitch.foreign.map(c=>e.jsx("code",{className:"bw-path",children:c},c))]}),e.jsxs("button",{className:"bw-why",onClick:()=>i(c=>!c),"aria-expanded":t,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:t?"▾":"▸"})," ",s.verdict==="protected"?a("shell.remote.undo"):a("shell.remote.reach")]}),t&&e.jsxs("div",{className:"bw-rc-body",children:[w.length>0&&e.jsx("dl",{className:"bw-key",children:w.map(c=>e.jsxs(h.Fragment,{children:[e.jsxs("dt",{children:[c.name,c.profile==="Default"?"":` · ${c.profile}`]}),e.jsxs("dd",{children:[a("shell.remote.detail",{state:c.report.enabled?a("shell.remote.enabled"):a("shell.remote.switchedOff"),scope:c.report.allUrls?a("shell.remote.allSites"):a("shell.remote.limited")}),c.report.sensitiveApis.length>0&&e.jsxs(e.Fragment,{children:[" — ",c.report.sensitiveApis.join(", ")]})]})]},`${c.browser}/${c.profile}`))}),b.length>0&&e.jsx("p",{className:"bw-rc-note",children:a("shell.remote.unreadable",{names:b.map(c=>c.name).join(", ")})}),!s.hostsRead&&e.jsx("p",{className:"bw-rc-note",children:a("shell.remote.hostsUnread",{path:s.hostsPath})}),w.some(c=>c.report.allUrls)&&e.jsx("p",{className:"bw-rc-note",children:ie(a("shell.remote.narrow"),"code",e.jsx("code",{className:"bw-path",children:"chrome://extensions"}))}),e.jsxs("div",{className:"bw-rc-cmd",children:[e.jsx("code",{children:n.command}),e.jsx("button",{className:"btn bw-rc-copy",onClick:r,children:a(l?"shell.copied":"shell.copy")})]}),e.jsx("p",{className:"bw-rc-note",children:n.note})]})]})}function Re(s){const[a,t]=h.useState(null),[i,l]=h.useState(null),[d,o]=h.useState(null),[n,r]=h.useState(!1),w=h.useRef(!1),[b,c]=h.useState(null),[u,g]=h.useState(!1),p=h.useRef(!1),x=h.useCallback(async m=>{var y,A;if(!(m&&!re(w.current))){m&&(w.current=!0,r(!0));try{const k=await fetch(`/api/browser-watch${m?"?refresh=1":""}`);if(!k.ok)throw new J(I("settings.bw.deckAnswered",{status:k.status}));const v=await k.json();t(v),p.current||c(((y=v==null?void 0:v.settings)==null?void 0:y.quietMinutes)??15),s(((A=v==null?void 0:v.settings)==null?void 0:A.enabled)===!0),l(null)}catch(k){l(Q(k,I("settings.bw.noAnswer")))}finally{m&&(w.current=!1,r(!1))}}},[s]);h.useEffect(()=>{x(!1)},[x]),h.useEffect(()=>{const m=setInterval(()=>{x(!1)},1e4);return()=>clearInterval(m)},[x]);const W=h.useCallback(async m=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:m.host,startMs:m.startMs})})}finally{await x(!1)}},[x]),T=h.useCallback(async m=>{p.current=!0,g(!0);try{const y=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(m)});if(!y.ok)throw new J(I("settings.bw.deckAnswered",{status:y.status}));await x(!1),o(null)}catch(y){o(Q(y,I("settings.bw.noAnswer")))}finally{p.current=!1,g(!1)}},[x]);return{snap:a,error:i,writeError:d,setWriteError:o,busy:n,quiet:b,setQuiet:c,saving:u,load:x,dismiss:W,save:T}}function Ae({onClose:s,onSeen:a,onWatching:t,palette:i}){const l=P(),d=le(s),o=ce(s),{snap:n,error:r,writeError:w,setWriteError:b,busy:c,quiet:u,setQuiet:g,saving:p,load:x,dismiss:W,save:T}=Re(t),[m,y]=h.useState(!1),[A,k]=h.useState(!1),v=h.useRef(null),F=h.useRef(a);F.current=a,h.useEffect(()=>()=>F.current(Date.now()),[]);const R=X(n==null?void 0:n.browsers),C=((n==null?void 0:n.browsers)??[]).filter(f=>!(f.installed&&f.profiles>0)),S=n?ye(n,l):null,$=R.reduce((f,N)=>f+N.profiles,0);return e.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:e.jsxs("div",{ref:d,className:"modal bw-modal",onClick:f=>f.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"bw-title",children:[e.jsxs("header",{className:"modal-head",children:[e.jsxs("div",{className:"modal-title",children:[e.jsx("span",{className:"modal-tool-name",id:"bw-title",children:l("settings.bw.title")}),e.jsx("span",{className:"modal-tool-id",children:n?l("settings.bw.scope.profiles",{count:$}):l("settings.bw.scope.localOnly")})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{ref:v,className:"glyph-btn",onClick:()=>void x(!0),...de(c),"aria-label":l("settings.bw.reread"),title:l("settings.bw.reread"),children:c?"…":e.jsx(oe,{})}),e.jsx("button",{className:"glyph-btn",onClick:s,"aria-label":l("settings.bw.close"),title:l("settings.bw.close"),children:"×"})]})]}),e.jsxs("div",{className:"modal-body bw-body",children:[!n&&!r&&e.jsxs("div",{className:"bw-loading",children:[e.jsx("span",{className:"bw-loading-bar","aria-hidden":!0}),e.jsx("p",{children:l("settings.bw.loading")})]}),r&&e.jsx("div",{className:"bw-state",children:e.jsxs("div",{className:"bw-row err",children:[e.jsx("span",{className:"bw-dot","aria-hidden":!0}),e.jsx("span",{className:"bw-row-label",children:l("settings.bw.readFail")}),e.jsx("span",{className:"bw-row-detail",children:r})]})}),n&&S&&e.jsx("p",{className:`bw-trouble ${S.kind}`,role:"status",children:S.text}),n&&e.jsxs("div",{className:"bw-work",children:[e.jsxs("aside",{className:"bw-side",children:[e.jsx(ke,{snap:n,watching:R,palette:i}),e.jsx(Me,{watching:R,rest:C}),n.relay&&e.jsx(Ce,{relay:n.relay})]}),e.jsxs("div",{className:"bw-main",children:[e.jsx(ue,{snap:n,dismiss:W,refreshRef:v}),e.jsx(he,{snap:n})]})]}),n&&m&&e.jsx(Se,{snap:n,quiet:u,setQuiet:g,save:T,access:A,setAccess:k}),w&&e.jsx("div",{className:"bw-state bw-write-err",role:"alert",children:e.jsxs("div",{className:"bw-row err",children:[e.jsx("span",{className:"bw-dot","aria-hidden":!0}),e.jsx("span",{className:"bw-row-label",children:l("settings.bw.saveFail")}),e.jsx("span",{className:"bw-row-detail",children:l("settings.bw.saveFailDetail",{error:w})}),e.jsx("button",{className:"glyph-btn bw-write-err-x",onClick:()=>b(null),"aria-label":l("settings.bw.dismiss"),title:l("settings.bw.dismiss"),children:"×"})]})}),n&&e.jsx(Te,{snap:n,saving:p,save:T,why:m,setWhy:y})]})]})})}export{Ae as default};
|
|
1
|
+
import{u as P,j as e,b as h,a1 as Z,a2 as ee,e as V,t as I,a3 as se,g as te,a4 as ne,x as ae,a5 as ie,s as re,a6 as J,o as Q,C as le,D as ce,R as oe,i as de}from"./app-Dx9D4Afq.js";function he({snap:s}){const a=P();return e.jsxs("section",{className:"bw-feed",children:[e.jsxs("h4",{className:"bw-sec-head bw-head-row",children:[a("settings.bw.feed"),e.jsx("span",{className:"bw-feed-count",children:a("settings.bw.feed.count",{count:s.log.length})})]}),e.jsx("p",{className:"bw-since bw-feed-note",children:a("settings.bw.feed.note")}),e.jsx("div",{className:"bw-log","aria-live":"polite","aria-relevant":"additions",children:s.log.length===0?e.jsx("p",{className:"bw-note",children:a("settings.bw.feed.empty")}):s.log.map(t=>e.jsxs("div",{className:`bw-log-line ${t.level}${t.parts?"":" sys"}`,children:[e.jsx("span",{className:"bw-log-time",children:new Date(t.atMs).toLocaleTimeString("en-GB",{hour12:!1})}),t.parts?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bw-log-browser",children:t.parts.browser}),e.jsx("span",{className:"bw-log-profile",title:t.parts.profile,children:t.parts.profile}),e.jsxs("span",{className:"bw-log-value",children:[t.parts.value,t.parts.flagged>0&&e.jsx("span",{className:"bw-log-flag",children:a("settings.bw.feed.flagged",{count:t.parts.flagged})})]})]}):e.jsx("span",{className:"bw-log-sys",children:t.text})]},`${t.atMs}-${t.level}-${t.text}`))})]})}const D=s=>`${s.host}-${s.startMs}`;function we(s){const a=t=>new Date(t).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1});return s.count===1||s.endMs-s.startMs<6e4?a(s.startMs):`${a(s.startMs)} → ${a(s.endMs)}`}function be(s){return new Date(s).toLocaleDateString(V(),{weekday:"short",day:"numeric",month:"short"})}function _(s,a){const t=Math.round((s.endMs-s.startMs)/6e4);return t<1?"":a("settings.bw.findings.minutes",{n:t})}function ue({snap:s,dismiss:a,refreshRef:t}){const i=P(),[l,d]=h.useState(null),o=h.useRef(new Map),n=h.useRef(null);h.useEffect(()=>{var c,u;const b=n.current;!b||s.episodes.some(g=>D(g)===b.id)||(n.current=null,Z(((c=document.activeElement)==null?void 0:c.tagName)??null)&&((u=(b.next?o.current.get(b.next):void 0)??t.current)==null||u.focus()))},[s]);const r=b=>{n.current={id:D(b),next:ee(s.episodes.map(D),D(b))},a(b)},w=h.useMemo(()=>{const b=[];for(const c of s.episodes){const u=be(c.startMs),g=b[b.length-1];g&&g.label===u?g.episodes.push(c):b.push({label:u,episodes:[c]})}return b},[s]);return e.jsxs("section",{className:"bw-findings",children:[e.jsxs("h4",{className:"bw-sec-head bw-head-row",children:[i("settings.bw.findings"),s.episodes.length>0&&e.jsx("span",{className:"bw-feed-count",children:i("settings.bw.findings.count",{count:s.episodes.length})})]}),e.jsx("div",{className:"bw-eps",children:w.length===0?e.jsxs("div",{className:"bw-empty",children:[e.jsx("p",{className:"bw-empty-head",children:i("settings.bw.findings.none")}),e.jsx("p",{className:"bw-empty-note",children:i("settings.bw.findings.noneNote",{count:s.settings.quietMinutes})}),!s.settings.enabled&&e.jsx("p",{className:"bw-empty-note",children:i("settings.bw.findings.offNote")})]}):w.map(b=>e.jsxs("div",{className:"bw-day",children:[e.jsx("h4",{className:"bw-sec-head",children:b.label}),b.episodes.map(c=>{const u=D(c),g=l===u;return e.jsxs("div",{className:`bw-ep${g?" open":""}`,children:[e.jsxs("div",{className:"bw-ep-row",children:[e.jsxs("button",{className:"bw-ep-head",ref:p=>{p?o.current.set(u,p):o.current.delete(u)},onClick:()=>d(g?null:u),"aria-expanded":g,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:g?"▾":"▸"}),e.jsx("span",{className:"bw-ep-host",children:c.host}),e.jsxs("span",{className:"bw-ep-meta",children:[we(c),_(c,i)&&e.jsxs(e.Fragment,{children:[" · ",_(c,i)]}),c.provisional&&e.jsxs(e.Fragment,{children:[" · ",e.jsx("span",{title:i("settings.bw.findings.provisionalTip"),children:i("settings.bw.findings.provisional")})]})]}),e.jsx("span",{className:"bw-ep-count",children:i("settings.bw.findings.pages",{count:c.count})})]}),e.jsx("button",{className:"glyph-btn bw-ep-x",onClick:()=>r(c),"aria-label":i("settings.bw.findings.dismissHost",{host:c.host}),title:i("settings.bw.findings.dismissTip"),children:"×"})]}),g&&e.jsx("ul",{className:"bw-urls",children:c.urls.map((p,x)=>e.jsxs("li",{children:[e.jsx("span",{className:"bw-url-time",children:new Date(p.timeMs).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit",hour12:!1})}),e.jsx("span",{className:"bw-url",children:p.url})]},`${p.url}-${p.timeMs}-${x}`))})]},u)})]},b.label))})]})}function ge(s){const a=/^#?([0-9a-f]{6})$/i.exec((s??"").trim());if(!a)return!1;const t=parseInt(a[1],16),i=[t>>16&255,t>>8&255,t&255].map(l=>{const d=l/255;return d<=.03928?d/12.92:Math.pow((d+.055)/1.055,2.4)});return .2126*i[0]+.7152*i[1]+.0722*i[2]>.5}const z=1e4,me=12e3;function fe({browsers:s,findings:a,watching:t,palette:i}){const l=P(),d=h.useRef(null),o=h.useRef(null);return o.current={browsers:s,findings:a,watching:t},h.useEffect(()=>{var g;const n=d.current;if(!n)return;const r=n.getContext("2d");if(!r)return;const w=((g=window.matchMedia)==null?void 0:g.call(window,"(prefers-reduced-motion: reduce)").matches)??!1;let b=0,c=!1;const u=()=>{var U;if(c)return;const p=o.current;if(!p)return;const{browsers:x,findings:W,watching:T}=p,m=i["--accent"]||"#7dd3fc",y=i["--line"]||"#1f2229",A=i["--text-dim"]||"#6e727c",k=ge(i["--bg"]),v=k?42:26,F=k?.85:.65,R=Date.now(),C=Math.min(window.devicePixelRatio||1,2),S=n.clientWidth,$=n.clientHeight;(n.width!==S*C||n.height!==$*C)&&(n.width=S*C,n.height=$*C),r.setTransform(C,0,0,C,0,0),r.clearRect(0,0,S,$);const f=S/2,N=$/2,M=Math.min(S,$)/2-6;r.strokeStyle=y,r.lineWidth=1,r.globalAlpha=k?1:.9;for(const j of[.4,.7,1])r.beginPath(),r.arc(f,N,M*j,0,Math.PI*2),r.stroke();r.beginPath(),r.moveTo(f-M,N),r.lineTo(f+M,N),r.moveTo(f,N-M),r.lineTo(f,N+M),r.stroke(),r.globalAlpha=1;const B=(T&&!w?R%z/z:0)*Math.PI*2-Math.PI/2;if(T){const j=(U=r.createConicGradient)==null?void 0:U.call(r,B-.85,f,N);j&&(j.addColorStop(0,"transparent"),j.addColorStop(.85/(Math.PI*2),`color-mix(in srgb, ${m} ${v}%, transparent)`),j.addColorStop(1,"transparent"),r.fillStyle=j,r.beginPath(),r.moveTo(f,N),r.arc(f,N,M,B-.85,B),r.closePath(),r.fill()),r.strokeStyle=m,r.globalAlpha=F,r.beginPath(),r.moveTo(f,N),r.lineTo(f+Math.cos(B)*M,N+Math.sin(B)*M),r.stroke(),r.globalAlpha=1}x.forEach((j,E)=>{const O=E/Math.max(x.length,1)*Math.PI*2-Math.PI/2,L=j.lastReadMs===null?1:Math.min(1,(R-j.lastReadMs)/12e4),q=M*(.42+L*.5),G=f+Math.cos(O)*q,K=N+Math.sin(O)*q,Y=Math.abs((B-O+Math.PI*3)%(Math.PI*2)-Math.PI),H=T?Math.max(0,1-Y/.55):0;r.beginPath(),r.arc(G,K,3+H*1.6,0,Math.PI*2),r.fillStyle=j.running?m:A,r.globalAlpha=j.running?.55+H*.45:.35,r.fill(),r.globalAlpha=1});for(const j of W){const E=(R-j.atMs)/me;if(E<0||E>1)continue;const L=Math.max(0,x.findIndex(K=>K.key===j.browser))/Math.max(x.length,1)*Math.PI*2-Math.PI/2,q=f+Math.cos(L)*M*.6,G=N+Math.sin(L)*M*.6;r.beginPath(),r.arc(q,G,4+E*22,0,Math.PI*2),r.strokeStyle=m,r.globalAlpha=(1-E)*.8,r.lineWidth=1.5,r.stroke(),r.globalAlpha=1}b=requestAnimationFrame(u)};return u(),()=>{c=!0,cancelAnimationFrame(b)}},[i]),e.jsx("canvas",{ref:d,className:"bw-radar",role:"img","aria-label":t?l("radar.watch.watching",{count:s.length}):l("radar.watch.idle")})}function xe(s,a,t){if(s===null)return null;const i=s+a-t;return i>0?i:null}function pe(s){const a=Math.ceil(s/1e3),t=Math.floor(a/60),i=a%60;return t>0?`${t}m ${i}s`:`${i}s`}function X(s){return(s??[]).filter(a=>a.installed&&a.profiles>0)}function je(s,a=I){return!Number.isFinite(s)||s<=0?a("settings.bw.logEmpty"):se(s)}function Ne(s,a){return s.map(t=>({key:t.key,name:t.name,running:t.running,visits:a.filter(i=>i.browser===t.key).reduce((i,l)=>i+l.programVisits,0)}))}function ve(s,a,t=I){if(s===null)return null;const i=Math.max(0,Math.round((a-s)/1e3));if(i<5)return t("settings.bw.ago.now");if(i<60)return t("settings.bw.ago.sec",{n:i});const l=Math.round(i/60);return l<60?t("settings.bw.ago.min",{n:l}):t("settings.bw.ago.hr",{n:Math.round(l/60)})}function ye(s,a=I){const t=s.profiles.filter(l=>l.degraded);if(t.length>0){const l=t[0],d=t.length-1;return{kind:"unreadable",text:a(d>0?"settings.bw.trouble.unreadableMore":"settings.bw.trouble.unreadable",{browser:l.name,profile:l.profile,reason:l.reason??a("settings.bw.trouble.noReason"),more:d})}}const i=X(s.browsers);return i.length===0?{kind:"no-profiles",text:a("settings.bw.trouble.noProfiles")}:i.some(l=>l.running)?null:{kind:"none-running",text:a("settings.bw.trouble.noneRunning")}}function ke({snap:s,watching:a,palette:t}){const i=P(),[l,d]=h.useState(!1),[o,n]=h.useState(()=>Date.now());h.useEffect(()=>{const w=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(w)},[]);const r=xe(s.coverage.lastHumanMs,s.coverage.quietMs,o);return e.jsxs("section",{className:"bw-sec",children:[e.jsxs("h4",{className:"bw-sec-head",children:[i("settings.bw.overview"),e.jsx("button",{className:"bw-help",onClick:()=>d(w=>!w),"aria-expanded":l,"aria-label":i("settings.bw.overview.help"),children:"?"})]}),e.jsxs("div",{className:"bw-glance",children:[e.jsx(fe,{browsers:a.map(w=>{var b;return{key:w.key,name:w.name,running:w.running,lastReadMs:((b=s.profiles.find(c=>c.browser===w.key))==null?void 0:b.lastWrittenMs)??null}}),findings:s.episodes.slice(0,6).map(w=>({browser:w.browser??null,atMs:w.endMs})),watching:s.settings.enabled,palette:t}),e.jsx("ul",{className:"bw-counts",children:Ne(a,s.profiles).map(w=>e.jsxs("li",{children:[e.jsx("span",{className:"bw-count-n",children:te(w.visits,0)}),e.jsx("span",{className:"bw-count-of",children:w.name})]},w.key))})]}),e.jsx("p",{className:"bw-since",children:i("settings.bw.overview.since")}),s.coverage.checkedMs>0&&e.jsxs("p",{className:"bw-since",children:[i("settings.bw.overview.checked",{ago:ve(s.coverage.checkedMs,o,i)??""}),s.coverage.checks>0&&e.jsxs(e.Fragment,{children:[" · ",i("settings.bw.overview.checks",{count:s.coverage.checks})]})]}),r!==null&&e.jsx("p",{className:"bw-gate",children:i("settings.bw.overview.gate",{time:pe(r)})}),l&&e.jsxs("dl",{className:"bw-key",children:[e.jsx("dt",{children:i("settings.bw.key.sweep")}),e.jsx("dd",{children:i("settings.bw.key.sweepText")}),e.jsx("dt",{children:i("settings.bw.key.dot")}),e.jsx("dd",{children:i("settings.bw.key.dotText")}),e.jsx("dt",{children:i("settings.bw.key.ring")}),e.jsx("dd",{children:i("settings.bw.key.ringText")})]})]})}function Me({watching:s,rest:a}){const t=P(),[i,l]=h.useState(!1),[d,o]=h.useState(!1);return e.jsxs("section",{className:"bw-sec",children:[e.jsxs("h4",{className:"bw-sec-head",children:[t("settings.bw.profiles"),e.jsx("button",{className:"bw-help",onClick:()=>l(n=>!n),"aria-expanded":i,"aria-label":t("settings.bw.profiles.help"),children:"?"})]}),i&&e.jsxs("dl",{className:"bw-key",children:[e.jsx("dt",{children:t("settings.bw.key.running")}),e.jsx("dd",{children:t("settings.bw.key.runningText")}),e.jsx("dt",{children:t("settings.bw.key.connected")}),e.jsx("dd",{children:t("settings.bw.key.connectedText")})]}),e.jsx("ul",{className:"bw-profiles",children:s.map(n=>e.jsxs("li",{children:[e.jsx("span",{className:`bw-prof-dot${n.running?" on":""}`,"aria-hidden":!0}),e.jsx("span",{className:"bw-prof-name",children:n.name}),e.jsx("span",{className:"bw-prof-state",children:n.running?t("settings.bw.running"):t("settings.bw.idle")}),n.running&&n.relay.state==="live"&&e.jsx("span",{className:"bw-relay",children:t("settings.bw.relay")})]},n.key))}),a.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:"bw-why bw-rest-head",onClick:()=>o(n=>!n),"aria-expanded":d,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:d?"▾":"▸"})," ",t("settings.bw.notWatched",{count:a.length})]}),d&&e.jsx("p",{className:"bw-rest",children:t("settings.bw.notWatchedText",{names:a.map(n=>n.name).join(", ")})})]})]})}function Se({snap:s,quiet:a,setQuiet:t,save:i,access:l,setAccess:d}){const o=P();return e.jsxs("div",{className:"bw-settings",children:[e.jsxs("label",{title:o("settings.bw.quiet.tip"),children:[e.jsx("span",{children:o("settings.bw.quiet.label")}),e.jsx("select",{value:a??s.settings.quietMinutes,onChange:n=>{t(Number(n.target.value)),i({quietMinutes:Number(n.target.value)})},children:[1,5,15,30,60].map(n=>e.jsx("option",{value:n,children:o("settings.bw.minutes",{n})},n))})]}),e.jsxs("label",{children:[e.jsx("span",{children:o("settings.bw.reaction.label")}),e.jsx("select",{value:s.settings.reaction,onChange:n=>void i({reaction:n.target.value}),disabled:!s.settings.enabled,title:s.settings.enabled?o("settings.bw.reaction.hintOn"):o("settings.bw.reaction.hintOff"),children:(s.reactions??["notify"]).map(n=>e.jsx("option",{value:n,children:o(n==="notify"?"settings.bw.reaction.notify":n==="close-tab"?"settings.bw.reaction.closeTab":"settings.bw.reaction.quit")},n))})]}),e.jsxs("div",{className:"bw-settings-note",children:[e.jsxs("p",{children:[o("settings.bw.note.chrome")," ",e.jsx("strong",{children:o("settings.bw.note.usually")})]}),e.jsxs("button",{className:"bw-why",onClick:()=>d(n=>!n),"aria-expanded":l,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:l?"▾":"▸"})," ",o("settings.bw.access.toggle")]}),l&&e.jsxs("dl",{className:"bw-access",children:[e.jsx("dt",{children:o("settings.bw.access.reads")}),e.jsx("dd",{children:o("settings.bw.access.readsText",{when:new Date(s.coverage.startedMs).toLocaleString(V())})}),e.jsx("dt",{children:o("settings.bw.access.keeps")}),e.jsx("dd",{children:ne(o("settings.bw.access.keepsText",{path:"{path}",size:typeof s.coverage.logBytes=="number"?` (${je(s.coverage.logBytes)})`:""}),{path:e.jsx("code",{className:"bw-path",children:s.coverage.logPath})})}),e.jsx("dt",{children:o("settings.bw.access.sends")}),e.jsx("dd",{children:o("settings.bw.access.sendsText")}),e.jsx("dt",{children:o("settings.bw.access.never")}),e.jsx("dd",{children:o("settings.bw.access.neverText")})]})]})]})}function Pe(s,a,t){return a?{kind:"saving",word:t("settings.bw.mode.saving")}:s.settings.enabled?{kind:"on",word:t("settings.bw.mode.watching")}:{kind:"off",word:t("settings.bw.mode.paused")}}function Te({snap:s,saving:a,save:t,why:i,setWhy:l}){const d=P(),o=Pe(s,a,d);return e.jsxs("footer",{className:"bw-status",children:[e.jsx("span",{className:`bw-mode-dot${s.settings.enabled?" on":""}`,"aria-hidden":!0}),e.jsx("span",{className:"bw-mode-word",children:o.word},o.kind),e.jsx("span",{className:"bw-status-text",children:s.coverage.archived===0?s.settings.enabled?d("settings.bw.disk.none"):d("settings.bw.disk.noneOff"):d("settings.bw.disk.some",{count:s.coverage.archived})}),e.jsx("button",{className:`glyph-btn bw-gear${i?" on":""}`,onClick:()=>l(n=>!n),"aria-expanded":i,"aria-label":d("settings.bw.settings"),title:d("settings.bw.settings"),children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3","aria-hidden":!0,children:[e.jsx("circle",{cx:"7",cy:"7",r:"2.1"}),e.jsx("path",{d:"M7 1.2v1.6M7 11.2v1.6M1.2 7h1.6M11.2 7h1.6M2.9 2.9l1.1 1.1M10 10l1.1 1.1M11.1 2.9L10 4M4 10l-1.1 1.1"})]})}),e.jsxs("label",{className:"bw-switch",htmlFor:"bw-enabled",children:[e.jsx("span",{className:"bw-switch-label",id:"bw-enabled-label",children:d("settings.bw.switch")}),e.jsx("button",{id:"bw-enabled",type:"button",role:"switch","aria-checked":s.settings.enabled,"aria-labelledby":"bw-enabled-label",className:"switch",onClick:()=>void t({enabled:!s.settings.enabled}),title:s.settings.enabled?d("settings.bw.switch.on"):d("settings.bw.switch.off"),children:e.jsx("span",{className:"switch-knob"})})]})]})}function Ce({relay:s}){const a=P(),[t,i]=h.useState(!1),[l,d]=h.useState(!1),o=s.killswitch.blocked?"unblock":"block",n=s.command[o],r=h.useCallback(async()=>{await ae(n.command)&&(d(!0),window.setTimeout(()=>d(!1),1600))},[n.command]),w=s.profiles.filter(c=>{var u;return(u=c.report)==null?void 0:u.present}),b=s.profiles.filter(c=>c.report===null);return e.jsxs("section",{className:"bw-sec",children:[e.jsx("h4",{className:"bw-sec-head",children:a("shell.remote.title")}),e.jsx("p",{className:`bw-rc-verdict ${s.verdict}`,role:"status",children:s.verdict==="exposed"?a("shell.remote.exposed"):s.verdict==="protected"?a("shell.remote.protected",{path:s.hostsPath}):a("shell.remote.nothing")}),s.killswitch.foreign.length>0&&e.jsxs("p",{className:"bw-rc-foreign",children:[a("shell.remote.foreign",{path:s.hostsPath}),s.killswitch.foreign.map(c=>e.jsx("code",{className:"bw-path",children:c},c))]}),e.jsxs("button",{className:"bw-why",onClick:()=>i(c=>!c),"aria-expanded":t,children:[e.jsx("span",{className:"bw-chev","aria-hidden":!0,children:t?"▾":"▸"})," ",s.verdict==="protected"?a("shell.remote.undo"):a("shell.remote.reach")]}),t&&e.jsxs("div",{className:"bw-rc-body",children:[w.length>0&&e.jsx("dl",{className:"bw-key",children:w.map(c=>e.jsxs(h.Fragment,{children:[e.jsxs("dt",{children:[c.name,c.profile==="Default"?"":` · ${c.profile}`]}),e.jsxs("dd",{children:[a("shell.remote.detail",{state:c.report.enabled?a("shell.remote.enabled"):a("shell.remote.switchedOff"),scope:c.report.allUrls?a("shell.remote.allSites"):a("shell.remote.limited")}),c.report.sensitiveApis.length>0&&e.jsxs(e.Fragment,{children:[" — ",c.report.sensitiveApis.join(", ")]})]})]},`${c.browser}/${c.profile}`))}),b.length>0&&e.jsx("p",{className:"bw-rc-note",children:a("shell.remote.unreadable",{names:b.map(c=>c.name).join(", ")})}),!s.hostsRead&&e.jsx("p",{className:"bw-rc-note",children:a("shell.remote.hostsUnread",{path:s.hostsPath})}),w.some(c=>c.report.allUrls)&&e.jsx("p",{className:"bw-rc-note",children:ie(a("shell.remote.narrow"),"code",e.jsx("code",{className:"bw-path",children:"chrome://extensions"}))}),e.jsxs("div",{className:"bw-rc-cmd",children:[e.jsx("code",{children:n.command}),e.jsx("button",{className:"btn bw-rc-copy",onClick:r,children:a(l?"shell.copied":"shell.copy")})]}),e.jsx("p",{className:"bw-rc-note",children:n.note})]})]})}function Re(s){const[a,t]=h.useState(null),[i,l]=h.useState(null),[d,o]=h.useState(null),[n,r]=h.useState(!1),w=h.useRef(!1),[b,c]=h.useState(null),[u,g]=h.useState(!1),p=h.useRef(!1),x=h.useCallback(async m=>{var y,A;if(!(m&&!re(w.current))){m&&(w.current=!0,r(!0));try{const k=await fetch(`/api/browser-watch${m?"?refresh=1":""}`);if(!k.ok)throw new J(I("settings.bw.deckAnswered",{status:k.status}));const v=await k.json();t(v),p.current||c(((y=v==null?void 0:v.settings)==null?void 0:y.quietMinutes)??15),s(((A=v==null?void 0:v.settings)==null?void 0:A.enabled)===!0),l(null)}catch(k){l(Q(k,I("settings.bw.noAnswer")))}finally{m&&(w.current=!1,r(!1))}}},[s]);h.useEffect(()=>{x(!1)},[x]),h.useEffect(()=>{const m=setInterval(()=>{x(!1)},1e4);return()=>clearInterval(m)},[x]);const W=h.useCallback(async m=>{try{await fetch("/api/browser-watch/dismiss",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({host:m.host,startMs:m.startMs})})}finally{await x(!1)}},[x]),T=h.useCallback(async m=>{p.current=!0,g(!0);try{const y=await fetch("/api/browser-watch",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(m)});if(!y.ok)throw new J(I("settings.bw.deckAnswered",{status:y.status}));await x(!1),o(null)}catch(y){o(Q(y,I("settings.bw.noAnswer")))}finally{p.current=!1,g(!1)}},[x]);return{snap:a,error:i,writeError:d,setWriteError:o,busy:n,quiet:b,setQuiet:c,saving:u,load:x,dismiss:W,save:T}}function Ae({onClose:s,onSeen:a,onWatching:t,palette:i}){const l=P(),d=le(s),o=ce(s),{snap:n,error:r,writeError:w,setWriteError:b,busy:c,quiet:u,setQuiet:g,saving:p,load:x,dismiss:W,save:T}=Re(t),[m,y]=h.useState(!1),[A,k]=h.useState(!1),v=h.useRef(null),F=h.useRef(a);F.current=a,h.useEffect(()=>()=>F.current(Date.now()),[]);const R=X(n==null?void 0:n.browsers),C=((n==null?void 0:n.browsers)??[]).filter(f=>!(f.installed&&f.profiles>0)),S=n?ye(n,l):null,$=R.reduce((f,N)=>f+N.profiles,0);return e.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:e.jsxs("div",{ref:d,className:"modal bw-modal",onClick:f=>f.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"bw-title",children:[e.jsxs("header",{className:"modal-head",children:[e.jsxs("div",{className:"modal-title",children:[e.jsx("span",{className:"modal-tool-name",id:"bw-title",children:l("settings.bw.title")}),e.jsx("span",{className:"modal-tool-id",children:n?l("settings.bw.scope.profiles",{count:$}):l("settings.bw.scope.localOnly")})]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{ref:v,className:"glyph-btn",onClick:()=>void x(!0),...de(c),"aria-label":l("settings.bw.reread"),title:l("settings.bw.reread"),children:c?"…":e.jsx(oe,{})}),e.jsx("button",{className:"glyph-btn",onClick:s,"aria-label":l("settings.bw.close"),title:l("settings.bw.close"),children:"×"})]})]}),e.jsxs("div",{className:"modal-body bw-body",children:[!n&&!r&&e.jsxs("div",{className:"bw-loading",children:[e.jsx("span",{className:"bw-loading-bar","aria-hidden":!0}),e.jsx("p",{children:l("settings.bw.loading")})]}),r&&e.jsx("div",{className:"bw-state",children:e.jsxs("div",{className:"bw-row err",children:[e.jsx("span",{className:"bw-dot","aria-hidden":!0}),e.jsx("span",{className:"bw-row-label",children:l("settings.bw.readFail")}),e.jsx("span",{className:"bw-row-detail",children:r})]})}),n&&S&&e.jsx("p",{className:`bw-trouble ${S.kind}`,role:"status",children:S.text}),n&&e.jsxs("div",{className:"bw-work",children:[e.jsxs("aside",{className:"bw-side",children:[e.jsx(ke,{snap:n,watching:R,palette:i}),e.jsx(Me,{watching:R,rest:C}),n.relay&&e.jsx(Ce,{relay:n.relay})]}),e.jsxs("div",{className:"bw-main",children:[e.jsx(ue,{snap:n,dismiss:W,refreshRef:v}),e.jsx(he,{snap:n})]})]}),n&&m&&e.jsx(Se,{snap:n,quiet:u,setQuiet:g,save:T,access:A,setAccess:k}),w&&e.jsx("div",{className:"bw-state bw-write-err",role:"alert",children:e.jsxs("div",{className:"bw-row err",children:[e.jsx("span",{className:"bw-dot","aria-hidden":!0}),e.jsx("span",{className:"bw-row-label",children:l("settings.bw.saveFail")}),e.jsx("span",{className:"bw-row-detail",children:l("settings.bw.saveFailDetail",{error:w})}),e.jsx("button",{className:"glyph-btn bw-write-err-x",onClick:()=>b(null),"aria-label":l("settings.bw.dismiss"),title:l("settings.bw.dismiss"),children:"×"})]})}),n&&e.jsx(Te,{snap:n,saving:p,save:T,why:m,setWhy:y})]})]})})}export{Ae as default};
|