@puddle-code/cli 0.0.29 → 0.0.30

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 (25) hide show
  1. package/CHANGELOG.md +6 -6
  2. package/dist/index.js +1 -1
  3. package/dist/public/assets/{Dashboard-BvPjzBPD.js → Dashboard-C3WvNQZm.js} +1 -1
  4. package/dist/public/assets/{EditorTabClose-Jq9KHVWj.js → EditorTabClose-B9fEd9D9.js} +1 -1
  5. package/dist/public/assets/{LazyTerminal-BByZdzv2.js → LazyTerminal-BNKlV3ik.js} +2 -2
  6. package/dist/public/assets/{ModelRefcount-DQjLPxaP.js → ModelRefcount-BNGUY0T3.js} +1 -1
  7. package/dist/public/assets/{PaneEditorBody-Bl1azbxb.js → PaneEditorBody-Cw7QvWd7.js} +1 -1
  8. package/dist/public/assets/{SettingsDialog-DcQ-SyUh.js → SettingsDialog--9U-efVU.js} +1 -1
  9. package/dist/public/assets/{Terminal-DmZUwk21.js → Terminal-D1eGlRYN.js} +8 -8
  10. package/dist/public/assets/Workspace-BzML0R8G.js +7 -0
  11. package/dist/public/assets/{buffer-store-BtbOQmBV.js → buffer-store-BUxk5YP-.js} +2 -2
  12. package/dist/public/assets/{context-menu-CRGhVWNL.js → context-menu-BW-kh-7_.js} +1 -1
  13. package/dist/public/assets/{cssMode-2WvXXY_J.js → cssMode-BwI2t1Xb.js} +1 -1
  14. package/dist/public/assets/{editor-sync-Txn-MU67.js → editor-sync-BQ7kr55o.js} +1 -1
  15. package/dist/public/assets/{htmlMode-DeJruPWa.js → htmlMode-DMBt4SND.js} +1 -1
  16. package/dist/public/assets/{index-DKJ3ig-N.css → index-CqjHKPtJ.css} +1 -1
  17. package/dist/public/assets/{index-Dbb7Hj-9.js → index-o0lu1P9z.js} +3 -3
  18. package/dist/public/assets/{jsonMode-ZKJU4Mw_.js → jsonMode-D5lVqFv_.js} +1 -1
  19. package/dist/public/assets/{session-seed-ClEQb2Ng.js → session-seed-Bk937CpU.js} +1 -1
  20. package/dist/public/assets/ssh-mode-Q0zAbzxn.js +1 -0
  21. package/dist/public/assets/{tsMode-CVaYLhfo.js → tsMode-C4iOvDaN.js} +1 -1
  22. package/dist/public/index.html +3 -3
  23. package/package.json +1 -1
  24. package/dist/public/assets/Workspace-BAC-rV10.js +0 -7
  25. package/dist/public/assets/ssh-mode-E_uFg4sY.js +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{_ as r,a as i,d as a,h as o,i as s,n as c,t as l}from"./hotkeys-qOqg9LFd.js";import{S as u,_ as d,f,g as p,h as m,m as h,p as g}from"./api-BJeOJuGe.js";import{a as _,g as v,i as y,n as b,o as x,r as S,t as C}from"./dialog-B43iKmfK.js";import{C as w,E as T,H as E,I as D,K as O,M as ee,P as k,R as te,V as ne,W as re,Y as ie,_ as ae,ct as A,et as oe,f as se,i as j,j as ce,k as le,lt as M,o as ue,p as de,q as N,r as fe,st as pe,tt as me,v as he,z as ge}from"./LazyTerminal-BByZdzv2.js";import{t as P}from"./utils-B6KiDbIe.js";import{t as F}from"./createLucideIcon-DyMAgLa3.js";import{a as I,i as L,n as R,o as z,r as B,s as _e,t as ve}from"./session-seed-ClEQb2Ng.js";import{r as ye}from"./dist-i-QevsUb.js";import{$ as be,B as V,Ct as xe,G as Se,H as Ce,It as we,J as H,K as Te,L as U,Mt as Ee,Q as De,St as Oe,U as ke,V as Ae,W as je,Y as W,Z as Me,_t as Ne,at as Pe,dt as Fe,et as Ie,gt as Le,ht as Re,lt as ze,mt as Be,nt as Ve,q as He,r as Ue,ut as We,vt as Ge,wt as Ke,xt as qe}from"./index-Dbb7Hj-9.js";var Je=F(`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`}]]),Ye=F(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Xe=F(`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`}]]),Ze=F(`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`}]]),Qe=F(`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`}]]),$e=F(`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`}]]),et=F(`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`}]]),tt=F(`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`}]]),G=e(t(),1),K=n();function q({id:e,value:t,min:n,max:r,step:i,className:a,onCommit:o}){let[s,c]=(0,G.useState)(String(t));return(0,G.useEffect)(()=>c(String(t)),[t]),(0,K.jsx)(A,{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 J({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,K.jsxs)(`div`,{className:P(`flex items-center gap-4 py-2.5`,a),children:[(0,K.jsxs)(`label`,{htmlFor:r,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,K.jsx)(`span`,{className:P(`text-xs text-fg-muted`,n),children:t})]}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function Y({children:e,note:t}){return(0,K.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function nt(){let e=W(),[t,n]=(0,G.useState)(we());return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Appearance`}),(0,K.jsx)(J,{label:`Theme`,children:(0,K.jsxs)(R,{value:t,onValueChange:e=>{n(e),Ee(e)},children:[(0,K.jsx)(I,{className:`w-32`,children:(0,K.jsx)(z,{})}),(0,K.jsxs)(B,{children:[(0,K.jsx)(L,{value:`dark`,children:`Dark`}),(0,K.jsx)(L,{value:`light`,children:`Light`}),(0,K.jsx)(L,{value:`system`,children:`System`})]})]})}),(0,K.jsx)(J,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,K.jsx)(q,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>H({uiFontSize:e})})}),(0,K.jsx)(J,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,K.jsx)(q,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>H({terminalFontSize:e})})}),(0,K.jsx)(J,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,K.jsx)(q,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>H({editorFontSize:e})})}),(0,K.jsx)(J,{label:`Density`,children:(0,K.jsxs)(R,{value:e.density,onValueChange:e=>H({density:e}),children:[(0,K.jsx)(I,{className:`w-36`,children:(0,K.jsx)(z,{})}),(0,K.jsxs)(B,{children:[(0,K.jsx)(L,{value:`compact`,children:`Compact`}),(0,K.jsx)(L,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,K.jsx)(J,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,K.jsx)(U,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>H({projectBasedLayout:e})})}),(0,K.jsx)(J,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,K.jsx)(U,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>H({showAllProjectSessions:e})})})]})}function rt({profile:e}){let t=ne(),[n,r]=(0,G.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>j(e)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>j(e)});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(J,{label:`Icon`,children:(0,K.jsxs)(De,{open:n,onOpenChange:r,children:[(0,K.jsx)(Ie,{asChild:!0,children:(0,K.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,K.jsx)(Be,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,K.jsx)(be,{align:`end`,className:`w-72`,children:(0,K.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,K.jsx)(`button`,{type:`button`,title:`Default`,onClick:()=>i(null),className:P(`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,K.jsx)(Be,{icon:null,colour:null,className:`size-4`})}),Le.map(({name:t,Icon:n})=>(0,K.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:P(`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,K.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,K.jsx)(J,{label:`Icon colour`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,K.jsxs)(`button`,{type:`button`,title:`Default`,onClick:()=>a(null),className:P(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,!e.icon_colour&&`bg-elevated`),children:[(0,K.jsx)(`span`,{className:`size-3.5 rounded-full bg-fg-muted`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Default colour`})]}),p.map(t=>(0,K.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:P(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,e.icon_colour===t&&`bg-elevated`),children:[(0,K.jsx)(`span`,{className:P(`size-3.5 rounded-full bg-current`,Re(t))}),(0,K.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var X=`__none__`;function it(){let e=r(),t=N().data?.find(t=>t.id===e),n=se(e??void 0),i=O(e??void 0),a=ne(),s=E(e??``),c=le(),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(``);if((0,G.useEffect)(()=>{t&&(u(t.name),f(t.branch_prefix))},[t]),!t)return null;let w=i.data?.default_account_id;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Profile`}),(0,K.jsxs)(J,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,K.jsx)(A,{id:`profile-name`,value:l,onChange:e=>u(e.target.value),className:`w-44`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:l===t.name||l.trim()===``||a.isPending,onClick:()=>a.mutate({id:t.id,name:l},{onError:e=>j(e)}),children:`Save`})]}),(0,K.jsxs)(J,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,K.jsx)(A,{id:`branch-prefix`,value:d,onChange:e=>f(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:d===t.branch_prefix||a.isPending,onClick:()=>a.mutate({id:t.id,branch_prefix:d},{onError:e=>j(e)}),children:`Save`})]}),(0,K.jsx)(rt,{profile:t}),(0,K.jsx)(J,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,K.jsxs)(R,{value:typeof w==`number`?String(w):X,onValueChange:e=>s.mutate({default_account_id:e===X?null:Number(e)},{onError:e=>j(e)}),children:[(0,K.jsx)(I,{className:`w-56`,children:(0,K.jsx)(z,{})}),(0,K.jsxs)(B,{children:[(0,K.jsx)(L,{value:X,children:`First available`}),n.data?.map(e=>(0,K.jsx)(L,{value:String(e.id),children:(0,K.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,K.jsx)(J,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,K.jsx)(v,{variant:`danger`,size:`sm`,onClick:()=>m(!0),children:`Delete…`})}),(0,K.jsx)(C,{open:p,onOpenChange:e=>{e||(m(!1),g(``))},children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Delete profile `,(0,K.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,K.jsx)(S,{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,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(pe,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,K.jsx)(A,{id:`delete-confirm-name`,value:h,onChange:e=>g(e.target.value),autoFocus:!0})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>{m(!1),g(``)},children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:h!==t.name||c.isPending,onClick:()=>c.mutate(t.id,{onSuccess:()=>{ze(),o.set(null)},onError:e=>{m(!1),g(``),j(e)}}),children:`Delete profile`})]})]})})]})}function at({agent:e,profileId:t,onClose:n,onCreated:r}){let i=he(),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(``),l=ce(Pe(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=>j(e)})};return(0,K.jsx)(C,{open:!0,onOpenChange:e=>!e&&n(),children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Add a `,e.display_name,` account`]}),(0,K.jsxs)(S,{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,K.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,K.jsx)(A,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,K.jsx)(fe,{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,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,K.jsxs)(v,{disabled:!f||i.isPending,onClick:p,children:[(0,K.jsx)(Oe,{}),`Add account`]})]})]})})}function ot({account:e,gateOpen:t,installed:n}){let r=D(),i=te(),a=T(),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(e.label);return(0,G.useEffect)(()=>d(e.label),[e.label]),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`input`,{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=>{j(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 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,K.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,K.jsx)(U,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>j(e)})})]}),(0,K.jsxs)(v,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>j(e)}),children:[(0,K.jsx)(Ke,{}),e.logged_in?`Re-login`:`Login`]}),(0,K.jsxs)(v,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,K.jsx)(Ge,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,K.jsx)(Me,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,K.jsx)(C,{open:c,onOpenChange:l,children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Delete `,(0,K.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,K.jsx)(S,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),j(e)}}),children:`Delete account`})]})]})})]})}function st(){let e=r(),t=de(),n=se(e??void 0),i=O(e??void 0),a=D(),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),d=i.data?.allowSkipPermissions===!0;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[],r=e.available!==!1;return(0,K.jsxs)(`div`,{className:`mb-5`,children:[(0,K.jsx)(J,{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,K.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.id})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,K.jsx)(ot,{account:t,gateOpen:d&&e.capabilities.skip_permissions,installed:r},t.id)),(0,K.jsx)(`div`,{className:`flex`,children:(0,K.jsxs)(v,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>l(e),children:[(0,K.jsx)(Oe,{}),`Add account`]})})]})]},e.id)}),o&&(0,K.jsx)(Me,{stream:o.stream,label:o.label,hint:o.hint,onClose:()=>s(null)}),c!==null&&e!==null&&(0,K.jsx)(at,{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}a.mutate(e.id,{onSuccess:t=>s({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>j(e)})}})]})}function ct(){let e=ae(),t=ge(),[n,r]=(0,G.useState)(``);return(0,G.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,K.jsx)(J,{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,K.jsx)(A,{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 lt({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=ve(e,n),o=n.sessionDefaults??{},[s,c]=(0,G.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,K.jsx)(J,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,K.jsx)(A,{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,K.jsx)(J,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,K.jsx)(U,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,K.jsx)(J,{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,K.jsx)(U,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function ut(){return(0,K.jsx)(J,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,K.jsx)(q,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:W().terminalScrollback,onCommit:e=>H({terminalScrollback:e})})})}function dt({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,G.useState)(r);return(0,K.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,K.jsx)(M,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,K.jsx)(v,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var ft={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 pt({initial:e,onSave:t,pending:n}){let[r,i]=(0,G.useState)(e),a=r.length>0?r:m;return(0,K.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,K.jsx)(A,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:m}),(0,K.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,K.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:Ve(ft,a)})]}),(0,K.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:d.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,K.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,K.jsx)(v,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(m),t(m)},children:`Reset to default`})]})]})}function mt(){let e=r(),t=N().data?.find(t=>t.id===e),n=O(e??void 0),i=E(e??``),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),l=n.data?.allowSkipPermissions===!0,u=e=>i.mutate({allowSkipPermissions:e},{onSuccess:()=>{o(!1),c(``)},onError:e=>j(e)}),d=e=>t=>i.mutate({[e]:t},{onError:e=>j(e)});return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Sessions`}),(0,K.jsx)(J,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,K.jsx)(U,{id:`gate`,checked:l,onCheckedChange:e=>{e?o(!0):u(!1)}})}),(0,K.jsx)(J,{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,K.jsx)(U,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:i.isPending,onCheckedChange:e=>i.mutate({captureSessionEnv:e},{onError:e=>j(e)})})}),(0,K.jsx)(ct,{}),(0,K.jsx)(ut,{}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{children:`New session defaults`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(lt,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>i.mutate({sessionDefaults:e},{onError:e=>j(e)}),pending:i.isPending},`${e}:agent-seed`),(0,K.jsx)(lt,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>i.mutate({sessionDefaults:e},{onError:e=>j(e)}),pending:i.isPending},`${e}:terminal-seed`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{note:`Sent to agent as opening message when a session (re)starts. You can make this empty.`,children:`Launch text`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(dt,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??g,defaultText:g,onSave:d(`onboardingTemplate`),pending:i.isPending},`${e}:onboarding`),(0,K.jsx)(dt,{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??f,defaultText:f,onSave:d(`concurrentTemplate`),pending:i.isPending},`${e}:concurrent`),(0,K.jsx)(dt,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??h,defaultText:h,onSave:d(`restartTemplate`),pending:i.isPending},`${e}:restart`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{children:`Tab title`}),n.data&&(0,K.jsx)(pt,{initial:n.data.tabTitleTemplate||"${name}",onSave:d(`tabTitleTemplate`),pending:i.isPending},`${e}:tab-title`)]}),(0,K.jsx)(C,{open:a,onOpenChange:e=>{e||(o(!1),c(``))},children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{className:`flex items-center gap-2`,children:[(0,K.jsx)($e,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,K.jsx)(S,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,K.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,K.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,K.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,K.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,K.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,K.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,K.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,K.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,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(pe,{htmlFor:`confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,K.jsx)(A,{id:`confirm-name`,value:s,onChange:e=>c(e.target.value),autoFocus:!0})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>{o(!1),c(``)},children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:s!==t?.name||i.isPending,onClick:()=>u(!0),children:`Open the gate`})]})]})})]})}var ht={desktop:!0,sound:!1,muted_projects:[]};function gt(){let[e,t]=(0,G.useState)(V);return(0,G.useEffect)(()=>{let e=()=>t(V());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(V())]}function _t({permission:e,onRequest:t}){return e===`granted`?null:(0,K.jsxs)(`p`,{className:`pb-2 text-xs text-warning`,children:[e==="default"&&(0,K.jsxs)(K.Fragment,{children:[`The browser has not been asked for permission yet, so nothing will show —`,` `,(0,K.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 vt(){let e=r(),t=O(e??void 0),n=E(e??``),i=ie(e??void 0),[a,o]=gt(),s={...ht,...t.data?.notifications??{}},c=e=>n.mutate({notifications:e},{onError:e=>j(e)}),l=()=>{typeof Notification>`u`||Notification.requestPermission().then(o)};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Notifications`}),(0,K.jsx)(J,{label:`Desktop notification on waiting`,htmlFor:`notify-desktop`,children:(0,K.jsx)(U,{id:`notify-desktop`,checked:s.desktop,onCheckedChange:e=>{e&&l(),c({...s,desktop:e})}})}),s.desktop&&(0,K.jsx)(_t,{permission:a,onRequest:l}),(0,K.jsx)(J,{label:`Sound`,htmlFor:`notify-sound`,children:(0,K.jsx)(U,{id:`notify-sound`,checked:s.sound,onCheckedChange:e=>c({...s,sound:e})})}),(0,K.jsx)(J,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,K.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[s.muted_projects.length,` muted`]})}),(0,K.jsx)(`div`,{className:`flex flex-col gap-1`,children:i.data?.map(e=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,K.jsx)(U,{checked:s.muted_projects.includes(e.id),onCheckedChange:t=>c({...s,muted_projects:t?[...s.muted_projects,e.id]:s.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function yt(){let e=W();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Editor`}),(0,K.jsx)(J,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,K.jsx)(q,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>H({editorTabSize:e})})}),(0,K.jsx)(J,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,K.jsx)(U,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>H({editorWordWrap:e})})}),(0,K.jsx)(J,{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,K.jsx)(A,{id:`editor-link-host`,type:`text`,placeholder:Ue.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>H({editorLinkSshHost:e.target.value})})})]})}function bt({value:e,isDefault:t,onRecord:n,onReset:r}){let[a,o]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.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=s(e.nativeEvent);t&&(n(t),o(!1))},className:P(`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…`:i(e)}),!t&&(0,K.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,K.jsx)(Ze,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function xt(){let e=r(),t=O(e??void 0),n=E(e??``),i=t.data?.hotkeys??{},o=(e,t)=>i[e]||t,s=new Map;for(let e of l){let t=o(e.id,a(e));s.set(t,(s.get(t)??0)+1)}let u=(e,t)=>n.mutate({hotkeys:{...i,[e]:t}},{onError:e=>j(e)}),d=e=>{let t={...i};delete t[e],n.mutate({hotkeys:t},{onError:e=>j(e)})};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Hotkeys`}),(0,K.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),c.map(e=>{let t=l.filter(t=>t.group===e);return t.length===0?null:(0,K.jsxs)(`div`,{className:`mb-5`,children:[(0,K.jsx)(`div`,{className:`mb-1 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e}),t.map(e=>{let t=o(e.id,a(e)),n=(s.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,K.jsx)(J,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,K.jsx)(bt,{value:t,isDefault:!i[e.id],onRecord:t=>u(e.id,t),onReset:()=>d(e.id)})},e.id)})]},e)})]})}var St=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Z=65,Q=Object.fromEntries([...St].map((e,t)=>[e,t])),Ct=`H`,wt=(()=>{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 Tt(e){let t=4294967295;for(let n of e)t=wt[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function Et(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function Dt(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 Ot(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function kt(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function At(e,t){let n=(t%Z+Z)%Z,r=``;for(let t of e){let e=Q[t];r+=e===void 0?t:St[(e+n)%Z]}return r}async function jt(e){let t=await Ot(JSON.stringify(e));return At(Et(t)+Tt(t),1+Math.floor(Math.random()*(Z-1)))}async function Mt(e){let t=e.trim(),n=t[0];if(!n||Q[n]===void 0)throw Error(`Not a settings export.`);let r=At(t,-((Q[n]-Q[Ct]+Z)%Z));if(r.length<9||r[0]!==Ct)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=Dt(i);if(Tt(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await kt(o))}var Nt=`puddle.sync-selection`;function Pt(){try{let e=JSON.parse(localStorage.getItem(Nt)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return je.map(e=>e.id)}function Ft({selected:e,onToggle:t}){return(0,K.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:je.map(n=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(U,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function It(){let e=r(),t=O(e??void 0),n=N().data?.find(t=>t.id===e),i=me(e??void 0,void 0),a=E(e??``),o=ne(),s=w(),c=Ce(),l=ke(),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(!1),[_,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(Pt),S=n&&c.data?Ae(c.data.file,n.name):void 0,C=S?.enabled===!0,T=C&&S?S.groups:b,D=()=>({client:He(),theme:we(),profileSettings:t.data??{},profile:n??{},scratchpad:i.data??[]}),ee={setClient:e=>H(e),setTheme:e=>{typeof e==`string`&&Ee(e)},patchProfileSettings:e=>a.mutate(e,{onError:e=>j(e)}),patchProfileColumns:t=>{e&&o.mutate({id:e,...t},{onError:e=>j(e)})},createScratchpad:t=>{if(e)for(let n of t)s.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},k=(e,t)=>{n&&l.mutate({profile:n.name,entry:{enabled:e.enabled??C,groups:t,doc:Te(t,D()),updatedAt:new Date().toISOString()}},{onError:e=>j(e)})},te=(e,t)=>{let n=t?[...T,e]:T.filter(t=>t!==e);x(n),localStorage.setItem(Nt,JSON.stringify(n)),C&&k({},n)},re=async()=>{y(!0);try{let e=Se(await Mt(d.trim()),ee,{profileSettings:t.data??{},scratchpad:i.data??[]});e.length===0?u.error(`Nothing recognised to import.`):(u.success(`Imported ${e.join(`, `)}.`),f(``))}catch(e){u.error(e.message)}finally{y(!1)}},ie=async()=>{y(!0);try{let e=await jt(Te(T,D()));m(e),await navigator.clipboard?.writeText(e),u.success(`Copied to clipboard`)}finally{y(!1)}};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Sync`}),(0,K.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,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),c.data?.available===!1?(0,K.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,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Sync selected groups through this machine’s`,` `,(0,K.jsx)(`span`,{className:`text-fg-secondary`,children:`~/.puddle`}),`, so every Puddle window stays in step for profiles named`,` `,(0,K.jsx)(`span`,{className:`text-fg-secondary`,children:n?.name??`…`}),`.`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(U,{checked:C,disabled:!n||c.isLoading||l.isPending,onCheckedChange:e=>k({enabled:e},T)}),`Sync locally`]})]})]}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.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,K.jsx)(_e,{className:`size-3.5`}):(0,K.jsx)(ye,{className:`size-3.5`}),`Choose what to sync`]}),h&&(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(Ft,{selected:T,onToggle:te})})]}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,K.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,K.jsx)(v,{size:`sm`,disabled:_,onClick:()=>void ie(),children:`Export & copy`}),p&&(0,K.jsx)(M,{readOnly:!0,value:p,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`mt-2 resize-y font-mono text-xs`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,K.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste a Puddle magic string to import its settings.`}),(0,K.jsx)(M,{value:d,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,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(v,{size:`sm`,disabled:!d.trim()||_,onClick:()=>void re(),children:`Import`})})]})]})}function Lt({repo:e}){let t=re(),n=ee(),[r,i]=(0,G.useState)(e.default_base_branch),[a,o]=(0,G.useState)(e.onboarding_notes??``),s=e=>j(e);return(0,K.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.path}),(0,K.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,K.jsxs)(v,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>u.success(`Fetched.`),onError:s}),children:[(0,K.jsx)(qe,{}),`Fetch now`]})]}),(0,K.jsxs)(J,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,K.jsx)(A,{id:`base-${e.id}`,value:r,onChange:e=>i(e.target.value),className:`w-40`}),(0,K.jsx)(v,{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,K.jsx)(J,{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,K.jsx)(U,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:s})})}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,K.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,K.jsx)(M,{id:`notes-${e.id}`,value:a,onChange:e=>o(e.target.value),rows:4}),(0,K.jsx)(`div`,{children:(0,K.jsx)(v,{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,K.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,K.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,K.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,K.jsx)(`li`,{className:`truncate text-2xs text-fg-muted`,children:e},e))})]})]})}function Rt(){let e=oe();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Projects`}),e.data?.length===0&&(0,K.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,K.jsx)(Lt,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=ge();return(0,K.jsx)(J,{label:e,description:t,htmlFor:`host-${n}`,children:(0,K.jsx)(A,{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=>j(e)})}})})}function zt(){let e=ae(),t=ge(),n=k();return e.data?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{note:`Affects all profiles on this host`,children:`Host`}),(0,K.jsx)(J,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,K.jsx)(A,{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=>j(e)})}})}),(0,K.jsx)($,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,K.jsx)($,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,K.jsx)($,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,K.jsx)($,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,K.jsx)(J,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,K.jsx)(U,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>j(e)})})})]}):null}var Bt=[{id:`appearance`,label:`Appearance`,icon:xe,render:()=>(0,K.jsx)(nt,{})},{id:`profile`,label:`Profile`,icon:Ne,render:()=>(0,K.jsx)(it,{})},{id:`accounts`,label:`Accounts`,icon:tt,render:()=>(0,K.jsx)(st,{})},{id:`sessions`,label:`Sessions`,icon:et,render:()=>(0,K.jsx)(mt,{})},{id:`editor`,label:`Editor`,icon:Ye,render:()=>(0,K.jsx)(yt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Xe,render:()=>(0,K.jsx)(xt,{})},{id:`notifications`,label:`Notifications`,icon:Je,render:()=>(0,K.jsx)(vt,{})},{id:`projects`,label:`Projects`,icon:ue,render:()=>(0,K.jsx)(Rt,{})},{id:`host`,label:`Host`,icon:Qe,render:()=>(0,K.jsx)(zt,{})},{id:`sync`,label:`Sync`,icon:qe,render:()=>(0,K.jsx)(It,{})}],Vt={terminal:`sessions`,repositories:`projects`};function Ht(){let e=Fe(),t=e===null?null:Vt[e]??e,n=Bt.find(e=>e.id===t)??Bt[0];return(0,K.jsx)(C,{open:e!==null,onOpenChange:e=>!e&&ze(),children:(0,K.jsxs)(b,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,K.jsx)(x,{className:`sr-only`,children:`Settings`}),(0,K.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,K.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),Bt.map(({id:e,label:t,icon:r})=>(0,K.jsxs)(`button`,{onClick:()=>We(e),className:P(`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,K.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]}),(0,K.jsx)(`div`,{className:`overflow-y-auto p-5`,children:n.render()})]})})}export{Ht as SettingsDialog};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{_ as r,a as i,d as a,h as o,i as s,n as c,t as l}from"./hotkeys-qOqg9LFd.js";import{S as u,_ as d,f,g as p,h as m,m as h,p as g}from"./api-BJeOJuGe.js";import{a as _,g as v,i as y,n as b,o as x,r as S,t as C}from"./dialog-B43iKmfK.js";import{C as w,E as T,H as E,I as D,K as O,M as ee,P as k,R as te,V as ne,W as re,Y as ie,_ as ae,ct as A,et as oe,f as se,i as j,j as ce,k as le,lt as M,o as ue,p as de,q as N,r as fe,st as pe,tt as me,v as he,z as ge}from"./LazyTerminal-BNKlV3ik.js";import{t as P}from"./utils-B6KiDbIe.js";import{t as F}from"./createLucideIcon-DyMAgLa3.js";import{a as I,i as L,n as R,o as z,r as B,s as _e,t as ve}from"./session-seed-Bk937CpU.js";import{r as ye}from"./dist-i-QevsUb.js";import{$ as be,B as V,Ct as xe,G as Se,H as Ce,It as we,J as H,K as Te,L as U,Mt as Ee,Q as De,St as Oe,U as ke,V as Ae,W as je,Y as W,Z as Me,_t as Ne,at as Pe,dt as Fe,et as Ie,gt as Le,ht as Re,lt as ze,mt as Be,nt as Ve,q as He,r as Ue,ut as We,vt as Ge,wt as Ke,xt as qe}from"./index-o0lu1P9z.js";var Je=F(`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`}]]),Ye=F(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Xe=F(`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`}]]),Ze=F(`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`}]]),Qe=F(`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`}]]),$e=F(`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`}]]),et=F(`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`}]]),tt=F(`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`}]]),G=e(t(),1),K=n();function q({id:e,value:t,min:n,max:r,step:i,className:a,onCommit:o}){let[s,c]=(0,G.useState)(String(t));return(0,G.useEffect)(()=>c(String(t)),[t]),(0,K.jsx)(A,{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 J({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,K.jsxs)(`div`,{className:P(`flex items-center gap-4 py-2.5`,a),children:[(0,K.jsxs)(`label`,{htmlFor:r,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,K.jsx)(`span`,{className:P(`text-xs text-fg-muted`,n),children:t})]}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function Y({children:e,note:t}){return(0,K.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function nt(){let e=W(),[t,n]=(0,G.useState)(we());return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Appearance`}),(0,K.jsx)(J,{label:`Theme`,children:(0,K.jsxs)(R,{value:t,onValueChange:e=>{n(e),Ee(e)},children:[(0,K.jsx)(I,{className:`w-32`,children:(0,K.jsx)(z,{})}),(0,K.jsxs)(B,{children:[(0,K.jsx)(L,{value:`dark`,children:`Dark`}),(0,K.jsx)(L,{value:`light`,children:`Light`}),(0,K.jsx)(L,{value:`system`,children:`System`})]})]})}),(0,K.jsx)(J,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,K.jsx)(q,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>H({uiFontSize:e})})}),(0,K.jsx)(J,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,K.jsx)(q,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>H({terminalFontSize:e})})}),(0,K.jsx)(J,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,K.jsx)(q,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>H({editorFontSize:e})})}),(0,K.jsx)(J,{label:`Density`,children:(0,K.jsxs)(R,{value:e.density,onValueChange:e=>H({density:e}),children:[(0,K.jsx)(I,{className:`w-36`,children:(0,K.jsx)(z,{})}),(0,K.jsxs)(B,{children:[(0,K.jsx)(L,{value:`compact`,children:`Compact`}),(0,K.jsx)(L,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,K.jsx)(J,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,K.jsx)(U,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>H({projectBasedLayout:e})})}),(0,K.jsx)(J,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,K.jsx)(U,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>H({showAllProjectSessions:e})})})]})}function rt({profile:e}){let t=ne(),[n,r]=(0,G.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>j(e)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>j(e)});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(J,{label:`Icon`,children:(0,K.jsxs)(De,{open:n,onOpenChange:r,children:[(0,K.jsx)(Ie,{asChild:!0,children:(0,K.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,K.jsx)(Be,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,K.jsx)(be,{align:`end`,className:`w-72`,children:(0,K.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,K.jsx)(`button`,{type:`button`,title:`Default`,onClick:()=>i(null),className:P(`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,K.jsx)(Be,{icon:null,colour:null,className:`size-4`})}),Le.map(({name:t,Icon:n})=>(0,K.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:P(`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,K.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,K.jsx)(J,{label:`Icon colour`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,K.jsxs)(`button`,{type:`button`,title:`Default`,onClick:()=>a(null),className:P(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,!e.icon_colour&&`bg-elevated`),children:[(0,K.jsx)(`span`,{className:`size-3.5 rounded-full bg-fg-muted`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Default colour`})]}),p.map(t=>(0,K.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:P(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,e.icon_colour===t&&`bg-elevated`),children:[(0,K.jsx)(`span`,{className:P(`size-3.5 rounded-full bg-current`,Re(t))}),(0,K.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var X=`__none__`;function it(){let e=r(),t=N().data?.find(t=>t.id===e),n=se(e??void 0),i=O(e??void 0),a=ne(),s=E(e??``),c=le(),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(``);if((0,G.useEffect)(()=>{t&&(u(t.name),f(t.branch_prefix))},[t]),!t)return null;let w=i.data?.default_account_id;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Profile`}),(0,K.jsxs)(J,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,K.jsx)(A,{id:`profile-name`,value:l,onChange:e=>u(e.target.value),className:`w-44`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:l===t.name||l.trim()===``||a.isPending,onClick:()=>a.mutate({id:t.id,name:l},{onError:e=>j(e)}),children:`Save`})]}),(0,K.jsxs)(J,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,K.jsx)(A,{id:`branch-prefix`,value:d,onChange:e=>f(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:d===t.branch_prefix||a.isPending,onClick:()=>a.mutate({id:t.id,branch_prefix:d},{onError:e=>j(e)}),children:`Save`})]}),(0,K.jsx)(rt,{profile:t}),(0,K.jsx)(J,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,K.jsxs)(R,{value:typeof w==`number`?String(w):X,onValueChange:e=>s.mutate({default_account_id:e===X?null:Number(e)},{onError:e=>j(e)}),children:[(0,K.jsx)(I,{className:`w-56`,children:(0,K.jsx)(z,{})}),(0,K.jsxs)(B,{children:[(0,K.jsx)(L,{value:X,children:`First available`}),n.data?.map(e=>(0,K.jsx)(L,{value:String(e.id),children:(0,K.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,K.jsx)(J,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,K.jsx)(v,{variant:`danger`,size:`sm`,onClick:()=>m(!0),children:`Delete…`})}),(0,K.jsx)(C,{open:p,onOpenChange:e=>{e||(m(!1),g(``))},children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Delete profile `,(0,K.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,K.jsx)(S,{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,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(pe,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,K.jsx)(A,{id:`delete-confirm-name`,value:h,onChange:e=>g(e.target.value),autoFocus:!0})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>{m(!1),g(``)},children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:h!==t.name||c.isPending,onClick:()=>c.mutate(t.id,{onSuccess:()=>{ze(),o.set(null)},onError:e=>{m(!1),g(``),j(e)}}),children:`Delete profile`})]})]})})]})}function at({agent:e,profileId:t,onClose:n,onCreated:r}){let i=he(),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(``),l=ce(Pe(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=>j(e)})};return(0,K.jsx)(C,{open:!0,onOpenChange:e=>!e&&n(),children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Add a `,e.display_name,` account`]}),(0,K.jsxs)(S,{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,K.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,K.jsx)(A,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,K.jsx)(fe,{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,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,K.jsxs)(v,{disabled:!f||i.isPending,onClick:p,children:[(0,K.jsx)(Oe,{}),`Add account`]})]})]})})}function ot({account:e,gateOpen:t,installed:n}){let r=D(),i=te(),a=T(),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(e.label);return(0,G.useEffect)(()=>d(e.label),[e.label]),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`input`,{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=>{j(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 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,K.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,K.jsx)(U,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>j(e)})})]}),(0,K.jsxs)(v,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>j(e)}),children:[(0,K.jsx)(Ke,{}),e.logged_in?`Re-login`:`Login`]}),(0,K.jsxs)(v,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,K.jsx)(Ge,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,K.jsx)(Me,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,K.jsx)(C,{open:c,onOpenChange:l,children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Delete `,(0,K.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,K.jsx)(S,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),j(e)}}),children:`Delete account`})]})]})})]})}function st(){let e=r(),t=de(),n=se(e??void 0),i=O(e??void 0),a=D(),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),d=i.data?.allowSkipPermissions===!0;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[],r=e.available!==!1;return(0,K.jsxs)(`div`,{className:`mb-5`,children:[(0,K.jsx)(J,{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,K.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.id})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,K.jsx)(ot,{account:t,gateOpen:d&&e.capabilities.skip_permissions,installed:r},t.id)),(0,K.jsx)(`div`,{className:`flex`,children:(0,K.jsxs)(v,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>l(e),children:[(0,K.jsx)(Oe,{}),`Add account`]})})]})]},e.id)}),o&&(0,K.jsx)(Me,{stream:o.stream,label:o.label,hint:o.hint,onClose:()=>s(null)}),c!==null&&e!==null&&(0,K.jsx)(at,{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}a.mutate(e.id,{onSuccess:t=>s({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>j(e)})}})]})}function ct(){let e=ae(),t=ge(),[n,r]=(0,G.useState)(``);return(0,G.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,K.jsx)(J,{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,K.jsx)(A,{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 lt({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=ve(e,n),o=n.sessionDefaults??{},[s,c]=(0,G.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,K.jsx)(J,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,K.jsx)(A,{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,K.jsx)(J,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,K.jsx)(U,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,K.jsx)(J,{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,K.jsx)(U,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function ut(){return(0,K.jsx)(J,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,K.jsx)(q,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:W().terminalScrollback,onCommit:e=>H({terminalScrollback:e})})})}function dt({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,G.useState)(r);return(0,K.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,K.jsx)(M,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,K.jsx)(v,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var ft={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 pt({initial:e,onSave:t,pending:n}){let[r,i]=(0,G.useState)(e),a=r.length>0?r:m;return(0,K.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,K.jsx)(A,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:m}),(0,K.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,K.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:Ve(ft,a)})]}),(0,K.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:d.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,K.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,K.jsx)(v,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(m),t(m)},children:`Reset to default`})]})]})}function mt(){let e=r(),t=N().data?.find(t=>t.id===e),n=O(e??void 0),i=E(e??``),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),l=n.data?.allowSkipPermissions===!0,u=e=>i.mutate({allowSkipPermissions:e},{onSuccess:()=>{o(!1),c(``)},onError:e=>j(e)}),d=e=>t=>i.mutate({[e]:t},{onError:e=>j(e)});return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Sessions`}),(0,K.jsx)(J,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,K.jsx)(U,{id:`gate`,checked:l,onCheckedChange:e=>{e?o(!0):u(!1)}})}),(0,K.jsx)(J,{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,K.jsx)(U,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:i.isPending,onCheckedChange:e=>i.mutate({captureSessionEnv:e},{onError:e=>j(e)})})}),(0,K.jsx)(ct,{}),(0,K.jsx)(ut,{}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{children:`New session defaults`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(lt,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>i.mutate({sessionDefaults:e},{onError:e=>j(e)}),pending:i.isPending},`${e}:agent-seed`),(0,K.jsx)(lt,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>i.mutate({sessionDefaults:e},{onError:e=>j(e)}),pending:i.isPending},`${e}:terminal-seed`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{note:`Sent to agent as opening message when a session (re)starts. You can make this empty.`,children:`Launch text`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(dt,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??g,defaultText:g,onSave:d(`onboardingTemplate`),pending:i.isPending},`${e}:onboarding`),(0,K.jsx)(dt,{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??f,defaultText:f,onSave:d(`concurrentTemplate`),pending:i.isPending},`${e}:concurrent`),(0,K.jsx)(dt,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??h,defaultText:h,onSave:d(`restartTemplate`),pending:i.isPending},`${e}:restart`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{children:`Tab title`}),n.data&&(0,K.jsx)(pt,{initial:n.data.tabTitleTemplate||"${name}",onSave:d(`tabTitleTemplate`),pending:i.isPending},`${e}:tab-title`)]}),(0,K.jsx)(C,{open:a,onOpenChange:e=>{e||(o(!1),c(``))},children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{className:`flex items-center gap-2`,children:[(0,K.jsx)($e,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,K.jsx)(S,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,K.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,K.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,K.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,K.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,K.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,K.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,K.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,K.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,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(pe,{htmlFor:`confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,K.jsx)(A,{id:`confirm-name`,value:s,onChange:e=>c(e.target.value),autoFocus:!0})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>{o(!1),c(``)},children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:s!==t?.name||i.isPending,onClick:()=>u(!0),children:`Open the gate`})]})]})})]})}var ht={desktop:!0,sound:!1,muted_projects:[]};function gt(){let[e,t]=(0,G.useState)(V);return(0,G.useEffect)(()=>{let e=()=>t(V());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(V())]}function _t({permission:e,onRequest:t}){return e===`granted`?null:(0,K.jsxs)(`p`,{className:`pb-2 text-xs text-warning`,children:[e==="default"&&(0,K.jsxs)(K.Fragment,{children:[`The browser has not been asked for permission yet, so nothing will show —`,` `,(0,K.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 vt(){let e=r(),t=O(e??void 0),n=E(e??``),i=ie(e??void 0),[a,o]=gt(),s={...ht,...t.data?.notifications??{}},c=e=>n.mutate({notifications:e},{onError:e=>j(e)}),l=()=>{typeof Notification>`u`||Notification.requestPermission().then(o)};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Notifications`}),(0,K.jsx)(J,{label:`Desktop notification on waiting`,htmlFor:`notify-desktop`,children:(0,K.jsx)(U,{id:`notify-desktop`,checked:s.desktop,onCheckedChange:e=>{e&&l(),c({...s,desktop:e})}})}),s.desktop&&(0,K.jsx)(_t,{permission:a,onRequest:l}),(0,K.jsx)(J,{label:`Sound`,htmlFor:`notify-sound`,children:(0,K.jsx)(U,{id:`notify-sound`,checked:s.sound,onCheckedChange:e=>c({...s,sound:e})})}),(0,K.jsx)(J,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,K.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[s.muted_projects.length,` muted`]})}),(0,K.jsx)(`div`,{className:`flex flex-col gap-1`,children:i.data?.map(e=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,K.jsx)(U,{checked:s.muted_projects.includes(e.id),onCheckedChange:t=>c({...s,muted_projects:t?[...s.muted_projects,e.id]:s.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function yt(){let e=W();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Editor`}),(0,K.jsx)(J,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,K.jsx)(q,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>H({editorTabSize:e})})}),(0,K.jsx)(J,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,K.jsx)(U,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>H({editorWordWrap:e})})}),(0,K.jsx)(J,{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,K.jsx)(A,{id:`editor-link-host`,type:`text`,placeholder:Ue.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>H({editorLinkSshHost:e.target.value})})})]})}function bt({value:e,isDefault:t,onRecord:n,onReset:r}){let[a,o]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.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=s(e.nativeEvent);t&&(n(t),o(!1))},className:P(`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…`:i(e)}),!t&&(0,K.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,K.jsx)(Ze,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function xt(){let e=r(),t=O(e??void 0),n=E(e??``),i=t.data?.hotkeys??{},o=(e,t)=>i[e]||t,s=new Map;for(let e of l){let t=o(e.id,a(e));s.set(t,(s.get(t)??0)+1)}let u=(e,t)=>n.mutate({hotkeys:{...i,[e]:t}},{onError:e=>j(e)}),d=e=>{let t={...i};delete t[e],n.mutate({hotkeys:t},{onError:e=>j(e)})};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Hotkeys`}),(0,K.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),c.map(e=>{let t=l.filter(t=>t.group===e);return t.length===0?null:(0,K.jsxs)(`div`,{className:`mb-5`,children:[(0,K.jsx)(`div`,{className:`mb-1 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e}),t.map(e=>{let t=o(e.id,a(e)),n=(s.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,K.jsx)(J,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,K.jsx)(bt,{value:t,isDefault:!i[e.id],onRecord:t=>u(e.id,t),onReset:()=>d(e.id)})},e.id)})]},e)})]})}var St=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Z=65,Q=Object.fromEntries([...St].map((e,t)=>[e,t])),Ct=`H`,wt=(()=>{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 Tt(e){let t=4294967295;for(let n of e)t=wt[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function Et(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function Dt(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 Ot(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function kt(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function At(e,t){let n=(t%Z+Z)%Z,r=``;for(let t of e){let e=Q[t];r+=e===void 0?t:St[(e+n)%Z]}return r}async function jt(e){let t=await Ot(JSON.stringify(e));return At(Et(t)+Tt(t),1+Math.floor(Math.random()*(Z-1)))}async function Mt(e){let t=e.trim(),n=t[0];if(!n||Q[n]===void 0)throw Error(`Not a settings export.`);let r=At(t,-((Q[n]-Q[Ct]+Z)%Z));if(r.length<9||r[0]!==Ct)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=Dt(i);if(Tt(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await kt(o))}var Nt=`puddle.sync-selection`;function Pt(){try{let e=JSON.parse(localStorage.getItem(Nt)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return je.map(e=>e.id)}function Ft({selected:e,onToggle:t}){return(0,K.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:je.map(n=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(U,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function It(){let e=r(),t=O(e??void 0),n=N().data?.find(t=>t.id===e),i=me(e??void 0,void 0),a=E(e??``),o=ne(),s=w(),c=Ce(),l=ke(),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(!1),[_,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(Pt),S=n&&c.data?Ae(c.data.file,n.name):void 0,C=S?.enabled===!0,T=C&&S?S.groups:b,D=()=>({client:He(),theme:we(),profileSettings:t.data??{},profile:n??{},scratchpad:i.data??[]}),ee={setClient:e=>H(e),setTheme:e=>{typeof e==`string`&&Ee(e)},patchProfileSettings:e=>a.mutate(e,{onError:e=>j(e)}),patchProfileColumns:t=>{e&&o.mutate({id:e,...t},{onError:e=>j(e)})},createScratchpad:t=>{if(e)for(let n of t)s.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},k=(e,t)=>{n&&l.mutate({profile:n.name,entry:{enabled:e.enabled??C,groups:t,doc:Te(t,D()),updatedAt:new Date().toISOString()}},{onError:e=>j(e)})},te=(e,t)=>{let n=t?[...T,e]:T.filter(t=>t!==e);x(n),localStorage.setItem(Nt,JSON.stringify(n)),C&&k({},n)},re=async()=>{y(!0);try{let e=Se(await Mt(d.trim()),ee,{profileSettings:t.data??{},scratchpad:i.data??[]});e.length===0?u.error(`Nothing recognised to import.`):(u.success(`Imported ${e.join(`, `)}.`),f(``))}catch(e){u.error(e.message)}finally{y(!1)}},ie=async()=>{y(!0);try{let e=await jt(Te(T,D()));m(e),await navigator.clipboard?.writeText(e),u.success(`Copied to clipboard`)}finally{y(!1)}};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Sync`}),(0,K.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,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),c.data?.available===!1?(0,K.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,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Sync selected groups through this machine’s`,` `,(0,K.jsx)(`span`,{className:`text-fg-secondary`,children:`~/.puddle`}),`, so every Puddle window stays in step for profiles named`,` `,(0,K.jsx)(`span`,{className:`text-fg-secondary`,children:n?.name??`…`}),`.`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(U,{checked:C,disabled:!n||c.isLoading||l.isPending,onCheckedChange:e=>k({enabled:e},T)}),`Sync locally`]})]})]}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.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,K.jsx)(_e,{className:`size-3.5`}):(0,K.jsx)(ye,{className:`size-3.5`}),`Choose what to sync`]}),h&&(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(Ft,{selected:T,onToggle:te})})]}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,K.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,K.jsx)(v,{size:`sm`,disabled:_,onClick:()=>void ie(),children:`Export & copy`}),p&&(0,K.jsx)(M,{readOnly:!0,value:p,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`mt-2 resize-y font-mono text-xs`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,K.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste a Puddle magic string to import its settings.`}),(0,K.jsx)(M,{value:d,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,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(v,{size:`sm`,disabled:!d.trim()||_,onClick:()=>void re(),children:`Import`})})]})]})}function Lt({repo:e}){let t=re(),n=ee(),[r,i]=(0,G.useState)(e.default_base_branch),[a,o]=(0,G.useState)(e.onboarding_notes??``),s=e=>j(e);return(0,K.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.path}),(0,K.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,K.jsxs)(v,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>u.success(`Fetched.`),onError:s}),children:[(0,K.jsx)(qe,{}),`Fetch now`]})]}),(0,K.jsxs)(J,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,K.jsx)(A,{id:`base-${e.id}`,value:r,onChange:e=>i(e.target.value),className:`w-40`}),(0,K.jsx)(v,{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,K.jsx)(J,{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,K.jsx)(U,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:s})})}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,K.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,K.jsx)(M,{id:`notes-${e.id}`,value:a,onChange:e=>o(e.target.value),rows:4}),(0,K.jsx)(`div`,{children:(0,K.jsx)(v,{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,K.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,K.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,K.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,K.jsx)(`li`,{className:`truncate text-2xs text-fg-muted`,children:e},e))})]})]})}function Rt(){let e=oe();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Projects`}),e.data?.length===0&&(0,K.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,K.jsx)(Lt,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=ge();return(0,K.jsx)(J,{label:e,description:t,htmlFor:`host-${n}`,children:(0,K.jsx)(A,{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=>j(e)})}})})}function zt(){let e=ae(),t=ge(),n=k();return e.data?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{note:`Affects all profiles on this host`,children:`Host`}),(0,K.jsx)(J,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,K.jsx)(A,{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=>j(e)})}})}),(0,K.jsx)($,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,K.jsx)($,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,K.jsx)($,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,K.jsx)($,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,K.jsx)(J,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,K.jsx)(U,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>j(e)})})})]}):null}var Bt=[{id:`appearance`,label:`Appearance`,icon:xe,render:()=>(0,K.jsx)(nt,{})},{id:`profile`,label:`Profile`,icon:Ne,render:()=>(0,K.jsx)(it,{})},{id:`accounts`,label:`Accounts`,icon:tt,render:()=>(0,K.jsx)(st,{})},{id:`sessions`,label:`Sessions`,icon:et,render:()=>(0,K.jsx)(mt,{})},{id:`editor`,label:`Editor`,icon:Ye,render:()=>(0,K.jsx)(yt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Xe,render:()=>(0,K.jsx)(xt,{})},{id:`notifications`,label:`Notifications`,icon:Je,render:()=>(0,K.jsx)(vt,{})},{id:`projects`,label:`Projects`,icon:ue,render:()=>(0,K.jsx)(Rt,{})},{id:`host`,label:`Host`,icon:Qe,render:()=>(0,K.jsx)(zt,{})},{id:`sync`,label:`Sync`,icon:qe,render:()=>(0,K.jsx)(It,{})}],Vt={terminal:`sessions`,repositories:`projects`};function Ht(){let e=Fe(),t=e===null?null:Vt[e]??e,n=Bt.find(e=>e.id===t)??Bt[0];return(0,K.jsx)(C,{open:e!==null,onOpenChange:e=>!e&&ze(),children:(0,K.jsxs)(b,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,K.jsx)(x,{className:`sr-only`,children:`Settings`}),(0,K.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,K.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),Bt.map(({id:e,label:t,icon:r})=>(0,K.jsxs)(`button`,{onClick:()=>We(e),className:P(`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,K.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]}),(0,K.jsx)(`div`,{className:`overflow-y-auto p-5`,children:n.render()})]})})}export{Ht as SettingsDialog};