@puddle-code/cli 0.3.6 → 0.3.8
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 +7 -3
- package/dist/host-control.mjs +23 -12
- package/dist/index.js +28 -15
- package/dist/public/assets/App-DldUYF2U.js +2 -0
- package/dist/public/assets/Dashboard-Bjrw6phb.js +1 -0
- package/dist/public/assets/{EditorTabClose-BV-zQyHT.js → EditorTabClose-BunNsUEz.js} +1 -1
- package/dist/public/assets/LazyTerminal-CdXNqTZt.js +2 -0
- package/dist/public/assets/{ModelRefcount-BasPzO4R.js → ModelRefcount-HPszadg6.js} +1 -1
- package/dist/public/assets/NewProjectDialog-BCtrjbMj.js +1 -0
- package/dist/public/assets/PaneEditorBody-KksboOhO.js +302 -0
- package/dist/public/assets/{PdfViewer-DAAfA9OC.js → PdfViewer-CfWAV5F2.js} +1 -1
- package/dist/public/assets/SettingsDialog-LIv4FuS1.js +8 -0
- package/dist/public/assets/{Terminal-DmlEI-h7.js → Terminal-CMOPxTVY.js} +4 -4
- package/dist/public/assets/Workspace-GWsJrLJW.js +20 -0
- package/dist/public/assets/auth-B4b-NPwe.js +64 -0
- package/dist/public/assets/{buffer-store-CYe-IdNO.js → buffer-store-Da5Z0NEV.js} +1 -1
- package/dist/public/assets/context-menu-CnmULRW3.js +1 -0
- package/dist/public/assets/{copy-CjatFFf8.js → copy-DD43yC2P.js} +1 -1
- package/dist/public/assets/{disclosure-7lu23NnB.js → disclosure-BQ-uiP85.js} +1 -1
- package/dist/public/assets/dist-Cg-J2BAP.js +1 -0
- package/dist/public/assets/{dist-7fft9rhQ.js → dist-Rswij5M_.js} +1 -1
- package/dist/public/assets/{errors-DhRwiizF.js → errors-C-GJcBJ-.js} +1 -1
- package/dist/public/assets/{index-BRywm-gU.js → index-BfBbMcnA.js} +3 -3
- package/dist/public/assets/index-BxtQ6WUO.css +2 -0
- package/dist/public/assets/input-Dx89yXF4.js +1 -0
- package/dist/public/assets/{markdown-mermaid-CF9txXiK.js → markdown-mermaid-CltyCx0-.js} +1 -1
- package/dist/public/assets/media-refresh-store-WCjZVi4Y.js +1 -0
- package/dist/public/assets/notification-delivery-vK2Y-rON.js +1 -0
- package/dist/public/assets/popover-CTPDNtFu.js +1 -0
- package/dist/public/assets/{protocol-support-gmAQBWF3.js → protocol-support-Q_1mBit9.js} +1 -1
- package/dist/public/assets/{scroll-restoration-hg7BYUz2.js → scroll-restoration-hslkZdX5.js} +1 -1
- package/dist/public/assets/select-iSqC2X51.js +1 -0
- package/dist/public/assets/{selection-actions-BZy4596m.js → selection-actions-Cith0Z9x.js} +1 -1
- package/dist/public/assets/session-order-B9wDgtkQ.js +1 -0
- package/dist/public/assets/switch-CeNFnG6w.js +1 -0
- package/dist/public/assets/use-ui-state-xScqhALU.js +1 -0
- package/dist/public/assets/{ws-oU1ansI7.js → ws-CT7jDKHs.js} +1 -1
- package/dist/public/index.html +3 -3
- package/dist/pudl.js +24 -13
- package/package.json +1 -1
- package/dist/public/assets/App-Duewv-oi.js +0 -2
- package/dist/public/assets/Dashboard-7gBsrB7q.js +0 -1
- package/dist/public/assets/LazyTerminal-gX1-vBQf.js +0 -2
- package/dist/public/assets/NewProjectDialog-CDYUPliQ.js +0 -1
- package/dist/public/assets/PaneEditorBody-CqLkAxM1.js +0 -302
- package/dist/public/assets/SettingsDialog-DiwhE5dK.js +0 -8
- package/dist/public/assets/Workspace-cfjpv0xU.js +0 -20
- package/dist/public/assets/auth-BxExwqPW.js +0 -73
- package/dist/public/assets/context-menu-DVUv5Z6a.js +0 -1
- package/dist/public/assets/dist-B67qxih2.js +0 -1
- package/dist/public/assets/index-XBWIhnuP.css +0 -2
- package/dist/public/assets/media-refresh-store-DLtYZTP9.js +0 -1
- package/dist/public/assets/notification-delivery-CoCRZRSK.js +0 -1
- package/dist/public/assets/popover-C-BfSLgw.js +0 -1
- package/dist/public/assets/project-abbrev-DX_a_ySv.js +0 -1
- package/dist/public/assets/recipes-K5GH3Kht.js +0 -1
- package/dist/public/assets/select-YFIOZ3zx.js +0 -1
- package/dist/public/assets/switch-OD1b2aeq.js +0 -1
- package/dist/public/assets/use-ui-state-C2LCTPRw.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,9 +4,13 @@ Archived release changelog. Governance lives in CLAUDE.md §"Changelog disciplin
|
|
|
4
4
|
|
|
5
5
|
# Changelog
|
|
6
6
|
|
|
7
|
-
## [0.3.
|
|
7
|
+
## [0.3.8] — 2026-10-25
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- Show Stop on live session tabs and Resume plus Archive on stopped tabs, and widen tabs to leave room for all three controls and title clicks.
|
|
8
12
|
|
|
9
13
|
### Fixed
|
|
10
14
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
15
|
+
- Restore desktop host windows reliably after quitting, retain pending or offline hosts across relaunches, and avoid opening an extra host picker during macOS startup.
|
|
16
|
+
- Hide archived projects from command search and list projects in the sidebar's saved order, with the same newest-first fallback.
|
package/dist/host-control.mjs
CHANGED
|
@@ -14680,16 +14680,7 @@ var hostInfoSchema = external_exports.object({
|
|
|
14680
14680
|
// ../shared/src/api/profiles.ts
|
|
14681
14681
|
var fsSafeName = external_exports.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/, "letters, digits, dot, underscore and hyphen only");
|
|
14682
14682
|
var RULES_TOKEN = "{{rules}}";
|
|
14683
|
-
var DEFAULT_ONBOARDING_TEMPLATE = `
|
|
14684
|
-
|
|
14685
|
-
1. Standing setup rules for this repository (user-authored):
|
|
14686
|
-
${RULES_TOKEN}
|
|
14687
|
-
|
|
14688
|
-
2. Inspect the codebase for setup requirements (README, CONTRIBUTING, lockfiles, .tool-versions, pyproject.toml, package.json, \u2026).
|
|
14689
|
-
3. Apply what the rules above settle without asking. Ask the user about anything they leave open, stating trade-offs where relevant (e.g. a symlinked .venv saves gigabytes per worktree, but parallel sessions then share mutable dependency state).
|
|
14690
|
-
4. If the user states a standing rule for all future worktrees ("always\u2026", "never\u2026", "from now on\u2026"), write the complete updated rules to \`.puddle/onboarding-notes.md\` in this worktree \u2014 full replacement, user-owned prose; record their decision, don't invent policy.
|
|
14691
|
-
|
|
14692
|
-
Then proceed with the task below (or await instructions if none is given).`;
|
|
14683
|
+
var DEFAULT_ONBOARDING_TEMPLATE = `This is a freshly created git worktree for this task. Before starting, set up the environment as appropriate by reading any setup rules (see below) and inspecting the codebase. If the user states a rule for all future worktrees, write the complete updated rules to \`.puddle/onboarding-notes.md\` in this worktree. Setup rules:${RULES_TOKEN}`;
|
|
14693
14684
|
var PROFILE_ICON_COLOURS = [
|
|
14694
14685
|
"navy",
|
|
14695
14686
|
"gold",
|
|
@@ -15496,17 +15487,37 @@ var notebookKernelsResponseSchema = external_exports.object({
|
|
|
15496
15487
|
error: external_exports.string().optional()
|
|
15497
15488
|
});
|
|
15498
15489
|
var notebookKernelRequestSchema = external_exports.object({ source: compilationFileTargetSchema });
|
|
15490
|
+
var pythonPathSchema = external_exports.string().trim().min(1).max(4096).refine((path) => !path.includes("\0"));
|
|
15491
|
+
var notebookEnvironmentSchema = external_exports.object({
|
|
15492
|
+
python: pythonPathSchema,
|
|
15493
|
+
label: external_exports.string(),
|
|
15494
|
+
ipykernel: external_exports.boolean(),
|
|
15495
|
+
nbconvert: external_exports.boolean(),
|
|
15496
|
+
error: external_exports.string().optional()
|
|
15497
|
+
});
|
|
15498
|
+
var notebookEnvironmentsResponseSchema = external_exports.object({
|
|
15499
|
+
environments: external_exports.array(notebookEnvironmentSchema)
|
|
15500
|
+
});
|
|
15499
15501
|
var notebookKernelStatusSchema = external_exports.object({
|
|
15500
15502
|
state: external_exports.enum(["stopped", "starting", "idle", "busy", "dead"]),
|
|
15501
15503
|
kernel: external_exports.string().nullable(),
|
|
15502
|
-
error: external_exports.string().optional()
|
|
15504
|
+
error: external_exports.string().optional(),
|
|
15505
|
+
environment: notebookEnvironmentSchema.optional()
|
|
15503
15506
|
});
|
|
15504
15507
|
var notebookKernelActionSchema = external_exports.discriminatedUnion("action", [
|
|
15505
15508
|
notebookKernelRequestSchema.extend({
|
|
15506
15509
|
action: external_exports.literal("select"),
|
|
15507
15510
|
kernel: external_exports.string().min(1).max(256)
|
|
15508
15511
|
}),
|
|
15509
|
-
notebookKernelRequestSchema.extend({ action: external_exports.enum(["interrupt", "restart", "shutdown"]) })
|
|
15512
|
+
notebookKernelRequestSchema.extend({ action: external_exports.enum(["interrupt", "restart", "shutdown"]) }),
|
|
15513
|
+
notebookKernelRequestSchema.extend({
|
|
15514
|
+
action: external_exports.literal("select-python"),
|
|
15515
|
+
python: pythonPathSchema
|
|
15516
|
+
}),
|
|
15517
|
+
notebookKernelRequestSchema.extend({
|
|
15518
|
+
action: external_exports.literal("install-python"),
|
|
15519
|
+
python: pythonPathSchema
|
|
15520
|
+
})
|
|
15510
15521
|
]);
|
|
15511
15522
|
|
|
15512
15523
|
// ../shared/src/api/latex.ts
|
package/dist/index.js
CHANGED
|
@@ -3925,7 +3925,7 @@ import { createInterface } from "node:readline";
|
|
|
3925
3925
|
import { Writable } from "node:stream";
|
|
3926
3926
|
|
|
3927
3927
|
// ../shared/src/protocol.ts
|
|
3928
|
-
var PROTOCOL_VERSION = { major: 25, minor:
|
|
3928
|
+
var PROTOCOL_VERSION = { major: 25, minor: 1 };
|
|
3929
3929
|
|
|
3930
3930
|
// ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
|
|
3931
3931
|
var external_exports = {};
|
|
@@ -18600,16 +18600,7 @@ var hostInfoSchema = external_exports.object({
|
|
|
18600
18600
|
// ../shared/src/api/profiles.ts
|
|
18601
18601
|
var fsSafeName = external_exports.string().min(1).max(64).regex(/^[A-Za-z0-9][A-Za-z0-9._-]*$/, "letters, digits, dot, underscore and hyphen only");
|
|
18602
18602
|
var RULES_TOKEN = "{{rules}}";
|
|
18603
|
-
var DEFAULT_ONBOARDING_TEMPLATE = `
|
|
18604
|
-
|
|
18605
|
-
1. Standing setup rules for this repository (user-authored):
|
|
18606
|
-
${RULES_TOKEN}
|
|
18607
|
-
|
|
18608
|
-
2. Inspect the codebase for setup requirements (README, CONTRIBUTING, lockfiles, .tool-versions, pyproject.toml, package.json, \u2026).
|
|
18609
|
-
3. Apply what the rules above settle without asking. Ask the user about anything they leave open, stating trade-offs where relevant (e.g. a symlinked .venv saves gigabytes per worktree, but parallel sessions then share mutable dependency state).
|
|
18610
|
-
4. If the user states a standing rule for all future worktrees ("always\u2026", "never\u2026", "from now on\u2026"), write the complete updated rules to \`.puddle/onboarding-notes.md\` in this worktree \u2014 full replacement, user-owned prose; record their decision, don't invent policy.
|
|
18611
|
-
|
|
18612
|
-
Then proceed with the task below (or await instructions if none is given).`;
|
|
18603
|
+
var DEFAULT_ONBOARDING_TEMPLATE = `This is a freshly created git worktree for this task. Before starting, set up the environment as appropriate by reading any setup rules (see below) and inspecting the codebase. If the user states a rule for all future worktrees, write the complete updated rules to \`.puddle/onboarding-notes.md\` in this worktree. Setup rules:${RULES_TOKEN}`;
|
|
18613
18604
|
var PROFILE_ICON_COLOURS = [
|
|
18614
18605
|
"navy",
|
|
18615
18606
|
"gold",
|
|
@@ -19416,17 +19407,37 @@ var notebookKernelsResponseSchema = external_exports.object({
|
|
|
19416
19407
|
error: external_exports.string().optional()
|
|
19417
19408
|
});
|
|
19418
19409
|
var notebookKernelRequestSchema = external_exports.object({ source: compilationFileTargetSchema });
|
|
19410
|
+
var pythonPathSchema = external_exports.string().trim().min(1).max(4096).refine((path) => !path.includes("\0"));
|
|
19411
|
+
var notebookEnvironmentSchema = external_exports.object({
|
|
19412
|
+
python: pythonPathSchema,
|
|
19413
|
+
label: external_exports.string(),
|
|
19414
|
+
ipykernel: external_exports.boolean(),
|
|
19415
|
+
nbconvert: external_exports.boolean(),
|
|
19416
|
+
error: external_exports.string().optional()
|
|
19417
|
+
});
|
|
19418
|
+
var notebookEnvironmentsResponseSchema = external_exports.object({
|
|
19419
|
+
environments: external_exports.array(notebookEnvironmentSchema)
|
|
19420
|
+
});
|
|
19419
19421
|
var notebookKernelStatusSchema = external_exports.object({
|
|
19420
19422
|
state: external_exports.enum(["stopped", "starting", "idle", "busy", "dead"]),
|
|
19421
19423
|
kernel: external_exports.string().nullable(),
|
|
19422
|
-
error: external_exports.string().optional()
|
|
19424
|
+
error: external_exports.string().optional(),
|
|
19425
|
+
environment: notebookEnvironmentSchema.optional()
|
|
19423
19426
|
});
|
|
19424
19427
|
var notebookKernelActionSchema = external_exports.discriminatedUnion("action", [
|
|
19425
19428
|
notebookKernelRequestSchema.extend({
|
|
19426
19429
|
action: external_exports.literal("select"),
|
|
19427
19430
|
kernel: external_exports.string().min(1).max(256)
|
|
19428
19431
|
}),
|
|
19429
|
-
notebookKernelRequestSchema.extend({ action: external_exports.enum(["interrupt", "restart", "shutdown"]) })
|
|
19432
|
+
notebookKernelRequestSchema.extend({ action: external_exports.enum(["interrupt", "restart", "shutdown"]) }),
|
|
19433
|
+
notebookKernelRequestSchema.extend({
|
|
19434
|
+
action: external_exports.literal("select-python"),
|
|
19435
|
+
python: pythonPathSchema
|
|
19436
|
+
}),
|
|
19437
|
+
notebookKernelRequestSchema.extend({
|
|
19438
|
+
action: external_exports.literal("install-python"),
|
|
19439
|
+
python: pythonPathSchema
|
|
19440
|
+
})
|
|
19430
19441
|
]);
|
|
19431
19442
|
|
|
19432
19443
|
// ../shared/src/api/latex.ts
|
|
@@ -21882,7 +21893,7 @@ import { readFileSync as readFileSync4 } from "node:fs";
|
|
|
21882
21893
|
import { dirname as dirname4, join as join5 } from "node:path";
|
|
21883
21894
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
21884
21895
|
function cliVersion() {
|
|
21885
|
-
if (true) return "0.3.
|
|
21896
|
+
if (true) return "0.3.8";
|
|
21886
21897
|
const here = dirname4(fileURLToPath2(import.meta.url));
|
|
21887
21898
|
for (const candidate of [
|
|
21888
21899
|
join5(here, "..", "..", "package.json"),
|
|
@@ -22286,7 +22297,9 @@ var RELEASE_PROTOCOLS = {
|
|
|
22286
22297
|
"0.3.3": { major: 24, minor: 2 },
|
|
22287
22298
|
"0.3.4": { major: 24, minor: 6 },
|
|
22288
22299
|
"0.3.5": { major: 25, minor: 0 },
|
|
22289
|
-
"0.3.6": { major: 25, minor: 0 }
|
|
22300
|
+
"0.3.6": { major: 25, minor: 0 },
|
|
22301
|
+
"0.3.7": { major: 25, minor: 1 },
|
|
22302
|
+
"0.3.8": { major: 25, minor: 1 }
|
|
22290
22303
|
};
|
|
22291
22304
|
function validProtocol(value) {
|
|
22292
22305
|
if (typeof value !== "object" || value === null) return false;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SettingsDialog-LIv4FuS1.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/auth-B4b-NPwe.js","assets/LazyTerminal-CdXNqTZt.js","assets/preload-helper-Czpn1I53.js","assets/es2015-CrC2hHeB.js","assets/x-DCpy1q13.js","assets/createLucideIcon-DyMAgLa3.js","assets/input-Dx89yXF4.js","assets/notification-delivery-vK2Y-rON.js","assets/dist-Rswij5M_.js","assets/protocol-support-Q_1mBit9.js","assets/switch-CeNFnG6w.js","assets/dist-BCwJL3w9.js","assets/dialog-Bnex_wlx.js","assets/client-settings-CwqpIric.js","assets/index-BfBbMcnA.js","assets/index-BxtQ6WUO.css","assets/button-Chvl9hcE.js","assets/select-iSqC2X51.js","assets/chevron-down--sjpQEHH.js","assets/dist-DmyIHyF9.js","assets/code-DRWf9a5s.js","assets/rotate-ccw-CNjR2LSi.js","assets/errors-C-GJcBJ-.js","assets/use-debounced-value-C86N-mOK.js","assets/popover-CTPDNtFu.js","assets/disclosure-BQ-uiP85.js","assets/Dashboard-Bjrw6phb.js","assets/session-order-B9wDgtkQ.js","assets/context-menu-CnmULRW3.js","assets/dist-Cg-J2BAP.js","assets/NewProjectDialog-BCtrjbMj.js","assets/ws-CT7jDKHs.js","assets/Workspace-GWsJrLJW.js","assets/copy-DD43yC2P.js","assets/media-refresh-store-WCjZVi4Y.js","assets/use-ui-state-xScqhALU.js","assets/preview-kind-CJ9RTgbs.js","assets/debounce-B9DrqirV.js","assets/whole-word-2m2pmAFT.js","assets/selection-actions-Cith0Z9x.js","assets/drafts-B_tChlzR.js","assets/buffer-logic-BAkSBQT7.js","assets/scroll-restoration-hslkZdX5.js","assets/Workspace-DdL3ODEC.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{B as i,O as a,V as o,j as s,l as c,o as l,r as u,v as d}from"./auth-B4b-NPwe.js";import{a as f,c as p,o as m}from"./LazyTerminal-CdXNqTZt.js";import{a as h,d as g,f as _,g as v,h as y,i as b,l as x,m as S,o as C,s as w,t as T,u as E}from"./notification-delivery-vK2Y-rON.js";import{i as D,r as O,t as ee}from"./client-settings-CwqpIric.js";import{t as k}from"./preload-helper-Czpn1I53.js";import{a as A,n as te,o as ne,r as re,t as j}from"./index-BfBbMcnA.js";import{i as ie,n as M,t as ae}from"./dist-Rswij5M_.js";import{$ as oe,$t as se,A as N,At as ce,Bt as le,C as ue,D as de,Et as fe,G as pe,Gt as me,I as he,It as ge,J as _e,Jt as ve,Kt as ye,L as be,Lt as xe,M as Se,N as Ce,O as we,P as Te,Qt as Ee,R as De,Rt as Oe,T as ke,Ut as Ae,W as je,Wt as P,X as Me,Xt as F,Yt as Ne,Zt as Pe,_ as Fe,_t as Ie,at as Le,b as Re,bt as ze,dt as Be,en as Ve,ft as He,gt as Ue,j as We,k as Ge,nn as Ke,o as qe,ot as Je,pt as Ye,qt as Xe,rn as Ze,st as Qe,tn as $e,tt as et,ut as tt,v as nt,vt as rt,w as it,x as at,yt as ot,z as st}from"./protocol-support-Q_1mBit9.js";import{n as ct,t as lt}from"./copy-DD43yC2P.js";import{a as ut,c as dt,d as ft,f as pt,h as mt,l as ht,m as gt,o as _t,p as vt,r as yt,u as bt}from"./session-order-B9wDgtkQ.js";import{c as I,p as L}from"./es2015-CrC2hHeB.js";import{n as R,s as xt}from"./x-DCpy1q13.js";import{i as St,n as Ct,o as wt,t as z}from"./input-Dx89yXF4.js";import{n as Tt,r as Et}from"./dist-BCwJL3w9.js";import{$ as Dt,G as Ot,H as kt,J as At,K as jt,Q as Mt,U as Nt,W as Pt,X as Ft,Y as It,at as Lt,d as Rt,et as zt,f as Bt,h as B,i as Vt,it as V,m as Ht,nt as Ut,ot as H,p as Wt,q as Gt,r as Kt,rt as U,t as qt,tt as Jt}from"./use-ui-state-xScqhALU.js";import{t as W}from"./button-Chvl9hcE.js";import{t as G}from"./createLucideIcon-DyMAgLa3.js";import{c as Yt,i as Xt,s as Zt,t as Qt,u as $t}from"./switch-CeNFnG6w.js";import{t as en}from"./NewProjectDialog-BCtrjbMj.js";import{n as K}from"./errors-C-GJcBJ-.js";import{t as q}from"./ws-CT7jDKHs.js";import{c as tn,l as nn,n as rn,s as an,t as on,u as sn}from"./dialog-Bnex_wlx.js";import{n as cn,r as ln,t as un}from"./popover-CTPDNtFu.js";var J=e(t(),1),Y=r();function dn(){let[e,t]=(0,J.useState)(`Opening forwarded application…`);return(0,J.useEffect)(()=>{if(!/^\/forward\/([^/]+)\/(\d+)$/.exec(window.location.pathname)){t(`This forwarding link is invalid.`);return}let e=!0;return ct(new URL(window.location.href)).then(t=>{e&&window.location.replace(t)}).catch(()=>{e&&t(`The application is unavailable. Reconnect to Puddle and open this link again.`)}),()=>{e=!1}},[]),(0,Y.jsx)(`p`,{className:`p-8 text-sm text-fg-secondary`,children:e})}var fn=class extends $e{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new Oe({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=pn(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=pn(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=pn(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=pn(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){P.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>ve(t,e))}findAll(e={}){return this.getAll().filter(t=>ve(e,t))}notify(e){P.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return P.batch(()=>Promise.all(e.map(e=>e.continue().catch(F))))}};function pn(e){return e.options.scope?.id}var mn=class extends $e{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Xe(r,t),a=this.get(i);return a||(a=new le({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){P.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Ne(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>Ne(e,t)):t}notify(e){P.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){P.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){P.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},hn=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new mn,this.#t=e.mutationCache||new fn,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=Ve.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=Ae.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Ee(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=me(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return P.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;P.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return P.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=P.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(F).catch(F)}invalidateQueries(e,t={}){return P.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=P.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(F)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(F)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Ee(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(F).catch(F)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(F).catch(F)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return Ae.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(ye(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Pe(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(ye(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Pe(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Xe(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===se&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},gn=class extends J.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidUpdate(e){this.state.error!==null&&e.resetOn!==this.props.resetOn&&this.setState({error:null})}componentDidCatch(e,t){console.error(`Puddle: the ${this.props.scope} crashed`,e,t.componentStack)}render(){let{error:e}=this.state;return e===null?this.props.children:(0,Y.jsxs)(`div`,{className:`flex h-full min-h-40 flex-col items-center justify-center gap-4 px-8 py-10 text-center`,children:[(0,Y.jsxs)(`p`,{className:`text-sm text-fg`,children:[`The `,this.props.scope,` stopped rendering.`]}),(0,Y.jsx)(`p`,{className:`max-w-lg font-mono text-2xs leading-relaxed text-interrupted`,children:e.message||String(e)}),(0,Y.jsx)(`p`,{className:`max-w-sm text-2xs leading-relaxed text-fg-muted`,children:`Your sessions and their worktrees are on the daemon and untouched; the layout is saved. The console has the full stack.`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,Y.jsx)(`button`,{type:`button`,onClick:()=>this.setState({error:null}),className:`text-2xs font-medium text-fg-gold transition-colors hover:underline`,children:`Try again`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Reload`})]})]})}};function _n(){return(0,Y.jsx)(ae,{theme:(0,J.useSyncExternalStore)(A,re),position:`bottom-right`,toastOptions:{style:{background:`var(--bg-elevated)`,border:`none`,boxShadow:`0 8px 30px rgb(0 0 0 / 0.25)`,color:`var(--text-primary)`},classNames:{description:`whitespace-pre-wrap break-words font-mono text-2xs leading-snug max-h-40 overflow-y-auto`}}})}function vn(){return(0,Y.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,Y.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-24`,children:[(0,Y.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm leading-relaxed text-fg-secondary`,children:[(0,Y.jsxs)(`p`,{children:[`Authorise this browser by running`,` `,(0,Y.jsx)(`span`,{className:`font-mono text-accent`,children:`puddle launch`}),` in a terminal.`]}),(0,Y.jsx)(`p`,{children:`Use the link it opens. Your sessions, drafts and layouts stay in place.`})]})]})})}var yn=e(n(),1),bn=`a, button, [role="button"], [role="slider"], input, select, textarea, summary, label, [onclick], .cursor-pointer`,xn=`.monaco-editor`;function Sn(e,t){return e?.closest(xn)&&!e.closest(t)?`text`:e?.closest(bn)?`interactive`:`default`}function Cn(e,t=`.no-custom-caret`){(0,J.useEffect)(()=>{let n=e.current;if(!n)return;let r=window.matchMedia(`(pointer: fine)`),i=()=>{n.style.opacity=`0`},a=e=>{if(e.pointerType===`touch`||!r.matches){i();return}n.style.transform=`translate3d(${e.clientX}px, ${e.clientY}px, 0) translate(-50%, -50%)`;let a=e.target instanceof Element?e.target:null;if(a instanceof HTMLIFrameElement){i();return}n.style.opacity=`1`;let o=a?.closest(xn),s=Sn(a,t),c=s===`text`,l=s===`interactive`,u=c;if(c&&o){let e=getComputedStyle(o);n.style.setProperty(`--custom-cursor-caret-height`,`${Math.round(Number.parseFloat(e.fontSize)*1.3)}px`)}else if(!l&&a&&!a.closest(t)&&Array.from(a.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())){let e=getComputedStyle(a);e.userSelect!==`none`&&(u=!0,n.style.setProperty(`--custom-cursor-caret-height`,`${Math.round(Number.parseFloat(e.fontSize)*1.3)}px`))}n.classList.toggle(`is-interactive`,l),n.classList.toggle(`is-text`,u)};return window.addEventListener(`pointermove`,a,{passive:!0}),document.documentElement.addEventListener(`pointerleave`,i),window.addEventListener(`blur`,i),()=>{window.removeEventListener(`pointermove`,a),document.documentElement.removeEventListener(`pointerleave`,i),window.removeEventListener(`blur`,i)}},[t,e])}var wn=[`top`,`right`,`bottom`,`left`];function Tn(){let e=(0,J.useRef)(null);return Cn(e),(0,Y.jsx)(`div`,{ref:e,className:`custom-cursor drafting-cursor`,"aria-hidden":`true`,children:wn.map(e=>(0,Y.jsx)(`span`,{className:`drafting-cursor-tick`,"data-side":e},e))})}function En(){let e=(0,J.useRef)(null);return Cn(e),(0,Y.jsx)(`div`,{ref:e,className:`custom-cursor invert-cursor`,"aria-hidden":`true`})}var Dn=`h1, h2, h3, h4, h5, h6, .no-rangefinder-caret`,On=40.5,X=4.05,kn=X*Math.sqrt(3)/2;function An(){let e=[],t=[],n=On/2,r=Math.ceil(n/kn)+1,i=e=>Math.round(e*100)/100,a=e=>`M${e.map(([e,t])=>`${i(e)} ${i(t)}`).join(`L`)}Z`;for(let i=-r;i<r;i+=1){let o=n+i*kn,s=o+kn,c=(i%2+2)%2*(X/2);for(let i=-r;i<r;i+=1){let r=n+i*X+c,l=[[r+X/2,o],[r,s],[r+X,s]],u=[[r+X/2,o],[r+3*X/2,o],[r+X,s]],d=e=>{let t=e.map(([e])=>e),n=e.map(([,e])=>e);return Math.max(...t)>0&&Math.min(...t)<On&&Math.max(...n)>0&&Math.min(...n)<On};d(l)&&e.push(a(l)),d(u)&&t.push(a(u))}}return{light:e.join(``),dark:t.join(``)}}var jn=An();function Mn(){let e=(0,J.useRef)(null);return Cn(e,Dn),(0,Y.jsx)(`div`,{ref:e,className:`custom-cursor rangefinder-cursor`,"aria-hidden":`true`,children:(0,Y.jsxs)(`svg`,{className:`rangefinder-cursor-facets`,viewBox:`0 0 ${On} ${On}`,focusable:`false`,children:[(0,Y.jsx)(`path`,{className:`rangefinder-cursor-facet-light`,d:jn.light}),(0,Y.jsx)(`path`,{className:`rangefinder-cursor-facet-dark`,d:jn.dark})]})})}function Nn(){let{cursorPackage:e}=D(),t=null;switch(e){case`rangefinder`:t=(0,Y.jsx)(Mn,{});break;case`drafting`:t=(0,Y.jsx)(Tn,{});break;case`invert`:t=(0,Y.jsx)(En,{});break;case`system`:return null}return(0,yn.createPortal)(t,document.body)}var Pn=G(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),Fn=G(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),In=G(`monitor-cog`,[[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`m14.305 7.53.923-.382`,key:`1mlnsw`}],[`path`,{d:`m15.228 4.852-.923-.383`,key:`82mpwg`}],[`path`,{d:`m16.852 3.228-.383-.924`,key:`ln4sir`}],[`path`,{d:`m16.852 8.772-.383.923`,key:`1dejw0`}],[`path`,{d:`m19.148 3.228.383-.924`,key:`192kgf`}],[`path`,{d:`m19.53 9.696-.382-.924`,key:`fiavlr`}],[`path`,{d:`m20.772 4.852.924-.383`,key:`1j8mgp`}],[`path`,{d:`m20.772 7.148.924.383`,key:`zix9be`}],[`path`,{d:`M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7`,key:`1tnzv8`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}]]),Ln=G(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),Rn=G(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),zn=G(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),Bn=G(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]);function Vn(){let e=rt(),t=pe(),[n,r]=(0,J.useState)(``),[i,a]=(0,J.useState)(s),o=()=>{n.trim()&&t.mutate({name:n.trim(),branch_prefix:i.trim()},{onSuccess:e=>Ge(e.id)})},c=(e.data?.length??0)>0;return(0,Y.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,Y.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-16`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,Y.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Who is working?`})]}),c&&(0,Y.jsx)(`div`,{className:`flex flex-col`,children:e.data.map(e=>(0,Y.jsxs)(`button`,{onClick:()=>Ge(e.id),className:`flex items-center gap-3 rounded-md px-3 py-2.5 text-left transition-colors hover:bg-elevated active:bg-border/70`,children:[(0,Y.jsx)(_,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,Y.jsx)(`span`,{className:R(`text-base`,f(e.icon_colour)||`text-fg`),children:e.name}),e.branch_prefix&&(0,Y.jsxs)(`span`,{className:`ml-auto text-2xs text-fg-muted`,children:[e.branch_prefix,`…`]})]},e.id))}),(0,Y.jsxs)(`form`,{className:`flex flex-col gap-5`,onSubmit:e=>{e.preventDefault(),o()},children:[c&&(0,Y.jsx)(`p`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`or create a profile`}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(p,{htmlFor:`profile-name`,children:`Name`}),(0,Y.jsx)(z,{id:`profile-name`,placeholder:`e.g. alice`,value:n,onChange:e=>r(e.target.value),className:`h-10`,autoFocus:!c})]}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Y.jsx)(p,{htmlFor:`branch-prefix`,children:`Branch prefix`}),(0,Y.jsx)(z,{id:`branch-prefix`,placeholder:`no prefix`,value:i,onChange:e=>a(e.target.value),className:`h-10`})]}),t.error&&(0,Y.jsx)(`p`,{className:`text-xs text-danger`,children:t.error.message}),(0,Y.jsx)(W,{type:`submit`,size:`lg`,className:`self-start px-6`,disabled:!n.trim()||t.isPending,children:`Create profile`})]})]})})}var Hn=1,Un=.9,Wn=.8,Gn=.17,Kn=.1,qn=.999,Jn=.9999,Yn=.99,Xn=/[\\\/_+.#"@\[\(\{&]/,Zn=/[\\\/_+.#"@\[\(\{&]/g,Qn=/[\s-]/,$n=/[\s-]/g;function er(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Hn:Yn;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=er(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Hn:Xn.test(e.charAt(l-1))?(d*=Wn,p=e.slice(i,l-1).match(Zn),p&&i>0&&(d*=qn**+p.length)):Qn.test(e.charAt(l-1))?(d*=Un,m=e.slice(i,l-1).match($n),m&&i>0&&(d*=qn**+m.length)):(d*=Gn,i>0&&(d*=qn**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=Jn)),(d<Kn&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=er(e,t,n,r,l+1,a+2,o),f*Kn>d&&(d=f*Kn)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function tr(e){return e.toLowerCase().replace($n,` `)}function nr(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,er(e,t,tr(e),tr(t),0,0,{})}var rr=`[cmdk-group=""]`,ir=`[cmdk-group-items=""]`,ar=`[cmdk-group-heading=""]`,or=`[cmdk-item=""]`,sr=`${or}:not([aria-disabled="true"])`,cr=`cmdk-item-select`,lr=`data-value`,ur=(e,t,n)=>nr(e,t,n),dr=J.createContext(void 0),fr=()=>J.useContext(dr),pr=J.createContext(void 0),mr=()=>J.useContext(pr),hr=J.createContext(void 0),gr=J.forwardRef((e,t)=>{let n=Q(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Q(()=>new Set),i=Q(()=>new Map),a=Q(()=>new Map),o=Q(()=>new Set),s=Or(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=I(),y=I(),b=I(),x=J.useRef(null),S=Ar();Z(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Z(()=>{S(6,ee)},[]);let C=J.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=k()?.id,C.emit()}),r||S(5,ee),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=J.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=k();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??ur;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;A().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(ir);t?t.appendChild(e.parentElement===t?e:e.closest(`${ir} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${ir} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${rr}[${lr}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=A().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(lr);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function ee(){var e;let t=k();t&&(t.parentElement?.firstChild===t&&((e=t.closest(rr)?.querySelector(ar))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function k(){return x.current?.querySelector(`${or}[aria-selected="true"]`)}function A(){return Array.from(x.current?.querySelectorAll(sr)||[])}function te(e){let t=A()[e];t&&C.setState(`value`,t.getAttribute(lr))}function ne(e){var t;let n=k(),r=A(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(lr))}function re(e){let t=k()?.closest(rr),n;for(;t&&!n;)t=e>0?Er(t,rr):Dr(t,rr),n=t?.querySelector(sr);n?C.setState(`value`,n.getAttribute(lr)):ne(e)}let j=()=>te(A().length-1),ie=e=>{e.preventDefault(),e.metaKey?j():e.altKey?re(1):ne(1)},M=e=>{e.preventDefault(),e.metaKey?te(0):e.altKey?re(-1):ne(-1)};return J.createElement(L.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&ie(e);break;case`ArrowDown`:ie(e);break;case`p`:case`k`:g&&e.ctrlKey&&M(e);break;case`ArrowUp`:M(e);break;case`Home`:e.preventDefault(),te(0);break;case`End`:e.preventDefault(),j();break;case`Enter`:{e.preventDefault();let t=k();if(t){let e=new Event(cr);t.dispatchEvent(e)}}}}},J.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:Nr},c),Mr(e,e=>J.createElement(pr.Provider,{value:C},J.createElement(dr.Provider,{value:w},e))))}),_r=J.forwardRef((e,t)=>{let n=I(),r=J.useRef(null),i=J.useContext(hr),a=fr(),o=Or(e),s=o.current?.forceMount??i?.forceMount;Z(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=kr(n,r,[e.value,e.children,r],e.keywords),l=mr(),u=$(e=>e.value&&e.value===c.current),d=$(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);J.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(cr,f),()=>t.removeEventListener(cr,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return J.createElement(L.div,{ref:xt(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),vr=J.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=I(),s=J.useRef(null),c=J.useRef(null),l=I(),u=fr(),d=$(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));Z(()=>u.group(o),[]),kr(o,s,[e.value,e.heading,c]);let f=J.useMemo(()=>({id:o,forceMount:i}),[i]);return J.createElement(L.div,{ref:xt(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&J.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),Mr(e,e=>J.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},J.createElement(hr.Provider,{value:f},e))))}),yr=J.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=J.useRef(null),a=$(e=>!e.search);return!n&&!a?null:J.createElement(L.div,{ref:xt(i,t),...r,"cmdk-separator":``,role:`separator`})}),br=J.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=mr(),o=$(e=>e.search),s=$(e=>e.selectedItemId),c=fr();return J.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),J.createElement(L.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),xr=J.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=J.useRef(null),o=J.useRef(null),s=$(e=>e.selectedItemId),c=fr();return J.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),J.createElement(L.div,{ref:xt(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Mr(e,e=>J.createElement(`div`,{ref:xt(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),Sr=J.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return J.createElement(an,{open:n,onOpenChange:r},J.createElement(sn,{container:o},J.createElement(nn,{"cmdk-overlay":``,className:i}),J.createElement(tn,{"aria-label":e.label,"cmdk-dialog":``,className:a},J.createElement(gr,{ref:t,...s}))))}),Cr=J.forwardRef((e,t)=>$(e=>e.filtered.count===0)?J.createElement(L.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),wr=J.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return J.createElement(L.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Mr(e,e=>J.createElement(`div`,{"aria-hidden":!0},e)))}),Tr=Object.assign(gr,{List:xr,Item:_r,Input:br,Group:vr,Separator:yr,Dialog:Sr,Empty:Cr,Loading:wr});function Er(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function Dr(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function Or(e){let t=J.useRef(e);return Z(()=>{t.current=e}),t}var Z=typeof window>`u`?J.useEffect:J.useLayoutEffect;function Q(e){let t=J.useRef();return t.current===void 0&&(t.current=e()),t}function $(e){let t=mr(),n=()=>e(t.snapshot());return J.useSyncExternalStore(t.subscribe,n,n)}function kr(e,t,n,r=[]){let i=J.useRef(),a=fr();return Z(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(lr,s),i.current=s}),i}var Ar=()=>{let[e,t]=J.useState(),n=Q(()=>new Map);return Z(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function jr(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Mr({asChild:e,children:t},n){return e&&J.isValidElement(t)?J.cloneElement(jr(t),{ref:t.ref},n(t.props.children)):n(t)}var Nr={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Pr({className:e,...t}){return(0,Y.jsx)(Tr,{className:R(`flex size-full flex-col overflow-hidden rounded-lg bg-elevated`,e),...t})}function Fr({open:e,onOpenChange:t,children:n}){return(0,Y.jsx)(on,{open:e,onOpenChange:t,children:(0,Y.jsx)(rn,{className:`max-w-lg overflow-hidden p-0 [&>button]:hidden`,children:(0,Y.jsx)(Pr,{loop:!0,children:n})})})}function Ir({className:e,...t}){return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-3 pt-1`,children:[(0,Y.jsx)(Ut,{className:`size-4 shrink-0 text-fg-muted`}),(0,Y.jsx)(Tr.Input,{className:R(`flex h-10 w-full bg-transparent text-sm text-fg outline-none placeholder:text-fg-muted`,e),...t})]})}function Lr({className:e,...t}){return(0,Y.jsx)(Tr.List,{className:R(`max-h-72 overflow-y-auto p-1`,e),...t})}function Rr(e){return(0,Y.jsx)(Tr.Empty,{className:`py-6 text-center text-sm text-fg-muted`,...e})}function zr({className:e,...t}){return(0,Y.jsx)(Tr.Group,{className:R(`overflow-hidden [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-2xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:uppercase [&_[cmdk-group-heading]]:tracking-wide [&_[cmdk-group-heading]]:text-fg-muted`,e),...t})}function Br({className:e,...t}){return(0,Y.jsx)(Tr.Item,{className:R(wt,St,`[&_svg]:size-3.5 [&_svg]:text-fg-muted data-[selected=true]:[&_svg]:text-action-ink`,e),...t})}function Vr({className:e,...t}){return(0,Y.jsx)(`span`,{className:R(`ml-auto font-mono text-2xs tracking-widest text-fg-muted`,e),...t})}var Hr=new class{transport;reload;pause;phase=`idle`;pending=null;constructor(e=fetch,t=()=>window.location.reload(),n=e=>new Promise(t=>setTimeout(t,e))){this.transport=e,this.reload=t,this.pause=n}refresh(e=12e4){return this.pending||=this.run(e).finally(()=>{this.pending=null}),this.pending}async run(e){this.phase=`requesting`;let t={authorization:`Bearer ${u.get()??``}`,"content-type":`application/json`};try{let n=await this.transport(`/cockpit/refresh`,{method:`POST`,headers:t,signal:AbortSignal.timeout(1e4),body:JSON.stringify({refreshId:crypto.randomUUID()})});if(n.status!==202)throw Error(`refresh rejected`);let r=d.parse(await n.json());this.phase=`waiting`;let i=Date.now()+e;for(;Date.now()<i;){await this.pause(1e3);try{let e=await this.transport(`/cockpit/status`,{headers:t,cache:`no-store`,signal:AbortSignal.timeout(3e3)});if(!e.ok)continue;let n=c.parse(await e.json());if(n.instance===r.instance||n.refreshId!==r.refreshId||n.upstream!==`ready`)continue;return this.phase=`complete`,this.reload(),!0}catch{}}}catch{}return this.phase=`failed`,!1}},Ur=null;function Wr(e){return Ur=e,()=>{Ur===e&&(Ur=null)}}function Gr(){Ur?.()}var Kr=new Set;function qr(){return[...Kr].flatMap(e=>e())}function Jr({onNewSession:e,onNewProject:t}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(`commands`),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(!1),f=gt(),p=mt(),m=N(),h=p.id,g=ze(m??void 0),_=Ie(m??void 0),v=ce(h),b=It();(0,J.useEffect)(()=>it(`palette.toggle`,()=>r(e=>!e)),[]),(0,J.useEffect)(()=>Dt(()=>r(!0)),[]),(0,J.useEffect)(()=>{n||(a(`commands`),s(``),l(null),d(!1))},[n]);let x=(0,J.useMemo)(()=>{let n=[],r=yt((g.data??[]).filter(e=>!e.archived),_.data?.projectOrder??[]);for(let e of r)n.push({id:`project-${e.id}`,group:`Projects`,label:e.name,icon:_t,keywords:`switch project open`,run:()=>void f(`/project/${e.id}`)});for(let e of v.data??[])e.status!==`archived`&&n.push({id:`session-${e.id}`,group:`Sessions`,label:b(e),icon:ut,keywords:`switch session ${e.branch}`,run:()=>void f(`/project/${e.project_id}/session/${e.id}`)});return h!==void 0&&e&&n.push({id:`new-agent`,group:`Actions`,label:`New agent`,icon:$t,keywords:`new agent create start session`,run:()=>e()},{id:`new-terminal`,group:`Actions`,label:`New terminal`,icon:ut,keywords:`new terminal create start shell session`,run:()=>e({kind:`terminal`})}),h!==void 0&&n.push({id:`open-path`,group:`Actions`,label:`Open path`,icon:_t,keywords:`open path file directory folder editor tree browse absolute relative home`,closeOnRun:!1,run:()=>{s(``),l(null),a(`path`)}}),t&&n.push({id:`new-project`,group:`Actions`,label:`New project`,icon:Et,keywords:`new project open create repository repo workspace`,run:t}),n.push({id:`theme-dark`,group:`Theme`,label:`Switch theme: dark`,icon:y,keywords:`switch theme dark appearance`,run:()=>void j(`dark`)},{id:`theme-light`,group:`Theme`,label:`Switch theme: light`,icon:S,keywords:`switch theme light appearance`,run:()=>void j(`light`)},{id:`theme-system`,group:`Theme`,label:`Switch theme: system`,icon:In,keywords:`switch theme system appearance`,run:()=>void j(`system`)},{id:`open-settings`,group:`Actions`,label:`Settings`,icon:Bn,keywords:`open settings preferences options configure`,run:()=>Xt()},{id:`switch-profile`,group:`Actions`,label:`Switch profile`,icon:Zt,keywords:`switch profile identity user change`,run:()=>we.set(null)},{id:`refresh-connection`,group:`Actions`,label:`Refresh connection`,icon:Yt,keywords:`refresh connection reconnect restart cockpit tunnel ssh daemon`,run:()=>Gr()}),[...n,...qr()]},[g.data,_.data?.projectOrder,v.data,h,f,e,t,b]),C=(0,J.useMemo)(()=>{let e=new Map;for(let t of x){let n=e.get(t.group)??[];n.push(t),e.set(t.group,n)}return[...e.entries()]},[x]),w=async()=>{let e=o.trim();if(!(e===``||u)){d(!0),l(null);try{await Ft(e),r(!1)}catch(e){l(e instanceof Error?e.message:`Could not open that path.`)}finally{d(!1)}}};return(0,Y.jsxs)(Fr,{open:n,onOpenChange:r,children:[(0,Y.jsx)(Ir,{value:o,onValueChange:e=>{s(e),l(null)},placeholder:i===`path`?`Enter a path…`:`Type a command or search…`,onKeyDown:e=>{i===`path`&&(e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),w()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),a(`commands`),s(``),l(null)))}}),i===`path`?(0,Y.jsx)(Lr,{children:(0,Y.jsxs)(`div`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[(0,Y.jsx)(`p`,{children:`Relative paths start from the bound worktree or project. Absolute and ~ paths work too.`}),(0,Y.jsx)(`p`,{className:c?`mt-2 text-danger`:`mt-2`,"aria-live":`polite`,children:c??(u?`Opening…`:`Press Enter to open.`)})]})}):(0,Y.jsxs)(Lr,{children:[(0,Y.jsx)(Rr,{children:`Nothing matches.`}),C.map(([e,t])=>(0,Y.jsx)(zr,{heading:e,children:t.map(e=>{let t=e.icon;return(0,Y.jsxs)(Br,{value:`${e.label} ${e.keywords??``}`,onSelect:()=>{e.closeOnRun!==!1&&r(!1),e.run()},children:[t&&(0,Y.jsx)(t,{}),e.label,e.shortcut&&(0,Y.jsx)(Vr,{children:e.shortcut})]},e.id)})},e))]})]})}function Yr(){let e=document.activeElement;return e instanceof Element&&e.closest(`.xterm`)!==null}function Xr(){let e=document.activeElement;return e instanceof Element&&e.closest(`.monaco-editor`)!==null}function Zr(){let e=Ie(N()??void 0).data?.hotkeys;return(0,J.useEffect)(()=>{ke(e&&typeof e==`object`?e:void 0)},[e]),(0,J.useEffect)(()=>it(`window.close`,()=>{let e=Ke();e?.closeWindow?e.closeWindow():window.close()}),[]),(0,J.useEffect)(()=>{let e=e=>{let t=nt(e);if(!t)return;let n=Fe(t);if(!n)return;let r=Re(n);if(!r||!ue(r,Xr()))return;let i=at(n);i&&(e.preventDefault(),e.stopPropagation(),i())},t=e=>{let t=nt(e);if(!t)return;let n=Fe(t);if(!n)return;let r=Re(n);if(!r||r.editor&&Xr()||r.deferInTerminal&&Yr())return;let i=at(n);i&&(e.preventDefault(),i())};return window.addEventListener(`keydown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,e,!0),window.removeEventListener(`keydown`,t)}},[]),null}var Qr=4e3;function $r(){let[e,t]=(0,J.useState)(`hidden`),n=(0,J.useRef)(e);n.current=e,(0,J.useEffect)(()=>{let e=null,r=q.onConnectionChange(r=>{if(r){e!==null&&clearTimeout(e),e=null,n.current===`lost`&&t(`hidden`);return}e!==null||n.current!==`hidden`||(e=setTimeout(()=>{e=null,n.current===`hidden`&&t(`lost`)},Qr))});return()=>{r(),e!==null&&clearTimeout(e)}},[]);let r=(0,J.useCallback)(async()=>{n.current!==`refreshing`&&(t(`refreshing`),await Hr.refresh()||(M.error(`The cockpit has not come back — it may need a terminal (ssh re-auth): puddle refresh`),t(q.isConnected()?`hidden`:`lost`)))},[]);return(0,J.useEffect)(()=>Wr(()=>void r()),[r]),e===`hidden`?null:(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 bg-elevated px-3 py-2`,children:[(0,Y.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:e===`refreshing`?`Restarting the cockpit.`:`Connection to the daemon lost.`}),e===`lost`&&(0,Y.jsxs)(W,{size:`sm`,className:`ml-auto`,onClick:()=>void r(),children:[(0,Y.jsx)(Yt,{}),`Refresh connection`]})]})}function ei({label:e,percentage:t,hint:n}){let r=Math.max(0,Math.min(100,t));return(0,Y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`w-24 shrink-0 truncate text-2xs text-fg-muted`,title:e,children:e}),(0,Y.jsx)(`span`,{className:`relative h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-border`,children:(0,Y.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full ${r>=90?`bg-danger`:r>=75?`bg-warning`:`bg-action`}`,style:{width:`${r}%`}})}),(0,Y.jsxs)(`span`,{className:`shrink-0 text-2xs tabular-nums text-fg-muted`,children:[Math.round(r),`%`,n?` · ${n}`:``]})]})}function ti(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function ni(e){if(e===null)return`never`;let t=new Date(e).getTime(),n=Math.max(0,Math.round((Date.now()-t)/1e3));if(n<60)return`just now`;let r=Math.round(n/60);if(r<60)return`${r}m ago`;let i=Math.round(r/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}function ri({account:e,onLogin:t,onStartSession:n,installed:r=!0}){let i=he(e.id),a=e.logged_in?n:r?t:null,o=i.data?.subscription;return(0,Y.jsxs)(`div`,{className:`rounded-md px-2 py-2 transition-colors hover:bg-elevated`,children:[(0,Y.jsxs)(`button`,{type:`button`,disabled:a===null,onClick:()=>a?.(),className:`flex w-full items-center gap-3 text-left disabled:cursor-default`,children:[(0,Y.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${e.logged_in?`bg-success`:`bg-idle`}`,"aria-hidden":!0}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.label}),(0,Y.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[e.logged_in?`logged in`:`logged out`,i.data&&(0,Y.jsxs)(Y.Fragment,{children:[` · `,i.data.session_count,` session`,i.data.session_count===1?``:`s`,i.data.active_session_count>0&&` (${i.data.active_session_count} active)`,` · `,`last `,ni(i.data.last_activity_at)]})]}),i.data?.agent_usage&&(0,Y.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[ti(i.data.agent_usage.input_tokens),` in ·`,` `,ti(i.data.agent_usage.output_tokens),` out ·`,` `,ti(i.data.agent_usage.cache_read_input_tokens),` cached ·`,` `,i.data.agent_usage.message_count,` msgs`]}),i.data?.live_usage?.context_used_percentage!=null&&(0,Y.jsx)(`span`,{className:`mt-1 block`,children:(0,Y.jsx)(ei,{label:`context`,percentage:i.data.live_usage.context_used_percentage})})]}),(0,Y.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted`,children:r?e.logged_in?n?`new agent`:``:(0,Y.jsxs)(`span`,{className:`flex items-center gap-1 text-warning`,children:[(0,Y.jsx)(v,{className:`size-3`}),`sign in`]}):`unavailable`})]}),o!=null&&o.windows.length>0&&(0,Y.jsx)(`div`,{className:`mt-2 flex flex-col gap-1 pl-5`,children:o.windows.map(e=>(0,Y.jsx)(ei,{label:e.label,percentage:e.used_percentage,hint:e.resets==null?void 0:`resets ${e.resets}`},e.key))})]})}function ii(){let[e,t]=(0,J.useState)(!1),[n,r]=(0,J.useState)(!1),i=N(),a=rt(),o=He(),s=a.data?.find(e=>e.id===i),c=be(i??void 0),l=De(),u=Qe(),{open:d,handler:p}=At(),[m,h]=(0,J.useState)(null),v=e=>u.mutate(e.id,{onSuccess:t=>h({stream:t.stream,label:`${e.agent_type}/${e.label}`}),onError:e=>K(e)}),y=e=>{t(!1),d({accountId:e.id})};return n&&s?(0,Y.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-3`,children:[(0,Y.jsx)(_,{icon:s.icon,colour:s.icon_colour}),(0,Y.jsx)(zt,{initial:s.name,maxLength:100,className:R(`w-32 text-sm`,f(s.icon_colour)),onCommit:e=>{r(!1);let t=e.trim();!i||!t||t===s?.name||o.mutate({id:i,name:t},{onError:e=>K(e)})},onCancel:()=>r(!1)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(un,{open:e,onOpenChange:t,children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsx)(ln,{asChild:!0,children:(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,className:`font-sans compact:h-7 compact:px-1.5`,children:[(0,Y.jsx)(_,{icon:s?.icon,colour:s?.icon_colour}),(0,Y.jsx)(`span`,{className:f(s?.icon_colour),...Jt(()=>{t(!1),r(!0)}),children:s?.name??`…`})]})})}),(0,Y.jsx)(V,{children:`Profile`})]}),(0,Y.jsxs)(cn,{className:`w-[28rem] max-w-[calc(100vw-1rem)]`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(l.data??[]).map(e=>{let t=c.data?.filter(t=>t.agent_type===e.id)??[];if(t.length===0)return null;let n=e.available!==!1;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,Y.jsxs)(`span`,{className:`px-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:[e.display_name,!n&&(0,Y.jsxs)(`span`,{className:`ml-2 normal-case tracking-normal text-fg-muted`,children:[`not installed — no `,e.binary??e.id,` on PATH`]})]}),t.map(e=>(0,Y.jsx)(ri,{account:e,onLogin:()=>v(e),onStartSession:p&&n?()=>y(e):null,installed:n},e.id))]},e.id)}),c.data?.length===0&&(0,Y.jsx)(`p`,{className:`px-2 text-sm text-fg-muted`,children:`No accounts yet — add one in settings.`})]}),(0,Y.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,onClick:()=>{t(!1),Xt(`accounts`)},children:[(0,Y.jsx)(Et,{}),`Add account`]}),(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,className:`ml-auto`,onClick:()=>{t(!1),we.set(null)},children:[(0,Y.jsx)(zn,{}),`Switch profile`]})]})]})]}),m&&(0,Y.jsx)(g,{stream:m.stream,label:m.label,onClose:()=>h(null)})]})}var ai=`desktop-update`;function oi(){let e=(0,J.useRef)(null);return(0,J.useEffect)(()=>{let t=Ke();if(t?.updateReady===void 0||t.onUpdateReady===void 0)return;let n=t=>{e.current!==t&&(e.current=t,M(`Puddle ${t} is downloaded and ready.`,{id:ai,duration:1/0,closeButton:!0,action:{label:`Restart to update`,onClick:()=>{Ke()?.installUpdate?.(),M.loading(`Restarting into Puddle ${t}…`,{id:`${ai}-restarting`,duration:1/0})}}}))};return t.updateReady().then(e=>{e!==null&&n(e)}),t.onUpdateReady(n)},[]),null}function si(){let e=N(),t=rt().data?.find(t=>t.id===e),n=Ie(e??void 0),r=fe(e??void 0,void 0),i=D(),a=C(),o=w(),s=Ye(e??``),c=He(),l=_e(),[u,d]=(0,J.useReducer)(e=>e+1,0);(0,J.useEffect)(()=>A(()=>d()),[]);let f=(0,J.useRef)(null);(0,J.useEffect)(()=>{f.current=null},[t?.name]);let p=a.data?.available===!0?a.data.file:void 0,m=t!==void 0&&e!==null&&n.data!==void 0&&r.data!==void 0&&p!==void 0,g=t&&p?h(p,t.name):void 0,_=s.isPending||c.isPending||l.isPending||o.isPending||n.isFetching||r.isFetching;(0,J.useEffect)(()=>{if(!m||!g?.enabled||_)return;let a={client:i,theme:ne(),profileSettings:n.data,profile:t,scratchpad:r.data},u={setClient:e=>O(e),setTheme:e=>{typeof e==`string`&&j(e)},patchProfileSettings:e=>s.mutate(e),patchProfileColumns:t=>c.mutate({id:e,...t}),createScratchpad:t=>{for(let n of t)l.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},d=JSON.stringify(g.doc);if(f.current!==d){f.current=d,x(g.doc,u,a,g.groups);return}let p=E(g.groups,a),h=JSON.stringify(p);h!==d&&(f.current=h,o.mutate({profile:t.name,entry:{...g,doc:p,updatedAt:new Date().toISOString()}}))})}function ci(e){let t=t=>{let n=o.safeParse(t);n.success&&e(n.data)},n=Ke()?.onNotificationClick?.((e,n)=>t(n)),r=e=>{e.data?.t===`notification-click`&&t(e.data.target)};return navigator.serviceWorker?.addEventListener(`message`,r),()=>{n?.(),navigator.serviceWorker?.removeEventListener(`message`,r)}}var li=5e3,ui=`[data-notification-session]`;function di(e){let t=null,n=()=>{t=null},r=e=>e.target instanceof Element?e.target.closest(ui):null,i=e=>{if(!e.isTrusted)return;let n=r(e),i=n?.dataset.notificationSession;t=n&&i?{element:n,session:i,at:performance.now()}:null},a=e=>{r(e)!==t?.element&&n()},o=[`pointerdown`,`keydown`,`input`,`paste`];for(let t of o)e.addEventListener(t,i,!0);return e.addEventListener(`focusin`,a,!0),e.addEventListener(`visibilitychange`,n),e.defaultView?.addEventListener(`blur`,n),{isInteracting(n){return t!==null&&t.session===n&&performance.now()-t.at<li&&e.visibilityState===`visible`&&e.hasFocus()&&t.element.isConnected&&t.element.dataset.notificationSession===n&&t.element.getClientRects().length>0},dispose(){n();for(let t of o)e.removeEventListener(t,i,!0);e.removeEventListener(`focusin`,a,!0),e.removeEventListener(`visibilitychange`,n),e.defaultView?.removeEventListener(`blur`,n)}}}var fi=new Set,pi=e=>!!e&&fi.has(e),mi=i.parse({});function hi(e){return e.prefs.muted_projects.includes(e.projectId)?{desktop:!1,sound:!1}:{desktop:e.prefs.desktop&&(e.permission===`granted`||e.permission===`unverified`)&&(e.prefs.when_focused||!e.sessionFocused),sound:e.prefs.sound}}function gi(e,t){for(let[,n]of e.getQueriesData({queryKey:[`sessions`]})){let e=n?.find(e=>e.id===t);if(e)return e}for(let[,n]of e.getQueriesData({queryKey:[`project`]})){let e=n?.sessions.find(e=>e.id===t);if(e)return e}}function _i(e){return e.title??e.agent_title??e.osc_title??e.id.slice(0,8)}function vi(){try{let e=new AudioContext,t=e.createGain();t.gain.value=.04,t.connect(e.destination);for(let[n,r]of[[880,0],[1318.5,.09]]){let i=e.createOscillator();i.type=`sine`,i.frequency.value=n,i.connect(t),i.start(e.currentTime+r),i.stop(e.currentTime+r+.12)}setTimeout(()=>void e.close(),400)}catch{}}function yi(){let e=gt(),t=(0,J.useRef)(null);(0,J.useEffect)(()=>{let e=di(document);return t.current=e,()=>{t.current=null,e.dispose()}},[]),(0,J.useEffect)(()=>ci(t=>{t.host||e(`/project/${t.project}/session/${t.session}`,{state:{notificationSession:t.session}})}),[e]),bi(t=>{e(`/project/${t.project_id}/session/${t.id}`,{state:{notificationSession:t.id}})},e=>t.current?.isInteracting(e.id)??!1)}function bi(e,t=()=>document.hasFocus()){let n=xe(),r=(0,J.useRef)(e);r.current=e;let a=(0,J.useRef)(t);a.current=t;let o=Ce(Le().data)??`Puddle`,s=(0,J.useRef)(o);(0,J.useEffect)(()=>{document.title===s.current&&(document.title=o),s.current=o},[o]),(0,J.useEffect)(()=>{let e=new Set,t=()=>{document.title=e.size>0?`(${e.size}) ${s.current}`:s.current},o=!0,c=async e=>{let t=gi(n,e.session);if(!t)try{t=(await We(n)).find(t=>t.id===e.session)}catch{return}if(!o||!t)return;let c=t,u,d;try{let e=await n.fetchQuery({queryKey:[`project`,c.project_id],queryFn:()=>ie(`GET`,`/api/projects/${c.project_id}`),staleTime:1e4});if(!o)return;d=e.project;let t=d.profile_id,r=await n.fetchQuery({queryKey:[`profile-settings`,t],queryFn:()=>ie(`GET`,`/api/profiles/${t}/settings`),staleTime:1e4});u=i.catch(mi).parse(r.notifications??{})}catch{return}if(!o)return;let f=hi({prefs:u,projectId:c.project_id,sessionFocused:a.current(c),permission:b()});f.sound&&vi(),f.desktop&&!pi(l()?.scope)&&await T({id:e.id?`puddle-event-${e.id}`:`puddle-agent-${c.id}`,title:e.content?.title??_i(c).slice(0,160),body:e.content?.body??(e.reason===`exited`?`Agent finished running`:`Waiting for your input`),target:{project:c.project_id,session:c.id,...l()?.notificationHost?{host:l().notificationHost}:{}}},()=>{o&&r.current(c)},{host:s.current,project:d})},u=q.onAgentNotification(e=>{c(e)}),d=q.onStatus(r=>{let i=e.has(r.session);r.status===`waiting_input`?e.add(r.session):e.delete(r.session),t(),!(r.status!==`waiting_input`||i)&&n.fetchQuery({queryKey:[`version`],queryFn:()=>ie(`GET`,`/api/version`),staleTime:1/0}).then(e=>{if(!(e.protocol.major>22||e.protocol.major===22&&e.protocol.minor>=3))return c({session:r.session,reason:`waiting_input`})}).catch(()=>{})});return()=>{o=!1,d(),u(),document.title=s.current}},[n])}function xi({initial:e,defaultScope:t,allowProject:n=!0,agents:r,onSave:i,onCancel:a}){let[o,s]=(0,J.useState)(e?.title??``),[c,l]=(0,J.useState)(e?.body??``),[u,d]=(0,J.useState)(n?e?.scope??t:`profile`),[f,p]=(0,J.useState)((e?.tags??[]).join(`, `)),[m,h]=(0,J.useState)(e?.agent_type??null),g=()=>{let e=c.trim();e&&i({title:o.trim()||null,body:e,scope:u,tags:f.split(`,`).map(e=>e.trim()).filter(Boolean),agent_type:m})};return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Y.jsx)(z,{value:o,placeholder:`Title (optional)`,spellCheck:!1,onChange:e=>s(e.target.value),onKeyDown:e=>e.stopPropagation(),className:`h-9 text-sm font-medium`}),(0,Y.jsx)(Ct,{autoFocus:!0,value:c,placeholder:`Prompt or note…`,spellCheck:!1,rows:10,onChange:e=>l(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`?a():e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&g()},className:`resize-y text-sm leading-relaxed`}),(0,Y.jsx)(z,{value:f,placeholder:`tags, comma, separated`,spellCheck:!1,onChange:e=>p(e.target.value),onKeyDown:e=>e.stopPropagation(),className:`h-8 text-xs`}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-2xs text-fg-secondary`,children:[(0,Y.jsx)(Qt,{checked:u===`profile`,onCheckedChange:e=>d(e?`profile`:`project`)}),`Profile-wide`]}),(0,Y.jsx)(`div`,{className:`ml-auto flex items-center gap-1`,children:r.map(e=>(0,Y.jsxs)(`button`,{type:`button`,title:e.display_name,"aria-pressed":m===e.id,onClick:()=>h(t=>t===e.id?null:e.id),className:R(`rounded-md p-1 transition-colors`,m===e.id?`bg-surface text-fg`:`text-fg-gold hover:bg-surface hover:text-fg`),children:[(0,Y.jsx)(jt,{type:e.id,className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:e.display_name})]},e.id))})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,onClick:a,children:`Cancel`}),(0,Y.jsx)(W,{size:`sm`,disabled:!c.trim(),onClick:g,children:`Save`})]})]})}function Si(){let e=Ot(),t=N(),n=mt().id,r=fe(t??void 0,n).data??[],i=De().data??[],a=_e(),o=Ue(),s=et(),c=Pt(),[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(null),[p,m]=(0,J.useState)(null),[h,g]=(0,J.useState)(null),[_,v]=(0,J.useState)(null);(0,J.useEffect)(()=>it(`scratchpad.toggle`,Nt),[]),(0,J.useEffect)(()=>{e||(u(null),f(null),m(null))},[e]);let y=(0,J.useMemo)(()=>[...new Set(r.flatMap(e=>e.tags))].sort((e,t)=>e.localeCompare(t)),[r]),b=(0,J.useMemo)(()=>[...new Set(r.map(e=>e.agent_type).filter(e=>e!==null))],[r]),x=d!==null||p!==null,S=r.filter(e=>(d===null||e.tags.includes(d))&&(p===null||e.agent_type===p)),C=x?S:_??r,w=e=>{t&&(a.mutate({profile_id:t,scope:e.scope,project_id:e.scope===`project`?n:void 0,title:e.title??void 0,body:e.body,tags:e.tags,agent_type:e.agent_type??void 0}),u(null))},T=(e,t)=>{o.mutate({id:e,scope:t.scope,project_id:t.scope===`project`?n??null:null,title:t.title,body:t.body,tags:t.tags,agent_type:t.agent_type}),u(null)},E=(e,t)=>{let n=_??r,i=n.findIndex(t=>t.id===e),a=n.findIndex(e=>e.id===t);if(i===-1||a===-1||i===a)return;let o=n.slice(),[s]=o.splice(i,1);o.splice(a,0,s),v(o)},D=()=>{let e=h,t=_;if(g(null),v(null),e===null||!t)return;let n=t.findIndex(t=>t.id===e);if(n===-1)return;let r=t[n-1],i=t[n+1],a=r?i?(r.position+i.position)/2:r.position+1:(i?i.position:0)-1;o.mutate({id:e,position:a})},O=e=>{navigator.clipboard?.writeText(e.body),M.success(`Copied to clipboard`)};return(0,Y.jsxs)(un,{open:e,onOpenChange:kt,children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsx)(ln,{asChild:!0,children:(0,Y.jsxs)(W,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,Y.jsx)(Ln,{}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Scratchpad`})]})})}),(0,Y.jsx)(V,{children:`Scratchpad`})]}),(0,Y.jsxs)(cn,{className:`w-[34rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,Y.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Scratchpad`}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>u(l===`new`?null:`new`),className:`ml-auto flex items-center rounded-md p-1 text-fg-gold transition-colors hover:bg-surface hover:text-fg`,children:[(0,Y.jsx)(Et,{className:`size-4`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`New entry`})]})]}),(y.length>0||b.length>0)&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:[y.map(e=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>f(t=>t===e?null:e),className:R(`rounded-full px-2 py-0.5 text-2xs transition-colors`,d===e?`bg-action text-action-ink`:`bg-surface text-fg-secondary hover:text-fg`),children:e},e)),b.map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>m(t=>t===e?null:e),className:R(`rounded-md p-1 transition-colors`,p===e?`bg-action text-action-ink`:`text-fg-gold hover:bg-surface`),children:(0,Y.jsx)(jt,{type:e,className:`size-3.5`})},e))]}),(0,Y.jsxs)(`div`,{className:`no-scrollbar max-h-[65vh] overflow-y-auto px-2 pb-3`,children:[l===`new`&&(0,Y.jsx)(`div`,{className:`px-3 py-2`,children:(0,Y.jsx)(xi,{defaultScope:n?`project`:`profile`,allowProject:n!==void 0,agents:i,onSave:w,onCancel:()=>u(null)})}),C.length===0&&l!==`new`&&(0,Y.jsx)(`p`,{className:`px-3 py-3 text-sm text-fg-muted`,children:x?`Nothing matches this filter.`:`No entries yet — press + to add a reusable prompt or note.`}),(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:C.map(e=>l===e.id?(0,Y.jsx)(`li`,{className:`px-3 py-2`,children:(0,Y.jsx)(xi,{initial:e,defaultScope:e.scope,allowProject:n!==void 0||e.scope===`project`,agents:i,onSave:t=>T(e.id,t),onCancel:()=>u(null)})},e.id):(0,Y.jsx)(`li`,{draggable:!x&&l===null,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,g(e.id)},onDragOver:t=>{h!==null&&(t.preventDefault(),h!==e.id&&E(h,e.id))},onDragEnd:D,className:R(`transition-opacity`,h===e.id&&`opacity-50`),children:(0,Y.jsx)(Ci,{entry:e,onInsert:c?()=>{c(e.body),kt(!1)}:null,onCopy:()=>O(e),onEdit:()=>u(e.id),onDelete:()=>s.mutate(e.id)})},e.id))})]})]})]})}function Ci({entry:e,onInsert:t,onCopy:n,onEdit:r,onDelete:i}){let[a,o]=(0,J.useState)(!1);return(0,Y.jsxs)(`div`,{onClick:e=>{e.target.closest(`button`)||r()},className:`cursor-pointer rounded-md px-3 py-2.5 transition-colors hover:bg-surface`,children:[e.title&&(0,Y.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.title}),(0,Y.jsx)(`p`,{className:R(`line-clamp-3 whitespace-pre-wrap text-sm text-fg-secondary`,e.title&&`mt-0.5`),children:e.body}),a?(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:`Delete this entry? This can’t be undone.`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),i()},className:`text-2xs font-medium text-interrupted transition-colors hover:underline`,children:`Delete`}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Cancel`})]}):(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:e.scope===`profile`?`Profile-wide`:`Project`}),e.agent_type&&(0,Y.jsx)(jt,{type:e.agent_type,className:`size-3 text-fg-gold`}),e.tags.map(e=>(0,Y.jsx)(`span`,{className:`rounded-full bg-surface px-1.5 text-2xs text-fg-secondary`,children:e},e)),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[t&&(0,Y.jsx)(wi,{icon:Pn,label:`Insert into focused terminal`,onClick:t}),(0,Y.jsx)(wi,{icon:lt,label:`Copy`,onClick:n}),(0,Y.jsx)(wi,{icon:m,label:`Edit`,onClick:r}),(0,Y.jsx)(wi,{icon:Tt,label:`Delete`,onClick:()=>o(!0)})]})]})]})}function wi({icon:e,label:t,onClick:n}){return(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,Y.jsx)(e,{className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,Y.jsx)(V,{children:t})]})}var Ti=a.parse({});function Ei(e,t){let[n,r]=(0,J.useState)(null),i=st(t).data,a=ze(e??void 0,t&&e!==null).data;return(0,J.useEffect)(()=>{if(!t||e===null){r(null);return}let n=!1,i;try{i=qt(sessionStorage.getItem(Kt(e)))}catch{i={kind:`absent`}}if(i.kind===`present`){r(i.snapshot);return}return Se(e).then(e=>{n||r(e?e.ui_state:Ti)}).catch(()=>{n||r(Ti)}),()=>{n=!0}},[t,e]),(0,J.useMemo)(()=>{if(!t||e===null||n===null)return null;let o=t=>{if(!i||!a)return!1;let{patch:o,projectBased:s}=Vt(n,t,{alive:new Set(i.filter(e=>e.status!==`archived`).map(e=>e.id)),sessionProject:new Map(i.map(e=>[e.id,e.project_id])),projectIds:a.map(e=>e.id),currentProject:null}),c={...n,...o};r(c),Te(e,c).catch(e=>console.warn(`ui-state save failed: ${e.message}`));try{sessionStorage.setItem(Kt(e),JSON.stringify(c))}catch(e){console.warn(`ui-state write failed: ${e.message}`)}return ee().projectBasedLayout!==s&&O({projectBasedLayout:s}),!0},s=Object.fromEntries(Object.entries(n.project_layouts).map(([e,t])=>[e,{layoutRef:t.layout_ref,signature:B(t.layout_tree)}]));return(n.layout_mode??`profile`)===`project`?{headless:!0,scope:`project`,projectId:``,layoutRef:null,signature:B(null),slices:s,capture:()=>({layout_tree:null,active_session:null}),apply:o}:{scope:`profile`,projectId:``,layoutRef:n.layout_ref,signature:B(n.layout_tree),slices:s,capture:()=>({layout_tree:n.layout_tree,active_session:n.active_session}),apply:o}},[t,e,n,i,a])}var Di=B(null);function Oi(){let e=Ht(),t=gt(),n=N(),r=Wt(),i=Ei(n,e&&r===null),a=r??i,o=Je(n??void 0,void 0).data??[],s=ze(n??void 0,e&&n!==null).data??[],c=je(),l=Be(),u=oe(),[d,f]=(0,J.useState)(``),[p,m]=(0,J.useState)(!1),[h,g]=(0,J.useState)(null);(0,J.useEffect)(()=>it(`layouts.toggle`,Bt),[]),(0,J.useEffect)(()=>{e||(f(``),m(!1),g(null))},[e]);let _=a?.headless===!0,v=a===null||_?null:o.find(e=>e.id===a.layoutRef)??null,y=a!==null&&!_&&(v===null?a.signature!==Di:B(v.layout_tree)!==a.signature),b=e=>{let t=a?.slices?.[e];if(!t)return!1;let n=t.layoutRef===null?null:o.find(e=>e.id===t.layoutRef)??null;return n?B(n.layout_tree)!==t.signature:t.signature!==Di},x=e=>a===null?!1:e.scope===`profile`?a.scope===`profile`&&y:e.project_id===null?!1:a.scope===`project`?!_&&e.project_id===a.projectId?y:b(e.project_id):y||b(e.project_id),S=e=>v!==null&&e.id===v.id,C=e=>(e===null?void 0:s.find(t=>t.id===e)?.name)??`Project`,w=a!==null&&!_&&a.scope===`project`?o.filter(e=>e.scope===`profile`||e.project_id===a.projectId):o,T=[...w.some(e=>e.scope===`profile`)?[{key:`profile`,name:`Profile-wide`}]:[],...[...new Set(w.flatMap(e=>e.project_id===null?[]:[e.project_id]))].map(e=>({key:e,name:C(e)})).sort((e,t)=>e.name.localeCompare(t.name))],E=h===null?w:h===`profile`?w.filter(e=>e.scope===`profile`):w.filter(e=>e.project_id===h),D=e=>a!==null&&e.scope===a.scope&&(a.scope===`profile`||e.project_id===a.projectId),O=(e,t,r)=>{!a||!n||c.mutate({profile_id:n,scope:a.scope,project_id:a.scope===`project`?a.projectId:void 0,name:e,...t},{onSuccess:e=>{r&&a.apply(e)},onError:e=>K(e)})},ee=e=>{if(!a)return;let t=D(e)?e:o.find(t=>t.name===e.name&&D(t));if(!t){O(e.name,a.capture(),!0);return}l.mutate({id:t.id,...a.capture()},{onSuccess:e=>a.apply(e),onError:e=>K(e)})},k=(e,t)=>O(t,{layout_tree:e.layout_tree,active_session:e.active_session},!1),A=e=>{if(a){if(!a.apply(e)){M.error(`Workspace is still loading — try again in a moment`);return}e.project_id!==null&&e.project_id!==a.projectId&&t(`/project/${e.project_id}`),Rt(!1)}};return(0,Y.jsxs)(un,{open:e,onOpenChange:Rt,children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsx)(ln,{asChild:!0,children:(0,Y.jsxs)(W,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,Y.jsx)(Fn,{}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Layouts`})]})})}),(0,Y.jsx)(V,{children:`Layouts`})]}),(0,Y.jsxs)(cn,{className:`w-[26rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,Y.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Layouts`}),a!==null&&!_&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>m(e=>!e),className:`ml-auto flex items-center rounded-md p-1 text-fg-gold transition-colors hover:bg-surface hover:text-fg`,children:[(0,Y.jsx)(Et,{className:`size-4`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Save the current layout as a new layout`})]})]}),a===null?(0,Y.jsx)(`p`,{className:`px-5 pb-3 text-sm text-fg-muted`,children:`Loading the profile’s layout state…`}):_?(0,Y.jsx)(`p`,{className:`px-5 pb-3 text-sm text-fg-muted`,children:`Project-based layout is on — every project keeps its own layout. Open a project to name or save it; loading works from here.`}):(v===null||p)&&(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2 px-5 pb-3`,children:[v===null&&(0,Y.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:`Unnamed layout`}),(0,Y.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:a.scope===`profile`?`Profile-wide`:`Project`}),(0,Y.jsx)(`span`,{className:`ml-auto text-2xs text-interrupted`,children:`Unsaved`})]}),(0,Y.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:e=>{e.preventDefault();let t=d.trim();t&&(O(t,a.capture(),!0),f(``),m(!1))},children:[(0,Y.jsx)(z,{autoFocus:p,value:d,placeholder:v===null?`Name this layout…`:`Save as a new layout…`,spellCheck:!1,onChange:e=>f(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&m(!1)},className:`h-8 flex-1 text-sm`}),(0,Y.jsx)(W,{size:`sm`,type:`submit`,disabled:!d.trim(),children:`Save`}),v!==null&&(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,onClick:()=>m(!1),children:`Cancel`})]})]}),T.length>1&&(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:T.map(e=>(0,Y.jsx)(ji,{active:h===e.key,onClick:()=>g(t=>t===e.key?null:e.key),children:e.name},e.key))}),(0,Y.jsxs)(`div`,{className:`no-scrollbar max-h-[60vh] overflow-y-auto px-2 pb-3`,children:[E.length===0&&(0,Y.jsx)(`p`,{className:`px-3 py-3 text-sm text-fg-muted`,children:h===null?`No layouts yet — name and save the current layout to keep it.`:`Nothing matches this filter.`}),(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:E.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsx)(ki,{layout:e,projectLabel:e.scope===`profile`?null:C(e.project_id),isCurrent:S(e),dirty:y,loadable:a!==null,savable:a!==null&&!_,confirmBeforeLoad:x(e),overwrites:D(e),onLoad:()=>A(e),onRename:t=>l.mutate({id:e.id,name:t}),onDelete:()=>u.mutate(e.id),onSaveAs:()=>ee(e),onDuplicate:t=>k(e,t)})},e.id))})]})]})]})}function ki({layout:e,projectLabel:t,isCurrent:n,dirty:r,loadable:i,savable:a,confirmBeforeLoad:o,overwrites:s,onLoad:c,onRename:l,onDelete:u,onSaveAs:d,onDuplicate:f}){let[p,h]=(0,J.useState)(null),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(e.name),b=()=>{if(!(!i||g!==null)){if(o&&p!==`load`){h(`load`);return}h(null),c()}},x=t=>{h(null),y(t===`rename`?e.name:`${e.name} copy`),_(t)},S=()=>{if(n){d();return}h(`save`)},C=n?r?`unsaved`:`active`:null;return(0,Y.jsxs)(`div`,{onClick:e=>{e.target.closest(`button, input`)||b()},className:R(`rounded-md px-3 py-2.5 transition-colors`,i&&`cursor-pointer hover:bg-surface`),children:[g===null?(0,Y.jsxs)(`p`,{className:R(`flex items-baseline gap-2 text-sm font-medium`,C===`active`?`text-success`:C===`unsaved`?`text-interrupted`:`text-fg`),children:[e.name,C!==null&&(0,Y.jsx)(`span`,{className:`text-2xs font-normal`,children:C===`active`?`Active`:`Unsaved`})]}):(0,Y.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:t=>{t.preventDefault();let n=v.trim();n&&(g===`rename`?n!==e.name&&l(n):f(n)),_(null)},children:[(0,Y.jsx)(z,{autoFocus:!0,value:v,spellCheck:!1,onChange:e=>y(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&_(null)},className:`h-7 flex-1 text-sm`}),(0,Y.jsx)(W,{size:`sm`,type:`submit`,disabled:!v.trim(),children:g===`rename`?`Rename`:`Save`})]}),p===`save`?(0,Y.jsx)(Ai,{question:s?`Overwrite “${e.name}” with the current layout?`:`Save the current layout as “${e.name}” here?`,verb:s?`Overwrite`:`Save`,onConfirm:()=>{h(null),d()},onCancel:()=>h(null)}):p===`delete`?(0,Y.jsx)(Ai,{question:`Delete this layout? This can’t be undone.`,verb:`Delete`,onConfirm:()=>{h(null),u()},onCancel:()=>h(null)}):p===`load`?(0,Y.jsx)(Ai,{question:`Loading discards unsaved layout changes.`,verb:`Load`,onConfirm:b,onCancel:()=>h(null)}):(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[t!==null&&(0,Y.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:t}),(0,Y.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[a&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Mi,{icon:Rn,label:n?`Save`:`Save the current layout as “${e.name}”`,onClick:S}),(0,Y.jsx)(Mi,{icon:lt,label:`Duplicate`,onClick:()=>x(`duplicate`)})]}),(0,Y.jsx)(Mi,{icon:m,label:`Rename`,onClick:()=>x(`rename`)}),(0,Y.jsx)(Mi,{icon:Tt,label:`Delete`,onClick:()=>h(`delete`)})]})]})]})}function Ai({question:e,verb:t,onConfirm:n,onCancel:r}){return(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,Y.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e}),(0,Y.jsx)(`button`,{type:`button`,onClick:n,className:`text-2xs font-medium text-interrupted transition-colors hover:underline`,children:t}),(0,Y.jsx)(`button`,{type:`button`,onClick:r,className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Cancel`})]})}function ji({active:e,onClick:t,children:n}){return(0,Y.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:t,className:R(`rounded-full px-2 py-0.5 text-2xs transition-colors`,e?`bg-action text-action-ink`:`bg-surface text-fg-secondary hover:text-fg`),children:n})}function Mi({icon:e,label:t,onClick:n}){return(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsxs)(`button`,{type:`button`,onClick:n,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,Y.jsx)(e,{className:`size-3.5`}),(0,Y.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,Y.jsx)(V,{children:t})]})}var Ni=Ke()!==void 0&&/Mac/.test(navigator.platform),Pi=(0,J.lazy)(()=>k(()=>import(`./SettingsDialog-LIv4FuS1.js`).then(e=>({default:e.SettingsDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29])));function Fi(){let e=xe();(0,J.useEffect)(()=>{let t=t=>{for(let[n,r]of e.getQueriesData({queryKey:[`sessions`]}))r&&e.setQueryData(n,r.map(t));for(let[n,r]of e.getQueriesData({queryKey:[`project`]}))r&&e.setQueryData(n,{...r,sessions:r.sessions.map(t)})},n=q.onStatus(e=>t(t=>t.id===e.session?{...t,status:e.status,last_activity_at:e.last_activity_at}:t)),r=q.onRenamed(e=>t(t=>t.id===e.session?{...t,title:e.title,agent_title:`agent_title`in e?e.agent_title:t.agent_title,osc_title:`osc_title`in e?e.osc_title:t.osc_title}:t)),i=q.onAccount(t=>{for(let[n,r]of e.getQueriesData({queryKey:[`accounts`]}))r&&e.setQueryData(n,r.map(e=>e.id===t.account_id?{...e,logged_in:t.logged_in}:e))}),a=t=>{e.invalidateQueries({queryKey:[`sessions`]});for(let n of t)e.invalidateQueries({queryKey:[`project`,n]})},o=q.onSessionsChanged(e=>a(e.project_ids)),s=q.onSessionSwitched(e=>a([e.target_project]));return()=>{n(),r(),i(),o(),s()}},[e])}function Ii(){let e=Le(),t=tt(),[n,r]=(0,J.useState)(!1),i=Ce(e.data),a=n=>{r(!1);let a=n.trim();a!==i&&t.mutate({displayName:a===e.data?.hostname?``:a},{onError:e=>K(e)})},o=!Ni&&(0,Y.jsx)(`img`,{src:`/puddle.svg`,alt:`Puddle`,className:`size-4`}),s=R(`flex shrink-0 items-center gap-2`,Ni&&`[-webkit-app-region:no-drag]`),c=`truncate text-sm font-semibold text-fg-secondary`;return n&&i!==void 0?(0,Y.jsxs)(`div`,{className:s,children:[o,(0,Y.jsx)(zt,{initial:e.data?.displayName??i,maxLength:64,className:R(c,`w-40`),onCommit:a,onCancel:()=>r(!1)})]}):(0,Y.jsxs)(ht,{to:`/`,className:R(s,`transition-opacity hover:opacity-70`),title:`All projects`,children:[o,i!==void 0&&(0,Y.jsx)(`span`,{className:c,...Jt(()=>r(!0)),children:i})]})}function Li(){let e=mt(),t=de(`palette.toggle`),n=ot(e.id).data?.project,r=n!==void 0&&n.id===e.id?n.name:void 0;return(0,Y.jsxs)(`button`,{type:`button`,onClick:Mt,className:R(`absolute left-1/2 flex h-6 w-[min(30rem,42%)] -translate-x-1/2 items-center justify-center gap-2 rounded-md bg-ground text-fg-muted transition-colors hover:bg-elevated hover:text-fg-secondary`,Ni&&`[-webkit-app-region:no-drag]`),children:[(0,Y.jsx)(`span`,{className:R(`truncate text-xs`,r&&f(n?.colour)),children:r??`Puddle`}),(0,Y.jsx)(`span`,{className:`text-2xs`,children:t})]})}function Ri(){let{fullScreen:e,animate:t}=Ze();return(0,Y.jsxs)(`header`,{className:R(`relative flex h-9 shrink-0 items-center gap-3 bg-surface pl-3 pr-3`,Ni&&!e&&`pl-[88px] [-webkit-app-region:drag]`,t&&`transition-[padding] duration-200 ease-out`),children:[(0,Y.jsx)(Ii,{}),(0,Y.jsx)(Li,{}),(0,Y.jsxs)(`div`,{className:R(`ml-auto flex items-center`,Ni&&`[-webkit-app-region:no-drag]`),children:[(0,Y.jsxs)(U,{children:[(0,Y.jsx)(H,{asChild:!0,children:(0,Y.jsxs)(W,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,onClick:()=>Xt(),children:[(0,Y.jsx)(Bn,{}),(0,Y.jsx)(`span`,{className:`sr-only`,children:`Settings`})]})}),(0,Y.jsx)(V,{children:`Settings`})]}),(0,Y.jsx)(Oi,{}),(0,Y.jsx)(Si,{}),(0,Y.jsx)(ii,{})]})]})}function zi(){Fi(),si(),yi();let{handler:e}=At(),t=N(),{pathname:n}=vt(),[r,i]=(0,J.useState)(!1),a=Me(),o=a.data!==void 0&&qe(a.data.protocol);return(0,J.useEffect)(()=>{if(!o)return;let e=()=>{let e=te();q.reportTheme(e(`--text-primary`),e(`--bg-base`))};return e(),A(e)},[o]),(0,Y.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden overscroll-y-none bg-ground`,children:[(0,Y.jsx)(Ri,{}),(0,Y.jsx)(`main`,{className:`min-h-0 flex-1`,children:(0,Y.jsx)(gn,{resetOn:n,scope:n.startsWith(`/project/`)?`workspace`:`view`,children:(0,Y.jsx)(bt,{})})}),(0,Y.jsx)($r,{}),(0,Y.jsx)(oi,{}),(0,Y.jsx)(Jr,{onNewSession:e??void 0,onNewProject:()=>i(!0)}),t!==null&&(0,Y.jsx)(en,{profileId:t,open:r,onOpenChange:i}),(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(Pi,{})}),(0,Y.jsx)(Zr,{})]})}function Bi(){return(0,Y.jsx)(Gt,{children:(0,Y.jsx)(zi,{})})}var Vi=(0,J.lazy)(()=>k(()=>import(`./Dashboard-Bjrw6phb.js`).then(e=>({default:e.Dashboard})),__vite__mapDeps([30,1,2,3,4,5,6,7,8,9,10,13,12,31,20,32,23,33,34,16,27,26,35]))),Hi=(0,J.lazy)(()=>k(()=>import(`./Workspace-GWsJrLJW.js`).then(e=>({default:e.Workspace})),__vite__mapDeps([36,1,2,3,4,5,6,7,8,9,10,17,18,19,12,13,37,38,23,33,31,15,39,14,40,41,20,32,42,21,22,43,35,26,16,44,45,46,29,47]))),Ui=new hn({defaultOptions:{queries:{retry:1,staleTime:5e3}},mutationCache:new fn({onError:e=>K(e)})});function Wi(){let e=N(),t=rt(),n=e!==null&&t.data!==void 0&&!t.data.some(t=>t.id===e);return e===null||n?(0,Y.jsx)(Vn,{}):(0,Y.jsx)(dt,{useTransitions:!1,children:(0,Y.jsx)(J.Suspense,{fallback:null,children:(0,Y.jsx)(pt,{children:(0,Y.jsxs)(ft,{element:(0,Y.jsx)(Bi,{}),children:[(0,Y.jsx)(ft,{path:`/`,element:(0,Y.jsx)(Vi,{})}),(0,Y.jsx)(ft,{path:`/project/:id`,element:(0,Y.jsx)(Hi,{})}),(0,Y.jsx)(ft,{path:`/project/:id/session/:sid`,element:(0,Y.jsx)(Hi,{})})]})})})})}function Gi(){let e=(0,J.useSyncExternalStore)(u.subscribe,u.get);return(0,Y.jsx)(ge,{client:Ui,children:(0,Y.jsxs)(Lt,{delayDuration:300,children:[(0,Y.jsx)(Nn,{}),(0,Y.jsx)(gn,{scope:`app`,children:e?window.location.pathname.startsWith(`/forward/`)?(0,Y.jsx)(dn,{}):(0,Y.jsx)(Wi,{}):(0,Y.jsx)(vn,{})}),(0,Y.jsx)(_n,{})]})})}export{Gi as App};
|
|
@@ -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{g as r}from"./auth-B4b-NPwe.js";import{a as i,c as a,d as o,i as s,o as c,s as l,t as u,u as d}from"./LazyTerminal-CdXNqTZt.js";import{A as f,At as p,D as m,Tt as h,X as g,_t as _,bt as v,f as y,mt as b,pt as x}from"./protocol-support-Q_1mBit9.js";import{a as S,i as C,l as w,o as T,r as E}from"./session-order-B9wDgtkQ.js";import{n as D}from"./x-DCpy1q13.js";import{t as O}from"./input-Dx89yXF4.js";import{t as k}from"./button-Chvl9hcE.js";import{c as A,d as j,n as M,r as N,t as ee,u as P}from"./context-menu-CnmULRW3.js";import{r as F}from"./dist-DmyIHyF9.js";import{t as I}from"./NewProjectDialog-BCtrjbMj.js";import{n as L}from"./errors-C-GJcBJ-.js";import{t as R}from"./ws-CT7jDKHs.js";import{a as z,i as B,n as V,o as H,t as U}from"./dialog-Bnex_wlx.js";var W=e(t(),1),G=n(),K=!1;function q(){let[e,t]=(0,W.useState)(K),[n,i]=(0,W.useState)(null);(0,W.useEffect)(()=>{if(!e)return;let t=!1;return R.spawnShell(r).then(e=>{t||i(e)}),()=>{t=!0}},[e]);let a=()=>{K=!1,t(!1),i(null)};return{open:e,term:n,toggle:()=>{e?(n&&R.killShell(r,n),a()):(K=!0,t(!0))},onExit:a}}function J({term:e,onExit:t}){return(0,G.jsx)(`div`,{className:`h-72 shrink-0 pb-6`,children:(0,G.jsx)(`div`,{className:`mx-auto size-full max-w-4xl px-6`,children:e!==null&&(0,G.jsx)(u,{stream:`home`,term:e,onExit:t})})})}var Y=`group block w-full rounded-lg bg-surface p-4 text-left transition-colors hover:bg-elevated`,X=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function te({project:e,repoPath:t,sessions:n}){let r=n.filter(e=>e.status!==`archived`);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h2`,{className:D(`truncate pr-16 text-base font-semibold`,i(e.colour)||`text-fg group-hover:text-accent`),children:e.name}),(0,G.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:t??`…`}),(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,G.jsxs)(`span`,{children:[r.length,` session`,r.length===1?``:`s`]}),X.map(({status:e,colour:t})=>{let n=r.filter(t=>t.status===e).length;return n>0?(0,G.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),n,` `,e.replace(`_`,` `)]},e):null})]})]})}function Z({icon:e,label:t,onClick:n}){return(0,G.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,G.jsx)(e,{className:`size-4`})})}function Q({project:e,repoPath:t,draggable:n,dragging:r,onDragStart:l,onDragEnd:u,onDragOver:f}){let m=b(),h=y(g().data?.protocol),_=p(e.id),[v,x]=(0,W.useState)(!1),[S,C]=(0,W.useState)(e.name),[T,E]=(0,W.useState)(o(e)),[F,I]=(0,W.useState)(e.colour??null),R=t=>m.mutate({id:e.id,archived:t},{onError:e=>L(e)}),K=()=>{C(e.name),I(e.colour??null),E(o(e)),x(!0)},q=()=>{let t=S.trim(),n=d(T);if(!t){x(!1);return}let r={...t===e.name?{}:{name:t},...n&&n!==o(e)?{abbrev:n}:{},...h&&F!==(e.colour??null)?{colour:F}:{}};if(Object.keys(r).length===0){x(!1);return}m.mutate({id:e.id,...r},{onSuccess:()=>x(!1),onError:e=>L(e)})};return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(ee,{children:[(0,G.jsx)(A,{asChild:!0,children:(0,G.jsxs)(`div`,{draggable:n,onDragStart:l,onDragEnd:u,onDragOver:f,className:D(`group relative transition-opacity`,r&&`opacity-50`),children:[(0,G.jsx)(w,{draggable:!1,to:`/project/${e.id}`,className:Y,children:(0,G.jsx)(te,{project:e,repoPath:t,sessions:_.data??[]})}),(0,G.jsx)(`div`,{className:`absolute right-2 top-2 hidden gap-0.5 group-hover:flex has-[[data-state=open]]:flex pointer-coarse:flex`,children:e.archived?(0,G.jsx)(Z,{icon:j,label:`Reopen project`,onClick:()=>R(!1)}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Z,{icon:c,label:`Edit project`,onClick:K}),(0,G.jsx)(Z,{icon:P,label:`Archive project`,onClick:()=>R(!0)})]})})]})}),(0,G.jsx)(M,{children:e.archived?(0,G.jsxs)(N,{onSelect:()=>R(!1),children:[(0,G.jsx)(j,{}),` Reopen`]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(N,{onSelect:K,children:[(0,G.jsx)(c,{}),` Edit`]}),(0,G.jsxs)(N,{onSelect:()=>R(!0),children:[(0,G.jsx)(P,{}),` Archive`]})]})})]}),(0,G.jsx)(U,{open:v,onOpenChange:x,children:(0,G.jsxs)(V,{children:[(0,G.jsx)(z,{children:(0,G.jsx)(H,{children:`Edit project`})}),(0,G.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),q()},children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(a,{htmlFor:`project-name-${e.id}`,children:`Name`}),(0,G.jsx)(O,{id:`project-name-${e.id}`,value:S,className:i(F),onChange:e=>C(e.target.value),autoFocus:!0})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(a,{htmlFor:`project-abbrev-${e.id}`,children:`Abbreviation`}),(0,G.jsx)(O,{id:`project-abbrev-${e.id}`,maxLength:5,value:T,onChange:e=>E(d(e.target.value)),className:`w-24 uppercase`}),(0,G.jsxs)(`p`,{className:`text-2xs text-fg-muted`,children:[`Up to `,5,` characters — the label on the collapsed sidebar rail.`]})]}),h&&(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:`Colour`}),(0,G.jsx)(s,{value:F,onChange:I,label:`Project colour`})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsx)(a,{className:`text-fg-muted`,children:`Path`}),(0,G.jsx)(`p`,{className:`truncate text-2xs text-fg-muted`,children:t??`…`})]}),(0,G.jsxs)(B,{children:[(0,G.jsx)(k,{type:`button`,variant:`ghost`,onClick:()=>x(!1),children:`Cancel`}),(0,G.jsx)(k,{type:`submit`,disabled:!S.trim()||m.isPending,children:`Save`})]})]})]})})]})}function $({icon:e,label:t,hint:n,onClick:r}){return(0,G.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,G.jsxs)(`h2`,{className:`flex items-center gap-2 truncate text-base font-semibold text-fg group-hover:text-accent`,children:[(0,G.jsx)(e,{className:`size-4 shrink-0`}),t]}),(0,G.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:n})]})}function ne(){let e=f(),t=v(e??void 0),n=h(),r=_(e??void 0),i=x(e??``),[a,o]=(0,W.useState)(!1),[s,c]=(0,W.useState)(null),[u,d]=(0,W.useState)(!1),p=q(),g=m(`palette.toggle`),y=e=>n.data?.find(t=>t.id===e)?.path,b=t.data??[],w=r.data?.projectOrder??[],O=E(b.filter(e=>!e.archived),w),k=b.filter(e=>e.archived),A=(e,t)=>{e!==t&&i.mutate({projectOrder:C(O.map(e=>e.id),e,t)})};return(0,G.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,G.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[b.length===0&&(0,G.jsxs)(`div`,{className:`mb-8 mt-16 flex flex-col items-center gap-3 text-center`,children:[(0,G.jsx)(l,{className:`size-8 text-fg-muted`}),(0,G.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No projects yet — open one below, or press `,g,`.`]})]}),(0,G.jsxs)(`div`,{className:`grid auto-rows-fr grid-cols-1 gap-3 sm:grid-cols-2`,children:[O.map(e=>(0,G.jsx)(Q,{project:e,repoPath:y(e.repo_id),draggable:!0,dragging:s===e.id,onDragStart:()=>c(e.id),onDragEnd:()=>c(null),onDragOver:t=>{t.preventDefault(),s&&s!==e.id&&A(s,e.id)}},e.id)),(0,G.jsx)($,{icon:T,label:`Open project`,hint:`Point at a repository on this host`,onClick:()=>o(!0)}),(0,G.jsx)($,{icon:S,label:p.open?`Close terminal`:`Open terminal`,hint:p.open?`End the shell below`:`A shell at ~ for cloning repositories`,onClick:p.toggle})]}),k.length>0&&(0,G.jsxs)(`div`,{className:`mt-6`,children:[(0,G.jsxs)(`button`,{type:`button`,onClick:()=>d(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,G.jsx)(F,{className:D(`size-3 transition-transform`,u&&`rotate-90`)}),(0,G.jsx)(P,{className:`size-3`}),(0,G.jsx)(`span`,{children:`Archived`}),(0,G.jsx)(`span`,{className:`tabular-nums`,children:k.length})]}),u&&(0,G.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:k.map(e=>(0,G.jsx)(Q,{project:e,repoPath:y(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]})]})}),p.open&&(0,G.jsx)(J,{term:p.term,onExit:p.onExit}),e!==null&&(0,G.jsx)(I,{profileId:e,open:a,onOpenChange:o})]})}export{ne 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{t as r}from"./x-DCpy1q13.js";import{t as i}from"./button-Chvl9hcE.js";import{t as a}from"./createLucideIcon-DyMAgLa3.js";import{a as o,i as s,n as c,o as l,r as u,t as d}from"./dialog-Bnex_wlx.js";import{t as f}from"./drafts-B_tChlzR.js";import{i as p,t as m,u as h}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{t as r}from"./x-DCpy1q13.js";import{t as i}from"./button-Chvl9hcE.js";import{t as a}from"./createLucideIcon-DyMAgLa3.js";import{a as o,i as s,n as c,o as l,r as u,t as d}from"./dialog-Bnex_wlx.js";import{t as f}from"./drafts-B_tChlzR.js";import{i as p,t as m,u as h}from"./buffer-store-Da5Z0NEV.js";import{t as g}from"./editor-sync-W1bamxAP.js";var _=a(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),v=e(t(),1),y=n();function b(e,t,n){let r=m(e,t,n);return(0,v.useSyncExternalStore)((0,v.useCallback)(e=>h(r,e),[r]),()=>p(r))}function x({session:e,path:t,kind:n,root:r}){return b(e,t,r)&&n!==`commit`?(0,y.jsx)(_,{"aria-hidden":!0,className:`size-2 shrink-0 fill-current text-fg-muted group-hover:hidden`}):null}function S({session:e,path:t,kind:n,root:a,label:p,onClose:m}){let h=b(e,t,a)&&n!==`commit`,[_,x]=(0,v.useState)(!1),S=()=>h?x(!0):m();return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`button`,{onClick:e=>{e.stopPropagation(),S()},className:`hidden size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg group-hover:flex pointer-coarse:flex`,"aria-label":`Close ${p}`,children:(0,y.jsx)(r,{className:`size-3`})}),(0,y.jsx)(d,{open:_,onOpenChange:e=>!e&&x(!1),children:(0,y.jsxs)(c,{children:[(0,y.jsxs)(o,{children:[(0,y.jsxs)(l,{children:[`Discard changes to `,p,`?`]}),(0,y.jsx)(u,{children:`This file has unsaved changes. Closing the tab will discard them.`})]}),(0,y.jsxs)(s,{children:[(0,y.jsx)(i,{variant:`ghost`,onClick:()=>x(!1),children:`Keep editing`}),(0,y.jsx)(i,{variant:`danger`,onClick:()=>{f(e,t,a),g(e,t,a),x(!1),m()},children:`Discard`})]})]})})]})}export{x as EditorDirtyDot,S as EditorTabClose};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-CMOPxTVY.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/auth-B4b-NPwe.js","assets/client-settings-CwqpIric.js","assets/preload-helper-Czpn1I53.js","assets/index-BfBbMcnA.js","assets/index-BxtQ6WUO.css","assets/dist-Rswij5M_.js","assets/protocol-support-Q_1mBit9.js","assets/copy-DD43yC2P.js","assets/createLucideIcon-DyMAgLa3.js","assets/x-DCpy1q13.js","assets/FindWidget-BSK2PIfO.js","assets/whole-word-2m2pmAFT.js","assets/chevron-down--sjpQEHH.js","assets/selection-actions-Cith0Z9x.js","assets/button-Chvl9hcE.js","assets/ws-CT7jDKHs.js","assets/code-DRWf9a5s.js","assets/errors-C-GJcBJ-.js","assets/math-delimiters-BCnTi7Ii.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{t as n}from"./jsx-runtime-ffCh33zF.js";import{I as r}from"./auth-B4b-NPwe.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{p as a}from"./es2015-CrC2hHeB.js";import{n as o}from"./x-DCpy1q13.js";import{t as s}from"./input-Dx89yXF4.js";import{t as c}from"./createLucideIcon-DyMAgLa3.js";function l(e){return e.trim().slice(0,5).toUpperCase()}function u(e){return e.abbrev??l(e.name)}function d(e){return e.trim().toUpperCase().slice(0,5)}var f=e(t(),1),p=n(),m=`Label`,h=f.forwardRef((e,t)=>(0,p.jsx)(a.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));h.displayName=m;var g=h;function _({className:e,...t}){return(0,p.jsx)(g,{className:o(`text-xs font-medium text-fg-secondary peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}var v=c(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),y=c(`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`}]]),b={navy:`text-fg`,gold:`text-fg-gold`,blue:`text-icon-blue`,green:`text-icon-green`,amber:`text-icon-amber`,red:`text-icon-red`,violet:`text-icon-violet`,cyan:`text-icon-cyan`,accent:`text-accent`};function x(e){return e&&b[e]||``}function S({value:e,onChange:t,disabled:n=!1,label:i=`Colour`}){return(0,p.jsx)(`div`,{role:`group`,"aria-label":i,className:`flex flex-wrap items-center gap-1`,children:[null,...r].map(r=>(0,p.jsx)(`button`,{type:`button`,title:r??`Default`,"aria-label":r??`Default colour`,"aria-pressed":(e??null)===r,disabled:n,onClick:()=>t(r),className:o(`flex size-7 cursor-pointer items-center justify-center rounded-md transition-colors hover:bg-border/50 focus-visible:bg-border/50 disabled:cursor-default disabled:opacity-50`,(e??null)===r&&`bg-border/50`),children:(0,p.jsx)(`span`,{className:o(`size-3.5 rounded-full`,r?o(`bg-current`,x(r)):`bg-fg-muted`)})},r??`default`))})}function C({id:e,value:t,onValueChange:n,onChoose:r,hints:i,placeholder:a,className:c,hintsClassName:l,autoFocus:u}){let[d,m]=(0,f.useState)(!1),[h,g]=(0,f.useState)(0),_=e=>{n(e.value),r?.(e),m(!1)};return(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(s,{id:e,value:t,onChange:e=>{n(e.target.value),m(!0),g(0)},onFocus:()=>m(!0),onBlur:()=>m(!1),onKeyDown:e=>{if(!(!d||i.length===0))if(e.key===`ArrowDown`)e.preventDefault(),g(e=>(e+1)%i.length);else if(e.key===`ArrowUp`)e.preventDefault(),g(e=>(e-1+i.length)%i.length);else if(e.key===`Enter`||e.key===`Tab`){let t=i[h]??i[0];t&&(e.preventDefault(),_(t))}else e.key===`Escape`&&(e.stopPropagation(),m(!1))},placeholder:a,className:c,autoComplete:`off`,spellCheck:!1,autoFocus:u}),d&&i.length>0&&(0,p.jsx)(`ul`,{className:o(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,l??`w-full`),children:i.map((e,t)=>(0,p.jsx)(`li`,{children:(0,p.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),_(e)},onMouseEnter:()=>g(t),className:o(`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 text-xs`),"data-selected":t===h,children:[(0,p.jsx)(`span`,{className:`truncate`,children:e.label??e.value}),e.badge&&(0,p.jsx)(`span`,{className:`ml-auto shrink-0 text-2xs opacity-70`,children:e.badge})]})},e.value))})]})}var w=(0,f.lazy)(()=>i(()=>import(`./Terminal-CMOPxTVY.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))),T=null;async function E(){T=(await i(()=>import(`./Terminal-CMOPxTVY.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23]))).Terminal}function D(e){return T?(0,p.jsx)(T,{...e}):(0,p.jsx)(f.Suspense,{fallback:(0,p.jsx)(`div`,{className:`size-full bg-ground`}),children:(0,p.jsx)(w,{...e})})}export{x as a,_ as c,u as d,S as i,l,E as n,y as o,C as r,v as s,D as t,d as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{c as n,o as r,t as i}from"./buffer-store-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{c as n,o as r,t as i}from"./buffer-store-Da5Z0NEV.js";var a=e(t(),1);function o({buffers:e}){let t=(0,a.useRef)(new Set);return(0,a.useEffect)(()=>{let a=new Set(e.map(e=>i(e.session,e.path,e.root))),o=t.current;for(let e of a)o.has(e)||(n(e),o.add(e));for(let e of[...o])a.has(e)||(r(e),o.delete(e))},[e]),(0,a.useEffect)(()=>()=>{for(let e of t.current)r(e);t.current.clear()},[]),null}export{o as ModelRefcount};
|
|
@@ -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,c as i,i as ee,l as a,r as o,s,u as c}from"./LazyTerminal-CdXNqTZt.js";import{K as l,Tt as u,X as d,at as te,c as ne,f as re,nt as f,q as ie}from"./protocol-support-Q_1mBit9.js";import{m as ae,s as p}from"./session-order-B9wDgtkQ.js";import{t as m}from"./input-Dx89yXF4.js";import{t as h}from"./button-Chvl9hcE.js";import{t as g}from"./createLucideIcon-DyMAgLa3.js";import{a as _,i as v,n as y,o as b,r as x,t as S}from"./dialog-Bnex_wlx.js";import{t as oe}from"./use-debounced-value-C86N-mOK.js";var C=g(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),w=e(t(),1),T=n();function E(e){let t=e.trim().replace(/\/+$/,``);return t===``?`/`:t}function D(e){return e.startsWith(`/`)||e.startsWith(`~`)}function O(e){let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n<=0?`/`:t.slice(0,n)}function se({dir:e,onNavigate:t,onChoose:n}){let r=f(e.endsWith(`/`)?e:`${e}/`);return(0,T.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,T.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,T.jsxs)(`button`,{type:`button`,onClick:()=>t(O(e)),disabled:e===`/`,title:`Parent directory`,className:`shrink-0 rounded-sm p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg disabled:pointer-events-none disabled:opacity-40`,children:[(0,T.jsx)(p,{className:`size-3.5`}),(0,T.jsx)(`span`,{className:`sr-only`,children:`Parent directory`})]}),(0,T.jsx)(`button`,{type:`button`,onClick:()=>n(e),className:`ml-auto shrink-0 text-2xs text-fg-muted transition-colors hover:text-fg`,children:`choose this folder`})]}),(0,T.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[(r.data?.entries??[]).map(e=>(0,T.jsxs)(`div`,{className:`flex items-center rounded-md transition-colors hover:bg-elevated`,children:[(0,T.jsxs)(`button`,{type:`button`,onClick:()=>t(e.path),className:`flex min-w-0 flex-1 items-center gap-2 px-2 py-1 text-left`,children:[e.is_git?(0,T.jsx)(s,{className:`size-3.5 shrink-0 text-success`}):(0,T.jsx)(C,{className:`size-3.5 shrink-0 text-fg-gold`}),(0,T.jsx)(`span`,{className:`truncate text-xs text-fg`,children:e.name})]}),e.is_git&&(0,T.jsx)(`button`,{type:`button`,onClick:()=>n(e.path),className:`shrink-0 px-2 py-1 text-2xs text-fg-muted transition-colors hover:text-fg`,children:`choose`})]},e.path)),r.data!==void 0&&r.data.entries.length===0&&(0,T.jsx)(`p`,{className:`px-2 py-1 text-xs text-fg-muted`,children:`No subdirectories.`})]})]})}function k({profileId:e,open:t,onOpenChange:n}){let s=u(),p=d().data?.protocol,g=ne(p),C=re(p),O=ie(),k=l(),A=ae(),j=te(),[M,N]=(0,w.useState)(``),[P,F]=(0,w.useState)(``),[I,L]=(0,w.useState)(!1),[R,z]=(0,w.useState)(``),[B,V]=(0,w.useState)(null),[H,U]=(0,w.useState)(!1),[W,G]=(0,w.useState)(null),[K,q]=(0,w.useState)(null),J=j.data?.home,ce=()=>{let e=M.trim(),t=D(e)&&J!==void 0?E(e.replace(/^~(?=\/|$)/,J)):D(e)&&e.startsWith(`/`)?E(e):J??`/`;X(t)},Y=e=>{F(e),H||z(a(e))},X=e=>{q(e),N(e)},le=e=>{N(e),q(null),Y(e.split(`/`).filter(Boolean).pop()??``),L(!0)},Z=f(oe(M,150)),ue=(0,w.useMemo)(()=>{if(!D(M))return(s.data??[]).map(e=>({value:e.path,badge:`registered`,is_git:!0}));let e=new Set((s.data??[]).map(e=>e.path));return(Z.data?.entries??[]).map(t=>({value:t.path,label:t.name,badge:e.has(t.path)?`registered`:t.is_git?`git`:void 0,is_git:t.is_git}))},[M,s.data,Z.data]),Q=async()=>{G(null);try{let t=E(M),r=s.data?.find(e=>e.path===t)?.id??(await O.mutateAsync({path:t,...g?{default_base_branch:``}:{}})).id,i=await k.mutateAsync({profile_id:e,repo_id:r,name:P.trim(),...C?{colour:B}:{},...c(R)?{abbrev:c(R)}:{}});n(!1),A(`/project/${i.id}`)}catch(e){G(e instanceof Error?e.message:String(e))}},$=P.trim()!==``&&D(M.trim());return(0,T.jsx)(S,{open:t,onOpenChange:n,children:(0,T.jsxs)(y,{children:[(0,T.jsxs)(_,{children:[(0,T.jsx)(b,{children:`New project`}),(0,T.jsx)(x,{children:`Point at a git repository on the daemon host — known repositories are reused.`})]}),(0,T.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),$&&Q()},children:[(0,T.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,T.jsx)(i,{htmlFor:`repo-path`,children:`Repository path`}),(0,T.jsx)(`button`,{type:`button`,onClick:()=>K===null?ce():q(null),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:K===null?`browse…`:`hide browser`})]}),(0,T.jsx)(o,{id:`repo-path`,placeholder:`~/src/my-repo`,value:M,onValueChange:N,onChoose:e=>{!I&&e.is_git&&Y(e.value.split(`/`).filter(Boolean).pop()??``)},hints:ue}),K!==null&&(0,T.jsx)(se,{dir:K,onNavigate:X,onChoose:le})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,T.jsx)(i,{htmlFor:`project-name`,children:`Project name`}),(0,T.jsx)(m,{id:`project-name`,placeholder:`e.g. checkout-rework`,value:P,className:r(B),onChange:e=>{Y(e.target.value),L(!0)}})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,T.jsx)(i,{htmlFor:`project-abbrev`,children:`Abbreviation`}),(0,T.jsx)(m,{id:`project-abbrev`,placeholder:P.trim()?a(P):`ABBRV`,maxLength:5,value:R,onChange:e=>{z(c(e.target.value)),U(!0)},className:`w-24 uppercase`}),(0,T.jsxs)(`p`,{className:`text-2xs text-fg-muted`,children:[`Up to `,5,` characters — the project's label on the collapsed sidebar rail.`]})]}),C&&(0,T.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,T.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:`Colour`}),(0,T.jsx)(ee,{value:B,onChange:V,label:`Project colour`})]}),W&&(0,T.jsx)(`p`,{className:`text-xs text-danger`,children:W}),(0,T.jsxs)(v,{children:[(0,T.jsx)(h,{type:`button`,variant:`ghost`,onClick:()=>n(!1),children:`Cancel`}),(0,T.jsx)(h,{type:`submit`,disabled:!$||O.isPending||k.isPending,children:`Create project`})]})]})]})})}export{k as t};
|