@puddle-code/cli 0.0.36 → 0.0.37

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 +7 -4
  2. package/dist/index.js +1 -1
  3. package/dist/public/assets/{Dashboard-B20Z3e4d.js → Dashboard-De0qibC9.js} +1 -1
  4. package/dist/public/assets/{EditorTabClose-DwLO7gqj.js → EditorTabClose-CUYeSES1.js} +1 -1
  5. package/dist/public/assets/{LazyTerminal-CWtg2h0c.js → LazyTerminal-BMAKZ-LV.js} +2 -2
  6. package/dist/public/assets/{ModelRefcount-xBAYEiob.js → ModelRefcount-B_SYSR4t.js} +1 -1
  7. package/dist/public/assets/{PaneEditorBody-NRX5kMbo.js → PaneEditorBody-C19PH386.js} +1 -1
  8. package/dist/public/assets/{SettingsDialog-Bb7zkQqk.js → SettingsDialog-CIqhsL22.js} +1 -1
  9. package/dist/public/assets/{Terminal-RZY06vvA.js → Terminal-C_jdwu6i.js} +2 -2
  10. package/dist/public/assets/{Workspace-DxvFcba4.js → Workspace-BclF89l6.js} +3 -3
  11. package/dist/public/assets/{buffer-store-CRg63XiZ.js → buffer-store-ON5LQeHS.js} +2 -2
  12. package/dist/public/assets/{context-menu-8unK33Qy.js → context-menu-Dcek1hv6.js} +1 -1
  13. package/dist/public/assets/{cssMode-BNyZs5yJ.js → cssMode-BWXQD6Ms.js} +1 -1
  14. package/dist/public/assets/{editor-context-CXmEI4YQ.js → editor-context-BbDRtFbv.js} +1 -1
  15. package/dist/public/assets/{editor-sync-DlS3PBFX.js → editor-sync-DL-NkjyA.js} +1 -1
  16. package/dist/public/assets/{hotkeys-BoAqfYKZ.js → hotkeys-CGVAxX-R.js} +1 -1
  17. package/dist/public/assets/{htmlMode-BmCd0VVy.js → htmlMode-DAiLNOsw.js} +1 -1
  18. package/dist/public/assets/{index-DyI3xhOE.js → index-De_cN03H.js} +3 -3
  19. package/dist/public/assets/{jsonMode-DEtsBFfw.js → jsonMode-BHtI91Q6.js} +1 -1
  20. package/dist/public/assets/{session-seed-CDI_3Kiu.js → session-seed-DUI1gVzC.js} +1 -1
  21. package/dist/public/assets/ssh-mode-CJ0lbAR5.js +1 -0
  22. package/dist/public/assets/{tsMode-Jjq3o1yN.js → tsMode-DpTmzuCP.js} +1 -1
  23. package/dist/public/index.html +3 -3
  24. package/package.json +1 -1
  25. package/dist/public/assets/ssh-mode-LZIS09C5.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{A as r,B as i,F as a,M as o,N as s,P as c,_ as l,a as u,d,h as f,i as p,j as m,n as h,t as g}from"./hotkeys-BoAqfYKZ.js";import{a as _,g as v,i as y,n as b,o as x,r as S,t as C}from"./dialog-B43iKmfK.js";import{a as w,c as T,i as E,l as D,o as ee,r as O,s as k}from"./LazyTerminal-CWtg2h0c.js";import{t as A}from"./utils-B6KiDbIe.js";import{t as j}from"./createLucideIcon-DyMAgLa3.js";import{a as M,i as N,n as te,o as P,r as F,s as ne,t as re}from"./session-seed-CDI_3Kiu.js";import{r as ie}from"./dist-i-QevsUb.js";import{$ as ae,$t as I,Bt as oe,Cn as se,Dn as ce,Dt as le,Et as ue,G as de,Gt as fe,H as pe,J as me,K as he,Kt as ge,Nt as _e,Ot as ve,Pt as ye,Q as be,Qt as xe,R as L,Rt as Se,St as Ce,Tt as we,U as Te,Ut as Ee,V as R,W as De,X as z,Xt as Oe,Y as B,Yt as ke,an as V,bt as Ae,en as H,et as je,fn as Me,ht as Ne,in as U,mt as Pe,ot as Fe,pn as Ie,pt as Le,q as Re,qt as ze,r as Be,rn as Ve,rt as He,sn as Ue,tn as W,tt as We,vt as Ge,xt as Ke,yt as qe,zt as Je}from"./index-DyI3xhOE.js";var Ye=j(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Xe=j(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Ze=j(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Qe=j(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),$e=j(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),et=j(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),tt=j(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),nt=j(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),G=e(t(),1),K=n();function q({id:e,value:t,min:n,max:r,step:i,className:a,onCommit:o}){let[s,c]=(0,G.useState)(String(t));return(0,G.useEffect)(()=>c(String(t)),[t]),(0,K.jsx)(T,{id:e,type:`number`,min:n,max:r,step:i,className:a,value:s,onChange:e=>c(e.target.value),onBlur:()=>{let e=Number(s);if(s.trim()===``||!Number.isFinite(e)){c(String(t));return}let i=Math.min(r??e,Math.max(n??e,e));c(String(i)),i!==t&&o(i)},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}function J({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,K.jsxs)(`div`,{className:A(`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:A(`text-xs text-fg-muted`,n),children:t})]}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function Y({children:e,note:t}){return(0,K.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function rt(){let e=z(),[t,n]=(0,G.useState)(ce());return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Appearance`}),(0,K.jsx)(J,{label:`Theme`,children:(0,K.jsxs)(te,{value:t,onValueChange:e=>{n(e),se(e)},children:[(0,K.jsx)(M,{className:`w-32`,children:(0,K.jsx)(P,{})}),(0,K.jsxs)(F,{children:[(0,K.jsx)(N,{value:`dark`,children:`Dark`}),(0,K.jsx)(N,{value:`light`,children:`Light`}),(0,K.jsx)(N,{value:`system`,children:`System`})]})]})}),(0,K.jsx)(J,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,K.jsx)(q,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>B({uiFontSize:e})})}),(0,K.jsx)(J,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,K.jsx)(q,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>B({terminalFontSize:e})})}),(0,K.jsx)(J,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,K.jsx)(q,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>B({editorFontSize:e})})}),(0,K.jsx)(J,{label:`Density`,children:(0,K.jsxs)(te,{value:e.density,onValueChange:e=>B({density:e}),children:[(0,K.jsx)(M,{className:`w-36`,children:(0,K.jsx)(P,{})}),(0,K.jsxs)(F,{children:[(0,K.jsx)(N,{value:`compact`,children:`Compact`}),(0,K.jsx)(N,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,K.jsx)(J,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,K.jsx)(L,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>B({projectBasedLayout:e})})}),(0,K.jsx)(J,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,K.jsx)(L,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>B({showAllProjectSessions:e})})})]})}function it({profile:e}){let t=H(),[n,r]=(0,G.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>E(e)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>E(e)});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(J,{label:`Icon`,children:(0,K.jsxs)(ae,{open:n,onOpenChange:r,children:[(0,K.jsx)(We,{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)(Ge,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,K.jsx)(je,{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:A(`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)(Ge,{icon:null,colour:null,className:`size-4`})}),Ae.map(({name:t,Icon:n})=>(0,K.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:A(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,e.icon===t&&`bg-elevated text-fg`),children:(0,K.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,K.jsx)(J,{label:`Icon colour`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,K.jsxs)(`button`,{type:`button`,title:`Default`,onClick:()=>a(null),className:A(`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`})]}),c.map(t=>(0,K.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:A(`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:A(`size-3.5 rounded-full bg-current`,qe(t))}),(0,K.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var X=`__none__`;function at(){let e=l(),t=V().data?.find(t=>t.id===e),n=_e(e??void 0),r=U(e??void 0),i=H(),a=W(e??``),o=fe(),[s,c]=(0,G.useState)(``),[u,d]=(0,G.useState)(``),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(``);if((0,G.useEffect)(()=>{t&&(c(t.name),d(t.branch_prefix))},[t]),!t)return null;let w=r.data?.default_account_id;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Profile`}),(0,K.jsxs)(J,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,K.jsx)(T,{id:`profile-name`,value:s,onChange:e=>c(e.target.value),className:`w-44`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:s===t.name||s.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:s},{onError:e=>E(e)}),children:`Save`})]}),(0,K.jsxs)(J,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,K.jsx)(T,{id:`branch-prefix`,value:u,onChange:e=>d(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:u===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:u},{onError:e=>E(e)}),children:`Save`})]}),(0,K.jsx)(it,{profile:t}),(0,K.jsx)(J,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,K.jsxs)(te,{value:typeof w==`number`?String(w):X,onValueChange:e=>a.mutate({default_account_id:e===X?null:Number(e)},{onError:e=>E(e)}),children:[(0,K.jsx)(M,{className:`w-56`,children:(0,K.jsx)(P,{})}),(0,K.jsxs)(F,{children:[(0,K.jsx)(N,{value:X,children:`First available`}),n.data?.map(e=>(0,K.jsx)(N,{value:String(e.id),children:(0,K.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,K.jsx)(J,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,K.jsx)(v,{variant:`danger`,size:`sm`,onClick:()=>m(!0),children:`Delete…`})}),(0,K.jsx)(C,{open:p,onOpenChange:e=>{e||(m(!1),g(``))},children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Delete profile `,(0,K.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,K.jsx)(S,{children:`Everything this profile owns goes with it: projects, workspace layouts, accounts and their credential directories, and archived session history. Branches, repositories, and terminal logs on disk are untouched. This cannot be undone.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(k,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,K.jsx)(T,{id:`delete-confirm-name`,value:h,onChange:e=>g(e.target.value),autoFocus:!0})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>{m(!1),g(``)},children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:h!==t.name||o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>{Le(),f.set(null)},onError:e=>{m(!1),g(``),E(e)}}),children:`Delete profile`})]})]})})]})}function ot({agent:e,profileId:t,onClose:n,onCreated:r}){let i=Je(),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(``),l=ge(Fe(s,150)),u=s.trim(),d=u===``||u.startsWith(`/`)||u.startsWith(`~`),f=a.trim()!==``&&d,p=()=>{!f||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...u===``?{}:{import_dir:u}},{onSuccess:e=>{n(),r(e,u!==``)},onError:e=>E(e)})};return(0,K.jsx)(C,{open:!0,onOpenChange:e=>!e&&n(),children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Add a `,e.display_name,` account`]}),(0,K.jsxs)(S,{children:[`Accounts are isolated config dirs under this profile. Naming one is enough — Puddle creates it and takes you straight to `,e.display_name,`’s login. To reuse an account you already have on this machine, give its config directory: it is copied in and the original is never touched.`]})]}),(0,K.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,K.jsx)(T,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,K.jsx)(O,{value:s,onValueChange:c,placeholder:`(optional) existing config dir, e.g. ~/.claude`,hints:(l.data?.entries??[]).map(e=>({value:e.path,label:e.name}))})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,K.jsxs)(v,{disabled:!f||i.isPending,onClick:p,children:[(0,K.jsx)(ue,{}),`Add account`]})]})]})})}function st({account:e,gateOpen:t,installed:n}){let r=Oe(),i=xe(),a=Ee(),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(e.label),f=(0,G.useRef)(null);return(0,G.useEffect)(()=>d(e.label),[e.label]),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{ref:f,value:u,onChange:e=>d(e.target.value),onBlur:()=>{let t=u.trim();if(t!==e.label){if(t===``){d(e.label);return}i.mutate({id:e.id,label:t},{onError:t=>{E(t),d(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(d(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full min-w-0 truncate rounded-sm bg-transparent px-1 py-0.5 text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,K.jsxs)(`button`,{type:`button`,title:`Rename account`,onClick:()=>{f.current?.focus(),f.current?.select()},className:`shrink-0 rounded-sm p-0.5 text-fg-muted transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(w,{className:`size-3`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Rename account`})]})]}),(0,K.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,K.jsx)(L,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>E(e)})})]}),(0,K.jsxs)(v,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>E(e)}),children:[(0,K.jsx)(ve,{}),e.logged_in?`Re-login`:`Login`]}),(0,K.jsxs)(v,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,K.jsx)(Ce,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,K.jsx)(be,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,K.jsx)(C,{open:c,onOpenChange:l,children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Delete `,(0,K.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,K.jsx)(S,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),E(e)}}),children:`Delete account`})]})]})})]})}function ct(){let e=l(),t=ye(),n=_e(e??void 0),r=U(e??void 0),a=Oe(),[o,s]=(0,G.useState)(null),[c,u]=(0,G.useState)(null),d=r.data?.allowSkipPermissions===!0;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[],r=e.available!==!1;return(0,K.jsxs)(`div`,{className:`mb-5`,children:[(0,K.jsx)(J,{label:e.display_name,description:r?`Accounts are initialised in config dirs owned by this profile.`:`No ${e.binary??e.id} on the daemon’s PATH. Install it or add its directory to the agent search path in Sessions.`,className:`py-1`,children:(0,K.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.id})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,K.jsx)(st,{account:t,gateOpen:d&&e.capabilities.skip_permissions,installed:r},t.id)),(0,K.jsx)(`div`,{className:`flex`,children:(0,K.jsxs)(v,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>u(e),children:[(0,K.jsx)(ue,{}),`Add account`]})})]})]},e.id)}),o&&(0,K.jsx)(be,{stream:o.stream,label:o.label,hint:o.hint,onClose:()=>s(null)}),c!==null&&e!==null&&(0,K.jsx)(ot,{agent:c,profileId:e,onClose:()=>u(null),onCreated:(e,t)=>{if(t){e.logged_in||i.info(`Imported without credentials — press Login to authenticate.`);return}a.mutate(e.id,{onSuccess:t=>s({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>E(e)})}})]})}function lt(){let e=Se(),t=I(),[n,r]=(0,G.useState)(``);return(0,G.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,K.jsx)(J,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH; helps find agent CLIs like claude (e.g. ~/.local/bin).`,htmlFor:`agent-path`,children:(0,K.jsx)(T,{id:`agent-path`,type:`text`,className:`w-64 text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function ut({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=re(e,n),o=n.sessionDefaults??{},[s,c]=(0,G.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,K.jsx)(J,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,K.jsx)(T,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,K.jsx)(J,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,K.jsx)(L,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,K.jsx)(J,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`Start on working copy of the selected branch instead of sharing one directory.`,htmlFor:`${e}-default-dir`,children:(0,K.jsx)(L,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function dt(){return(0,K.jsx)(J,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,K.jsx)(q,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:z().terminalScrollback,onCommit:e=>B({terminalScrollback:e})})})}function ft({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)(D,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,K.jsx)(v,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var pt={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 mt({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)(T,{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(pt,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)(v,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,K.jsx)(v,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(s),t(s)},children:`Reset to default`})]})]})}function ht(){let e=l(),t=V().data?.find(t=>t.id===e),n=U(e??void 0),i=W(e??``),[a,s]=(0,G.useState)(!1),[c,u]=(0,G.useState)(``),d=n.data?.allowSkipPermissions===!0,f=e=>i.mutate({allowSkipPermissions:e},{onSuccess:()=>{s(!1),u(``)},onError:e=>E(e)}),p=e=>t=>i.mutate({[e]:t},{onError:e=>E(e)});return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Sessions`}),(0,K.jsx)(J,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,K.jsx)(L,{id:`gate`,checked:d,onCheckedChange:e=>{e?s(!0):f(!1)}})}),(0,K.jsx)(J,{label:`Capture exported env variables`,description:n.data?.captureSessionEnv===!1?`No variables are captured or injected; already-captured variabless are kept for when this is re-enabled.`:`Variables exported in a session persist and are re-injected upon terminal and agent restarts.`,htmlFor:`capture-env`,children:(0,K.jsx)(L,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:i.isPending,onCheckedChange:e=>i.mutate({captureSessionEnv:e},{onError:e=>E(e)})})}),(0,K.jsx)(lt,{}),(0,K.jsx)(dt,{}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{children:`New session defaults`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ut,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>i.mutate({sessionDefaults:e},{onError:e=>E(e)}),pending:i.isPending},`${e}:agent-seed`),(0,K.jsx)(ut,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>i.mutate({sessionDefaults:e},{onError:e=>E(e)}),pending:i.isPending},`${e}:terminal-seed`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{note:`Sent to agent as opening message when a session (re)starts. You can make this empty.`,children:`Launch text`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ft,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??m,defaultText:m,onSave:p(`onboardingTemplate`),pending:i.isPending},`${e}:onboarding`),(0,K.jsx)(ft,{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:p(`concurrentTemplate`),pending:i.isPending},`${e}:concurrent`),(0,K.jsx)(ft,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??o,defaultText:o,onSave:p(`restartTemplate`),pending:i.isPending},`${e}:restart`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{children:`Tab title`}),n.data&&(0,K.jsx)(mt,{initial:n.data.tabTitleTemplate||"${name}",onSave:p(`tabTitleTemplate`),pending:i.isPending},`${e}:tab-title`)]}),(0,K.jsx)(C,{open:a,onOpenChange:e=>{e||(s(!1),u(``))},children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{className:`flex items-center gap-2`,children:[(0,K.jsx)(et,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,K.jsx)(S,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,K.jsx)(`p`,{children:`A prompt-free agent acts unattended, with your credentials, inside its worktree — and nothing technically stops a shell command from reaching outside it. It can:`}),(0,K.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,K.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,K.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,K.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,K.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,K.jsx)(`p`,{children:`Only open this gate if every account you opt in runs work you would trust a colleague to run unsupervised on this machine.`}),(0,K.jsx)(`p`,{className:`text-fg-muted`,children:`Opening it also records the agent’s own bypass-permissions acceptance for this profile’s accounts, so the skip actually takes effect.`})]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(k,{htmlFor:`confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,K.jsx)(T,{id:`confirm-name`,value:c,onChange:e=>u(e.target.value),autoFocus:!0})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>{s(!1),u(``)},children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:c!==t?.name||i.isPending,onClick:()=>f(!0),children:`Open the gate`})]})]})})]})}var gt={desktop:!0,sound:!1,muted_projects:[]};function _t(){let[e,t]=(0,G.useState)(R);return(0,G.useEffect)(()=>{let e=()=>t(R());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(R())]}function vt({permission:e,onRequest:t}){return e===`granted`?null:(0,K.jsxs)(`p`,{className:`pb-2 text-xs text-warning`,children:[e==="default"&&(0,K.jsxs)(K.Fragment,{children:[`The browser has not been asked for permission yet, so nothing will show —`,` `,(0,K.jsx)(`button`,{type:`button`,onClick:t,className:`underline underline-offset-2 transition-colors hover:text-fg`,children:`request it now`}),`.`]}),e===`denied`&&`Blocked by the browser — allow notifications for this site in its site settings, then return here.`,e===`unsupported`&&`This browser cannot show desktop notifications.`]})}function yt(){let e=l(),t=U(e??void 0),n=W(e??``),r=Ue(e??void 0),[i,a]=_t(),o={...gt,...t.data?.notifications??{}},s=e=>n.mutate({notifications:e},{onError:e=>E(e)}),c=()=>{typeof Notification>`u`||Notification.requestPermission().then(a)};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Notifications`}),(0,K.jsx)(J,{label:`Desktop notification on waiting`,htmlFor:`notify-desktop`,children:(0,K.jsx)(L,{id:`notify-desktop`,checked:o.desktop,onCheckedChange:e=>{e&&c(),s({...o,desktop:e})}})}),o.desktop&&(0,K.jsx)(vt,{permission:i,onRequest:c}),(0,K.jsx)(J,{label:`Sound`,htmlFor:`notify-sound`,children:(0,K.jsx)(L,{id:`notify-sound`,checked:o.sound,onCheckedChange:e=>s({...o,sound:e})})}),(0,K.jsx)(J,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,K.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[o.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)(L,{checked:o.muted_projects.includes(e.id),onCheckedChange:t=>s({...o,muted_projects:t?[...o.muted_projects,e.id]:o.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function bt(){let e=z();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Editor`}),(0,K.jsx)(J,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,K.jsx)(q,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>B({editorTabSize:e})})}),(0,K.jsx)(J,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,K.jsx)(L,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>B({editorWordWrap:e})})}),(0,K.jsx)(J,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,K.jsx)(T,{id:`editor-link-host`,type:`text`,placeholder:Be.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>B({editorLinkSshHost:e.target.value})})})]})}function xt({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=p(e.nativeEvent);t&&(n(t),a(!1))},className:A(`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…`:u(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)(Qe,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function St(){let e=l(),t=U(e??void 0),n=W(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of g){let t=i(e.id,d(e));a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>E(e)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>E(e)})};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Hotkeys`}),(0,K.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),(0,K.jsx)(J,{label:`App shortcuts in terminals`,description:t.data?.terminalAppShortcuts===!1?`A focused terminal receives these keys instead.`:`The shortcuts below work while a terminal is focused.`,htmlFor:`terminal-app-shortcuts`,className:`mb-4`,children:(0,K.jsx)(L,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>E(e)})})}),h.map(e=>{let t=g.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,d(e)),n=(a.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,K.jsx)(J,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,K.jsx)(xt,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(e.id)})},e.id)})]},e)})]})}var Ct=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Z=65,Q=Object.fromEntries([...Ct].map((e,t)=>[e,t])),wt=`H`,Tt=(()=>{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 Et(e){let t=4294967295;for(let n of e)t=Tt[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function Dt(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function Ot(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 kt(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function At(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function jt(e,t){let n=(t%Z+Z)%Z,r=``;for(let t of e){let e=Q[t];r+=e===void 0?t:Ct[(e+n)%Z]}return r}async function Mt(e){let t=await kt(JSON.stringify(e));return jt(Dt(t)+Et(t),1+Math.floor(Math.random()*(Z-1)))}async function Nt(e){let t=e.trim(),n=t[0];if(!n||Q[n]===void 0)throw Error(`Not a settings export.`);let r=jt(t,-((Q[n]-Q[wt]+Z)%Z));if(r.length<9||r[0]!==wt)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=Ot(i);if(Et(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await At(o))}var Pt=`puddle.sync-selection`;function Ft(){try{let e=JSON.parse(localStorage.getItem(Pt)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return de.map(e=>e.id)}function It({selected:e,onToggle:t}){return(0,K.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:de.map(n=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(L,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function Lt(){let e=l(),t=U(e??void 0),n=V().data?.find(t=>t.id===e),r=Ie(e??void 0,void 0),a=W(e??``),o=H(),s=oe(),c=Te(),u=De(),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(!1),[_,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(Ft),S=n&&c.data?pe(c.data.file,n.name):void 0,C=S?.enabled===!0,w=C&&S?S.groups:b,T=()=>({client:me(),theme:ce(),profileSettings:t.data??{},profile:n??{},scratchpad:r.data??[]}),ee={setClient:e=>B(e),setTheme:e=>{typeof e==`string`&&se(e)},patchProfileSettings:e=>a.mutate(e,{onError:e=>E(e)}),patchProfileColumns:t=>{e&&o.mutate({id:e,...t},{onError:e=>E(e)})},createScratchpad:t=>{if(e)for(let n of t)s.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},O=(e,t)=>{n&&u.mutate({profile:n.name,entry:{enabled:e.enabled??C,groups:t,doc:Re(t,T()),updatedAt:new Date().toISOString()}},{onError:e=>E(e)})},k=(e,t)=>{let n=t?[...w,e]:w.filter(t=>t!==e);x(n),localStorage.setItem(Pt,JSON.stringify(n)),C&&O({},n)},A=async()=>{y(!0);try{let e=he(await Nt(d.trim()),ee,{profileSettings:t.data??{},scratchpad:r.data??[]});e.length===0?i.error(`Nothing recognised to import.`):(i.success(`Imported ${e.join(`, `)}.`),f(``))}catch(e){i.error(e.message)}finally{y(!1)}},j=async()=>{y(!0);try{let e=await Mt(Re(w,T()));m(e),await navigator.clipboard?.writeText(e),i.success(`Copied to clipboard`)}finally{y(!1)}};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Sync`}),(0,K.jsx)(`p`,{className:`mb-5 text-xs text-fg-muted`,children:`Carry your settings between machines. Accounts, repositories, and anything host-specific are never included. Applies to this profile.`}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),c.data?.available===!1?(0,K.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:`Not available in this cockpit — start the UI with the Puddle CLI to sync across windows.`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Sync selected groups through this machine’s`,` `,(0,K.jsx)(`span`,{className:`text-fg-secondary`,children:`~/.puddle`}),`, so every Puddle window stays in step for profiles named`,` `,(0,K.jsx)(`span`,{className:`text-fg-secondary`,children:n?.name??`…`}),`.`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(L,{checked:C,disabled:!n||c.isLoading||u.isPending,onCheckedChange:e=>O({enabled:e},w)}),`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)(ne,{className:`size-3.5`}):(0,K.jsx)(ie,{className:`size-3.5`}),`Choose what to sync`]}),h&&(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(It,{selected:w,onToggle:k})})]}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,K.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:`Builds a Puddle magic string that encodes settings from the checklist above.`}),(0,K.jsx)(v,{size:`sm`,disabled:_,onClick:()=>void j(),children:`Export & copy`}),p&&(0,K.jsx)(D,{readOnly:!0,value:p,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`mt-2 resize-y font-mono text-xs`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,K.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste a Puddle magic string to import its settings.`}),(0,K.jsx)(D,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:`Paste a settings export…`,rows:3,spellCheck:!1,className:`resize-y font-mono text-xs`}),(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(v,{size:`sm`,disabled:!d.trim()||_,onClick:()=>void A(),children:`Import`})})]})]})}function Rt({repo:e}){let t=Ve(),n=ze(),[r,a]=(0,G.useState)(e.default_base_branch),[o,s]=(0,G.useState)(e.onboarding_notes??``),c=e=>E(e);return(0,K.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.path}),(0,K.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,K.jsxs)(v,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>i.success(`Fetched.`),onError:c}),children:[(0,K.jsx)(we,{}),`Fetch now`]})]}),(0,K.jsxs)(J,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,K.jsx)(T,{id:`base-${e.id}`,value:r,onChange:e=>a(e.target.value),className:`w-40`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:r===e.default_base_branch||t.isPending,onClick:()=>t.mutate({id:e.id,default_base_branch:r},{onError:c}),children:`Save`})]}),(0,K.jsx)(J,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,K.jsx)(L,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:c})})}),(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)(D,{id:`notes-${e.id}`,value:o,onChange:e=>s(e.target.value),rows:4}),(0,K.jsx)(`div`,{children:(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:o===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:o},{onError:c}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,K.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Orphan worktrees — directories no session claims. Puddle never deletes these automatically; remove them by hand if unwanted.`}),(0,K.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,K.jsx)(`li`,{className:`truncate text-2xs text-fg-muted`,children:e},e))})]})]})}function zt(){let e=Me();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Projects`}),e.data?.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No projects yet — create one from the dashboard, pointing at a repository.`}),e.data?.map(e=>(0,K.jsx)(Rt,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=I();return(0,K.jsx)(J,{label:e,description:t,htmlFor:`host-${n}`,children:(0,K.jsx)(T,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{if(e.target.value.trim()===``){e.target.value=String(r[n]);return}let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>E(e)})}})})}function Bt(){let e=Se(),t=I(),n=ke();return e.data?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{note:`Affects all profiles on this host`,children:`Host`}),(0,K.jsx)(J,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,K.jsx)(T,{id:`host-displayName`,type:`text`,maxLength:64,className:`w-48`,placeholder:n.data?.hostname,defaultValue:e.data.displayName,onBlur:n=>{let r=n.target.value.trim();r!==e.data.displayName&&t.mutate({displayName:r},{onError:e=>E(e)})}})}),(0,K.jsx)($,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,K.jsx)($,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,K.jsx)($,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,K.jsx)($,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,K.jsx)(J,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,K.jsx)(L,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>E(e)})})})]}):null}var Vt=[{id:`appearance`,label:`Appearance`,icon:le,render:()=>(0,K.jsx)(rt,{})},{id:`profile`,label:`Profile`,icon:Ke,render:()=>(0,K.jsx)(at,{})},{id:`accounts`,label:`Accounts`,icon:nt,render:()=>(0,K.jsx)(ct,{})},{id:`sessions`,label:`Sessions`,icon:tt,render:()=>(0,K.jsx)(ht,{})},{id:`editor`,label:`Editor`,icon:Xe,render:()=>(0,K.jsx)(bt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Ze,render:()=>(0,K.jsx)(St,{})},{id:`notifications`,label:`Notifications`,icon:Ye,render:()=>(0,K.jsx)(yt,{})},{id:`projects`,label:`Projects`,icon:ee,render:()=>(0,K.jsx)(zt,{})},{id:`host`,label:`Host`,icon:$e,render:()=>(0,K.jsx)(Bt,{})},{id:`sync`,label:`Sync`,icon:we,render:()=>(0,K.jsx)(Lt,{})}],Ht={terminal:`sessions`,repositories:`projects`};function Ut(){let e=Ne(),t=e===null?null:Ht[e]??e,n=Vt.find(e=>e.id===t)??Vt[0];return(0,K.jsx)(C,{open:e!==null,onOpenChange:e=>!e&&Le(),children:(0,K.jsxs)(b,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,K.jsx)(x,{className:`sr-only`,children:`Settings`}),(0,K.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,K.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),Vt.map(({id:e,label:t,icon:r})=>(0,K.jsxs)(`button`,{onClick:()=>Pe(e),className:A(`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{Ut 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{A as r,B as i,F as a,M as o,N as s,P as c,_ as l,a as u,d,h as f,i as p,j as m,n as h,t as g}from"./hotkeys-CGVAxX-R.js";import{a as _,g as v,i as y,n as b,o as x,r as S,t as C}from"./dialog-B43iKmfK.js";import{a as w,c as T,i as E,l as D,o as ee,r as O,s as k}from"./LazyTerminal-BMAKZ-LV.js";import{t as A}from"./utils-B6KiDbIe.js";import{t as j}from"./createLucideIcon-DyMAgLa3.js";import{a as M,i as N,n as te,o as P,r as F,s as ne,t as re}from"./session-seed-DUI1gVzC.js";import{r as ie}from"./dist-i-QevsUb.js";import{$ as ae,$t as I,Bt as oe,Cn as se,Dn as ce,Dt as le,Et as ue,G as de,Gt as fe,H as pe,J as me,K as he,Kt as ge,Nt as _e,Ot as ve,Pt as ye,Q as be,Qt as xe,R as L,Rt as Se,St as Ce,Tt as we,U as Te,Ut as Ee,V as R,W as De,X as z,Xt as Oe,Y as B,Yt as ke,an as V,bt as Ae,en as H,et as je,fn as Me,ht as Ne,in as U,mt as Pe,ot as Fe,pn as Ie,pt as Le,q as Re,qt as ze,r as Be,rn as Ve,rt as He,sn as Ue,tn as W,tt as We,vt as Ge,xt as Ke,yt as qe,zt as Je}from"./index-De_cN03H.js";var Ye=j(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Xe=j(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Ze=j(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Qe=j(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),$e=j(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),et=j(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),tt=j(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),nt=j(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),G=e(t(),1),K=n();function q({id:e,value:t,min:n,max:r,step:i,className:a,onCommit:o}){let[s,c]=(0,G.useState)(String(t));return(0,G.useEffect)(()=>c(String(t)),[t]),(0,K.jsx)(T,{id:e,type:`number`,min:n,max:r,step:i,className:a,value:s,onChange:e=>c(e.target.value),onBlur:()=>{let e=Number(s);if(s.trim()===``||!Number.isFinite(e)){c(String(t));return}let i=Math.min(r??e,Math.max(n??e,e));c(String(i)),i!==t&&o(i)},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}function J({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,K.jsxs)(`div`,{className:A(`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:A(`text-xs text-fg-muted`,n),children:t})]}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function Y({children:e,note:t}){return(0,K.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function rt(){let e=z(),[t,n]=(0,G.useState)(ce());return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Appearance`}),(0,K.jsx)(J,{label:`Theme`,children:(0,K.jsxs)(te,{value:t,onValueChange:e=>{n(e),se(e)},children:[(0,K.jsx)(M,{className:`w-32`,children:(0,K.jsx)(P,{})}),(0,K.jsxs)(F,{children:[(0,K.jsx)(N,{value:`dark`,children:`Dark`}),(0,K.jsx)(N,{value:`light`,children:`Light`}),(0,K.jsx)(N,{value:`system`,children:`System`})]})]})}),(0,K.jsx)(J,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,K.jsx)(q,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>B({uiFontSize:e})})}),(0,K.jsx)(J,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,K.jsx)(q,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>B({terminalFontSize:e})})}),(0,K.jsx)(J,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,K.jsx)(q,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>B({editorFontSize:e})})}),(0,K.jsx)(J,{label:`Density`,children:(0,K.jsxs)(te,{value:e.density,onValueChange:e=>B({density:e}),children:[(0,K.jsx)(M,{className:`w-36`,children:(0,K.jsx)(P,{})}),(0,K.jsxs)(F,{children:[(0,K.jsx)(N,{value:`compact`,children:`Compact`}),(0,K.jsx)(N,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,K.jsx)(J,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,K.jsx)(L,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>B({projectBasedLayout:e})})}),(0,K.jsx)(J,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,K.jsx)(L,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>B({showAllProjectSessions:e})})})]})}function it({profile:e}){let t=H(),[n,r]=(0,G.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>E(e)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>E(e)});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(J,{label:`Icon`,children:(0,K.jsxs)(ae,{open:n,onOpenChange:r,children:[(0,K.jsx)(We,{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)(Ge,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,K.jsx)(je,{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:A(`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)(Ge,{icon:null,colour:null,className:`size-4`})}),Ae.map(({name:t,Icon:n})=>(0,K.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:A(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,e.icon===t&&`bg-elevated text-fg`),children:(0,K.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,K.jsx)(J,{label:`Icon colour`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,K.jsxs)(`button`,{type:`button`,title:`Default`,onClick:()=>a(null),className:A(`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`})]}),c.map(t=>(0,K.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:A(`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:A(`size-3.5 rounded-full bg-current`,qe(t))}),(0,K.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var X=`__none__`;function at(){let e=l(),t=V().data?.find(t=>t.id===e),n=_e(e??void 0),r=U(e??void 0),i=H(),a=W(e??``),o=fe(),[s,c]=(0,G.useState)(``),[u,d]=(0,G.useState)(``),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(``);if((0,G.useEffect)(()=>{t&&(c(t.name),d(t.branch_prefix))},[t]),!t)return null;let w=r.data?.default_account_id;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Profile`}),(0,K.jsxs)(J,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,K.jsx)(T,{id:`profile-name`,value:s,onChange:e=>c(e.target.value),className:`w-44`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:s===t.name||s.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:s},{onError:e=>E(e)}),children:`Save`})]}),(0,K.jsxs)(J,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,K.jsx)(T,{id:`branch-prefix`,value:u,onChange:e=>d(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:u===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:u},{onError:e=>E(e)}),children:`Save`})]}),(0,K.jsx)(it,{profile:t}),(0,K.jsx)(J,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,K.jsxs)(te,{value:typeof w==`number`?String(w):X,onValueChange:e=>a.mutate({default_account_id:e===X?null:Number(e)},{onError:e=>E(e)}),children:[(0,K.jsx)(M,{className:`w-56`,children:(0,K.jsx)(P,{})}),(0,K.jsxs)(F,{children:[(0,K.jsx)(N,{value:X,children:`First available`}),n.data?.map(e=>(0,K.jsx)(N,{value:String(e.id),children:(0,K.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,K.jsx)(J,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,K.jsx)(v,{variant:`danger`,size:`sm`,onClick:()=>m(!0),children:`Delete…`})}),(0,K.jsx)(C,{open:p,onOpenChange:e=>{e||(m(!1),g(``))},children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Delete profile `,(0,K.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,K.jsx)(S,{children:`Everything this profile owns goes with it: projects, workspace layouts, accounts and their credential directories, and archived session history. Branches, repositories, and terminal logs on disk are untouched. This cannot be undone.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(k,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,K.jsx)(T,{id:`delete-confirm-name`,value:h,onChange:e=>g(e.target.value),autoFocus:!0})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>{m(!1),g(``)},children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:h!==t.name||o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>{Le(),f.set(null)},onError:e=>{m(!1),g(``),E(e)}}),children:`Delete profile`})]})]})})]})}function ot({agent:e,profileId:t,onClose:n,onCreated:r}){let i=Je(),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(``),l=ge(Fe(s,150)),u=s.trim(),d=u===``||u.startsWith(`/`)||u.startsWith(`~`),f=a.trim()!==``&&d,p=()=>{!f||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...u===``?{}:{import_dir:u}},{onSuccess:e=>{n(),r(e,u!==``)},onError:e=>E(e)})};return(0,K.jsx)(C,{open:!0,onOpenChange:e=>!e&&n(),children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Add a `,e.display_name,` account`]}),(0,K.jsxs)(S,{children:[`Accounts are isolated config dirs under this profile. Naming one is enough — Puddle creates it and takes you straight to `,e.display_name,`’s login. To reuse an account you already have on this machine, give its config directory: it is copied in and the original is never touched.`]})]}),(0,K.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,K.jsx)(T,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,K.jsx)(O,{value:s,onValueChange:c,placeholder:`(optional) existing config dir, e.g. ~/.claude`,hints:(l.data?.entries??[]).map(e=>({value:e.path,label:e.name}))})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,K.jsxs)(v,{disabled:!f||i.isPending,onClick:p,children:[(0,K.jsx)(ue,{}),`Add account`]})]})]})})}function st({account:e,gateOpen:t,installed:n}){let r=Oe(),i=xe(),a=Ee(),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(e.label),f=(0,G.useRef)(null);return(0,G.useEffect)(()=>d(e.label),[e.label]),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{ref:f,value:u,onChange:e=>d(e.target.value),onBlur:()=>{let t=u.trim();if(t!==e.label){if(t===``){d(e.label);return}i.mutate({id:e.id,label:t},{onError:t=>{E(t),d(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(d(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full min-w-0 truncate rounded-sm bg-transparent px-1 py-0.5 text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,K.jsxs)(`button`,{type:`button`,title:`Rename account`,onClick:()=>{f.current?.focus(),f.current?.select()},className:`shrink-0 rounded-sm p-0.5 text-fg-muted transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(w,{className:`size-3`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Rename account`})]})]}),(0,K.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,K.jsx)(L,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>E(e)})})]}),(0,K.jsxs)(v,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>E(e)}),children:[(0,K.jsx)(ve,{}),e.logged_in?`Re-login`:`Login`]}),(0,K.jsxs)(v,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,K.jsx)(Ce,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,K.jsx)(be,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,K.jsx)(C,{open:c,onOpenChange:l,children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Delete `,(0,K.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,K.jsx)(S,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),E(e)}}),children:`Delete account`})]})]})})]})}function ct(){let e=l(),t=ye(),n=_e(e??void 0),r=U(e??void 0),a=Oe(),[o,s]=(0,G.useState)(null),[c,u]=(0,G.useState)(null),d=r.data?.allowSkipPermissions===!0;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[],r=e.available!==!1;return(0,K.jsxs)(`div`,{className:`mb-5`,children:[(0,K.jsx)(J,{label:e.display_name,description:r?`Accounts are initialised in config dirs owned by this profile.`:`No ${e.binary??e.id} on the daemon’s PATH. Install it or add its directory to the agent search path in Sessions.`,className:`py-1`,children:(0,K.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.id})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,K.jsx)(st,{account:t,gateOpen:d&&e.capabilities.skip_permissions,installed:r},t.id)),(0,K.jsx)(`div`,{className:`flex`,children:(0,K.jsxs)(v,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>u(e),children:[(0,K.jsx)(ue,{}),`Add account`]})})]})]},e.id)}),o&&(0,K.jsx)(be,{stream:o.stream,label:o.label,hint:o.hint,onClose:()=>s(null)}),c!==null&&e!==null&&(0,K.jsx)(ot,{agent:c,profileId:e,onClose:()=>u(null),onCreated:(e,t)=>{if(t){e.logged_in||i.info(`Imported without credentials — press Login to authenticate.`);return}a.mutate(e.id,{onSuccess:t=>s({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>E(e)})}})]})}function lt(){let e=Se(),t=I(),[n,r]=(0,G.useState)(``);return(0,G.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,K.jsx)(J,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH; helps find agent CLIs like claude (e.g. ~/.local/bin).`,htmlFor:`agent-path`,children:(0,K.jsx)(T,{id:`agent-path`,type:`text`,className:`w-64 text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function ut({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=re(e,n),o=n.sessionDefaults??{},[s,c]=(0,G.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,K.jsx)(J,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,K.jsx)(T,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,K.jsx)(J,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,K.jsx)(L,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,K.jsx)(J,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`Start on working copy of the selected branch instead of sharing one directory.`,htmlFor:`${e}-default-dir`,children:(0,K.jsx)(L,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function dt(){return(0,K.jsx)(J,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,K.jsx)(q,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:z().terminalScrollback,onCommit:e=>B({terminalScrollback:e})})})}function ft({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)(D,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,K.jsx)(v,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var pt={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 mt({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)(T,{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(pt,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)(v,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,K.jsx)(v,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(s),t(s)},children:`Reset to default`})]})]})}function ht(){let e=l(),t=V().data?.find(t=>t.id===e),n=U(e??void 0),i=W(e??``),[a,s]=(0,G.useState)(!1),[c,u]=(0,G.useState)(``),d=n.data?.allowSkipPermissions===!0,f=e=>i.mutate({allowSkipPermissions:e},{onSuccess:()=>{s(!1),u(``)},onError:e=>E(e)}),p=e=>t=>i.mutate({[e]:t},{onError:e=>E(e)});return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Sessions`}),(0,K.jsx)(J,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,K.jsx)(L,{id:`gate`,checked:d,onCheckedChange:e=>{e?s(!0):f(!1)}})}),(0,K.jsx)(J,{label:`Capture exported env variables`,description:n.data?.captureSessionEnv===!1?`No variables are captured or injected; already-captured variabless are kept for when this is re-enabled.`:`Variables exported in a session persist and are re-injected upon terminal and agent restarts.`,htmlFor:`capture-env`,children:(0,K.jsx)(L,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:i.isPending,onCheckedChange:e=>i.mutate({captureSessionEnv:e},{onError:e=>E(e)})})}),(0,K.jsx)(lt,{}),(0,K.jsx)(dt,{}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{children:`New session defaults`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ut,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>i.mutate({sessionDefaults:e},{onError:e=>E(e)}),pending:i.isPending},`${e}:agent-seed`),(0,K.jsx)(ut,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>i.mutate({sessionDefaults:e},{onError:e=>E(e)}),pending:i.isPending},`${e}:terminal-seed`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{note:`Sent to agent as opening message when a session (re)starts. You can make this empty.`,children:`Launch text`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ft,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??m,defaultText:m,onSave:p(`onboardingTemplate`),pending:i.isPending},`${e}:onboarding`),(0,K.jsx)(ft,{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:p(`concurrentTemplate`),pending:i.isPending},`${e}:concurrent`),(0,K.jsx)(ft,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??o,defaultText:o,onSave:p(`restartTemplate`),pending:i.isPending},`${e}:restart`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{children:`Tab title`}),n.data&&(0,K.jsx)(mt,{initial:n.data.tabTitleTemplate||"${name}",onSave:p(`tabTitleTemplate`),pending:i.isPending},`${e}:tab-title`)]}),(0,K.jsx)(C,{open:a,onOpenChange:e=>{e||(s(!1),u(``))},children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{className:`flex items-center gap-2`,children:[(0,K.jsx)(et,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,K.jsx)(S,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,K.jsx)(`p`,{children:`A prompt-free agent acts unattended, with your credentials, inside its worktree — and nothing technically stops a shell command from reaching outside it. It can:`}),(0,K.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,K.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,K.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,K.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,K.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,K.jsx)(`p`,{children:`Only open this gate if every account you opt in runs work you would trust a colleague to run unsupervised on this machine.`}),(0,K.jsx)(`p`,{className:`text-fg-muted`,children:`Opening it also records the agent’s own bypass-permissions acceptance for this profile’s accounts, so the skip actually takes effect.`})]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(k,{htmlFor:`confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,K.jsx)(T,{id:`confirm-name`,value:c,onChange:e=>u(e.target.value),autoFocus:!0})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>{s(!1),u(``)},children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:c!==t?.name||i.isPending,onClick:()=>f(!0),children:`Open the gate`})]})]})})]})}var gt={desktop:!0,sound:!1,muted_projects:[]};function _t(){let[e,t]=(0,G.useState)(R);return(0,G.useEffect)(()=>{let e=()=>t(R());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(R())]}function vt({permission:e,onRequest:t}){return e===`granted`?null:(0,K.jsxs)(`p`,{className:`pb-2 text-xs text-warning`,children:[e==="default"&&(0,K.jsxs)(K.Fragment,{children:[`The browser has not been asked for permission yet, so nothing will show —`,` `,(0,K.jsx)(`button`,{type:`button`,onClick:t,className:`underline underline-offset-2 transition-colors hover:text-fg`,children:`request it now`}),`.`]}),e===`denied`&&`Blocked by the browser — allow notifications for this site in its site settings, then return here.`,e===`unsupported`&&`This browser cannot show desktop notifications.`]})}function yt(){let e=l(),t=U(e??void 0),n=W(e??``),r=Ue(e??void 0),[i,a]=_t(),o={...gt,...t.data?.notifications??{}},s=e=>n.mutate({notifications:e},{onError:e=>E(e)}),c=()=>{typeof Notification>`u`||Notification.requestPermission().then(a)};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Notifications`}),(0,K.jsx)(J,{label:`Desktop notification on waiting`,htmlFor:`notify-desktop`,children:(0,K.jsx)(L,{id:`notify-desktop`,checked:o.desktop,onCheckedChange:e=>{e&&c(),s({...o,desktop:e})}})}),o.desktop&&(0,K.jsx)(vt,{permission:i,onRequest:c}),(0,K.jsx)(J,{label:`Sound`,htmlFor:`notify-sound`,children:(0,K.jsx)(L,{id:`notify-sound`,checked:o.sound,onCheckedChange:e=>s({...o,sound:e})})}),(0,K.jsx)(J,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,K.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[o.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)(L,{checked:o.muted_projects.includes(e.id),onCheckedChange:t=>s({...o,muted_projects:t?[...o.muted_projects,e.id]:o.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function bt(){let e=z();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Editor`}),(0,K.jsx)(J,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,K.jsx)(q,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>B({editorTabSize:e})})}),(0,K.jsx)(J,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,K.jsx)(L,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>B({editorWordWrap:e})})}),(0,K.jsx)(J,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,K.jsx)(T,{id:`editor-link-host`,type:`text`,placeholder:Be.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>B({editorLinkSshHost:e.target.value})})})]})}function xt({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=p(e.nativeEvent);t&&(n(t),a(!1))},className:A(`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…`:u(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)(Qe,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function St(){let e=l(),t=U(e??void 0),n=W(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of g){let t=i(e.id,d(e));a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>E(e)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>E(e)})};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Hotkeys`}),(0,K.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),(0,K.jsx)(J,{label:`App shortcuts in terminals`,description:t.data?.terminalAppShortcuts===!1?`A focused terminal receives these keys instead.`:`The shortcuts below work while a terminal is focused.`,htmlFor:`terminal-app-shortcuts`,className:`mb-4`,children:(0,K.jsx)(L,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>E(e)})})}),h.map(e=>{let t=g.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,d(e)),n=(a.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,K.jsx)(J,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,K.jsx)(xt,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(e.id)})},e.id)})]},e)})]})}var Ct=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Z=65,Q=Object.fromEntries([...Ct].map((e,t)=>[e,t])),wt=`H`,Tt=(()=>{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 Et(e){let t=4294967295;for(let n of e)t=Tt[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function Dt(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function Ot(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 kt(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function At(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function jt(e,t){let n=(t%Z+Z)%Z,r=``;for(let t of e){let e=Q[t];r+=e===void 0?t:Ct[(e+n)%Z]}return r}async function Mt(e){let t=await kt(JSON.stringify(e));return jt(Dt(t)+Et(t),1+Math.floor(Math.random()*(Z-1)))}async function Nt(e){let t=e.trim(),n=t[0];if(!n||Q[n]===void 0)throw Error(`Not a settings export.`);let r=jt(t,-((Q[n]-Q[wt]+Z)%Z));if(r.length<9||r[0]!==wt)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=Ot(i);if(Et(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await At(o))}var Pt=`puddle.sync-selection`;function Ft(){try{let e=JSON.parse(localStorage.getItem(Pt)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return de.map(e=>e.id)}function It({selected:e,onToggle:t}){return(0,K.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:de.map(n=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(L,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function Lt(){let e=l(),t=U(e??void 0),n=V().data?.find(t=>t.id===e),r=Ie(e??void 0,void 0),a=W(e??``),o=H(),s=oe(),c=Te(),u=De(),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(!1),[_,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(Ft),S=n&&c.data?pe(c.data.file,n.name):void 0,C=S?.enabled===!0,w=C&&S?S.groups:b,T=()=>({client:me(),theme:ce(),profileSettings:t.data??{},profile:n??{},scratchpad:r.data??[]}),ee={setClient:e=>B(e),setTheme:e=>{typeof e==`string`&&se(e)},patchProfileSettings:e=>a.mutate(e,{onError:e=>E(e)}),patchProfileColumns:t=>{e&&o.mutate({id:e,...t},{onError:e=>E(e)})},createScratchpad:t=>{if(e)for(let n of t)s.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},O=(e,t)=>{n&&u.mutate({profile:n.name,entry:{enabled:e.enabled??C,groups:t,doc:Re(t,T()),updatedAt:new Date().toISOString()}},{onError:e=>E(e)})},k=(e,t)=>{let n=t?[...w,e]:w.filter(t=>t!==e);x(n),localStorage.setItem(Pt,JSON.stringify(n)),C&&O({},n)},A=async()=>{y(!0);try{let e=he(await Nt(d.trim()),ee,{profileSettings:t.data??{},scratchpad:r.data??[]});e.length===0?i.error(`Nothing recognised to import.`):(i.success(`Imported ${e.join(`, `)}.`),f(``))}catch(e){i.error(e.message)}finally{y(!1)}},j=async()=>{y(!0);try{let e=await Mt(Re(w,T()));m(e),await navigator.clipboard?.writeText(e),i.success(`Copied to clipboard`)}finally{y(!1)}};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Sync`}),(0,K.jsx)(`p`,{className:`mb-5 text-xs text-fg-muted`,children:`Carry your settings between machines. Accounts, repositories, and anything host-specific are never included. Applies to this profile.`}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),c.data?.available===!1?(0,K.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:`Not available in this cockpit — start the UI with the Puddle CLI to sync across windows.`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Sync selected groups through this machine’s`,` `,(0,K.jsx)(`span`,{className:`text-fg-secondary`,children:`~/.puddle`}),`, so every Puddle window stays in step for profiles named`,` `,(0,K.jsx)(`span`,{className:`text-fg-secondary`,children:n?.name??`…`}),`.`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(L,{checked:C,disabled:!n||c.isLoading||u.isPending,onCheckedChange:e=>O({enabled:e},w)}),`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)(ne,{className:`size-3.5`}):(0,K.jsx)(ie,{className:`size-3.5`}),`Choose what to sync`]}),h&&(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(It,{selected:w,onToggle:k})})]}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,K.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:`Builds a Puddle magic string that encodes settings from the checklist above.`}),(0,K.jsx)(v,{size:`sm`,disabled:_,onClick:()=>void j(),children:`Export & copy`}),p&&(0,K.jsx)(D,{readOnly:!0,value:p,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`mt-2 resize-y font-mono text-xs`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,K.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste a Puddle magic string to import its settings.`}),(0,K.jsx)(D,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:`Paste a settings export…`,rows:3,spellCheck:!1,className:`resize-y font-mono text-xs`}),(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(v,{size:`sm`,disabled:!d.trim()||_,onClick:()=>void A(),children:`Import`})})]})]})}function Rt({repo:e}){let t=Ve(),n=ze(),[r,a]=(0,G.useState)(e.default_base_branch),[o,s]=(0,G.useState)(e.onboarding_notes??``),c=e=>E(e);return(0,K.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.path}),(0,K.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,K.jsxs)(v,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>i.success(`Fetched.`),onError:c}),children:[(0,K.jsx)(we,{}),`Fetch now`]})]}),(0,K.jsxs)(J,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,K.jsx)(T,{id:`base-${e.id}`,value:r,onChange:e=>a(e.target.value),className:`w-40`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:r===e.default_base_branch||t.isPending,onClick:()=>t.mutate({id:e.id,default_base_branch:r},{onError:c}),children:`Save`})]}),(0,K.jsx)(J,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,K.jsx)(L,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:c})})}),(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)(D,{id:`notes-${e.id}`,value:o,onChange:e=>s(e.target.value),rows:4}),(0,K.jsx)(`div`,{children:(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:o===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:o},{onError:c}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,K.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Orphan worktrees — directories no session claims. Puddle never deletes these automatically; remove them by hand if unwanted.`}),(0,K.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,K.jsx)(`li`,{className:`truncate text-2xs text-fg-muted`,children:e},e))})]})]})}function zt(){let e=Me();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Projects`}),e.data?.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No projects yet — create one from the dashboard, pointing at a repository.`}),e.data?.map(e=>(0,K.jsx)(Rt,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=I();return(0,K.jsx)(J,{label:e,description:t,htmlFor:`host-${n}`,children:(0,K.jsx)(T,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{if(e.target.value.trim()===``){e.target.value=String(r[n]);return}let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>E(e)})}})})}function Bt(){let e=Se(),t=I(),n=ke();return e.data?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{note:`Affects all profiles on this host`,children:`Host`}),(0,K.jsx)(J,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,K.jsx)(T,{id:`host-displayName`,type:`text`,maxLength:64,className:`w-48`,placeholder:n.data?.hostname,defaultValue:e.data.displayName,onBlur:n=>{let r=n.target.value.trim();r!==e.data.displayName&&t.mutate({displayName:r},{onError:e=>E(e)})}})}),(0,K.jsx)($,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,K.jsx)($,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,K.jsx)($,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,K.jsx)($,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,K.jsx)(J,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,K.jsx)(L,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>E(e)})})})]}):null}var Vt=[{id:`appearance`,label:`Appearance`,icon:le,render:()=>(0,K.jsx)(rt,{})},{id:`profile`,label:`Profile`,icon:Ke,render:()=>(0,K.jsx)(at,{})},{id:`accounts`,label:`Accounts`,icon:nt,render:()=>(0,K.jsx)(ct,{})},{id:`sessions`,label:`Sessions`,icon:tt,render:()=>(0,K.jsx)(ht,{})},{id:`editor`,label:`Editor`,icon:Xe,render:()=>(0,K.jsx)(bt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Ze,render:()=>(0,K.jsx)(St,{})},{id:`notifications`,label:`Notifications`,icon:Ye,render:()=>(0,K.jsx)(yt,{})},{id:`projects`,label:`Projects`,icon:ee,render:()=>(0,K.jsx)(zt,{})},{id:`host`,label:`Host`,icon:$e,render:()=>(0,K.jsx)(Bt,{})},{id:`sync`,label:`Sync`,icon:we,render:()=>(0,K.jsx)(Lt,{})}],Ht={terminal:`sessions`,repositories:`projects`};function Ut(){let e=Ne(),t=e===null?null:Ht[e]??e,n=Vt.find(e=>e.id===t)??Vt[0];return(0,K.jsx)(C,{open:e!==null,onOpenChange:e=>!e&&Le(),children:(0,K.jsxs)(b,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,K.jsx)(x,{className:`sr-only`,children:`Settings`}),(0,K.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,K.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),Vt.map(({id:e,label:t,icon:r})=>(0,K.jsxs)(`button`,{onClick:()=>Pe(e),className:A(`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{Ut 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{B as r,L as i,T as a,_ as o,b as s,i as c,o as l,r as u,s as d}from"./hotkeys-BoAqfYKZ.js";import{t as f}from"./utils-B6KiDbIe.js";import{En as p,Ht as m,On as h,X as g,in as _,lt as v,ut as y,wn as ee}from"./index-DyI3xhOE.js";import{t as te}from"./ssh-mode-LZIS09C5.js";var b=e(t(),1),ne=Object.defineProperty,x=Object.getOwnPropertyDescriptor,re=(e,t)=>{for(var n in t)ne(e,n,{get:t[n],enumerable:!0})},S=(e,t,n,r)=>{for(var i=r>1?void 0:r?x(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&&ne(t,n,i),i},C=(e,t)=>(n,r)=>t(n,r,e),ie=`Terminal input`,w={get:()=>ie,set:e=>ie=e},ae=`Too much output to announce, navigate to rows manually to read`,oe={get:()=>ae,set:e=>ae=e};function se(e){return e.replace(/\r?\n/g,`\r`)}function T(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function E(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function D(e,t,n,r){e.stopPropagation(),e.clipboardData&&ce(e.clipboardData.getData(`text/plain`),t,n,r)}function ce(e,t,n,r){e=se(e),e=T(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function le(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 ue(e,t,n,r,i){le(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function O(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function de(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 fe=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}},pe=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}},me=``,he=` `,ge=class e{constructor(){this.fg=0,this.bg=0,this.extended=new _e}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}},_e=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}},ve=class e extends ge{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new _e,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?O(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()]}},ye=`di$target`,be=`di$dependencies`,xe=new Map;function Se(e){return e[be]||[]}function k(e){if(xe.has(e))return xe.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Ce(t,e,r)};return t._id=e,xe.set(e,t),t}function Ce(e,t,n){t[ye]===t?t[be].push({id:e,index:n}):(t[be]=[{id:e,index:n}],t[ye]=t)}var we=k(`BufferService`),Te=k(`CoreMouseService`),Ee=k(`CoreService`),De=k(`CharsetService`),Oe=k(`InstantiationService`),ke=k(`LogService`),Ae=k(`OptionsService`),je=k(`OscLinkService`),Me=k(`UnicodeService`),Ne=k(`DecorationService`),Pe=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 ve,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):Fe(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)}};Pe=S([C(0,we),C(1,Ae),C(2,je)],Pe);function Fe(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{B as r,L as i,T as a,_ as o,b as s,i as c,o as l,r as u,s as d}from"./hotkeys-CGVAxX-R.js";import{t as f}from"./utils-B6KiDbIe.js";import{En as p,Ht as m,On as h,X as g,in as _,lt as v,ut as y,wn as ee}from"./index-De_cN03H.js";import{t as te}from"./ssh-mode-CJ0lbAR5.js";var b=e(t(),1),ne=Object.defineProperty,x=Object.getOwnPropertyDescriptor,re=(e,t)=>{for(var n in t)ne(e,n,{get:t[n],enumerable:!0})},S=(e,t,n,r)=>{for(var i=r>1?void 0:r?x(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&&ne(t,n,i),i},C=(e,t)=>(n,r)=>t(n,r,e),ie=`Terminal input`,w={get:()=>ie,set:e=>ie=e},ae=`Too much output to announce, navigate to rows manually to read`,oe={get:()=>ae,set:e=>ae=e};function se(e){return e.replace(/\r?\n/g,`\r`)}function T(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function E(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function D(e,t,n,r){e.stopPropagation(),e.clipboardData&&ce(e.clipboardData.getData(`text/plain`),t,n,r)}function ce(e,t,n,r){e=se(e),e=T(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function le(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 ue(e,t,n,r,i){le(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function O(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function de(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 fe=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}},pe=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}},me=``,he=` `,ge=class e{constructor(){this.fg=0,this.bg=0,this.extended=new _e}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}},_e=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}},ve=class e extends ge{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new _e,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?O(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()]}},ye=`di$target`,be=`di$dependencies`,xe=new Map;function Se(e){return e[be]||[]}function k(e){if(xe.has(e))return xe.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Ce(t,e,r)};return t._id=e,xe.set(e,t),t}function Ce(e,t,n){t[ye]===t?t[be].push({id:e,index:n}):(t[be]=[{id:e,index:n}],t[ye]=t)}var we=k(`BufferService`),Te=k(`CoreMouseService`),Ee=k(`CoreService`),De=k(`CharsetService`),Oe=k(`InstantiationService`),ke=k(`LogService`),Ae=k(`OptionsService`),je=k(`OscLinkService`),Me=k(`UnicodeService`),Ne=k(`DecorationService`),Pe=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 ve,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):Fe(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)}};Pe=S([C(0,we),C(1,Ae),C(2,je)],Pe);function Fe(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 Ie=k(`CharSizeService`),Le=k(`CoreBrowserService`),Re=k(`MouseService`),ze=k(`RenderService`),Be=k(`SelectionService`),Ve=k(`CharacterJoinerService`),He=k(`ThemeService`),Ue=k(`LinkProviderService`),We=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Xe.isErrorNoTelemetry(e)?new Xe(e.message+`
4
4
 
@@ -114,4 +114,4 @@ out vec4 outColor;
114
114
 
115
115
  void main() {
116
116
  outColor = v_color;
117
- }`,qu=8,Ju=qu*Float32Array.BYTES_PER_ELEMENT,Yu=20*qu,Xu=class{constructor(){this.attributes=new Float32Array(Yu),this.count=0}},Zu=0,Qu=0,$u=0,ed=0,td=0,nd=0,rd=0,id=class extends Pc{constructor(e,t,n,r){super(),this._terminal=e,this._gl=t,this._dimensions=n,this._themeService=r,this._vertices=new Xu,this._verticesCursor=new Xu;let i=this._gl;this._program=X(Tu(i,Gu,Ku)),this._register(jc(()=>i.deleteProgram(this._program))),this._projectionLocation=X(i.getUniformLocation(this._program,`u_projection`)),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),o=i.createBuffer();this._register(jc(()=>i.deleteBuffer(o))),i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,a,i.STATIC_DRAW),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let s=new Uint8Array([0,1,2,3]),c=i.createBuffer();this._register(jc(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=X(i.createBuffer()),this._register(jc(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,Ju,0),i.vertexAttribDivisor(0,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,Ju,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,4,i.FLOAT,!1,Ju,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(2,1),this._updateCachedColors(r.colors),this._register(this._themeService.onChangeColors(e=>{this._updateCachedColors(e),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(e){let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),t.uniformMatrix4fv(this._projectionLocation,!1,wu),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,e.attributes,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,e.count)}handleResize(){this._updateViewportRectangle()}setDimensions(e){this._dimensions=e}_updateCachedColors(e){this._bgFloat=this._colorToFloat32Array(e.background),this._cursorFloat=this._colorToFloat32Array(e.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(e){let t=this._terminal,n=this._vertices,r=1,i,a,o,s,c,l,u,d,f,p,m;for(i=0;i<t.rows;i++){for(o=-1,s=0,c=0,l=!1,a=0;a<t.cols;a++)u=(i*t.cols+a)*zu,d=e.cells[u+Bu],f=e.cells[u+Vu],p=!!(f&67108864),(d!==s||f!==c&&(l||p))&&((s!==0||l&&c!==0)&&(m=r++*qu,this._updateRectangle(n,m,c,s,o,a,i)),o=a,s=d,c=f,l=p);(s!==0||l&&c!==0)&&(m=r++*qu,this._updateRectangle(n,m,c,s,o,t.cols,i))}n.count=r}updateCursor(e){let t=this._verticesCursor,n=e.cursor;if(!n||n.style===`block`){t.count=0;return}let r,i=0;(n.style===`bar`||n.style===`outline`)&&(r=i++*qu,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.style===`bar`?n.dpr*n.cursorWidth:n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(n.style===`underline`||n.style===`outline`)&&(r=i++*qu,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,(n.y+1)*this._dimensions.device.cell.height-n.dpr,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat)),n.style===`outline`&&(r=i++*qu,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat),r=i++*qu,this._addRectangleFloat(t.attributes,r,(n.x+n.width)*this._dimensions.device.cell.width-n.dpr,n.y*this._dimensions.device.cell.height,n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),t.count=i}_updateRectangle(e,t,n,r,i,a,o){if(n&67108864)switch(n&50331648){case 16777216:case 33554432:Zu=this._themeService.colors.ansi[n&255].rgba;break;case 50331648:Zu=(n&16777215)<<8;break;case 0:default:Zu=this._themeService.colors.foreground.rgba}else switch(r&50331648){case 16777216:case 33554432:Zu=this._themeService.colors.ansi[r&255].rgba;break;case 50331648:Zu=(r&16777215)<<8;break;case 0:default:Zu=this._themeService.colors.background.rgba}e.attributes.length<t+4&&(e.attributes=Du(e.attributes,this._terminal.rows*this._terminal.cols*qu)),Qu=i*this._dimensions.device.cell.width,$u=o*this._dimensions.device.cell.height,ed=(Zu>>24&255)/255,td=(Zu>>16&255)/255,nd=(Zu>>8&255)/255,rd=1,this._addRectangle(e.attributes,t,Qu,$u,(a-i)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,ed,td,nd,rd)}_addRectangle(e,t,n,r,i,a,o,s,c,l){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o,e[t+5]=s,e[t+6]=c,e[t+7]=l}_addRectangleFloat(e,t,n,r,i,a,o){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o[0],e[t+5]=o[1],e[t+6]=o[2],e[t+7]=o[3]}_colorToFloat32Array(e){return new Float32Array([(e.rgba>>24&255)/255,(e.rgba>>16&255)/255,(e.rgba>>8&255)/255,(e.rgba&255)/255])}},ad=class extends Pc{constructor(e,t,n,r,i,a,o,s){super(),this._container=t,this._alpha=i,this._coreBrowserService=a,this._optionsService=o,this._themeService=s,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-${n}-layer`),this._canvas.style.zIndex=r.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(t=>{this._refreshCharAtlas(e,t),this.reset(e)})),this._register(jc(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=X(this._canvas.getContext(`2d`,{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(e){}handleFocus(e){}handleCursorMove(e){}handleGridChanged(e,t,n){}handleSelectionChanged(e,t,n,r=!1){}_setTransparency(e,t){if(t===this._alpha)return;let n=this._canvas;this._alpha=t,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,n),this._refreshCharAtlas(e,this._themeService.colors),this.handleGridChanged(e,0,e.rows-1)}_refreshCharAtlas(e,t){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=_u(e,this._optionsService.rawOptions,t,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(e,t){this._deviceCellWidth=t.device.cell.width,this._deviceCellHeight=t.device.cell.height,this._deviceCharWidth=t.device.char.width,this._deviceCharHeight=t.device.char.height,this._deviceCharLeft=t.device.char.left,this._deviceCharTop=t.device.char.top,this._canvas.width=t.device.canvas.width,this._canvas.height=t.device.canvas.height,this._canvas.style.width=`${t.css.canvas.width}px`,this._canvas.style.height=`${t.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(e,this._themeService.colors)}_fillBottomLineAtCells(e,t,n=1){this._ctx.fillRect(e*this._deviceCellWidth,(t+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,n*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(e,t,n,r){this._alpha?this._ctx.clearRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight))}_fillCharTrueColor(e,t,n,r){this._ctx.font=this._getFont(e,!1,!1),this._ctx.textBaseline=bl,this._clipCell(n,r,t.getWidth()),this._ctx.fillText(t.getChars(),n*this._deviceCellWidth+this._deviceCharLeft,r*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(e,t,n){this._ctx.beginPath(),this._ctx.rect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(e,t,n){let r=t?e.options.fontWeightBold:e.options.fontWeight;return`${n?`italic`:``} ${r} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}},od=class extends ad{constructor(e,t,n,r,i,a,o){super(n,e,`link`,t,!0,i,a,o),this._register(r.onShowLinkUnderline(e=>this._handleShowLinkUnderline(e))),this._register(r.onHideLinkUnderline(e=>this._handleHideLinkUnderline(e)))}resize(e,t){super.resize(e,t),this._state=void 0}reset(e){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let e=this._state.y2-this._state.y1-1;e>0&&this._clearCells(0,this._state.y1+1,this._state.cols,e),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(e){if(e.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:e.fg!==void 0&&hu(e.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[e.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,e.y1===e.y2)this._fillBottomLineAtCells(e.x1,e.y1,e.x2-e.x1);else{this._fillBottomLineAtCells(e.x1,e.y1,e.cols-e.x1);for(let t=e.y1+1;t<e.y2;t++)this._fillBottomLineAtCells(0,t,e.cols);this._fillBottomLineAtCells(0,e.y2,e.x2)}this._state=e}_handleHideLinkUnderline(e){this._clearCurrentLink()}},sd=typeof window==`object`?window:globalThis,cd=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Z,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Z,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};cd.INSTANCE=new cd;var ld=cd;function ud(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}ld.INSTANCE.onDidChangeZoomLevel,ld.INSTANCE.onDidChangeFullscreen;var dd=typeof navigator==`object`?navigator.userAgent:``;dd.indexOf(`Firefox`);var fd=dd.indexOf(`AppleWebKit`)>=0;!(dd.indexOf(`Chrome`)>=0)&&dd.indexOf(`Safari`),dd.indexOf(`Electron/`),dd.indexOf(`Android`);var pd=!1;if(typeof sd.matchMedia==`function`){let e=sd.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=sd.matchMedia(`(display-mode: fullscreen)`);pd=e.matches,ud(sd,e,({matches:e})=>{pd&&t.matches||(pd=e)})}function md(){return pd}var hd=`en`,gd=!1,_d=!1,vd=!1,yd=hd,bd,xd=globalThis,Sd;typeof xd.vscode<`u`&&typeof xd.vscode.process<`u`?Sd=xd.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(Sd=process);var Cd=typeof Sd?.versions?.electron==`string`&&Sd?.type===`renderer`;if(typeof Sd==`object`){Sd.platform,Sd.platform,gd=Sd.platform===`linux`,gd&&Sd.env.SNAP&&Sd.env.SNAP_REVISION,Sd.env.CI||Sd.env.BUILD_ARTIFACTSTAGINGDIRECTORY,yd=hd;let e=Sd.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,yd=t.resolvedLanguage||hd,t.languagePack?.translationsConfigFile}catch{}_d=!0}else typeof navigator==`object`&&!Cd?(bd=navigator.userAgent,bd.indexOf(`Windows`),bd.indexOf(`Macintosh`),(bd.indexOf(`Macintosh`)>=0||bd.indexOf(`iPad`)>=0||bd.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,gd=bd.indexOf(`Linux`)>=0,bd?.indexOf(`Mobi`),vd=!0,yd=globalThis._VSCODE_NLS_LANGUAGE||hd,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var wd=_d;vd&&typeof xd.importScripts==`function`&&xd.origin;var Td=bd,Ed=yd,Dd;(e=>{function t(){return Ed}e.value=t;function n(){return Ed.length===2?Ed===`en`:Ed.length>=3&&Ed[0]===`e`&&Ed[1]===`n`&&Ed[2]===`-`}e.isDefaultVariant=n;function r(){return Ed===`en`}e.isDefault=r})(Dd||={});var Od=typeof xd.postMessage==`function`&&!xd.importScripts;(()=>{if(Od){let e=[];xd.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),xd.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var kd=!!(Td&&Td.indexOf(`Chrome`)>=0);Td&&Td.indexOf(`Firefox`),!kd&&Td&&Td.indexOf(`Safari`),Td&&Td.indexOf(`Edg/`),Td&&Td.indexOf(`Android`);var Ad=typeof navigator==`object`?navigator:{};wd||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||Ad&&Ad.clipboard&&Ad.clipboard.writeText,wd||Ad&&Ad.clipboard&&Ad.clipboard.readText,wd||md()||Ad.keyboard,`ontouchstart`in sd||Ad.maxTouchPoints,sd.PointerEvent&&(`ontouchstart`in sd||navigator.maxTouchPoints);var jd=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Md=new jd,Nd=new jd,Pd=new jd;Array(230);var Fd;(e=>{function t(e){return Md.keyCodeToStr(e)}e.toString=t;function n(e){return Md.strToKeyCode(e)}e.fromString=n;function r(e){return Nd.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return Pd.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return Nd.strToKeyCode(e)||Pd.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return Md.keyCodeToStr(e)}e.toElectronAccelerator=o})(Fd||={});var Id=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Ld;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof Rd?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Gl.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Id})})(Ld||={});var Rd=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Id:(this._emitter||=new Z,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var zd;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(zd||={});var Bd=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Z,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Gl.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Bd.EMPTY=Bd.fromArray([]);function Vd(e){return 55296<=e&&e<=56319}function Hd(e){return 56320<=e&&e<=57343}function Ud(e,t){return(e-55296<<10)+(t-56320)+65536}function Wd(e){return Gd(e,0)}function Gd(e,t){switch(typeof e){case`object`:return e===null?Kd(349,t):Array.isArray(e)?Yd(e,t):Xd(e,t);case`string`:return Jd(e,t);case`boolean`:return qd(e,t);case`number`:return Kd(e,t);case`undefined`:return Kd(937,t);default:return Kd(617,t)}}function Kd(e,t){return(t<<5)-t+e|0}function qd(e,t){return Kd(e?433:863,t)}function Jd(e,t){t=Kd(149417,t);for(let n=0,r=e.length;n<r;n++)t=Kd(e.charCodeAt(n),t);return t}function Yd(e,t){return t=Kd(104579,t),e.reduce((e,t)=>Gd(t,e),t)}function Xd(e,t){return t=Kd(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=Jd(n,t),Gd(e[n],t)),t)}function Zd(e,t,n=32){let r=n-t,i=~((1<<r)-1);return(e<<t|(i&e)>>>r)>>>0}function Qd(e,t=0,n=e.byteLength,r=0){for(let i=0;i<n;i++)e[t+i]=r}function $d(e,t,n=`0`){for(;e.length<t;)e=n+e;return e}function ef(e,t=32){return e instanceof ArrayBuffer?Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,`0`)).join(``):$d((e>>>0).toString(16),t/4)}var tf=class e{constructor(){this._h0=1732584193,this._h1=4023233417,this._h2=2562383102,this._h3=271733878,this._h4=3285377520,this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}update(e){let t=e.length;if(t===0)return;let n=this._buff,r=this._buffLen,i=this._leftoverHighSurrogate,a,o;for(i===0?(a=e.charCodeAt(0),o=0):(a=i,o=-1,i=0);;){let s=a;if(Vd(a))if(o+1<t){let t=e.charCodeAt(o+1);Hd(t)?(o++,s=Ud(a,t)):s=65533}else{i=a;break}else Hd(a)&&(s=65533);if(r=this._push(n,r,s),o++,o<t)a=e.charCodeAt(o);else break}this._buffLen=r,this._leftoverHighSurrogate=i}_push(e,t,n){return n<128?e[t++]=n:n<2048?(e[t++]=192|(n&1984)>>>6,e[t++]=128|(n&63)>>>0):n<65536?(e[t++]=224|(n&61440)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0):(e[t++]=240|(n&1835008)>>>18,e[t++]=128|(n&258048)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0),t>=64&&(this._step(),t-=64,this._totalLen+=64,e[0]=e[64],e[1]=e[65],e[2]=e[66]),t}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),ef(this._h0)+ef(this._h1)+ef(this._h2)+ef(this._h3)+ef(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,Qd(this._buff,this._buffLen),this._buffLen>56&&(this._step(),Qd(this._buff));let e=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(e/4294967296),!1),this._buffDV.setUint32(60,e%4294967296,!1),this._step()}_step(){let t=e._bigBlock32,n=this._buffDV;for(let e=0;e<64;e+=4)t.setUint32(e,n.getUint32(e,!1),!1);for(let e=64;e<320;e+=4)t.setUint32(e,Zd(t.getUint32(e-12,!1)^t.getUint32(e-32,!1)^t.getUint32(e-56,!1)^t.getUint32(e-64,!1),1),!1);let r=this._h0,i=this._h1,a=this._h2,o=this._h3,s=this._h4,c,l,u;for(let e=0;e<80;e++)e<20?(c=i&a|~i&o,l=1518500249):e<40?(c=i^a^o,l=1859775393):e<60?(c=i&a|i&o|a&o,l=2400959708):(c=i^a^o,l=3395469782),u=Zd(r,5)+c+s+l+t.getUint32(e*4,!1)&4294967295,s=o,o=a,a=Zd(i,30),i=r,r=u;this._h0=this._h0+r&4294967295,this._h1=this._h1+i&4294967295,this._h2=this._h2+a&4294967295,this._h3=this._h3+o&4294967295,this._h4=this._h4+s&4294967295}};tf._bigBlock32=new DataView(new ArrayBuffer(320));var{registerWindow:nf,getWindow:rf,getDocument:af,getWindows:of,getWindowsCount:sf,getWindowId:cf,getWindowById:lf,hasWindow:uf,onDidRegisterWindow:df,onWillUnregisterWindow:ff,onDidUnregisterWindow:pf}=function(){let e=new Map,t={window:sd,disposables:new Nc};e.set(sd.vscodeWindowId,t);let n=new Z,r=new Z,i=new Z;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return Pc.None;let a=new Nc,o={window:t,disposables:a.add(new Nc)};return e.set(t.vscodeWindowId,o),a.add(jc(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(hf(t,_f.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:sd},getDocument(e){return rf(e).document}}}(),mf=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function hf(e,t,n,r){return new mf(e,t,n,r)}var gf=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};gf.None=new gf(0,0),new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=Wd(n),a=r.get(i);if(a)a.users+=1;else{let o=new Z,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(jc(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var _f={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:fd?`webkitAnimationStart`:`animationstart`,ANIMATION_END:fd?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:fd?`webkitAnimationIteration`:`animationiteration`},vf=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;function yf(e,t,n,...r){let i=vf.exec(t);if(!i)throw Error(`Bad use of emmet`);let a=i[1]||`div`,o;return o=e===`http://www.w3.org/1999/xhtml`?document.createElement(a):document.createElementNS(e,a),i[3]&&(o.id=i[3]),i[4]&&(o.className=i[4].replace(/\./g,` `).trim()),n&&Object.entries(n).forEach(([e,t])=>{typeof t>`u`||(/^on\w+$/.test(e)?o[e]=t:e===`selected`?t&&o.setAttribute(e,`true`):o.setAttribute(e,t))}),o.append(...r),o}function bf(e,t,...n){return yf(`http://www.w3.org/1999/xhtml`,e,t,...n)}bf.SVG=function(e,t,...n){return yf(`http://www.w3.org/2000/svg`,e,t,...n)};var xf=class extends Pc{constructor(e,t,n,r,i,a,o,s,c){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._optionsService=o,this._themeService=s,this._cursorBlinkStateManager=new Fc,this._charAtlasDisposable=this._register(new Fc),this._observerDisposable=this._register(new Fc),this._model=new Wu,this._workCell=new Cu,this._workCell2=new Cu,this._rectangleRenderer=this._register(new Fc),this._glyphRenderer=this._register(new Fc),this._onChangeTextureAtlas=this._register(new Z),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Z),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Z),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new Z),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new Z),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`);let l={antialias:!1,depth:!1,preserveDrawingBuffer:c};if(this._gl=this._canvas.getContext(`webgl2`,l),!this._gl)throw Error(`WebGL2 not supported `+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new vl(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new od(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions=cl(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(o.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(hf(this._canvas,`webglcontextlost`,e=>{console.log(`webglcontextlost event received`),e.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn(`webgl context not restored; firing onContextLoss`),this._onContextLoss.fire(e)},3e3)})),this._register(hf(this._canvas,`webglcontextrestored`,e=>{console.warn(`webglcontextrestored event received`),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,vu(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=xu(this._canvas,this._coreBrowserService.window,(e,t)=>this._setCanvasDevicePixelDimensions(e,t)),this._register(this._coreBrowserService.onWindowChange(e=>{this._observerDisposable.value=xu(this._canvas,e,(e,t)=>this._setCanvasDevicePixelDimensions(e,t))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(jc(()=>{for(let e of this._renderLayers)e.dispose();this._canvas.parentElement?.removeChild(this._canvas),vu(this._terminal)}))}get textureAtlas(){return this._charAtlas?.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(e,t){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let e of this._renderLayers)e.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,this._rectangleRenderer.value?.setDimensions(this.dimensions),this._rectangleRenderer.value?.handleResize(),this._glyphRenderer.value?.setDimensions(this.dimensions),this._glyphRenderer.value?.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){for(let e of this._renderLayers)e.handleBlur(this._terminal);this._cursorBlinkStateManager.value?.pause(),this._requestRedrawViewport()}handleFocus(){for(let e of this._renderLayers)e.handleFocus(this._terminal);this._cursorBlinkStateManager.value?.resume(),this._requestRedrawViewport()}handleSelectionChanged(e,t,n){for(let r of this._renderLayers)r.handleSelectionChanged(this._terminal,e,t,n);this._model.selection.update(this._core,e,t,n),this._requestRedrawViewport()}handleCursorMove(){for(let e of this._renderLayers)e.handleCursorMove(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new id(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new Iu(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let e=_u(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize);this._charAtlas!==e&&(this._onChangeTextureAtlas.fire(e.pages[0].canvas),this._charAtlasDisposable.value=Ac(Gl.forward(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Gl.forward(e.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=e,this._charAtlas.warmUp(),this._glyphRenderer.value?.setAtlas(this._charAtlas)}_clearModel(e){this._model.clear(),e&&this._glyphRenderer.value?.clear()}clearTextureAtlas(){this._charAtlas?.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(e,t){if(!this._isAttached)if(this._core.screenElement?.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return;for(let n of this._renderLayers)n.handleGridChanged(this._terminal,e,t);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(e,t),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new bu(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let n=this._core,r=this._workCell,i,a,o,s,c,l,u=0,d=!0,f,p,m,h,g,_,v,y,ee;e=Cf(e,n.rows-1,0),t=Cf(t,n.rows-1,0);let te=this._coreService.decPrivateModes.cursorStyle??n.options.cursorStyle??`block`,b=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,ne=b-n.buffer.ydisp,x=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),re=-1,S=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let C=!1;for(a=e;a<=t;a++)for(o=a+n.buffer.ydisp,s=n.buffer.lines.get(o),this._model.lineLengths[a]=0,m=b===o,u=0,c=this._characterJoinerService.getJoinedCharacters(o),y=0;y<n.cols;y++){if(i=this._cellColorResolver.result.bg,s.loadCell(y,r),y===0&&(i=this._cellColorResolver.result.bg),l=!1,d=y>=u,f=y,c.length>0&&y===c[0][0]&&d){p=c.shift();let e=this._model.selection.isCellSelected(this._terminal,p[0],o);for(v=p[0]+1;v<p[1];v++)d&&=e===this._model.selection.isCellSelected(this._terminal,v,o);d&&=!m||x<p[0]||x>=p[1],d?(l=!0,r=new Sf(r,s.translateToString(!0,p[0],p[1]),p[1]-p[0]),f=p[1]-1):u=p[1]}if(h=r.getChars(),g=r.getCode(),v=(a*n.cols+y)*zu,this._cellColorResolver.resolve(r,y,o,this.dimensions.device.cell.width),S&&o===b&&(y===x&&(this._model.cursor={x,y:ne,width:r.getWidth(),style:this._coreBrowserService.isFocused?te:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},re=x+r.getWidth()-1),y>=x&&y<=re&&(this._coreBrowserService.isFocused&&te===`block`||this._coreBrowserService.isFocused===!1&&n.options.cursorInactiveStyle===`block`)&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),g!==0&&(this._model.lineLengths[a]=y+1),!(this._model.cells[v]===g&&this._model.cells[v+Bu]===this._cellColorResolver.result.bg&&this._model.cells[v+Vu]===this._cellColorResolver.result.fg&&this._model.cells[v+Hu]===this._cellColorResolver.result.ext)&&(C=!0,h.length>1&&(g|=Uu),this._model.cells[v]=g,this._model.cells[v+Bu]=this._cellColorResolver.result.bg,this._model.cells[v+Vu]=this._cellColorResolver.result.fg,this._model.cells[v+Hu]=this._cellColorResolver.result.ext,_=r.getWidth(),this._glyphRenderer.value.updateCell(y,a,g,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,h,_,i),l)){for(r=this._workCell,y++;y<=f;y++)ee=(a*n.cols+y)*zu,this._glyphRenderer.value.updateCell(y,a,0,0,0,0,Uc,0,0),this._model.cells[ee]=0,this._model.cells[ee+Bu]=this._cellColorResolver.result.bg,this._model.cells[ee+Vu]=this._cellColorResolver.result.fg,this._model.cells[ee+Hu]=this._cellColorResolver.result.ext;y--}}C&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let e=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:e,end:e})}},Sf=class extends Bl{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function Cf(e,t,n=0){return Math.max(Math.min(e,t),n)}var wf=`di$target`,Tf=`di$dependencies`,Ef=new Map;function Df(e){if(Ef.has(e))return Ef.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Of(t,e,r)};return t._id=e,Ef.set(e,t),t}function Of(e,t,n){t[wf]===t?t[Tf].push({id:e,index:n}):(t[Tf]=[{id:e,index:n}],t[wf]=t)}Df(`BufferService`),Df(`CoreMouseService`),Df(`CoreService`),Df(`CharsetService`),Df(`InstantiationService`),Df(`LogService`);var kf=Df(`OptionsService`);Df(`OscLinkService`),Df(`UnicodeService`),Df(`DecorationService`);var Af={trace:0,debug:1,info:2,warn:3,error:4,off:5},jf=`xterm.js: `,Mf=class extends Pc{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),Nf=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Af[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:jf)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};Mf=oc([sc(0,kf)],Mf);var Nf,Pf=class extends Pc{constructor(e){if(Vc&&Hc()<16&&!document.createElement(`canvas`).getContext(`webgl2`,{antialias:!1,depth:!1,preserveDrawingBuffer:!0}))throw Error(`Webgl2 is only supported on Safari 16 and above`);super(),this._preserveDrawingBuffer=e,this._onChangeTextureAtlas=this._register(new Z),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Z),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Z),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new Z),this.onContextLoss=this._onContextLoss.event}activate(e){let t=e._core;if(!e.element){this._register(t.onWillOpen(()=>this.activate(e)));return}this._terminal=e;let n=t.coreService,r=t.optionsService,i=t,a=i._renderService,o=i._characterJoinerService,s=i._charSizeService,c=i._coreBrowserService,l=i._decorationService;i._logService;let u=i._themeService;this._renderer=this._register(new xf(e,o,s,c,n,l,r,u,this._preserveDrawingBuffer)),this._register(Gl.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Gl.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Gl.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Gl.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),a.setRenderer(this._renderer),this._register(jc(()=>{if(this._terminal._core._store._isDisposed)return;let t=this._terminal._core._renderService;t.setRenderer(this._terminal._core._createRenderer()),t.handleResize(e.cols,e.rows)}))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}};function Ff(e){return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)}function If(){return(0,b.useSyncExternalStore)(Ff,()=>document.visibilityState===`visible`)}function Lf(e){let t=/^#?([0-9a-fA-F]{6})(?:[0-9a-fA-F]{2})?$/.exec(e.trim());if(!t)return null;let n=t[1].toLowerCase(),r=e=>n.slice(e,e+2).repeat(2);return`rgb:${r(0)}/${r(2)}/${r(4)}`}function Rf(e,t){let n=Lf(t);return n?`\x1b]${e};${n}\x1b\\`:null}function zf(e,t){return e.type===`keydown`?t?e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&e.key===`c`:e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()===`c`:!1}function Bf(e,t,n){if(t.startsWith(`login-`)||t===`home`)return!1;let i=Array.from(e.clipboardData?.items??[]);if(i.some(e=>e.type===`text/plain`))return!1;let o=i.find(e=>e.kind===`file`&&e.type.startsWith(`image/`));if(!o)return!1;let s=o.getAsFile();if(!s)return!1;let c=a.safeParse(o.type);return c.success?(Vf(s,c.data,t,n),!0):(r.error(`Cannot paste ${o.type} — png, jpeg, gif, and webp are supported`),!0)}async function Vf(e,t,n,i){try{let r=await Hf(e),a=await s(`POST`,`/api/worktrees/${n}/paste`,{mime:t,data:r});v.write(n,i,`${a.path} `)}catch(e){r.error(e instanceof Error?`Image paste failed: ${e.message}`:`Image paste failed`)}}function Hf(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result).replace(/^data:[^,]*,/,``)),r.onerror=()=>n(r.error??Error(`could not read the clipboard image`)),r.readAsDataURL(e)})}var Uf=new Set([`localhost`,`127.0.0.1`,`::1`,`[::1]`]);function Wf(e,t,n,r){if(!n)return e;let i;try{i=new URL(e)}catch{return e}if(i.protocol!==`http:`&&i.protocol!==`https:`||!Uf.has(i.hostname))return e;let a=i.port===``?i.protocol===`https:`?`443`:`80`:i.port,o=r?`puddle_token=${r}`:``,s=i.search?`${i.search}${o?`&${o}`:``}`:o?`?${o}`:``;return`/proxy/${t}/${a}${i.pathname}${s}${i.hash}`}var Gf=/(?:^|[\s"'`([<])((?:(?:\/|\.{1,2}\/|~\/)(?:[\w.+@~-]+\/)*[\w.+@~-]+|(?:[\w.+@~-]+\/)+[\w.+@~-]*|[\w.+@~-]+\.[A-Za-z]\w{0,11}))(?::(\d{1,6})(?::(\d{1,6}))?)?/dg,Kf=new Set([`.`,`,`,`;`,`:`,`)`,`]`,`'`,`"`]);function qf(e){let t=[],n=new RegExp(Gf.source,Gf.flags),r;for(;r=n.exec(e);){let e=r.indices,n=r[1];if(!e?.[1]||n===void 0)continue;let i=e[1][0],a=e[1][1],o=n;for(o.startsWith(`@`)&&(o=o.slice(1),i++);o.length>0&&Kf.has(o[o.length-1]);)o=o.slice(0,-1),a--;if(o.length===0)continue;let s=r[2]===void 0?void 0:Number.parseInt(r[2],10),c=r[3]===void 0?void 0:Number.parseInt(r[3],10),l=c!==void 0&&e[3]?e[3][1]:s!==void 0&&e[2]?e[2][1]:a;t.push({path:o,line:s,column:c,start:i,end:l})}return t}var Jf=class{fetcher;now;positiveTtlMs;negativeTtlMs;maxEntries;maxConcurrent;entries=new Map;inflight=new Map;inUse=0;waiters=[];constructor(e){this.fetcher=e.fetcher,this.now=e.now??Date.now,this.positiveTtlMs=e.positiveTtlMs??15e3,this.negativeTtlMs=e.negativeTtlMs??5e3,this.maxEntries=e.maxEntries??500,this.maxConcurrent=e.maxConcurrent??4}resolve(e,t,n){let r=`${e}\0${t}`,i=this.entries.get(r);if(i){if(this.now()<i.expiresAt)return Promise.resolve(i.value);this.entries.delete(r)}let a=this.inflight.get(r);if(a)return a;let o=this.withSlot(()=>this.fetcher(e,t,n)).then(e=>(this.store(r,e),e)).finally(()=>{this.inflight.delete(r)});return this.inflight.set(r,o),o}store(e,t){let n=t?this.positiveTtlMs:this.negativeTtlMs;for(this.entries.set(e,{value:t,expiresAt:this.now()+n});this.entries.size>this.maxEntries;){let e=this.entries.keys().next().value;if(e===void 0)break;this.entries.delete(e)}}async withSlot(e){this.inUse>=this.maxConcurrent&&await new Promise(e=>this.waiters.push(e)),this.inUse++;try{return await e()}finally{this.inUse--,this.waiters.shift()?.()}}};function Yf(e,t){let n=t;for(;n>0&&e.getLine(n)?.isWrapped;)n--;let r=``;for(let t=n;;t++){let i=e.getLine(t);if(!i||t!==n&&!i.isWrapped||(r+=i.translateToString(!0),r.length>2048))break}return{text:r,startRow:n}}function Xf(e,t,n,r){let i=e.getNullCell(),a=t,o=n,s=r;for(;s>=0;){let t=e.getLine(a);if(!t)return null;for(;o<t.length;o++){if(t.getCell(o,i),i.getWidth()&&(s-=i.getChars().length||1,o===t.length-1&&i.getChars()===``)){let t=e.getLine(a+1);t?.isWrapped&&(t.getCell(0,i),i.getWidth()===2&&(s+=1))}if(s<0)return{row:a,col:o}}a++,o=0}return{row:a,col:o}}async function Zf(e,t,n){let r=new URLSearchParams({path:t});n!==void 0&&r.set(`line`,String(n));try{return await s(`GET`,`/api/worktrees/${e}/resolve?${r}`)}catch{return null}}function Qf(e,t,n){let r=new Jf({fetcher:Zf});return e.registerLinkProvider({provideLinks(i,a){let o=e.buffer.active,{text:s,startRow:c}=Yf(o,i-1),l=qf(s);if(l.length===0){a(void 0);return}Promise.all(l.map(async e=>{let i=await r.resolve(t,e.path,e.line);if(!i)return null;let a=Xf(o,c,0,e.start),l=Xf(o,a?.row??c,a?.col??0,e.end-e.start);return!a||!l?null:{range:{start:{x:a.col+1,y:a.row+1},end:{x:l.col,y:l.row+1}},text:s.slice(e.start,e.end),decorations:{underline:!0,pointerCursor:!0},activate:t=>{if(!t.metaKey&&!t.ctrlKey)return;let r=i.kind??`file`;n({kind:r,path:i.path,...i.root===void 0?{}:{root:i.root},...r===`file`&&e.line!==void 0?{line:Math.max(1,e.line)}:{},...r===`file`&&e.column!==void 0?{column:e.column}:{}})}}})).then(e=>{let t=e.filter(e=>e!==null);a(t.length>0?t:void 0)})}})}var $f=n(),ep=/Mac|iPhone|iPad/.test(navigator.platform),tp=`'Ubuntu Sans Mono', ui-monospace, monospace`,np=`12px 'Ubuntu Sans Mono'`,rp=typeof document>`u`||!(`fonts`in document)||document.fonts.check(np),ip=rp?null:document.fonts.load(np).catch(()=>void 0).then(()=>{rp=!0});function ap(){let[e,t]=(0,b.useState)(rp);return(0,b.useEffect)(()=>{if(e||ip===null)return;let n=!0;return ip.then(()=>{n&&t(!0)}),()=>{n=!1}},[e]),e}var op=[`starting`,`running`,`waiting_input`],sp={ArrowLeft:``,ArrowRight:``,Backspace:``,Delete:`\v`};function cp(e,t){let[n,r]=(0,b.useState)(e);return(0,b.useEffect)(()=>{if(e){r(!0);return}let n=setTimeout(()=>r(!1),t);return()=>clearTimeout(n)},[e,t]),n}var lp=1500;function up({stream:e,term:t=`agent`,className:n,onExit:r,onOpenFile:a,paused:s=!1}){let ne=(0,b.useRef)(null),x=(0,b.useRef)(null),re=(0,b.useRef)(null),S=(0,b.useRef)(!1),C=g(),ie=(0,b.useRef)(r);ie.current=r;let w=(0,b.useRef)(a);w.current=a;let ae=If(),oe=cp(!s&&ae,lp),se=ap(),T=y(m().data?.protocol),E=_(o()??void 0).data?.terminalAppShortcuts!==!1,D=(0,b.useRef)(E);D.current=E;let ce=(0,b.useCallback)(()=>{let n=x.current,r=ne.current;!n||!r||r.clientWidth===0||(re.current?.fit(),n.resize(n.cols,n.rows),n.refresh(0,n.rows-1),v.resize(e,t,n.cols,n.rows))},[e,t]);return(0,b.useEffect)(()=>{let n=ne.current;if(!n||!se)return;let r=e.startsWith(`login-`)||e===`home`,a=t=>{let n=r?t:Wf(t,e,te()!==null,i.get());window.open(n,`_blank`,`noopener,noreferrer`)},o=new Js({theme:h(),fontFamily:tp,fontSize:C.terminalFontSize,scrollback:C.terminalScrollback,cursorBlink:!0,macOptionClickForcesSelection:ep,linkHandler:{activate:(e,t)=>a(t)}});x.current=o;let s=new Zs;o.loadAddon(s),o.loadAddon(new rc((e,t)=>a(t))),o.open(n),s.fit(),re.current=s;let f=w.current&&!r?Qf(o,e,e=>w.current?.(e)):null,m={stash:null},g=o.onData(n=>{n.startsWith(`\x1B[<`)||(m.stash=null),v.write(e,t,n)}),_=(n,r)=>i=>{if(i!==`?`)return!1;if(S.current)return!0;let a=Rf(n,ee()(r));return a&&v.write(e,t,a),!0},y=T?null:o.parser.registerOscHandler(10,_(10,`--text-primary`)),b=T?null:o.parser.registerOscHandler(11,_(11,`--bg-base`)),ie=o.parser.registerOscHandler(52,e=>{if(S.current)return!0;let t=e.indexOf(`;`),n=t===-1?``:e.slice(t+1);if(!n||n===`?`)return!0;try{let e=Uint8Array.from(atob(n),e=>e.charCodeAt(0));m.stash=new TextDecoder().decode(e)}catch{}return!0});o.attachCustomKeyEventHandler(n=>{if(zf(n,ep)){let e=o.getSelection()||m.stash;return e?(navigator.clipboard?.writeText(e),n.preventDefault(),!1):!0}if(n.type===`keydown`&&D.current){let e=c(n),t=e===null?void 0:u(e),r=t===void 0?void 0:l(t);if(t!==void 0&&r!==void 0&&!r.editor&&!r.deferInTerminal&&d(t)!==void 0)return!1}if(!ep||n.type!==`keydown`||!n.metaKey||n.ctrlKey||n.altKey||n.shiftKey)return!0;let r=sp[n.key];return r?(n.preventDefault(),v.write(e,t,r),!1):!0});let ae=n=>{Bf(n,e,t)&&(n.preventDefault(),n.stopPropagation())};n.addEventListener(`paste`,ae,!0);let oe=new ResizeObserver(()=>ce());oe.observe(n);let E=p(()=>{o.options.theme=h()});return()=>{n.removeEventListener(`paste`,ae,!0),oe.disconnect(),E(),y?.dispose(),b?.dispose(),ie.dispose(),f?.dispose(),g.dispose(),o.dispose(),x.current=null,re.current=null}},[e,t,ce,se,T]),(0,b.useEffect)(()=>{let n=x.current;if(!n||!oe)return;let r=ne.current;r&&r.clientWidth>0&&(re.current?.fit(),n.resize(n.cols,n.rows));let i=null;try{i=new Pf,i.onContextLoss(()=>{i?.dispose(),i=null,n.refresh(0,n.rows-1)}),n.loadAddon(i)}catch{i=null}n.refresh(0,n.rows-1);let a=v.attach(e,t,n.cols,n.rows,{onData:(e,t)=>{if(t===`replay`){S.current=!0,n.reset(),n.write(e,()=>{S.current=!1});return}n.write(e)},onExit:e=>ie.current?.(e)});return()=>{i?.dispose(),i=null,a()}},[e,t,oe,se]),(0,b.useEffect)(()=>{let e=x.current;e&&(e.options.fontSize=C.terminalFontSize,e.options.scrollback=C.terminalScrollback,ce())},[C.terminalFontSize,C.terminalScrollback,ce]),(0,b.useEffect)(()=>{let t=!1;return v.onStatus(n=>{if(n.session!==e)return;let r=op.includes(n.status);r&&!t&&ce(),t=r})},[e,ce]),(0,$f.jsx)(`div`,{ref:ne,className:f(`size-full`,n)})}export{up as Terminal};
117
+ }`,qu=8,Ju=qu*Float32Array.BYTES_PER_ELEMENT,Yu=20*qu,Xu=class{constructor(){this.attributes=new Float32Array(Yu),this.count=0}},Zu=0,Qu=0,$u=0,ed=0,td=0,nd=0,rd=0,id=class extends Pc{constructor(e,t,n,r){super(),this._terminal=e,this._gl=t,this._dimensions=n,this._themeService=r,this._vertices=new Xu,this._verticesCursor=new Xu;let i=this._gl;this._program=X(Tu(i,Gu,Ku)),this._register(jc(()=>i.deleteProgram(this._program))),this._projectionLocation=X(i.getUniformLocation(this._program,`u_projection`)),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),o=i.createBuffer();this._register(jc(()=>i.deleteBuffer(o))),i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,a,i.STATIC_DRAW),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let s=new Uint8Array([0,1,2,3]),c=i.createBuffer();this._register(jc(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=X(i.createBuffer()),this._register(jc(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,Ju,0),i.vertexAttribDivisor(0,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,Ju,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,4,i.FLOAT,!1,Ju,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(2,1),this._updateCachedColors(r.colors),this._register(this._themeService.onChangeColors(e=>{this._updateCachedColors(e),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(e){let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),t.uniformMatrix4fv(this._projectionLocation,!1,wu),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,e.attributes,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,e.count)}handleResize(){this._updateViewportRectangle()}setDimensions(e){this._dimensions=e}_updateCachedColors(e){this._bgFloat=this._colorToFloat32Array(e.background),this._cursorFloat=this._colorToFloat32Array(e.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(e){let t=this._terminal,n=this._vertices,r=1,i,a,o,s,c,l,u,d,f,p,m;for(i=0;i<t.rows;i++){for(o=-1,s=0,c=0,l=!1,a=0;a<t.cols;a++)u=(i*t.cols+a)*zu,d=e.cells[u+Bu],f=e.cells[u+Vu],p=!!(f&67108864),(d!==s||f!==c&&(l||p))&&((s!==0||l&&c!==0)&&(m=r++*qu,this._updateRectangle(n,m,c,s,o,a,i)),o=a,s=d,c=f,l=p);(s!==0||l&&c!==0)&&(m=r++*qu,this._updateRectangle(n,m,c,s,o,t.cols,i))}n.count=r}updateCursor(e){let t=this._verticesCursor,n=e.cursor;if(!n||n.style===`block`){t.count=0;return}let r,i=0;(n.style===`bar`||n.style===`outline`)&&(r=i++*qu,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.style===`bar`?n.dpr*n.cursorWidth:n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),(n.style===`underline`||n.style===`outline`)&&(r=i++*qu,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,(n.y+1)*this._dimensions.device.cell.height-n.dpr,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat)),n.style===`outline`&&(r=i++*qu,this._addRectangleFloat(t.attributes,r,n.x*this._dimensions.device.cell.width,n.y*this._dimensions.device.cell.height,n.width*this._dimensions.device.cell.width,n.dpr,this._cursorFloat),r=i++*qu,this._addRectangleFloat(t.attributes,r,(n.x+n.width)*this._dimensions.device.cell.width-n.dpr,n.y*this._dimensions.device.cell.height,n.dpr,this._dimensions.device.cell.height,this._cursorFloat)),t.count=i}_updateRectangle(e,t,n,r,i,a,o){if(n&67108864)switch(n&50331648){case 16777216:case 33554432:Zu=this._themeService.colors.ansi[n&255].rgba;break;case 50331648:Zu=(n&16777215)<<8;break;case 0:default:Zu=this._themeService.colors.foreground.rgba}else switch(r&50331648){case 16777216:case 33554432:Zu=this._themeService.colors.ansi[r&255].rgba;break;case 50331648:Zu=(r&16777215)<<8;break;case 0:default:Zu=this._themeService.colors.background.rgba}e.attributes.length<t+4&&(e.attributes=Du(e.attributes,this._terminal.rows*this._terminal.cols*qu)),Qu=i*this._dimensions.device.cell.width,$u=o*this._dimensions.device.cell.height,ed=(Zu>>24&255)/255,td=(Zu>>16&255)/255,nd=(Zu>>8&255)/255,rd=1,this._addRectangle(e.attributes,t,Qu,$u,(a-i)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,ed,td,nd,rd)}_addRectangle(e,t,n,r,i,a,o,s,c,l){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o,e[t+5]=s,e[t+6]=c,e[t+7]=l}_addRectangleFloat(e,t,n,r,i,a,o){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o[0],e[t+5]=o[1],e[t+6]=o[2],e[t+7]=o[3]}_colorToFloat32Array(e){return new Float32Array([(e.rgba>>24&255)/255,(e.rgba>>16&255)/255,(e.rgba>>8&255)/255,(e.rgba&255)/255])}},ad=class extends Pc{constructor(e,t,n,r,i,a,o,s){super(),this._container=t,this._alpha=i,this._coreBrowserService=a,this._optionsService=o,this._themeService=s,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-${n}-layer`),this._canvas.style.zIndex=r.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(t=>{this._refreshCharAtlas(e,t),this.reset(e)})),this._register(jc(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=X(this._canvas.getContext(`2d`,{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(e){}handleFocus(e){}handleCursorMove(e){}handleGridChanged(e,t,n){}handleSelectionChanged(e,t,n,r=!1){}_setTransparency(e,t){if(t===this._alpha)return;let n=this._canvas;this._alpha=t,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,n),this._refreshCharAtlas(e,this._themeService.colors),this.handleGridChanged(e,0,e.rows-1)}_refreshCharAtlas(e,t){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=_u(e,this._optionsService.rawOptions,t,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(e,t){this._deviceCellWidth=t.device.cell.width,this._deviceCellHeight=t.device.cell.height,this._deviceCharWidth=t.device.char.width,this._deviceCharHeight=t.device.char.height,this._deviceCharLeft=t.device.char.left,this._deviceCharTop=t.device.char.top,this._canvas.width=t.device.canvas.width,this._canvas.height=t.device.canvas.height,this._canvas.style.width=`${t.css.canvas.width}px`,this._canvas.style.height=`${t.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(e,this._themeService.colors)}_fillBottomLineAtCells(e,t,n=1){this._ctx.fillRect(e*this._deviceCellWidth,(t+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,n*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(e,t,n,r){this._alpha?this._ctx.clearRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight))}_fillCharTrueColor(e,t,n,r){this._ctx.font=this._getFont(e,!1,!1),this._ctx.textBaseline=bl,this._clipCell(n,r,t.getWidth()),this._ctx.fillText(t.getChars(),n*this._deviceCellWidth+this._deviceCharLeft,r*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(e,t,n){this._ctx.beginPath(),this._ctx.rect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(e,t,n){let r=t?e.options.fontWeightBold:e.options.fontWeight;return`${n?`italic`:``} ${r} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}},od=class extends ad{constructor(e,t,n,r,i,a,o){super(n,e,`link`,t,!0,i,a,o),this._register(r.onShowLinkUnderline(e=>this._handleShowLinkUnderline(e))),this._register(r.onHideLinkUnderline(e=>this._handleHideLinkUnderline(e)))}resize(e,t){super.resize(e,t),this._state=void 0}reset(e){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let e=this._state.y2-this._state.y1-1;e>0&&this._clearCells(0,this._state.y1+1,this._state.cols,e),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(e){if(e.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:e.fg!==void 0&&hu(e.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[e.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,e.y1===e.y2)this._fillBottomLineAtCells(e.x1,e.y1,e.x2-e.x1);else{this._fillBottomLineAtCells(e.x1,e.y1,e.cols-e.x1);for(let t=e.y1+1;t<e.y2;t++)this._fillBottomLineAtCells(0,t,e.cols);this._fillBottomLineAtCells(0,e.y2,e.x2)}this._state=e}_handleHideLinkUnderline(e){this._clearCurrentLink()}},sd=typeof window==`object`?window:globalThis,cd=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new Z,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new Z,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};cd.INSTANCE=new cd;var ld=cd;function ud(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}ld.INSTANCE.onDidChangeZoomLevel,ld.INSTANCE.onDidChangeFullscreen;var dd=typeof navigator==`object`?navigator.userAgent:``;dd.indexOf(`Firefox`);var fd=dd.indexOf(`AppleWebKit`)>=0;!(dd.indexOf(`Chrome`)>=0)&&dd.indexOf(`Safari`),dd.indexOf(`Electron/`),dd.indexOf(`Android`);var pd=!1;if(typeof sd.matchMedia==`function`){let e=sd.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=sd.matchMedia(`(display-mode: fullscreen)`);pd=e.matches,ud(sd,e,({matches:e})=>{pd&&t.matches||(pd=e)})}function md(){return pd}var hd=`en`,gd=!1,_d=!1,vd=!1,yd=hd,bd,xd=globalThis,Sd;typeof xd.vscode<`u`&&typeof xd.vscode.process<`u`?Sd=xd.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(Sd=process);var Cd=typeof Sd?.versions?.electron==`string`&&Sd?.type===`renderer`;if(typeof Sd==`object`){Sd.platform,Sd.platform,gd=Sd.platform===`linux`,gd&&Sd.env.SNAP&&Sd.env.SNAP_REVISION,Sd.env.CI||Sd.env.BUILD_ARTIFACTSTAGINGDIRECTORY,yd=hd;let e=Sd.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,yd=t.resolvedLanguage||hd,t.languagePack?.translationsConfigFile}catch{}_d=!0}else typeof navigator==`object`&&!Cd?(bd=navigator.userAgent,bd.indexOf(`Windows`),bd.indexOf(`Macintosh`),(bd.indexOf(`Macintosh`)>=0||bd.indexOf(`iPad`)>=0||bd.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,gd=bd.indexOf(`Linux`)>=0,bd?.indexOf(`Mobi`),vd=!0,yd=globalThis._VSCODE_NLS_LANGUAGE||hd,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var wd=_d;vd&&typeof xd.importScripts==`function`&&xd.origin;var Td=bd,Ed=yd,Dd;(e=>{function t(){return Ed}e.value=t;function n(){return Ed.length===2?Ed===`en`:Ed.length>=3&&Ed[0]===`e`&&Ed[1]===`n`&&Ed[2]===`-`}e.isDefaultVariant=n;function r(){return Ed===`en`}e.isDefault=r})(Dd||={});var Od=typeof xd.postMessage==`function`&&!xd.importScripts;(()=>{if(Od){let e=[];xd.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.id===t.data.vscodeScheduleAsyncWork){e.splice(n,1),r.callback();return}}});let t=0;return n=>{let r=++t;e.push({id:r,callback:n}),xd.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var kd=!!(Td&&Td.indexOf(`Chrome`)>=0);Td&&Td.indexOf(`Firefox`),!kd&&Td&&Td.indexOf(`Safari`),Td&&Td.indexOf(`Edg/`),Td&&Td.indexOf(`Android`);var Ad=typeof navigator==`object`?navigator:{};wd||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||Ad&&Ad.clipboard&&Ad.clipboard.writeText,wd||Ad&&Ad.clipboard&&Ad.clipboard.readText,wd||md()||Ad.keyboard,`ontouchstart`in sd||Ad.maxTouchPoints,sd.PointerEvent&&(`ontouchstart`in sd||navigator.maxTouchPoints);var jd=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Md=new jd,Nd=new jd,Pd=new jd;Array(230);var Fd;(e=>{function t(e){return Md.keyCodeToStr(e)}e.toString=t;function n(e){return Md.strToKeyCode(e)}e.fromString=n;function r(e){return Nd.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return Pd.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return Nd.strToKeyCode(e)||Pd.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return Md.keyCodeToStr(e)}e.toElectronAccelerator=o})(Fd||={});var Id=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),Ld;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof Rd?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Gl.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Id})})(Ld||={});var Rd=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Id:(this._emitter||=new Z,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var zd;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(zd||={});var Bd=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new Z,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e<this._results.length)return{done:!1,value:this._results[e++]};if(this._state===1)return{done:!0,value:void 0};await Gl.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};Bd.EMPTY=Bd.fromArray([]);function Vd(e){return 55296<=e&&e<=56319}function Hd(e){return 56320<=e&&e<=57343}function Ud(e,t){return(e-55296<<10)+(t-56320)+65536}function Wd(e){return Gd(e,0)}function Gd(e,t){switch(typeof e){case`object`:return e===null?Kd(349,t):Array.isArray(e)?Yd(e,t):Xd(e,t);case`string`:return Jd(e,t);case`boolean`:return qd(e,t);case`number`:return Kd(e,t);case`undefined`:return Kd(937,t);default:return Kd(617,t)}}function Kd(e,t){return(t<<5)-t+e|0}function qd(e,t){return Kd(e?433:863,t)}function Jd(e,t){t=Kd(149417,t);for(let n=0,r=e.length;n<r;n++)t=Kd(e.charCodeAt(n),t);return t}function Yd(e,t){return t=Kd(104579,t),e.reduce((e,t)=>Gd(t,e),t)}function Xd(e,t){return t=Kd(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=Jd(n,t),Gd(e[n],t)),t)}function Zd(e,t,n=32){let r=n-t,i=~((1<<r)-1);return(e<<t|(i&e)>>>r)>>>0}function Qd(e,t=0,n=e.byteLength,r=0){for(let i=0;i<n;i++)e[t+i]=r}function $d(e,t,n=`0`){for(;e.length<t;)e=n+e;return e}function ef(e,t=32){return e instanceof ArrayBuffer?Array.from(new Uint8Array(e)).map(e=>e.toString(16).padStart(2,`0`)).join(``):$d((e>>>0).toString(16),t/4)}var tf=class e{constructor(){this._h0=1732584193,this._h1=4023233417,this._h2=2562383102,this._h3=271733878,this._h4=3285377520,this._buff=new Uint8Array(67),this._buffDV=new DataView(this._buff.buffer),this._buffLen=0,this._totalLen=0,this._leftoverHighSurrogate=0,this._finished=!1}update(e){let t=e.length;if(t===0)return;let n=this._buff,r=this._buffLen,i=this._leftoverHighSurrogate,a,o;for(i===0?(a=e.charCodeAt(0),o=0):(a=i,o=-1,i=0);;){let s=a;if(Vd(a))if(o+1<t){let t=e.charCodeAt(o+1);Hd(t)?(o++,s=Ud(a,t)):s=65533}else{i=a;break}else Hd(a)&&(s=65533);if(r=this._push(n,r,s),o++,o<t)a=e.charCodeAt(o);else break}this._buffLen=r,this._leftoverHighSurrogate=i}_push(e,t,n){return n<128?e[t++]=n:n<2048?(e[t++]=192|(n&1984)>>>6,e[t++]=128|(n&63)>>>0):n<65536?(e[t++]=224|(n&61440)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0):(e[t++]=240|(n&1835008)>>>18,e[t++]=128|(n&258048)>>>12,e[t++]=128|(n&4032)>>>6,e[t++]=128|(n&63)>>>0),t>=64&&(this._step(),t-=64,this._totalLen+=64,e[0]=e[64],e[1]=e[65],e[2]=e[66]),t}digest(){return this._finished||(this._finished=!0,this._leftoverHighSurrogate&&(this._leftoverHighSurrogate=0,this._buffLen=this._push(this._buff,this._buffLen,65533)),this._totalLen+=this._buffLen,this._wrapUp()),ef(this._h0)+ef(this._h1)+ef(this._h2)+ef(this._h3)+ef(this._h4)}_wrapUp(){this._buff[this._buffLen++]=128,Qd(this._buff,this._buffLen),this._buffLen>56&&(this._step(),Qd(this._buff));let e=8*this._totalLen;this._buffDV.setUint32(56,Math.floor(e/4294967296),!1),this._buffDV.setUint32(60,e%4294967296,!1),this._step()}_step(){let t=e._bigBlock32,n=this._buffDV;for(let e=0;e<64;e+=4)t.setUint32(e,n.getUint32(e,!1),!1);for(let e=64;e<320;e+=4)t.setUint32(e,Zd(t.getUint32(e-12,!1)^t.getUint32(e-32,!1)^t.getUint32(e-56,!1)^t.getUint32(e-64,!1),1),!1);let r=this._h0,i=this._h1,a=this._h2,o=this._h3,s=this._h4,c,l,u;for(let e=0;e<80;e++)e<20?(c=i&a|~i&o,l=1518500249):e<40?(c=i^a^o,l=1859775393):e<60?(c=i&a|i&o|a&o,l=2400959708):(c=i^a^o,l=3395469782),u=Zd(r,5)+c+s+l+t.getUint32(e*4,!1)&4294967295,s=o,o=a,a=Zd(i,30),i=r,r=u;this._h0=this._h0+r&4294967295,this._h1=this._h1+i&4294967295,this._h2=this._h2+a&4294967295,this._h3=this._h3+o&4294967295,this._h4=this._h4+s&4294967295}};tf._bigBlock32=new DataView(new ArrayBuffer(320));var{registerWindow:nf,getWindow:rf,getDocument:af,getWindows:of,getWindowsCount:sf,getWindowId:cf,getWindowById:lf,hasWindow:uf,onDidRegisterWindow:df,onWillUnregisterWindow:ff,onDidUnregisterWindow:pf}=function(){let e=new Map,t={window:sd,disposables:new Nc};e.set(sd.vscodeWindowId,t);let n=new Z,r=new Z,i=new Z;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return Pc.None;let a=new Nc,o={window:t,disposables:a.add(new Nc)};return e.set(t.vscodeWindowId,o),a.add(jc(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(hf(t,_f.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:sd},getDocument(e){return rf(e).document}}}(),mf=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function hf(e,t,n,r){return new mf(e,t,n,r)}var gf=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};gf.None=new gf(0,0),new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=Wd(n),a=r.get(i);if(a)a.users+=1;else{let o=new Z,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(jc(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var _f={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:fd?`webkitAnimationStart`:`animationstart`,ANIMATION_END:fd?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:fd?`webkitAnimationIteration`:`animationiteration`},vf=/([\w\-]+)?(#([\w\-]+))?((\.([\w\-]+))*)/;function yf(e,t,n,...r){let i=vf.exec(t);if(!i)throw Error(`Bad use of emmet`);let a=i[1]||`div`,o;return o=e===`http://www.w3.org/1999/xhtml`?document.createElement(a):document.createElementNS(e,a),i[3]&&(o.id=i[3]),i[4]&&(o.className=i[4].replace(/\./g,` `).trim()),n&&Object.entries(n).forEach(([e,t])=>{typeof t>`u`||(/^on\w+$/.test(e)?o[e]=t:e===`selected`?t&&o.setAttribute(e,`true`):o.setAttribute(e,t))}),o.append(...r),o}function bf(e,t,...n){return yf(`http://www.w3.org/1999/xhtml`,e,t,...n)}bf.SVG=function(e,t,...n){return yf(`http://www.w3.org/2000/svg`,e,t,...n)};var xf=class extends Pc{constructor(e,t,n,r,i,a,o,s,c){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._optionsService=o,this._themeService=s,this._cursorBlinkStateManager=new Fc,this._charAtlasDisposable=this._register(new Fc),this._observerDisposable=this._register(new Fc),this._model=new Wu,this._workCell=new Cu,this._workCell2=new Cu,this._rectangleRenderer=this._register(new Fc),this._glyphRenderer=this._register(new Fc),this._onChangeTextureAtlas=this._register(new Z),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Z),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Z),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new Z),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new Z),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`);let l={antialias:!1,depth:!1,preserveDrawingBuffer:c};if(this._gl=this._canvas.getContext(`webgl2`,l),!this._gl)throw Error(`WebGL2 not supported `+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new vl(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new od(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions=cl(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(o.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(hf(this._canvas,`webglcontextlost`,e=>{console.log(`webglcontextlost event received`),e.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn(`webgl context not restored; firing onContextLoss`),this._onContextLoss.fire(e)},3e3)})),this._register(hf(this._canvas,`webglcontextrestored`,e=>{console.warn(`webglcontextrestored event received`),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,vu(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=xu(this._canvas,this._coreBrowserService.window,(e,t)=>this._setCanvasDevicePixelDimensions(e,t)),this._register(this._coreBrowserService.onWindowChange(e=>{this._observerDisposable.value=xu(this._canvas,e,(e,t)=>this._setCanvasDevicePixelDimensions(e,t))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(jc(()=>{for(let e of this._renderLayers)e.dispose();this._canvas.parentElement?.removeChild(this._canvas),vu(this._terminal)}))}get textureAtlas(){return this._charAtlas?.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(e,t){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let e of this._renderLayers)e.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,this._rectangleRenderer.value?.setDimensions(this.dimensions),this._rectangleRenderer.value?.handleResize(),this._glyphRenderer.value?.setDimensions(this.dimensions),this._glyphRenderer.value?.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){for(let e of this._renderLayers)e.handleBlur(this._terminal);this._cursorBlinkStateManager.value?.pause(),this._requestRedrawViewport()}handleFocus(){for(let e of this._renderLayers)e.handleFocus(this._terminal);this._cursorBlinkStateManager.value?.resume(),this._requestRedrawViewport()}handleSelectionChanged(e,t,n){for(let r of this._renderLayers)r.handleSelectionChanged(this._terminal,e,t,n);this._model.selection.update(this._core,e,t,n),this._requestRedrawViewport()}handleCursorMove(){for(let e of this._renderLayers)e.handleCursorMove(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new id(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new Iu(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let e=_u(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize);this._charAtlas!==e&&(this._onChangeTextureAtlas.fire(e.pages[0].canvas),this._charAtlasDisposable.value=Ac(Gl.forward(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),Gl.forward(e.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=e,this._charAtlas.warmUp(),this._glyphRenderer.value?.setAtlas(this._charAtlas)}_clearModel(e){this._model.clear(),e&&this._glyphRenderer.value?.clear()}clearTextureAtlas(){this._charAtlas?.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(e,t){if(!this._isAttached)if(this._core.screenElement?.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return;for(let n of this._renderLayers)n.handleGridChanged(this._terminal,e,t);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(e,t),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new bu(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let n=this._core,r=this._workCell,i,a,o,s,c,l,u=0,d=!0,f,p,m,h,g,_,v,y,ee;e=Cf(e,n.rows-1,0),t=Cf(t,n.rows-1,0);let te=this._coreService.decPrivateModes.cursorStyle??n.options.cursorStyle??`block`,b=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,ne=b-n.buffer.ydisp,x=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),re=-1,S=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let C=!1;for(a=e;a<=t;a++)for(o=a+n.buffer.ydisp,s=n.buffer.lines.get(o),this._model.lineLengths[a]=0,m=b===o,u=0,c=this._characterJoinerService.getJoinedCharacters(o),y=0;y<n.cols;y++){if(i=this._cellColorResolver.result.bg,s.loadCell(y,r),y===0&&(i=this._cellColorResolver.result.bg),l=!1,d=y>=u,f=y,c.length>0&&y===c[0][0]&&d){p=c.shift();let e=this._model.selection.isCellSelected(this._terminal,p[0],o);for(v=p[0]+1;v<p[1];v++)d&&=e===this._model.selection.isCellSelected(this._terminal,v,o);d&&=!m||x<p[0]||x>=p[1],d?(l=!0,r=new Sf(r,s.translateToString(!0,p[0],p[1]),p[1]-p[0]),f=p[1]-1):u=p[1]}if(h=r.getChars(),g=r.getCode(),v=(a*n.cols+y)*zu,this._cellColorResolver.resolve(r,y,o,this.dimensions.device.cell.width),S&&o===b&&(y===x&&(this._model.cursor={x,y:ne,width:r.getWidth(),style:this._coreBrowserService.isFocused?te:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},re=x+r.getWidth()-1),y>=x&&y<=re&&(this._coreBrowserService.isFocused&&te===`block`||this._coreBrowserService.isFocused===!1&&n.options.cursorInactiveStyle===`block`)&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),g!==0&&(this._model.lineLengths[a]=y+1),!(this._model.cells[v]===g&&this._model.cells[v+Bu]===this._cellColorResolver.result.bg&&this._model.cells[v+Vu]===this._cellColorResolver.result.fg&&this._model.cells[v+Hu]===this._cellColorResolver.result.ext)&&(C=!0,h.length>1&&(g|=Uu),this._model.cells[v]=g,this._model.cells[v+Bu]=this._cellColorResolver.result.bg,this._model.cells[v+Vu]=this._cellColorResolver.result.fg,this._model.cells[v+Hu]=this._cellColorResolver.result.ext,_=r.getWidth(),this._glyphRenderer.value.updateCell(y,a,g,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,h,_,i),l)){for(r=this._workCell,y++;y<=f;y++)ee=(a*n.cols+y)*zu,this._glyphRenderer.value.updateCell(y,a,0,0,0,0,Uc,0,0),this._model.cells[ee]=0,this._model.cells[ee+Bu]=this._cellColorResolver.result.bg,this._model.cells[ee+Vu]=this._cellColorResolver.result.fg,this._model.cells[ee+Hu]=this._cellColorResolver.result.ext;y--}}C&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let e=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:e,end:e})}},Sf=class extends Bl{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function Cf(e,t,n=0){return Math.max(Math.min(e,t),n)}var wf=`di$target`,Tf=`di$dependencies`,Ef=new Map;function Df(e){if(Ef.has(e))return Ef.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Of(t,e,r)};return t._id=e,Ef.set(e,t),t}function Of(e,t,n){t[wf]===t?t[Tf].push({id:e,index:n}):(t[Tf]=[{id:e,index:n}],t[wf]=t)}Df(`BufferService`),Df(`CoreMouseService`),Df(`CoreService`),Df(`CharsetService`),Df(`InstantiationService`),Df(`LogService`);var kf=Df(`OptionsService`);Df(`OscLinkService`),Df(`UnicodeService`),Df(`DecorationService`);var Af={trace:0,debug:1,info:2,warn:3,error:4,off:5},jf=`xterm.js: `,Mf=class extends Pc{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),Nf=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Af[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]==`function`&&(e[t]=e[t]())}_log(e,t,n){this._evalLazyOptionalParams(n),e.call(console,(this._optionsService.options.logger?``:jf)+t,...n)}trace(e,...t){this._logLevel<=0&&this._log(this._optionsService.options.logger?.trace.bind(this._optionsService.options.logger)??console.log,e,t)}debug(e,...t){this._logLevel<=1&&this._log(this._optionsService.options.logger?.debug.bind(this._optionsService.options.logger)??console.log,e,t)}info(e,...t){this._logLevel<=2&&this._log(this._optionsService.options.logger?.info.bind(this._optionsService.options.logger)??console.info,e,t)}warn(e,...t){this._logLevel<=3&&this._log(this._optionsService.options.logger?.warn.bind(this._optionsService.options.logger)??console.warn,e,t)}error(e,...t){this._logLevel<=4&&this._log(this._optionsService.options.logger?.error.bind(this._optionsService.options.logger)??console.error,e,t)}};Mf=oc([sc(0,kf)],Mf);var Nf,Pf=class extends Pc{constructor(e){if(Vc&&Hc()<16&&!document.createElement(`canvas`).getContext(`webgl2`,{antialias:!1,depth:!1,preserveDrawingBuffer:!0}))throw Error(`Webgl2 is only supported on Safari 16 and above`);super(),this._preserveDrawingBuffer=e,this._onChangeTextureAtlas=this._register(new Z),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new Z),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new Z),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onContextLoss=this._register(new Z),this.onContextLoss=this._onContextLoss.event}activate(e){let t=e._core;if(!e.element){this._register(t.onWillOpen(()=>this.activate(e)));return}this._terminal=e;let n=t.coreService,r=t.optionsService,i=t,a=i._renderService,o=i._characterJoinerService,s=i._charSizeService,c=i._coreBrowserService,l=i._decorationService;i._logService;let u=i._themeService;this._renderer=this._register(new xf(e,o,s,c,n,l,r,u,this._preserveDrawingBuffer)),this._register(Gl.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(Gl.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(Gl.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(Gl.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),a.setRenderer(this._renderer),this._register(jc(()=>{if(this._terminal._core._store._isDisposed)return;let t=this._terminal._core._renderService;t.setRenderer(this._terminal._core._createRenderer()),t.handleResize(e.cols,e.rows)}))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}};function Ff(e){return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)}function If(){return(0,b.useSyncExternalStore)(Ff,()=>document.visibilityState===`visible`)}function Lf(e){let t=/^#?([0-9a-fA-F]{6})(?:[0-9a-fA-F]{2})?$/.exec(e.trim());if(!t)return null;let n=t[1].toLowerCase(),r=e=>n.slice(e,e+2).repeat(2);return`rgb:${r(0)}/${r(2)}/${r(4)}`}function Rf(e,t){let n=Lf(t);return n?`\x1b]${e};${n}\x1b\\`:null}function zf(e,t){return e.type===`keydown`?t?e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&e.key===`c`:e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&e.key.toLowerCase()===`c`:!1}function Bf(e,t,n){if(t.startsWith(`login-`)||t===`home`)return!1;let i=Array.from(e.clipboardData?.items??[]);if(i.some(e=>e.type===`text/plain`))return!1;let o=i.find(e=>e.kind===`file`&&e.type.startsWith(`image/`));if(!o)return!1;let s=o.getAsFile();if(!s)return!1;let c=a.safeParse(o.type);return c.success?(Vf(s,c.data,t,n),!0):(r.error(`Cannot paste ${o.type} — png, jpeg, gif, and webp are supported`),!0)}async function Vf(e,t,n,i){try{let r=await Hf(e),a=await s(`POST`,`/api/worktrees/${n}/paste`,{mime:t,data:r});v.write(n,i,`${a.path} `)}catch(e){r.error(e instanceof Error?`Image paste failed: ${e.message}`:`Image paste failed`)}}function Hf(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result).replace(/^data:[^,]*,/,``)),r.onerror=()=>n(r.error??Error(`could not read the clipboard image`)),r.readAsDataURL(e)})}var Uf=new Set([`localhost`,`127.0.0.1`,`::1`,`[::1]`]);function Wf(e,t,n,r){if(!n)return e;let i;try{i=new URL(e)}catch{return e}if(i.protocol!==`http:`&&i.protocol!==`https:`||!Uf.has(i.hostname))return e;let a=i.port===``?i.protocol===`https:`?`443`:`80`:i.port,o=r?`puddle_token=${r}`:``,s=i.search?`${i.search}${o?`&${o}`:``}`:o?`?${o}`:``;return`/proxy/${t}/${a}${i.pathname}${s}${i.hash}`}var Gf=/(?:^|[\s"'`([<])((?:(?:\/|\.{1,2}\/|~\/)(?:[\w.+@~-]+\/)*[\w.+@~-]+|(?:[\w.+@~-]+\/)+[\w.+@~-]*|[\w.+@~-]+\.[A-Za-z]\w{0,11}))(?::(\d{1,6})(?::(\d{1,6}))?)?/dg,Kf=new Set([`.`,`,`,`;`,`:`,`)`,`]`,`'`,`"`]);function qf(e){let t=[],n=new RegExp(Gf.source,Gf.flags),r;for(;r=n.exec(e);){let e=r.indices,n=r[1];if(!e?.[1]||n===void 0)continue;let i=e[1][0],a=e[1][1],o=n;for(o.startsWith(`@`)&&(o=o.slice(1),i++);o.length>0&&Kf.has(o[o.length-1]);)o=o.slice(0,-1),a--;if(o.length===0)continue;let s=r[2]===void 0?void 0:Number.parseInt(r[2],10),c=r[3]===void 0?void 0:Number.parseInt(r[3],10),l=c!==void 0&&e[3]?e[3][1]:s!==void 0&&e[2]?e[2][1]:a;t.push({path:o,line:s,column:c,start:i,end:l})}return t}var Jf=class{fetcher;now;positiveTtlMs;negativeTtlMs;maxEntries;maxConcurrent;entries=new Map;inflight=new Map;inUse=0;waiters=[];constructor(e){this.fetcher=e.fetcher,this.now=e.now??Date.now,this.positiveTtlMs=e.positiveTtlMs??15e3,this.negativeTtlMs=e.negativeTtlMs??5e3,this.maxEntries=e.maxEntries??500,this.maxConcurrent=e.maxConcurrent??4}resolve(e,t,n){let r=`${e}\0${t}`,i=this.entries.get(r);if(i){if(this.now()<i.expiresAt)return Promise.resolve(i.value);this.entries.delete(r)}let a=this.inflight.get(r);if(a)return a;let o=this.withSlot(()=>this.fetcher(e,t,n)).then(e=>(this.store(r,e),e)).finally(()=>{this.inflight.delete(r)});return this.inflight.set(r,o),o}store(e,t){let n=t?this.positiveTtlMs:this.negativeTtlMs;for(this.entries.set(e,{value:t,expiresAt:this.now()+n});this.entries.size>this.maxEntries;){let e=this.entries.keys().next().value;if(e===void 0)break;this.entries.delete(e)}}async withSlot(e){this.inUse>=this.maxConcurrent&&await new Promise(e=>this.waiters.push(e)),this.inUse++;try{return await e()}finally{this.inUse--,this.waiters.shift()?.()}}};function Yf(e,t){let n=t;for(;n>0&&e.getLine(n)?.isWrapped;)n--;let r=``;for(let t=n;;t++){let i=e.getLine(t);if(!i||t!==n&&!i.isWrapped||(r+=i.translateToString(!0),r.length>2048))break}return{text:r,startRow:n}}function Xf(e,t,n,r){let i=e.getNullCell(),a=t,o=n,s=r;for(;s>=0;){let t=e.getLine(a);if(!t)return null;for(;o<t.length;o++){if(t.getCell(o,i),i.getWidth()&&(s-=i.getChars().length||1,o===t.length-1&&i.getChars()===``)){let t=e.getLine(a+1);t?.isWrapped&&(t.getCell(0,i),i.getWidth()===2&&(s+=1))}if(s<0)return{row:a,col:o}}a++,o=0}return{row:a,col:o}}async function Zf(e,t,n){let r=new URLSearchParams({path:t});n!==void 0&&r.set(`line`,String(n));try{return await s(`GET`,`/api/worktrees/${e}/resolve?${r}`)}catch{return null}}function Qf(e,t,n){let r=new Jf({fetcher:Zf});return e.registerLinkProvider({provideLinks(i,a){let o=e.buffer.active,{text:s,startRow:c}=Yf(o,i-1),l=qf(s);if(l.length===0){a(void 0);return}Promise.all(l.map(async e=>{let i=await r.resolve(t,e.path,e.line);if(!i)return null;let a=Xf(o,c,0,e.start),l=Xf(o,a?.row??c,a?.col??0,e.end-e.start);return!a||!l?null:{range:{start:{x:a.col+1,y:a.row+1},end:{x:l.col,y:l.row+1}},text:s.slice(e.start,e.end),decorations:{underline:!0,pointerCursor:!0},activate:t=>{if(!t.metaKey&&!t.ctrlKey)return;let r=i.kind??`file`;n({kind:r,path:i.path,...i.root===void 0?{}:{root:i.root},...r===`file`&&e.line!==void 0?{line:Math.max(1,e.line)}:{},...r===`file`&&e.column!==void 0?{column:e.column}:{}})}}})).then(e=>{let t=e.filter(e=>e!==null);a(t.length>0?t:void 0)})}})}var $f=n(),ep=/Mac|iPhone|iPad/.test(navigator.platform),tp=`'Ubuntu Sans Mono', ui-monospace, monospace`,np=`12px 'Ubuntu Sans Mono'`,rp=typeof document>`u`||!(`fonts`in document)||document.fonts.check(np),ip=rp?null:document.fonts.load(np).catch(()=>void 0).then(()=>{rp=!0});function ap(){let[e,t]=(0,b.useState)(rp);return(0,b.useEffect)(()=>{if(e||ip===null)return;let n=!0;return ip.then(()=>{n&&t(!0)}),()=>{n=!1}},[e]),e}var op=[`starting`,`running`,`waiting_input`],sp={ArrowLeft:``,ArrowRight:``,Backspace:``,Delete:`\v`};function cp(e,t){let[n,r]=(0,b.useState)(e);return(0,b.useEffect)(()=>{if(e){r(!0);return}let n=setTimeout(()=>r(!1),t);return()=>clearTimeout(n)},[e,t]),n}var lp=1500;function up({stream:e,term:t=`agent`,className:n,onExit:r,onOpenFile:a,paused:s=!1}){let ne=(0,b.useRef)(null),x=(0,b.useRef)(null),re=(0,b.useRef)(null),S=(0,b.useRef)(!1),C=g(),ie=(0,b.useRef)(r);ie.current=r;let w=(0,b.useRef)(a);w.current=a;let ae=If(),oe=cp(!s&&ae,lp),se=ap(),T=y(m().data?.protocol),E=_(o()??void 0).data?.terminalAppShortcuts!==!1,D=(0,b.useRef)(E);D.current=E;let ce=(0,b.useCallback)(()=>{let n=x.current,r=ne.current;!n||!r||r.clientWidth===0||(re.current?.fit(),n.resize(n.cols,n.rows),n.refresh(0,n.rows-1),v.resize(e,t,n.cols,n.rows))},[e,t]);return(0,b.useEffect)(()=>{let n=ne.current;if(!n||!se)return;let r=e.startsWith(`login-`)||e===`home`,a=t=>{let n=r?t:Wf(t,e,te()!==null,i.get());window.open(n,`_blank`,`noopener,noreferrer`)},o=new Js({theme:h(),fontFamily:tp,fontSize:C.terminalFontSize,scrollback:C.terminalScrollback,cursorBlink:!0,macOptionClickForcesSelection:ep,linkHandler:{activate:(e,t)=>a(t)}});x.current=o;let s=new Zs;o.loadAddon(s),o.loadAddon(new rc((e,t)=>a(t))),o.open(n),s.fit(),re.current=s;let f=w.current&&!r?Qf(o,e,e=>w.current?.(e)):null,m={stash:null},g=o.onData(n=>{S.current||(n.startsWith(`\x1B[<`)||(m.stash=null),v.write(e,t,n))}),_=(n,r)=>i=>{if(i!==`?`)return!1;if(S.current)return!0;let a=Rf(n,ee()(r));return a&&v.write(e,t,a),!0},y=T?null:o.parser.registerOscHandler(10,_(10,`--text-primary`)),b=T?null:o.parser.registerOscHandler(11,_(11,`--bg-base`)),ie=o.parser.registerOscHandler(52,e=>{if(S.current)return!0;let t=e.indexOf(`;`),n=t===-1?``:e.slice(t+1);if(!n||n===`?`)return!0;try{let e=Uint8Array.from(atob(n),e=>e.charCodeAt(0));m.stash=new TextDecoder().decode(e)}catch{}return!0});o.attachCustomKeyEventHandler(n=>{if(zf(n,ep)){let e=o.getSelection()||m.stash;return e?(navigator.clipboard?.writeText(e),n.preventDefault(),!1):!0}if(n.type===`keydown`&&D.current){let e=c(n),t=e===null?void 0:u(e),r=t===void 0?void 0:l(t);if(t!==void 0&&r!==void 0&&!r.editor&&!r.deferInTerminal&&d(t)!==void 0)return!1}if(!ep||n.type!==`keydown`||!n.metaKey||n.ctrlKey||n.altKey||n.shiftKey)return!0;let r=sp[n.key];return r?(n.preventDefault(),v.write(e,t,r),!1):!0});let ae=n=>{Bf(n,e,t)&&(n.preventDefault(),n.stopPropagation())};n.addEventListener(`paste`,ae,!0);let oe=()=>ce();n.addEventListener(`focusin`,oe);let E=new ResizeObserver(()=>ce());E.observe(n);let le=p(()=>{o.options.theme=h()});return()=>{n.removeEventListener(`paste`,ae,!0),n.removeEventListener(`focusin`,oe),E.disconnect(),le(),y?.dispose(),b?.dispose(),ie.dispose(),f?.dispose(),g.dispose(),o.dispose(),x.current=null,re.current=null}},[e,t,ce,se,T]),(0,b.useEffect)(()=>{let n=x.current;if(!n||!oe)return;let r=ne.current;r&&r.clientWidth>0&&(re.current?.fit(),n.resize(n.cols,n.rows));let i=null;try{i=new Pf,i.onContextLoss(()=>{i?.dispose(),i=null,n.refresh(0,n.rows-1)}),n.loadAddon(i)}catch{i=null}n.refresh(0,n.rows-1);let a=v.attach(e,t,n.cols,n.rows,{onData:(e,t)=>{if(t===`replay`){S.current=!0,n.reset(),n.write(e,()=>{S.current=!1});return}n.write(e)},onExit:e=>ie.current?.(e)});return()=>{i?.dispose(),i=null,a()}},[e,t,oe,se]),(0,b.useEffect)(()=>{let e=x.current;e&&(e.options.fontSize=C.terminalFontSize,e.options.scrollback=C.terminalScrollback,ce())},[C.terminalFontSize,C.terminalScrollback,ce]),(0,b.useEffect)(()=>{let t=!1;return v.onStatus(n=>{if(n.session!==e)return;let r=op.includes(n.status);r&&!t&&ce(),t=r})},[e,ce]),(0,$f.jsx)(`div`,{ref:ne,className:f(`size-full`,n)})}export{up as Terminal};