@hienlh/ppm 0.22.0 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/CLAUDE.md +1 -1
- package/assets/skills/ppm/SKILL.md +1 -1
- package/assets/skills/ppm/references/cli-reference.md +4 -4
- package/assets/skills/ppm/references/http-api.md +1 -1
- package/dist/web/assets/accounts-settings-section-D3BylchP.js +1 -0
- package/dist/web/assets/{ai-resource-editor-CdDpOwjh.js → ai-resource-editor-BLPcnhTM.js} +1 -1
- package/dist/web/assets/{ai-settings-section-X2UOfSaS.js → ai-settings-section-BtR7rF-T.js} +1 -1
- package/dist/web/assets/{ai-settings-section-B1hQyjAd.js → ai-settings-section-r9JctHNM.js} +1 -1
- package/dist/web/assets/{appearance-settings-section-DLoPK0LD.js → appearance-settings-section-CiMdk3sb.js} +1 -1
- package/dist/web/assets/{branch-review-tab-G84Ojzae.js → branch-review-tab-B1pFjlKM.js} +1 -1
- package/dist/web/assets/chat-tab-DZagX06m.js +15 -0
- package/dist/web/assets/{code-editor-D04iUPsZ.js → code-editor-BJhOEsnZ.js} +4 -4
- package/dist/web/assets/{codex-daily-guard-BSccLRGT.js → codex-daily-guard-CaCQJ4r_.js} +1 -1
- package/dist/web/assets/{conflict-editor-C4ay676e.js → conflict-editor-B7u_p49h.js} +3 -3
- package/dist/web/assets/{csv-preview-DbwEmG7o.js → csv-preview-CttjJU1e.js} +1 -1
- package/dist/web/assets/{database-viewer-S6LsALjX.js → database-viewer-Ca4HxIfx.js} +1 -1
- package/dist/web/assets/{diff-viewer-3oBA7vgQ.js → diff-viewer-9-XjLIwa.js} +1 -1
- package/dist/web/assets/{editor-language-service-DJmaKVY0.js → editor-language-service-D0DuEOs_.js} +1 -1
- package/dist/web/assets/{explorer-body-BQ0jyAGv.js → explorer-body-VdCBqcZu.js} +2 -2
- package/dist/web/assets/{explorer-window-content-jdkWt34J.js → explorer-window-content-BIsbl7Th.js} +1 -1
- package/dist/web/assets/extension-manager-section-HkY7geS5.js +1 -0
- package/dist/web/assets/{extension-webview-BGSDUbdK.js → extension-webview-DZG8YHX9.js} +1 -1
- package/dist/web/assets/{files-settings-section-Gnyd7han.js → files-settings-section-qnRtkX05.js} +1 -1
- package/dist/web/assets/{general-settings-section-V6Khh15V.js → general-settings-section-BAFSZmCE.js} +1 -1
- package/dist/web/assets/{git-log-panel-Bi513qjT.js → git-log-panel-2sGpfEla.js} +1 -1
- package/dist/web/assets/{glide-data-grid-DnQwYSmQ.js → glide-data-grid-f0hyITiF.js} +1 -1
- package/dist/web/assets/{group-chat-tab-DpczdwyV.js → group-chat-tab-Ck6sk7yY.js} +1 -1
- package/dist/web/assets/index-CEZVxM4G.js +52 -0
- package/dist/web/assets/{jira-watcher-section-f2HUbGDY.js → jira-watcher-section-CeLmhvu1.js} +1 -1
- package/dist/web/assets/keybindings-store-C_3ChOEf.js +1 -0
- package/dist/web/assets/{keyboard-shortcuts-section-BpvVEw_Y.js → keyboard-shortcuts-section-PVz6kuh2.js} +1 -1
- package/dist/web/assets/markdown-renderer-C140Ijk0.js +3 -0
- package/dist/web/assets/{markdown-renderer-Bcaf9_bA.js → markdown-renderer-Dz7-DYUg.js} +1 -1
- package/dist/web/assets/{mobile-explorer-sheet-Bol3XAO1.js → mobile-explorer-sheet-CUG_owdf.js} +1 -1
- package/dist/web/assets/notification-store-6vib1ISy.js +1 -0
- package/dist/web/assets/{ppmbot-settings-section-DKJUA3Kq.js → ppmbot-settings-section-Cji-Mil-.js} +1 -1
- package/dist/web/assets/{problems-panel-CFcoUx8h.js → problems-panel-a6_hrWvl.js} +1 -1
- package/dist/web/assets/{process-table-EKr2dqG6.js → process-table-CiIqlOIK.js} +1 -1
- package/dist/web/assets/{proxy-settings-section-B7qRVl8w.js → proxy-settings-section-BjI4IFgp.js} +1 -1
- package/dist/web/assets/{remote-desktop-clipboard-notice-0WDYsyCA.js → remote-desktop-clipboard-notice-eXYvwgx7.js} +1 -1
- package/dist/web/assets/{remote-desktop-mobile-sheet-COYDg16H.js → remote-desktop-mobile-sheet-Doh-fci-.js} +2 -2
- package/dist/web/assets/{remote-desktop-mobile-view-2DqSuS2U.js → remote-desktop-mobile-view-Dt8Akc3p.js} +1 -1
- package/dist/web/assets/{remote-desktop-readiness-gate-Dm_qMJMH.js → remote-desktop-readiness-gate-t83fqbID.js} +1 -1
- package/dist/web/assets/{remote-desktop-window-content-UodhsF7W.js → remote-desktop-window-content-CguhZMmx.js} +1 -1
- package/dist/web/assets/{schedules-settings-section-bG2lYfGv.js → schedules-settings-section-BVkpW5ms.js} +1 -1
- package/dist/web/assets/{settings-body-C06bFarv.js → settings-body-CoIxYAh6.js} +2 -2
- package/dist/web/assets/{settings-tab-34RSaASd.js → settings-tab-7DKVUTbM.js} +1 -1
- package/dist/web/assets/{settings-window-content-Dr_2lmHH.js → settings-window-content-3_39TeX-.js} +1 -1
- package/dist/web/assets/{sql-query-editor-BgRH0cHD.js → sql-query-editor-CQB7Yp7U.js} +1 -1
- package/dist/web/assets/{sqlite-viewer-DUxGslpa.js → sqlite-viewer-Bd7rjr1D.js} +1 -1
- package/dist/web/assets/{system-monitor-body-IZuLn7Qh.js → system-monitor-body-DsRXeMyU.js} +2 -2
- package/dist/web/assets/{system-monitor-tab-DiSA490Z.js → system-monitor-tab-DdSZgux3.js} +1 -1
- package/dist/web/assets/{system-monitor-window-content-CEaFISgj.js → system-monitor-window-content-ClPo4-El.js} +1 -1
- package/dist/web/assets/{tab-host-window-content-D0TN8Wrq.js → tab-host-window-content-d2TAD4PU.js} +1 -1
- package/dist/web/assets/{team-member-sheet-DDPNcCjd.js → team-member-sheet-7d2Qp-ie.js} +2 -2
- package/dist/web/assets/{team-member-window-content-DCiW_1-E.js → team-member-window-content-Bctg2gmg.js} +1 -1
- package/dist/web/assets/{terminal-tab-4ypP0NDY.js → terminal-tab-0HQic25V.js} +3 -3
- package/dist/web/assets/{tool-cards-Dd6E7Q3k.js → tool-cards-CmLLRACd.js} +2 -2
- package/dist/web/assets/{use-inline-blame-vrfFHuaR.js → use-inline-blame-sDMjcz1-.js} +3 -3
- package/dist/web/assets/{use-lsp-CsuZu49X.js → use-lsp-CBgID-EU.js} +1 -1
- package/dist/web/assets/{use-monaco-theme-BIVYJBIn.js → use-monaco-theme-gvhJ_jZh.js} +1 -1
- package/dist/web/assets/{use-websocket-BMbufhX7.js → use-websocket-C9wlRliB.js} +1 -1
- package/dist/web/assets/{video-preview-Byj8P_jA.js → video-preview-CSDK5j6H.js} +1 -1
- package/dist/web/index.html +1 -1
- package/dist/web/sw.js +1 -1
- package/docs/architecture/ai-chat-and-providers.md +9 -0
- package/package.json +1 -1
- package/packages/ext-git-graph/src/webview-html.test.ts +30 -5
- package/packages/ext-git-graph/src/webview-html.ts +99 -31
- package/src/services/edge-forwarder.ts +191 -191
- package/src/services/windows-process-tree.ts +351 -351
- package/src/shared/codex-daily-guard.ts +12 -5
- package/src/web/components/extensions/extension-tree-view.tsx +4 -11
- package/src/web/components/layout/command-palette.tsx +2 -18
- package/src/web/components/settings/accounts/account-card.tsx +2 -2
- package/src/web/components/settings/accounts/codex-accounts-section.tsx +4 -4
- package/src/web/components/settings/extension-manager-section.tsx +8 -1
- package/src/web/lib/extension-icons.ts +70 -0
- package/src/web/lib/tab-type-icons.ts +14 -0
- package/dist/web/assets/accounts-settings-section-BVr9-FZJ.js +0 -1
- package/dist/web/assets/chat-tab-DQJfjm8E.js +0 -15
- package/dist/web/assets/extension-manager-section-DG1guILi.js +0 -1
- package/dist/web/assets/index-DU68xk06.js +0 -52
- package/dist/web/assets/keybindings-store-DCRsnKg5.js +0 -1
- package/dist/web/assets/markdown-renderer-DGJp8HC3.js +0 -3
- package/dist/web/assets/notification-store-BXt54VIn.js +0 -1
- package/packages/vscode-compat/node_modules/.bin/tsc.bunx +0 -0
- package/packages/vscode-compat/node_modules/.bin/tsc.exe +0 -0
- package/packages/vscode-compat/node_modules/.bin/tsserver.bunx +0 -0
- package/packages/vscode-compat/node_modules/.bin/tsserver.exe +0 -0
- package/src/web/hooks/use-delayed-flag.ts +0 -35
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [0.22.1] - 2026-09-18
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
- **An extension's panels wear the icon its manifest declares.** Git Graph, Blame, File History, Compare, Interactive Rebase and Reflog were six tabs with the same puzzle piece on them, and the extension list in Settings drew one too — the names had been in the manifest all along, with nothing reading them. Three separate half-tables of icon names became one, so a name that works in the command palette now works on a tab and in a tree view as well.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- **The Git Graph is panned by dragging it, and has no scrollbar of its own.** The scrollbar sat in the 24px header row with its thumb across the word "Graph", and moving it under the header only traded that for a strip taking a row between the header and the first commit. Drag the graph sideways instead — the pointer says so, a finger still scrolls the list vertically, and a drag no longer opens the commit it ends on. A thin marker shows where in the lanes you are while something is moving them, and fades out after.
|
|
12
|
+
- **Codex's daily guard paces a weekly quota over five weekdays, not seven days.** A seventh of the week each day meant the allowance kept rising over a weekend nobody was working, and the week's real capacity was already spent by Thursday. Weekdays are counted in UTC so every device agrees on which day it is.
|
|
13
|
+
|
|
5
14
|
## [0.22.0] - 2026-09-18
|
|
6
15
|
|
|
7
16
|
### Added
|
package/CLAUDE.md
CHANGED
|
@@ -112,7 +112,7 @@ Related: `configService.save()`/`set()` throw when `load()` has not run, because
|
|
|
112
112
|
- **A file icon theme is five separate traps, and every one of them fails silently**: PPM draws the real `vscode-icons` artwork, vendored at build time by `bun scripts/gen-file-icons.ts` into `src/web/lib/file-icons.generated.ts` (the name → glyph tables) and `src/web/styles/file-icons.generated.css` (one `background-image` class per glyph). Both are committed; re-run the script after editing its lists, and `tests/unit/web/file-icons.test.ts` fails if the two files drift, because a name with no class renders a correctly-sized span of nothing. First trap: `width`/`height` **do not apply to a non-replaced inline element**, so the icon span needs `inline-block` — the trees are flex rows and blockify it for free, while the tab strip wraps its icon in a `<span class="relative">` for the notification dot and there the icon measured 0×0 and simply was not there. An inline `<svg>` would have worked without saying so, which is why this only broke in one place. Second: `vscode-icons-js` answers with the **light-theme** drawing for 143 glyphs and offers no way to ask for the other one (`getIconForFile("a.json")` is `file_type_light_json`, full stop), and those are darker ink meant for a light workbench — `file-type-light-toml` has no `fill` at all, i.e. black on black. The generator canonicalises the class to the theme-independent name and emits the light drawing as a `:root.light` override, which costs +1.2 KiB brotli for +100 KiB raw because the two bodies differ by a colour and brotli collapses the duplication. Third: the *mapping* is not the artwork's package. It is built from the extension's own `src/iconsManifest` (pinned tag + SHA-256 per file), because the third-party `vscode-icons-js` repackaging lags it badly — its table of multi-dot extensions holds **41** entries against the manifest's 127 — and it has never held `controller.ts`, `module.ts` or `service.ts` in any of its tables, which is why `app.controller.ts`, `app.module.ts` and `app.service.ts` drew the plain TypeScript glyph while the Nest artwork sat unused in the bundle. It is still read *second*, and that is not laziness: the manifest associates a great many types by **VS Code language id** and nothing else (the `dotenv` entry has `extensions: []`; `.cc`, `.htm`, `.conf`, `.kts` reach their icon only because the editor already knows which language owns them), so a manifest-only port silently lost 36 names that previously had an icon. Three consequences. The sources cascade **per key, not per table** — merging first and resolving after loses a key outright when the winning source names a glyph that is missing or over budget, which is how `cargo.lock` ended up blank while the second source's answer sat right there. The manifest's *language* layer ranks **below** `vscode-icons-js`'s flattening of VS Code's real associations, because `knownExtensions` turns "this language is known by .css" into "a .css file is this icon" and `tailwindcss` also claims `css` and sorts after it — every stylesheet in the app came out with the Tailwind logo. And the legacy tables answer with `file_type_light_*` names too, so the `light_` prefix has to be stripped there as well or trap two comes back through the side door. Fourth, and the reason `.service.ts` needs a project to answer it: `nest_*` and `ng_*` ship `disabled: true` upstream, behind two presets that are **mutually exclusive** — they claim the same six suffixes (`module`, `service`, `guard`, `pipe`, `interceptor`, `controller`) and `ng_` sorts after `nest_`, so enabling both hands a NestJS repository the Angular artwork. They are emitted as *overlays* and `project-framework-store.ts` picks one per project from a `package.json` dependency; `FileIcon` subscribes rather than taking a prop, because two of the eight call sites go through `fileIconElement`, which hands out a component with no project in scope. Fifth: a byte budget cuts by weight, not by worth. At 1800 bytes it dropped `file-type-reactts` (1833) and with it every `.tsx` file in a TypeScript repository, plus `.jsx`, `.go` and `.rs`. And measure the right number: the generated stylesheet is big enough that the bundler gives it its own chunk (`assets/file-icons-*.css`, 382 KiB brotli for the full 1193-glyph port), which is outside the service worker's `globPatterns` — so it never shows up in `precache N entries` and only `precompress-web.ts`'s `.br` sibling tells you what it costs.
|
|
113
113
|
- **Icons come from `@/lib/icons`, never from `lucide-react`, and mixing the two is invisible until you look twice**: the app's chrome is Fluent System Icons at 20px Regular (the set `miguelsolorio.fluent-icons` puts over VS Code's product icons), vendored by `bun scripts/gen-product-icons.ts` into `src/web/lib/icons.generated.tsx` and built on the one component in `src/web/lib/fluent-icon.tsx`. 207 of the 222 names resolve; the other 15 stay on lucide on purpose and `tests/unit/web/product-icons.test.ts` pins that list, because "fix the missing icon by falling back" is how an icon set stops being one. Four things to know. The two sets share almost no vocabulary — lucide's `X` is Fluent's `dismiss`, `Check` is `checkmark`, `Trash2` is `delete`, `Plus` is `add`, `RefreshCw` is `arrow-sync`, and only 72 names kebab-case straight across — so `MAP` in the script is a hand-checked table, and every entry is verified against the collection at generation time rather than trusted. The glyphs keep their **20px** viewBox rather than being re-boxed to lucide's 24: Fluent's outlines are drawn for that grid, and the app sizes icons with Tailwind `size-*` classes anyway, which beat the width/height attributes because they are CSS. `strokeWidth` is accepted and *dropped* — these are filled outlines with nothing to weight, and spreading it would put a dead attribute in the DOM and make React warn about `absoluteStrokeWidth` on every render. And the identifying hook is `data-icon="<name>"`, not a class: lucide put the same information in `class="lucide lucide-circle-check"`, which is what let a tool-card test assert "this card is spinning" by string-matching the markup — an attribute keeps that possible without offering stylesheets a class name to start depending on. Related and separate: the *file* icons are a different system (`@/lib/file-icons`, the entry above), because those are full-colour artwork with no `currentColor` to inherit.
|
|
114
114
|
- **A banding rule qualified with an id outranks hover and selection**: `#commit-list .commit-row:nth-child(even)` is (1,2,0) against `.commit-row:hover` and `.commit-row.selected` at (0,2,0), so every *other* row silently stopped highlighting on hover and when selected — the kind of thing that reads as "sometimes it doesn't work". Zebra striping has to be written at the same specificity and earlier in the file, and a test asserts both. In the same stylesheet, the phone block (`@media (max-width: 640px)`) must come after the `@media (pointer: coarse)` block and after the two width tiers (900px drops date and hash, 760px drops changes), because the later block is what decides a tie.
|
|
115
|
-
- **The Git Graph's column widths are one number owned by JS, and the message column is what pays for getting it wrong**: the commit row is a flexbox whose six other cells are all pinned by a `min-width`, so `.col-message` is the only thing that can shrink — and it was written `min-width: 0`. The graph column was then set to the SVG's *intrinsic* width (`28 + (lanes − 1) × 22`), with no relation to the panel, so from about 22 parallel lanes up in a 1020px panel the message column was zero pixels wide and the columns behind it were clipped away with `overflow-x: hidden` over them. The fix is a cap (`graphColCap()` measures the header's own cells, so a hidden column hands its pixels over without anything having to know which columns exist) plus a floor (`MESSAGE_MIN_W`, interpolated into both the CSS and the script from one constant). Three things are load-bearing. A cap without a **clip** is not a fix: the SVG is `position: absolute` and the rows are static, so it paints *above* them — an uncapped overlay draws branch lines through the messages, which is why `#graph-clip` exists and why the clip box is offset by the row's 6px padding while the 2px the drawing sits in from there moved onto the SVG (both on the box and it ends 2px into the message).
|
|
115
|
+
- **The Git Graph's column widths are one number owned by JS, and the message column is what pays for getting it wrong**: the commit row is a flexbox whose six other cells are all pinned by a `min-width`, so `.col-message` is the only thing that can shrink — and it was written `min-width: 0`. The graph column was then set to the SVG's *intrinsic* width (`28 + (lanes − 1) × 22`), with no relation to the panel, so from about 22 parallel lanes up in a 1020px panel the message column was zero pixels wide and the columns behind it were clipped away with `overflow-x: hidden` over them. The fix is a cap (`graphColCap()` measures the header's own cells, so a hidden column hands its pixels over without anything having to know which columns exist) plus a floor (`MESSAGE_MIN_W`, interpolated into both the CSS and the script from one constant). Three things are load-bearing. A cap without a **clip** is not a fix: the SVG is `position: absolute` and the rows are static, so it paints *above* them — an uncapped overlay draws branch lines through the messages, which is why `#graph-clip` exists and why the clip box is offset by the row's 6px padding while the 2px the drawing sits in from there moved onto the SVG (both on the box and it ends 2px into the message). There is nowhere to put a real scrollbar, which is why what the clip hides is reached by **dragging the graph**: the clip is as tall as the whole history, so `overflow-x: auto` on it puts the bar thousands of pixels below the viewport, and a strip inside the 24px header row lands its thumb across the word "Graph" (a strip *under* the header works, and costs a row of its own that the reader did not ask for). The drag needs one non-obvious line: a row's `.col-graph` is an empty spacer in a row that centres its cells, so it is **0px tall** and `elementFromPoint` there answers with the row — `align-self: stretch` is what makes the cell the thing under the pointer, and it must not reach the header's cell, which has a label that then lifts off the other headings' line. The rest is a movement threshold (sideways, past 4px, or it is the click that opens a commit), `touch-action: pan-y` so a finger scrolling the list still belongs to the browser, and a capture-phase `click` handler, because a pan ends over a row whose own handler would otherwise open it. And the cap is a share of the panel, so it needs a `ResizeObserver`: nothing re-renders the graph when a window is dragged, and the old cap then quietly outlives the width it was computed for. Verify with `bun tests/e2e/git-graph-narrow-layout.ts`, which measures a synthetic 40-branch history in headless Chrome — a CSS assertion cannot tell you that a column ended up 240px wide.
|
|
116
116
|
- **`vscode.languages` and every editor API are absent for extensions**: no `activeTextEditor`, no `setDecorations`, no hover providers. Anything GitLens-shaped that wants to annotate code has to render its own view in a webview panel.
|
|
117
117
|
- **Screen wake lock needs a secure context**: `navigator.wakeLock` does not exist at all over plain HTTP, so reaching PPM at `http://<lan-ip>:<port>` silently disables "keep screen awake" — the very setup (a tablet on the LAN) it was built for. Only HTTPS and `localhost` qualify. The lock is also released by the browser on *every* hide, so `src/web/hooks/use-wake-lock.ts` re-acquires on `visibilitychange` and drops its handle on hide rather than waiting for the `release` event, whose ordering against `visibilitychange` is undefined.
|
|
118
118
|
- **Remote desktop on macOS (avfoundation)**: address the screen by **name** (`-i "Capture screen 0"`), never by index — the device list reorders at runtime when a Continuity Camera joins (index 3 became the iPhone). `-framerate` is ignored (the screen input delivers at display refresh, 120–165 fps, with a stuck pts) → `-use_wallclock_as_timestamps 1` + `-vf fps=30`. ffmpeg-avfoundation ignores SIGTERM/SIGINT → `proc.kill("SIGKILL")` or it leaks one process per session. No Screen Recording grant = **black frames, no error**; no Accessibility grant = silent no-op input — both are pre-flighted in `remote-desktop-requirements.ts`, never inferred from failures. TCC keys the grant to the `bun` executable.
|
|
@@ -71,4 +71,4 @@ This skill covers the `ppm` CLI, its HTTP API, and its config DB. It does **not*
|
|
|
71
71
|
- Third-party extensions (inspect via `ppm ext list`).
|
|
72
72
|
- The Claude Agent SDK internals (separate skill).
|
|
73
73
|
|
|
74
|
-
<!-- Generated for PPM v0.22.
|
|
74
|
+
<!-- Generated for PPM v0.22.1 at build time. Re-run `ppm export skill --install` to refresh. -->
|
|
@@ -781,7 +781,7 @@ Show recent runs for a schedule
|
|
|
781
781
|
Manage and inspect discovered skills & commands
|
|
782
782
|
|
|
783
783
|
**Options:**
|
|
784
|
-
- `--project <path>` — Project path (default: `"C:\\Users\\PC\\ppm"`)
|
|
784
|
+
- `--project <path>` — Project path (default: `"C:\\Users\\PC\\ppm-release-0.22.1"`)
|
|
785
785
|
|
|
786
786
|
**Usage:** `ppm skills [options] [command]`
|
|
787
787
|
|
|
@@ -791,7 +791,7 @@ List all discovered skills and commands
|
|
|
791
791
|
|
|
792
792
|
**Options:**
|
|
793
793
|
- `--json` — JSON output
|
|
794
|
-
- `--project <path>` — Project path (default: `"C:\\Users\\PC\\ppm"`)
|
|
794
|
+
- `--project <path>` — Project path (default: `"C:\\Users\\PC\\ppm-release-0.22.1"`)
|
|
795
795
|
|
|
796
796
|
### `ppm skills search`
|
|
797
797
|
|
|
@@ -799,7 +799,7 @@ Fuzzy search skills and commands
|
|
|
799
799
|
|
|
800
800
|
**Options:**
|
|
801
801
|
- `--json` — JSON output
|
|
802
|
-
- `--project <path>` — Project path (default: `"C:\\Users\\PC\\ppm"`)
|
|
802
|
+
- `--project <path>` — Project path (default: `"C:\\Users\\PC\\ppm-release-0.22.1"`)
|
|
803
803
|
|
|
804
804
|
**Usage:** `ppm skills search [options] <query>`
|
|
805
805
|
|
|
@@ -809,7 +809,7 @@ Show detailed info for a specific skill
|
|
|
809
809
|
|
|
810
810
|
**Options:**
|
|
811
811
|
- `--json` — JSON output
|
|
812
|
-
- `--project <path>` — Project path (default: `"C:\\Users\\PC\\ppm"`)
|
|
812
|
+
- `--project <path>` — Project path (default: `"C:\\Users\\PC\\ppm-release-0.22.1"`)
|
|
813
813
|
|
|
814
814
|
**Usage:** `ppm skills info [options] <name>`
|
|
815
815
|
|
|
@@ -349,4 +349,4 @@ _Base URL: `http://localhost:8080` (default; override via `ppm config set port <
|
|
|
349
349
|
- `ws://<host>/ws/terminal` — PTY terminal multiplexer
|
|
350
350
|
- `ws://<host>/ws/extensions` — extension host channel
|
|
351
351
|
|
|
352
|
-
<!-- Generated from src/server/routes/ for PPM v0.22.
|
|
352
|
+
<!-- Generated from src/server/routes/ for PPM v0.22.1 -->
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import{Br as r,Tn as i,V as a,Xt as o,ct as s,dn as c,kr as l,ln as u,nt as d,or as f,qn as p,st as m,wr as h,xt as g}from"./icons-DQjqk0lJ.js";import{n as _,r as v}from"./api-client-C1ZwRL4Y.js";import{n as y}from"./utils-Bmf_8h7Y.js";import"./portal-container-context-BarKmT4S.js";import{n as b}from"./use-is-mobile-TkcwP1Gx.js";import{n as x,t as S}from"./button-B9CTrsEf.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./dialog-B84_DJQ8.js";import{t as k}from"./mobile-bottom-sheet-C3TniEP-.js";import"./use-visual-viewport-Lp878uzs.js";import{t as A}from"./input-C7Q8FxeL.js";import{$t as j,Cn as M,G as N,J as P,K as F,Tn as I,W as ee,Y as L,fn as te,q as R,rt as z,wn as B}from"./index-CEZVxM4G.js";import{addAccount as V,deleteAccount as H,exchangeOAuthCode as U,getAISettings as W,getAccountSettings as G,getOAuthUrl as K,getUsageHistory as ne,importAccounts as q,patchAccount as J,testAccountToken as re,testExport as Y,testRawToken as ie,updateAccountSettings as X}from"./api-settings-_7Q-ULxp.js";import{a as ae,c as oe,d as se,f as ce,i as le,n as ue,o as de,r as fe,s as pe,t as me,u as he}from"./codex-daily-guard-CaCQJ4r_.js";var Z=e(t(),1),Q=n(),ge=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],$=Array.from({length:24},(e,t)=>t);function _e(e,t){let n=Array.from({length:7},()=>Array.from({length:24},()=>({sum:0,count:0,avg:0})));for(let r of e){let e=t===`5h`?r.five_hour_util:r.weekly_util;if(e==null)continue;let i=new Date(r.recorded_at+(r.recorded_at.endsWith(`Z`)?``:`Z`)),a=(i.getDay()+6)%7,o=i.getHours();n[a][o].sum+=e,n[a][o].count+=1}for(let e of n)for(let t of e)t.avg=t.count>0?t.sum/t.count:0;return n}function ve(e){return e.map(e=>{let t=e.reduce((e,t)=>e+t.sum,0),n=e.reduce((e,t)=>e+t.count,0);return n>0?t/n:0})}function ye(e){return $.map(t=>{let n=0,r=0;for(let i of e)n+=i[t].sum,r+=i[t].count;return r>0?n/r:0})}function be(e){return e===0?`bg-surface-elevated`:e<.3?`bg-success/30`:e<.5?`bg-success/60`:e<.7?`bg-warning/50`:e<.9?`bg-warning/80`:`bg-error/80`}function xe(e){return e<.3?`bg-success`:e<.7?`bg-warning`:`bg-error`}function Se({accountId:e}){let[t,n]=(0,Z.useState)(null),[r,i]=(0,Z.useState)(!0),[a,o]=(0,Z.useState)(`5h`);(0,Z.useEffect)(()=>{i(!0),ne(e).then(n).catch(()=>n([])).finally(()=>i(!1))},[e]);let s=(0,Z.useMemo)(()=>t?_e(t,a):null,[t,a]),c=(0,Z.useMemo)(()=>s?ve(s):[],[s]),l=(0,Z.useMemo)(()=>s?ye(s):[],[s]),d=Math.max(...c,.01);if(Math.max(...l,.01),r)return(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,Q.jsx)(u,{className:`size-3 animate-spin text-text-subtle`})});if(!t||t.length===0)return(0,Q.jsx)(`div`,{className:`text-[10px] text-text-subtle py-2 text-center`,children:`No usage history yet`});let f=t.length,p=new Set(t.map(e=>new Date(e.recorded_at+(e.recorded_at.endsWith(`Z`)?``:`Z`)).toDateString())).size;return(0,Q.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`span`,{className:`text-[10px] font-medium text-text-subtle`,children:`Usage Pattern (7d)`}),(0,Q.jsxs)(`div`,{className:`flex gap-0.5 text-[9px]`,children:[(0,Q.jsx)(`button`,{onClick:()=>o(`5h`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`5h`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`5-hour rolling window limit — resets every 5 hours`,children:`5h`}),(0,Q.jsx)(`button`,{onClick:()=>o(`weekly`),className:`px-1.5 py-0.5 rounded cursor-pointer transition-colors ${a===`weekly`?`bg-primary/15 text-primary`:`text-text-subtle hover:text-text-secondary`}`,title:`Weekly limit — resets every 7 days`,children:`Wk`})]})]}),(0,Q.jsxs)(`p`,{className:`text-[9px] text-text-subtle leading-tight`,children:[`Avg `,a===`5h`?`5-hour`:`weekly`,` limit usage over `,p,`d (`,f,` samples). Higher % = closer to rate limit. Hover cells for details.`]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by day of week`}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-[2px] mt-0.5`,children:ge.map((e,t)=>{let n=c[t]??0;return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-[8px] text-text-subtle w-5 shrink-0 text-right tabular-nums`,children:e}),(0,Q.jsx)(`div`,{className:`flex-1 h-2.5 bg-surface-elevated rounded-sm overflow-hidden`,children:(0,Q.jsx)(`div`,{className:`h-full rounded-sm transition-all ${xe(n)}`,style:{width:`${Math.round(n/d*100)}%`}})}),(0,Q.jsxs)(`span`,{className:`text-[8px] text-text-subtle w-6 shrink-0 text-right tabular-nums`,children:[Math.round(n*100),`%`]})]},e)})})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Avg usage by hour (0h-23h)`}),(0,Q.jsx)(`div`,{className:`flex gap-[1px] mt-0.5`,children:$.map(e=>{let t=l[e]??0;return(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center gap-[1px]`,children:[(0,Q.jsx)(`div`,{className:`w-full aspect-square rounded-[2px] ${be(t)}`,title:`${e}:00 — avg ${Math.round(t*100)}% usage`}),e%6==0&&(0,Q.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})]},e)})})]}),s&&(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`span`,{className:`text-[9px] text-text-subtle`,children:`Day x Hour heatmap`}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-[1px] mt-0.5`,children:[ge.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,Q.jsx)(`span`,{className:`text-[7px] text-text-subtle w-4 shrink-0 text-right`,children:e.charAt(0)}),$.map(n=>{let r=s[t][n];return(0,Q.jsx)(`div`,{className:`flex-1 aspect-square rounded-[1px] ${be(r.avg)}`,title:`${e} ${n}:00 — ${r.count>0?`avg ${Math.round(r.avg*100)}% (${r.count} samples)`:`no data`}`},n)})]},e)),(0,Q.jsxs)(`div`,{className:`flex items-center gap-[1px]`,children:[(0,Q.jsx)(`span`,{className:`w-4 shrink-0`}),$.map(e=>(0,Q.jsx)(`div`,{className:`flex-1 text-center`,children:e%6==0&&(0,Q.jsx)(`span`,{className:`text-[7px] text-text-subtle tabular-nums`,children:e})},e))]})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[8px] text-text-subtle`,children:[(0,Q.jsx)(`span`,{children:`Low`}),(0,Q.jsxs)(`div`,{className:`flex gap-[2px]`,children:[(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/30`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-success/60`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/50`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-warning/80`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-error/80`})]}),(0,Q.jsx)(`span`,{children:`High`}),(0,Q.jsx)(`span`,{className:`ml-1`,children:`|`}),(0,Q.jsx)(`div`,{className:`size-2 rounded-[1px] bg-surface-elevated border border-border/30`}),(0,Q.jsx)(`span`,{children:`No data`})]})]})}function Ce({profile:e,accountId:t,onClose:n}){let i=[[`Name`,e.account?.display_name],[`Email`,e.account?.email],[`Org`,e.organization?.name],[`Type`,e.organization?.organization_type],[`Tier`,e.organization?.rate_limit_tier],[`Status`,e.organization?.subscription_status]];return(0,Q.jsxs)(`section`,{className:`space-y-2 border-t border-border pt-3`,"data-testid":`account-profile-panel`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`Profile`}),(0,Q.jsx)(`button`,{className:`p-2 text-muted-foreground hover:text-foreground cursor-pointer`,onClick:n,"aria-label":`Close profile`,children:(0,Q.jsx)(r,{className:`size-4`})})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-[80px_1fr] gap-x-3 gap-y-1 text-xs`,children:i.map(([e,t])=>t?(0,Q.jsxs)(`span`,{className:`contents`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,Q.jsx)(`span`,{className:`break-all`,children:t})]},e):null)}),(0,Q.jsx)(Se,{accountId:t})]})}function we({display:e,onConfirm:t,onCancel:n}){let r=b(),i=(0,Q.jsxs)(`div`,{className:`space-y-4`,"data-testid":`account-delete-confirm`,children:[(0,Q.jsxs)(`p`,{className:`text-sm`,children:[`Remove `,(0,Q.jsx)(`span`,{className:`font-medium`,children:e}),`?`]}),(0,Q.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`The stored token is deleted from this machine. Any export you already made keeps working.`}),(0,Q.jsxs)(`div`,{className:`flex flex-col-reverse md:flex-row gap-2 md:justify-end pt-2`,children:[(0,Q.jsx)(S,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Cancel`}),(0,Q.jsx)(S,{variant:`destructive`,autoFocus:!1,onClick:t,className:`min-h-11`,children:`Remove account`})]})]});return r?(0,Q.jsx)(k,{open:!0,onClose:n,children:(0,Q.jsxs)(`div`,{className:`px-4 pb-4`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold mb-3`,children:`Remove account`}),i]})}):(0,Q.jsx)(O,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(T,{className:`sm:max-w-sm`,children:[(0,Q.jsx)(C,{children:(0,Q.jsx)(E,{className:`text-sm`,children:`Remove account`})}),i]})})}function Te({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),[l,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(``),[g,_]=(0,Z.useState)(!1),[v,y]=(0,Z.useState)(`idle`);function b(){p(null),h(``),y(`idle`),d(null)}function x(){t(!1),b(),i(``),o(``),d(null)}async function k(){_(!0),d(null);try{let{url:e,state:t}=await K();p(t),y(`waiting`),window.open(e,`_blank`)}catch(e){d(e.message)}_(!1)}async function j(){if(!(!m.trim()||!f)){_(!0),d(null);try{let e=m.trim();e.includes(`#`)&&(e=e.split(`#`)[0]??e);let t=await U(e,f);x(),n(t?.status===`disabled`?`Signed in. This account is still disabled — enable it to use it.`:`Account connected via OAuth!`)}catch(e){d(e.message)}_(!1)}}async function M(){if(r.trim()){c(!0),d(null);try{let e=await V({apiKey:r.trim(),label:a.trim()||void 0});x(),n(e?.status===`disabled`?`Token updated. This account is still disabled — enable it to use it.`:`Account added!`)}catch(e){d(e.message)}c(!1)}}let N=r.trim()?r.trim().startsWith(`sk-ant-oat`)?`OAuth token (Claude Max/Pro)`:r.trim().startsWith(`sk-ant-api`)?`API key`:`Unknown format`:``;return(0,Q.jsx)(O,{open:e,onOpenChange:e=>{e||x()},children:(0,Q.jsxs)(T,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(C,{children:[(0,Q.jsx)(E,{className:`text-sm`,children:`Add Claude Account`}),(0,Q.jsx)(D,{className:`text-xs leading-relaxed`,children:`Connect via OAuth (recommended) or paste a token manually.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Recommended: Login with Claude`}),v===`idle`?(0,Q.jsx)(S,{size:`sm`,className:`w-full h-8 text-xs`,onClick:k,disabled:g,children:g?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(u,{className:`size-3 animate-spin mr-1`}),` Opening...`]}):`Login with Claude`}):(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Authorize in the opened tab, then paste the code:`}),(0,Q.jsx)(A,{placeholder:`Paste code here...`,value:m,onChange:e=>h(e.target.value),className:`text-xs h-8 font-mono`,autoFocus:!0}),(0,Q.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,Q.jsx)(S,{size:`sm`,className:`flex-1 h-7 text-xs`,onClick:j,disabled:!m.trim()||g,children:g?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(u,{className:`size-3 animate-spin mr-1`}),` Connecting...`]}):`Connect`}),(0,Q.jsx)(S,{size:`sm`,variant:`ghost`,className:`h-7 text-xs`,onClick:b,children:`Cancel`})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex-1 border-t`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`or paste token`}),(0,Q.jsx)(`div`,{className:`flex-1 border-t`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(z,{htmlFor:`add-token`,className:`text-xs`,children:`Token`}),(0,Q.jsx)(A,{id:`add-token`,type:`password`,placeholder:`sk-ant-...`,value:r,onChange:e=>i(e.target.value),className:`text-xs h-8 font-mono`}),N&&(0,Q.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[`Detected: `,N]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(z,{htmlFor:`add-label`,className:`text-xs`,children:`Label (optional)`}),(0,Q.jsx)(A,{id:`add-label`,placeholder:`e.g. Personal, Work`,value:a,onChange:e=>o(e.target.value),className:`text-xs h-8`})]})]}),l&&(0,Q.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:l}),(0,Q.jsxs)(w,{children:[(0,Q.jsx)(S,{size:`sm`,variant:`outline`,className:`text-xs h-7`,onClick:x,children:`Cancel`}),(0,Q.jsx)(S,{size:`sm`,className:`text-xs h-7`,onClick:M,disabled:!r.trim()||s,children:s?`Adding...`:`Add Token`})]})]})})}function Ee(e){let t=new Blob([e],{type:`application/json`}),n=document.createElement(`a`);n.href=URL.createObjectURL(t),n.download=`ppm-accounts-backup.json`,n.click(),URL.revokeObjectURL(n.href)}function De({open:e,onOpenChange:t,accounts:n,preselectId:r,onMessage:i}){let a=n.filter(e=>e.hasRefreshToken),[o,s]=(0,Z.useState)(new Set),[l,f]=(0,Z.useState)(``),[p,h]=(0,Z.useState)(!1),[g,_]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,k]=(0,Z.useState)(!1);e&&!x&&(s(r?new Set([r]):new Set(a.map(e=>e.id))),k(!0)),!e&&x&&k(!1);function M(){t(!1),f(``),h(!1),_(!1)}async function N(e){if(o.size===0)return;b(!0);let t=l.trim()||`ppm-hienlh`;try{let n={"Content-Type":`application/json`},r=v();r&&(n.Authorization=`Bearer ${r}`);let a=await fetch(`/api/accounts/export`,{method:`POST`,headers:n,body:JSON.stringify({password:t,accountIds:[...o],includeRefreshToken:p,refreshBeforeExport:g})});if(!a.ok){let e=await a.json();throw Error(e.error??`Export failed: ${a.status}`)}let s=await a.text();e&&await j(s)?i?.(`Backup copied to clipboard!`):(Ee(s),i?.(`Backup downloaded.`)),M()}catch{}b(!1)}let P=o.size>0&&!y;return(0,Q.jsx)(O,{open:e,onOpenChange:e=>{e||M()},children:(0,Q.jsxs)(T,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(C,{children:[(0,Q.jsxs)(E,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(c,{className:`size-3.5`}),` Export Accounts`]}),(0,Q.jsx)(D,{className:`text-xs`,children:`Select accounts and set a password to protect the backup.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium text-muted-foreground`,children:`Accounts to export`}),(0,Q.jsx)(`button`,{className:`text-[10px] text-primary hover:underline cursor-pointer`,onClick:()=>s(o.size===a.length?new Set:new Set(a.map(e=>e.id))),children:o.size===a.length?`Deselect all`:`Select all`})]}),a.length===0?(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground p-2 border rounded`,children:`No exportable accounts.`}):(0,Q.jsx)(`div`,{className:`max-h-36 overflow-y-auto space-y-1 border rounded p-2`,children:a.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`exp-${e.id}`,checked:o.has(e.id),onChange:t=>{let n=new Set(o);t.target.checked?n.add(e.id):n.delete(e.id),s(n)},className:`size-3.5 accent-primary cursor-pointer`}),(0,Q.jsx)(`label`,{htmlFor:`exp-${e.id}`,className:`text-xs cursor-pointer truncate`,children:e.label??e.email??e.id.slice(0,8)})]},e.id))})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(z,{className:`text-xs`,children:[`Password `,(0,Q.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,Q.jsx)(A,{type:`password`,placeholder:`Leave empty for default`,value:l,onChange:e=>f(e.target.value),className:`text-xs h-8`,autoComplete:`new-password`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`exp-full`,checked:p,onChange:e=>h(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,Q.jsx)(`label`,{htmlFor:`exp-full`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens (full transfer)`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,id:`exp-refresh`,checked:g,onChange:e=>_(e.target.checked),className:`size-3.5 accent-primary cursor-pointer`}),(0,Q.jsx)(`label`,{htmlFor:`exp-refresh`,className:`text-[11px] cursor-pointer`,children:`Refresh tokens before export`})]}),p?(0,Q.jsxs)(`div`,{className:`rounded-md border border-error/30 bg-error/5 p-2.5`,children:[(0,Q.jsx)(`p`,{className:`text-[10px] font-medium text-error`,children:`Full transfer — source accounts will expire`}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Refresh tokens included. Source machine expires in ~1h after target refreshes.`})]}):g?(0,Q.jsx)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-2.5`,children:(0,Q.jsx)(`p`,{className:`text-[10px] font-medium text-warning`,children:`Refresh before export — invalidates previous shares`})}):(0,Q.jsx)(`div`,{className:`rounded-md border border-success/30 bg-success/5 p-2.5`,children:(0,Q.jsx)(`p`,{className:`text-[10px] font-medium text-success`,children:`Share current token (safe)`})}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`Encrypted with AES-256-GCM + scrypt.`})]}),(0,Q.jsxs)(w,{className:`gap-1.5 flex-col sm:flex-row`,children:[(0,Q.jsx)(S,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:M,children:`Cancel`}),(0,Q.jsxs)(S,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,disabled:!P,onClick:()=>N(!0),children:[(0,Q.jsx)(d,{className:`size-3 mr-1`}),` Copy`]}),(0,Q.jsx)(S,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!P,onClick:()=>N(!1),children:y?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(u,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(m,{className:`size-3 mr-1`}),` Download`]})})]})]})})}function Oe({open:e,onOpenChange:t,onSuccess:n}){let[r,i]=(0,Z.useState)(``),[a,o]=(0,Z.useState)(``),[s,l]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null);function p(){t(!1),i(``),o(``),f(null)}async function m(){if(r.trim()){l(!0),f(null);try{let e=await q({data:r.trim(),password:a.trim()||`ppm-hienlh`});p(),n(`Imported ${e.imported} account(s)`)}catch(e){f(e.message||`Import failed`)}l(!1)}}return(0,Q.jsx)(O,{open:e,onOpenChange:e=>{e||p()},children:(0,Q.jsxs)(T,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(C,{children:[(0,Q.jsxs)(E,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(c,{className:`size-3.5`}),` Import Accounts`]}),(0,Q.jsx)(D,{className:`text-xs`,children:`Paste backup data and enter the export password. Imported accounts are temporary (~1h).`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(z,{className:`text-xs`,children:`Backup data`}),(0,Q.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),placeholder:`Paste backup JSON here...`,rows:4,className:`w-full text-xs p-2 rounded border border-border bg-background font-mono resize-none focus:outline-none focus:ring-1 focus:ring-primary`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(z,{className:`text-xs`,children:[`Password `,(0,Q.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(optional)`})]}),(0,Q.jsx)(A,{type:`password`,placeholder:`Leave empty for default`,value:a,onChange:e=>o(e.target.value),className:`text-xs h-8`,autoComplete:`current-password`})]})]}),d&&(0,Q.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:d}),(0,Q.jsxs)(w,{children:[(0,Q.jsx)(S,{size:`sm`,variant:`outline`,className:`text-xs h-7 cursor-pointer`,onClick:p,children:`Cancel`}),(0,Q.jsx)(S,{size:`sm`,className:`text-xs h-7 cursor-pointer`,disabled:!r.trim()||s,onClick:m,children:s?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(u,{className:`size-3 animate-spin mr-1`}),` Importing...`]}):`Import`})]})]})})}var ke=typeof window<`u`?window.matchMedia(`(min-width: 768px)`):null;function Ae(e){return ke?.addEventListener(`change`,e),()=>ke?.removeEventListener(`change`,e)}function je(){return ke?.matches??!0}function Me(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(!0);return(0,Z.useEffect)(()=>{r(!0),G().then(t).finally(()=>r(!1))},[]),n?(0,Q.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Loading...`}):e?(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Rotation Strategy`}),(0,Q.jsxs)(ee,{value:e.strategy,onValueChange:async e=>{t(await X({strategy:e}))},children:[(0,Q.jsx)(R,{className:`w-full h-9 text-xs`,children:(0,Q.jsx)(P,{})}),(0,Q.jsxs)(N,{children:[(0,Q.jsx)(F,{value:`round-robin`,children:`Round-robin`}),(0,Q.jsx)(F,{value:`fill-first`,children:`Fill-first`}),(0,Q.jsx)(F,{value:`lowest-usage`,children:`Lowest usage`})]})]}),(0,Q.jsxs)(`p`,{className:`text-[10px] text-text-subtle`,children:[e.strategy===`round-robin`&&`Cycles through accounts evenly`,e.strategy===`fill-first`&&`Uses one account until its limit, then moves on`,e.strategy===`lowest-usage`&&`Picks the account with the lowest current usage`]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Max Retry`}),(0,Q.jsx)(`input`,{type:`number`,min:0,value:e.maxRetry,className:`w-full h-9 text-xs border rounded-md px-3 bg-background`,onChange:async e=>{let n=parseInt(e.target.value,10);!isNaN(n)&&n>=0&&t(await X({maxRetry:n}))}}),(0,Q.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`How many accounts to try on failure. 0 = try all available accounts.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5 border-t border-border pt-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`text-xs font-medium text-text-primary`,children:`Cooldown parking`}),(0,Q.jsx)(L,{checked:e.cooldownEnabled,onCheckedChange:async e=>{t(await X({cooldownEnabled:e}))}})]}),(0,Q.jsx)(`p`,{className:`text-[10px] text-text-subtle`,children:`Park a failing account (rate limit / usage limit / auth error) until it recovers. Off: accounts stay selectable — rotation still skips accounts already ≥95% on the 5-hour limit.`})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between text-xs border-t border-border pt-3`,children:[(0,Q.jsx)(`span`,{className:`text-text-subtle`,children:`Active accounts`}),(0,Q.jsx)(`span`,{className:`font-medium text-text-primary`,children:e.activeCount})]})]}):(0,Q.jsx)(`p`,{className:`text-xs text-text-subtle py-4 text-center`,children:`Failed to load settings`})}function Ne({open:e,onOpenChange:t}){let n=(0,Z.useSyncExternalStore)(Ae,je);return e?n?(0,Q.jsx)(O,{open:e,onOpenChange:t,children:(0,Q.jsxs)(T,{className:`sm:max-w-sm`,children:[(0,Q.jsx)(C,{children:(0,Q.jsxs)(E,{className:`text-sm flex items-center gap-2`,children:[(0,Q.jsx)(f,{className:`size-4`}),` Rotation & Retry`]})}),(0,Q.jsx)(Me,{})]})}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`fixed inset-0 z-50 transition-opacity duration-200 opacity-100`,onClick:()=>t(!1),style:{backgroundColor:`rgba(0,0,0,0.5)`}}),(0,Q.jsxs)(`div`,{className:y(`fixed bottom-0 left-0 right-0 z-50 bg-background rounded-t-2xl border-t border-border shadow-2xl`,`transition-transform duration-300 ease-out max-h-[85vh] overflow-y-auto`,`translate-y-0`),children:[(0,Q.jsx)(`div`,{className:`flex justify-center pt-3 pb-1`,children:(0,Q.jsx)(`div`,{className:`w-10 h-1 rounded-full bg-border`})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2 border-b border-border`,children:[(0,Q.jsxs)(`span`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,Q.jsx)(f,{className:`size-4`}),` Rotation & Retry`]}),(0,Q.jsx)(`button`,{onClick:()=>t(!1),className:`flex items-center justify-center size-7 rounded-md hover:bg-surface-elevated transition-colors`,children:(0,Q.jsx)(r,{className:`size-4`})})]}),(0,Q.jsx)(`div`,{className:`px-4 py-4 pb-8`,children:(0,Q.jsx)(Me,{})})]})]}):null}var Pe=x(`inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground shadow`,secondary:`border-transparent bg-secondary text-secondary-foreground`,destructive:`border-transparent bg-destructive text-destructive-foreground shadow`,outline:`text-foreground`}},defaultVariants:{variant:`default`}});function Fe({className:e,variant:t,...n}){return(0,Q.jsx)(`div`,{className:y(Pe({variant:t}),e),...n})}function Ie(e){let t=Math.floor(Date.now()/1e3);return e>t?`${Math.floor((e-t)/60)}m`:`exp`}function Le({accounts:e}){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(new Map),l=e.filter(e=>e.hasRefreshToken);async function d(){if(l.length!==0){i(!0);try{let e=await Y(l.map(e=>e.id),a);n(t=>[...t,{round:t.length+1,time:new Date().toLocaleTimeString(),includeRefresh:a,items:e}])}catch{}i(!1)}}async function f(e,t){c(t=>new Map(t).set(e,{loading:!0}));try{let n=await ie(t);c(t=>new Map(t).set(e,{loading:!1,...n}))}catch(t){c(n=>new Map(n).set(e,{loading:!1,status:`error`,error:t.message}))}}function p(e,t){return[{key:`r${e.round}-pre-${t.id}`,label:`Pre-export`,token:t.preExportTokenFull,preview:t.preExportToken,expires:t.preExportExpires},{key:`r${e.round}-exp-${t.id}`,label:`Exported`,token:t.exportedTokenFull,preview:t.exportedToken,expires:t.exportedExpires},{key:`r${e.round}-post-${t.id}`,label:`Post-export`,token:t.postExportTokenFull,preview:t.postExportToken,expires:t.postExportExpires}]}function m(){for(let e of t)for(let t of e.items)for(let n of p(e,t))n.token&&f(n.key,n.token)}return(0,Q.jsxs)(`section`,{className:`border-t pt-4 space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium`,children:`Simulate export`}),t.length>0&&(0,Q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[t.length,` round(s)`]})]}),(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Every run appends a round. Earlier rounds are kept so tokens can be compared across runs.`}),l.length===0?(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No OAuth account with a refresh token to export.`}):(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(L,{id:`sim-include-refresh`,checked:a,onCheckedChange:o,className:`cursor-pointer`}),(0,Q.jsx)(z,{htmlFor:`sim-include-refresh`,className:`text-[11px] cursor-pointer`,children:`Include refresh tokens`})]}),(0,Q.jsx)(S,{size:`sm`,className:`h-7 text-xs cursor-pointer`,disabled:r,onClick:()=>void d(),children:r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(u,{className:`size-3 animate-spin mr-1`}),` Exporting...`]}):`Run export #${t.length+1}`})]}),t.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(S,{size:`sm`,variant:`outline`,className:`w-full h-7 text-[11px] cursor-pointer`,onClick:m,children:[`Test all tokens (`,t.reduce((e,t)=>e+t.items.length*3,0),`)`]}),t.map(e=>(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(`p`,{className:`text-xs font-medium text-primary`,children:[`Round #`,e.round]}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.time}),(0,Q.jsx)(Fe,{variant:e.includeRefresh?`destructive`:`secondary`,className:`text-[9px] px-1 py-0`,children:e.includeRefresh?`with refresh`:`access only`})]}),e.items.map(t=>(0,Q.jsxs)(`div`,{className:`p-2 rounded-lg border bg-card space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-[11px] font-medium`,children:t.label??t.email??t.id.slice(0,8)}),t.tokenChanged&&(0,Q.jsx)(Fe,{variant:`secondary`,className:`text-[9px] px-1 py-0`,children:`DB token changed`})]}),p(e,t).map(e=>{let t=s.get(e.key);return(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px]`,children:[(0,Q.jsx)(`span`,{className:`w-20 shrink-0 text-muted-foreground text-[10px]`,children:e.label}),(0,Q.jsx)(`code`,{className:`flex-1 truncate font-mono text-[10px] bg-muted px-1 rounded`,children:e.preview??`N/A`}),e.expires&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground shrink-0`,children:Ie(e.expires)}),e.token?(0,Q.jsx)(S,{size:`sm`,variant:`outline`,className:`h-6 text-[10px] px-1.5 cursor-pointer shrink-0`,disabled:t?.loading,onClick:()=>void f(e.key,e.token),children:t?.loading?(0,Q.jsx)(u,{className:`size-3 animate-spin`}):`Test`}):(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`-`}),t&&!t.loading&&(0,Q.jsx)(`span`,{className:`text-[10px] font-medium shrink-0 ${t.status?.startsWith(`valid`)?`text-success`:`text-error`}`,children:t.status})]},e.key)})]},`r${e.round}-${t.id}`))]},e.round))]})]})}function Re(e){let t=Math.floor(Date.now()/1e3),n=Math.floor(Math.abs(e-t)/60);return e>t?`${n}m left`:`expired ${n}m ago`}function ze({open:e,onOpenChange:t,accounts:n}){let[r,i]=(0,Z.useState)(new Map),[a,o]=(0,Z.useState)(!1);async function s(e){i(t=>new Map(t).set(e,{loading:!0}));try{let t=await re(e,a);i(n=>new Map(n).set(e,{loading:!1,result:t}))}catch(t){i(n=>new Map(n).set(e,{loading:!1,error:t.message}))}}function c(){for(let e of n.filter(e=>e.expiresAt!==null))s(e.id)}return(0,Q.jsx)(O,{open:e,onOpenChange:t,children:(0,Q.jsxs)(T,{className:`sm:max-w-xl max-h-[85vh] flex flex-col`,children:[(0,Q.jsxs)(C,{children:[(0,Q.jsxs)(E,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(g,{className:`size-4`}),` Token Test`]}),(0,Q.jsx)(D,{className:`text-xs`,children:`Probe stored tokens for validity. Nothing is modified.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-4 overflow-y-auto flex-1 pr-1`,children:[(0,Q.jsxs)(`section`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium`,children:`Current tokens`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(L,{id:`token-test-refresh`,checked:a,onCheckedChange:o,className:`cursor-pointer`}),(0,Q.jsx)(z,{htmlFor:`token-test-refresh`,className:`text-[11px] cursor-pointer`,children:`Also test refresh`})]}),(0,Q.jsx)(S,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer`,onClick:c,children:`Test all`})]})]}),n.length===0&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No accounts to test.`}),(0,Q.jsx)(`div`,{className:`space-y-1.5`,children:n.map(e=>{let t=r.get(e.id),n=t?.result?.accessToken.status;return(0,Q.jsxs)(`div`,{className:`p-2 rounded border bg-card space-y-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium truncate block`,children:e.label??e.email??e.id.slice(0,8)}),e.expiresAt&&(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:Re(e.expiresAt)})]}),(0,Q.jsx)(S,{size:`sm`,variant:`outline`,className:`h-7 text-xs cursor-pointer shrink-0`,disabled:t?.loading,onClick:()=>void s(e.id),children:t?.loading?(0,Q.jsx)(u,{className:`size-3 animate-spin`}):`Test`})]}),t&&!t.loading&&(0,Q.jsxs)(`div`,{className:`text-[11px] pl-2 border-l-2 border-muted`,children:[t.error&&(0,Q.jsx)(`p`,{className:`text-error`,children:t.error}),n&&(0,Q.jsxs)(`span`,{className:n.startsWith(`valid`)?`text-success`:`text-error`,children:[n,t.result?.accessToken.code?` (${t.result.accessToken.code})`:``]})]})]},e.id)})})]}),(0,Q.jsx)(Le,{accounts:n})]}),(0,Q.jsx)(w,{children:(0,Q.jsx)(S,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Close`})})]})})}function Be(){let{usages:e,accounts:t,activeAccountId:n,initialLoading:r,refreshing:i,flashIds:a,reload:s}=fe(),[c,d]=(0,Z.useState)(null),[h,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(null);function D(e){s(),e&&d(e)}async function O(e,t){_(e);try{await J(e,{status:t===`disabled`?`active`:`disabled`})}catch(e){d(e.message)}_(null),s()}async function k(){if(v){try{await H(v.id),d(`Account "${v.display}" removed.`),s()}catch(e){d(`Failed to remove: ${e.message}`)}y(null)}}let A=new Map(t.map(e=>[e.id,e])),j=e[0]?.usage.lastFetchedAt;return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(pe,{description:`Connect multiple Claude accounts. PPM rotates between them automatically to avoid rate limits.`,onRefresh:()=>void s(),refreshing:i,disabled:r,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(S,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>E(`add`),children:[(0,Q.jsx)(p,{className:`size-4`}),` Add account`]}),(0,Q.jsxs)(S,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>{w(null),E(`export`)},children:[(0,Q.jsx)(m,{className:`size-4`}),` Export`]}),(0,Q.jsxs)(S,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>E(`import`),children:[(0,Q.jsx)(l,{className:`size-4`}),` Import`]}),(0,Q.jsxs)(S,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>E(`rotation`),children:[(0,Q.jsx)(f,{className:`size-4`}),` Rotation`]}),(0,Q.jsxs)(S,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>E(`token-test`),children:[(0,Q.jsx)(g,{className:`size-4`}),` Token test`]})]})}),(0,Q.jsx)(oe,{message:c,onDismiss:()=>d(null)}),(0,Q.jsxs)(`section`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`Accounts`}),j&&(0,Q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`usage `,se(new Date(j).getTime())]})]}),r?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(u,{className:`size-4 animate-spin`}),` Loading accounts...`]}):e.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,Q.jsx)(o,{className:`size-5 text-muted-foreground`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No accounts connected yet.`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Add one to start using PPM.`})]}):(0,Q.jsx)(ae,{children:e.map(e=>(0,Q.jsx)(le,{layout:`strip`,entry:e,isActive:e.accountId===n,accountInfo:A.get(e.accountId),onToggle:O,toggling:h===e.accountId,onDelete:(e,t)=>y({id:e,display:t}),onExport:e=>{w(e),E(`export`)},onViewProfile:(e,t)=>x({profile:e,accountId:t}),flash:a.has(e.accountId)},e.accountId))})]}),b&&(0,Q.jsx)(Ce,{profile:b.profile,accountId:b.accountId,onClose:()=>x(null)}),v&&(0,Q.jsx)(we,{display:v.display,onConfirm:()=>void k(),onCancel:()=>y(null)}),(0,Q.jsx)(Te,{open:T===`add`,onOpenChange:e=>E(e?`add`:null),onSuccess:D}),(0,Q.jsx)(De,{open:T===`export`,onOpenChange:e=>{E(e?`export`:null),e||w(null)},accounts:t,preselectId:C,onMessage:d}),(0,Q.jsx)(Oe,{open:T===`import`,onOpenChange:e=>E(e?`import`:null),onSuccess:D}),(0,Q.jsx)(Ne,{open:T===`rotation`,onOpenChange:e=>E(e?`rotation`:null)}),(0,Q.jsx)(ze,{open:T===`token-test`,onOpenChange:e=>E(e?`token-test`:null),accounts:t})]})}function Ve({open:e,onOpenChange:t,label:n,onLabelChange:r,apiKey:a,onApiKeyChange:c,adding:l,onAddApiKey:d,deviceWaiting:f,onStartDevice:p,device:m,error:h,browser:g,onStartBrowser:_,loginStarting:v,callbackUrl:y,onCallbackUrlChange:b,submittingCallback:x,onSubmitCallback:k}){let j=v||f||!!g||l;return(0,Q.jsx)(O,{open:e,onOpenChange:t,children:(0,Q.jsxs)(T,{className:`sm:max-w-md max-h-[90dvh] overflow-y-auto`,children:[(0,Q.jsxs)(C,{children:[(0,Q.jsx)(E,{className:`text-sm`,children:`Add Codex Account`}),(0,Q.jsx)(D,{className:`text-xs leading-relaxed`,children:`Choose browser login, a device code, or an OpenAI API key.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(z,{htmlFor:`codex-label`,className:`text-xs`,children:`Label (optional)`}),(0,Q.jsx)(A,{id:`codex-label`,placeholder:`e.g. Personal, Work`,value:n,onChange:e=>r(e.target.value),disabled:j,className:`text-xs`})]}),(0,Q.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Browser login`}),(0,Q.jsxs)(S,{size:`sm`,className:`w-full cursor-pointer gap-1.5`,onClick:_,disabled:j,children:[(0,Q.jsx)(s,{className:`size-4`}),` Sign in with browser`]}),g&&(0,Q.jsxs)(`div`,{className:`space-y-2 text-xs`,children:[(0,Q.jsxs)(`a`,{href:g.authUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-primary hover:underline`,children:[(0,Q.jsx)(s,{className:`size-3`}),` Open ChatGPT sign-in`]}),(0,Q.jsx)(`p`,{children:`Sign in, then copy the full localhost callback URL from the address bar and paste it below. On a phone, copy it even if the page fails to load.`}),(0,Q.jsx)(z,{htmlFor:`codex-callback-url`,children:`Callback URL`}),(0,Q.jsx)(A,{id:`codex-callback-url`,type:`password`,autoComplete:`off`,spellCheck:!1,placeholder:`http://localhost:.../auth/callback?...`,value:y,onChange:e=>b(e.target.value),disabled:x}),(0,Q.jsxs)(S,{size:`sm`,onClick:k,disabled:!y.trim()||x,children:[x&&(0,Q.jsx)(u,{className:`size-3 animate-spin`}),` Submit callback URL`]}),(0,Q.jsxs)(`p`,{role:`status`,className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(u,{className:`size-3 animate-spin`}),` Waiting for authorization. This may complete automatically on this computer.`]})]})]}),(0,Q.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-[11px] font-medium`,children:`Device code`}),(0,Q.jsx)(S,{size:`sm`,className:`w-full cursor-pointer gap-1.5`,onClick:p,disabled:j,children:f?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(u,{className:`size-4 animate-spin`}),` Waiting for authorization...`]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(i,{className:`size-4`}),` Sign in with device code`]})}),m&&(0,Q.jsxs)(`div`,{className:`rounded-md border border-primary/40 bg-primary/10 p-2.5 space-y-1.5`,children:[(0,Q.jsx)(`p`,{className:`text-[11px]`,children:`Enter this code to authorize:`}),(0,Q.jsx)(`div`,{className:`font-mono text-lg tracking-widest`,children:m.userCode}),(0,Q.jsxs)(`a`,{href:m.verificationUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-primary hover:underline text-[11px]`,children:[(0,Q.jsx)(s,{className:`size-3`}),` `,m.verificationUrl]})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:`flex-1 border-t`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`or paste an API key`}),(0,Q.jsx)(`div`,{className:`flex-1 border-t`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(z,{htmlFor:`codex-api-key`,className:`text-xs`,children:`OpenAI API key`}),(0,Q.jsx)(A,{id:`codex-api-key`,type:`password`,placeholder:`sk-...`,value:a,onChange:e=>c(e.target.value),className:`text-xs font-mono`})]})]}),v&&(0,Q.jsx)(`p`,{role:`status`,className:`text-xs`,children:`Starting login...`}),h&&(0,Q.jsx)(`div`,{role:`alert`,className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:h}),(0,Q.jsxs)(w,{children:[(0,Q.jsx)(S,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsxs)(S,{size:`sm`,className:`text-xs cursor-pointer gap-1.5`,onClick:d,disabled:!a.trim()||j,children:[l?(0,Q.jsx)(u,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(o,{className:`size-3.5`}),`Add key`]})]})]})})}function He({mode:e,onOpenChange:t,password:n,onPasswordChange:r,busy:i,onExport:a,onImport:o,error:s}){let d=(0,Z.useRef)(null),f=e===`export`;return(0,Q.jsx)(O,{open:e!==null,onOpenChange:t,children:(0,Q.jsxs)(T,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(C,{children:[(0,Q.jsxs)(E,{className:`text-sm flex items-center gap-1.5`,children:[(0,Q.jsx)(c,{className:`size-4`}),` `,f?`Export Codex Accounts`:`Import Codex Accounts`]}),(0,Q.jsx)(D,{className:`text-xs leading-relaxed`,children:f?`Writes a password-encrypted file containing each account's login.`:`Reads a backup file. The password must be the one it was exported with.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(z,{htmlFor:`codex-backup-password`,className:`text-xs`,children:`Password`}),(0,Q.jsx)(A,{id:`codex-backup-password`,type:`password`,placeholder:f?`Choose a password`:`Password used for the export`,value:n,onChange:e=>r(e.target.value),className:`text-xs`,autoComplete:f?`new-password`:`current-password`}),(0,Q.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:`A backup holds full logins — keep the file and its password together.`})]}),s&&(0,Q.jsx)(`div`,{className:`text-[11px] p-2 rounded bg-error/10 text-error`,children:s}),(0,Q.jsx)(`input`,{ref:d,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&o(t)}}),(0,Q.jsxs)(w,{children:[(0,Q.jsx)(S,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsxs)(S,{size:`sm`,className:`text-xs cursor-pointer gap-1.5`,disabled:!n.trim()||i,onClick:()=>f?a():d.current?.click(),children:[i?(0,Q.jsx)(u,{className:`size-3.5 animate-spin`}):f?(0,Q.jsx)(m,{className:`size-3.5`}):(0,Q.jsx)(l,{className:`size-3.5`}),f?`Download backup`:`Choose file`]})]})]})})}var Ue=[{value:`round-robin`,label:`Round-robin`,hint:`Take the next account each time.`},{value:`fill-first`,label:`Fill-first`,hint:`Stay on one account until it runs out.`},{value:`lowest-usage`,label:`Lowest usage`,hint:`Pick whichever has the most left.`}];function We({open:e,onOpenChange:t,strategy:n,onChange:r}){return(0,Q.jsx)(O,{open:e,onOpenChange:t,children:(0,Q.jsxs)(T,{className:`sm:max-w-md`,children:[(0,Q.jsxs)(C,{children:[(0,Q.jsx)(E,{className:`text-sm`,children:`Codex Rotation`}),(0,Q.jsx)(D,{className:`text-xs leading-relaxed`,children:`How a new chat chooses among your Codex accounts.`})]}),(0,Q.jsx)(`div`,{className:`space-y-2`,children:Ue.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>r(e.value),"aria-current":n===e.value?`true`:void 0,className:y(`w-full text-left rounded-md border px-3 py-2.5 min-h-11 cursor-pointer transition-colors`,n===e.value?`border-primary bg-primary/10`:`border-border hover:bg-accent/50 active:bg-accent`),children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:e.label}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.hint})]},e.value))}),(0,Q.jsx)(w,{children:(0,Q.jsx)(S,{size:`sm`,variant:`outline`,className:`text-xs cursor-pointer`,onClick:()=>t(!1),children:`Done`})})]})})}function Ge(e){return e==null?null:Math.round(e*100)}function Ke({usage:e}){let t=e.session==null&&e.weekly==null;return(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(t||e.session!=null)&&(0,Q.jsx)(he,{label:`5-Hour Session`,pct:Ge(e.fiveHour),reset:ce(e.session),resetsAt:e.session?.resetsAt}),(t||e.weekly!=null)&&(0,Q.jsx)(he,{label:`Weekly`,pct:Ge(e.sevenDay),reset:ce(e.weekly),resetsAt:e.weekly?.resetsAt})]})}var qe=2e3,Je=21e4;function Ye(e){let[t,n]=(0,Z.useState)([]),[r,i]=(0,Z.useState)(`round-robin`),[a,o]=(0,Z.useState)({}),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(new Set),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(``),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(``),[F,I]=(0,Z.useState)(!1),[ee,L]=(0,Z.useState)(!1),[te,R]=(0,Z.useState)(null),z=(0,Z.useRef)(null),B=(0,Z.useRef)(null),V=(0,Z.useRef)(0),H=(0,Z.useRef)(!1),U=(0,Z.useRef)(!1),W=(0,Z.useRef)(!1),G=(0,Z.useRef)(e);G.current=e;let K=(0,Z.useCallback)(async()=>{c(!0);try{let e=await _.get(`/api/codex-accounts`);n(e.accounts),i(e.strategy),_.get(`/api/codex-accounts/usage`).then(o).catch(()=>{})}finally{c(!1)}},[]);(0,Z.useEffect)(()=>{K()},[K]);let ne=async()=>{if(!(!d.trim()||U.current||H.current||B.current)){U.current=!0,g(!0),b(null);try{await _.post(`/api/codex-accounts/api-key`,{apiKey:d.trim(),label:p.trim()||void 0}),f(``),m(``),e(),await K()}catch(e){b(e.message)}finally{U.current=!1,g(!1)}}},q=(0,Z.useCallback)(()=>{V.current+=1,H.current=!1,W.current=!1,z.current?.(),z.current=null;let e=B.current;B.current=null,e&&_.del(`/api/codex-accounts/${e.method}-login/${e.id}`).catch(()=>{})},[]),J=(0,Z.useCallback)(()=>{q(),S(null),w(!1),E(null),O(!1),A(``),M(!1)},[q]),re=(0,Z.useCallback)((e,t)=>{let n=Date.now()+(t===`browser`?61e4:Je),r=!1,i;z.current=()=>{r=!0,clearTimeout(i)};let a=async()=>{if(r)return;let o=null;try{o=await _.get(`/api/codex-accounts/${t}-login/${e}/status`)}catch{}if(!r){if(o?.state===`done`){J(),m(``),G.current(),await K();return}if(o?.state===`error`||Date.now()>n){J(),b(o?.state===`error`?o.error:`${t===`browser`?`Browser`:`Device`} login timed out.`);return}i=setTimeout(a,qe)}};a()},[J,K]);(0,Z.useEffect)(()=>q,[q]);let Y=async e=>{if(H.current||B.current||U.current)return;H.current=!0;let t=++V.current;O(!0),b(null);try{let n=await _.post(`/api/codex-accounts/${e}-login`,{label:p.trim()||void 0});if(t!==V.current){_.del(`/api/codex-accounts/${e}-login/${n.id}`).catch(()=>{});return}B.current={id:n.id,method:e},e===`device`?(S(n),w(!0)):E(n),re(n.id,e)}catch(e){t===V.current&&b(e.message)}finally{t===V.current&&(H.current=!1,O(!1))}};return{accounts:t,strategy:r,usages:a,loading:s,apiKey:d,setApiKey:f,label:p,setLabel:m,adding:h,err:y,setErr:b,device:x,deviceWaiting:C,backupPassword:N,setBackupPassword:P,exporting:F,importing:ee,msg:te,setMsg:R,toggling:l,load:K,addApiKey:ne,startDevice:()=>Y(`device`),startBrowser:()=>Y(`browser`),browser:T,loginStarting:D,callbackUrl:k,setCallbackUrl:A,submittingCallback:j,submitCallback:async()=>{let e=B.current;if(e?.method!==`browser`||!k.trim()||W.current)return;let t=V.current;W.current=!0,M(!0),b(null);let n=k.trim();A(``);try{await _.post(`/api/codex-accounts/browser-login/${e.id}/callback`,{callbackUrl:n})}catch(e){t===V.current&&b(e.message)}finally{t===V.current&&(W.current=!1,M(!1))}},cancelLogin:J,remove:async e=>{await _.del(`/api/codex-accounts/${e}`),await K()},toggle:async(e,t)=>{let n=t===`disabled`?`active`:`disabled`;u(t=>new Set(t).add(e)),b(null);try{await _.patch(`/api/codex-accounts/${e}`,{status:n}),await K()}catch(e){b(e.message||`Could not change the account`)}finally{u(t=>{let n=new Set(t);return n.delete(e),n})}},toggleDailyGuard:async(e,t)=>{u(t=>new Set(t).add(e)),b(null);try{await _.patch(`/api/codex-accounts/${e}`,{dailyGuardEnabled:!t}),await K()}catch(e){b(e.message||`Could not change Daily guard`)}finally{u(t=>{let n=new Set(t);return n.delete(e),n})}},changeStrategy:async e=>{i(e);try{await _.put(`/api/codex-accounts/strategy`,{strategy:e})}catch{}},doExport:async()=>{if(!N.trim()){b(`Set a backup password first.`);return}I(!0),b(null),R(null);try{let t={"Content-Type":`application/json`},n=v();n&&(t.Authorization=`Bearer ${n}`);let r=await fetch(`/api/codex-accounts/export`,{method:`POST`,headers:t,body:JSON.stringify({password:N})});if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error??`Export failed: ${r.status}`)}let i=await r.text(),a=new Blob([i],{type:`application/json`}),o=document.createElement(`a`);o.href=URL.createObjectURL(a),o.download=`ppm-codex-accounts-backup.json`,o.click(),URL.revokeObjectURL(o.href),R(`Backup downloaded.`),e()}catch(e){b(e.message)}finally{I(!1)}},doImport:async t=>{if(!N.trim()){b(`Enter the backup password first.`);return}L(!0),b(null),R(null);try{let n=await t.text(),r=await _.post(`/api/codex-accounts/import`,{data:n,password:N});R(`Imported ${r.imported}${r.skipped?`, skipped ${r.skipped}`:``}.`),e(),await K()}catch(e){b(e.message)}finally{L(!1)}}}}function Xe(){let[e,t]=(0,Z.useState)(null),n=Ye(()=>t(null));return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(pe,{description:(0,Q.jsxs)(Q.Fragment,{children:[`Each Codex account keeps its own login (`,(0,Q.jsx)(`code`,{children:`CODEX_HOME`}),`). One is picked per chat by the rotation setting.`]}),onRefresh:()=>void n.load(),refreshing:n.loading,actions:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(S,{size:`sm`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`add`),children:[(0,Q.jsx)(p,{className:`size-4`}),` Add account`]}),(0,Q.jsxs)(S,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`export`),children:[(0,Q.jsx)(m,{className:`size-4`}),` Export`]}),(0,Q.jsxs)(S,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`import`),children:[(0,Q.jsx)(l,{className:`size-4`}),` Import`]}),(0,Q.jsxs)(S,{size:`sm`,variant:`outline`,className:`cursor-pointer gap-1.5`,onClick:()=>t(`rotation`),children:[(0,Q.jsx)(f,{className:`size-4`}),` Rotation`]})]})}),(0,Q.jsx)(oe,{message:n.msg??n.err,onDismiss:()=>{n.setMsg(null),n.setErr(null)}}),(0,Q.jsxs)(`section`,{className:`space-y-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium`,children:`Codex Accounts`}),(0,Q.jsx)(`span`,{className:`text-[10px] text-muted-foreground capitalize`,children:n.strategy.replace(`-`,` `)})]}),n.loading&&n.accounts.length===0?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(u,{className:`size-4 animate-spin`}),` Loading accounts...`]}):n.accounts.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 py-8 text-center`,children:[(0,Q.jsx)(o,{className:`size-5 text-muted-foreground`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No Codex accounts yet.`}),(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Chats use your default `,(0,Q.jsx)(`code`,{children:`~/.codex`}),` login until you add one.`]})]}):(0,Q.jsx)(ae,{children:n.accounts.map(e=>{let t=n.usages[e.id]??{};return(0,Q.jsxs)(de,{dense:!0,className:`min-w-[300px] shrink-0 snap-start`,"data-testid":`account-card`,"data-account-id":e.id,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium truncate flex-1 min-w-0`,children:e.label}),(0,Q.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-text-subtle border border-border rounded px-1 shrink-0`,children:e.type}),ue(e.planType)&&(0,Q.jsx)(`span`,{className:`text-[10px] text-text-subtle shrink-0`,children:ue(e.planType)}),(0,Q.jsx)(L,{checked:e.status!==`disabled`,onCheckedChange:()=>void n.toggle(e.id,e.status??`active`),disabled:n.toggling.has(e.id),"aria-label":e.status===`disabled`?`Enable account`:`Disable account`,className:`cursor-pointer shrink-0`}),(0,Q.jsxs)(M,{children:[(0,Q.jsx)(I,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void n.remove(e.id),"aria-label":`Remove account`,className:`p-2 rounded cursor-pointer text-text-subtle hover:text-error hover:bg-surface-elevated transition-colors shrink-0`,children:(0,Q.jsx)(h,{className:`size-4`})})}),(0,Q.jsx)(B,{side:`top`,children:`Remove account`})]})]}),(0,Q.jsx)(Ke,{usage:t}),t.session==null&&(()=>{let r=me(t.weekly);return r?(0,Q.jsxs)(`div`,{className:`flex min-h-12 items-center justify-between gap-3 rounded-md border px-2.5 py-1.5 ${e.dailyGuardEnabled&&r.blocked?`border-error/40 bg-error/5`:`border-border/50 bg-surface/40`}`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 space-y-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium ${e.dailyGuardEnabled&&r.blocked?`text-error`:`text-text-secondary`}`,children:[(0,Q.jsx)(`span`,{children:`Daily guard`}),(0,Q.jsxs)(M,{children:[(0,Q.jsx)(I,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`About Daily guard`,className:`text-text-subtle hover:text-text-primary cursor-help`,children:(0,Q.jsx)(a,{className:`size-3.5`})})}),(0,Q.jsx)(B,{side:`top`,className:`max-w-64 text-xs leading-relaxed`,children:`Spreads the weekly quota across five weekdays, adding 20% per weekday. Weekend slots keep the previous cap; unused allowance carries forward. Daily slots start at the reset time and use UTC weekdays. Turn it off any time to use the remaining quota freely.`})]})]}),(0,Q.jsx)(`p`,{className:`text-[10px] tabular-nums ${e.dailyGuardEnabled&&r.blocked?`text-error`:`text-text-subtle`}`,children:e.dailyGuardEnabled&&r.blocked?`${Math.round(r.used*100)}% used / ${Math.round(r.cap*100)}% daily cap. New turns paused.`:`Weekday ${r.day}/5, ${Math.round(r.cap*100)}% daily cap`})]}),(0,Q.jsxs)(`span`,{className:`hidden`,title:`Weekday ${r.day}/5: hold weekly usage at or below ${Math.round(r.cap*100)}% to last until reset.`,children:[`Daily guard `,e.dailyGuardEnabled?`· Weekday ${r.day}/5 cap ${Math.round(r.cap*100)}%`:``]}),(0,Q.jsx)(L,{checked:!!e.dailyGuardEnabled,onCheckedChange:()=>void n.toggleDailyGuard(e.id,!!e.dailyGuardEnabled),disabled:n.toggling.has(e.id),"aria-label":e.dailyGuardEnabled?`Disable Daily guard`:`Enable Daily guard`,className:`cursor-pointer shrink-0`})]}):null})()]},e.id)})})]}),(0,Q.jsx)(Ve,{open:e===`add`,onOpenChange:e=>{e||n.cancelLogin(),t(e?`add`:null)},label:n.label,onLabelChange:n.setLabel,apiKey:n.apiKey,onApiKeyChange:n.setApiKey,adding:n.adding,onAddApiKey:()=>void n.addApiKey(),deviceWaiting:n.deviceWaiting,onStartDevice:()=>void n.startDevice(),device:n.device,browser:n.browser,onStartBrowser:()=>void n.startBrowser(),loginStarting:n.loginStarting,callbackUrl:n.callbackUrl,onCallbackUrlChange:n.setCallbackUrl,submittingCallback:n.submittingCallback,onSubmitCallback:()=>void n.submitCallback(),error:n.err}),(0,Q.jsx)(He,{mode:e===`export`?`export`:e===`import`?`import`:null,onOpenChange:e=>{e||t(null)},password:n.backupPassword,onPasswordChange:n.setBackupPassword,busy:n.exporting||n.importing,onExport:()=>void n.doExport(),onImport:e=>void n.doImport(e),error:n.err}),(0,Q.jsx)(We,{open:e===`rotation`,onOpenChange:e=>t(e?`rotation`:null),strategy:n.strategy,onChange:e=>void n.changeStrategy(e)})]})}var Ze=[{id:`claude`,label:`Claude`},{id:`codex`,label:`Codex`}];function Qe(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(`claude`);(0,Z.useEffect)(()=>{let e=!1;return W().then(n=>{e||t(new Set(Object.keys(n.providers??{})))}).catch(()=>{e||t(new Set([`claude`]))}),()=>{e=!0}},[]);let i=Ze.filter(t=>t.id===`claude`||e?.has(t.id)),a=i.length>1;return(0,Q.jsxs)(`div`,{className:`space-y-4`,"data-testid":`accounts-pane`,"data-provider":n,children:[a&&(0,Q.jsx)(`div`,{className:`flex gap-1 border-b border-border/50`,children:i.map(e=>(0,Q.jsxs)(`button`,{onClick:()=>r(e.id),"data-testid":`accounts-tab-${e.id}`,"aria-current":n===e.id?`page`:void 0,className:`flex items-center gap-1.5 px-3 py-2 text-xs rounded-t transition-colors cursor-pointer ${n===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,Q.jsx)(te,{providerId:e.id}),e.label]},e.id))}),e===null&&!a&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(u,{className:`size-3 animate-spin`}),` Checking configured providers...`]}),n===`claude`?(0,Q.jsx)(Be,{}):(0,Q.jsx)(Xe,{})]})}export{Qe as AccountsSettingsSection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import{Dr as r,dn as i,ln as a,r as o,tr as s}from"./icons-DQjqk0lJ.js";import{s as c}from"./api-client-C1ZwRL4Y.js";import"./settings-store-krC6bc79.js";import"./vendor-mermaid-BitiXJlL.js";import{n as l}from"./utils-Bmf_8h7Y.js";import{B as u,H as d,U as f,V as p,c as m,z as h}from"./index-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import{Dr as r,dn as i,ln as a,r as o,tr as s}from"./icons-DQjqk0lJ.js";import{s as c}from"./api-client-C1ZwRL4Y.js";import"./settings-store-krC6bc79.js";import"./vendor-mermaid-BitiXJlL.js";import{n as l}from"./utils-Bmf_8h7Y.js";import{B as u,H as d,U as f,V as p,c as m,z as h}from"./index-CEZVxM4G.js";import{t as g}from"./use-monaco-theme-gvhJ_jZh.js";var _=e(t(),1),v=n();function y({metadata:e}){let t=e?.filePath,n=e?.name,l=e?.resourceType??`skill`,y=e?.scope??`user`,x=e?.readOnly===!0,S=e?.shadowed===!0,C=e?.shadowedBy,w=e?.project??``,[T,E]=(0,_.useState)(``),[D,O]=(0,_.useState)(``),[k,A]=(0,_.useState)(!0),[j,M]=(0,_.useState)(null),[N,P]=(0,_.useState)(!1),F=g(),I=(0,_.useRef)(``),L=T!==D;(0,_.useEffect)(()=>{let e=!1;return A(!0),M(null),d(t,w).then(t=>{e||(E(t.content),O(t.content),I.current=t.content)}).catch(t=>{e||M(t.message)}).finally(()=>{e||A(!1)}),()=>{e=!0}},[t,w]);let R=(0,_.useCallback)(async()=>{if(x||N)return;let e=I.current;if(e!==D){P(!0);try{await f(t,e,w),O(e),E(e),c.success(`Saved`),p.getState().reload()}catch(e){c.error(e.message)}finally{P(!1)}}},[t,w,D,x,N]);(0,_.useEffect)(()=>{let e=e=>{(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),R())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[R]);let z=u[l];return(0,v.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-3 py-2 shrink-0`,children:[(0,v.jsx)(z,{className:`size-4 text-text-subtle`}),(0,v.jsx)(`span`,{className:`text-sm font-semibold`,children:n}),(0,v.jsx)(h,{scope:y}),L&&!x&&(0,v.jsx)(`span`,{className:`size-1.5 rounded-full bg-primary`,title:`Unsaved changes`}),(0,v.jsx)(`div`,{className:`flex-1`}),(0,v.jsxs)(`span`,{className:`hidden sm:block text-[11px] text-text-subtle`,children:[l,` · markdown`]}),!x&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`button`,{onClick:()=>E(D),disabled:!L||N,className:`flex items-center gap-1 rounded px-2 py-1 text-xs text-text-secondary hover:bg-surface-elevated disabled:opacity-40`,children:[(0,v.jsx)(r,{className:`size-3.5`}),` Revert`]}),(0,v.jsxs)(`button`,{onClick:()=>void R(),disabled:!L||N,className:`flex items-center gap-1 rounded bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-40`,children:[N?(0,v.jsx)(a,{className:`size-3.5 animate-spin`}):(0,v.jsx)(s,{className:`size-3.5`}),` Save`]})]})]}),x&&(0,v.jsx)(b,{icon:i,tone:`muted`,children:`Bundled resource — read-only. Duplicate it (from the AI Resources panel) to make an editable copy.`}),S&&C&&(0,v.jsxs)(b,{icon:o,tone:`warn`,children:[`This `,l,` is overridden by another “`,C.name,`” from a higher-priority source (`,C.source,`). It is currently inactive.`]}),(0,v.jsx)(`div`,{className:`min-h-0 flex-1`,children:k?(0,v.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,v.jsx)(a,{className:`size-5 animate-spin text-primary`})}):j?(0,v.jsx)(`div`,{className:`p-6 text-center text-sm text-destructive`,children:j}):(0,v.jsx)(m,{height:`100%`,language:`markdown`,theme:F,value:T,onChange:e=>{let t=e??``;I.current=t,E(t)},options:{readOnly:x,minimap:{enabled:!1},fontSize:13,wordWrap:`on`,scrollBeyondLastLine:!1,lineNumbers:`on`}})})]})}function b({icon:e,tone:t,children:n}){return(0,v.jsxs)(`div`,{className:l(`flex items-start gap-2 px-3 py-2 text-[12px] shrink-0 border-b border-border`,t===`warn`?`bg-amber-500/10 text-amber-300`:`bg-surface-elevated text-text-secondary`),children:[(0,v.jsx)(e,{className:`mt-0.5 size-3.5 shrink-0`}),(0,v.jsx)(`span`,{children:n})]})}export{y as AiResourceEditor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import"./icons-DQjqk0lJ.js";import"./api-client-C1ZwRL4Y.js";import"./portal-container-context-BarKmT4S.js";import"./panel-store-CboGJAwh.js";import"./window-store-UC1jJeLM.js";import"./tab-store-OJa1GPCq.js";import"./use-is-mobile-TkcwP1Gx.js";import"./input-C7Q8FxeL.js";import{t as e}from"./ai-settings-section-
|
|
1
|
+
import"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import"./icons-DQjqk0lJ.js";import"./api-client-C1ZwRL4Y.js";import"./portal-container-context-BarKmT4S.js";import"./panel-store-CboGJAwh.js";import"./window-store-UC1jJeLM.js";import"./tab-store-OJa1GPCq.js";import"./use-is-mobile-TkcwP1Gx.js";import"./input-C7Q8FxeL.js";import{t as e}from"./ai-settings-section-r9JctHNM.js";export{e as AISettingsSection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import{Qn as r,ct as i,wr as a}from"./icons-DQjqk0lJ.js";import{n as o}from"./api-client-C1ZwRL4Y.js";import{t as s}from"./input-C7Q8FxeL.js";import{G as c,J as l,K as u,W as d,Y as f,dn as p,nn as m,q as h,rt as g}from"./index-DU68xk06.js";import{getAISettings as _,updateAISettings as v}from"./api-settings-_7Q-ULxp.js";var y=e(t(),1),b=n(),x=[128e3,272e3,4e5,512e3,872e3,1e6],S=[1e5,2e5,23e4,35e4,45e4,75e4,9e5];function C({id:e,label:t,value:n,presets:r,disabled:i,compact:a,onChange:o}){let[c,l]=(0,y.useState)(!!n&&!r.includes(Number(n))),u=a?`text-[11px]`:`text-sm`;return(0,b.jsxs)(`div`,{className:`space-y-1`,children:[(0,b.jsx)(g,{htmlFor:e,className:u,children:t}),(0,b.jsxs)(`select`,{id:e,value:c?`custom`:n||`default`,disabled:i,"aria-describedby":`codex-context-help`,className:`w-full min-h-11 sm:min-h-0 rounded-md border border-input bg-background px-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 ${a?`h-7`:`h-9`} ${u}`,onChange:e=>{let t=e.target.value;l(t===`custom`),t!==`custom`&&o(t===`default`?``:t)},children:[(0,b.jsx)(`option`,{value:`default`,children:`Codex default`}),r.map(e=>(0,b.jsxs)(`option`,{value:String(e),children:[e===1e6?`1M`:`${e/1e3}K`,` tokens`]},e)),(0,b.jsx)(`option`,{value:`custom`,children:`Custom...`})]}),c&&(0,b.jsx)(s,{id:`${e}-custom`,"aria-label":`Custom ${t.toLowerCase()}`,type:`number`,min:1,step:1,required:!0,value:n,disabled:i,placeholder:`Enter tokens`,"aria-describedby":`codex-context-help`,className:`min-h-11 sm:min-h-0 ${a?`h-7 text-[11px]`:``}`,onChange:e=>o(e.target.value)})]})}function w({config:e,compact:t,saving:n,onSave:r}){let[i,a]=(0,y.useState)(String(e?.model_context_window??``)),[o,s]=(0,y.useState)(String(e?.model_auto_compact_token_limit??``)),[c,l]=(0,y.useState)(null),u=t?`text-[11px]`:`text-sm`,d=t?`text-[9px]`:`text-[11px]`;async function f(e){e.preventDefault();let t=i.trim()?Number(i):null,n=o.trim()?Number(o):null;if([t,n].some(e=>e!==null&&(!Number.isSafeInteger(e)||e<=0))){l(`Enter positive whole numbers of tokens, or leave blank for Codex defaults.`);return}if(t!==null&&n!==null&&n>t){l(`Auto-compact threshold must not exceed the context window.`);return}l(null),await r({model_context_window:t,model_auto_compact_token_limit:n})}return(0,b.jsxs)(`form`,{onSubmit:f,className:`space-y-2 rounded-md border border-border p-3`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,b.jsx)(C,{id:`codex-context-window`,label:`Context window (tokens)`,value:i,presets:x,disabled:n,compact:t,onChange:e=>{a(e),l(null)}}),(0,b.jsx)(C,{id:`codex-compact-threshold`,label:`Auto-compact threshold (tokens)`,value:o,presets:S,disabled:n,compact:t,onChange:e=>{s(e),l(null)}})]}),(0,b.jsx)(`p`,{id:`codex-context-help`,className:`${d} text-muted-foreground`,children:`Choose Codex default to use Codex configuration and model defaults, or Custom to enter a value. Presets are shortcuts, not a list of limits supported by your model; increasing these values does not unlock a larger context window. Applies to new sessions and sessions resumed after a PPM restart.`}),c&&(0,b.jsx)(`p`,{role:`alert`,className:`${u} text-error`,children:c}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`a`,{href:`https://learn.chatgpt.com/docs/config-file/config-reference`,target:`_blank`,rel:`noreferrer`,className:`${d} text-primary underline`,children:`Codex context documentation`}),(0,b.jsx)(`button`,{type:`submit`,disabled:n,className:`min-h-11 sm:min-h-0 rounded-md border border-border px-3 py-1.5 hover:bg-surface-elevated disabled:opacity-50 ${u}`,children:n?`Saving...`:`Save context settings`})]})]})}var T=[{value:`low`,label:`Low`},{value:`medium`,label:`Medium`},{value:`high`,label:`High`},{value:`xhigh`,label:`Extra`},{value:`max`,label:`Max`}],E=[{value:`bypassPermissions`,label:`Bypass permissions (default)`},{value:`default`,label:`Ask before edits`},{value:`acceptEdits`,label:`Edit automatically`},{value:`plan`,label:`Plan mode`}],D={claude:`Claude`,cursor:`Cursor`,codex:`Codex`,gemini:`Gemini`};function O({compact:e}={}){let[t,n]=(0,y.useState)(null),[r,a]=(0,y.useState)(``),[x,S]=(0,y.useState)([]),[C,O]=(0,y.useState)(!1),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(null),[P,F]=(0,y.useState)(0);(0,y.useEffect)(()=>{_().then(e=>{n(e),a(e.default_provider??`claude`)}).catch(e=>N(e.message))},[]),(0,y.useEffect)(()=>{r&&(O(!0),o.get(`/api/settings/ai/providers/${r}/models`).then(S).catch(()=>S([])).finally(()=>O(!1)))},[r]);let I=t?Object.keys(t.providers).filter(e=>e!==`mock`).map(e=>({id:e,name:D[e]??e})):[],L=t?.providers[r],R=L?.type===`agent-sdk`||!L?.type&&r===`claude`,z=async e=>{if(!t)return!1;j(!0),N(null);try{return n(await v(e)),F(e=>e+1),!0}catch(e){return N(e.message),!1}finally{j(!1)}},B=(e,t)=>z({providers:{[r]:{[e]:t}}}),V=e?`text-[11px]`:`text-sm`,H=e?`text-xs`:`text-sm`,U=e?`space-y-2`:`space-y-4`,W=e?`space-y-1.5`:`space-y-3`,G=e?`space-y-1`:`space-y-1.5`;if(!t)return(0,b.jsxs)(`div`,{className:W,children:[(0,b.jsx)(`h3`,{className:`${H} font-medium text-text-secondary`,children:`AI Settings`}),(0,b.jsx)(`p`,{className:`${V} text-text-subtle`,children:M?`Error: ${M}`:`Loading...`})]});let K=R?x:[{value:`__default__`,label:`Auto (default)`},...x];return(0,b.jsxs)(`div`,{className:U,children:[(0,b.jsx)(`h3`,{className:`${H} font-medium text-text-secondary`,children:`AI Settings`}),(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border p-3`,children:[(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-share-provider-context`,className:e?V:void 0,children:`Share rules and memory between providers`}),(0,b.jsx)(`p`,{id:`ai-share-provider-context-description`,className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Share project rules and memory, plus global instruction files, across providers. Applies from the next project-chat message. Turning off keeps context already sent.`})]}),(0,b.jsx)(f,{id:`ai-share-provider-context`,"aria-describedby":`ai-share-provider-context-description`,checked:t.share_provider_context??!0,disabled:A,onCheckedChange:e=>z({share_provider_context:e})})]}),I.length>1&&(0,b.jsx)(`div`,{className:`flex gap-0.5 border-b border-border/50 -mx-1 px-1`,children:I.map(e=>(0,b.jsxs)(`button`,{onClick:()=>a(e.id),className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-t transition-colors ${r===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,b.jsx)(p,{providerId:e.id}),(0,b.jsx)(`span`,{className:`capitalize`,children:e.name})]},e.id))}),(0,b.jsxs)(`div`,{className:W,children:[r===`codex`&&(0,b.jsxs)(`button`,{type:`button`,onClick:()=>m(`accounts`),className:`w-full flex items-center justify-between gap-2 rounded-md border border-border px-2.5 py-2 text-left cursor-pointer hover:bg-surface-elevated transition-colors`,children:[(0,b.jsx)(`span`,{className:`${V} text-text-secondary`,children:`Codex accounts & login`}),(0,b.jsx)(i,{className:`size-3.5 text-text-subtle shrink-0`})]}),x.length>0&&(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-model`,className:e?V:void 0,children:`Model`}),(0,b.jsxs)(d,{value:R?L?.model??x[0]?.value:L?.model||`__default__`,onValueChange:e=>B(`model`,e===`__default__`?void 0:e),disabled:C,children:[(0,b.jsx)(h,{id:`ai-model`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,b.jsx)(l,{placeholder:C?`Loading models...`:`Select model`})}),(0,b.jsx)(c,{className:`max-h-[300px]`,children:K.map(e=>(0,b.jsx)(u,{value:e.value,children:e.label},e.value))})]})]}),r===`codex`&&(0,b.jsx)(w,{config:L,compact:e,saving:A,onSave:e=>z({providers:{codex:e}})},JSON.stringify([L?.model_context_window,L?.model_auto_compact_token_limit])),R&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-base-url`,className:e?V:void 0,children:`Base URL`}),(0,b.jsx)(s,{id:`ai-base-url`,type:`url`,defaultValue:L?.base_url??``,placeholder:`https://api.anthropic.com (default)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{B(`base_url`,e.target.value.trim()||void 0)}},`baseurl-${r}-${P}`)]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-api-key`,className:e?V:void 0,children:`API Key / Token`}),(0,b.jsx)(s,{id:`ai-api-key`,type:`password`,defaultValue:L?.api_key??``,placeholder:`sk-ant-... (optional, overrides accounts)`,className:e?`h-7 text-[11px] font-mono`:`font-mono`,onBlur:e=>{let t=e.target.value.trim();t.startsWith(`••••`)||B(`api_key`,t||void 0)}},`apikey-${r}-${P}`),(0,b.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Direct API key or OAuth token. Leave empty to use connected accounts.`})]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-effort`,className:e?V:void 0,children:`Effort`}),(0,b.jsxs)(d,{value:L?.effort??`high`,onValueChange:e=>B(`effort`,e),children:[(0,b.jsx)(h,{id:`ai-effort`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,b.jsx)(l,{})}),(0,b.jsx)(c,{children:T.map(e=>(0,b.jsx)(u,{value:e.value,children:e.label},e.value))})]})]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-max-turns`,className:e?V:void 0,children:`Max Turns (1-500)`}),(0,b.jsx)(s,{id:`ai-max-turns`,type:`number`,min:1,max:500,defaultValue:L?.max_turns??100,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);isNaN(t)||B(`max_turns`,t)}},`turns-${r}-${P}`)]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-budget`,className:e?V:void 0,children:`Max Budget (USD)`}),(0,b.jsx)(s,{id:`ai-budget`,type:`number`,step:.1,min:.01,max:50,defaultValue:L?.max_budget_usd??``,placeholder:`No limit`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseFloat(e.target.value);B(`max_budget_usd`,isNaN(t)?void 0:t)}},`budget-${r}-${P}`)]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-thinking`,className:e?V:void 0,children:`Thinking Budget (tokens)`}),(0,b.jsx)(s,{id:`ai-thinking`,type:`number`,min:0,defaultValue:L?.thinking_budget_tokens??``,placeholder:`Adaptive (model decides)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);B(`thinking_budget_tokens`,isNaN(t)?void 0:t)}},`thinking-${r}-${P}`)]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(g,{htmlFor:`ai-agent-teams`,className:e?V:void 0,children:`Agent Teams`}),(0,b.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Experimental. Enables multi-agent collaboration with shared tasks and messaging. Uses ~7x more tokens.`})]}),(0,b.jsx)(f,{id:`ai-agent-teams`,checked:L?.agent_teams??!1,onCheckedChange:e=>B(`agent_teams`,e)})]}),L?.agent_teams&&(0,b.jsx)(k,{compact:e}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(g,{htmlFor:`ai-context-1m`,className:e?V:void 0,children:`1M Context Window`}),(0,b.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Requires an entitled account (Max/Team/Enterprise) and an Opus 4 / Sonnet 4 model. Other accounts will error.`})]}),(0,b.jsx)(f,{id:`ai-context-1m`,checked:L?.context_1m??!1,onCheckedChange:e=>B(`context_1m`,e)})]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(g,{htmlFor:`ai-inherit-mcp`,className:e?V:void 0,children:`Inherit Claude Code MCP`}),(0,b.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Auto-load MCP servers from Claude Code's ~/.claude.json (global + per-project). Your own MCP servers override inherited ones.`})]}),(0,b.jsx)(f,{id:`ai-inherit-mcp`,checked:L?.inherit_claude_mcp??!0,onCheckedChange:e=>B(`inherit_claude_mcp`,e)})]})]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-permission-mode`,className:e?V:void 0,children:`Default Permission Mode`}),(0,b.jsxs)(d,{value:L?.permission_mode??`bypassPermissions`,onValueChange:e=>B(`permission_mode`,e),children:[(0,b.jsx)(h,{id:`ai-permission-mode`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,b.jsx)(l,{})}),(0,b.jsx)(c,{children:E.map(e=>(0,b.jsx)(u,{value:e.value,children:e.label},e.value))})]})]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-system-prompt`,className:e?V:void 0,children:`Additional Instructions`}),(0,b.jsx)(`textarea`,{id:`ai-system-prompt`,rows:e?3:4,defaultValue:L?.system_prompt??``,placeholder:`Enter additional instructions for ${r}...`,className:`w-full rounded-md border border-input bg-background px-3 py-2 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${e?`text-[11px]`:`text-sm`}`,onBlur:e=>{B(`system_prompt`,e.target.value.trim()||void 0)}},`sysprompt-${r}-${P}`)]})]}),A&&(0,b.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Saving...`}),M&&(0,b.jsx)(`p`,{className:`text-xs text-error`,children:M})]})}function k({compact:e}){let[t,n]=(0,y.useState)([]),[i,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null),u=(0,y.useCallback)(async()=>{s(!0);try{n(await o.get(`/api/teams`)??[])}catch{}s(!1)},[]);(0,y.useEffect)(()=>{u()},[u]);let d=async e=>{try{await o.del(`/api/teams/${encodeURIComponent(e)}`),n(t=>t.filter(t=>t.name!==e)),l(null)}catch{}};return t.length===0&&!i?null:(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsxs)(g,{className:e?`text-[11px]`:void 0,children:[`Teams (`,t.length,`)`]}),(0,b.jsx)(`button`,{onClick:u,className:`text-text-subtle hover:text-foreground p-1`,"aria-label":`Refresh teams`,children:(0,b.jsx)(r,{className:`size-3 ${i?`animate-spin`:``}`})})]}),t.map(e=>(0,b.jsxs)(`div`,{className:`flex items-center justify-between p-2 rounded bg-surface-elevated text-xs`,children:[(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`div`,{className:`font-medium truncate`,children:e.name}),e.description&&(0,b.jsx)(`div`,{className:`text-text-subtle truncate`,children:e.description}),(0,b.jsxs)(`div`,{className:`text-text-subtle`,children:[e.members?.length??e.memberCount??0,` members`,e.createdAt?` · ${new Date(e.createdAt).toLocaleDateString()}`:``]})]}),c===e.name?(0,b.jsxs)(`div`,{className:`flex gap-1 shrink-0 ml-2`,children:[(0,b.jsx)(`button`,{onClick:()=>d(e.name),className:`px-2 py-1 bg-error text-white rounded text-[10px]`,children:`Delete`}),(0,b.jsx)(`button`,{onClick:()=>l(null),className:`px-2 py-1 bg-panel-2 text-text rounded text-[10px]`,children:`Cancel`})]}):(0,b.jsx)(`button`,{onClick:()=>l(e.name),className:`shrink-0 text-text-subtle hover:text-error p-1 ml-2`,"aria-label":`Delete team ${e.name}`,children:(0,b.jsx)(a,{className:`size-3.5`})})]},e.name))]})}export{O as t};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import{Qn as r,ct as i,wr as a}from"./icons-DQjqk0lJ.js";import{n as o}from"./api-client-C1ZwRL4Y.js";import{t as s}from"./input-C7Q8FxeL.js";import{G as c,J as l,K as u,W as d,Y as f,fn as p,q as m,rn as h,rt as g}from"./index-CEZVxM4G.js";import{getAISettings as _,updateAISettings as v}from"./api-settings-_7Q-ULxp.js";var y=e(t(),1),b=n(),x=[128e3,272e3,4e5,512e3,872e3,1e6],S=[1e5,2e5,23e4,35e4,45e4,75e4,9e5];function C({id:e,label:t,value:n,presets:r,disabled:i,compact:a,onChange:o}){let[c,l]=(0,y.useState)(!!n&&!r.includes(Number(n))),u=a?`text-[11px]`:`text-sm`;return(0,b.jsxs)(`div`,{className:`space-y-1`,children:[(0,b.jsx)(g,{htmlFor:e,className:u,children:t}),(0,b.jsxs)(`select`,{id:e,value:c?`custom`:n||`default`,disabled:i,"aria-describedby":`codex-context-help`,className:`w-full min-h-11 sm:min-h-0 rounded-md border border-input bg-background px-3 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 ${a?`h-7`:`h-9`} ${u}`,onChange:e=>{let t=e.target.value;l(t===`custom`),t!==`custom`&&o(t===`default`?``:t)},children:[(0,b.jsx)(`option`,{value:`default`,children:`Codex default`}),r.map(e=>(0,b.jsxs)(`option`,{value:String(e),children:[e===1e6?`1M`:`${e/1e3}K`,` tokens`]},e)),(0,b.jsx)(`option`,{value:`custom`,children:`Custom...`})]}),c&&(0,b.jsx)(s,{id:`${e}-custom`,"aria-label":`Custom ${t.toLowerCase()}`,type:`number`,min:1,step:1,required:!0,value:n,disabled:i,placeholder:`Enter tokens`,"aria-describedby":`codex-context-help`,className:`min-h-11 sm:min-h-0 ${a?`h-7 text-[11px]`:``}`,onChange:e=>o(e.target.value)})]})}function w({config:e,compact:t,saving:n,onSave:r}){let[i,a]=(0,y.useState)(String(e?.model_context_window??``)),[o,s]=(0,y.useState)(String(e?.model_auto_compact_token_limit??``)),[c,l]=(0,y.useState)(null),u=t?`text-[11px]`:`text-sm`,d=t?`text-[9px]`:`text-[11px]`;async function f(e){e.preventDefault();let t=i.trim()?Number(i):null,n=o.trim()?Number(o):null;if([t,n].some(e=>e!==null&&(!Number.isSafeInteger(e)||e<=0))){l(`Enter positive whole numbers of tokens, or leave blank for Codex defaults.`);return}if(t!==null&&n!==null&&n>t){l(`Auto-compact threshold must not exceed the context window.`);return}l(null),await r({model_context_window:t,model_auto_compact_token_limit:n})}return(0,b.jsxs)(`form`,{onSubmit:f,className:`space-y-2 rounded-md border border-border p-3`,children:[(0,b.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,b.jsx)(C,{id:`codex-context-window`,label:`Context window (tokens)`,value:i,presets:x,disabled:n,compact:t,onChange:e=>{a(e),l(null)}}),(0,b.jsx)(C,{id:`codex-compact-threshold`,label:`Auto-compact threshold (tokens)`,value:o,presets:S,disabled:n,compact:t,onChange:e=>{s(e),l(null)}})]}),(0,b.jsx)(`p`,{id:`codex-context-help`,className:`${d} text-muted-foreground`,children:`Choose Codex default to use Codex configuration and model defaults, or Custom to enter a value. Presets are shortcuts, not a list of limits supported by your model; increasing these values does not unlock a larger context window. Applies to new sessions and sessions resumed after a PPM restart.`}),c&&(0,b.jsx)(`p`,{role:`alert`,className:`${u} text-error`,children:c}),(0,b.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,b.jsx)(`a`,{href:`https://learn.chatgpt.com/docs/config-file/config-reference`,target:`_blank`,rel:`noreferrer`,className:`${d} text-primary underline`,children:`Codex context documentation`}),(0,b.jsx)(`button`,{type:`submit`,disabled:n,className:`min-h-11 sm:min-h-0 rounded-md border border-border px-3 py-1.5 hover:bg-surface-elevated disabled:opacity-50 ${u}`,children:n?`Saving...`:`Save context settings`})]})]})}var T=[{value:`low`,label:`Low`},{value:`medium`,label:`Medium`},{value:`high`,label:`High`},{value:`xhigh`,label:`Extra`},{value:`max`,label:`Max`}],E=[{value:`bypassPermissions`,label:`Bypass permissions (default)`},{value:`default`,label:`Ask before edits`},{value:`acceptEdits`,label:`Edit automatically`},{value:`plan`,label:`Plan mode`}],D={claude:`Claude`,cursor:`Cursor`,codex:`Codex`,gemini:`Gemini`};function O({compact:e}={}){let[t,n]=(0,y.useState)(null),[r,a]=(0,y.useState)(``),[x,S]=(0,y.useState)([]),[C,O]=(0,y.useState)(!1),[A,j]=(0,y.useState)(!1),[M,N]=(0,y.useState)(null),[P,F]=(0,y.useState)(0);(0,y.useEffect)(()=>{_().then(e=>{n(e),a(e.default_provider??`claude`)}).catch(e=>N(e.message))},[]),(0,y.useEffect)(()=>{r&&(O(!0),o.get(`/api/settings/ai/providers/${r}/models`).then(S).catch(()=>S([])).finally(()=>O(!1)))},[r]);let I=t?Object.keys(t.providers).filter(e=>e!==`mock`).map(e=>({id:e,name:D[e]??e})):[],L=t?.providers[r],R=L?.type===`agent-sdk`||!L?.type&&r===`claude`,z=async e=>{if(!t)return!1;j(!0),N(null);try{return n(await v(e)),F(e=>e+1),!0}catch(e){return N(e.message),!1}finally{j(!1)}},B=(e,t)=>z({providers:{[r]:{[e]:t}}}),V=e?`text-[11px]`:`text-sm`,H=e?`text-xs`:`text-sm`,U=e?`space-y-2`:`space-y-4`,W=e?`space-y-1.5`:`space-y-3`,G=e?`space-y-1`:`space-y-1.5`;if(!t)return(0,b.jsxs)(`div`,{className:W,children:[(0,b.jsx)(`h3`,{className:`${H} font-medium text-text-secondary`,children:`AI Settings`}),(0,b.jsx)(`p`,{className:`${V} text-text-subtle`,children:M?`Error: ${M}`:`Loading...`})]});let K=R?x:[{value:`__default__`,label:`Auto (default)`},...x];return(0,b.jsxs)(`div`,{className:U,children:[(0,b.jsx)(`h3`,{className:`${H} font-medium text-text-secondary`,children:`AI Settings`}),(0,b.jsxs)(`div`,{className:`flex items-start justify-between gap-3 rounded-md border border-border p-3`,children:[(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-share-provider-context`,className:e?V:void 0,children:`Share rules and memory between providers`}),(0,b.jsx)(`p`,{id:`ai-share-provider-context-description`,className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Share project rules and memory, plus global instruction files, across providers. Applies from the next project-chat message. Turning off keeps context already sent.`})]}),(0,b.jsx)(f,{id:`ai-share-provider-context`,"aria-describedby":`ai-share-provider-context-description`,checked:t.share_provider_context??!0,disabled:A,onCheckedChange:e=>z({share_provider_context:e})})]}),I.length>1&&(0,b.jsx)(`div`,{className:`flex gap-0.5 border-b border-border/50 -mx-1 px-1`,children:I.map(e=>(0,b.jsxs)(`button`,{onClick:()=>a(e.id),className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-t transition-colors ${r===e.id?`text-primary border-b-2 border-primary font-medium`:`text-text-subtle hover:text-text-secondary`}`,children:[(0,b.jsx)(p,{providerId:e.id}),(0,b.jsx)(`span`,{className:`capitalize`,children:e.name})]},e.id))}),(0,b.jsxs)(`div`,{className:W,children:[r===`codex`&&(0,b.jsxs)(`button`,{type:`button`,onClick:()=>h(`accounts`),className:`w-full flex items-center justify-between gap-2 rounded-md border border-border px-2.5 py-2 text-left cursor-pointer hover:bg-surface-elevated transition-colors`,children:[(0,b.jsx)(`span`,{className:`${V} text-text-secondary`,children:`Codex accounts & login`}),(0,b.jsx)(i,{className:`size-3.5 text-text-subtle shrink-0`})]}),x.length>0&&(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-model`,className:e?V:void 0,children:`Model`}),(0,b.jsxs)(d,{value:R?L?.model??x[0]?.value:L?.model||`__default__`,onValueChange:e=>B(`model`,e===`__default__`?void 0:e),disabled:C,children:[(0,b.jsx)(m,{id:`ai-model`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,b.jsx)(l,{placeholder:C?`Loading models...`:`Select model`})}),(0,b.jsx)(c,{className:`max-h-[300px]`,children:K.map(e=>(0,b.jsx)(u,{value:e.value,children:e.label},e.value))})]})]}),r===`codex`&&(0,b.jsx)(w,{config:L,compact:e,saving:A,onSave:e=>z({providers:{codex:e}})},JSON.stringify([L?.model_context_window,L?.model_auto_compact_token_limit])),R&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-base-url`,className:e?V:void 0,children:`Base URL`}),(0,b.jsx)(s,{id:`ai-base-url`,type:`url`,defaultValue:L?.base_url??``,placeholder:`https://api.anthropic.com (default)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{B(`base_url`,e.target.value.trim()||void 0)}},`baseurl-${r}-${P}`)]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-api-key`,className:e?V:void 0,children:`API Key / Token`}),(0,b.jsx)(s,{id:`ai-api-key`,type:`password`,defaultValue:L?.api_key??``,placeholder:`sk-ant-... (optional, overrides accounts)`,className:e?`h-7 text-[11px] font-mono`:`font-mono`,onBlur:e=>{let t=e.target.value.trim();t.startsWith(`••••`)||B(`api_key`,t||void 0)}},`apikey-${r}-${P}`),(0,b.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Direct API key or OAuth token. Leave empty to use connected accounts.`})]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-effort`,className:e?V:void 0,children:`Effort`}),(0,b.jsxs)(d,{value:L?.effort??`high`,onValueChange:e=>B(`effort`,e),children:[(0,b.jsx)(m,{id:`ai-effort`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,b.jsx)(l,{})}),(0,b.jsx)(c,{children:T.map(e=>(0,b.jsx)(u,{value:e.value,children:e.label},e.value))})]})]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-max-turns`,className:e?V:void 0,children:`Max Turns (1-500)`}),(0,b.jsx)(s,{id:`ai-max-turns`,type:`number`,min:1,max:500,defaultValue:L?.max_turns??100,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);isNaN(t)||B(`max_turns`,t)}},`turns-${r}-${P}`)]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-budget`,className:e?V:void 0,children:`Max Budget (USD)`}),(0,b.jsx)(s,{id:`ai-budget`,type:`number`,step:.1,min:.01,max:50,defaultValue:L?.max_budget_usd??``,placeholder:`No limit`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseFloat(e.target.value);B(`max_budget_usd`,isNaN(t)?void 0:t)}},`budget-${r}-${P}`)]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-thinking`,className:e?V:void 0,children:`Thinking Budget (tokens)`}),(0,b.jsx)(s,{id:`ai-thinking`,type:`number`,min:0,defaultValue:L?.thinking_budget_tokens??``,placeholder:`Adaptive (model decides)`,className:e?`h-7 text-[11px]`:void 0,onBlur:e=>{let t=parseInt(e.target.value);B(`thinking_budget_tokens`,isNaN(t)?void 0:t)}},`thinking-${r}-${P}`)]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(g,{htmlFor:`ai-agent-teams`,className:e?V:void 0,children:`Agent Teams`}),(0,b.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Experimental. Enables multi-agent collaboration with shared tasks and messaging. Uses ~7x more tokens.`})]}),(0,b.jsx)(f,{id:`ai-agent-teams`,checked:L?.agent_teams??!1,onCheckedChange:e=>B(`agent_teams`,e)})]}),L?.agent_teams&&(0,b.jsx)(k,{compact:e}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(g,{htmlFor:`ai-context-1m`,className:e?V:void 0,children:`1M Context Window`}),(0,b.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Requires an entitled account (Max/Team/Enterprise) and an Opus 4 / Sonnet 4 model. Other accounts will error.`})]}),(0,b.jsx)(f,{id:`ai-context-1m`,checked:L?.context_1m??!1,onCheckedChange:e=>B(`context_1m`,e)})]}),(0,b.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsx)(g,{htmlFor:`ai-inherit-mcp`,className:e?V:void 0,children:`Inherit Claude Code MCP`}),(0,b.jsx)(`p`,{className:`${e?`text-[9px]`:`text-[11px]`} text-muted-foreground`,children:`Auto-load MCP servers from Claude Code's ~/.claude.json (global + per-project). Your own MCP servers override inherited ones.`})]}),(0,b.jsx)(f,{id:`ai-inherit-mcp`,checked:L?.inherit_claude_mcp??!0,onCheckedChange:e=>B(`inherit_claude_mcp`,e)})]})]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-permission-mode`,className:e?V:void 0,children:`Default Permission Mode`}),(0,b.jsxs)(d,{value:L?.permission_mode??`bypassPermissions`,onValueChange:e=>B(`permission_mode`,e),children:[(0,b.jsx)(m,{id:`ai-permission-mode`,className:`w-full ${e?`h-7 text-[11px]`:``}`,children:(0,b.jsx)(l,{})}),(0,b.jsx)(c,{children:E.map(e=>(0,b.jsx)(u,{value:e.value,children:e.label},e.value))})]})]}),(0,b.jsxs)(`div`,{className:G,children:[(0,b.jsx)(g,{htmlFor:`ai-system-prompt`,className:e?V:void 0,children:`Additional Instructions`}),(0,b.jsx)(`textarea`,{id:`ai-system-prompt`,rows:e?3:4,defaultValue:L?.system_prompt??``,placeholder:`Enter additional instructions for ${r}...`,className:`w-full rounded-md border border-input bg-background px-3 py-2 ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${e?`text-[11px]`:`text-sm`}`,onBlur:e=>{B(`system_prompt`,e.target.value.trim()||void 0)}},`sysprompt-${r}-${P}`)]})]}),A&&(0,b.jsx)(`p`,{className:`text-xs text-text-subtle`,children:`Saving...`}),M&&(0,b.jsx)(`p`,{className:`text-xs text-error`,children:M})]})}function k({compact:e}){let[t,n]=(0,y.useState)([]),[i,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null),u=(0,y.useCallback)(async()=>{s(!0);try{n(await o.get(`/api/teams`)??[])}catch{}s(!1)},[]);(0,y.useEffect)(()=>{u()},[u]);let d=async e=>{try{await o.del(`/api/teams/${encodeURIComponent(e)}`),n(t=>t.filter(t=>t.name!==e)),l(null)}catch{}};return t.length===0&&!i?null:(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsxs)(g,{className:e?`text-[11px]`:void 0,children:[`Teams (`,t.length,`)`]}),(0,b.jsx)(`button`,{onClick:u,className:`text-text-subtle hover:text-foreground p-1`,"aria-label":`Refresh teams`,children:(0,b.jsx)(r,{className:`size-3 ${i?`animate-spin`:``}`})})]}),t.map(e=>(0,b.jsxs)(`div`,{className:`flex items-center justify-between p-2 rounded bg-surface-elevated text-xs`,children:[(0,b.jsxs)(`div`,{className:`min-w-0`,children:[(0,b.jsx)(`div`,{className:`font-medium truncate`,children:e.name}),e.description&&(0,b.jsx)(`div`,{className:`text-text-subtle truncate`,children:e.description}),(0,b.jsxs)(`div`,{className:`text-text-subtle`,children:[e.members?.length??e.memberCount??0,` members`,e.createdAt?` · ${new Date(e.createdAt).toLocaleDateString()}`:``]})]}),c===e.name?(0,b.jsxs)(`div`,{className:`flex gap-1 shrink-0 ml-2`,children:[(0,b.jsx)(`button`,{onClick:()=>d(e.name),className:`px-2 py-1 bg-error text-white rounded text-[10px]`,children:`Delete`}),(0,b.jsx)(`button`,{onClick:()=>l(null),className:`px-2 py-1 bg-panel-2 text-text rounded text-[10px]`,children:`Cancel`})]}):(0,b.jsx)(`button`,{onClick:()=>l(e.name),className:`shrink-0 text-text-subtle hover:text-error p-1 ml-2`,"aria-label":`Delete team ${e.name}`,children:(0,b.jsx)(a,{className:`size-3.5`})})]},e.name))]})}export{O as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import{c as r,l as i,s as a,u as o}from"./vendor-ui-DmZ-Mb-H.js";import{Wr as s,qn as c,w as l,wr as u,zr as d}from"./icons-DQjqk0lJ.js";import{s as f}from"./api-client-C1ZwRL4Y.js";import{t as p}from"./settings-store-krC6bc79.js";import"./vendor-mermaid-BitiXJlL.js";import{n as m}from"./utils-Bmf_8h7Y.js";import"./portal-container-context-BarKmT4S.js";import{n as h}from"./use-is-mobile-TkcwP1Gx.js";import{n as g,t as _}from"./button-B9CTrsEf.js";import{a as v,i as y,n as b,o as x,r as S,t as C}from"./dialog-B84_DJQ8.js";import{t as w}from"./input-C7Q8FxeL.js";import{n as T,r as E,t as D}from"./resolve-theme-B_ukrg_8.js";import{Rt as O,Y as k,_ as A,h as j,i as M}from"./index-DU68xk06.js";import{t as N}from"./separator-TRMsJUYe.js";var P=n();function F(){let e=p(e=>e.themeStyle),t=p(e=>e.themeMode),n=p(e=>e.customThemeId),r=p(e=>e.customThemes),i=p(e=>e.setThemeStyle),a=p(e=>e.setThemeMode),o=D(e,t,r,n);return(0,P.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:T.map(e=>{let t=E[e];if(!t)return null;let n=o.id===e;return(0,P.jsxs)(`button`,{onClick:()=>{i(t.style),a(t.mode)},className:m(`relative flex items-center gap-2 rounded-lg border p-2 text-left transition-colors min-h-11`,n?`border-primary ring-[3px] ring-accent-wash`:`border-border hover:bg-accent/40`),children:[(0,P.jsx)(A,{swatch:t.swatch}),(0,P.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`span`,{className:`block truncate text-xs font-medium text-text`,children:t.name.replace(/ (Dark|Light)$/,``)}),(0,P.jsx)(`span`,{className:`block text-[10px] text-text-3 capitalize`,children:t.mode})]}),n&&(0,P.jsx)(l,{className:`absolute top-1 right-1 size-3.5 text-primary`})]},e)})})}var I=e(t(),1);function L({className:e,orientation:t=`horizontal`,...n}){return(0,P.jsx)(i,{"data-slot":`tabs`,"data-orientation":t,orientation:t,className:m(`group/tabs flex gap-2 data-[orientation=horizontal]:flex-col`,e),...n})}var R=g(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function z({className:e,variant:t=`default`,...n}){return(0,P.jsx)(r,{"data-slot":`tabs-list`,"data-variant":t,className:m(R({variant:t}),e),...n})}function B({className:e,...t}){return(0,P.jsx)(o,{"data-slot":`tabs-trigger`,className:m(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent`,`data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100`,e),...t})}function V({className:e,...t}){return(0,P.jsx)(a,{"data-slot":`tabs-content`,className:m(`flex-1 outline-none`,e),...t})}function H({open:e,onOpenChange:t}){let n=p(e=>e.importThemeFrom),r=p(e=>e.setCustomTheme),[i,a]=(0,I.useState)(`url`),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(``),[m,h]=(0,I.useState)(!1),g=()=>{s(``),l(``),d(``),a(`url`)},T=async()=>{let e=i===`url`?o.trim():c.trim();if(!e){f.error(`Nothing to import`);return}h(!0);try{let a=await n({source:i===`url`?`url`:i===`upload`?`upload`:`json`,value:e,name:u.trim()||void 0});f.success(a.length>1?`Imported ${a.length} themes`:`Imported "${a[0]?.name}"`),a[0]&&r(a[0].id),g(),t(!1)}catch(e){f.error(e.message||`Import failed`)}finally{h(!1)}},E=async e=>{if(e)try{l(await e.text()),d(e.name.replace(/\.json$/i,``))}catch{f.error(`Could not read file`)}};return(0,P.jsx)(C,{open:e,onOpenChange:t,children:(0,P.jsxs)(b,{className:`max-w-md`,children:[(0,P.jsxs)(v,{children:[(0,P.jsx)(x,{children:`Import theme`}),(0,P.jsx)(S,{className:`text-text-3`,children:`Import a VSCode color theme. Single-mode themes apply to both dark and light.`})]}),(0,P.jsxs)(L,{value:i,onValueChange:e=>a(e),children:[(0,P.jsxs)(z,{className:`w-full`,children:[(0,P.jsx)(B,{value:`url`,className:`flex-1`,children:`URL`}),(0,P.jsx)(B,{value:`json`,className:`flex-1`,children:`Paste JSON`}),(0,P.jsx)(B,{value:`upload`,className:`flex-1`,children:`Upload`})]}),(0,P.jsxs)(V,{value:`url`,className:`space-y-2 pt-2`,children:[(0,P.jsx)(w,{placeholder:`https://…/theme.json or Marketplace .vsix URL`,value:o,onChange:e=>s(e.target.value)}),(0,P.jsx)(`p`,{className:`text-[11px] text-text-3`,children:`Only https URLs; private/internal addresses are blocked.`})]}),(0,P.jsx)(V,{value:`json`,className:`pt-2`,children:(0,P.jsx)(`textarea`,{className:`w-full h-40 rounded-md border border-border bg-surface p-2 text-xs font-mono text-text focus:outline-none focus:border-ring`,placeholder:`{ "name": "My Theme", "type": "dark", "colors": { … }, "tokenColors": [ … ] }`,value:c,onChange:e=>l(e.target.value)})}),(0,P.jsxs)(V,{value:`upload`,className:`space-y-2 pt-2`,children:[(0,P.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:e=>E(e.target.files?.[0]),className:`block w-full text-xs text-text-2 file:mr-3 file:rounded file:border file:border-border file:bg-panel-2 file:px-2 file:py-1 file:text-text`}),c&&(0,P.jsxs)(`p`,{className:`text-[11px] text-success`,children:[`File loaded (`,c.length,` chars)`]})]})]}),(0,P.jsx)(w,{placeholder:`Optional name`,value:u,onChange:e=>d(e.target.value)}),(0,P.jsxs)(y,{children:[(0,P.jsx)(_,{variant:`outline`,onClick:()=>t(!1),disabled:m,children:`Cancel`}),(0,P.jsx)(_,{onClick:T,disabled:m,children:m?`Importing…`:`Import`})]})]})})}function U(){let e=p(e=>e.customThemes),t=p(e=>e.themeStyle),n=p(e=>e.customThemeId),r=p(e=>e.setCustomTheme),i=p(e=>e.deleteCustomTheme),[a,o]=(0,I.useState)(!1);return(0,P.jsxs)(`section`,{className:`space-y-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:`Imported themes`}),(0,P.jsxs)(_,{size:`sm`,variant:`outline`,className:`h-7 gap-1 text-xs`,onClick:()=>o(!0),children:[(0,P.jsx)(c,{className:`size-3.5`}),` Import`]})]}),e.length===0?(0,P.jsx)(`p`,{className:`text-[11px] text-text-3`,children:`No imported themes yet. Import a VSCode theme from a URL, .vsix, or JSON.`}):(0,P.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let a=t===`custom`&&n===e.id;return(0,P.jsxs)(`li`,{className:m(`flex items-center gap-2 rounded-md border px-2 py-1.5`,a?`border-primary bg-primary/10`:`border-border`),children:[(0,P.jsx)(A,{swatch:e.swatch}),(0,P.jsxs)(`button`,{className:`flex-1 min-w-0 text-left`,onClick:()=>r(e.id),children:[(0,P.jsx)(`span`,{className:`block truncate text-xs text-text`,children:e.name}),(0,P.jsx)(`span`,{className:`block text-[10px] text-text-3`,children:e.mode})]}),a&&(0,P.jsx)(l,{className:`size-4 text-primary shrink-0`}),(0,P.jsx)(`button`,{className:`text-text-3 hover:text-error transition-colors shrink-0`,title:`Delete`,onClick:()=>void i(e.id),children:(0,P.jsx)(u,{className:`size-3.5`})})]},e.id)})}),(0,P.jsx)(H,{open:a,onOpenChange:o})]})}var W=[{value:`default`,label:`Default`},{value:`boxed`,label:`Boxed`},{value:`pill`,label:`Pill`}],G=[{value:`auto`,label:`Auto`},{value:`windows`,label:`Windows`},{value:`macos`,label:`macOS`}];function K({options:e,value:t,onChange:n}){return(0,P.jsx)(`div`,{className:`flex gap-2`,children:e.map(e=>(0,P.jsx)(_,{variant:t===e.value?`default`:`outline`,onClick:()=>n(e.value),className:m(`flex-1 cursor-pointer`,t===e.value&&`ring-2 ring-primary`),children:e.label},e.value))})}function q(){let{theme:e,setTheme:t,tabWrap:n,toggleTabWrap:r,editorTabStyle:i,setEditorTabStyle:a,explorerSkin:o,setExplorerSkin:c}=p(O(e=>({theme:e.themeMode,setTheme:e.setThemeMode,tabWrap:e.tabWrap,toggleTabWrap:e.toggleTabWrap,editorTabStyle:e.editorTabStyle,setEditorTabStyle:e.setEditorTabStyle,explorerSkin:e.explorerSkin,setExplorerSkin:e.setExplorerSkin}))),{wordWrap:l,toggleWordWrap:u,mobileWordWrap:f,toggleMobileWordWrap:g,lspEnabled:v,setLspEnabled:y}=p(O(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap,mobileWordWrap:e.mobileWordWrap,toggleMobileWordWrap:e.toggleMobileWordWrap,lspEnabled:e.lspEnabled,setLspEnabled:e.setLspEnabled}))),b=h(),x=M();return(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsxs)(`section`,{className:`space-y-3`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium`,children:`Theme`}),(0,P.jsx)(F,{}),(0,P.jsx)(`div`,{className:`flex gap-2`,children:j.map(n=>{let r=n.icon;return(0,P.jsxs)(_,{variant:e===n.value?`default`:`outline`,onClick:()=>t(n.value),className:m(`flex-1 gap-2 cursor-pointer`,e===n.value&&`ring-2 ring-primary`),children:[(0,P.jsx)(r,{className:`size-4`}),n.label]},n.value)})})]}),(0,P.jsx)(N,{}),(0,P.jsx)(U,{}),(0,P.jsx)(N,{}),(0,P.jsxs)(`section`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,P.jsx)(d,{className:`size-4 text-muted-foreground shrink-0`}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Wrap Tabs`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Stack tabs in rows instead of scrolling`})]})]}),(0,P.jsx)(k,{checked:n,onCheckedChange:r})]}),(0,P.jsxs)(`section`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,P.jsx)(d,{className:`size-4 text-muted-foreground shrink-0`}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Word Wrap`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b?`Wrap long lines instead of scrolling sideways (this device)`:`Wrap long lines in the editor (Alt+Z)`})]})]}),(0,P.jsx)(k,{checked:b?f:l,onCheckedChange:()=>b?g():u()})]}),(0,P.jsxs)(`section`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,P.jsx)(s,{className:`size-4 text-muted-foreground shrink-0`}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Language Server`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:x?`Off on a touch device — it runs a server process per project`:`Completions, hover, F12, rename and quick fix (this device)`})]})]}),(0,P.jsx)(k,{checked:v&&!x,disabled:x,onCheckedChange:y})]}),(0,P.jsxs)(`section`,{className:`space-y-2`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium`,children:`Tab Style`}),(0,P.jsx)(K,{options:W,value:i,onChange:a})]}),(0,P.jsxs)(`section`,{className:`space-y-2`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium`,children:`Explorer Skin`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Chrome the OS File Explorer window wears. Auto follows the host platform.`}),(0,P.jsx)(K,{options:G,value:o,onChange:c})]})]})}export{q as AppearanceSettingsSection};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import{c as r,l as i,s as a,u as o}from"./vendor-ui-DmZ-Mb-H.js";import{Wr as s,qn as c,w as l,wr as u,zr as d}from"./icons-DQjqk0lJ.js";import{s as f}from"./api-client-C1ZwRL4Y.js";import{t as p}from"./settings-store-krC6bc79.js";import"./vendor-mermaid-BitiXJlL.js";import{n as m}from"./utils-Bmf_8h7Y.js";import"./portal-container-context-BarKmT4S.js";import{n as h}from"./use-is-mobile-TkcwP1Gx.js";import{n as g,t as _}from"./button-B9CTrsEf.js";import{a as v,i as y,n as b,o as x,r as S,t as C}from"./dialog-B84_DJQ8.js";import{t as w}from"./input-C7Q8FxeL.js";import{n as T,r as E,t as D}from"./resolve-theme-B_ukrg_8.js";import{Rt as O,Y as k,_ as A,h as j,i as M}from"./index-CEZVxM4G.js";import{t as N}from"./separator-TRMsJUYe.js";var P=n();function F(){let e=p(e=>e.themeStyle),t=p(e=>e.themeMode),n=p(e=>e.customThemeId),r=p(e=>e.customThemes),i=p(e=>e.setThemeStyle),a=p(e=>e.setThemeMode),o=D(e,t,r,n);return(0,P.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:T.map(e=>{let t=E[e];if(!t)return null;let n=o.id===e;return(0,P.jsxs)(`button`,{onClick:()=>{i(t.style),a(t.mode)},className:m(`relative flex items-center gap-2 rounded-lg border p-2 text-left transition-colors min-h-11`,n?`border-primary ring-[3px] ring-accent-wash`:`border-border hover:bg-accent/40`),children:[(0,P.jsx)(A,{swatch:t.swatch}),(0,P.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,P.jsx)(`span`,{className:`block truncate text-xs font-medium text-text`,children:t.name.replace(/ (Dark|Light)$/,``)}),(0,P.jsx)(`span`,{className:`block text-[10px] text-text-3 capitalize`,children:t.mode})]}),n&&(0,P.jsx)(l,{className:`absolute top-1 right-1 size-3.5 text-primary`})]},e)})})}var I=e(t(),1);function L({className:e,orientation:t=`horizontal`,...n}){return(0,P.jsx)(i,{"data-slot":`tabs`,"data-orientation":t,orientation:t,className:m(`group/tabs flex gap-2 data-[orientation=horizontal]:flex-col`,e),...n})}var R=g(`group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-[orientation=horizontal]/tabs:h-9 group-data-[orientation=vertical]/tabs:h-fit group-data-[orientation=vertical]/tabs:flex-col data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function z({className:e,variant:t=`default`,...n}){return(0,P.jsx)(r,{"data-slot":`tabs-list`,"data-variant":t,className:m(R({variant:t}),e),...n})}function B({className:e,...t}){return(0,P.jsx)(o,{"data-slot":`tabs-trigger`,className:m(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-[orientation=vertical]/tabs:w-full group-data-[orientation=vertical]/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 group-data-[variant=default]/tabs-list:data-[state=active]:shadow-sm group-data-[variant=line]/tabs-list:data-[state=active]:shadow-none dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:border-transparent dark:group-data-[variant=line]/tabs-list:data-[state=active]:bg-transparent`,`data-[state=active]:bg-background data-[state=active]:text-foreground dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 dark:data-[state=active]:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-[orientation=horizontal]/tabs:after:inset-x-0 group-data-[orientation=horizontal]/tabs:after:bottom-[-5px] group-data-[orientation=horizontal]/tabs:after:h-0.5 group-data-[orientation=vertical]/tabs:after:inset-y-0 group-data-[orientation=vertical]/tabs:after:-right-1 group-data-[orientation=vertical]/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-[state=active]:after:opacity-100`,e),...t})}function V({className:e,...t}){return(0,P.jsx)(a,{"data-slot":`tabs-content`,className:m(`flex-1 outline-none`,e),...t})}function H({open:e,onOpenChange:t}){let n=p(e=>e.importThemeFrom),r=p(e=>e.setCustomTheme),[i,a]=(0,I.useState)(`url`),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(``),[m,h]=(0,I.useState)(!1),g=()=>{s(``),l(``),d(``),a(`url`)},T=async()=>{let e=i===`url`?o.trim():c.trim();if(!e){f.error(`Nothing to import`);return}h(!0);try{let a=await n({source:i===`url`?`url`:i===`upload`?`upload`:`json`,value:e,name:u.trim()||void 0});f.success(a.length>1?`Imported ${a.length} themes`:`Imported "${a[0]?.name}"`),a[0]&&r(a[0].id),g(),t(!1)}catch(e){f.error(e.message||`Import failed`)}finally{h(!1)}},E=async e=>{if(e)try{l(await e.text()),d(e.name.replace(/\.json$/i,``))}catch{f.error(`Could not read file`)}};return(0,P.jsx)(C,{open:e,onOpenChange:t,children:(0,P.jsxs)(b,{className:`max-w-md`,children:[(0,P.jsxs)(v,{children:[(0,P.jsx)(x,{children:`Import theme`}),(0,P.jsx)(S,{className:`text-text-3`,children:`Import a VSCode color theme. Single-mode themes apply to both dark and light.`})]}),(0,P.jsxs)(L,{value:i,onValueChange:e=>a(e),children:[(0,P.jsxs)(z,{className:`w-full`,children:[(0,P.jsx)(B,{value:`url`,className:`flex-1`,children:`URL`}),(0,P.jsx)(B,{value:`json`,className:`flex-1`,children:`Paste JSON`}),(0,P.jsx)(B,{value:`upload`,className:`flex-1`,children:`Upload`})]}),(0,P.jsxs)(V,{value:`url`,className:`space-y-2 pt-2`,children:[(0,P.jsx)(w,{placeholder:`https://…/theme.json or Marketplace .vsix URL`,value:o,onChange:e=>s(e.target.value)}),(0,P.jsx)(`p`,{className:`text-[11px] text-text-3`,children:`Only https URLs; private/internal addresses are blocked.`})]}),(0,P.jsx)(V,{value:`json`,className:`pt-2`,children:(0,P.jsx)(`textarea`,{className:`w-full h-40 rounded-md border border-border bg-surface p-2 text-xs font-mono text-text focus:outline-none focus:border-ring`,placeholder:`{ "name": "My Theme", "type": "dark", "colors": { … }, "tokenColors": [ … ] }`,value:c,onChange:e=>l(e.target.value)})}),(0,P.jsxs)(V,{value:`upload`,className:`space-y-2 pt-2`,children:[(0,P.jsx)(`input`,{type:`file`,accept:`.json,application/json`,onChange:e=>E(e.target.files?.[0]),className:`block w-full text-xs text-text-2 file:mr-3 file:rounded file:border file:border-border file:bg-panel-2 file:px-2 file:py-1 file:text-text`}),c&&(0,P.jsxs)(`p`,{className:`text-[11px] text-success`,children:[`File loaded (`,c.length,` chars)`]})]})]}),(0,P.jsx)(w,{placeholder:`Optional name`,value:u,onChange:e=>d(e.target.value)}),(0,P.jsxs)(y,{children:[(0,P.jsx)(_,{variant:`outline`,onClick:()=>t(!1),disabled:m,children:`Cancel`}),(0,P.jsx)(_,{onClick:T,disabled:m,children:m?`Importing…`:`Import`})]})]})})}function U(){let e=p(e=>e.customThemes),t=p(e=>e.themeStyle),n=p(e=>e.customThemeId),r=p(e=>e.setCustomTheme),i=p(e=>e.deleteCustomTheme),[a,o]=(0,I.useState)(!1);return(0,P.jsxs)(`section`,{className:`space-y-2`,children:[(0,P.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,P.jsx)(`h3`,{className:`text-xs font-medium text-muted-foreground`,children:`Imported themes`}),(0,P.jsxs)(_,{size:`sm`,variant:`outline`,className:`h-7 gap-1 text-xs`,onClick:()=>o(!0),children:[(0,P.jsx)(c,{className:`size-3.5`}),` Import`]})]}),e.length===0?(0,P.jsx)(`p`,{className:`text-[11px] text-text-3`,children:`No imported themes yet. Import a VSCode theme from a URL, .vsix, or JSON.`}):(0,P.jsx)(`ul`,{className:`space-y-1`,children:e.map(e=>{let a=t===`custom`&&n===e.id;return(0,P.jsxs)(`li`,{className:m(`flex items-center gap-2 rounded-md border px-2 py-1.5`,a?`border-primary bg-primary/10`:`border-border`),children:[(0,P.jsx)(A,{swatch:e.swatch}),(0,P.jsxs)(`button`,{className:`flex-1 min-w-0 text-left`,onClick:()=>r(e.id),children:[(0,P.jsx)(`span`,{className:`block truncate text-xs text-text`,children:e.name}),(0,P.jsx)(`span`,{className:`block text-[10px] text-text-3`,children:e.mode})]}),a&&(0,P.jsx)(l,{className:`size-4 text-primary shrink-0`}),(0,P.jsx)(`button`,{className:`text-text-3 hover:text-error transition-colors shrink-0`,title:`Delete`,onClick:()=>void i(e.id),children:(0,P.jsx)(u,{className:`size-3.5`})})]},e.id)})}),(0,P.jsx)(H,{open:a,onOpenChange:o})]})}var W=[{value:`default`,label:`Default`},{value:`boxed`,label:`Boxed`},{value:`pill`,label:`Pill`}],G=[{value:`auto`,label:`Auto`},{value:`windows`,label:`Windows`},{value:`macos`,label:`macOS`}];function K({options:e,value:t,onChange:n}){return(0,P.jsx)(`div`,{className:`flex gap-2`,children:e.map(e=>(0,P.jsx)(_,{variant:t===e.value?`default`:`outline`,onClick:()=>n(e.value),className:m(`flex-1 cursor-pointer`,t===e.value&&`ring-2 ring-primary`),children:e.label},e.value))})}function q(){let{theme:e,setTheme:t,tabWrap:n,toggleTabWrap:r,editorTabStyle:i,setEditorTabStyle:a,explorerSkin:o,setExplorerSkin:c}=p(O(e=>({theme:e.themeMode,setTheme:e.setThemeMode,tabWrap:e.tabWrap,toggleTabWrap:e.toggleTabWrap,editorTabStyle:e.editorTabStyle,setEditorTabStyle:e.setEditorTabStyle,explorerSkin:e.explorerSkin,setExplorerSkin:e.setExplorerSkin}))),{wordWrap:l,toggleWordWrap:u,mobileWordWrap:f,toggleMobileWordWrap:g,lspEnabled:v,setLspEnabled:y}=p(O(e=>({wordWrap:e.wordWrap,toggleWordWrap:e.toggleWordWrap,mobileWordWrap:e.mobileWordWrap,toggleMobileWordWrap:e.toggleMobileWordWrap,lspEnabled:e.lspEnabled,setLspEnabled:e.setLspEnabled}))),b=h(),x=M();return(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsxs)(`section`,{className:`space-y-3`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium`,children:`Theme`}),(0,P.jsx)(F,{}),(0,P.jsx)(`div`,{className:`flex gap-2`,children:j.map(n=>{let r=n.icon;return(0,P.jsxs)(_,{variant:e===n.value?`default`:`outline`,onClick:()=>t(n.value),className:m(`flex-1 gap-2 cursor-pointer`,e===n.value&&`ring-2 ring-primary`),children:[(0,P.jsx)(r,{className:`size-4`}),n.label]},n.value)})})]}),(0,P.jsx)(N,{}),(0,P.jsx)(U,{}),(0,P.jsx)(N,{}),(0,P.jsxs)(`section`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,P.jsx)(d,{className:`size-4 text-muted-foreground shrink-0`}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Wrap Tabs`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Stack tabs in rows instead of scrolling`})]})]}),(0,P.jsx)(k,{checked:n,onCheckedChange:r})]}),(0,P.jsxs)(`section`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,P.jsx)(d,{className:`size-4 text-muted-foreground shrink-0`}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Word Wrap`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:b?`Wrap long lines instead of scrolling sideways (this device)`:`Wrap long lines in the editor (Alt+Z)`})]})]}),(0,P.jsx)(k,{checked:b?f:l,onCheckedChange:()=>b?g():u()})]}),(0,P.jsxs)(`section`,{className:`flex items-center justify-between gap-4`,children:[(0,P.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,P.jsx)(s,{className:`size-4 text-muted-foreground shrink-0`}),(0,P.jsxs)(`div`,{className:`min-w-0`,children:[(0,P.jsx)(`p`,{className:`text-sm font-medium`,children:`Language Server`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:x?`Off on a touch device — it runs a server process per project`:`Completions, hover, F12, rename and quick fix (this device)`})]})]}),(0,P.jsx)(k,{checked:v&&!x,disabled:x,onCheckedChange:y})]}),(0,P.jsxs)(`section`,{className:`space-y-2`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium`,children:`Tab Style`}),(0,P.jsx)(K,{options:W,value:i,onChange:a})]}),(0,P.jsxs)(`section`,{className:`space-y-2`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-medium`,children:`Explorer Skin`}),(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Chrome the OS File Explorer window wears. Auto follows the host platform.`}),(0,P.jsx)(K,{options:G,value:o,onChange:c})]})]})}export{q as AppearanceSettingsSection};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import{O as r,Qn as i,_t as a,an as o,j as s,ln as c,u as l,w as u}from"./icons-DQjqk0lJ.js";import{n as d}from"./api-client-C1ZwRL4Y.js";import"./settings-store-krC6bc79.js";import"./vendor-mermaid-BitiXJlL.js";import"./portal-container-context-BarKmT4S.js";import"./project-store-B87hLRSk.js";import"./project-framework-store-B70Q3dNM.js";import{n as f}from"./use-is-mobile-TkcwP1Gx.js";import"./git-repo-store-88Z8v-pF.js";import{t as p}from"./button-B9CTrsEf.js";import{t as m}from"./file-icons-BXdvggK2.js";import{t as h}from"./mobile-bottom-sheet-C3TniEP-.js";import"./use-visual-viewport-Lp878uzs.js";import{t as g}from"./scroll-area-BzeiOd-B.js";import{$ as ee,Et as te,Q as ne,et as _,nt as re,tt as ie}from"./index-DU68xk06.js";import"./use-monaco-theme-BIVYJBIn.js";import"./use-inline-blame-vrfFHuaR.js";import{DiffViewer as ae}from"./diff-viewer-3oBA7vgQ.js";var v=e(t(),1),y=`ppm:branch-review`,b=`${y}:recent`,x=20;function oe(e,t,n){return`${y}:${e}:${t}:${n}`}function S(e,t){return e[t.path]===t.blob}function se(e,t){let n={...e};return S(e,t)?delete n[t.path]:n[t.path]=t.blob,n}function C(e,t,n){if(!n)return{};let r={...e};for(let e of t)r[e.path]=e.blob;return r}function w(e,t){return t.reduce((t,n)=>t+(S(e,n)?1:0),0)}function T(e,t){let n=new Set(t.map(e=>e.path)),r={};for(let[t,i]of Object.entries(e))n.has(t)&&(r[t]=i);return r}function E(e){return e.find(e=>!e.binary)??e[0]??null}function ce(e,t,n){if(t.length===0)return null;let r=n?t.findIndex(e=>e.path===n)+1:0;for(let n=0;n<t.length;n++){let i=t[(r+n)%t.length];if(i&&!S(e,i))return i}return null}function le(e){try{let t=localStorage.getItem(e);if(!t)return{};let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))return{};let r={};for(let[e,t]of Object.entries(n))typeof t==`string`&&(r[e]=t);return r}catch{return{}}}function D(e,t,n=x){let r=[t,...e.filter(e=>e!==t)];return{recent:r.slice(0,n),evicted:r.slice(n)}}function O(){try{let e=JSON.parse(localStorage.getItem(b)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function k(e,t){try{if(Object.keys(t).length===0){localStorage.removeItem(e);let t=O().filter(t=>t!==e);localStorage.setItem(b,JSON.stringify(t));return}localStorage.setItem(e,JSON.stringify(t));let{recent:n,evicted:r}=D(O(),e);for(let e of r)localStorage.removeItem(e);localStorage.setItem(b,JSON.stringify(n))}catch{}}var A=n(),j={M:`text-warning`,A:`text-success`,D:`text-error`,R:`text-primary`,C:`text-accent-2`,T:`text-text-3`};function M({children:e}){return(0,A.jsx)(`span`,{dir:`rtl`,className:`truncate text-left min-w-0 flex-1`,children:(0,A.jsx)(`bdi`,{children:e})})}function N(e){let{node:t,depth:n,byPath:i,reviewed:a,selectedPath:o,collapsed:c,onToggleCollapse:l,onSelect:d,onToggleReviewed:f}=e,p=t.file?i.get(t.fullPath):void 0;if(!p){let i=c.has(t.fullPath);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`button`,{type:`button`,"data-testid":`branch-review-folder`,className:`w-full flex items-center gap-1 px-2 py-1 text-xs min-h-11 md:min-h-0 hover:bg-surface-hover text-left`,style:{paddingLeft:n*14+8},onClick:()=>l(t.fullPath),children:[i?(0,A.jsx)(s,{className:`size-3 shrink-0`}):(0,A.jsx)(r,{className:`size-3 shrink-0`}),(0,A.jsx)(`span`,{className:`truncate text-text-2`,children:t.name})]}),!i&&t.children.map(t=>(0,A.jsx)(N,{...e,node:t,depth:n+1},t.fullPath))]})}let h=S(a,p),g=o===p.path;return(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 pr-2 py-1 text-xs cursor-pointer border-l-2 min-h-11 md:min-h-0 hover:bg-surface-hover ${g?`bg-primary/10 border-primary`:`border-transparent`}`,style:{paddingLeft:n*14+6},onClick:()=>d(p.path),"aria-current":g?`true`:void 0,"data-testid":`branch-review-file`,"data-path":p.path,"data-selected":g?`true`:`false`,"data-reviewed":h?`true`:`false`,children:[(0,A.jsx)(`button`,{type:`button`,"aria-label":h?`Mark ${p.path} unreviewed`:`Mark ${p.path} reviewed`,"data-testid":`branch-review-check`,className:`size-11 md:size-4 shrink-0 flex items-center justify-center`,onClick:e=>{e.stopPropagation(),f(p)},children:(0,A.jsx)(`span`,{"data-testid":`branch-review-check-box`,className:`size-4 rounded border flex items-center justify-center ${h?`bg-primary border-primary text-primary-foreground`:`border-border`}`,children:h&&(0,A.jsx)(u,{className:`size-3`})})}),(0,A.jsx)(m,{name:t.name,className:`size-3.5 shrink-0`}),(0,A.jsx)(M,{children:t.name}),(0,A.jsx)(`span`,{className:`shrink-0 font-mono ${j[p.status]}`,children:p.status}),p.binary?(0,A.jsx)(`span`,{className:`shrink-0 text-text-3 italic`,children:`bin`}):(0,A.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[10px]`,children:[(0,A.jsxs)(`span`,{className:`text-success`,children:[`+`,p.additions]}),` `,(0,A.jsxs)(`span`,{className:`text-error`,children:[`-`,p.deletions]})]})]})}function ue(e,t){let n=e.filter(e=>!e.remote&&e.name!==t);return n.find(e=>e.name===`main`)?.name??n.find(e=>e.name===`master`)?.name??n[0]?.name??``}function P({metadata:e}){let t=e?.projectName,n=te(t),r=f(),[s,u]=(0,v.useState)([]),[m,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(``),[S,D]=(0,v.useState)(null),[O,j]=(0,v.useState)(null),[P,F]=(0,v.useState)({}),[de,I]=(0,v.useState)(new Set),[L,R]=(0,v.useState)(!1),[z,B]=(0,v.useState)(null),[V,H]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!t||!n.repo)return;let e=!1;return d.get(n.gitUrl(`/branches`)).then(t=>{if(e)return;u(t);let n=t.find(e=>e.current)?.name;x(e=>e||n||``),y(e=>e||ue(t,n))}).catch(t=>!e&&B(t instanceof Error?t.message:`Could not list branches`)),()=>{e=!0}},[t,n]);let U=(0,v.useRef)(null),W=(0,v.useCallback)(async()=>{if(!t||!n.repo||!m||!b)return;U.current?.abort();let e=new AbortController;U.current=e,R(!0),B(null);try{let t=new URLSearchParams({base:m,head:b}),r=await d.get(n.gitUrl(`/branch-diff?${t}`),{signal:e.signal});if(e.signal.aborted)return;D(r),j(e=>e&&r.files.some(t=>t.path===e)?e:E(r.files)?.path??null)}catch(t){if(e.signal.aborted)return;D(null),B(t instanceof Error?t.message:`Could not compare these branches`)}finally{e.signal.aborted||R(!1)}},[t,n,m,b]);(0,v.useEffect)(()=>(W(),()=>U.current?.abort()),[W]);let G=t&&m&&b?oe(t,m,b):null;(0,v.useEffect)(()=>{I(new Set)},[G]),(0,v.useEffect)(()=>{F(G?le(G):{})},[G]);let K=S&&S.base===m&&S.head===b?S:null;(0,v.useEffect)(()=>{!G||!K||F(e=>{let t=T(e,K.files);return Object.keys(t).length!==Object.keys(e).length&&k(G,t),t})},[G,K]);let q=(0,v.useCallback)(e=>{F(e),G&&k(G,e)},[G]),J=K?.files??[],Y=(0,v.useMemo)(()=>new Map(J.map(e=>[e.path,e])),[J]),X=(0,v.useMemo)(()=>w(P,J),[P,J]),fe=(0,v.useMemo)(()=>ee(ne(J.map(e=>({path:e.path,status:e.status===`T`?`M`:e.status})))),[J]),Z=O?Y.get(O)??null:null,Q=(0,v.useCallback)(()=>{let e=ce(P,J,O);e&&(j(e.path),H(!1))},[P,J,O]);if(n.noRepo)return(0,A.jsx)(_,{onReload:n.reload});if(n.needsPick)return(0,A.jsx)(re,{repos:n.repos,onChoose:n.choose});let $=(0,A.jsx)(g,{className:`h-full`,children:(0,A.jsxs)(`div`,{className:`py-1`,children:[J.length===0&&!L&&(0,A.jsx)(`div`,{className:`px-3 py-6 text-center text-xs text-text-3`,children:z?`—`:`These branches have identical trees.`}),fe.map(e=>(0,A.jsx)(N,{node:e,depth:0,byPath:Y,reviewed:P,selectedPath:O,collapsed:de,onToggleCollapse:e=>I(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:e=>{j(e),H(!1)},onToggleReviewed:e=>q(se(P,e))},e.fullPath)),!!K?.omitted&&(0,A.jsxs)(`div`,{className:`px-3 py-3 text-center text-xs text-text-3`,children:[K.omitted.toLocaleString(),` more `,K.omitted===1?`file`:`files`,` not listed.`]})]})});return(0,A.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-bg`,children:[n.isNested&&n.repo&&(0,A.jsx)(ie,{repo:n.repo,repos:n.repos,onChoose:n.choose}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 border-b border-border shrink-0 flex-wrap`,children:[(0,A.jsx)(`select`,{value:m,onChange:e=>y(e.target.value),"aria-label":`Base branch`,"data-testid":`branch-review-base`,className:`h-7 max-w-[38%] rounded-md border border-border bg-panel px-2 text-xs min-w-0`,children:s.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,A.jsx)(l,{className:`size-3.5 text-text-3 shrink-0`}),(0,A.jsx)(`select`,{value:b,onChange:e=>x(e.target.value),"aria-label":`Branch to review`,"data-testid":`branch-review-head`,className:`h-7 max-w-[38%] rounded-md border border-border bg-panel px-2 text-xs min-w-0`,children:s.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,A.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,A.jsxs)(`span`,{className:`text-xs text-text-2 tabular-nums`,"data-testid":`branch-review-progress`,children:[X,`/`,J.length,` reviewed`]}),(0,A.jsx)(p,{variant:`ghost`,size:`icon-xs`,title:X===J.length&&J.length>0?`Clear all`:`Mark all reviewed`,disabled:J.length===0,onClick:()=>q(C(P,J,X!==J.length)),children:(0,A.jsx)(o,{className:`size-3.5`})}),(0,A.jsx)(p,{variant:`ghost`,size:`icon-xs`,title:`Reload`,onClick:()=>void W(),children:(0,A.jsx)(i,{className:L?`animate-spin`:``})})]})]}),z&&(0,A.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0`,children:z}),(0,A.jsxs)(`div`,{className:`flex-1 flex min-h-0`,children:[!r&&(0,A.jsx)(`div`,{className:`w-72 shrink-0 border-r border-border flex flex-col min-h-0`,children:$}),(0,A.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col`,children:Z?(0,A.jsx)(ae,{metadata:{filePath:n.projectFile(Z.path),projectName:t,ref1:K?.mergeBase,ref2:K?.headCommit}},`${Z.path}:${K?.mergeBase}:${K?.headCommit}`):(0,A.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-text-3`,children:L?(0,A.jsx)(c,{className:`size-4 animate-spin`}):`Nothing to review.`})})]}),r&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border p-2 shrink-0`,children:[(0,A.jsxs)(p,{variant:`secondary`,size:`sm`,className:`flex-1 min-h-11`,onClick:()=>H(!0),children:[(0,A.jsx)(a,{className:`size-4`}),J.length,` files`]}),(0,A.jsx)(p,{variant:`secondary`,size:`sm`,className:`flex-1 min-h-11`,onClick:Q,children:`Next unreviewed`})]}),r&&(0,A.jsx)(h,{open:V,onClose:()=>H(!1),children:(0,A.jsx)(`div`,{className:`max-h-[70vh] overflow-hidden flex flex-col`,children:$})}),!r&&Z&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border px-2 py-1 shrink-0`,children:[(0,A.jsx)(M,{children:Z.path}),(0,A.jsx)(p,{variant:`ghost`,size:`xs`,onClick:Q,children:`Next unreviewed`})]})]})}export{P as BranchReviewTab};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-FhOqtrmT.js";import{C as t,S as n}from"./vendor-markdown-CuWCHIVb.js";import"./vendor-ui-DmZ-Mb-H.js";import{O as r,Qn as i,_t as a,an as o,j as s,ln as c,u as l,w as u}from"./icons-DQjqk0lJ.js";import{n as d}from"./api-client-C1ZwRL4Y.js";import"./settings-store-krC6bc79.js";import"./vendor-mermaid-BitiXJlL.js";import"./portal-container-context-BarKmT4S.js";import"./project-store-B87hLRSk.js";import"./project-framework-store-B70Q3dNM.js";import{n as f}from"./use-is-mobile-TkcwP1Gx.js";import"./git-repo-store-88Z8v-pF.js";import{t as p}from"./button-B9CTrsEf.js";import{t as m}from"./file-icons-BXdvggK2.js";import{t as h}from"./mobile-bottom-sheet-C3TniEP-.js";import"./use-visual-viewport-Lp878uzs.js";import{t as g}from"./scroll-area-BzeiOd-B.js";import{$ as ee,Et as te,Q as ne,et as _,nt as re,tt as ie}from"./index-CEZVxM4G.js";import"./use-monaco-theme-gvhJ_jZh.js";import"./use-inline-blame-sDMjcz1-.js";import{DiffViewer as ae}from"./diff-viewer-9-XjLIwa.js";var v=e(t(),1),y=`ppm:branch-review`,b=`${y}:recent`,x=20;function oe(e,t,n){return`${y}:${e}:${t}:${n}`}function S(e,t){return e[t.path]===t.blob}function se(e,t){let n={...e};return S(e,t)?delete n[t.path]:n[t.path]=t.blob,n}function C(e,t,n){if(!n)return{};let r={...e};for(let e of t)r[e.path]=e.blob;return r}function w(e,t){return t.reduce((t,n)=>t+(S(e,n)?1:0),0)}function T(e,t){let n=new Set(t.map(e=>e.path)),r={};for(let[t,i]of Object.entries(e))n.has(t)&&(r[t]=i);return r}function E(e){return e.find(e=>!e.binary)??e[0]??null}function ce(e,t,n){if(t.length===0)return null;let r=n?t.findIndex(e=>e.path===n)+1:0;for(let n=0;n<t.length;n++){let i=t[(r+n)%t.length];if(i&&!S(e,i))return i}return null}function le(e){try{let t=localStorage.getItem(e);if(!t)return{};let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))return{};let r={};for(let[e,t]of Object.entries(n))typeof t==`string`&&(r[e]=t);return r}catch{return{}}}function D(e,t,n=x){let r=[t,...e.filter(e=>e!==t)];return{recent:r.slice(0,n),evicted:r.slice(n)}}function O(){try{let e=JSON.parse(localStorage.getItem(b)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function k(e,t){try{if(Object.keys(t).length===0){localStorage.removeItem(e);let t=O().filter(t=>t!==e);localStorage.setItem(b,JSON.stringify(t));return}localStorage.setItem(e,JSON.stringify(t));let{recent:n,evicted:r}=D(O(),e);for(let e of r)localStorage.removeItem(e);localStorage.setItem(b,JSON.stringify(n))}catch{}}var A=n(),j={M:`text-warning`,A:`text-success`,D:`text-error`,R:`text-primary`,C:`text-accent-2`,T:`text-text-3`};function M({children:e}){return(0,A.jsx)(`span`,{dir:`rtl`,className:`truncate text-left min-w-0 flex-1`,children:(0,A.jsx)(`bdi`,{children:e})})}function N(e){let{node:t,depth:n,byPath:i,reviewed:a,selectedPath:o,collapsed:c,onToggleCollapse:l,onSelect:d,onToggleReviewed:f}=e,p=t.file?i.get(t.fullPath):void 0;if(!p){let i=c.has(t.fullPath);return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`button`,{type:`button`,"data-testid":`branch-review-folder`,className:`w-full flex items-center gap-1 px-2 py-1 text-xs min-h-11 md:min-h-0 hover:bg-surface-hover text-left`,style:{paddingLeft:n*14+8},onClick:()=>l(t.fullPath),children:[i?(0,A.jsx)(s,{className:`size-3 shrink-0`}):(0,A.jsx)(r,{className:`size-3 shrink-0`}),(0,A.jsx)(`span`,{className:`truncate text-text-2`,children:t.name})]}),!i&&t.children.map(t=>(0,A.jsx)(N,{...e,node:t,depth:n+1},t.fullPath))]})}let h=S(a,p),g=o===p.path;return(0,A.jsxs)(`div`,{className:`flex items-center gap-1.5 pr-2 py-1 text-xs cursor-pointer border-l-2 min-h-11 md:min-h-0 hover:bg-surface-hover ${g?`bg-primary/10 border-primary`:`border-transparent`}`,style:{paddingLeft:n*14+6},onClick:()=>d(p.path),"aria-current":g?`true`:void 0,"data-testid":`branch-review-file`,"data-path":p.path,"data-selected":g?`true`:`false`,"data-reviewed":h?`true`:`false`,children:[(0,A.jsx)(`button`,{type:`button`,"aria-label":h?`Mark ${p.path} unreviewed`:`Mark ${p.path} reviewed`,"data-testid":`branch-review-check`,className:`size-11 md:size-4 shrink-0 flex items-center justify-center`,onClick:e=>{e.stopPropagation(),f(p)},children:(0,A.jsx)(`span`,{"data-testid":`branch-review-check-box`,className:`size-4 rounded border flex items-center justify-center ${h?`bg-primary border-primary text-primary-foreground`:`border-border`}`,children:h&&(0,A.jsx)(u,{className:`size-3`})})}),(0,A.jsx)(m,{name:t.name,className:`size-3.5 shrink-0`}),(0,A.jsx)(M,{children:t.name}),(0,A.jsx)(`span`,{className:`shrink-0 font-mono ${j[p.status]}`,children:p.status}),p.binary?(0,A.jsx)(`span`,{className:`shrink-0 text-text-3 italic`,children:`bin`}):(0,A.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[10px]`,children:[(0,A.jsxs)(`span`,{className:`text-success`,children:[`+`,p.additions]}),` `,(0,A.jsxs)(`span`,{className:`text-error`,children:[`-`,p.deletions]})]})]})}function ue(e,t){let n=e.filter(e=>!e.remote&&e.name!==t);return n.find(e=>e.name===`main`)?.name??n.find(e=>e.name===`master`)?.name??n[0]?.name??``}function P({metadata:e}){let t=e?.projectName,n=te(t),r=f(),[s,u]=(0,v.useState)([]),[m,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(``),[S,D]=(0,v.useState)(null),[O,j]=(0,v.useState)(null),[P,F]=(0,v.useState)({}),[de,I]=(0,v.useState)(new Set),[L,R]=(0,v.useState)(!1),[z,B]=(0,v.useState)(null),[V,H]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!t||!n.repo)return;let e=!1;return d.get(n.gitUrl(`/branches`)).then(t=>{if(e)return;u(t);let n=t.find(e=>e.current)?.name;x(e=>e||n||``),y(e=>e||ue(t,n))}).catch(t=>!e&&B(t instanceof Error?t.message:`Could not list branches`)),()=>{e=!0}},[t,n]);let U=(0,v.useRef)(null),W=(0,v.useCallback)(async()=>{if(!t||!n.repo||!m||!b)return;U.current?.abort();let e=new AbortController;U.current=e,R(!0),B(null);try{let t=new URLSearchParams({base:m,head:b}),r=await d.get(n.gitUrl(`/branch-diff?${t}`),{signal:e.signal});if(e.signal.aborted)return;D(r),j(e=>e&&r.files.some(t=>t.path===e)?e:E(r.files)?.path??null)}catch(t){if(e.signal.aborted)return;D(null),B(t instanceof Error?t.message:`Could not compare these branches`)}finally{e.signal.aborted||R(!1)}},[t,n,m,b]);(0,v.useEffect)(()=>(W(),()=>U.current?.abort()),[W]);let G=t&&m&&b?oe(t,m,b):null;(0,v.useEffect)(()=>{I(new Set)},[G]),(0,v.useEffect)(()=>{F(G?le(G):{})},[G]);let K=S&&S.base===m&&S.head===b?S:null;(0,v.useEffect)(()=>{!G||!K||F(e=>{let t=T(e,K.files);return Object.keys(t).length!==Object.keys(e).length&&k(G,t),t})},[G,K]);let q=(0,v.useCallback)(e=>{F(e),G&&k(G,e)},[G]),J=K?.files??[],Y=(0,v.useMemo)(()=>new Map(J.map(e=>[e.path,e])),[J]),X=(0,v.useMemo)(()=>w(P,J),[P,J]),fe=(0,v.useMemo)(()=>ee(ne(J.map(e=>({path:e.path,status:e.status===`T`?`M`:e.status})))),[J]),Z=O?Y.get(O)??null:null,Q=(0,v.useCallback)(()=>{let e=ce(P,J,O);e&&(j(e.path),H(!1))},[P,J,O]);if(n.noRepo)return(0,A.jsx)(_,{onReload:n.reload});if(n.needsPick)return(0,A.jsx)(re,{repos:n.repos,onChoose:n.choose});let $=(0,A.jsx)(g,{className:`h-full`,children:(0,A.jsxs)(`div`,{className:`py-1`,children:[J.length===0&&!L&&(0,A.jsx)(`div`,{className:`px-3 py-6 text-center text-xs text-text-3`,children:z?`—`:`These branches have identical trees.`}),fe.map(e=>(0,A.jsx)(N,{node:e,depth:0,byPath:Y,reviewed:P,selectedPath:O,collapsed:de,onToggleCollapse:e=>I(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelect:e=>{j(e),H(!1)},onToggleReviewed:e=>q(se(P,e))},e.fullPath)),!!K?.omitted&&(0,A.jsxs)(`div`,{className:`px-3 py-3 text-center text-xs text-text-3`,children:[K.omitted.toLocaleString(),` more `,K.omitted===1?`file`:`files`,` not listed.`]})]})});return(0,A.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-bg`,children:[n.isNested&&n.repo&&(0,A.jsx)(ie,{repo:n.repo,repos:n.repos,onChoose:n.choose}),(0,A.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 border-b border-border shrink-0 flex-wrap`,children:[(0,A.jsx)(`select`,{value:m,onChange:e=>y(e.target.value),"aria-label":`Base branch`,"data-testid":`branch-review-base`,className:`h-7 max-w-[38%] rounded-md border border-border bg-panel px-2 text-xs min-w-0`,children:s.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,A.jsx)(l,{className:`size-3.5 text-text-3 shrink-0`}),(0,A.jsx)(`select`,{value:b,onChange:e=>x(e.target.value),"aria-label":`Branch to review`,"data-testid":`branch-review-head`,className:`h-7 max-w-[38%] rounded-md border border-border bg-panel px-2 text-xs min-w-0`,children:s.map(e=>(0,A.jsx)(`option`,{value:e.name,children:e.name},e.name))}),(0,A.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,A.jsxs)(`span`,{className:`text-xs text-text-2 tabular-nums`,"data-testid":`branch-review-progress`,children:[X,`/`,J.length,` reviewed`]}),(0,A.jsx)(p,{variant:`ghost`,size:`icon-xs`,title:X===J.length&&J.length>0?`Clear all`:`Mark all reviewed`,disabled:J.length===0,onClick:()=>q(C(P,J,X!==J.length)),children:(0,A.jsx)(o,{className:`size-3.5`})}),(0,A.jsx)(p,{variant:`ghost`,size:`icon-xs`,title:`Reload`,onClick:()=>void W(),children:(0,A.jsx)(i,{className:L?`animate-spin`:``})})]})]}),z&&(0,A.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0`,children:z}),(0,A.jsxs)(`div`,{className:`flex-1 flex min-h-0`,children:[!r&&(0,A.jsx)(`div`,{className:`w-72 shrink-0 border-r border-border flex flex-col min-h-0`,children:$}),(0,A.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col`,children:Z?(0,A.jsx)(ae,{metadata:{filePath:n.projectFile(Z.path),projectName:t,ref1:K?.mergeBase,ref2:K?.headCommit}},`${Z.path}:${K?.mergeBase}:${K?.headCommit}`):(0,A.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-text-3`,children:L?(0,A.jsx)(c,{className:`size-4 animate-spin`}):`Nothing to review.`})})]}),r&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border p-2 shrink-0`,children:[(0,A.jsxs)(p,{variant:`secondary`,size:`sm`,className:`flex-1 min-h-11`,onClick:()=>H(!0),children:[(0,A.jsx)(a,{className:`size-4`}),J.length,` files`]}),(0,A.jsx)(p,{variant:`secondary`,size:`sm`,className:`flex-1 min-h-11`,onClick:Q,children:`Next unreviewed`})]}),r&&(0,A.jsx)(h,{open:V,onClose:()=>H(!1),children:(0,A.jsx)(`div`,{className:`max-h-[70vh] overflow-hidden flex flex-col`,children:$})}),!r&&Z&&(0,A.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border px-2 py-1 shrink-0`,children:[(0,A.jsx)(M,{children:Z.path}),(0,A.jsx)(p,{variant:`ghost`,size:`xs`,onClick:Q,children:`Next unreviewed`})]})]})}export{P as BranchReviewTab};
|