@puddle-code/cli 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -5
- package/dist/index.js +3 -2
- package/dist/public/assets/{Dashboard-BhJZAZkm.js → Dashboard-C4IkYsCm.js} +1 -1
- package/dist/public/assets/{EditorTabClose-D5-9GTuN.js → EditorTabClose-CP-0okVg.js} +1 -1
- package/dist/public/assets/{LazyTerminal-DpW_dV8-.js → LazyTerminal-D2S8HMn8.js} +2 -2
- package/dist/public/assets/{ModelRefcount-Bc70ux--.js → ModelRefcount-YhJ4_JuZ.js} +1 -1
- package/dist/public/assets/{PaneEditorBody-DPfYk1MG.js → PaneEditorBody-hELgpssb.js} +1 -1
- package/dist/public/assets/{SettingsDialog-C1YGjO8w.js → SettingsDialog-7FDk2aeu.js} +1 -1
- package/dist/public/assets/{Terminal-DmMk3PAE.js → Terminal-CsvZikns.js} +15 -15
- package/dist/public/assets/{Workspace-HBspP42h.js → Workspace-DJCxj1xo.js} +3 -3
- package/dist/public/assets/{buffer-store-Ch_ccGob.js → buffer-store-QVYUAdFa.js} +2 -2
- package/dist/public/assets/{context-menu-BIpVA6AC.js → context-menu-BsiIEMZV.js} +1 -1
- package/dist/public/assets/{cssMode-DP2qOqv1.js → cssMode-Ba1dD9hA.js} +1 -1
- package/dist/public/assets/{drafts-CyZAHsxG.js → drafts-CawkoLGT.js} +1 -1
- package/dist/public/assets/{file-links-DhiBZF5y.js → file-links-DTvsPp97.js} +1 -1
- package/dist/public/assets/{htmlMode-DDBP46Y_.js → htmlMode-CHgmaUWs.js} +1 -1
- package/dist/public/assets/{index-CzVID1ZA.js → index-C6Vjy8Jr.js} +3 -3
- package/dist/public/assets/{jsonMode-B-208CCp.js → jsonMode-BJPlqhSU.js} +1 -1
- package/dist/public/assets/{session-seed-YCLBYoEN.js → session-seed-vlAMEMll.js} +1 -1
- package/dist/public/assets/{tsMode-BOmmwl1s.js → tsMode-DP1fT4Wf.js} +1 -1
- package/dist/public/assets/{use-find-controls-Bs5HCbAh.js → use-find-controls-mWy3wINk.js} +1 -1
- package/dist/public/index.html +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,n as r,r as i}from"./x-BJOrp_m5.js";import{A as a,E as o,Ft as s,G as c,H as l,Ht as u,I as d,It as f,Lt as p,Mt as m,Nt as h,Pt as g,Q as _,T as v,W as ee,Y as te,Z as y,a as b,at as x,ct as S,et as C,f as w,g as ne,i as re,j as ie,mt as ae,n as oe,ot as se,pt as ce,q as le,rt as ue,t as de,tt as T,v as E,z as fe}from"./hotkeys-CekBkaTu.js";import{a as D,h as O,i as k,n as A,o as j,r as M,t as N}from"./dialog-DjL0qoAv.js";import{a as P,c as pe,l as F,o as me,r as he,s as ge,u as I}from"./LazyTerminal-DpW_dV8-.js";import{a as L,i as R,n as z,o as B,r as V,t as _e}from"./session-seed-YCLBYoEN.js";import{t as ve}from"./chevron-down-59O6CgEo.js";import{r as ye}from"./dist-DDFe8e3m.js";import{$ as be,At as xe,Ct as Se,Et as Ce,G as we,It as Te,J as Ee,Jt as De,K as Oe,Lt as H,Mt as ke,Q as Ae,Rt as U,St as je,Tt as Me,V as W,W as G,Wt as Ne,X as Pe,Y as Fe,_t as Ie,et as Le,jt as Re,kt as ze,ot as Be,q as Ve,r as He,rt as Ue,tt as We,vt as Ge,wt as Ke,yt as qe,zt as Je}from"./index-CzVID1ZA.js";var Ye=r(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Xe=r(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Ze=r(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Qe=r(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),$e=r(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),et=r(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),tt=r(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),nt=r(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),K=e(t(),1),q=n();function J({id:e,value:t,min:n,max:r,step:i,className:a,onCommit:o}){let[s,c]=(0,K.useState)(String(t));return(0,K.useEffect)(()=>c(String(t)),[t]),(0,q.jsx)(F,{id:e,type:`number`,min:n,max:r,step:i,className:a,value:s,onChange:e=>c(e.target.value),onBlur:()=>{let e=Number(s);if(s.trim()===``||!Number.isFinite(e)){c(String(t));return}let i=Math.min(r??e,Math.max(n??e,e));c(String(i)),i!==t&&o(i)},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}function Y({label:e,description:t,descriptionClassName:n,htmlFor:r,children:a,className:o}){return(0,q.jsxs)(`div`,{className:i(`flex items-center gap-4 py-2.5`,o),children:[(0,q.jsxs)(`label`,{htmlFor:r,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:i(`text-xs text-fg-muted`,n),children:t})]}),(0,q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:a})]})}function X({children:e,note:t}){return(0,q.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function rt(){let e=U(),[t,n]=(0,K.useState)(De());return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Appearance`}),(0,q.jsx)(Y,{label:`Theme`,children:(0,q.jsxs)(z,{value:t,onValueChange:e=>{n(e),Ne(e)},children:[(0,q.jsx)(L,{className:`w-32`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(R,{value:`dark`,children:`Dark`}),(0,q.jsx)(R,{value:`light`,children:`Light`}),(0,q.jsx)(R,{value:`system`,children:`System`})]})]})}),(0,q.jsx)(Y,{label:`Cursor style`,children:(0,q.jsxs)(z,{value:e.cursorPackage,onValueChange:e=>H({cursorPackage:e}),children:[(0,q.jsx)(L,{className:`w-36`,children:(0,q.jsx)(B,{})}),(0,q.jsx)(V,{children:Je.map(e=>(0,q.jsx)(R,{value:e.id,children:e.label},e.id))})]})}),(0,q.jsx)(Y,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,q.jsx)(J,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>H({uiFontSize:e})})}),(0,q.jsx)(Y,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,q.jsx)(J,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>H({terminalFontSize:e})})}),(0,q.jsx)(Y,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,q.jsx)(J,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>H({editorFontSize:e})})}),(0,q.jsx)(Y,{label:`Density`,children:(0,q.jsxs)(z,{value:e.density,onValueChange:e=>H({density:e}),children:[(0,q.jsx)(L,{className:`w-36`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(R,{value:`compact`,children:`Compact`}),(0,q.jsx)(R,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,q.jsx)(Y,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,q.jsx)(W,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>H({projectBasedLayout:e})})}),(0,q.jsx)(Y,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,q.jsx)(W,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>H({showAllProjectSessions:e})})})]})}function it({profile:e}){let t=C(),[n,r]=(0,K.useState)(!1),a=n=>{t.mutate({id:e.id,icon:n},{onError:e=>P(e)}),r(!1)},o=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>P(e)});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Icon`,children:(0,q.jsxs)(be,{open:n,onOpenChange:r,children:[(0,q.jsx)(We,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:`flex size-9 items-center justify-center rounded-md text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(je,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,q.jsx)(Le,{align:`end`,className:`w-72`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,title:`Default`,onClick:()=>a(null),className:i(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,!e.icon&&`bg-elevated text-fg`),children:(0,q.jsx)(je,{icon:null,colour:null,className:`size-4`})}),Ke.map(({name:t,Icon:n})=>(0,q.jsx)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:i(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,e.icon===t&&`bg-elevated text-fg`),children:(0,q.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,q.jsx)(Y,{label:`Icon colour`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,q.jsxs)(`button`,{type:`button`,title:`Default`,onClick:()=>o(null),className:i(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,!e.icon_colour&&`bg-elevated`),children:[(0,q.jsx)(`span`,{className:`size-3.5 rounded-full bg-fg-muted`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Default colour`})]}),f.map(t=>(0,q.jsxs)(`button`,{type:`button`,title:t,onClick:()=>o(t),className:i(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,e.icon_colour===t&&`bg-elevated`),children:[(0,q.jsx)(`span`,{className:i(`size-3.5 rounded-full bg-current`,Se(t))}),(0,q.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var at=`__none__`;function ot(){let e=E(),t=se().data?.find(t=>t.id===e),n=v(e??void 0),r=x(e??void 0),i=C(),a=T(e??``),o=l(),[s,c]=(0,K.useState)(``),[u,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(!1),[m,h]=(0,K.useState)(``);if((0,K.useEffect)(()=>{t&&(c(t.name),d(t.branch_prefix))},[t]),!t)return null;let g=r.data?.default_account_id;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Profile`}),(0,q.jsxs)(Y,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,q.jsx)(F,{id:`profile-name`,value:s,onChange:e=>c(e.target.value),className:`w-44`}),(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:s===t.name||s.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:s},{onError:e=>P(e)}),children:`Save`})]}),(0,q.jsxs)(Y,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,q.jsx)(F,{id:`branch-prefix`,value:u,onChange:e=>d(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:u===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:u},{onError:e=>P(e)}),children:`Save`})]}),(0,q.jsx)(it,{profile:t}),(0,q.jsx)(Y,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,q.jsxs)(z,{value:typeof g==`number`?String(g):at,onValueChange:e=>a.mutate({default_account_id:e===at?null:Number(e)},{onError:e=>P(e)}),children:[(0,q.jsx)(L,{className:`w-56`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(R,{value:at,children:`First available`}),n.data?.map(e=>(0,q.jsx)(R,{value:String(e.id),children:(0,q.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,q.jsx)(Y,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,q.jsx)(O,{variant:`danger`,size:`sm`,onClick:()=>p(!0),children:`Delete…`})}),(0,q.jsx)(N,{open:f,onOpenChange:e=>{e||(p(!1),h(``))},children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{children:[`Delete profile `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,q.jsx)(M,{children:`Everything this profile owns goes with it: projects, workspace layouts, accounts and their credential directories, and archived session history. Branches, repositories, and terminal logs on disk are untouched. This cannot be undone.`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(pe,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,q.jsx)(F,{id:`delete-confirm-name`,value:m,onChange:e=>h(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:()=>{p(!1),h(``)},children:`Cancel`}),(0,q.jsx)(O,{variant:`danger`,disabled:m!==t.name||o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>{Ie(),ne.set(null)},onError:e=>{p(!1),h(``),P(e)}}),children:`Delete profile`})]})]})})]})}function st({agent:e,profileId:t,onClose:n,onCreated:r}){let i=ie(),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),l=ee(Be(s,150)),u=s.trim(),d=u===``||u.startsWith(`/`)||u.startsWith(`~`),f=a.trim()!==``&&d,p=()=>{!f||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...u===``?{}:{import_dir:u}},{onSuccess:e=>{n(),r(e,u!==``)},onError:e=>P(e)})};return(0,q.jsx)(N,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{children:[`Add a `,e.display_name,` account`]}),(0,q.jsxs)(M,{children:[`Accounts are isolated config dirs under this profile. Naming one is enough — Puddle creates it and takes you straight to `,e.display_name,`’s login. To reuse an account you already have on this machine, give its config directory: it is copied in and the original is never touched.`]})]}),(0,q.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,q.jsx)(F,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(he,{value:s,onValueChange:c,placeholder:`(optional) existing config dir, e.g. ~/.claude`,hints:(l.data?.entries??[]).map(e=>({value:e.path,label:e.name}))})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,q.jsxs)(O,{disabled:!f||i.isPending,onClick:p,children:[(0,q.jsx)(xe,{}),`Add account`]})]})]})})}function ct({account:e,gateOpen:t,installed:n}){let r=te(),i=y(),a=fe(),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(e.label),f=(0,K.useRef)(null);return(0,K.useEffect)(()=>d(e.label),[e.label]),(0,q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`input`,{ref:f,value:u,onChange:e=>d(e.target.value),onBlur:()=>{let t=u.trim();if(t!==e.label){if(t===``){d(e.label);return}i.mutate({id:e.id,label:t},{onError:t=>{P(t),d(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(d(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full min-w-0 truncate rounded-sm bg-transparent px-1 py-0.5 text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,q.jsxs)(`button`,{type:`button`,title:`Rename account`,onClick:()=>{f.current?.focus(),f.current?.select()},className:`shrink-0 rounded-sm p-0.5 text-fg-muted transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(me,{className:`size-3`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Rename account`})]})]}),(0,q.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,q.jsx)(W,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>P(e)})})]}),(0,q.jsxs)(O,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>P(e)}),children:[(0,q.jsx)(ke,{}),e.logged_in?`Re-login`:`Login`]}),(0,q.jsxs)(O,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,q.jsx)(Ce,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,q.jsx)(Ae,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,q.jsx)(N,{open:c,onOpenChange:l,children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{children:[`Delete `,(0,q.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,q.jsx)(M,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,q.jsx)(O,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),P(e)}}),children:`Delete account`})]})]})})]})}function lt(){let e=E(),t=o(),n=v(e??void 0),r=x(e??void 0),i=te(),[a,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(null),d=r.data?.allowSkipPermissions===!0;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[],r=e.available!==!1;return(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(Y,{label:e.display_name,description:r?`Accounts are initialised in config dirs owned by this profile.`:`No ${e.binary??e.id} on the daemon’s PATH. Install it or add its directory to the agent search path in Sessions.`,className:`py-1`,children:(0,q.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.id})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,q.jsx)(ct,{account:t,gateOpen:d&&e.capabilities.skip_permissions,installed:r},t.id)),(0,q.jsx)(`div`,{className:`flex`,children:(0,q.jsxs)(O,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>l(e),children:[(0,q.jsx)(xe,{}),`Add account`]})})]})]},e.id)}),a&&(0,q.jsx)(Ae,{stream:a.stream,label:a.label,hint:a.hint,onClose:()=>s(null)}),c!==null&&e!==null&&(0,q.jsx)(st,{agent:c,profileId:e,onClose:()=>l(null),onCreated:(e,t)=>{if(t){e.logged_in||u.info(`Imported without credentials — press Login to authenticate.`);return}i.mutate(e.id,{onSuccess:t=>s({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>P(e)})}})]})}function ut(){let e=a(),t=_(),[n,r]=(0,K.useState)(``);return(0,K.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,q.jsx)(Y,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH; helps find agent CLIs like claude (e.g. ~/.local/bin).`,htmlFor:`agent-path`,children:(0,q.jsx)(F,{id:`agent-path`,type:`text`,className:`w-64 text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function dt({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=_e(e,n),o=n.sessionDefaults??{},[s,c]=(0,K.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,q.jsx)(Y,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,q.jsx)(F,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,q.jsx)(Y,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,q.jsx)(W,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,q.jsx)(Y,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`Start on working copy of the selected branch instead of sharing one directory.`,htmlFor:`${e}-default-dir`,children:(0,q.jsx)(W,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function ft(){return(0,q.jsx)(Y,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,q.jsx)(J,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:U().terminalScrollback,onCommit:e=>H({terminalScrollback:e})})})}function pt({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,K.useState)(r);return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,q.jsx)(I,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,q.jsx)(O,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var mt={id:`4f3c2b1a-7e6d-5c4b-3a2f-1e0d9c8b7a6f`,title:null,agent_title:`Refactor the auth flow`,osc_title:`claude`,branch:`alice/refactor-auth`,worktree_path:`/home/alice/code/app--refactor-auth`,status:`waiting_input`,agent_type:`claude-code`};function ht({initial:e,onSave:t,pending:n}){let[r,i]=(0,K.useState)(e),a=r.length>0?r:s;return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,q.jsx)(F,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:s}),(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,q.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:Ue(mt,a)})]}),(0,q.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:p.map(([e,t])=>(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,q.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,q.jsx)(O,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(s),t(s)},children:`Reset to default`})]})]})}function gt(){let e=E(),t=se().data?.find(t=>t.id===e),n=x(e??void 0),r=T(e??``),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(``),c=n.data?.allowSkipPermissions===!0,l=e=>r.mutate({allowSkipPermissions:e},{onSuccess:()=>{a(!1),s(``)},onError:e=>P(e)}),u=e=>t=>r.mutate({[e]:t},{onError:e=>P(e)});return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sessions`}),(0,q.jsx)(Y,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,q.jsx)(W,{id:`gate`,checked:c,onCheckedChange:e=>{e?a(!0):l(!1)}})}),(0,q.jsx)(Y,{label:`Capture exported env variables`,description:n.data?.captureSessionEnv===!1?`No variables are captured or injected; already-captured variabless are kept for when this is re-enabled.`:`Variables exported in a session persist and are re-injected upon terminal and agent restarts.`,htmlFor:`capture-env`,children:(0,q.jsx)(W,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:r.isPending,onCheckedChange:e=>r.mutate({captureSessionEnv:e},{onError:e=>P(e)})})}),(0,q.jsx)(ut,{}),(0,q.jsx)(ft,{}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`New session defaults`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(dt,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>P(e)}),pending:r.isPending},`${e}:agent-seed`),(0,q.jsx)(dt,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>P(e)}),pending:r.isPending},`${e}:terminal-seed`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{note:`Sent to agent as opening message when a session (re)starts. You can make this empty.`,children:`Launch text`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(pt,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??h,defaultText:h,onSave:u(`onboardingTemplate`),pending:r.isPending},`${e}:onboarding`),(0,q.jsx)(pt,{id:`concurrent-template`,label:`Existing / shared worktree`,description:`For a session joining a worktree other agents may already be working in.`,initial:n.data.concurrentTemplate??m,defaultText:m,onSave:u(`concurrentTemplate`),pending:r.isPending},`${e}:concurrent`),(0,q.jsx)(pt,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??g,defaultText:g,onSave:u(`restartTemplate`),pending:r.isPending},`${e}:restart`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`Tab title`}),n.data&&(0,q.jsx)(ht,{initial:n.data.tabTitleTemplate||"${name}",onSave:u(`tabTitleTemplate`),pending:r.isPending},`${e}:tab-title`)]}),(0,q.jsx)(N,{open:i,onOpenChange:e=>{e||(a(!1),s(``))},children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{className:`flex items-center gap-2`,children:[(0,q.jsx)(et,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,q.jsx)(M,{asChild:!0,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,q.jsx)(`p`,{children:`A prompt-free agent acts unattended, with your credentials, inside its worktree — and nothing technically stops a shell command from reaching outside it. It can:`}),(0,q.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,q.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,q.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,q.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,q.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,q.jsx)(`p`,{children:`Only open this gate if every account you opt in runs work you would trust a colleague to run unsupervised on this machine.`}),(0,q.jsx)(`p`,{className:`text-fg-muted`,children:`Opening it also records the agent’s own bypass-permissions acceptance for this profile’s accounts, so the skip actually takes effect.`})]})})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(pe,{htmlFor:`confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,q.jsx)(F,{id:`confirm-name`,value:o,onChange:e=>s(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:()=>{a(!1),s(``)},children:`Cancel`}),(0,q.jsx)(O,{variant:`danger`,disabled:o!==t?.name||r.isPending,onClick:()=>l(!0),children:`Open the gate`})]})]})})]})}var _t={desktop:!0,sound:!1,muted_projects:[]};function vt(){let[e,t]=(0,K.useState)(G);return(0,K.useEffect)(()=>{let e=()=>t(G());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(G())]}function yt({permission:e,onRequest:t}){return e===`granted`?null:(0,q.jsxs)(`p`,{className:`pb-2 text-xs text-warning`,children:[e==="default"&&(0,q.jsxs)(q.Fragment,{children:[`The browser has not been asked for permission yet, so nothing will show —`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:t,className:`underline underline-offset-2 transition-colors hover:text-fg`,children:`request it now`}),`.`]}),e===`denied`&&`Blocked by the browser — allow notifications for this site in its site settings, then return here.`,e===`unsupported`&&`This browser cannot show desktop notifications.`]})}function bt(){let e=E(),t=x(e??void 0),n=T(e??``),r=S(e??void 0),[i,a]=vt(),o={..._t,...t.data?.notifications??{}},s=e=>n.mutate({notifications:e},{onError:e=>P(e)}),c=()=>{typeof Notification>`u`||Notification.requestPermission().then(a)};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Notifications`}),(0,q.jsx)(Y,{label:`Desktop notification on waiting`,htmlFor:`notify-desktop`,children:(0,q.jsx)(W,{id:`notify-desktop`,checked:o.desktop,onCheckedChange:e=>{e&&c(),s({...o,desktop:e})}})}),o.desktop&&(0,q.jsx)(yt,{permission:i,onRequest:c}),(0,q.jsx)(Y,{label:`Sound`,htmlFor:`notify-sound`,children:(0,q.jsx)(W,{id:`notify-sound`,checked:o.sound,onCheckedChange:e=>s({...o,sound:e})})}),(0,q.jsx)(Y,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,q.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[o.muted_projects.length,` muted`]})}),(0,q.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.data?.map(e=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,q.jsx)(W,{checked:o.muted_projects.includes(e.id),onCheckedChange:t=>s({...o,muted_projects:t?[...o.muted_projects,e.id]:o.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function xt(){let e=U();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Editor`}),(0,q.jsx)(Y,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,q.jsx)(J,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>H({editorTabSize:e})})}),(0,q.jsx)(Y,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,q.jsx)(W,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>H({editorWordWrap:e})})}),(0,q.jsx)(Y,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,q.jsx)(F,{id:`editor-link-host`,type:`text`,placeholder:He.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>H({editorLinkSshHost:e.target.value})})})]})}function St({value:e,isDefault:t,onRecord:n,onReset:r}){let[a,o]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(!0),onBlur:()=>o(!1),onKeyDown:e=>{if(!a)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){o(!1);return}let t=re(e.nativeEvent);t&&(n(t),o(!1))},className:i(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,a?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:a?`Press keys…`:b(e)}),!t&&(0,q.jsxs)(`button`,{type:`button`,title:`Reset to default`,onClick:r,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(Qe,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function Ct(){let e=E(),t=x(e??void 0),n=T(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of de){let t=i(e.id,w(e));a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>P(e)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>P(e)})};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Hotkeys`}),(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),(0,q.jsx)(Y,{label:`App shortcuts in terminals`,description:t.data?.terminalAppShortcuts===!1?`A focused terminal receives these keys instead.`:`The shortcuts below work while a terminal is focused.`,htmlFor:`terminal-app-shortcuts`,className:`mb-4`,children:(0,q.jsx)(W,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>P(e)})})}),oe.map(e=>{let t=de.filter(t=>t.group===e);return t.length===0?null:(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(`div`,{className:`mb-1 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e}),t.map(e=>{let t=i(e.id,w(e)),n=(a.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,q.jsx)(Y,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,q.jsx)(St,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(e.id)})},e.id)})]},e)})]})}var wt=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Z=65,Q=Object.fromEntries([...wt].map((e,t)=>[e,t])),Tt=`H`,Et=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let n=t;for(let e=0;e<8;e+=1)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function Dt(e){let t=4294967295;for(let n of e)t=Et[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function Ot(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function kt(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}async function At(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function jt(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function Mt(e,t){let n=(t%Z+Z)%Z,r=``;for(let t of e){let e=Q[t];r+=e===void 0?t:wt[(e+n)%Z]}return r}async function Nt(e){let t=await At(JSON.stringify(e));return Mt(Ot(t)+Dt(t),1+Math.floor(Math.random()*(Z-1)))}async function Pt(e){let t=e.trim(),n=t[0];if(!n||Q[n]===void 0)throw Error(`Not a settings export.`);let r=Mt(t,-((Q[n]-Q[Tt]+Z)%Z));if(r.length<9||r[0]!==Tt)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=kt(i);if(Dt(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await jt(o))}var Ft=`puddle.sync-selection`;function It(){try{let e=JSON.parse(localStorage.getItem(Ft)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return Ee.map(e=>e.id)}function Lt({selected:e,onToggle:t}){return(0,q.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:Ee.map(n=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(W,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function Rt(){let e=E(),t=x(e??void 0),n=se().data?.find(t=>t.id===e),r=ae(e??void 0,void 0),i=T(e??``),a=C(),o=d(),s=Oe(),c=Ve(),[l,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(``),[h,g]=(0,K.useState)(!1),[_,v]=(0,K.useState)(!1),[ee,te]=(0,K.useState)(It),y=n&&s.data?we(s.data.file,n.name):void 0,b=y?.enabled===!0,S=b&&y?y.groups:ee,w=()=>({client:Te(),theme:De(),profileSettings:t.data??{},profile:n??{},scratchpad:r.data??[]}),ne={setClient:e=>H(e),setTheme:e=>{typeof e==`string`&&Ne(e)},patchProfileSettings:e=>i.mutate(e,{onError:e=>P(e)}),patchProfileColumns:t=>{e&&a.mutate({id:e,...t},{onError:e=>P(e)})},createScratchpad:t=>{if(e)for(let n of t)o.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},re=(e,t)=>{n&&c.mutate({profile:n.name,entry:{enabled:e.enabled??b,groups:t,doc:Pe(t,w()),updatedAt:new Date().toISOString()}},{onError:e=>P(e)})},ie=(e,t)=>{let n=t?[...S,e]:S.filter(t=>t!==e);te(n),localStorage.setItem(Ft,JSON.stringify(n)),b&&re({},n)},oe=async()=>{v(!0);try{let e=Fe(await Pt(l.trim()),ne,{profileSettings:t.data??{},scratchpad:r.data??[]});e.length===0?u.error(`Nothing recognised to import.`):(u.success(`Imported ${e.join(`, `)}.`),f(``))}catch(e){u.error(e.message)}finally{v(!1)}},ce=async()=>{v(!0);try{let e=await Nt(Pe(S,w()));m(e),await navigator.clipboard?.writeText(e),u.success(`Copied to clipboard`)}finally{v(!1)}};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sync`}),(0,q.jsx)(`p`,{className:`mb-5 text-xs text-fg-muted`,children:`Carry your settings between machines. Accounts, repositories, and anything host-specific are never included. Applies to this profile.`}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),s.data?.available===!1?(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:`Not available in this cockpit — start the UI with the Puddle CLI to sync across windows.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Sync selected groups through this machine’s`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:`~/.puddle`}),`, so every Puddle window stays in step for profiles named`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:n?.name??`…`}),`.`]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(W,{checked:b,disabled:!n||s.isLoading||c.isPending,onCheckedChange:e=>re({enabled:e},S)}),`Sync locally`]})]})]}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`flex items-center gap-1 text-xs text-fg-secondary transition-colors hover:text-fg`,children:[h?(0,q.jsx)(ve,{className:`size-3.5`}):(0,q.jsx)(ye,{className:`size-3.5`}),`Choose what to sync`]}),h&&(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(Lt,{selected:S,onToggle:ie})})]}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,q.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:`Builds a Puddle magic string that encodes settings from the checklist above.`}),(0,q.jsx)(O,{size:`sm`,disabled:_,onClick:()=>void ce(),children:`Export & copy`}),p&&(0,q.jsx)(I,{readOnly:!0,value:p,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`mt-2 resize-y font-mono text-xs`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,q.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste a Puddle magic string to import its settings.`}),(0,q.jsx)(I,{value:l,onChange:e=>f(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:`Paste a settings export…`,rows:3,spellCheck:!1,className:`resize-y font-mono text-xs`}),(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(O,{size:`sm`,disabled:!l.trim()||_,onClick:()=>void oe(),children:`Import`})})]})]})}function zt({repo:e}){let t=ue(),n=c(),[r,i]=(0,K.useState)(e.default_base_branch),[a,o]=(0,K.useState)(e.onboarding_notes??``),s=e=>P(e);return(0,q.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.path}),(0,q.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,q.jsxs)(O,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>u.success(`Fetched.`),onError:s}),children:[(0,q.jsx)(ze,{}),`Fetch now`]})]}),(0,q.jsxs)(Y,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,q.jsx)(F,{id:`base-${e.id}`,value:r,onChange:e=>i(e.target.value),className:`w-40`}),(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:r===e.default_base_branch||t.isPending,onClick:()=>t.mutate({id:e.id,default_base_branch:r},{onError:s}),children:`Save`})]}),(0,q.jsx)(Y,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,q.jsx)(W,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:s})})}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Standing setup rules, injected into every fresh worktree. Agents update them via .puddle/onboarding-notes.md.`})]}),(0,q.jsx)(I,{id:`notes-${e.id}`,value:a,onChange:e=>o(e.target.value),rows:4}),(0,q.jsx)(`div`,{children:(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:a===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:a},{onError:s}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,q.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,q.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Orphan worktrees — directories no session claims. Puddle never deletes these automatically; remove them by hand if unwanted.`}),(0,q.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,q.jsx)(`li`,{className:`truncate text-2xs text-fg-muted`,children:e},e))})]})]})}function Bt(){let e=ce();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Projects`}),e.data?.length===0&&(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No projects yet — create one from the dashboard, pointing at a repository.`}),e.data?.map(e=>(0,q.jsx)(zt,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=_();return(0,q.jsx)(Y,{label:e,description:t,htmlFor:`host-${n}`,children:(0,q.jsx)(F,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{if(e.target.value.trim()===``){e.target.value=String(r[n]);return}let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>P(e)})}})})}function Vt(){let e=a(),t=_(),n=le();return e.data?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{note:`Affects all profiles on this host`,children:`Host`}),(0,q.jsx)(Y,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,q.jsx)(F,{id:`host-displayName`,type:`text`,maxLength:64,className:`w-48`,placeholder:n.data?.hostname,defaultValue:e.data.displayName,onBlur:n=>{let r=n.target.value.trim();r!==e.data.displayName&&t.mutate({displayName:r},{onError:e=>P(e)})}})}),(0,q.jsx)($,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,q.jsx)($,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,q.jsx)($,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,q.jsx)($,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,q.jsx)(Y,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,q.jsx)(W,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>P(e)})})})]}):null}var Ht=[{id:`appearance`,label:`Appearance`,icon:Re,render:()=>(0,q.jsx)(rt,{})},{id:`profile`,label:`Profile`,icon:Me,render:()=>(0,q.jsx)(ot,{})},{id:`accounts`,label:`Accounts`,icon:nt,render:()=>(0,q.jsx)(lt,{})},{id:`sessions`,label:`Sessions`,icon:tt,render:()=>(0,q.jsx)(gt,{})},{id:`editor`,label:`Editor`,icon:Xe,render:()=>(0,q.jsx)(xt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Ze,render:()=>(0,q.jsx)(Ct,{})},{id:`notifications`,label:`Notifications`,icon:Ye,render:()=>(0,q.jsx)(bt,{})},{id:`projects`,label:`Projects`,icon:ge,render:()=>(0,q.jsx)(Bt,{})},{id:`host`,label:`Host`,icon:$e,render:()=>(0,q.jsx)(Vt,{})},{id:`sync`,label:`Sync`,icon:ze,render:()=>(0,q.jsx)(Rt,{})}],Ut={terminal:`sessions`,repositories:`projects`};function Wt(){let e=qe(),t=e===null?null:Ut[e]??e,n=Ht.find(e=>e.id===t)??Ht[0];return(0,q.jsx)(N,{open:e!==null,onOpenChange:e=>!e&&Ie(),children:(0,q.jsxs)(A,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,q.jsx)(j,{className:`sr-only`,children:`Settings`}),(0,q.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,q.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),Ht.map(({id:e,label:t,icon:r})=>(0,q.jsxs)(`button`,{onClick:()=>Ge(e),className:i(`flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors`,e===n.id?`bg-elevated text-fg`:`text-fg-secondary hover:bg-elevated hover:text-fg`),children:[(0,q.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]}),(0,q.jsx)(`div`,{className:`overflow-y-auto p-5`,children:n.render()})]})})}export{Wt as SettingsDialog};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,n as r,r as i}from"./x-BJOrp_m5.js";import{A as a,E as o,Ft as s,G as c,H as l,Ht as u,I as d,It as f,Lt as p,Mt as m,Nt as h,Pt as g,Q as _,T as v,W as ee,Y as te,Z as y,a as b,at as x,ct as S,et as C,f as w,g as ne,i as re,j as ie,mt as ae,n as oe,ot as se,pt as ce,q as le,rt as ue,t as de,tt as T,v as E,z as fe}from"./hotkeys-CekBkaTu.js";import{a as D,h as O,i as k,n as A,o as j,r as M,t as N}from"./dialog-DjL0qoAv.js";import{a as P,c as pe,l as F,o as me,r as he,s as ge,u as I}from"./LazyTerminal-D2S8HMn8.js";import{a as L,i as R,n as z,o as B,r as V,t as _e}from"./session-seed-vlAMEMll.js";import{t as ve}from"./chevron-down-59O6CgEo.js";import{r as ye}from"./dist-DDFe8e3m.js";import{$ as be,At as xe,Ct as Se,Et as Ce,G as we,It as Te,J as Ee,Jt as De,K as Oe,Lt as H,Mt as ke,Q as Ae,Rt as U,St as je,Tt as Me,V as W,W as G,Wt as Ne,X as Pe,Y as Fe,_t as Ie,et as Le,jt as Re,kt as ze,ot as Be,q as Ve,r as He,rt as Ue,tt as We,vt as Ge,wt as Ke,yt as qe,zt as Je}from"./index-C6Vjy8Jr.js";var Ye=r(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Xe=r(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Ze=r(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Qe=r(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),$e=r(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),et=r(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),tt=r(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),nt=r(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),K=e(t(),1),q=n();function J({id:e,value:t,min:n,max:r,step:i,className:a,onCommit:o}){let[s,c]=(0,K.useState)(String(t));return(0,K.useEffect)(()=>c(String(t)),[t]),(0,q.jsx)(F,{id:e,type:`number`,min:n,max:r,step:i,className:a,value:s,onChange:e=>c(e.target.value),onBlur:()=>{let e=Number(s);if(s.trim()===``||!Number.isFinite(e)){c(String(t));return}let i=Math.min(r??e,Math.max(n??e,e));c(String(i)),i!==t&&o(i)},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}function Y({label:e,description:t,descriptionClassName:n,htmlFor:r,children:a,className:o}){return(0,q.jsxs)(`div`,{className:i(`flex items-center gap-4 py-2.5`,o),children:[(0,q.jsxs)(`label`,{htmlFor:r,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:i(`text-xs text-fg-muted`,n),children:t})]}),(0,q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:a})]})}function X({children:e,note:t}){return(0,q.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function rt(){let e=U(),[t,n]=(0,K.useState)(De());return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Appearance`}),(0,q.jsx)(Y,{label:`Theme`,children:(0,q.jsxs)(z,{value:t,onValueChange:e=>{n(e),Ne(e)},children:[(0,q.jsx)(L,{className:`w-32`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(R,{value:`dark`,children:`Dark`}),(0,q.jsx)(R,{value:`light`,children:`Light`}),(0,q.jsx)(R,{value:`system`,children:`System`})]})]})}),(0,q.jsx)(Y,{label:`Cursor style`,children:(0,q.jsxs)(z,{value:e.cursorPackage,onValueChange:e=>H({cursorPackage:e}),children:[(0,q.jsx)(L,{className:`w-36`,children:(0,q.jsx)(B,{})}),(0,q.jsx)(V,{children:Je.map(e=>(0,q.jsx)(R,{value:e.id,children:e.label},e.id))})]})}),(0,q.jsx)(Y,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,q.jsx)(J,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>H({uiFontSize:e})})}),(0,q.jsx)(Y,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,q.jsx)(J,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>H({terminalFontSize:e})})}),(0,q.jsx)(Y,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,q.jsx)(J,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>H({editorFontSize:e})})}),(0,q.jsx)(Y,{label:`Density`,children:(0,q.jsxs)(z,{value:e.density,onValueChange:e=>H({density:e}),children:[(0,q.jsx)(L,{className:`w-36`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(R,{value:`compact`,children:`Compact`}),(0,q.jsx)(R,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,q.jsx)(Y,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,q.jsx)(W,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>H({projectBasedLayout:e})})}),(0,q.jsx)(Y,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,q.jsx)(W,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>H({showAllProjectSessions:e})})})]})}function it({profile:e}){let t=C(),[n,r]=(0,K.useState)(!1),a=n=>{t.mutate({id:e.id,icon:n},{onError:e=>P(e)}),r(!1)},o=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>P(e)});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Icon`,children:(0,q.jsxs)(be,{open:n,onOpenChange:r,children:[(0,q.jsx)(We,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:`flex size-9 items-center justify-center rounded-md text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(je,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,q.jsx)(Le,{align:`end`,className:`w-72`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,title:`Default`,onClick:()=>a(null),className:i(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,!e.icon&&`bg-elevated text-fg`),children:(0,q.jsx)(je,{icon:null,colour:null,className:`size-4`})}),Ke.map(({name:t,Icon:n})=>(0,q.jsx)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:i(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,e.icon===t&&`bg-elevated text-fg`),children:(0,q.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,q.jsx)(Y,{label:`Icon colour`,children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,q.jsxs)(`button`,{type:`button`,title:`Default`,onClick:()=>o(null),className:i(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,!e.icon_colour&&`bg-elevated`),children:[(0,q.jsx)(`span`,{className:`size-3.5 rounded-full bg-fg-muted`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Default colour`})]}),f.map(t=>(0,q.jsxs)(`button`,{type:`button`,title:t,onClick:()=>o(t),className:i(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,e.icon_colour===t&&`bg-elevated`),children:[(0,q.jsx)(`span`,{className:i(`size-3.5 rounded-full bg-current`,Se(t))}),(0,q.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var at=`__none__`;function ot(){let e=E(),t=se().data?.find(t=>t.id===e),n=v(e??void 0),r=x(e??void 0),i=C(),a=T(e??``),o=l(),[s,c]=(0,K.useState)(``),[u,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(!1),[m,h]=(0,K.useState)(``);if((0,K.useEffect)(()=>{t&&(c(t.name),d(t.branch_prefix))},[t]),!t)return null;let g=r.data?.default_account_id;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Profile`}),(0,q.jsxs)(Y,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,q.jsx)(F,{id:`profile-name`,value:s,onChange:e=>c(e.target.value),className:`w-44`}),(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:s===t.name||s.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:s},{onError:e=>P(e)}),children:`Save`})]}),(0,q.jsxs)(Y,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,q.jsx)(F,{id:`branch-prefix`,value:u,onChange:e=>d(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:u===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:u},{onError:e=>P(e)}),children:`Save`})]}),(0,q.jsx)(it,{profile:t}),(0,q.jsx)(Y,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,q.jsxs)(z,{value:typeof g==`number`?String(g):at,onValueChange:e=>a.mutate({default_account_id:e===at?null:Number(e)},{onError:e=>P(e)}),children:[(0,q.jsx)(L,{className:`w-56`,children:(0,q.jsx)(B,{})}),(0,q.jsxs)(V,{children:[(0,q.jsx)(R,{value:at,children:`First available`}),n.data?.map(e=>(0,q.jsx)(R,{value:String(e.id),children:(0,q.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,q.jsx)(Y,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,q.jsx)(O,{variant:`danger`,size:`sm`,onClick:()=>p(!0),children:`Delete…`})}),(0,q.jsx)(N,{open:f,onOpenChange:e=>{e||(p(!1),h(``))},children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{children:[`Delete profile `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,q.jsx)(M,{children:`Everything this profile owns goes with it: projects, workspace layouts, accounts and their credential directories, and archived session history. Branches, repositories, and terminal logs on disk are untouched. This cannot be undone.`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(pe,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,q.jsx)(F,{id:`delete-confirm-name`,value:m,onChange:e=>h(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:()=>{p(!1),h(``)},children:`Cancel`}),(0,q.jsx)(O,{variant:`danger`,disabled:m!==t.name||o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>{Ie(),ne.set(null)},onError:e=>{p(!1),h(``),P(e)}}),children:`Delete profile`})]})]})})]})}function st({agent:e,profileId:t,onClose:n,onCreated:r}){let i=ie(),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),l=ee(Be(s,150)),u=s.trim(),d=u===``||u.startsWith(`/`)||u.startsWith(`~`),f=a.trim()!==``&&d,p=()=>{!f||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...u===``?{}:{import_dir:u}},{onSuccess:e=>{n(),r(e,u!==``)},onError:e=>P(e)})};return(0,q.jsx)(N,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{children:[`Add a `,e.display_name,` account`]}),(0,q.jsxs)(M,{children:[`Accounts are isolated config dirs under this profile. Naming one is enough — Puddle creates it and takes you straight to `,e.display_name,`’s login. To reuse an account you already have on this machine, give its config directory: it is copied in and the original is never touched.`]})]}),(0,q.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,q.jsx)(F,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(he,{value:s,onValueChange:c,placeholder:`(optional) existing config dir, e.g. ~/.claude`,hints:(l.data?.entries??[]).map(e=>({value:e.path,label:e.name}))})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,q.jsxs)(O,{disabled:!f||i.isPending,onClick:p,children:[(0,q.jsx)(xe,{}),`Add account`]})]})]})})}function ct({account:e,gateOpen:t,installed:n}){let r=te(),i=y(),a=fe(),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(e.label),f=(0,K.useRef)(null);return(0,K.useEffect)(()=>d(e.label),[e.label]),(0,q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`input`,{ref:f,value:u,onChange:e=>d(e.target.value),onBlur:()=>{let t=u.trim();if(t!==e.label){if(t===``){d(e.label);return}i.mutate({id:e.id,label:t},{onError:t=>{P(t),d(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(d(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full min-w-0 truncate rounded-sm bg-transparent px-1 py-0.5 text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,q.jsxs)(`button`,{type:`button`,title:`Rename account`,onClick:()=>{f.current?.focus(),f.current?.select()},className:`shrink-0 rounded-sm p-0.5 text-fg-muted transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(me,{className:`size-3`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Rename account`})]})]}),(0,q.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,q.jsx)(W,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>P(e)})})]}),(0,q.jsxs)(O,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>P(e)}),children:[(0,q.jsx)(ke,{}),e.logged_in?`Re-login`:`Login`]}),(0,q.jsxs)(O,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,q.jsx)(Ce,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,q.jsx)(Ae,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,q.jsx)(N,{open:c,onOpenChange:l,children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{children:[`Delete `,(0,q.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,q.jsx)(M,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,q.jsx)(O,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),P(e)}}),children:`Delete account`})]})]})})]})}function lt(){let e=E(),t=o(),n=v(e??void 0),r=x(e??void 0),i=te(),[a,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(null),d=r.data?.allowSkipPermissions===!0;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[],r=e.available!==!1;return(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(Y,{label:e.display_name,description:r?`Accounts are initialised in config dirs owned by this profile.`:`No ${e.binary??e.id} on the daemon’s PATH. Install it or add its directory to the agent search path in Sessions.`,className:`py-1`,children:(0,q.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.id})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,q.jsx)(ct,{account:t,gateOpen:d&&e.capabilities.skip_permissions,installed:r},t.id)),(0,q.jsx)(`div`,{className:`flex`,children:(0,q.jsxs)(O,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>l(e),children:[(0,q.jsx)(xe,{}),`Add account`]})})]})]},e.id)}),a&&(0,q.jsx)(Ae,{stream:a.stream,label:a.label,hint:a.hint,onClose:()=>s(null)}),c!==null&&e!==null&&(0,q.jsx)(st,{agent:c,profileId:e,onClose:()=>l(null),onCreated:(e,t)=>{if(t){e.logged_in||u.info(`Imported without credentials — press Login to authenticate.`);return}i.mutate(e.id,{onSuccess:t=>s({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>P(e)})}})]})}function ut(){let e=a(),t=_(),[n,r]=(0,K.useState)(``);return(0,K.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,q.jsx)(Y,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH; helps find agent CLIs like claude (e.g. ~/.local/bin).`,htmlFor:`agent-path`,children:(0,q.jsx)(F,{id:`agent-path`,type:`text`,className:`w-64 text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function dt({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=_e(e,n),o=n.sessionDefaults??{},[s,c]=(0,K.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,q.jsx)(Y,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,q.jsx)(F,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,q.jsx)(Y,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,q.jsx)(W,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,q.jsx)(Y,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`Start on working copy of the selected branch instead of sharing one directory.`,htmlFor:`${e}-default-dir`,children:(0,q.jsx)(W,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function ft(){return(0,q.jsx)(Y,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,q.jsx)(J,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:U().terminalScrollback,onCommit:e=>H({terminalScrollback:e})})})}function pt({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,K.useState)(r);return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,q.jsx)(I,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,q.jsx)(O,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var mt={id:`4f3c2b1a-7e6d-5c4b-3a2f-1e0d9c8b7a6f`,title:null,agent_title:`Refactor the auth flow`,osc_title:`claude`,branch:`alice/refactor-auth`,worktree_path:`/home/alice/code/app--refactor-auth`,status:`waiting_input`,agent_type:`claude-code`};function ht({initial:e,onSave:t,pending:n}){let[r,i]=(0,K.useState)(e),a=r.length>0?r:s;return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,q.jsx)(F,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:s}),(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,q.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:Ue(mt,a)})]}),(0,q.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:p.map(([e,t])=>(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,q.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,q.jsx)(O,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(s),t(s)},children:`Reset to default`})]})]})}function gt(){let e=E(),t=se().data?.find(t=>t.id===e),n=x(e??void 0),r=T(e??``),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(``),c=n.data?.allowSkipPermissions===!0,l=e=>r.mutate({allowSkipPermissions:e},{onSuccess:()=>{a(!1),s(``)},onError:e=>P(e)}),u=e=>t=>r.mutate({[e]:t},{onError:e=>P(e)});return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sessions`}),(0,q.jsx)(Y,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,q.jsx)(W,{id:`gate`,checked:c,onCheckedChange:e=>{e?a(!0):l(!1)}})}),(0,q.jsx)(Y,{label:`Capture exported env variables`,description:n.data?.captureSessionEnv===!1?`No variables are captured or injected; already-captured variabless are kept for when this is re-enabled.`:`Variables exported in a session persist and are re-injected upon terminal and agent restarts.`,htmlFor:`capture-env`,children:(0,q.jsx)(W,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:r.isPending,onCheckedChange:e=>r.mutate({captureSessionEnv:e},{onError:e=>P(e)})})}),(0,q.jsx)(ut,{}),(0,q.jsx)(ft,{}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`New session defaults`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(dt,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>P(e)}),pending:r.isPending},`${e}:agent-seed`),(0,q.jsx)(dt,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>P(e)}),pending:r.isPending},`${e}:terminal-seed`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{note:`Sent to agent as opening message when a session (re)starts. You can make this empty.`,children:`Launch text`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(pt,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??h,defaultText:h,onSave:u(`onboardingTemplate`),pending:r.isPending},`${e}:onboarding`),(0,q.jsx)(pt,{id:`concurrent-template`,label:`Existing / shared worktree`,description:`For a session joining a worktree other agents may already be working in.`,initial:n.data.concurrentTemplate??m,defaultText:m,onSave:u(`concurrentTemplate`),pending:r.isPending},`${e}:concurrent`),(0,q.jsx)(pt,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??g,defaultText:g,onSave:u(`restartTemplate`),pending:r.isPending},`${e}:restart`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`Tab title`}),n.data&&(0,q.jsx)(ht,{initial:n.data.tabTitleTemplate||"${name}",onSave:u(`tabTitleTemplate`),pending:r.isPending},`${e}:tab-title`)]}),(0,q.jsx)(N,{open:i,onOpenChange:e=>{e||(a(!1),s(``))},children:(0,q.jsxs)(A,{children:[(0,q.jsxs)(D,{children:[(0,q.jsxs)(j,{className:`flex items-center gap-2`,children:[(0,q.jsx)(et,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,q.jsx)(M,{asChild:!0,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,q.jsx)(`p`,{children:`A prompt-free agent acts unattended, with your credentials, inside its worktree — and nothing technically stops a shell command from reaching outside it. It can:`}),(0,q.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,q.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,q.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,q.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,q.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,q.jsx)(`p`,{children:`Only open this gate if every account you opt in runs work you would trust a colleague to run unsupervised on this machine.`}),(0,q.jsx)(`p`,{className:`text-fg-muted`,children:`Opening it also records the agent’s own bypass-permissions acceptance for this profile’s accounts, so the skip actually takes effect.`})]})})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(pe,{htmlFor:`confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,q.jsx)(F,{id:`confirm-name`,value:o,onChange:e=>s(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(k,{children:[(0,q.jsx)(O,{variant:`ghost`,onClick:()=>{a(!1),s(``)},children:`Cancel`}),(0,q.jsx)(O,{variant:`danger`,disabled:o!==t?.name||r.isPending,onClick:()=>l(!0),children:`Open the gate`})]})]})})]})}var _t={desktop:!0,sound:!1,muted_projects:[]};function vt(){let[e,t]=(0,K.useState)(G);return(0,K.useEffect)(()=>{let e=()=>t(G());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(G())]}function yt({permission:e,onRequest:t}){return e===`granted`?null:(0,q.jsxs)(`p`,{className:`pb-2 text-xs text-warning`,children:[e==="default"&&(0,q.jsxs)(q.Fragment,{children:[`The browser has not been asked for permission yet, so nothing will show —`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:t,className:`underline underline-offset-2 transition-colors hover:text-fg`,children:`request it now`}),`.`]}),e===`denied`&&`Blocked by the browser — allow notifications for this site in its site settings, then return here.`,e===`unsupported`&&`This browser cannot show desktop notifications.`]})}function bt(){let e=E(),t=x(e??void 0),n=T(e??``),r=S(e??void 0),[i,a]=vt(),o={..._t,...t.data?.notifications??{}},s=e=>n.mutate({notifications:e},{onError:e=>P(e)}),c=()=>{typeof Notification>`u`||Notification.requestPermission().then(a)};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Notifications`}),(0,q.jsx)(Y,{label:`Desktop notification on waiting`,htmlFor:`notify-desktop`,children:(0,q.jsx)(W,{id:`notify-desktop`,checked:o.desktop,onCheckedChange:e=>{e&&c(),s({...o,desktop:e})}})}),o.desktop&&(0,q.jsx)(yt,{permission:i,onRequest:c}),(0,q.jsx)(Y,{label:`Sound`,htmlFor:`notify-sound`,children:(0,q.jsx)(W,{id:`notify-sound`,checked:o.sound,onCheckedChange:e=>s({...o,sound:e})})}),(0,q.jsx)(Y,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,q.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[o.muted_projects.length,` muted`]})}),(0,q.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.data?.map(e=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,q.jsx)(W,{checked:o.muted_projects.includes(e.id),onCheckedChange:t=>s({...o,muted_projects:t?[...o.muted_projects,e.id]:o.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function xt(){let e=U();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Editor`}),(0,q.jsx)(Y,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,q.jsx)(J,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>H({editorTabSize:e})})}),(0,q.jsx)(Y,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,q.jsx)(W,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>H({editorWordWrap:e})})}),(0,q.jsx)(Y,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,q.jsx)(F,{id:`editor-link-host`,type:`text`,placeholder:He.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>H({editorLinkSshHost:e.target.value})})})]})}function St({value:e,isDefault:t,onRecord:n,onReset:r}){let[a,o]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`button`,{type:`button`,onClick:()=>o(!0),onBlur:()=>o(!1),onKeyDown:e=>{if(!a)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){o(!1);return}let t=re(e.nativeEvent);t&&(n(t),o(!1))},className:i(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,a?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:a?`Press keys…`:b(e)}),!t&&(0,q.jsxs)(`button`,{type:`button`,title:`Reset to default`,onClick:r,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(Qe,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function Ct(){let e=E(),t=x(e??void 0),n=T(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of de){let t=i(e.id,w(e));a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>P(e)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>P(e)})};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Hotkeys`}),(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),(0,q.jsx)(Y,{label:`App shortcuts in terminals`,description:t.data?.terminalAppShortcuts===!1?`A focused terminal receives these keys instead.`:`The shortcuts below work while a terminal is focused.`,htmlFor:`terminal-app-shortcuts`,className:`mb-4`,children:(0,q.jsx)(W,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>P(e)})})}),oe.map(e=>{let t=de.filter(t=>t.group===e);return t.length===0?null:(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(`div`,{className:`mb-1 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e}),t.map(e=>{let t=i(e.id,w(e)),n=(a.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,q.jsx)(Y,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,q.jsx)(St,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(e.id)})},e.id)})]},e)})]})}var wt=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Z=65,Q=Object.fromEntries([...wt].map((e,t)=>[e,t])),Tt=`H`,Et=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let n=t;for(let e=0;e<8;e+=1)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function Dt(e){let t=4294967295;for(let n of e)t=Et[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function Ot(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function kt(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}async function At(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function jt(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function Mt(e,t){let n=(t%Z+Z)%Z,r=``;for(let t of e){let e=Q[t];r+=e===void 0?t:wt[(e+n)%Z]}return r}async function Nt(e){let t=await At(JSON.stringify(e));return Mt(Ot(t)+Dt(t),1+Math.floor(Math.random()*(Z-1)))}async function Pt(e){let t=e.trim(),n=t[0];if(!n||Q[n]===void 0)throw Error(`Not a settings export.`);let r=Mt(t,-((Q[n]-Q[Tt]+Z)%Z));if(r.length<9||r[0]!==Tt)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=kt(i);if(Dt(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await jt(o))}var Ft=`puddle.sync-selection`;function It(){try{let e=JSON.parse(localStorage.getItem(Ft)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return Ee.map(e=>e.id)}function Lt({selected:e,onToggle:t}){return(0,q.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:Ee.map(n=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(W,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function Rt(){let e=E(),t=x(e??void 0),n=se().data?.find(t=>t.id===e),r=ae(e??void 0,void 0),i=T(e??``),a=C(),o=d(),s=Oe(),c=Ve(),[l,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(``),[h,g]=(0,K.useState)(!1),[_,v]=(0,K.useState)(!1),[ee,te]=(0,K.useState)(It),y=n&&s.data?we(s.data.file,n.name):void 0,b=y?.enabled===!0,S=b&&y?y.groups:ee,w=()=>({client:Te(),theme:De(),profileSettings:t.data??{},profile:n??{},scratchpad:r.data??[]}),ne={setClient:e=>H(e),setTheme:e=>{typeof e==`string`&&Ne(e)},patchProfileSettings:e=>i.mutate(e,{onError:e=>P(e)}),patchProfileColumns:t=>{e&&a.mutate({id:e,...t},{onError:e=>P(e)})},createScratchpad:t=>{if(e)for(let n of t)o.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},re=(e,t)=>{n&&c.mutate({profile:n.name,entry:{enabled:e.enabled??b,groups:t,doc:Pe(t,w()),updatedAt:new Date().toISOString()}},{onError:e=>P(e)})},ie=(e,t)=>{let n=t?[...S,e]:S.filter(t=>t!==e);te(n),localStorage.setItem(Ft,JSON.stringify(n)),b&&re({},n)},oe=async()=>{v(!0);try{let e=Fe(await Pt(l.trim()),ne,{profileSettings:t.data??{},scratchpad:r.data??[]});e.length===0?u.error(`Nothing recognised to import.`):(u.success(`Imported ${e.join(`, `)}.`),f(``))}catch(e){u.error(e.message)}finally{v(!1)}},ce=async()=>{v(!0);try{let e=await Nt(Pe(S,w()));m(e),await navigator.clipboard?.writeText(e),u.success(`Copied to clipboard`)}finally{v(!1)}};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sync`}),(0,q.jsx)(`p`,{className:`mb-5 text-xs text-fg-muted`,children:`Carry your settings between machines. Accounts, repositories, and anything host-specific are never included. Applies to this profile.`}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),s.data?.available===!1?(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:`Not available in this cockpit — start the UI with the Puddle CLI to sync across windows.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Sync selected groups through this machine’s`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:`~/.puddle`}),`, so every Puddle window stays in step for profiles named`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:n?.name??`…`}),`.`]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(W,{checked:b,disabled:!n||s.isLoading||c.isPending,onCheckedChange:e=>re({enabled:e},S)}),`Sync locally`]})]})]}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`flex items-center gap-1 text-xs text-fg-secondary transition-colors hover:text-fg`,children:[h?(0,q.jsx)(ve,{className:`size-3.5`}):(0,q.jsx)(ye,{className:`size-3.5`}),`Choose what to sync`]}),h&&(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(Lt,{selected:S,onToggle:ie})})]}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,q.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:`Builds a Puddle magic string that encodes settings from the checklist above.`}),(0,q.jsx)(O,{size:`sm`,disabled:_,onClick:()=>void ce(),children:`Export & copy`}),p&&(0,q.jsx)(I,{readOnly:!0,value:p,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`mt-2 resize-y font-mono text-xs`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,q.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste a Puddle magic string to import its settings.`}),(0,q.jsx)(I,{value:l,onChange:e=>f(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:`Paste a settings export…`,rows:3,spellCheck:!1,className:`resize-y font-mono text-xs`}),(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(O,{size:`sm`,disabled:!l.trim()||_,onClick:()=>void oe(),children:`Import`})})]})]})}function zt({repo:e}){let t=ue(),n=c(),[r,i]=(0,K.useState)(e.default_base_branch),[a,o]=(0,K.useState)(e.onboarding_notes??``),s=e=>P(e);return(0,q.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.path}),(0,q.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,q.jsxs)(O,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>u.success(`Fetched.`),onError:s}),children:[(0,q.jsx)(ze,{}),`Fetch now`]})]}),(0,q.jsxs)(Y,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,q.jsx)(F,{id:`base-${e.id}`,value:r,onChange:e=>i(e.target.value),className:`w-40`}),(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:r===e.default_base_branch||t.isPending,onClick:()=>t.mutate({id:e.id,default_base_branch:r},{onError:s}),children:`Save`})]}),(0,q.jsx)(Y,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,q.jsx)(W,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:s})})}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Standing setup rules, injected into every fresh worktree. Agents update them via .puddle/onboarding-notes.md.`})]}),(0,q.jsx)(I,{id:`notes-${e.id}`,value:a,onChange:e=>o(e.target.value),rows:4}),(0,q.jsx)(`div`,{children:(0,q.jsx)(O,{size:`sm`,variant:`secondary`,disabled:a===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:a},{onError:s}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,q.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,q.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Orphan worktrees — directories no session claims. Puddle never deletes these automatically; remove them by hand if unwanted.`}),(0,q.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,q.jsx)(`li`,{className:`truncate text-2xs text-fg-muted`,children:e},e))})]})]})}function Bt(){let e=ce();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Projects`}),e.data?.length===0&&(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No projects yet — create one from the dashboard, pointing at a repository.`}),e.data?.map(e=>(0,q.jsx)(zt,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=_();return(0,q.jsx)(Y,{label:e,description:t,htmlFor:`host-${n}`,children:(0,q.jsx)(F,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{if(e.target.value.trim()===``){e.target.value=String(r[n]);return}let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>P(e)})}})})}function Vt(){let e=a(),t=_(),n=le();return e.data?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{note:`Affects all profiles on this host`,children:`Host`}),(0,q.jsx)(Y,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,q.jsx)(F,{id:`host-displayName`,type:`text`,maxLength:64,className:`w-48`,placeholder:n.data?.hostname,defaultValue:e.data.displayName,onBlur:n=>{let r=n.target.value.trim();r!==e.data.displayName&&t.mutate({displayName:r},{onError:e=>P(e)})}})}),(0,q.jsx)($,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,q.jsx)($,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,q.jsx)($,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,q.jsx)($,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,q.jsx)(Y,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,q.jsx)(W,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>P(e)})})})]}):null}var Ht=[{id:`appearance`,label:`Appearance`,icon:Re,render:()=>(0,q.jsx)(rt,{})},{id:`profile`,label:`Profile`,icon:Me,render:()=>(0,q.jsx)(ot,{})},{id:`accounts`,label:`Accounts`,icon:nt,render:()=>(0,q.jsx)(lt,{})},{id:`sessions`,label:`Sessions`,icon:tt,render:()=>(0,q.jsx)(gt,{})},{id:`editor`,label:`Editor`,icon:Xe,render:()=>(0,q.jsx)(xt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Ze,render:()=>(0,q.jsx)(Ct,{})},{id:`notifications`,label:`Notifications`,icon:Ye,render:()=>(0,q.jsx)(bt,{})},{id:`projects`,label:`Projects`,icon:ge,render:()=>(0,q.jsx)(Bt,{})},{id:`host`,label:`Host`,icon:$e,render:()=>(0,q.jsx)(Vt,{})},{id:`sync`,label:`Sync`,icon:ze,render:()=>(0,q.jsx)(Rt,{})}],Ut={terminal:`sessions`,repositories:`projects`};function Wt(){let e=qe(),t=e===null?null:Ut[e]??e,n=Ht.find(e=>e.id===t)??Ht[0];return(0,q.jsx)(N,{open:e!==null,onOpenChange:e=>!e&&Ie(),children:(0,q.jsxs)(A,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,q.jsx)(j,{className:`sr-only`,children:`Settings`}),(0,q.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,q.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),Ht.map(({id:e,label:t,icon:r})=>(0,q.jsxs)(`button`,{onClick:()=>Ge(e),className:i(`flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors`,e===n.id?`bg-elevated text-fg`:`text-fg-secondary hover:bg-elevated hover:text-fg`),children:[(0,q.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]}),(0,q.jsx)(`div`,{className:`overflow-y-auto p-5`,children:n.render()})]})})}export{Wt as SettingsDialog};
|