@puddle-code/cli 0.3.10 → 0.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +3 -6
  2. package/dist/host-control.mjs +17 -0
  3. package/dist/index.js +22 -3
  4. package/dist/public/assets/App-CZFfLe7B.js +2 -0
  5. package/dist/public/assets/{Dashboard-v3OproVW.js → Dashboard-pZ9Z5be0.js} +1 -1
  6. package/dist/public/assets/{EditorTabClose-DwhahpvS.js → EditorTabClose-CcTqpPLn.js} +1 -1
  7. package/dist/public/assets/{LazyTerminal-CgQryH0p.js → LazyTerminal-DXz4jhHV.js} +2 -2
  8. package/dist/public/assets/{ModelRefcount-njA_f4bS.js → ModelRefcount-DzQrxain.js} +1 -1
  9. package/dist/public/assets/{NewProjectDialog-BT8rR4yn.js → NewProjectDialog-ByTHhInN.js} +1 -1
  10. package/dist/public/assets/{NotebookWidget-Cwd77EGL.js → NotebookWidget-DuRBEgL5.js} +1 -1
  11. package/dist/public/assets/{PaneEditorBody-RaUBrZPu.js → PaneEditorBody-D3WP68Nl.js} +4 -4
  12. package/dist/public/assets/PdfViewer-Re37jQgv.css +1 -0
  13. package/dist/public/assets/PdfViewer-TJmeNeCX.js +2 -0
  14. package/dist/public/assets/{SettingsDialog-CaHklYzG.js → SettingsDialog-XdYkVxAp.js} +1 -1
  15. package/dist/public/assets/{Terminal-_10Xyj1h.js → Terminal-FQpZf8ol.js} +3 -3
  16. package/dist/public/assets/{Workspace-GgVr1uYN.js → Workspace-BKA9SyN-.js} +6 -6
  17. package/dist/public/assets/{api-i6xNY3bF.js → api-CWrvqTDd.js} +1 -1
  18. package/dist/public/assets/{auth-GfOuXpIe.js → auth-Bvs3kkqE.js} +1 -1
  19. package/dist/public/assets/{buffer-store-eMnMxbpI.js → buffer-store-BJI12hvF.js} +1 -1
  20. package/dist/public/assets/{context-DW21k43a.js → context-d6tkpKkh.js} +1 -1
  21. package/dist/public/assets/{disclosure-CHXbNzgZ.js → disclosure-CQHbCEyT.js} +1 -1
  22. package/dist/public/assets/{errors-O9DWXa3f.js → errors-D7cN9zwV.js} +1 -1
  23. package/dist/public/assets/{forward-link-RM7_5Shu.js → forward-link-C3mxMevv.js} +1 -1
  24. package/dist/public/assets/{hotkeys-1uTWFYAL.js → hotkeys-Bb6oSnV3.js} +1 -1
  25. package/dist/public/assets/{index-np8JXeG6.js → index-CegatrLH.js} +3 -3
  26. package/dist/public/assets/{markdown-mermaid-CNYDlgGt.js → markdown-mermaid-C7nLS7Ua.js} +1 -1
  27. package/dist/public/assets/{media-refresh-store-Bu4kWCGq.js → media-refresh-store-DXCUuQT6.js} +1 -1
  28. package/dist/public/assets/{notification-delivery-Dfvdt_1U.js → notification-delivery-Kb7nptM3.js} +1 -1
  29. package/dist/public/assets/{protocol-support-BGmIChNK.js → protocol-support-B9FOVWIr.js} +1 -1
  30. package/dist/public/assets/{scroll-restoration-OVgiE4G9.js → scroll-restoration-CIlNpqBL.js} +1 -1
  31. package/dist/public/assets/{selection-actions-D875GPFU.js → selection-actions-Ch1RDI54.js} +1 -1
  32. package/dist/public/assets/{session-order-f7QxTbVD.js → session-order-C9VTNopC.js} +1 -1
  33. package/dist/public/assets/{switch-DhNyUV8C.js → switch-BVIHUKzP.js} +1 -1
  34. package/dist/public/assets/use-ui-state-i_yYlIxi.js +1 -0
  35. package/dist/public/assets/{ws-CMPCIzY4.js → ws-bjTyWUY1.js} +1 -1
  36. package/dist/public/index.html +2 -2
  37. package/dist/pudl.js +18 -1
  38. package/package.json +1 -1
  39. package/dist/public/assets/App-CNB4a07v.js +0 -2
  40. package/dist/public/assets/PdfViewer-Bppu4-0-.js +0 -2
  41. package/dist/public/assets/use-ui-state-CHqXhyx4.js +0 -1
package/CHANGELOG.md CHANGED
@@ -4,15 +4,12 @@ Archived release changelog. Governance lives in CLAUDE.md §"Changelog disciplin
4
4
 
5
5
  # Changelog
6
6
 
7
- ## [0.3.10] — 2026-10-25
7
+ ## [0.3.12] — 2026-11-02
8
8
 
9
9
  ### Added
10
10
 
11
- - Render Jupyter widgets with the official manager, including live controls, linked models, Markdown/maths, callback output, binary uploads/images, compatible custom extensions and saved notebook state.
12
- - Retain Jupyter widget state and binary buffers across cell runs, forward live widget comms and Output callbacks, and reject actions from retired kernels (protocol 25.4).
11
+ - Add local and SSH storage diagnostics, with explicit unsaved runtime metadata and a cockpit warning when persistence is unavailable (protocol 25.5).
13
12
 
14
13
  ### Fixed
15
14
 
16
- - Place notebook input prompts inside the executing cell's output with Enter submission, Ctrl+C interruption and fresh input state for each prompt.
17
- - Keep Output widget capture and display updates working between cell runs and preserve widget metadata in executed copies.
18
- - Restore widget views after event-history gaps without repeating callbacks, and retain trait changes when the kernel disables echo updates.
15
+ - Allow native text selection and copying in PDF previews, including across pages and after zooming.
@@ -14973,6 +14973,8 @@ var sessionSchema = external_exports.object({
14973
14973
  agent_mode: agentModeSchema.optional(),
14974
14974
  /** Live foreground agent in a terminal session; icon hint only, never persisted. */
14975
14975
  detected_agent_type: external_exports.string().nullable().optional(),
14976
+ /** Runtime status is observed in memory and has not yet been saved. */
14977
+ persistence_pending: external_exports.boolean().optional(),
14976
14978
  agent_session_ref: external_exports.string().nullable(),
14977
14979
  /** Durable native-conversation catalogue row; null for terminal sessions. */
14978
14980
  conversation_id: rowId.nullable().optional(),
@@ -16552,6 +16554,21 @@ var notebookWidgetCommSchema = external_exports.object({
16552
16554
  })
16553
16555
  });
16554
16556
 
16557
+ // ../shared/src/api/storage.ts
16558
+ var storageStatusSchema = external_exports.object({
16559
+ checked_at: external_exports.string().nullable(),
16560
+ volumes: external_exports.array(
16561
+ external_exports.object({
16562
+ path: external_exports.string(),
16563
+ available_bytes: external_exports.number().nonnegative().nullable(),
16564
+ available_inodes: external_exports.number().nonnegative().nullable(),
16565
+ level: external_exports.enum(["ok", "warning", "critical", "unknown"])
16566
+ })
16567
+ ),
16568
+ logs_degraded: external_exports.boolean(),
16569
+ database_degraded: external_exports.boolean()
16570
+ });
16571
+
16555
16572
  // ../shared/src/node/security.ts
16556
16573
  import { createHash, randomBytes } from "node:crypto";
16557
16574
  import {
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: 4 };
3928
+ var PROTOCOL_VERSION = { major: 25, minor: 5 };
3929
3929
 
3930
3930
  // ../../node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/classic/external.js
3931
3931
  var external_exports = {};
@@ -18893,6 +18893,8 @@ var sessionSchema = external_exports.object({
18893
18893
  agent_mode: agentModeSchema.optional(),
18894
18894
  /** Live foreground agent in a terminal session; icon hint only, never persisted. */
18895
18895
  detected_agent_type: external_exports.string().nullable().optional(),
18896
+ /** Runtime status is observed in memory and has not yet been saved. */
18897
+ persistence_pending: external_exports.boolean().optional(),
18896
18898
  agent_session_ref: external_exports.string().nullable(),
18897
18899
  /** Durable native-conversation catalogue row; null for terminal sessions. */
18898
18900
  conversation_id: rowId.nullable().optional(),
@@ -20472,6 +20474,21 @@ var notebookWidgetCommSchema = external_exports.object({
20472
20474
  })
20473
20475
  });
20474
20476
 
20477
+ // ../shared/src/api/storage.ts
20478
+ var storageStatusSchema = external_exports.object({
20479
+ checked_at: external_exports.string().nullable(),
20480
+ volumes: external_exports.array(
20481
+ external_exports.object({
20482
+ path: external_exports.string(),
20483
+ available_bytes: external_exports.number().nonnegative().nullable(),
20484
+ available_inodes: external_exports.number().nonnegative().nullable(),
20485
+ level: external_exports.enum(["ok", "warning", "critical", "unknown"])
20486
+ })
20487
+ ),
20488
+ logs_degraded: external_exports.boolean(),
20489
+ database_degraded: external_exports.boolean()
20490
+ });
20491
+
20475
20492
  // src/lib/transport/local.ts
20476
20493
  import { spawn } from "node:child_process";
20477
20494
  import { copyFileSync, mkdirSync, readFileSync } from "node:fs";
@@ -22010,7 +22027,7 @@ import { readFileSync as readFileSync4 } from "node:fs";
22010
22027
  import { dirname as dirname4, join as join5 } from "node:path";
22011
22028
  import { fileURLToPath as fileURLToPath2 } from "node:url";
22012
22029
  function cliVersion() {
22013
- if (true) return "0.3.10";
22030
+ if (true) return "0.3.12";
22014
22031
  const here = dirname4(fileURLToPath2(import.meta.url));
22015
22032
  for (const candidate of [
22016
22033
  join5(here, "..", "..", "package.json"),
@@ -22418,7 +22435,9 @@ var RELEASE_PROTOCOLS = {
22418
22435
  "0.3.7": { major: 25, minor: 1 },
22419
22436
  "0.3.8": { major: 25, minor: 1 },
22420
22437
  "0.3.9": { major: 25, minor: 3 },
22421
- "0.3.10": { major: 25, minor: 4 }
22438
+ "0.3.10": { major: 25, minor: 4 },
22439
+ "0.3.11": { major: 25, minor: 4 },
22440
+ "0.3.12": { major: 25, minor: 5 }
22422
22441
  };
22423
22442
  function validProtocol(value) {
22424
22443
  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-XdYkVxAp.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/auth-Bvs3kkqE.js","assets/LazyTerminal-DXz4jhHV.js","assets/jsx-runtime-By8HlURe.js","assets/preload-helper-Czpn1I53.js","assets/dialog-BMWRC2HO.js","assets/react-dom-cJyBB_A4.js","assets/x-DCpy1q13.js","assets/createLucideIcon-DyMAgLa3.js","assets/input-CxgRsoVg.js","assets/notification-delivery-Kb7nptM3.js","assets/api-CWrvqTDd.js","assets/hotkeys-Bb6oSnV3.js","assets/protocol-support-B9FOVWIr.js","assets/switch-BVIHUKzP.js","assets/dist-Cde1E3eV.js","assets/client-settings-CwqpIric.js","assets/index-CegatrLH.js","assets/index-CPHfr3MU.css","assets/dist-BOS6OKSE.js","assets/button-BgeBH2Uc.js","assets/select-Bg0rWqco.js","assets/chevron-down--sjpQEHH.js","assets/dist-Ds3438NL.js","assets/code-DRWf9a5s.js","assets/rotate-ccw-CNjR2LSi.js","assets/errors-D7cN9zwV.js","assets/use-debounced-value-C86N-mOK.js","assets/popover-CCHRaCvX.js","assets/disclosure-CQHbCEyT.js","assets/Dashboard-pZ9Z5be0.js","assets/session-order-C9VTNopC.js","assets/context-menu-CMWkmDu6.js","assets/dist-C_x5-hi8.js","assets/NewProjectDialog-ByTHhInN.js","assets/ws-bjTyWUY1.js","assets/Workspace-BKA9SyN-.js","assets/forward-link-C3mxMevv.js","assets/media-refresh-store-DXCUuQT6.js","assets/use-ui-state-i_yYlIxi.js","assets/preview-kind-DiWpvEc0.js","assets/debounce-B9DrqirV.js","assets/whole-word-2m2pmAFT.js","assets/selection-actions-Ch1RDI54.js","assets/copy-CGsu8426.js","assets/drafts-B_tChlzR.js","assets/buffer-logic-BAkSBQT7.js","assets/scroll-restoration-CIlNpqBL.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{t as n}from"./react-dom-cJyBB_A4.js";import{P as r,U as i,W as a,f as o,j as s,o as c,r as l,x as u}from"./auth-Bvs3kkqE.js";import{a as d,c as f,o as p}from"./LazyTerminal-DXz4jhHV.js";import{a as m,d as h,f as g,g as _,h as v,i as y,l as b,m as x,o as S,s as C,t as w,u as T}from"./notification-delivery-Kb7nptM3.js";import{i as E,r as D,t as O}from"./client-settings-CwqpIric.js";import{t as ee}from"./jsx-runtime-By8HlURe.js";import{t as k}from"./preload-helper-Czpn1I53.js";import{a as te,n as ne,o as re,r as ie,t as A}from"./index-CegatrLH.js";import{n as j}from"./api-CWrvqTDd.js";import{_ as M,d as ae,g as N,h as oe,i as se,l as ce,m as le,o as ue,p as de,r as fe,s as pe,u as me,v as he}from"./hotkeys-Bb6oSnV3.js";import{t as ge}from"./forward-link-C3mxMevv.js";import{$ as _e,At as ve,B as ye,Bt as be,C as xe,Ct as Se,Dt as Ce,E as we,F as Te,Ft as Ee,H as De,Ht as Oe,It as ke,J as Ae,K as je,L as Me,Lt as P,M as Ne,Mt as Pe,Nt as Fe,Pt as Ie,Q as Le,Rt as Re,T as ze,Tt as Be,Vt as Ve,Z as He,_t as Ue,at as F,b as We,et as Ge,it as Ke,j as qe,jt as I,o as Je,ot as Ye,pt as Xe,q as Ze,rt as Qe,st as $e,v as et,w as tt,wt as nt,x as rt,xt as it,y as at,zt as ot}from"./protocol-support-B9FOVWIr.js";import{a as st,c as ct,d as L,f as lt,h as ut,l as dt,m as ft,o as pt,p as mt,r as ht,u as gt}from"./session-order-C9VTNopC.js";import{n as R,t as _t}from"./dist-BOS6OKSE.js";import{n as z}from"./x-DCpy1q13.js";import{n as vt,t as B}from"./input-CxgRsoVg.js";import{n as yt,r as bt}from"./dist-Cde1E3eV.js";import{$ as xt,G as St,H as Ct,J as wt,K as Tt,Q as Et,U as Dt,W as Ot,X as kt,Y as At,at as jt,d as Mt,et as Nt,f as Pt,h as V,i as Ft,it as H,m as It,nt as Lt,ot as U,p as Rt,q as zt,r as Bt,rt as W,t as Vt,tt as Ht}from"./use-ui-state-i_yYlIxi.js";import{t as G}from"./button-BgeBH2Uc.js";import{t as K}from"./createLucideIcon-DyMAgLa3.js";import{c as Ut,i as Wt,s as Gt,t as Kt,u as qt}from"./switch-BVIHUKzP.js";import{t as Jt}from"./copy-CGsu8426.js";import{t as Yt}from"./NewProjectDialog-ByTHhInN.js";import{n as q}from"./errors-D7cN9zwV.js";import{t as J}from"./ws-bjTyWUY1.js";import{a as Xt,c as Zt,i as Qt,n as $t,o as en,r as tn,s as nn}from"./command-D7m0dmA-.js";import{n as rn,r as an,t as on}from"./popover-CCHRaCvX.js";var Y=e(t(),1),X=ee();function sn(){let[e,t]=(0,Y.useState)(`Opening forwarded application…`);return(0,Y.useEffect)(()=>{if(!/^\/forward\/([^/]+)\/(\d+)$/.exec(window.location.pathname)){t(`This forwarding link is invalid.`);return}let e=!0;return ge(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,X.jsx)(`p`,{className:`p-8 text-sm text-fg-secondary`,children:e})}var cn=class extends Oe{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 Be({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=ln(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=ln(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=ln(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=ln(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){I.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=>Ee(t,e))}findAll(e={}){return this.getAll().filter(t=>Ee(e,t))}notify(e){I.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return I.batch(()=>Promise.all(e.map(e=>e.continue().catch(P))))}};function ln(e){return e.options.scope?.id}var un=class extends Oe{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Ie(r,t),a=this.get(i);return a||(a=new Ce({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(){I.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=>ke(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>ke(e,t)):t}notify(e){I.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){I.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){I.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},dn=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new un,this.#t=e.mutationCache||new cn,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=ve.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(ot(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=Pe(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return I.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;I.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return I.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=I.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(P).catch(P)}invalidateQueries(e,t={}){return I.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=I.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(P)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(P)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(ot(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(P).catch(P)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(P).catch(P)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return ve.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(Fe(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{Re(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Fe(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{Re(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||=Ie(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===be&&(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()}},fn=class extends Y.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,X.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,X.jsxs)(`p`,{className:`text-sm text-fg`,children:[`The `,this.props.scope,` stopped rendering.`]}),(0,X.jsx)(`p`,{className:`max-w-lg font-mono text-2xs leading-relaxed text-interrupted`,children:e.message||String(e)}),(0,X.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,X.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,X.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,X.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Reload`})]})]})}};function pn(){return(0,X.jsx)(_t,{theme:(0,Y.useSyncExternalStore)(te,ie),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 mn(){return(0,X.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,X.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-24`,children:[(0,X.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm leading-relaxed text-fg-secondary`,children:[(0,X.jsxs)(`p`,{children:[`Authorise this browser by running`,` `,(0,X.jsx)(`span`,{className:`font-mono text-accent`,children:`puddle launch`}),` in a terminal.`]}),(0,X.jsx)(`p`,{children:`Use the link it opens. Your sessions, drafts and layouts stay in place.`})]})]})})}var hn=e(n(),1),gn=`a, button, [role="button"], [role="slider"], input, select, textarea, summary, label, [onclick], .cursor-pointer`,_n=`.monaco-editor`;function vn(e,t){return e?.closest(_n)&&!e.closest(t)?`text`:e?.closest(gn)?`interactive`:`default`}function yn(e,t=`.no-custom-caret`){(0,Y.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(_n),s=vn(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 bn=[`top`,`right`,`bottom`,`left`];function xn(){let e=(0,Y.useRef)(null);return yn(e),(0,X.jsx)(`div`,{ref:e,className:`custom-cursor drafting-cursor`,"aria-hidden":`true`,children:bn.map(e=>(0,X.jsx)(`span`,{className:`drafting-cursor-tick`,"data-side":e},e))})}function Sn(){let e=(0,Y.useRef)(null);return yn(e),(0,X.jsx)(`div`,{ref:e,className:`custom-cursor invert-cursor`,"aria-hidden":`true`})}var Cn=`h1, h2, h3, h4, h5, h6, .no-rangefinder-caret`,Z=40.5,Q=4.05,wn=Q*Math.sqrt(3)/2;function Tn(){let e=[],t=[],n=Z/2,r=Math.ceil(n/wn)+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*wn,s=o+wn,c=(i%2+2)%2*(Q/2);for(let i=-r;i<r;i+=1){let r=n+i*Q+c,l=[[r+Q/2,o],[r,s],[r+Q,s]],u=[[r+Q/2,o],[r+3*Q/2,o],[r+Q,s]],d=e=>{let t=e.map(([e])=>e),n=e.map(([,e])=>e);return Math.max(...t)>0&&Math.min(...t)<Z&&Math.max(...n)>0&&Math.min(...n)<Z};d(l)&&e.push(a(l)),d(u)&&t.push(a(u))}}return{light:e.join(``),dark:t.join(``)}}var En=Tn();function Dn(){let e=(0,Y.useRef)(null);return yn(e,Cn),(0,X.jsx)(`div`,{ref:e,className:`custom-cursor rangefinder-cursor`,"aria-hidden":`true`,children:(0,X.jsxs)(`svg`,{className:`rangefinder-cursor-facets`,viewBox:`0 0 ${Z} ${Z}`,focusable:`false`,children:[(0,X.jsx)(`path`,{className:`rangefinder-cursor-facet-light`,d:En.light}),(0,X.jsx)(`path`,{className:`rangefinder-cursor-facet-dark`,d:En.dark})]})})}function On(){let{cursorPackage:e}=E(),t=null;switch(e){case`rangefinder`:t=(0,X.jsx)(Dn,{});break;case`drafting`:t=(0,X.jsx)(xn,{});break;case`invert`:t=(0,X.jsx)(Sn,{});break;case`system`:return null}return(0,hn.createPortal)(t,document.body)}var kn=K(`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`}]]),An=K(`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`}]]),jn=K(`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`}]]),Mn=K(`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`}]]),Nn=K(`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`}]]),Pn=K(`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`}]]),Fn=K(`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 In(){let e=F(),t=Ne(),[n,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(r),s=()=>{n.trim()&&t.mutate({name:n.trim(),branch_prefix:a.trim()},{onSuccess:e=>oe(e.id)})},c=(e.data?.length??0)>0;return(0,X.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,X.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-16`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,X.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Who is working?`})]}),c&&(0,X.jsx)(`div`,{className:`flex flex-col`,children:e.data.map(e=>(0,X.jsxs)(`button`,{onClick:()=>oe(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,X.jsx)(g,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,X.jsx)(`span`,{className:z(`text-base`,d(e.icon_colour)||`text-fg`),children:e.name}),e.branch_prefix&&(0,X.jsxs)(`span`,{className:`ml-auto text-2xs text-fg-muted`,children:[e.branch_prefix,`…`]})]},e.id))}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-5`,onSubmit:e=>{e.preventDefault(),s()},children:[c&&(0,X.jsx)(`p`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`or create a profile`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(f,{htmlFor:`profile-name`,children:`Name`}),(0,X.jsx)(B,{id:`profile-name`,placeholder:`e.g. alice`,value:n,onChange:e=>i(e.target.value),className:`h-10`,autoFocus:!c})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(f,{htmlFor:`branch-prefix`,children:`Branch prefix`}),(0,X.jsx)(B,{id:`branch-prefix`,placeholder:`no prefix`,value:a,onChange:e=>o(e.target.value),className:`h-10`})]}),t.error&&(0,X.jsx)(`p`,{className:`text-xs text-danger`,children:t.error.message}),(0,X.jsx)(G,{type:`submit`,size:`lg`,className:`self-start px-6`,disabled:!n.trim()||t.isPending,children:`Create profile`})]})]})})}function Ln(){let e=Me().data?.protocol,{data:t}=it({queryKey:[`storage`],queryFn:()=>j(`GET`,`/api/storage`),enabled:e!==void 0&&(e.major>25||e.major===25&&e.minor>=5)&&!c(),refetchInterval:1e4,retry:!1});if(!t)return null;let n=t.volumes.filter(e=>e.level!==`ok`);if(!t.logs_degraded&&!t.database_degraded&&n.length===0)return null;let r=n.some(e=>e.level===`critical`);return(0,X.jsxs)(`div`,{role:`status`,className:`flex shrink-0 items-start gap-2 px-3 py-2 text-xs text-warning`,children:[(0,X.jsx)(Lt,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[t.database_degraded&&(0,X.jsx)(`p`,{children:`Storage is full. Changes cannot be saved. Live session status may be unsaved.`}),t.logs_degraded&&(0,X.jsx)(`p`,{children:`Terminal history is temporarily not being saved. Live terminals remain connected.`}),r&&(0,X.jsx)(`p`,{children:`Storage is critically low. Free space or inodes before starting new sessions or worktrees.`}),n.map(e=>(0,X.jsxs)(`p`,{className:`break-all text-fg-secondary`,children:[e.level===`unknown`?`Could not check storage`:`Low storage`,` at`,` `,e.path,e.available_bytes!==null&&` · ${Math.round(e.available_bytes/1024**2).toLocaleString()} MiB available`,e.available_inodes!==null&&` · ${e.available_inodes.toLocaleString()} inodes available`]},e.path))]})]})}var Rn=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 ${l.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=u.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=o.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}},zn=null;function Bn(e){return zn=e,()=>{zn===e&&(zn=null)}}function Vn(){zn?.()}var Hn=new Set;function Un(){return[...Hn].flatMap(e=>e())}function Wn({onNewSession:e,onNewProject:t}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(`commands`),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(!1),f=ft(),p=ut(),m=N(),h=p.id,g=$e(m??void 0),_=Ke(m??void 0),y=Ue(h),b=At();(0,Y.useEffect)(()=>me(`palette.toggle`,()=>r(e=>!e)),[]),(0,Y.useEffect)(()=>xt(()=>r(!0)),[]),(0,Y.useEffect)(()=>{n||(a(`commands`),s(``),l(null),d(!1))},[n]);let S=(0,Y.useMemo)(()=>{let n=[],r=ht((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:pt,keywords:`switch project open`,run:()=>void f(`/project/${e.id}`)});for(let e of y.data??[])e.status!==`archived`&&n.push({id:`session-${e.id}`,group:`Sessions`,label:b(e),icon:st,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:qt,keywords:`new agent create start session`,run:()=>e()},{id:`new-terminal`,group:`Actions`,label:`New terminal`,icon:st,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:pt,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:bt,keywords:`new project open create repository repo workspace`,run:t}),n.push({id:`theme-dark`,group:`Theme`,label:`Switch theme: dark`,icon:v,keywords:`switch theme dark appearance`,run:()=>void A(`dark`)},{id:`theme-light`,group:`Theme`,label:`Switch theme: light`,icon:x,keywords:`switch theme light appearance`,run:()=>void A(`light`)},{id:`theme-system`,group:`Theme`,label:`Switch theme: system`,icon:jn,keywords:`switch theme system appearance`,run:()=>void A(`system`)},{id:`open-settings`,group:`Actions`,label:`Settings`,icon:Fn,keywords:`open settings preferences options configure`,run:()=>Wt()},{id:`switch-profile`,group:`Actions`,label:`Switch profile`,icon:Gt,keywords:`switch profile identity user change`,run:()=>le.set(null)},{id:`refresh-connection`,group:`Actions`,label:`Refresh connection`,icon:Ut,keywords:`refresh connection reconnect restart cockpit tunnel ssh daemon`,run:()=>Vn()}),[...n,...Un()]},[g.data,_.data?.projectOrder,y.data,h,f,e,t,b]),C=(0,Y.useMemo)(()=>{let e=new Map;for(let t of S){let n=e.get(t.group)??[];n.push(t),e.set(t.group,n)}return[...e.entries()]},[S]),w=async()=>{let e=o.trim();if(!(e===``||u)){d(!0),l(null);try{await kt(e),r(!1)}catch(e){l(e instanceof Error?e.message:`Could not open that path.`)}finally{d(!1)}}};return(0,X.jsxs)($t,{open:n,onOpenChange:r,children:[(0,X.jsx)(Xt,{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,X.jsx)(nn,{children:(0,X.jsxs)(`div`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[(0,X.jsx)(`p`,{children:`Relative paths start from the bound worktree or project. Absolute and ~ paths work too.`}),(0,X.jsx)(`p`,{className:c?`mt-2 text-danger`:`mt-2`,"aria-live":`polite`,children:c??(u?`Opening…`:`Press Enter to open.`)})]})}):(0,X.jsxs)(nn,{children:[(0,X.jsx)(tn,{children:`Nothing matches.`}),C.map(([e,t])=>(0,X.jsx)(Qt,{heading:e,children:t.map(e=>{let t=e.icon;return(0,X.jsxs)(en,{value:`${e.label} ${e.keywords??``}`,onSelect:()=>{e.closeOnRun!==!1&&r(!1),e.run()},children:[t&&(0,X.jsx)(t,{}),e.label,e.shortcut&&(0,X.jsx)(Zt,{children:e.shortcut})]},e.id)})},e))]})]})}function Gn(){let e=document.activeElement;return e instanceof Element&&e.closest(`.xterm`)!==null}function Kn(){let e=document.activeElement;return e instanceof Element&&e.closest(`.monaco-editor`)!==null}function qn(){let e=Ke(N()??void 0).data?.hotkeys;return(0,Y.useEffect)(()=>{ae(e&&typeof e==`object`?e:void 0)},[e]),(0,Y.useEffect)(()=>me(`window.close`,()=>{let e=M();e?.closeWindow?e.closeWindow():window.close()}),[]),(0,Y.useEffect)(()=>{let e=e=>{let t=se(e);if(!t)return;let n=fe(t);if(!n)return;let r=ue(n);if(!r||!ce(r,Kn()))return;let i=pe(n);i&&(e.preventDefault(),e.stopPropagation(),i())},t=e=>{let t=se(e);if(!t)return;let n=fe(t);if(!n)return;let r=ue(n);if(!r||r.editor&&Kn()||r.deferInTerminal&&Gn())return;let i=pe(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 Jn=4e3;function Yn(){let[e,t]=(0,Y.useState)(`hidden`),n=(0,Y.useRef)(e);n.current=e,(0,Y.useEffect)(()=>{let e=null,r=J.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`)},Jn))});return()=>{r(),e!==null&&clearTimeout(e)}},[]);let r=(0,Y.useCallback)(async()=>{n.current!==`refreshing`&&(t(`refreshing`),await Rn.refresh()||(R.error(`The cockpit has not come back — it may need a terminal (ssh re-auth): puddle refresh`),t(J.isConnected()?`hidden`:`lost`)))},[]);return(0,Y.useEffect)(()=>Bn(()=>void r()),[r]),e===`hidden`?null:(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 bg-elevated px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:e===`refreshing`?`Restarting the cockpit.`:`Connection to the daemon lost.`}),e===`lost`&&(0,X.jsxs)(G,{size:`sm`,className:`ml-auto`,onClick:()=>void r(),children:[(0,X.jsx)(Ut,{}),`Refresh connection`]})]})}function Xn({label:e,percentage:t,hint:n}){let r=Math.max(0,Math.min(100,t));return(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`w-24 shrink-0 truncate text-2xs text-fg-muted`,title:e,children:e}),(0,X.jsx)(`span`,{className:`relative h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-border`,children:(0,X.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,X.jsxs)(`span`,{className:`shrink-0 text-2xs tabular-nums text-fg-muted`,children:[Math.round(r),`%`,n?` · ${n}`:``]})]})}function Zn(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Qn(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 $n({account:e,onLogin:t,onStartSession:n,installed:r=!0}){let i=xe(e.id),a=e.logged_in?n:r?t:null,o=i.data?.subscription;return(0,X.jsxs)(`div`,{className:`rounded-md px-2 py-2 transition-colors hover:bg-elevated`,children:[(0,X.jsxs)(`button`,{type:`button`,disabled:a===null,onClick:()=>a?.(),className:`flex w-full items-center gap-3 text-left disabled:cursor-default`,children:[(0,X.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${e.logged_in?`bg-success`:`bg-idle`}`,"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.label}),(0,X.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[e.logged_in?`logged in`:`logged out`,i.data&&(0,X.jsxs)(X.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 `,Qn(i.data.last_activity_at)]})]}),i.data?.agent_usage&&(0,X.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[Zn(i.data.agent_usage.input_tokens),` in ·`,` `,Zn(i.data.agent_usage.output_tokens),` out ·`,` `,Zn(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,X.jsx)(`span`,{className:`mt-1 block`,children:(0,X.jsx)(Xn,{label:`context`,percentage:i.data.live_usage.context_used_percentage})})]}),(0,X.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted`,children:r?e.logged_in?n?`new agent`:``:(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-warning`,children:[(0,X.jsx)(_,{className:`size-3`}),`sign in`]}):`unavailable`})]}),o!=null&&o.windows.length>0&&(0,X.jsx)(`div`,{className:`mt-2 flex flex-col gap-1 pl-5`,children:o.windows.map(e=>(0,X.jsx)(Xn,{label:e.label,percentage:e.used_percentage,hint:e.resets==null?void 0:`resets ${e.resets}`},e.key))})]})}function er(){let[e,t]=(0,Y.useState)(!1),[n,r]=(0,Y.useState)(!1),i=N(),a=F(),o=_e(),s=a.data?.find(e=>e.id===i),c=tt(i??void 0),l=ze(),u=Ae(),{open:f,handler:p}=wt(),[m,_]=(0,Y.useState)(null),v=e=>u.mutate(e.id,{onSuccess:t=>_({stream:t.stream,label:`${e.agent_type}/${e.label}`}),onError:e=>q(e)}),y=e=>{t(!1),f({accountId:e.id})};return n&&s?(0,X.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-3`,children:[(0,X.jsx)(g,{icon:s.icon,colour:s.icon_colour}),(0,X.jsx)(Nt,{initial:s.name,maxLength:100,className:z(`w-32 text-sm`,d(s.icon_colour)),onCommit:e=>{r(!1);let t=e.trim();!i||!t||t===s?.name||o.mutate({id:i,name:t},{onError:e=>q(e)})},onCancel:()=>r(!1)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(on,{open:e,onOpenChange:t,children:[(0,X.jsxs)(W,{children:[(0,X.jsx)(U,{asChild:!0,children:(0,X.jsx)(an,{asChild:!0,children:(0,X.jsxs)(G,{variant:`ghost`,size:`sm`,className:`font-sans compact:h-7 compact:px-1.5`,children:[(0,X.jsx)(g,{icon:s?.icon,colour:s?.icon_colour}),(0,X.jsx)(`span`,{className:d(s?.icon_colour),...Ht(()=>{t(!1),r(!0)}),children:s?.name??`…`})]})})}),(0,X.jsx)(H,{children:`Profile`})]}),(0,X.jsxs)(rn,{className:`w-[28rem] max-w-[calc(100vw-1rem)]`,children:[(0,X.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,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsxs)(`span`,{className:`px-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:[e.display_name,!n&&(0,X.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,X.jsx)($n,{account:e,onLogin:()=>v(e),onStartSession:p&&n?()=>y(e):null,installed:n},e.id))]},e.id)}),c.data?.length===0&&(0,X.jsx)(`p`,{className:`px-2 text-sm text-fg-muted`,children:`No accounts yet — add one in settings.`})]}),(0,X.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,X.jsxs)(G,{variant:`ghost`,size:`sm`,onClick:()=>{t(!1),Wt(`accounts`)},children:[(0,X.jsx)(bt,{}),`Add account`]}),(0,X.jsxs)(G,{variant:`ghost`,size:`sm`,className:`ml-auto`,onClick:()=>{t(!1),le.set(null)},children:[(0,X.jsx)(Pn,{}),`Switch profile`]})]})]})]}),m&&(0,X.jsx)(h,{stream:m.stream,label:m.label,onClose:()=>_(null)})]})}var tr=`desktop-update`;function nr(){let e=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{let t=M();if(t?.updateReady===void 0||t.onUpdateReady===void 0)return;let n=t=>{e.current!==t&&(e.current=t,R(`Puddle ${t} is downloaded and ready.`,{id:tr,duration:1/0,closeButton:!0,action:{label:`Restart to update`,onClick:()=>{M()?.installUpdate?.(),R.loading(`Restarting into Puddle ${t}…`,{id:`${tr}-restarting`,duration:1/0})}}}))};return t.updateReady().then(e=>{e!==null&&n(e)}),t.onUpdateReady(n)},[]),null}function rr(){let e=N(),t=F().data?.find(t=>t.id===e),n=Ke(e??void 0),r=Xe(e??void 0,void 0),i=E(),a=S(),o=C(),s=Ge(e??``),c=_e(),l=Te(),[u,d]=(0,Y.useReducer)(e=>e+1,0);(0,Y.useEffect)(()=>te(()=>d()),[]);let f=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{f.current=null},[t?.name]);let p=a.data?.available===!0?a.data.file:void 0,h=t!==void 0&&e!==null&&n.data!==void 0&&r.data!==void 0&&p!==void 0,g=t&&p?m(p,t.name):void 0,_=s.isPending||c.isPending||l.isPending||o.isPending||n.isFetching||r.isFetching;(0,Y.useEffect)(()=>{if(!h||!g?.enabled||_)return;let a={client:i,theme:re(),profileSettings:n.data,profile:t,scratchpad:r.data},u={setClient:e=>D(e),setTheme:e=>{typeof e==`string`&&A(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,b(g.doc,u,a,g.groups);return}let p=T(g.groups,a),m=JSON.stringify(p);m!==d&&(f.current=m,o.mutate({profile:t.name,entry:{...g,doc:p,updatedAt:new Date().toISOString()}}))})}function ir(e){let t=t=>{let n=a.safeParse(t);n.success&&e(n.data)},n=M()?.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 ar=5e3,or=`[data-notification-session]`;function sr(e){let t=null,n=()=>{t=null},r=e=>e.target instanceof Element?e.target.closest(or):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<ar&&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 cr=new Set,lr=e=>!!e&&cr.has(e),ur=i.parse({});function dr(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 fr(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 pr(e){return e.title??e.agent_title??e.osc_title??e.id.slice(0,8)}function mr(){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 hr(){let e=ft(),t=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let e=sr(document);return t.current=e,()=>{t.current=null,e.dispose()}},[]),(0,Y.useEffect)(()=>ir(t=>{t.host||e(`/project/${t.project}/session/${t.session}`,{state:{notificationSession:t.session}})}),[e]),gr(t=>{e(`/project/${t.project_id}/session/${t.id}`,{state:{notificationSession:t.id}})},e=>t.current?.isInteracting(e.id)??!1)}function gr(e,t=()=>document.hasFocus()){let n=nt(),r=(0,Y.useRef)(e);r.current=e;let a=(0,Y.useRef)(t);a.current=t;let o=We(je().data)??`Puddle`,s=(0,Y.useRef)(o);(0,Y.useEffect)(()=>{document.title===s.current&&(document.title=o),s.current=o},[o]),(0,Y.useEffect)(()=>{let e=new Set,t=()=>{document.title=e.size>0?`(${e.size}) ${s.current}`:s.current},o=!0,l=async e=>{let t=fr(n,e.session);if(!t)try{t=(await et(n)).find(t=>t.id===e.session)}catch{return}if(!o||!t)return;let l=t,u,d;try{let e=await n.fetchQuery({queryKey:[`project`,l.project_id],queryFn:()=>j(`GET`,`/api/projects/${l.project_id}`),staleTime:1e4});if(!o)return;d=e.project;let t=d.profile_id,r=await n.fetchQuery({queryKey:[`profile-settings`,t],queryFn:()=>j(`GET`,`/api/profiles/${t}/settings`),staleTime:1e4});u=i.catch(ur).parse(r.notifications??{})}catch{return}if(!o)return;let f=dr({prefs:u,projectId:l.project_id,sessionFocused:a.current(l),permission:y()});f.sound&&mr(),f.desktop&&!lr(c()?.scope)&&await w({id:e.id?`puddle-event-${e.id}`:`puddle-agent-${l.id}`,title:e.content?.title??pr(l).slice(0,160),body:e.content?.body??(e.reason===`exited`?`Agent finished running`:`Waiting for your input`),target:{project:l.project_id,session:l.id,...c()?.notificationHost?{host:c().notificationHost}:{}}},()=>{o&&r.current(l)},{host:s.current,project:d})},u=J.onAgentNotification(e=>{l(e)}),d=J.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:()=>j(`GET`,`/api/version`),staleTime:1/0}).then(e=>{if(!(e.protocol.major>22||e.protocol.major===22&&e.protocol.minor>=3))return l({session:r.session,reason:`waiting_input`})}).catch(()=>{})});return()=>{o=!1,d(),u(),document.title=s.current}},[n])}function _r({initial:e,defaultScope:t,allowProject:n=!0,agents:r,onSave:i,onCancel:a}){let[o,s]=(0,Y.useState)(e?.title??``),[c,l]=(0,Y.useState)(e?.body??``),[u,d]=(0,Y.useState)(n?e?.scope??t:`profile`),[f,p]=(0,Y.useState)((e?.tags??[]).join(`, `)),[m,h]=(0,Y.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,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(B,{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,X.jsx)(vt,{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,X.jsx)(B,{value:f,placeholder:`tags, comma, separated`,spellCheck:!1,onChange:e=>p(e.target.value),onKeyDown:e=>e.stopPropagation(),className:`h-8 text-xs`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,X.jsxs)(`label`,{className:`flex items-center gap-1.5 text-2xs text-fg-secondary`,children:[(0,X.jsx)(Kt,{checked:u===`profile`,onCheckedChange:e=>d(e?`profile`:`project`)}),`Profile-wide`]}),(0,X.jsx)(`div`,{className:`ml-auto flex items-center gap-1`,children:r.map(e=>(0,X.jsxs)(`button`,{type:`button`,title:e.display_name,"aria-pressed":m===e.id,onClick:()=>h(t=>t===e.id?null:e.id),className:z(`rounded-md p-1 transition-colors`,m===e.id?`bg-surface text-fg`:`text-fg-gold hover:bg-surface hover:text-fg`),children:[(0,X.jsx)(Tt,{type:e.id,className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:e.display_name})]},e.id))})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,X.jsx)(G,{variant:`ghost`,size:`sm`,onClick:a,children:`Cancel`}),(0,X.jsx)(G,{size:`sm`,disabled:!c.trim(),onClick:g,children:`Save`})]})]})}function vr(){let e=St(),t=N(),n=ut().id,r=Xe(t??void 0,n).data??[],i=ze().data??[],a=Te(),o=Qe(),s=De(),c=Ot(),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null);(0,Y.useEffect)(()=>me(`scratchpad.toggle`,Dt),[]),(0,Y.useEffect)(()=>{e||(u(null),f(null),m(null))},[e]);let y=(0,Y.useMemo)(()=>[...new Set(r.flatMap(e=>e.tags))].sort((e,t)=>e.localeCompare(t)),[r]),b=(0,Y.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),R.success(`Copied to clipboard`)};return(0,X.jsxs)(on,{open:e,onOpenChange:Ct,children:[(0,X.jsxs)(W,{children:[(0,X.jsx)(U,{asChild:!0,children:(0,X.jsx)(an,{asChild:!0,children:(0,X.jsxs)(G,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,X.jsx)(Mn,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Scratchpad`})]})})}),(0,X.jsx)(H,{children:`Scratchpad`})]}),(0,X.jsxs)(rn,{className:`w-[34rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,X.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Scratchpad`}),(0,X.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,X.jsx)(bt,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`New entry`})]})]}),(y.length>0||b.length>0)&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:[y.map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(t=>t===e?null:e),className:z(`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,X.jsx)(`button`,{type:`button`,"aria-pressed":p===e,onClick:()=>m(t=>t===e?null:e),className:z(`rounded-md p-1 transition-colors`,p===e?`bg-action text-action-ink`:`text-fg-gold hover:bg-surface`),children:(0,X.jsx)(Tt,{type:e,className:`size-3.5`})},e))]}),(0,X.jsxs)(`div`,{className:`no-scrollbar max-h-[65vh] overflow-y-auto px-2 pb-3`,children:[l===`new`&&(0,X.jsx)(`div`,{className:`px-3 py-2`,children:(0,X.jsx)(_r,{defaultScope:n?`project`:`profile`,allowProject:n!==void 0,agents:i,onSave:w,onCancel:()=>u(null)})}),C.length===0&&l!==`new`&&(0,X.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,X.jsx)(`ul`,{className:`flex flex-col`,children:C.map(e=>l===e.id?(0,X.jsx)(`li`,{className:`px-3 py-2`,children:(0,X.jsx)(_r,{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,X.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:z(`transition-opacity`,h===e.id&&`opacity-50`),children:(0,X.jsx)(yr,{entry:e,onInsert:c?()=>{c(e.body),Ct(!1)}:null,onCopy:()=>O(e),onEdit:()=>u(e.id),onDelete:()=>s.mutate(e.id)})},e.id))})]})]})]})}function yr({entry:e,onInsert:t,onCopy:n,onEdit:r,onDelete:i}){let[a,o]=(0,Y.useState)(!1);return(0,X.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,X.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.title}),(0,X.jsx)(`p`,{className:z(`line-clamp-3 whitespace-pre-wrap text-sm text-fg-secondary`,e.title&&`mt-0.5`),children:e.body}),a?(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:`Delete this entry? This can’t be undone.`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),i()},className:`text-2xs font-medium text-interrupted transition-colors hover:underline`,children:`Delete`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Cancel`})]}):(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:e.scope===`profile`?`Profile-wide`:`Project`}),e.agent_type&&(0,X.jsx)(Tt,{type:e.agent_type,className:`size-3 text-fg-gold`}),e.tags.map(e=>(0,X.jsx)(`span`,{className:`rounded-full bg-surface px-1.5 text-2xs text-fg-secondary`,children:e},e)),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[t&&(0,X.jsx)(br,{icon:kn,label:`Insert into focused terminal`,onClick:t}),(0,X.jsx)(br,{icon:Jt,label:`Copy`,onClick:n}),(0,X.jsx)(br,{icon:p,label:`Edit`,onClick:r}),(0,X.jsx)(br,{icon:yt,label:`Delete`,onClick:()=>o(!0)})]})]})]})}function br({icon:e,label:t,onClick:n}){return(0,X.jsxs)(W,{children:[(0,X.jsx)(U,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:n,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,X.jsx)(e,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,X.jsx)(H,{children:t})]})}var xr=s.parse({});function Sr(e,t){let[n,r]=(0,Y.useState)(null),i=we(t).data,a=$e(e??void 0,t&&e!==null).data;return(0,Y.useEffect)(()=>{if(!t||e===null){r(null);return}let n=!1,i;try{i=Vt(sessionStorage.getItem(Bt(e)))}catch{i={kind:`absent`}}if(i.kind===`present`){r(i.snapshot);return}return at(e).then(e=>{n||r(e?e.ui_state:xr)}).catch(()=>{n||r(xr)}),()=>{n=!0}},[t,e]),(0,Y.useMemo)(()=>{if(!t||e===null||n===null)return null;let o=t=>{if(!i||!a)return!1;let{patch:o,projectBased:s}=Ft(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),rt(e,c).catch(e=>console.warn(`ui-state save failed: ${e.message}`));try{sessionStorage.setItem(Bt(e),JSON.stringify(c))}catch(e){console.warn(`ui-state write failed: ${e.message}`)}return O().projectBasedLayout!==s&&D({projectBasedLayout:s}),!0},s=Object.fromEntries(Object.entries(n.project_layouts).map(([e,t])=>[e,{layoutRef:t.layout_ref,signature:V(t.layout_tree)}]));return(n.layout_mode??`profile`)===`project`?{headless:!0,scope:`project`,projectId:``,layoutRef:null,signature:V(null),slices:s,capture:()=>({layout_tree:null,active_session:null}),apply:o}:{scope:`profile`,projectId:``,layoutRef:n.layout_ref,signature:V(n.layout_tree),slices:s,capture:()=>({layout_tree:n.layout_tree,active_session:n.active_session}),apply:o}},[t,e,n,i,a])}var Cr=V(null);function wr(){let e=It(),t=ft(),n=N(),r=Rt(),i=Sr(n,e&&r===null),a=r??i,o=Ze(n??void 0,void 0).data??[],s=$e(n??void 0,e&&n!==null).data??[],c=qe(),l=Le(),u=ye(),[d,f]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(null);(0,Y.useEffect)(()=>me(`layouts.toggle`,Pt),[]),(0,Y.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!==Cr:V(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?V(n.layout_tree)!==t.signature:t.signature!==Cr},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=>q(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=>q(e)})},k=(e,t)=>O(t,{layout_tree:e.layout_tree,active_session:e.active_session},!1),te=e=>{if(a){if(!a.apply(e)){R.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}`),Mt(!1)}};return(0,X.jsxs)(on,{open:e,onOpenChange:Mt,children:[(0,X.jsxs)(W,{children:[(0,X.jsx)(U,{asChild:!0,children:(0,X.jsx)(an,{asChild:!0,children:(0,X.jsxs)(G,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,X.jsx)(An,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Layouts`})]})})}),(0,X.jsx)(H,{children:`Layouts`})]}),(0,X.jsxs)(rn,{className:`w-[26rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,X.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Layouts`}),a!==null&&!_&&(0,X.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,X.jsx)(bt,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Save the current layout as a new layout`})]})]}),a===null?(0,X.jsx)(`p`,{className:`px-5 pb-3 text-sm text-fg-muted`,children:`Loading the profile’s layout state…`}):_?(0,X.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,X.jsxs)(`div`,{className:`flex flex-col gap-2 px-5 pb-3`,children:[v===null&&(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:`Unnamed layout`}),(0,X.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:a.scope===`profile`?`Profile-wide`:`Project`}),(0,X.jsx)(`span`,{className:`ml-auto text-2xs text-interrupted`,children:`Unsaved`})]}),(0,X.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,X.jsx)(B,{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,X.jsx)(G,{size:`sm`,type:`submit`,disabled:!d.trim(),children:`Save`}),v!==null&&(0,X.jsx)(G,{variant:`ghost`,size:`sm`,onClick:()=>m(!1),children:`Cancel`})]})]}),T.length>1&&(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:T.map(e=>(0,X.jsx)(Dr,{active:h===e.key,onClick:()=>g(t=>t===e.key?null:e.key),children:e.name},e.key))}),(0,X.jsxs)(`div`,{className:`no-scrollbar max-h-[60vh] overflow-y-auto px-2 pb-3`,children:[E.length===0&&(0,X.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,X.jsx)(`ul`,{className:`flex flex-col`,children:E.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(Tr,{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:()=>te(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 Tr({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[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(e.name),b=()=>{if(!(!i||g!==null)){if(o&&m!==`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,X.jsxs)(`div`,{onClick:e=>{e.target.closest(`button, input`)||b()},className:z(`rounded-md px-3 py-2.5 transition-colors`,i&&`cursor-pointer hover:bg-surface`),children:[g===null?(0,X.jsxs)(`p`,{className:z(`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,X.jsx)(`span`,{className:`text-2xs font-normal`,children:C===`active`?`Active`:`Unsaved`})]}):(0,X.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,X.jsx)(B,{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,X.jsx)(G,{size:`sm`,type:`submit`,disabled:!v.trim(),children:g===`rename`?`Rename`:`Save`})]}),m===`save`?(0,X.jsx)(Er,{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)}):m===`delete`?(0,X.jsx)(Er,{question:`Delete this layout? This can’t be undone.`,verb:`Delete`,onConfirm:()=>{h(null),u()},onCancel:()=>h(null)}):m===`load`?(0,X.jsx)(Er,{question:`Loading discards unsaved layout changes.`,verb:`Load`,onConfirm:b,onCancel:()=>h(null)}):(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[t!==null&&(0,X.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:t}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[a&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Or,{icon:Nn,label:n?`Save`:`Save the current layout as “${e.name}”`,onClick:S}),(0,X.jsx)(Or,{icon:Jt,label:`Duplicate`,onClick:()=>x(`duplicate`)})]}),(0,X.jsx)(Or,{icon:p,label:`Rename`,onClick:()=>x(`rename`)}),(0,X.jsx)(Or,{icon:yt,label:`Delete`,onClick:()=>h(`delete`)})]})]})]})}function Er({question:e,verb:t,onConfirm:n,onCancel:r}){return(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e}),(0,X.jsx)(`button`,{type:`button`,onClick:n,className:`text-2xs font-medium text-interrupted transition-colors hover:underline`,children:t}),(0,X.jsx)(`button`,{type:`button`,onClick:r,className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Cancel`})]})}function Dr({active:e,onClick:t,children:n}){return(0,X.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:t,className:z(`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 Or({icon:e,label:t,onClick:n}){return(0,X.jsxs)(W,{children:[(0,X.jsx)(U,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:n,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,X.jsx)(e,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,X.jsx)(H,{children:t})]})}var $=M()!==void 0&&/Mac/.test(navigator.platform),kr=(0,Y.lazy)(()=>k(()=>import(`./SettingsDialog-XdYkVxAp.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,30,31])));function Ar(){let e=nt();(0,Y.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=J.onStatus(e=>t(t=>t.id===e.session?{...t,status:e.status,last_activity_at:e.last_activity_at}:t)),r=J.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=J.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=J.onSessionsChanged(e=>a(e.project_ids)),s=J.onSessionSwitched(e=>a([e.target_project]));return()=>{n(),r(),i(),o(),s()}},[e])}function jr(){let e=je(),t=He(),[n,r]=(0,Y.useState)(!1),i=We(e.data),a=n=>{r(!1);let a=n.trim();a!==i&&t.mutate({displayName:a===e.data?.hostname?``:a},{onError:e=>q(e)})},o=!$&&(0,X.jsx)(`img`,{src:`/puddle.svg`,alt:`Puddle`,className:`size-4`}),s=z(`flex shrink-0 items-center gap-2`,$&&`[-webkit-app-region:no-drag]`),c=`truncate text-sm font-semibold text-fg-secondary`;return n&&i!==void 0?(0,X.jsxs)(`div`,{className:s,children:[o,(0,X.jsx)(Nt,{initial:e.data?.displayName??i,maxLength:64,className:z(c,`w-40`),onCommit:a,onCancel:()=>r(!1)})]}):(0,X.jsxs)(dt,{to:`/`,className:z(s,`transition-opacity hover:opacity-70`),title:`All projects`,children:[o,i!==void 0&&(0,X.jsx)(`span`,{className:c,...Ht(()=>r(!0)),children:i})]})}function Mr(){let e=ut(),t=de(`palette.toggle`),n=Ye(e.id).data?.project,r=n!==void 0&&n.id===e.id?n.name:void 0;return(0,X.jsxs)(`button`,{type:`button`,onClick:Et,className:z(`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`,$&&`[-webkit-app-region:no-drag]`),children:[(0,X.jsx)(`span`,{className:z(`truncate text-xs`,r&&d(n?.colour)),children:r??`Puddle`}),(0,X.jsx)(`span`,{className:`text-2xs`,children:t})]})}function Nr(){let{fullScreen:e,animate:t}=he();return(0,X.jsxs)(`header`,{className:z(`relative flex h-9 shrink-0 items-center gap-3 bg-surface pl-3 pr-3`,$&&!e&&`pl-[88px] [-webkit-app-region:drag]`,t&&`transition-[padding] duration-200 ease-out`),children:[(0,X.jsx)(jr,{}),(0,X.jsx)(Mr,{}),(0,X.jsxs)(`div`,{className:z(`ml-auto flex items-center`,$&&`[-webkit-app-region:no-drag]`),children:[(0,X.jsxs)(W,{children:[(0,X.jsx)(U,{asChild:!0,children:(0,X.jsxs)(G,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,onClick:()=>Wt(),children:[(0,X.jsx)(Fn,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Settings`})]})}),(0,X.jsx)(H,{children:`Settings`})]}),(0,X.jsx)(wr,{}),(0,X.jsx)(vr,{}),(0,X.jsx)(er,{})]})]})}function Pr(){Ar(),rr(),hr();let{handler:e}=wt(),t=N(),{pathname:n}=mt(),[r,i]=(0,Y.useState)(!1),a=Me(),o=a.data!==void 0&&Je(a.data.protocol);return(0,Y.useEffect)(()=>{if(!o)return;let e=()=>{let e=ne();J.reportTheme(e(`--text-primary`),e(`--bg-base`))};return e(),te(e)},[o]),(0,X.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden overscroll-y-none bg-ground`,children:[(0,X.jsx)(Nr,{}),(0,X.jsx)(`main`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(fn,{resetOn:n,scope:n.startsWith(`/project/`)?`workspace`:`view`,children:(0,X.jsx)(gt,{})})}),(0,X.jsx)(Ln,{}),(0,X.jsx)(Yn,{}),(0,X.jsx)(nr,{}),(0,X.jsx)(Wn,{onNewSession:e??void 0,onNewProject:()=>i(!0)}),t!==null&&(0,X.jsx)(Yt,{profileId:t,open:r,onOpenChange:i}),(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(kr,{})}),(0,X.jsx)(qn,{})]})}function Fr(){return(0,X.jsx)(zt,{children:(0,X.jsx)(Pr,{})})}var Ir=(0,Y.lazy)(()=>k(()=>import(`./Dashboard-pZ9Z5be0.js`).then(e=>({default:e.Dashboard})),__vite__mapDeps([32,1,2,3,4,5,6,7,8,9,10,11,14,15,13,33,22,34,25,35,36,29,28,21,37]))),Lr=(0,Y.lazy)(()=>k(()=>import(`./Workspace-BKA9SyN-.js`).then(e=>({default:e.Workspace})),__vite__mapDeps([38,1,2,8,3,4,5,6,7,9,10,11,18,19,20,13,14,39,15,40,21,25,35,33,17,41,16,42,43,22,34,44,23,24,45,46,37,28,47,48,49,31,50]))),Rr=new dn({defaultOptions:{queries:{retry:1,staleTime:5e3}},mutationCache:new cn({onError:e=>q(e)})});function zr(){let e=N(),t=F(),n=e!==null&&t.data!==void 0&&!t.data.some(t=>t.id===e);return e===null||n?(0,X.jsx)(In,{}):(0,X.jsx)(ct,{useTransitions:!1,children:(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(lt,{children:(0,X.jsxs)(L,{element:(0,X.jsx)(Fr,{}),children:[(0,X.jsx)(L,{path:`/`,element:(0,X.jsx)(Ir,{})}),(0,X.jsx)(L,{path:`/project/:id`,element:(0,X.jsx)(Lr,{})}),(0,X.jsx)(L,{path:`/project/:id/session/:sid`,element:(0,X.jsx)(Lr,{})})]})})})})}function Br(){let e=(0,Y.useSyncExternalStore)(l.subscribe,l.get);return(0,X.jsx)(Se,{client:Rr,children:(0,X.jsxs)(jt,{delayDuration:300,children:[(0,X.jsx)(On,{}),(0,X.jsx)(fn,{scope:`app`,children:e?window.location.pathname.startsWith(`/forward/`)?(0,X.jsx)(sn,{}):(0,X.jsx)(zr,{}):(0,X.jsx)(mn,{})}),(0,X.jsx)(pn,{})]})})}export{Br as App};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{y as n}from"./auth-GfOuXpIe.js";import{a as r,c as i,d as a,i as o,o as s,s as c,t as l,u}from"./LazyTerminal-CgQryH0p.js";import{t as d}from"./jsx-runtime-By8HlURe.js";import{g as f,p}from"./hotkeys-1uTWFYAL.js";import{L as m,_t as h,et as g,ft as _,h as v,it as y,st as b,tt as x}from"./protocol-support-BGmIChNK.js";import{a as S,i as C,l as w,o as T,r as E}from"./session-order-f7QxTbVD.js";import{a as D,i as O,n as k,o as A,t as ee}from"./dialog-BMWRC2HO.js";import{n as j}from"./x-DCpy1q13.js";import{t as M}from"./input-CxgRsoVg.js";import{t as N}from"./button-BgeBH2Uc.js";import{c as P,d as F,n as te,r as I,t as L,u as R}from"./context-menu-CMWkmDu6.js";import{r as z}from"./dist-Ds3438NL.js";import{t as B}from"./NewProjectDialog-BT8rR4yn.js";import{n as V}from"./errors-O9DWXa3f.js";import{t as H}from"./ws-CMPCIzY4.js";var U=e(t(),1),W=d(),G=!1;function K(){let[e,t]=(0,U.useState)(G),[r,i]=(0,U.useState)(null);(0,U.useEffect)(()=>{if(!e)return;let t=!1;return H.spawnShell(n).then(e=>{t||i(e)}),()=>{t=!0}},[e]);let a=()=>{G=!1,t(!1),i(null)};return{open:e,term:r,toggle:()=>{e?(r&&H.killShell(n,r),a()):(G=!0,t(!0))},onExit:a}}function q({term:e,onExit:t}){return(0,W.jsx)(`div`,{className:`h-72 shrink-0 pb-6`,children:(0,W.jsx)(`div`,{className:`mx-auto size-full max-w-4xl px-6`,children:e!==null&&(0,W.jsx)(l,{stream:`home`,term:e,onExit:t})})})}var J=`group block w-full rounded-lg bg-surface p-4 text-left transition-colors hover:bg-elevated`,Y=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function X({project:e,repoPath:t,sessions:n}){let i=n.filter(e=>e.status!==`archived`);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h2`,{className:j(`truncate pr-16 text-base font-semibold`,r(e.colour)||`text-fg group-hover:text-accent`),children:e.name}),(0,W.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:t??`…`}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,W.jsxs)(`span`,{children:[i.length,` session`,i.length===1?``:`s`]}),Y.map(({status:e,colour:t})=>{let n=i.filter(t=>t.status===e).length;return n>0?(0,W.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),n,` `,e.replace(`_`,` `)]},e):null})]})]})}function Z({icon:e,label:t,onClick:n}){return(0,W.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,W.jsx)(e,{className:`size-4`})})}function Q({project:e,repoPath:t,draggable:n,dragging:c,onDragStart:l,onDragEnd:d,onDragOver:f}){let p=x(),g=v(m().data?.protocol),_=h(e.id),[y,b]=(0,U.useState)(!1),[S,C]=(0,U.useState)(e.name),[T,E]=(0,U.useState)(a(e)),[z,B]=(0,U.useState)(e.colour??null),H=t=>p.mutate({id:e.id,archived:t},{onError:e=>V(e)}),G=()=>{C(e.name),B(e.colour??null),E(a(e)),b(!0)},K=()=>{let t=S.trim(),n=u(T);if(!t){b(!1);return}let r={...t===e.name?{}:{name:t},...n&&n!==a(e)?{abbrev:n}:{},...g&&z!==(e.colour??null)?{colour:z}:{}};if(Object.keys(r).length===0){b(!1);return}p.mutate({id:e.id,...r},{onSuccess:()=>b(!1),onError:e=>V(e)})};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(L,{children:[(0,W.jsx)(P,{asChild:!0,children:(0,W.jsxs)(`div`,{draggable:n,onDragStart:l,onDragEnd:d,onDragOver:f,className:j(`group relative transition-opacity`,c&&`opacity-50`),children:[(0,W.jsx)(w,{draggable:!1,to:`/project/${e.id}`,className:J,children:(0,W.jsx)(X,{project:e,repoPath:t,sessions:_.data??[]})}),(0,W.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,W.jsx)(Z,{icon:F,label:`Reopen project`,onClick:()=>H(!1)}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Z,{icon:s,label:`Edit project`,onClick:G}),(0,W.jsx)(Z,{icon:R,label:`Archive project`,onClick:()=>H(!0)})]})})]})}),(0,W.jsx)(te,{children:e.archived?(0,W.jsxs)(I,{onSelect:()=>H(!1),children:[(0,W.jsx)(F,{}),` Reopen`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(I,{onSelect:G,children:[(0,W.jsx)(s,{}),` Edit`]}),(0,W.jsxs)(I,{onSelect:()=>H(!0),children:[(0,W.jsx)(R,{}),` Archive`]})]})})]}),(0,W.jsx)(ee,{open:y,onOpenChange:b,children:(0,W.jsxs)(k,{children:[(0,W.jsx)(D,{children:(0,W.jsx)(A,{children:`Edit project`})}),(0,W.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),K()},children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(i,{htmlFor:`project-name-${e.id}`,children:`Name`}),(0,W.jsx)(M,{id:`project-name-${e.id}`,value:S,className:r(z),onChange:e=>C(e.target.value),autoFocus:!0})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(i,{htmlFor:`project-abbrev-${e.id}`,children:`Abbreviation`}),(0,W.jsx)(M,{id:`project-abbrev-${e.id}`,maxLength:5,value:T,onChange:e=>E(u(e.target.value)),className:`w-24 uppercase`}),(0,W.jsxs)(`p`,{className:`text-2xs text-fg-muted`,children:[`Up to `,5,` characters — the label on the collapsed sidebar rail.`]})]}),g&&(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:`Colour`}),(0,W.jsx)(o,{value:z,onChange:B,label:`Project colour`})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsx)(i,{className:`text-fg-muted`,children:`Path`}),(0,W.jsx)(`p`,{className:`truncate text-2xs text-fg-muted`,children:t??`…`})]}),(0,W.jsxs)(O,{children:[(0,W.jsx)(N,{type:`button`,variant:`ghost`,onClick:()=>b(!1),children:`Cancel`}),(0,W.jsx)(N,{type:`submit`,disabled:!S.trim()||p.isPending,children:`Save`})]})]})]})})]})}function $({icon:e,label:t,hint:n,onClick:r}){return(0,W.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,W.jsxs)(`h2`,{className:`flex items-center gap-2 truncate text-base font-semibold text-fg group-hover:text-accent`,children:[(0,W.jsx)(e,{className:`size-4 shrink-0`}),t]}),(0,W.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:n})]})}function ne(){let e=f(),t=b(e??void 0),n=_(),r=y(e??void 0),i=g(e??``),[a,o]=(0,U.useState)(!1),[s,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(!1),m=K(),h=p(`palette.toggle`),v=e=>n.data?.find(t=>t.id===e)?.path,x=t.data??[],w=r.data?.projectOrder??[],D=E(x.filter(e=>!e.archived),w),O=x.filter(e=>e.archived),k=(e,t)=>{e!==t&&i.mutate({projectOrder:C(D.map(e=>e.id),e,t)})};return(0,W.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,W.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[x.length===0&&(0,W.jsxs)(`div`,{className:`mb-8 mt-16 flex flex-col items-center gap-3 text-center`,children:[(0,W.jsx)(c,{className:`size-8 text-fg-muted`}),(0,W.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No projects yet — open one below, or press `,h,`.`]})]}),(0,W.jsxs)(`div`,{className:`grid auto-rows-fr grid-cols-1 gap-3 sm:grid-cols-2`,children:[D.map(e=>(0,W.jsx)(Q,{project:e,repoPath:v(e.repo_id),draggable:!0,dragging:s===e.id,onDragStart:()=>l(e.id),onDragEnd:()=>l(null),onDragOver:t=>{t.preventDefault(),s&&s!==e.id&&k(s,e.id)}},e.id)),(0,W.jsx)($,{icon:T,label:`Open project`,hint:`Point at a repository on this host`,onClick:()=>o(!0)}),(0,W.jsx)($,{icon:S,label:m.open?`Close terminal`:`Open terminal`,hint:m.open?`End the shell below`:`A shell at ~ for cloning repositories`,onClick:m.toggle})]}),O.length>0&&(0,W.jsxs)(`div`,{className:`mt-6`,children:[(0,W.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,W.jsx)(z,{className:j(`size-3 transition-transform`,u&&`rotate-90`)}),(0,W.jsx)(R,{className:`size-3`}),(0,W.jsx)(`span`,{children:`Archived`}),(0,W.jsx)(`span`,{className:`tabular-nums`,children:O.length})]}),u&&(0,W.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:O.map(e=>(0,W.jsx)(Q,{project:e,repoPath:v(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]})]})}),m.open&&(0,W.jsx)(q,{term:m.term,onExit:m.onExit}),e!==null&&(0,W.jsx)(B,{profileId:e,open:a,onOpenChange:o})]})}export{ne as Dashboard};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{y as n}from"./auth-Bvs3kkqE.js";import{a as r,c as i,d as a,i as o,o as s,s as c,t as l,u}from"./LazyTerminal-DXz4jhHV.js";import{t as d}from"./jsx-runtime-By8HlURe.js";import{g as f,p}from"./hotkeys-Bb6oSnV3.js";import{L as m,_t as h,et as g,ft as _,h as v,it as y,st as b,tt as x}from"./protocol-support-B9FOVWIr.js";import{a as S,i as C,l as w,o as T,r as E}from"./session-order-C9VTNopC.js";import{a as D,i as O,n as k,o as A,t as ee}from"./dialog-BMWRC2HO.js";import{n as j}from"./x-DCpy1q13.js";import{t as M}from"./input-CxgRsoVg.js";import{t as N}from"./button-BgeBH2Uc.js";import{c as P,d as F,n as te,r as I,t as L,u as R}from"./context-menu-CMWkmDu6.js";import{r as z}from"./dist-Ds3438NL.js";import{t as B}from"./NewProjectDialog-ByTHhInN.js";import{n as V}from"./errors-D7cN9zwV.js";import{t as H}from"./ws-bjTyWUY1.js";var U=e(t(),1),W=d(),G=!1;function K(){let[e,t]=(0,U.useState)(G),[r,i]=(0,U.useState)(null);(0,U.useEffect)(()=>{if(!e)return;let t=!1;return H.spawnShell(n).then(e=>{t||i(e)}),()=>{t=!0}},[e]);let a=()=>{G=!1,t(!1),i(null)};return{open:e,term:r,toggle:()=>{e?(r&&H.killShell(n,r),a()):(G=!0,t(!0))},onExit:a}}function q({term:e,onExit:t}){return(0,W.jsx)(`div`,{className:`h-72 shrink-0 pb-6`,children:(0,W.jsx)(`div`,{className:`mx-auto size-full max-w-4xl px-6`,children:e!==null&&(0,W.jsx)(l,{stream:`home`,term:e,onExit:t})})})}var J=`group block w-full rounded-lg bg-surface p-4 text-left transition-colors hover:bg-elevated`,Y=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function X({project:e,repoPath:t,sessions:n}){let i=n.filter(e=>e.status!==`archived`);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h2`,{className:j(`truncate pr-16 text-base font-semibold`,r(e.colour)||`text-fg group-hover:text-accent`),children:e.name}),(0,W.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:t??`…`}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,W.jsxs)(`span`,{children:[i.length,` session`,i.length===1?``:`s`]}),Y.map(({status:e,colour:t})=>{let n=i.filter(t=>t.status===e).length;return n>0?(0,W.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,W.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),n,` `,e.replace(`_`,` `)]},e):null})]})]})}function Z({icon:e,label:t,onClick:n}){return(0,W.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,W.jsx)(e,{className:`size-4`})})}function Q({project:e,repoPath:t,draggable:n,dragging:c,onDragStart:l,onDragEnd:d,onDragOver:f}){let p=x(),g=v(m().data?.protocol),_=h(e.id),[y,b]=(0,U.useState)(!1),[S,C]=(0,U.useState)(e.name),[T,E]=(0,U.useState)(a(e)),[z,B]=(0,U.useState)(e.colour??null),H=t=>p.mutate({id:e.id,archived:t},{onError:e=>V(e)}),G=()=>{C(e.name),B(e.colour??null),E(a(e)),b(!0)},K=()=>{let t=S.trim(),n=u(T);if(!t){b(!1);return}let r={...t===e.name?{}:{name:t},...n&&n!==a(e)?{abbrev:n}:{},...g&&z!==(e.colour??null)?{colour:z}:{}};if(Object.keys(r).length===0){b(!1);return}p.mutate({id:e.id,...r},{onSuccess:()=>b(!1),onError:e=>V(e)})};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(L,{children:[(0,W.jsx)(P,{asChild:!0,children:(0,W.jsxs)(`div`,{draggable:n,onDragStart:l,onDragEnd:d,onDragOver:f,className:j(`group relative transition-opacity`,c&&`opacity-50`),children:[(0,W.jsx)(w,{draggable:!1,to:`/project/${e.id}`,className:J,children:(0,W.jsx)(X,{project:e,repoPath:t,sessions:_.data??[]})}),(0,W.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,W.jsx)(Z,{icon:F,label:`Reopen project`,onClick:()=>H(!1)}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Z,{icon:s,label:`Edit project`,onClick:G}),(0,W.jsx)(Z,{icon:R,label:`Archive project`,onClick:()=>H(!0)})]})})]})}),(0,W.jsx)(te,{children:e.archived?(0,W.jsxs)(I,{onSelect:()=>H(!1),children:[(0,W.jsx)(F,{}),` Reopen`]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(I,{onSelect:G,children:[(0,W.jsx)(s,{}),` Edit`]}),(0,W.jsxs)(I,{onSelect:()=>H(!0),children:[(0,W.jsx)(R,{}),` Archive`]})]})})]}),(0,W.jsx)(ee,{open:y,onOpenChange:b,children:(0,W.jsxs)(k,{children:[(0,W.jsx)(D,{children:(0,W.jsx)(A,{children:`Edit project`})}),(0,W.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),K()},children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(i,{htmlFor:`project-name-${e.id}`,children:`Name`}),(0,W.jsx)(M,{id:`project-name-${e.id}`,value:S,className:r(z),onChange:e=>C(e.target.value),autoFocus:!0})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(i,{htmlFor:`project-abbrev-${e.id}`,children:`Abbreviation`}),(0,W.jsx)(M,{id:`project-abbrev-${e.id}`,maxLength:5,value:T,onChange:e=>E(u(e.target.value)),className:`w-24 uppercase`}),(0,W.jsxs)(`p`,{className:`text-2xs text-fg-muted`,children:[`Up to `,5,` characters — the label on the collapsed sidebar rail.`]})]}),g&&(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:`Colour`}),(0,W.jsx)(o,{value:z,onChange:B,label:`Project colour`})]}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,W.jsx)(i,{className:`text-fg-muted`,children:`Path`}),(0,W.jsx)(`p`,{className:`truncate text-2xs text-fg-muted`,children:t??`…`})]}),(0,W.jsxs)(O,{children:[(0,W.jsx)(N,{type:`button`,variant:`ghost`,onClick:()=>b(!1),children:`Cancel`}),(0,W.jsx)(N,{type:`submit`,disabled:!S.trim()||p.isPending,children:`Save`})]})]})]})})]})}function $({icon:e,label:t,hint:n,onClick:r}){return(0,W.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,W.jsxs)(`h2`,{className:`flex items-center gap-2 truncate text-base font-semibold text-fg group-hover:text-accent`,children:[(0,W.jsx)(e,{className:`size-4 shrink-0`}),t]}),(0,W.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:n})]})}function ne(){let e=f(),t=b(e??void 0),n=_(),r=y(e??void 0),i=g(e??``),[a,o]=(0,U.useState)(!1),[s,l]=(0,U.useState)(null),[u,d]=(0,U.useState)(!1),m=K(),h=p(`palette.toggle`),v=e=>n.data?.find(t=>t.id===e)?.path,x=t.data??[],w=r.data?.projectOrder??[],D=E(x.filter(e=>!e.archived),w),O=x.filter(e=>e.archived),k=(e,t)=>{e!==t&&i.mutate({projectOrder:C(D.map(e=>e.id),e,t)})};return(0,W.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,W.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[x.length===0&&(0,W.jsxs)(`div`,{className:`mb-8 mt-16 flex flex-col items-center gap-3 text-center`,children:[(0,W.jsx)(c,{className:`size-8 text-fg-muted`}),(0,W.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`No projects yet — open one below, or press `,h,`.`]})]}),(0,W.jsxs)(`div`,{className:`grid auto-rows-fr grid-cols-1 gap-3 sm:grid-cols-2`,children:[D.map(e=>(0,W.jsx)(Q,{project:e,repoPath:v(e.repo_id),draggable:!0,dragging:s===e.id,onDragStart:()=>l(e.id),onDragEnd:()=>l(null),onDragOver:t=>{t.preventDefault(),s&&s!==e.id&&k(s,e.id)}},e.id)),(0,W.jsx)($,{icon:T,label:`Open project`,hint:`Point at a repository on this host`,onClick:()=>o(!0)}),(0,W.jsx)($,{icon:S,label:m.open?`Close terminal`:`Open terminal`,hint:m.open?`End the shell below`:`A shell at ~ for cloning repositories`,onClick:m.toggle})]}),O.length>0&&(0,W.jsxs)(`div`,{className:`mt-6`,children:[(0,W.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,W.jsx)(z,{className:j(`size-3 transition-transform`,u&&`rotate-90`)}),(0,W.jsx)(R,{className:`size-3`}),(0,W.jsx)(`span`,{children:`Archived`}),(0,W.jsx)(`span`,{className:`tabular-nums`,children:O.length})]}),u&&(0,W.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:O.map(e=>(0,W.jsx)(Q,{project:e,repoPath:v(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]})]})}),m.open&&(0,W.jsx)(q,{term:m.term,onExit:m.onExit}),e!==null&&(0,W.jsx)(B,{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-By8HlURe.js";import{a as r,i,n as a,o,r as s,t as c}from"./dialog-BMWRC2HO.js";import{t as l}from"./x-DCpy1q13.js";import{t as u}from"./button-BgeBH2Uc.js";import{t as d}from"./createLucideIcon-DyMAgLa3.js";import{t as f}from"./drafts-B_tChlzR.js";import{i as p,t as m,u as h}from"./buffer-store-eMnMxbpI.js";import{t as g}from"./editor-sync-W1bamxAP.js";var _=d(`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:d,label:p,onClose:m}){let h=b(e,t,d)&&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)(l,{className:`size-3`})}),(0,y.jsx)(c,{open:_,onOpenChange:e=>!e&&x(!1),children:(0,y.jsxs)(a,{children:[(0,y.jsxs)(r,{children:[(0,y.jsxs)(o,{children:[`Discard changes to `,p,`?`]}),(0,y.jsx)(s,{children:`This file has unsaved changes. Closing the tab will discard them.`})]}),(0,y.jsxs)(i,{children:[(0,y.jsx)(u,{variant:`ghost`,onClick:()=>x(!1),children:`Keep editing`}),(0,y.jsx)(u,{variant:`danger`,onClick:()=>{f(e,t,d),g(e,t,d),x(!1),m()},children:`Discard`})]})]})})]})}export{x as EditorDirtyDot,S as EditorTabClose};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-By8HlURe.js";import{a as r,i,n as a,o,r as s,t as c}from"./dialog-BMWRC2HO.js";import{t as l}from"./x-DCpy1q13.js";import{t as u}from"./button-BgeBH2Uc.js";import{t as d}from"./createLucideIcon-DyMAgLa3.js";import{t as f}from"./drafts-B_tChlzR.js";import{i as p,t as m,u as h}from"./buffer-store-BJI12hvF.js";import{t as g}from"./editor-sync-W1bamxAP.js";var _=d(`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:d,label:p,onClose:m}){let h=b(e,t,d)&&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)(l,{className:`size-3`})}),(0,y.jsx)(c,{open:_,onOpenChange:e=>!e&&x(!1),children:(0,y.jsxs)(a,{children:[(0,y.jsxs)(r,{children:[(0,y.jsxs)(o,{children:[`Discard changes to `,p,`?`]}),(0,y.jsx)(s,{children:`This file has unsaved changes. Closing the tab will discard them.`})]}),(0,y.jsxs)(i,{children:[(0,y.jsx)(u,{variant:`ghost`,onClick:()=>x(!1),children:`Keep editing`}),(0,y.jsx)(u,{variant:`danger`,onClick:()=>{f(e,t,d),g(e,t,d),x(!1),m()},children:`Discard`})]})]})})]})}export{x as EditorDirtyDot,S as EditorTabClose};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-_10Xyj1h.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/react-dom-cJyBB_A4.js","assets/auth-GfOuXpIe.js","assets/client-settings-CwqpIric.js","assets/jsx-runtime-By8HlURe.js","assets/preload-helper-Czpn1I53.js","assets/index-np8JXeG6.js","assets/index-CPHfr3MU.css","assets/hotkeys-1uTWFYAL.js","assets/forward-link-RM7_5Shu.js","assets/api-i6xNY3bF.js","assets/protocol-support-BGmIChNK.js","assets/dist-BOS6OKSE.js","assets/x-DCpy1q13.js","assets/createLucideIcon-DyMAgLa3.js","assets/FindWidget-CVH9U-_P.js","assets/whole-word-2m2pmAFT.js","assets/chevron-down--sjpQEHH.js","assets/selection-actions-D875GPFU.js","assets/button-BgeBH2Uc.js","assets/copy-CGsu8426.js","assets/ws-CMPCIzY4.js","assets/code-DRWf9a5s.js","assets/errors-O9DWXa3f.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{z as n}from"./auth-GfOuXpIe.js";import{t as r}from"./jsx-runtime-By8HlURe.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{S as a}from"./dialog-BMWRC2HO.js";import{n as o}from"./x-DCpy1q13.js";import{t as s}from"./input-CxgRsoVg.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=r(),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:r=!1,label:i=`Colour`}){return(0,p.jsx)(`div`,{role:`group`,"aria-label":i,className:`flex flex-wrap items-center gap-1`,children:[null,...n].map(n=>(0,p.jsx)(`button`,{type:`button`,title:n??`Default`,"aria-label":n??`Default colour`,"aria-pressed":(e??null)===n,disabled:r,onClick:()=>t(n),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)===n&&`bg-border/50`),children:(0,p.jsx)(`span`,{className:o(`size-3.5 rounded-full`,n?o(`bg-current`,x(n)):`bg-fg-muted`)})},n??`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-_10Xyj1h.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,24,25,26,27]))),T=null;async function E(){T=(await i(()=>import(`./Terminal-_10Xyj1h.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,24,25,26,27]))).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
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-FQpZf8ol.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/react-dom-cJyBB_A4.js","assets/auth-Bvs3kkqE.js","assets/client-settings-CwqpIric.js","assets/jsx-runtime-By8HlURe.js","assets/preload-helper-Czpn1I53.js","assets/index-CegatrLH.js","assets/index-CPHfr3MU.css","assets/hotkeys-Bb6oSnV3.js","assets/forward-link-C3mxMevv.js","assets/api-CWrvqTDd.js","assets/protocol-support-B9FOVWIr.js","assets/dist-BOS6OKSE.js","assets/x-DCpy1q13.js","assets/createLucideIcon-DyMAgLa3.js","assets/FindWidget-CVH9U-_P.js","assets/whole-word-2m2pmAFT.js","assets/chevron-down--sjpQEHH.js","assets/selection-actions-Ch1RDI54.js","assets/button-BgeBH2Uc.js","assets/copy-CGsu8426.js","assets/ws-bjTyWUY1.js","assets/code-DRWf9a5s.js","assets/errors-D7cN9zwV.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{z as n}from"./auth-Bvs3kkqE.js";import{t as r}from"./jsx-runtime-By8HlURe.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{S as a}from"./dialog-BMWRC2HO.js";import{n as o}from"./x-DCpy1q13.js";import{t as s}from"./input-CxgRsoVg.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=r(),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:r=!1,label:i=`Colour`}){return(0,p.jsx)(`div`,{role:`group`,"aria-label":i,className:`flex flex-wrap items-center gap-1`,children:[null,...n].map(n=>(0,p.jsx)(`button`,{type:`button`,title:n??`Default`,"aria-label":n??`Default colour`,"aria-pressed":(e??null)===n,disabled:r,onClick:()=>t(n),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)===n&&`bg-border/50`),children:(0,p.jsx)(`span`,{className:o(`size-3.5 rounded-full`,n?o(`bg-current`,x(n)):`bg-fg-muted`)})},n??`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-FQpZf8ol.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,24,25,26,27]))),T=null;async function E(){T=(await i(()=>import(`./Terminal-FQpZf8ol.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,24,25,26,27]))).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-eMnMxbpI.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};
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-BJI12hvF.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};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,c as r,i,l as a,r as ee,s as o,u as s}from"./LazyTerminal-CgQryH0p.js";import{t as c}from"./jsx-runtime-By8HlURe.js";import{K as l,L as u,N as d,P as te,U as f,c as ne,ft as re,h as ie}from"./protocol-support-BGmIChNK.js";import{m as ae,s as p}from"./session-order-f7QxTbVD.js";import{a as m,i as h,n as g,o as _,r as v,t as y}from"./dialog-BMWRC2HO.js";import{t as b}from"./input-CxgRsoVg.js";import{t as x}from"./button-BgeBH2Uc.js";import{t as S}from"./createLucideIcon-DyMAgLa3.js";import{t as oe}from"./use-debounced-value-C86N-mOK.js";var C=S(`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=c();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)(o,{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:o}){let c=re(),p=u().data?.protocol,S=ne(p),C=ie(p),O=te(),k=d(),A=ae(),j=l(),[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(c.data??[]).map(e=>({value:e.path,badge:`registered`,is_git:!0}));let e=new Set((c.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,c.data,Z.data]),Q=async()=>{G(null);try{let t=E(M),n=c.data?.find(e=>e.path===t)?.id??(await O.mutateAsync({path:t,...S?{default_base_branch:``}:{}})).id,r=await k.mutateAsync({profile_id:e,repo_id:n,name:P.trim(),...C?{colour:B}:{},...s(R)?{abbrev:s(R)}:{}});o(!1),A(`/project/${r.id}`)}catch(e){G(e instanceof Error?e.message:String(e))}},$=P.trim()!==``&&D(M.trim());return(0,T.jsx)(y,{open:t,onOpenChange:o,children:(0,T.jsxs)(g,{children:[(0,T.jsxs)(m,{children:[(0,T.jsx)(_,{children:`New project`}),(0,T.jsx)(v,{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)(r,{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)(ee,{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)(r,{htmlFor:`project-name`,children:`Project name`}),(0,T.jsx)(b,{id:`project-name`,placeholder:`e.g. checkout-rework`,value:P,className:n(B),onChange:e=>{Y(e.target.value),L(!0)}})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,T.jsx)(r,{htmlFor:`project-abbrev`,children:`Abbreviation`}),(0,T.jsx)(b,{id:`project-abbrev`,placeholder:P.trim()?a(P):`ABBRV`,maxLength:5,value:R,onChange:e=>{z(s(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)(i,{value:B,onChange:V,label:`Project colour`})]}),W&&(0,T.jsx)(`p`,{className:`text-xs text-danger`,children:W}),(0,T.jsxs)(h,{children:[(0,T.jsx)(x,{type:`button`,variant:`ghost`,onClick:()=>o(!1),children:`Cancel`}),(0,T.jsx)(x,{type:`submit`,disabled:!$||O.isPending||k.isPending,children:`Create project`})]})]})]})})}export{k as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,c as r,i,l as a,r as ee,s as o,u as s}from"./LazyTerminal-DXz4jhHV.js";import{t as c}from"./jsx-runtime-By8HlURe.js";import{K as l,L as u,N as d,P as te,U as f,c as ne,ft as re,h as ie}from"./protocol-support-B9FOVWIr.js";import{m as ae,s as p}from"./session-order-C9VTNopC.js";import{a as m,i as h,n as g,o as _,r as v,t as y}from"./dialog-BMWRC2HO.js";import{t as b}from"./input-CxgRsoVg.js";import{t as x}from"./button-BgeBH2Uc.js";import{t as S}from"./createLucideIcon-DyMAgLa3.js";import{t as oe}from"./use-debounced-value-C86N-mOK.js";var C=S(`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=c();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)(o,{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:o}){let c=re(),p=u().data?.protocol,S=ne(p),C=ie(p),O=te(),k=d(),A=ae(),j=l(),[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(c.data??[]).map(e=>({value:e.path,badge:`registered`,is_git:!0}));let e=new Set((c.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,c.data,Z.data]),Q=async()=>{G(null);try{let t=E(M),n=c.data?.find(e=>e.path===t)?.id??(await O.mutateAsync({path:t,...S?{default_base_branch:``}:{}})).id,r=await k.mutateAsync({profile_id:e,repo_id:n,name:P.trim(),...C?{colour:B}:{},...s(R)?{abbrev:s(R)}:{}});o(!1),A(`/project/${r.id}`)}catch(e){G(e instanceof Error?e.message:String(e))}},$=P.trim()!==``&&D(M.trim());return(0,T.jsx)(y,{open:t,onOpenChange:o,children:(0,T.jsxs)(g,{children:[(0,T.jsxs)(m,{children:[(0,T.jsx)(_,{children:`New project`}),(0,T.jsx)(v,{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)(r,{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)(ee,{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)(r,{htmlFor:`project-name`,children:`Project name`}),(0,T.jsx)(b,{id:`project-name`,placeholder:`e.g. checkout-rework`,value:P,className:n(B),onChange:e=>{Y(e.target.value),L(!0)}})]}),(0,T.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,T.jsx)(r,{htmlFor:`project-abbrev`,children:`Abbreviation`}),(0,T.jsx)(b,{id:`project-abbrev`,placeholder:P.trim()?a(P):`ABBRV`,maxLength:5,value:R,onChange:e=>{z(s(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)(i,{value:B,onChange:V,label:`Project colour`})]}),W&&(0,T.jsx)(`p`,{className:`text-xs text-danger`,children:W}),(0,T.jsxs)(h,{children:[(0,T.jsx)(x,{type:`button`,variant:`ghost`,onClick:()=>o(!1),children:`Cancel`}),(0,T.jsx)(x,{type:`submit`,disabled:!$||O.isPending||k.isPending,children:`Create project`})]})]})]})})}export{k as t};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{s as n}from"./auth-GfOuXpIe.js";import{t as r}from"./context-DW21k43a.js";import{t as i}from"./jsx-runtime-By8HlURe.js";import{t as a}from"./preload-helper-Czpn1I53.js";import{a as o,r as s}from"./index-np8JXeG6.js";var c=e(t(),1),l=i(),u=()=>()=>{},d={generation:null,revision:0,events:[]},f=()=>d;function p({modelId:e,fallback:t}){let n=(0,c.useContext)(r),i=n?.session,a=(0,c.useSyncExternalStore)(i?.subscribe??u,i?.getSnapshot??f),o=!!i?.state.state[e]&&!!a.generation&&!a.error,s=o?i.state:n?.saved,[d,p]=(0,c.useState)(!1);return s?.state[e]?(0,l.jsx)(h,{modelId:e,snapshot:s,session:o?i:null,generation:o?a.generation:null,extensions:o||d,onLoadExtension:()=>p(!0)},`${o?a.generation:`saved`}:${e}:${d}`):(0,l.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[t&&(0,l.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-sm text-fg-secondary`,children:t}),(0,l.jsx)(`p`,{children:a.error??(i?`Run this cell to create its widget.`:`Live Jupyter widgets require a local or SSH host with protocol 25.4 or newer.`)})]})}function m(){let e=getComputedStyle(document.documentElement),t=t=>e.getPropertyValue(t).trim();return{"--jp-layout-color0":t(`--bg-base`),"--jp-layout-color1":t(`--bg-surface`),"--jp-layout-color2":t(`--bg-elevated`),"--jp-layout-color3":t(`--bg-elevated`),"--jp-ui-font-color0":t(`--text-primary`),"--jp-ui-font-color1":t(`--text-primary`),"--jp-ui-font-color2":t(`--text-secondary`),"--jp-ui-font-color3":t(`--text-muted`),"--jp-content-font-color1":t(`--text-primary`),"--jp-border-color1":t(`--border`),"--jp-content-font-color0":t(`--text-primary`),"--jp-content-font-color2":t(`--text-secondary`),"--jp-content-font-color3":t(`--text-muted`),"--jp-content-font-family":t(`--font-sans`),"--jp-error-color1":t(`--danger`),"--jp-warn-color1":t(`--warning`),"--jp-success-color1":t(`--success`),"--jp-info-color1":t(`--accent`),"--jp-brand-color1":t(`--accent`),"--jp-ui-font-family":t(`--font-sans`),"--jp-code-font-family":t(`--font-mono`),"--danger":t(`--danger`)}}function h({modelId:e,snapshot:t,session:r,generation:i,extensions:u,onLoadExtension:d}){let f=(0,c.useRef)(null),p=(0,c.useRef)(null),h=(0,c.useRef)(t);h.current=t;let[g,_]=(0,c.useState)(),[v,y]=(0,c.useState)(0),[b,x]=(0,c.useState)(48),[S,C]=(0,c.useState)(),[w,T]=(0,c.useState)();return(0,c.useEffect)(()=>{p.current?.postMessage({type:`theme`,theme:m()})},[(0,c.useSyncExternalStore)(o,s,s)]),(0,c.useEffect)(()=>{let t=!1,o,s=a=>{if(a.source!==f.current?.contentWindow||a.data?.type!==`puddle-widget-ready`||p.current)return;let s=new MessageChannel;p.current=s.port1,s.port1.onmessage=e=>{if(t||!e.data||typeof e.data!=`object`)return;let a=e.data;if(a.type===`height`&&Number.isFinite(a.height)&&x(Math.max(24,Math.min(2e3,a.height))),a.type===`error`&&C(String(a.error).slice(0,1024)),a.type===`extension`&&T(String(a.name).slice(0,256)),a.type!==`comm`||!r||!i)return;let o=n.safeParse({source:r.source,generation:i,message:a.message});if(!o.success||JSON.stringify(o.data).length>2*1024*1024){C(`Widget action exceeds the supported message limits`);return}r.send(i,o.data.message).catch(e=>{t||s.port1.postMessage({type:`error`,msg_id:o.data.message.msg_id,error:e instanceof Error?e.message:`Widget action failed`})})},s.port1.start(),f.current.contentWindow.postMessage({type:`puddle-widget-connect`},`*`,[s.port2]),s.port1.postMessage({type:`init`,snapshot:structuredClone(r?.state??h.current),modelId:e,live:!!i,extensions:u,theme:m()}),o=r?.subscribe(e=>{e.generation!==i||e.error?s.port1.postMessage({type:`error`,error:e.error??`The kernel changed. Run the cell again.`}):e.snapshot?(p.current?.close(),p.current=null,o?.(),y(e=>e+1)):s.port1.postMessage({type:`events`,events:e.events})})};return window.addEventListener(`message`,s),(async()=>{let{default:e}=await a(async()=>{let{default:e}=await import(`./_virtual_notebook-widget-runtime-Dro422xS.js`);return{default:e}},[]);t||_(`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob: https:; style-src 'unsafe-inline' https:; img-src data: blob: https:; font-src data: https:; media-src data: blob: https:; connect-src https:; worker-src blob:; form-action 'none'; base-uri 'none'"><style>
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{s as n}from"./auth-Bvs3kkqE.js";import{t as r}from"./context-d6tkpKkh.js";import{t as i}from"./jsx-runtime-By8HlURe.js";import{t as a}from"./preload-helper-Czpn1I53.js";import{a as o,r as s}from"./index-CegatrLH.js";var c=e(t(),1),l=i(),u=()=>()=>{},d={generation:null,revision:0,events:[]},f=()=>d;function p({modelId:e,fallback:t}){let n=(0,c.useContext)(r),i=n?.session,a=(0,c.useSyncExternalStore)(i?.subscribe??u,i?.getSnapshot??f),o=!!i?.state.state[e]&&!!a.generation&&!a.error,s=o?i.state:n?.saved,[d,p]=(0,c.useState)(!1);return s?.state[e]?(0,l.jsx)(h,{modelId:e,snapshot:s,session:o?i:null,generation:o?a.generation:null,extensions:o||d,onLoadExtension:()=>p(!0)},`${o?a.generation:`saved`}:${e}:${d}`):(0,l.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[t&&(0,l.jsx)(`pre`,{className:`whitespace-pre-wrap font-mono text-sm text-fg-secondary`,children:t}),(0,l.jsx)(`p`,{children:a.error??(i?`Run this cell to create its widget.`:`Live Jupyter widgets require a local or SSH host with protocol 25.4 or newer.`)})]})}function m(){let e=getComputedStyle(document.documentElement),t=t=>e.getPropertyValue(t).trim();return{"--jp-layout-color0":t(`--bg-base`),"--jp-layout-color1":t(`--bg-surface`),"--jp-layout-color2":t(`--bg-elevated`),"--jp-layout-color3":t(`--bg-elevated`),"--jp-ui-font-color0":t(`--text-primary`),"--jp-ui-font-color1":t(`--text-primary`),"--jp-ui-font-color2":t(`--text-secondary`),"--jp-ui-font-color3":t(`--text-muted`),"--jp-content-font-color1":t(`--text-primary`),"--jp-border-color1":t(`--border`),"--jp-content-font-color0":t(`--text-primary`),"--jp-content-font-color2":t(`--text-secondary`),"--jp-content-font-color3":t(`--text-muted`),"--jp-content-font-family":t(`--font-sans`),"--jp-error-color1":t(`--danger`),"--jp-warn-color1":t(`--warning`),"--jp-success-color1":t(`--success`),"--jp-info-color1":t(`--accent`),"--jp-brand-color1":t(`--accent`),"--jp-ui-font-family":t(`--font-sans`),"--jp-code-font-family":t(`--font-mono`),"--danger":t(`--danger`)}}function h({modelId:e,snapshot:t,session:r,generation:i,extensions:u,onLoadExtension:d}){let f=(0,c.useRef)(null),p=(0,c.useRef)(null),h=(0,c.useRef)(t);h.current=t;let[g,_]=(0,c.useState)(),[v,y]=(0,c.useState)(0),[b,x]=(0,c.useState)(48),[S,C]=(0,c.useState)(),[w,T]=(0,c.useState)();return(0,c.useEffect)(()=>{p.current?.postMessage({type:`theme`,theme:m()})},[(0,c.useSyncExternalStore)(o,s,s)]),(0,c.useEffect)(()=>{let t=!1,o,s=a=>{if(a.source!==f.current?.contentWindow||a.data?.type!==`puddle-widget-ready`||p.current)return;let s=new MessageChannel;p.current=s.port1,s.port1.onmessage=e=>{if(t||!e.data||typeof e.data!=`object`)return;let a=e.data;if(a.type===`height`&&Number.isFinite(a.height)&&x(Math.max(24,Math.min(2e3,a.height))),a.type===`error`&&C(String(a.error).slice(0,1024)),a.type===`extension`&&T(String(a.name).slice(0,256)),a.type!==`comm`||!r||!i)return;let o=n.safeParse({source:r.source,generation:i,message:a.message});if(!o.success||JSON.stringify(o.data).length>2*1024*1024){C(`Widget action exceeds the supported message limits`);return}r.send(i,o.data.message).catch(e=>{t||s.port1.postMessage({type:`error`,msg_id:o.data.message.msg_id,error:e instanceof Error?e.message:`Widget action failed`})})},s.port1.start(),f.current.contentWindow.postMessage({type:`puddle-widget-connect`},`*`,[s.port2]),s.port1.postMessage({type:`init`,snapshot:structuredClone(r?.state??h.current),modelId:e,live:!!i,extensions:u,theme:m()}),o=r?.subscribe(e=>{e.generation!==i||e.error?s.port1.postMessage({type:`error`,error:e.error??`The kernel changed. Run the cell again.`}):e.snapshot?(p.current?.close(),p.current=null,o?.(),y(e=>e+1)):s.port1.postMessage({type:`events`,events:e.events})})};return window.addEventListener(`message`,s),(async()=>{let{default:e}=await a(async()=>{let{default:e}=await import(`./_virtual_notebook-widget-runtime-Dro422xS.js`);return{default:e}},[]);t||_(`<!doctype html><html><head><meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob: https:; style-src 'unsafe-inline' https:; img-src data: blob: https:; font-src data: https:; media-src data: blob: https:; connect-src https:; worker-src blob:; form-action 'none'; base-uri 'none'"><style>
2
2
  html,body{margin:0;background:var(--jp-layout-color0)!important;color:var(--jp-ui-font-color1)!important;font-family:var(--jp-ui-font-family)!important}
3
3
  .jupyter-widgets input,.jupyter-widgets select,.jupyter-widgets textarea,.jupyter-widgets button{border:0!important;color:var(--jp-ui-font-color1);background:var(--jp-layout-color1)}
4
4
  .jupyter-widgets button,.jupyter-widgets select,.jupyter-widgets input[type=range]{cursor:pointer}