@puddle-code/cli 0.0.13 → 0.0.14

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 +45 -6
  2. package/README.md +4 -4
  3. package/dist/index.js +446 -166
  4. package/dist/public/assets/{Dashboard-T4hbzT6P.js → Dashboard-Ct5exI8s.js} +1 -1
  5. package/dist/public/assets/{EditorTabClose-DxU5M-9J.js → EditorTabClose-BhFjRoCZ.js} +1 -1
  6. package/dist/public/assets/{LazyTerminal-Dpk5-lcY.js → LazyTerminal-B0xYs2ul.js} +2 -2
  7. package/dist/public/assets/{ModelRefcount-BGB1nvG5.js → ModelRefcount-BY5Ul0p3.js} +1 -1
  8. package/dist/public/assets/{PaneEditorBody-DX0u3ISF.js → PaneEditorBody-DLMtDiov.js} +1 -1
  9. package/dist/public/assets/{SettingsDialog-58D8eQOa.js → SettingsDialog-WhQXNCmS.js} +1 -1
  10. package/dist/public/assets/{Terminal-DlXSwAG0.js → Terminal-DA8zjtmU.js} +1 -1
  11. package/dist/public/assets/{Workspace-B_eXJKAN.js → Workspace-B0FDl771.js} +2 -2
  12. package/dist/public/assets/{buffer-store-zsL8CNKc.js → buffer-store-BHJ82Nh3.js} +2 -2
  13. package/dist/public/assets/{context-menu-C8MwVsBG.js → context-menu--H5GoapF.js} +1 -1
  14. package/dist/public/assets/{cssMode-Dzho6NMm.js → cssMode-Ctq00nXG.js} +1 -1
  15. package/dist/public/assets/{htmlMode-pj_l07tD.js → htmlMode-pYCLPiZ_.js} +1 -1
  16. package/dist/public/assets/index-CjgsCY-C.css +2 -0
  17. package/dist/public/assets/{index-oAv85qtL.js → index-RvCLpi9M.js} +4 -4
  18. package/dist/public/assets/{jsonMode-Dx2T0LuI.js → jsonMode-Ch5UticT.js} +1 -1
  19. package/dist/public/assets/{session-seed-C8M00YNU.js → session-seed-DBxHPYBK.js} +1 -1
  20. package/dist/public/assets/ssh-mode-eNTVum_C.js +1 -0
  21. package/dist/public/assets/{tsMode-DXWeq4NK.js → tsMode-CeXrzlPn.js} +1 -1
  22. package/dist/public/index.html +3 -3
  23. package/package.json +1 -1
  24. package/dist/public/assets/index-DK5CyY2G.css +0 -2
  25. package/dist/public/assets/ssh-mode-BdHO6hP9.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{d as r,f as i,g as a,h as o,m as s,p as c,u as l,x as u}from"./api-Bh5IJ30S.js";import{a as d,g as f,i as p,n as m,o as h,r as g,t as _}from"./dialog-B43iKmfK.js";import{A as v,D as y,F as b,H as x,I as S,L as C,M as w,P as T,S as E,T as D,V as O,W as k,X as ee,Y as te,_ as A,f as j,i as ne,it as M,k as re,nt as ie,o as N,p as ae,r as oe,rt as P,v as se,z as ce}from"./LazyTerminal-Dpk5-lcY.js";import{t as F}from"./utils-B6KiDbIe.js";import{t as I}from"./createLucideIcon-DyMAgLa3.js";import{a as L,i as R,n as z,o as B,r as V,s as le,t as ue}from"./session-seed-C8M00YNU.js";import{i as de,r as fe}from"./dist-VDiYuPKw.js";import{A as pe,B as me,C as he,D as ge,E as _e,F as ve,H as ye,I as be,J as xe,K as Se,L as Ce,N as we,O as Te,T as Ee,U as De,V as Oe,Y as ke,a as H,b as Ae,c as je,d as Me,f as Ne,g as U,h as W,l as Pe,m as Fe,nt as Ie,ot as Le,p as Re,q as ze,u as Be,v as Ve,x as He,y as Ue,z as We}from"./index-oAv85qtL.js";var Ge=I(`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`}]]),Ke=I(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),qe=I(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),Je=I(`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`}]]),Ye=I(`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`}]]),Xe=I(`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`}]]),Ze=I(`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`}]]),Qe=I(`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`}]]),$e=I(`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({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,K.jsxs)(`div`,{className:F(`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:F(`text-xs text-fg-muted`,n),children:t})]}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function J({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 et(){let e=U(),[t,n]=(0,G.useState)(Le());return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`This browser only`,children:`Appearance`}),(0,K.jsx)(q,{label:`Theme`,description:`Chrome, terminal, and editor restyle together.`,children:(0,K.jsxs)(z,{value:t,onValueChange:e=>{n(e),Ie(e)},children:[(0,K.jsx)(L,{className:`w-32`,children:(0,K.jsx)(B,{})}),(0,K.jsxs)(V,{children:[(0,K.jsx)(R,{value:`dark`,children:`Dark`}),(0,K.jsx)(R,{value:`light`,children:`Light`}),(0,K.jsx)(R,{value:`system`,children:`System`})]})]})}),(0,K.jsx)(q,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,K.jsx)(P,{id:`ui-font-size`,type:`number`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onChange:e=>W({uiFontSize:Number(e.target.value)||Re.uiFontSize})})}),(0,K.jsx)(q,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,K.jsx)(P,{id:`terminal-font-size`,type:`number`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onChange:e=>W({terminalFontSize:Number(e.target.value)||13})})}),(0,K.jsx)(q,{label:`Density`,children:(0,K.jsxs)(z,{value:e.density,onValueChange:e=>W({density:e}),children:[(0,K.jsx)(L,{className:`w-36`,children:(0,K.jsx)(B,{})}),(0,K.jsxs)(V,{children:[(0,K.jsx)(R,{value:`compact`,children:`Compact`}),(0,K.jsx)(R,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,K.jsx)(q,{label:`Reduced motion`,description:`Status ripples become static dots.`,htmlFor:`reduced-motion`,children:(0,K.jsx)(H,{id:`reduced-motion`,checked:e.reducedMotion,onCheckedChange:e=>W({reducedMotion:e})})}),(0,K.jsx)(q,{label:`All projects in the sidebar`,description:`Show every project's sessions in the right sidebar, grouped by project.`,htmlFor:`all-project-sessions`,children:(0,K.jsx)(H,{id:`all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>W({showAllProjectSessions:e})})})]})}function tt({profile:e}){let t=S(),[n,r]=(0,G.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>u.error(e.message)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>u.error(e.message)});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(q,{label:`Icon`,description:`The glyph shown wherever this profile appears.`,children:(0,K.jsxs)(Ue,{open:n,onOpenChange:r,children:[(0,K.jsx)(He,{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)(We,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,K.jsx)(Ae,{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:F(`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)(We,{icon:null,colour:null,className:`size-4`})}),Oe.map(({name:t,Icon:n})=>(0,K.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:F(`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)(q,{label:`Icon colour`,description:`Any theme colour; recolours with light/dark.`,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:F(`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`})]}),o.map(t=>(0,K.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:F(`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:F(`size-3.5 rounded-full bg-current`,me(t))}),(0,K.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var Y=`__none__`;function nt(){let e=N(),t=x().data?.find(t=>t.id===e),n=j(e??void 0),r=O(e??void 0),i=S(),a=C(e??``),o=y(),[s,c]=(0,G.useState)(``),[v,b]=(0,G.useState)(``),[w,T]=(0,G.useState)(!1),[E,D]=(0,G.useState)(``);if((0,G.useEffect)(()=>{t&&(c(t.name),b(t.branch_prefix))},[t]),!t)return null;let k=r.data?.default_account_id;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Profile`}),(0,K.jsxs)(q,{label:`Name`,description:`A display label. Letters, digits, dot, underscore and hyphen; must be unique.`,htmlFor:`profile-name`,children:[(0,K.jsx)(P,{id:`profile-name`,value:s,onChange:e=>c(e.target.value),className:`w-44 font-mono`}),(0,K.jsx)(f,{size:`sm`,variant:`secondary`,disabled:s===t.name||s.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:s},{onError:e=>u.error(e.message)}),children:`Save`})]}),(0,K.jsxs)(q,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,K.jsx)(P,{id:`branch-prefix`,value:v,onChange:e=>b(e.target.value),placeholder:l,className:`w-44 font-mono`}),(0,K.jsx)(f,{size:`sm`,variant:`secondary`,disabled:v===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:v},{onError:e=>u.error(e.message)}),children:`Save`})]}),(0,K.jsx)(tt,{profile:t}),(0,K.jsx)(q,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,K.jsxs)(z,{value:typeof k==`number`?String(k):Y,onValueChange:e=>a.mutate({default_account_id:e===Y?null:Number(e)},{onError:e=>u.error(e.message)}),children:[(0,K.jsx)(L,{className:`w-56`,children:(0,K.jsx)(B,{})}),(0,K.jsxs)(V,{children:[(0,K.jsx)(R,{value:Y,children:`First available`}),n.data?.map(e=>(0,K.jsx)(R,{value:String(e.id),children:(0,K.jsxs)(`span`,{className:`font-mono`,children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,K.jsx)(q,{label:`Delete profile`,description:`Removes its projects, accounts (logging them out), and archived history. Non-archived sessions block deletion.`,className:`mt-4`,children:(0,K.jsx)(f,{variant:`danger`,size:`sm`,onClick:()=>T(!0),children:`Delete…`})}),(0,K.jsx)(_,{open:w,onOpenChange:e=>{e||(T(!1),D(``))},children:(0,K.jsxs)(m,{children:[(0,K.jsxs)(d,{children:[(0,K.jsxs)(h,{children:[`Delete profile `,(0,K.jsx)(`span`,{className:`font-mono`,children:t.name}),`?`]}),(0,K.jsx)(g,{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)(ie,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`font-mono text-fg`,children:t.name}),` to confirm`]}),(0,K.jsx)(P,{id:`delete-confirm-name`,value:E,onChange:e=>D(e.target.value),className:`font-mono`,autoFocus:!0})]}),(0,K.jsxs)(p,{children:[(0,K.jsx)(f,{variant:`ghost`,onClick:()=>{T(!1),D(``)},children:`Cancel`}),(0,K.jsx)(f,{variant:`danger`,disabled:E!==t.name||o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>{ve(),ne.set(null)},onError:e=>{T(!1),D(``),u.error(e.message)}}),children:`Delete profile`})]})]})})]})}function rt({agentId:e,profileId:t,onClose:n}){let r=se(),[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(``),c=re(we(o,150)),l=i.trim()!==``&&(o.startsWith(`/`)||o.startsWith(`~`));return(0,K.jsx)(_,{open:!0,onOpenChange:e=>!e&&n(),children:(0,K.jsxs)(m,{children:[(0,K.jsxs)(d,{children:[(0,K.jsx)(h,{children:`Import an existing account`}),(0,K.jsx)(g,{children:`The directory is copied into a puddle-owned account; the original is never touched. If credentials do not travel (macOS keychain), log in once afterwards.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(P,{placeholder:`label, e.g. personal`,value:i,onChange:e=>a(e.target.value),className:`font-mono`}),(0,K.jsx)(oe,{value:o,onValueChange:s,placeholder:`config dir on the host, e.g. ~/.claude`,hints:(c.data?.entries??[]).map(e=>({value:e.path,label:e.name})),className:`font-mono`})]}),(0,K.jsxs)(p,{children:[(0,K.jsx)(f,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,K.jsxs)(f,{disabled:!l||r.isPending,onClick:()=>r.mutate({profile_id:t,agent_type:e,label:i.trim(),import_dir:o.trim()},{onSuccess:e=>{n(),e.logged_in||u.info(`Imported without credentials — press Login to authenticate.`)},onError:e=>u.error(e.message)}),children:[(0,K.jsx)(qe,{}),`Import`]})]})]})})}function it({account:e,gateOpen:t}){let n=w(),r=T(),i=D(),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(!1),[l,v]=(0,G.useState)(e.label);return(0,G.useEffect)(()=>v(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:l,onChange:e=>v(e.target.value),onBlur:()=>{let t=l.trim();if(t!==e.label){if(t===``){v(e.label);return}r.mutate({id:e.id,label:t},{onError:t=>{u.error(t.message),v(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(v(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 font-mono 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-running`:`text-waiting`}`,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)(H,{checked:e.skip_permissions_default,onCheckedChange:t=>r.mutate({id:e.id,skip_permissions_default:t},{onError:e=>u.error(e.message)})})]}),(0,K.jsxs)(f,{size:`sm`,variant:`secondary`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:e=>o(e.stream),onError:e=>u.error(e.message)}),children:[(0,K.jsx)(ke,{}),e.logged_in?`Re-login`:`Login`]}),(0,K.jsxs)(f,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>c(!0),children:[(0,K.jsx)(De,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),a&&(0,K.jsx)(Ve,{stream:a,label:`${e.agent_type}/${e.label}`,onClose:()=>o(null)}),(0,K.jsx)(_,{open:s,onOpenChange:c,children:(0,K.jsxs)(m,{children:[(0,K.jsxs)(d,{children:[(0,K.jsxs)(h,{children:[`Delete `,(0,K.jsx)(`span`,{className:`font-mono`,children:e.label}),`?`]}),(0,K.jsx)(g,{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)(p,{children:[(0,K.jsx)(f,{variant:`ghost`,onClick:()=>c(!1),children:`Cancel`}),(0,K.jsx)(f,{variant:`danger`,disabled:i.isPending,onClick:()=>i.mutate(e.id,{onSuccess:()=>c(!1),onError:e=>{c(!1),u.error(e.message)}}),children:`Delete account`})]})]})})]})}function at(){let e=N(),t=ae(),n=j(e??void 0),r=O(e??void 0),i=se(),a=w(),[o,s]=(0,G.useState)({}),[c,l]=(0,G.useState)(null),[d,p]=(0,G.useState)(null),m=r.data?.allowSkipPermissions===!0,h=t=>{let n=(o[t]??``).trim();!n||e===null||i.mutate({profile_id:e,agent_type:t,label:n},{onSuccess:e=>{s(e=>({...e,[t]:``})),a.mutate(e.id,{onSuccess:n=>l({stream:n.stream,label:`${t}/${e.label}`})})},onError:e=>u.error(e.message)})};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[];return(0,K.jsxs)(`div`,{className:`mb-5`,children:[(0,K.jsx)(q,{label:e.display_name,description:`Accounts are isolated config dirs under this profile.`,className:`py-1`,children:(0,K.jsx)(`span`,{className:`font-mono 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)(it,{account:t,gateOpen:m&&e.capabilities.skip_permissions},t.id)),(0,K.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),h(e.id)},children:[(0,K.jsx)(P,{placeholder:`label, e.g. personal`,value:o[e.id]??``,onChange:t=>s(n=>({...n,[e.id]:t.target.value})),className:`w-48 font-mono`}),(0,K.jsxs)(f,{type:`submit`,size:`sm`,variant:`secondary`,disabled:!(o[e.id]??``).trim()||i.isPending,children:[(0,K.jsx)(ze,{}),`Add account`]}),(0,K.jsxs)(f,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>p(e.id),children:[(0,K.jsx)(qe,{}),`Import existing…`]})]})]})]},e.id)}),c&&(0,K.jsx)(Ve,{stream:c.stream,label:c.label,onClose:()=>l(null)}),d!==null&&e!==null&&(0,K.jsx)(rt,{agentId:d,profileId:e,onClose:()=>p(null)})]})}function ot(){let e=A(),t=b(),[n,r]=(0,G.useState)(``);return(0,G.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,K.jsx)(q,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH to find agent CLIs like claude (e.g. ~/.local/bin). Applies after the daemon restarts.`,htmlFor:`agent-path`,children:(0,K.jsx)(P,{id:`agent-path`,type:`text`,className:`w-64 font-mono text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function st({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=ue(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)(q,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,K.jsx)(P,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48 font-mono`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,K.jsx)(q,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,K.jsx)(H,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,K.jsx)(q,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`An own working copy of the base branch, instead of sharing one.`,htmlFor:`${e}-default-dir`,children:(0,K.jsx)(H,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function ct(){return(0,K.jsx)(q,{label:`Terminal scrollback`,description:`Lines kept per terminal. This browser only.`,htmlFor:`scrollback`,children:(0,K.jsx)(P,{id:`scrollback`,type:`number`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:U().terminalScrollback,onChange:e=>W({terminalScrollback:Number(e.target.value)||5e3})})})}function X({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)(f,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,K.jsx)(f,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var lt={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 ut({initial:e,onSave:t,pending:n}){let[r,i]=(0,G.useState)(e),o=r.length>0?r:s;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)(P,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:s}),(0,K.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,K.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:he(lt,o)})]}),(0,K.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:a.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)(f,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,K.jsx)(f,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(s),t(s)},children:`Reset to default`})]})]})}function dt(){let e=N(),t=x().data?.find(t=>t.id===e),n=O(e??void 0),a=C(e??``),[o,s]=(0,G.useState)(!1),[l,v]=(0,G.useState)(``),y=n.data?.allowSkipPermissions===!0,b=e=>a.mutate({allowSkipPermissions:e},{onSuccess:()=>{s(!1),v(``)},onError:e=>u.error(e.message)}),S=e=>t=>a.mutate({[e]:t},{onError:e=>u.error(e.message)});return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Sessions`}),(0,K.jsx)(`p`,{className:`mb-3 text-xs text-fg-secondary`,children:`Permission prompts are on by default, everywhere. Skipping them requires this profile gate, a per-account opt-in, and a per-session toggle — and the daemon re-checks all three on every launch, resume, and hand-off.`}),(0,K.jsx)(q,{label:`Allow skipping permission prompts`,description:y?`The gate is open: opted-in accounts can start prompt-free sessions.`:`The gate is closed: every session keeps its permission prompts.`,htmlFor:`gate`,children:(0,K.jsx)(H,{id:`gate`,checked:y,onCheckedChange:e=>{e?s(!0):b(!1)}})}),(0,K.jsx)(q,{label:`Capture exported env vars`,description:n.data?.captureSessionEnv===!1?`Paused: session shells spawn plain — nothing new is captured or injected. Already-captured vars are kept for when this is re-enabled.`:`Vars exported in a session terminal persist: re-injected into its new shells and agent restarts. Values stay on the daemon host.`,htmlFor:`capture-env`,children:(0,K.jsx)(H,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:a.isPending,onCheckedChange:e=>a.mutate({captureSessionEnv:e},{onError:e=>u.error(e.message)})})}),(0,K.jsx)(ot,{}),(0,K.jsx)(ct,{}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`What the new-agent and new-terminal modals open with — everything stays editable per session.`,children:`New session defaults`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(st,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>a.mutate({sessionDefaults:e},{onError:e=>u.error(e.message)}),pending:a.isPending},`${e}:agent-seed`),(0,K.jsx)(st,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>a.mutate({sessionDefaults:e},{onError:e=>u.error(e.message)}),pending:a.isPending},`${e}:terminal-seed`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`Sent to the agent as its opening message when a session starts. Leave a box empty to send no preamble.`,children:`Launch text`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{id:`onboarding-template`,label:`New worktree`,description:`For a freshly created worktree. Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??i,defaultText:i,onSave:S(`onboardingTemplate`),pending:a.isPending},`${e}:onboarding`),(0,K.jsx)(X,{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??r,defaultText:r,onSave:S(`concurrentTemplate`),pending:a.isPending},`${e}:concurrent`),(0,K.jsx)(X,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot — its processes are gone.`,initial:n.data.restartTemplate??c,defaultText:c,onSave:S(`restartTemplate`),pending:a.isPending},`${e}:restart`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`How each session's tab and sidebar label is composed from its parts.`,children:`Tab title`}),n.data&&(0,K.jsx)(ut,{initial:n.data.tabTitleTemplate??"${name}",onSave:S(`tabTitleTemplate`),pending:a.isPending},`${e}:tab-title`)]}),(0,K.jsx)(_,{open:o,onOpenChange:e=>{e||(s(!1),v(``))},children:(0,K.jsxs)(m,{children:[(0,K.jsxs)(d,{children:[(0,K.jsxs)(h,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ze,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,K.jsx)(g,{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)(ie,{htmlFor:`confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`font-mono text-fg`,children:t?.name}),` to confirm`]}),(0,K.jsx)(P,{id:`confirm-name`,value:l,onChange:e=>v(e.target.value),className:`font-mono`,autoFocus:!0})]}),(0,K.jsxs)(p,{children:[(0,K.jsx)(f,{variant:`ghost`,onClick:()=>{s(!1),v(``)},children:`Cancel`}),(0,K.jsx)(f,{variant:`danger`,disabled:l!==t?.name||a.isPending,onClick:()=>b(!0),children:`Open the gate`})]})]})})]})}var ft={desktop:!0,sound:!1,muted_projects:[]};function pt(){let e=N(),t=O(e??void 0),n=C(e??``),r=k(e??void 0),i={...ft,...t.data?.notifications??{}},a=e=>n.mutate({notifications:e},{onError:e=>u.error(e.message)});return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`When an agent flips to waiting for input`,children:`Notifications`}),(0,K.jsx)(q,{label:`Desktop notification on waiting`,description:`Shown while this window is unfocused; clicking it opens the session.`,htmlFor:`notify-desktop`,children:(0,K.jsx)(H,{id:`notify-desktop`,checked:i.desktop,onCheckedChange:e=>{e&&typeof Notification<`u`&&Notification.requestPermission(),a({...i,desktop:e})}})}),(0,K.jsx)(q,{label:`Sound`,htmlFor:`notify-sound`,children:(0,K.jsx)(H,{id:`notify-sound`,checked:i.sound,onCheckedChange:e=>a({...i,sound:e})})}),(0,K.jsx)(q,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,K.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[i.muted_projects.length,` muted`]})}),(0,K.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.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)(H,{checked:i.muted_projects.includes(e.id),onCheckedChange:t=>a({...i,muted_projects:t?[...i.muted_projects,e.id]:i.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function mt(){let e=U();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`This browser only`,children:`Editor`}),(0,K.jsx)(q,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,K.jsx)(P,{id:`tab-size`,type:`number`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onChange:e=>W({editorTabSize:Number(e.target.value)||2})})}),(0,K.jsx)(q,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,K.jsx)(H,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>W({editorWordWrap:e})})}),(0,K.jsx)(q,{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)(P,{id:`editor-link-host`,type:`text`,placeholder:`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>W({editorLinkSshHost:e.target.value})})})]})}function ht({value:e,isDefault:t,onRecord:n,onReset:r}){let[i,a]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>a(!0),onBlur:()=>a(!1),onKeyDown:e=>{if(!i)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){a(!1);return}let t=ge(e.nativeEvent);t&&(n(t),a(!1))},className:F(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,i?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:i?`Press keys…`:Te(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)(Ye,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function gt(){let e=N(),t=O(e??void 0),n=C(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of Ee){let t=i(e.id,e.defaultBinding);a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>u.error(e.message)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>u.error(e.message)})};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{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. Browser-reserved combos (⌘W, ⌘T, ⌘⇧B, …) can’t be captured by a web tab.`}),_e.map(e=>{let t=Ee.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=i(e.id,e.defaultBinding),n=(a.get(t)??0)>1,c=pe(t)?`Browser-reserved — won’t fire in a tab.`:n?`Conflicts with another shortcut.`:void 0;return(0,K.jsx)(q,{label:e.label,description:c,descriptionClassName:c?`text-interrupted`:void 0,children:(0,K.jsx)(ht,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(e.id)})},e.id)})]},e)})]})}var _t=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Z=65,Q=Object.fromEntries([..._t].map((e,t)=>[e,t])),vt=`H`,yt=(()=>{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 bt(e){let t=4294967295;for(let n of e)t=yt[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function xt(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function St(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 Ct(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function wt(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function Tt(e,t){let n=(t%Z+Z)%Z,r=``;for(let t of e){let e=Q[t];r+=e===void 0?t:_t[(e+n)%Z]}return r}async function Et(e){let t=await Ct(JSON.stringify(e));return Tt(xt(t)+bt(t),1+Math.floor(Math.random()*(Z-1)))}async function Dt(e){let t=e.trim(),n=t[0];if(!n||Q[n]===void 0)throw Error(`Not a settings export.`);let r=Tt(t,-((Q[n]-Q[vt]+Z)%Z));if(r.length<9||r[0]!==vt)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=St(i);if(bt(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await wt(o))}var Ot=`puddle.sync-selection`;function kt(){try{let e=JSON.parse(localStorage.getItem(Ot)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return je.map(e=>e.id)}function At({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)(H,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function jt(){let e=N(),t=O(e??void 0),n=x().data?.find(t=>t.id===e),r=ee(e??void 0,void 0),i=C(e??``),a=S(),o=E(),s=Me(),c=Ne(),[l,d]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(kt),w=n?s.data?.file.profiles[n.name]:void 0,T=w?.enabled===!0,D=T&&w?w.groups:y,k=()=>({client:Fe(),theme:Le(),profileSettings:t.data??{},profile:n??{},scratchpad:r.data??[]}),te={setClient:e=>W(e),setTheme:e=>{typeof e==`string`&&Ie(e)},patchProfileSettings:e=>i.mutate(e,{onError:e=>u.error(e.message)}),patchProfileColumns:t=>{e&&a.mutate({id:e,...t},{onError:e=>u.error(e.message)})},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})}},A=(e,t)=>{n&&c.mutate({profile:n.name,entry:{enabled:e.enabled??T,groups:t,doc:Be(t,k()),updatedAt:new Date().toISOString()}},{onError:e=>u.error(e.message)})},j=(e,t)=>{let n=t?[...D,e]:D.filter(t=>t!==e);b(n),localStorage.setItem(Ot,JSON.stringify(n)),T&&A({},n)},ne=async()=>{v(!0);try{let e=Pe(await Dt(l.trim()),te,{profileSettings:t.data??{},scratchpad:r.data??[]});e.length===0?u.error(`Nothing recognised to import.`):(u.success(`Imported ${e.join(`, `)}.`),d(``))}catch(e){u.error(e.message)}finally{v(!1)}},re=async()=>{v(!0);try{let e=await Et(Be(D,k()));m(e),await navigator.clipboard?.writeText(e),u.success(`Copied to clipboard`)}finally{v(!1)}};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{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`}),s.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:[`Mirror the selected groups through this machine’s`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:`~/.puddle`}),`, so every puddle window — any port, any host — stays in step for profiles named`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:n?.name??`…`}),`. The checklist below then applies to imports and exports alike; scratchpad entries merge and never overwrite.`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(H,{checked:T,disabled:!n||s.isLoading||c.isPending,onCheckedChange:e=>A({enabled:e},D)}),`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)(le,{className:`size-3.5`}):(0,K.jsx)(de,{className:`size-3.5`}),`Choose what to sync`]}),h&&(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(At,{selected:D,onToggle:j})})]}),(0,K.jsxs)(`div`,{className:`mb-6`,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 an exported string — only the settings it carries are updated. Scratchpad entries are added alongside yours, never replacing them.`}),(0,K.jsx)(M,{value:l,onChange:e=>d(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)(f,{size:`sm`,disabled:!l.trim()||_,onClick:()=>void ne(),children:`Import`})})]}),(0,K.jsxs)(`div`,{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:`One click builds the string from the checklist above and copies it to your clipboard.`}),(0,K.jsx)(f,{size:`sm`,disabled:_,onClick:()=>void re(),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`})]})]})}function Mt({repo:e}){let t=ce(),n=v(),[r,i]=(0,G.useState)(e.default_base_branch),[a,o]=(0,G.useState)(e.onboarding_notes??``),s=e=>u.error(e.message);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 font-mono 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)(f,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>u.success(`Fetched.`),onError:s}),children:[(0,K.jsx)(Se,{}),`Fetch now`]})]}),(0,K.jsxs)(q,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,K.jsx)(P,{id:`base-${e.id}`,value:r,onChange:e=>i(e.target.value),className:`w-40 font-mono`}),(0,K.jsx)(f,{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)(q,{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)(H,{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,className:`font-mono`}),(0,K.jsx)(`div`,{children:(0,K.jsx)(f,{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 font-mono text-2xs text-fg-muted`,children:e},e))})]})]})}function Nt(){let e=te();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Repositories`}),e.data?.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No repositories yet — register one from the new-project flow on the dashboard.`}),e.data?.map(e=>(0,K.jsx)(Mt,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=b();return(0,K.jsx)(q,{label:e,description:t,htmlFor:`host-${n}`,children:(0,K.jsx)(P,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>u.error(e.message)})}})})}function Pt(){let e=A(),t=b();return e.data?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`Affects all profiles on this host`,children:`Host`}),(0,K.jsx)(q,{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)(P,{id:`host-displayName`,type:`text`,maxLength:64,className:`w-48`,defaultValue:e.data.displayName,onBlur:n=>{let r=n.target.value.trim();r!==e.data.displayName&&t.mutate({displayName:r},{onError:e=>u.error(e.message)})}})}),(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)(q,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,K.jsx)(H,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>u.error(e.message)})})})]}):null}var Ft=[{id:`appearance`,label:`Appearance`,icon:xe,render:()=>(0,K.jsx)(et,{})},{id:`profile`,label:`Profile`,icon:ye,render:()=>(0,K.jsx)(nt,{})},{id:`accounts`,label:`Accounts`,icon:$e,render:()=>(0,K.jsx)(at,{})},{id:`sessions`,label:`Sessions`,icon:Qe,render:()=>(0,K.jsx)(dt,{})},{id:`editor`,label:`Editor`,icon:Ke,render:()=>(0,K.jsx)(mt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Je,render:()=>(0,K.jsx)(gt,{})},{id:`notifications`,label:`Notifications`,icon:Ge,render:()=>(0,K.jsx)(pt,{})},{id:`repositories`,label:`Repositories`,icon:fe,render:()=>(0,K.jsx)(Nt,{})},{id:`host`,label:`Host`,icon:Xe,render:()=>(0,K.jsx)(Pt,{})},{id:`sync`,label:`Sync`,icon:Se,render:()=>(0,K.jsx)(jt,{})}],It={terminal:`sessions`};function Lt(){let e=Ce(),t=e===null?null:It[e]??e,n=Ft.find(e=>e.id===t)??Ft[0];return(0,K.jsx)(_,{open:e!==null,onOpenChange:e=>!e&&ve(),children:(0,K.jsxs)(m,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,K.jsx)(h,{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`}),Ft.map(({id:e,label:t,icon:r})=>(0,K.jsxs)(`button`,{onClick:()=>be(e),className:F(`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{Lt 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{d as r,f as i,g as a,h as o,m as s,p as c,u as l,x as u}from"./api-Bh5IJ30S.js";import{a as d,g as f,i as p,n as m,o as h,r as g,t as _}from"./dialog-B43iKmfK.js";import{A as v,D as y,F as b,H as x,I as S,L as C,M as w,P as T,S as E,T as D,V as O,W as k,X as ee,Y as te,_ as A,f as j,i as ne,it as M,k as re,nt as ie,o as N,p as ae,r as oe,rt as P,v as se,z as ce}from"./LazyTerminal-B0xYs2ul.js";import{t as F}from"./utils-B6KiDbIe.js";import{t as I}from"./createLucideIcon-DyMAgLa3.js";import{a as L,i as R,n as z,o as B,r as V,s as le,t as ue}from"./session-seed-DBxHPYBK.js";import{i as de,r as fe}from"./dist-VDiYuPKw.js";import{A as pe,B as me,C as he,D as ge,E as _e,F as ve,H as ye,I as be,J as xe,K as Se,L as Ce,N as we,O as Te,T as Ee,U as De,V as Oe,Y as ke,a as H,b as Ae,c as je,d as Me,f as Ne,g as U,h as W,l as Pe,m as Fe,nt as Ie,ot as Le,p as Re,q as ze,u as Be,v as Ve,x as He,y as Ue,z as We}from"./index-RvCLpi9M.js";var Ge=I(`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`}]]),Ke=I(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),qe=I(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),Je=I(`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`}]]),Ye=I(`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`}]]),Xe=I(`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`}]]),Ze=I(`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`}]]),Qe=I(`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`}]]),$e=I(`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({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,K.jsxs)(`div`,{className:F(`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:F(`text-xs text-fg-muted`,n),children:t})]}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function J({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 et(){let e=U(),[t,n]=(0,G.useState)(Le());return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`This browser only`,children:`Appearance`}),(0,K.jsx)(q,{label:`Theme`,description:`Chrome, terminal, and editor restyle together.`,children:(0,K.jsxs)(z,{value:t,onValueChange:e=>{n(e),Ie(e)},children:[(0,K.jsx)(L,{className:`w-32`,children:(0,K.jsx)(B,{})}),(0,K.jsxs)(V,{children:[(0,K.jsx)(R,{value:`dark`,children:`Dark`}),(0,K.jsx)(R,{value:`light`,children:`Light`}),(0,K.jsx)(R,{value:`system`,children:`System`})]})]})}),(0,K.jsx)(q,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,K.jsx)(P,{id:`ui-font-size`,type:`number`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onChange:e=>W({uiFontSize:Number(e.target.value)||Re.uiFontSize})})}),(0,K.jsx)(q,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,K.jsx)(P,{id:`terminal-font-size`,type:`number`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onChange:e=>W({terminalFontSize:Number(e.target.value)||13})})}),(0,K.jsx)(q,{label:`Density`,children:(0,K.jsxs)(z,{value:e.density,onValueChange:e=>W({density:e}),children:[(0,K.jsx)(L,{className:`w-36`,children:(0,K.jsx)(B,{})}),(0,K.jsxs)(V,{children:[(0,K.jsx)(R,{value:`compact`,children:`Compact`}),(0,K.jsx)(R,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,K.jsx)(q,{label:`Reduced motion`,description:`Status ripples become static dots.`,htmlFor:`reduced-motion`,children:(0,K.jsx)(H,{id:`reduced-motion`,checked:e.reducedMotion,onCheckedChange:e=>W({reducedMotion:e})})}),(0,K.jsx)(q,{label:`All projects in the sidebar`,description:`Show every project's sessions in the right sidebar, grouped by project.`,htmlFor:`all-project-sessions`,children:(0,K.jsx)(H,{id:`all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>W({showAllProjectSessions:e})})})]})}function tt({profile:e}){let t=S(),[n,r]=(0,G.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>u.error(e.message)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>u.error(e.message)});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(q,{label:`Icon`,description:`The glyph shown wherever this profile appears.`,children:(0,K.jsxs)(Ue,{open:n,onOpenChange:r,children:[(0,K.jsx)(He,{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)(We,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,K.jsx)(Ae,{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:F(`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)(We,{icon:null,colour:null,className:`size-4`})}),Oe.map(({name:t,Icon:n})=>(0,K.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:F(`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)(q,{label:`Icon colour`,description:`Any theme colour; recolours with light/dark.`,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:F(`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`})]}),o.map(t=>(0,K.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:F(`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:F(`size-3.5 rounded-full bg-current`,me(t))}),(0,K.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var Y=`__none__`;function nt(){let e=N(),t=x().data?.find(t=>t.id===e),n=j(e??void 0),r=O(e??void 0),i=S(),a=C(e??``),o=y(),[s,c]=(0,G.useState)(``),[v,b]=(0,G.useState)(``),[w,T]=(0,G.useState)(!1),[E,D]=(0,G.useState)(``);if((0,G.useEffect)(()=>{t&&(c(t.name),b(t.branch_prefix))},[t]),!t)return null;let k=r.data?.default_account_id;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Profile`}),(0,K.jsxs)(q,{label:`Name`,description:`A display label. Letters, digits, dot, underscore and hyphen; must be unique.`,htmlFor:`profile-name`,children:[(0,K.jsx)(P,{id:`profile-name`,value:s,onChange:e=>c(e.target.value),className:`w-44 font-mono`}),(0,K.jsx)(f,{size:`sm`,variant:`secondary`,disabled:s===t.name||s.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:s},{onError:e=>u.error(e.message)}),children:`Save`})]}),(0,K.jsxs)(q,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,K.jsx)(P,{id:`branch-prefix`,value:v,onChange:e=>b(e.target.value),placeholder:l,className:`w-44 font-mono`}),(0,K.jsx)(f,{size:`sm`,variant:`secondary`,disabled:v===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:v},{onError:e=>u.error(e.message)}),children:`Save`})]}),(0,K.jsx)(tt,{profile:t}),(0,K.jsx)(q,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,K.jsxs)(z,{value:typeof k==`number`?String(k):Y,onValueChange:e=>a.mutate({default_account_id:e===Y?null:Number(e)},{onError:e=>u.error(e.message)}),children:[(0,K.jsx)(L,{className:`w-56`,children:(0,K.jsx)(B,{})}),(0,K.jsxs)(V,{children:[(0,K.jsx)(R,{value:Y,children:`First available`}),n.data?.map(e=>(0,K.jsx)(R,{value:String(e.id),children:(0,K.jsxs)(`span`,{className:`font-mono`,children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,K.jsx)(q,{label:`Delete profile`,description:`Removes its projects, accounts (logging them out), and archived history. Non-archived sessions block deletion.`,className:`mt-4`,children:(0,K.jsx)(f,{variant:`danger`,size:`sm`,onClick:()=>T(!0),children:`Delete…`})}),(0,K.jsx)(_,{open:w,onOpenChange:e=>{e||(T(!1),D(``))},children:(0,K.jsxs)(m,{children:[(0,K.jsxs)(d,{children:[(0,K.jsxs)(h,{children:[`Delete profile `,(0,K.jsx)(`span`,{className:`font-mono`,children:t.name}),`?`]}),(0,K.jsx)(g,{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)(ie,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`font-mono text-fg`,children:t.name}),` to confirm`]}),(0,K.jsx)(P,{id:`delete-confirm-name`,value:E,onChange:e=>D(e.target.value),className:`font-mono`,autoFocus:!0})]}),(0,K.jsxs)(p,{children:[(0,K.jsx)(f,{variant:`ghost`,onClick:()=>{T(!1),D(``)},children:`Cancel`}),(0,K.jsx)(f,{variant:`danger`,disabled:E!==t.name||o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>{ve(),ne.set(null)},onError:e=>{T(!1),D(``),u.error(e.message)}}),children:`Delete profile`})]})]})})]})}function rt({agentId:e,profileId:t,onClose:n}){let r=se(),[i,a]=(0,G.useState)(``),[o,s]=(0,G.useState)(``),c=re(we(o,150)),l=i.trim()!==``&&(o.startsWith(`/`)||o.startsWith(`~`));return(0,K.jsx)(_,{open:!0,onOpenChange:e=>!e&&n(),children:(0,K.jsxs)(m,{children:[(0,K.jsxs)(d,{children:[(0,K.jsx)(h,{children:`Import an existing account`}),(0,K.jsx)(g,{children:`The directory is copied into a puddle-owned account; the original is never touched. If credentials do not travel (macOS keychain), log in once afterwards.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(P,{placeholder:`label, e.g. personal`,value:i,onChange:e=>a(e.target.value),className:`font-mono`}),(0,K.jsx)(oe,{value:o,onValueChange:s,placeholder:`config dir on the host, e.g. ~/.claude`,hints:(c.data?.entries??[]).map(e=>({value:e.path,label:e.name})),className:`font-mono`})]}),(0,K.jsxs)(p,{children:[(0,K.jsx)(f,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,K.jsxs)(f,{disabled:!l||r.isPending,onClick:()=>r.mutate({profile_id:t,agent_type:e,label:i.trim(),import_dir:o.trim()},{onSuccess:e=>{n(),e.logged_in||u.info(`Imported without credentials — press Login to authenticate.`)},onError:e=>u.error(e.message)}),children:[(0,K.jsx)(qe,{}),`Import`]})]})]})})}function it({account:e,gateOpen:t}){let n=w(),r=T(),i=D(),[a,o]=(0,G.useState)(null),[s,c]=(0,G.useState)(!1),[l,v]=(0,G.useState)(e.label);return(0,G.useEffect)(()=>v(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:l,onChange:e=>v(e.target.value),onBlur:()=>{let t=l.trim();if(t!==e.label){if(t===``){v(e.label);return}r.mutate({id:e.id,label:t},{onError:t=>{u.error(t.message),v(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(v(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 font-mono 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-running`:`text-waiting`}`,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)(H,{checked:e.skip_permissions_default,onCheckedChange:t=>r.mutate({id:e.id,skip_permissions_default:t},{onError:e=>u.error(e.message)})})]}),(0,K.jsxs)(f,{size:`sm`,variant:`secondary`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:e=>o(e.stream),onError:e=>u.error(e.message)}),children:[(0,K.jsx)(ke,{}),e.logged_in?`Re-login`:`Login`]}),(0,K.jsxs)(f,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>c(!0),children:[(0,K.jsx)(De,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),a&&(0,K.jsx)(Ve,{stream:a,label:`${e.agent_type}/${e.label}`,onClose:()=>o(null)}),(0,K.jsx)(_,{open:s,onOpenChange:c,children:(0,K.jsxs)(m,{children:[(0,K.jsxs)(d,{children:[(0,K.jsxs)(h,{children:[`Delete `,(0,K.jsx)(`span`,{className:`font-mono`,children:e.label}),`?`]}),(0,K.jsx)(g,{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)(p,{children:[(0,K.jsx)(f,{variant:`ghost`,onClick:()=>c(!1),children:`Cancel`}),(0,K.jsx)(f,{variant:`danger`,disabled:i.isPending,onClick:()=>i.mutate(e.id,{onSuccess:()=>c(!1),onError:e=>{c(!1),u.error(e.message)}}),children:`Delete account`})]})]})})]})}function at(){let e=N(),t=ae(),n=j(e??void 0),r=O(e??void 0),i=se(),a=w(),[o,s]=(0,G.useState)({}),[c,l]=(0,G.useState)(null),[d,p]=(0,G.useState)(null),m=r.data?.allowSkipPermissions===!0,h=t=>{let n=(o[t]??``).trim();!n||e===null||i.mutate({profile_id:e,agent_type:t,label:n},{onSuccess:e=>{s(e=>({...e,[t]:``})),a.mutate(e.id,{onSuccess:n=>l({stream:n.stream,label:`${t}/${e.label}`})})},onError:e=>u.error(e.message)})};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[];return(0,K.jsxs)(`div`,{className:`mb-5`,children:[(0,K.jsx)(q,{label:e.display_name,description:`Accounts are isolated config dirs under this profile.`,className:`py-1`,children:(0,K.jsx)(`span`,{className:`font-mono 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)(it,{account:t,gateOpen:m&&e.capabilities.skip_permissions},t.id)),(0,K.jsxs)(`form`,{className:`flex gap-2`,onSubmit:t=>{t.preventDefault(),h(e.id)},children:[(0,K.jsx)(P,{placeholder:`label, e.g. personal`,value:o[e.id]??``,onChange:t=>s(n=>({...n,[e.id]:t.target.value})),className:`w-48 font-mono`}),(0,K.jsxs)(f,{type:`submit`,size:`sm`,variant:`secondary`,disabled:!(o[e.id]??``).trim()||i.isPending,children:[(0,K.jsx)(ze,{}),`Add account`]}),(0,K.jsxs)(f,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>p(e.id),children:[(0,K.jsx)(qe,{}),`Import existing…`]})]})]})]},e.id)}),c&&(0,K.jsx)(Ve,{stream:c.stream,label:c.label,onClose:()=>l(null)}),d!==null&&e!==null&&(0,K.jsx)(rt,{agentId:d,profileId:e,onClose:()=>p(null)})]})}function ot(){let e=A(),t=b(),[n,r]=(0,G.useState)(``);return(0,G.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,K.jsx)(q,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH to find agent CLIs like claude (e.g. ~/.local/bin). Applies after the daemon restarts.`,htmlFor:`agent-path`,children:(0,K.jsx)(P,{id:`agent-path`,type:`text`,className:`w-64 font-mono text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function st({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=ue(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)(q,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,K.jsx)(P,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48 font-mono`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,K.jsx)(q,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,K.jsx)(H,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,K.jsx)(q,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`An own working copy of the base branch, instead of sharing one.`,htmlFor:`${e}-default-dir`,children:(0,K.jsx)(H,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function ct(){return(0,K.jsx)(q,{label:`Terminal scrollback`,description:`Lines kept per terminal. This browser only.`,htmlFor:`scrollback`,children:(0,K.jsx)(P,{id:`scrollback`,type:`number`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:U().terminalScrollback,onChange:e=>W({terminalScrollback:Number(e.target.value)||5e3})})})}function X({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)(f,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,K.jsx)(f,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var lt={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 ut({initial:e,onSave:t,pending:n}){let[r,i]=(0,G.useState)(e),o=r.length>0?r:s;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)(P,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:s}),(0,K.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,K.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:he(lt,o)})]}),(0,K.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:a.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)(f,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,K.jsx)(f,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(s),t(s)},children:`Reset to default`})]})]})}function dt(){let e=N(),t=x().data?.find(t=>t.id===e),n=O(e??void 0),a=C(e??``),[o,s]=(0,G.useState)(!1),[l,v]=(0,G.useState)(``),y=n.data?.allowSkipPermissions===!0,b=e=>a.mutate({allowSkipPermissions:e},{onSuccess:()=>{s(!1),v(``)},onError:e=>u.error(e.message)}),S=e=>t=>a.mutate({[e]:t},{onError:e=>u.error(e.message)});return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Sessions`}),(0,K.jsx)(`p`,{className:`mb-3 text-xs text-fg-secondary`,children:`Permission prompts are on by default, everywhere. Skipping them requires this profile gate, a per-account opt-in, and a per-session toggle — and the daemon re-checks all three on every launch, resume, and hand-off.`}),(0,K.jsx)(q,{label:`Allow skipping permission prompts`,description:y?`The gate is open: opted-in accounts can start prompt-free sessions.`:`The gate is closed: every session keeps its permission prompts.`,htmlFor:`gate`,children:(0,K.jsx)(H,{id:`gate`,checked:y,onCheckedChange:e=>{e?s(!0):b(!1)}})}),(0,K.jsx)(q,{label:`Capture exported env vars`,description:n.data?.captureSessionEnv===!1?`Paused: session shells spawn plain — nothing new is captured or injected. Already-captured vars are kept for when this is re-enabled.`:`Vars exported in a session terminal persist: re-injected into its new shells and agent restarts. Values stay on the daemon host.`,htmlFor:`capture-env`,children:(0,K.jsx)(H,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:a.isPending,onCheckedChange:e=>a.mutate({captureSessionEnv:e},{onError:e=>u.error(e.message)})})}),(0,K.jsx)(ot,{}),(0,K.jsx)(ct,{}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`What the new-agent and new-terminal modals open with — everything stays editable per session.`,children:`New session defaults`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(st,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>a.mutate({sessionDefaults:e},{onError:e=>u.error(e.message)}),pending:a.isPending},`${e}:agent-seed`),(0,K.jsx)(st,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>a.mutate({sessionDefaults:e},{onError:e=>u.error(e.message)}),pending:a.isPending},`${e}:terminal-seed`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`Sent to the agent as its opening message when a session starts. Leave a box empty to send no preamble.`,children:`Launch text`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{id:`onboarding-template`,label:`New worktree`,description:`For a freshly created worktree. Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??i,defaultText:i,onSave:S(`onboardingTemplate`),pending:a.isPending},`${e}:onboarding`),(0,K.jsx)(X,{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??r,defaultText:r,onSave:S(`concurrentTemplate`),pending:a.isPending},`${e}:concurrent`),(0,K.jsx)(X,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot — its processes are gone.`,initial:n.data.restartTemplate??c,defaultText:c,onSave:S(`restartTemplate`),pending:a.isPending},`${e}:restart`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`How each session's tab and sidebar label is composed from its parts.`,children:`Tab title`}),n.data&&(0,K.jsx)(ut,{initial:n.data.tabTitleTemplate??"${name}",onSave:S(`tabTitleTemplate`),pending:a.isPending},`${e}:tab-title`)]}),(0,K.jsx)(_,{open:o,onOpenChange:e=>{e||(s(!1),v(``))},children:(0,K.jsxs)(m,{children:[(0,K.jsxs)(d,{children:[(0,K.jsxs)(h,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Ze,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,K.jsx)(g,{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)(ie,{htmlFor:`confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`font-mono text-fg`,children:t?.name}),` to confirm`]}),(0,K.jsx)(P,{id:`confirm-name`,value:l,onChange:e=>v(e.target.value),className:`font-mono`,autoFocus:!0})]}),(0,K.jsxs)(p,{children:[(0,K.jsx)(f,{variant:`ghost`,onClick:()=>{s(!1),v(``)},children:`Cancel`}),(0,K.jsx)(f,{variant:`danger`,disabled:l!==t?.name||a.isPending,onClick:()=>b(!0),children:`Open the gate`})]})]})})]})}var ft={desktop:!0,sound:!1,muted_projects:[]};function pt(){let e=N(),t=O(e??void 0),n=C(e??``),r=k(e??void 0),i={...ft,...t.data?.notifications??{}},a=e=>n.mutate({notifications:e},{onError:e=>u.error(e.message)});return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`When an agent flips to waiting for input`,children:`Notifications`}),(0,K.jsx)(q,{label:`Desktop notification on waiting`,description:`Shown while this window is unfocused; clicking it opens the session.`,htmlFor:`notify-desktop`,children:(0,K.jsx)(H,{id:`notify-desktop`,checked:i.desktop,onCheckedChange:e=>{e&&typeof Notification<`u`&&Notification.requestPermission(),a({...i,desktop:e})}})}),(0,K.jsx)(q,{label:`Sound`,htmlFor:`notify-sound`,children:(0,K.jsx)(H,{id:`notify-sound`,checked:i.sound,onCheckedChange:e=>a({...i,sound:e})})}),(0,K.jsx)(q,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,K.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[i.muted_projects.length,` muted`]})}),(0,K.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.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)(H,{checked:i.muted_projects.includes(e.id),onCheckedChange:t=>a({...i,muted_projects:t?[...i.muted_projects,e.id]:i.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function mt(){let e=U();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`This browser only`,children:`Editor`}),(0,K.jsx)(q,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,K.jsx)(P,{id:`tab-size`,type:`number`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onChange:e=>W({editorTabSize:Number(e.target.value)||2})})}),(0,K.jsx)(q,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,K.jsx)(H,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>W({editorWordWrap:e})})}),(0,K.jsx)(q,{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)(P,{id:`editor-link-host`,type:`text`,placeholder:`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>W({editorLinkSshHost:e.target.value})})})]})}function ht({value:e,isDefault:t,onRecord:n,onReset:r}){let[i,a]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>a(!0),onBlur:()=>a(!1),onKeyDown:e=>{if(!i)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){a(!1);return}let t=ge(e.nativeEvent);t&&(n(t),a(!1))},className:F(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,i?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:i?`Press keys…`:Te(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)(Ye,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function gt(){let e=N(),t=O(e??void 0),n=C(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of Ee){let t=i(e.id,e.defaultBinding);a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>u.error(e.message)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>u.error(e.message)})};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{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. Browser-reserved combos (⌘W, ⌘T, ⌘⇧B, …) can’t be captured by a web tab.`}),_e.map(e=>{let t=Ee.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=i(e.id,e.defaultBinding),n=(a.get(t)??0)>1,c=pe(t)?`Browser-reserved — won’t fire in a tab.`:n?`Conflicts with another shortcut.`:void 0;return(0,K.jsx)(q,{label:e.label,description:c,descriptionClassName:c?`text-interrupted`:void 0,children:(0,K.jsx)(ht,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(e.id)})},e.id)})]},e)})]})}var _t=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Z=65,Q=Object.fromEntries([..._t].map((e,t)=>[e,t])),vt=`H`,yt=(()=>{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 bt(e){let t=4294967295;for(let n of e)t=yt[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function xt(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function St(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 Ct(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function wt(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function Tt(e,t){let n=(t%Z+Z)%Z,r=``;for(let t of e){let e=Q[t];r+=e===void 0?t:_t[(e+n)%Z]}return r}async function Et(e){let t=await Ct(JSON.stringify(e));return Tt(xt(t)+bt(t),1+Math.floor(Math.random()*(Z-1)))}async function Dt(e){let t=e.trim(),n=t[0];if(!n||Q[n]===void 0)throw Error(`Not a settings export.`);let r=Tt(t,-((Q[n]-Q[vt]+Z)%Z));if(r.length<9||r[0]!==vt)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=St(i);if(bt(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await wt(o))}var Ot=`puddle.sync-selection`;function kt(){try{let e=JSON.parse(localStorage.getItem(Ot)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return je.map(e=>e.id)}function At({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)(H,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function jt(){let e=N(),t=O(e??void 0),n=x().data?.find(t=>t.id===e),r=ee(e??void 0,void 0),i=C(e??``),a=S(),o=E(),s=Me(),c=Ne(),[l,d]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(kt),w=n?s.data?.file.profiles[n.name]:void 0,T=w?.enabled===!0,D=T&&w?w.groups:y,k=()=>({client:Fe(),theme:Le(),profileSettings:t.data??{},profile:n??{},scratchpad:r.data??[]}),te={setClient:e=>W(e),setTheme:e=>{typeof e==`string`&&Ie(e)},patchProfileSettings:e=>i.mutate(e,{onError:e=>u.error(e.message)}),patchProfileColumns:t=>{e&&a.mutate({id:e,...t},{onError:e=>u.error(e.message)})},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})}},A=(e,t)=>{n&&c.mutate({profile:n.name,entry:{enabled:e.enabled??T,groups:t,doc:Be(t,k()),updatedAt:new Date().toISOString()}},{onError:e=>u.error(e.message)})},j=(e,t)=>{let n=t?[...D,e]:D.filter(t=>t!==e);b(n),localStorage.setItem(Ot,JSON.stringify(n)),T&&A({},n)},ne=async()=>{v(!0);try{let e=Pe(await Dt(l.trim()),te,{profileSettings:t.data??{},scratchpad:r.data??[]});e.length===0?u.error(`Nothing recognised to import.`):(u.success(`Imported ${e.join(`, `)}.`),d(``))}catch(e){u.error(e.message)}finally{v(!1)}},re=async()=>{v(!0);try{let e=await Et(Be(D,k()));m(e),await navigator.clipboard?.writeText(e),u.success(`Copied to clipboard`)}finally{v(!1)}};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{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`}),s.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:[`Mirror the selected groups through this machine’s`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:`~/.puddle`}),`, so every puddle window — any port, any host — stays in step for profiles named`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:n?.name??`…`}),`. The checklist below then applies to imports and exports alike; scratchpad entries merge and never overwrite.`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(H,{checked:T,disabled:!n||s.isLoading||c.isPending,onCheckedChange:e=>A({enabled:e},D)}),`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)(le,{className:`size-3.5`}):(0,K.jsx)(de,{className:`size-3.5`}),`Choose what to sync`]}),h&&(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(At,{selected:D,onToggle:j})})]}),(0,K.jsxs)(`div`,{className:`mb-6`,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 an exported string — only the settings it carries are updated. Scratchpad entries are added alongside yours, never replacing them.`}),(0,K.jsx)(M,{value:l,onChange:e=>d(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)(f,{size:`sm`,disabled:!l.trim()||_,onClick:()=>void ne(),children:`Import`})})]}),(0,K.jsxs)(`div`,{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:`One click builds the string from the checklist above and copies it to your clipboard.`}),(0,K.jsx)(f,{size:`sm`,disabled:_,onClick:()=>void re(),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`})]})]})}function Mt({repo:e}){let t=ce(),n=v(),[r,i]=(0,G.useState)(e.default_base_branch),[a,o]=(0,G.useState)(e.onboarding_notes??``),s=e=>u.error(e.message);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 font-mono 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)(f,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>u.success(`Fetched.`),onError:s}),children:[(0,K.jsx)(Se,{}),`Fetch now`]})]}),(0,K.jsxs)(q,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,K.jsx)(P,{id:`base-${e.id}`,value:r,onChange:e=>i(e.target.value),className:`w-40 font-mono`}),(0,K.jsx)(f,{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)(q,{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)(H,{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,className:`font-mono`}),(0,K.jsx)(`div`,{children:(0,K.jsx)(f,{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 font-mono text-2xs text-fg-muted`,children:e},e))})]})]})}function Nt(){let e=te();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Repositories`}),e.data?.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No repositories yet — register one from the new-project flow on the dashboard.`}),e.data?.map(e=>(0,K.jsx)(Mt,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=b();return(0,K.jsx)(q,{label:e,description:t,htmlFor:`host-${n}`,children:(0,K.jsx)(P,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>u.error(e.message)})}})})}function Pt(){let e=A(),t=b();return e.data?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`Affects all profiles on this host`,children:`Host`}),(0,K.jsx)(q,{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)(P,{id:`host-displayName`,type:`text`,maxLength:64,className:`w-48`,defaultValue:e.data.displayName,onBlur:n=>{let r=n.target.value.trim();r!==e.data.displayName&&t.mutate({displayName:r},{onError:e=>u.error(e.message)})}})}),(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)(q,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,K.jsx)(H,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>u.error(e.message)})})})]}):null}var Ft=[{id:`appearance`,label:`Appearance`,icon:xe,render:()=>(0,K.jsx)(et,{})},{id:`profile`,label:`Profile`,icon:ye,render:()=>(0,K.jsx)(nt,{})},{id:`accounts`,label:`Accounts`,icon:$e,render:()=>(0,K.jsx)(at,{})},{id:`sessions`,label:`Sessions`,icon:Qe,render:()=>(0,K.jsx)(dt,{})},{id:`editor`,label:`Editor`,icon:Ke,render:()=>(0,K.jsx)(mt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Je,render:()=>(0,K.jsx)(gt,{})},{id:`notifications`,label:`Notifications`,icon:Ge,render:()=>(0,K.jsx)(pt,{})},{id:`repositories`,label:`Repositories`,icon:fe,render:()=>(0,K.jsx)(Nt,{})},{id:`host`,label:`Host`,icon:Xe,render:()=>(0,K.jsx)(Pt,{})},{id:`sync`,label:`Sync`,icon:Se,render:()=>(0,K.jsx)(jt,{})}],It={terminal:`sessions`};function Lt(){let e=Ce(),t=e===null?null:It[e]??e,n=Ft.find(e=>e.id===t)??Ft[0];return(0,K.jsx)(_,{open:e!==null,onOpenChange:e=>!e&&ve(),children:(0,K.jsxs)(m,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,K.jsx)(h,{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`}),Ft.map(({id:e,label:t,icon:r})=>(0,K.jsxs)(`button`,{onClick:()=>be(e),className:F(`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{Lt as SettingsDialog};
@@ -1,4 +1,4 @@
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{n as r,s as i,v as a,x as o}from"./api-Bh5IJ30S.js";import{t as s}from"./utils-B6KiDbIe.js";import{P as c,at as l,g as u,rt as d,st as f}from"./index-oAv85qtL.js";import{t as p}from"./ssh-mode-BdHO6hP9.js";var m=e(t(),1),h=Object.defineProperty,g=Object.getOwnPropertyDescriptor,_=(e,t)=>{for(var n in t)h(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?g(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&h(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),ee=`Terminal input`,te={get:()=>ee,set:e=>ee=e},ne=`Too much output to announce, navigate to rows manually to read`,re={get:()=>ne,set:e=>ne=e};function ie(e){return e.replace(/\r?\n/g,`\r`)}function ae(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function oe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function b(e,t,n,r){e.stopPropagation(),e.clipboardData&&se(e.clipboardData.getData(`text/plain`),t,n,r)}function se(e,t,n,r){e=ie(e),e=ae(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function x(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ce(e,t,n,r,i){x(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function S(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function le(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var C=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},w=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},T=``,ue=` `,de=class e{constructor(){this.fg=0,this.bg=0,this.extended=new fe}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},fe=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},pe=class e extends de{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new fe,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?S(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},me=`di$target`,he=`di$dependencies`,ge=new Map;function _e(e){return e[he]||[]}function E(e){if(ge.has(e))return ge.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);ve(t,e,r)};return t._id=e,ge.set(e,t),t}function ve(e,t,n){t[me]===t?t[he].push({id:e,index:n}):(t[he]=[{id:e,index:n}],t[me]=t)}var D=E(`BufferService`),ye=E(`CoreMouseService`),be=E(`CoreService`),xe=E(`CharsetService`),Se=E(`InstantiationService`),Ce=E(`LogService`),we=E(`OptionsService`),Te=E(`OscLinkService`),Ee=E(`UnicodeService`),De=E(`DecorationService`),Oe=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new pe,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):ke(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Oe=v([y(0,D),y(1,we),y(2,Te)],Oe);function ke(e,t){if(confirm(`Do you want to navigate to ${t}?
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{n as r,s as i,v as a,x as o}from"./api-Bh5IJ30S.js";import{t as s}from"./utils-B6KiDbIe.js";import{P as c,at as l,g as u,rt as d,st as f}from"./index-RvCLpi9M.js";import{t as p}from"./ssh-mode-eNTVum_C.js";var m=e(t(),1),h=Object.defineProperty,g=Object.getOwnPropertyDescriptor,_=(e,t)=>{for(var n in t)h(e,n,{get:t[n],enumerable:!0})},v=(e,t,n,r)=>{for(var i=r>1?void 0:r?g(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&h(t,n,i),i},y=(e,t)=>(n,r)=>t(n,r,e),ee=`Terminal input`,te={get:()=>ee,set:e=>ee=e},ne=`Too much output to announce, navigate to rows manually to read`,re={get:()=>ne,set:e=>ne=e};function ie(e){return e.replace(/\r?\n/g,`\r`)}function ae(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function oe(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function b(e,t,n,r){e.stopPropagation(),e.clipboardData&&se(e.clipboardData.getData(`text/plain`),t,n,r)}function se(e,t,n,r){e=ie(e),e=ae(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function x(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function ce(e,t,n,r,i){x(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function S(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function le(e,t=0,n=e.length){let r=``;for(let i=t;i<n;++i){let t=e[i];t>65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var C=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a<n;++a){let i=e.charCodeAt(a);if(55296<=i&&i<=56319){if(++a>=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o);continue}i!==65279&&(t[r++]=i)}return r}},w=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l<u;){if(l>=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}else this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d<n;){for(;d<u&&!((i=e[d])&128)&&!((a=e[d+1])&128)&&!((o=e[d+2])&128)&&!((s=e[d+3])&128);)t[r++]=i,t[r++]=a,t[r++]=o,t[r++]=s,d+=4;if(i=e[d++],i<128)t[r++]=i;else if((i&224)==192){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(c=(i&31)<<6|a&63,c<128){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},T=``,ue=` `,de=class e{constructor(){this.fg=0,this.bg=0,this.extended=new fe}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return(this.fg&50331648)==0}isBgDefault(){return(this.bg&50331648)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},fe=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},pe=class e extends de{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new fe,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?S(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},me=`di$target`,he=`di$dependencies`,ge=new Map;function _e(e){return e[he]||[]}function E(e){if(ge.has(e))return ge.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);ve(t,e,r)};return t._id=e,ge.set(e,t),t}function ve(e,t,n){t[me]===t?t[he].push({id:e,index:n}):(t[he]=[{id:e,index:n}],t[me]=t)}var D=E(`BufferService`),ye=E(`CoreMouseService`),be=E(`CoreService`),xe=E(`CharsetService`),Se=E(`InstantiationService`),Ce=E(`LogService`),we=E(`OptionsService`),Te=E(`OscLinkService`),Ee=E(`UnicodeService`),De=E(`DecorationService`),Oe=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new pe,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;t<o;t++)if(!(c===-1&&!n.hasContent(t))){if(n.loadCell(t,a),a.hasExtendedAttrs()&&a.extended.urlId)if(c===-1){c=t,s=a.extended.urlId;continue}else l=a.extended.urlId!==s;else c!==-1&&(l=!0);if(l||c!==-1&&t===o-1){let n=this._oscLinkService.getLinkData(s)?.uri;if(n){let a={start:{x:c+1,y:e},end:{x:t+ +(!l&&t===o-1),y:e}},s=!1;if(!i?.allowNonHttpProtocols)try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)||(s=!0)}catch{s=!0}s||r.push({text:n,range:a,activate:(e,t)=>i?i.activate(e,t,a):ke(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};Oe=v([y(0,D),y(1,we),y(2,Te)],Oe);function ke(e,t){if(confirm(`Do you want to navigate to ${t}?
2
2
 
3
3
  WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var Ae=E(`CharSizeService`),je=E(`CoreBrowserService`),Me=E(`MouseService`),Ne=E(`RenderService`),Pe=E(`SelectionService`),Fe=E(`CharacterJoinerService`),Ie=E(`ThemeService`),Le=E(`LinkProviderService`),Re=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?We.isErrorNoTelemetry(e)?new We(e.message+`
4
4