diff --git a/README.md b/README.md index abb34d2..52d420b 100644 --- a/README.md +++ b/README.md @@ -210,7 +210,8 @@ includes the explicit backgrounds used for consistent terminal rendering. graph, with a 6/12-month range and lifetime, peak-day, and streak summaries when supplied. This server-side history can lag live local telemetry. - An always-on Sessions view that measures local token activity while Codexometer - is running, with a Reset button for establishing a fresh baseline. + is running, with a Zero button for establishing a fresh baseline. Zero affects + only the local measurement interval and does not use a quota-reset token. Each independent local root session gets its own metrics and 30-second graph; explicitly linked spawned agents are included with their root. - Dismissible session rows that automatically return on fresh activity, @@ -470,7 +471,7 @@ Set up the recommended arrangement as follows. new live context arrives. 5. Leave Codexometer running while you work. Session monitoring starts automatically; - use Reset when you want a fresh measured interval, and keep unrelated Codex + use Zero when you want a fresh measured interval, and keep unrelated Codex activity quiet while running Benchmarks if you want the cleanest comparisons. Codexometer subscribes only to thread IDs that are already loaded by the @@ -586,7 +587,9 @@ codexometer --codex /path/to/codex | `Shift+Tab` | Select the previous top-level tab | | `r` | Refresh account history in Usage; otherwise refresh quota data | | `v` | Cycle views within Quota or Usage | -| `s` | Reset the Sessions baseline, or open Benchmark Scope | +| `z` | Zero the Sessions baseline | +| `s` | Open Benchmark Scope (Benchmark view only) | +| `o` | Arm Close All in the Sessions overview; press again to confirm, or `Esc` to cancel | | `g` | Cycle available trend periods in Quota → Pace or Zone | | `h` | Toggle the trace in Quota → Pace or Zone; in Sessions, reset all rows to graph-only / split detail-and-graph, closing full detail and clearing individual row choices | | `Left` / `Right` | In Sessions, less / more detail for the selected session: graph ↔ split ↔ wide ↔ full screen; stops at either end | @@ -1097,7 +1100,10 @@ The other top-level views are: parent sessions and are not counted again. Tokens retain the existing measurement baseline (including previously dismissed sessions); the session/state counts describe currently visible rows. Elapsed time and average rate - remain underneath when space permits; a clickable Reset control sits beside it. + remain underneath when space permits; clickable Zero and Close All controls + sit beside it, labelled `(Z)ERO` and `CL(O)SE ALL`. Close All dismisses + every visible session row, including those outside the current page, while + keeping the measurement baseline and telemetry. Account-wide quota details live in Quota, not Sessions. During unavailable observation, live state counts show **—**, not zero. Active sessions are checked once per second and the idle cadence relaxes to five seconds. @@ -1144,10 +1150,17 @@ The other top-level views are: when tokens, model calls, turn timing, durable activity, or attention moves forward, or when an inactive session becomes active again. An alert already visible when `[×]` is clicked is dismissed with its row; a later new or - changed alert restores it. Resetting session monitoring also restores every dismissed + changed alert restores it. Zeroing session monitoring also restores every dismissed row. With the keyboard, `Down` initially selects the top row, `Up` initially selects the bottom row, subsequent arrow presses move the highlight, and `x` - closes the selected row. + closes the selected row. Close All applies the same dismissal and automatic + return behavior to all rows. On narrow terminals its label becomes `[××]` + with `(O)` below it; Zero shows `0` with `(Z)`. + Close All requires confirmation: click or press `o` once to arm it, then click + or press `o` again within five seconds to confirm. `Esc` cancels. A change + to the visible rows requires a fresh confirmation; switching views or Zero + cancels an armed action. + Close All is disabled when no rows are visible. When the terminal cannot fit every root, use Page Up, Page Down, or the mouse wheel to page through the rows. - **Benchmark** — runs the selected scope from the active Core, Extended, or @@ -1261,7 +1274,7 @@ and output statistics are omitted rather than filling the card with `N/A`. **AVG TOK/MIN** is average observed tokens per minute since the measurement began (or the session joined)—not instantaneous generation speed. The total and all session averages update together every five seconds, unaffected -by mouse movement or keyboard-driven redraws. Start and reset update them +by mouse movement or keyboard-driven redraws. Start and Zero update them immediately; token counts and the rest of the interface retain their usual cadence. `CALLS` counts upstream model-response cycles observed after the current Sessions @@ -1289,7 +1302,7 @@ Codex. `NO INTEGER Δ` means no whole-point movement was observed, not necessari zero consumption; a smaller apportioned estimate is shown as `<1PP`. Stale, missing, late-baseline, and reset-crossing windows do not produce a per-session number. -Starting or resetting reads quota before establishing the local token baseline. +Starting or zeroing reads quota before establishing the local token baseline. These operations are not atomic, so unrelated account activity during the short boundary read remains another source of uncertainty. @@ -1369,7 +1382,7 @@ same action on that session. The presentations are: **WORKING** badge blinks only its ball, keeping the text and colour steady, and uses the same observed-work evidence as the animated dots, not merely recent activity. Completion and attention badges take priority; - starting/resetting monitoring, observation errors, or inactive sessions + starting/zeroing monitoring, observation errors, or inactive sessions suppress **WORKING**. Compact previews keep their content-type title. Eligible approval buttons sit below the complete command/request and source session. If the complete request plus controls cannot fit, a @@ -1564,6 +1577,7 @@ are clickable. Writable web mode exposes the same catalogue through | Command family | Live options and behaviour | | --- | --- | +| `/rename` | Edit the selected session’s saved name, review it and confirm. Uses Codex’s name API; works during an active turn and does not send a prompt or change model settings. | | `/model` | Advertised models, their descriptions and supported reasoning levels. Choosing a model resets its explicit speed override to the server default. | | Advertised speed commands, such as `/fast` | Names, IDs and descriptions come from the current model's service-tier catalogue; enable a tier or clear the explicit override. No speed names or tier IDs are assumed. | | `/plan` | Advertised collaboration modes, using Codex's built-in mode instructions. | @@ -1600,6 +1614,8 @@ scope is process-wide rather than session-local. See the official [app-server API overview](https://learn.chatgpt.com/docs/app-server#api-overview) for the upstream catalogues. +Renames require a loaded session and explicit confirmation within 30 seconds; a concurrent rename or reconnect invalidates the confirmation. The updated name appears on the next telemetry refresh. + Codex session-setting changes require a loaded, idle session and explicit confirmation within 30 seconds. The command and options are revalidated before sending; stale connections, pending approvals and changed options fail closed. A successful @@ -1610,6 +1626,16 @@ confirmations retain the draft and error context. These changes do not modify gl quota thresholds may later supersede model settings. Uncertain requests are not retried automatically. Read-only web mode offers no command-control endpoint. +**Remaining CLI command gaps** (compared with the official documented CLI list): + +| Area | Commands not implemented as Codexometer slash commands | +| --- | --- | +| Session lifecycle and conversation actions | `/new`, `/clear`, `/resume`, `/fork`, `/archive`, `/delete`, `/compact`, `/review`, `/init`, `/goal`, `/side`, `/btw`, `/approve` | +| CLI navigation and display | `/agent`, `/subagents`, `/copy`, `/diff`, `/status`, `/usage`, `/raw`, `/title`, `/theme`, `/pets`, `/pet`, `/keymap`, `/vim`, `/app`, `/exit`, `/quit` | +| Configuration and tools | `/ide`, `/plugins`, `/memories`, `/import`, `/feedback`, `/logout`, `/mention`, `/personality`, `/ps`, `/stop`, `/setup-default-sandbox`, `/sandbox-add-read-dir`, `/debug-config` | + +`/apps`, `/skills`, `/mcp`, `/hooks` and `/experimental` remain **browse-only** here; CLI invocation, installation, authentication, trust and toggle actions are not implemented. `/plan` changes mode but does not implement the CLI's optional prompt argument. `/fast` and other advertised tiers are session overrides, rather than persistent CLI defaults. `/statusline` configures Codexometer's own footer. Existing session navigation, copying and telemetry views provide some analogous actions without those slash names. Availability upstream varies by platform, version and enabled features; see the [official CLI command reference](https://learn.chatgpt.com/docs/developer-commands#built-in-slash-commands). + Slash commands cannot be sent, steered, queued or scheduled as ordinary prompts. Use `//` to send a literal leading slash (for example `//tmp/file` sends `/tmp/file`). Structured question answers are unaffected. API help is shown in @@ -1824,6 +1850,8 @@ session. Short boxes prioritise readable context and approval controls; the compact view omits the dots when fewer than three body rows fit. Sent-message acknowledgement animations remain confined to full detail. +Full approval reviews use a separate **65,536-character** budget, so longer commands and justifications retain their complete text and decision buttons. Ordinary telemetry excerpts remain limited to 4,096 characters. Requests exceeding the approval budget still require Codex; the reason stays pinned below the scrolling Detail text. **Home/End** jump to the first/last Detail line. Approval controls stay fixed while the review scrolls. Tabs, leading/trailing whitespace and Windows line endings do not disable approval buttons; display formatting preserves the original command and directory used for the decision. + Local rollout logs do **not** persist Codex's approval-request events, so a local preview can show only the message preceding an approval. `INPUT NEEDED` or `CHECK SESSION` alone never enables these controls. Requests with missing, diff --git a/internal/codex/file_approval.go b/internal/codex/file_approval.go index 5c24238..2d4f965 100644 --- a/internal/codex/file_approval.go +++ b/internal/codex/file_approval.go @@ -90,7 +90,11 @@ func configureFileApproval(c *SessionContext, grantRoot string, state *daemonCon c.ApprovalBlocked = "permissions" return } - if SanitizeSessionContext(c.Text) != c.Text { + if !approvalTextFits(c.Text) { + c.ApprovalBlocked = "truncated" + return + } + if !approvalTextDisplayable(c.Text) { c.ApprovalBlocked = "sanitised" return } diff --git a/internal/codex/file_approval_test.go b/internal/codex/file_approval_test.go index 7b01567..bcf8681 100644 --- a/internal/codex/file_approval_test.go +++ b/internal/codex/file_approval_test.go @@ -133,3 +133,16 @@ func TestFileDiffTotals(t *testing.T) { t.Fatal("empty diff has changes") } } + +func TestFileApprovalReasonWhitespace(t *testing.T) { + for _, reason := range []string{" Review the patch. ", "Review the patch.\n", "Review\tthis patch.\r\n"} { + _, c := fileApprovalFixture(t, testFilePatch, map[string]any{"reason": reason}) + if c.ApprovalToken == "" || c.ApprovalBlocked != "" || c.FileChanges == "" { + t.Fatalf("ordinary reason whitespace disabled decisions: %s", c.ApprovalBlocked) + } + } + _, c := fileApprovalFixture(t, testFilePatch, map[string]any{"reason": strings.Repeat("x", approvalTextLimit+1)}) + if c.ApprovalToken != "" || c.ApprovalBlocked != "truncated" { + t.Fatalf("incomplete review: blocked=%s actionable=%v", c.ApprovalBlocked, c.ApprovalToken != "") + } +} diff --git a/internal/codex/session_approval_test.go b/internal/codex/session_approval_test.go index 7d9d4b4..60a56a3 100644 --- a/internal/codex/session_approval_test.go +++ b/internal/codex/session_approval_test.go @@ -32,20 +32,22 @@ func TestApprovalCompleteCommandAndFailClosed(t *testing.T) { t.Fatal("structured fields did not preserve source values", c.CommandDetails) } for name, fields := range map[string]map[string]any{ - "stdin action": {"kind": "writeStdin"}, - "future action": {"kind": "unknownAction"}, - "null action": {"kind": nil}, - "malformed action": {"kind": 42}, - "wrong turn": {"turnId": "other"}, - "wrong item": {"itemId": "other"}, - "truncated": {"command": strings.Repeat("x", 5000)}, - "controls": {"command": "echo \x1b[31mhidden"}, - "hidden directory suffix": {"cwd": "/work\t"}, - "bidi": {"command": "echo \u202Ehidden"}, - "network": {"networkApprovalContext": map[string]string{"host": "example.com", "protocol": "https"}}, - "permissions": {"additionalPermissions": map[string]any{"network": true}}, - "no decisions": {"availableDecisions": []string{}}, - "ambiguous argv": {"command": []string{"echo", "a b"}}, + "stdin action": {"kind": "writeStdin"}, + "future action": {"kind": "unknownAction"}, + "null action": {"kind": nil}, + "malformed action": {"kind": 42}, + "wrong turn": {"turnId": "other"}, + "wrong item": {"itemId": "other"}, + "truncated": {"command": strings.Repeat("x", approvalTextLimit+1)}, + "expanded tabs exceed budget": {"command": strings.Repeat("\t", approvalTextLimit/4+1)}, + "controls": {"command": "echo \x1b[31mhidden"}, + "hidden directory suffix": {"cwd": "/work\u202e"}, + "bidi": {"command": "echo \u202Ehidden"}, + "bare carriage return": {"command": "echo visible\rhidden"}, + "network": {"networkApprovalContext": map[string]string{"host": "example.com", "protocol": "https"}}, + "permissions": {"additionalPermissions": map[string]any{"network": true}}, + "no decisions": {"availableDecisions": []string{}}, + "ambiguous argv": {"command": []string{"echo", "a b"}}, } { t.Run(name, func(t *testing.T) { _, c := approvalFixture(t, fields) @@ -74,7 +76,7 @@ func TestApprovalKindExplicitAndLegacyCommand(t *testing.T) { func TestApprovalStructuredJustificationIsBounded(t *testing.T) { _, c := approvalFixture(t, map[string]any{"reason": strings.Repeat(" ", 10000) + "Explanation\nCommand: not the real command"}) - if c.ApprovalToken == "" || c.CommandDetails.Command != "git push" || c.CommandDetails.Justification != "Explanation\nCommand: not the real command" { + if c.ApprovalToken == "" || c.CommandDetails.Command != "git push" || c.CommandDetails.Justification != strings.Repeat(" ", 10000)+"Explanation\nCommand: not the real command" { t.Fatal("justification confused command fields", c.CommandDetails) } } @@ -108,8 +110,9 @@ func TestApprovalRejectionDiagnostics(t *testing.T) { {map[string]any{"itemId": "unknown", "command": "pwd"}, "missing-directory"}, {map[string]any{"turnId": "", "command": "pwd", "cwd": "/work"}, "missing-identity"}, {map[string]any{"availableDecisions": []string{}}, "decisions"}, - {map[string]any{"command": strings.Repeat("x", 5000)}, "truncated"}, - {map[string]any{"command": "pwd\t"}, "sanitised"}, + {map[string]any{"command": strings.Repeat("x", approvalTextLimit+1)}, "truncated"}, + {map[string]any{"command": strings.Repeat("\t", approvalTextLimit/4+1)}, "truncated"}, + {map[string]any{"command": "pwd\x1b[31m"}, "sanitised"}, } { _, c := approvalFixture(t, tc.fields) if c.ApprovalBlocked != tc.reason || c.ApprovalToken != "" { @@ -121,3 +124,63 @@ func TestApprovalRejectionDiagnostics(t *testing.T) { t.Fatal("eligible request gained a rejection") } } + +func TestLongCommandApprovalKeepsCompleteReview(t *testing.T) { + command := "python3 - <<'PY'\n" + strings.Repeat("print('long review')\n", 400) + "# END OF COMMAND\nPY" + reason := strings.Repeat("Long explanation. ", 400) + "END OF JUSTIFICATION" + _, c := approvalFixture(t, map[string]any{"command": command, "reason": reason}) + if c.ApprovalToken == "" || c.ApprovalBlocked != "" || c.CommandDetails.Command != command || c.CommandDetails.Justification != reason || !strings.Contains(c.Text, command) || !strings.Contains(c.Text, reason) { + t.Fatal("long approval lost its complete review or controls") + } + if SanitizeSessionContext(reason) == reason { + t.Fatal("fixture does not exceed the ordinary excerpt budget") + } +} + +func TestLongApprovalCorrelatesCompleteStartedCommand(t *testing.T) { + states := map[string]*daemonContextState{} + command := strings.Repeat("echo long-command\n", 400) + "END OF COMMAND" + raw, _ := json.Marshal(map[string]any{"threadId": "root", "turnId": "turn", "item": map[string]any{"id": "cmd", "type": "commandExecution", "command": command, "cwd": "/work"}}) + daemonContextEvent(states, "item/started", nil, raw, time.Now()) + raw, _ = json.Marshal(map[string]any{"threadId": "root", "turnId": "turn", "itemId": "cmd", "reason": "Review command", "availableDecisions": []string{"accept", "decline"}}) + daemonContextEvent(states, "item/commandExecution/requestApproval", json.RawMessage(`"req"`), raw, time.Now()) + c := states["root"].requests[`"req"`] + if c.ApprovalToken == "" || c.CommandDetails.Command != command { + t.Fatal("started-command fallback truncated the approval") + } +} + +func TestApprovalWhitespaceDoesNotDisableDecisions(t *testing.T) { + for _, command := range []string{ + "git status\n", + "\n git status \n\n", + "python3 - <<'PY'\nif True:\n\tprint('ok')\nPY\n", + "printf 'a\tb'\n", + "git status\r\n", + } { + t.Run(command, func(t *testing.T) { + reason := " Review this command.\n\tKeep normal formatting.\n" + _, c := approvalFixture(t, map[string]any{"command": command, "reason": reason}) + if c.ApprovalToken == "" || c.ApprovalBlocked != "" { + t.Fatalf("ordinary whitespace disabled decisions: %s", c.ApprovalBlocked) + } + if c.CommandDetails.Command != command || c.CommandDetails.Directory != "/work" { + t.Fatal("formatting changed the original command or directory") + } + }) + } +} + +func TestApprovalDisplayPreservesWhitespace(t *testing.T) { + input := "\n first line \n\tsecond line\r\n\n" + want := "\n first line \n second line\n\n" + if got := SanitizeApprovalText(input); got != want { + t.Fatalf("review whitespace lost: got %q, want %q", got, want) + } + if !approvalTextDisplayable(input) { + t.Fatal("normal display formatting disabled decisions") + } + if approvalTextDisplayable("echo\x1b[2Jhidden") || approvalTextDisplayable("echo\u202ehidden") { + t.Fatal("non-whitespace controls treated as display formatting") + } +} diff --git a/internal/codex/session_commands.go b/internal/codex/session_commands.go index 8074cd6..96d82ca 100644 --- a/internal/codex/session_commands.go +++ b/internal/codex/session_commands.go @@ -25,6 +25,8 @@ type SessionCommandMenu struct { Path string `json:"path"` Revision string `json:"revision"` Multiple bool `json:"multiple,omitempty"` + Input bool `json:"input,omitempty"` + Value string `json:"value,omitempty"` Choices []SessionCommandChoice `json:"choices"` } diff --git a/internal/codex/session_commands_unix.go b/internal/codex/session_commands_unix.go index dfb7819..e994043 100644 --- a/internal/codex/session_commands_unix.go +++ b/internal/codex/session_commands_unix.go @@ -21,8 +21,8 @@ type commandModel struct { } type commandThread struct { - ID, Cwd string - Status struct{ Type string } + ID, Cwd, Name string + Status struct{ Type string } } func commandDigest(value any) string { @@ -107,6 +107,9 @@ func (p *daemonStatusProvider) SessionCommands(ctx context.Context, id, path str return SessionCommandMenu{}, ErrSessionCommand } path = strings.TrimPrefix(strings.TrimSpace(path), "/") + if name, ok := strings.CutPrefix(path, "rename "); ok { + path = "rename/" + url.PathEscape(strings.TrimSpace(name)) + } thread, err := p.commandThread(ctx, id) if err != nil { return SessionCommandMenu{}, err @@ -119,7 +122,7 @@ func (p *daemonStatusProvider) SessionCommands(ctx context.Context, id, path str p.mu.Lock() connection := fmt.Sprintf("%p", p.connection) p.mu.Unlock() - menu.Revision = commandDigest([]any{connection, thread.ID, thread.Cwd, thread.Status.Type, menu.Revision}) + menu.Revision = commandDigest([]any{connection, thread.ID, thread.Cwd, thread.Status.Type, thread.Name, menu.Revision}) return normalizeCommandMenu(menu), nil } @@ -151,7 +154,7 @@ func (p *daemonStatusProvider) commandMenu(ctx context.Context, t commandThread, m := SessionCommandMenu{Title: "/" + path, Help: "Live options from the shared Codex app-server.", Choices: []SessionCommandChoice{}} parts := strings.Split(path, "/") if path == "" || path == "help" { - families := []string{"model", "plan", "permissions", "skills", "apps", "mcp", "hooks", "experimental"} + families := []string{"rename", "model", "plan", "permissions", "skills", "apps", "mcp", "hooks", "experimental"} menus := make([]SessionCommandMenu, len(families)) errs := make([]error, len(families)) var wg sync.WaitGroup @@ -161,7 +164,7 @@ func (p *daemonStatusProvider) commandMenu(ctx context.Context, t commandThread, } wg.Wait() for i, family := range families { - if errs[i] == nil && len(menus[i].Choices) > 0 { + if errs[i] == nil && (len(menus[i].Choices) > 0 || menus[i].Input) { m.Choices = append(m.Choices, SessionCommandChoice{Label: "/" + family, Help: menus[i].Help, Next: family}) } } @@ -180,7 +183,29 @@ func (p *daemonStatusProvider) commandMenu(ctx context.Context, t commandThread, } } m.Title = "/ COMMANDS" - m.Help = "Choose a command. Options/help are discovered live. Settings changes target this session only, require confirmation and are available only while idle. Catalogues marked browse-only do not execute tools or change global configuration." + m.Help = "Choose a command. Options/help are discovered live. Changes target this session only and require confirmation. Model and permission settings are available only while idle. Catalogues marked browse-only do not execute tools or change global configuration." + return m, nil + } + if parts[0] == "rename" { + m.Title = "/rename" + m.Help = "Rename this session in Codex. Enter a single-line name, then review and confirm the change. It does not send a prompt or change model settings." + if path == "rename" { + m.Input = true + m.Value = commandLabel(t.Name) + return m, nil + } + if len(parts) != 2 { + return m, ErrSessionCommand + } + name, err := url.PathUnescape(parts[1]) + if err != nil || name == "" || len([]rune(name)) > 512 || commandLabel(name) != name { + return m, ErrSessionCommand + } + m.Choices = append(m.Choices, SessionCommandChoice{ + Label: "Rename to " + name, + Help: "Current name: " + commandLabel(t.Name) + "\nNew name: " + name + "\nOnly this session's saved name changes.", + method: "thread/name/set", params: map[string]any{"threadId": t.ID, "name": name}, + }) return m, nil } if parts[0] == "model" || parts[0] == "tier" || parts[0] == "plan" || parts[0] == "permissions" { @@ -294,7 +319,7 @@ func (p *daemonStatusProvider) commandMenu(ctx context.Context, t commandThread, } func commandReserved(s string) bool { - for _, name := range []string{"help", "model", "tier", "plan", "permissions", "skills", "apps", "mcp", "hooks", "experimental"} { + for _, name := range []string{"help", "rename", "model", "tier", "plan", "permissions", "skills", "apps", "mcp", "hooks", "experimental"} { if s == name { return true } @@ -321,7 +346,7 @@ func (p *daemonStatusProvider) ExecuteSessionCommand(ctx context.Context, id, pa for _, o := range m.Choices { if o.ID == choice && o.Action { p.mu.Lock() - valid := p.connection == conn && (p.contexts[id] == nil || len(p.contexts[id].requests) == 0) + valid := p.connection == conn && (o.method == "thread/name/set" || p.contexts[id] == nil || len(p.contexts[id].requests) == 0) p.mu.Unlock() if !valid { return ErrSessionCommand diff --git a/internal/codex/session_commands_unix_test.go b/internal/codex/session_commands_unix_test.go index 2851e93..52c99de 100644 --- a/internal/codex/session_commands_unix_test.go +++ b/internal/codex/session_commands_unix_test.go @@ -4,6 +4,7 @@ package codex import ( "context" + "net/url" "strings" "testing" ) @@ -106,3 +107,77 @@ func TestCommandMenuSingleLineLabelsFailClosed(t *testing.T) { } } } + +func TestSessionRenameScopedAndConfirmed(t *testing.T) { + p, f := newQuotaDaemon(t) + ctx := context.Background() + f.names = map[string]string{"one": "Original", "two": "Other session"} + f.commandStatus = "active" + root, err := p.SessionCommands(ctx, "one", "") + found := false + for _, o := range root.Choices { + found = found || o.Next == "rename" + } + if err != nil || !found { + t.Fatal("rename missing from root", err) + } + input, err := p.SessionCommands(ctx, "one", "rename") + if err != nil || !input.Input || input.Value != "Original" { + t.Fatal("missing current-name editor", input, err) + } + name := "Review / quota + rendering 界" + m, err := p.SessionCommands(ctx, "one", "rename/"+url.PathEscape(name)) + if err != nil || len(m.Choices) != 1 || !m.Choices[0].Action { + t.Fatal(m, err) + } + if len(f.nameWrites) != 0 { + t.Fatal("preparing rename sent a mutation") + } + if err := p.ExecuteSessionCommand(ctx, "one", m.Path, "stale", m.Choices[0].ID); err == nil { + t.Fatal("stale rename accepted") + } + if err := p.ExecuteSessionCommand(ctx, "two", m.Path, m.Revision, m.Choices[0].ID); err == nil { + t.Fatal("cross-session rename accepted") + } + if err := p.ExecuteSessionCommand(ctx, "one", m.Path, m.Revision, m.Choices[0].ID); err != nil { + t.Fatal(err) + } + f.mu.Lock() + if len(f.nameWrites) != 1 || f.names["one"] != name || f.names["two"] != "Other session" || len(f.writes) != 0 { + t.Error("wrong rename scope", f.nameWrites) + } + f.mu.Unlock() + if err := p.ExecuteSessionCommand(ctx, "one", m.Path, m.Revision, m.Choices[0].ID); err == nil { + t.Fatal("changed name did not invalidate confirmation") + } +} + +func TestSessionRenameRejectsUnsafeAndChangedNames(t *testing.T) { + p, f := newQuotaDaemon(t) + ctx := context.Background() + for _, path := range []string{"rename/", "rename/%zz", "rename/a/b", "rename/" + url.PathEscape("bad\nname"), "rename/" + url.PathEscape("bad\x1b[31mname"), "rename/" + strings.Repeat("x", 513)} { + if _, err := p.SessionCommands(ctx, "one", path); err == nil { + t.Fatalf("accepted unsafe name %q", path) + } + } + m, err := p.SessionCommands(ctx, "one", "/rename My session") + if err != nil { + t.Fatal(err) + } + f.mu.Lock() + f.names = map[string]string{"one": "Renamed elsewhere"} + f.mu.Unlock() + if err := p.ExecuteSessionCommand(ctx, "one", m.Path, m.Revision, m.Choices[0].ID); err == nil { + t.Fatal("overwrote concurrent rename") + } + m, err = p.SessionCommands(ctx, "one", m.Path) + if err != nil { + t.Fatal(err) + } + f.mu.Lock() + f.fail = "rename" + f.mu.Unlock() + if err := p.ExecuteSessionCommand(ctx, "one", m.Path, m.Revision, m.Choices[0].ID); err == nil { + t.Fatal("server rejection reported success") + } +} diff --git a/internal/codex/session_context.go b/internal/codex/session_context.go index ee86860..be1ec2c 100644 --- a/internal/codex/session_context.go +++ b/internal/codex/session_context.go @@ -69,9 +69,35 @@ type ApprovalCommandDetails struct { const sessionContextLimit = 4096 +// Approval reviews need the complete request, rather than a telemetry excerpt. +// Keep a separate bounded budget; ordinary context retains its smaller limit. +const approvalTextLimit = 64 * 1024 + // SanitizeSessionContext removes terminal escapes and control/bidi formatting. // It does not promise to redact secrets embedded in ordinary message text. func SanitizeSessionContext(text string) string { + return sanitizeContextText(text, sessionContextLimit, true) +} + +// SanitizeApprovalText formats a bounded approval review for terminal display. +// Ordinary whitespace formatting does not change the original approval action. +func SanitizeApprovalText(text string) string { + return sanitizeContextText(text, approvalTextLimit, false) +} + +// Account for tab expansion so an eligible review cannot be clipped in display. +func approvalTextFits(text string) bool { + return len([]rune(text))+3*strings.Count(text, "\t") <= approvalTextLimit +} + +// approvalTextDisplayable checks for content that terminal rendering would lose. +// Tabs, line breaks and surrounding spaces are ordinary request formatting; +// CRLF is a normal line ending on Windows. Keep the original action unchanged. +func approvalTextDisplayable(text string) bool { + return safePatchText(strings.ReplaceAll(text, "\r\n", "\n")) +} + +func sanitizeContextText(text string, limit int, trim bool) string { text = ansi.Strip(strings.ToValidUTF8(text, "�")) text = strings.Map(func(r rune) rune { if r == '\n' || r == '\t' { @@ -83,9 +109,12 @@ func SanitizeSessionContext(text string) string { return r }, text) text = strings.ReplaceAll(text, "\t", " ") - runes := []rune(strings.TrimSpace(text)) - if len(runes) > sessionContextLimit { - return string(runes[:sessionContextLimit-1]) + "…" + if trim { + text = strings.TrimSpace(text) + } + runes := []rune(text) + if len(runes) > limit { + return string(runes[:limit-1]) + "…" } return string(runes) } diff --git a/internal/codex/session_context_daemon.go b/internal/codex/session_context_daemon.go index 330519d..789f898 100644 --- a/internal/codex/session_context_daemon.go +++ b/internal/codex/session_context_daemon.go @@ -147,8 +147,8 @@ func daemonContextEvent(states map[string]*daemonContextState, method string, id } } allowed := c.ApprovalOptions[0].Kind != "" - // Fail closed if the display loses ANY command/request content, or if - // this is a broader grant rather than an ordinary command decision. + // Check completeness and supported action semantics independently of + // normal display formatting. Preserve the original command and directory. switch { case !kindValid: c.ApprovalBlocked = "approval-kind" @@ -166,13 +166,13 @@ func daemonContextEvent(states map[string]*daemonContextState, method string, id c.ApprovalBlocked = "missing-identity" case !allowed: c.ApprovalBlocked = "decisions" - case len([]rune(c.Text)) > sessionContextLimit: + case !approvalTextFits(c.Text) || !approvalTextFits(p.Reason) || !approvalTextFits(command) || !approvalTextFits(p.CWD): c.ApprovalBlocked = "truncated" - case SanitizeSessionContext(c.Text) != c.Text || SanitizeSessionContext(command) != command || SanitizeSessionContext(p.CWD) != p.CWD: + case !approvalTextDisplayable(c.Text) || !approvalTextDisplayable(p.Reason) || !approvalTextDisplayable(command) || !approvalTextDisplayable(p.CWD): c.ApprovalBlocked = "sanitised" default: c.ApprovalToken = rand.Text() - c.CommandDetails = ApprovalCommandDetails{Justification: SanitizeSessionContext(p.Reason), Command: command, Directory: p.CWD} + c.CommandDetails = ApprovalCommandDetails{Justification: SanitizeApprovalText(p.Reason), Command: command, Directory: p.CWD} } case "item/fileChange/requestApproval": c.Kind, c.Text = SessionContextApproval, p.Reason @@ -294,8 +294,8 @@ func daemonContextEvent(states map[string]*daemonContextState, method string, id // remain ineligible for approval, without retaining unbounded text. bounded := func(s string) string { r := []rune(s) - if len(r) > sessionContextLimit+1 { - return string(r[:sessionContextLimit+1]) + if len(r) > approvalTextLimit+1 { + return string(r[:approvalTextLimit+1]) } return s } @@ -317,7 +317,11 @@ func daemonContextEvent(states map[string]*daemonContextState, method string, id default: return } - c.Text = SanitizeSessionContext(c.Text) + if c.Kind == SessionContextApproval { + c.Text = SanitizeApprovalText(c.Text) + } else { + c.Text = SanitizeSessionContext(c.Text) + } if c.Text == "" { return } diff --git a/internal/codex/session_settings_unix_test.go b/internal/codex/session_settings_unix_test.go index 909e370..8da6143 100644 --- a/internal/codex/session_settings_unix_test.go +++ b/internal/codex/session_settings_unix_test.go @@ -28,6 +28,8 @@ type quotaDaemonFixture struct { commandStatus string catalogues map[string]map[string]any historyReads []map[string]any + names map[string]string + nameWrites []map[string]any } func TestQuotaEffortDefaultFallback(t *testing.T) { @@ -112,7 +114,16 @@ func newQuotaDaemon(t *testing.T) (*daemonStatusProvider, *quotaDaemonFixture) { if status == "" { status = "idle" } - result["thread"] = map[string]any{"id": id, "cwd": "/work", "status": map[string]any{"type": status}} + result["thread"] = map[string]any{"id": id, "cwd": "/work", "status": map[string]any{"type": status}, "name": fixture.names[id]} + case "thread/name/set": + fixture.nameWrites = append(fixture.nameWrites, req.Params) + failure = fixture.fail == "rename" + if !failure { + if fixture.names == nil { + fixture.names = map[string]string{} + } + fixture.names[id], _ = req.Params["name"].(string) + } case "thread/settings/update": fixture.writes = append(fixture.writes, req.Params) desired := fixture.sessions[id] diff --git a/internal/i18n/locales/da.json b/internal/i18n/locales/da.json index 2b668e9..3b34305 100644 --- a/internal/i18n/locales/da.json +++ b/internal/i18n/locales/da.json @@ -300,7 +300,9 @@ "QUOTA WATCH": "HOLD ØJE MED KVOTEN", "RANK": "RANG", "AVG TOK/MIN ": "GNS. TOK/MIN ", - "RE(S)ET": "NULSTIL (S)", + "CL(O)SE ALL": "LUK ALLE (O)", + "C(O)NFIRM": "BEKRÆFT (O)", + "(Z)ERO": "NULSTIL (Z)", "READY": "KLAR", "REMOTE SESSIONS": "FJERNSESSIONER", "RESET": "NULSTIL", @@ -310,7 +312,7 @@ "RESET FRESH // GO!": "NYLIGT NULSTILLET // KØR!", "RESET T-%s": "NULSTILLING T-%s", "RESET T-%s // %s": "NULSTILLING T-%s // %s", - "RESETTING": "NULSTILLER", + "ZEROING": "NULSTILLER", "RESULT": "RESULTAT", "RESULT // ": "RESULTAT // ", "RESULT MATRIX // STANDARD API-EQUIVALENT USD": "RESULTATMATRIX // STANDARD API-ÆKVIVALENT USD", diff --git a/internal/i18n/locales/de.json b/internal/i18n/locales/de.json index 9b89cb9..913dfab 100644 --- a/internal/i18n/locales/de.json +++ b/internal/i18n/locales/de.json @@ -300,7 +300,9 @@ "QUOTA WATCH": "KONTINGENT BEACHTEN", "RANK": "RANG", "AVG TOK/MIN ": "Ø TOK/MIN ", - "RE(S)ET": "(S) ZURÜCKSETZEN", + "CL(O)SE ALL": "ALLE SCHLIESSEN (O)", + "C(O)NFIRM": "BESTÄTIGEN (O)", + "(Z)ERO": "NULLEN (Z)", "READY": "BEREIT", "REMOTE SESSIONS": "REMOTE-SITZUNGEN", "RESET": "ZURÜCKSETZEN", @@ -310,7 +312,7 @@ "RESET FRESH // GO!": "ZURÜCKSETZEN FRISCH // LOS!", "RESET T-%s": "ZURÜCKSETZEN T-%s", "RESET T-%s // %s": "ZURÜCKSETZEN T-%s // %s", - "RESETTING": "WIRD ZURÜCKGESETZT", + "ZEROING": "WIRD GENULLT", "RESULT": "ERGEBNIS", "RESULT // ": "ERGEBNIS // ", "RESULT MATRIX // STANDARD API-EQUIVALENT USD": "ERGEBNISMATRIX // STANDARD-API-ÄQUIVALENT USD", diff --git a/internal/i18n/locales/en-GB.json b/internal/i18n/locales/en-GB.json index 23668d1..5e3a63a 100644 --- a/internal/i18n/locales/en-GB.json +++ b/internal/i18n/locales/en-GB.json @@ -300,7 +300,9 @@ "QUOTA WATCH": "QUOTA WATCH", "RANK": "RANK", "AVG TOK/MIN ": "AVG TOK/MIN ", - "RE(S)ET": "RE(S)ET", + "CL(O)SE ALL": "CL(O)SE ALL", + "C(O)NFIRM": "C(O)NFIRM", + "(Z)ERO": "(Z)ERO", "READY": "READY", "REMOTE SESSIONS": "REMOTE SESSIONS", "RESET": "RESET", @@ -310,7 +312,7 @@ "RESET FRESH // GO!": "RESET FRESH // GO!", "RESET T-%s": "RESET T-%s", "RESET T-%s // %s": "RESET T-%s // %s", - "RESETTING": "RESETTING", + "ZEROING": "ZEROING", "RESULT": "RESULT", "RESULT // ": "RESULT // ", "RESULT MATRIX // STANDARD API-EQUIVALENT USD": "RESULT MATRIX // STANDARD API-EQUIVALENT USD", diff --git a/internal/i18n/locales/es.json b/internal/i18n/locales/es.json index 2e16b1c..9655051 100644 --- a/internal/i18n/locales/es.json +++ b/internal/i18n/locales/es.json @@ -300,7 +300,9 @@ "QUOTA WATCH": "VIGILAR CUOTA", "RANK": "POSICIÓN", "AVG TOK/MIN ": "PROM. TOK/MIN ", - "RE(S)ET": "(S) RESTABLECER", + "CL(O)SE ALL": "CERRAR TODO (O)", + "C(O)NFIRM": "CONFIRMAR (O)", + "(Z)ERO": "PONER A CERO (Z)", "READY": "LISTO", "REMOTE SESSIONS": "SESIONES REMOTAS", "RESET": "RESTABLECER", @@ -310,7 +312,7 @@ "RESET FRESH // GO!": "RESTABLECER ¡RENOVADA // ADELANTE!", "RESET T-%s": "RESTABLECER T-%s", "RESET T-%s // %s": "RESTABLECER T-%s // %s", - "RESETTING": "RESTABLECIENDO", + "ZEROING": "PONIENDO A CERO", "RESULT": "RESULTADO", "RESULT // ": "RESULTADO // ", "RESULT MATRIX // STANDARD API-EQUIVALENT USD": "MATRIZ DE RESULTADOS // EQUIVALENTE API ESTÁNDAR EN USD", diff --git a/internal/i18n/locales/et.json b/internal/i18n/locales/et.json index 97df30d..5d2212b 100644 --- a/internal/i18n/locales/et.json +++ b/internal/i18n/locales/et.json @@ -300,7 +300,9 @@ "QUOTA WATCH": "JÄLGI KVOOTI", "RANK": "KOHT", "AVG TOK/MIN ": "KESK. TOK/MIN ", - "RE(S)ET": "LÄHTESTA (S)", + "CL(O)SE ALL": "SULGE KÕIK (O)", + "C(O)NFIRM": "KINNITA (O)", + "(Z)ERO": "NULLI (Z)", "READY": "VALMIS", "REMOTE SESSIONS": "KAUGSEANSID", "RESET": "LÄHTESTA", @@ -310,7 +312,7 @@ "RESET FRESH // GO!": "UUS KVOOT // ALUSTA!", "RESET T-%s": "LÄHTESTA T-%s", "RESET T-%s // %s": "LÄHTESTA T-%s // %s", - "RESETTING": "LÄHTESTAMINE", + "ZEROING": "NULLIMINE", "RESULT": "TULEMUS", "RESULT // ": "TULEMUS // ", "RESULT MATRIX // STANDARD API-EQUIVALENT USD": "TULEMUSTABEL // STANDARDNE API-EKVIVALENT USD", diff --git a/internal/i18n/locales/fi.json b/internal/i18n/locales/fi.json index ff207d7..0f836c2 100644 --- a/internal/i18n/locales/fi.json +++ b/internal/i18n/locales/fi.json @@ -300,7 +300,9 @@ "QUOTA WATCH": "SEURAA KIINTIÖTÄ", "RANK": "SIJA", "AVG TOK/MIN ": "KESKIM. TOK/MIN ", - "RE(S)ET": "NOLLAA (S)", + "CL(O)SE ALL": "SULJE KAIKKI (O)", + "C(O)NFIRM": "VAHVISTA (O)", + "(Z)ERO": "NOLLAA (Z)", "READY": "VALMIS", "REMOTE SESSIONS": "ETÄISTUNNOT", "RESET": "NOLLAA", @@ -310,7 +312,7 @@ "RESET FRESH // GO!": "UUSI KIINTIÖ // MENOKSI!", "RESET T-%s": "NOLLAA T-%s", "RESET T-%s // %s": "NOLLAA T-%s // %s", - "RESETTING": "NOLLATAAN", + "ZEROING": "NOLLATAAN", "RESULT": "TULOS", "RESULT // ": "TULOS // ", "RESULT MATRIX // STANDARD API-EQUIVALENT USD": "TULOSTAULUKKO // VAKIOHINTAINEN API-VASTINE USD", diff --git a/internal/i18n/locales/fr.json b/internal/i18n/locales/fr.json index 57c81c2..c4830cd 100644 --- a/internal/i18n/locales/fr.json +++ b/internal/i18n/locales/fr.json @@ -300,7 +300,9 @@ "QUOTA WATCH": "QUOTA À SURVEILLER", "RANK": "CLASSEMENT", "AVG TOK/MIN ": "MOY. TOK/MIN ", - "RE(S)ET": "(S) RÉINITIALISER", + "CL(O)SE ALL": "TOUT FERMER (O)", + "C(O)NFIRM": "CONFIRMER (O)", + "(Z)ERO": "REMISE À ZÉRO (Z)", "READY": "PRÊT", "REMOTE SESSIONS": "SESSIONS DISTANTES", "RESET": "RÉINITIALISER", @@ -310,7 +312,7 @@ "RESET FRESH // GO!": "RÉINITIALISER RECHARGÉ // C’EST PARTI !", "RESET T-%s": "RÉINITIALISER T-%s", "RESET T-%s // %s": "RÉINITIALISER T-%s // %s", - "RESETTING": "REMISE À ZÉRO", + "ZEROING": "MISE À ZÉRO", "RESULT": "RÉSULTAT", "RESULT // ": "RÉSULTAT // ", "RESULT MATRIX // STANDARD API-EQUIVALENT USD": "TABLEAU DES RÉSULTATS // ÉQUIVALENT API STANDARD EN USD", diff --git a/internal/i18n/locales/it.json b/internal/i18n/locales/it.json index e54449e..0d73d5a 100644 --- a/internal/i18n/locales/it.json +++ b/internal/i18n/locales/it.json @@ -300,7 +300,9 @@ "QUOTA WATCH": "ATTENZIONE ALLA QUOTA", "RANK": "POSIZIONE", "AVG TOK/MIN ": "MEDIA TOK/MIN ", - "RE(S)ET": "(S) AZZERA", + "CL(O)SE ALL": "CHIUDI TUTTO (O)", + "C(O)NFIRM": "CONFERMA (O)", + "(Z)ERO": "AZZERA (Z)", "READY": "PRONTO", "REMOTE SESSIONS": "SESSIONI REMOTE", "RESET": "AZZERA", @@ -310,7 +312,7 @@ "RESET FRESH // GO!": "AZZERA RICARICATA // VAI!", "RESET T-%s": "AZZERA T-%s", "RESET T-%s // %s": "AZZERA T-%s // %s", - "RESETTING": "RIPRISTINO", + "ZEROING": "AZZERAMENTO", "RESULT": "RISULTATO", "RESULT // ": "RISULTATO // ", "RESULT MATRIX // STANDARD API-EQUIVALENT USD": "MATRICE RISULTATI // EQUIVALENTE API STANDARD IN USD", diff --git a/internal/i18n/locales/ja.json b/internal/i18n/locales/ja.json index 107e457..3320937 100644 --- a/internal/i18n/locales/ja.json +++ b/internal/i18n/locales/ja.json @@ -300,7 +300,9 @@ "QUOTA WATCH": "利用枠に注意", "RANK": "順位", "AVG TOK/MIN ": "平均トークン/分 ", - "RE(S)ET": "(S) リセット", + "CL(O)SE ALL": "すべて閉じる (O)", + "C(O)NFIRM": "確認 (O)", + "(Z)ERO": "ゼロにする (Z)", "READY": "準備完了", "REMOTE SESSIONS": "リモートセッション", "RESET": "リセット", @@ -310,7 +312,7 @@ "RESET FRESH // GO!": "リセット 回復済み // さあ開始!", "RESET T-%s": "リセット T-%s", "RESET T-%s // %s": "リセット T-%s // %s", - "RESETTING": "リセット中", + "ZEROING": "ゼロ化中", "RESULT": "結果", "RESULT // ": "結果 // ", "RESULT MATRIX // STANDARD API-EQUIVALENT USD": "結果一覧 // 標準API換算 USD", diff --git a/internal/i18n/locales/nb.json b/internal/i18n/locales/nb.json index 455a3f2..c43cd70 100644 --- a/internal/i18n/locales/nb.json +++ b/internal/i18n/locales/nb.json @@ -300,7 +300,9 @@ "QUOTA WATCH": "FØLG MED PÅ KVOTEN", "RANK": "RANGERING", "AVG TOK/MIN ": "SNITT TOK/MIN ", - "RE(S)ET": "TILBAKESTILL (S)", + "CL(O)SE ALL": "LUKK ALLE (O)", + "C(O)NFIRM": "BEKREFT (O)", + "(Z)ERO": "NULLSTILL (Z)", "READY": "KLAR", "REMOTE SESSIONS": "EKSTERNE ØKTER", "RESET": "TILBAKESTILL", @@ -310,7 +312,7 @@ "RESET FRESH // GO!": "NY KVOTE // KJØR!", "RESET T-%s": "TILBAKESTILL T-%s", "RESET T-%s // %s": "TILBAKESTILL T-%s // %s", - "RESETTING": "TILBAKESTILLER", + "ZEROING": "NULLSTILLER", "RESULT": "RESULTAT", "RESULT // ": "RESULTAT // ", "RESULT MATRIX // STANDARD API-EQUIVALENT USD": "RESULTATMATRISE // STANDARD API-EKVIVALENT USD", diff --git a/internal/i18n/locales/nl.json b/internal/i18n/locales/nl.json index 3c30868..b868da0 100644 --- a/internal/i18n/locales/nl.json +++ b/internal/i18n/locales/nl.json @@ -300,7 +300,9 @@ "QUOTA WATCH": "LET OP QUOTUM", "RANK": "RANG", "AVG TOK/MIN ": "GEM. TOK/MIN ", - "RE(S)ET": "(S) RESETTEN", + "CL(O)SE ALL": "ALLES SLUITEN (O)", + "C(O)NFIRM": "BEVESTIG (O)", + "(Z)ERO": "NULSTELLEN (Z)", "READY": "GEREED", "REMOTE SESSIONS": "EXTERNE SESSIES", "RESET": "RESETTEN", @@ -310,7 +312,7 @@ "RESET FRESH // GO!": "RESETTEN VERS // AAN DE SLAG!", "RESET T-%s": "RESETTEN T-%s", "RESET T-%s // %s": "RESETTEN T-%s // %s", - "RESETTING": "RESETTEN", + "ZEROING": "NULSTELLEN", "RESULT": "RESULTAAT", "RESULT // ": "RESULTAAT // ", "RESULT MATRIX // STANDARD API-EQUIVALENT USD": "RESULTATENMATRIX // STANDAARD API-EQUIVALENT USD", diff --git a/internal/i18n/locales/pt-BR.json b/internal/i18n/locales/pt-BR.json index ceece19..e6e13d2 100644 --- a/internal/i18n/locales/pt-BR.json +++ b/internal/i18n/locales/pt-BR.json @@ -300,7 +300,9 @@ "QUOTA WATCH": "ATENÇÃO À COTA", "RANK": "RANKING", "AVG TOK/MIN ": "MÉDIA TOK/MIN ", - "RE(S)ET": "REDEFINIR (S)", + "CL(O)SE ALL": "FECHAR TUDO (O)", + "C(O)NFIRM": "CONFIRMAR (O)", + "(Z)ERO": "ZERAR (Z)", "READY": "PRONTO", "REMOTE SESSIONS": "SESSÕES REMOTAS", "RESET": "REDEFINIR", @@ -310,7 +312,7 @@ "RESET FRESH // GO!": "COTA RENOVADA // VAMOS!", "RESET T-%s": "REDEFINIÇÃO T-%s", "RESET T-%s // %s": "REDEFINIÇÃO T-%s // %s", - "RESETTING": "REDEFININDO", + "ZEROING": "ZERANDO", "RESULT": "RESULTADO", "RESULT // ": "RESULTADO // ", "RESULT MATRIX // STANDARD API-EQUIVALENT USD": "MATRIZ DE RESULTADOS // EQUIVALENTE API PADRÃO EM USD", diff --git a/internal/i18n/locales/pt-PT.json b/internal/i18n/locales/pt-PT.json index 5219b7e..764ab59 100644 --- a/internal/i18n/locales/pt-PT.json +++ b/internal/i18n/locales/pt-PT.json @@ -300,7 +300,9 @@ "QUOTA WATCH": "ATENÇÃO À QUOTA", "RANK": "RANKING", "AVG TOK/MIN ": "MÉDIA TOK/MIN ", - "RE(S)ET": "REPOR (S)", + "CL(O)SE ALL": "FECHAR TUDO (O)", + "C(O)NFIRM": "CONFIRMAR (O)", + "(Z)ERO": "ZERAR (Z)", "READY": "PRONTO", "REMOTE SESSIONS": "SESSÕES REMOTAS", "RESET": "REPOR", @@ -310,7 +312,7 @@ "RESET FRESH // GO!": "QUOTA RENOVADA // VAMOS!", "RESET T-%s": "REPOSIÇÃO T-%s", "RESET T-%s // %s": "REPOSIÇÃO T-%s // %s", - "RESETTING": "A REPOR", + "ZEROING": "A ZERAR", "RESULT": "RESULTADO", "RESULT // ": "RESULTADO // ", "RESULT MATRIX // STANDARD API-EQUIVALENT USD": "MATRIZ DE RESULTADOS // EQUIVALENTE API PADRÃO EM USD", diff --git a/internal/i18n/locales/ru.json b/internal/i18n/locales/ru.json index 916a7f7..02d64f8 100644 --- a/internal/i18n/locales/ru.json +++ b/internal/i18n/locales/ru.json @@ -300,7 +300,9 @@ "QUOTA WATCH": "СЛЕДИТЕ ЗА КВОТОЙ", "RANK": "РАНГ", "AVG TOK/MIN ": "СР. ТОК/МИН ", - "RE(S)ET": "(S) СБРОС", + "CL(O)SE ALL": "ЗАКРЫТЬ ВСЕ (O)", + "C(O)NFIRM": "ПОДТВЕРДИТЬ (O)", + "(Z)ERO": "ОБНУЛИТЬ (Z)", "READY": "ГОТОВО", "REMOTE SESSIONS": "УДАЛЁННЫЕ СЕАНСЫ", "RESET": "СБРОС", @@ -310,7 +312,7 @@ "RESET FRESH // GO!": "СБРОС ОБНОВЛЕНО // ВПЕРЁД!", "RESET T-%s": "СБРОС T-%s", "RESET T-%s // %s": "СБРОС T-%s // %s", - "RESETTING": "СБРОС", + "ZEROING": "ОБНУЛЕНИЕ", "RESULT": "РЕЗУЛЬТАТ", "RESULT // ": "РЕЗУЛЬТАТ // ", "RESULT MATRIX // STANDARD API-EQUIVALENT USD": "ТАБЛИЦА РЕЗУЛЬТАТОВ // ЭКВИВАЛЕНТ СТАНДАРТНОГО API В USD", diff --git a/internal/i18n/locales/sv.json b/internal/i18n/locales/sv.json index b9ea029..267ca2f 100644 --- a/internal/i18n/locales/sv.json +++ b/internal/i18n/locales/sv.json @@ -300,7 +300,9 @@ "QUOTA WATCH": "BEVAKA KVOTEN", "RANK": "RANG", "AVG TOK/MIN ": "SNITT TOK/MIN ", - "RE(S)ET": "ÅTERSTÄLL (S)", + "CL(O)SE ALL": "STÄNG ALLA (O)", + "C(O)NFIRM": "BEKRÄFTA (O)", + "(Z)ERO": "NOLLSTÄLL (Z)", "READY": "REDO", "REMOTE SESSIONS": "FJÄRRSESSIONER", "RESET": "ÅTERSTÄLL", @@ -310,7 +312,7 @@ "RESET FRESH // GO!": "NY KVOT // KÖR!", "RESET T-%s": "ÅTERSTÄLL T-%s", "RESET T-%s // %s": "ÅTERSTÄLL T-%s // %s", - "RESETTING": "ÅTERSTÄLLER", + "ZEROING": "NOLLSTÄLLER", "RESULT": "RESULTAT", "RESULT // ": "RESULTAT // ", "RESULT MATRIX // STANDARD API-EQUIVALENT USD": "RESULTATMATRIS // STANDARD API-MOTSVARIGHET USD", diff --git a/internal/i18n/locales/tr.json b/internal/i18n/locales/tr.json index 0a760d5..6567eb1 100644 --- a/internal/i18n/locales/tr.json +++ b/internal/i18n/locales/tr.json @@ -300,7 +300,9 @@ "QUOTA WATCH": "KOTAYI İZLE", "RANK": "SIRA", "AVG TOK/MIN ": "ORT. TOK/DK ", - "RE(S)ET": "(S) SIFIRLA", + "CL(O)SE ALL": "TÜMÜNÜ KAPAT (O)", + "C(O)NFIRM": "ONAYLA (O)", + "(Z)ERO": "SAYACI SIFIRLA (Z)", "READY": "HAZIR", "REMOTE SESSIONS": "UZAK OTURUMLAR", "RESET": "SIFIRLA", @@ -310,7 +312,7 @@ "RESET FRESH // GO!": "KOTA YENİLENDİ // BAŞLA!", "RESET T-%s": "SIFIRLA T-%s", "RESET T-%s // %s": "SIFIRLA T-%s // %s", - "RESETTING": "SIFIRLANIYOR", + "ZEROING": "SAYAÇ SIFIRLANIYOR", "RESULT": "SONUÇ", "RESULT // ": "SONUÇ // ", "RESULT MATRIX // STANDARD API-EQUIVALENT USD": "SONUÇ MATRİSİ // STANDART API EŞDEĞERİ USD", diff --git a/internal/i18n/locales/zh-Hans.json b/internal/i18n/locales/zh-Hans.json index b22be49..9d11e62 100644 --- a/internal/i18n/locales/zh-Hans.json +++ b/internal/i18n/locales/zh-Hans.json @@ -300,7 +300,9 @@ "QUOTA WATCH": "关注配额", "RANK": "排名", "AVG TOK/MIN ": "平均令牌/分钟 ", - "RE(S)ET": "(S) 重置", + "CL(O)SE ALL": "全部关闭 (O)", + "C(O)NFIRM": "确认 (O)", + "(Z)ERO": "归零 (Z)", "READY": "就绪", "REMOTE SESSIONS": "远程会话", "RESET": "重置", @@ -310,7 +312,7 @@ "RESET FRESH // GO!": "重置 已恢复 // 开始吧!", "RESET T-%s": "重置 T-%s", "RESET T-%s // %s": "重置 T-%s // %s", - "RESETTING": "正在重置", + "ZEROING": "正在归零", "RESULT": "结果", "RESULT // ": "结果 // ", "RESULT MATRIX // STANDARD API-EQUIVALENT USD": "结果表 // 标准 API 等值 USD", diff --git a/internal/ui/english_snapshot_test.go b/internal/ui/english_snapshot_test.go index fd84b54..18a35a6 100644 --- a/internal/ui/english_snapshot_test.go +++ b/internal/ui/english_snapshot_test.go @@ -36,9 +36,10 @@ func TestEnglishPresentationSnapshot(t *testing.T) { } } got := fmt.Sprintf("%x", hash.Sum(nil)) - // Baseline includes Pace/Zone graph controls and explicit panel/border - // backgrounds; every theme, view and size remains covered. - const want = "69551ed984646ea73c635182b73cb4e31c5557e3ad6e0de41078983c6edb66e4" + // Baseline includes Pace/Zone graph controls, explicit panel/border + // backgrounds and Sessions Zero/Close All; every theme, view and size + // remains covered. + const want = "07592d4740f0a32a45f7dd70c153e889f4101e5793e33cb61daf35c0a4edd34c" if got != want { t.Fatalf("English presentation changed: got %s, want %s", got, want) } diff --git a/internal/ui/localisation_test.go b/internal/ui/localisation_test.go index a5c9936..d38ae3a 100644 --- a/internal/ui/localisation_test.go +++ b/internal/ui/localisation_test.go @@ -64,6 +64,7 @@ func TestLocalisedScreensHelper(t *testing.T) { } t.Run("benchmark_click_surfaces", TestBenchmarkRenderedClickSurfacesMatchHitTestingAcrossSizes) t.Run("monitor_click_surfaces", TestMonitorButtonBoxesMatchEnabledHitSurfacesAcrossSizes) + t.Run("monitor_control_shortcuts", TestMonitorCompactControlsKeepShortcutHints) t.Run("schedule_click_surfaces", TestScheduleRenderedControlSurfaces) t.Run("schedule_status_labels", TestScheduleLocalisedStatusAndHint) t.Run("queue_editor_surfaces", TestQueueEditorButtonsAndKeyboardFocus) diff --git a/internal/ui/model.go b/internal/ui/model.go index 6d1c330..df70b7c 100644 --- a/internal/ui/model.go +++ b/internal/ui/model.go @@ -198,6 +198,8 @@ type Model struct { monitorCopyFlash string monitorCopySequence uint64 monitorDismissSeq uint64 + monitorCloseAllConfirm []string + monitorCloseAllUntil time.Time monitorScroll int monitorError string monitorQuotaWindows []monitorQuotaWindow @@ -380,6 +382,7 @@ const ( footerButtonRefresh footerButtonQuit footerButtonMonitorReset + footerButtonMonitorCloseAll footerButtonBenchmarkPrevious footerButtonBenchmarkNext footerButtonBenchmarkSelected @@ -626,6 +629,16 @@ func (m Model) Update(message tea.Msg) (tea.Model, tea.Cmd) { return m, nil } if m.meterView == viewMonitor { + if strings.EqualFold(message.String(), "o") { + if !message.IsRepeat && m.monitorContextDetail == "" && m.monitorCloseAllEnabled() { + return m.pressFooterButton(footerButtonMonitorCloseAll) + } + return m, nil + } + if message.String() == "esc" && len(m.monitorCloseAllConfirm) > 0 { + m.clearMonitorCloseAllConfirmation() + return m, nil + } next, cmd, handled := m.updateMonitorContextKey(strings.ToLower(message.String())) m = next if handled { @@ -699,10 +712,11 @@ func (m Model) Update(message tea.Msg) (tea.Model, tea.Cmd) { return m, tea.Quit case "t": return m.pressFooterButton(footerButtonTheme) - case "s": + case "z": if m.meterView == viewMonitor { return m.pressFooterButton(footerButtonMonitorReset) } + case "s": if m.meterView == viewBenchmark && !m.benchmarkScopeOpen && m.benchmarkDetail == nil && len(m.benchmarkPlan.Models) > 0 { updated, command := m.pressFooterButton(footerButtonBenchmarkScope) next := updated.(Model) @@ -1294,6 +1308,7 @@ func (m Model) Update(message tea.Msg) (tea.Model, tea.Cmd) { } func (m Model) pressViewTab(view meterViewID) (tea.Model, tea.Cmd) { + m.clearMonitorCloseAllConfirmation() m.clearQuotaConfirmation() if view != m.meterView { m.monitorApprovalConfirm = "" @@ -1413,9 +1428,14 @@ func (m Model) activateFooterButton(button footerButtonID) (Model, tea.Cmd) { } case footerButtonMonitorReset: if m.meterView == viewMonitor && m.monitorState == monitorRunning { + m.clearMonitorCloseAllConfirmation() m.monitorState = monitorResetting return m.beginMonitorFetch(monitorFetchReset) } + case footerButtonMonitorCloseAll: + if m.meterView == viewMonitor && m.monitorCloseAllEnabled() { + m.requestMonitorCloseAll() + } case footerButtonBenchmarkPrevious: if !m.benchmarkRunActive() { m.selectBenchmarkSuite(-1) @@ -2516,6 +2536,7 @@ func sameOptionalInt64(left, right *int64) bool { } func (m *Model) startMonitorSessions(usage codex.LiveUsageSnapshot, observedAt time.Time) { + m.clearMonitorCloseAllConfirmation() m.monitorHistory = nil m.monitorSessionData = nil m.monitorDismissed = nil @@ -2634,6 +2655,7 @@ func (m *Model) syncMonitorSessions(usage codex.LiveUsageSnapshot, observedAt ti } func (m *Model) dismissMonitorSession(id string) { + m.clearMonitorCloseAllConfirmation() m.clearQuotaConfirmation() if id == m.monitorContextTarget() { m.monitorContextDetail = "" @@ -2661,6 +2683,28 @@ func (m *Model) dismissMonitorSession(id string) { m.monitorScroll = min(m.monitorScroll, maximumScroll) } +// Dismiss the whole list, including rows outside the current page. Retain +// previous dismissal watermarks so bulk dismissal cannot delay their return. +func (m *Model) dismissAllMonitorSessions() { + m.stashMonitorDraft() + for _, session := range m.monitorSessionData { + if m.monitorSessionVisible(session) { + m.dismissMonitorSession(session.id) + } + } + m.monitorSelectedID = "" + m.monitorScroll = 0 + m.monitorContextDetail = "" + m.monitorContextExpanded = "" + m.monitorContextScroll = 0 + m.monitorContextHover = "" + m.monitorApprovalConfirm = "" + m.monitorPrompt = monitorPromptState{} + m.monitorDismissHover = "" + m.monitorDismissFlash = "" + m.monitorDismissSeq++ +} + func (m *Model) restoreMonitorSessionOnActivity(session *monitorSession) { dismissal, dismissed := m.monitorDismissed[session.id] if !dismissed { diff --git a/internal/ui/monitor.go b/internal/ui/monitor.go index 5fcfe9e..c8aa581 100644 --- a/internal/ui/monitor.go +++ b/internal/ui/monitor.go @@ -27,8 +27,9 @@ func (r monitorRect) contains(x, y int) bool { } type monitorView struct { - view string - resetRect monitorRect + view string + resetRect monitorRect + closeAllRect monitorRect } type monitorGeometry struct { @@ -41,6 +42,7 @@ type monitorGeometry struct { graphHeight int readoutWidth int resetRect monitorRect + closeAllRect monitorRect } const monitorDismissLabel = "[×]" @@ -55,8 +57,12 @@ func layoutMonitorArea(width, height int) monitorGeometry { } graphHeight := max(height-topHeight-gap, 1) - resetWidth := min(max(width/5, 8), max(width-2, 1)) - readoutWidth := max(width-resetWidth-gap, 1) + // Keep the summary usable on narrow terminals; compact both controls when + // their full translated labels cannot fit. + controlsWidth := min(max(width/4, 22), max(width*2/5, 3)) + resetWidth := max((controlsWidth-gap)/2, 1) + closeAllWidth := max(controlsWidth-resetWidth-gap, 1) + readoutWidth := max(width-controlsWidth-gap, 1) if height >= 12 { topHeight = min(monitorSummaryHeight(readoutWidth), height-7) graphHeight = max(height-topHeight-gap, 1) @@ -69,6 +75,7 @@ func layoutMonitorArea(width, height int) monitorGeometry { graphHeight: graphHeight, readoutWidth: readoutWidth, resetRect: monitorRect{x: readoutWidth + gap, width: resetWidth, height: topHeight}, + closeAllRect: monitorRect{x: readoutWidth + gap + resetWidth + gap, width: closeAllWidth, height: topHeight}, } } @@ -88,12 +95,31 @@ func (m Model) renderMonitorArea(width, height int, colors palette) monitorView layout := m.monitorArea(width, height) readout := m.renderMonitorReadout(layout.readoutWidth, layout.topHeight, colors) - resetLabel := i18n.Text("RE(S)ET") + resetLabel := i18n.Text("(Z)ERO") if layout.resetRect.width < lipgloss.Width(resetLabel)+2 { - resetLabel = "(S)" + resetLabel = "0 (Z)" + if layout.resetRect.width < lipgloss.Width(resetLabel)+2 { + resetLabel = "0\n(Z)" + } } resetButton := m.renderMonitorButton(layout.resetRect.width, layout.topHeight, resetLabel, footerButtonMonitorReset, m.monitorResetEnabled(), colors) - top := lipgloss.JoinHorizontal(lipgloss.Top, readout, strings.Repeat(" ", layout.resetRect.x-layout.readoutWidth), resetButton) + closeAllLabel := i18n.Text("CL(O)SE ALL") + if layout.closeAllRect.width < lipgloss.Width(closeAllLabel)+2 { + wrapped := strings.Replace(closeAllLabel, " ", "\n", 1) + if lipgloss.Width(wrapped)+2 <= layout.closeAllRect.width && lipgloss.Height(wrapped)+2 <= layout.topHeight { + closeAllLabel = wrapped + } else { + closeAllLabel = "[××]\n(O)" + } + } + if m.monitorCloseAllArmed() { + closeAllLabel = i18n.Text("C(O)NFIRM") + "\nEsc" + if layout.closeAllRect.width < lipgloss.Width(i18n.Text("C(O)NFIRM"))+2 { + closeAllLabel = "(O)?\nEsc" + } + } + closeAllButton := m.renderMonitorButton(layout.closeAllRect.width, layout.topHeight, closeAllLabel, footerButtonMonitorCloseAll, m.monitorCloseAllEnabled(), colors) + top := lipgloss.JoinHorizontal(lipgloss.Top, readout, strings.Repeat(" ", layout.resetRect.x-layout.readoutWidth), resetButton, strings.Repeat(" ", layout.closeAllRect.x-layout.resetRect.x-layout.resetRect.width), closeAllButton) graph := m.renderMonitorSessions(layout.width, layout.graphHeight, colors) parts := []string{top} if layout.attentionRows > 0 { @@ -106,7 +132,7 @@ func (m Model) renderMonitorArea(width, height int, colors palette) monitorView } return monitorView{ - view: view, resetRect: layout.resetRect, + view: view, resetRect: layout.resetRect, closeAllRect: layout.closeAllRect, } } @@ -123,7 +149,7 @@ func (m Model) renderMonitorSummary(width, height int, colors palette, navigatio case monitorRunning: state, hint = i18n.Text("MONITORING ●"), i18n.Format("LIVE LOCAL SESSIONS %d", m.monitorSessions) case monitorResetting: - state, hint = i18n.Text("RESETTING"), i18n.Text("ESTABLISHING A FRESH BASELINE") + state, hint = i18n.Text("ZEROING"), i18n.Text("ESTABLISHING A FRESH BASELINE") } if m.monitorError != "" { state, hint = i18n.Text("NO TOKEN SIGNAL"), m.monitorError @@ -740,6 +766,9 @@ func (m Model) monitorButtonAt(x, y int) footerButtonID { if m.monitorResetEnabled() && area.resetRect.contains(localX, localY) { return footerButtonMonitorReset } + if m.monitorCloseAllEnabled() && area.closeAllRect.contains(localX, localY) { + return footerButtonMonitorCloseAll + } return footerButtonNone } @@ -777,6 +806,10 @@ func (m Model) monitorResetEnabled() bool { return m.monitorState == monitorRunning } +func (m Model) monitorCloseAllEnabled() bool { + return m.monitorState == monitorRunning && m.visibleMonitorSessionCount() > 0 +} + func (m Model) monitorElapsed(now time.Time) time.Duration { if m.monitorStartedAt.IsZero() { return 0 diff --git a/internal/ui/monitor_close_all.go b/internal/ui/monitor_close_all.go new file mode 100644 index 0000000..d7e2278 --- /dev/null +++ b/internal/ui/monitor_close_all.go @@ -0,0 +1,36 @@ +package ui + +import ( + "slices" + "time" +) + +func (m Model) visibleMonitorSessionIDs() []string { + var ids []string + for _, s := range m.monitorSessionData { + if m.monitorSessionVisible(s) { + ids = append(ids, s.id) + } + } + return ids +} + +func (m Model) monitorCloseAllArmed() bool { + return len(m.monitorCloseAllConfirm) > 0 && time.Now().Before(m.monitorCloseAllUntil) && + slices.Equal(m.monitorCloseAllConfirm, m.visibleMonitorSessionIDs()) +} + +func (m *Model) clearMonitorCloseAllConfirmation() { + m.monitorCloseAllConfirm = nil + m.monitorCloseAllUntil = time.Time{} +} + +func (m *Model) requestMonitorCloseAll() { + if m.monitorCloseAllArmed() { + m.dismissAllMonitorSessions() + return + } + m.monitorPrompt.input.Blur() + m.monitorCloseAllConfirm = m.visibleMonitorSessionIDs() + m.monitorCloseAllUntil = time.Now().Add(5 * time.Second) +} diff --git a/internal/ui/monitor_close_all_test.go b/internal/ui/monitor_close_all_test.go new file mode 100644 index 0000000..6b6df3c --- /dev/null +++ b/internal/ui/monitor_close_all_test.go @@ -0,0 +1,268 @@ +package ui + +import ( + "fmt" + "reflect" + "strings" + "testing" + "time" + + tea "charm.land/bubbletea/v2" + "charm.land/lipgloss/v2" + "github.com/charmbracelet/x/ansi" + "github.com/merefield/codexometer/internal/codex" + "github.com/merefield/codexometer/internal/i18n" +) + +func TestMonitorCloseAllDismissesOffScreenRowsAndPreservesMeasurement(t *testing.T) { + now := time.Unix(1000, 0) + usage := codex.LiveUsageSnapshot{} + for i := range 12 { + usage.Sessions = append(usage.Sessions, codex.LiveUsageSession{ + ID: fmt.Sprintf("session-%d", i), TotalTokens: 100, Active: true, LastActivity: now, + }) + } + m := Model{snapshot: codex.DemoSnapshot(), width: 100, height: 24, + meterView: viewMonitor, monitorState: monitorRunning, monitorStartedAt: now, + monitorBaseline: 1200, monitorLatest: 1320, + monitorSamples: []monitorSample{{intervalTokens: 120}}, + } + m.startMonitorSessions(usage, now) + for i := range usage.Sessions { + usage.Sessions[i].TotalTokens = 110 + } + m.syncMonitorSessions(usage, now.Add(time.Second)) + m.captureMonitorSamples(now.Add(monitorSampleInterval)) + m.dismissMonitorSession("session-11") + oldDismissal := m.monitorDismissed["session-11"] + oldDismissal.inactiveObserved, oldDismissal.attentionCleared = true, true + m.monitorDismissed["session-11"] = oldDismissal + m.monitorSelectedID, m.monitorContextExpanded = "session-0", "session-0" + m.monitorApprovalConfirm = "pending-confirmation" + m.monitorPrompt = monitorPromptState{session: "session-0", input: newMonitorEditor()} + m.monitorPrompt.input.SetValue("keep my draft") + m.monitorScroll = 2 + if m.monitorPageSize() >= m.visibleMonitorSessionCount() { + t.Fatal("test requires rows beyond the current page") + } + before := append([]monitorSession(nil), m.monitorSessionData...) + samplesBefore := append([]monitorSample(nil), m.monitorSamples...) + g := m.monitorDashboardLayout() + r := m.monitorArea(g.contentWidth, g.meterHeight).closeAllRect + updated, cmd := m.Update(tea.MouseClickMsg{X: 2 + r.x + 1, Y: g.meterY + r.y + 1, Button: tea.MouseLeft}) + m = updated.(Model) + if !m.monitorCloseAllArmed() || m.visibleMonitorSessionCount() != 11 { + t.Fatal("first Close All click did not require confirmation") + } + updated, cmd = m.Update(tea.MouseClickMsg{X: 2 + r.x + 1, Y: g.meterY + r.y + 1, Button: tea.MouseLeft}) + m = updated.(Model) + if cmd == nil || m.flashedButton != footerButtonMonitorCloseAll || m.visibleMonitorSessionCount() != 0 || m.monitorSessions != 0 { + t.Fatal("Close All click did not dismiss all rows and flash the control") + } + if m.monitorState != monitorRunning || m.monitorRecordedTokens() != 120 || m.monitorBaseline != 1200 || !m.monitorStartedAt.Equal(now) || !reflect.DeepEqual(samplesBefore, m.monitorSamples) || !reflect.DeepEqual(before, m.monitorSessionData) { + t.Fatal("Close All changed measurements or session telemetry") + } + if m.monitorSelectedID != "" || m.monitorScroll != 0 || m.monitorContextExpanded != "" || m.monitorApprovalConfirm != "" || m.monitorPrompt.session != "" || m.monitorDrafts["session-0"] != "keep my draft" { + t.Fatal("Close All left stale controls or discarded an ordinary draft") + } + if m.monitorDismissed["session-11"] != oldDismissal { + t.Fatal("Close All replaced a previous dismissal watermark") + } + // Exclude the earlier dismissed row: its saved inactive transition makes it + // eligible to return independently, and must remain effective after Close All. + m.syncMonitorSessions(codex.LiveUsageSnapshot{Sessions: usage.Sessions[:11]}, now.Add(2*time.Second)) + if m.visibleMonitorSessionCount() != 0 { + t.Fatal("unchanged telemetry immediately restored closed rows") + } + m.captureMonitorSamples(now.Add(2 * monitorSampleInterval)) + if len(m.monitorSessionData[0].samples) != len(before[0].samples)+1 { + t.Fatal("Close All stopped collecting hidden-row telemetry") + } + usage.Sessions[0].TotalTokens++ + m.syncMonitorSessions(codex.LiveUsageSnapshot{Sessions: usage.Sessions[:11]}, now.Add(3*time.Second)) + if m.visibleMonitorSessionCount() != 1 || !m.monitorSessionVisible(m.monitorSessionData[0]) { + t.Fatal("fresh activity did not restore only the renewed row") + } +} + +func TestMonitorCloseAllRenderedControlAndEmptyList(t *testing.T) { + m := Model{snapshot: codex.DemoSnapshot(), width: 120, height: 36, + meterView: viewMonitor, monitorState: monitorRunning, + monitorSessionData: []monitorSession{{id: "one", displayed: true}}, + } + g := m.monitorDashboardLayout() + a := m.monitorArea(g.contentWidth, g.meterHeight) + view := m.renderMonitorArea(g.contentWidth, g.meterHeight, paletteFor(m.theme)) + if a.closeAllRect.x <= a.resetRect.x+a.resetRect.width || a.closeAllRect.y != a.resetRect.y || a.closeAllRect.height != a.resetRect.height { + t.Fatal("Close All is not beside Zero") + } + if !strings.Contains(ansi.Strip(view.view), i18n.Text("CL(O)SE ALL")) || lipgloss.Width(view.view) > g.contentWidth { + t.Fatal("Close All label is missing or overflows the header") + } + updated, cmd := m.Update(tea.MouseMotionMsg{X: 2 + a.closeAllRect.x + 1, Y: g.meterY + 1}) + m = updated.(Model) + if cmd != nil || m.hoveredButton != footerButtonMonitorCloseAll { + t.Fatal("Close All hover did not select the button") + } + m.dismissAllMonitorSessions() + if m.monitorCloseAllEnabled() || m.monitorButtonAt(2+a.closeAllRect.x+1, g.meterY+1) != footerButtonNone || !m.monitorResetEnabled() { + t.Fatal("empty list did not disable Close All while leaving Zero available") + } +} + +func TestMonitorControlsHaveDistinctScopedShortcuts(t *testing.T) { + for _, k := range []tea.KeyPressMsg{key('z'), key('Z')} { + m := contextTestModel() + next, cmd := m.Update(k) + m = next.(Model) + if cmd == nil || m.monitorState != monitorResetting || m.flashedButton != footerButtonMonitorReset || m.visibleMonitorSessionCount() != 3 { + t.Fatal("Z did not exclusively zero the measurement") + } + } + for _, k := range []tea.KeyPressMsg{key('s'), key('S')} { + m := contextTestModel() + next, cmd := m.Update(k) + m = next.(Model) + if cmd != nil || m.monitorState != monitorRunning || m.flashedButton != footerButtonNone { + t.Fatal("S remains a Sessions hotkey") + } + } + for _, k := range []tea.KeyPressMsg{key('o'), key('O')} { + m := contextTestModel() + next, cmd := m.Update(k) + m = next.(Model) + if cmd == nil || !m.monitorCloseAllArmed() || m.visibleMonitorSessionCount() != 3 { + t.Fatal("O did not arm Close All without dismissing rows") + } + next, cmd = m.Update(k) + m = next.(Model) + if cmd == nil || m.visibleMonitorSessionCount() != 0 || m.monitorState != monitorRunning || m.flashedButton != footerButtonMonitorCloseAll { + t.Fatal("second O did not confirm Close All") + } + } + m := contextTestModel() + m.monitorSelectedID = "root-one" + next, _ := m.Update(key('x')) + m = next.(Model) + if m.visibleMonitorSessionCount() != 2 { + t.Fatal("plain x no longer closes only the selected row") + } + m = contextTestModel() + m.requestMonitorCloseAll() + repeated := key('o') + repeated.IsRepeat = true + next, cmd := m.Update(repeated) + m = next.(Model) + if cmd != nil || m.visibleMonitorSessionCount() != 3 { + t.Fatal("repeated O confirmed Close All") + } + m = contextTestModel() + m.meterView = viewBars + for _, k := range []tea.KeyPressMsg{key('z'), key('o')} { + next, cmd = m.Update(k) + m = next.(Model) + if cmd != nil || m.monitorState != monitorRunning || m.visibleMonitorSessionCount() != 3 { + t.Fatal("Sessions shortcut acted outside Sessions") + } + } +} + +func TestMonitorControlShortcutsTypeNormallyInComposer(t *testing.T) { + m, _ := inlinePromptTestModel() + m, _ = promptKey(m, tea.KeyEnter, "") + if !m.monitorPrompt.input.Focused() { + t.Fatal("inline composer did not focus") + } + for _, k := range []tea.KeyPressMsg{key('z'), key('o'), key('O')} { + next, _ := m.Update(k) + m = next.(Model) + } + if m.monitorPrompt.input.Value() != "zoO" || m.monitorState != monitorRunning || m.visibleMonitorSessionCount() != 1 || m.flashedButton != footerButtonNone { + t.Fatal("typing Z or O triggered a Sessions control") + } +} + +func TestMonitorCompactControlsKeepShortcutHints(t *testing.T) { + for _, size := range []struct{ w, h int }{{40, 16}, {80, 24}, {120, 40}} { + m := contextTestModel() + m.width, m.height = size.w, size.h + g := m.monitorDashboardLayout() + a := m.monitorArea(g.contentWidth, g.meterHeight) + view := m.renderMonitorArea(g.contentWidth, g.meterHeight, paletteFor(m.theme)).view + if lipgloss.Width(view) > g.contentWidth || lipgloss.Height(view) > g.meterHeight { + t.Fatalf("controls overflow at %dx%d", size.w, size.h) + } + lines := strings.Split(view, "\n") + for _, b := range []struct { + r monitorRect + hint string + }{{a.resetRect, "(Z)"}, {a.closeAllRect, "(O)"}} { + var rendered []string + for y := b.r.y; y < b.r.y+b.r.height; y++ { + rendered = append(rendered, ansi.Strip(ansi.Cut(lines[y], b.r.x, b.r.x+b.r.width))) + } + text := strings.Join(rendered, "\n") + if !strings.Contains(text, b.hint) { + t.Fatalf("%dx%d button is missing its shortcut: %q", size.w, size.h, text) + } + } + } +} + +func TestMonitorCloseAllConfirmationCancelExpiryAndChangedRows(t *testing.T) { + m := contextTestModel() + m.requestMonitorCloseAll() + next, cmd := m.Update(specialKey(tea.KeyEscape)) + m = next.(Model) + if cmd != nil || m.monitorCloseAllArmed() || m.visibleMonitorSessionCount() != 3 { + t.Fatal("Escape did not cancel without closing rows or quitting") + } + m.requestMonitorCloseAll() + m.monitorCloseAllUntil = time.Now().Add(-time.Second) + next, _ = m.Update(key('o')) + m = next.(Model) + if !m.monitorCloseAllArmed() || m.visibleMonitorSessionCount() != 3 { + t.Fatal("expired confirmation did not require a fresh arm") + } + m.monitorSessionData = append(m.monitorSessionData, monitorSession{id: "new", displayed: true}) + next, _ = m.Update(key('o')) + m = next.(Model) + if !m.monitorCloseAllArmed() || m.visibleMonitorSessionCount() != 4 { + t.Fatal("changed rows were closed without fresh confirmation") + } + next, _ = m.Update(key('z')) + m = next.(Model) + if len(m.monitorCloseAllConfirm) != 0 { + t.Fatal("Zero retained the armed Close All") + } + m = contextTestModel() + m.requestMonitorCloseAll() + next, _ = m.pressViewTab(viewBars) + m = next.(Model) + if len(m.monitorCloseAllConfirm) != 0 { + t.Fatal("switching views retained the armed Close All") + } +} + +func TestMonitorCloseAllArmingShowsConfirmationAndReleasesTypingFocus(t *testing.T) { + m, _ := inlinePromptTestModel() + m, _ = promptKey(m, tea.KeyEnter, "") + m.monitorPrompt.input.SetValue("draft") + m.requestMonitorCloseAll() + if !m.monitorCloseAllArmed() || m.monitorPrompt.input.Focused() || m.monitorPrompt.input.Value() != "draft" { + t.Fatal("arming did not preserve the draft and focus the confirmation") + } + g := m.monitorDashboardLayout() + r := m.monitorArea(g.contentWidth, g.meterHeight).closeAllRect + view := m.renderMonitorArea(g.contentWidth, g.meterHeight, paletteFor(m.theme)).view + var text []string + for y, line := range strings.Split(view, "\n") { + if y >= r.y && y < r.y+r.height { + text = append(text, ansi.Strip(ansi.Cut(line, r.x, r.x+r.width))) + } + } + label := strings.Join(text, "\n") + if !strings.Contains(label, "C(O)NFIRM") || !strings.Contains(label, "Esc") { + t.Fatal("armed button does not clearly offer confirmation and cancellation") + } +} diff --git a/internal/ui/monitor_commands.go b/internal/ui/monitor_commands.go index 19afa50..d8b288f 100644 --- a/internal/ui/monitor_commands.go +++ b/internal/ui/monitor_commands.go @@ -3,9 +3,11 @@ package ui import ( "context" "fmt" + "net/url" "strings" "time" + "charm.land/bubbles/v2/textinput" tea "charm.land/bubbletea/v2" "github.com/charmbracelet/x/ansi" "github.com/merefield/codexometer/internal/codex" @@ -21,6 +23,7 @@ type monitorCommandsState struct { notice string until time.Time footerHover string + input textinput.Model } type monitorCommandsResult struct { session string @@ -55,6 +58,7 @@ func (m *Model) loadMonitorCommands(path string) tea.Cmd { p.notice = "Shared app-server commands unavailable." return nil } + p.input.Blur() p.busy = true p.detail = false p.notice = "" @@ -89,6 +93,7 @@ func (m Model) openMonitorCommands(path string) (Model, tea.Cmd, bool) { } func (m *Model) closeMonitorCommands() { + m.monitorCommands.input.Blur() m.monitorCommands.open = false m.monitorCommands.request++ m.monitorCommands.busy = false @@ -153,7 +158,7 @@ func (m Model) confirmMonitorCommand() (Model, tea.Cmd, bool) { ctx, cancel := context.WithTimeout(context.Background(), 12*time.Second) defer cancel() err := c.ExecuteSessionCommand(ctx, id, path, rev, o.ID) - return monitorCommandsResult{session: id, request: seq, applied: true, err: err} + return monitorCommandsResult{session: id, path: path, request: seq, applied: true, err: err} }, true } @@ -180,6 +185,18 @@ func (m Model) monitorCommandRows(width, height int) []commandDisplayRow { } return rows } + if p.menu.Input { + rows = append(rows, commandDisplayRow{text: "SESSION NAME", choice: -1}) + p.input.SetWidth(max(w-2, 1)) + rows = append(rows, commandDisplayRow{text: p.input.View(), choice: -1}) + for _, line := range strings.Split(ansi.Hardwrap(p.menu.Help, w, true), "\n") { + if len(rows) >= capacity { + break + } + rows = append(rows, commandDisplayRow{text: line, choice: -1}) + } + return rows + } if p.detail { o, ok := m.commandChoice() if !ok { @@ -187,7 +204,12 @@ func (m Model) monitorCommandRows(width, height int) []commandDisplayRow { } text := o.Label + "\n\n" + p.menu.Help + "\n\n" + o.Help if o.Action { - text += "\n\nTARGET // " + p.session + "\nChanges apply to subsequent turns of this session. They are not global defaults. Confirm only after reviewing the option. Automatic quota thresholds may later supersede model settings." + text += "\n\nTARGET // " + p.session + if strings.HasPrefix(p.menu.Path, "rename/") { + text += "\nOnly this session's saved name changes. Confirm after reviewing the new name." + } else { + text += "\nChanges apply to subsequent turns of this session. They are not global defaults. Confirm only after reviewing the option. Automatic quota thresholds may later supersede model settings." + } } lines := strings.Split(ansi.Hardwrap(text, w, true), "\n") start := min(p.scroll, max(len(lines)-capacity, 0)) @@ -229,7 +251,9 @@ func (m Model) monitorCommandRows(width, height int) []commandDisplayRow { func (m Model) commandFooter(width int) []commandDisplayRow { p := m.monitorCommands var buttons []commandDisplayRow - if p.menu.Multiple { + if p.menu.Input && !p.busy { + buttons = append(buttons, commandDisplayRow{text: "[ ENTER REVIEW ]", action: "review"}) + } else if p.menu.Multiple { buttons = append(buttons, commandDisplayRow{text: "[ C APPLY ]", action: "confirm"}) } else if o, ok := m.commandChoice(); ok && p.detail && o.Action && !p.busy && p.notice == "" { buttons = append(buttons, commandDisplayRow{text: "[ C CONFIRM ]", action: "confirm"}) @@ -269,7 +293,9 @@ func (m Model) renderMonitorCommands(width, height int, colors palette) string { } if len(body) > 1 { hint := "↑/↓ select or scroll • Enter open • / root" - if p.menu.Multiple { + if p.menu.Input { + hint = "Enter review • Escape cancel" + } else if p.menu.Multiple { hint = "↑/↓ select • Space toggle • ←/→ order • C apply" } body[len(body)-2] = colors.dimmed().Render(ansi.Truncate(hint, max(width-4, 1), "")) @@ -314,9 +340,24 @@ func (m Model) updateMonitorCommands(msg tea.Msg) (Model, tea.Cmd, bool) { cmd := m.focusMonitorPrompt() m.monitorPrompt.session = r.session m.monitorPrompt.notice = "Change requested. Codex will apply it to subsequent turns." + if strings.HasPrefix(r.path, "rename/") { + m.monitorPrompt.notice = "Session renamed." + } return m, cmd, true } else { p.menu = r.menu + if p.menu.Input { + p.input = textinput.New() + p.input.CharLimit = 512 + p.input.SetWidth(max(m.monitorDashboardLayout().contentWidth-6, 1)) + p.input.SetValue(p.menu.Value) + cmd := p.input.Focus() + return m, cmd, true + } + if strings.HasPrefix(p.menu.Path, "rename/") && len(p.menu.Choices) == 1 { + p.detail = true + p.until = time.Now().Add(30 * time.Second) + } if p.menu.Path == "" || p.menu.Path == "help" { p.menu.Choices = append(p.menu.Choices, localStatusLineChoice()) } @@ -349,6 +390,35 @@ func (m Model) updateMonitorCommands(msg tea.Msg) (Model, tea.Cmd, bool) { } return m.loadMonitorCommands(path) } + if p.menu.Input && !p.busy { + if key, ok := msg.(tea.KeyPressMsg); ok { + switch key.String() { + case "esc": + m.closeMonitorCommands() + return m, nil, true + case "enter": + return m.reviewMonitorCommandInput() + case "ctrl+c": + m.closeMonitorCommands() + return m, nil, false + } + } + if _, mouse := msg.(tea.MouseMsg); !mouse { + before := p.input.Value() + var cmd tea.Cmd + p.input, cmd = p.input.Update(msg) + switch msg.(type) { + case tea.KeyPressMsg, tea.PasteMsg: + return m, cmd, true + } + // Private clipboard/cursor events belong to the widget. Dashboard + // ticks, telemetry, resize and action results must keep flowing; + // swallowing one tick permanently stops its self-scheduling loop. + if cmd != nil || p.input.Value() != before { + return m, cmd, true + } + } + } if key, ok := msg.(tea.KeyPressMsg); ok { if p.menu.Multiple { switch key.String() { @@ -440,6 +510,8 @@ func (m Model) updateMonitorCommands(msg tea.Msg) (Model, tea.Cmd, bool) { p.footerHover = b.action if click && v.Button == tea.MouseLeft { switch b.action { + case "review": + return m.reviewMonitorCommandInput() case "confirm": return m.confirmMonitorCommand() case "back": @@ -457,3 +529,16 @@ func (m Model) updateMonitorCommands(msg tea.Msg) (Model, tea.Cmd, bool) { } return m, nil, false } + +func (m Model) reviewMonitorCommandInput() (Model, tea.Cmd, bool) { + p := &m.monitorCommands + if !p.menu.Input || p.menu.Path != "rename" || p.busy { + return m, nil, true + } + name := strings.TrimSpace(p.input.Value()) + if name == "" { + return m, nil, true + } + cmd := m.loadMonitorCommands("rename/" + url.PathEscape(name)) + return m, cmd, true +} diff --git a/internal/ui/monitor_commands_test.go b/internal/ui/monitor_commands_test.go index 04daaa9..adb60d3 100644 --- a/internal/ui/monitor_commands_test.go +++ b/internal/ui/monitor_commands_test.go @@ -3,6 +3,7 @@ package ui import ( "context" "errors" + "net/url" "strconv" "strings" "testing" @@ -205,3 +206,124 @@ func TestMonitorCommandsLateSuccessCannotClearAnotherSessionDraft(t *testing.T) t.Fatal("late success modified the newly selected session") } } + +type renameTestClient struct { + *commandTestClient + path string +} + +func (f *renameTestClient) SessionCommands(_ context.Context, _ string, path string) (codex.SessionCommandMenu, error) { + f.path = path + m := codex.SessionCommandMenu{Title: "/rename", Path: path, Revision: "rename-revision"} + if path == "rename" { + m.Input = true + m.Value = "Current name" + } else { + name, _ := url.PathUnescape(strings.TrimPrefix(path, "rename/")) + m.Choices = []codex.SessionCommandChoice{{ID: "rename-choice", Label: "Rename to " + name, Help: "Only the saved name changes.", Action: true}} + } + return m, nil +} +func TestMonitorRenameEditorReviewAndConfirmation(t *testing.T) { + m, base := commandTestModel(t) + f := &renameTestClient{commandTestClient: base} + m.fetcher = f + m.monitorPrompt.input.SetValue("unsent ordinary draft") + m, cmd, _ := m.openMonitorCommands("rename") + next, _ := m.Update(cmd()) + m = next.(Model) + if !m.monitorCommands.menu.Input || !m.monitorCommands.input.Focused() || m.monitorCommands.input.Value() != "Current name" { + t.Fatal("rename editor missing or not focused") + } + m.monitorCommands.input.SetValue("quota / review") + // Letters used as global shortcuts belong to the name editor. + next, _ = m.Update(key('r')) + m = next.(Model) + if !strings.Contains(m.monitorCommands.input.Value(), "r") || !m.monitorCommands.open { + t.Fatal("name editor lost input") + } + m.monitorCommands.input.SetValue("quota / review") + m, cmd, _ = m.updateMonitorCommands(tea.KeyPressMsg{Code: tea.KeyEnter}) + if cmd == nil || !m.monitorCommands.busy || f.calls != 0 { + t.Fatal("review missing or rename sent before confirmation") + } + next, _ = m.Update(cmd()) + m = next.(Model) + if f.path != "rename/"+url.PathEscape("quota / review") || !m.monitorCommands.detail || !strings.Contains(ansi.Strip(m.render()), "quota / review") { + t.Fatal("new name not reviewed", f.path) + } + m, cmd, _ = m.updateMonitorCommands(tea.KeyPressMsg{Code: tea.KeyEnter}) + if cmd != nil || f.calls != 0 { + t.Fatal("Enter bypassed rename confirmation") + } + m, cmd, _ = m.confirmMonitorCommand() + if cmd == nil { + t.Fatal("missing confirmed rename") + } + next, _ = m.Update(cmd()) + m = next.(Model) + if f.calls != 1 || m.monitorCommands.open || m.monitorPrompt.input.Value() != "unsent ordinary draft" || m.monitorPrompt.notice != "Session renamed." { + t.Fatal("rename did not restore draft and notice") + } +} + +func renameEditorTestModel(t *testing.T) Model { + t.Helper() + m, base := commandTestModel(t) + m.fetcher = &renameTestClient{commandTestClient: base} + m, cmd, _ := m.openMonitorCommands("rename") + next, _ := m.Update(cmd()) + m = next.(Model) + if !m.monitorCommands.menu.Input || !m.monitorCommands.input.Focused() { + t.Fatal("rename editor did not open") + } + return m +} + +func TestMonitorRenameEditorKeepsBackgroundUpdates(t *testing.T) { + t.Run("poll ticker", func(t *testing.T) { + m := renameEditorTestModel(t) + phase := m.phase + next, cmd := m.Update(secondMsg(time.Now())) + m = next.(Model) + if m.phase != phase+1 || cmd == nil || !m.monitorFetchActive { + t.Fatal("rename editor swallowed the ticker: animation and polling will never resume") + } + if !m.monitorCommands.open || m.monitorCommands.input.Value() != "Current name" { + t.Fatal("background tick changed the rename draft") + } + }) + t.Run("telemetry and steer reconciliation", func(t *testing.T) { + m := renameEditorTestModel(t) + m.monitorRequest, m.monitorFetchActive = 7, true + m.recordMonitorSteer(monitorSteerReceipt{session: "root-one", thread: "root-one", turn: "turn", text: "new guidance"}) + next, _ := m.Update(monitorFetchedMsg{kind: monitorFetchSample, sequence: 7, at: time.Now(), usage: codex.LiveUsageSnapshot{ + TotalTokens: 100, + Sessions: []codex.LiveUsageSession{{ID: "root-one", Name: "Renamed root", TotalTokens: 100, Active: true, + Attention: codex.SessionAttentionApproval, + Context: codex.SessionContext{Kind: codex.SessionContextApproval, ThreadID: "root-one", TurnID: "turn", Text: "new approval", LatestGuidance: "new guidance", LatestGuidanceID: "guidance-2"}, + }}, + }}) + m = next.(Model) + if m.monitorFetchActive || m.monitorLatest != 100 || m.monitorSessionData[0].name != "Renamed root" || m.monitorSessionData[0].preview.Text != "new approval" || m.monitorSessionData[0].attention != codex.SessionAttentionApproval || len(m.monitorSteers) != 0 { + t.Fatal("rename editor swallowed telemetry: name, approvals and sent-steer receipts remain stale") + } + // The editor can close normally even in the buggy version. Verify that + // the completed fetch was released so later ticks schedule another read. + m.closeMonitorCommands() + phase := m.phase + next, cmd := m.Update(secondMsg(time.Now().Add(2 * time.Second))) + m = next.(Model) + if cmd == nil || m.phase != phase+1 || m.monitorRequest != 8 || !m.monitorFetchActive { + t.Fatal("polling did not continue after leaving the rename editor") + } + }) + t.Run("window resize", func(t *testing.T) { + m := renameEditorTestModel(t) + next, _ := m.Update(tea.WindowSizeMsg{Width: 180, Height: 50}) + m = next.(Model) + if m.width != 180 || m.height != 50 { + t.Fatal("rename editor swallowed window size") + } + }) +} diff --git a/internal/ui/monitor_context.go b/internal/ui/monitor_context.go index 774e23a..e969264 100644 --- a/internal/ui/monitor_context.go +++ b/internal/ui/monitor_context.go @@ -356,6 +356,10 @@ func (m Model) updateMonitorContextKey(key string) (Model, tea.Cmd, bool) { case "esc", "x": m.stepBackMonitorContext() return m, nil, true + case "home": + m.monitorContextScroll = 0 + case "end": + m.scrollMonitorContext(m.monitorContextScrollLimit()) case "up": m.scrollMonitorContext(-1) case "down": diff --git a/internal/ui/monitor_context_test.go b/internal/ui/monitor_context_test.go index e13a0f2..c3729ef 100644 --- a/internal/ui/monitor_context_test.go +++ b/internal/ui/monitor_context_test.go @@ -178,7 +178,7 @@ func TestMonitorContextPrivacyAndModalIsolation(t *testing.T) { if m.monitorContextScroll == 0 { t.Fatal("detail did not scroll") } - updated, _ = m.Update(key('s')) + updated, _ = m.Update(key('z')) m = updated.(Model) if m.monitorState != monitorRunning { t.Fatal("modal activated underlying reset") diff --git a/internal/ui/monitor_detail.go b/internal/ui/monitor_detail.go index 7164a58..fea0251 100644 --- a/internal/ui/monitor_detail.go +++ b/internal/ui/monitor_detail.go @@ -67,6 +67,10 @@ func (m Model) contextDetailDocument(width int) (document []detailLine) { return lines } c := s.preview + sanitize := codex.SanitizeSessionContext + if c.Kind == codex.SessionContextApproval { + sanitize = codex.SanitizeApprovalText + } var lines []detailLine appendText := func(text, kind, prefix string) { for _, line := range strings.Split(ansi.Hardwrap(text, max(width-lipgloss.Width(prefix), 1), true), "\n") { @@ -117,7 +121,7 @@ func (m Model) contextDetailDocument(width int) (document []detailLine) { appendText(codex.SanitizeSessionContext(c.Activity.Command), "command", prefix) } else if c.Kind == codex.SessionContextApproval && c.FileChanges != "" { section(contextTitle(c)) - appendText(codex.SanitizeSessionContext(c.Text), "body", "") + appendText(sanitize(c.Text), "body", "") lines = append(lines, detailLine{}) lines = append(lines, fileApprovalDocument(c.FileChanges, width)...) } else if c.Kind == codex.SessionContextApproval && c.CommandDetails.Command != "" { @@ -125,25 +129,25 @@ func (m Model) contextDetailDocument(width int) (document []detailLine) { d := c.CommandDetails if strings.TrimSpace(d.Justification) != "" { section(i18n.Text("JUSTIFICATION")) - appendText(codex.SanitizeSessionContext(d.Justification), "body", "") + appendText(sanitize(d.Justification), "body", "") } section(i18n.Text("COMMAND")) prefix := "│ " if width < 3 { prefix = "" } - appendText(codex.SanitizeSessionContext(d.Command), "command", prefix) + appendText(sanitize(d.Command), "command", prefix) section(i18n.Text("WORKING DIRECTORY")) - appendText(codex.SanitizeSessionContext(d.Directory), "metadata", "") + appendText(sanitize(d.Directory), "metadata", "") for _, option := range c.ApprovalOptions { if option.Detail != "" { section(i18n.Text("PERSISTENT PERMISSION RULE")) - appendText(codex.SanitizeSessionContext(option.Detail), "warning", "") + appendText(sanitize(option.Detail), "warning", "") } } } else if c.Text != "" { section(contextTitle(c)) - text := codex.SanitizeSessionContext(c.Text) + text := sanitize(c.Text) // Legacy/unstructured requests remain verbatim. This cosmetic spacer // does not claim to identify an authoritative command boundary. if c.Kind == codex.SessionContextApproval { diff --git a/internal/ui/monitor_detail_activity.go b/internal/ui/monitor_detail_activity.go index 7ee6ca3..49d94ce 100644 --- a/internal/ui/monitor_detail_activity.go +++ b/internal/ui/monitor_detail_activity.go @@ -115,6 +115,11 @@ func (m Model) layoutDetailControlsBase(width, height int) detailControlLayout { if rows := m.monitorApprovalControlRows(width, height); rows > 0 { return detailControlLayout{kind: "approval", rows: rows} } + if s, ok := m.contextDetailSession(); ok && s.preview.Kind == codex.SessionContextApproval && !m.monitorApprovalHasOutcome() { + notice := i18n.Text("REPLY IN CODEX") + " // " + m.monitorApprovalBlockReason(s.preview) + rows := len(strings.Split(ansi.Hardwrap(notice, max(width-4, 1), true), "\n")) + return detailControlLayout{kind: "approval-blocked", rows: min(rows, max(min(height-5, 3), 1)), notice: notice} + } if m.monitorContextDetail != "" && m.hasSchedule(m.monitorContextDetail) && len(m.monitorPromptOffer().Questions) == 0 && (m.scheduleUI.confirmID != "" || m.scheduleUI.notice != "") { if width < 24 || height < 8 { return detailControlLayout{kind: "notice", rows: 1, notice: i18n.Text("Ctrl+S: EDIT")} @@ -154,6 +159,13 @@ func (layout detailControlLayout) renderBase(m Model, width, height int, colors return m.renderMonitorApprovalControls(width, height, colors) case "prompt": return m.renderMonitorPrompt(width, height, colors) + case "approval-blocked": + lines := strings.Split(ansi.Hardwrap(layout.notice, max(width-4, 1), true), "\n") + lines = lines[:min(len(lines), layout.rows)] + for i := range lines { + lines[i] = colors.label().Foreground(colors.warning).Render(ansi.Truncate(lines[i], max(width-4, 1), "")) + } + return strings.Join(lines, "\n") case "notice": return colors.label().Render(ansi.Truncate(layout.notice, max(width-4, 1), "")) default: diff --git a/internal/ui/monitor_detail_scroll_test.go b/internal/ui/monitor_detail_scroll_test.go new file mode 100644 index 0000000..f432cfe --- /dev/null +++ b/internal/ui/monitor_detail_scroll_test.go @@ -0,0 +1,92 @@ +package ui + +import ( + "fmt" + "strings" + "testing" + "time" + + tea "charm.land/bubbletea/v2" + "charm.land/lipgloss/v2" + "github.com/charmbracelet/x/ansi" + "github.com/merefield/codexometer/internal/codex" +) + +func TestLongApprovalDetailFullScreen(t *testing.T) { + for _, size := range [][2]int{{60, 24}, {80, 30}, {120, 30}, {180, 40}} { + for _, history := range []bool{false, true} { + t.Run(fmt.Sprintf("%dx%d/history=%t", size[0], size[1], history), func(t *testing.T) { + m := approvalTestModel() + m.width, m.height = size[0], size[1] + c := &m.monitorSessionData[0].preview + c.CurrentTask = strings.Repeat("Long task details with wrapping. ", 30) + c.ApprovalContext = strings.Repeat("Prior commentary with wrapping. ", 30) + c.Text = "Review the full command" + c.CommandDetails = codex.ApprovalCommandDetails{Justification: strings.Repeat("Long explanation. ", 400) + "END OF JUSTIFICATION", Command: strings.Repeat("echo long-command\n", 400) + "END OF COMMAND", Directory: "/work"} + if history { + m.monitorHistory = map[string]monitorTurnHistory{m.monitorContextDetail: {turns: []codex.SessionContext{{ThreadID: m.monitorContextDetail, TurnID: "old", Kind: codex.SessionContextReply, Text: "previous reply", At: time.Now().Add(-time.Minute)}}}} + } + for _, offset := range []int{0, 10000} { + m.scrollMonitorContext(offset) + plain := ansi.Strip(m.render()) + g := m.monitorDashboardLayout() + if lipgloss.Height(plain) > m.height || lipgloss.Width(plain) > m.width { + t.Fatalf("render overflow %dx%d", lipgloss.Width(plain), lipgloss.Height(plain)) + } + lines := strings.Split(plain, "\n") + buttons := m.monitorApprovalButtons(g.contentWidth, g.meterHeight) + if len(buttons) == 0 { + t.Fatal("missing controls") + } + for _, b := range buttons { + found := false + for y, line := range lines { + if x := strings.Index(line, b.label); x >= 0 { + found = true + if got := m.monitorContextAt(lipgloss.Width(line[:x]), y); got != b.action { + t.Errorf("button hit %q expected %q", got, b.action) + } + } + } + if !found { + t.Errorf("button clipped: %s", b.label) + } + } + if offset > 0 && !strings.Contains(plain, "END OF COMMAND") { + t.Fatal("last text row inaccessible") + } + } + }) + } + } +} + +func TestBlockedApprovalReasonStaysVisible(t *testing.T) { + m := approvalTestModel() + m.monitorSessionData[0].preview.Text = strings.Repeat("request detail\n", 200) + m.monitorSessionData[0].preview.ApprovalToken = "" + m.monitorSessionData[0].preview.ApprovalBlocked = "truncated" + for _, key := range []string{"home", "end"} { + m, _, _ = m.updateMonitorContextKey(key) + plain := ansi.Strip(m.render()) + if !strings.Contains(plain, "REPLY IN CODEX") || !strings.Contains(plain, "Request details exceed the display limit.") { + t.Fatal("blocked reason scrolled away") + } + if key == "end" && m.monitorContextScroll != m.monitorContextScrollLimit() { + t.Fatal("End did not reach final line") + } + } + m, _, _ = m.updateMonitorContextKey("home") + if m.monitorContextScroll != 0 { + t.Fatal("Home did not return to the start") + } + // Mouse wheel events must reach the same bottom as End. + g := m.monitorDashboardLayout() + for i := 0; i < 100; i++ { + next, _ := m.Update(tea.MouseWheelMsg(tea.Mouse{X: 10, Y: g.meterY + 2, Button: tea.MouseWheelDown})) + m = next.(Model) + } + if m.monitorContextScroll != m.monitorContextScrollLimit() { + t.Fatal("wheel cannot reach final line") + } +} diff --git a/internal/ui/monitor_detail_test.go b/internal/ui/monitor_detail_test.go index 0b8c26e..876016c 100644 --- a/internal/ui/monitor_detail_test.go +++ b/internal/ui/monitor_detail_test.go @@ -89,3 +89,26 @@ func TestApprovalCommentaryFullDetailOnly(t *testing.T) { t.Fatal("context leaked into row") } } + +func TestApprovalDetailKeepsCommandWhitespaceAndControls(t *testing.T) { + m := approvalTestModel() + c := &m.monitorSessionData[0].preview + c.CommandDetails = codex.ApprovalCommandDetails{Command: "\n printf 'a\tb' \r\n\n", Directory: "/work"} + before := *c + var command []string + for _, line := range m.contextDetailDocument(120) { + if line.kind == "command" { + command = append(command, strings.TrimPrefix(line.text, "│ ")) + } + } + if got := strings.Join(command, "\n"); got != "\n printf 'a b' \n\n" { + t.Fatalf("command formatting lost: %q", got) + } + g := m.monitorDashboardLayout() + if !m.monitorApprovalControls(g.contentWidth, g.meterHeight) { + t.Fatal("whitespace disabled approval controls") + } + if *c != before { + t.Fatal("display formatting changed the original approval") + } +} diff --git a/internal/ui/monitor_test.go b/internal/ui/monitor_test.go index f65eaa6..31c87d1 100644 --- a/internal/ui/monitor_test.go +++ b/internal/ui/monitor_test.go @@ -53,7 +53,7 @@ func TestMonitorAutoStartAndResetLifecycle(t *testing.T) { t.Fatalf("30-second graph bucket was not recorded: %#v", model.monitorSamples) } - updated, command = model.Update(key('s')) + updated, command = model.Update(key('z')) model = updated.(Model) if command == nil || model.monitorState != monitorResetting || model.flashedButton != footerButtonMonitorReset { t.Fatalf("Reset did not request a fresh baseline: state=%d flash=%d", model.monitorState, model.flashedButton) @@ -760,7 +760,7 @@ func TestMonitorViewIsResponsiveAndGraphAutoScales(t *testing.T) { } output := model.render() plain := ansi.Strip(output) - for _, want := range []string{"SESSION TOTALS", "TOKENS", "6,250", "SESSIONS", "WORKING", "APPROVAL", "INPUT", "CHECK*", "RE(S)ET", "LOCAL TOKEN BARS", "AUTO 0-10K", "█", "░"} { + for _, want := range []string{"SESSION TOTALS", "TOKENS", "6,250", "SESSIONS", "WORKING", "APPROVAL", "INPUT", "CHECK*", "(Z)ERO", "LOCAL TOKEN BARS", "AUTO 0-10K", "█", "░"} { if !strings.Contains(plain, want) { t.Errorf("%dx%d monitor missing %q:\n%s", size.width, size.height, want, plain) } @@ -830,7 +830,7 @@ func TestMonitorLargeButtonsAreClickableAcrossTheirBoxes(t *testing.T) { dashboard := model.dashboardLayout() geometry := layoutMonitorArea(dashboard.contentWidth, dashboard.meterHeight) area := model.renderMonitorArea(dashboard.contentWidth, dashboard.meterHeight, colors) - if area.resetRect != geometry.resetRect { + if area.resetRect != geometry.resetRect || area.closeAllRect != geometry.closeAllRect { t.Fatalf("rendered controls diverged from pure layout: rendered=%#v layout=%#v", area, geometry) } originX := 2 @@ -854,8 +854,8 @@ func TestMonitorLargeButtonsAreClickableAcrossTheirBoxes(t *testing.T) { if command != nil || model.hoveredButton != footerButtonMonitorReset { t.Fatal("hovering the Reset box did not select it") } - hovered := model.renderMonitorButton(14, 6, "RE(S)ET", footerButtonMonitorReset, true, colors) - wantHover := lipgloss.NewStyle().Bold(true).Foreground(colors.accent).Background(colors.background).Render("RE(S)ET") + hovered := model.renderMonitorButton(14, 6, "(Z)ERO", footerButtonMonitorReset, true, colors) + wantHover := lipgloss.NewStyle().Bold(true).Foreground(colors.accent).Background(colors.background).Render("(Z)ERO") if !strings.Contains(hovered, wantHover) { t.Fatal("hovering the Reset box did not highlight its label") } @@ -880,7 +880,7 @@ func TestMonitorHeaderComponentsHonorAllocatedDimensions(t *testing.T) { t.Errorf("%dx%d readout rendered %dx%d, want %dx%d", size.width, size.height, gotWidth, gotHeight, geometry.readoutWidth, geometry.topHeight) } - for index, width := range []int{geometry.resetRect.width} { + for index, width := range []int{geometry.resetRect.width, geometry.closeAllRect.width} { button := model.renderMonitorButton(width, geometry.topHeight, "BUTTON", footerButtonMonitorReset, true, colors) if gotWidth, gotHeight := lipgloss.Width(button), lipgloss.Height(button); gotWidth != width || gotHeight != geometry.topHeight { t.Errorf("%dx%d button %d rendered %dx%d, want %dx%d", size.width, size.height, index, gotWidth, gotHeight, width, geometry.topHeight) @@ -895,6 +895,7 @@ func TestMonitorButtonBoxesMatchEnabledHitSurfacesAcrossSizes(t *testing.T) { model := Model{ snapshot: codex.DemoSnapshot(), width: size.width, height: size.height, meterView: viewMonitor, monitorState: state, + monitorSessionData: []monitorSession{{id: "visible", displayed: true}}, } dashboard := model.dashboardLayout() geometry := layoutMonitorArea(dashboard.contentWidth, dashboard.meterHeight) @@ -906,8 +907,8 @@ func TestMonitorButtonBoxesMatchEnabledHitSurfacesAcrossSizes(t *testing.T) { } } } - if geometry.readoutWidth < geometry.width*3/4 { - t.Fatal("readout did not retain its expanded space") + if geometry.readoutWidth < geometry.width*3/5 { + t.Fatal("readout did not retain enough space beside the controls") } for _, button := range []struct { rect monitorRect @@ -915,6 +916,7 @@ func TestMonitorButtonBoxesMatchEnabledHitSurfacesAcrossSizes(t *testing.T) { enabled bool }{ {geometry.resetRect, footerButtonMonitorReset, model.monitorResetEnabled()}, + {geometry.closeAllRect, footerButtonMonitorCloseAll, model.monitorCloseAllEnabled()}, } { want := footerButtonNone if button.enabled { diff --git a/internal/ui/tabs_test.go b/internal/ui/tabs_test.go index 334533a..59d2cf2 100644 --- a/internal/ui/tabs_test.go +++ b/internal/ui/tabs_test.go @@ -241,10 +241,10 @@ func TestVSelectsQuotaViewAndMonitorShortcutsStayScoped(t *testing.T) { } model = Model{meterView: viewMonitor, monitorState: monitorRunning} - updated, command = model.Update(key('s')) + updated, command = model.Update(key('z')) model = updated.(Model) if command == nil || model.monitorState != monitorResetting || model.flashedButton != footerButtonMonitorReset { - t.Fatalf("Monitor S did not reset: state=%d flash=%d", model.monitorState, model.flashedButton) + t.Fatalf("Monitor Z did not zero: state=%d flash=%d", model.monitorState, model.flashedButton) } model = Model{meterView: viewMonitor, monitorState: monitorRunning} diff --git a/internal/web/control_commands.go b/internal/web/control_commands.go index cdc5df5..4e05e7c 100644 --- a/internal/web/control_commands.go +++ b/internal/web/control_commands.go @@ -5,6 +5,7 @@ import ( "crypto/rand" "encoding/json" "net/http" + "strings" "time" ) @@ -48,7 +49,11 @@ func (c *control) handleCommands(w http.ResponseWriter, r *http.Request, body ac http.Error(w, "Command unconfirmed; check Codex before retrying", 409) return } - _ = json.NewEncoder(w).Encode(map[string]string{"message": "Change requested. Codex will apply it to subsequent turns."}) + message := "Change requested. Codex will apply it to subsequent turns." + if strings.HasPrefix(q.Path, "rename/") { + message = "Session renamed." + } + _ = json.NewEncoder(w).Encode(map[string]string{"message": message}) return } m, err := c.commands.SessionCommands(ctx, body.Session, q.Path) diff --git a/internal/web/control_commands_test.go b/internal/web/control_commands_test.go index f9a507b..b5a3820 100644 --- a/internal/web/control_commands_test.go +++ b/internal/web/control_commands_test.go @@ -28,7 +28,7 @@ func TestCommandConfirmationIsBoundAndSingleUse(t *testing.T) { s, _, token := controlServer(t) f := &commandsFake{revision: "current"} s.control.commands = f - b := actionRequest{Session: "parent", Command: &commandRequest{Mode: "prepare", Path: "model/test", Revision: "current", Choice: "choice"}} + b := actionRequest{Session: "parent", Command: &commandRequest{Mode: "prepare", Path: "rename/new-name", Revision: "current", Choice: "choice"}} w := actionCall(s, token, "commands", b) var response struct{ Confirmation string } if w.Code != 200 || json.Unmarshal(w.Body.Bytes(), &response) != nil || response.Confirmation == "" { @@ -46,6 +46,10 @@ func TestCommandConfirmationIsBoundAndSingleUse(t *testing.T) { if w = actionCall(s, token, "commands", b); w.Code != 200 || f.calls != 1 { t.Fatalf("commit %d %s calls %d", w.Code, w.Body, f.calls) } + var result struct{ Message string } + if json.Unmarshal(w.Body.Bytes(), &result) != nil || result.Message != "Session renamed." { + t.Fatal("confirmed rename reported as still pending", w.Body) + } if w = actionCall(s, token, "commands", b); w.Code != 409 || f.calls != 1 { t.Fatal("replayed command") } diff --git a/internal/web/dist/assets/index-C14IM-bC.js b/internal/web/dist/assets/index-C14IM-bC.js deleted file mode 100644 index 3944c5e..0000000 --- a/internal/web/dist/assets/index-C14IM-bC.js +++ /dev/null @@ -1,43 +0,0 @@ -(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=Array.isArray,t=Array.prototype.indexOf,n=Array.prototype.includes,r=Array.from,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyDescriptors,s=Object.prototype,c=Array.prototype,l=Object.getPrototypeOf,u=Object.isExtensible;function d(e){return typeof e==`function`}var f=()=>{};function p(e){return e()}function m(e){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}function g(e,t,n=!1){return e===void 0?n?t():t:e}function _(e,t){if(Array.isArray(e))return e;if(t===void 0||!(Symbol.iterator in e))return Array.from(e);let n=[];for(let r of e)if(n.push(r),n.length===t)break;return n}var v=1024,y=2048,b=4096,x=8192,S=16384,C=32768,w=1<<25,T=65536,ee=1<<19,te=1<<20,E=1<<25,D=1<<21,ne=1<<22,O=1<<23,re=Symbol(`$state`),ie=Symbol(`component`),ae=Symbol(`legacy props`),oe=Symbol(``),se=Symbol(`attributes`),ce=Symbol(`class`),le=Symbol(`style`),ue=Symbol(`text`),de=Symbol(`form reset`),fe=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},pe=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`),me={},he=Symbol(`uninitialized`),ge=`http://www.w3.org/1999/xhtml`;function _e(){console.warn(`https://svelte.dev/e/derived_inert`)}function ve(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function ye(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function be(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var k=!1;function xe(e){k=e}var A;function Se(e){if(e===null)throw ve(),me;return A=e}function Ce(){return Se(cn(A))}function j(e){if(k){if(cn(A)!==null)throw ve(),me;A=e}}function we(e=1){if(k){for(var t=e,n=A;t--;)n=cn(n);A=n}}function Te(e=!0){for(var t=0,n=A;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else(r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=cn(n);e&&n.remove(),n=i}}function Ee(e){if(!e||e.nodeType!==8)throw ve(),me;return e.data}function De(e){return e===this.v}function Oe(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function ke(e){return!Oe(e,this.v)}function Ae(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function je(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function Me(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function Ne(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function Pe(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Fe(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Ie(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Le(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Re(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function ze(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function Be(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Ve(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var He=!1;function Ue(){He=!0}var M=null;function We(e){M=e}function Ge(e,t=!1,n){M={p:M,i:!1,c:null,e:null,s:e,x:null,r:U,l:He&&!t?{s:null,u:null,$:[]}:null}}function Ke(e){var t=M,n=t.e;if(n!==null){t.e=null;for(var r of n)xn(r)}return e!==void 0&&(t.x=e),t.i=!0,M=t.p,qe(e)}function qe(e={}){return i(e,ie,{value:!0}),e}function Je(){return!He||M!==null&&M.l===null}var Ye=[];function Xe(){var e=Ye;Ye=[],m(e)}function Ze(e){if(Ye.length===0&&!Tt){var t=Ye;queueMicrotask(()=>{t===Ye&&Xe()})}Ye.push(e)}function Qe(){for(;Ye.length>0;)Xe()}var $e=~(y|b|v);function et(e,t){e.f=e.f&$e|t}function tt(e){e.f&512||e.deps===null?et(e,v):et(e,b)}function nt(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),et(e,v)}function rt(e){k&&sn(e)!==null&&ln(e)}var it=!1;function at(){it||(it=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[de]?.()})},{capture:!0}))}function ot(e){var t=H,n=U;Gn(null),Kn(null);try{return e()}finally{Gn(t),Kn(n)}}function st(e,t,n,r=n){e.addEventListener(t,()=>ot(n));let i=e[de];e[de]=i?()=>{i(),r(!0)}:()=>r(!0),at()}function ct(e,t,n,r){let i=Je()?ft:ht;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=U,c=lt(),l=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function u(e){if(!(s.f&16384)){c();try{r([...o,...e])}catch(e){mn(e,s)}ut()}}var d=dt();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>mt(e))).then(u).catch(e=>mn(e,s)).finally(d)}l?l.then(()=>{c(),f(),ut()}):f()}function lt(){var e=U,t=H,n=M,r=P;return function(i=!0){Kn(e),Gn(t),We(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function ut(e=!0){Kn(null),Gn(null),We(null),e&&P?.deactivate()}function dt(){var e=U,t=e.b,n=P,r=!!t?.is_rendered();return t?.update_pending_count(1,n),n.increment(r,e),()=>{t?.update_pending_count(-1,n),n.decrement(r,e)}}function ft(e){var t=2|y;return U!==null&&(U.f|=ee),{ctx:M,deps:null,effects:null,equals:De,f:t,fn:e,reactions:null,rv:0,v:he,wv:0,parent:U,ac:null}}var pt=Symbol(`obsolete`);function mt(e,t,n){let r=U;r===null&&je();var i=void 0,a=Ht(he),o=!H,s=new Set;return Tn(()=>{var t=U,n=h();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==fe&&n.reject(e)}).finally(ut)}catch(e){n.reject(e),ut()}var c=P;if(o){if(t.f&32768)var l=dt();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(pt);else for(let e of s.values())e.reject(pt);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==pt&&(c.activate(),t?(a.f|=O,Kt(a,t)):(a.f&8388608&&(a.f^=O),Kt(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),yn(()=>{for(let e of s)e.reject(pt)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function N(e){let t=ft(e);return Jn(t),t}function ht(e){let t=ft(e);return t.equals=ke,t}function gt(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n{t.ac.abort(fe),t.ac=null}),t.fn!==null&&(t.teardown=f),lr(t,0),An(t))}function bt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&ur(t)}var xt=null,P=null,St=null,Ct=null,wt=null,Tt=!1,Et=!1,Dt=null,Ot=null,kt=0,At=1,jt=class e{id=At++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;#r=new Set;#i=new Set;#a=0;#o=new Map;#s=null;#c=[];#l=[];#u=new Set;#d=new Set;#f=new Map;#p=new Set;is_fork=!1;#m=!1;constructor(){xt===null?xt=this:(xt.#n=this,this.#t=xt),xt=this}#h(){if(this.is_fork)return!0;for(let n of this.#o.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#f.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#p.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){this.#f.delete(e);for(var r of n.d)et(r,y),t(r);for(r of n.m)et(r,b),t(r)}this.#p.add(e)}#g(){var e=[];for(let i of this.#c)if(!(i.f&16384||!(i.f&6144))){for(var t=i,n=!1;t.parent!==null;){t=t.parent;var r=t.f;if(r&96){if(!(r&1024)){n=!0;break}t.f^=v}}n||e.push(t)}return this.#c=[],e}#_(){this.#e=!0;for(let e of this.#u)this.#d.delete(e),et(e,y),this.schedule(e);for(let e of this.#d)et(e,b),this.schedule(e);this.apply();for(var t=Dt=[],n=[],r=Ot=[];this.#c.length>0;){kt++>1e3&&(this.#S(),Nt());for(let e of this.#g())try{this.#v(e,t,n)}catch(t){throw Rt(e),this.#h()||this.discard(),t}}if(P=null,r.length>0){var i=e.ensure();for(let e of r)i.schedule(e)}if(Dt=null,Ot=null,this.#h()){this.#x(n),this.#x(t);for(let[e,t]of this.#f)Lt(e,t);r.length>0&&P.#_();return}let a=this.#y();if(a){this.#x(n),this.#x(t),a.#b(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),St=this,Ft(n),Ft(t),St=null,this.#s?.resolve();var o=P;if(this.#a===0&&(this.#c.length===0||o!==null)&&this.#S(),this.#c.length>0){if(o!==null){for(let e of this.#c)o.#c.push(e);this.#c=[]}else o=this}o!==null&&(Bt.clear(),o.#_())}#v(e,t,n){e.f^=v;for(var r=e.first;r!==null;){var i=r.f,a=!!(i&96);if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=v:i&4?t.push(r):ir(r)&&(i&16&&this.#d.add(r),ur(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#y(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#b(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}e.async_deriveds.clear(),this.transfer_effects(e.#u,e.#d);let t=e=>{var n=e.reactions;if(n!==null&&!(e.f&2&&!(e.f&6144)))for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#d.delete(i),et(i,y),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),P=this,this.#_()}#x(e){for(var t=0;t{this.#m=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#u.add(t);for(let e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#s??=h()).promise}static ensure(){if(P===null){let t=P=new e;!Et&&!Tt&&Ze(()=>{t.#e||t.flush()})}return P}apply(){Ct=null}schedule(e){if(wt=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}this.#c.push(e)}#S(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?xt=e:t.#t=e,this.linked=!1}}};function Mt(e){var t=Tt;Tt=!0;try{var n;for(e&&(P!==null&&!P.is_fork&&P.flush(),n=e());;){if(Qe(),P===null)return n;P.flush()}}finally{Tt=t}}function Nt(){try{Ie()}catch(e){mn(e,wt)}}var Pt=null;function Ft(e){var t=e.length;if(t!==0){for(var n=0;n0)){Bt.clear();for(let e of Pt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Pt.has(n)&&(Pt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||ur(n)}}Pt.clear()}}Pt=null}}function It(e){P.schedule(e)}function Lt(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),et(e,v);for(var n=e.first;n!==null;)Lt(n,t),n=n.next}}function Rt(e){et(e,v);for(var t=e.first;t!==null;)Rt(t),t=t.next}var zt=new Set,Bt=new Map,Vt=!1;function Ht(e,t){return{f:0,v:e,reactions:null,equals:De,rv:0,wv:0}}function F(e,t){let n=Ht(e,t);return Jn(n),n}function Ut(e,t=!1,n=!0){let r=Ht(e);return t||(r.equals=ke),He&&n&&M!==null&&M.l!==null&&(M.l.s??=[]).push(r),r}function I(e,t,n=!1){return H!==null&&(!Wn||H.f&131072)&&Je()&&H.f&4325394&&(qn===null||!qn.has(e))&&Be(),Kt(e,n?Zt(t):t,Ot)}var Wt=null,Gt=0;function Kt(e,t,n=null){if(!e.equals(t)){Hn?Bt.set(e,t):Bt.has(e)||Bt.set(e,e.v);var r=jt.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&&_t(t),Ct===null&&tt(t)}e.wv=rr(),Wt=null,Gt=0,Xt(e,y,n),Wt=null,Je()&&U!==null&&U.f&1024&&!(U.f&96)&&(Zn===null?Qn([e]):Zn.push(e)),!r.is_fork&&zt.size>0&&!Vt&&qt()}return t}function qt(){Vt=!1;for(let e of zt){e.f&1024&&et(e,b);let t;try{t=ir(e)}catch{t=!0}t&&ur(e)}zt.clear()}function Jt(e,t=1){var n=W(e),r=t===1?n++:n--;return I(e,n),r}function Yt(e){I(e,e.v+1)}function Xt(e,t,n){var r=e.reactions;if(r!==null){var i=Je(),a=r.length;if(Gt+=a,Gt>1e5&&Wt===null&&(Wt=new Set),Wt!==null){if(Wt.has(e))return;Wt.add(e)}for(var o=0;o{if(tr===d)return e();var t=H,n=tr;Gn(null),nr(d);var r=e();return Gn(t),nr(n),r};return i&&r.set(`length`,F(t.length,u)),new Proxy(t,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&Re();var i=r.get(t);return i===void 0?f(()=>{var e=F(n.value,u);return r.set(t,e),e}):I(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>F(he,u));r.set(t,e),Yt(o)}}else I(n,he),Yt(o);return!0},get(e,n,i){if(n===re)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>F(Zt(s?e[n]:he),u)),r.set(n,o)),o!==void 0){var c=W(o);return c===he?void 0:c}return Reflect.get(e,n,i)},getOwnPropertyDescriptor(e,t){this.has?.(e,t);var n=Reflect.getOwnPropertyDescriptor(e,t),i=r.get(t);if(i!==void 0){var a=W(i);if(a===he)return;if(n&&`value`in n)n.value=a;else return{enumerable:!0,configurable:!0,value:a,writable:!0}}return n},has(e,t){if(t===re)return!0;var n=r.get(t),i=n!==void 0&&n.v!==he||Reflect.has(e,t);return(n!==void 0||U!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>F(i?Zt(e[t]):he,u)),r.set(t,n)),W(n)===he)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dF(he,u)),r.set(d+``,p)):I(p,he)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>F(void 0,u)),I(c,Zt(n)),r.set(t,c));else{l=c.v!==he;var m=f(()=>Zt(n));I(c,m)}var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(s,n),!l){if(i&&typeof t==`string`){var g=r.get(`length`),_=Number(t);Number.isInteger(_)&&_>=g.v&&I(g,_+1)}Yt(o)}return!0},ownKeys(e){W(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==he});for(var[n,i]of r)i.v!==he&&!(n in e)&&t.push(n);return t},setPrototypeOf(){ze()}})}function Qt(e){try{if(typeof e==`object`&&e&&re in e)return e[re]}catch{}return e}function $t(e,t){return Object.is(Qt(e),Qt(t))}var en,tn,nn,rn;function an(){if(en===void 0){en=window,tn=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;nn=a(t,`firstChild`).get,rn=a(t,`nextSibling`).get,u(e)&&(e[ce]=void 0,e[se]=null,e[le]=void 0,e.__e=void 0),u(n)&&(n[ue]=void 0)}}function on(e=``){return document.createTextNode(e)}function sn(e){return nn.call(e)}function cn(e){return rn.call(e)}function L(e,t){if(!k)return sn(e);var n=sn(A);if(n===null)n=A.appendChild(on());else if(t&&n.nodeType!==3){var r=on();return n?.before(r),Se(r),r}return t&&fn(n),Se(n),n}function R(e,t=!1){if(!k){var n=sn(e);return n instanceof Comment&&n.data===``?cn(n):n}if(t){if(A?.nodeType!==3){var r=on();return A?.before(r),Se(r),r}fn(A)}return A}function z(e,t=!1){if(!k)return sn(e);var n=L(e,t);return j(e),n}function B(e,t=1,n=!1){let r=k?A:e;for(var i;t--;)i=r,r=cn(r);if(!k)return r;if(n){if(r?.nodeType!==3){var a=on();return r===null?i?.after(a):r.before(a),Se(a),a}fn(r)}return Se(r),r}function ln(e){e.textContent=``}function un(){return!1}function dn(e,t,n){return t==null||t===`http://www.w3.org/1999/xhtml`?n?document.createElement(e,{is:n}):document.createElement(e):n?document.createElementNS(t,e,{is:n}):document.createElementNS(t,e)}function fn(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function pn(e){var t=U;if(t===null)return H.f|=O,e;if(!(t.f&32768)&&!(t.f&4))throw e;mn(e,t)}function mn(e,t){if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128&&!(t.f&33570816)){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}function hn(e){U===null&&(H===null&&Fe(e),Pe()),Hn&&Ne(e)}function gn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function _n(e,t){var n=U;n!==null&&n.f&8192&&(e|=x);var r={ctx:M,deps:null,nodes:null,f:e|y|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};P?.register_created_effect(r);var i=r;if(e&4)Dt===null?jt.ensure().schedule(r):Dt.push(r);else if(t!==null){try{ur(r)}catch(e){throw Mn(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=T))}if(i!==null&&(i.parent=n,n!==null&&gn(i,n),H!==null&&H.f&2&&!(e&64))){var a=H;(a.effects??=[]).push(i)}return r}function vn(){return H!==null&&!Wn}function yn(e){let t=_n(8,null);return et(t,v),t.teardown=e,t}function bn(e){hn(`$effect`);var t=U.f;if(!H&&t&32&&M!==null&&!M.i){var n=M;(n.e??=[]).push(e)}else return xn(e)}function xn(e){return _n(4|te,e)}function Sn(e){return hn(`$effect.pre`),_n(8|te,e)}function Cn(e){jt.ensure();let t=_n(64|ee,e);return(e={})=>new Promise(n=>{e.outro?Fn(t,()=>{Mn(t),n(void 0)}):(Mn(t),n(void 0))})}function wn(e){return _n(4,e)}function Tn(e){return _n(ne|ee,e)}function En(e,t=0){return _n(8|t,e)}function V(e,t=[],n=[],r=[]){ct(r,t,n,t=>{_n(8,()=>{e(...t.map(W))})})}function Dn(e,t=0){return _n(16|t,e)}function On(e){return _n(32|ee,e)}function kn(e){var t=e.teardown;if(t!==null){let n=Hn,r=H;Un(!0),Gn(null);try{t.call(null)}catch(t){mn(t,e.parent)}finally{Un(n),Gn(r)}}}function An(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&ot(()=>{e.abort(fe)});var r=n.next;n.f&64?n.parent=null:Mn(n,t),n=r}}function jn(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||Mn(t),t=n}}function Mn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Nn(e.nodes.start,e.nodes.end),n=!0),e.f|=w,An(e,t&&!n),lr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();kn(e),e.f^=w,e.f|=S;var i=e.parent;i!==null&&i.first!==null&&Pn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Nn(e,t){for(;e!==null;){var n=e===t?null:cn(e);e.remove(),e=n}}function Pn(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function Fn(e,t,n=!0){var r=[];e.f|=256,In(e,r,!0);var i=()=>{n&&Mn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function In(e,t,n){if(!(e.f&8192)){e.f^=x;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=!!(i.f&65536)||!!(i.f&32)&&!!(e.f&16);In(i,t,o?n:!1)}i=a}}}function Ln(e){e.f&=-257,Rn(e,!0)}function Rn(e,t){if(!(e.f&256)&&e.f&8192){e.f^=x,e.f&1024||(et(e,y),jt.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=!!(n.f&65536)||!!(n.f&32);Rn(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function zn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:cn(n);t.append(n),n=i}}var Bn=null,Vn=!1,Hn=!1;function Un(e){Hn=e}var H=null,Wn=!1;function Gn(e){H=e}var U=null;function Kn(e){U=e}var qn=null;function Jn(e){H!==null&&(H.f&2097152||H.f&2)&&(qn??=new Set).add(e)}var Yn=null,Xn=0,Zn=null;function Qn(e){Zn=e}var $n=1,er=0,tr=er;function nr(e){tr=e}function rr(){return++$n}function ir(e){var t=e.f;if(t&2048)return!0;if(t&4096){for(var n=e.deps,r=n.length,i=0;ie.wv)return!0}t&512&&Ct===null&&et(e,v)}return!1}function ar(e,t,n=!0){var r=e.reactions;if(r!==null&&!(qn!==null&&qn.has(e)))for(var i=0;i{e.ac.abort(fe)}),e.ac=null);try{e.f|=D;var u=e.fn,d=u();e.f|=C;var f=sr(e);if(Je()&&Zn!==null&&!Wn&&f!==null&&!(e.f&6146))for(var p=0;p0)for(t.length=Xn+Yn.length,r=0;r{s.ac.abort(fe),s.ac=null,et(s,y)}),yt(s),lr(s,0)}}function lr(e,t){var n=e.deps;if(n!==null)for(var r=t;rn?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?(i.__removed=!1,Ze(()=>{i.__removed||t.addEventListener(e,i,r)})):t.addEventListener(e,i,r),i}function Cr(e,t,n,r,i){var a={capture:r,passive:i},o=Sr(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&yn(()=>{o.__removed=!0,t.removeEventListener(e,o,a)})}function G(e,t,n){(t[yr]??={})[e]=n}function wr(e){for(var t=0;t{Er=!1,Tr=null}));var s=0,c=Tr===e&&e[yr];if(c){var l=a.indexOf(c);if(l!==-1&&(t===document||t===window)){e[yr]=t;return}var u=a.indexOf(t);if(u===-1)return;l<=u&&(s=l)}if(o=a[s]||e.target,o!==t){i(e,`currentTarget`,{configurable:!0,get(){return o||n}});var d=H,f=U;Gn(null),Kn(null);try{for(var p,m=[];o!==null&&o!==t;){try{var h=o[yr]?.[r];h!=null&&(!o.disabled||e.target===o)&&h.call(o,e)}catch(e){p?m.push(e):p=e}if(e.cancelBubble)break;s++,o=s{throw e});throw p}}finally{e[yr]=t,delete e.currentTarget,Gn(d),Kn(f)}}}var Or=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function kr(e){return Or?.createHTML(e)??e}function Ar(e){var t=dn(`template`);return t.innerHTML=kr(e.replaceAll(``,``)),t.content}function jr(e,t){var n=U;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function K(e,t){var n=!!(t&1),r=!!(t&2),i,a=!e.startsWith(``);return()=>{if(k)return jr(A,null),A;i===void 0&&(i=Ar(a?e:``+e),n||(i=sn(i)));var t=r||tn?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=sn(t),s=t.lastChild;jr(o,s)}else jr(t,t);return t}}function Mr(e,t,n=`svg`){var r=!e.startsWith(``),i=!!(t&1),a=`<${n}>${r?e:``+e}`,o;return()=>{if(k)return jr(A,null),A;if(!o){var e=sn(Ar(a));if(i)for(o=document.createDocumentFragment();sn(e);)o.appendChild(sn(e));else o=sn(e)}var t=o.cloneNode(!0);if(i){var n=sn(t),r=t.lastChild;jr(n,r)}else jr(t,t);return t}}function Nr(e,t){return Mr(e,t,`svg`)}function Pr(e=``){if(!k){var t=on(e+``);return jr(t,t),t}var n=A;return n.nodeType===3?fn(n):(n.before(n=on()),Se(n)),jr(n,n),n}function Fr(){if(k)return jr(A,null),A;var e=document.createDocumentFragment(),t=document.createComment(``),n=on();return e.append(t,n),jr(t,n),e}function q(e,t){if(k){var n=U;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=A),Ce();return}e!==null&&e.before(t)}function Ir(){if(k&&A&&A.nodeType===8&&A.textContent?.startsWith(`$`)){let e=A.textContent.substring(1);return Ce(),e}return(window.__svelte??={}).uid??=1,`c${window.__svelte.uid++}`}function Lr(e){let t=0,n=Ht(0),r;return()=>{vn()&&(W(n),En(()=>(t===0&&(r=mr(()=>e(()=>Yt(n)))),t+=1,()=>{Ze(()=>{--t,t===0&&(r?.(),r=void 0,Yt(n))})})))}}var Rr=T|ee;function zr(e,t,n,r){new Br(e,t,n,r)}var Br=class{parent;is_pending=!1;transform_error;#e;#t=k?A:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=0;#d=!1;#f=new Set;#p=new Set;#m=null;#h=Lr(()=>(this.#m=Ht(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=U;t.b=this,t.f|=128,n(e)},this.parent=U.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=Dn(()=>{if(k){let e=this.#t;Ce();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#y():this.#g()}else this.#b()},Rr),k&&(this.#e=A)}#g(){try{this.#a=On(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed,{reset:n,invoke_onerror:r}=this.#v(e);Ze(r),t&&(this.#s=On(()=>{t(this.#e,()=>e,()=>n)}))}#v(e){var t=!1,n=!1;let r=()=>{if(t){be();return}t=!0,n&&Ve(),this.#s!==null&&Fn(this.#s,()=>{this.#s=null}),this.#S(()=>{this.#b()})};return{reset:r,invoke_onerror:()=>{try{n=!0,this.#n.onerror?.(e,r),n=!1}catch(e){mn(e,this.#i&&this.#i.parent)}}}}#y(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=On(()=>e(this.#e)),Ze(()=>{var e=this.#c=document.createDocumentFragment(),t=on(),n=!1;if(e.append(t),this.#a=this.#S(()=>{try{return On(()=>this.#r(t))}catch(e){try{this.error(e),n=!0}catch(e){mn(e,this.#i.parent)}return null}}),this.#a===null){this.#c=null,n&&this.#x(P);return}this.#u===0&&(this.#e.before(e),this.#c=null,Fn(this.#o,()=>{this.#o=null}),this.#x(P))}))}#b(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=On(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();zn(this.#a,e);let t=this.#n.pending;this.#o=On(()=>t(this.#e))}else this.#x(P)}catch(e){this.error(e)}}#x(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){nt(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#S(e){var t=U,n=H,r=M;Kn(this.#i),Gn(this.#i),We(this.#i.ctx);try{return jt.ensure(),e()}finally{Kn(t),Gn(n),We(r)}}#C(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#C(e,t);return}this.#u+=e,this.#u===0&&(this.#x(t),this.#o&&Fn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#C(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,Ze(()=>{this.#d=!1,this.#m&&Kt(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),W(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;P?.is_fork?(this.#a&&P.skip_effect(this.#a),this.#o&&P.skip_effect(this.#o),this.#s&&P.skip_effect(this.#s),P.oncommit(()=>{this.#w(e)})):this.#w(e)}#w(e){this.#a&&=(Mn(this.#a),null),this.#o&&=(Mn(this.#o),null),this.#s&&=(Mn(this.#s),null),k&&(Se(this.#t),we(),Se(Te()));let t=this.#n.failed,n=e=>{let{reset:n,invoke_onerror:r}=this.#v(e);r(),t&&(this.#s=this.#S(()=>{try{return On(()=>{var r=U;r.b=this,r.f|=128,t(this.#e,()=>e,()=>n)})}catch(e){return mn(e,this.#i.parent),null}}))};Ze(()=>{var t;try{t=this.transform_error(e)}catch(e){mn(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(n,e=>mn(e,this.#i&&this.#i.parent)):n(t)})}};function J(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[ue]??=e.nodeValue)&&(e[ue]=n,e.nodeValue=`${n}`)}function Vr(e,t){return Ur(e,t)}var Hr=new Map;function Ur(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){an();var l=void 0,u=Cn(()=>{var s=n??t.appendChild(on());zr(s,{pending:()=>{}},t=>{Ge({});var n=M;if(o&&(n.c=o),a&&(i.$$events=a),k&&jr(t,null),l=e(t,i)||qe(),k&&(U.nodes.end=A,A===null||A.nodeType!==8||A.data!==`]`))throw ve(),me;Ke()},c);var u=new Set,d=e=>{for(var n=0;n{for(var e of u)for(let n of[t,document]){var r=Hr.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Dr),r.delete(e),r.size===0&&Hr.delete(n)):r.set(e,i)}xr.delete(d),s!==n&&s.parentNode?.removeChild(s)}});return Wr.set(l,u),l}var Wr=new WeakMap,Gr=class{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;constructor(e,t=!0){this.anchor=e,this.#i=t}#a=e=>{if(this.#e.has(e)){var t=this.#e.get(e),n=this.#t.get(t);if(n)Ln(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(Ln(r.effect),this.#t.set(t,r.effect),this.#n.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(let[t,n]of this.#e){if(this.#e.delete(t),t===e)break;let r=this.#n.get(n);r&&(Mn(r.effect),this.#n.delete(n))}for(let[e,r]of this.#t){if(e===t||this.#r.has(e))continue;let i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=document.createDocumentFragment();zn(r,t),t.append(on()),this.#n.set(e,{effect:r,fragment:t})}else Mn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Fn(r,i,!1)):i()}}};#o=e=>{this.#e.delete(e);let t=Array.from(this.#e.values());for(let[e,n]of this.#n)t.includes(e)||(Mn(n.effect),this.#n.delete(e))};ensure(e,t){var n=P,r=un();if(t&&!this.#t.has(e)&&!this.#n.has(e)){if(r){var i=document.createDocumentFragment(),a=on();i.append(a),this.#n.set(e,{effect:On(()=>t(a)),fragment:i})}else this.#t.set(e,On(()=>t(this.anchor)))}if(this.#e.set(n,e),r){for(let[t,r]of this.#t)t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of this.#n)t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(this.#a),n.ondiscard(this.#o)}else k&&(this.anchor=A),this.#a(n)}};function Y(e,t,n=!1){var r;k&&(r=A,Ce());var i=new Gr(e),a=n?T:0;function o(e,t){if(k){var n=Ee(r);if(e!==parseInt(n.substring(1))){var a=Te();Se(a),i.anchor=a,xe(!1),i.ensure(e,t),xe(!0);return}}i.ensure(e,t)}Dn(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var Kr=Symbol(`NaN`);function qr(e,t,n){k&&Ce();var r=new Gr(e),i=!Je();Dn(()=>{var e=t();e!==e&&(e=Kr),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function X(e,t){return t}function Jr(e,t,n){for(var i=[],a=t.length,o,s=t.length,c=0;c{if(o){if(o.pending.delete(n),o.done.add(n),o.pending.size===0){var t=e.outrogroups;Yr(e,r(o.done)),t.delete(o),t.size===0&&(e.outrogroups=null)}}else--s},!1)}if(s===0){var l=i.length===0&&n!==null&&e.pending.size===0;if(l){var u=n,d=u.parentNode;ln(d),d.append(u),e.items.clear()}Yr(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function Yr(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i{var t=i();return e(t)?t:t==null?[]:r(t)}),p,m=new Map,h=!0;function g(e){v.effect.f&16384||(v.pending.delete(e),v.fallback=d,Qr(v,p,c,n,a),d!==null&&(p.length===0?d.f&33554432?(d.f^=E,ei(d,null,c)):Ln(d):Fn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:Dn(()=>{p=W(f);var e=p.length;let t=!1;k&&Ee(c)===`[!`!=(e===0)&&(c=Te(),Se(c),xe(!1),t=!0);for(var r=new Set,u=P,v=un(),y=0;ys(c)):(d=On(()=>s(Xr??=on())),d.f|=E)),e>r.size&&Me(``,``,``),k&&e>0&&Se(Te()),!h){if(m.set(u,r),v){for(let[e,t]of l)r.has(e)||u.skip_effect(t.e);u.oncommit(g),u.ondiscard(_)}else g(u)}t&&xe(!0),W(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,k&&(c=A)}function Zr(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function Qr(e,t,n,i,a){var o=!!(i&8),s=t.length,c=e.items,l=Zr(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v0){var ee=i&4&&s===0?n:null;if(o){for(v=0;v{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function $r(e,t,n,r,i,a,o,s){var c=o&1?o&16?Ht(n):Ut(n,!1,!1):null,l=o&2?Ht(i):null;return{v:c,i:l,e:On(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function ei(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=cn(r);if(a.before(r),r===i)return;r=o}}function ti(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function ni(e,t,n){var r;k&&(r=A,Ce());var i=new Gr(e);Dn(()=>{var e=t()??null;if(k&&Ee(r)===`[`!=(e!==null)){var a=Te();Se(a),i.anchor=a,xe(!1),i.ensure(e,e&&(t=>n(t,e))),xe(!0);return}i.ensure(e,e&&(t=>n(t,e)))},T)}var ri=[...` -\r\f\xA0\v`];function ii(e,t,n){var r=e==null?``:``+e;if(t&&(r=r?r+` `+t:t),n){for(var i of Object.keys(n))if(n[i])r=r?r+` `+i:i;else if(r.length)for(var a=i.length,o=0;(o=r.indexOf(i,o))>=0;){var s=o+a;(o===0||ri.includes(r[o-1]))&&(s===r.length||ri.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function ai(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function oi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function si(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\/\*.*?\*\//g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(oi)),i&&c.push(...Object.keys(i).map(oi));var l=0,u=-1;let t=e.length;for(var d=0;d{t.every(_i)||(`__defaultValue`in e&&fi(e,!1),`__value`in e&&pi(e,e.__value))});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),yn(()=>{t.disconnect()})}function hi(e,t,n=t){var r=new WeakSet,i=!0;st(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),gi);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&gi(o)}n(a),e.__value=a,P!==null&&r.add(P)}),wn(()=>{var a=t();if(e===document.activeElement){var o=P;if(r.has(o))return}if(pi(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=gi(s),n(a))}e.__value=a,i=!1})}function gi(e){return`__value`in e?e.__value:e.value}function _i(e){if(e.target.closest(`selectedcontent`)!==null)return!0;if(e.type===`childList`){var t=[...e.addedNodes,...e.removedNodes];return t.length>0&&t.every(e=>e.nodeName===`SELECTEDCONTENT`)}return!1}var vi=Symbol(`is custom element`),yi=Symbol(`is html`),bi=pe?`link`:`LINK`;function xi(e){if(k){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;Q(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;Q(e,`checked`,null),e.checked=r}}};e[de]=n,Ze(n),at()}}function Si(e,t){var n=Ci(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function Q(e,t,n,r){var i=Ci(e);k&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===bi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[oe]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&Ti(e).has(t)?e[t]=n:e.setAttribute(t,n))}function Ci(e){return e[se]??={[vi]:e.nodeName.includes(`-`),[yi]:e.namespaceURI===ge}}var wi=new Map;function Ti(e){var t=e.getAttribute(`is`)||e.nodeName,n=wi.get(t);if(n)return n;wi.set(t,n=new Set);for(var r,i=e,a=Element.prototype;a!==i;){for(var s in r=o(i),r)r[s].set&&s!==`innerHTML`&&s!==`textContent`&&s!==`innerText`&&n.add(s);i=l(i)}return n}function Ei(e,t,n=t){var r=new WeakSet;st(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=ji(e)?Mi(a):a,n(a),P!==null&&r.add(P),await dr(),a!==(a=t())){var o=e.selectionStart,s=e.selectionEnd,c=e.value.length;if(e.value=a??``,s!==null){var l=e.value.length;o===s&&s===c&&l>c?(e.selectionStart=l,e.selectionEnd=l):(e.selectionStart=o,e.selectionEnd=Math.min(s,l))}}}),(k&&e.defaultValue!==e.value||mr(t)==null&&e.value)&&(n(ji(e)?Mi(e.value):e.value),P!==null&&r.add(P)),En(()=>{var n=t();if(e===document.activeElement){var i=P;if(r.has(i))return}ji(e)&&n===Mi(e.value)||(e.type!==`date`||n||e.value)&&n!==e.value&&(e.value=n??``)})}var Di=new Set;function Oi(e,t,n,r,i=r){var a=n.getAttribute(`type`)===`checkbox`,o=e;let s=!1;if(t!==null)for(var c of t)o=o[c]??=[];o.push(n),st(n,`change`,()=>{var e=n.__value;a&&(e=Ai(o,e,n.checked)),i(e)},()=>i(a?[]:null)),En(()=>{var e=r();if(k&&n.defaultChecked!==n.checked){s=!0;return}a?(e||=[],n.checked=e.includes(n.__value)):n.checked=$t(n.__value,e)}),yn(()=>{var e=o.indexOf(n);e!==-1&&o.splice(e,1)}),Di.has(o)||(Di.add(o),Ze(()=>{o.sort((e,t)=>e.compareDocumentPosition(t)===4?-1:1),Di.delete(o)})),Ze(()=>{if(s){var e=a?Ai(o,e,n.checked):o.find(e=>e.checked)?.__value;i(e)}})}function ki(e,t,n=t){st(e,`change`,t=>{n(t?e.defaultChecked:e.checked)}),(k&&e.defaultChecked!==e.checked||mr(t)==null)&&n(e.checked),En(()=>{e.checked=!!t()})}function Ai(e,t,n){for(var r=new Set,i=0;i{var n=this.#e.get(e);n.delete(t),n.size===0&&(this.#e.delete(e),this.#t.unobserve(e))}}#r(){return this.#t??=new ResizeObserver(t=>{for(var n of t){e.entries.set(n.target,n);for(var r of this.#e.get(n.target)||[])r(n)}})}}({box:`border-box`});function Pi(e,t,n){var r=Ni.observe(e,()=>n(e[t]));wn(()=>(mr(()=>n(e[t])),r))}function Fi(e,t){return e===t||e?.[re]===t}function Ii(e=qe(),t,n,r){var i=M.r,a=U;return wn(()=>{var o,s;return En(()=>{o=s,s=r?.()||[],mr(()=>{Fi(n(...s),e)||(t(e,...s),o&&Fi(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&Fi(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}function Li(e,t,n,r,i){var a=()=>{r(n[e])};n.addEventListener(t,a),i?En(()=>{n[e]=i()}):a(),(n===document.body||n===window||n===document)&&yn(()=>{n.removeEventListener(t,a)})}function Ri(e=!1){let t=M,n=t.l.u;if(!n)return;let r=()=>hr(t.s);if(e){let e=0,n={},i=ft(()=>{let r=!1,i=t.s;for(let e in i)i[e]!==n[e]&&(n[e]=i[e],r=!0);return r&&e++,e});r=()=>W(i)}n.b.length&&Sn(()=>{zi(t,r),m(n.b)}),bn(()=>{let e=mr(()=>n.m.map(p));return()=>{for(let t of e)typeof t==`function`&&t()}}),n.a.length&&bn(()=>{zi(t,r),m(n.a)})}function zi(e,t){if(e.l.s)for(let t of e.l.s)W(t);t()}var Bi=!1;function Vi(e){var t=Bi;try{return Bi=!1,[e(),Bi]}finally{Bi=t}}var Hi={get(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(d(r)&&(r=r()),typeof r==`object`&&r&&t in r)return r[t]}},set(e,t,n){let r=e.props.length;for(;r--;){let i=e.props[r];d(i)&&(i=i());let o=a(i,t);if(o&&o.set)return o.set(n),!0}return!1},getOwnPropertyDescriptor(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(d(r)&&(r=r()),typeof r==`object`&&r&&t in r){let e=a(r,t);return e&&!e.configurable&&(e.configurable=!0),e}}},has(e,t){if(t===re||t===ae)return!1;for(let n of e.props)if(d(n)&&(n=n()),n!=null&&t in n)return!0;return!1},ownKeys(e){let t=[];for(let n of e.props)if(d(n)&&(n=n()),n){for(let e in n)t.includes(e)||t.push(e);for(let e of Object.getOwnPropertySymbols(n))t.includes(e)||t.push(e)}return t}};function Ui(...e){return new Proxy({props:e},Hi)}function Wi(e,t,n,r){var i=!He||!!(n&2),o=!!(n&8),s=!!(n&16),c=r,l=!0,u=void 0,d=()=>s&&i?(u??=ft(r),W(u)):(l&&(l=!1,c=s?mr(r):r),c);let f;if(o){var p=re in e||ae in e;f=a(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;o?[m,h]=Vi(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&Le(t),f(m)));var g=i?()=>{var n=e[t];return n===void 0?d():(l=!0,n)}:()=>{var n=e[t];return n!==void 0&&(c=void 0),n===void 0?c:n};if(i&&!(n&4))return g;if(f){var _=e.$$legacy;return(function(e,t){return arguments.length>0?((!i||!t||_||h)&&f(t?g():e),e):g()})}var v=!1,y=(n&1?ft:ht)(()=>(v=!1,g()));o&&W(y);var b=U;return(function(e,t){if(arguments.length>0){let n=t?W(y):i&&o?Zt(e):e;return I(y,n),v=!0,c!==void 0&&(c=n),e}return Hn&&v||b.f&16384?y.v:W(y)})}function Gi(e){M===null&&Ae(`onMount`),He&&M.l!==null?qi(M).m.push(e):bn(()=>{let t=mr(e);if(typeof t==`function`)return t})}function Ki(e){M===null&&Ae(`onDestroy`),Gi(()=>()=>mr(e))}function qi(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);function Ji(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,i,a,o=[],s=``,c=e.split(`/`);for(c[0]||c.shift();i=c.shift();)n=i[0],n===`*`?(o.push(`wild`),s+=`/(.*)`):n===`:`?(r=i.indexOf(`?`,1),a=i.indexOf(`.`,1),o.push(i.substring(1,~r?r:~a?a:i.length)),s+=~r&&!~a?`(?:/([^/]+?))?`:`/([^/]+?)`,~a&&(s+=(~r?`?`:``)+`\\`+i.substring(a))):s+=`/`+i;return{keys:o,pattern:RegExp(`^`+s+(t?`(?=$|/)`:`/?$`),`i`)}}var Yi=new class{#e=F(Xi());get _loc(){return W(this.#e)}set _loc(e){I(this.#e,e)}#t=N(()=>this._loc.location);get _location(){return W(this.#t)}set _location(e){I(this.#t,e)}#n=N(()=>this._loc.querystring);get _querystring(){return W(this.#n)}set _querystring(e){I(this.#n,e)}#r=F(void 0);get _params(){return W(this.#r)}set _params(e){I(this.#r,e)}get loc(){return this._loc}get location(){return this._location}get querystring(){return this._querystring}get params(){return this._params}constructor(){typeof window<`u`?window.addEventListener(`hashchange`,()=>{this._loc=Xi()}):console.warn(`[svelte-spa-router] window 'window' is not defined, skipping initiation`)}};function Xi(){let e=typeof window<`u`?window.location.href:``,t=e.indexOf(`#/`),n=t>-1?e.substr(t+1):`/`,r=n.indexOf(`?`),i=``;return r>-1&&(i=n.substr(r+1),n=n.substr(0,r)),{location:n,querystring:i}}function Zi(e){e?window.scrollTo(e.__svelte_spa_router_scrollX||0,e.__svelte_spa_router_scrollY||0):window.scrollTo(0,0)}function Qi(e,t){Ge(t,!0);let n=Wi(t,`routes`,19,()=>({})),r=Wi(t,`prefix`,3,``),i=Wi(t,`restoreScrollState`,3,!1),a=Wi(t,`onConditionsFailed`,3,()=>{}),o=Wi(t,`onRouteLoaded`,3,()=>{}),s=Wi(t,`onRouteLoading`,3,()=>{}),c=Wi(t,`onRouteEvent`,3,()=>{});class l{path;component;conditions;userData;props;_pattern;_keys;constructor(e,t){let n=e=>typeof e==`object`&&!!e&&e._sveltesparouter===!0;if(!t||typeof t!=`function`&&!n(t))throw Error(`Invalid component object`);if(!e||typeof e==`string`&&(e.length<1||e.charAt(0)!=`/`&&e.charAt(0)!=`*`)||typeof e==`object`&&!(e instanceof RegExp))throw Error(`Invalid value for "path" argument - strings must start with / or *`);let r=Ji(e);if(this.path=e,n(t)){let e=t;this.component=e.component,this.conditions=e.conditions||[],this.userData=e.userData,this.props=e.props||{}}else{let e=t;this.component=()=>Promise.resolve(e),this.conditions=[],this.props={}}this._pattern=r.pattern,this._keys=r.keys}match(e){if(r()){if(typeof r()==`string`){if(e.startsWith(r()))e=e.substr(r().length)||`/`;else return null}else if(r()instanceof RegExp){let t=e.match(r());if(t&&t[0])e=e.substr(t[0].length)||`/`;else return null}}let t=this._pattern.exec(e);if(t===null)return null;if(this._keys===!1)return t;let n={},i=0;for(;i{u.push(new l(t,e))}):Object.keys(n()).forEach(e=>{let t=n();u.push(new l(e,t[e]))});let d=F(null),f=F(null),p=F({}),m=null,h=null;bn(()=>{history.scrollRestoration=i()?`manual`:`auto`}),bn(()=>{if(!i())return;let e=e=>{m=e.state&&(e.state.__svelte_spa_router_scrollY||e.state.__svelte_spa_router_scrollX)?e.state:null};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)});async function g(e,t){await dr(),e(t)}bn(()=>{let e=Yi.loc,t=!1;return mr(async()=>{let n=0;for(;n{t=!0}});function _(e){return e&&typeof e==`object`&&Object.keys(e).length?e:null}var v=Fr(),y=R(v),b=e=>{let t=N(()=>W(d));var n=Fr(),r=R(n),i=e=>{var n=Fr();ni(R(n),()=>W(t),(e,t)=>{t(e,Ui({get params(){return W(f)},get onRouteEvent(){return c()}},()=>W(p)))}),q(e,n)},a=e=>{var n=Fr();ni(R(n),()=>W(t),(e,t)=>{t(e,Ui({get onRouteEvent(){return c()}},()=>W(p)))}),q(e,n)};Y(r,e=>{W(f)?e(i):e(a,-1)}),q(e,n)};Y(y,e=>{W(d)&&e(b)}),q(e,v),Ke()}var $i=[`bars`,`pace`,`zone`,`pie`,`fuel`,`resets`,`thresholds`],ea=`codexometer.web.preferences.v1`,ta={statusLine:null,tab:`quota`,view:`bars`,selected:``,defaultDetail:0,layouts:[]};function na(){try{let e=JSON.parse(localStorage.getItem(ea)||`null`);return!e||typeof e!=`object`?ta:{statusLine:Array.isArray(e.statusLine)?[...new Set(e.statusLine.filter(e=>typeof e==`string`&&e.length<64))].slice(0,32):null,tab:[`quota`,`sessions`,`usage`].includes(e.tab)?e.tab:`quota`,view:$i.includes(e.view)?e.view:`bars`,selected:typeof e.selected==`string`?e.selected.slice(0,256):``,defaultDetail:+(e.defaultDetail===1),layouts:Array.isArray(e.layouts)?e.layouts.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&t.id.length<=256&&[0,1,2].includes(t.level)}).slice(-100):[]}}catch{return ta}}var ra=Zt(na()),ia=Zt({open:!1});function aa(){let e=JSON.stringify(ra);try{localStorage.setItem(ea,e)}catch{}}function oa(){return ra.tab===`quota`?`/quota/`+ra.view:`/`+ra.tab}function sa(e){return ra.layouts.find(t=>t.id===e)?.level??ra.defaultDetail}function ca(e){ra.defaultDetail=e,ra.layouts=[]}function la(e,t){ra.layouts=[...ra.layouts.filter(t=>t.id!==e),{id:e,level:Math.max(0,Math.min(2,t))}].slice(-100)}var $=Zt({data:null,connected:!1,error:``}),ua=e=>e==null?`Unavailable`:e.toLocaleString(`en-GB`),da=e=>!e||String(e).startsWith(`0001-`)?`Not yet available`:new Date(typeof e==`number`?e*1e3:e).toLocaleString(`en-GB`),fa=`codexometer.web.session`,pa=class extends Error{},ma;async function ha(e,t,n){if(!ma||!$.connected||!$.data?.control||$.data.sessionsError)throw Error(`Session controls unavailable. Check the live connection.`);return await ma(e,t,n)}function ga(){let e=new AbortController,t,n=``;ma=async(t,r,i)=>{let a=await fetch(`/api/control/`+t,{method:`POST`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`},body:JSON.stringify(r),signal:AbortSignal.any([e.signal,AbortSignal.timeout(8e3),...i?[i]:[]]),cache:`no-store`});if(!a.ok)throw a.status===502?Error(`Outcome uncertain. Check Codex before taking another action; nothing was retried.`):new pa(`Action rejected, expired or changed. Refresh and check Codex; nothing was retried.`);return a.json()};try{n=sessionStorage.getItem(fa)||``}catch{}let r=location.hash,i=r.startsWith(`#pair=`)?r.slice(6):``;(i||!r||r===`#`)&&(history.replaceState(null,``,`/#`+oa()),window.dispatchEvent(new HashChangeEvent(`hashchange`)));async function a(){if(i)try{let t=await fetch(`/api/pair`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({secret:i}),signal:e.signal});if(!t.ok)throw Error(`Pairing link expired or already used. Restart --web for a fresh link.`);n=(await t.json()).token;try{sessionStorage.setItem(fa,n)}catch{}}catch(t){e.signal.aborted||($.error=t instanceof Error?t.message:`Pairing failed`);return}if(!n){$.error=`Open the private pairing link printed by codexometer --web in your terminal.`;return}await o()}async function o(){try{let t=await fetch(`/api/events`,{headers:{Authorization:`Bearer ${n}`},signal:e.signal,cache:`no-store`});if(t.status===401){try{sessionStorage.removeItem(fa)}catch{}$.error=`Browser session expired. Restart --web and open its new pairing link.`;return}if(!t.ok||!t.body)throw Error(`Live connection unavailable`);let r=t.body.getReader(),i=new TextDecoder,a=``;for(;!e.signal.aborted;){let{done:e,value:t}=await r.read();if(e)break;a+=i.decode(t,{stream:!0});let n;for(;(n=a.indexOf(` - -`))>=0;){let e=a.slice(0,n);a=a.slice(n+2),e.startsWith(`data: `)&&($.data=JSON.parse(e.slice(6)),$.connected=!0,$.error=``)}}}catch{}finally{$.connected=!1}e.signal.aborted||($.error=`Connection lost — showing last observation. Reconnecting…`,t=setTimeout(o,2500))}return a(),()=>{ma=void 0,e.abort(),clearTimeout(t),$.connected=!1}}Ue();var _a=K(`

Quota refresh failed. Policy state is based on the last successful - observation.

`),va=K(`

`),ya=K(`

The longest Codex quota window selects one active model profile. ASK - creates a per-session review; AUTO applies the profile on the next - eligible check.

`,1),ba=K(`

No threshold-based model steps were configured at launch.

`);function xa(e,t){Ge(t,!1),Ri();var n=Fr(),r=R(n),i=e=>{var t=ya(),n=R(t),r=z(n),i=B(n,2),a=e=>{q(e,_a())};Y(i,e=>{$.data.quotaError&&e(a)});var o=B(i,2),s=L(o),c=z(s),l=B(s,4);Z(l,5,()=>$.data.thresholds,X,(e,t)=>{var n=va();let r;var i=L(n),a=z(i),o=B(i,2),s=L(o),c=z(s,!0),l=z(B(s,2));j(o);var u=B(o,2),d=z(u,!0),f=z(B(u,2));j(n),V((e,i)=>{r=ci(n,1,``,null,r,{active:W(t).state===`ACTIVE`,next:W(t).state===`NEXT`}),J(a,`${W(t).threshold??``}%`),J(c,W(t).model),J(l,`${e??``} REASONING // ${i??``} - SPEED`),J(d,W(t).mode),J(f,`${W(t).state??``}${W(t).state===`NEXT`?` // ${W(t).remaining||0} PP TO GO`:``}`)},[()=>W(t).effort.toUpperCase(),()=>W(t).speed.toUpperCase()]),q(e,n)}),j(l),j(o),V(e=>{J(r,`MODEL STEP POLICY // OBSERVED ${e??``}`),J(c,`THRESHOLDS // ${$.data.thresholds.length??``} CONFIGURED`)},[()=>da($.data.quotaAt)]),q(e,t)},a=e=>{q(e,ba())};Y(r,e=>{$.data?.thresholds?.length?e(i):e(a,-1)}),q(e,n),Ke()}var Sa=Nr(``),Ca=Nr(` `,1),wa=Nr(` `,1),Ta=Nr(`SAFE`),Ea=Nr(` `,1),Da=Nr(` `,1),Oa=K(`
`,1),ka=K(` `),Aa=K(`
Quota observations
Observed atPeriod elapsedConsumedTrail segment
`),ja=K(`
OBSERVATION DATA
`),Ma=K(`
QUOTA PERIOD ELAPSED
`,1);function Na(e,t){let n=Ir();Ge(t,!0);let r=Wi(t,`trail`,19,()=>[]),i=Wi(t,`paceView`,3,!1),a=F(!1),o=F(!0),s=F(`window`),c=[0,25,50,75,100],l={off:0,halfHour:30,hour:60,day:1440,window:0},u=N(()=>i()?[-100,-50,0,50,100]:c),d=N(()=>i()?-100:0),f=N(()=>i()?200:100),p=F(400),m=F(240),h=N(()=>W(p)-24),g=N(()=>W(m)-48),_=N(()=>Math.max(1,W(h)-48)),v=N(()=>Math.max(1,W(g)-20)),y=N(()=>48+Math.max(0,Math.min(100,t.elapsed))/100*W(_));function b(e){return W(g)-(e-W(d))/W(f)*W(v)}function x(e,t){return i()?e-t:e}let S=N(()=>b(x(t.used,t.elapsed))),C=N(()=>t.used-t.elapsed),w=N(()=>r().map((e,t)=>`${t===0||e.break?`M`:`L`}${48+e.elapsed/100*W(_)} ${b(x(e.used,e.elapsed))}`).join(` `)),T=N(()=>{let e=0;for(let t=r().length-1;t>0;t--)if(r()[t].break){e=t;break}return r().slice(e)}),ee=N(()=>W(T).length<2?0:Math.max(0,Date.parse(W(T).at(-1).at)-Date.parse(W(T)[0].at)));function te(e){if(W(ee)Date.parse(e.at)>=t).length>=2}let E=N(()=>({off:!0,halfHour:te(18e5),hour:te(36e5),day:te(864e5),window:Number.isFinite(t.elapsed)&&t.elapsed>0&&Number.isFinite(t.used)}));bn(()=>{W(s)!==`window`&&!W(E)[W(s)]&&I(s,`window`)});function D(e){if(e===`off`||!W(E)[e])return[];let t=l[e]*6e4,n=Date.parse(W(T).at(-1).at)-t,r=W(T).findIndex(e=>Date.parse(e.at)>=n);return r<0?[]:W(T).slice(r)}function ne(e){if(e.length<2)return null;let t=e.reduce((e,t)=>e+t.elapsed,0)/e.length,n=e.reduce((e,t)=>e+t.used,0)/e.length,r=0,i=0;for(let a of e)r+=(a.elapsed-t)*(a.used-n),i+=(a.elapsed-t)**2;return i>0?Math.max(0,r/i):null}let O=N(()=>{let e=W(s)===`window`&&W(E).window?t.used/t.elapsed:ne(D(W(s)));if(e===null||!t.duration)return null;let n=t.used+e*(100-t.elapsed),r=W(s)===`window`?0:t.used-e*t.elapsed,a=e-+!!i(),o=Math.max(0,t.elapsed-l[W(s)]/t.duration*100);W(s)===`window`&&(o=0);let c=100;if(a!==0){let e=(W(d)-r)/a,t=(W(d)+W(f)-r)/a;o=Math.max(o,Math.min(e,t)),c=Math.min(100,Math.max(e,t))}if(o>c)return null;let u=r+a*o,p=r+a*c,m=Math.hypot((c-o)/100*W(_),(p-u)/W(f)*W(v)),h=Math.max(3,Math.min(9,Math.floor(m/65)+2));return{path:`M${Array.from({length:h},(e,t)=>{let n=o+(c-o)*t/(h-1),r=u+(p-u)*t/(h-1);return`${48+n/100*W(_)} ${b(r)}`}).join(` L`)}`,projected:n,safe:n<=100}}),re=N(()=>{if(W(T).length===0)return`NO OBSERVATIONS`;if(W(T).length===1)return`ONE OBSERVATION`;let e=Math.floor(W(ee)/6e4);if(e<60)return`${e} MIN CONTINUOUS`;let t=Math.floor(e/60);return t<24?`${t}H CONTINUOUS`:`${Math.floor(t/24)}D ${t%24}H CONTINUOUS`});var ie=Ma(),ae=R(ie),oe=L(ae);let se;var ce=L(oe),le=L(ce),ue=B(L(le)),de=e=>{q(e,Sa())};Y(ue,e=>{i()&&e(de)});var fe=B(ue);we(),j(le);var pe=B(le);j(ce);var me=B(ce),he=B(me);Z(he,17,()=>c,X,(e,t)=>{var n=Ca(),r=R(n),i=B(r),a=z(i);V(()=>{Q(r,`x1`,48+W(t)/100*W(_)),Q(r,`x2`,48+W(t)/100*W(_)),Q(r,`y2`,W(g)),Q(i,`x`,48+W(t)/100*W(_)),Q(i,`y`,W(g)+20),J(a,`${W(t)??``}%`)}),q(e,n)});var ge=B(he);Z(ge,17,()=>W(u),X,(e,t)=>{var n=wa(),r=R(n),a=B(r),o=z(a,!0);V((e,n,s)=>{Q(r,`y1`,e),Q(r,`x2`,W(h)),Q(r,`y2`,n),Q(a,`y`,s),J(o,i()?`${W(t)>0?`+`:``}${W(t)}`:`${W(t)}%`)},[()=>b(W(t)),()=>b(W(t)),()=>b(W(t))+4]),q(e,n)});var _e=B(ge),ve=B(_e),ye=B(ve),be=e=>{var t=Ta();V(e=>{Q(t,`x`,W(h)-5),Q(t,`y`,e)},[()=>b(0)-6]),q(e,t)};Y(ye,e=>{i()&&e(be)});var k=B(ye),xe=e=>{var t=Ea(),n=R(t),i=B(n),a=B(i),o=z(L(a));j(a),V((e,t)=>{Q(n,`d`,W(w)),Q(i,`d`,W(w)),Q(a,`cx`,48+r()[0].elapsed/100*W(_)),Q(a,`cy`,e),J(o,`First observation: ${t??``}`)},[()=>b(x(r()[0].used,r()[0].elapsed)),()=>da(r()[0].at)]),q(e,t)};Y(k,e=>{W(o)&&r().length&&e(xe)});var A=B(k),Se=e=>{var t=Da(),r=R(t),i=B(r),a=z(L(i));j(i),V(e=>{Q(r,`d`,W(O).path),Q(i,`d`,W(O).path),Q(i,`marker-mid`,`url(#${n}-trend-arrow)`),J(a,`${W(s)===`window`?`Window-average pace`:`Recent consumption trajectory`} projects ${e??``}% at reset if continued`)},[()=>W(O).projected.toFixed(1)]),q(e,t)};Y(A,e=>{W(O)&&e(Se)});var Ce=B(A),Te=z(Ce,!0),Ee=B(Ce),De=B(Ee),Oe=B(De),ke=z(L(Oe));j(Oe),j(oe),j(ae);var Ae=B(ae,2),je=L(Ae),Me=L(je),Ne=e=>{var t=Pr();V(e=>J(t,`${W(C)>0?`+`:``}${e??``} PP FROM SAFETY`),[()=>W(C).toFixed(1)]),q(e,t)},Pe=e=>{var n=Pr();V(()=>J(n,`${t.used??``}% - USED`)),q(e,n)};Y(Me,e=>{i()?e(Ne):e(Pe,-1)});var Fe=B(Me),Ie=B(Fe,3),Le=z(Ie,!0),Re=B(Ie,2),ze=e=>{var t=Oa(),n=z(B(R(t)));V(e=>J(n,`TREND // ${e??``}`),[()=>i()?`${W(O).projected-100>0?`+`:``}${(W(O).projected-100).toFixed(1)} PP AT RESET`:W(O).projected>=100?`QUOTA EXHAUSTION PROJECTED`:`${W(O).projected.toFixed(1)}% PROJECTED AT RESET`]),q(e,t)};Y(Re,e=>{W(O)&&e(ze)}),j(je);var Be=B(je,2),Ve=L(Be),He=L(Ve);xi(He),we(),j(Ve);var Ue=B(Ve,2),M=B(L(Ue),2),We=L(M);We.value=We.__value=`off`;var qe=B(We),Je=z(qe);qe.value=qe.__value=`halfHour`;var Ye=B(qe),Xe=z(Ye);Ye.value=Ye.__value=`hour`;var Ze=B(Ye),Qe=z(Ze);Ze.value=Ze.__value=`day`;var $e=B(Ze),et=z($e);$e.value=$e.__value=`window`,j(M),mi(M),j(Ue);var tt=z(B(Ue,2));j(Be),j(Ae);var nt=B(Ae,2),rt=e=>{var t=ja(),n=B(L(t),2),i=e=>{var t=Aa(),n=L(t),i=B(L(n),2);Z(i,21,r,X,(e,t,n)=>{var r=ka(),i=L(r),a=L(i),o=z(a,!0);j(i);var s=B(i),c=z(s),l=B(s),u=z(l),d=z(B(l),!0);j(r),V((e,r)=>{Q(a,`datetime`,W(t).at),J(o,e),J(c,`${r??``}%`),J(u,`${W(t).used??``}%`),J(d,n===0?`First observation`:W(t).break?`Gap before this observation`:`Connected to previous observation`)},[()=>da(W(t).at),()=>W(t).elapsed.toFixed(1)]),q(e,r)}),j(i),j(n),j(t),q(e,t)};Y(n,e=>{W(a)&&e(i)}),j(t),Li(`open`,`toggle`,t,e=>I(a,e),()=>W(a)),q(e,t)};Y(nt,e=>{r().length&&e(rt)}),V((e,r,a,o,s,c,l)=>{Q(oe,`viewBox`,`0 0 ${W(p)} ${W(m)}`),Q(oe,`aria-label`,e),se=ui(oe,``,se,{"--trend-color":W(O)?.safe?`#115b35`:`#7f1825`}),Q(le,`id`,n),Q(le,`x2`,i()?`0%`:`100%`),Q(fe,`stop-color`,i()?`#ae903b`:`#8c793d`),Q(pe,`id`,n+`-trend-arrow`),Q(me,`width`,W(_)),Q(me,`height`,W(v)),Q(me,`fill`,`url(#${n})`),Q(_e,`d`,`M48 20 V${W(g)} H${W(h)}`),Q(ve,`y1`,r),Q(ve,`x2`,W(h)),Q(ve,`y2`,a),J(Te,i()?`DISTANCE FROM SAFETY (PP)`:`CONSUMPTION`),Q(Ee,`x`,48+W(_)/2),Q(Ee,`y`,W(m)-5),Q(De,`cx`,W(y)),Q(De,`cy`,W(S)),Q(Oe,`cx`,W(y)),Q(Oe,`cy`,W(S)),J(ke,`${t.used??``}% consumed // ${o??``}% of period elapsed${s??``}`),J(Fe,` // ${c??``}% TIME ELAPSED`),J(Le,l),qe.disabled=!W(E).halfHour,J(Je,`LAST 30 MINUTES${W(E).halfHour?``:` — UNAVAILABLE`}`),Ye.disabled=!W(E).hour,J(Xe,`LAST HOUR${W(E).hour?``:` — UNAVAILABLE`}`),Ze.disabled=!W(E).day,J(Qe,`LAST 24 HOURS${W(E).day?``:` — UNAVAILABLE`}`),$e.disabled=!W(E).window,J(et,`FROM WINDOW START${W(E).window?``:` — NO TIME ELAPSED`}`),J(tt,`HISTORY // ${W(re)??``}`)},[()=>`${i()?`Pace zone`:`Consumption zone`}: ${t.used}% consumed, ${t.elapsed.toFixed(1)}% of quota period elapsed. ${i()?`${W(C).toFixed(1)} percentage points from safety.`:`${W(C)>0?`Above`:W(C)<0?`Below`:`On`} the steady-consumption line.`}${W(o)&&r().length?` Trace path contains ${r().length} ${r().length===1?`observation`:`observations`}; gaps are not interpolated.`:``}`,()=>b(0),()=>i()?b(0):b(100),()=>t.elapsed.toFixed(1),()=>i()?` // ${W(C).toFixed(1)} PP from safety`:``,()=>t.elapsed.toFixed(1),()=>Math.abs(W(C))<.05?`ON PACE`:W(C)>0?i()?`ABOVE SAFETY — CONSUMPTION AHEAD OF TIME`:`ABOVE THE LINE — CONSUMING FASTER THAN TIME`:i()?`BELOW SAFETY — QUOTA HEADROOM`:`BELOW THE LINE — WITHIN PACE`]),Pi(ae,`clientWidth`,e=>I(p,e)),Pi(ae,`clientHeight`,e=>I(m,e)),ki(He,()=>W(o),e=>I(o,e)),hi(M,()=>W(s),e=>I(s,e)),q(e,ie),Ke()}var Pa=K(` `),Fa=K(`

Quota refresh failed. Values below are the last successful observation.

`),Ia=K(`

Expiry details unavailable. No listed expiry does not mean no expiry.

`),La=K(`

`),Ra=K(`

Read-only preview. Use the terminal to redeem a reset.

The backend may return only some credits. This list does not establish - redemption order.

`),za=K(` `,1),Ba=Nr(``),Va=Nr(``),Ha=K(`
`),Ua=K(`

Cycle duration or reset date unavailable — position cannot be - plotted.

`),Wa=K(`
EMPTYFULL
`),Ga=K(`

`,1),Ka=K(`
`,1),qa=K(`

`),Ja=K(`

`),Ya=K(`

No quota windows reported yet.

`),Xa=K(`
`,1),Za=K(`

All reported windows are shown. API-equivalent learning and quota status - scoring remain in the terminal for this first preview.

`,1),Qa=K(` `,1);function $a(e,t){Ge(t,!0);let n=Wi(t,`params`,19,()=>({})),r=N(()=>$i.filter(e=>e!==`thresholds`||!!$.data?.thresholds?.length)),i=F(Zt(Date.now())),a=N(()=>W(r).includes(n().view||``)?n().view:`bars`);Gi(()=>{let e=setInterval(()=>I(i,Date.now(),!0),1e3);return()=>clearInterval(e)});function o(e){return!e.duration||e.duration<=0||!e.reset?null:Math.max(0,Math.min(100,100*(1-(e.reset*1e3-W(i))/(e.duration*6e4))))}bn(()=>{ra.view=W(a)});function s(e){let t=e/100*Math.PI*2;return`M60 60 L60 14 A46 46 0 ${+(e>50)} 1 ${60+46*Math.sin(t)} ${60-46*Math.cos(t)} Z`}var c=Qa(),l=R(c);Z(l,21,()=>W(r),X,(e,t)=>{var n=Pa();let r;var i=z(n,!0);V(e=>{Q(n,`href`,`#/quota/`+W(t)),Q(n,`aria-current`,W(a)===W(t)?`page`:void 0),r=ci(n,1,``,null,r,{active:W(a)===W(t)}),J(i,e)},[()=>W(t)===`fuel`?`FUEL TANK`:W(t).toUpperCase()]),q(e,n)}),j(l);var u=B(l,2),d=e=>{var t=Za(),n=R(t),r=e=>{q(e,Fa())};Y(n,e=>{$.data.quotaError&&e(r)});var i=B(n,2),c=z(i),l=B(i,2),u=e=>{xa(e,{})},d=e=>{var t=Ra(),n=L(t),r=z(n),i=B(n,4),a=e=>{q(e,Ia())};Y(i,e=>{$.data.credits.length||e(a)}),Z(B(i,2),17,()=>$.data.credits,X,(e,t)=>{var n=La(),r=L(n),i=z(r),a=z(B(r,2),!0);j(n),V(e=>{J(i,`${(W(t).title||`Quota reset`)??``} // ${W(t).status??``}`),J(a,e)},[()=>W(t).expiryKnown?W(t).expires?`EXPIRES `+da(W(t).expires):`Does not expire`:`Expiry information unavailable`]),q(e,n)}),we(2),j(t),V(()=>J(r,`RESET INVENTORY // ${$.data.creditCount??``} AVAILABLE`)),q(e,t)},f=e=>{var t=Xa(),n=R(t);let r;Z(n,21,()=>$.data.meters,X,(e,t)=>{let n=N(()=>o(W(t)));var r=Ja(),i=L(r),c=z(i,!0),l=B(i,2),u=L(l),d=e=>{var n=za(),r=R(n),i=z(r),a=z(B(r));V(()=>{J(i,`FREE ${100-W(t).used}%`),J(a,`USED ${W(t).used??``}%`)}),q(e,n)},f=e=>{var n=za(),r=R(n),i=z(r),a=z(B(r));V(()=>{J(i,`USED ${W(t).used??``}%`),J(a,`FREE ${100-W(t).used}%`)}),q(e,n)};Y(u,e=>{W(a)===`fuel`?e(d):e(f,-1)}),j(l);var p=B(l,2);let m;var h=L(p),g=e=>{var n=Ha(),r=L(n),i=B(L(r)),a=e=>{q(e,Ba())},o=e=>{var n=Va();V(e=>Q(n,`d`,e),[()=>s(W(t).used)]),q(e,n)};Y(i,e=>{W(t).used>=100?e(a):W(t).used>0&&e(o,1)}),j(r),j(n),V(()=>Q(r,`aria-label`,`${W(t).used}% quota used`)),q(e,n)},_=e=>{var r=Fr(),i=R(r),o=e=>{{let r=N(()=>W(t).trail||[]),i=N(()=>W(a)===`pace`);Na(e,{get used(){return W(t).used},get elapsed(){return W(n)},get trail(){return W(r)},get duration(){return W(t).duration},get paceView(){return W(i)}})}},s=e=>{q(e,Ua())};Y(i,e=>{W(n)===null?e(s,-1):e(o)}),q(e,r)},v=e=>{var r=Ka(),i=R(r),o=L(i);let s;j(i);var c=B(i,2),l=e=>{q(e,Wa())};Y(c,e=>{W(a)===`fuel`&&e(l)});var u=B(c,2),d=e=>{var t=Ga(),r=R(t),i=z(r),o=B(r,2),s=L(o);let c;j(o),V(e=>{J(i,`RESET CYCLE // ${e??``}% ELAPSED`),c=ui(s,``,c,{width:`${W(a)===`fuel`?100-W(n):W(n)}%`})},[()=>Math.floor(W(n))]),q(e,t)};Y(u,e=>{W(n)!==null&&e(d)}),V(()=>{Q(i,`aria-label`,W(a)===`fuel`?`Fuel remaining`:`Quota used`),Q(i,`aria-valuenow`,W(a)===`fuel`?100-W(t).used:W(t).used),s=ui(o,``,s,{width:`${W(a)===`fuel`?100-W(t).used:W(t).used}%`})}),q(e,r)};Y(h,e=>{W(a)===`pie`?e(g):W(a)===`zone`||W(a)===`pace`?e(_,1):e(v,-1)}),j(p);var y=B(p,2),b=z(y),x=B(y,2),S=e=>{var n=qa(),r=z(n,!0);V(()=>J(r,W(t).details)),q(e,n)};Y(x,e=>{W(t).details&&e(S)}),j(r),V(e=>{J(c,W(t).name),m=ci(p,1,`meter-graphic`,null,m,{"bar-graphic":W(a)===`bars`||W(a)===`fuel`}),J(b,`RESETS // ${e??``}`)},[()=>da(W(t).reset)]),q(e,r)}),j(n);var i=B(n,2),c=e=>{q(e,Ya())};Y(i,e=>{$.data.meters.length||e(c)}),V(()=>r=ci(n,1,`quota-grid`,null,r,{radial:W(a)===`pie`,zone:W(a)===`zone`||W(a)===`pace`})),q(e,t)};Y(l,e=>{W(a)===`thresholds`?e(u):W(a)===`resets`?e(d,1):e(f,-1)}),we(2),V(e=>J(c,`QUOTA // OBSERVED ${e??``}`),[()=>da($.data.quotaAt)]),q(e,t)};Y(u,e=>{$.data&&e(d)}),q(e,c),Ke()}var eo=K(`
`),to=K(`

`,1);function no(e,t){Ge(t,!0);let n=Wi(t,`values`,19,()=>[]),r=Wi(t,`label`,3,`Token activity`),i=Wi(t,`capacity`,3,0),a=N(()=>Math.max(0,...n())),o=N(()=>i()>n().length?[...Array(i()-n().length).fill(0),...n()]:n());var s=to(),c=R(s),l=z(c),u=B(c,2);Z(u,21,()=>W(o),X,(e,t)=>{var n=eo();let r;V((e,t)=>{Q(n,`title`,e),r=ui(n,``,r,{height:t})},[()=>W(t).toLocaleString(`en-GB`)+` tokens`,()=>`${100*W(t)/Math.max(1,W(a))}%`]),q(e,n)}),j(u),V((e,t)=>{J(l,`SCALE // 0 — ${e??``} TOKENS`),Q(u,`aria-label`,t)},[()=>W(a).toLocaleString(`en-GB`),()=>`${r()}. Peak ${W(a).toLocaleString(`en-GB`)} tokens.`]),q(e,s),Ke()}var ro=K(`

`),io=K(`

`,1),ao=K(`

`),oo=K(`

Loading / sending…

`),so=K(`

Confirmation expired. Reopen the option.

`),co=K(`

`,1),lo=K(`

 
`,1),uo=K(` `),fo=K(``),po=K(`

No available matching commands.

`),mo=K(`

↑/↓ select · Tab complete · Enter options · Escape dismiss

`),ho=K(`
`,1),go=K(` `,1),_o=K(`
`),vo=K(`
`);function yo(e,t){Ge(t,!0);let n=Wi(t,`query`,3,``),r=Wi(t,`onchange`,3,()=>{}),i=Wi(t,`oncomplete`,3,e=>{}),a=F(!1),o=F(!1),s=F(``),c=F(null),l=F(null),u=F(``),d=F(0),f=F(Zt(Date.now())),p=0,m=F(0),h=F(null),g=F(void 0),_=setInterval(()=>{I(f,Date.now(),!0)},1e3);Ki(()=>{clearInterval(_),p++});let v=N(()=>n().trim().startsWith(`/`)&&!n().trim().startsWith(`//`)),y=N(()=>W(c)?.path===``&&W(v)?n().trim().slice(1).toLowerCase():``),b=N(()=>(W(c)?.choices||[]).filter(e=>!W(y)||e.label.toLowerCase().startsWith(`/`+W(y)))),x=N(()=>!$.connected||!!$.data?.sessionsError),S=N(()=>W(a)&&W(v)&&(!W(c)||W(c).path===``)&&!W(l));bn(()=>{n(),I(m,0)}),bn(()=>{let e=W(m);W(b),W(S)&&dr().then(()=>{let t=W(g)?.children[e];if(!t||!W(g))return;let n=W(g).getBoundingClientRect(),r=t.getBoundingClientRect();r.topn.bottom&&(W(g).scrollTop+=r.bottom-n.bottom)})});function C(e){if(!W(v)||!W(a)||W(c)&&W(c).path!==``||W(l)||W(x)||e.isComposing||e.ctrlKey||e.metaKey||e.altKey||![`ArrowUp`,`ArrowDown`,`Tab`,`Enter`,`Escape`].includes(e.key)||e.key===`Tab`&&e.shiftKey)return;if(e.preventDefault(),e.key===`Escape`){I(a,!1),I(h,n()),I(u,``);return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){I(m,Math.min(Math.max(W(m)+(e.key===`ArrowUp`?-1:1),0),Math.max(W(b).length-1,0)),!0);return}let t=W(b)[W(m)];t&&!W(o)&&(e.key===`Tab`?i()(t.label):T(t))}bn(()=>{W(x)&&(p++,I(o,!1),I(u,``),W(a)&&(I(a,!1),I(h,n())),I(c,null),I(l,null))}),bn(()=>{W(v)&&!W(a)&&n()!==W(h)&&!W(x)&&(I(a,!0),w(``))});async function w(e){let n=++p;I(o,!0),I(l,null),I(u,``),I(s,``);try{let r=await ha(`commands`,{session:t.session,command:{mode:`list`,path:e}});n===p&&((e===``||e===`help`)&&r.choices.push({id:`local-statusline`,label:`/statusline`,help:`Choose multiple fields for Codexometer’s detail footer.`,next:`statusline`}),I(c,r,!0))}catch{n===p&&(I(s,`Command catalogue unavailable. Use Codex.`),(e===``||e===`help`)&&I(c,{title:`/ COMMANDS`,help:`Local display settings remain available.`,path:``,revision:``,choices:[{id:`local-statusline`,label:`/statusline`,help:`Choose multiple fields for Codexometer’s detail footer.`,next:`statusline`}]},!0))}finally{n===p&&I(o,!1)}}async function T(e){if(e.next===`statusline`){ia.open=!0,I(a,!1),I(h,n());return}if(e.next){await w(e.next);return}if(I(l,e,!0),I(u,``),I(s,``),!e.action||!W(c))return;let r=++p;I(o,!0);try{let n=await ha(`commands`,{session:t.session,command:{mode:`prepare`,path:W(c).path,revision:W(c).revision,choice:e.id}});r===p&&(I(u,n.confirmation,!0),I(d,Date.parse(n.expires),!0))}catch{r===p&&I(s,`Option changed or unavailable. Refresh before retrying.`)}finally{r===p&&I(o,!1)}}async function ee(){if(!W(u)||W(x)||W(o)||W(f)>=W(d)||!W(c))return;let e=W(u);I(u,``),I(o,!0);let n=++p;try{let i=await ha(`commands`,{session:t.session,confirmation:e,command:{mode:`commit`,path:W(c).path}});n===p&&(I(s,i.message,!0),I(a,!1),I(c,null),I(l,null),I(d,0),I(h,null),r()())}catch{n===p&&I(s,`Change unconfirmed. Check Codex before retrying.`)}finally{n===p&&I(o,!1)}}var te={handleKey:C},E=vo(),D=L(E),ne=B(D,2),O=e=>{var t=ro(),n=z(t,!0);V(()=>J(n,W(s))),q(e,t)};Y(ne,e=>{W(s)&&!W(a)&&e(O)});var re=B(ne,2),ie=e=>{var n=_o();let r;var i=L(n),a=e=>{var t=io(),n=R(t),r=z(n,!0),i=z(B(n,2),!0);V(()=>{J(r,W(c)?.title||`/ COMMANDS`),J(i,W(c)?.help||`Loading live options…`)}),q(e,t)};Y(i,e=>{W(S)||e(a)});var p=B(i,2),h=e=>{var t=ao(),n=z(t,!0);V(()=>J(n,W(s))),q(e,t)};Y(p,e=>{W(s)&&e(h)});var _=B(p,2),y=e=>{q(e,oo())};Y(_,e=>{W(o)&&e(y)});var C=B(_,2),te=e=>{var n=lo(),r=R(n),i=z(r,!0),a=B(r,2),s=z(a,!0),c=B(a,2),p=e=>{var n=co(),r=R(n),i=z(r),a=B(r,2),s=B(a,2),c=e=>{q(e,so())};Y(s,e=>{W(u)&&W(f)>=W(d)&&e(c)}),V(()=>{J(i,`TARGET // ${t.session??``}. Changes affect subsequent turns of this - session, not global defaults. Automatic quota thresholds may later - supersede model settings.`),a.disabled=W(o)||W(x)||!W(u)||W(f)>=W(d)}),G(`click`,a,ee),q(e,n)};Y(c,e=>{W(l).action&&e(p)});var m=B(c,2);V(()=>{J(i,W(l).label),J(s,W(l).help||`No additional help supplied by Codex.`),m.disabled=W(o)}),G(`click`,m,()=>{I(l,null),I(u,``)}),q(e,n)},E=e=>{var t=ho(),n=R(t);let r;Z(n,23,()=>W(b),e=>e.id,(e,t,n)=>{var r=fo();let i;var a=L(r),s=z(a,!0),l=B(a),u=z(l,!0),d=B(l),f=e=>{var n=uo(),r=z(n,!0);V(()=>J(r,W(t).help)),q(e,n)};Y(d,e=>{W(v)&&W(c)?.path===``&&e(f)}),j(r),V(()=>{r.disabled=W(o)||W(x),Q(r,`title`,W(t).help),Q(r,`aria-label`,W(t).label+(W(t).next?` →`:W(t).action?``:` // HELP`)),i=ci(r,1,`svelte-7bfwr9`,null,i,{suggested:W(v)&&W(c)?.path===``&&W(m)===W(n)}),J(s,W(t).label),J(u,W(t).next?` →`:W(t).action?``:` // HELP`)}),G(`click`,r,()=>T(W(t))),q(e,r)}),j(n),Ii(n,e=>I(g,e),()=>W(g));var i=B(n,2),a=e=>{q(e,po())};Y(i,e=>{!W(o)&&!W(b).length&&e(a)});var s=B(i,2),l=e=>{q(e,mo())};Y(s,e=>{W(v)&&W(c)?.path===``&&e(l)}),V(()=>r=ci(n,1,`command-options svelte-7bfwr9`,null,r,{vertical:W(S)})),q(e,t)};Y(C,e=>{W(l)?e(te):e(E,-1)});var D=B(C,2),ne=e=>{var t=go(),n=R(t),r=B(n,2);V(()=>{n.disabled=W(o),r.disabled=W(o)}),G(`click`,n,()=>w(``)),G(`click`,r,()=>w(W(c)?.path||``)),q(e,t)};Y(D,e=>{W(S)||e(ne)}),j(n),V(()=>{Q(n,`aria-label`,W(S)?`Slash command suggestions`:void 0),r=ci(n,1,`svelte-7bfwr9`,null,r,{"command-popup":W(S)})}),q(e,n)};return Y(re,e=>{W(a)&&e(ie)}),j(E),V(()=>D.disabled=W(x)||W(o)),G(`click`,D,()=>{I(a,!W(a)),I(h,W(a)?null:n(),!0),I(u,``),W(a)&&w(``)}),q(e,E),Ke(te)}wr([`click`]);var bo=K(` `,1),xo=K(`
`),So=K(`
/
`);function Co(e,t){Ge(t,!0);let n=N(()=>t.lines.filter(e=>e.kind===`addition`).length),r=N(()=>t.lines.filter(e=>e.kind===`removal`).length);var i=So(),a=L(i),o=L(a),s=z(o),c=z(B(o,2));j(a),Z(B(a,2),17,()=>t.lines,X,(e,t)=>{var n=xo();let r;var i=L(n),a=e=>{var n=bo(),r=R(n),i=z(r,!0),a=z(B(r),!0);V(()=>{J(i,W(t).old||``),J(a,W(t).new||``)}),q(e,n)};Y(i,e=>{W(t).kind!==`heading`&&W(t).kind!==`metadata`&&e(a)});var o=z(B(i),!0);j(n),V(()=>{r=ci(n,1,`diff-line svelte-x4gtb6`,null,r,{added:W(t).kind===`addition`,removed:W(t).kind===`removal`,heading:W(t).kind===`heading`}),J(o,W(t).text)}),q(e,n)}),j(i),V(()=>{Q(a,`aria-label`,`${W(n)} lines added, ${W(r)} lines removed`),J(s,`+${W(n)??``}`),J(c,`−${W(r)??``}`)}),q(e,i),Ke()}var wo=K(`

`),To=K(`

Send this saved prompt now? This starts Codex work and consumes quota.

`,1),Eo=K(``),Do=K(`

 

In memory only. Follows session model, reasoning and speed. Closing - Codexometer cancels pending work.

`),Oo=K(`

CURRENT PROFILE

MODEL / REASONING LEVEL / SPEED

 

PROPOSED PROFILE

MODEL / REASONING LEVEL / SPEED

 

Applied settings remain after Codexometer closes.

`,1),ko=K(`

`),Ao=K(`

 
`,1),jo=K(`

Command unavailable from this observation. Open Codex to inspect the - request.

`),Mo=K(`

Session controls temporarily unavailable. Check Codex for current state.

`),No=K(`

Checking session controls…

`),Po=K(`

`),Fo=K(`
About browser controls

Controls require a supported live request from a connected shared - app-server session. Local observations alone cannot provide them.

`),Io=K(` `,1),Lo=K(` `),Ro=K(`Grants permission beyond this one action. Check the scope - carefully.`),zo=K(``),Bo=K(``),Vo=K(``),Ho=K(``),Uo=K(`

Not before this time; when quota and idle allow.

`),Wo=K(`

`,1),Go=K(`

The existing trigger remains active until saved or deleted. If - it changes or sends while you edit, saving is blocked.

`),Ko=K(` `,1),qo=K(``),Jo=K(``),Yo=K(``),Xo=K(` `,1),Zo=K(`
  • `),Qo=K(`
    View fixed choices

    Type one of these choices exactly. Your answer stays masked.

      `),$o=K(` `,1),es=K(`

      `),ts=K(`

      `,1),ns=K(` `,1),rs=K(``),is=K(`

      `,1),as=K(`

      `);function os(e,t){Ge(t,!0);let n=[],r=Wi(t,`observedCommand`,3,``),i=Wi(t,`observedFileChanges`,19,()=>[]),a=Wi(t,`review`,3,``),o=Wi(t,`suspended`,3,!1),s=Wi(t,`openScheduler`,3,!1),c=Wi(t,`onProtectedChange`,3,e=>{}),l=F(null),u=F(Zt([])),d=F(null),f=F(``),p=F(0),m=F(Zt(Date.now())),h=F(!1),g=F(``),_=F(!1),v=F(!1),y=F(``),b=F(!1),x=F(``),S=F(!1),C=F(``),w=F(`now`),T=F(60),ee=F(``),te=F(!1),E=F(``),D=F(Zt([])),ne=N(()=>W(D).find(e=>e.status!==`sent`)),O=F(void 0),re=F(void 0);function ie(e){if(W(b)){dr().then(()=>W(O)?.focus());return}if(e.status!==`pending`||W(h)||!W(l)?.id||W(l).kind!==`prompt`||W(l).questions?.length)return;I(b,!0),I(x,e.id,!0),dr().then(()=>W(O)?.focus()),I(u,[e.text],!0),I(w,e.trigger===`quota`?`quota`:`at`,!0),I(f,``),I(C,``);let t=new Date(e.at);e.trigger!==`quota`&&I(ee,new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,16),!0)}bn(()=>{s()&&W(ne)&&!W(S)&&W(l)?.id&&W(l).kind===`prompt`&&!W(l).questions?.length&&(I(S,!0),ie(W(ne)))});async function ae(){if(!a())try{I(D,await ha(`schedules`,{session:t.session},be.signal),!0),W(b)&&!W(D).some(e=>e.id===W(x)&&e.status===`pending`)&&I(f,``),W(C)&&!W(D).some(e=>e.id===W(C)&&e.status===`pending`)&&(I(f,``),I(C,``))}catch{}}async function oe(e){try{I(D,await ha(`schedules`,{session:t.session,cancelId:e},be.signal),!0),I(b,!1),I(f,``),I(C,``),I(u,[],!0)}catch(e){I(g,e instanceof Error?e.message:`Unable to cancel trigger.`,!0)}}bn(()=>(c()(W(h)||W(u).some(e=>e.length>0)),()=>c()(!1)));let se=N(()=>$.data?.sessions.find(e=>e.id===t.session)?.status),ce=N(()=>!$.connected||!!$.data?.sessionsError),le=N(()=>a()!==`profile`&&W(l)?.kind===`prompt`&&!W(l).questions?.length&&!!$.data?.profiles?.some(e=>e.session===t.session&&e.pending)),ue=N(()=>!W(ce)&&!W(v)&&!!W(l)?.id&&W(l).kind===`approval`&&W(y)!==W(l).id),de=N(()=>W(ue)?W(l).command:r()),fe=N(()=>!!W(f)&&W(m)W(l)?.questions?.length?W(l).questions:[{text:`Follow-up message`,secret:!1,freeText:!0,options:[]}]),me=N(()=>W(l)?.kind===`approval`||W(l)?.kind===`profile`?W(d)!==null:W(u).length===W(pe).length&&W(u).every((e,t)=>e.trim().length>0&&(W(pe)[t].freeText||W(pe)[t].options?.includes(e)))),he=N(()=>W(l)?.kind===`prompt`&&!W(l).questions?.length&&W(w)!==`now`),ge=N(()=>W(w)===`delay`?W(m)+W(T)*6e4:Date.parse(W(ee))),_e=N(()=>{if(!W(he))return``;if(W(b)&&!W(D).some(e=>e.id===W(x)&&e.status===`pending`))return`Trigger changed, removed or already sent. Go back and reopen it; your draft has not been saved.`;if(!W(u)[0]?.trim())return`Enter a message to schedule.`;if(W(w)===`quota`)return``;if(!Number.isFinite(W(ge))||W(ge)<=W(m))return`Choose a future date/time or a delay greater than zero.`;let e=new Date(W(m));return e.setFullYear(e.getFullYear()+1),W(ge)>=e.getTime()?`Choose a time within one year.`:``});function ve(e){return new Date(e).toLocaleString([],{timeZoneName:`short`})}function ye(e){if(e.status!==`pending`)return e.status;if(e.trigger===`at`&&Date.parse(e.at)>W(m))return`Due in `+Math.ceil((Date.parse(e.at)-W(m))/6e4)+` min`;let t=W(ce)?`waiting for a fresh connection`:e.waitingReason||(e.canSend?`ready; awaiting dispatch`:`waiting for quota and an eligible idle session`);return(e.trigger===`at`?`Time reached — `:``)+t}bn(()=>{(W(ce)||o()||W(le)||W(m)>=W(p))&&I(f,``)});let be=new AbortController;Gi(()=>{let e=e=>{e.ctrlKey&&e.key.toLowerCase()===`s`&&!a()&&W(ne)&&(e.preventDefault(),ie(W(ne)))};window.addEventListener(`keydown`,e);let n,r=setInterval(()=>{I(m,Date.now(),!0)},1e3);async function i(){await ae();try{let e=await ha(`offer`,{session:t.session,...a()?{review:a()}:{}},be.signal);if(be.signal.aborted)return;I(v,!1),W(l)?.id!==e.id&&(I(f,``),I(d,null),I(u,Array(Math.max(1,e.questions?.length||0)).fill(``),!0)),I(l,e,!0),W(_)&&e.id&&e.id!==W(y)&&(I(g,``),I(_,!1))}catch{be.signal.aborted||(I(l,null),I(v,!0),I(f,``))}finally{be.signal.aborted||(n=setTimeout(i,2e3))}}return i(),()=>{window.removeEventListener(`keydown`,e),be.abort(),clearTimeout(n),clearInterval(r)}});async function k(e){if(!e&&W(l)?.kind===`prompt`&&!W(l).questions?.length&&W(u)[0]?.trim().startsWith(`/`)&&!W(u)[0]?.trim().startsWith(`//`)){I(g,`Choose a slash command from COMMANDS; use // for literal slash text.`);return}if(!W(l)?.id||W(h)||W(ce)||o()||W(le)||(e?!e.canSend:!W(me)||W(_e)))return;let n=W(l).id;I(h,!0),I(g,``),I(_,!1),I(f,``),I(C,e?.id||``,!0);try{let r=!e&&W(l).kind===`prompt`&&!W(l).questions?.length&&W(w)!==`now`?{trigger:W(w)===`quota`?`quota`:`at`,zone:Intl.DateTimeFormat().resolvedOptions().timeZone,...W(w)===`quota`?{}:{at:(W(w)===`delay`?new Date(Date.now()+W(T)*6e4):new Date(W(ee))).toISOString()}}:void 0;I(te,!!r),I(E,r?r.trigger===`quota`?`After fresh quota becomes available, when the session is idle`:ve(r.at)+` — not before this time; when quota and idle allow`:``,!0);let i=await ha(`prepare`,{session:t.session,...a()?{review:a()}:{},offer:n,...e?{sendId:e.id}:{},...r?{schedule:r}:{},...r&&W(b)?{editId:W(x)}:{},...W(l).kind===`approval`||W(l).kind===`profile`?{choice:W(d)}:{answers:e?[e.text]:[...W(u)]}},be.signal);W(l)?.id===n&&!be.signal.aborted&&!W(ce)&&!o()&&!W(le)&&(I(f,i.confirmation,!0),I(p,Date.parse(i.expires),!0))}catch(e){be.signal.aborted||I(g,e instanceof Error?e.message:`Unable to prepare action.`,!0)}finally{I(h,!1)}}async function xe(){if(!W(l)?.id||W(h)||o()||W(le)||!W(fe))return;let e=W(l).id,n=W(l).kind,r=W(f);I(f,``),I(h,!0),I(y,e,!0);try{await ha(`commit`,{session:t.session,...a()?{review:a()}:{},offer:e,confirmation:r},be.signal),I(_,!0),I(b,!1),W(te)&&(I(y,``),await ae()),I(g,W(te)?`Trigger set. Closing Codexometer cancels it.`:n===`profile`?`Profile decision completed.`:n===`approval`?`Decision sent.`:`Text sent.`,!0)}catch(e){I(g,e instanceof pa?e.message:`Outcome uncertain. Check Codex before taking another action; nothing was retried.`,!0)}finally{I(h,!1),I(C,``),await ae(),I(u,[],!0),I(d,null)}}var A=Io(),Se=R(A),Ce=e=>{var t=Fr();Z(R(t),17,()=>W(D).filter(e=>e.status!==`sent`),e=>e.id,(e,t)=>{var n=Do(),r=L(n),i=z(r,!0),a=B(r,2),s=z(a),c=B(a,2),u=z(c,!0),d=B(c,2),p=z(d,!0),m=B(d,2),_=z(m,!0),v=B(m,2),y=e=>{var t=wo(),n=z(t,!0);V(()=>J(n,W(g))),q(e,t)};Y(v,e=>{W(g)&&e(y)});var b=B(v,4),x=B(b,2),S=B(x,2),w=e=>{var n=To(),r=B(R(n),2),i=B(r,2);V(()=>r.disabled=W(h)||W(ce)||!W(t).canSend),G(`click`,r,xe),G(`click`,i,()=>{I(f,``),I(C,``)}),q(e,n)},T=e=>{var n=Eo();V(()=>n.disabled=W(h)||W(ce)||!W(t).canSend||o()),G(`click`,n,()=>k(W(t))),q(e,n)};Y(S,e=>{W(fe)&&W(C)===W(t).id?e(w):e(T,-1)}),j(n),V((e,n)=>{J(i,W(t).status===`uncertain`?`CHECK TRIGGER — outcome uncertain; not retried`:`SCHEDULED FOLLOW-UP`),J(s,`TARGET // ${W(t).session??``}`),J(u,e),J(p,n),J(_,W(t).text),b.disabled=W(h)||!W(l)?.id||W(l).kind!==`prompt`||!!W(l).questions?.length||W(t).status!==`pending`,x.disabled=W(h)||W(t).status===`sending`},[()=>W(t).trigger===`quota`?`After confirmed quota recovery, when idle`:`Not before ${ve(W(t).at)}`,()=>ye(W(t))]),G(`click`,b,()=>ie(W(t))),G(`click`,x,()=>oe(W(t).id)),q(e,n)}),q(e,t)},Te=N(()=>!a()&&W(l)?.kind!==`approval`&&!W(l)?.questions?.length&&![`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(se)||``));Y(Se,e=>{W(Te)&&e(Ce)});var Ee=B(Se,2),De=e=>{var r=as(),o=L(r),s=z(o,!0),c=B(o,2),x=e=>{var t=Oo(),n=R(t),r=z(n),i=B(n,6),a=z(i,!0),o=z(B(i,6),!0);we(2),V(()=>{J(r,`Your ${W(l).profile.threshold??``}% quota threshold has been reached. Review - the profile for subsequent turns.`),J(a,W(l).profile.current),J(o,W(l).profile.proposed)}),q(e,t)};Y(c,e=>{W(l)?.profile&&!W(ce)&&!W(v)&&e(x)});var S=B(c,2),C=e=>{var t=ko();let n;var r=z(t,!0);V(()=>{n=ci(t,1,`svelte-1oupzfc`,null,n,{notice:!W(_),sent:W(_)}),J(r,W(g))}),q(e,t)};Y(S,e=>{W(g)&&e(C)});var D=B(S,2),ne=e=>{Co(e,{get lines(){return W(l).fileChanges}})},ie=e=>{Co(e,{get lines(){return i()}})},ae=e=>{var t=Ao(),n=R(t),r=z(n,!0),i=z(B(n,2),!0);V(()=>{J(r,W(ue)?`EXACT COMMAND`:`LAST OBSERVED COMMAND`),J(i,W(de))}),q(e,t)},oe=e=>{q(e,jo())};Y(D,e=>{W(l)?.fileChanges?.length&&!W(ce)&&!W(v)?e(ne):i().length?e(ie,1):W(de)?e(ae,2):a()!==`profile`&&W(se)===`APPROVAL NEEDED`&&!W(_)&&e(oe,3)});var le=B(D,2),he=e=>{q(e,Mo())},ye=e=>{q(e,No())},be=e=>{var t=Io(),n=R(t),r=e=>{var t=Po(),n=z(t,!0);V(e=>J(n,e),[()=>W(se)===`WORKING`?`Codex is working — nothing to respond to.`:[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(se)||``)?`Respond in Codex for this request.`:`Nothing needs a response right now.`]),q(e,t)};Y(n,e=>{(W(se)===`WORKING`||!W(_)&&!W(h))&&e(r)});var i=B(n,2),a=e=>{q(e,Fo())},o=N(()=>[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(W(se)||``)&&!W(_));Y(i,e=>{W(o)&&e(a)}),q(e,t)},A=e=>{var r=is(),i=R(r),o=z(i),s=B(i,2),c=L(s),g=z(c,!0),_=B(c,2),v=e=>{var r=Fr();Z(R(r),17,()=>W(l).choices||[],X,(e,r,i)=>{var o=zo(),s=L(o);xi(s),s.value=s.__value=i;var c=B(s),l=B(c),u=e=>{var t=Lo(),n=z(t,!0);V(()=>J(n,W(r).detail)),q(e,t)};Y(l,e=>{W(r).detail&&e(u)});var f=B(l,2),p=e=>{q(e,Ro())};Y(f,e=>{W(r).persistent&&e(p)}),j(o),V(()=>{Q(s,`name`,`decision-`+t.session+`-`+a()),J(c,` ${W(r).label??``} `)}),Oi(n,[],s,()=>W(d),e=>I(d,e)),q(e,o)}),q(e,r)},y=e=>{var n=Io(),r=R(n),i=e=>{var t=Ko(),n=R(t),r=B(L(n)),i=L(r),a=e=>{var t=Bo();t.value=t.__value=`now`,q(e,t)};Y(i,e=>{W(b)||e(a)});var o=B(i);o.value=o.__value=`quota`;var s=B(o);s.value=s.__value=`delay`;var c=B(s);c.value=c.__value=`at`,j(r),mi(r),j(n);var l=B(n,2),u=e=>{var t=Vo(),n=B(L(t));xi(n),j(t),Ei(n,()=>W(T),e=>I(T,e)),q(e,t)};Y(l,e=>{W(w)===`delay`&&e(u)});var d=B(l,2),f=e=>{var t=Ho(),n=B(L(t));xi(n),j(t),Ei(n,()=>W(ee),e=>I(ee,e)),q(e,t)};Y(d,e=>{W(w)===`at`&&e(f)});var p=B(d,2),m=e=>{var t=Wo(),n=R(t),r=z(n),i=B(n,2),a=e=>{q(e,Uo())};Y(i,e=>{W(w)!==`quota`&&e(a)});var o=B(i,2);o.textContent=`Timezone: ${Intl.DateTimeFormat().resolvedOptions().timeZone??``}. - One pending request per session; saving replaces it. Memory - only; Codexometer must stay running. Uses session model, - reasoning and speed.`,V(e=>J(r,`Will send: ${e??``}`),[()=>W(w)===`quota`?`when quota is available and this session is idle`:Number.isFinite(W(ge))?ve(W(ge)):`choose a date and time`]),q(e,t)};Y(p,e=>{W(w)!==`now`&&e(m)});var h=B(p,2),g=e=>{q(e,Go())};Y(h,e=>{W(b)&&e(g)}),hi(r,()=>W(w),e=>I(w,e)),q(e,t)};Y(r,e=>{W(l).questions?.length||e(i)}),Z(B(r,2),17,()=>W(pe),X,(e,n,r)=>{var i=$o(),o=R(i),s=e=>{{let n=N(()=>W(u)[0]||``);Ii(yo(e,{get session(){return t.session},get query(){return W(n)},oncomplete:e=>{I(u,[e],!0),dr().then(()=>W(O)?.focus())},onchange:()=>{I(u,[``],!0),dr().then(()=>W(O)?.focus())}}),e=>I(re,e,!0),()=>W(re))}};Y(o,e=>{r===0&&a()!==`profile`&&W(l).kind===`prompt`&&!W(l).questions?.length&&e(s)});var c=B(o,2),d=L(c),f=B(d),p=e=>{var t=qo();xi(t),Ei(t,()=>W(u)[r],e=>W(u)[r]=e),q(e,t)},m=e=>{var t=Yo(),i=L(t);i.value=i.__value=``,Z(B(i),17,()=>W(n).options||[],X,(e,t)=>{var n=Jo(),r=z(n,!0),i={};V(()=>{J(r,W(t)),i!==(i=W(t))&&(n.value=(n.__value=i)??``)}),q(e,n)}),j(t),mi(t),hi(t,()=>W(u)[r],e=>W(u)[r]=e),q(e,t)},h=e=>{var t=Xo(),i=R(t);rt(i),Ii(i,e=>I(O,e),()=>W(O));var a=B(i,2),o=e=>{var t=Po(),r=z(t);V(e=>J(r,`Suggested answers: ${e??``}`),[()=>W(n).options.join(` · `)]),q(e,t)};Y(a,e=>{W(n).options?.length&&e(o)}),G(`keydown`,i,e=>{W(l)?.kind===`prompt`&&!W(l).questions?.length&&W(re)?.handleKey(e)}),Ei(i,()=>W(u)[r],e=>W(u)[r]=e),q(e,t)};Y(f,e=>{W(n).secret?e(p):W(n).freeText?e(h,-1):e(m,1)}),j(c);var g=B(c,2),_=e=>{var t=Qo(),r=B(L(t),4);Z(r,21,()=>W(n).options||[],X,(e,t)=>{var n=Zo(),r=z(n,!0);V(()=>J(r,W(t))),q(e,n)}),j(r),j(t),q(e,t)};Y(g,e=>{W(n).secret&&!W(n).freeText&&e(_)}),V(()=>J(d,`${W(n).text??``} `)),q(e,i)}),q(e,n)};Y(_,e=>{W(l).kind===`approval`||W(l).kind===`profile`?e(v):e(y,-1)}),j(s);var x=B(s,2),S=e=>{var t=ts(),n=R(t),r=e=>{var t=es(),n=z(t);V(()=>J(n,`TRIGGER // ${W(E)??``}`)),q(e,t)};Y(n,e=>{W(te)&&e(r)});var i=B(n,2),a=z(i),o=B(i,2),s=z(o),c=B(o,2);V(e=>{J(a,`Check the target and ${W(l).kind===`profile`?`profile above`:W(l).kind===`approval`?W(l).fileChanges?.length?`proposed file changes above`:`exact command and permission scope`:`message above`}. ${W(te)?`This schedules a follow-up that will send automatically when eligible`:`This will send to Codex`}; it may start work using your quota. - Confirmation expires in ${e??``}s.`),o.disabled=W(h)||W(ce),J(s,`CONFIRM ${(W(l).kind===`approval`||W(l).kind===`profile`?W(l).choices?.[W(d)]?.label:W(te)?W(b)?`SAVE CHANGES`:`SCHEDULE`:`SEND`)??``}`)},[()=>Math.max(0,Math.ceil((W(p)-W(m))/1e3))]),G(`click`,o,xe),G(`click`,c,()=>{I(f,``)}),q(e,t)},C=e=>{var t=ns(),n=R(t),r=e=>{var t=wo(),n=z(t,!0);V(()=>J(n,W(_e))),q(e,t)};Y(n,e=>{W(_e)&&e(r)});var i=B(n,2),a=z(i,!0);V(()=>{i.disabled=W(h)||W(ce)||!W(me)||!!W(_e),J(a,W(h)?`SENDING…`:W(b)?`REVIEW CHANGES`:`REVIEW BEFORE SENDING`)}),G(`click`,i,()=>k()),q(e,t)};Y(x,e=>{W(fe)?e(S):e(C,-1)});var D=B(x,2),ne=e=>{var t=rs();G(`click`,t,()=>{I(b,!1),I(f,``),I(u,[],!0)}),q(e,t)};Y(D,e=>{W(b)&&e(ne)}),V(()=>{J(o,`TARGET // ${W(l).thread??``} // ${(W(l).directory||`Directory unavailable`)??``}`),s.disabled=W(h)||W(fe)||W(ce),J(g,W(l).kind===`approval`||W(l).kind===`profile`?`Choose a decision`:W(b)?`EDIT SCHEDULED FOLLOW-UP`:`Reply to this session`)}),q(e,r)};Y(le,e=>{W(ce)||W(v)?e(he):W(l)?W(l).id?W(y)!==W(l).id&&e(A,3):e(be,2):e(ye,1)}),j(r),V(()=>J(s,a()===`profile`?`QUOTA THRESHOLD`:`SESSION CONTROL // EXPERIMENTAL`)),q(e,r)};Y(Ee,e=>{!W(le)&&(!W(ne)||W(b)||a()||W(l)?.kind!==`prompt`||W(l).questions?.length)&&e(De)}),q(e,A),Ke()}wr([`click`,`keydown`]);var ss=K(` `,1),cs=K(`
      `),ls=K(`

      STATUS LINE // CODEXOMETER

      Choose multiple fields and their order. These display preferences do not - change Codex CLI configuration. Missing values are omitted.

      `),us=K(`

      `,1);function ds(e,t){Ge(t,!0);let n=Wi(t,`stale`,3,!1),r=F(Zt([])),i=F(!1),a=N(()=>$.data?.statusLineFields||[]),o=e=>[...new Set(e??W(a).filter(e=>e.default).map(e=>e.id))].filter(e=>W(a).some(t=>t.id===e)),s=e=>o(e).map(e=>e===`run-state`&&(n()||!$.connected||$.data?.sessionsError)?`STALE`:t.session.statusLine?.[e]).filter(Boolean).join(` · `),c=N(()=>[...W(r).map(e=>W(a).find(t=>t.id===e)).filter(Boolean),...W(a).filter(e=>!W(r).includes(e.id))]);bn(()=>{ia.open&&!W(i)?(I(r,o(ra.statusLine),!0),I(i,!0)):ia.open||I(i,!1)});function l(e,t){I(r,t?[...W(r),e]:W(r).filter(t=>t!==e),!0)}function u(e,t){let n=W(r).indexOf(e),i=n+t;if(n<0||i<0||i>=W(r).length)return;let a=[...W(r)];[a[n],a[i]]=[a[i],a[n]],I(r,a,!0)}var d=us(),f=R(d),p=e=>{var t=ls(),n=B(L(t),4);Z(n,21,()=>W(c),e=>e.id,(e,t)=>{var n=cs(),i=L(n),a=L(i);xi(a);var o=B(a,1,!0),s=z(B(o),!0);j(i);var c=B(i,2),d=e=>{var n=ss(),i=R(n),a=B(i,2);V((e,n)=>{Q(i,`aria-label`,`Move `+W(t).label+` earlier`),i.disabled=e,Q(a,`aria-label`,`Move `+W(t).label+` later`),a.disabled=n},[()=>W(r).indexOf(W(t).id)===0,()=>W(r).indexOf(W(t).id)===W(r).length-1]),G(`click`,i,()=>u(W(t).id,-1)),G(`click`,a,()=>u(W(t).id,1)),q(e,n)},f=N(()=>W(r).includes(W(t).id));Y(c,e=>{W(f)&&e(d)}),j(n),V(e=>{Q(i,`title`,W(t).help),Si(a,e),J(o,W(t).label),J(s,W(t).help)},[()=>W(r).includes(W(t).id)]),G(`change`,a,e=>l(W(t).id,e.currentTarget.checked)),q(e,n)}),j(n);var i=B(n,2),a=z(i),o=B(i,2),d=B(o,2);j(t),V(e=>J(a,`Preview // ${e??``}`),[()=>s(W(r))||`—`]),G(`click`,o,()=>{ra.statusLine=[...W(r)],aa(),ia.open=!1}),G(`click`,d,()=>{ia.open=!1}),q(e,t)};Y(f,e=>{ia.open&&e(p)});var m=B(f,2),h=L(m),g=z(h,!0),_=B(h,2);j(m),V((e,t)=>{Q(h,`title`,e),J(g,t)},[()=>s(ra.statusLine),()=>s(ra.statusLine)]),G(`click`,_,()=>{ia.open=!ia.open}),q(e,d),Ke()}wr([`change`,`click`]);var fs=K(`
      `);function ps(e,t){Ge(t,!0);let n=Wi(t,`active`,3,!1),r=N(()=>t.session.text||t.session.contextKind===`LAST ACTIVITY`&&t.session.workingCommand||``),i=N(()=>[`LAST REPLY`,`LAST ACTIVITY`].includes(t.session.contextKind)&&!!W(r).trim()),a=F(!1),o=F(``),s=F(!1);bn(()=>{if(!W(s))return;let e=setTimeout(()=>{I(s,!1)},150);return()=>clearTimeout(e)}),bn(()=>{W(r),t.session.status,I(o,``)});async function c(){if(!W(i)||W(a))return;let e=W(r);I(a,!0),I(s,!0),I(o,``);try{await navigator.clipboard.writeText(e),W(r)===e&&I(o,`Copied.`)}catch{W(r)===e&&I(o,`Clipboard unavailable. Select the visible text and copy it manually.`)}finally{I(a,!1)}}function l(e){!n()||!W(i)||e.defaultPrevented||e.repeat||e.ctrlKey||e.metaKey||e.altKey||e.key.toLowerCase()!==`c`||e.target instanceof Element&&e.target.closest(`input, textarea, select, [contenteditable]`)||(e.preventDefault(),c())}var u=Fr();Cr(`keydown`,en,l);var d=R(u),f=e=>{var t=fs(),n=L(t),r=z(n,!0),i=B(n,2);let l;j(t),V(()=>{J(r,W(o)),i.disabled=W(a),l=ci(i,1,`svelte-543j00`,null,l,{flashed:W(s)})}),G(`click`,i,c),q(e,t)};Y(d,e=>{W(i)&&e(f)}),q(e,u),Ke()}wr([`click`]);var ms=K(`

       
      `,1),hs=K(`

      LATEST GUIDANCE

       
      `,1),gs=K(`

      CONTEXT

       

      `,1),_s=K(`

      `),vs=K(`

      `),ys=K(`
       
      `),bs=K(`

       
      `,1),xs=K(`
       
      `),Ss=K(`

      Command unavailable from this observation. Open Codex to inspect the - request.

      `),Cs=K(`

      `,1),ws=K(`

      `),Ts=K(` `,1),Es=K(`
      `),Ds=K(`

      Session connection or refresh unavailable. Context and telemetry may be - stale.

      `),Os=K(`

      Some quota profile checks are unavailable. Only sessions with freshly - verified quota and settings can be updated; previous outcome notices remain - visible.

      `),ks=K(` `),As=K(` `),js=K(` `),Ms=K(``),Ns=K(`

      Read only — reply or approve in Codex.

      `),Ps=K(`

      `),Fs=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),Is=K(`
      `),Ls=K(`
      `),Rs=K(`

      This session is no longer in the current observation. Return to sessions.

      `),zs=K(`

      `),Bs=K(``),Vs=K(`

      `),Hs=K(` `),Us=K(`

      `),Ws=K(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),Gs=K(` `,1),Ks=K(`

      `),qs=K(`

      TOKEN ACTIVITY // 30 SECOND SAMPLES

      `),Js=K(`

      TOKENS

      FULL DETAIL →
      `),Ys=K(`

      No locally observed sessions yet. Keep Codex running alongside - Codexometer.

      `),Xs=K(`

      ↑ ↓ SELECT SESSION // ← LESS DETAIL // → MORE DETAIL // ESC BACK

      `,1),Zs=K(`

      SESSION TOTALS

      `,1);function Qs(e,t){Ge(t,!0);let n=(e,t=f,n,r)=>{let i=ht(()=>g(n?.(),!0)),a=ht(()=>g(r?.(),!1));var o=Ts(),s=R(o),c=e=>{var n=ms(),r=R(n),i=z(r,!0),a=z(B(r,2),!0);V(()=>{J(i,t().contextKind===`LAST REPLY`&&!t().streaming?`TASK`:`CURRENT TASK`),J(a,t().currentTask)}),q(e,n)};Y(s,e=>{t().currentTask&&e(c)});var l=B(s,2),u=e=>{var n=hs(),r=z(B(R(n),2),!0);V(()=>J(r,t().latestGuidance)),q(e,n)};Y(l,e=>{t().latestGuidance&&e(u)});var d=B(l,2),p=e=>{var n=gs(),r=z(B(R(n),2),!0);we(2),V(()=>J(r,t().approvalContext)),q(e,n)};Y(d,e=>{W(a)&&t().contextKind===`APPROVAL REQUEST`&&t().approvalContext&&e(p)});var m=B(d,2),_=e=>{var n=_s();let r;var i=z(n,!0);V(e=>{r=ci(n,1,`attention-note`,null,r,{inferred:t().status===`CHECK SESSION`}),J(i,e)},[()=>C(t())]),q(e,n)},v=N(()=>C(t())&&(!W(a)||W(h)||t().status===`CHECK SESSION`));Y(m,e=>{W(v)&&e(_)});var y=B(m,2),b=e=>{var n=vs(),r=z(n,!0);V(e=>J(r,e),[()=>w(t())]),q(e,n)};Y(y,e=>{W(i)&&e(b)});var x=B(y,2),S=e=>{var n=ys(),r=z(n,!0);V(()=>J(r,t().text||`No session context available.`)),q(e,n)};Y(x,e=>{(t().text||!t().workingCommand)&&e(S)});var T=B(x,2),ee=e=>{var n=bs(),r=B(R(n),2),i=L(r),a=B(i),o=e=>{var n=Pr();V(()=>J(n,`// +${(t().runningCommands||0)-+(t().commandStatus===`running`)} RUNNING`)),q(e,n)};Y(a,e=>{!W(h)&&(t().runningCommands||0)>+(t().commandStatus===`running`)&&e(o)});var s=B(a,2),c=e=>{q(e,Pr(`+`))};Y(s,e=>{t().runningLimited&&e(c)}),j(r);var l=z(B(r,2),!0);V(e=>{J(i,`COMMAND // ${e??``} `),J(l,t().workingCommand)},[()=>W(h)?`UNKNOWN`:(t().commandStatus||`unknown`).toUpperCase()]),q(e,n)};Y(T,e=>{t().workingCommand&&e(ee)});var te=B(T,2),E=e=>{Co(e,{get lines(){return t().fileChanges}})},D=e=>{var n=Cs(),r=B(R(n),2),i=z(r,!0),a=B(r,2),o=e=>{var n=xs(),r=z(n,!0);V(()=>J(r,t().command)),q(e,n)},s=e=>{q(e,Ss())};Y(a,e=>{t().command?e(o):e(s,-1)}),V(()=>J(i,W(h)||t().status!==`APPROVAL NEEDED`?`LAST OBSERVED COMMAND`:$.data?.control?`COMMAND REQUEST`:`COMMAND TO APPROVE IN CODEX`)),q(e,n)};Y(te,e=>{(!W(a)||!$.data?.control)&&t().fileChanges?.length?e(E):(!W(a)||!$.data?.control)&&(t().command||t().status===`APPROVAL NEEDED`)&&e(D,1)});var ne=B(te,2),O=e=>{var n=ws(),r=z(n);V(()=>J(r,`CONTEXT SOURCE // ${(t().source||`LOCAL`)??``} // OBSERVATION`)),q(e,n)};Y(ne,e=>{W(a)||e(O)}),q(e,o)},r=Wi(t,`params`,19,()=>({})),i=N(()=>$.data?.sessions||[]),a=N(()=>$.data?.control&&$.data.profiles||[]),o=N(()=>($.data?.triggers||[]).filter(e=>W(i).some(t=>t.id===e.session)));function s(e,t){if(r().id&&r().id!==t&&W(l)){e.preventDefault();return}b(t)}function c(e){return[`TURN COMPLETE`,`IDLE`,`ACTIVE`].includes(e.status)&&W(o).some(t=>t.session===e.id)?`TRIGGER SET`:e.status}let l=F(!1);function u(e,t){if(r().id&&r().id!==t&&W(l)){e.preventDefault();return}b(t)}bn(()=>{let e=r().id;e&&mr(()=>{ra.selected=e,la(e,2)})});let d=N(()=>W(i).find(e=>e.id===r().id)),p=N(()=>new URLSearchParams(Yi.querystring).get(`review`)===`profile`&&W(a).some(e=>e.session===r().id&&e.pending)),m=N(()=>W(i).some(e=>e.id===ra.selected)?ra.selected:W(i)[0]?.id),h=N(()=>!$.connected||!!$.data?.sessionsError),v=N(()=>[[`OBSERVED TOKENS`,ua(W(i).reduce((e,t)=>e+t.tokens,0))],[`LISTED SESSIONS`,ua(W(i).length)],...[[`WORKING`,`WORKING`],[`AWAITING APPROVAL`,`APPROVAL NEEDED`],[`AWAITING INPUT`,`INPUT NEEDED`],[`CHECK · INFERRED`,`CHECK SESSION`]].map(([e,t])=>[e,W(h)?`—`:ua(W(i).filter(e=>e.status===t).length)])]),y=N(()=>W(i).filter(e=>[`INPUT NEEDED`,`APPROVAL NEEDED`,`CHECK SESSION`].includes(e.status)));function b(e){ra.selected=e,dr().then(()=>document.querySelector(`.session-row.selected`)?.scrollIntoView({block:`nearest`}))}function x(e,t){if(b(e),r().id){t<0&&(la(e,2),location.hash=`/sessions`);return}let n=sa(e)+t;n>2?location.hash=`/sessions/`+encodeURIComponent(e):la(e,n)}function S(e){let t=e.target;if(!(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||t.closest(`input, textarea, select, [contenteditable="true"]`))){if(e.key===`Escape`&&r().id)e.preventDefault(),x(r().id,-1);else if([`ArrowLeft`,`ArrowRight`].includes(e.key)&&(r().id||W(m)))e.preventDefault(),x(r().id||W(m),e.key===`ArrowLeft`?-1:1);else if(!r().id&&[`ArrowUp`,`ArrowDown`].includes(e.key)&&W(i).length){e.preventDefault();let t=W(i).findIndex(e=>e.id===W(m));b(W(i)[Math.max(0,Math.min(W(i).length-1,t+(e.key===`ArrowUp`?-1:1)))].id)}}}function C(e){return W(h)?`Last observation only — refresh unavailable. Check Codex for current state.`:e.status===`CHECK SESSION`?`INFERRED INACTIVITY — a quiet session, not a confirmed input or approval request. Local tools may still be running.`:$.data?.control&&[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(e.status)?`Open full detail for supported live controls; otherwise reply in Codex.`:e.status===`APPROVAL NEEDED`?`OBSERVED APPROVAL SIGNAL — approve or decline in Codex.`:e.status===`INPUT NEEDED`?`OBSERVED INPUT SIGNAL — reply in Codex.`:e.status===`TURN COMPLETE`?`OBSERVED TURN COMPLETION — informational, not an approval request.`:``}function w(e){return e.streaming&&e.contextKind===`LAST REPLY`?`REPLY // STREAMING`:e.contextKind||`LAST ACTIVITY`}var T=Zs();Cr(`keydown`,en,S);var ee=R(T),te=z(B(L(ee),2));j(ee);var E=B(ee,2);let D;Z(E,21,()=>W(v),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1];var a=Es(),o=L(a),s=z(o,!0),c=z(B(o,2),!0);j(a),V(()=>{J(s,r()),J(c,i())}),q(e,a)}),j(E);var ne=B(E,2),O=z(ne),re=B(ne,2),ie=e=>{q(e,Ds())};Y(re,e=>{W(h)&&e(ie)});var ae=B(re,2),oe=e=>{q(e,Os())};Y(ae,e=>{$.data?.profileError&&e(oe)});var se=B(ae,2),ce=e=>{var t=Ms(),n=L(t);Z(n,17,()=>W(y),X,(e,t)=>{var n=ks();let r;var i=z(n);V((e,a)=>{r=ci(n,1,`button`,null,r,{approval:W(t).status===`APPROVAL NEEDED`}),Q(n,`href`,e),J(i,`${W(t).status??``} - ${a??``} // ${(W(t).name||W(t).directory||W(t).id)??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,n,()=>b(W(t).id)),q(e,n)});var c=B(n,2);Z(c,17,()=>W(a).filter(e=>e.pending&&W(i).some(t=>t.id===e.session)),X,(e,t)=>{var n=As(),a=z(n);V((e,i,o)=>{Q(n,`title`,r().id&&r().id!==W(t).session&&W(l)?`Finish sending or clear your current draft before switching sessions.`:`Review this session’s quota threshold`),Q(n,`href`,e),J(a,`QUOTA THRESHOLD ${i??``} // ${o??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session)+`?review=profile`,()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory||W(t).session]),G(`click`,n,e=>u(e,W(t).session)),q(e,n)}),Z(B(c,2),17,()=>W(o),X,(e,t)=>{var n=js(),r=z(n);V((e,t,i)=>{Q(n,`href`,e),J(r,`TRIGGER SET ${t??``} // ${i??``}`)},[()=>`#/sessions/`+encodeURIComponent(W(t).session),()=>Array.from(W(t).session).slice(-5).join(``).toUpperCase(),()=>W(i).find(e=>e.id===W(t).session)?.name||W(i).find(e=>e.id===W(t).session)?.directory]),G(`click`,n,e=>s(e,W(t).session)),q(e,n)}),j(t),q(e,t)},le=N(()=>(W(y).length||W(a).some(e=>e.pending)||W(o).length)&&!W(h));Y(se,e=>{W(le)&&e(ce)});var ue=B(se,2),de=e=>{var t=Fr(),i=R(t),o=e=>{var t=Ls(),i=L(t),o=L(i),s=L(o);let u;var f=B(s);j(o);var m=B(o,2);j(i);var g=B(i,2),_=e=>{var t=ws(),n=z(t,!0);V(()=>J(n,W(d).directory)),q(e,t)};Y(g,e=>{W(d).name&&W(d).directory&&e(_)});var v=B(g,2),y=z(v),x=B(v,2);let S;var C=L(x),w=L(C);n(w,()=>W(d),()=>!0,()=>!0),j(C);var T=B(C,2),ee=e=>{var t=Fr();qr(R(t),()=>W(d).id,e=>{{let t=N(()=>new URLSearchParams(Yi.querystring).get(`schedule`)===`edit`),n=N(()=>W(d).fileChanges||[]);os(e,{get session(){return W(d).id},get openScheduler(){return W(t)},get observedCommand(){return W(d).command},get observedFileChanges(){return W(n)},get suspended(){return W(p)},onProtectedChange:e=>{I(l,e,!0)}})}}),q(e,t)},te=e=>{q(e,Ns())};Y(T,e=>{$.data?.control?e(ee):e(te,-1)}),j(x);var E=B(x,2);Z(E,17,()=>W(a).filter(e=>e.session===W(d).id),e=>e.session,(e,t)=>{var n=Is(),r=L(n),i=e=>{var n=Ps(),r=z(n,!0);V(()=>J(r,W(t).notice)),q(e,n)};Y(r,e=>{W(t).notice&&e(i)});var a=B(r,2),o=e=>{os(e,{get session(){return W(d).id},review:`profile`})},s=e=>{var t=Fs();V(e=>Q(t,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(d).id)+`?review=profile`]),q(e,t)};Y(a,e=>{W(t).pending&&W(p)?e(o):W(t).pending&&e(s,1)}),j(n),V(()=>Q(n,`id`,`quota-profile-`+W(d).id)),q(e,n)});var D=B(E,2),ne=e=>{var t=Fr();qr(R(t),()=>W(d).id,e=>{ps(e,{get session(){return W(d)},active:!0})}),q(e,t)};Y(D,e=>{W(p)||e(ne)}),qr(B(D,2),()=>W(d).id,e=>{ds(e,{get session(){return W(d)},get stale(){return W(h)}})}),j(t),V((e,t)=>{u=ci(s,1,`lamp lit`,null,u,{working:W(d).status===`WORKING`&&!W(h)}),J(f,`${e??``} // ${(W(d).name||W(d).directory)??``}`),J(y,`${t??``} TOKENS // ${W(d).id??``} // CONTEXT SOURCE // ${(W(d).source||`LOCAL`)??``}`),S=ui(x,``,S,{display:W(p)?`none`:void 0})},[()=>W(h)?`STALE`:W(p)?`QUOTA THRESHOLD`:c(W(d)),()=>ua(W(d).tokens)]),G(`click`,m,()=>{b(r().id),la(r().id,2)}),q(e,t)},s=e=>{q(e,Rs())};Y(i,e=>{W(d)?e(o):e(s,-1)}),q(e,t)},fe=e=>{var t=Xs(),r=R(t),o=B(L(r),2),s=L(o),l=B(s,2);j(o),j(r);var d=B(r,2);Z(d,17,()=>W(i),e=>e.id,(e,t)=>{let r=N(()=>sa(W(t).id));var i=Js();let o;var s=L(i),l=L(s),d=e=>{var n=zs(),r=L(n),i=z(r);j(n),V(e=>{Q(r,`aria-pressed`,W(m)===W(t).id),J(i,`${e??``} // ${W(t).name??``}`)},[()=>Array.from(W(t).id).slice(-5).join(``).toUpperCase()]),G(`click`,r,()=>b(W(t).id)),q(e,n)};Y(l,e=>{W(t).name&&e(d)});var f=B(l,2),p=L(f),g=L(p);let _;var v=B(g,1,!0);j(p),j(f);var y=B(f,2),S=e=>{var n=Bs(),r=z(n,!0);V(()=>{Q(n,`aria-pressed`,W(m)===W(t).id),J(r,W(t).directory||W(t).id)}),G(`click`,n,()=>b(W(t).id)),q(e,n)};Y(y,e=>{W(t).name||e(S)});var C=B(y,2),T=L(C);we(),j(C);var ee=B(C,2),te=e=>{var n=ws(),r=z(n,!0);V(()=>J(r,W(t).directory)),q(e,n)};Y(ee,e=>{W(t).name&&W(t).directory&&e(te)});var E=B(ee,2),D=z(E),ne=B(E,2),O=z(ne),re=B(ne,2),ie=L(re),ae=B(ie,2),oe=z(ae,!0),se=B(ae,2);j(re);var ce=B(re,2),le=B(ce,2),ue=e=>{var n=Vs(),r=z(n,!0);V(()=>J(r,W(t).status===`CHECK SESSION`?`INFERRED INACTIVITY`:$.data?.control?`OPEN FULL DETAIL OR REPLY IN CODEX`:W(t).status===`APPROVAL NEEDED`?`APPROVE OR DECLINE IN CODEX`:`REPLY IN CODEX`)),q(e,n)},de=N(()=>!W(h)&&[`APPROVAL NEEDED`,`INPUT NEEDED`,`CHECK SESSION`].includes(W(t).status));Y(le,e=>{W(de)&&e(ue)}),j(s);var fe=B(s,2),pe=e=>{var r=Ks(),i=L(r),o=L(i),s=z(o,!0),c=B(o,2),l=e=>{var n=Hs(),r=z(n,!0);V(e=>{Q(n,`href`,e),J(r,$.data?.control?`REVIEW IN FULL DETAIL ↗`:`APPROVAL IN CODEX ↗`)},[()=>`#/sessions/`+encodeURIComponent(W(t).id)]),q(e,n)};Y(c,e=>{!W(h)&&W(t).status===`APPROVAL NEEDED`&&e(l)}),j(i);var d=B(i,2);n(d,()=>W(t),()=>!1);var f=B(d,2);Z(f,17,()=>W(a).filter(e=>e.session===W(t).id),X,(e,n)=>{var r=Gs(),i=R(r),a=e=>{var t=Us(),r=z(t,!0);V(()=>J(r,W(n).notice)),q(e,t)};Y(i,e=>{W(n).notice&&e(a)});var o=B(i,2),s=e=>{var n=Ws();V(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(W(t).id)+`?review=profile`]),G(`click`,n,e=>u(e,W(t).id)),q(e,n)};Y(o,e=>{W(n).pending&&e(s)}),q(e,r)});var p=B(f,2);{let e=N(()=>W(m)===W(t).id);ps(p,{get session(){return W(t)},get active(){return W(e)}})}j(r),V(e=>J(s,e),[()=>w(W(t))]),q(e,r)};Y(fe,e=>{W(r)>0&&e(pe)});var me=B(fe,2),he=e=>{var n=qs(),r=B(L(n),2);{let e=N(()=>(W(t).samples||[]).map(e=>e.tokens));no(r,{get values(){return W(e)},capacity:120})}var i=z(B(r,2));j(n),V(()=>J(i,`LAST ${(W(t).samples?.length||0)??``} SAMPLES // AUTO SCALE`)),q(e,n)};Y(me,e=>{W(r)<2&&e(he)}),j(i),V((e,n,a,s,c)=>{o=ci(i,1,`session-row`,null,o,{selected:W(m)===W(t).id,wide:W(r)===2,split:W(r)===1}),Q(i,`aria-label`,`Session `+(W(t).name||W(t).directory||W(t).id)),Q(p,`href`,e),_=ci(g,1,`lamp lit`,null,_,{working:W(t).status===`WORKING`&&!W(h)}),J(v,n),J(T,`${a??``} `),J(D,`${W(t).agents??``} LINKED AGENTS`),J(O,`ACTIVE // ${s??``}`),ie.disabled=W(r)===0,Q(ae,`aria-expanded`,W(r)>0),J(oe,W(r)?`HIDE DETAIL`:`SHOW DETAIL`),Q(ce,`href`,c)},[()=>`#/sessions/`+encodeURIComponent(W(t).id),()=>W(h)?`STALE`:c(W(t)),()=>ua(W(t).tokens),()=>da(W(t).activity),()=>`#/sessions/`+encodeURIComponent(W(t).id)]),G(`click`,p,()=>b(W(t).id)),G(`click`,ie,()=>x(W(t).id,-1)),G(`click`,ae,()=>{b(W(t).id),la(W(t).id,+!W(r))}),G(`click`,se,()=>x(W(t).id,1)),G(`click`,ce,()=>b(W(t).id)),q(e,i)});var f=B(d,2),p=e=>{q(e,Ys())};Y(f,e=>{W(i).length||e(p)}),G(`click`,s,()=>ca(1)),G(`click`,l,()=>ca(0)),q(e,t)};Y(ue,e=>{r().id?e(de):e(fe,-1)}),V(e=>{J(te,`OBSERVED ${e??``}`),D=ci(E,1,`session-totals`,null,D,{stale:W(h)}),J(O,`${W(h)?`LAST KNOWN TOTALS — live state counts unavailable. `:``}Tokens - observed since this server started for currently listed sessions; linked - agents are already included. Totals can decrease when a session leaves the - list. History samples every 30 seconds. Not account-wide totals.`)},[()=>da($.data?.sessionsAt)]),q(e,T),Ke()}wr([`click`]);var $s=K(`

      `),ec=K(`

      Relative usage/credits are not tokens or quota percentages. Groupings - describe the same usage, not additional consumption.

      `,1),tc=K(`// APPROXIMATE`),nc=K(`

      Partial accounting: totals may still change.

      `),rc=K(`

      Percentage of this period's historical allowance, not today's limit. May - exceed 100%. This is not a manual/automatic reset log.

      `,1),ic=K(`

      `,1),ac=K(`

      This optional account report is unavailable. Token history remains - available; missing data does not mean zero usage.

      `),oc=K(`
      `),sc=K(`
      `),cc=K(`

      No usage reported for this day.

      `),lc=K(`

      Selected breakdown unavailable; missing does not mean zero.

      `),uc=K(`

      `,1);function dc(e,t){Ge(t,!0);let n=F(`surface`),r=F(0),i=N(()=>t.reports?.daily),a=N(()=>t.reports?.plan),o=N(()=>t.mode===`breakdown`?W(i)?.days.length||0:W(a)?.periods.length||0),s=N(()=>Math.min(W(r),Math.max(0,W(o)-1))),c=N(()=>W(i)?.days[(W(i)?.days.length||0)-1-W(s)]),l=N(()=>W(a)?.periods[W(s)]),u=N(()=>t.mode===`breakdown`?W(i)?.units||``:`%`),d=N(()=>{let e=Object.create(null);if(t.mode===`breakdown`)e=W(c)?.groups[W(n)]||{};else{let t=W(n)===`feature`?`thread_source`:W(n)===`task start`?`turn_trigger`:W(n);for(let n of W(l)?.breakdowns||[])if(n.dimension===t)for(let t of n.rows)e[t.key]=(e[t.key]||0)+t.basis_points/100}return Object.entries(e).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}),f=N(()=>t.mode===`breakdown`?W(c)?.total:W(l)?.used_basis_points==null?null:W(l).used_basis_points/100),p=N(()=>Math.max(1,W(f)||0,...W(d).map(([,e])=>e))),m=e=>e==null?`UNKNOWN`:e.toLocaleString(`en-GB`,{maximumFractionDigits:2});var h=uc(),g=R(h),v=L(g),y=B(L(v)),b=L(y);b.value=b.__value=`surface`;var x=B(b);x.value=x.__value=`model`;var S=B(x);S.value=S.__value=`feature`;var C=B(S);C.value=C.__value=`task start`,j(y),mi(y),j(v);var w=B(v,2),T=B(w,2),ee=z(B(T,2),!0);j(g);var te=B(g,2),E=L(te),D=z(E,!0),ne=B(E,2),O=z(ne),re=B(ne,2),ie=e=>{var t=ec(),n=R(t),r=z(n),a=B(n,2),o=e=>{var t=$s(),n=z(t);V(()=>J(n,`Data as of ${W(i).dataAsOf??``}`)),q(e,t)};Y(a,e=>{W(i).dataAsOf&&e(o)});var s=z(B(a,2));we(2),V((e,t)=>{J(r,`Latest fetch ${e??``} // queried ${W(i).from??``} → ${W(i).through??``}. - Reports are fetched from OpenAI and are not saved between runs.`),J(s,`${(W(c)?.date||`No daily buckets reported`)??``} // ${t??``} - ${W(u)??``}`)},[()=>da(W(i).fetchedAt),()=>m(W(f))]),q(e,t)},ae=e=>{var t=ic(),n=R(t),r=L(n);let i;var o=z(r,!0),s=B(r),c=e=>{q(e,tc())};Y(s,e=>{W(a).approximate&&e(c)});var u=B(s);j(n);var d=B(n,2),p=L(d),h=B(p),g=e=>{var t=Pr();V(()=>J(t,`// Boundary tolerance ${W(a).boundary_tolerance_seconds??``}s`)),q(e,t)};Y(h,e=>{W(a).boundary_tolerance_seconds!=null&&e(g)}),j(d);var _=B(d,2),v=e=>{var t=rc(),n=R(t),r=L(n),i=B(r);let a;var o=z(i);j(n);var s=B(n,2),c=z(s),u=B(s,2),d=e=>{q(e,nc())};Y(u,e=>{W(l).accounting_complete||e(d)}),we(2),V(e=>{J(r,`${W(l).window_minutes??``} MIN // ${W(l).plan_type??``} // `),a=ci(i,1,`svelte-1fbui7h`,null,a,{muted:W(f)==null,"quota-near":W(f)!=null&&W(f)>=80&&W(f)<100,"quota-full":W(f)!=null&&W(f)>=100}),J(o,`USED ${e??``}${W(f)==null?``:`%`}`),J(c,`${W(l).starts_at??``} → ${W(l).ends_at??``}`)},[()=>m(W(f))]),q(e,t)};Y(_,e=>{W(l)&&e(v)}),V(e=>{i=ci(r,1,`svelte-1fbui7h`,null,i,{"quality-warning":!W(a).coverage_complete}),J(o,W(a).coverage_complete?`Reported range complete`:`Partial coverage`),J(u,` // Latest fetch ${e??``}`),J(p,`Coverage starts ${(W(a).coverage_start||`unknown`)??``} // Data as of ${(W(a).data_as_of||`unknown`)??``}`)},[()=>da(W(a).fetchedAt)]),q(e,t)},oe=e=>{q(e,ac())};Y(re,e=>{t.mode===`breakdown`&&W(i)?e(ie):t.mode===`periods`&&W(a)?e(ae,1):e(oe,-1)});var se=B(re,2),ce=e=>{var n=sc(),r=L(n),i=z(B(L(r),2),!0);j(r),Z(B(r,2),17,()=>W(d),X,(e,n,r)=>{var i=N(()=>_(W(n),2));let a=()=>W(i)[0],o=()=>W(i)[1];var s=oc();let c;var l=L(s),u=z(l,!0),d=B(l,2),f=L(d);let h;j(d);var g=z(B(d,2));j(s),V((e,n,i)=>{c=ci(s,1,`report-row svelte-1fbui7h`,null,c,{unknown:e,alternate:r%2==1}),Q(l,`title`,a()),J(u,a()),h=ui(f,``,h,{width:n}),J(g,`${i??``}${t.mode===`periods`?`%`:``}`)},[()=>a().trim().toLowerCase()===`unknown`,()=>`${Math.max(0,100*o()/W(p))}%`,()=>m(o())]),q(e,s)}),j(n),V(()=>J(i,t.mode===`breakdown`?W(u):`QUOTA USED`)),q(e,n)},le=e=>{q(e,cc())},ue=e=>{q(e,lc())};Y(se,e=>{W(d).length?e(ce):t.mode===`breakdown`&&W(c)?.total===0&&W(c)?.groups[W(n)]!=null?e(le,1):(W(i)&&t.mode===`breakdown`||W(a)&&t.mode===`periods`)&&e(ue,2)}),j(te),V(()=>{w.disabled=W(s)>=W(o)-1,T.disabled=W(s)===0,J(ee,W(o)?`${W(s)+1} / ${W(o)}`:`NO DATA`),J(D,t.mode===`breakdown`?`DAILY BREAKDOWN`:`QUOTA WINDOWS`),J(O,`${(t.mode===`breakdown`?t.reports?.dailyStatus||`UNAVAILABLE`:t.reports?.planStatus||`UNAVAILABLE`)??``} // UTC`)}),hi(y,()=>W(n),e=>I(n,e)),G(`click`,w,()=>I(r,W(s)+1)),G(`click`,T,()=>I(r,W(s)-1)),q(e,h),Ke()}wr([`click`]);var fc=864e5;function pc(e,t){let n=new Date(e);n.setUTCDate(1),n.setUTCMonth(n.getUTCMonth()+t);let r=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,0)).getUTCDate();return n.setUTCDate(Math.min(e.getUTCDate(),r)),n}function mc(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));for(let e=0;;e++){let i=pc(r,-t),a=new Date(i.getTime()+fc);if(e===n)return{start:a,end:r};r=i}}var hc=K(``),gc=K(``,1),_c=K(`

      History refresh failed. Any displayed history is the last successful - observation.

      `),vc=K(`

      Token history unavailable; other reports may still be available.

      `),yc=K(``),bc=K(`
      `),xc=K(`

      LESS ░ ▒ ▓ █ MORE // HOVER FOR DATE AND TOKENS

      `,1),Sc=K(`
      `,1),Cc=K(` `),wc=K(`

      LIFETIME TOKENS

      PEAK DAY

      CURRENT STREAK

      DAYS

      LONGEST TURN

      SECONDS

      LONGEST STREAK

      DAYS

      OPENAI // UTC

      Accessible data table
      Date (UTC)Tokens

      `,1),Tc=K(`

      History unavailable or awaiting a matching account observation. Missing - history is not treated as zero usage.

      `),Ec=K(`

      USAGE // ACCOUNT HISTORY

      Account-wide history reported by Codex, not the local Sessions counter. Dates - use UTC. Allowance history is approximate where indicated; reset causes are - not provided.

      `,1);function Dc(e,t){Ge(t,!0);let n=F(`daily`),r=F(12),i=F(0),a=N(()=>{let e=$.data?.usage?.dailyUsageBuckets;if(!e)return[];let{start:t,end:n}=mc(new Date,W(r),W(i)),a=new Map;for(let t of e)!Number.isFinite(t.tokens)||t.tokens<0||a.set(t.startDate,(a.get(t.startDate)||0)+t.tokens);let o=[];for(let e=t;e<=n;e=new Date(e.getTime()+864e5)){let t=e.toISOString().slice(0,10);o.push({date:t,tokens:a.get(t)||0})}return o}),o=N(()=>Math.max(1,...W(a).map(e=>e.tokens))),s=N(()=>W(a).length?new Date(W(a)[0].date+`T00:00:00Z`).getUTCDay():0),c=N(()=>{if(W(n)===`monthly`){let e=new Map;for(let t of W(a))e.set(t.date.slice(0,7),(e.get(t.date.slice(0,7))||0)+t.tokens);return[...e].map(([e,t])=>({date:e,tokens:t}))}let e=0;return W(a).map(t=>({date:t.date,tokens:e+=t.tokens}))});var l=Ec(),u=B(R(l),4);Z(u,20,()=>[[`daily`,`Daily`],[`monthly`,`Monthly`],[`cumulative`,`Cumulative`],[`breakdown`,`Breakdown`],[`periods`,`Windows`]],X,(e,t)=>{var r=N(()=>_(t,2));let a=()=>W(r)[0],o=()=>W(r)[1];var s=hc();let c;var l=z(s,!0);V(()=>{Q(s,`aria-pressed`,W(n)===a()),c=ci(s,1,``,null,c,{active:W(n)===a()}),J(l,o())}),G(`click`,s,()=>{I(n,a(),!0),I(i,0)}),q(e,s)}),j(u);var d=B(u,2),f=L(d),p=e=>{var t=gc(),n=R(t),a=B(L(n)),o=L(a);o.value=o.__value=6;var s=B(o);s.value=s.__value=12,j(a),mi(a),j(n);var c=B(n),l=B(c);V(()=>l.disabled=W(i)===0),G(`change`,a,()=>I(i,0)),hi(a,()=>W(r),e=>I(r,e)),G(`click`,c,()=>Jt(i)),G(`click`,l,()=>Jt(i,-1)),q(e,t)};Y(f,e=>{W(n)!==`breakdown`&&W(n)!==`periods`&&e(p)}),j(d);var m=B(d,2),h=e=>{q(e,_c())};Y(m,e=>{$.data?.usageError&&e(h)});var g=B(m,2),v=e=>{q(e,vc())};Y(g,e=>{$.data?.usage?.tokenStatus===`UNAVAILABLE`&&W(n)!==`breakdown`&&W(n)!==`periods`&&e(v)});var y=B(g,2),b=e=>{var t=Fr();qr(R(t),()=>W(n),e=>{{let t=N(()=>$.data?.usage?.reports);dc(e,{get reports(){return W(t)},get mode(){return W(n)}})}}),q(e,t)},x=e=>{var t=wc(),r=R(t),i=L(r),l=z(B(L(i),2),!0);j(i);var u=B(i,2),d=z(B(L(u),2),!0);j(u);var f=B(u,2),p=B(L(f),2),m=L(p);we(),j(p),j(f);var h=B(f,2),g=B(L(h),2),_=L(g);we(),j(g),j(h);var v=B(h,2),y=B(L(v),2),b=L(y);we(),j(y),j(v),j(r);var x=B(r,4),S=L(x),C=z(S),w=B(S,2),T=e=>{var t=xc(),n=R(t),r=L(n),i=L(r);Z(i,17,()=>Array(W(s)),X,(e,t)=>{q(e,yc())}),Z(B(i,2),17,()=>W(a),X,(e,t)=>{var n=bc();let r,i;V(e=>{r=ci(n,1,`heat-cell`,null,r,{zero:W(t).tokens===0}),Q(n,`title`,e),i=ui(n,``,i,{opacity:W(t).tokens?.25+.75*W(t).tokens/W(o):1})},[()=>`${W(t).date}: ${ua(W(t).tokens)} tokens`]),q(e,n)}),j(r),j(n),we(2),q(e,t)},ee=e=>{var t=Sc(),r=R(t);{let e=N(()=>W(c).map(e=>e.tokens)),t=N(()=>W(n)+` usage`);no(r,{get values(){return W(e)},get label(){return W(t)}})}var i=B(r,2),a=L(i),o=z(a,!0),s=z(B(a),!0);j(i),V(e=>{J(o,W(c)[0]?.date),J(s,e)},[()=>W(c).at(-1)?.date]),q(e,t)};Y(w,e=>{W(n)===`daily`?e(T):e(ee,-1)});var te=B(w,2),E=B(L(te),2),D=L(E),ne=B(L(D));Z(ne,21,()=>W(n)===`daily`?W(a):W(c),X,(e,t)=>{var n=Cc(),r=L(n),i=z(r,!0),a=z(B(r),!0);j(n),V(e=>{J(i,W(t).date),J(a,e)},[()=>ua(W(t).tokens)]),q(e,n)}),j(ne),j(D),j(E),j(te),j(x);var O=z(B(x,2));V((e,t,n,r,i,o,s)=>{J(l,e),J(d,t),J(m,`${n??``} `),J(_,`${r??``} `),J(b,`${i??``} `),J(C,`${W(a)[0]?.date??``} — ${o??``}`),J(O,`OBSERVED ${s??``} // CUMULATIVE IS FOR THE SELECTED PERIOD`)},[()=>ua($.data.usage.summary.lifetimeTokens),()=>ua($.data.usage.summary.peakDailyTokens),()=>ua($.data.usage.summary.currentStreakDays),()=>ua($.data.usage.summary.longestRunningTurnSec),()=>ua($.data.usage.summary.longestStreakDays),()=>W(a).at(-1)?.date,()=>da($.data.usageAt)]),q(e,t)},S=e=>{q(e,Tc())};Y(y,e=>{W(n)===`breakdown`||W(n)===`periods`?e(b):$.data?.usage&&$.data.usage.dailyUsageBuckets!==null?e(x,1):e(S,-1)}),q(e,l),Ke()}wr([`click`,`change`]);var Oc=K(`

      Page not found

      Return to Quota

      `,1);function kc(e){var t=Oc();we(2),q(e,t)}var Ac=K(` `),jc=K(`

      `),Mc=K(`

      Connecting to your local Codexometer…

      `),Nc=K(``),Pc=K(`
      CODEXOMETER

      Your quota. Your sessions. Your command centre.

      `);function Fc(e,t){Ge(t,!0);let n={"/":$a,"/quota/:view?":$a,"/sessions/:id?":Qs,"/usage":Dc,"*":kc},r={quota:/^(?:\/|\/quota(?:\/[^/]+)?\/?)$/,sessions:/^\/sessions(?:\/[^/]+)?\/?$/,usage:/^\/usage\/?$/},i=F(`hacker`),a=[`hacker`,`rust`,`blue-steel`,`ultraviolet`,`nightshade`];bn(()=>{aa()}),bn(()=>{if($.data)for(let[e,t]of Object.entries(r))t.test(Yi.location)&&(ra.tab=e)}),Gi(()=>{try{let e=localStorage.getItem(`codexometer.web.theme`);e&&a.includes(e)&&I(i,e,!0)}catch{}return ga()});function o(){try{localStorage.setItem(`codexometer.web.theme`,W(i))}catch{}}var s=Pc(),c=L(s),l=B(L(c),2),u=L(l);let d;var f=B(u,1,!0),p=z(B(f));j(l),j(c);var m=B(c,2);Z(m,21,()=>Object.entries(r),X,(e,t)=>{var n=N(()=>_(W(t),2));let r=()=>W(n)[0],i=()=>W(n)[1],a=N(()=>i().test(Yi.location));var o=Ac();let s;var c=z(o,!0);V(e=>{Q(o,`href`,r()===`quota`?`#/quota/`+ra.view:`#/`+r()),Q(o,`aria-current`,W(a)?`page`:void 0),s=ci(o,1,``,null,s,{active:W(a)}),J(c,e)},[()=>r().toUpperCase()]),q(e,o)}),j(m);var h=B(m,2),g=L(h),v=e=>{var t=jc(),n=z(t,!0);V(()=>J(n,$.error)),q(e,t)};Y(g,e=>{$.error&&e(v)});var y=B(g,2),b=e=>{Qi(e,{get routes(){return n}})},x=e=>{q(e,Mc())};Y(y,e=>{$.data?e(b):$.error||e(x,1)}),j(h);var S=B(h,2),C=L(S),w=z(C),T=B(C,2),ee=z(T,!0),te=B(T,2),E=B(L(te));Z(E,21,()=>a,X,(e,t)=>{var n=Nc(),r=z(n,!0),i={};V(e=>{J(r,e),i!==(i=W(t))&&(n.value=(n.__value=i)??``)},[()=>W(t).replace(`-`,` `).toUpperCase()]),q(e,n)}),j(E),mi(E),j(te),j(S),j(s),V(()=>{Q(s,`data-theme`,W(i)),d=ci(u,1,`lamp`,null,d,{lit:$.connected}),J(f,$.connected?`CONNECTED`:`OFFLINE`),J(p,`EXPERIMENTAL // ${$.data?.control?`SESSION CONTROL`:`READ ONLY`}`),J(w,`v${($.data?.version||`…`)??``} // LOCAL ONLY`),J(ee,$.data?.control?`Session control enabled. Stop the server to revoke access.`:`No actions can be sent from this preview.`)}),G(`change`,E,o),hi(E,()=>W(i),e=>I(i,e)),q(e,s),Ke()}wr([`change`]),Vr(Fc,{target:document.getElementById(`app`)}); \ No newline at end of file diff --git a/internal/web/dist/assets/index-LUN8vjss.js b/internal/web/dist/assets/index-LUN8vjss.js new file mode 100644 index 0000000..c87c05f --- /dev/null +++ b/internal/web/dist/assets/index-LUN8vjss.js @@ -0,0 +1,44 @@ +(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var e=Array.isArray,t=Array.prototype.indexOf,n=Array.prototype.includes,r=Array.from,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyDescriptors,s=Object.prototype,c=Array.prototype,l=Object.getPrototypeOf,u=Object.isExtensible;function d(e){return typeof e==`function`}var f=()=>{};function p(e){return e()}function m(e){for(var t=0;t{e=n,t=r}),resolve:e,reject:t}}function g(e,t,n=!1){return e===void 0?n?t():t:e}function _(e,t){if(Array.isArray(e))return e;if(t===void 0||!(Symbol.iterator in e))return Array.from(e);let n=[];for(let r of e)if(n.push(r),n.length===t)break;return n}var v=1024,y=2048,b=4096,x=8192,S=16384,C=32768,w=1<<25,T=65536,E=1<<19,ee=1<<20,D=1<<25,O=1<<21,te=1<<22,k=1<<23,ne=Symbol(`$state`),re=Symbol(`component`),ie=Symbol(`legacy props`),ae=Symbol(``),oe=Symbol(`attributes`),se=Symbol(`class`),ce=Symbol(`style`),le=Symbol(`text`),ue=Symbol(`form reset`),de=new class extends Error{name=`StaleReactionError`;message="The reaction that called `getAbortSignal()` was re-run or destroyed"},fe=!!globalThis.document?.contentType&&globalThis.document.contentType.includes(`xml`),pe={},me=Symbol(`uninitialized`),he=`http://www.w3.org/1999/xhtml`;function ge(){console.warn(`https://svelte.dev/e/derived_inert`)}function _e(e){console.warn(`https://svelte.dev/e/hydration_mismatch`)}function ve(){console.warn(`https://svelte.dev/e/select_multiple_invalid_value`)}function ye(){console.warn(`https://svelte.dev/e/svelte_boundary_reset_noop`)}var A=!1;function be(e){A=e}var j;function xe(e){if(e===null)throw _e(),pe;return j=e}function Se(){return xe(sn(j))}function M(e){if(A){if(sn(j)!==null)throw _e(),pe;j=e}}function Ce(e=1){if(A){for(var t=e,n=j;t--;)n=sn(n);j=n}}function we(e=!0){for(var t=0,n=j;;){if(n.nodeType===8){var r=n.data;if(r===`]`){if(t===0)return n;--t}else(r===`[`||r===`[!`||r[0]===`[`&&!isNaN(Number(r.slice(1))))&&(t+=1)}var i=sn(n);e&&n.remove(),n=i}}function Te(e){if(!e||e.nodeType!==8)throw _e(),pe;return e.data}function Ee(e){return e===this.v}function De(e,t){return e==e?e!==t||typeof e==`object`&&!!e||typeof e==`function`:t==t}function Oe(e){return!De(e,this.v)}function ke(e){throw Error(`https://svelte.dev/e/lifecycle_outside_component`)}function Ae(){throw Error(`https://svelte.dev/e/async_derived_orphan`)}function je(e,t,n){throw Error(`https://svelte.dev/e/each_key_duplicate`)}function Me(e){throw Error(`https://svelte.dev/e/effect_in_teardown`)}function Ne(){throw Error(`https://svelte.dev/e/effect_in_unowned_derived`)}function Pe(e){throw Error(`https://svelte.dev/e/effect_orphan`)}function Fe(){throw Error(`https://svelte.dev/e/effect_update_depth_exceeded`)}function Ie(e){throw Error(`https://svelte.dev/e/props_invalid_value`)}function Le(){throw Error(`https://svelte.dev/e/state_descriptors_fixed`)}function Re(){throw Error(`https://svelte.dev/e/state_prototype_fixed`)}function ze(){throw Error(`https://svelte.dev/e/state_unsafe_mutation`)}function Be(){throw Error(`https://svelte.dev/e/svelte_boundary_reset_onerror`)}var Ve=!1;function He(){Ve=!0}var N=null;function Ue(e){N=e}function We(e,t=!1,n){N={p:N,i:!1,c:null,e:null,s:e,x:null,r:W,l:Ve&&!t?{s:null,u:null,$:[]}:null}}function Ge(e){var t=N,n=t.e;if(n!==null){t.e=null;for(var r of n)bn(r)}return e!==void 0&&(t.x=e),t.i=!0,N=t.p,Ke(e)}function Ke(e={}){return i(e,re,{value:!0}),e}function qe(){return!Ve||N!==null&&N.l===null}var Je=[];function Ye(){var e=Je;Je=[],m(e)}function Xe(e){if(Je.length===0&&!wt){var t=Je;queueMicrotask(()=>{t===Je&&Ye()})}Je.push(e)}function Ze(){for(;Je.length>0;)Ye()}var Qe=~(y|b|v);function $e(e,t){e.f=e.f&Qe|t}function et(e){e.f&512||e.deps===null?$e(e,v):$e(e,b)}function tt(e,t,n){e.f&2048?t.add(e):e.f&4096&&n.add(e),$e(e,v)}function nt(e){A&&on(e)!==null&&cn(e)}var rt=!1;function it(){rt||(rt=!0,document.addEventListener(`reset`,e=>{Promise.resolve().then(()=>{if(!e.defaultPrevented)for(let t of e.target.elements)t[ue]?.()})},{capture:!0}))}function at(e){var t=U,n=W;Wn(null),Gn(null);try{return e()}finally{Wn(t),Gn(n)}}function ot(e,t,n,r=n){e.addEventListener(t,()=>at(n));let i=e[ue];e[ue]=i?()=>{i(),r(!0)}:()=>r(!0),it()}function st(e,t,n,r){let i=qe()?dt:mt;var a=e.filter(e=>!e.settled),o=t.map(i);if(n.length===0&&a.length===0){r(o);return}var s=W,c=ct(),l=a.length===1?a[0].promise:a.length>1?Promise.all(a.map(e=>e.promise)):null;function u(e){if(!(s.f&16384)){c();try{r([...o,...e])}catch(e){pn(e,s)}lt()}}var d=ut();if(n.length===0){l.then(()=>u([])).finally(d);return}function f(){Promise.all(n.map(e=>pt(e))).then(u).catch(e=>pn(e,s)).finally(d)}l?l.then(()=>{c(),f(),lt()}):f()}function ct(){var e=W,t=U,n=N,r=F;return function(i=!0){Gn(e),Wn(t),Ue(n),i&&!(e.f&16384)&&(r?.activate(),r?.apply())}}function lt(e=!0){Gn(null),Wn(null),Ue(null),e&&F?.deactivate()}function ut(){var e=W,t=e.b,n=F,r=!!t?.is_rendered();return t?.update_pending_count(1,n),n.increment(r,e),()=>{t?.update_pending_count(-1,n),n.decrement(r,e)}}function dt(e){var t=2|y;return W!==null&&(W.f|=E),{ctx:N,deps:null,effects:null,equals:Ee,f:t,fn:e,reactions:null,rv:0,v:me,wv:0,parent:W,ac:null}}var ft=Symbol(`obsolete`);function pt(e,t,n){let r=W;r===null&&Ae();var i=void 0,a=Vt(me),o=!U,s=new Set;return wn(()=>{var t=W,n=h();i=n.promise;try{Promise.resolve(e()).then(n.resolve,e=>{e!==de&&n.reject(e)}).finally(lt)}catch(e){n.reject(e),lt()}var c=F;if(o){if(t.f&32768)var l=ut();if(r.b?.is_rendered())c.async_deriveds.get(t)?.reject(ft);else for(let e of s.values())e.reject(ft);s.add(n),c.async_deriveds.set(t,n)}let u=(e,t=void 0)=>{l?.(),s.delete(n),t!==ft&&(c.activate(),t?(a.f|=k,Gt(a,t)):(a.f&8388608&&(a.f^=k),Gt(a,e)),c.deactivate())};n.promise.then(u,e=>u(null,e||`unknown`))}),vn(()=>{for(let e of s)e.reject(ft)}),new Promise(e=>{function t(n){function r(){n===i?e(a):t(i)}n.then(r,r)}t(i)})}function P(e){let t=dt(e);return qn(t),t}function mt(e){let t=dt(e);return t.equals=Oe,t}function ht(e){var t=e.effects;if(t!==null){e.effects=null;for(var n=0;n{t.ac.abort(de),t.ac=null}),t.fn!==null&&(t.teardown=f),cr(t,0),kn(t))}function yt(e){if(e.effects!==null)for(let t of e.effects)t.teardown&&t.fn!==null&&lr(t)}var bt=null,F=null,xt=null,St=null,Ct=null,wt=!1,Tt=!1,Et=null,Dt=null,Ot=0,kt=1,At=class e{id=kt++;#e=!1;linked=!0;#t=null;#n=null;async_deriveds=new Map;current=new Map;previous=new Map;#r=new Set;#i=new Set;#a=0;#o=new Map;#s=null;#c=[];#l=[];#u=new Set;#d=new Set;#f=new Map;#p=new Set;is_fork=!1;#m=!1;constructor(){bt===null?bt=this:(bt.#n=this,this.#t=bt),bt=this}#h(){if(this.is_fork)return!0;for(let n of this.#o.keys()){for(var e=n,t=!1;e.parent!==null;){if(this.#f.has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1}skip_effect(e){this.#f.has(e)||this.#f.set(e,{d:[],m:[]}),this.#p.delete(e)}unskip_effect(e,t=e=>this.schedule(e)){var n=this.#f.get(e);if(n){this.#f.delete(e);for(var r of n.d)$e(r,y),t(r);for(r of n.m)$e(r,b),t(r)}this.#p.add(e)}#g(){var e=[];for(let i of this.#c)if(!(i.f&16384||!(i.f&6144))){for(var t=i,n=!1;t.parent!==null;){t=t.parent;var r=t.f;if(r&96){if(!(r&1024)){n=!0;break}t.f^=v}}n||e.push(t)}return this.#c=[],e}#_(){this.#e=!0;for(let e of this.#u)this.#d.delete(e),$e(e,y),this.schedule(e);for(let e of this.#d)$e(e,b),this.schedule(e);this.apply();for(var t=Et=[],n=[],r=Dt=[];this.#c.length>0;){Ot++>1e3&&(this.#S(),Mt());for(let e of this.#g())try{this.#v(e,t,n)}catch(t){throw Lt(e),this.#h()||this.discard(),t}}if(F=null,r.length>0){var i=e.ensure();for(let e of r)i.schedule(e)}if(Et=null,Dt=null,this.#h()){this.#x(n),this.#x(t);for(let[e,t]of this.#f)It(e,t);r.length>0&&F.#_();return}let a=this.#y();if(a){this.#x(n),this.#x(t),a.#b(this);return}this.#u.clear(),this.#d.clear();for(let e of this.#r)e(this);this.#r.clear(),xt=this,Pt(n),Pt(t),xt=null,this.#s?.resolve();var o=F;if(this.#a===0&&(this.#c.length===0||o!==null)&&this.#S(),this.#c.length>0){if(o!==null){for(let e of this.#c)o.#c.push(e);this.#c=[]}else o=this}o!==null&&(zt.clear(),o.#_())}#v(e,t,n){e.f^=v;for(var r=e.first;r!==null;){var i=r.f,a=!!(i&96);if(!(a&&i&1024||i&8192||this.#f.has(r))&&r.fn!==null){a?r.f^=v:i&4?t.push(r):rr(r)&&(i&16&&this.#d.add(r),lr(r));var o=r.first;if(o!==null){r=o;continue}}for(;r!==null;){var s=r.next;if(s!==null){r=s;break}r=r.parent}}}#y(){for(var e=this.#t;e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=e.#t}return null}#b(e){for(let[t,n]of e.current)!this.previous.has(t)&&e.previous.has(t)&&this.previous.set(t,e.previous.get(t)),this.current.set(t,n);for(let[t,n]of e.async_deriveds){let e=this.async_deriveds.get(t);e&&n.promise.then(e.resolve).catch(e.reject)}e.async_deriveds.clear(),this.transfer_effects(e.#u,e.#d);let t=e=>{var n=e.reactions;if(n!==null&&!(e.f&2&&!(e.f&6144)))for(let e of n){var r=e.f;if(r&2)t(e);else{var i=e;r&4194320&&!this.async_deriveds.has(i)&&(this.#d.delete(i),$e(i,y),this.schedule(i))}}};for(let e of this.current.keys())t(e);this.oncommit(()=>e.discard()),e.#S(),F=this,this.#_()}#x(e){for(var t=0;t{this.#m=!1,this.linked&&this.flush()}))}transfer_effects(e,t){for(let t of e)this.#u.add(t);for(let e of t)this.#d.add(e);e.clear(),t.clear()}oncommit(e){this.#r.add(e)}ondiscard(e){this.#i.add(e)}settled(){return(this.#s??=h()).promise}static ensure(){if(F===null){let t=F=new e;!Tt&&!wt&&Xe(()=>{t.#e||t.flush()})}return F}apply(){St=null}schedule(e){if(Ct=e,e.b?.is_pending&&e.f&16777228&&!(e.f&32768)){e.b.defer_effect(e);return}this.#c.push(e)}#S(){if(this.linked){var e=this.#t,t=this.#n;e===null||(e.#n=t),t===null?bt=e:t.#t=e,this.linked=!1}}};function jt(e){var t=wt;wt=!0;try{var n;for(e&&(F!==null&&!F.is_fork&&F.flush(),n=e());;){if(Ze(),F===null)return n;F.flush()}}finally{wt=t}}function Mt(){try{Fe()}catch(e){pn(e,Ct)}}var Nt=null;function Pt(e){var t=e.length;if(t!==0){for(var n=0;n0)){zt.clear();for(let e of Nt){if(e.f&24576)continue;let t=[e],n=e.parent;for(;n!==null;)Nt.has(n)&&(Nt.delete(n),t.push(n)),n=n.parent;for(let e=t.length-1;e>=0;e--){let n=t[e];n.f&24576||lr(n)}}Nt.clear()}}Nt=null}}function Ft(e){F.schedule(e)}function It(e,t){if(!(e.f&32&&e.f&1024)){e.f&2048?t.d.push(e):e.f&4096&&t.m.push(e),$e(e,v);for(var n=e.first;n!==null;)It(n,t),n=n.next}}function Lt(e){$e(e,v);for(var t=e.first;t!==null;)Lt(t),t=t.next}var Rt=new Set,zt=new Map,Bt=!1;function Vt(e,t){return{f:0,v:e,reactions:null,equals:Ee,rv:0,wv:0}}function I(e,t){let n=Vt(e,t);return qn(n),n}function Ht(e,t=!1,n=!0){let r=Vt(e);return t||(r.equals=Oe),Ve&&n&&N!==null&&N.l!==null&&(N.l.s??=[]).push(r),r}function L(e,t,n=!1){return U!==null&&(!Un||U.f&131072)&&qe()&&U.f&4325394&&(Kn===null||!Kn.has(e))&&ze(),Gt(e,n?Xt(t):t,Dt)}var Ut=null,Wt=0;function Gt(e,t,n=null){if(!e.equals(t)){Vn?zt.set(e,t):zt.has(e)||zt.set(e,e.v);var r=At.ensure();if(r.capture(e,t),e.f&2){let t=e;e.f&2048&>(t),St===null&&et(t)}e.wv=nr(),Ut=null,Wt=0,Yt(e,y,n),Ut=null,qe()&&W!==null&&W.f&1024&&!(W.f&96)&&(Xn===null?Zn([e]):Xn.push(e)),!r.is_fork&&Rt.size>0&&!Bt&&Kt()}return t}function Kt(){Bt=!1;for(let e of Rt){e.f&1024&&$e(e,b);let t;try{t=rr(e)}catch{t=!0}t&&lr(e)}Rt.clear()}function qt(e,t=1){var n=G(e),r=t===1?n++:n--;return L(e,n),r}function Jt(e){L(e,e.v+1)}function Yt(e,t,n){var r=e.reactions;if(r!==null){var i=qe(),a=r.length;if(Wt+=a,Wt>1e5&&Ut===null&&(Ut=new Set),Ut!==null){if(Ut.has(e))return;Ut.add(e)}for(var o=0;o{if(er===d)return e();var t=U,n=er;Wn(null),tr(d);var r=e();return Wn(t),tr(n),r};return i&&r.set(`length`,I(t.length,u)),new Proxy(t,{defineProperty(e,t,n){(!(`value`in n)||n.configurable===!1||n.enumerable===!1||n.writable===!1)&&Le();var i=r.get(t);return i===void 0?f(()=>{var e=I(n.value,u);return r.set(t,e),e}):L(i,n.value,!0),!0},deleteProperty(e,t){var n=r.get(t);if(n===void 0){if(t in e){let e=f(()=>I(me,u));r.set(t,e),Jt(o)}}else L(n,me),Jt(o);return!0},get(e,n,i){if(n===ne)return t;var o=r.get(n),s=n in e;if(o===void 0&&(!s||a(e,n)?.writable)&&(o=f(()=>I(Xt(s?e[n]:me),u)),r.set(n,o)),o!==void 0){var c=G(o);return c===me?void 0:c}return Reflect.get(e,n,i)},getOwnPropertyDescriptor(e,t){this.has?.(e,t);var n=Reflect.getOwnPropertyDescriptor(e,t),i=r.get(t);if(i!==void 0){var a=G(i);if(a===me)return;if(n&&`value`in n)n.value=a;else return{enumerable:!0,configurable:!0,value:a,writable:!0}}return n},has(e,t){if(t===ne)return!0;var n=r.get(t),i=n!==void 0&&n.v!==me||Reflect.has(e,t);return(n!==void 0||W!==null&&(!i||a(e,t)?.writable))&&(n===void 0&&(n=f(()=>I(i?Xt(e[t]):me,u)),r.set(t,n)),G(n)===me)?!1:i},set(e,t,n,s){var c=r.get(t),l=t in e;if(i&&t===`length`)for(var d=n;dI(me,u)),r.set(d+``,p)):L(p,me)}if(c===void 0)(!l||a(e,t)?.writable)&&(c=f(()=>I(void 0,u)),L(c,Xt(n)),r.set(t,c));else{l=c.v!==me;var m=f(()=>Xt(n));L(c,m)}var h=Reflect.getOwnPropertyDescriptor(e,t);if(h?.set&&h.set.call(s,n),!l){if(i&&typeof t==`string`){var g=r.get(`length`),_=Number(t);Number.isInteger(_)&&_>=g.v&&L(g,_+1)}Jt(o)}return!0},ownKeys(e){G(o);var t=Reflect.ownKeys(e).filter(e=>{var t=r.get(e);return t===void 0||t.v!==me});for(var[n,i]of r)i.v!==me&&!(n in e)&&t.push(n);return t},setPrototypeOf(){Re()}})}function Zt(e){try{if(typeof e==`object`&&e&&ne in e)return e[ne]}catch{}return e}function Qt(e,t){return Object.is(Zt(e),Zt(t))}var $t,en,tn,nn;function rn(){if($t===void 0){$t=window,en=/Firefox/.test(navigator.userAgent);var e=Element.prototype,t=Node.prototype,n=Text.prototype;tn=a(t,`firstChild`).get,nn=a(t,`nextSibling`).get,u(e)&&(e[se]=void 0,e[oe]=null,e[ce]=void 0,e.__e=void 0),u(n)&&(n[le]=void 0)}}function an(e=``){return document.createTextNode(e)}function on(e){return tn.call(e)}function sn(e){return nn.call(e)}function R(e,t){if(!A)return on(e);var n=on(j);if(n===null)n=j.appendChild(an());else if(t&&n.nodeType!==3){var r=an();return n?.before(r),xe(r),r}return t&&dn(n),xe(n),n}function z(e,t=!1){if(!A){var n=on(e);return n instanceof Comment&&n.data===``?sn(n):n}if(t){if(j?.nodeType!==3){var r=an();return j?.before(r),xe(r),r}dn(j)}return j}function B(e,t=!1){if(!A)return on(e);var n=R(e,t);return M(e),n}function V(e,t=1,n=!1){let r=A?j:e;for(var i;t--;)i=r,r=sn(r);if(!A)return r;if(n){if(r?.nodeType!==3){var a=an();return r===null?i?.after(a):r.before(a),xe(a),a}dn(r)}return xe(r),r}function cn(e){e.textContent=``}function ln(){return!1}function un(e,t,n){return t==null||t===`http://www.w3.org/1999/xhtml`?n?document.createElement(e,{is:n}):document.createElement(e):n?document.createElementNS(t,e,{is:n}):document.createElementNS(t,e)}function dn(e){if(e.nodeValue.length<65536)return;let t=e.nextSibling;for(;t!==null&&t.nodeType===3;)t.remove(),e.nodeValue+=t.nodeValue,t=e.nextSibling}function fn(e){var t=W;if(t===null)return U.f|=k,e;if(!(t.f&32768)&&!(t.f&4))throw e;pn(e,t)}function pn(e,t){if(!(t!==null&&t.f&16384)){for(;t!==null;){if(t.f&128&&!(t.f&33570816)){if(!(t.f&32768))throw e;try{t.b.error(e);return}catch(t){e=t}}t=t.parent}throw e}}function mn(e){W===null&&(U===null&&Pe(e),Ne()),Vn&&Me(e)}function hn(e,t){var n=t.last;n===null?t.last=t.first=e:(n.next=e,e.prev=n,t.last=e)}function gn(e,t){var n=W;n!==null&&n.f&8192&&(e|=x);var r={ctx:N,deps:null,nodes:null,f:e|y|512,first:null,fn:t,last:null,next:null,parent:n,b:n&&n.b,prev:null,teardown:null,wv:0,ac:null};F?.register_created_effect(r);var i=r;if(e&4)Et===null?At.ensure().schedule(r):Et.push(r);else if(t!==null){try{lr(r)}catch(e){throw jn(r),e}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&!(i.f&524288)&&(i=i.first,e&16&&e&65536&&i!==null&&(i.f|=T))}if(i!==null&&(i.parent=n,n!==null&&hn(i,n),U!==null&&U.f&2&&!(e&64))){var a=U;(a.effects??=[]).push(i)}return r}function _n(){return U!==null&&!Un}function vn(e){let t=gn(8,null);return $e(t,v),t.teardown=e,t}function yn(e){mn(`$effect`);var t=W.f;if(!U&&t&32&&N!==null&&!N.i){var n=N;(n.e??=[]).push(e)}else return bn(e)}function bn(e){return gn(4|ee,e)}function xn(e){return mn(`$effect.pre`),gn(8|ee,e)}function Sn(e){At.ensure();let t=gn(64|E,e);return(e={})=>new Promise(n=>{e.outro?Pn(t,()=>{jn(t),n(void 0)}):(jn(t),n(void 0))})}function Cn(e){return gn(4,e)}function wn(e){return gn(te|E,e)}function Tn(e,t=0){return gn(8|t,e)}function H(e,t=[],n=[],r=[]){st(r,t,n,t=>{gn(8,()=>{e(...t.map(G))})})}function En(e,t=0){return gn(16|t,e)}function Dn(e){return gn(32|E,e)}function On(e){var t=e.teardown;if(t!==null){let n=Vn,r=U;Hn(!0),Wn(null);try{t.call(null)}catch(t){pn(t,e.parent)}finally{Hn(n),Wn(r)}}}function kn(e,t=!1){var n=e.first;for(e.first=e.last=null;n!==null;){let e=n.ac;e!==null&&at(()=>{e.abort(de)});var r=n.next;n.f&64?n.parent=null:jn(n,t),n=r}}function An(e){for(var t=e.first;t!==null;){var n=t.next;t.f&32||jn(t),t=n}}function jn(e,t=!0){var n=!1;(t||e.f&262144)&&e.nodes!==null&&e.nodes.end!==null&&(Mn(e.nodes.start,e.nodes.end),n=!0),e.f|=w,kn(e,t&&!n),cr(e,0);var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)e.stop();On(e),e.f^=w,e.f|=S;var i=e.parent;i!==null&&i.first!==null&&Nn(e),e.next=e.prev=e.teardown=e.ctx=e.deps=e.fn=e.nodes=e.ac=e.b=null}function Mn(e,t){for(;e!==null;){var n=e===t?null:sn(e);e.remove(),e=n}}function Nn(e){var t=e.parent,n=e.prev,r=e.next;n!==null&&(n.next=r),r!==null&&(r.prev=n),t!==null&&(t.first===e&&(t.first=r),t.last===e&&(t.last=n))}function Pn(e,t,n=!0){var r=[];e.f|=256,Fn(e,r,!0);var i=()=>{n&&jn(e),t&&t()},a=r.length;if(a>0){var o=()=>--a||i();for(var s of r)s.out(o)}else i()}function Fn(e,t,n){if(!(e.f&8192)){e.f^=x;var r=e.nodes&&e.nodes.t;if(r!==null)for(let e of r)(e.is_global||n)&&t.push(e);for(var i=e.first;i!==null;){var a=i.next;if(!(i.f&64)){var o=!!(i.f&65536)||!!(i.f&32)&&!!(e.f&16);Fn(i,t,o?n:!1)}i=a}}}function In(e){e.f&=-257,Ln(e,!0)}function Ln(e,t){if(!(e.f&256)&&e.f&8192){e.f^=x,e.f&1024||($e(e,y),At.ensure().schedule(e));for(var n=e.first;n!==null;){var r=n.next,i=!!(n.f&65536)||!!(n.f&32);Ln(n,i?t:!1),n=r}var a=e.nodes&&e.nodes.t;if(a!==null)for(let e of a)(e.is_global||t)&&e.in()}}function Rn(e,t){if(e.nodes)for(var n=e.nodes.start,r=e.nodes.end;n!==null;){var i=n===r?null:sn(n);t.append(n),n=i}}var zn=null,Bn=!1,Vn=!1;function Hn(e){Vn=e}var U=null,Un=!1;function Wn(e){U=e}var W=null;function Gn(e){W=e}var Kn=null;function qn(e){U!==null&&(U.f&2097152||U.f&2)&&(Kn??=new Set).add(e)}var Jn=null,Yn=0,Xn=null;function Zn(e){Xn=e}var Qn=1,$n=0,er=$n;function tr(e){er=e}function nr(){return++Qn}function rr(e){var t=e.f;if(t&2048)return!0;if(t&4096){for(var n=e.deps,r=n.length,i=0;ie.wv)return!0}t&512&&St===null&&$e(e,v)}return!1}function ir(e,t,n=!0){var r=e.reactions;if(r!==null&&!(Kn!==null&&Kn.has(e)))for(var i=0;i{e.ac.abort(de)}),e.ac=null);try{e.f|=O;var u=e.fn,d=u();e.f|=C;var f=or(e);if(qe()&&Xn!==null&&!Un&&f!==null&&!(e.f&6146))for(var p=0;p0)for(t.length=Yn+Jn.length,r=0;r{s.ac.abort(de),s.ac=null,$e(s,y)}),vt(s),cr(s,0)}}function cr(e,t){var n=e.deps;if(n!==null)for(var r=t;rn?.call(this,e))}return e.startsWith(`pointer`)||e.startsWith(`touch`)||e===`wheel`?(i.__removed=!1,Xe(()=>{i.__removed||t.addEventListener(e,i,r)})):t.addEventListener(e,i,r),i}function Sr(e,t,n,r,i){var a={capture:r,passive:i},o=xr(e,t,n,a);(t===document.body||t===window||t===document||t instanceof HTMLMediaElement)&&vn(()=>{o.__removed=!0,t.removeEventListener(e,o,a)})}function K(e,t,n){(t[vr]??={})[e]=n}function Cr(e){for(var t=0;t{Tr=!1,wr=null}));var s=0,c=wr===e&&e[vr];if(c){var l=a.indexOf(c);if(l!==-1&&(t===document||t===window)){e[vr]=t;return}var u=a.indexOf(t);if(u===-1)return;l<=u&&(s=l)}if(o=a[s]||e.target,o!==t){i(e,`currentTarget`,{configurable:!0,get(){return o||n}});var d=U,f=W;Wn(null),Gn(null);try{for(var p,m=[];o!==null&&o!==t;){try{var h=o[vr]?.[r];h!=null&&(!o.disabled||e.target===o)&&h.call(o,e)}catch(e){p?m.push(e):p=e}if(e.cancelBubble)break;s++,o=s{throw e});throw p}}finally{e[vr]=t,delete e.currentTarget,Wn(d),Gn(f)}}}var Dr=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy(`svelte-trusted-html`,{createHTML:e=>e});function Or(e){return Dr?.createHTML(e)??e}function kr(e){var t=un(`template`);return t.innerHTML=Or(e.replaceAll(``,``)),t.content}function Ar(e,t){var n=W;n.nodes===null&&(n.nodes={start:e,end:t,a:null,t:null})}function q(e,t){var n=!!(t&1),r=!!(t&2),i,a=!e.startsWith(``);return()=>{if(A)return Ar(j,null),j;i===void 0&&(i=kr(a?e:``+e),n||(i=on(i)));var t=r||en?document.importNode(i,!0):i.cloneNode(!0);if(n){var o=on(t),s=t.lastChild;Ar(o,s)}else Ar(t,t);return t}}function jr(e,t,n=`svg`){var r=!e.startsWith(``),i=!!(t&1),a=`<${n}>${r?e:``+e}`,o;return()=>{if(A)return Ar(j,null),j;if(!o){var e=on(kr(a));if(i)for(o=document.createDocumentFragment();on(e);)o.appendChild(on(e));else o=on(e)}var t=o.cloneNode(!0);if(i){var n=on(t),r=t.lastChild;Ar(n,r)}else Ar(t,t);return t}}function Mr(e,t){return jr(e,t,`svg`)}function Nr(e=``){if(!A){var t=an(e+``);return Ar(t,t),t}var n=j;return n.nodeType===3?dn(n):(n.before(n=an()),xe(n)),Ar(n,n),n}function Pr(){if(A)return Ar(j,null),j;var e=document.createDocumentFragment(),t=document.createComment(``),n=an();return e.append(t,n),Ar(t,n),e}function J(e,t){if(A){var n=W;(!(n.f&32768)||n.nodes.end===null)&&(n.nodes.end=j),Se();return}e!==null&&e.before(t)}function Fr(){if(A&&j&&j.nodeType===8&&j.textContent?.startsWith(`$`)){let e=j.textContent.substring(1);return Se(),e}return(window.__svelte??={}).uid??=1,`c${window.__svelte.uid++}`}function Ir(e){let t=0,n=Vt(0),r;return()=>{_n()&&(G(n),Tn(()=>(t===0&&(r=pr(()=>e(()=>Jt(n)))),t+=1,()=>{Xe(()=>{--t,t===0&&(r?.(),r=void 0,Jt(n))})})))}}var Lr=T|E;function Rr(e,t,n,r){new zr(e,t,n,r)}var zr=class{parent;is_pending=!1;transform_error;#e;#t=A?j:null;#n;#r;#i;#a=null;#o=null;#s=null;#c=null;#l=0;#u=0;#d=!1;#f=new Set;#p=new Set;#m=null;#h=Ir(()=>(this.#m=Vt(this.#l),()=>{this.#m=null}));constructor(e,t,n,r){this.#e=e,this.#n=t,this.#r=e=>{var t=W;t.b=this,t.f|=128,n(e)},this.parent=W.b,this.transform_error=r??this.parent?.transform_error??(e=>e),this.#i=En(()=>{if(A){let e=this.#t;Se();let t=e.data===`[!`;if(e.data.startsWith(`[?`)){let t=JSON.parse(e.data.slice(2));this.#_(t)}else t?this.#y():this.#g()}else this.#b()},Lr),A&&(this.#e=j)}#g(){try{this.#a=Dn(()=>this.#r(this.#e))}catch(e){this.error(e)}}#_(e){let t=this.#n.failed,{reset:n,invoke_onerror:r}=this.#v(e);Xe(r),t&&(this.#s=Dn(()=>{t(this.#e,()=>e,()=>n)}))}#v(e){var t=!1,n=!1;let r=()=>{if(t){ye();return}t=!0,n&&Be(),this.#s!==null&&Pn(this.#s,()=>{this.#s=null}),this.#S(()=>{this.#b()})};return{reset:r,invoke_onerror:()=>{try{n=!0,this.#n.onerror?.(e,r),n=!1}catch(e){pn(e,this.#i&&this.#i.parent)}}}}#y(){let e=this.#n.pending;e&&(this.is_pending=!0,this.#o=Dn(()=>e(this.#e)),Xe(()=>{var e=this.#c=document.createDocumentFragment(),t=an(),n=!1;if(e.append(t),this.#a=this.#S(()=>{try{return Dn(()=>this.#r(t))}catch(e){try{this.error(e),n=!0}catch(e){pn(e,this.#i.parent)}return null}}),this.#a===null){this.#c=null,n&&this.#x(F);return}this.#u===0&&(this.#e.before(e),this.#c=null,Pn(this.#o,()=>{this.#o=null}),this.#x(F))}))}#b(){try{if(this.is_pending=this.has_pending_snippet(),this.#u=0,this.#l=0,this.#a=Dn(()=>{this.#r(this.#e)}),this.#u>0){var e=this.#c=document.createDocumentFragment();Rn(this.#a,e);let t=this.#n.pending;this.#o=Dn(()=>t(this.#e))}else this.#x(F)}catch(e){this.error(e)}}#x(e){this.is_pending=!1,e.transfer_effects(this.#f,this.#p)}defer_effect(e){tt(e,this.#f,this.#p)}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!this.#n.pending}#S(e){var t=W,n=U,r=N;Gn(this.#i),Wn(this.#i),Ue(this.#i.ctx);try{return At.ensure(),e()}finally{Gn(t),Wn(n),Ue(r)}}#C(e,t){if(!this.has_pending_snippet()){this.parent&&this.parent.#C(e,t);return}this.#u+=e,this.#u===0&&(this.#x(t),this.#o&&Pn(this.#o,()=>{this.#o=null}),this.#c&&=(this.#e.before(this.#c),null))}update_pending_count(e,t){this.#C(e,t),this.#l+=e,!(!this.#m||this.#d)&&(this.#d=!0,Xe(()=>{this.#d=!1,this.#m&&Gt(this.#m,this.#l)}))}get_effect_pending(){return this.#h(),G(this.#m)}error(e){if(!this.#n.onerror&&!this.#n.failed)throw e;F?.is_fork?(this.#a&&F.skip_effect(this.#a),this.#o&&F.skip_effect(this.#o),this.#s&&F.skip_effect(this.#s),F.oncommit(()=>{this.#w(e)})):this.#w(e)}#w(e){this.#a&&=(jn(this.#a),null),this.#o&&=(jn(this.#o),null),this.#s&&=(jn(this.#s),null),A&&(xe(this.#t),Ce(),xe(we()));let t=this.#n.failed,n=e=>{let{reset:n,invoke_onerror:r}=this.#v(e);r(),t&&(this.#s=this.#S(()=>{try{return Dn(()=>{var r=W;r.b=this,r.f|=128,t(this.#e,()=>e,()=>n)})}catch(e){return pn(e,this.#i.parent),null}}))};Xe(()=>{var t;try{t=this.transform_error(e)}catch(e){pn(e,this.#i&&this.#i.parent);return}typeof t==`object`&&t&&typeof t.then==`function`?t.then(n,e=>pn(e,this.#i&&this.#i.parent)):n(t)})}};function Y(e,t){var n=t==null?``:typeof t==`object`?`${t}`:t;n!==(e[le]??=e.nodeValue)&&(e[le]=n,e.nodeValue=`${n}`)}function Br(e,t){return Hr(e,t)}var Vr=new Map;function Hr(e,{target:t,anchor:n,props:i={},events:a,context:o,intro:s=!0,transformError:c}){rn();var l=void 0,u=Sn(()=>{var s=n??t.appendChild(an());Rr(s,{pending:()=>{}},t=>{We({});var n=N;if(o&&(n.c=o),a&&(i.$$events=a),A&&Ar(t,null),l=e(t,i)||Ke(),A&&(W.nodes.end=j,j===null||j.nodeType!==8||j.data!==`]`))throw _e(),pe;Ge()},c);var u=new Set,d=e=>{for(var n=0;n{for(var e of u)for(let n of[t,document]){var r=Vr.get(n),i=r.get(e);--i==0?(n.removeEventListener(e,Er),r.delete(e),r.size===0&&Vr.delete(n)):r.set(e,i)}br.delete(d),s!==n&&s.parentNode?.removeChild(s)}});return Ur.set(l,u),l}var Ur=new WeakMap,Wr=class{anchor;#e=new Map;#t=new Map;#n=new Map;#r=new Set;#i=!0;constructor(e,t=!0){this.anchor=e,this.#i=t}#a=e=>{if(this.#e.has(e)){var t=this.#e.get(e),n=this.#t.get(t);if(n)In(n),this.#r.delete(t);else{var r=this.#n.get(t);r&&(In(r.effect),this.#t.set(t,r.effect),this.#n.delete(t),r.fragment.lastChild.remove(),this.anchor.before(r.fragment),n=r.effect)}for(let[t,n]of this.#e){if(this.#e.delete(t),t===e)break;let r=this.#n.get(n);r&&(jn(r.effect),this.#n.delete(n))}for(let[e,r]of this.#t){if(e===t||this.#r.has(e))continue;let i=()=>{if(Array.from(this.#e.values()).includes(e)){var t=document.createDocumentFragment();Rn(r,t),t.append(an()),this.#n.set(e,{effect:r,fragment:t})}else jn(r);this.#r.delete(e),this.#t.delete(e)};this.#i||!n?(this.#r.add(e),Pn(r,i,!1)):i()}}};#o=e=>{this.#e.delete(e);let t=Array.from(this.#e.values());for(let[e,n]of this.#n)t.includes(e)||(jn(n.effect),this.#n.delete(e))};ensure(e,t){var n=F,r=ln();if(t&&!this.#t.has(e)&&!this.#n.has(e)){if(r){var i=document.createDocumentFragment(),a=an();i.append(a),this.#n.set(e,{effect:Dn(()=>t(a)),fragment:i})}else this.#t.set(e,Dn(()=>t(this.anchor)))}if(this.#e.set(n,e),r){for(let[t,r]of this.#t)t===e?n.unskip_effect(r):n.skip_effect(r);for(let[t,r]of this.#n)t===e?n.unskip_effect(r.effect):n.skip_effect(r.effect);n.oncommit(this.#a),n.ondiscard(this.#o)}else A&&(this.anchor=j),this.#a(n)}};function X(e,t,n=!1){var r;A&&(r=j,Se());var i=new Wr(e),a=n?T:0;function o(e,t){if(A){var n=Te(r);if(e!==parseInt(n.substring(1))){var a=we();xe(a),i.anchor=a,be(!1),i.ensure(e,t),be(!0);return}}i.ensure(e,t)}En(()=>{var e=!1;t((t,n=0)=>{e=!0,o(n,t)}),e||o(-1,null)},a)}var Gr=Symbol(`NaN`);function Kr(e,t,n){A&&Se();var r=new Wr(e),i=!qe();En(()=>{var e=t();e!==e&&(e=Gr),i&&typeof e==`object`&&e&&(e={}),r.ensure(e,n)})}function qr(e,t){return t}function Jr(e,t,n){for(var i=[],a=t.length,o,s=t.length,c=0;c{if(o){if(o.pending.delete(n),o.done.add(n),o.pending.size===0){var t=e.outrogroups;Yr(e,r(o.done)),t.delete(o),t.size===0&&(e.outrogroups=null)}}else--s},!1)}if(s===0){var l=i.length===0&&n!==null&&e.pending.size===0;if(l){var u=n,d=u.parentNode;cn(d),d.append(u),e.items.clear()}Yr(e,t,!l)}else o={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(o)}function Yr(e,t,n=!0){var r;if(e.pending.size>0){r=new Set;for(let t of e.pending.values())for(let n of t)r.add(e.items.get(n).e)}for(var i=0;i{var t=i();return e(t)?t:t==null?[]:r(t)}),p,m=new Map,h=!0;function g(e){v.effect.f&16384||(v.pending.delete(e),v.fallback=d,Qr(v,p,c,n,a),d!==null&&(p.length===0?d.f&33554432?(d.f^=D,ei(d,null,c)):In(d):Pn(d,()=>{d=null})))}function _(e){v.pending.delete(e)}var v={effect:En(()=>{p=G(f);var e=p.length;let t=!1;A&&Te(c)===`[!`!=(e===0)&&(c=we(),xe(c),be(!1),t=!0);for(var r=new Set,u=F,v=ln(),y=0;ys(c)):(d=Dn(()=>s(Xr??=an())),d.f|=D)),e>r.size&&je(``,``,``),A&&e>0&&xe(we()),!h){if(m.set(u,r),v){for(let[e,t]of l)r.has(e)||u.skip_effect(t.e);u.oncommit(g),u.ondiscard(_)}else g(u)}t&&be(!0),G(f)}),flags:n,items:l,pending:m,outrogroups:null,fallback:d};h=!1,A&&(c=j)}function Zr(e){for(;e!==null&&!(e.f&32);)e=e.next;return e}function Qr(e,t,n,i,a){var o=!!(i&8),s=t.length,c=e.items,l=Zr(e.effect.first),u,d=null,f,p=[],m=[],h,g,_,v;if(o)for(v=0;v0){var E=i&4&&s===0?n:null;if(o){for(v=0;v{if(f!==void 0)for(_ of f)_.nodes?.a?.apply()})}function $r(e,t,n,r,i,a,o,s){var c=o&1?o&16?Vt(n):Ht(n,!1,!1):null,l=o&2?Vt(i):null;return{v:c,i:l,e:Dn(()=>(a(t,c??n,l??i,s),()=>{e.delete(r)}))}}function ei(e,t,n){if(e.nodes)for(var r=e.nodes.start,i=e.nodes.end,a=t&&!(t.f&33554432)?t.nodes.start:n;r!==null;){var o=sn(r);if(a.before(r),r===i)return;r=o}}function ti(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function ni(e,t,n){var r;A&&(r=j,Se());var i=new Wr(e);En(()=>{var e=t()??null;if(A&&Te(r)===`[`!=(e!==null)){var a=we();xe(a),i.anchor=a,be(!1),i.ensure(e,e&&(t=>n(t,e))),be(!0);return}i.ensure(e,e&&(t=>n(t,e)))},T)}var ri=[...` +\r\f\xA0\v`];function ii(e,t,n){var r=e==null?``:``+e;if(t&&(r=r?r+` `+t:t),n){for(var i of Object.keys(n))if(n[i])r=r?r+` `+i:i;else if(r.length)for(var a=i.length,o=0;(o=r.indexOf(i,o))>=0;){var s=o+a;(o===0||ri.includes(r[o-1]))&&(s===r.length||ri.includes(r[s]))?r=(o===0?``:r.substring(0,o))+r.substring(s+1):o=s}}return r===``?null:r}function ai(e,t=!1){var n=t?` !important;`:`;`,r=``;for(var i of Object.keys(e)){var a=e[i];a!=null&&a!==``&&(r+=` `+i+`: `+a+n)}return r}function oi(e){return e[0]!==`-`||e[1]!==`-`?e.toLowerCase():e}function si(e,t){if(t){var n=``,r,i;if(Array.isArray(t)?(r=t[0],i=t[1]):r=t,e){e=String(e).replaceAll(/\/\*.*?\*\//g,``).trim();var a=!1,o=0,s=!1,c=[];r&&c.push(...Object.keys(r).map(oi)),i&&c.push(...Object.keys(i).map(oi));var l=0,u=-1;let t=e.length;for(var d=0;d{t.every(_i)||(`__defaultValue`in e&&fi(e,!1),`__value`in e&&pi(e,e.__value))});t.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`]}),vn(()=>{t.disconnect()})}function hi(e,t,n=t){var r=new WeakSet,i=!0;ot(e,`change`,t=>{var i=t?`[selected]`:`:checked`,a;if(e.multiple)a=[].map.call(e.querySelectorAll(i),gi);else{var o=e.querySelector(i)??e.querySelector(`option:not([disabled])`);a=o&&gi(o)}n(a),e.__value=a,F!==null&&r.add(F)}),Cn(()=>{var a=t();if(e===document.activeElement){var o=F;if(r.has(o))return}if(pi(e,a,i),i&&a===void 0){var s=e.querySelector(`:checked`);s!==null&&(a=gi(s),n(a))}e.__value=a,i=!1})}function gi(e){return`__value`in e?e.__value:e.value}function _i(e){if(e.target.closest(`selectedcontent`)!==null)return!0;if(e.type===`childList`){var t=[...e.addedNodes,...e.removedNodes];return t.length>0&&t.every(e=>e.nodeName===`SELECTEDCONTENT`)}return!1}var vi=Symbol(`is custom element`),yi=Symbol(`is html`),bi=fe?`link`:`LINK`;function xi(e){if(A){var t=!1,n=()=>{if(!t){if(t=!0,e.hasAttribute(`value`)){var n=e.value;Q(e,`value`,null),e.value=n}if(e.hasAttribute(`checked`)){var r=e.checked;Q(e,`checked`,null),e.checked=r}}};e[ue]=n,Xe(n),it()}}function Si(e,t){var n=Ci(e);n.checked!==(n.checked=t??void 0)&&(e.checked=t)}function Q(e,t,n,r){var i=Ci(e);A&&(i[t]=e.getAttribute(t),t===`src`||t===`srcset`||t===`href`&&e.nodeName===bi)||i[t]!==(i[t]=n)&&(t===`loading`&&(e[ae]=n),n==null?e.removeAttribute(t):typeof n!=`string`&&Ti(e).has(t)?e[t]=n:e.setAttribute(t,n))}function Ci(e){return e[oe]??={[vi]:e.nodeName.includes(`-`),[yi]:e.namespaceURI===he}}var wi=new Map;function Ti(e){var t=e.getAttribute(`is`)||e.nodeName,n=wi.get(t);if(n)return n;wi.set(t,n=new Set);for(var r,i=e,a=Element.prototype;a!==i;){for(var s in r=o(i),r)r[s].set&&s!==`innerHTML`&&s!==`textContent`&&s!==`innerText`&&n.add(s);i=l(i)}return n}function Ei(e,t,n=t){var r=new WeakSet;ot(e,`input`,async i=>{var a=i?e.defaultValue:e.value;if(a=ji(e)?Mi(a):a,n(a),F!==null&&r.add(F),await ur(),a!==(a=t())){var o=e.selectionStart,s=e.selectionEnd,c=e.value.length;if(e.value=a??``,s!==null){var l=e.value.length;o===s&&s===c&&l>c?(e.selectionStart=l,e.selectionEnd=l):(e.selectionStart=o,e.selectionEnd=Math.min(s,l))}}}),(A&&e.defaultValue!==e.value||pr(t)==null&&e.value)&&(n(ji(e)?Mi(e.value):e.value),F!==null&&r.add(F)),Tn(()=>{var n=t();if(e===document.activeElement){var i=F;if(r.has(i))return}ji(e)&&n===Mi(e.value)||(e.type!==`date`||n||e.value)&&n!==e.value&&(e.value=n??``)})}var Di=new Set;function Oi(e,t,n,r,i=r){var a=n.getAttribute(`type`)===`checkbox`,o=e;let s=!1;if(t!==null)for(var c of t)o=o[c]??=[];o.push(n),ot(n,`change`,()=>{var e=n.__value;a&&(e=Ai(o,e,n.checked)),i(e)},()=>i(a?[]:null)),Tn(()=>{var e=r();if(A&&n.defaultChecked!==n.checked){s=!0;return}a?(e||=[],n.checked=e.includes(n.__value)):n.checked=Qt(n.__value,e)}),vn(()=>{var e=o.indexOf(n);e!==-1&&o.splice(e,1)}),Di.has(o)||(Di.add(o),Xe(()=>{o.sort((e,t)=>e.compareDocumentPosition(t)===4?-1:1),Di.delete(o)})),Xe(()=>{if(s){var e=a?Ai(o,e,n.checked):o.find(e=>e.checked)?.__value;i(e)}})}function ki(e,t,n=t){ot(e,`change`,t=>{n(t?e.defaultChecked:e.checked)}),(A&&e.defaultChecked!==e.checked||pr(t)==null)&&n(e.checked),Tn(()=>{e.checked=!!t()})}function Ai(e,t,n){for(var r=new Set,i=0;i{var n=this.#e.get(e);n.delete(t),n.size===0&&(this.#e.delete(e),this.#t.unobserve(e))}}#r(){return this.#t??=new ResizeObserver(t=>{for(var n of t){e.entries.set(n.target,n);for(var r of this.#e.get(n.target)||[])r(n)}})}}({box:`border-box`});function Pi(e,t,n){var r=Ni.observe(e,()=>n(e[t]));Cn(()=>(pr(()=>n(e[t])),r))}function Fi(e,t){return e===t||e?.[ne]===t}function Ii(e=Ke(),t,n,r){var i=N.r,a=W;return Cn(()=>{var o,s;return Tn(()=>{o=s,s=r?.()||[],pr(()=>{Fi(n(...s),e)||(t(e,...s),o&&Fi(n(...o),e)&&t(null,...o))})}),()=>{let r=a;for(;r!==i&&r.parent!==null&&r.parent.f&33554432;)r=r.parent;let o=()=>{s&&Fi(n(...s),e)&&t(null,...s)},c=r.teardown;r.teardown=()=>{o(),c?.()}}}),e}function Li(e,t,n,r,i){var a=()=>{r(n[e])};n.addEventListener(t,a),i?Tn(()=>{n[e]=i()}):a(),(n===document.body||n===window||n===document)&&vn(()=>{n.removeEventListener(t,a)})}function Ri(e=!1){let t=N,n=t.l.u;if(!n)return;let r=()=>mr(t.s);if(e){let e=0,n={},i=dt(()=>{let r=!1,i=t.s;for(let e in i)i[e]!==n[e]&&(n[e]=i[e],r=!0);return r&&e++,e});r=()=>G(i)}n.b.length&&xn(()=>{zi(t,r),m(n.b)}),yn(()=>{let e=pr(()=>n.m.map(p));return()=>{for(let t of e)typeof t==`function`&&t()}}),n.a.length&&yn(()=>{zi(t,r),m(n.a)})}function zi(e,t){if(e.l.s)for(let t of e.l.s)G(t);t()}var Bi=!1;function Vi(e){var t=Bi;try{return Bi=!1,[e(),Bi]}finally{Bi=t}}var Hi={get(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(d(r)&&(r=r()),typeof r==`object`&&r&&t in r)return r[t]}},set(e,t,n){let r=e.props.length;for(;r--;){let i=e.props[r];d(i)&&(i=i());let o=a(i,t);if(o&&o.set)return o.set(n),!0}return!1},getOwnPropertyDescriptor(e,t){let n=e.props.length;for(;n--;){let r=e.props[n];if(d(r)&&(r=r()),typeof r==`object`&&r&&t in r){let e=a(r,t);return e&&!e.configurable&&(e.configurable=!0),e}}},has(e,t){if(t===ne||t===ie)return!1;for(let n of e.props)if(d(n)&&(n=n()),n!=null&&t in n)return!0;return!1},ownKeys(e){let t=[];for(let n of e.props)if(d(n)&&(n=n()),n){for(let e in n)t.includes(e)||t.push(e);for(let e of Object.getOwnPropertySymbols(n))t.includes(e)||t.push(e)}return t}};function Ui(...e){return new Proxy({props:e},Hi)}function Wi(e,t,n,r){var i=!Ve||!!(n&2),o=!!(n&8),s=!!(n&16),c=r,l=!0,u=void 0,d=()=>s&&i?(u??=dt(r),G(u)):(l&&(l=!1,c=s?pr(r):r),c);let f;if(o){var p=ne in e||ie in e;f=a(e,t)?.set??(p&&t in e?n=>e[t]=n:void 0)}var m,h=!1;o?[m,h]=Vi(()=>e[t]):m=e[t],m===void 0&&r!==void 0&&(m=d(),f&&(i&&Ie(t),f(m)));var g=i?()=>{var n=e[t];return n===void 0?d():(l=!0,n)}:()=>{var n=e[t];return n!==void 0&&(c=void 0),n===void 0?c:n};if(i&&!(n&4))return g;if(f){var _=e.$$legacy;return(function(e,t){return arguments.length>0?((!i||!t||_||h)&&f(t?g():e),e):g()})}var v=!1,y=(n&1?dt:mt)(()=>(v=!1,g()));o&&G(y);var b=W;return(function(e,t){if(arguments.length>0){let n=t?G(y):i&&o?Xt(e):e;return L(y,n),v=!0,c!==void 0&&(c=n),e}return Vn&&v||b.f&16384?y.v:G(y)})}function Gi(e){N===null&&ke(`onMount`),Ve&&N.l!==null?qi(N).m.push(e):yn(()=>{let t=pr(e);if(typeof t==`function`)return t})}function Ki(e){N===null&&ke(`onDestroy`),Gi(()=>()=>pr(e))}function qi(e){var t=e.l;return t.u??={a:[],b:[],m:[]}}typeof window<`u`&&((window.__svelte??={}).v??=new Set).add(`5`);function Ji(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,i,a,o=[],s=``,c=e.split(`/`);for(c[0]||c.shift();i=c.shift();)n=i[0],n===`*`?(o.push(`wild`),s+=`/(.*)`):n===`:`?(r=i.indexOf(`?`,1),a=i.indexOf(`.`,1),o.push(i.substring(1,~r?r:~a?a:i.length)),s+=~r&&!~a?`(?:/([^/]+?))?`:`/([^/]+?)`,~a&&(s+=(~r?`?`:``)+`\\`+i.substring(a))):s+=`/`+i;return{keys:o,pattern:RegExp(`^`+s+(t?`(?=$|/)`:`/?$`),`i`)}}var Yi=new class{#e=I(Xi());get _loc(){return G(this.#e)}set _loc(e){L(this.#e,e)}#t=P(()=>this._loc.location);get _location(){return G(this.#t)}set _location(e){L(this.#t,e)}#n=P(()=>this._loc.querystring);get _querystring(){return G(this.#n)}set _querystring(e){L(this.#n,e)}#r=I(void 0);get _params(){return G(this.#r)}set _params(e){L(this.#r,e)}get loc(){return this._loc}get location(){return this._location}get querystring(){return this._querystring}get params(){return this._params}constructor(){typeof window<`u`?window.addEventListener(`hashchange`,()=>{this._loc=Xi()}):console.warn(`[svelte-spa-router] window 'window' is not defined, skipping initiation`)}};function Xi(){let e=typeof window<`u`?window.location.href:``,t=e.indexOf(`#/`),n=t>-1?e.substr(t+1):`/`,r=n.indexOf(`?`),i=``;return r>-1&&(i=n.substr(r+1),n=n.substr(0,r)),{location:n,querystring:i}}function Zi(e){e?window.scrollTo(e.__svelte_spa_router_scrollX||0,e.__svelte_spa_router_scrollY||0):window.scrollTo(0,0)}function Qi(e,t){We(t,!0);let n=Wi(t,`routes`,19,()=>({})),r=Wi(t,`prefix`,3,``),i=Wi(t,`restoreScrollState`,3,!1),a=Wi(t,`onConditionsFailed`,3,()=>{}),o=Wi(t,`onRouteLoaded`,3,()=>{}),s=Wi(t,`onRouteLoading`,3,()=>{}),c=Wi(t,`onRouteEvent`,3,()=>{});class l{path;component;conditions;userData;props;_pattern;_keys;constructor(e,t){let n=e=>typeof e==`object`&&!!e&&e._sveltesparouter===!0;if(!t||typeof t!=`function`&&!n(t))throw Error(`Invalid component object`);if(!e||typeof e==`string`&&(e.length<1||e.charAt(0)!=`/`&&e.charAt(0)!=`*`)||typeof e==`object`&&!(e instanceof RegExp))throw Error(`Invalid value for "path" argument - strings must start with / or *`);let r=Ji(e);if(this.path=e,n(t)){let e=t;this.component=e.component,this.conditions=e.conditions||[],this.userData=e.userData,this.props=e.props||{}}else{let e=t;this.component=()=>Promise.resolve(e),this.conditions=[],this.props={}}this._pattern=r.pattern,this._keys=r.keys}match(e){if(r()){if(typeof r()==`string`){if(e.startsWith(r()))e=e.substr(r().length)||`/`;else return null}else if(r()instanceof RegExp){let t=e.match(r());if(t&&t[0])e=e.substr(t[0].length)||`/`;else return null}}let t=this._pattern.exec(e);if(t===null)return null;if(this._keys===!1)return t;let n={},i=0;for(;i{u.push(new l(t,e))}):Object.keys(n()).forEach(e=>{let t=n();u.push(new l(e,t[e]))});let d=I(null),f=I(null),p=I({}),m=null,h=null;yn(()=>{history.scrollRestoration=i()?`manual`:`auto`}),yn(()=>{if(!i())return;let e=e=>{m=e.state&&(e.state.__svelte_spa_router_scrollY||e.state.__svelte_spa_router_scrollX)?e.state:null};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)});async function g(e,t){await ur(),e(t)}yn(()=>{let e=Yi.loc,t=!1;return pr(async()=>{let n=0;for(;n{t=!0}});function _(e){return e&&typeof e==`object`&&Object.keys(e).length?e:null}var v=Pr(),y=z(v),b=e=>{let t=P(()=>G(d));var n=Pr(),r=z(n),i=e=>{var n=Pr();ni(z(n),()=>G(t),(e,t)=>{t(e,Ui({get params(){return G(f)},get onRouteEvent(){return c()}},()=>G(p)))}),J(e,n)},a=e=>{var n=Pr();ni(z(n),()=>G(t),(e,t)=>{t(e,Ui({get onRouteEvent(){return c()}},()=>G(p)))}),J(e,n)};X(r,e=>{G(f)?e(i):e(a,-1)}),J(e,n)};X(y,e=>{G(d)&&e(b)}),J(e,v),Ge()}var $i=[`bars`,`pace`,`zone`,`pie`,`fuel`,`resets`,`thresholds`],ea=`codexometer.web.preferences.v1`,ta={statusLine:null,tab:`quota`,view:`bars`,selected:``,defaultDetail:0,layouts:[]};function na(){try{let e=JSON.parse(localStorage.getItem(ea)||`null`);return!e||typeof e!=`object`?ta:{statusLine:Array.isArray(e.statusLine)?[...new Set(e.statusLine.filter(e=>typeof e==`string`&&e.length<64))].slice(0,32):null,tab:[`quota`,`sessions`,`usage`].includes(e.tab)?e.tab:`quota`,view:$i.includes(e.view)?e.view:`bars`,selected:typeof e.selected==`string`?e.selected.slice(0,256):``,defaultDetail:+(e.defaultDetail===1),layouts:Array.isArray(e.layouts)?e.layouts.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`string`&&t.id.length<=256&&[0,1,2].includes(t.level)}).slice(-100):[]}}catch{return ta}}var ra=Xt(na()),ia=Xt({open:!1});function aa(){let e=JSON.stringify(ra);try{localStorage.setItem(ea,e)}catch{}}function oa(){return ra.tab===`quota`?`/quota/`+ra.view:`/`+ra.tab}function sa(e){return ra.layouts.find(t=>t.id===e)?.level??ra.defaultDetail}function ca(e){ra.defaultDetail=e,ra.layouts=[]}function la(e,t){ra.layouts=[...ra.layouts.filter(t=>t.id!==e),{id:e,level:Math.max(0,Math.min(2,t))}].slice(-100)}var $=Xt({data:null,connected:!1,error:``}),ua=e=>e==null?`Unavailable`:e.toLocaleString(`en-GB`),da=e=>!e||String(e).startsWith(`0001-`)?`Not yet available`:new Date(typeof e==`number`?e*1e3:e).toLocaleString(`en-GB`),fa=`codexometer.web.session`,pa=class extends Error{},ma;async function ha(e,t,n){if(!ma||!$.connected||!$.data?.control||$.data.sessionsError)throw Error(`Session controls unavailable. Check the live connection.`);return await ma(e,t,n)}function ga(){let e=new AbortController,t,n=``;ma=async(t,r,i)=>{let a=await fetch(`/api/control/`+t,{method:`POST`,headers:{Authorization:`Bearer ${n}`,"Content-Type":`application/json`},body:JSON.stringify(r),signal:AbortSignal.any([e.signal,AbortSignal.timeout(8e3),...i?[i]:[]]),cache:`no-store`});if(!a.ok)throw a.status===502?Error(`Outcome uncertain. Check Codex before taking another action; nothing was retried.`):new pa(`Action rejected, expired or changed. Refresh and check Codex; nothing was retried.`);return a.json()};try{n=sessionStorage.getItem(fa)||``}catch{}let r=location.hash,i=r.startsWith(`#pair=`)?r.slice(6):``;(i||!r||r===`#`)&&(history.replaceState(null,``,`/#`+oa()),window.dispatchEvent(new HashChangeEvent(`hashchange`)));async function a(){if(i)try{let t=await fetch(`/api/pair`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({secret:i}),signal:e.signal});if(!t.ok)throw Error(`Pairing link expired or already used. Restart --web for a fresh link.`);n=(await t.json()).token;try{sessionStorage.setItem(fa,n)}catch{}}catch(t){e.signal.aborted||($.error=t instanceof Error?t.message:`Pairing failed`);return}if(!n){$.error=`Open the private pairing link printed by codexometer --web in your terminal.`;return}await o()}async function o(){try{let t=await fetch(`/api/events`,{headers:{Authorization:`Bearer ${n}`},signal:e.signal,cache:`no-store`});if(t.status===401){try{sessionStorage.removeItem(fa)}catch{}$.error=`Browser session expired. Restart --web and open its new pairing link.`;return}if(!t.ok||!t.body)throw Error(`Live connection unavailable`);let r=t.body.getReader(),i=new TextDecoder,a=``;for(;!e.signal.aborted;){let{done:e,value:t}=await r.read();if(e)break;a+=i.decode(t,{stream:!0});let n;for(;(n=a.indexOf(` + +`))>=0;){let e=a.slice(0,n);a=a.slice(n+2),e.startsWith(`data: `)&&($.data=JSON.parse(e.slice(6)),$.connected=!0,$.error=``)}}}catch{}finally{$.connected=!1}e.signal.aborted||($.error=`Connection lost — showing last observation. Reconnecting…`,t=setTimeout(o,2500))}return a(),()=>{ma=void 0,e.abort(),clearTimeout(t),$.connected=!1}}He();var _a=q(`

      Quota refresh failed. Policy state is based on the last successful + observation.

      `),va=q(`

      `),ya=q(`

      The longest Codex quota window selects one active model profile. ASK + creates a per-session review; AUTO applies the profile on the next + eligible check.

      `,1),ba=q(`

      No threshold-based model steps were configured at launch.

      `);function xa(e,t){We(t,!1),Ri();var n=Pr(),r=z(n),i=e=>{var t=ya(),n=z(t),r=B(n),i=V(n,2),a=e=>{J(e,_a())};X(i,e=>{$.data.quotaError&&e(a)});var o=V(i,2),s=R(o),c=B(s),l=V(s,4);Z(l,5,()=>$.data.thresholds,qr,(e,t)=>{var n=va();let r;var i=R(n),a=B(i),o=V(i,2),s=R(o),c=B(s,!0),l=B(V(s,2));M(o);var u=V(o,2),d=B(u,!0),f=B(V(u,2));M(n),H((e,i)=>{r=ci(n,1,``,null,r,{active:G(t).state===`ACTIVE`,next:G(t).state===`NEXT`}),Y(a,`${G(t).threshold??``}%`),Y(c,G(t).model),Y(l,`${e??``} REASONING // ${i??``} + SPEED`),Y(d,G(t).mode),Y(f,`${G(t).state??``}${G(t).state===`NEXT`?` // ${G(t).remaining||0} PP TO GO`:``}`)},[()=>G(t).effort.toUpperCase(),()=>G(t).speed.toUpperCase()]),J(e,n)}),M(l),M(o),H(e=>{Y(r,`MODEL STEP POLICY // OBSERVED ${e??``}`),Y(c,`THRESHOLDS // ${$.data.thresholds.length??``} CONFIGURED`)},[()=>da($.data.quotaAt)]),J(e,t)},a=e=>{J(e,ba())};X(r,e=>{$.data?.thresholds?.length?e(i):e(a,-1)}),J(e,n),Ge()}var Sa=Mr(``),Ca=Mr(` `,1),wa=Mr(` `,1),Ta=Mr(`SAFE`),Ea=Mr(` `,1),Da=Mr(` `,1),Oa=q(`
      `,1),ka=q(` `),Aa=q(`
      Quota observations
      Observed atPeriod elapsedConsumedTrail segment
      `),ja=q(`
      OBSERVATION DATA
      `),Ma=q(`
      QUOTA PERIOD ELAPSED
      `,1);function Na(e,t){let n=Fr();We(t,!0);let r=Wi(t,`trail`,19,()=>[]),i=Wi(t,`paceView`,3,!1),a=I(!1),o=I(!0),s=I(`window`),c=[0,25,50,75,100],l={off:0,halfHour:30,hour:60,day:1440,window:0},u=P(()=>i()?[-100,-50,0,50,100]:c),d=P(()=>i()?-100:0),f=P(()=>i()?200:100),p=I(400),m=I(240),h=P(()=>G(p)-24),g=P(()=>G(m)-48),_=P(()=>Math.max(1,G(h)-48)),v=P(()=>Math.max(1,G(g)-20)),y=P(()=>48+Math.max(0,Math.min(100,t.elapsed))/100*G(_));function b(e){return G(g)-(e-G(d))/G(f)*G(v)}function x(e,t){return i()?e-t:e}let S=P(()=>b(x(t.used,t.elapsed))),C=P(()=>t.used-t.elapsed),w=P(()=>r().map((e,t)=>`${t===0||e.break?`M`:`L`}${48+e.elapsed/100*G(_)} ${b(x(e.used,e.elapsed))}`).join(` `)),T=P(()=>{let e=0;for(let t=r().length-1;t>0;t--)if(r()[t].break){e=t;break}return r().slice(e)}),E=P(()=>G(T).length<2?0:Math.max(0,Date.parse(G(T).at(-1).at)-Date.parse(G(T)[0].at)));function ee(e){if(G(E)Date.parse(e.at)>=t).length>=2}let D=P(()=>({off:!0,halfHour:ee(18e5),hour:ee(36e5),day:ee(864e5),window:Number.isFinite(t.elapsed)&&t.elapsed>0&&Number.isFinite(t.used)}));yn(()=>{G(s)!==`window`&&!G(D)[G(s)]&&L(s,`window`)});function O(e){if(e===`off`||!G(D)[e])return[];let t=l[e]*6e4,n=Date.parse(G(T).at(-1).at)-t,r=G(T).findIndex(e=>Date.parse(e.at)>=n);return r<0?[]:G(T).slice(r)}function te(e){if(e.length<2)return null;let t=e.reduce((e,t)=>e+t.elapsed,0)/e.length,n=e.reduce((e,t)=>e+t.used,0)/e.length,r=0,i=0;for(let a of e)r+=(a.elapsed-t)*(a.used-n),i+=(a.elapsed-t)**2;return i>0?Math.max(0,r/i):null}let k=P(()=>{let e=G(s)===`window`&&G(D).window?t.used/t.elapsed:te(O(G(s)));if(e===null||!t.duration)return null;let n=t.used+e*(100-t.elapsed),r=G(s)===`window`?0:t.used-e*t.elapsed,a=e-+!!i(),o=Math.max(0,t.elapsed-l[G(s)]/t.duration*100);G(s)===`window`&&(o=0);let c=100;if(a!==0){let e=(G(d)-r)/a,t=(G(d)+G(f)-r)/a;o=Math.max(o,Math.min(e,t)),c=Math.min(100,Math.max(e,t))}if(o>c)return null;let u=r+a*o,p=r+a*c,m=Math.hypot((c-o)/100*G(_),(p-u)/G(f)*G(v)),h=Math.max(3,Math.min(9,Math.floor(m/65)+2));return{path:`M${Array.from({length:h},(e,t)=>{let n=o+(c-o)*t/(h-1),r=u+(p-u)*t/(h-1);return`${48+n/100*G(_)} ${b(r)}`}).join(` L`)}`,projected:n,safe:n<=100}}),ne=P(()=>{if(G(T).length===0)return`NO OBSERVATIONS`;if(G(T).length===1)return`ONE OBSERVATION`;let e=Math.floor(G(E)/6e4);if(e<60)return`${e} MIN CONTINUOUS`;let t=Math.floor(e/60);return t<24?`${t}H CONTINUOUS`:`${Math.floor(t/24)}D ${t%24}H CONTINUOUS`});var re=Ma(),ie=z(re),ae=R(ie);let oe;var se=R(ae),ce=R(se),le=V(R(ce)),ue=e=>{J(e,Sa())};X(le,e=>{i()&&e(ue)});var de=V(le);Ce(),M(ce);var fe=V(ce);M(se);var pe=V(se),me=V(pe);Z(me,17,()=>c,qr,(e,t)=>{var n=Ca(),r=z(n),i=V(r),a=B(i);H(()=>{Q(r,`x1`,48+G(t)/100*G(_)),Q(r,`x2`,48+G(t)/100*G(_)),Q(r,`y2`,G(g)),Q(i,`x`,48+G(t)/100*G(_)),Q(i,`y`,G(g)+20),Y(a,`${G(t)??``}%`)}),J(e,n)});var he=V(me);Z(he,17,()=>G(u),qr,(e,t)=>{var n=wa(),r=z(n),a=V(r),o=B(a,!0);H((e,n,s)=>{Q(r,`y1`,e),Q(r,`x2`,G(h)),Q(r,`y2`,n),Q(a,`y`,s),Y(o,i()?`${G(t)>0?`+`:``}${G(t)}`:`${G(t)}%`)},[()=>b(G(t)),()=>b(G(t)),()=>b(G(t))+4]),J(e,n)});var ge=V(he),_e=V(ge),ve=V(_e),ye=e=>{var t=Ta();H(e=>{Q(t,`x`,G(h)-5),Q(t,`y`,e)},[()=>b(0)-6]),J(e,t)};X(ve,e=>{i()&&e(ye)});var A=V(ve),be=e=>{var t=Ea(),n=z(t),i=V(n),a=V(i),o=B(R(a));M(a),H((e,t)=>{Q(n,`d`,G(w)),Q(i,`d`,G(w)),Q(a,`cx`,48+r()[0].elapsed/100*G(_)),Q(a,`cy`,e),Y(o,`First observation: ${t??``}`)},[()=>b(x(r()[0].used,r()[0].elapsed)),()=>da(r()[0].at)]),J(e,t)};X(A,e=>{G(o)&&r().length&&e(be)});var j=V(A),xe=e=>{var t=Da(),r=z(t),i=V(r),a=B(R(i));M(i),H(e=>{Q(r,`d`,G(k).path),Q(i,`d`,G(k).path),Q(i,`marker-mid`,`url(#${n}-trend-arrow)`),Y(a,`${G(s)===`window`?`Window-average pace`:`Recent consumption trajectory`} projects ${e??``}% at reset if continued`)},[()=>G(k).projected.toFixed(1)]),J(e,t)};X(j,e=>{G(k)&&e(xe)});var Se=V(j),we=B(Se,!0),Te=V(Se),Ee=V(Te),De=V(Ee),Oe=B(R(De));M(De),M(ae),M(ie);var ke=V(ie,2),Ae=R(ke),je=R(Ae),Me=e=>{var t=Nr();H(e=>Y(t,`${G(C)>0?`+`:``}${e??``} PP FROM SAFETY`),[()=>G(C).toFixed(1)]),J(e,t)},Ne=e=>{var n=Nr();H(()=>Y(n,`${t.used??``}% + USED`)),J(e,n)};X(je,e=>{i()?e(Me):e(Ne,-1)});var Pe=V(je),Fe=V(Pe,3),Ie=B(Fe,!0),Le=V(Fe,2),Re=e=>{var t=Oa(),n=B(V(z(t)));H(e=>Y(n,`TREND // ${e??``}`),[()=>i()?`${G(k).projected-100>0?`+`:``}${(G(k).projected-100).toFixed(1)} PP AT RESET`:G(k).projected>=100?`QUOTA EXHAUSTION PROJECTED`:`${G(k).projected.toFixed(1)}% PROJECTED AT RESET`]),J(e,t)};X(Le,e=>{G(k)&&e(Re)}),M(Ae);var ze=V(Ae,2),Be=R(ze),Ve=R(Be);xi(Ve),Ce(),M(Be);var He=V(Be,2),N=V(R(He),2),Ue=R(N);Ue.value=Ue.__value=`off`;var Ke=V(Ue),qe=B(Ke);Ke.value=Ke.__value=`halfHour`;var Je=V(Ke),Ye=B(Je);Je.value=Je.__value=`hour`;var Xe=V(Je),Ze=B(Xe);Xe.value=Xe.__value=`day`;var Qe=V(Xe),$e=B(Qe);Qe.value=Qe.__value=`window`,M(N),mi(N),M(He);var et=B(V(He,2));M(ze),M(ke);var tt=V(ke,2),nt=e=>{var t=ja(),n=V(R(t),2),i=e=>{var t=Aa(),n=R(t),i=V(R(n),2);Z(i,21,r,qr,(e,t,n)=>{var r=ka(),i=R(r),a=R(i),o=B(a,!0);M(i);var s=V(i),c=B(s),l=V(s),u=B(l),d=B(V(l),!0);M(r),H((e,r)=>{Q(a,`datetime`,G(t).at),Y(o,e),Y(c,`${r??``}%`),Y(u,`${G(t).used??``}%`),Y(d,n===0?`First observation`:G(t).break?`Gap before this observation`:`Connected to previous observation`)},[()=>da(G(t).at),()=>G(t).elapsed.toFixed(1)]),J(e,r)}),M(i),M(n),M(t),J(e,t)};X(n,e=>{G(a)&&e(i)}),M(t),Li(`open`,`toggle`,t,e=>L(a,e),()=>G(a)),J(e,t)};X(tt,e=>{r().length&&e(nt)}),H((e,r,a,o,s,c,l)=>{Q(ae,`viewBox`,`0 0 ${G(p)} ${G(m)}`),Q(ae,`aria-label`,e),oe=ui(ae,``,oe,{"--trend-color":G(k)?.safe?`#115b35`:`#7f1825`}),Q(ce,`id`,n),Q(ce,`x2`,i()?`0%`:`100%`),Q(de,`stop-color`,i()?`#ae903b`:`#8c793d`),Q(fe,`id`,n+`-trend-arrow`),Q(pe,`width`,G(_)),Q(pe,`height`,G(v)),Q(pe,`fill`,`url(#${n})`),Q(ge,`d`,`M48 20 V${G(g)} H${G(h)}`),Q(_e,`y1`,r),Q(_e,`x2`,G(h)),Q(_e,`y2`,a),Y(we,i()?`DISTANCE FROM SAFETY (PP)`:`CONSUMPTION`),Q(Te,`x`,48+G(_)/2),Q(Te,`y`,G(m)-5),Q(Ee,`cx`,G(y)),Q(Ee,`cy`,G(S)),Q(De,`cx`,G(y)),Q(De,`cy`,G(S)),Y(Oe,`${t.used??``}% consumed // ${o??``}% of period elapsed${s??``}`),Y(Pe,` // ${c??``}% TIME ELAPSED`),Y(Ie,l),Ke.disabled=!G(D).halfHour,Y(qe,`LAST 30 MINUTES${G(D).halfHour?``:` — UNAVAILABLE`}`),Je.disabled=!G(D).hour,Y(Ye,`LAST HOUR${G(D).hour?``:` — UNAVAILABLE`}`),Xe.disabled=!G(D).day,Y(Ze,`LAST 24 HOURS${G(D).day?``:` — UNAVAILABLE`}`),Qe.disabled=!G(D).window,Y($e,`FROM WINDOW START${G(D).window?``:` — NO TIME ELAPSED`}`),Y(et,`HISTORY // ${G(ne)??``}`)},[()=>`${i()?`Pace zone`:`Consumption zone`}: ${t.used}% consumed, ${t.elapsed.toFixed(1)}% of quota period elapsed. ${i()?`${G(C).toFixed(1)} percentage points from safety.`:`${G(C)>0?`Above`:G(C)<0?`Below`:`On`} the steady-consumption line.`}${G(o)&&r().length?` Trace path contains ${r().length} ${r().length===1?`observation`:`observations`}; gaps are not interpolated.`:``}`,()=>b(0),()=>i()?b(0):b(100),()=>t.elapsed.toFixed(1),()=>i()?` // ${G(C).toFixed(1)} PP from safety`:``,()=>t.elapsed.toFixed(1),()=>Math.abs(G(C))<.05?`ON PACE`:G(C)>0?i()?`ABOVE SAFETY — CONSUMPTION AHEAD OF TIME`:`ABOVE THE LINE — CONSUMING FASTER THAN TIME`:i()?`BELOW SAFETY — QUOTA HEADROOM`:`BELOW THE LINE — WITHIN PACE`]),Pi(ie,`clientWidth`,e=>L(p,e)),Pi(ie,`clientHeight`,e=>L(m,e)),ki(Ve,()=>G(o),e=>L(o,e)),hi(N,()=>G(s),e=>L(s,e)),J(e,re),Ge()}var Pa=q(` `),Fa=q(`

      Quota refresh failed. Values below are the last successful observation.

      `),Ia=q(`

      Expiry details unavailable. No listed expiry does not mean no expiry.

      `),La=q(`

      `),Ra=q(`

      Read-only preview. Use the terminal to redeem a reset.

      The backend may return only some credits. This list does not establish + redemption order.

      `),za=q(` `,1),Ba=Mr(``),Va=Mr(``),Ha=q(`
      `),Ua=q(`

      Cycle duration or reset date unavailable — position cannot be + plotted.

      `),Wa=q(`
      EMPTYFULL
      `),Ga=q(`

      `,1),Ka=q(`
      `,1),qa=q(`

      `),Ja=q(`

      `),Ya=q(`

      No quota windows reported yet.

      `),Xa=q(`
      `,1),Za=q(`

      All reported windows are shown. API-equivalent learning and quota status + scoring remain in the terminal for this first preview.

      `,1),Qa=q(` `,1);function $a(e,t){We(t,!0);let n=Wi(t,`params`,19,()=>({})),r=P(()=>$i.filter(e=>e!==`thresholds`||!!$.data?.thresholds?.length)),i=I(Xt(Date.now())),a=P(()=>G(r).includes(n().view||``)?n().view:`bars`);Gi(()=>{let e=setInterval(()=>L(i,Date.now(),!0),1e3);return()=>clearInterval(e)});function o(e){return!e.duration||e.duration<=0||!e.reset?null:Math.max(0,Math.min(100,100*(1-(e.reset*1e3-G(i))/(e.duration*6e4))))}yn(()=>{ra.view=G(a)});function s(e){let t=e/100*Math.PI*2;return`M60 60 L60 14 A46 46 0 ${+(e>50)} 1 ${60+46*Math.sin(t)} ${60-46*Math.cos(t)} Z`}var c=Qa(),l=z(c);Z(l,21,()=>G(r),qr,(e,t)=>{var n=Pa();let r;var i=B(n,!0);H(e=>{Q(n,`href`,`#/quota/`+G(t)),Q(n,`aria-current`,G(a)===G(t)?`page`:void 0),r=ci(n,1,``,null,r,{active:G(a)===G(t)}),Y(i,e)},[()=>G(t)===`fuel`?`FUEL TANK`:G(t).toUpperCase()]),J(e,n)}),M(l);var u=V(l,2),d=e=>{var t=Za(),n=z(t),r=e=>{J(e,Fa())};X(n,e=>{$.data.quotaError&&e(r)});var i=V(n,2),c=B(i),l=V(i,2),u=e=>{xa(e,{})},d=e=>{var t=Ra(),n=R(t),r=B(n),i=V(n,4),a=e=>{J(e,Ia())};X(i,e=>{$.data.credits.length||e(a)}),Z(V(i,2),17,()=>$.data.credits,qr,(e,t)=>{var n=La(),r=R(n),i=B(r),a=B(V(r,2),!0);M(n),H(e=>{Y(i,`${(G(t).title||`Quota reset`)??``} // ${G(t).status??``}`),Y(a,e)},[()=>G(t).expiryKnown?G(t).expires?`EXPIRES `+da(G(t).expires):`Does not expire`:`Expiry information unavailable`]),J(e,n)}),Ce(2),M(t),H(()=>Y(r,`RESET INVENTORY // ${$.data.creditCount??``} AVAILABLE`)),J(e,t)},f=e=>{var t=Xa(),n=z(t);let r;Z(n,21,()=>$.data.meters,qr,(e,t)=>{let n=P(()=>o(G(t)));var r=Ja(),i=R(r),c=B(i,!0),l=V(i,2),u=R(l),d=e=>{var n=za(),r=z(n),i=B(r),a=B(V(r));H(()=>{Y(i,`FREE ${100-G(t).used}%`),Y(a,`USED ${G(t).used??``}%`)}),J(e,n)},f=e=>{var n=za(),r=z(n),i=B(r),a=B(V(r));H(()=>{Y(i,`USED ${G(t).used??``}%`),Y(a,`FREE ${100-G(t).used}%`)}),J(e,n)};X(u,e=>{G(a)===`fuel`?e(d):e(f,-1)}),M(l);var p=V(l,2);let m;var h=R(p),g=e=>{var n=Ha(),r=R(n),i=V(R(r)),a=e=>{J(e,Ba())},o=e=>{var n=Va();H(e=>Q(n,`d`,e),[()=>s(G(t).used)]),J(e,n)};X(i,e=>{G(t).used>=100?e(a):G(t).used>0&&e(o,1)}),M(r),M(n),H(()=>Q(r,`aria-label`,`${G(t).used}% quota used`)),J(e,n)},_=e=>{var r=Pr(),i=z(r),o=e=>{{let r=P(()=>G(t).trail||[]),i=P(()=>G(a)===`pace`);Na(e,{get used(){return G(t).used},get elapsed(){return G(n)},get trail(){return G(r)},get duration(){return G(t).duration},get paceView(){return G(i)}})}},s=e=>{J(e,Ua())};X(i,e=>{G(n)===null?e(s,-1):e(o)}),J(e,r)},v=e=>{var r=Ka(),i=z(r),o=R(i);let s;M(i);var c=V(i,2),l=e=>{J(e,Wa())};X(c,e=>{G(a)===`fuel`&&e(l)});var u=V(c,2),d=e=>{var t=Ga(),r=z(t),i=B(r),o=V(r,2),s=R(o);let c;M(o),H(e=>{Y(i,`RESET CYCLE // ${e??``}% ELAPSED`),c=ui(s,``,c,{width:`${G(a)===`fuel`?100-G(n):G(n)}%`})},[()=>Math.floor(G(n))]),J(e,t)};X(u,e=>{G(n)!==null&&e(d)}),H(()=>{Q(i,`aria-label`,G(a)===`fuel`?`Fuel remaining`:`Quota used`),Q(i,`aria-valuenow`,G(a)===`fuel`?100-G(t).used:G(t).used),s=ui(o,``,s,{width:`${G(a)===`fuel`?100-G(t).used:G(t).used}%`})}),J(e,r)};X(h,e=>{G(a)===`pie`?e(g):G(a)===`zone`||G(a)===`pace`?e(_,1):e(v,-1)}),M(p);var y=V(p,2),b=B(y),x=V(y,2),S=e=>{var n=qa(),r=B(n,!0);H(()=>Y(r,G(t).details)),J(e,n)};X(x,e=>{G(t).details&&e(S)}),M(r),H(e=>{Y(c,G(t).name),m=ci(p,1,`meter-graphic`,null,m,{"bar-graphic":G(a)===`bars`||G(a)===`fuel`}),Y(b,`RESETS // ${e??``}`)},[()=>da(G(t).reset)]),J(e,r)}),M(n);var i=V(n,2),c=e=>{J(e,Ya())};X(i,e=>{$.data.meters.length||e(c)}),H(()=>r=ci(n,1,`quota-grid`,null,r,{radial:G(a)===`pie`,zone:G(a)===`zone`||G(a)===`pace`})),J(e,t)};X(l,e=>{G(a)===`thresholds`?e(u):G(a)===`resets`?e(d,1):e(f,-1)}),Ce(2),H(e=>Y(c,`QUOTA // OBSERVED ${e??``}`),[()=>da($.data.quotaAt)]),J(e,t)};X(u,e=>{$.data&&e(d)}),J(e,c),Ge()}var eo=q(`
      `),to=q(`

      `,1);function no(e,t){We(t,!0);let n=Wi(t,`values`,19,()=>[]),r=Wi(t,`label`,3,`Token activity`),i=Wi(t,`capacity`,3,0),a=P(()=>Math.max(0,...n())),o=P(()=>i()>n().length?[...Array(i()-n().length).fill(0),...n()]:n());var s=to(),c=z(s),l=B(c),u=V(c,2);Z(u,21,()=>G(o),qr,(e,t)=>{var n=eo();let r;H((e,t)=>{Q(n,`title`,e),r=ui(n,``,r,{height:t})},[()=>G(t).toLocaleString(`en-GB`)+` tokens`,()=>`${100*G(t)/Math.max(1,G(a))}%`]),J(e,n)}),M(u),H((e,t)=>{Y(l,`SCALE // 0 — ${e??``} TOKENS`),Q(u,`aria-label`,t)},[()=>G(a).toLocaleString(`en-GB`),()=>`${r()}. Peak ${G(a).toLocaleString(`en-GB`)} tokens.`]),J(e,s),Ge()}var ro=q(`

      `),io=q(`

      `,1),ao=q(`

      `),oo=q(`

      Loading / sending…

      `),so=q(`
      `),co=q(`

      Confirmation expired. Reopen the option.

      `),lo=q(`

      `,1),uo=q(`

       
      `,1),fo=q(` `),po=q(``),mo=q(`

      No available matching commands.

      `),ho=q(`

      ↑/↓ select · Tab complete · Enter options · Escape dismiss

      `),go=q(`
      `,1),_o=q(` `,1),vo=q(`
      `),yo=q(`
      `);function bo(e,t){We(t,!0);let n=Wi(t,`query`,3,``),r=Wi(t,`onchange`,3,()=>{}),i=Wi(t,`oncomplete`,3,e=>{}),a=I(!1),o=I(!1),s=I(``),c=I(null),l=I(null),u=I(``),d=I(0),f=I(Xt(Date.now())),p=I(``),m=0,h=I(0),g=I(null),_=I(void 0),v=setInterval(()=>{L(f,Date.now(),!0)},1e3);Ki(()=>{clearInterval(v),m++});let y=P(()=>n().trim().startsWith(`/`)&&!n().trim().startsWith(`//`)),b=P(()=>G(c)?.path===``&&G(y)?n().trim().slice(1).toLowerCase():``),x=P(()=>(G(c)?.choices||[]).filter(e=>!G(b)||e.label.toLowerCase().startsWith(`/`+G(b)))),S=P(()=>!$.connected||!!$.data?.sessionsError),C=P(()=>G(a)&&G(y)&&(!G(c)||G(c).path===``)&&!G(l));yn(()=>{n(),L(h,0)}),yn(()=>{let e=G(h);G(x),G(C)&&ur().then(()=>{let t=G(_)?.children[e];if(!t||!G(_))return;let n=G(_).getBoundingClientRect(),r=t.getBoundingClientRect();r.topn.bottom&&(G(_).scrollTop+=r.bottom-n.bottom)})});function w(e){if(!G(y)||!G(a)||G(c)&&G(c).path!==``||G(l)||G(S)||e.isComposing||e.ctrlKey||e.metaKey||e.altKey||![`ArrowUp`,`ArrowDown`,`Tab`,`Enter`,`Escape`].includes(e.key)||e.key===`Tab`&&e.shiftKey)return;if(e.preventDefault(),e.key===`Escape`){L(a,!1),L(g,n()),L(u,``);return}if(e.key===`ArrowUp`||e.key===`ArrowDown`){L(h,Math.min(Math.max(G(h)+(e.key===`ArrowUp`?-1:1),0),Math.max(G(x).length-1,0)),!0);return}let t=G(x)[G(h)];t&&!G(o)&&(e.key===`Tab`?i()(t.label):E(t))}yn(()=>{G(S)&&(m++,L(o,!1),L(u,``),G(a)&&(L(a,!1),L(g,n())),L(c,null),L(l,null))}),yn(()=>{G(y)&&!G(a)&&n()!==G(g)&&!G(S)&&(L(a,!0),T(``))});async function T(e){let n=++m;L(o,!0),L(l,null),L(u,``),L(s,``);try{let r=await ha(`commands`,{session:t.session,command:{mode:`list`,path:e}});n===m&&((e===``||e===`help`)&&r.choices.push({id:`local-statusline`,label:`/statusline`,help:`Choose multiple fields for Codexometer’s detail footer.`,next:`statusline`}),L(c,r,!0),L(p,r.value||``,!0),r.path.startsWith(`rename/`)&&r.choices.length===1&&E(r.choices[0]))}catch{n===m&&(L(s,`Command catalogue unavailable. Use Codex.`),(e===``||e===`help`)&&L(c,{title:`/ COMMANDS`,help:`Local display settings remain available.`,path:``,revision:``,choices:[{id:`local-statusline`,label:`/statusline`,help:`Choose multiple fields for Codexometer’s detail footer.`,next:`statusline`}]},!0))}finally{n===m&&L(o,!1)}}async function E(e){if(e.next===`statusline`){ia.open=!0,L(a,!1),L(g,n());return}if(e.next){await T(e.next);return}if(L(l,e,!0),L(u,``),L(s,``),!e.action||!G(c))return;let r=++m;L(o,!0);try{let n=await ha(`commands`,{session:t.session,command:{mode:`prepare`,path:G(c).path,revision:G(c).revision,choice:e.id}});r===m&&(L(u,n.confirmation,!0),L(d,Date.parse(n.expires),!0))}catch{r===m&&L(s,`Option changed or unavailable. Refresh before retrying.`)}finally{r===m&&L(o,!1)}}async function ee(){if(!G(u)||G(S)||G(o)||G(f)>=G(d)||!G(c))return;let e=G(u);L(u,``),L(o,!0);let n=++m;try{let i=await ha(`commands`,{session:t.session,confirmation:e,command:{mode:`commit`,path:G(c).path}});n===m&&(L(s,i.message,!0),L(a,!1),L(c,null),L(l,null),L(d,0),L(g,null),r()())}catch{n===m&&L(s,`Change unconfirmed. Check Codex before retrying.`)}finally{n===m&&L(o,!1)}}var D={handleKey:w},O=yo(),te=R(O),k=V(te,2),ne=e=>{var t=ro(),n=B(t,!0);H(()=>Y(n,G(s))),J(e,t)};X(k,e=>{G(s)&&!G(a)&&e(ne)});var re=V(k,2),ie=e=>{var n=vo();let r;var i=R(n),a=e=>{var t=io(),n=z(t),r=B(n,!0),i=B(V(n,2),!0);H(()=>{Y(r,G(c)?.title||`/ COMMANDS`),Y(i,G(c)?.help||`Loading live options…`)}),J(e,t)};X(i,e=>{G(C)||e(a)});var m=V(i,2),g=e=>{var t=ao(),n=B(t,!0);H(()=>Y(n,G(s))),J(e,t)};X(m,e=>{G(s)&&e(g)});var v=V(m,2),b=e=>{J(e,oo())};X(v,e=>{G(o)&&e(b)});var w=V(v,2),D=e=>{var t=so(),n=R(t),r=V(R(n));xi(r),M(n);var i=V(n,2);M(t),H(e=>{r.disabled=G(o)||G(S),i.disabled=e},[()=>G(o)||G(S)||!G(p).trim()]),Sr(`submit`,t,e=>{e.preventDefault(),G(p).trim()&&!G(o)&&!G(S)&&T(`rename/`+encodeURIComponent(G(p).trim()))}),Ei(r,()=>G(p),e=>L(p,e)),J(e,t)},O=e=>{var n=uo(),r=z(n),i=B(r,!0),a=V(r,2),s=B(a,!0),p=V(a,2),m=e=>{var n=lo(),r=z(n),i=R(r),a=V(i),s=e=>{J(e,Nr(`Only this session's saved name + changes.`))},l=P(()=>G(c)?.path.startsWith(`rename/`)),p=e=>{J(e,Nr(`Changes affect subsequent turns of this session, not global + defaults. Automatic quota thresholds may later supersede model + settings.`))};X(a,e=>{G(l)?e(s):e(p,-1)}),M(r);var m=V(r,2),h=V(m,2),g=e=>{J(e,co())};X(h,e=>{G(u)&&G(f)>=G(d)&&e(g)}),H(()=>{Y(i,`TARGET // ${t.session??``}. `),m.disabled=G(o)||G(S)||!G(u)||G(f)>=G(d)}),K(`click`,m,ee),J(e,n)};X(p,e=>{G(l).action&&e(m)});var h=V(p,2);H(()=>{Y(i,G(l).label),Y(s,G(l).help||`No additional help supplied by Codex.`),h.disabled=G(o)}),K(`click`,h,()=>{L(l,null),L(u,``)}),J(e,n)},te=e=>{var t=go(),n=z(t);let r;Z(n,23,()=>G(x),e=>e.id,(e,t,n)=>{var r=po();let i;var a=R(r),s=B(a,!0),l=V(a),u=B(l,!0),d=V(l),f=e=>{var n=fo(),r=B(n,!0);H(()=>Y(r,G(t).help)),J(e,n)};X(d,e=>{G(y)&&G(c)?.path===``&&e(f)}),M(r),H(()=>{r.disabled=G(o)||G(S),Q(r,`title`,G(t).help),Q(r,`aria-label`,G(t).label+(G(t).next?` →`:G(t).action?``:` // HELP`)),i=ci(r,1,`svelte-7bfwr9`,null,i,{suggested:G(y)&&G(c)?.path===``&&G(h)===G(n)}),Y(s,G(t).label),Y(u,G(t).next?` →`:G(t).action?``:` // HELP`)}),K(`click`,r,()=>E(G(t))),J(e,r)}),M(n),Ii(n,e=>L(_,e),()=>G(_));var i=V(n,2),a=e=>{J(e,mo())};X(i,e=>{!G(o)&&!G(x).length&&e(a)});var s=V(i,2),l=e=>{J(e,ho())};X(s,e=>{G(y)&&G(c)?.path===``&&e(l)}),H(()=>r=ci(n,1,`command-options svelte-7bfwr9`,null,r,{vertical:G(C)})),J(e,t)};X(w,e=>{G(c)?.input?e(D):G(l)?e(O,1):e(te,-1)});var k=V(w,2),ne=e=>{var t=_o(),n=z(t),r=V(n,2);H(()=>{n.disabled=G(o),r.disabled=G(o)}),K(`click`,n,()=>T(``)),K(`click`,r,()=>T(G(c)?.path||``)),J(e,t)};X(k,e=>{G(C)||e(ne)}),M(n),H(()=>{Q(n,`aria-label`,G(C)?`Slash command suggestions`:void 0),r=ci(n,1,`svelte-7bfwr9`,null,r,{"command-popup":G(C)})}),J(e,n)};return X(re,e=>{G(a)&&e(ie)}),M(O),H(()=>te.disabled=G(S)||G(o)),K(`click`,te,()=>{L(a,!G(a)),L(g,G(a)?null:n(),!0),L(u,``),G(a)&&T(``)}),J(e,O),Ge(D)}Cr([`click`]);var xo=q(` `,1),So=q(`
      `),Co=q(`
      /
      `);function wo(e,t){We(t,!0);let n=P(()=>t.lines.filter(e=>e.kind===`addition`).length),r=P(()=>t.lines.filter(e=>e.kind===`removal`).length);var i=Co(),a=R(i),o=R(a),s=B(o),c=B(V(o,2));M(a),Z(V(a,2),17,()=>t.lines,qr,(e,t)=>{var n=So();let r;var i=R(n),a=e=>{var n=xo(),r=z(n),i=B(r,!0),a=B(V(r),!0);H(()=>{Y(i,G(t).old||``),Y(a,G(t).new||``)}),J(e,n)};X(i,e=>{G(t).kind!==`heading`&&G(t).kind!==`metadata`&&e(a)});var o=B(V(i),!0);M(n),H(()=>{r=ci(n,1,`diff-line svelte-x4gtb6`,null,r,{added:G(t).kind===`addition`,removed:G(t).kind===`removal`,heading:G(t).kind===`heading`}),Y(o,G(t).text)}),J(e,n)}),M(i),H(()=>{Q(a,`aria-label`,`${G(n)} lines added, ${G(r)} lines removed`),Y(s,`+${G(n)??``}`),Y(c,`−${G(r)??``}`)}),J(e,i),Ge()}var To=q(`

      `),Eo=q(`

      Send this saved prompt now? This starts Codex work and consumes quota.

      `,1),Do=q(``),Oo=q(`

       

      In memory only. Follows session model, reasoning and speed. Closing + Codexometer cancels pending work.

      `),ko=q(`

      CURRENT PROFILE

      MODEL / REASONING LEVEL / SPEED

       

      PROPOSED PROFILE

      MODEL / REASONING LEVEL / SPEED

       

      Applied settings remain after Codexometer closes.

      `,1),Ao=q(`

      `),jo=q(`

       
      `,1),Mo=q(`

      Command unavailable from this observation. Open Codex to inspect the + request.

      `),No=q(`

      Session controls temporarily unavailable. Check Codex for current state.

      `),Po=q(`

      Checking session controls…

      `),Fo=q(`

      `),Io=q(`
      About browser controls

      Controls require a supported live request from a connected shared + app-server session. Local observations alone cannot provide them.

      `),Lo=q(` `,1),Ro=q(` `),zo=q(`Grants permission beyond this one action. Check the scope + carefully.`),Bo=q(``),Vo=q(``),Ho=q(``),Uo=q(``),Wo=q(`

      Not before this time; when quota and idle allow.

      `),Go=q(`

      `,1),Ko=q(`

      The existing trigger remains active until saved or deleted. If + it changes or sends while you edit, saving is blocked.

      `),qo=q(` `,1),Jo=q(``),Yo=q(``),Xo=q(``),Zo=q(` `,1),Qo=q(`
    • `),$o=q(`
      View fixed choices

      Type one of these choices exactly. Your answer stays masked.

        `),es=q(` `,1),ts=q(`

        `),ns=q(`

        `,1),rs=q(` `,1),is=q(``),as=q(`

        `,1),os=q(`

        `);function ss(e,t){We(t,!0);let n=[],r=Wi(t,`observedCommand`,3,``),i=Wi(t,`observedFileChanges`,19,()=>[]),a=Wi(t,`review`,3,``),o=Wi(t,`suspended`,3,!1),s=Wi(t,`openScheduler`,3,!1),c=Wi(t,`onProtectedChange`,3,e=>{}),l=I(null),u=I(Xt([])),d=I(null),f=I(``),p=I(0),m=I(Xt(Date.now())),h=I(!1),g=I(``),_=I(!1),v=I(!1),y=I(``),b=I(!1),x=I(``),S=I(!1),C=I(``),w=I(`now`),T=I(60),E=I(``),ee=I(!1),D=I(``),O=I(Xt([])),te=P(()=>G(O).find(e=>e.status!==`sent`)),k=I(void 0),ne=I(void 0);function re(e){if(G(b)){ur().then(()=>G(k)?.focus());return}if(e.status!==`pending`||G(h)||!G(l)?.id||G(l).kind!==`prompt`||G(l).questions?.length)return;L(b,!0),L(x,e.id,!0),ur().then(()=>G(k)?.focus()),L(u,[e.text],!0),L(w,e.trigger===`quota`?`quota`:`at`,!0),L(f,``),L(C,``);let t=new Date(e.at);e.trigger!==`quota`&&L(E,new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,16),!0)}yn(()=>{s()&&G(te)&&!G(S)&&G(l)?.id&&G(l).kind===`prompt`&&!G(l).questions?.length&&(L(S,!0),re(G(te)))});async function ie(){if(!a())try{L(O,await ha(`schedules`,{session:t.session},ye.signal),!0),G(b)&&!G(O).some(e=>e.id===G(x)&&e.status===`pending`)&&L(f,``),G(C)&&!G(O).some(e=>e.id===G(C)&&e.status===`pending`)&&(L(f,``),L(C,``))}catch{}}async function ae(e){try{L(O,await ha(`schedules`,{session:t.session,cancelId:e},ye.signal),!0),L(b,!1),L(f,``),L(C,``),L(u,[],!0)}catch(e){L(g,e instanceof Error?e.message:`Unable to cancel trigger.`,!0)}}yn(()=>(c()(G(h)||G(u).some(e=>e.length>0)),()=>c()(!1)));let oe=P(()=>$.data?.sessions.find(e=>e.id===t.session)?.status),se=P(()=>!$.connected||!!$.data?.sessionsError),ce=P(()=>a()!==`profile`&&G(l)?.kind===`prompt`&&!G(l).questions?.length&&!!$.data?.profiles?.some(e=>e.session===t.session&&e.pending)),le=P(()=>!G(se)&&!G(v)&&!!G(l)?.id&&G(l).kind===`approval`&&G(y)!==G(l).id),ue=P(()=>G(le)?G(l).command:r()),de=P(()=>!!G(f)&&G(m)G(l)?.questions?.length?G(l).questions:[{text:`Follow-up message`,secret:!1,freeText:!0,options:[]}]),pe=P(()=>G(l)?.kind===`approval`||G(l)?.kind===`profile`?G(d)!==null:G(u).length===G(fe).length&&G(u).every((e,t)=>e.trim().length>0&&(G(fe)[t].freeText||G(fe)[t].options?.includes(e)))),me=P(()=>G(l)?.kind===`prompt`&&!G(l).questions?.length&&G(w)!==`now`),he=P(()=>G(w)===`delay`?G(m)+G(T)*6e4:Date.parse(G(E))),ge=P(()=>{if(!G(me))return``;if(G(b)&&!G(O).some(e=>e.id===G(x)&&e.status===`pending`))return`Trigger changed, removed or already sent. Go back and reopen it; your draft has not been saved.`;if(!G(u)[0]?.trim())return`Enter a message to schedule.`;if(G(w)===`quota`)return``;if(!Number.isFinite(G(he))||G(he)<=G(m))return`Choose a future date/time or a delay greater than zero.`;let e=new Date(G(m));return e.setFullYear(e.getFullYear()+1),G(he)>=e.getTime()?`Choose a time within one year.`:``});function _e(e){return new Date(e).toLocaleString([],{timeZoneName:`short`})}function ve(e){if(e.status!==`pending`)return e.status;if(e.trigger===`at`&&Date.parse(e.at)>G(m))return`Due in `+Math.ceil((Date.parse(e.at)-G(m))/6e4)+` min`;let t=G(se)?`waiting for a fresh connection`:e.waitingReason||(e.canSend?`ready; awaiting dispatch`:`waiting for quota and an eligible idle session`);return(e.trigger===`at`?`Time reached — `:``)+t}yn(()=>{(G(se)||o()||G(ce)||G(m)>=G(p))&&L(f,``)});let ye=new AbortController;Gi(()=>{let e=e=>{e.ctrlKey&&e.key.toLowerCase()===`s`&&!a()&&G(te)&&(e.preventDefault(),re(G(te)))};window.addEventListener(`keydown`,e);let n,r=setInterval(()=>{L(m,Date.now(),!0)},1e3);async function i(){await ie();try{let e=await ha(`offer`,{session:t.session,...a()?{review:a()}:{}},ye.signal);if(ye.signal.aborted)return;L(v,!1),G(l)?.id!==e.id&&(L(f,``),L(d,null),L(u,Array(Math.max(1,e.questions?.length||0)).fill(``),!0)),L(l,e,!0),G(_)&&e.id&&e.id!==G(y)&&(L(g,``),L(_,!1))}catch{ye.signal.aborted||(L(l,null),L(v,!0),L(f,``))}finally{ye.signal.aborted||(n=setTimeout(i,2e3))}}return i(),()=>{window.removeEventListener(`keydown`,e),ye.abort(),clearTimeout(n),clearInterval(r)}});async function A(e){if(!e&&G(l)?.kind===`prompt`&&!G(l).questions?.length&&G(u)[0]?.trim().startsWith(`/`)&&!G(u)[0]?.trim().startsWith(`//`)){L(g,`Choose a slash command from COMMANDS; use // for literal slash text.`);return}if(!G(l)?.id||G(h)||G(se)||o()||G(ce)||(e?!e.canSend:!G(pe)||G(ge)))return;let n=G(l).id;L(h,!0),L(g,``),L(_,!1),L(f,``),L(C,e?.id||``,!0);try{let r=!e&&G(l).kind===`prompt`&&!G(l).questions?.length&&G(w)!==`now`?{trigger:G(w)===`quota`?`quota`:`at`,zone:Intl.DateTimeFormat().resolvedOptions().timeZone,...G(w)===`quota`?{}:{at:(G(w)===`delay`?new Date(Date.now()+G(T)*6e4):new Date(G(E))).toISOString()}}:void 0;L(ee,!!r),L(D,r?r.trigger===`quota`?`After fresh quota becomes available, when the session is idle`:_e(r.at)+` — not before this time; when quota and idle allow`:``,!0);let i=await ha(`prepare`,{session:t.session,...a()?{review:a()}:{},offer:n,...e?{sendId:e.id}:{},...r?{schedule:r}:{},...r&&G(b)?{editId:G(x)}:{},...G(l).kind===`approval`||G(l).kind===`profile`?{choice:G(d)}:{answers:e?[e.text]:[...G(u)]}},ye.signal);G(l)?.id===n&&!ye.signal.aborted&&!G(se)&&!o()&&!G(ce)&&(L(f,i.confirmation,!0),L(p,Date.parse(i.expires),!0))}catch(e){ye.signal.aborted||L(g,e instanceof Error?e.message:`Unable to prepare action.`,!0)}finally{L(h,!1)}}async function be(){if(!G(l)?.id||G(h)||o()||G(ce)||!G(de))return;let e=G(l).id,n=G(l).kind,r=G(f);L(f,``),L(h,!0),L(y,e,!0);try{await ha(`commit`,{session:t.session,...a()?{review:a()}:{},offer:e,confirmation:r},ye.signal),L(_,!0),L(b,!1),G(ee)&&(L(y,``),await ie()),L(g,G(ee)?`Trigger set. Closing Codexometer cancels it.`:n===`profile`?`Profile decision completed.`:n===`approval`?`Decision sent.`:`Text sent.`,!0)}catch(e){L(g,e instanceof pa?e.message:`Outcome uncertain. Check Codex before taking another action; nothing was retried.`,!0)}finally{L(h,!1),L(C,``),await ie(),L(u,[],!0),L(d,null)}}var j=Lo(),xe=z(j),Se=e=>{var t=Pr();Z(z(t),17,()=>G(O).filter(e=>e.status!==`sent`),e=>e.id,(e,t)=>{var n=Oo(),r=R(n),i=B(r,!0),a=V(r,2),s=B(a),c=V(a,2),u=B(c,!0),d=V(c,2),p=B(d,!0),m=V(d,2),_=B(m,!0),v=V(m,2),y=e=>{var t=To(),n=B(t,!0);H(()=>Y(n,G(g))),J(e,t)};X(v,e=>{G(g)&&e(y)});var b=V(v,4),x=V(b,2),S=V(x,2),w=e=>{var n=Eo(),r=V(z(n),2),i=V(r,2);H(()=>r.disabled=G(h)||G(se)||!G(t).canSend),K(`click`,r,be),K(`click`,i,()=>{L(f,``),L(C,``)}),J(e,n)},T=e=>{var n=Do();H(()=>n.disabled=G(h)||G(se)||!G(t).canSend||o()),K(`click`,n,()=>A(G(t))),J(e,n)};X(S,e=>{G(de)&&G(C)===G(t).id?e(w):e(T,-1)}),M(n),H((e,n)=>{Y(i,G(t).status===`uncertain`?`CHECK TRIGGER — outcome uncertain; not retried`:`SCHEDULED FOLLOW-UP`),Y(s,`TARGET // ${G(t).session??``}`),Y(u,e),Y(p,n),Y(_,G(t).text),b.disabled=G(h)||!G(l)?.id||G(l).kind!==`prompt`||!!G(l).questions?.length||G(t).status!==`pending`,x.disabled=G(h)||G(t).status===`sending`},[()=>G(t).trigger===`quota`?`After confirmed quota recovery, when idle`:`Not before ${_e(G(t).at)}`,()=>ve(G(t))]),K(`click`,b,()=>re(G(t))),K(`click`,x,()=>ae(G(t).id)),J(e,n)}),J(e,t)},we=P(()=>!a()&&G(l)?.kind!==`approval`&&!G(l)?.questions?.length&&![`APPROVAL NEEDED`,`INPUT NEEDED`].includes(G(oe)||``));X(xe,e=>{G(we)&&e(Se)});var Te=V(xe,2),Ee=e=>{var r=os(),o=R(r),s=B(o,!0),c=V(o,2),x=e=>{var t=ko(),n=z(t),r=B(n),i=V(n,6),a=B(i,!0),o=B(V(i,6),!0);Ce(2),H(()=>{Y(r,`Your ${G(l).profile.threshold??``}% quota threshold has been reached. Review + the profile for subsequent turns.`),Y(a,G(l).profile.current),Y(o,G(l).profile.proposed)}),J(e,t)};X(c,e=>{G(l)?.profile&&!G(se)&&!G(v)&&e(x)});var S=V(c,2),C=e=>{var t=Ao();let n;var r=B(t,!0);H(()=>{n=ci(t,1,`svelte-1oupzfc`,null,n,{notice:!G(_),sent:G(_)}),Y(r,G(g))}),J(e,t)};X(S,e=>{G(g)&&e(C)});var O=V(S,2),te=e=>{wo(e,{get lines(){return G(l).fileChanges}})},re=e=>{wo(e,{get lines(){return i()}})},ie=e=>{var t=jo(),n=z(t),r=B(n,!0),i=B(V(n,2),!0);H(()=>{Y(r,G(le)?`EXACT COMMAND`:`LAST OBSERVED COMMAND`),Y(i,G(ue))}),J(e,t)},ae=e=>{J(e,Mo())};X(O,e=>{G(l)?.fileChanges?.length&&!G(se)&&!G(v)?e(te):i().length?e(re,1):G(ue)?e(ie,2):a()!==`profile`&&G(oe)===`APPROVAL NEEDED`&&!G(_)&&e(ae,3)});var ce=V(O,2),me=e=>{J(e,No())},ve=e=>{J(e,Po())},ye=e=>{var t=Lo(),n=z(t),r=e=>{var t=Fo(),n=B(t,!0);H(e=>Y(n,e),[()=>G(oe)===`WORKING`?`Codex is working — nothing to respond to.`:[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(G(oe)||``)?`Respond in Codex for this request.`:`Nothing needs a response right now.`]),J(e,t)};X(n,e=>{(G(oe)===`WORKING`||!G(_)&&!G(h))&&e(r)});var i=V(n,2),a=e=>{J(e,Io())},o=P(()=>[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(G(oe)||``)&&!G(_));X(i,e=>{G(o)&&e(a)}),J(e,t)},j=e=>{var r=as(),i=z(r),o=B(i),s=V(i,2),c=R(s),g=B(c,!0),_=V(c,2),v=e=>{var r=Pr();Z(z(r),17,()=>G(l).choices||[],qr,(e,r,i)=>{var o=Bo(),s=R(o);xi(s),s.value=s.__value=i;var c=V(s),l=V(c),u=e=>{var t=Ro(),n=B(t,!0);H(()=>Y(n,G(r).detail)),J(e,t)};X(l,e=>{G(r).detail&&e(u)});var f=V(l,2),p=e=>{J(e,zo())};X(f,e=>{G(r).persistent&&e(p)}),M(o),H(()=>{Q(s,`name`,`decision-`+t.session+`-`+a()),Y(c,` ${G(r).label??``} `)}),Oi(n,[],s,()=>G(d),e=>L(d,e)),J(e,o)}),J(e,r)},y=e=>{var n=Lo(),r=z(n),i=e=>{var t=qo(),n=z(t),r=V(R(n)),i=R(r),a=e=>{var t=Vo();t.value=t.__value=`now`,J(e,t)};X(i,e=>{G(b)||e(a)});var o=V(i);o.value=o.__value=`quota`;var s=V(o);s.value=s.__value=`delay`;var c=V(s);c.value=c.__value=`at`,M(r),mi(r),M(n);var l=V(n,2),u=e=>{var t=Ho(),n=V(R(t));xi(n),M(t),Ei(n,()=>G(T),e=>L(T,e)),J(e,t)};X(l,e=>{G(w)===`delay`&&e(u)});var d=V(l,2),f=e=>{var t=Uo(),n=V(R(t));xi(n),M(t),Ei(n,()=>G(E),e=>L(E,e)),J(e,t)};X(d,e=>{G(w)===`at`&&e(f)});var p=V(d,2),m=e=>{var t=Go(),n=z(t),r=B(n),i=V(n,2),a=e=>{J(e,Wo())};X(i,e=>{G(w)!==`quota`&&e(a)});var o=V(i,2);o.textContent=`Timezone: ${Intl.DateTimeFormat().resolvedOptions().timeZone??``}. + One pending request per session; saving replaces it. Memory + only; Codexometer must stay running. Uses session model, + reasoning and speed.`,H(e=>Y(r,`Will send: ${e??``}`),[()=>G(w)===`quota`?`when quota is available and this session is idle`:Number.isFinite(G(he))?_e(G(he)):`choose a date and time`]),J(e,t)};X(p,e=>{G(w)!==`now`&&e(m)});var h=V(p,2),g=e=>{J(e,Ko())};X(h,e=>{G(b)&&e(g)}),hi(r,()=>G(w),e=>L(w,e)),J(e,t)};X(r,e=>{G(l).questions?.length||e(i)}),Z(V(r,2),17,()=>G(fe),qr,(e,n,r)=>{var i=es(),o=z(i),s=e=>{{let n=P(()=>G(u)[0]||``);Ii(bo(e,{get session(){return t.session},get query(){return G(n)},oncomplete:e=>{L(u,[e],!0),ur().then(()=>G(k)?.focus())},onchange:()=>{L(u,[``],!0),ur().then(()=>G(k)?.focus())}}),e=>L(ne,e,!0),()=>G(ne))}};X(o,e=>{r===0&&a()!==`profile`&&G(l).kind===`prompt`&&!G(l).questions?.length&&e(s)});var c=V(o,2),d=R(c),f=V(d),p=e=>{var t=Jo();xi(t),Ei(t,()=>G(u)[r],e=>G(u)[r]=e),J(e,t)},m=e=>{var t=Xo(),i=R(t);i.value=i.__value=``,Z(V(i),17,()=>G(n).options||[],qr,(e,t)=>{var n=Yo(),r=B(n,!0),i={};H(()=>{Y(r,G(t)),i!==(i=G(t))&&(n.value=(n.__value=i)??``)}),J(e,n)}),M(t),mi(t),hi(t,()=>G(u)[r],e=>G(u)[r]=e),J(e,t)},h=e=>{var t=Zo(),i=z(t);nt(i),Ii(i,e=>L(k,e),()=>G(k));var a=V(i,2),o=e=>{var t=Fo(),r=B(t);H(e=>Y(r,`Suggested answers: ${e??``}`),[()=>G(n).options.join(` · `)]),J(e,t)};X(a,e=>{G(n).options?.length&&e(o)}),K(`keydown`,i,e=>{G(l)?.kind===`prompt`&&!G(l).questions?.length&&G(ne)?.handleKey(e)}),Ei(i,()=>G(u)[r],e=>G(u)[r]=e),J(e,t)};X(f,e=>{G(n).secret?e(p):G(n).freeText?e(h,-1):e(m,1)}),M(c);var g=V(c,2),_=e=>{var t=$o(),r=V(R(t),4);Z(r,21,()=>G(n).options||[],qr,(e,t)=>{var n=Qo(),r=B(n,!0);H(()=>Y(r,G(t))),J(e,n)}),M(r),M(t),J(e,t)};X(g,e=>{G(n).secret&&!G(n).freeText&&e(_)}),H(()=>Y(d,`${G(n).text??``} `)),J(e,i)}),J(e,n)};X(_,e=>{G(l).kind===`approval`||G(l).kind===`profile`?e(v):e(y,-1)}),M(s);var x=V(s,2),S=e=>{var t=ns(),n=z(t),r=e=>{var t=ts(),n=B(t);H(()=>Y(n,`TRIGGER // ${G(D)??``}`)),J(e,t)};X(n,e=>{G(ee)&&e(r)});var i=V(n,2),a=B(i),o=V(i,2),s=B(o),c=V(o,2);H(e=>{Y(a,`Check the target and ${G(l).kind===`profile`?`profile above`:G(l).kind===`approval`?G(l).fileChanges?.length?`proposed file changes above`:`exact command and permission scope`:`message above`}. ${G(ee)?`This schedules a follow-up that will send automatically when eligible`:`This will send to Codex`}; it may start work using your quota. + Confirmation expires in ${e??``}s.`),o.disabled=G(h)||G(se),Y(s,`CONFIRM ${(G(l).kind===`approval`||G(l).kind===`profile`?G(l).choices?.[G(d)]?.label:G(ee)?G(b)?`SAVE CHANGES`:`SCHEDULE`:`SEND`)??``}`)},[()=>Math.max(0,Math.ceil((G(p)-G(m))/1e3))]),K(`click`,o,be),K(`click`,c,()=>{L(f,``)}),J(e,t)},C=e=>{var t=rs(),n=z(t),r=e=>{var t=To(),n=B(t,!0);H(()=>Y(n,G(ge))),J(e,t)};X(n,e=>{G(ge)&&e(r)});var i=V(n,2),a=B(i,!0);H(()=>{i.disabled=G(h)||G(se)||!G(pe)||!!G(ge),Y(a,G(h)?`SENDING…`:G(b)?`REVIEW CHANGES`:`REVIEW BEFORE SENDING`)}),K(`click`,i,()=>A()),J(e,t)};X(x,e=>{G(de)?e(S):e(C,-1)});var O=V(x,2),te=e=>{var t=is();K(`click`,t,()=>{L(b,!1),L(f,``),L(u,[],!0)}),J(e,t)};X(O,e=>{G(b)&&e(te)}),H(()=>{Y(o,`TARGET // ${G(l).thread??``} // ${(G(l).directory||`Directory unavailable`)??``}`),s.disabled=G(h)||G(de)||G(se),Y(g,G(l).kind===`approval`||G(l).kind===`profile`?`Choose a decision`:G(b)?`EDIT SCHEDULED FOLLOW-UP`:`Reply to this session`)}),J(e,r)};X(ce,e=>{G(se)||G(v)?e(me):G(l)?G(l).id?G(y)!==G(l).id&&e(j,3):e(ye,2):e(ve,1)}),M(r),H(()=>Y(s,a()===`profile`?`QUOTA THRESHOLD`:`SESSION CONTROL // EXPERIMENTAL`)),J(e,r)};X(Te,e=>{!G(ce)&&(!G(te)||G(b)||a()||G(l)?.kind!==`prompt`||G(l).questions?.length)&&e(Ee)}),J(e,j),Ge()}Cr([`click`,`keydown`]);var cs=q(` `,1),ls=q(`
        `),us=q(`

        STATUS LINE // CODEXOMETER

        Choose multiple fields and their order. These display preferences do not + change Codex CLI configuration. Missing values are omitted.

        `),ds=q(`

        `,1);function fs(e,t){We(t,!0);let n=Wi(t,`stale`,3,!1),r=I(Xt([])),i=I(!1),a=P(()=>$.data?.statusLineFields||[]),o=e=>[...new Set(e??G(a).filter(e=>e.default).map(e=>e.id))].filter(e=>G(a).some(t=>t.id===e)),s=e=>o(e).map(e=>e===`run-state`&&(n()||!$.connected||$.data?.sessionsError)?`STALE`:t.session.statusLine?.[e]).filter(Boolean).join(` · `),c=P(()=>[...G(r).map(e=>G(a).find(t=>t.id===e)).filter(Boolean),...G(a).filter(e=>!G(r).includes(e.id))]);yn(()=>{ia.open&&!G(i)?(L(r,o(ra.statusLine),!0),L(i,!0)):ia.open||L(i,!1)});function l(e,t){L(r,t?[...G(r),e]:G(r).filter(t=>t!==e),!0)}function u(e,t){let n=G(r).indexOf(e),i=n+t;if(n<0||i<0||i>=G(r).length)return;let a=[...G(r)];[a[n],a[i]]=[a[i],a[n]],L(r,a,!0)}var d=ds(),f=z(d),p=e=>{var t=us(),n=V(R(t),4);Z(n,21,()=>G(c),e=>e.id,(e,t)=>{var n=ls(),i=R(n),a=R(i);xi(a);var o=V(a,1,!0),s=B(V(o),!0);M(i);var c=V(i,2),d=e=>{var n=cs(),i=z(n),a=V(i,2);H((e,n)=>{Q(i,`aria-label`,`Move `+G(t).label+` earlier`),i.disabled=e,Q(a,`aria-label`,`Move `+G(t).label+` later`),a.disabled=n},[()=>G(r).indexOf(G(t).id)===0,()=>G(r).indexOf(G(t).id)===G(r).length-1]),K(`click`,i,()=>u(G(t).id,-1)),K(`click`,a,()=>u(G(t).id,1)),J(e,n)},f=P(()=>G(r).includes(G(t).id));X(c,e=>{G(f)&&e(d)}),M(n),H(e=>{Q(i,`title`,G(t).help),Si(a,e),Y(o,G(t).label),Y(s,G(t).help)},[()=>G(r).includes(G(t).id)]),K(`change`,a,e=>l(G(t).id,e.currentTarget.checked)),J(e,n)}),M(n);var i=V(n,2),a=B(i),o=V(i,2),d=V(o,2);M(t),H(e=>Y(a,`Preview // ${e??``}`),[()=>s(G(r))||`—`]),K(`click`,o,()=>{ra.statusLine=[...G(r)],aa(),ia.open=!1}),K(`click`,d,()=>{ia.open=!1}),J(e,t)};X(f,e=>{ia.open&&e(p)});var m=V(f,2),h=R(m),g=B(h,!0),_=V(h,2);M(m),H((e,t)=>{Q(h,`title`,e),Y(g,t)},[()=>s(ra.statusLine),()=>s(ra.statusLine)]),K(`click`,_,()=>{ia.open=!ia.open}),J(e,d),Ge()}Cr([`change`,`click`]);var ps=q(`
        `);function ms(e,t){We(t,!0);let n=Wi(t,`active`,3,!1),r=P(()=>t.session.text||t.session.contextKind===`LAST ACTIVITY`&&t.session.workingCommand||``),i=P(()=>[`LAST REPLY`,`LAST ACTIVITY`].includes(t.session.contextKind)&&!!G(r).trim()),a=I(!1),o=I(``),s=I(!1);yn(()=>{if(!G(s))return;let e=setTimeout(()=>{L(s,!1)},150);return()=>clearTimeout(e)}),yn(()=>{G(r),t.session.status,L(o,``)});async function c(){if(!G(i)||G(a))return;let e=G(r);L(a,!0),L(s,!0),L(o,``);try{await navigator.clipboard.writeText(e),G(r)===e&&L(o,`Copied.`)}catch{G(r)===e&&L(o,`Clipboard unavailable. Select the visible text and copy it manually.`)}finally{L(a,!1)}}function l(e){!n()||!G(i)||e.defaultPrevented||e.repeat||e.ctrlKey||e.metaKey||e.altKey||e.key.toLowerCase()!==`c`||e.target instanceof Element&&e.target.closest(`input, textarea, select, [contenteditable]`)||(e.preventDefault(),c())}var u=Pr();Sr(`keydown`,$t,l);var d=z(u),f=e=>{var t=ps(),n=R(t),r=B(n,!0),i=V(n,2);let l;M(t),H(()=>{Y(r,G(o)),i.disabled=G(a),l=ci(i,1,`svelte-543j00`,null,l,{flashed:G(s)})}),K(`click`,i,c),J(e,t)};X(d,e=>{G(i)&&e(f)}),J(e,u),Ge()}Cr([`click`]);var hs=q(`

         
        `,1),gs=q(`

        LATEST GUIDANCE

         
        `,1),_s=q(`

        CONTEXT

         

        `,1),vs=q(`

        `),ys=q(`

        `),bs=q(`
         
        `),xs=q(`

         
        `,1),Ss=q(`
         
        `),Cs=q(`

        Command unavailable from this observation. Open Codex to inspect the + request.

        `),ws=q(`

        `,1),Ts=q(`

        `),Es=q(` `,1),Ds=q(`
        `),Os=q(`

        Session connection or refresh unavailable. Context and telemetry may be + stale.

        `),ks=q(`

        Some quota profile checks are unavailable. Only sessions with freshly + verified quota and settings can be updated; previous outcome notices remain + visible.

        `),As=q(` `),js=q(` `),Ms=q(` `),Ns=q(``),Ps=q(`

        Read only — reply or approve in Codex.

        `),Fs=q(`

        `),Is=q(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),Ls=q(`
        `),Rs=q(`
        `),zs=q(`

        This session is no longer in the current observation. Return to sessions.

        `),Bs=q(`

        `),Vs=q(``),Hs=q(`

        `),Us=q(` `),Ws=q(`

        `),Gs=q(`QUOTA THRESHOLD // REVIEW PROFILE ↗`),Ks=q(` `,1),qs=q(`

        `),Js=q(`

        TOKEN ACTIVITY // 30 SECOND SAMPLES

        `),Ys=q(`

        TOKENS

        FULL DETAIL →
        `),Xs=q(`

        No locally observed sessions yet. Keep Codex running alongside + Codexometer.

        `),Zs=q(`

        ↑ ↓ SELECT SESSION // ← LESS DETAIL // → MORE DETAIL // ESC BACK

        `,1),Qs=q(`

        SESSION TOTALS

        `,1);function $s(e,t){We(t,!0);let n=(e,t=f,n,r)=>{let i=mt(()=>g(n?.(),!0)),a=mt(()=>g(r?.(),!1));var o=Es(),s=z(o),c=e=>{var n=hs(),r=z(n),i=B(r,!0),a=B(V(r,2),!0);H(()=>{Y(i,t().contextKind===`LAST REPLY`&&!t().streaming?`TASK`:`CURRENT TASK`),Y(a,t().currentTask)}),J(e,n)};X(s,e=>{t().currentTask&&e(c)});var l=V(s,2),u=e=>{var n=gs(),r=B(V(z(n),2),!0);H(()=>Y(r,t().latestGuidance)),J(e,n)};X(l,e=>{t().latestGuidance&&e(u)});var d=V(l,2),p=e=>{var n=_s(),r=B(V(z(n),2),!0);Ce(2),H(()=>Y(r,t().approvalContext)),J(e,n)};X(d,e=>{G(a)&&t().contextKind===`APPROVAL REQUEST`&&t().approvalContext&&e(p)});var m=V(d,2),_=e=>{var n=vs();let r;var i=B(n,!0);H(e=>{r=ci(n,1,`attention-note`,null,r,{inferred:t().status===`CHECK SESSION`}),Y(i,e)},[()=>C(t())]),J(e,n)},v=P(()=>C(t())&&(!G(a)||G(h)||t().status===`CHECK SESSION`));X(m,e=>{G(v)&&e(_)});var y=V(m,2),b=e=>{var n=ys(),r=B(n,!0);H(e=>Y(r,e),[()=>w(t())]),J(e,n)};X(y,e=>{G(i)&&e(b)});var x=V(y,2),S=e=>{var n=bs(),r=B(n,!0);H(()=>Y(r,t().text||`No session context available.`)),J(e,n)};X(x,e=>{(t().text||!t().workingCommand)&&e(S)});var T=V(x,2),E=e=>{var n=xs(),r=V(z(n),2),i=R(r),a=V(i),o=e=>{var n=Nr();H(()=>Y(n,`// +${(t().runningCommands||0)-+(t().commandStatus===`running`)} RUNNING`)),J(e,n)};X(a,e=>{!G(h)&&(t().runningCommands||0)>+(t().commandStatus===`running`)&&e(o)});var s=V(a,2),c=e=>{J(e,Nr(`+`))};X(s,e=>{t().runningLimited&&e(c)}),M(r);var l=B(V(r,2),!0);H(e=>{Y(i,`COMMAND // ${e??``} `),Y(l,t().workingCommand)},[()=>G(h)?`UNKNOWN`:(t().commandStatus||`unknown`).toUpperCase()]),J(e,n)};X(T,e=>{t().workingCommand&&e(E)});var ee=V(T,2),D=e=>{wo(e,{get lines(){return t().fileChanges}})},O=e=>{var n=ws(),r=V(z(n),2),i=B(r,!0),a=V(r,2),o=e=>{var n=Ss(),r=B(n,!0);H(()=>Y(r,t().command)),J(e,n)},s=e=>{J(e,Cs())};X(a,e=>{t().command?e(o):e(s,-1)}),H(()=>Y(i,G(h)||t().status!==`APPROVAL NEEDED`?`LAST OBSERVED COMMAND`:$.data?.control?`COMMAND REQUEST`:`COMMAND TO APPROVE IN CODEX`)),J(e,n)};X(ee,e=>{(!G(a)||!$.data?.control)&&t().fileChanges?.length?e(D):(!G(a)||!$.data?.control)&&(t().command||t().status===`APPROVAL NEEDED`)&&e(O,1)});var te=V(ee,2),k=e=>{var n=Ts(),r=B(n);H(()=>Y(r,`CONTEXT SOURCE // ${(t().source||`LOCAL`)??``} // OBSERVATION`)),J(e,n)};X(te,e=>{G(a)||e(k)}),J(e,o)},r=Wi(t,`params`,19,()=>({})),i=P(()=>$.data?.sessions||[]),a=P(()=>$.data?.control&&$.data.profiles||[]),o=P(()=>($.data?.triggers||[]).filter(e=>G(i).some(t=>t.id===e.session)));function s(e,t){if(r().id&&r().id!==t&&G(l)){e.preventDefault();return}b(t)}function c(e){return[`TURN COMPLETE`,`IDLE`,`ACTIVE`].includes(e.status)&&G(o).some(t=>t.session===e.id)?`TRIGGER SET`:e.status}let l=I(!1);function u(e,t){if(r().id&&r().id!==t&&G(l)){e.preventDefault();return}b(t)}yn(()=>{let e=r().id;e&&pr(()=>{ra.selected=e,la(e,2)})});let d=P(()=>G(i).find(e=>e.id===r().id)),p=P(()=>new URLSearchParams(Yi.querystring).get(`review`)===`profile`&&G(a).some(e=>e.session===r().id&&e.pending)),m=P(()=>G(i).some(e=>e.id===ra.selected)?ra.selected:G(i)[0]?.id),h=P(()=>!$.connected||!!$.data?.sessionsError),v=P(()=>[[`OBSERVED TOKENS`,ua(G(i).reduce((e,t)=>e+t.tokens,0))],[`LISTED SESSIONS`,ua(G(i).length)],...[[`WORKING`,`WORKING`],[`AWAITING APPROVAL`,`APPROVAL NEEDED`],[`AWAITING INPUT`,`INPUT NEEDED`],[`CHECK · INFERRED`,`CHECK SESSION`]].map(([e,t])=>[e,G(h)?`—`:ua(G(i).filter(e=>e.status===t).length)])]),y=P(()=>G(i).filter(e=>[`INPUT NEEDED`,`APPROVAL NEEDED`,`CHECK SESSION`].includes(e.status)));function b(e){ra.selected=e,ur().then(()=>document.querySelector(`.session-row.selected`)?.scrollIntoView({block:`nearest`}))}function x(e,t){if(b(e),r().id){t<0&&(la(e,2),location.hash=`/sessions`);return}let n=sa(e)+t;n>2?location.hash=`/sessions/`+encodeURIComponent(e):la(e,n)}function S(e){let t=e.target;if(!(e.altKey||e.ctrlKey||e.metaKey||e.shiftKey||t.closest(`input, textarea, select, [contenteditable="true"]`))){if(e.key===`Escape`&&r().id)e.preventDefault(),x(r().id,-1);else if([`ArrowLeft`,`ArrowRight`].includes(e.key)&&(r().id||G(m)))e.preventDefault(),x(r().id||G(m),e.key===`ArrowLeft`?-1:1);else if(!r().id&&[`ArrowUp`,`ArrowDown`].includes(e.key)&&G(i).length){e.preventDefault();let t=G(i).findIndex(e=>e.id===G(m));b(G(i)[Math.max(0,Math.min(G(i).length-1,t+(e.key===`ArrowUp`?-1:1)))].id)}}}function C(e){return G(h)?`Last observation only — refresh unavailable. Check Codex for current state.`:e.status===`CHECK SESSION`?`INFERRED INACTIVITY — a quiet session, not a confirmed input or approval request. Local tools may still be running.`:$.data?.control&&[`APPROVAL NEEDED`,`INPUT NEEDED`].includes(e.status)?`Open full detail for supported live controls; otherwise reply in Codex.`:e.status===`APPROVAL NEEDED`?`OBSERVED APPROVAL SIGNAL — approve or decline in Codex.`:e.status===`INPUT NEEDED`?`OBSERVED INPUT SIGNAL — reply in Codex.`:e.status===`TURN COMPLETE`?`OBSERVED TURN COMPLETION — informational, not an approval request.`:``}function w(e){return e.streaming&&e.contextKind===`LAST REPLY`?`REPLY // STREAMING`:e.contextKind||`LAST ACTIVITY`}var T=Qs();Sr(`keydown`,$t,S);var E=z(T),ee=B(V(R(E),2));M(E);var D=V(E,2);let O;Z(D,21,()=>G(v),qr,(e,t)=>{var n=P(()=>_(G(t),2));let r=()=>G(n)[0],i=()=>G(n)[1];var a=Ds(),o=R(a),s=B(o,!0),c=B(V(o,2),!0);M(a),H(()=>{Y(s,r()),Y(c,i())}),J(e,a)}),M(D);var te=V(D,2),k=B(te),ne=V(te,2),re=e=>{J(e,Os())};X(ne,e=>{G(h)&&e(re)});var ie=V(ne,2),ae=e=>{J(e,ks())};X(ie,e=>{$.data?.profileError&&e(ae)});var oe=V(ie,2),se=e=>{var t=Ns(),n=R(t);Z(n,17,()=>G(y),qr,(e,t)=>{var n=As();let r;var i=B(n);H((e,a)=>{r=ci(n,1,`button`,null,r,{approval:G(t).status===`APPROVAL NEEDED`}),Q(n,`href`,e),Y(i,`${G(t).status??``} + ${a??``} // ${(G(t).name||G(t).directory||G(t).id)??``}`)},[()=>`#/sessions/`+encodeURIComponent(G(t).id),()=>Array.from(G(t).id).slice(-5).join(``).toUpperCase()]),K(`click`,n,()=>b(G(t).id)),J(e,n)});var c=V(n,2);Z(c,17,()=>G(a).filter(e=>e.pending&&G(i).some(t=>t.id===e.session)),qr,(e,t)=>{var n=js(),a=B(n);H((e,i,o)=>{Q(n,`title`,r().id&&r().id!==G(t).session&&G(l)?`Finish sending or clear your current draft before switching sessions.`:`Review this session’s quota threshold`),Q(n,`href`,e),Y(a,`QUOTA THRESHOLD ${i??``} // ${o??``}`)},[()=>`#/sessions/`+encodeURIComponent(G(t).session)+`?review=profile`,()=>Array.from(G(t).session).slice(-5).join(``).toUpperCase(),()=>G(i).find(e=>e.id===G(t).session)?.name||G(i).find(e=>e.id===G(t).session)?.directory||G(t).session]),K(`click`,n,e=>u(e,G(t).session)),J(e,n)}),Z(V(c,2),17,()=>G(o),qr,(e,t)=>{var n=Ms(),r=B(n);H((e,t,i)=>{Q(n,`href`,e),Y(r,`TRIGGER SET ${t??``} // ${i??``}`)},[()=>`#/sessions/`+encodeURIComponent(G(t).session),()=>Array.from(G(t).session).slice(-5).join(``).toUpperCase(),()=>G(i).find(e=>e.id===G(t).session)?.name||G(i).find(e=>e.id===G(t).session)?.directory]),K(`click`,n,e=>s(e,G(t).session)),J(e,n)}),M(t),J(e,t)},ce=P(()=>(G(y).length||G(a).some(e=>e.pending)||G(o).length)&&!G(h));X(oe,e=>{G(ce)&&e(se)});var le=V(oe,2),ue=e=>{var t=Pr(),i=z(t),o=e=>{var t=Rs(),i=R(t),o=R(i),s=R(o);let u;var f=V(s);M(o);var m=V(o,2);M(i);var g=V(i,2),_=e=>{var t=Ts(),n=B(t,!0);H(()=>Y(n,G(d).directory)),J(e,t)};X(g,e=>{G(d).name&&G(d).directory&&e(_)});var v=V(g,2),y=B(v),x=V(v,2);let S;var C=R(x),w=R(C);n(w,()=>G(d),()=>!0,()=>!0),M(C);var T=V(C,2),E=e=>{var t=Pr();Kr(z(t),()=>G(d).id,e=>{{let t=P(()=>new URLSearchParams(Yi.querystring).get(`schedule`)===`edit`),n=P(()=>G(d).fileChanges||[]);ss(e,{get session(){return G(d).id},get openScheduler(){return G(t)},get observedCommand(){return G(d).command},get observedFileChanges(){return G(n)},get suspended(){return G(p)},onProtectedChange:e=>{L(l,e,!0)}})}}),J(e,t)},ee=e=>{J(e,Ps())};X(T,e=>{$.data?.control?e(E):e(ee,-1)}),M(x);var D=V(x,2);Z(D,17,()=>G(a).filter(e=>e.session===G(d).id),e=>e.session,(e,t)=>{var n=Ls(),r=R(n),i=e=>{var n=Fs(),r=B(n,!0);H(()=>Y(r,G(t).notice)),J(e,n)};X(r,e=>{G(t).notice&&e(i)});var a=V(r,2),o=e=>{ss(e,{get session(){return G(d).id},review:`profile`})},s=e=>{var t=Is();H(e=>Q(t,`href`,e),[()=>`#/sessions/`+encodeURIComponent(G(d).id)+`?review=profile`]),J(e,t)};X(a,e=>{G(t).pending&&G(p)?e(o):G(t).pending&&e(s,1)}),M(n),H(()=>Q(n,`id`,`quota-profile-`+G(d).id)),J(e,n)});var O=V(D,2),te=e=>{var t=Pr();Kr(z(t),()=>G(d).id,e=>{ms(e,{get session(){return G(d)},active:!0})}),J(e,t)};X(O,e=>{G(p)||e(te)}),Kr(V(O,2),()=>G(d).id,e=>{fs(e,{get session(){return G(d)},get stale(){return G(h)}})}),M(t),H((e,t)=>{u=ci(s,1,`lamp lit`,null,u,{working:G(d).status===`WORKING`&&!G(h)}),Y(f,`${e??``} // ${(G(d).name||G(d).directory)??``}`),Y(y,`${t??``} TOKENS // ${G(d).id??``} // CONTEXT SOURCE // ${(G(d).source||`LOCAL`)??``}`),S=ui(x,``,S,{display:G(p)?`none`:void 0})},[()=>G(h)?`STALE`:G(p)?`QUOTA THRESHOLD`:c(G(d)),()=>ua(G(d).tokens)]),K(`click`,m,()=>{b(r().id),la(r().id,2)}),J(e,t)},s=e=>{J(e,zs())};X(i,e=>{G(d)?e(o):e(s,-1)}),J(e,t)},de=e=>{var t=Zs(),r=z(t),o=V(R(r),2),s=R(o),l=V(s,2);M(o),M(r);var d=V(r,2);Z(d,17,()=>G(i),e=>e.id,(e,t)=>{let r=P(()=>sa(G(t).id));var i=Ys();let o;var s=R(i),l=R(s),d=e=>{var n=Bs(),r=R(n),i=B(r);M(n),H(e=>{Q(r,`aria-pressed`,G(m)===G(t).id),Y(i,`${e??``} // ${G(t).name??``}`)},[()=>Array.from(G(t).id).slice(-5).join(``).toUpperCase()]),K(`click`,r,()=>b(G(t).id)),J(e,n)};X(l,e=>{G(t).name&&e(d)});var f=V(l,2),p=R(f),g=R(p);let _;var v=V(g,1,!0);M(p),M(f);var y=V(f,2),S=e=>{var n=Vs(),r=B(n,!0);H(()=>{Q(n,`aria-pressed`,G(m)===G(t).id),Y(r,G(t).directory||G(t).id)}),K(`click`,n,()=>b(G(t).id)),J(e,n)};X(y,e=>{G(t).name||e(S)});var C=V(y,2),T=R(C);Ce(),M(C);var E=V(C,2),ee=e=>{var n=Ts(),r=B(n,!0);H(()=>Y(r,G(t).directory)),J(e,n)};X(E,e=>{G(t).name&&G(t).directory&&e(ee)});var D=V(E,2),O=B(D),te=V(D,2),k=B(te),ne=V(te,2),re=R(ne),ie=V(re,2),ae=B(ie,!0),oe=V(ie,2);M(ne);var se=V(ne,2),ce=V(se,2),le=e=>{var n=Hs(),r=B(n,!0);H(()=>Y(r,G(t).status===`CHECK SESSION`?`INFERRED INACTIVITY`:$.data?.control?`OPEN FULL DETAIL OR REPLY IN CODEX`:G(t).status===`APPROVAL NEEDED`?`APPROVE OR DECLINE IN CODEX`:`REPLY IN CODEX`)),J(e,n)},ue=P(()=>!G(h)&&[`APPROVAL NEEDED`,`INPUT NEEDED`,`CHECK SESSION`].includes(G(t).status));X(ce,e=>{G(ue)&&e(le)}),M(s);var de=V(s,2),fe=e=>{var r=qs(),i=R(r),o=R(i),s=B(o,!0),c=V(o,2),l=e=>{var n=Us(),r=B(n,!0);H(e=>{Q(n,`href`,e),Y(r,$.data?.control?`REVIEW IN FULL DETAIL ↗`:`APPROVAL IN CODEX ↗`)},[()=>`#/sessions/`+encodeURIComponent(G(t).id)]),J(e,n)};X(c,e=>{!G(h)&&G(t).status===`APPROVAL NEEDED`&&e(l)}),M(i);var d=V(i,2);n(d,()=>G(t),()=>!1);var f=V(d,2);Z(f,17,()=>G(a).filter(e=>e.session===G(t).id),qr,(e,n)=>{var r=Ks(),i=z(r),a=e=>{var t=Ws(),r=B(t,!0);H(()=>Y(r,G(n).notice)),J(e,t)};X(i,e=>{G(n).notice&&e(a)});var o=V(i,2),s=e=>{var n=Gs();H(e=>Q(n,`href`,e),[()=>`#/sessions/`+encodeURIComponent(G(t).id)+`?review=profile`]),K(`click`,n,e=>u(e,G(t).id)),J(e,n)};X(o,e=>{G(n).pending&&e(s)}),J(e,r)});var p=V(f,2);{let e=P(()=>G(m)===G(t).id);ms(p,{get session(){return G(t)},get active(){return G(e)}})}M(r),H(e=>Y(s,e),[()=>w(G(t))]),J(e,r)};X(de,e=>{G(r)>0&&e(fe)});var pe=V(de,2),me=e=>{var n=Js(),r=V(R(n),2);{let e=P(()=>(G(t).samples||[]).map(e=>e.tokens));no(r,{get values(){return G(e)},capacity:120})}var i=B(V(r,2));M(n),H(()=>Y(i,`LAST ${(G(t).samples?.length||0)??``} SAMPLES // AUTO SCALE`)),J(e,n)};X(pe,e=>{G(r)<2&&e(me)}),M(i),H((e,n,a,s,c)=>{o=ci(i,1,`session-row`,null,o,{selected:G(m)===G(t).id,wide:G(r)===2,split:G(r)===1}),Q(i,`aria-label`,`Session `+(G(t).name||G(t).directory||G(t).id)),Q(p,`href`,e),_=ci(g,1,`lamp lit`,null,_,{working:G(t).status===`WORKING`&&!G(h)}),Y(v,n),Y(T,`${a??``} `),Y(O,`${G(t).agents??``} LINKED AGENTS`),Y(k,`ACTIVE // ${s??``}`),re.disabled=G(r)===0,Q(ie,`aria-expanded`,G(r)>0),Y(ae,G(r)?`HIDE DETAIL`:`SHOW DETAIL`),Q(se,`href`,c)},[()=>`#/sessions/`+encodeURIComponent(G(t).id),()=>G(h)?`STALE`:c(G(t)),()=>ua(G(t).tokens),()=>da(G(t).activity),()=>`#/sessions/`+encodeURIComponent(G(t).id)]),K(`click`,p,()=>b(G(t).id)),K(`click`,re,()=>x(G(t).id,-1)),K(`click`,ie,()=>{b(G(t).id),la(G(t).id,+!G(r))}),K(`click`,oe,()=>x(G(t).id,1)),K(`click`,se,()=>b(G(t).id)),J(e,i)});var f=V(d,2),p=e=>{J(e,Xs())};X(f,e=>{G(i).length||e(p)}),K(`click`,s,()=>ca(1)),K(`click`,l,()=>ca(0)),J(e,t)};X(le,e=>{r().id?e(ue):e(de,-1)}),H(e=>{Y(ee,`OBSERVED ${e??``}`),O=ci(D,1,`session-totals`,null,O,{stale:G(h)}),Y(k,`${G(h)?`LAST KNOWN TOTALS — live state counts unavailable. `:``}Tokens + observed since this server started for currently listed sessions; linked + agents are already included. Totals can decrease when a session leaves the + list. History samples every 30 seconds. Not account-wide totals.`)},[()=>da($.data?.sessionsAt)]),J(e,T),Ge()}Cr([`click`]);var ec=q(`

        `),tc=q(`

        Relative usage/credits are not tokens or quota percentages. Groupings + describe the same usage, not additional consumption.

        `,1),nc=q(`// APPROXIMATE`),rc=q(`

        Partial accounting: totals may still change.

        `),ic=q(`

        Percentage of this period's historical allowance, not today's limit. May + exceed 100%. This is not a manual/automatic reset log.

        `,1),ac=q(`

        `,1),oc=q(`

        This optional account report is unavailable. Token history remains + available; missing data does not mean zero usage.

        `),sc=q(`
        `),cc=q(`
        `),lc=q(`

        No usage reported for this day.

        `),uc=q(`

        Selected breakdown unavailable; missing does not mean zero.

        `),dc=q(`

        `,1);function fc(e,t){We(t,!0);let n=I(`surface`),r=I(0),i=P(()=>t.reports?.daily),a=P(()=>t.reports?.plan),o=P(()=>t.mode===`breakdown`?G(i)?.days.length||0:G(a)?.periods.length||0),s=P(()=>Math.min(G(r),Math.max(0,G(o)-1))),c=P(()=>G(i)?.days[(G(i)?.days.length||0)-1-G(s)]),l=P(()=>G(a)?.periods[G(s)]),u=P(()=>t.mode===`breakdown`?G(i)?.units||``:`%`),d=P(()=>{let e=Object.create(null);if(t.mode===`breakdown`)e=G(c)?.groups[G(n)]||{};else{let t=G(n)===`feature`?`thread_source`:G(n)===`task start`?`turn_trigger`:G(n);for(let n of G(l)?.breakdowns||[])if(n.dimension===t)for(let t of n.rows)e[t.key]=(e[t.key]||0)+t.basis_points/100}return Object.entries(e).sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}),f=P(()=>t.mode===`breakdown`?G(c)?.total:G(l)?.used_basis_points==null?null:G(l).used_basis_points/100),p=P(()=>Math.max(1,G(f)||0,...G(d).map(([,e])=>e))),m=e=>e==null?`UNKNOWN`:e.toLocaleString(`en-GB`,{maximumFractionDigits:2});var h=dc(),g=z(h),v=R(g),y=V(R(v)),b=R(y);b.value=b.__value=`surface`;var x=V(b);x.value=x.__value=`model`;var S=V(x);S.value=S.__value=`feature`;var C=V(S);C.value=C.__value=`task start`,M(y),mi(y),M(v);var w=V(v,2),T=V(w,2),E=B(V(T,2),!0);M(g);var ee=V(g,2),D=R(ee),O=B(D,!0),te=V(D,2),k=B(te),ne=V(te,2),re=e=>{var t=tc(),n=z(t),r=B(n),a=V(n,2),o=e=>{var t=ec(),n=B(t);H(()=>Y(n,`Data as of ${G(i).dataAsOf??``}`)),J(e,t)};X(a,e=>{G(i).dataAsOf&&e(o)});var s=B(V(a,2));Ce(2),H((e,t)=>{Y(r,`Latest fetch ${e??``} // queried ${G(i).from??``} → ${G(i).through??``}. + Reports are fetched from OpenAI and are not saved between runs.`),Y(s,`${(G(c)?.date||`No daily buckets reported`)??``} // ${t??``} + ${G(u)??``}`)},[()=>da(G(i).fetchedAt),()=>m(G(f))]),J(e,t)},ie=e=>{var t=ac(),n=z(t),r=R(n);let i;var o=B(r,!0),s=V(r),c=e=>{J(e,nc())};X(s,e=>{G(a).approximate&&e(c)});var u=V(s);M(n);var d=V(n,2),p=R(d),h=V(p),g=e=>{var t=Nr();H(()=>Y(t,`// Boundary tolerance ${G(a).boundary_tolerance_seconds??``}s`)),J(e,t)};X(h,e=>{G(a).boundary_tolerance_seconds!=null&&e(g)}),M(d);var _=V(d,2),v=e=>{var t=ic(),n=z(t),r=R(n),i=V(r);let a;var o=B(i);M(n);var s=V(n,2),c=B(s),u=V(s,2),d=e=>{J(e,rc())};X(u,e=>{G(l).accounting_complete||e(d)}),Ce(2),H(e=>{Y(r,`${G(l).window_minutes??``} MIN // ${G(l).plan_type??``} // `),a=ci(i,1,`svelte-1fbui7h`,null,a,{muted:G(f)==null,"quota-near":G(f)!=null&&G(f)>=80&&G(f)<100,"quota-full":G(f)!=null&&G(f)>=100}),Y(o,`USED ${e??``}${G(f)==null?``:`%`}`),Y(c,`${G(l).starts_at??``} → ${G(l).ends_at??``}`)},[()=>m(G(f))]),J(e,t)};X(_,e=>{G(l)&&e(v)}),H(e=>{i=ci(r,1,`svelte-1fbui7h`,null,i,{"quality-warning":!G(a).coverage_complete}),Y(o,G(a).coverage_complete?`Reported range complete`:`Partial coverage`),Y(u,` // Latest fetch ${e??``}`),Y(p,`Coverage starts ${(G(a).coverage_start||`unknown`)??``} // Data as of ${(G(a).data_as_of||`unknown`)??``}`)},[()=>da(G(a).fetchedAt)]),J(e,t)},ae=e=>{J(e,oc())};X(ne,e=>{t.mode===`breakdown`&&G(i)?e(re):t.mode===`periods`&&G(a)?e(ie,1):e(ae,-1)});var oe=V(ne,2),se=e=>{var n=cc(),r=R(n),i=B(V(R(r),2),!0);M(r),Z(V(r,2),17,()=>G(d),qr,(e,n,r)=>{var i=P(()=>_(G(n),2));let a=()=>G(i)[0],o=()=>G(i)[1];var s=sc();let c;var l=R(s),u=B(l,!0),d=V(l,2),f=R(d);let h;M(d);var g=B(V(d,2));M(s),H((e,n,i)=>{c=ci(s,1,`report-row svelte-1fbui7h`,null,c,{unknown:e,alternate:r%2==1}),Q(l,`title`,a()),Y(u,a()),h=ui(f,``,h,{width:n}),Y(g,`${i??``}${t.mode===`periods`?`%`:``}`)},[()=>a().trim().toLowerCase()===`unknown`,()=>`${Math.max(0,100*o()/G(p))}%`,()=>m(o())]),J(e,s)}),M(n),H(()=>Y(i,t.mode===`breakdown`?G(u):`QUOTA USED`)),J(e,n)},ce=e=>{J(e,lc())},le=e=>{J(e,uc())};X(oe,e=>{G(d).length?e(se):t.mode===`breakdown`&&G(c)?.total===0&&G(c)?.groups[G(n)]!=null?e(ce,1):(G(i)&&t.mode===`breakdown`||G(a)&&t.mode===`periods`)&&e(le,2)}),M(ee),H(()=>{w.disabled=G(s)>=G(o)-1,T.disabled=G(s)===0,Y(E,G(o)?`${G(s)+1} / ${G(o)}`:`NO DATA`),Y(O,t.mode===`breakdown`?`DAILY BREAKDOWN`:`QUOTA WINDOWS`),Y(k,`${(t.mode===`breakdown`?t.reports?.dailyStatus||`UNAVAILABLE`:t.reports?.planStatus||`UNAVAILABLE`)??``} // UTC`)}),hi(y,()=>G(n),e=>L(n,e)),K(`click`,w,()=>L(r,G(s)+1)),K(`click`,T,()=>L(r,G(s)-1)),J(e,h),Ge()}Cr([`click`]);var pc=864e5;function mc(e,t){let n=new Date(e);n.setUTCDate(1),n.setUTCMonth(n.getUTCMonth()+t);let r=new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+1,0)).getUTCDate();return n.setUTCDate(Math.min(e.getUTCDate(),r)),n}function hc(e,t,n){let r=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));for(let e=0;;e++){let i=mc(r,-t),a=new Date(i.getTime()+pc);if(e===n)return{start:a,end:r};r=i}}var gc=q(``),_c=q(``,1),vc=q(`

        History refresh failed. Any displayed history is the last successful + observation.

        `),yc=q(`

        Token history unavailable; other reports may still be available.

        `),bc=q(``),xc=q(`
        `),Sc=q(`

        LESS ░ ▒ ▓ █ MORE // HOVER FOR DATE AND TOKENS

        `,1),Cc=q(`
        `,1),wc=q(` `),Tc=q(`

        LIFETIME TOKENS

        PEAK DAY

        CURRENT STREAK

        DAYS

        LONGEST TURN

        SECONDS

        LONGEST STREAK

        DAYS

        OPENAI // UTC

        Accessible data table
        Date (UTC)Tokens

        `,1),Ec=q(`

        History unavailable or awaiting a matching account observation. Missing + history is not treated as zero usage.

        `),Dc=q(`

        USAGE // ACCOUNT HISTORY

        Account-wide history reported by Codex, not the local Sessions counter. Dates + use UTC. Allowance history is approximate where indicated; reset causes are + not provided.

        `,1);function Oc(e,t){We(t,!0);let n=I(`daily`),r=I(12),i=I(0),a=P(()=>{let e=$.data?.usage?.dailyUsageBuckets;if(!e)return[];let{start:t,end:n}=hc(new Date,G(r),G(i)),a=new Map;for(let t of e)!Number.isFinite(t.tokens)||t.tokens<0||a.set(t.startDate,(a.get(t.startDate)||0)+t.tokens);let o=[];for(let e=t;e<=n;e=new Date(e.getTime()+864e5)){let t=e.toISOString().slice(0,10);o.push({date:t,tokens:a.get(t)||0})}return o}),o=P(()=>Math.max(1,...G(a).map(e=>e.tokens))),s=P(()=>G(a).length?new Date(G(a)[0].date+`T00:00:00Z`).getUTCDay():0),c=P(()=>{if(G(n)===`monthly`){let e=new Map;for(let t of G(a))e.set(t.date.slice(0,7),(e.get(t.date.slice(0,7))||0)+t.tokens);return[...e].map(([e,t])=>({date:e,tokens:t}))}let e=0;return G(a).map(t=>({date:t.date,tokens:e+=t.tokens}))});var l=Dc(),u=V(z(l),4);Z(u,20,()=>[[`daily`,`Daily`],[`monthly`,`Monthly`],[`cumulative`,`Cumulative`],[`breakdown`,`Breakdown`],[`periods`,`Windows`]],qr,(e,t)=>{var r=P(()=>_(t,2));let a=()=>G(r)[0],o=()=>G(r)[1];var s=gc();let c;var l=B(s,!0);H(()=>{Q(s,`aria-pressed`,G(n)===a()),c=ci(s,1,``,null,c,{active:G(n)===a()}),Y(l,o())}),K(`click`,s,()=>{L(n,a(),!0),L(i,0)}),J(e,s)}),M(u);var d=V(u,2),f=R(d),p=e=>{var t=_c(),n=z(t),a=V(R(n)),o=R(a);o.value=o.__value=6;var s=V(o);s.value=s.__value=12,M(a),mi(a),M(n);var c=V(n),l=V(c);H(()=>l.disabled=G(i)===0),K(`change`,a,()=>L(i,0)),hi(a,()=>G(r),e=>L(r,e)),K(`click`,c,()=>qt(i)),K(`click`,l,()=>qt(i,-1)),J(e,t)};X(f,e=>{G(n)!==`breakdown`&&G(n)!==`periods`&&e(p)}),M(d);var m=V(d,2),h=e=>{J(e,vc())};X(m,e=>{$.data?.usageError&&e(h)});var g=V(m,2),v=e=>{J(e,yc())};X(g,e=>{$.data?.usage?.tokenStatus===`UNAVAILABLE`&&G(n)!==`breakdown`&&G(n)!==`periods`&&e(v)});var y=V(g,2),b=e=>{var t=Pr();Kr(z(t),()=>G(n),e=>{{let t=P(()=>$.data?.usage?.reports);fc(e,{get reports(){return G(t)},get mode(){return G(n)}})}}),J(e,t)},x=e=>{var t=Tc(),r=z(t),i=R(r),l=B(V(R(i),2),!0);M(i);var u=V(i,2),d=B(V(R(u),2),!0);M(u);var f=V(u,2),p=V(R(f),2),m=R(p);Ce(),M(p),M(f);var h=V(f,2),g=V(R(h),2),_=R(g);Ce(),M(g),M(h);var v=V(h,2),y=V(R(v),2),b=R(y);Ce(),M(y),M(v),M(r);var x=V(r,4),S=R(x),C=B(S),w=V(S,2),T=e=>{var t=Sc(),n=z(t),r=R(n),i=R(r);Z(i,17,()=>Array(G(s)),qr,(e,t)=>{J(e,bc())}),Z(V(i,2),17,()=>G(a),qr,(e,t)=>{var n=xc();let r,i;H(e=>{r=ci(n,1,`heat-cell`,null,r,{zero:G(t).tokens===0}),Q(n,`title`,e),i=ui(n,``,i,{opacity:G(t).tokens?.25+.75*G(t).tokens/G(o):1})},[()=>`${G(t).date}: ${ua(G(t).tokens)} tokens`]),J(e,n)}),M(r),M(n),Ce(2),J(e,t)},E=e=>{var t=Cc(),r=z(t);{let e=P(()=>G(c).map(e=>e.tokens)),t=P(()=>G(n)+` usage`);no(r,{get values(){return G(e)},get label(){return G(t)}})}var i=V(r,2),a=R(i),o=B(a,!0),s=B(V(a),!0);M(i),H(e=>{Y(o,G(c)[0]?.date),Y(s,e)},[()=>G(c).at(-1)?.date]),J(e,t)};X(w,e=>{G(n)===`daily`?e(T):e(E,-1)});var ee=V(w,2),D=V(R(ee),2),O=R(D),te=V(R(O));Z(te,21,()=>G(n)===`daily`?G(a):G(c),qr,(e,t)=>{var n=wc(),r=R(n),i=B(r,!0),a=B(V(r),!0);M(n),H(e=>{Y(i,G(t).date),Y(a,e)},[()=>ua(G(t).tokens)]),J(e,n)}),M(te),M(O),M(D),M(ee),M(x);var k=B(V(x,2));H((e,t,n,r,i,o,s)=>{Y(l,e),Y(d,t),Y(m,`${n??``} `),Y(_,`${r??``} `),Y(b,`${i??``} `),Y(C,`${G(a)[0]?.date??``} — ${o??``}`),Y(k,`OBSERVED ${s??``} // CUMULATIVE IS FOR THE SELECTED PERIOD`)},[()=>ua($.data.usage.summary.lifetimeTokens),()=>ua($.data.usage.summary.peakDailyTokens),()=>ua($.data.usage.summary.currentStreakDays),()=>ua($.data.usage.summary.longestRunningTurnSec),()=>ua($.data.usage.summary.longestStreakDays),()=>G(a).at(-1)?.date,()=>da($.data.usageAt)]),J(e,t)},S=e=>{J(e,Ec())};X(y,e=>{G(n)===`breakdown`||G(n)===`periods`?e(b):$.data?.usage&&$.data.usage.dailyUsageBuckets!==null?e(x,1):e(S,-1)}),J(e,l),Ge()}Cr([`click`,`change`]);var kc=q(`

        Page not found

        Return to Quota

        `,1);function Ac(e){var t=kc();Ce(2),J(e,t)}var jc=q(` `),Mc=q(`

        `),Nc=q(`

        Connecting to your local Codexometer…

        `),Pc=q(``),Fc=q(`
        CODEXOMETER

        Your quota. Your sessions. Your command centre.

        `);function Ic(e,t){We(t,!0);let n={"/":$a,"/quota/:view?":$a,"/sessions/:id?":$s,"/usage":Oc,"*":Ac},r={quota:/^(?:\/|\/quota(?:\/[^/]+)?\/?)$/,sessions:/^\/sessions(?:\/[^/]+)?\/?$/,usage:/^\/usage\/?$/},i=I(`hacker`),a=[`hacker`,`rust`,`blue-steel`,`ultraviolet`,`nightshade`];yn(()=>{aa()}),yn(()=>{if($.data)for(let[e,t]of Object.entries(r))t.test(Yi.location)&&(ra.tab=e)}),Gi(()=>{try{let e=localStorage.getItem(`codexometer.web.theme`);e&&a.includes(e)&&L(i,e,!0)}catch{}return ga()});function o(){try{localStorage.setItem(`codexometer.web.theme`,G(i))}catch{}}var s=Fc(),c=R(s),l=V(R(c),2),u=R(l);let d;var f=V(u,1,!0),p=B(V(f));M(l),M(c);var m=V(c,2);Z(m,21,()=>Object.entries(r),qr,(e,t)=>{var n=P(()=>_(G(t),2));let r=()=>G(n)[0],i=()=>G(n)[1],a=P(()=>i().test(Yi.location));var o=jc();let s;var c=B(o,!0);H(e=>{Q(o,`href`,r()===`quota`?`#/quota/`+ra.view:`#/`+r()),Q(o,`aria-current`,G(a)?`page`:void 0),s=ci(o,1,``,null,s,{active:G(a)}),Y(c,e)},[()=>r().toUpperCase()]),J(e,o)}),M(m);var h=V(m,2),g=R(h),v=e=>{var t=Mc(),n=B(t,!0);H(()=>Y(n,$.error)),J(e,t)};X(g,e=>{$.error&&e(v)});var y=V(g,2),b=e=>{Qi(e,{get routes(){return n}})},x=e=>{J(e,Nc())};X(y,e=>{$.data?e(b):$.error||e(x,1)}),M(h);var S=V(h,2),C=R(S),w=B(C),T=V(C,2),E=B(T,!0),ee=V(T,2),D=V(R(ee));Z(D,21,()=>a,qr,(e,t)=>{var n=Pc(),r=B(n,!0),i={};H(e=>{Y(r,e),i!==(i=G(t))&&(n.value=(n.__value=i)??``)},[()=>G(t).replace(`-`,` `).toUpperCase()]),J(e,n)}),M(D),mi(D),M(ee),M(S),M(s),H(()=>{Q(s,`data-theme`,G(i)),d=ci(u,1,`lamp`,null,d,{lit:$.connected}),Y(f,$.connected?`CONNECTED`:`OFFLINE`),Y(p,`EXPERIMENTAL // ${$.data?.control?`SESSION CONTROL`:`READ ONLY`}`),Y(w,`v${($.data?.version||`…`)??``} // LOCAL ONLY`),Y(E,$.data?.control?`Session control enabled. Stop the server to revoke access.`:`No actions can be sent from this preview.`)}),K(`change`,D,o),hi(D,()=>G(i),e=>L(i,e)),J(e,s),Ge()}Cr([`change`]),Br(Ic,{target:document.getElementById(`app`)}); \ No newline at end of file diff --git a/internal/web/dist/index.html b/internal/web/dist/index.html index c02049b..06efbf1 100644 --- a/internal/web/dist/index.html +++ b/internal/web/dist/index.html @@ -5,7 +5,7 @@ Codexometer // Experimental web - + diff --git a/web/src/SessionCommands.svelte b/web/src/SessionCommands.svelte index b1f872d..c9ad74a 100644 --- a/web/src/SessionCommands.svelte +++ b/web/src/SessionCommands.svelte @@ -26,6 +26,8 @@ path: string; revision: string; choices: Choice[]; + input?: boolean; + value?: string; } let open = $state(false), busy = $state(false), @@ -35,6 +37,7 @@ let confirmation = $state(''), expires = $state(0), now = $state(Date.now()); + let name = $state(''); let request = 0; let selectedIndex = $state(0); let dismissedQuery = $state(null); @@ -154,6 +157,9 @@ next: 'statusline', }); menu = result; + name = result.value || ''; + if (result.path.startsWith('rename/') && result.choices.length === 1) + void choose(result.choices[0]); } } catch { if (seq === request) { @@ -273,13 +279,36 @@ {/if} {#if notice}

        {notice}

        {/if} {#if busy}

        Loading / sending…

        {/if} - {#if selected} + {#if menu?.input} +
        { + event.preventDefault(); + if (name.trim() && !busy && !unavailable) + void load('rename/' + encodeURIComponent(name.trim())); + }} + > + + +
        + {:else if selected}

        {selected.label}

        {selected.help || 'No additional help supplied by Codex.'}
        {#if selected.action}

        - TARGET // {session}. Changes affect subsequent turns of this - session, not global defaults. Automatic quota thresholds may later - supersede model settings. + TARGET // {session}. + {#if menu?.path.startsWith('rename/')}Only this session's saved name + changes. + {:else}Changes affect subsequent turns of this session, not global + defaults. Automatic quota thresholds may later supersede model + settings.{/if}