@puddle-code/cli 0.0.10 → 0.0.12
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 +83 -22
- package/README.md +12 -0
- package/dist/index.js +147 -35
- package/dist/public/assets/Dashboard-DOKOSPsG.js +1 -0
- package/dist/public/assets/{EditorTabClose-DXG0-8LG.js → EditorTabClose-C3OCj0Ia.js} +1 -1
- package/dist/public/assets/LazyTerminal-BihPI9J1.js +2 -0
- package/dist/public/assets/{ModelRefcount-Cr0OdhVF.js → ModelRefcount-wkKpjkKn.js} +1 -1
- package/dist/public/assets/PaneEditorBody-DRR16vdx.js +66 -0
- package/dist/public/assets/SettingsDialog-CpnehH60.js +1 -0
- package/dist/public/assets/Terminal-Ci3-2jXt.js +117 -0
- package/dist/public/assets/Workspace-D1XOZzcy.js +6 -0
- package/dist/public/assets/api-Bh5IJ30S.js +73 -0
- package/dist/public/assets/{buffer-store-DF2zMOcz.js → buffer-store-mErJ-u_7.js} +3 -3
- package/dist/public/assets/context-menu-DyvGbiNT.js +1 -0
- package/dist/public/assets/{cssMode-DYb85Jum.js → cssMode-BxSU83en.js} +1 -1
- package/dist/public/assets/editor-tabs-D0_DZriG.js +1 -0
- package/dist/public/assets/{htmlMode-DyXrW8ZC.js → htmlMode-BI3Fg8wV.js} +1 -1
- package/dist/public/assets/index-DIgA5eoW.js +10 -0
- package/dist/public/assets/index-WMJ9gBck.css +2 -0
- package/dist/public/assets/{jsonMode-B5kO-8PP.js → jsonMode-Bsh_R96t.js} +1 -1
- package/dist/public/assets/poll-focus-B7dQPFj6.js +1 -0
- package/dist/public/assets/session-seed-BbO3y4XI.js +1 -0
- package/dist/public/assets/ssh-mode-BuFhqbL1.js +1 -0
- package/dist/public/assets/{tsMode-BnA0oGE5.js → tsMode-CV6x0W8w.js} +1 -1
- package/dist/public/index.html +5 -4
- package/package.json +1 -1
- package/dist/public/assets/Dashboard-Botzm-4a.js +0 -1
- package/dist/public/assets/PaneEditorBody-BzhoRYgd.js +0 -66
- package/dist/public/assets/SettingsDialog-Cd6rZoyo.js +0 -1
- package/dist/public/assets/Terminal-DogmkohW.js +0 -35
- package/dist/public/assets/Workspace-BDettW-h.js +0 -7
- package/dist/public/assets/api-BHwI7sYX.js +0 -73
- package/dist/public/assets/context-menu-CHZoXuDL.js +0 -1
- package/dist/public/assets/editor-tabs-BaSR99_-.js +0 -1
- package/dist/public/assets/index-BgfBBLZx.js +0 -10
- package/dist/public/assets/index-szwjDL7m.css +0 -2
- package/dist/public/assets/session-seed-Dy0HnELo.js +0 -1
- package/dist/public/assets/ssh-mode-CY9J7nfI.js +0 -1
- package/dist/public/assets/useMutation-Da9b4jwS.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,28 +7,89 @@ Past releases: see docs/changelogs/.
|
|
|
7
7
|
|
|
8
8
|
# Changelog
|
|
9
9
|
|
|
10
|
-
## [0.0.
|
|
10
|
+
## [0.0.12] — 2026-07-28
|
|
11
11
|
|
|
12
12
|
### Added
|
|
13
13
|
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
14
|
+
- Notifications actually fire now: when an agent flips to waiting for input,
|
|
15
|
+
puddle shows a desktop notification (while the window is unfocused; clicking
|
|
16
|
+
it opens the session), plays the optional sound, and badges the tab title
|
|
17
|
+
with the count of waiting agents — honouring the Notifications settings and
|
|
18
|
+
per-project mutes. Enabling the desktop toggle asks for browser permission.
|
|
19
|
+
|
|
20
|
+
- A `running` agent that has recorded no transcript activity for over an hour
|
|
21
|
+
is flagged `stale_running` (computed on read, protocol **10.1** — additive):
|
|
22
|
+
the UI fades its status dot, drops the ripple, and hints "possibly stalled".
|
|
23
|
+
Advisory only — the daemon never interrupts an agent over it.
|
|
24
|
+
|
|
25
|
+
- Desktop shell (`packages/desktop`): puddle now also builds as a standalone
|
|
26
|
+
Electron app. The main process drives the exact same cockpit engine as the
|
|
27
|
+
`puddle` CLI (`startLocal` from the new embedder surface
|
|
28
|
+
`@puddle-code/cli/lib`) and opens a window on the embedded cockpit — one
|
|
29
|
+
codebase, two downstream builds. External links and editor deep links open
|
|
30
|
+
via the OS, the connection banner's refresh restarts the cockpit
|
|
31
|
+
in-process, notification clicks raise the window, and quitting never
|
|
32
|
+
touches the daemon or running agents. `pnpm --filter @puddle/desktop start`
|
|
33
|
+
to run, `… dist` to package (dmg/zip/AppImage).
|
|
34
|
+
- Desktop remote hosts: File → "Connect to SSH Host…" (⌘⇧O, with a Recent
|
|
35
|
+
Hosts submenu) drives the CLI's `connectRemote` — one window per host,
|
|
36
|
+
closing it stops only that cockpit's tunnel/UI server. Key-authenticated
|
|
37
|
+
hosts only (no TTY for ssh prompts); the dialogue points password/2FA
|
|
38
|
+
hosts at `puddle connect`.
|
|
39
|
+
- Desktop release packaging: tags now also build the app (dmg/zip on macOS
|
|
40
|
+
arm64, AppImage on linux x64) and attach it to the GitHub release with
|
|
41
|
+
checksums in SHA256SUMS. macOS signing + notarisation switch on when the
|
|
42
|
+
`MAC_CERT_P12`/`MAC_CERT_PASSWORD` and `APPLE_ID`/`APPLE_APP_SPECIFIC_PASSWORD`/
|
|
43
|
+
`APPLE_TEAM_ID` secrets exist; unsigned otherwise — the accepted default,
|
|
44
|
+
with the Gatekeeper "Open Anyway"/`xattr` path documented in the README.
|
|
45
|
+
- Desktop app icon: the puddle mark in dark-theme gold on a navy squircle
|
|
46
|
+
(icon.svg → committed png/icns via `packages/desktop/scripts/render-icon.sh`).
|
|
47
|
+
|
|
48
|
+
### Fixed
|
|
49
|
+
|
|
50
|
+
- Battery: the web UI now idles properly. Terminals detach from their PTY
|
|
51
|
+
stream while hidden (background tab of a pane, or the whole browser tab
|
|
52
|
+
hidden) and repaint from the daemon's replay when shown again — a hidden
|
|
53
|
+
terminal no longer receives and parses every output byte. Visible terminals
|
|
54
|
+
render on the GPU (`@xterm/addon-webgl`, DOM-renderer fallback). The status
|
|
55
|
+
ripples/pulses are finite (~30 s / ~1 min after a status change) instead of
|
|
56
|
+
animating forever, and the ports/env (5 s) and git status/diff (10 s) polls
|
|
57
|
+
stretch 12× while the window is unfocused, snapping back on refocus. Agent
|
|
58
|
+
processes and PTYs are untouched by all of this — pausing is viewer-side
|
|
59
|
+
only.
|
|
60
|
+
- Battery, daemon-side: the 3 s agent-title refresh stat-guards the transcript
|
|
61
|
+
and skips the 128 KiB read when unchanged; PTY log writes coalesce on a
|
|
62
|
+
100 ms flush instead of one synchronous write per output chunk; session logs
|
|
63
|
+
are now actually capped at `logMaxBytes` (the config existed but was never
|
|
64
|
+
enforced — logs grew without bound), rotating to the newest half; the status
|
|
65
|
+
detector compiles its regexes once instead of per chunk; and the WS gateway
|
|
66
|
+
stops JSON-encoding output for streams whose last viewer detached.
|
|
67
|
+
- Replayed terminal history no longer re-executes OSC side effects: a stale
|
|
68
|
+
OSC 52 copy can't clobber the clipboard and stale colour-query replies are
|
|
69
|
+
never written into a working agent's stdin; a re-attach also repaints the
|
|
70
|
+
buffer from scratch instead of appending the replay to what it showed.
|
|
71
|
+
- Status detection no longer sticks on green: agent status is now driven by
|
|
72
|
+
the agent's own hooks instead of scraping the terminal. For Claude Code the
|
|
73
|
+
daemon installs Stop / Notification(permission_prompt, idle_prompt) /
|
|
74
|
+
UserPromptSubmit / PreToolUse hooks (verified against 2.1.219) whose helper
|
|
75
|
+
reports to a new nonce-gated `POST /agent-signal` endpoint (protocol 9.4);
|
|
76
|
+
the old regex detection remains as a fallback until a session's first
|
|
77
|
+
signal. Existing accounts pick the hooks up at the next daemon boot.
|
|
78
|
+
- Desktop Linux packaging: the AppImage build failed because electron-builder derived the executable name from the package name (`@puddle/desktop` → `@puddledesktop`, rejected for the `@`); set `linux.executableName: puddle-desktop` explicitly, plus `desktopName` + `linux.syncDesktopName` so the `.desktop` entry, `StartupWMClass`, and Electron's app_id all match for window association.
|
|
79
|
+
|
|
80
|
+
### Changed
|
|
81
|
+
|
|
82
|
+
- `PROTOCOL_VERSION` → **10.0**: a deliberate major bump (the 6.0/8.0
|
|
83
|
+
pattern) so every connected daemon auto-upgrades at the next handshake —
|
|
84
|
+
this release's hook-driven status detection and archive-kills-live
|
|
85
|
+
behaviour live daemon-side, and a 9.x daemon would leave sessions stuck
|
|
86
|
+
green. Rolls up the unreleased 9.3/9.4 additions (`POST /agent-signal`,
|
|
87
|
+
archive accepting live sessions).
|
|
88
|
+
|
|
89
|
+
- Archiving is one gesture for any session: the ⋯/right-click menu offers
|
|
90
|
+
Archive on live agents and terminals too — the daemon kills the session as
|
|
91
|
+
part of archiving (still a reversible hide; unarchive brings it back
|
|
92
|
+
resumable), so there is no kill-first dance and no confirmation dialog.
|
|
93
|
+
Protocol 9.3.
|
|
94
|
+
- Kill lost its confirmation dialog too: it only stops the agent process (the
|
|
95
|
+
conversation stays resumable), so the menu action now fires immediately.
|
package/README.md
CHANGED
|
@@ -47,6 +47,18 @@ Daemon-only installs (no CLI) use the `install.sh` attached to each release —
|
|
|
47
47
|
curl -fsSL https://github.com/PerceptronV/puddle-code/releases/latest/download/install.sh | sh
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
**Desktop app (optional):**
|
|
51
|
+
|
|
52
|
+
The same cockpit also ships as a standalone desktop app — identical UI and engine, plus a File → "Connect to SSH Host…" menu for remote hosts. Grab the dmg (macOS arm64) or AppImage (Linux x64) from the Releases page.
|
|
53
|
+
|
|
54
|
+
The macOS downloads are **not code-signed** (an open-source project without Apple Developer Program fees), so Gatekeeper will refuse the first launch. Either allow it once — open the app, let macOS block it, then System Settings → Privacy & Security → **Open Anyway** — or clear the download quarantine in a terminal:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
xattr -dr com.apple.quarantine /Applications/Puddle.app
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Building from source avoids the dance entirely (locally built apps are never quarantined): `pnpm build && pnpm --filter @puddle/desktop dist`.
|
|
61
|
+
|
|
50
62
|
**Host requirements**: Linux (glibc — Ubuntu 22.04+, Debian 12+, RHEL 9+; Alpine is not supported) or macOS, with `git` and `curl`, plus whichever agent CLIs you want on `PATH`. The client side works from any OS with a browser and `ssh` (Windows works, with repeated auth prompts unless you use a key).
|
|
51
63
|
|
|
52
64
|
## How it works
|
package/dist/index.js
CHANGED
|
@@ -4148,7 +4148,7 @@ function argvFor(command) {
|
|
|
4148
4148
|
// src/cli/run.ts
|
|
4149
4149
|
init_attach();
|
|
4150
4150
|
import { existsSync as existsSync3 } from "node:fs";
|
|
4151
|
-
import { dirname as
|
|
4151
|
+
import { dirname as dirname6, join as join8 } from "node:path";
|
|
4152
4152
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
4153
4153
|
|
|
4154
4154
|
// src/lib/browser.ts
|
|
@@ -4166,8 +4166,11 @@ function openBrowser(url2, platform = process.platform) {
|
|
|
4166
4166
|
}
|
|
4167
4167
|
}
|
|
4168
4168
|
|
|
4169
|
+
// src/lib/connect.ts
|
|
4170
|
+
import { join as join5 } from "node:path";
|
|
4171
|
+
|
|
4169
4172
|
// ../shared/src/protocol.ts
|
|
4170
|
-
var PROTOCOL_VERSION = { major:
|
|
4173
|
+
var PROTOCOL_VERSION = { major: 10, minor: 1 };
|
|
4171
4174
|
|
|
4172
4175
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
4173
4176
|
var external_exports = {};
|
|
@@ -18705,6 +18708,12 @@ var versionResponseSchema = external_exports.object({
|
|
|
18705
18708
|
})
|
|
18706
18709
|
});
|
|
18707
18710
|
|
|
18711
|
+
// ../shared/src/api/agent-signal.ts
|
|
18712
|
+
var agentSignalRequestSchema = external_exports.object({
|
|
18713
|
+
nonce: external_exports.string().min(16),
|
|
18714
|
+
state: external_exports.enum(["working", "waiting_input"])
|
|
18715
|
+
});
|
|
18716
|
+
|
|
18708
18717
|
// ../shared/src/api/config.ts
|
|
18709
18718
|
var fields = {
|
|
18710
18719
|
port: external_exports.number().int().min(1).max(65535),
|
|
@@ -18720,7 +18729,13 @@ var fields = {
|
|
|
18720
18729
|
* expands to the daemon user's home. Covers Claude Code's native-installer
|
|
18721
18730
|
* location (`~/.local/bin`). Takes effect on the next daemon start.
|
|
18722
18731
|
*/
|
|
18723
|
-
agentPath: external_exports.string()
|
|
18732
|
+
agentPath: external_exports.string(),
|
|
18733
|
+
/**
|
|
18734
|
+
* User-chosen label for this host, shown across the UI in place of the OS
|
|
18735
|
+
* hostname when non-empty (surfaced via GET /api/host as `displayName`).
|
|
18736
|
+
* Purely cosmetic — never used for ssh commands or anything transport-level.
|
|
18737
|
+
*/
|
|
18738
|
+
displayName: external_exports.string().max(64)
|
|
18724
18739
|
};
|
|
18725
18740
|
var daemonConfigSchema = external_exports.object({
|
|
18726
18741
|
port: fields.port.default(7434),
|
|
@@ -18729,7 +18744,8 @@ var daemonConfigSchema = external_exports.object({
|
|
|
18729
18744
|
logMaxBytes: fields.logMaxBytes.default(10 * 1024 * 1024),
|
|
18730
18745
|
replayBytes: fields.replayBytes.default(256 * 1024),
|
|
18731
18746
|
uiStateRetentionDays: fields.uiStateRetentionDays.default(90),
|
|
18732
|
-
agentPath: fields.agentPath.default("~/.local/bin:~/bin:/opt/homebrew/bin:/usr/local/bin")
|
|
18747
|
+
agentPath: fields.agentPath.default("~/.local/bin:~/bin:/opt/homebrew/bin:/usr/local/bin"),
|
|
18748
|
+
displayName: fields.displayName.default("")
|
|
18733
18749
|
});
|
|
18734
18750
|
var daemonConfigPatchSchema = external_exports.object(fields).partial();
|
|
18735
18751
|
|
|
@@ -18748,7 +18764,13 @@ var hostInfoSchema = external_exports.object({
|
|
|
18748
18764
|
username: external_exports.string(),
|
|
18749
18765
|
hostname: external_exports.string(),
|
|
18750
18766
|
/** The daemon user's home directory, for ~-compressing displayed paths. */
|
|
18751
|
-
home: external_exports.string()
|
|
18767
|
+
home: external_exports.string(),
|
|
18768
|
+
/**
|
|
18769
|
+
* The user-chosen host label (config.json `displayName`), present when
|
|
18770
|
+
* non-empty. Display-only: the UI shows it wherever the host is named, but
|
|
18771
|
+
* ssh commands always use the real `hostname`.
|
|
18772
|
+
*/
|
|
18773
|
+
displayName: external_exports.string().optional()
|
|
18752
18774
|
});
|
|
18753
18775
|
|
|
18754
18776
|
// ../shared/src/api/profiles.ts
|
|
@@ -19029,6 +19051,14 @@ var sessionSchema = external_exports.object({
|
|
|
19029
19051
|
last_activity_at: isoTimestamp.nullable(),
|
|
19030
19052
|
/** Computed on read: the worktree dir is gone; the session can only be archived. */
|
|
19031
19053
|
worktree_missing: external_exports.boolean().optional(),
|
|
19054
|
+
/**
|
|
19055
|
+
* Computed on read: the session says `running` but the agent's own
|
|
19056
|
+
* transcript has been quiet for over an hour — the agent process is likely
|
|
19057
|
+
* wedged (SPEC §4). Advisory only: the daemon never interrupts an agent on
|
|
19058
|
+
* the strength of it (a very long tool call looks identical), it just lets
|
|
19059
|
+
* the UI say "this may be stalled". Optional: older daemons omit it.
|
|
19060
|
+
*/
|
|
19061
|
+
stale_running: external_exports.boolean().optional(),
|
|
19032
19062
|
/**
|
|
19033
19063
|
* Ahead/behind counts vs. the base branch plus a dirty-file count. Optional:
|
|
19034
19064
|
* older daemons omit it, and it is computed only on the single-session GET
|
|
@@ -19228,11 +19258,13 @@ var uiStateSnapshotSchema = external_exports.looseObject({
|
|
|
19228
19258
|
/** Whether the right sessions sidebar is collapsed to a slim rail. */
|
|
19229
19259
|
sessions_collapsed: external_exports.boolean().default(false),
|
|
19230
19260
|
/**
|
|
19231
|
-
*
|
|
19232
|
-
*
|
|
19233
|
-
*
|
|
19261
|
+
* RETIRED (the Scratchpad moved to a top-bar popover — SPEC §11): nothing
|
|
19262
|
+
* reads or writes this any more. The key stays in the schema, optional and
|
|
19263
|
+
* defaultless, so snapshots from older clients round-trip byte-faithfully
|
|
19264
|
+
* without a major protocol bump (the old default-injection made every PUT
|
|
19265
|
+
* grow the field, which nothing wanted).
|
|
19234
19266
|
*/
|
|
19235
|
-
right_panel: external_exports.enum(["sessions", "scratchpad"]).
|
|
19267
|
+
right_panel: external_exports.enum(["sessions", "scratchpad"]).optional(),
|
|
19236
19268
|
/**
|
|
19237
19269
|
* User-chosen order of the sessions sidebar (session ids). Sessions not
|
|
19238
19270
|
* listed here (newly created ones) sort to the top; the list is otherwise
|
|
@@ -19629,7 +19661,7 @@ import { readFileSync } from "node:fs";
|
|
|
19629
19661
|
import { dirname, join as join2 } from "node:path";
|
|
19630
19662
|
import { fileURLToPath } from "node:url";
|
|
19631
19663
|
function cliVersion() {
|
|
19632
|
-
if (true) return "0.0.
|
|
19664
|
+
if (true) return "0.0.12";
|
|
19633
19665
|
const here = dirname(fileURLToPath(import.meta.url));
|
|
19634
19666
|
for (const candidate of [
|
|
19635
19667
|
join2(here, "..", "..", "package.json"),
|
|
@@ -19882,6 +19914,77 @@ function isLocalOrigin(origin) {
|
|
|
19882
19914
|
}
|
|
19883
19915
|
}
|
|
19884
19916
|
|
|
19917
|
+
// src/lib/serve/local-sync.ts
|
|
19918
|
+
import { mkdirSync, readFileSync as readFileSync3, renameSync, writeFileSync } from "node:fs";
|
|
19919
|
+
import { dirname as dirname3 } from "node:path";
|
|
19920
|
+
var MAX_BODY_BYTES = 5 * 1024 * 1024;
|
|
19921
|
+
function readStore(file2) {
|
|
19922
|
+
try {
|
|
19923
|
+
const raw = JSON.parse(readFileSync3(file2, "utf8"));
|
|
19924
|
+
if (raw && typeof raw === "object" && raw.profiles && typeof raw.profiles === "object") {
|
|
19925
|
+
return { version: 1, profiles: raw.profiles };
|
|
19926
|
+
}
|
|
19927
|
+
} catch {
|
|
19928
|
+
}
|
|
19929
|
+
return { version: 1, profiles: {} };
|
|
19930
|
+
}
|
|
19931
|
+
function writeStore(file2, store) {
|
|
19932
|
+
mkdirSync(dirname3(file2), { recursive: true });
|
|
19933
|
+
const tmp = `${file2}.tmp-${process.pid}`;
|
|
19934
|
+
writeFileSync(tmp, JSON.stringify(store, null, 2) + "\n");
|
|
19935
|
+
renameSync(tmp, file2);
|
|
19936
|
+
}
|
|
19937
|
+
function readBody(req) {
|
|
19938
|
+
return new Promise((resolve3, reject) => {
|
|
19939
|
+
let size = 0;
|
|
19940
|
+
const chunks = [];
|
|
19941
|
+
req.on("data", (chunk) => {
|
|
19942
|
+
size += chunk.length;
|
|
19943
|
+
if (size > MAX_BODY_BYTES) {
|
|
19944
|
+
reject(new Error("body_too_large"));
|
|
19945
|
+
req.destroy();
|
|
19946
|
+
return;
|
|
19947
|
+
}
|
|
19948
|
+
chunks.push(chunk);
|
|
19949
|
+
});
|
|
19950
|
+
req.on("end", () => resolve3(Buffer.concat(chunks).toString("utf8")));
|
|
19951
|
+
req.on("error", reject);
|
|
19952
|
+
});
|
|
19953
|
+
}
|
|
19954
|
+
function handleLocalSync(req, res, opts) {
|
|
19955
|
+
const send = (status, body) => {
|
|
19956
|
+
res.writeHead(status, { "content-type": "application/json", "cache-control": "no-store" });
|
|
19957
|
+
res.end(JSON.stringify(body));
|
|
19958
|
+
};
|
|
19959
|
+
const fail = (status, code, message) => send(status, { error: { code, message } });
|
|
19960
|
+
if (!isLocalHostHeader(req.headers.host) || !isLocalOrigin(req.headers.origin)) {
|
|
19961
|
+
return fail(403, "forbidden_host", "requests must address localhost");
|
|
19962
|
+
}
|
|
19963
|
+
if (opts === void 0) {
|
|
19964
|
+
return fail(404, "local_sync_unavailable", "this cockpit has no local sync store");
|
|
19965
|
+
}
|
|
19966
|
+
if (req.headers.authorization !== `Bearer ${opts.token}`) {
|
|
19967
|
+
return fail(401, "unauthorised", "missing or invalid token");
|
|
19968
|
+
}
|
|
19969
|
+
if (req.method === "GET") return send(200, readStore(opts.file));
|
|
19970
|
+
if (req.method === "PUT") {
|
|
19971
|
+
void readBody(req).then((text) => {
|
|
19972
|
+
const body = JSON.parse(text);
|
|
19973
|
+
if (typeof body.profile !== "string" || body.profile === "" || body.entry === void 0) {
|
|
19974
|
+
return fail(400, "bad_request", "expected { profile: string, entry: object }");
|
|
19975
|
+
}
|
|
19976
|
+
const store = readStore(opts.file);
|
|
19977
|
+
store.profiles[body.profile] = body.entry;
|
|
19978
|
+
writeStore(opts.file, store);
|
|
19979
|
+
return send(200, store);
|
|
19980
|
+
}).catch(
|
|
19981
|
+
(e) => e instanceof Error && e.message === "body_too_large" ? fail(413, "body_too_large", "sync entry exceeds the size cap") : fail(400, "bad_request", "body must be JSON")
|
|
19982
|
+
);
|
|
19983
|
+
return;
|
|
19984
|
+
}
|
|
19985
|
+
return fail(405, "method_not_allowed", "use GET or PUT");
|
|
19986
|
+
}
|
|
19987
|
+
|
|
19885
19988
|
// src/lib/serve/proxy-recovery.ts
|
|
19886
19989
|
var PROXY_PAGE = /^\/proxy\/([^/]+)\/(\d+)(?:\/|$)/;
|
|
19887
19990
|
function recoverProxiedPath(referer, requestUrl) {
|
|
@@ -20113,6 +20216,10 @@ async function startUiServer(opts) {
|
|
|
20113
20216
|
handleRefresh(req, res, opts.control);
|
|
20114
20217
|
return;
|
|
20115
20218
|
}
|
|
20219
|
+
if ((url2.split("?")[0] ?? "") === "/cockpit/local-sync") {
|
|
20220
|
+
handleLocalSync(req, res, opts.localSync);
|
|
20221
|
+
return;
|
|
20222
|
+
}
|
|
20116
20223
|
if (isProxiedPath(url2)) {
|
|
20117
20224
|
if (!isLocalHostHeader(req.headers.host) || !isLocalOrigin(req.headers.origin)) {
|
|
20118
20225
|
res.writeHead(403, { "content-type": "application/json" });
|
|
@@ -20359,8 +20466,8 @@ async function openTunnel(ssh, remotePort, opts = {}) {
|
|
|
20359
20466
|
|
|
20360
20467
|
// src/lib/transport/local.ts
|
|
20361
20468
|
import { spawn as spawn3 } from "node:child_process";
|
|
20362
|
-
import { copyFileSync, mkdirSync, readFileSync as
|
|
20363
|
-
import { dirname as
|
|
20469
|
+
import { copyFileSync, mkdirSync as mkdirSync2, readFileSync as readFileSync4 } from "node:fs";
|
|
20470
|
+
import { dirname as dirname4 } from "node:path";
|
|
20364
20471
|
var LocalTransport = class {
|
|
20365
20472
|
kind = "local";
|
|
20366
20473
|
label = "this machine";
|
|
@@ -20394,14 +20501,14 @@ var LocalTransport = class {
|
|
|
20394
20501
|
}
|
|
20395
20502
|
readFile(path) {
|
|
20396
20503
|
try {
|
|
20397
|
-
return Promise.resolve(
|
|
20504
|
+
return Promise.resolve(readFileSync4(expandHome(path), "utf8"));
|
|
20398
20505
|
} catch {
|
|
20399
20506
|
return Promise.resolve(null);
|
|
20400
20507
|
}
|
|
20401
20508
|
}
|
|
20402
20509
|
copyTo(localPath, destPath) {
|
|
20403
20510
|
const dest = expandHome(destPath);
|
|
20404
|
-
|
|
20511
|
+
mkdirSync2(dirname4(dest), { recursive: true });
|
|
20405
20512
|
copyFileSync(localPath, dest);
|
|
20406
20513
|
return Promise.resolve();
|
|
20407
20514
|
}
|
|
@@ -20414,7 +20521,7 @@ function expandHome(path) {
|
|
|
20414
20521
|
|
|
20415
20522
|
// src/lib/transport/ssh.ts
|
|
20416
20523
|
import { spawn as spawn4 } from "node:child_process";
|
|
20417
|
-
import { mkdirSync as
|
|
20524
|
+
import { mkdirSync as mkdirSync3 } from "node:fs";
|
|
20418
20525
|
init_types();
|
|
20419
20526
|
var SshTransport = class {
|
|
20420
20527
|
constructor(host, opts = {}) {
|
|
@@ -20427,7 +20534,7 @@ var SshTransport = class {
|
|
|
20427
20534
|
this.controlArgs = [];
|
|
20428
20535
|
} else {
|
|
20429
20536
|
const home = clientHome();
|
|
20430
|
-
|
|
20537
|
+
mkdirSync3(home, { recursive: true });
|
|
20431
20538
|
this.controlArgs = [
|
|
20432
20539
|
"-o",
|
|
20433
20540
|
"ControlMaster=auto",
|
|
@@ -20601,7 +20708,10 @@ async function connectRemote(opts) {
|
|
|
20601
20708
|
// a preferred port stays non-strict
|
|
20602
20709
|
avoidPort,
|
|
20603
20710
|
target: { host: "127.0.0.1", port: tunnel.localPort },
|
|
20604
|
-
...opts.onRefreshRequest !== void 0 ? { control: { token: endpoint.token, onRefresh: opts.onRefreshRequest } } : {}
|
|
20711
|
+
...opts.onRefreshRequest !== void 0 ? { control: { token: endpoint.token, onRefresh: opts.onRefreshRequest } } : {},
|
|
20712
|
+
// The store lives on the CLIENT machine — every cockpit here shares it,
|
|
20713
|
+
// whichever remote daemon each one drives.
|
|
20714
|
+
localSync: { token: endpoint.token, file: join5(clientHome(), "local-sync.json") }
|
|
20605
20715
|
});
|
|
20606
20716
|
tunnel.onPortChange((port) => ui.setTarget({ host: "127.0.0.1", port }));
|
|
20607
20717
|
const eventCbs = /* @__PURE__ */ new Set();
|
|
@@ -20651,29 +20761,29 @@ async function showLogs(transport, opts) {
|
|
|
20651
20761
|
}
|
|
20652
20762
|
|
|
20653
20763
|
// src/lib/registry.ts
|
|
20654
|
-
import { mkdirSync as
|
|
20655
|
-
import { join as
|
|
20764
|
+
import { mkdirSync as mkdirSync4, readdirSync, readFileSync as readFileSync5, rmSync, writeFileSync as writeFileSync2 } from "node:fs";
|
|
20765
|
+
import { join as join6 } from "node:path";
|
|
20656
20766
|
function cockpitsDir(env) {
|
|
20657
|
-
return
|
|
20767
|
+
return join6(clientHome(env), "cockpits");
|
|
20658
20768
|
}
|
|
20659
20769
|
function slug(target) {
|
|
20660
20770
|
return target.replace(/[^A-Za-z0-9@._-]/g, "_");
|
|
20661
20771
|
}
|
|
20662
20772
|
function cockpitRecordPath(target) {
|
|
20663
|
-
return
|
|
20773
|
+
return join6(cockpitsDir(), `${slug(target)}.json`);
|
|
20664
20774
|
}
|
|
20665
20775
|
function cockpitLogPath(target) {
|
|
20666
|
-
return
|
|
20776
|
+
return join6(clientHome(), "logs", `cockpit-${slug(target)}.log`);
|
|
20667
20777
|
}
|
|
20668
20778
|
function writeCockpitRecord(record2) {
|
|
20669
|
-
|
|
20670
|
-
|
|
20779
|
+
mkdirSync4(cockpitsDir(), { recursive: true, mode: 448 });
|
|
20780
|
+
writeFileSync2(cockpitRecordPath(record2.target), JSON.stringify(record2, null, 2) + "\n", {
|
|
20671
20781
|
mode: 384
|
|
20672
20782
|
});
|
|
20673
20783
|
}
|
|
20674
20784
|
function readCockpitRecord(target) {
|
|
20675
20785
|
try {
|
|
20676
|
-
return JSON.parse(
|
|
20786
|
+
return JSON.parse(readFileSync5(cockpitRecordPath(target), "utf8"));
|
|
20677
20787
|
} catch {
|
|
20678
20788
|
return null;
|
|
20679
20789
|
}
|
|
@@ -20692,7 +20802,7 @@ function listCockpitRecords() {
|
|
|
20692
20802
|
for (const name of names) {
|
|
20693
20803
|
if (!name.endsWith(".json")) continue;
|
|
20694
20804
|
try {
|
|
20695
|
-
records.push(JSON.parse(
|
|
20805
|
+
records.push(JSON.parse(readFileSync5(join6(cockpitsDir(), name), "utf8")));
|
|
20696
20806
|
} catch {
|
|
20697
20807
|
}
|
|
20698
20808
|
}
|
|
@@ -20724,6 +20834,7 @@ async function checkCockpit(record2) {
|
|
|
20724
20834
|
}
|
|
20725
20835
|
|
|
20726
20836
|
// src/lib/start.ts
|
|
20837
|
+
import { join as join7 } from "node:path";
|
|
20727
20838
|
init_types();
|
|
20728
20839
|
async function startLocal(opts) {
|
|
20729
20840
|
const logger = opts.logger ?? silentLogger;
|
|
@@ -20745,7 +20856,8 @@ async function startLocal(opts) {
|
|
|
20745
20856
|
avoidPort: endpoint.port,
|
|
20746
20857
|
// never squat the daemon's own port
|
|
20747
20858
|
target: { host: "127.0.0.1", port: endpoint.port },
|
|
20748
|
-
...opts.onRefreshRequest !== void 0 ? { control: { token: endpoint.token, onRefresh: opts.onRefreshRequest } } : {}
|
|
20859
|
+
...opts.onRefreshRequest !== void 0 ? { control: { token: endpoint.token, onRefresh: opts.onRefreshRequest } } : {},
|
|
20860
|
+
localSync: { token: endpoint.token, file: join7(clientHome(), "local-sync.json") }
|
|
20749
20861
|
});
|
|
20750
20862
|
const eventCbs = /* @__PURE__ */ new Set();
|
|
20751
20863
|
return {
|
|
@@ -20808,8 +20920,8 @@ async function upgradeDaemon(transport, opts = {}) {
|
|
|
20808
20920
|
|
|
20809
20921
|
// src/cli/detach.ts
|
|
20810
20922
|
import { spawn as spawn5 } from "node:child_process";
|
|
20811
|
-
import { closeSync, mkdirSync as
|
|
20812
|
-
import { dirname as
|
|
20923
|
+
import { closeSync, mkdirSync as mkdirSync5, openSync, readFileSync as readFileSync6 } from "node:fs";
|
|
20924
|
+
import { dirname as dirname5 } from "node:path";
|
|
20813
20925
|
init_types();
|
|
20814
20926
|
var COCKPIT_CHILD_ENV = "PUDDLE_COCKPIT_CHILD";
|
|
20815
20927
|
var READY_TIMEOUT_MS = 3e5;
|
|
@@ -20850,7 +20962,7 @@ async function launchDetached(opts) {
|
|
|
20850
20962
|
}
|
|
20851
20963
|
if (target !== "local") await new SshTransport(target).open();
|
|
20852
20964
|
const logFile = cockpitLogPath(target);
|
|
20853
|
-
|
|
20965
|
+
mkdirSync5(dirname5(logFile), { recursive: true });
|
|
20854
20966
|
const fd = openSync(logFile, "w");
|
|
20855
20967
|
const argv = opts.argv ?? process.argv.slice(2);
|
|
20856
20968
|
const child = spawn5(process.execPath, [process.argv[1] ?? "", ...argv], {
|
|
@@ -20890,7 +21002,7 @@ async function followStartup(target, childPid, logFile) {
|
|
|
20890
21002
|
let offset = 0;
|
|
20891
21003
|
const relay = () => {
|
|
20892
21004
|
try {
|
|
20893
|
-
const buf =
|
|
21005
|
+
const buf = readFileSync6(logFile);
|
|
20894
21006
|
if (buf.length > offset) {
|
|
20895
21007
|
process.stderr.write(buf.subarray(offset));
|
|
20896
21008
|
offset = buf.length;
|
|
@@ -20915,7 +21027,7 @@ async function followStartup(target, childPid, logFile) {
|
|
|
20915
21027
|
}
|
|
20916
21028
|
function spawnDetachedRefresh(target, argv) {
|
|
20917
21029
|
const logFile = cockpitLogPath(target);
|
|
20918
|
-
|
|
21030
|
+
mkdirSync5(dirname5(logFile), { recursive: true });
|
|
20919
21031
|
const fd = openSync(logFile, "a");
|
|
20920
21032
|
const env = { ...process.env };
|
|
20921
21033
|
delete env[COCKPIT_CHILD_ENV];
|
|
@@ -20972,9 +21084,9 @@ function timestampedLogger() {
|
|
|
20972
21084
|
|
|
20973
21085
|
// src/cli/run.ts
|
|
20974
21086
|
function assetsDir() {
|
|
20975
|
-
const here =
|
|
20976
|
-
for (const candidate of [
|
|
20977
|
-
if (existsSync3(
|
|
21087
|
+
const here = dirname6(fileURLToPath3(import.meta.url));
|
|
21088
|
+
for (const candidate of [join8(here, "public"), join8(here, "..", "..", "dist", "public")]) {
|
|
21089
|
+
if (existsSync3(join8(candidate, "index.html"))) return candidate;
|
|
20978
21090
|
}
|
|
20979
21091
|
throw new CliError(
|
|
20980
21092
|
"not_installed",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{a as r,x as i}from"./api-Bh5IJ30S.js";import{a,g as o,i as s,n as c,o as l,t as u}from"./dialog-B43iKmfK.js";import{$ as d,B as f,I as p,J as m,L as h,U as g,nt as _,o as v,s as y,t as b,tt as x}from"./LazyTerminal-BihPI9J1.js";import{t as S}from"./utils-B6KiDbIe.js";import{A as C,O as w,c as T,j as E,k as D,n as O,r as k,t as A}from"./context-menu-DyvGbiNT.js";import{i as j,r as M}from"./dist-VDiYuPKw.js";import{M as N,P,W as F,X as I,ct as L}from"./index-DIgA5eoW.js";var R=e(t(),1),z=n(),B=!1;function V(){let[e,t]=(0,R.useState)(B),[n,i]=(0,R.useState)(null);(0,R.useEffect)(()=>{if(!e)return;let t=!1;return P.spawnShell(r).then(e=>{t||i(e)}),()=>{t=!0}},[e]);let a=()=>{B=!1,t(!1),i(null)};return{open:e,term:n,toggle:()=>{e?(n&&P.killShell(r,n),a()):(B=!0,t(!0))},onExit:a}}function H({term:e,onExit:t}){return(0,z.jsx)(`div`,{className:`h-72 shrink-0 pb-6`,children:(0,z.jsx)(`div`,{className:`mx-auto size-full max-w-4xl px-6`,children:e!==null&&(0,z.jsx)(b,{stream:`home`,term:e,onExit:t})})})}var U=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function W({projectId:e}){let t=d(e),n=(0,R.useMemo)(()=>{let e=new Map;for(let n of t.data??[])e.set(n.status,(e.get(n.status)??0)+1);return e},[t.data]),r=(t.data??[]).filter(e=>e.status!==`archived`).length;return(0,z.jsxs)(`div`,{className:`flex items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,z.jsxs)(`span`,{children:[r,` session`,r===1?``:`s`]}),U.map(({status:e,colour:t})=>{let r=n.get(e)??0;return r===0?null:(0,z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),r,` `,e.replace(`_`,` `)]},e)})]})}function G({icon:e,label:t,onClick:n}){return(0,z.jsx)(`button`,{type:`button`,"aria-label":t,title:t,onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},className:`flex items-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-ground hover:text-fg`,children:(0,z.jsx)(e,{className:`size-4`})})}function K({project:e,repoPath:t,draggable:n,dragging:r,onDragStart:d,onDragEnd:f,onDragOver:p}){let m=h(),[g,v]=(0,R.useState)(!1),[b,w]=(0,R.useState)(e.name),D=t=>m.mutate({id:e.id,archived:t},{onError:e=>i.error(e.message)}),j=()=>{let t=b.trim();if(!t||t===e.name){v(!1);return}m.mutate({id:e.id,name:t},{onSuccess:()=>v(!1),onError:e=>i.error(e.message)})};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(A,{children:[(0,z.jsx)(T,{asChild:!0,children:(0,z.jsxs)(`div`,{draggable:n,onDragStart:d,onDragEnd:f,onDragOver:p,className:S(`group relative transition-opacity`,r&&`opacity-50`),children:[(0,z.jsxs)(L,{draggable:!1,to:`/project/${e.id}`,className:`block rounded-lg bg-surface p-4 transition-colors hover:bg-elevated`,children:[(0,z.jsx)(`h2`,{className:`truncate pr-16 text-base font-semibold text-fg group-hover:text-accent`,children:e.name}),(0,z.jsx)(`p`,{className:`mt-1 truncate font-mono text-2xs text-fg-muted`,children:t??`…`}),(0,z.jsx)(`div`,{className:`mt-3`,children:(0,z.jsx)(W,{projectId:e.id})})]}),(0,z.jsx)(`div`,{className:`absolute right-2 top-2 hidden gap-0.5 group-hover:flex has-[[data-state=open]]:flex`,children:e.archived?(0,z.jsx)(G,{icon:E,label:`Reopen project`,onClick:()=>D(!1)}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(G,{icon:y,label:`Rename project`,onClick:()=>{w(e.name),v(!0)}}),(0,z.jsx)(G,{icon:C,label:`Archive project`,onClick:()=>D(!0)})]})})]})}),(0,z.jsx)(O,{children:e.archived?(0,z.jsxs)(k,{onSelect:()=>D(!1),children:[(0,z.jsx)(E,{}),` Reopen`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(k,{onSelect:()=>{w(e.name),v(!0)},children:[(0,z.jsx)(y,{}),` Rename`]}),(0,z.jsxs)(k,{onSelect:()=>D(!0),children:[(0,z.jsx)(C,{}),` Archive`]})]})})]}),(0,z.jsx)(u,{open:g,onOpenChange:v,children:(0,z.jsxs)(c,{children:[(0,z.jsx)(a,{children:(0,z.jsx)(l,{children:`Rename project`})}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),j()},children:[(0,z.jsx)(_,{value:b,onChange:e=>w(e.target.value),autoFocus:!0}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsx)(x,{className:`text-fg-muted`,children:`Path`}),(0,z.jsx)(`p`,{className:`truncate font-mono text-2xs text-fg-muted`,children:t??`…`})]}),(0,z.jsxs)(s,{children:[(0,z.jsx)(o,{type:`button`,variant:`ghost`,onClick:()=>v(!1),children:`Cancel`}),(0,z.jsx)(o,{type:`submit`,disabled:!b.trim()||m.isPending,children:`Rename`})]})]})]})})]})}function q({icon:e,label:t,hint:n,onClick:r}){return(0,z.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex flex-col rounded-lg bg-surface p-4 text-left transition-colors hover:bg-elevated`,children:[(0,z.jsxs)(`h2`,{className:`flex items-center gap-2 truncate text-base font-semibold text-fg group-hover:text-accent`,children:[(0,z.jsx)(e,{className:`size-4 shrink-0`}),t]}),(0,z.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:n})]})}function J(){let e=v(),t=g(e??void 0),n=m(),r=f(e??void 0),i=p(e??``),[a,o]=(0,R.useState)(!1),[s,c]=(0,R.useState)(null),[l,u]=(0,R.useState)(!1),d=V(),h=e=>n.data?.find(t=>t.id===e)?.path,_=t.data??[],y=r.data?.projectOrder??[],b=w(_.filter(e=>!e.archived),y),x=_.filter(e=>e.archived),T=(e,t)=>{e!==t&&i.mutate({projectOrder:D(b.map(e=>e.id),e,t)})};return(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,z.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[_.length===0&&(0,z.jsxs)(`div`,{className:`mb-8 mt-16 flex flex-col items-center gap-3 text-center`,children:[(0,z.jsx)(M,{className:`size-8 text-fg-muted`}),(0,z.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`No projects yet — open one below, or press ⌘K.`})]}),(0,z.jsxs)(`div`,{className:`grid auto-rows-fr grid-cols-1 gap-3 sm:grid-cols-2`,children:[b.map(e=>(0,z.jsx)(K,{project:e,repoPath:h(e.repo_id),draggable:!0,dragging:s===e.id,onDragStart:()=>c(e.id),onDragEnd:()=>c(null),onDragOver:t=>{t.preventDefault(),s&&s!==e.id&&T(s,e.id)}},e.id)),(0,z.jsx)(q,{icon:I,label:`Open project`,hint:`Point at a repository on this host`,onClick:()=>o(!0)}),(0,z.jsx)(q,{icon:F,label:d.open?`Close terminal`:`Open terminal`,hint:d.open?`End the shell below`:`A shell at ~ for cloning repositories`,onClick:d.toggle})]}),x.length>0&&(0,z.jsxs)(`div`,{className:`mt-6`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),className:`flex items-center gap-1.5 px-1 py-1.5 text-2xs uppercase tracking-wide text-fg-muted transition-colors hover:text-fg`,children:[(0,z.jsx)(j,{className:S(`size-3 transition-transform`,l&&`rotate-90`)}),(0,z.jsx)(C,{className:`size-3`}),(0,z.jsx)(`span`,{children:`Archived`}),(0,z.jsx)(`span`,{className:`tabular-nums`,children:x.length})]}),l&&(0,z.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:x.map(e=>(0,z.jsx)(K,{project:e,repoPath:h(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]})]})}),d.open&&(0,z.jsx)(H,{term:d.term,onExit:d.onExit}),e!==null&&(0,z.jsx)(N,{profileId:e,open:a,onOpenChange:o})]})}export{J as Dashboard};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{a as r,g as i,h as a,i as o,n as s,o as c,r as l,t as u}from"./dialog-B43iKmfK.js";import{t as d}from"./createLucideIcon-DyMAgLa3.js";import{l as f,r as p,t as m}from"./buffer-store-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{a as r,g as i,h as a,i as o,n as s,o as c,r as l,t as u}from"./dialog-B43iKmfK.js";import{t as d}from"./createLucideIcon-DyMAgLa3.js";import{l as f,r as p,t as m}from"./buffer-store-mErJ-u_7.js";import{s as h,t as g}from"./editor-sync-F3Wyveaa.js";var _=d(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),v=e(t(),1),y=n();function b(e,t){let n=m(e,t);return(0,v.useSyncExternalStore)((0,v.useCallback)(e=>f(n,e),[n]),()=>p(n))}function x({session:e,path:t,kind:n,label:d,onClose:f}){let p=b(e,t)&&n!==`commit`,[m,x]=(0,v.useState)(!1),S=()=>p?x(!0):f();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{onClick:e=>{e.stopPropagation(),S()},className:`flex size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg`,"aria-label":`Close ${d}`,children:p?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(_,{className:`size-2 fill-current group-hover:hidden`}),(0,y.jsx)(a,{className:`hidden size-3 group-hover:block`})]}):(0,y.jsx)(a,{className:`size-3 opacity-0 group-hover:opacity-100`})}),(0,y.jsx)(u,{open:m,onOpenChange:e=>!e&&x(!1),children:(0,y.jsxs)(s,{children:[(0,y.jsxs)(r,{children:[(0,y.jsxs)(c,{children:[`Discard changes to `,d,`?`]}),(0,y.jsx)(l,{children:`This file has unsaved changes. Closing the tab will discard them.`})]}),(0,y.jsxs)(o,{children:[(0,y.jsx)(i,{variant:`ghost`,onClick:()=>x(!1),children:`Keep editing`}),(0,y.jsx)(i,{variant:`danger`,onClick:()=>{h(e,t),g(e,t),x(!1),f()},children:`Discard`})]})]})})]})}export{x as EditorTabClose};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-Ci3-2jXt.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/api-Bh5IJ30S.js","assets/utils-B6KiDbIe.js","assets/index-DIgA5eoW.js","assets/poll-focus-B7dQPFj6.js","assets/preload-helper-Czpn1I53.js","assets/dialog-B43iKmfK.js","assets/createLucideIcon-DyMAgLa3.js","assets/index-WMJ9gBck.css","assets/ssh-mode-BuFhqbL1.js","assets/Terminal-BrP-ENHg.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,t as r}from"./jsx-runtime-ffCh33zF.js";import{n as i,o as a,r as o,t as s}from"./poll-focus-B7dQPFj6.js";import{t as c}from"./preload-helper-Czpn1I53.js";import{n as l,y as u}from"./api-Bh5IJ30S.js";import{A as d,C as f,O as p,w as m,x as h}from"./dialog-B43iKmfK.js";import{t as g}from"./utils-B6KiDbIe.js";import{t as _}from"./createLucideIcon-DyMAgLa3.js";var v=e(t(),1),y=[`top`,`right`,`bottom`,`left`],b=Math.min,x=Math.max,S=Math.round,C=Math.floor,w=e=>({x:e,y:e}),T={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function E(e,t,n){return x(e,b(t,n))}function D(e,t){return typeof e==`function`?e(t):e}function O(e){return e.split(`-`)[0]}function k(e){return e.split(`-`)[1]}function A(e){return e===`x`?`y`:`x`}function j(e){return e===`y`?`height`:`width`}function M(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function N(e){return A(M(e))}function P(e,t,n){n===void 0&&(n=!1);let r=k(e),i=N(e),a=j(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=B(o)),[o,B(o)]}function F(e){let t=B(e);return[I(e),t,I(t)]}function I(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var L=[`left`,`right`],R=[`right`,`left`],z=[`top`,`bottom`],ee=[`bottom`,`top`];function te(e,t,n){switch(e){case`top`:case`bottom`:return n?t?R:L:t?L:R;case`left`:case`right`:return t?z:ee;default:return[]}}function ne(e,t,n,r){let i=k(e),a=te(O(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(I)))),a}function B(e){let t=O(e);return T[t]+e.slice(t.length)}function re(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function ie(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:re(e)}function ae(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function oe(e,t,n){let{reference:r,floating:i}=e,a=M(t),o=N(t),s=j(o),c=O(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=k(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function se(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=D(t,e),p=ie(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=ae(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=ae(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var ce=50,le=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:se},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=oe(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<ce&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=oe(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},ue=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=D(e,t)||{};if(l==null)return{};let d=ie(u),f={x:n,y:r},p=N(i),m=j(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,x=a.reference[m]+a.reference[p]-f[p]-a.floating[m],S=f[p]-a.reference[p],C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),w=C?C[y]:0;(!w||!await(o.isElement==null?void 0:o.isElement(C)))&&(w=s.floating[y]||a.floating[m]);let T=x/2-S/2,O=w/2-h[m]/2-1,A=b(d[_],O),M=b(d[v],O),P=w-h[m]-M,F=w/2-h[m]/2+T,I=E(A,F,P),L=!c.arrow&&k(i)!=null&&F!==I&&a.reference[m]/2-(F<A?A:M)-h[m]/2<0,R=L?F<A?F-A:F-P:0;return{[p]:f[p]+R,data:{[p]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),de=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=D(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=O(r),_=M(o),v=O(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[B(o)]:F(o)),x=p!==`none`;!d&&x&&b.push(...ne(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=P(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==M(t))||T.every(e=>M(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=M(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function fe(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function pe(e){return y.some(t=>e[t]>=0)}var me=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=D(e,t);switch(i){case`referenceHidden`:{let e=fe(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:pe(e)}}}case`escaped`:{let e=fe(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:pe(e)}}}default:return{}}}}},he=new Set([`left`,`top`]);async function ge(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=O(n),s=k(n),c=M(n)===`y`,l=he.has(o)?-1:1,u=a&&c?-1:1,d=D(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var _e=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await ge(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},ve=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=D(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=M(i),p=A(f),m=u[p],h=u[f],g=(e,t)=>E(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},ye=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=D(e,t),u={x:n,y:r},d=M(i),f=A(d),p=u[f],m=u[d],h=D(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=he.has(O(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},be=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=D(e,t),c=await i.detectOverflow(t,s),l=O(n),u=k(n),d=M(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=b(p-c[m],g),y=b(f-c[h],_),S=t.middlewareData.shift,C=!S,w=v,T=y;S!=null&&S.enabled.x&&(T=_),S!=null&&S.enabled.y&&(w=g),C&&!u&&(d?T=f-2*x(c.left,c.right):w=p-2*x(c.top,c.bottom)),await o({...t,availableWidth:T,availableHeight:w});let E=await i.getDimensions(a.floating);return f!==E.width||p!==E.height?{reset:{rects:!0}}:{}}}};function xe(){return typeof window<`u`}function V(e){return Se(e)?(e.nodeName||``).toLowerCase():`#document`}function H(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function U(e){return((Se(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Se(e){return xe()?e instanceof Node||e instanceof H(e).Node:!1}function W(e){return xe()?e instanceof Element||e instanceof H(e).Element:!1}function G(e){return xe()?e instanceof HTMLElement||e instanceof H(e).HTMLElement:!1}function Ce(e){return!xe()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof H(e).ShadowRoot}function we(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=J(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Te(e){return/^(table|td|th)$/.test(V(e))}function Ee(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var De=/transform|translate|scale|rotate|perspective|filter/,Oe=/paint|layout|strict|content/,K=e=>!!e&&e!==`none`,ke;function Ae(e){let t=W(e)?J(e):e;return K(t.transform)||K(t.translate)||K(t.scale)||K(t.rotate)||K(t.perspective)||!Me()&&(K(t.backdropFilter)||K(t.filter))||De.test(t.willChange||``)||Oe.test(t.contain||``)}function je(e){let t=Y(e);for(;G(t)&&!q(t);){if(Ae(t))return t;if(Ee(t))return null;t=Y(t)}return null}function Me(){return ke??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),ke}function q(e){return/^(html|body|#document)$/.test(V(e))}function J(e){return H(e).getComputedStyle(e)}function Ne(e){return W(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Y(e){if(V(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Ce(e)&&e.host||U(e);return Ce(t)?t.host:t}function Pe(e){let t=Y(e);return q(t)?(e.ownerDocument||e).body:G(t)&&we(t)?t:Pe(t)}function Fe(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Pe(e),i=r===e.ownerDocument?.body,a=H(r);if(i){let e=Ie(a);return t.concat(a,a.visualViewport||[],we(r)?r:[],e&&n?Fe(e):[])}else return t.concat(r,Fe(r,[],n))}function Ie(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Le(e){let t=J(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=G(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=S(n)!==a||S(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Re(e){return W(e)?e:e.contextElement}function X(e){let t=Re(e);if(!G(t))return w(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Le(t),o=(a?S(n.width):n.width)/r,s=(a?S(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var ze=w(0);function Be(e){let t=H(e);return!Me()||!t.visualViewport?ze:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ve(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===H(e)}function Z(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Re(e),o=w(1);t&&(r?W(r)&&(o=X(r)):o=X(e));let s=Ve(a,n,r)?Be(a):w(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=H(a),t=W(r)?H(r):r,n=e,i=Ie(n);for(;i&&t!==n;){let e=X(i),t=i.getBoundingClientRect(),r=J(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=H(i),i=Ie(n)}}return ae({width:u,height:d,x:c,y:l})}function He(e,t){let n=Ne(e).scrollLeft;return t?t.left+n:Z(U(e)).left+n}function Ue(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-He(e,n),y:n.top+t.scrollTop}}function We(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=U(r),s=t?Ee(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=w(1),u=w(0),d=G(r);if((d||!a)&&((V(r)!==`body`||we(o))&&(c=Ne(r)),d)){let e=Z(r);l=X(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Ue(o,c):w(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Ge(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Ke(e){let t=Ne(e),n=e.ownerDocument.body,r=x(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=x(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+He(e),o=-t.scrollTop;return J(n).direction===`rtl`&&(a+=x(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var qe=25;function Je(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=H(e),a=U(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!Me()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(He(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=qe&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Ye(e,t){let n=Z(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=X(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Xe(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Je(e,n,t);else if(t===`document`)r=Ke(U(e));else if(W(t))r=Ye(t,n);else{let n=Be(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return ae(r)}function Ze(e,t){let n=t.get(e);if(n)return n;let r=Fe(e,[],!1).filter(e=>W(e)&&V(e)!==`body`),i=null,a=J(e).position===`fixed`,o=a?Y(e):e;for(;W(o)&&!q(o);){let e=J(o),t=Ae(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Y(o)}return t.set(e,r),r}function Qe(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Ee(t)?[]:Ze(t,this._c):[].concat(n),r],o=Xe(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Xe(t,a[e],i);s=x(n.top,s),c=b(n.right,c),l=b(n.bottom,l),u=x(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function $e(e){let{width:t,height:n}=Le(e);return{width:t,height:n}}function et(e,t,n){let r=G(t),i=U(t),a=n===`fixed`,o=Z(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=w(0);if((r||!a)&&((V(t)!==`body`||we(i))&&(s=Ne(t)),r)){let e=Z(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=He(i));let l=i&&!r&&!a?Ue(i,s):w(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function tt(e){return J(e).position===`static`}function nt(e,t){if(!G(e)||J(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return U(e)===n&&(n=n.ownerDocument.body),n}function rt(e,t){let n=H(e);if(Ee(e))return n;if(!G(e)){let t=Y(e);for(;t&&!q(t);){if(W(t)&&!tt(t))return t;t=Y(t)}return n}let r=nt(e,t);for(;r&&Te(r)&&tt(r);)r=nt(r,t);return r&&q(r)&&tt(r)&&!Ae(r)?n:r||je(e)||n}var it=async function(e){let t=this.getOffsetParent||rt,n=this.getDimensions,r=await n(e.floating);return{reference:et(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function at(e){return J(e).direction===`rtl`}var ot={convertOffsetParentRelativeRectToViewportRelativeRect:We,getDocumentElement:U,getClippingRect:Qe,getOffsetParent:rt,getElementRects:it,getClientRects:Ge,getDimensions:$e,getScale:X,isElement:W,isRTL:at};function st(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ct(e,t,n){let r=null,i,a=U(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=C(d),h=C(a.clientWidth-(u+f)),g=C(a.clientHeight-(d+p)),_=C(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:x(0,b(1,c))||1},y=!0;function S(t){let n=t[0].intersectionRatio;if(!st(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(S,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(S,v)}r.observe(e)}let c=H(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function lt(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Re(e),u=i||a?[...l?Fe(l):[],...t?Fe(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?ct(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Z(e):null;c&&g();function g(){let t=Z(e);h&&!st(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var ut=_e,dt=ve,ft=de,pt=be,mt=me,ht=ue,gt=ye,_t=(e,t,n)=>{let r=new Map,i=n??{},a={...ot,...i.platform,_c:r};return le(e,t,{...i,platform:a})},vt=e(n(),1),yt=typeof document<`u`?v.useLayoutEffect:function(){};function bt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!bt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!bt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function xt(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function St(e,t){let n=xt(e);return Math.round(t*n)/n}function Ct(e){let t=v.useRef(e);return yt(()=>{t.current=e}),t}function wt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=v.useState(r);bt(f,r)||p(r);let[m,h]=v.useState(null),[g,_]=v.useState(null),y=v.useCallback(e=>{e!==C.current&&(C.current=e,h(e))},[]),b=v.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),x=a||m,S=o||g,C=v.useRef(null),w=v.useRef(null),T=v.useRef(u),E=c!=null,D=Ct(c),O=Ct(i),k=Ct(l),A=v.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),_t(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!bt(T.current,t)&&(T.current=t,vt.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);yt(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=v.useRef(!1);yt(()=>(j.current=!0,()=>{j.current=!1}),[]),yt(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=v.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=v.useMemo(()=>({reference:x,floating:S}),[x,S]),P=v.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=St(N.floating,u.x),r=St(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...xt(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return v.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var Tt=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:ht({element:r.current,padding:i}).fn(n):r?ht({element:r,padding:i}).fn(n):{}}}},Et=(e,t)=>{let n=ut(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dt=(e,t)=>{let n=dt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ot=(e,t)=>({fn:gt(e).fn,options:[e,t]}),kt=(e,t)=>{let n=ft(e);return{name:n.name,fn:n.fn,options:[e,t]}},At=(e,t)=>{let n=pt(e);return{name:n.name,fn:n.fn,options:[e,t]}},jt=(e,t)=>{let n=mt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Mt=(e,t)=>{let n=Tt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Q=r(),Nt=`Arrow`,Pt=v.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,Q.jsx)(m.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,Q.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Pt.displayName=Nt;var Ft=Pt;function It(e){let[t,n]=v.useState(void 0);return h(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var Lt=`Popper`,[Rt,zt]=p(Lt),[Bt,Vt]=Rt(Lt),Ht=e=>{let{__scopePopper:t,children:n}=e,[r,i]=v.useState(null),[a,o]=v.useState(void 0);return(0,Q.jsx)(Bt,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};Ht.displayName=Lt;var Ut=`PopperAnchor`,Wt=v.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=Vt(Ut,n),o=v.useRef(null),s=a.onAnchorChange,c=d(t,v.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=v.useRef(null);v.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&en(a.placementState),f=u?.[0],p=u?.[1];return r?null:(0,Q.jsx)(m.div,{"data-radix-popper-side":f,"data-radix-popper-align":p,...i,ref:c})});Wt.displayName=Ut;var Gt=`PopperContent`,[Kt,qt]=Rt(Gt),Jt=v.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:p=`partial`,hideWhenDetached:g=!1,updatePositionStrategy:_=`optimized`,onPlaced:y,...b}=e,x=Vt(Gt,n),[S,C]=v.useState(null),w=d(t,C),[T,E]=v.useState(null),D=It(T),O=D?.width??0,k=D?.height??0,A=r+(a===`center`?``:`-`+a),j=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},M=Array.isArray(l)?l:[l],N=M.length>0,P={padding:j,boundary:M.filter(Qt),altBoundary:N},{refs:F,floatingStyles:I,placement:L,isPositioned:R,middlewareData:z}=wt({strategy:`fixed`,placement:A,whileElementsMounted:(...e)=>lt(...e,{animationFrame:_===`always`}),elements:{reference:x.anchor},middleware:[Et({mainAxis:i+k,alignmentAxis:o}),c&&Dt({mainAxis:!0,crossAxis:!1,limiter:p===`partial`?Ot():void 0,...P}),c&&kt({...P}),At({...P,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),T&&Mt({element:T,padding:s}),$t({arrowWidth:O,arrowHeight:k}),g&&jt({strategy:`referenceHidden`,...P,boundary:N?P.boundary:void 0})]}),ee=x.setPlacementState;h(()=>(ee(L),()=>{ee(void 0)}),[L,ee]);let[te,ne]=en(L),B=f(y);h(()=>{R&&B?.()},[R,B]);let re=z.arrow?.x,ie=z.arrow?.y,ae=z.arrow?.centerOffset!==0,[oe,se]=v.useState();return h(()=>{S&&se(window.getComputedStyle(S).zIndex)},[S]),(0,Q.jsx)(`div`,{ref:F.setFloating,"data-radix-popper-content-wrapper":``,style:{...I,transform:R?I.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:oe,"--radix-popper-transform-origin":[z.transformOrigin?.x,z.transformOrigin?.y].join(` `),...z.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,Q.jsx)(Kt,{scope:n,placedSide:te,placedAlign:ne,onArrowChange:E,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,Q.jsx)(m.div,{"data-side":te,"data-align":ne,...b,ref:w,style:{...b.style,animation:R?void 0:`none`}})})})});Jt.displayName=Gt;var Yt=`PopperArrow`,Xt={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Zt=v.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=qt(Yt,n),a=Xt[i.placedSide];return(0,Q.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,Q.jsx)(Ft,{...r,ref:t,style:{...r.style,display:`block`}})})});Zt.displayName=Yt;function Qt(e){return e!==null}var $t=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=en(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function en(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var tn=Ht,nn=Wt,rn=Jt,an=Zt,on=`rounded-md bg-border/50 text-sm text-fg placeholder:text-fg-muted transition-colors hover:bg-border/80 focus:bg-border/80 disabled:cursor-not-allowed disabled:opacity-50`,sn=`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,cn=`data-[highlighted]:bg-action data-[highlighted]:text-action-ink data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,ln=`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`;function un({className:e,type:t,...n}){return(0,Q.jsx)(`input`,{type:t,className:g(`flex h-8 w-full px-2.5`,on,e),...n})}function dn({className:e,...t}){return(0,Q.jsx)(`textarea`,{className:g(`flex min-h-16 w-full px-2.5 py-2`,on,e),...t})}var fn=`Label`,pn=v.forwardRef((e,t)=>(0,Q.jsx)(m.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));pn.displayName=fn;var mn=pn;function hn({className:e,...t}){return(0,Q.jsx)(mn,{className:g(`text-xs font-medium text-fg-secondary peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function gn(){return o({queryKey:[`profiles`],queryFn:()=>l(`GET`,`/api/profiles`)})}function _n(e){return o({queryKey:[`profile-settings`,e],queryFn:()=>l(`GET`,`/api/profiles/${e}/settings`),enabled:e!==void 0})}function vn(e){return o({queryKey:[`accounts`,e],queryFn:()=>l(`GET`,`/api/accounts?profile=${e}`),enabled:e!==void 0})}function yn(e){return o({queryKey:[`account-usage`,e],queryFn:()=>l(`GET`,`/api/accounts/${e}/usage`),enabled:e!==void 0,staleTime:15e3})}function bn(){return o({queryKey:[`repos`],queryFn:()=>l(`GET`,`/api/repos`)})}function xn(e){return o({queryKey:[`projects`,e??`all`],queryFn:()=>l(`GET`,e===void 0?`/api/projects`:`/api/projects?profile=${e}`)})}function Sn(e){return o({queryKey:[`project`,e],queryFn:()=>l(`GET`,`/api/projects/${e}`),enabled:e!==void 0})}function Cn(e){return o({queryKey:[`sessions`,e],queryFn:()=>l(`GET`,`/api/sessions?project=${e}`),enabled:e!==void 0})}function wn(){return o({queryKey:[`sessions`,`all`],queryFn:()=>l(`GET`,`/api/sessions`)})}function Tn(){return o({queryKey:[`config`],queryFn:()=>l(`GET`,`/api/config`)})}function En(e){return o({queryKey:[`repo-branches`,e],queryFn:()=>l(`GET`,`/api/repos/${e}/branches`),enabled:e!==void 0,staleTime:3e4})}function Dn(e){return o({queryKey:[`repo-worktrees`,e],queryFn:()=>l(`GET`,`/api/repos/${e}/worktrees`),enabled:e!==void 0,staleTime:1e4})}function On(e,t){let n=a();return i({mutationFn:t=>l(`DELETE`,`/api/repos/${e}/worktrees?path=${encodeURIComponent(t)}`),onSuccess:r=>{n.setQueryData([`repo-worktrees`,e],r),n.invalidateQueries({queryKey:[`project`,t]})}})}function kn(e,t){let n=a();return i({mutationFn:({name:t,confirm:n})=>{let r=new URLSearchParams({name:t});return n&&r.set(`confirm`,`1`),l(`DELETE`,`/api/repos/${e}/branches?${r.toString()}`)},onSuccess:r=>{n.setQueryData([`repo-worktrees`,e],r),n.invalidateQueries({queryKey:[`project`,t]})}})}function An(e){return o({queryKey:[`fs-dirs`,e],queryFn:()=>l(`GET`,`/api/fs/dirs?prefix=${encodeURIComponent(e)}`),enabled:e.startsWith(`/`)||e.startsWith(`~`),placeholderData:e=>e,staleTime:1e4})}function jn(){return o({queryKey:[`version`],queryFn:()=>l(`GET`,`/api/version`),staleTime:1/0})}function Mn(){return o({queryKey:[`host`],queryFn:()=>l(`GET`,`/api/host`),staleTime:1/0})}function Nn(){return o({queryKey:[`agents`],queryFn:()=>l(`GET`,`/api/agents`),staleTime:1/0})}function Pn(){let e=a();return i({mutationFn:e=>l(`POST`,`/api/profiles`,e),onSuccess:()=>void e.invalidateQueries({queryKey:[`profiles`]})})}function Fn(e){let t=a();return i({mutationFn:t=>l(`PATCH`,`/api/profiles/${e}/settings`,t),onSuccess:n=>t.setQueryData([`profile-settings`,e],n)})}function In(){let e=a();return i({mutationFn:({id:e,...t})=>l(`PATCH`,`/api/profiles/${e}`,t),onSuccess:()=>void e.invalidateQueries({queryKey:[`profiles`]})})}function Ln(){let e=a();return i({mutationFn:({id:e,...t})=>l(`PATCH`,`/api/accounts/${e}`,t),onSuccess:t=>{e.invalidateQueries({queryKey:[`accounts`,t.profile_id]}),e.invalidateQueries({queryKey:[`account-usage`,t.id]})}})}function Rn(){let e=a();return i({mutationFn:e=>l(`DELETE`,`/api/profiles/${e}`),onSuccess:()=>e.clear()})}function zn(){let e=a();return i({mutationFn:e=>l(`DELETE`,`/api/accounts/${e}`),onSuccess:()=>void e.invalidateQueries({queryKey:[`accounts`]})})}function Bn(){let e=a();return i({mutationFn:e=>l(`POST`,`/api/accounts`,e),onSuccess:t=>void e.invalidateQueries({queryKey:[`accounts`,t.profile_id]})})}function Vn(){return i({mutationFn:e=>l(`POST`,`/api/accounts/${e}/login`)})}function Hn(){let e=a();return i({mutationFn:e=>l(`POST`,`/api/repos`,e),onSuccess:()=>void e.invalidateQueries({queryKey:[`repos`]})})}function Un(){let e=a();return i({mutationFn:({id:e,...t})=>l(`PATCH`,`/api/repos/${e}`,t),onSuccess:()=>void e.invalidateQueries({queryKey:[`repos`]})})}function Wn(){let e=a();return i({mutationFn:e=>l(`POST`,`/api/repos/${e}/fetch`),onSuccess:()=>void e.invalidateQueries({queryKey:[`repos`]})})}function Gn(){let e=a();return i({mutationFn:e=>l(`POST`,`/api/projects`,e),onSuccess:()=>void e.invalidateQueries({queryKey:[`projects`]})})}function Kn(){let e=a();return i({mutationFn:({id:e,...t})=>l(`PATCH`,`/api/projects/${e}`,t),onSuccess:()=>void e.invalidateQueries({queryKey:[`projects`]})})}function qn(e,t){return o({queryKey:[`scratchpad`,e,t??`none`],queryFn:()=>l(`GET`,`/api/scratchpad?profile=${e}${t?`&project=${t}`:``}`),enabled:e!==void 0})}function Jn(){let e=a();return i({mutationFn:e=>l(`POST`,`/api/scratchpad`,e),onSuccess:()=>void e.invalidateQueries({queryKey:[`scratchpad`]})})}function Yn(){let e=a();return i({mutationFn:({id:e,...t})=>l(`PATCH`,`/api/scratchpad/${e}`,t),onSuccess:()=>void e.invalidateQueries({queryKey:[`scratchpad`]})})}function Xn(){let e=a();return i({mutationFn:e=>l(`DELETE`,`/api/scratchpad/${e}`),onSuccess:()=>void e.invalidateQueries({queryKey:[`scratchpad`]})})}function $(e,t){e.invalidateQueries({queryKey:[`sessions`]}),e.invalidateQueries({queryKey:[`project`,t.project_id]})}function Zn(){let e=a();return i({mutationFn:e=>l(`POST`,`/api/sessions`,e),onSuccess:t=>$(e,t)})}function Qn(e){let t=a();return i({mutationFn:t=>l(`POST`,`/api/sessions/${t}/${e}`),onSuccess:e=>$(t,e)})}function $n(){let e=a();return i({mutationFn:({sessionId:e,accountId:t})=>l(`POST`,`/api/sessions/${e}/migrate`,{account_id:t}),onSuccess:t=>$(e,t)})}function er(){let e=a();return i({mutationFn:e=>l(`POST`,`/api/sessions/${e}/archive`),onSuccess:t=>$(e,t)})}function tr(){let e=a();return i({mutationFn:e=>l(`POST`,`/api/sessions/${e}/unarchive`),onSuccess:t=>$(e,t)})}function nr(){let e=a();return i({mutationFn:({sessionId:e,title:t})=>l(`PATCH`,`/api/sessions/${e}`,{title:t}),onSuccess:t=>$(e,t)})}function rr(){let e=a();return i({mutationFn:e=>l(`PATCH`,`/api/config`,e),onSuccess:(t,n)=>{e.setQueryData([`config`],t),`displayName`in n&&e.invalidateQueries({queryKey:[`host`]})}})}async function ir(e){try{return await l(`GET`,`/api/profiles/${e}/state`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`no_state`)return null;throw e}}function ar(e,t){return l(`PUT`,`/api/profiles/${e}/state`,{ui_state:t})}function or(e,t){return o({queryKey:[`ports`,e],queryFn:()=>l(`GET`,`/api/sessions/${e}/ports`),enabled:e!==void 0&&t,refetchInterval:s(5e3),refetchIntervalInBackground:!1})}function sr(e,t){return o({queryKey:[`session-env`,e],queryFn:()=>l(`GET`,`/api/sessions/${e}/env`),enabled:e!==void 0&&t,refetchInterval:s(5e3),refetchIntervalInBackground:!1})}function cr(){let e=a();return i({mutationFn:e=>l(`DELETE`,`/api/sessions/${e}/env`),onSuccess:(t,n)=>{e.setQueryData([`session-env`,n],{vars:[]})}})}var lr=_(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),ur=u(`puddle.profile-id`);function dr(){let e=(0,v.useSyncExternalStore)(ur.subscribe,ur.get);return e!==null&&/^[0-9a-f]{10}$/.test(e)?e:null}function fr(e){ur.set(e)}function pr({id:e,value:t,onValueChange:n,onChoose:r,hints:i,placeholder:a,className:o,hintsClassName:s,autoFocus:c}){let[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(0),p=e=>{n(e.value),r?.(e),u(!1)};return(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(un,{id:e,value:t,onChange:e=>{n(e.target.value),u(!0),f(0)},onFocus:()=>u(!0),onBlur:()=>u(!1),onKeyDown:e=>{if(!(!l||i.length===0))if(e.key===`ArrowDown`)e.preventDefault(),f(e=>(e+1)%i.length);else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>(e-1+i.length)%i.length);else if(e.key===`Enter`||e.key===`Tab`){let t=i[d]??i[0];t&&(e.preventDefault(),p(t))}else e.key===`Escape`&&(e.stopPropagation(),u(!1))},placeholder:a,className:o,autoComplete:`off`,spellCheck:!1,autoFocus:c}),l&&i.length>0&&(0,Q.jsx)(`ul`,{className:g(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,s??`w-full`),children:i.map((e,t)=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),p(e)},onMouseEnter:()=>f(t),className:g(`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`,`w-full font-mono text-xs`),"data-selected":t===d,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.label??e.value}),e.badge&&(0,Q.jsx)(`span`,{className:`ml-auto shrink-0 text-2xs opacity-70`,children:e.badge})]})},e.value))})]})}var mr=(0,v.lazy)(()=>c(()=>import(`./Terminal-Ci3-2jXt.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))),hr=null;async function gr(){hr=(await c(()=>import(`./Terminal-Ci3-2jXt.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))).Terminal}function _r(e){return hr?(0,Q.jsx)(hr,{...e}):(0,Q.jsx)(v.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`size-full bg-ground`}),children:(0,Q.jsx)(mr,{...e})})}export{Cn as $,Mn as A,_n as B,jn as C,Xn as D,Rn as E,In as F,nr as G,Sn as H,Fn as I,bn as J,En as K,Kn as L,$n as M,Ln as N,An as O,rr as P,or as Q,Un as R,Zn as S,kn as T,xn as U,gn as V,On as W,Qn as X,qn as Y,sr as Z,Bn as _,fr as a,ln as at,Hn as b,ir as c,nn as ct,vn as d,tn as dt,tr as et,Nn as f,zt as ft,Tn as g,cr as h,ur as i,on as it,Vn as j,Wn as k,ar as l,an as lt,er as m,gr as n,un as nt,dr as o,cn as ot,wn as p,It as pt,Dn as q,pr as r,dn as rt,lr as s,sn as st,_r as t,hn as tt,yn as u,rn as ut,Pn as v,zn as w,Jn as x,Gn as y,Yn as z};
|