@puddle-code/cli 0.0.19 → 0.0.20

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 -8
  2. package/dist/index.js +1 -1
  3. package/dist/public/assets/{Dashboard-pA2IWfaK.js → Dashboard-Sq34AFXs.js} +1 -1
  4. package/dist/public/assets/{EditorTabClose-CNtmnz_W.js → EditorTabClose-C5BL8wr0.js} +1 -1
  5. package/dist/public/assets/{LazyTerminal-BVbNrjnw.js → LazyTerminal-CeLHCKsO.js} +2 -2
  6. package/dist/public/assets/{ModelRefcount-DvPjg3Ns.js → ModelRefcount-sJruf69B.js} +1 -1
  7. package/dist/public/assets/{PaneEditorBody-JXep35cg.js → PaneEditorBody-CbwKaj3E.js} +1 -1
  8. package/dist/public/assets/SettingsDialog-BuTx8DF2.js +1 -0
  9. package/dist/public/assets/{Terminal-DdMmi23H.js → Terminal-CN5FGN0_.js} +1 -1
  10. package/dist/public/assets/{Workspace-BQfCu-Oy.js → Workspace-NHcfAFZP.js} +4 -4
  11. package/dist/public/assets/{buffer-store-BrujywTq.js → buffer-store-CiF8VU5A.js} +2 -2
  12. package/dist/public/assets/{context-menu-DPd00x5d.js → context-menu-Bitp8sY-.js} +1 -1
  13. package/dist/public/assets/{cssMode-DxLTtqXU.js → cssMode-cJJRRtLZ.js} +1 -1
  14. package/dist/public/assets/{htmlMode-BkTm4vcY.js → htmlMode-Caw-2LOw.js} +1 -1
  15. package/dist/public/assets/index-CRUVuFoo.css +2 -0
  16. package/dist/public/assets/{index-C0rwYhwD.js → index-iPj6x3rM.js} +3 -3
  17. package/dist/public/assets/{jsonMode-DRxywuJy.js → jsonMode-CijUS1dz.js} +1 -1
  18. package/dist/public/assets/{session-seed-QMKYXZTo.js → session-seed-B2YmPsU-.js} +1 -1
  19. package/dist/public/assets/ssh-mode-CAA0-mpZ.js +1 -0
  20. package/dist/public/assets/{tsMode-yXwQVEEv.js → tsMode-_wbIu1Es.js} +1 -1
  21. package/dist/public/index.html +3 -3
  22. package/package.json +1 -1
  23. package/dist/public/assets/SettingsDialog-BghuULx0.js +0 -1
  24. package/dist/public/assets/index-DuiUHuMe.css +0 -2
  25. package/dist/public/assets/ssh-mode-DZa3UGPR.js +0 -1
package/CHANGELOG.md CHANGED
@@ -7,18 +7,17 @@ Past releases: see docs/changelogs/.
7
7
 
8
8
  # Changelog
9
9
 
10
- ## [0.0.19] — 2026-08-02
10
+ ## [0.0.20] — 2026-08-03
11
11
 
12
12
  ### Changed
13
13
 
14
- - Adding an account is one button and one dialogue. The inline label field, **Add account** and **Import existing…** — three controls per agent for what is really one action — collapse into a single **Add account** that opens the dialogue import already used. The config directory there is optional: name the account and puddle creates it and takes you to the agent's login, or point at an existing config dir to copy it in.
14
+ - Place Settings Sync export above import, keeping the one-click export-and-copy flow ahead of the paste target it produces.
15
+ - Session rows and tabs show one glyph, not two: the agent's brand mark (or a terminal glyph) drawn in the status colour, replacing the separate coloured dot beside it. The collapsed session rail keeps the dot — there is no mark beside it to deduplicate. The sidebar's account line drops its agent mark too, now that the row already leads with one.
15
16
 
16
- ### Added
17
+ ### Fixed
17
18
 
18
- - **Open Terminal in Directory** on the file tree's folder context menu: starts a terminal session whose shell begins in that folder rather than the worktree root. The directory is remembered, so resuming the session after a daemon restart returns to it, and extra shell tabs open there too. Protocol 11.1 (additive `cwd` on the session shape and on terminal creation).
19
- - Session tabs now carry the agent's brand mark beside the status dot, matching the sidebar, so you can tell a Claude Code tab from a Codex one at a glance. Terminal tabs are unchanged — the status dot already says what they are.
19
+ - Show Codex's observed idle composer and Claude's first completed prompt as waiting-for-input green instead of leaving their status running amber.
20
20
 
21
- ### Fixed
21
+ ### Removed
22
22
 
23
- - Codex sessions show their real name, and a rename appears within a few seconds. Codex keeps session names in its own `state_<n>.sqlite` rather than in the rollout file, which puddle never read so every codex session fell back to the terminal title, which codex sets to the working directory's basename. Every session in a repo therefore showed the same static name and a rename never surfaced.
24
- - Browsing to the top of the file tree no longer reports "path escapes the worktree" for every entry. Walking up to the filesystem root left the containment check comparing paths against `//`, so nothing under `/` could be listed, opened, or saved — expanding `Users` failed even though the browse root explicitly allowed it. Reading and editing files anywhere above the worktree now works, and genuine escapes are still refused.
23
+ - Status animations, and the **Reduced motion** setting with them. The running ripple and the waiting pulse are gone: the indicator's colour already carried the state and the motion only repeated it, at the cost of compositor frames after every status change on every visible session. With nothing left animating there is nothing for reduced motion to reduce, so the Appearance toggle has gone too an existing value in local storage is simply ignored, and an imported settings payload carrying it is skipped.
package/dist/index.js CHANGED
@@ -4184,7 +4184,7 @@ import { readFileSync } from "node:fs";
4184
4184
  import { dirname, join as join2 } from "node:path";
4185
4185
  import { fileURLToPath } from "node:url";
4186
4186
  function cliVersion() {
4187
- if (true) return "0.0.19";
4187
+ if (true) return "0.0.20";
4188
4188
  const here = dirname(fileURLToPath(import.meta.url));
4189
4189
  for (const candidate of [
4190
4190
  join2(here, "..", "..", "package.json"),
@@ -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{r}from"./profile-store-D2pB4wB-.js";import{a as i}from"./api-CZDct42i.js";import{a,g as o,i as s,n as c,o as l,t as u}from"./dialog-B43iKmfK.js";import{G as d,H as f,R as p,X as m,a as h,it as g,o as _,r as v,rt as y,t as b,tt as x,z as S}from"./LazyTerminal-BVbNrjnw.js";import{t as C}from"./utils-B6KiDbIe.js";import{A as w,O as T,c as E,j as D,k as O,n as k,r as A,t as j}from"./context-menu-DPd00x5d.js";import{r as M}from"./dist-i-QevsUb.js";import{I as N,K as P,N as F,Q as I,dt as L}from"./index-C0rwYhwD.js";var R=e(t(),1),z=n(),B=!1;function V(){let[e,t]=(0,R.useState)(B),[n,r]=(0,R.useState)(null);(0,R.useEffect)(()=>{if(!e)return;let t=!1;return N.spawnShell(i).then(e=>{t||r(e)}),()=>{t=!0}},[e]);let a=()=>{B=!1,t(!1),r(null)};return{open:e,term:n,toggle:()=>{e?(n&&N.killShell(i,n),a()):(B=!0,t(!0))},onExit:a}}function H({term:e,onExit:t}){return(0,z.jsx)(`div`,{className:`h-72 shrink-0 pb-6`,children:(0,z.jsx)(`div`,{className:`mx-auto size-full max-w-4xl px-6`,children:e!==null&&(0,z.jsx)(b,{stream:`home`,term:e,onExit:t})})})}var U=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function W({projectId:e}){let t=x(e),n=(0,R.useMemo)(()=>{let e=new Map;for(let n of t.data??[])e.set(n.status,(e.get(n.status)??0)+1);return e},[t.data]),r=(t.data??[]).filter(e=>e.status!==`archived`).length;return(0,z.jsxs)(`div`,{className:`flex items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,z.jsxs)(`span`,{children:[r,` session`,r===1?``:`s`]}),U.map(({status:e,colour:t})=>{let r=n.get(e)??0;return r===0?null:(0,z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),r,` `,e.replace(`_`,` `)]},e)})]})}function G({icon:e,label:t,onClick:n}){return(0,z.jsx)(`button`,{type:`button`,"aria-label":t,title:t,onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},className:`flex items-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-ground hover:text-fg`,children:(0,z.jsx)(e,{className:`size-4`})})}function K({project:e,repoPath:t,draggable:n,dragging:r,onDragStart:i,onDragEnd:d,onDragOver:f}){let p=S(),[m,_]=(0,R.useState)(!1),[b,x]=(0,R.useState)(e.name),T=t=>p.mutate({id:e.id,archived:t},{onError:e=>v(e)}),O=()=>{let t=b.trim();if(!t||t===e.name){_(!1);return}p.mutate({id:e.id,name:t},{onSuccess:()=>_(!1),onError:e=>v(e)})};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(j,{children:[(0,z.jsx)(E,{asChild:!0,children:(0,z.jsxs)(`div`,{draggable:n,onDragStart:i,onDragEnd:d,onDragOver:f,className:C(`group relative transition-opacity`,r&&`opacity-50`),children:[(0,z.jsxs)(L,{draggable:!1,to:`/project/${e.id}`,className:`block rounded-lg bg-surface p-4 transition-colors hover:bg-elevated`,children:[(0,z.jsx)(`h2`,{className:`truncate pr-16 text-base font-semibold text-fg group-hover:text-accent`,children:e.name}),(0,z.jsx)(`p`,{className:`mt-1 truncate font-mono text-2xs text-fg-muted`,children:t??`…`}),(0,z.jsx)(`div`,{className:`mt-3`,children:(0,z.jsx)(W,{projectId:e.id})})]}),(0,z.jsx)(`div`,{className:`absolute right-2 top-2 hidden gap-0.5 group-hover:flex has-[[data-state=open]]:flex pointer-coarse:flex`,children:e.archived?(0,z.jsx)(G,{icon:D,label:`Reopen project`,onClick:()=>T(!1)}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(G,{icon:h,label:`Rename project`,onClick:()=>{x(e.name),_(!0)}}),(0,z.jsx)(G,{icon:w,label:`Archive project`,onClick:()=>T(!0)})]})})]})}),(0,z.jsx)(k,{children:e.archived?(0,z.jsxs)(A,{onSelect:()=>T(!1),children:[(0,z.jsx)(D,{}),` Reopen`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(A,{onSelect:()=>{x(e.name),_(!0)},children:[(0,z.jsx)(h,{}),` Rename`]}),(0,z.jsxs)(A,{onSelect:()=>T(!0),children:[(0,z.jsx)(w,{}),` Archive`]})]})})]}),(0,z.jsx)(u,{open:m,onOpenChange:_,children:(0,z.jsxs)(c,{children:[(0,z.jsx)(a,{children:(0,z.jsx)(l,{children:`Rename project`})}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),O()},children:[(0,z.jsx)(g,{value:b,onChange:e=>x(e.target.value),autoFocus:!0}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsx)(y,{className:`text-fg-muted`,children:`Path`}),(0,z.jsx)(`p`,{className:`truncate font-mono text-2xs text-fg-muted`,children:t??`…`})]}),(0,z.jsxs)(s,{children:[(0,z.jsx)(o,{type:`button`,variant:`ghost`,onClick:()=>_(!1),children:`Cancel`}),(0,z.jsx)(o,{type:`submit`,disabled:!b.trim()||p.isPending,children:`Rename`})]})]})]})})]})}function q({icon:e,label:t,hint:n,onClick:r}){return(0,z.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex flex-col rounded-lg bg-surface p-4 text-left transition-colors hover:bg-elevated`,children:[(0,z.jsxs)(`h2`,{className:`flex items-center gap-2 truncate text-base font-semibold text-fg group-hover:text-accent`,children:[(0,z.jsx)(e,{className:`size-4 shrink-0`}),t]}),(0,z.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:n})]})}function J(){let e=r(),t=d(e??void 0),n=m(),i=f(e??void 0),a=p(e??``),[o,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(null),[u,h]=(0,R.useState)(!1),g=V(),v=e=>n.data?.find(t=>t.id===e)?.path,y=t.data??[],b=i.data?.projectOrder??[],x=T(y.filter(e=>!e.archived),b),S=y.filter(e=>e.archived),E=(e,t)=>{e!==t&&a.mutate({projectOrder:O(x.map(e=>e.id),e,t)})};return(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,z.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[y.length===0&&(0,z.jsxs)(`div`,{className:`mb-8 mt-16 flex flex-col items-center gap-3 text-center`,children:[(0,z.jsx)(_,{className:`size-8 text-fg-muted`}),(0,z.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`No projects yet — open one below, or press ⌘K.`})]}),(0,z.jsxs)(`div`,{className:`grid auto-rows-fr grid-cols-1 gap-3 sm:grid-cols-2`,children:[x.map(e=>(0,z.jsx)(K,{project:e,repoPath:v(e.repo_id),draggable:!0,dragging:c===e.id,onDragStart:()=>l(e.id),onDragEnd:()=>l(null),onDragOver:t=>{t.preventDefault(),c&&c!==e.id&&E(c,e.id)}},e.id)),(0,z.jsx)(q,{icon:I,label:`Open project`,hint:`Point at a repository on this host`,onClick:()=>s(!0)}),(0,z.jsx)(q,{icon:P,label:g.open?`Close terminal`:`Open terminal`,hint:g.open?`End the shell below`:`A shell at ~ for cloning repositories`,onClick:g.toggle})]}),S.length>0&&(0,z.jsxs)(`div`,{className:`mt-6`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>h(e=>!e),className:`flex items-center gap-1.5 px-1 py-1.5 text-2xs uppercase tracking-wide text-fg-muted transition-colors hover:text-fg`,children:[(0,z.jsx)(M,{className:C(`size-3 transition-transform`,u&&`rotate-90`)}),(0,z.jsx)(w,{className:`size-3`}),(0,z.jsx)(`span`,{children:`Archived`}),(0,z.jsx)(`span`,{className:`tabular-nums`,children:S.length})]}),u&&(0,z.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:S.map(e=>(0,z.jsx)(K,{project:e,repoPath:v(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]})]})}),g.open&&(0,z.jsx)(H,{term:g.term,onExit:g.onExit}),e!==null&&(0,z.jsx)(F,{profileId:e,open:o,onOpenChange:s})]})}export{J as Dashboard};
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{r}from"./profile-store-D2pB4wB-.js";import{a as i}from"./api-CZDct42i.js";import{a,g as o,i as s,n as c,o as l,t as u}from"./dialog-B43iKmfK.js";import{G as d,H as f,R as p,X as m,a as h,it as g,o as _,r as v,rt as y,t as b,tt as x,z as S}from"./LazyTerminal-CeLHCKsO.js";import{t as C}from"./utils-B6KiDbIe.js";import{A as w,O as T,c as E,j as D,k as O,n as k,r as A,t as j}from"./context-menu-Bitp8sY-.js";import{r as M}from"./dist-i-QevsUb.js";import{I as N,K as P,N as F,Q as I,dt as L}from"./index-iPj6x3rM.js";var R=e(t(),1),z=n(),B=!1;function V(){let[e,t]=(0,R.useState)(B),[n,r]=(0,R.useState)(null);(0,R.useEffect)(()=>{if(!e)return;let t=!1;return N.spawnShell(i).then(e=>{t||r(e)}),()=>{t=!0}},[e]);let a=()=>{B=!1,t(!1),r(null)};return{open:e,term:n,toggle:()=>{e?(n&&N.killShell(i,n),a()):(B=!0,t(!0))},onExit:a}}function H({term:e,onExit:t}){return(0,z.jsx)(`div`,{className:`h-72 shrink-0 pb-6`,children:(0,z.jsx)(`div`,{className:`mx-auto size-full max-w-4xl px-6`,children:e!==null&&(0,z.jsx)(b,{stream:`home`,term:e,onExit:t})})})}var U=[{status:`running`,colour:`bg-running`},{status:`waiting_input`,colour:`bg-waiting`},{status:`interrupted`,colour:`bg-interrupted`}];function W({projectId:e}){let t=x(e),n=(0,R.useMemo)(()=>{let e=new Map;for(let n of t.data??[])e.set(n.status,(e.get(n.status)??0)+1);return e},[t.data]),r=(t.data??[]).filter(e=>e.status!==`archived`).length;return(0,z.jsxs)(`div`,{className:`flex items-center gap-3 text-2xs text-fg-muted tabular-nums`,children:[(0,z.jsxs)(`span`,{children:[r,` session`,r===1?``:`s`]}),U.map(({status:e,colour:t})=>{let r=n.get(e)??0;return r===0?null:(0,z.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,z.jsx)(`span`,{className:`size-1.5 rounded-full ${t}`}),r,` `,e.replace(`_`,` `)]},e)})]})}function G({icon:e,label:t,onClick:n}){return(0,z.jsx)(`button`,{type:`button`,"aria-label":t,title:t,onClick:e=>{e.preventDefault(),e.stopPropagation(),n()},className:`flex items-center rounded-md p-1.5 text-fg-muted transition-colors hover:bg-ground hover:text-fg`,children:(0,z.jsx)(e,{className:`size-4`})})}function K({project:e,repoPath:t,draggable:n,dragging:r,onDragStart:i,onDragEnd:d,onDragOver:f}){let p=S(),[m,_]=(0,R.useState)(!1),[b,x]=(0,R.useState)(e.name),T=t=>p.mutate({id:e.id,archived:t},{onError:e=>v(e)}),O=()=>{let t=b.trim();if(!t||t===e.name){_(!1);return}p.mutate({id:e.id,name:t},{onSuccess:()=>_(!1),onError:e=>v(e)})};return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(j,{children:[(0,z.jsx)(E,{asChild:!0,children:(0,z.jsxs)(`div`,{draggable:n,onDragStart:i,onDragEnd:d,onDragOver:f,className:C(`group relative transition-opacity`,r&&`opacity-50`),children:[(0,z.jsxs)(L,{draggable:!1,to:`/project/${e.id}`,className:`block rounded-lg bg-surface p-4 transition-colors hover:bg-elevated`,children:[(0,z.jsx)(`h2`,{className:`truncate pr-16 text-base font-semibold text-fg group-hover:text-accent`,children:e.name}),(0,z.jsx)(`p`,{className:`mt-1 truncate font-mono text-2xs text-fg-muted`,children:t??`…`}),(0,z.jsx)(`div`,{className:`mt-3`,children:(0,z.jsx)(W,{projectId:e.id})})]}),(0,z.jsx)(`div`,{className:`absolute right-2 top-2 hidden gap-0.5 group-hover:flex has-[[data-state=open]]:flex pointer-coarse:flex`,children:e.archived?(0,z.jsx)(G,{icon:D,label:`Reopen project`,onClick:()=>T(!1)}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(G,{icon:h,label:`Rename project`,onClick:()=>{x(e.name),_(!0)}}),(0,z.jsx)(G,{icon:w,label:`Archive project`,onClick:()=>T(!0)})]})})]})}),(0,z.jsx)(k,{children:e.archived?(0,z.jsxs)(A,{onSelect:()=>T(!1),children:[(0,z.jsx)(D,{}),` Reopen`]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(A,{onSelect:()=>{x(e.name),_(!0)},children:[(0,z.jsx)(h,{}),` Rename`]}),(0,z.jsxs)(A,{onSelect:()=>T(!0),children:[(0,z.jsx)(w,{}),` Archive`]})]})})]}),(0,z.jsx)(u,{open:m,onOpenChange:_,children:(0,z.jsxs)(c,{children:[(0,z.jsx)(a,{children:(0,z.jsx)(l,{children:`Rename project`})}),(0,z.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),O()},children:[(0,z.jsx)(g,{value:b,onChange:e=>x(e.target.value),autoFocus:!0}),(0,z.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,z.jsx)(y,{className:`text-fg-muted`,children:`Path`}),(0,z.jsx)(`p`,{className:`truncate font-mono text-2xs text-fg-muted`,children:t??`…`})]}),(0,z.jsxs)(s,{children:[(0,z.jsx)(o,{type:`button`,variant:`ghost`,onClick:()=>_(!1),children:`Cancel`}),(0,z.jsx)(o,{type:`submit`,disabled:!b.trim()||p.isPending,children:`Rename`})]})]})]})})]})}function q({icon:e,label:t,hint:n,onClick:r}){return(0,z.jsxs)(`button`,{type:`button`,onClick:r,className:`group flex flex-col rounded-lg bg-surface p-4 text-left transition-colors hover:bg-elevated`,children:[(0,z.jsxs)(`h2`,{className:`flex items-center gap-2 truncate text-base font-semibold text-fg group-hover:text-accent`,children:[(0,z.jsx)(e,{className:`size-4 shrink-0`}),t]}),(0,z.jsx)(`p`,{className:`mt-1 truncate text-2xs text-fg-muted`,children:n})]})}function J(){let e=r(),t=d(e??void 0),n=m(),i=f(e??void 0),a=p(e??``),[o,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(null),[u,h]=(0,R.useState)(!1),g=V(),v=e=>n.data?.find(t=>t.id===e)?.path,y=t.data??[],b=i.data?.projectOrder??[],x=T(y.filter(e=>!e.archived),b),S=y.filter(e=>e.archived),E=(e,t)=>{e!==t&&a.mutate({projectOrder:O(x.map(e=>e.id),e,t)})};return(0,z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,z.jsxs)(`div`,{className:`mx-auto max-w-4xl p-6`,children:[y.length===0&&(0,z.jsxs)(`div`,{className:`mb-8 mt-16 flex flex-col items-center gap-3 text-center`,children:[(0,z.jsx)(_,{className:`size-8 text-fg-muted`}),(0,z.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`No projects yet — open one below, or press ⌘K.`})]}),(0,z.jsxs)(`div`,{className:`grid auto-rows-fr grid-cols-1 gap-3 sm:grid-cols-2`,children:[x.map(e=>(0,z.jsx)(K,{project:e,repoPath:v(e.repo_id),draggable:!0,dragging:c===e.id,onDragStart:()=>l(e.id),onDragEnd:()=>l(null),onDragOver:t=>{t.preventDefault(),c&&c!==e.id&&E(c,e.id)}},e.id)),(0,z.jsx)(q,{icon:I,label:`Open project`,hint:`Point at a repository on this host`,onClick:()=>s(!0)}),(0,z.jsx)(q,{icon:P,label:g.open?`Close terminal`:`Open terminal`,hint:g.open?`End the shell below`:`A shell at ~ for cloning repositories`,onClick:g.toggle})]}),S.length>0&&(0,z.jsxs)(`div`,{className:`mt-6`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>h(e=>!e),className:`flex items-center gap-1.5 px-1 py-1.5 text-2xs uppercase tracking-wide text-fg-muted transition-colors hover:text-fg`,children:[(0,z.jsx)(M,{className:C(`size-3 transition-transform`,u&&`rotate-90`)}),(0,z.jsx)(w,{className:`size-3`}),(0,z.jsx)(`span`,{children:`Archived`}),(0,z.jsx)(`span`,{className:`tabular-nums`,children:S.length})]}),u&&(0,z.jsx)(`div`,{className:`mt-2 grid grid-cols-1 gap-3 sm:grid-cols-2`,children:S.map(e=>(0,z.jsx)(K,{project:e,repoPath:v(e.repo_id),draggable:!1,dragging:!1,onDragStart:()=>{},onDragEnd:()=>{},onDragOver:()=>{}},e.id))})]})]})}),g.open&&(0,z.jsx)(H,{term:g.term,onExit:g.onExit}),e!==null&&(0,z.jsx)(F,{profileId:e,open:o,onOpenChange:s})]})}export{J as Dashboard};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{a as r,g as i,h as a,i as o,n as s,o as c,r as l,t as u}from"./dialog-B43iKmfK.js";import{t as d}from"./utils-B6KiDbIe.js";import{t as f}from"./createLucideIcon-DyMAgLa3.js";import{l as p,r as m,t as h}from"./buffer-store-BrujywTq.js";import{s as g,t as _}from"./editor-sync-f1V6Wuxn.js";var v=f(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),y=e(t(),1),b=n();function x(e,t,n){let r=h(e,t,n);return(0,y.useSyncExternalStore)((0,y.useCallback)(e=>p(r,e),[r]),()=>m(r))}function S({session:e,path:t,kind:n,root:f,label:p,onClose:m}){let h=x(e,t,f)&&n!==`commit`,[S,C]=(0,y.useState)(!1),w=()=>h?C(!0):m();return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:e=>{e.stopPropagation(),w()},className:d(`size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg`,h?`flex`:`hidden group-hover:flex pointer-coarse:flex`),"aria-label":`Close ${p}`,children:h?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(v,{className:`size-2 fill-current group-hover:hidden`}),(0,b.jsx)(a,{className:`hidden size-3 group-hover:block`})]}):(0,b.jsx)(a,{className:`size-3`})}),(0,b.jsx)(u,{open:S,onOpenChange:e=>!e&&C(!1),children:(0,b.jsxs)(s,{children:[(0,b.jsxs)(r,{children:[(0,b.jsxs)(c,{children:[`Discard changes to `,p,`?`]}),(0,b.jsx)(l,{children:`This file has unsaved changes. Closing the tab will discard them.`})]}),(0,b.jsxs)(o,{children:[(0,b.jsx)(i,{variant:`ghost`,onClick:()=>C(!1),children:`Keep editing`}),(0,b.jsx)(i,{variant:`danger`,onClick:()=>{g(e,t,f),_(e,t,f),C(!1),m()},children:`Discard`})]})]})})]})}export{S as EditorTabClose};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{a as r,g as i,h as a,i as o,n as s,o as c,r as l,t as u}from"./dialog-B43iKmfK.js";import{t as d}from"./utils-B6KiDbIe.js";import{t as f}from"./createLucideIcon-DyMAgLa3.js";import{l as p,r as m,t as h}from"./buffer-store-CiF8VU5A.js";import{s as g,t as _}from"./editor-sync-f1V6Wuxn.js";var v=f(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),y=e(t(),1),b=n();function x(e,t,n){let r=h(e,t,n);return(0,y.useSyncExternalStore)((0,y.useCallback)(e=>p(r,e),[r]),()=>m(r))}function S({session:e,path:t,kind:n,root:f,label:p,onClose:m}){let h=x(e,t,f)&&n!==`commit`,[S,C]=(0,y.useState)(!1),w=()=>h?C(!0):m();return(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(`button`,{onClick:e=>{e.stopPropagation(),w()},className:d(`size-4 items-center justify-center rounded-sm text-fg-muted transition-colors hover:text-fg`,h?`flex`:`hidden group-hover:flex pointer-coarse:flex`),"aria-label":`Close ${p}`,children:h?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(v,{className:`size-2 fill-current group-hover:hidden`}),(0,b.jsx)(a,{className:`hidden size-3 group-hover:block`})]}):(0,b.jsx)(a,{className:`size-3`})}),(0,b.jsx)(u,{open:S,onOpenChange:e=>!e&&C(!1),children:(0,b.jsxs)(s,{children:[(0,b.jsxs)(r,{children:[(0,b.jsxs)(c,{children:[`Discard changes to `,p,`?`]}),(0,b.jsx)(l,{children:`This file has unsaved changes. Closing the tab will discard them.`})]}),(0,b.jsxs)(o,{children:[(0,b.jsx)(i,{variant:`ghost`,onClick:()=>C(!1),children:`Keep editing`}),(0,b.jsx)(i,{variant:`danger`,onClick:()=>{g(e,t,f),_(e,t,f),C(!1),m()},children:`Discard`})]})]})})]})}export{S as EditorTabClose};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-DdMmi23H.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/api-CZDct42i.js","assets/utils-B6KiDbIe.js","assets/index-C0rwYhwD.js","assets/profile-store-D2pB4wB-.js","assets/preload-helper-Czpn1I53.js","assets/dialog-B43iKmfK.js","assets/createLucideIcon-DyMAgLa3.js","assets/index-DuiUHuMe.css","assets/ssh-mode-DZa3UGPR.js","assets/Terminal-BrP-ENHg.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,t as r}from"./jsx-runtime-ffCh33zF.js";import{a as i,i as a,l as o,o as s}from"./profile-store-D2pB4wB-.js";import{t as c}from"./preload-helper-Czpn1I53.js";import{S as l,n as u}from"./api-CZDct42i.js";import{A as d,C as f,O as p,w as m,x as h}from"./dialog-B43iKmfK.js";import{t as g}from"./utils-B6KiDbIe.js";import{t as _}from"./createLucideIcon-DyMAgLa3.js";var v=e(t(),1),y=[`top`,`right`,`bottom`,`left`],b=Math.min,x=Math.max,S=Math.round,C=Math.floor,w=e=>({x:e,y:e}),T={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function E(e,t,n){return x(e,b(t,n))}function D(e,t){return typeof e==`function`?e(t):e}function O(e){return e.split(`-`)[0]}function k(e){return e.split(`-`)[1]}function A(e){return e===`x`?`y`:`x`}function j(e){return e===`y`?`height`:`width`}function M(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function N(e){return A(M(e))}function P(e,t,n){n===void 0&&(n=!1);let r=k(e),i=N(e),a=j(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=B(o)),[o,B(o)]}function F(e){let t=B(e);return[I(e),t,I(t)]}function I(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var L=[`left`,`right`],R=[`right`,`left`],z=[`top`,`bottom`],ee=[`bottom`,`top`];function te(e,t,n){switch(e){case`top`:case`bottom`:return n?t?R:L:t?L:R;case`left`:case`right`:return t?z:ee;default:return[]}}function ne(e,t,n,r){let i=k(e),a=te(O(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(I)))),a}function B(e){let t=O(e);return T[t]+e.slice(t.length)}function re(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function ie(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:re(e)}function V(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function ae(e,t,n){let{reference:r,floating:i}=e,a=M(t),o=N(t),s=j(o),c=O(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=k(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function oe(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=D(t,e),p=ie(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=V(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=V(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var se=50,ce=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:oe},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ae(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<se&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=ae(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},le=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=D(e,t)||{};if(l==null)return{};let d=ie(u),f={x:n,y:r},p=N(i),m=j(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,x=a.reference[m]+a.reference[p]-f[p]-a.floating[m],S=f[p]-a.reference[p],C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),w=C?C[y]:0;(!w||!await(o.isElement==null?void 0:o.isElement(C)))&&(w=s.floating[y]||a.floating[m]);let T=x/2-S/2,O=w/2-h[m]/2-1,A=b(d[_],O),M=b(d[v],O),P=w-h[m]-M,F=w/2-h[m]/2+T,I=E(A,F,P),L=!c.arrow&&k(i)!=null&&F!==I&&a.reference[m]/2-(F<A?A:M)-h[m]/2<0,R=L?F<A?F-A:F-P:0;return{[p]:f[p]+R,data:{[p]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),ue=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=D(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=O(r),_=M(o),v=O(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[B(o)]:F(o)),x=p!==`none`;!d&&x&&b.push(...ne(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=P(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==M(t))||T.every(e=>M(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=M(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function de(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function fe(e){return y.some(t=>e[t]>=0)}var pe=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=D(e,t);switch(i){case`referenceHidden`:{let e=de(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:fe(e)}}}case`escaped`:{let e=de(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:fe(e)}}}default:return{}}}}},me=new Set([`left`,`top`]);async function he(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=O(n),s=k(n),c=M(n)===`y`,l=me.has(o)?-1:1,u=a&&c?-1:1,d=D(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var ge=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await he(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},_e=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=D(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=M(i),p=A(f),m=u[p],h=u[f],g=(e,t)=>E(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},ve=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=D(e,t),u={x:n,y:r},d=M(i),f=A(d),p=u[f],m=u[d],h=D(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=me.has(O(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},ye=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=D(e,t),c=await i.detectOverflow(t,s),l=O(n),u=k(n),d=M(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=b(p-c[m],g),y=b(f-c[h],_),S=t.middlewareData.shift,C=!S,w=v,T=y;S!=null&&S.enabled.x&&(T=_),S!=null&&S.enabled.y&&(w=g),C&&!u&&(d?T=f-2*x(c.left,c.right):w=p-2*x(c.top,c.bottom)),await o({...t,availableWidth:T,availableHeight:w});let E=await i.getDimensions(a.floating);return f!==E.width||p!==E.height?{reset:{rects:!0}}:{}}}};function be(){return typeof window<`u`}function H(e){return xe(e)?(e.nodeName||``).toLowerCase():`#document`}function U(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function W(e){return((xe(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function xe(e){return be()?e instanceof Node||e instanceof U(e).Node:!1}function G(e){return be()?e instanceof Element||e instanceof U(e).Element:!1}function K(e){return be()?e instanceof HTMLElement||e instanceof U(e).HTMLElement:!1}function Se(e){return!be()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof U(e).ShadowRoot}function Ce(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=J(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function we(e){return/^(table|td|th)$/.test(H(e))}function Te(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Ee=/transform|translate|scale|rotate|perspective|filter/,De=/paint|layout|strict|content/,q=e=>!!e&&e!==`none`,Oe;function ke(e){let t=G(e)?J(e):e;return q(t.transform)||q(t.translate)||q(t.scale)||q(t.rotate)||q(t.perspective)||!je()&&(q(t.backdropFilter)||q(t.filter))||Ee.test(t.willChange||``)||De.test(t.contain||``)}function Ae(e){let t=Y(e);for(;K(t)&&!Me(t);){if(ke(t))return t;if(Te(t))return null;t=Y(t)}return null}function je(){return Oe??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Oe}function Me(e){return/^(html|body|#document)$/.test(H(e))}function J(e){return U(e).getComputedStyle(e)}function Ne(e){return G(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Y(e){if(H(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Se(e)&&e.host||W(e);return Se(t)?t.host:t}function Pe(e){let t=Y(e);return Me(t)?(e.ownerDocument||e).body:K(t)&&Ce(t)?t:Pe(t)}function Fe(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Pe(e),i=r===e.ownerDocument?.body,a=U(r);if(i){let e=Ie(a);return t.concat(a,a.visualViewport||[],Ce(r)?r:[],e&&n?Fe(e):[])}else return t.concat(r,Fe(r,[],n))}function Ie(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Le(e){let t=J(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=K(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=S(n)!==a||S(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Re(e){return G(e)?e:e.contextElement}function X(e){let t=Re(e);if(!K(t))return w(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Le(t),o=(a?S(n.width):n.width)/r,s=(a?S(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var ze=w(0);function Be(e){let t=U(e);return!je()||!t.visualViewport?ze:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ve(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===U(e)}function Z(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Re(e),o=w(1);t&&(r?G(r)&&(o=X(r)):o=X(e));let s=Ve(a,n,r)?Be(a):w(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=U(a),t=G(r)?U(r):r,n=e,i=Ie(n);for(;i&&t!==n;){let e=X(i),t=i.getBoundingClientRect(),r=J(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=U(i),i=Ie(n)}}return V({width:u,height:d,x:c,y:l})}function He(e,t){let n=Ne(e).scrollLeft;return t?t.left+n:Z(W(e)).left+n}function Ue(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-He(e,n),y:n.top+t.scrollTop}}function We(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=W(r),s=t?Te(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=w(1),u=w(0),d=K(r);if((d||!a)&&((H(r)!==`body`||Ce(o))&&(c=Ne(r)),d)){let e=Z(r);l=X(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Ue(o,c):w(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Ge(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Ke(e){let t=Ne(e),n=e.ownerDocument.body,r=x(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=x(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+He(e),o=-t.scrollTop;return J(n).direction===`rtl`&&(a+=x(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var qe=25;function Je(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=U(e),a=W(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!je()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(He(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=qe&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Ye(e,t){let n=Z(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=X(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Xe(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Je(e,n,t);else if(t===`document`)r=Ke(W(e));else if(G(t))r=Ye(t,n);else{let n=Be(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return V(r)}function Ze(e,t){let n=t.get(e);if(n)return n;let r=Fe(e,[],!1).filter(e=>G(e)&&H(e)!==`body`),i=null,a=J(e).position===`fixed`,o=a?Y(e):e;for(;G(o)&&!Me(o);){let e=J(o),t=ke(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Y(o)}return t.set(e,r),r}function Qe(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Te(t)?[]:Ze(t,this._c):[].concat(n),r],o=Xe(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Xe(t,a[e],i);s=x(n.top,s),c=b(n.right,c),l=b(n.bottom,l),u=x(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function $e(e){let{width:t,height:n}=Le(e);return{width:t,height:n}}function et(e,t,n){let r=K(t),i=W(t),a=n===`fixed`,o=Z(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=w(0);if((r||!a)&&((H(t)!==`body`||Ce(i))&&(s=Ne(t)),r)){let e=Z(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=He(i));let l=i&&!r&&!a?Ue(i,s):w(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function tt(e){return J(e).position===`static`}function nt(e,t){if(!K(e)||J(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return W(e)===n&&(n=n.ownerDocument.body),n}function rt(e,t){let n=U(e);if(Te(e))return n;if(!K(e)){let t=Y(e);for(;t&&!Me(t);){if(G(t)&&!tt(t))return t;t=Y(t)}return n}let r=nt(e,t);for(;r&&we(r)&&tt(r);)r=nt(r,t);return r&&Me(r)&&tt(r)&&!ke(r)?n:r||Ae(e)||n}var it=async function(e){let t=this.getOffsetParent||rt,n=this.getDimensions,r=await n(e.floating);return{reference:et(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function at(e){return J(e).direction===`rtl`}var ot={convertOffsetParentRelativeRectToViewportRelativeRect:We,getDocumentElement:W,getClippingRect:Qe,getOffsetParent:rt,getElementRects:it,getClientRects:Ge,getDimensions:$e,getScale:X,isElement:G,isRTL:at};function st(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ct(e,t,n){let r=null,i,a=W(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=C(d),h=C(a.clientWidth-(u+f)),g=C(a.clientHeight-(d+p)),_=C(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:x(0,b(1,c))||1},y=!0;function S(t){let n=t[0].intersectionRatio;if(!st(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(S,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(S,v)}r.observe(e)}let c=U(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function lt(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Re(e),u=i||a?[...l?Fe(l):[],...t?Fe(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?ct(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Z(e):null;c&&g();function g(){let t=Z(e);h&&!st(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var ut=ge,dt=_e,ft=ue,pt=ye,mt=pe,ht=le,gt=ve,_t=(e,t,n)=>{let r=new Map,i=n??{},a={...ot,...i.platform,_c:r};return ce(e,t,{...i,platform:a})},vt=e(n(),1),yt=typeof document<`u`?v.useLayoutEffect:function(){};function bt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!bt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!bt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function xt(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function St(e,t){let n=xt(e);return Math.round(t*n)/n}function Ct(e){let t=v.useRef(e);return yt(()=>{t.current=e}),t}function wt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=v.useState(r);bt(f,r)||p(r);let[m,h]=v.useState(null),[g,_]=v.useState(null),y=v.useCallback(e=>{e!==C.current&&(C.current=e,h(e))},[]),b=v.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),x=a||m,S=o||g,C=v.useRef(null),w=v.useRef(null),T=v.useRef(u),E=c!=null,D=Ct(c),O=Ct(i),k=Ct(l),A=v.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),_t(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!bt(T.current,t)&&(T.current=t,vt.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);yt(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=v.useRef(!1);yt(()=>(j.current=!0,()=>{j.current=!1}),[]),yt(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=v.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=v.useMemo(()=>({reference:x,floating:S}),[x,S]),P=v.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=St(N.floating,u.x),r=St(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...xt(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return v.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var Tt=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:ht({element:r.current,padding:i}).fn(n):r?ht({element:r,padding:i}).fn(n):{}}}},Et=(e,t)=>{let n=ut(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dt=(e,t)=>{let n=dt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ot=(e,t)=>({fn:gt(e).fn,options:[e,t]}),kt=(e,t)=>{let n=ft(e);return{name:n.name,fn:n.fn,options:[e,t]}},At=(e,t)=>{let n=pt(e);return{name:n.name,fn:n.fn,options:[e,t]}},jt=(e,t)=>{let n=mt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Mt=(e,t)=>{let n=Tt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Q=r(),Nt=`Arrow`,Pt=v.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,Q.jsx)(m.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,Q.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Pt.displayName=Nt;var Ft=Pt;function It(e){let[t,n]=v.useState(void 0);return h(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var Lt=`Popper`,[Rt,zt]=p(Lt),[Bt,Vt]=Rt(Lt),Ht=e=>{let{__scopePopper:t,children:n}=e,[r,i]=v.useState(null),[a,o]=v.useState(void 0);return(0,Q.jsx)(Bt,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};Ht.displayName=Lt;var Ut=`PopperAnchor`,Wt=v.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=Vt(Ut,n),o=v.useRef(null),s=a.onAnchorChange,c=d(t,v.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=v.useRef(null);v.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&en(a.placementState),f=u?.[0],p=u?.[1];return r?null:(0,Q.jsx)(m.div,{"data-radix-popper-side":f,"data-radix-popper-align":p,...i,ref:c})});Wt.displayName=Ut;var Gt=`PopperContent`,[Kt,qt]=Rt(Gt),Jt=v.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:p=`partial`,hideWhenDetached:g=!1,updatePositionStrategy:_=`optimized`,onPlaced:y,...b}=e,x=Vt(Gt,n),[S,C]=v.useState(null),w=d(t,C),[T,E]=v.useState(null),D=It(T),O=D?.width??0,k=D?.height??0,A=r+(a===`center`?``:`-`+a),j=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},M=Array.isArray(l)?l:[l],N=M.length>0,P={padding:j,boundary:M.filter(Qt),altBoundary:N},{refs:F,floatingStyles:I,placement:L,isPositioned:R,middlewareData:z}=wt({strategy:`fixed`,placement:A,whileElementsMounted:(...e)=>lt(...e,{animationFrame:_===`always`}),elements:{reference:x.anchor},middleware:[Et({mainAxis:i+k,alignmentAxis:o}),c&&Dt({mainAxis:!0,crossAxis:!1,limiter:p===`partial`?Ot():void 0,...P}),c&&kt({...P}),At({...P,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),T&&Mt({element:T,padding:s}),$t({arrowWidth:O,arrowHeight:k}),g&&jt({strategy:`referenceHidden`,...P,boundary:N?P.boundary:void 0})]}),ee=x.setPlacementState;h(()=>(ee(L),()=>{ee(void 0)}),[L,ee]);let[te,ne]=en(L),B=f(y);h(()=>{R&&B?.()},[R,B]);let re=z.arrow?.x,ie=z.arrow?.y,V=z.arrow?.centerOffset!==0,[ae,oe]=v.useState();return h(()=>{S&&oe(window.getComputedStyle(S).zIndex)},[S]),(0,Q.jsx)(`div`,{ref:F.setFloating,"data-radix-popper-content-wrapper":``,style:{...I,transform:R?I.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ae,"--radix-popper-transform-origin":[z.transformOrigin?.x,z.transformOrigin?.y].join(` `),...z.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,Q.jsx)(Kt,{scope:n,placedSide:te,placedAlign:ne,onArrowChange:E,arrowX:re,arrowY:ie,shouldHideArrow:V,children:(0,Q.jsx)(m.div,{"data-side":te,"data-align":ne,...b,ref:w,style:{...b.style,animation:R?void 0:`none`}})})})});Jt.displayName=Gt;var Yt=`PopperArrow`,Xt={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Zt=v.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=qt(Yt,n),a=Xt[i.placedSide];return(0,Q.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,Q.jsx)(Ft,{...r,ref:t,style:{...r.style,display:`block`}})})});Zt.displayName=Yt;function Qt(e){return e!==null}var $t=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=en(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function en(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var tn=Ht,nn=Wt,rn=Jt,an=Zt,on=`rounded-md bg-border/50 text-sm text-fg placeholder:text-fg-muted transition-colors hover:bg-border/80 focus:bg-border/80 disabled:cursor-not-allowed disabled:opacity-50`,sn=`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,cn=`data-[highlighted]:bg-action data-[highlighted]:text-action-ink data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,ln=`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`;function un({className:e,type:t,...n}){return(0,Q.jsx)(`input`,{type:t,className:g(`flex h-8 w-full px-2.5`,on,e),...n})}function dn({className:e,...t}){return(0,Q.jsx)(`textarea`,{className:g(`flex min-h-16 w-full px-2.5 py-2`,on,e),...t})}var fn=`Label`,pn=v.forwardRef((e,t)=>(0,Q.jsx)(m.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));pn.displayName=fn;var mn=pn;function hn({className:e,...t}){return(0,Q.jsx)(mn,{className:g(`text-xs font-medium text-fg-secondary peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function gn(){return s({queryKey:[`profiles`],queryFn:()=>u(`GET`,`/api/profiles`)})}function _n(e){return s({queryKey:[`profile-settings`,e],queryFn:()=>u(`GET`,`/api/profiles/${e}/settings`),enabled:e!==void 0})}function vn(e){return s({queryKey:[`accounts`,e],queryFn:()=>u(`GET`,`/api/accounts?profile=${e}`),enabled:e!==void 0})}function yn(e){return s({queryKey:[`account-usage`,e],queryFn:()=>u(`GET`,`/api/accounts/${e}/usage`),enabled:e!==void 0,staleTime:15e3})}function bn(){return s({queryKey:[`repos`],queryFn:()=>u(`GET`,`/api/repos`)})}function xn(e){return s({queryKey:[`projects`,e??`all`],queryFn:()=>u(`GET`,e===void 0?`/api/projects`:`/api/projects?profile=${e}`)})}function Sn(e){return s({queryKey:[`project`,e],queryFn:()=>u(`GET`,`/api/projects/${e}`),enabled:e!==void 0})}function Cn(e){return s({queryKey:[`sessions`,e],queryFn:()=>u(`GET`,`/api/sessions?project=${e}`),enabled:e!==void 0})}var wn={queryKey:[`sessions`,`all`],queryFn:()=>u(`GET`,`/api/sessions`)};function Tn(){return s(wn)}function En(e){return e.fetchQuery(wn)}function Dn(){return s({queryKey:[`config`],queryFn:()=>u(`GET`,`/api/config`)})}function On(e){return s({queryKey:[`repo-branches`,e],queryFn:()=>u(`GET`,`/api/repos/${e}/branches`),enabled:e!==void 0,staleTime:3e4})}function kn(e){return s({queryKey:[`repo-worktrees`,e],queryFn:()=>u(`GET`,`/api/repos/${e}/worktrees`),enabled:e!==void 0,staleTime:1e4})}function An(e,t){let n=o();return i({mutationFn:t=>u(`DELETE`,`/api/repos/${e}/worktrees?path=${encodeURIComponent(t)}`),onSuccess:r=>{n.setQueryData([`repo-worktrees`,e],r),n.invalidateQueries({queryKey:[`project`,t]})}})}function jn(e,t){let n=o();return i({mutationFn:({name:t,confirm:n})=>{let r=new URLSearchParams({name:t});return n&&r.set(`confirm`,`1`),u(`DELETE`,`/api/repos/${e}/branches?${r.toString()}`)},onSuccess:r=>{n.setQueryData([`repo-worktrees`,e],r),n.invalidateQueries({queryKey:[`project`,t]})}})}function Mn(e){return s({queryKey:[`fs-dirs`,e],queryFn:()=>u(`GET`,`/api/fs/dirs?prefix=${encodeURIComponent(e)}`),enabled:e.startsWith(`/`)||e.startsWith(`~`),placeholderData:e=>e,staleTime:1e4})}function Nn(){return s({queryKey:[`version`],queryFn:()=>u(`GET`,`/api/version`),staleTime:1/0})}function Pn(){return s({queryKey:[`host`],queryFn:()=>u(`GET`,`/api/host`),staleTime:1/0})}function Fn(e){return e?e.displayName||e.hostname:void 0}function In(){return s({queryKey:[`agents`],queryFn:()=>u(`GET`,`/api/agents`),staleTime:3e4,refetchOnWindowFocus:!0})}function Ln(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/profiles`,e),onSuccess:()=>void e.invalidateQueries({queryKey:[`profiles`]})})}function Rn(e){let t=o();return i({mutationFn:t=>u(`PATCH`,`/api/profiles/${e}/settings`,t),onSuccess:n=>t.setQueryData([`profile-settings`,e],n)})}function zn(){let e=o();return i({mutationFn:({id:e,...t})=>u(`PATCH`,`/api/profiles/${e}`,t),onSuccess:()=>void e.invalidateQueries({queryKey:[`profiles`]})})}function Bn(){let e=o();return i({mutationFn:({id:e,...t})=>u(`PATCH`,`/api/accounts/${e}`,t),onSuccess:t=>{e.invalidateQueries({queryKey:[`accounts`,t.profile_id]}),e.invalidateQueries({queryKey:[`account-usage`,t.id]})}})}function Vn(){let e=o();return i({mutationFn:e=>u(`DELETE`,`/api/profiles/${e}`),onSuccess:()=>e.clear()})}function Hn(){let e=o();return i({mutationFn:e=>u(`DELETE`,`/api/accounts/${e}`),onSuccess:()=>void e.invalidateQueries({queryKey:[`accounts`]})})}function Un(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/accounts`,e),onSuccess:t=>void e.invalidateQueries({queryKey:[`accounts`,t.profile_id]})})}function Wn(){return i({mutationFn:e=>u(`POST`,`/api/accounts/${e}/login`)})}function Gn(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/repos`,e),onSuccess:()=>void e.invalidateQueries({queryKey:[`repos`]})})}function Kn(){let e=o();return i({mutationFn:({id:e,...t})=>u(`PATCH`,`/api/repos/${e}`,t),onSuccess:()=>void e.invalidateQueries({queryKey:[`repos`]})})}function qn(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/repos/${e}/fetch`),onSuccess:()=>void e.invalidateQueries({queryKey:[`repos`]})})}function Jn(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/projects`,e),onSuccess:()=>void e.invalidateQueries({queryKey:[`projects`]})})}function Yn(){let e=o();return i({mutationFn:({id:e,...t})=>u(`PATCH`,`/api/projects/${e}`,t),onSuccess:()=>void e.invalidateQueries({queryKey:[`projects`]})})}function Xn(e,t){return s({queryKey:[`scratchpad`,e,t??`none`],queryFn:()=>u(`GET`,`/api/scratchpad?profile=${e}${t?`&project=${t}`:``}`),enabled:e!==void 0})}function Zn(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/scratchpad`,e),onSuccess:()=>void e.invalidateQueries({queryKey:[`scratchpad`]})})}function Qn(){let e=o();return i({mutationFn:({id:e,...t})=>u(`PATCH`,`/api/scratchpad/${e}`,t),onSuccess:()=>void e.invalidateQueries({queryKey:[`scratchpad`]})})}function $n(){let e=o();return i({mutationFn:e=>u(`DELETE`,`/api/scratchpad/${e}`),onSuccess:()=>void e.invalidateQueries({queryKey:[`scratchpad`]})})}function $(e,t){e.invalidateQueries({queryKey:[`sessions`]}),e.invalidateQueries({queryKey:[`project`,t.project_id]})}function er(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/sessions`,e),onSuccess:t=>$(e,t)})}function tr(e){let t=o();return i({mutationFn:t=>u(`POST`,`/api/sessions/${t}/${e}`),onSuccess:e=>$(t,e)})}function nr(){let e=o();return i({mutationFn:({sessionId:e,accountId:t})=>u(`POST`,`/api/sessions/${e}/migrate`,{account_id:t}),onSuccess:t=>$(e,t)})}function rr(){let e=o();return i({mutationFn:({sessionId:e,accountId:t})=>u(`POST`,`/api/sessions/${e}/handoff`,{account_id:t}),onSuccess:(t,{sessionId:n})=>{$(e,t),e.invalidateQueries({queryKey:[`session`,n]})}})}function ir(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/sessions/${e}/archive`),onSuccess:t=>$(e,t)})}function ar(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/sessions/${e}/unarchive`),onSuccess:t=>$(e,t)})}function or(){let e=o();return i({mutationFn:({sessionId:e,title:t})=>u(`PATCH`,`/api/sessions/${e}`,{title:t}),onSuccess:t=>$(e,t)})}function sr(){let e=o();return i({mutationFn:e=>u(`PATCH`,`/api/config`,e),onSuccess:(t,n)=>{e.setQueryData([`config`],t),`displayName`in n&&e.invalidateQueries({queryKey:[`host`]})}})}async function cr(e){try{return await u(`GET`,`/api/profiles/${e}/state`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`no_state`)return null;throw e}}function lr(e,t){return u(`PUT`,`/api/profiles/${e}/state`,{ui_state:t})}function ur(e,t){return s({queryKey:[`ports`,e],queryFn:()=>u(`GET`,`/api/sessions/${e}/ports`),enabled:e!==void 0&&t,refetchInterval:a(5e3),refetchIntervalInBackground:!1})}function dr(e,t){return s({queryKey:[`session-env`,e],queryFn:()=>u(`GET`,`/api/sessions/${e}/env`),enabled:e!==void 0&&t,refetchInterval:a(5e3),refetchIntervalInBackground:!1})}function fr(){let e=o();return i({mutationFn:e=>u(`DELETE`,`/api/sessions/${e}/env`),onSuccess:(t,n)=>{e.setQueryData([`session-env`,n],{vars:[]})}})}var pr=_(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),mr=_(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]);function hr({id:e,value:t,onValueChange:n,onChoose:r,hints:i,placeholder:a,className:o,hintsClassName:s,autoFocus:c}){let[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(0),p=e=>{n(e.value),r?.(e),u(!1)};return(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(un,{id:e,value:t,onChange:e=>{n(e.target.value),u(!0),f(0)},onFocus:()=>u(!0),onBlur:()=>u(!1),onKeyDown:e=>{if(!(!l||i.length===0))if(e.key===`ArrowDown`)e.preventDefault(),f(e=>(e+1)%i.length);else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>(e-1+i.length)%i.length);else if(e.key===`Enter`||e.key===`Tab`){let t=i[d]??i[0];t&&(e.preventDefault(),p(t))}else e.key===`Escape`&&(e.stopPropagation(),u(!1))},placeholder:a,className:o,autoComplete:`off`,spellCheck:!1,autoFocus:c}),l&&i.length>0&&(0,Q.jsx)(`ul`,{className:g(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,s??`w-full`),children:i.map((e,t)=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),p(e)},onMouseEnter:()=>f(t),className:g(`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`,`w-full font-mono text-xs`),"data-selected":t===d,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.label??e.value}),e.badge&&(0,Q.jsx)(`span`,{className:`ml-auto shrink-0 text-2xs opacity-70`,children:e.badge})]})},e.value))})]})}function gr(e){l.error(_r(e),{id:`err:${_r(e)}`})}function _r(e){return e instanceof Error&&e.message.trim()!==``?e.message:typeof e==`string`&&e.trim()!==``?e:`Something went wrong`}var vr=(0,v.lazy)(()=>c(()=>import(`./Terminal-DdMmi23H.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))),yr=null;async function br(){yr=(await c(()=>import(`./Terminal-DdMmi23H.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))).Terminal}function xr(e){return yr?(0,Q.jsx)(yr,{...e}):(0,Q.jsx)(v.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`size-full bg-ground`}),children:(0,Q.jsx)(vr,{...e})})}export{dr as $,qn as A,Kn as B,er as C,Vn as D,jn as E,Bn as F,xn as G,_n as H,sr as I,On as J,An as K,zn as L,Pn as M,Wn as N,$n as O,nr as P,tr as Q,Rn as R,Zn as S,Hn as T,gn as U,Qn as V,Sn as W,bn as X,kn as Y,Xn as Z,Dn as _,mr as a,dn as at,Jn as b,cr as c,cn as ct,yn as d,an as dt,ur as et,vn as f,rn as ft,fr as g,ir as h,It as ht,hr as i,un as it,rr as j,Mn as k,Fn as l,sn as lt,Tn as m,zt as mt,br as n,ar as nt,pr as o,on as ot,In as p,tn as pt,or as q,gr as r,hn as rt,En as s,ln as st,xr as t,Cn as tt,lr as u,nn as ut,Un as v,Nn as w,Gn as x,Ln as y,Yn as z};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/Terminal-CN5FGN0_.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-ffCh33zF.js","assets/api-CZDct42i.js","assets/utils-B6KiDbIe.js","assets/index-iPj6x3rM.js","assets/profile-store-D2pB4wB-.js","assets/preload-helper-Czpn1I53.js","assets/dialog-B43iKmfK.js","assets/createLucideIcon-DyMAgLa3.js","assets/index-CRUVuFoo.css","assets/ssh-mode-CAA0-mpZ.js","assets/Terminal-BrP-ENHg.css"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{n,t as r}from"./jsx-runtime-ffCh33zF.js";import{a as i,i as a,l as o,o as s}from"./profile-store-D2pB4wB-.js";import{t as c}from"./preload-helper-Czpn1I53.js";import{S as l,n as u}from"./api-CZDct42i.js";import{A as d,C as f,O as p,w as m,x as h}from"./dialog-B43iKmfK.js";import{t as g}from"./utils-B6KiDbIe.js";import{t as _}from"./createLucideIcon-DyMAgLa3.js";var v=e(t(),1),y=[`top`,`right`,`bottom`,`left`],b=Math.min,x=Math.max,S=Math.round,C=Math.floor,w=e=>({x:e,y:e}),T={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function E(e,t,n){return x(e,b(t,n))}function D(e,t){return typeof e==`function`?e(t):e}function O(e){return e.split(`-`)[0]}function k(e){return e.split(`-`)[1]}function A(e){return e===`x`?`y`:`x`}function j(e){return e===`y`?`height`:`width`}function M(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function N(e){return A(M(e))}function P(e,t,n){n===void 0&&(n=!1);let r=k(e),i=N(e),a=j(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=B(o)),[o,B(o)]}function F(e){let t=B(e);return[I(e),t,I(t)]}function I(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var L=[`left`,`right`],R=[`right`,`left`],z=[`top`,`bottom`],ee=[`bottom`,`top`];function te(e,t,n){switch(e){case`top`:case`bottom`:return n?t?R:L:t?L:R;case`left`:case`right`:return t?z:ee;default:return[]}}function ne(e,t,n,r){let i=k(e),a=te(O(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(I)))),a}function B(e){let t=O(e);return T[t]+e.slice(t.length)}function re(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function ie(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:re(e)}function V(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function ae(e,t,n){let{reference:r,floating:i}=e,a=M(t),o=N(t),s=j(o),c=O(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=k(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function oe(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=D(t,e),p=ie(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=V(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=V(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var se=50,ce=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:oe},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ae(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<se&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=ae(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},le=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=D(e,t)||{};if(l==null)return{};let d=ie(u),f={x:n,y:r},p=N(i),m=j(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,x=a.reference[m]+a.reference[p]-f[p]-a.floating[m],S=f[p]-a.reference[p],C=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),w=C?C[y]:0;(!w||!await(o.isElement==null?void 0:o.isElement(C)))&&(w=s.floating[y]||a.floating[m]);let T=x/2-S/2,O=w/2-h[m]/2-1,A=b(d[_],O),M=b(d[v],O),P=w-h[m]-M,F=w/2-h[m]/2+T,I=E(A,F,P),L=!c.arrow&&k(i)!=null&&F!==I&&a.reference[m]/2-(F<A?A:M)-h[m]/2<0,R=L?F<A?F-A:F-P:0;return{[p]:f[p]+R,data:{[p]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),ue=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=D(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=O(r),_=M(o),v=O(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[B(o)]:F(o)),x=p!==`none`;!d&&x&&b.push(...ne(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=P(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==M(t))||T.every(e=>M(e.placement)!==_||e.overflows[0]>0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=M(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function de(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function fe(e){return y.some(t=>e[t]>=0)}var pe=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=D(e,t);switch(i){case`referenceHidden`:{let e=de(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:fe(e)}}}case`escaped`:{let e=de(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:fe(e)}}}default:return{}}}}},me=new Set([`left`,`top`]);async function he(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=O(n),s=k(n),c=M(n)===`y`,l=me.has(o)?-1:1,u=a&&c?-1:1,d=D(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var ge=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await he(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},_e=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=D(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=M(i),p=A(f),m=u[p],h=u[f],g=(e,t)=>E(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let _=c.fn({...t,[p]:m,[f]:h});return{..._,data:{x:_.x-n,y:_.y-r,enabled:{[p]:o,[f]:s}}}}}},ve=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=D(e,t),u={x:n,y:r},d=M(i),f=A(d),p=u[f],m=u[d],h=D(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=me.has(O(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},ye=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=D(e,t),c=await i.detectOverflow(t,s),l=O(n),u=k(n),d=M(n)===`y`,{width:f,height:p}=r.floating,m,h;l===`top`||l===`bottom`?(m=l,h=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(h=l,m=u===`end`?`top`:`bottom`);let g=p-c.top-c.bottom,_=f-c.left-c.right,v=b(p-c[m],g),y=b(f-c[h],_),S=t.middlewareData.shift,C=!S,w=v,T=y;S!=null&&S.enabled.x&&(T=_),S!=null&&S.enabled.y&&(w=g),C&&!u&&(d?T=f-2*x(c.left,c.right):w=p-2*x(c.top,c.bottom)),await o({...t,availableWidth:T,availableHeight:w});let E=await i.getDimensions(a.floating);return f!==E.width||p!==E.height?{reset:{rects:!0}}:{}}}};function be(){return typeof window<`u`}function H(e){return xe(e)?(e.nodeName||``).toLowerCase():`#document`}function U(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function W(e){return((xe(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function xe(e){return be()?e instanceof Node||e instanceof U(e).Node:!1}function G(e){return be()?e instanceof Element||e instanceof U(e).Element:!1}function K(e){return be()?e instanceof HTMLElement||e instanceof U(e).HTMLElement:!1}function Se(e){return!be()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof U(e).ShadowRoot}function Ce(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=J(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function we(e){return/^(table|td|th)$/.test(H(e))}function Te(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Ee=/transform|translate|scale|rotate|perspective|filter/,De=/paint|layout|strict|content/,q=e=>!!e&&e!==`none`,Oe;function ke(e){let t=G(e)?J(e):e;return q(t.transform)||q(t.translate)||q(t.scale)||q(t.rotate)||q(t.perspective)||!je()&&(q(t.backdropFilter)||q(t.filter))||Ee.test(t.willChange||``)||De.test(t.contain||``)}function Ae(e){let t=Y(e);for(;K(t)&&!Me(t);){if(ke(t))return t;if(Te(t))return null;t=Y(t)}return null}function je(){return Oe??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Oe}function Me(e){return/^(html|body|#document)$/.test(H(e))}function J(e){return U(e).getComputedStyle(e)}function Ne(e){return G(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Y(e){if(H(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Se(e)&&e.host||W(e);return Se(t)?t.host:t}function Pe(e){let t=Y(e);return Me(t)?(e.ownerDocument||e).body:K(t)&&Ce(t)?t:Pe(t)}function Fe(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Pe(e),i=r===e.ownerDocument?.body,a=U(r);if(i){let e=Ie(a);return t.concat(a,a.visualViewport||[],Ce(r)?r:[],e&&n?Fe(e):[])}else return t.concat(r,Fe(r,[],n))}function Ie(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Le(e){let t=J(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=K(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=S(n)!==a||S(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Re(e){return G(e)?e:e.contextElement}function X(e){let t=Re(e);if(!K(t))return w(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Le(t),o=(a?S(n.width):n.width)/r,s=(a?S(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var ze=w(0);function Be(e){let t=U(e);return!je()||!t.visualViewport?ze:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ve(e,t,n){return t===void 0&&(t=!1),!!n&&t&&n===U(e)}function Z(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Re(e),o=w(1);t&&(r?G(r)&&(o=X(r)):o=X(e));let s=Ve(a,n,r)?Be(a):w(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a&&r){let e=U(a),t=G(r)?U(r):r,n=e,i=Ie(n);for(;i&&t!==n;){let e=X(i),t=i.getBoundingClientRect(),r=J(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=U(i),i=Ie(n)}}return V({width:u,height:d,x:c,y:l})}function He(e,t){let n=Ne(e).scrollLeft;return t?t.left+n:Z(W(e)).left+n}function Ue(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-He(e,n),y:n.top+t.scrollTop}}function We(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=W(r),s=t?Te(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=w(1),u=w(0),d=K(r);if((d||!a)&&((H(r)!==`body`||Ce(o))&&(c=Ne(r)),d)){let e=Z(r);l=X(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Ue(o,c):w(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Ge(e){return e.getClientRects?Array.from(e.getClientRects()):[]}function Ke(e){let t=Ne(e),n=e.ownerDocument.body,r=x(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),i=x(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight),a=-t.scrollLeft+He(e),o=-t.scrollTop;return J(n).direction===`rtl`&&(a+=x(e.clientWidth,n.clientWidth)-r),{width:r,height:i,x:a,y:o}}var qe=25;function Je(e,t,n){n===void 0&&(n=`viewport`);let r=n===`layoutViewport`,i=U(e),a=W(e),o=i.visualViewport,s=a.clientWidth,c=a.clientHeight,l=0,u=0;if(o){let e=!je()||t===`fixed`;r?e||(l=-o.offsetLeft,u=-o.offsetTop):(s=o.width,c=o.height,e&&(l=o.offsetLeft,u=o.offsetTop))}if(He(a)<=0){let e=a.ownerDocument,t=e.body,n=getComputedStyle(t),r=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(a.clientWidth-t.clientWidth-r),o=getComputedStyle(a).scrollbarGutter===`stable both-edges`?i/2:i;o<=qe&&(s-=o)}return{width:s,height:c,x:l,y:u}}function Ye(e,t){let n=Z(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=X(e);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Xe(e,t,n){let r;if(t===`viewport`||t===`layoutViewport`)r=Je(e,n,t);else if(t===`document`)r=Ke(W(e));else if(G(t))r=Ye(t,n);else{let n=Be(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return V(r)}function Ze(e,t){let n=t.get(e);if(n)return n;let r=Fe(e,[],!1).filter(e=>G(e)&&H(e)!==`body`),i=null,a=J(e).position===`fixed`,o=a?Y(e):e;for(;G(o)&&!Me(o);){let e=J(o),t=ke(o),n=i?i.position:a?`fixed`:``;!t&&(n===`fixed`||n===`absolute`&&e.position===`static`)?r=r.filter(e=>e!==o):i=e,o=Y(o)}return t.set(e,r),r}function Qe(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Te(t)?[]:Ze(t,this._c):[].concat(n),r],o=Xe(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Xe(t,a[e],i);s=x(n.top,s),c=b(n.right,c),l=b(n.bottom,l),u=x(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function $e(e){let{width:t,height:n}=Le(e);return{width:t,height:n}}function et(e,t,n){let r=K(t),i=W(t),a=n===`fixed`,o=Z(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=w(0);if((r||!a)&&((H(t)!==`body`||Ce(i))&&(s=Ne(t)),r)){let e=Z(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}!r&&i&&(c.x=He(i));let l=i&&!r&&!a?Ue(i,s):w(0);return{x:o.left+s.scrollLeft-c.x-l.x,y:o.top+s.scrollTop-c.y-l.y,width:o.width,height:o.height}}function tt(e){return J(e).position===`static`}function nt(e,t){if(!K(e)||J(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return W(e)===n&&(n=n.ownerDocument.body),n}function rt(e,t){let n=U(e);if(Te(e))return n;if(!K(e)){let t=Y(e);for(;t&&!Me(t);){if(G(t)&&!tt(t))return t;t=Y(t)}return n}let r=nt(e,t);for(;r&&we(r)&&tt(r);)r=nt(r,t);return r&&Me(r)&&tt(r)&&!ke(r)?n:r||Ae(e)||n}var it=async function(e){let t=this.getOffsetParent||rt,n=this.getDimensions,r=await n(e.floating);return{reference:et(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function at(e){return J(e).direction===`rtl`}var ot={convertOffsetParentRelativeRectToViewportRelativeRect:We,getDocumentElement:W,getClippingRect:Qe,getOffsetParent:rt,getElementRects:it,getClientRects:Ge,getDimensions:$e,getScale:X,isElement:G,isRTL:at};function st(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ct(e,t,n){let r=null,i,a=W(e);function o(){var e;clearTimeout(i),(e=r)==null||e.disconnect(),r=null}function s(n,c){n===void 0&&(n=!1),c===void 0&&(c=1),o();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(n||t(),!f||!p)return;let m=C(d),h=C(a.clientWidth-(u+f)),g=C(a.clientHeight-(d+p)),_=C(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:x(0,b(1,c))||1},y=!0;function S(t){let n=t[0].intersectionRatio;if(!st(l,e.getBoundingClientRect()))return s();if(n!==c){if(!y)return s();n?s(!1,n):i=setTimeout(()=>{s(!1,1e-7)},1e3)}y=!1}try{r=new IntersectionObserver(S,{...v,root:a.ownerDocument})}catch{r=new IntersectionObserver(S,v)}r.observe(e)}let c=U(e),l=()=>s(n);return c.addEventListener(`resize`,l),s(!0),()=>{c.removeEventListener(`resize`,l),o()}}function lt(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Re(e),u=i||a?[...l?Fe(l):[],...t?Fe(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n),a&&e.addEventListener(`resize`,n)});let d=l&&s?ct(l,n,a):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Z(e):null;c&&g();function g(){let t=Z(e);h&&!st(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var ut=ge,dt=_e,ft=ue,pt=ye,mt=pe,ht=le,gt=ve,_t=(e,t,n)=>{let r=new Map,i=n??{},a={...ot,...i.platform,_c:r};return ce(e,t,{...i,platform:a})},vt=e(n(),1),yt=typeof document<`u`?v.useLayoutEffect:function(){};function bt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!bt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!bt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function xt(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function St(e,t){let n=xt(e);return Math.round(t*n)/n}function Ct(e){let t=v.useRef(e);return yt(()=>{t.current=e}),t}function wt(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=v.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=v.useState(r);bt(f,r)||p(r);let[m,h]=v.useState(null),[g,_]=v.useState(null),y=v.useCallback(e=>{e!==C.current&&(C.current=e,h(e))},[]),b=v.useCallback(e=>{e!==w.current&&(w.current=e,_(e))},[]),x=a||m,S=o||g,C=v.useRef(null),w=v.useRef(null),T=v.useRef(u),E=c!=null,D=Ct(c),O=Ct(i),k=Ct(l),A=v.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:f};O.current&&(e.platform=O.current),_t(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!bt(T.current,t)&&(T.current=t,vt.flushSync(()=>{d(t)}))})},[f,t,n,O,k]);yt(()=>{l===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let j=v.useRef(!1);yt(()=>(j.current=!0,()=>{j.current=!1}),[]),yt(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=v.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=v.useMemo(()=>({reference:x,floating:S}),[x,S]),P=v.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=St(N.floating,u.x),r=St(N.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...xt(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,u.x,u.y]);return v.useMemo(()=>({...u,update:A,refs:M,elements:N,floatingStyles:P}),[u,A,M,N,P])}var Tt=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:ht({element:r.current,padding:i}).fn(n):r?ht({element:r,padding:i}).fn(n):{}}}},Et=(e,t)=>{let n=ut(e);return{name:n.name,fn:n.fn,options:[e,t]}},Dt=(e,t)=>{let n=dt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ot=(e,t)=>({fn:gt(e).fn,options:[e,t]}),kt=(e,t)=>{let n=ft(e);return{name:n.name,fn:n.fn,options:[e,t]}},At=(e,t)=>{let n=pt(e);return{name:n.name,fn:n.fn,options:[e,t]}},jt=(e,t)=>{let n=mt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Mt=(e,t)=>{let n=Tt(e);return{name:n.name,fn:n.fn,options:[e,t]}},Q=r(),Nt=`Arrow`,Pt=v.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,Q.jsx)(m.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,Q.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Pt.displayName=Nt;var Ft=Pt;function It(e){let[t,n]=v.useState(void 0);return h(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var Lt=`Popper`,[Rt,zt]=p(Lt),[Bt,Vt]=Rt(Lt),Ht=e=>{let{__scopePopper:t,children:n}=e,[r,i]=v.useState(null),[a,o]=v.useState(void 0);return(0,Q.jsx)(Bt,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};Ht.displayName=Lt;var Ut=`PopperAnchor`,Wt=v.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=Vt(Ut,n),o=v.useRef(null),s=a.onAnchorChange,c=d(t,v.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=v.useRef(null);v.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&en(a.placementState),f=u?.[0],p=u?.[1];return r?null:(0,Q.jsx)(m.div,{"data-radix-popper-side":f,"data-radix-popper-align":p,...i,ref:c})});Wt.displayName=Ut;var Gt=`PopperContent`,[Kt,qt]=Rt(Gt),Jt=v.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:p=`partial`,hideWhenDetached:g=!1,updatePositionStrategy:_=`optimized`,onPlaced:y,...b}=e,x=Vt(Gt,n),[S,C]=v.useState(null),w=d(t,C),[T,E]=v.useState(null),D=It(T),O=D?.width??0,k=D?.height??0,A=r+(a===`center`?``:`-`+a),j=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},M=Array.isArray(l)?l:[l],N=M.length>0,P={padding:j,boundary:M.filter(Qt),altBoundary:N},{refs:F,floatingStyles:I,placement:L,isPositioned:R,middlewareData:z}=wt({strategy:`fixed`,placement:A,whileElementsMounted:(...e)=>lt(...e,{animationFrame:_===`always`}),elements:{reference:x.anchor},middleware:[Et({mainAxis:i+k,alignmentAxis:o}),c&&Dt({mainAxis:!0,crossAxis:!1,limiter:p===`partial`?Ot():void 0,...P}),c&&kt({...P}),At({...P,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),T&&Mt({element:T,padding:s}),$t({arrowWidth:O,arrowHeight:k}),g&&jt({strategy:`referenceHidden`,...P,boundary:N?P.boundary:void 0})]}),ee=x.setPlacementState;h(()=>(ee(L),()=>{ee(void 0)}),[L,ee]);let[te,ne]=en(L),B=f(y);h(()=>{R&&B?.()},[R,B]);let re=z.arrow?.x,ie=z.arrow?.y,V=z.arrow?.centerOffset!==0,[ae,oe]=v.useState();return h(()=>{S&&oe(window.getComputedStyle(S).zIndex)},[S]),(0,Q.jsx)(`div`,{ref:F.setFloating,"data-radix-popper-content-wrapper":``,style:{...I,transform:R?I.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ae,"--radix-popper-transform-origin":[z.transformOrigin?.x,z.transformOrigin?.y].join(` `),...z.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,Q.jsx)(Kt,{scope:n,placedSide:te,placedAlign:ne,onArrowChange:E,arrowX:re,arrowY:ie,shouldHideArrow:V,children:(0,Q.jsx)(m.div,{"data-side":te,"data-align":ne,...b,ref:w,style:{...b.style,animation:R?void 0:`none`}})})})});Jt.displayName=Gt;var Yt=`PopperArrow`,Xt={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Zt=v.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=qt(Yt,n),a=Xt[i.placedSide];return(0,Q.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,Q.jsx)(Ft,{...r,ref:t,style:{...r.style,display:`block`}})})});Zt.displayName=Yt;function Qt(e){return e!==null}var $t=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=en(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function en(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var tn=Ht,nn=Wt,rn=Jt,an=Zt,on=`rounded-md bg-border/50 text-sm text-fg placeholder:text-fg-muted transition-colors hover:bg-border/80 focus:bg-border/80 disabled:cursor-not-allowed disabled:opacity-50`,sn=`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,cn=`data-[highlighted]:bg-action data-[highlighted]:text-action-ink data-[disabled]:pointer-events-none data-[disabled]:opacity-50`,ln=`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`;function un({className:e,type:t,...n}){return(0,Q.jsx)(`input`,{type:t,className:g(`flex h-8 w-full px-2.5`,on,e),...n})}function dn({className:e,...t}){return(0,Q.jsx)(`textarea`,{className:g(`flex min-h-16 w-full px-2.5 py-2`,on,e),...t})}var fn=`Label`,pn=v.forwardRef((e,t)=>(0,Q.jsx)(m.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));pn.displayName=fn;var mn=pn;function hn({className:e,...t}){return(0,Q.jsx)(mn,{className:g(`text-xs font-medium text-fg-secondary peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}function gn(){return s({queryKey:[`profiles`],queryFn:()=>u(`GET`,`/api/profiles`)})}function _n(e){return s({queryKey:[`profile-settings`,e],queryFn:()=>u(`GET`,`/api/profiles/${e}/settings`),enabled:e!==void 0})}function vn(e){return s({queryKey:[`accounts`,e],queryFn:()=>u(`GET`,`/api/accounts?profile=${e}`),enabled:e!==void 0})}function yn(e){return s({queryKey:[`account-usage`,e],queryFn:()=>u(`GET`,`/api/accounts/${e}/usage`),enabled:e!==void 0,staleTime:15e3})}function bn(){return s({queryKey:[`repos`],queryFn:()=>u(`GET`,`/api/repos`)})}function xn(e){return s({queryKey:[`projects`,e??`all`],queryFn:()=>u(`GET`,e===void 0?`/api/projects`:`/api/projects?profile=${e}`)})}function Sn(e){return s({queryKey:[`project`,e],queryFn:()=>u(`GET`,`/api/projects/${e}`),enabled:e!==void 0})}function Cn(e){return s({queryKey:[`sessions`,e],queryFn:()=>u(`GET`,`/api/sessions?project=${e}`),enabled:e!==void 0})}var wn={queryKey:[`sessions`,`all`],queryFn:()=>u(`GET`,`/api/sessions`)};function Tn(){return s(wn)}function En(e){return e.fetchQuery(wn)}function Dn(){return s({queryKey:[`config`],queryFn:()=>u(`GET`,`/api/config`)})}function On(e){return s({queryKey:[`repo-branches`,e],queryFn:()=>u(`GET`,`/api/repos/${e}/branches`),enabled:e!==void 0,staleTime:3e4})}function kn(e){return s({queryKey:[`repo-worktrees`,e],queryFn:()=>u(`GET`,`/api/repos/${e}/worktrees`),enabled:e!==void 0,staleTime:1e4})}function An(e,t){let n=o();return i({mutationFn:t=>u(`DELETE`,`/api/repos/${e}/worktrees?path=${encodeURIComponent(t)}`),onSuccess:r=>{n.setQueryData([`repo-worktrees`,e],r),n.invalidateQueries({queryKey:[`project`,t]})}})}function jn(e,t){let n=o();return i({mutationFn:({name:t,confirm:n})=>{let r=new URLSearchParams({name:t});return n&&r.set(`confirm`,`1`),u(`DELETE`,`/api/repos/${e}/branches?${r.toString()}`)},onSuccess:r=>{n.setQueryData([`repo-worktrees`,e],r),n.invalidateQueries({queryKey:[`project`,t]})}})}function Mn(e){return s({queryKey:[`fs-dirs`,e],queryFn:()=>u(`GET`,`/api/fs/dirs?prefix=${encodeURIComponent(e)}`),enabled:e.startsWith(`/`)||e.startsWith(`~`),placeholderData:e=>e,staleTime:1e4})}function Nn(){return s({queryKey:[`version`],queryFn:()=>u(`GET`,`/api/version`),staleTime:1/0})}function Pn(){return s({queryKey:[`host`],queryFn:()=>u(`GET`,`/api/host`),staleTime:1/0})}function Fn(e){return e?e.displayName||e.hostname:void 0}function In(){return s({queryKey:[`agents`],queryFn:()=>u(`GET`,`/api/agents`),staleTime:3e4,refetchOnWindowFocus:!0})}function Ln(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/profiles`,e),onSuccess:()=>void e.invalidateQueries({queryKey:[`profiles`]})})}function Rn(e){let t=o();return i({mutationFn:t=>u(`PATCH`,`/api/profiles/${e}/settings`,t),onSuccess:n=>t.setQueryData([`profile-settings`,e],n)})}function zn(){let e=o();return i({mutationFn:({id:e,...t})=>u(`PATCH`,`/api/profiles/${e}`,t),onSuccess:()=>void e.invalidateQueries({queryKey:[`profiles`]})})}function Bn(){let e=o();return i({mutationFn:({id:e,...t})=>u(`PATCH`,`/api/accounts/${e}`,t),onSuccess:t=>{e.invalidateQueries({queryKey:[`accounts`,t.profile_id]}),e.invalidateQueries({queryKey:[`account-usage`,t.id]})}})}function Vn(){let e=o();return i({mutationFn:e=>u(`DELETE`,`/api/profiles/${e}`),onSuccess:()=>e.clear()})}function Hn(){let e=o();return i({mutationFn:e=>u(`DELETE`,`/api/accounts/${e}`),onSuccess:()=>void e.invalidateQueries({queryKey:[`accounts`]})})}function Un(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/accounts`,e),onSuccess:t=>void e.invalidateQueries({queryKey:[`accounts`,t.profile_id]})})}function Wn(){return i({mutationFn:e=>u(`POST`,`/api/accounts/${e}/login`)})}function Gn(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/repos`,e),onSuccess:()=>void e.invalidateQueries({queryKey:[`repos`]})})}function Kn(){let e=o();return i({mutationFn:({id:e,...t})=>u(`PATCH`,`/api/repos/${e}`,t),onSuccess:()=>void e.invalidateQueries({queryKey:[`repos`]})})}function qn(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/repos/${e}/fetch`),onSuccess:()=>void e.invalidateQueries({queryKey:[`repos`]})})}function Jn(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/projects`,e),onSuccess:()=>void e.invalidateQueries({queryKey:[`projects`]})})}function Yn(){let e=o();return i({mutationFn:({id:e,...t})=>u(`PATCH`,`/api/projects/${e}`,t),onSuccess:()=>void e.invalidateQueries({queryKey:[`projects`]})})}function Xn(e,t){return s({queryKey:[`scratchpad`,e,t??`none`],queryFn:()=>u(`GET`,`/api/scratchpad?profile=${e}${t?`&project=${t}`:``}`),enabled:e!==void 0})}function Zn(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/scratchpad`,e),onSuccess:()=>void e.invalidateQueries({queryKey:[`scratchpad`]})})}function Qn(){let e=o();return i({mutationFn:({id:e,...t})=>u(`PATCH`,`/api/scratchpad/${e}`,t),onSuccess:()=>void e.invalidateQueries({queryKey:[`scratchpad`]})})}function $n(){let e=o();return i({mutationFn:e=>u(`DELETE`,`/api/scratchpad/${e}`),onSuccess:()=>void e.invalidateQueries({queryKey:[`scratchpad`]})})}function $(e,t){e.invalidateQueries({queryKey:[`sessions`]}),e.invalidateQueries({queryKey:[`project`,t.project_id]})}function er(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/sessions`,e),onSuccess:t=>$(e,t)})}function tr(e){let t=o();return i({mutationFn:t=>u(`POST`,`/api/sessions/${t}/${e}`),onSuccess:e=>$(t,e)})}function nr(){let e=o();return i({mutationFn:({sessionId:e,accountId:t})=>u(`POST`,`/api/sessions/${e}/migrate`,{account_id:t}),onSuccess:t=>$(e,t)})}function rr(){let e=o();return i({mutationFn:({sessionId:e,accountId:t})=>u(`POST`,`/api/sessions/${e}/handoff`,{account_id:t}),onSuccess:(t,{sessionId:n})=>{$(e,t),e.invalidateQueries({queryKey:[`session`,n]})}})}function ir(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/sessions/${e}/archive`),onSuccess:t=>$(e,t)})}function ar(){let e=o();return i({mutationFn:e=>u(`POST`,`/api/sessions/${e}/unarchive`),onSuccess:t=>$(e,t)})}function or(){let e=o();return i({mutationFn:({sessionId:e,title:t})=>u(`PATCH`,`/api/sessions/${e}`,{title:t}),onSuccess:t=>$(e,t)})}function sr(){let e=o();return i({mutationFn:e=>u(`PATCH`,`/api/config`,e),onSuccess:(t,n)=>{e.setQueryData([`config`],t),`displayName`in n&&e.invalidateQueries({queryKey:[`host`]})}})}async function cr(e){try{return await u(`GET`,`/api/profiles/${e}/state`)}catch(e){if(e instanceof Error&&`code`in e&&e.code===`no_state`)return null;throw e}}function lr(e,t){return u(`PUT`,`/api/profiles/${e}/state`,{ui_state:t})}function ur(e,t){return s({queryKey:[`ports`,e],queryFn:()=>u(`GET`,`/api/sessions/${e}/ports`),enabled:e!==void 0&&t,refetchInterval:a(5e3),refetchIntervalInBackground:!1})}function dr(e,t){return s({queryKey:[`session-env`,e],queryFn:()=>u(`GET`,`/api/sessions/${e}/env`),enabled:e!==void 0&&t,refetchInterval:a(5e3),refetchIntervalInBackground:!1})}function fr(){let e=o();return i({mutationFn:e=>u(`DELETE`,`/api/sessions/${e}/env`),onSuccess:(t,n)=>{e.setQueryData([`session-env`,n],{vars:[]})}})}var pr=_(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),mr=_(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]);function hr({id:e,value:t,onValueChange:n,onChoose:r,hints:i,placeholder:a,className:o,hintsClassName:s,autoFocus:c}){let[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(0),p=e=>{n(e.value),r?.(e),u(!1)};return(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(un,{id:e,value:t,onChange:e=>{n(e.target.value),u(!0),f(0)},onFocus:()=>u(!0),onBlur:()=>u(!1),onKeyDown:e=>{if(!(!l||i.length===0))if(e.key===`ArrowDown`)e.preventDefault(),f(e=>(e+1)%i.length);else if(e.key===`ArrowUp`)e.preventDefault(),f(e=>(e-1+i.length)%i.length);else if(e.key===`Enter`||e.key===`Tab`){let t=i[d]??i[0];t&&(e.preventDefault(),p(t))}else e.key===`Escape`&&(e.stopPropagation(),u(!1))},placeholder:a,className:o,autoComplete:`off`,spellCheck:!1,autoFocus:c}),l&&i.length>0&&(0,Q.jsx)(`ul`,{className:g(`absolute top-full z-10 mt-1 max-h-56 overflow-y-auto rounded-md bg-elevated p-1 shadow-xl`,s??`w-full`),children:i.map((e,t)=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),p(e)},onMouseEnter:()=>f(t),className:g(`relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm text-fg outline-none transition-colors`,`data-[selected=true]:bg-action data-[selected=true]:text-action-ink data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50`,`w-full font-mono text-xs`),"data-selected":t===d,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.label??e.value}),e.badge&&(0,Q.jsx)(`span`,{className:`ml-auto shrink-0 text-2xs opacity-70`,children:e.badge})]})},e.value))})]})}function gr(e){l.error(_r(e),{id:`err:${_r(e)}`})}function _r(e){return e instanceof Error&&e.message.trim()!==``?e.message:typeof e==`string`&&e.trim()!==``?e:`Something went wrong`}var vr=(0,v.lazy)(()=>c(()=>import(`./Terminal-CN5FGN0_.js`).then(e=>({default:e.Terminal})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))),yr=null;async function br(){yr=(await c(()=>import(`./Terminal-CN5FGN0_.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))).Terminal}function xr(e){return yr?(0,Q.jsx)(yr,{...e}):(0,Q.jsx)(v.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`size-full bg-ground`}),children:(0,Q.jsx)(vr,{...e})})}export{dr as $,qn as A,Kn as B,er as C,Vn as D,jn as E,Bn as F,xn as G,_n as H,sr as I,On as J,An as K,zn as L,Pn as M,Wn as N,$n as O,nr as P,tr as Q,Rn as R,Zn as S,Hn as T,gn as U,Qn as V,Sn as W,bn as X,kn as Y,Xn as Z,Dn as _,mr as a,dn as at,Jn as b,cr as c,cn as ct,yn as d,an as dt,ur as et,vn as f,rn as ft,fr as g,ir as h,It as ht,hr as i,un as it,rr as j,Mn as k,Fn as l,sn as lt,Tn as m,zt as mt,br as n,ar as nt,pr as o,on as ot,In as p,tn as pt,or as q,gr as r,hn as rt,En as s,ln as st,xr as t,Cn as tt,lr as u,nn as ut,Un as v,Nn as w,Gn as x,Ln as y,Yn as z};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,s as r,t as i}from"./buffer-store-BrujywTq.js";var a=e(t(),1);function o({buffers:e}){let t=(0,a.useRef)(new Set);return(0,a.useEffect)(()=>{let a=new Set(e.map(e=>i(e.session,e.path,e.root))),o=t.current;for(let e of a)o.has(e)||(r(e),o.add(e));for(let e of[...o])a.has(e)||(n(e),o.delete(e))},[e]),(0,a.useEffect)(()=>()=>{for(let e of t.current)n(e);t.current.clear()},[]),null}export{o as ModelRefcount};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{a as n,s as r,t as i}from"./buffer-store-CiF8VU5A.js";var a=e(t(),1);function o({buffers:e}){let t=(0,a.useRef)(new Set);return(0,a.useEffect)(()=>{let a=new Set(e.map(e=>i(e.session,e.path,e.root))),o=t.current;for(let e of a)o.has(e)||(r(e),o.add(e));for(let e of[...o])a.has(e)||(n(e),o.delete(e))},[e]),(0,a.useEffect)(()=>()=>{for(let e of t.current)n(e);t.current.clear()},[]),null}export{o as ModelRefcount};
@@ -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{r}from"./profile-store-D2pB4wB-.js";import{C as i,D as a,E as o,O as s,T as c,g as l,h as u,i as d,k as f,l as p,m,n as h,o as g,r as _,t as v,u as y,x as b}from"./editor-tabs-3ilPGolh.js";import{t as x}from"./preload-helper-Czpn1I53.js";import{S,r as C,t as ee}from"./api-CZDct42i.js";import{t as te}from"./createLucideIcon-DyMAgLa3.js";import{A as ne,_ as re,g as ie,h as ae}from"./index-C0rwYhwD.js";import{i as oe,r as se}from"./editor.api2-4X9Vh9Zw.js";import{a as ce,c as le,d as ue,f as de,i as w,l as fe,n as pe,o as me,r as he,s as ge,t as _e,u as ve}from"./buffer-store-BrujywTq.js";import{t as ye}from"./debounce-B9DrqirV.js";import{a as be,c as xe,i as Se,l as Ce,n as we,o as Te,r as Ee,s as De}from"./editor-sync-f1V6Wuxn.js";import{r as Oe}from"./buffer-logic-BrpRsL1b.js";var ke=te(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),T=e(t(),1);function Ae(e){return!e}function je(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=oe.CtrlCmd:e===`ctrl`?r|=oe.WinCtrl:e===`alt`?r|=oe.Alt:e===`shift`&&(r|=oe.Shift);let i=se[/^Key[A-Z]$/.test(n)?`Key${n.slice(3)}`:/^Digit[0-9]$/.test(n)?`Digit${n.slice(5)}`:n];return typeof i==`number`?r|i:null}function Me(e,t){let n=je(ne(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=je(ne(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>ie({editorWordWrap:Ae(ae().editorWordWrap)})})}function Ne(e,t,n,r){let i=_e(e,t,r),o=f(e,t,{root:r}),s=a(e,r),[c,l]=(0,T.useState)(null),[u,d]=(0,T.useState)(!1),p=(0,T.useRef)(!1),m=(0,T.useRef)(null),h=(0,T.useRef)(null),g=(0,T.useRef)(n);g.current=n;let _=(0,T.useRef)(!1),v=(0,T.useCallback)((e,t)=>{h.current?.cancel(),_.current=!0;try{me(i,e,t)}finally{_.current=!1}},[i]),y=(0,T.useSyncExternalStore)((0,T.useCallback)(e=>fe(i,e),[i]),()=>he(i)),b=(0,T.useSyncExternalStore)((0,T.useCallback)(e=>Te(i,e),[i]),()=>be(i));(0,T.useEffect)(()=>{let n=o.data;if(!n||n.binary||n.content===null||p.current)return;p.current=!0;let a=le(i)!==void 0,s=pe(e,t,n.content,n.mtime_ms,r);l(s),!a&&Ce(e,t,r).then(e=>{e&&(e.base_mtime_ms===n.mtime_ms?Oe(s,e.content)&&d(!0):S(`This file has an unsaved draft from an earlier version.`,{description:`The file changed on disk since the draft was saved.`,duration:12e3,action:{label:`Restore draft`,onClick:()=>{Oe(s,e.content)&&d(!0)}}}))})},[o.data,i,e,t,r]),(0,T.useEffect)(()=>{if(!c)return;let n=xe(e,t,r);h.current=n;let a=c.onDidChangeContent(()=>{_.current||(n(c.getValue(),le(i)??0),we(e,t,r))});return()=>{n.flush(),a.dispose(),h.current=null}},[c,i,e,t,r]),(0,T.useEffect)(()=>{!c||!b.savedElsewhere||he(i)||o.refetch().then(e=>{he(i)||(e.data&&e.data.content!==null&&v(e.data.content,e.data.mtime_ms),Se(i))})},[b.savedElsewhere,c,i]),(0,T.useEffect)(()=>{let e=o.data;!c||!e||e.content===null||!he(i)&&e.mtime_ms!==le(i)&&v(e.content,e.mtime_ms)},[o.data,c,i]);let x=(0,T.useCallback)((n,a)=>{w(i,n,a),h.current?.cancel(),De(e,t,r),Ee(e,t,a,r),d(!1)},[i,e,t,r]),C=(0,T.useCallback)(()=>{o.refetch().then(n=>{n.data&&n.data.content!==null&&v(n.data.content,n.data.mtime_ms),De(e,t,r),d(!1)})},[i,e,t,v]),te=(0,T.useCallback)((e,n)=>{s.mutate({path:t,content:e},{onSuccess:e=>x(n,e.mtime_ms),onError:e=>S.error(e instanceof Error?e.message:`Overwrite failed`)})},[s,t,x]),ne=(0,T.useCallback)(()=>{if(!c||!he(i))return;let e=c.getValue(),n=c.getAlternativeVersionId();s.mutate({path:t,content:e,expected_mtime_ms:le(i)},{onSuccess:e=>x(n,e.mtime_ms),onError:t=>{t instanceof ee&&t.status===409&&t.code===`stale_file`?S.error(`File changed on disk (probably the agent)`,{duration:1/0,action:{label:`Reload`,onClick:()=>C()},cancel:{label:`Overwrite`,onClick:()=>te(e,n)}}):S.error(t instanceof Error?t.message:`Save failed`)}})},[c,i,s,t,x,C,te]),re=(0,T.useRef)(ne);re.current=ne;let ie=(0,T.useCallback)(()=>{let n=m.current,i=g.current;r===void 0&&(!n||!i||i.session!==e||i.path!==t||(n.revealLineInCenter(i.line),n.setPosition({lineNumber:i.line,column:i.column??1}),n.focus()))},[e,t,r]),ae=(0,T.useCallback)(e=>{m.current=e,Me(e,{onSave:()=>re.current()}),ie()},[ie]);(0,T.useEffect)(()=>{ie()},[n,c,ie]);let oe=(0,T.useCallback)(()=>{C()},[C]),se,ce=null;o.data?.binary?se=`binary`:o.error?o.error instanceof ee&&o.error.status===413?se=`too-large`:(se=`error`,ce=o.error instanceof Error?o.error.message:`Failed to load file`):se=c?`ready`:`loading`;let ue=y&&b.savedElsewhere?`saved-elsewhere`:y&&b.dirtyElsewhere?`dirty-elsewhere`:null;return{status:se,errorMessage:ce,model:c,dirty:y,restoredNotice:u,discardRestore:oe,peerBadge:ue,save:ne,onMount:ae}}var E=n();function Pe({message:e,session:t,path:n,root:r,download:i}){return(0,E.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,E.jsx)(`span`,{children:e}),i&&(0,E.jsxs)(`button`,{type:`button`,onClick:()=>void b(t,n,r).catch(e=>S.error(e instanceof Error?e.message:`Download failed`)),className:`flex items-center gap-1.5 text-fg-secondary transition-colors hover:text-fg`,children:[(0,E.jsx)(ke,{className:`size-4`}),`Download`]})]})}function Fe({session:e,path:t,reveal:n,root:r}){let i=re(),a=Ne(e,t,n,r),o=(0,T.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(a.status===`binary`)return(0,E.jsx)(Pe,{message:`Binary file — use Download`,session:e,path:t,root:r,download:!0});if(a.status===`too-large`)return(0,E.jsx)(Pe,{message:`File too large to edit — use Download`,session:e,path:t,root:r,download:!0});if(a.status===`error`)return(0,E.jsx)(Pe,{message:a.errorMessage??`Failed to load file`,session:e,path:t,root:r});let s=a.peerBadge===`saved-elsewhere`?`Saved in another window`:a.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,E.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[a.restoredNotice&&(0,E.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,E.jsx)(`span`,{children:`Restored unsaved changes`}),(0,E.jsx)(`button`,{type:`button`,onClick:a.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),s&&(0,E.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:s}),(0,E.jsx)(`div`,{className:`min-h-0 flex-1`,children:a.model&&(0,E.jsx)(ue,{path:a.model.uri.toString(),defaultValue:a.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>a.onMount(e),loading:(0,E.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:o,tabSize:i.editorTabSize,wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function Ie({children:e}){return(0,E.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function Le(e,t){let n=(0,T.useRef)(t);n.current=t,(0,T.useEffect)(()=>(ge(e),()=>{n.current?.(),ce(e)}),[e])}function Re(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function ze({session:e,refName:t,path:n,content:r}){let i=(0,T.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,E.jsx)(ue,{path:Re(`puddle-view`,e,t,n),defaultValue:r,theme:ve,loading:(0,E.jsx)(Ie,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:i,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Be({session:e,against:t,path:n}){let r=o(e,t,n);return r.isPending?(0,E.jsx)(Ie,{children:`…`}):r.error?(0,E.jsx)(Ie,{children:r.error instanceof Error?r.error.message:`Failed to load`}):r.data.binary?(0,E.jsx)(Ie,{children:`Binary file — deleted`}):(0,E.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,E.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,E.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,E.jsx)(ze,{session:e,refName:t,path:n,content:r.data.content??``})})]})}function Ve({session:e,against:t,path:n,basePath:r}){let i=re(),a=Ne(e,n,null),s=o(e,t,r),c=(0,T.useRef)(null);Le(_e(e,n),()=>{let e=c.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),c.current=null});let l=(0,T.useRef)(a.save);l.current=a.save;let u=(0,T.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),d=s.error instanceof ee&&s.error.status===404;return a.status===`binary`||s.data?.binary?(0,E.jsx)(Ie,{children:`Binary file`}):a.status===`too-large`?(0,E.jsx)(Ie,{children:`File too large to show`}):a.status===`error`?(0,E.jsx)(Ie,{children:a.errorMessage??`Failed to load file`}):d?(0,E.jsx)(Fe,{session:e,path:n,reveal:null}):s.isPending||!a.model?(0,E.jsx)(Ie,{children:`…`}):s.error?(0,E.jsx)(Ie,{children:s.error instanceof Error?s.error.message:`Failed to load base`}):(0,E.jsx)(de,{modifiedModelPath:a.model.uri.toString(),originalModelPath:Re(`puddle-base`,e,t,r),original:s.data.content??``,language:a.model.getLanguageId(),theme:ve,keepCurrentModifiedModel:!0,loading:(0,E.jsx)(Ie,{children:`…`}),onMount:e=>{c.current=e,e.onDidDispose(()=>{c.current=null}),e.getModifiedEditor().addCommand(oe.CtrlCmd|se.KeyS,()=>l.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function He({session:e,path:t}){return Le(_e(e,t)),(0,E.jsx)(Fe,{session:e,path:t,reveal:null})}function Ue({session:e,against:t,entry:n}){switch(n.status){case`added`:return(0,E.jsx)(He,{session:e,path:n.path});case`deleted`:return(0,E.jsx)(Be,{session:e,against:t,path:n.path});case`modified`:case`renamed`:return(0,E.jsx)(Ve,{session:e,against:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function We({session:e,sha:t,path:n}){let r=o(e,t,n);return r.isPending?(0,E.jsx)(Ie,{children:`…`}):r.error?(0,E.jsx)(Ie,{children:r.error instanceof Error?r.error.message:`Failed to load file`}):r.data.binary?(0,E.jsx)(Ie,{children:`Binary file`}):(0,E.jsx)(ze,{session:e,refName:t,path:n,content:r.data.content??``})}function Ge({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o}){let s=(0,T.useRef)(null),c=(0,T.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,T.useEffect)(()=>()=>{let e=s.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),t?.modified.dispose(),s.current=null},[]),(0,E.jsx)(de,{originalModelPath:Re(`puddle-hist-orig`,e,t,n),modifiedModelPath:Re(`puddle-hist-mod`,e,i,a),original:r,modified:o,theme:ve,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,E.jsx)(Ie,{children:`…`}),onMount:e=>{s.current=e,e.onDidDispose(()=>{s.current=null})},options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Ke({session:e,sha:t,path:n,basePath:r}){let i=o(e,`${t}^`,r),a=o(e,t,n);return i.error instanceof ee&&i.error.status===404?(0,E.jsx)(We,{session:e,sha:t,path:n}):i.isPending||a.isPending?(0,E.jsx)(Ie,{children:`…`}):i.error?(0,E.jsx)(Ie,{children:i.error instanceof Error?i.error.message:`Failed to load original`}):a.error?(0,E.jsx)(Ie,{children:a.error instanceof Error?a.error.message:`Failed to load file`}):i.data.binary||a.data.binary?(0,E.jsx)(Ie,{children:`Binary file`}):(0,E.jsx)(Ge,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:i.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:a.data.content??``})}function qe({session:e,sha:t,entry:n,isRootCommit:r}){switch(l(n.status,r)){case`added`:return(0,E.jsx)(We,{session:e,sha:t,path:n.path});case`deleted`:return(0,E.jsx)(Be,{session:e,against:`${t}^`,path:n.path});case`modified`:case`renamed`:return(0,E.jsx)(Ke,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function Je({session:e,sha:t,path:n}){let r=c(e,t);if(r.isPending)return(0,E.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(r.error)return(0,E.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load commit`});let i=r.data.files.find(e=>e.path===n);return i?(0,E.jsx)(`div`,{className:`h-full`,children:(0,E.jsx)(qe,{session:e,sha:t,entry:i,isRootCommit:r.data.parents.length===0})}):(0,E.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,E.jsx)(`span`,{className:`font-mono`,children:n}),` is not part of `,t.slice(0,7),`.`]})}function Ye({session:e,path:t}){let n=s(e);if(n.isPending)return(0,E.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(n.error)return(0,E.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:n.error instanceof Error?n.error.message:`Failed to load diff`});let r=n.data.entries.find(e=>e.path===t);return r?(0,E.jsx)(`div`,{className:`h-full`,children:(0,E.jsx)(Ue,{session:e,against:n.data.against,entry:r})}):(0,E.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,E.jsx)(`span`,{className:`mx-1 font-mono`,children:t}),` against the base.`]})}var Xe=800;function Ze({name:e}){let t=r(),n=u(t,e),i=(0,T.useRef)(null),a=(0,T.useRef)(null),o=(0,T.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if((0,T.useEffect)(()=>{if(t===null)return;let n=ye(n=>{m(t,e,n).catch(e=>S.error(e instanceof Error?e.message:`Draft not saved`))},Xe);return a.current=n,()=>{n.flush(),a.current=null}},[t,e]),t===null)return null;if(n.error)return(0,E.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:n.error instanceof Error?n.error.message:`Failed to load the draft`});if(n.data===void 0)return(0,E.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`});let s=()=>{let t=i.current;t&&(a.current?.flush(),y({name:e,content:t.getValue()}))};return(0,E.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,E.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:`Draft — not in any worktree; ⌘S saves it into one`}),(0,E.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,E.jsx)(ue,{path:`puddle-untitled://${t}/${e}`,defaultValue:n.data.content,theme:ve,keepCurrentModel:!1,loading:(0,E.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:t=>{i.current=t,p(e,t.getValue()),Me(t,{onSave:s})},onChange:t=>{let n=t??``;p(e,n),a.current?.(n)},options:{automaticLayout:!0,fontFamily:o,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function Qe(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function $e(e){if(Array.isArray(e))return e}function et(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function tt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
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{r}from"./profile-store-D2pB4wB-.js";import{C as i,D as a,E as o,O as s,T as c,g as l,h as u,i as d,k as f,l as p,m,n as h,o as g,r as _,t as v,u as y,x as b}from"./editor-tabs-3ilPGolh.js";import{t as x}from"./preload-helper-Czpn1I53.js";import{S,r as C,t as ee}from"./api-CZDct42i.js";import{t as te}from"./createLucideIcon-DyMAgLa3.js";import{A as ne,_ as re,g as ie,h as ae}from"./index-iPj6x3rM.js";import{i as oe,r as se}from"./editor.api2-4X9Vh9Zw.js";import{a as ce,c as le,d as ue,f as de,i as w,l as fe,n as pe,o as me,r as he,s as ge,t as _e,u as ve}from"./buffer-store-CiF8VU5A.js";import{t as ye}from"./debounce-B9DrqirV.js";import{a as be,c as xe,i as Se,l as Ce,n as we,o as Te,r as Ee,s as De}from"./editor-sync-f1V6Wuxn.js";import{r as Oe}from"./buffer-logic-BrpRsL1b.js";var ke=te(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),T=e(t(),1);function Ae(e){return!e}function je(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=oe.CtrlCmd:e===`ctrl`?r|=oe.WinCtrl:e===`alt`?r|=oe.Alt:e===`shift`&&(r|=oe.Shift);let i=se[/^Key[A-Z]$/.test(n)?`Key${n.slice(3)}`:/^Digit[0-9]$/.test(n)?`Digit${n.slice(5)}`:n];return typeof i==`number`?r|i:null}function Me(e,t){let n=je(ne(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=je(ne(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>ie({editorWordWrap:Ae(ae().editorWordWrap)})})}function Ne(e,t,n,r){let i=_e(e,t,r),o=f(e,t,{root:r}),s=a(e,r),[c,l]=(0,T.useState)(null),[u,d]=(0,T.useState)(!1),p=(0,T.useRef)(!1),m=(0,T.useRef)(null),h=(0,T.useRef)(null),g=(0,T.useRef)(n);g.current=n;let _=(0,T.useRef)(!1),v=(0,T.useCallback)((e,t)=>{h.current?.cancel(),_.current=!0;try{me(i,e,t)}finally{_.current=!1}},[i]),y=(0,T.useSyncExternalStore)((0,T.useCallback)(e=>fe(i,e),[i]),()=>he(i)),b=(0,T.useSyncExternalStore)((0,T.useCallback)(e=>Te(i,e),[i]),()=>be(i));(0,T.useEffect)(()=>{let n=o.data;if(!n||n.binary||n.content===null||p.current)return;p.current=!0;let a=le(i)!==void 0,s=pe(e,t,n.content,n.mtime_ms,r);l(s),!a&&Ce(e,t,r).then(e=>{e&&(e.base_mtime_ms===n.mtime_ms?Oe(s,e.content)&&d(!0):S(`This file has an unsaved draft from an earlier version.`,{description:`The file changed on disk since the draft was saved.`,duration:12e3,action:{label:`Restore draft`,onClick:()=>{Oe(s,e.content)&&d(!0)}}}))})},[o.data,i,e,t,r]),(0,T.useEffect)(()=>{if(!c)return;let n=xe(e,t,r);h.current=n;let a=c.onDidChangeContent(()=>{_.current||(n(c.getValue(),le(i)??0),we(e,t,r))});return()=>{n.flush(),a.dispose(),h.current=null}},[c,i,e,t,r]),(0,T.useEffect)(()=>{!c||!b.savedElsewhere||he(i)||o.refetch().then(e=>{he(i)||(e.data&&e.data.content!==null&&v(e.data.content,e.data.mtime_ms),Se(i))})},[b.savedElsewhere,c,i]),(0,T.useEffect)(()=>{let e=o.data;!c||!e||e.content===null||!he(i)&&e.mtime_ms!==le(i)&&v(e.content,e.mtime_ms)},[o.data,c,i]);let x=(0,T.useCallback)((n,a)=>{w(i,n,a),h.current?.cancel(),De(e,t,r),Ee(e,t,a,r),d(!1)},[i,e,t,r]),C=(0,T.useCallback)(()=>{o.refetch().then(n=>{n.data&&n.data.content!==null&&v(n.data.content,n.data.mtime_ms),De(e,t,r),d(!1)})},[i,e,t,v]),te=(0,T.useCallback)((e,n)=>{s.mutate({path:t,content:e},{onSuccess:e=>x(n,e.mtime_ms),onError:e=>S.error(e instanceof Error?e.message:`Overwrite failed`)})},[s,t,x]),ne=(0,T.useCallback)(()=>{if(!c||!he(i))return;let e=c.getValue(),n=c.getAlternativeVersionId();s.mutate({path:t,content:e,expected_mtime_ms:le(i)},{onSuccess:e=>x(n,e.mtime_ms),onError:t=>{t instanceof ee&&t.status===409&&t.code===`stale_file`?S.error(`File changed on disk (probably the agent)`,{duration:1/0,action:{label:`Reload`,onClick:()=>C()},cancel:{label:`Overwrite`,onClick:()=>te(e,n)}}):S.error(t instanceof Error?t.message:`Save failed`)}})},[c,i,s,t,x,C,te]),re=(0,T.useRef)(ne);re.current=ne;let ie=(0,T.useCallback)(()=>{let n=m.current,i=g.current;r===void 0&&(!n||!i||i.session!==e||i.path!==t||(n.revealLineInCenter(i.line),n.setPosition({lineNumber:i.line,column:i.column??1}),n.focus()))},[e,t,r]),ae=(0,T.useCallback)(e=>{m.current=e,Me(e,{onSave:()=>re.current()}),ie()},[ie]);(0,T.useEffect)(()=>{ie()},[n,c,ie]);let oe=(0,T.useCallback)(()=>{C()},[C]),se,ce=null;o.data?.binary?se=`binary`:o.error?o.error instanceof ee&&o.error.status===413?se=`too-large`:(se=`error`,ce=o.error instanceof Error?o.error.message:`Failed to load file`):se=c?`ready`:`loading`;let ue=y&&b.savedElsewhere?`saved-elsewhere`:y&&b.dirtyElsewhere?`dirty-elsewhere`:null;return{status:se,errorMessage:ce,model:c,dirty:y,restoredNotice:u,discardRestore:oe,peerBadge:ue,save:ne,onMount:ae}}var E=n();function Pe({message:e,session:t,path:n,root:r,download:i}){return(0,E.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,E.jsx)(`span`,{children:e}),i&&(0,E.jsxs)(`button`,{type:`button`,onClick:()=>void b(t,n,r).catch(e=>S.error(e instanceof Error?e.message:`Download failed`)),className:`flex items-center gap-1.5 text-fg-secondary transition-colors hover:text-fg`,children:[(0,E.jsx)(ke,{className:`size-4`}),`Download`]})]})}function Fe({session:e,path:t,reveal:n,root:r}){let i=re(),a=Ne(e,t,n,r),o=(0,T.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(a.status===`binary`)return(0,E.jsx)(Pe,{message:`Binary file — use Download`,session:e,path:t,root:r,download:!0});if(a.status===`too-large`)return(0,E.jsx)(Pe,{message:`File too large to edit — use Download`,session:e,path:t,root:r,download:!0});if(a.status===`error`)return(0,E.jsx)(Pe,{message:a.errorMessage??`Failed to load file`,session:e,path:t,root:r});let s=a.peerBadge===`saved-elsewhere`?`Saved in another window`:a.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,E.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[a.restoredNotice&&(0,E.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,E.jsx)(`span`,{children:`Restored unsaved changes`}),(0,E.jsx)(`button`,{type:`button`,onClick:a.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),s&&(0,E.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:s}),(0,E.jsx)(`div`,{className:`min-h-0 flex-1`,children:a.model&&(0,E.jsx)(ue,{path:a.model.uri.toString(),defaultValue:a.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>a.onMount(e),loading:(0,E.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:o,tabSize:i.editorTabSize,wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function Ie({children:e}){return(0,E.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function Le(e,t){let n=(0,T.useRef)(t);n.current=t,(0,T.useEffect)(()=>(ge(e),()=>{n.current?.(),ce(e)}),[e])}function Re(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function ze({session:e,refName:t,path:n,content:r}){let i=(0,T.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,E.jsx)(ue,{path:Re(`puddle-view`,e,t,n),defaultValue:r,theme:ve,loading:(0,E.jsx)(Ie,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:i,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Be({session:e,against:t,path:n}){let r=o(e,t,n);return r.isPending?(0,E.jsx)(Ie,{children:`…`}):r.error?(0,E.jsx)(Ie,{children:r.error instanceof Error?r.error.message:`Failed to load`}):r.data.binary?(0,E.jsx)(Ie,{children:`Binary file — deleted`}):(0,E.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,E.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,E.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,E.jsx)(ze,{session:e,refName:t,path:n,content:r.data.content??``})})]})}function Ve({session:e,against:t,path:n,basePath:r}){let i=re(),a=Ne(e,n,null),s=o(e,t,r),c=(0,T.useRef)(null);Le(_e(e,n),()=>{let e=c.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),c.current=null});let l=(0,T.useRef)(a.save);l.current=a.save;let u=(0,T.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),d=s.error instanceof ee&&s.error.status===404;return a.status===`binary`||s.data?.binary?(0,E.jsx)(Ie,{children:`Binary file`}):a.status===`too-large`?(0,E.jsx)(Ie,{children:`File too large to show`}):a.status===`error`?(0,E.jsx)(Ie,{children:a.errorMessage??`Failed to load file`}):d?(0,E.jsx)(Fe,{session:e,path:n,reveal:null}):s.isPending||!a.model?(0,E.jsx)(Ie,{children:`…`}):s.error?(0,E.jsx)(Ie,{children:s.error instanceof Error?s.error.message:`Failed to load base`}):(0,E.jsx)(de,{modifiedModelPath:a.model.uri.toString(),originalModelPath:Re(`puddle-base`,e,t,r),original:s.data.content??``,language:a.model.getLanguageId(),theme:ve,keepCurrentModifiedModel:!0,loading:(0,E.jsx)(Ie,{children:`…`}),onMount:e=>{c.current=e,e.onDidDispose(()=>{c.current=null}),e.getModifiedEditor().addCommand(oe.CtrlCmd|se.KeyS,()=>l.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function He({session:e,path:t}){return Le(_e(e,t)),(0,E.jsx)(Fe,{session:e,path:t,reveal:null})}function Ue({session:e,against:t,entry:n}){switch(n.status){case`added`:return(0,E.jsx)(He,{session:e,path:n.path});case`deleted`:return(0,E.jsx)(Be,{session:e,against:t,path:n.path});case`modified`:case`renamed`:return(0,E.jsx)(Ve,{session:e,against:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function We({session:e,sha:t,path:n}){let r=o(e,t,n);return r.isPending?(0,E.jsx)(Ie,{children:`…`}):r.error?(0,E.jsx)(Ie,{children:r.error instanceof Error?r.error.message:`Failed to load file`}):r.data.binary?(0,E.jsx)(Ie,{children:`Binary file`}):(0,E.jsx)(ze,{session:e,refName:t,path:n,content:r.data.content??``})}function Ge({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o}){let s=(0,T.useRef)(null),c=(0,T.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,T.useEffect)(()=>()=>{let e=s.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),t?.modified.dispose(),s.current=null},[]),(0,E.jsx)(de,{originalModelPath:Re(`puddle-hist-orig`,e,t,n),modifiedModelPath:Re(`puddle-hist-mod`,e,i,a),original:r,modified:o,theme:ve,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,E.jsx)(Ie,{children:`…`}),onMount:e=>{s.current=e,e.onDidDispose(()=>{s.current=null})},options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Ke({session:e,sha:t,path:n,basePath:r}){let i=o(e,`${t}^`,r),a=o(e,t,n);return i.error instanceof ee&&i.error.status===404?(0,E.jsx)(We,{session:e,sha:t,path:n}):i.isPending||a.isPending?(0,E.jsx)(Ie,{children:`…`}):i.error?(0,E.jsx)(Ie,{children:i.error instanceof Error?i.error.message:`Failed to load original`}):a.error?(0,E.jsx)(Ie,{children:a.error instanceof Error?a.error.message:`Failed to load file`}):i.data.binary||a.data.binary?(0,E.jsx)(Ie,{children:`Binary file`}):(0,E.jsx)(Ge,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:i.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:a.data.content??``})}function qe({session:e,sha:t,entry:n,isRootCommit:r}){switch(l(n.status,r)){case`added`:return(0,E.jsx)(We,{session:e,sha:t,path:n.path});case`deleted`:return(0,E.jsx)(Be,{session:e,against:`${t}^`,path:n.path});case`modified`:case`renamed`:return(0,E.jsx)(Ke,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function Je({session:e,sha:t,path:n}){let r=c(e,t);if(r.isPending)return(0,E.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(r.error)return(0,E.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load commit`});let i=r.data.files.find(e=>e.path===n);return i?(0,E.jsx)(`div`,{className:`h-full`,children:(0,E.jsx)(qe,{session:e,sha:t,entry:i,isRootCommit:r.data.parents.length===0})}):(0,E.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,E.jsx)(`span`,{className:`font-mono`,children:n}),` is not part of `,t.slice(0,7),`.`]})}function Ye({session:e,path:t}){let n=s(e);if(n.isPending)return(0,E.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(n.error)return(0,E.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:n.error instanceof Error?n.error.message:`Failed to load diff`});let r=n.data.entries.find(e=>e.path===t);return r?(0,E.jsx)(`div`,{className:`h-full`,children:(0,E.jsx)(Ue,{session:e,against:n.data.against,entry:r})}):(0,E.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,E.jsx)(`span`,{className:`mx-1 font-mono`,children:t}),` against the base.`]})}var Xe=800;function Ze({name:e}){let t=r(),n=u(t,e),i=(0,T.useRef)(null),a=(0,T.useRef)(null),o=(0,T.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if((0,T.useEffect)(()=>{if(t===null)return;let n=ye(n=>{m(t,e,n).catch(e=>S.error(e instanceof Error?e.message:`Draft not saved`))},Xe);return a.current=n,()=>{n.flush(),a.current=null}},[t,e]),t===null)return null;if(n.error)return(0,E.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:n.error instanceof Error?n.error.message:`Failed to load the draft`});if(n.data===void 0)return(0,E.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`});let s=()=>{let t=i.current;t&&(a.current?.flush(),y({name:e,content:t.getValue()}))};return(0,E.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,E.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:`Draft — not in any worktree; ⌘S saves it into one`}),(0,E.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,E.jsx)(ue,{path:`puddle-untitled://${t}/${e}`,defaultValue:n.data.content,theme:ve,keepCurrentModel:!1,loading:(0,E.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:t=>{i.current=t,p(e,t.getValue()),Me(t,{onSave:s})},onChange:t=>{let n=t??``;p(e,n),a.current?.(n)},options:{automaticLayout:!0,fontFamily:o,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function Qe(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function $e(e){if(Array.isArray(e))return e}function et(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function tt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nt(e,t){return $e(e)||et(e,t)||rt(e,t)||tt()}function rt(e,t){if(e){if(typeof e==`string`)return Qe(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Qe(e,t):void 0}}var it=Object.entries,at=Object.setPrototypeOf,ot=Object.isFrozen,st=Object.getPrototypeOf,ct=Object.getOwnPropertyDescriptor,lt=Object.freeze,ut=Object.seal,dt=Object.create,ft=typeof Reflect<`u`&&Reflect,pt=ft.apply,mt=ft.construct;lt||=function(e){return e},ut||=function(e){return e},pt||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},mt||=function(e){return new e(...[...arguments].slice(1))};var ht=Pt(Array.prototype.forEach),gt=Pt(Array.prototype.lastIndexOf),_t=Pt(Array.prototype.pop),vt=Pt(Array.prototype.push),yt=Pt(Array.prototype.splice),bt=Array.isArray,xt=Pt(String.prototype.toLowerCase),St=Pt(String.prototype.toString),Ct=Pt(String.prototype.match),wt=Pt(String.prototype.replace),Tt=Pt(String.prototype.indexOf),Et=Pt(String.prototype.trim),Dt=Pt(Number.prototype.toString),Ot=Pt(Boolean.prototype.toString),D=typeof BigInt>`u`?null:Pt(BigInt.prototype.toString),kt=typeof Symbol>`u`?null:Pt(Symbol.prototype.toString),At=Pt(Object.prototype.hasOwnProperty),jt=Pt(Object.prototype.toString),Mt=Pt(RegExp.prototype.test),Nt=Ft(TypeError);function Pt(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return pt(e,t,n)}}function Ft(e){return function(){return mt(e,[...arguments])}}function O(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:xt;if(at&&at(e,null),!bt(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(ot(t)||(t[r]=e),i=e)}e[i]=!0}return e}function It(e){for(let t=0;t<e.length;t++)At(e,t)||(e[t]=null);return e}function Lt(e){let t=dt(null);for(let r of it(e)){var n=nt(r,2);let i=n[0],a=n[1];At(e,i)&&(bt(a)?t[i]=It(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=Lt(a):t[i]=a)}return t}function Rt(e){switch(typeof e){case`string`:return e;case`number`:return Dt(e);case`boolean`:return Ot(e);case`bigint`:return D?D(e):`0`;case`symbol`:return kt?kt(e):`Symbol()`;case`undefined`:return jt(e);case`function`:case`object`:{if(e===null)return jt(e);let t=e,n=zt(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:jt(e)}return jt(e)}default:return jt(e)}}function zt(e,t){for(;e!==null;){let n=ct(e,t);if(n){if(n.get)return Pt(n.get);if(typeof n.value==`function`)return Pt(n.value)}e=st(e)}function n(){return null}return n}function Bt(e){try{return Mt(e,``),!0}catch{return!1}}var Vt=lt(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),Ht=lt(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),Ut=lt([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Wt=lt([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),Gt=lt(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),Kt=lt([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),qt=lt([`#text`]),Jt=lt(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Yt=lt(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Xt=lt(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),Zt=lt([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Qt=ut(/{{[\w\W]*|^[\w\W]*}}/g),$t=ut(/<%[\w\W]*|^[\w\W]*%>/g),en=ut(/\${[\w\W]*/g),tn=ut(/^data-[\-\w.\u00B7-\uFFFF]+$/),nn=ut(/^aria-[\-\w]+$/),rn=ut(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),an=ut(/^(?:\w+script|data):/i),on=ut(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),sn=ut(/^html$/i),cn=ut(/^[a-z][.\w]*(-[.\w]+)+$/i),ln=ut(/<[/\w!]/g),un=ut(/<[/\w]/g),dn=ut(/<\/no(script|embed|frames)/i),fn=ut(/\/>/i),pn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},mn=function(){return typeof window>`u`?null:window},hn=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},gn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},_n=function(e,t,n,r){return At(e,t)&&bt(e[t])?O(r.base?Lt(r.base):{},e[t],r.transform):n};function vn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:mn(),t=e=>vn(e);if(t.version=`3.4.12`,t.removed=[],!e||!e.document||e.document.nodeType!==pn.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=zt(d,`cloneNode`),p=zt(d,`remove`),m=zt(d,`nextSibling`),h=zt(d,`childNodes`),g=zt(d,`parentNode`),_=zt(d,`shadowRoot`),v=zt(d,`attributes`),y=o&&o.prototype?zt(o.prototype,`nodeType`):null,b=o&&o.prototype?zt(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,C,ee=!1,te=0,ne=function(){if(te>0)throw Nt(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},re=function(e){ne(),te++;try{return x.createHTML(e)}finally{te--}},ie=function(e){ne(),te++;try{return x.createScriptURL(e)}finally{te--}},ae=function(){return ee||=(C=hn(u,i),!0),C},oe=n,se=oe.implementation,ce=oe.createNodeIterator,le=oe.createDocumentFragment,ue=oe.getElementsByTagName,de=r.importNode,w=gn();t.isSupported=typeof it==`function`&&typeof g==`function`&&se&&se.createHTMLDocument!==void 0;let fe=Qt,pe=$t,me=en,he=tn,ge=nn,_e=an,ve=on,ye=cn,be=rn,xe=null,Se=O({},[...Vt,...Ht,...Ut,...Gt,...qt]),Ce=null,we=O({},[...Jt,...Yt,...Xt,...Zt]),Te=Object.seal(dt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ee=null,De=null,Oe=Object.seal(dt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),ke=!0,T=!0,Ae=!1,je=!0,Me=!1,Ne=!0,E=!1,Pe=!1,Fe=null,Ie=null,Le=!1,Re=!1,ze=!1,Be=!1,Ve=!0,He=!1,Ue=`user-content-`,We=!0,Ge=!1,Ke={},qe=null,Je=O({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Ye=null,Xe=O({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ze=null,Qe=O({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),$e=`http://www.w3.org/1998/Math/MathML`,et=`http://www.w3.org/2000/svg`,tt=`http://www.w3.org/1999/xhtml`,nt=tt,rt=!1,at=null,ot=O({},[$e,et,tt],St),st=lt([`mi`,`mo`,`mn`,`ms`,`mtext`]),ct=O({},st),ft=lt([`annotation-xml`]),pt=O({},ft),mt=O({},[`title`,`style`,`font`,`a`,`script`]),Dt=null,Ot=[`application/xhtml+xml`,`text/html`],D=null,kt=null,jt=n.createElement(`form`),Pt=function(e){return e instanceof RegExp||e instanceof Function},Ft=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(kt&&kt===e)return;(!e||typeof e!=`object`)&&(e={}),e=Lt(e),Dt=Ot.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,D=Dt===`application/xhtml+xml`?St:xt,xe=_n(e,`ALLOWED_TAGS`,Se,{transform:D}),Ce=_n(e,`ALLOWED_ATTR`,we,{transform:D}),at=_n(e,`ALLOWED_NAMESPACES`,ot,{transform:St}),Ze=_n(e,`ADD_URI_SAFE_ATTR`,Qe,{transform:D,base:Qe}),Ye=_n(e,`ADD_DATA_URI_TAGS`,Xe,{transform:D,base:Xe}),qe=_n(e,`FORBID_CONTENTS`,Je,{transform:D}),Ee=_n(e,`FORBID_TAGS`,Lt({}),{transform:D}),De=_n(e,`FORBID_ATTR`,Lt({}),{transform:D}),Ke=At(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Lt(e.USE_PROFILES):e.USE_PROFILES:!1,ke=e.ALLOW_ARIA_ATTR!==!1,T=e.ALLOW_DATA_ATTR!==!1,Ae=e.ALLOW_UNKNOWN_PROTOCOLS||!1,je=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Me=e.SAFE_FOR_TEMPLATES||!1,Ne=e.SAFE_FOR_XML!==!1,E=e.WHOLE_DOCUMENT||!1,Re=e.RETURN_DOM||!1,ze=e.RETURN_DOM_FRAGMENT||!1,Be=e.RETURN_TRUSTED_TYPE||!1,Le=e.FORCE_BODY||!1,Ve=e.SANITIZE_DOM!==!1,He=e.SANITIZE_NAMED_PROPS||!1,We=e.KEEP_CONTENT!==!1,Ge=e.IN_PLACE||!1,be=Bt(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:rn,nt=typeof e.NAMESPACE==`string`?e.NAMESPACE:tt,ct=At(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?Lt(e.MATHML_TEXT_INTEGRATION_POINTS):O({},st),pt=At(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?Lt(e.HTML_INTEGRATION_POINTS):O({},ft);let t=At(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?Lt(e.CUSTOM_ELEMENT_HANDLING):dt(null);if(Te=dt(null),At(t,`tagNameCheck`)&&Pt(t.tagNameCheck)&&(Te.tagNameCheck=t.tagNameCheck),At(t,`attributeNameCheck`)&&Pt(t.attributeNameCheck)&&(Te.attributeNameCheck=t.attributeNameCheck),At(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(Te.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),ut(Te),Me&&(T=!1),ze&&(Re=!0),Ke&&(xe=O({},qt),Ce=dt(null),Ke.html===!0&&(O(xe,Vt),O(Ce,Jt)),Ke.svg===!0&&(O(xe,Ht),O(Ce,Yt),O(Ce,Zt)),Ke.svgFilters===!0&&(O(xe,Ut),O(Ce,Yt),O(Ce,Zt)),Ke.mathMl===!0&&(O(xe,Gt),O(Ce,Xt),O(Ce,Zt))),Oe.tagCheck=null,Oe.attributeCheck=null,At(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?Oe.tagCheck=e.ADD_TAGS:bt(e.ADD_TAGS)&&(xe===Se&&(xe=Lt(xe)),O(xe,e.ADD_TAGS,D))),At(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?Oe.attributeCheck=e.ADD_ATTR:bt(e.ADD_ATTR)&&(Ce===we&&(Ce=Lt(Ce)),O(Ce,e.ADD_ATTR,D))),At(e,`ADD_URI_SAFE_ATTR`)&&bt(e.ADD_URI_SAFE_ATTR)&&O(Ze,e.ADD_URI_SAFE_ATTR,D),At(e,`FORBID_CONTENTS`)&&bt(e.FORBID_CONTENTS)&&(qe===Je&&(qe=Lt(qe)),O(qe,e.FORBID_CONTENTS,D)),At(e,`ADD_FORBID_CONTENTS`)&&bt(e.ADD_FORBID_CONTENTS)&&(qe===Je&&(qe=Lt(qe)),O(qe,e.ADD_FORBID_CONTENTS,D)),We&&(xe[`#text`]=!0),E&&O(xe,[`html`,`head`,`body`]),xe.table&&(O(xe,[`tbody`]),delete Ee.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Nt(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Nt(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=re(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=ae()),x&&typeof S==`string`&&(S=re(``)));lt&&lt(e),kt=e},It=O({},[...Ht,...Ut,...Wt]),yn=O({},[...Gt,...Kt]),bn=function(e,t,n){return t.namespaceURI===tt?e===`svg`:t.namespaceURI===$e?e===`svg`&&(n===`annotation-xml`||ct[n]):!!It[e]},xn=function(e,t,n){return t.namespaceURI===tt?e===`math`:t.namespaceURI===et?e===`math`&&pt[n]:!!yn[e]},Sn=function(e,t,n){return t.namespaceURI===et&&!pt[n]||t.namespaceURI===$e&&!ct[n]?!1:!yn[e]&&(mt[e]||!It[e])},Cn=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:nt,tagName:`template`});let n=xt(e.tagName),r=xt(t.tagName);return at[e.namespaceURI]?e.namespaceURI===et?bn(n,t,r):e.namespaceURI===$e?xn(n,t,r):e.namespaceURI===tt?Sn(n,t,r):!!(Dt===`application/xhtml+xml`&&at[e.namespaceURI]):!1},wn=function(e){vt(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw Nt(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},k=function(e){Dn(e);let t=h(e);if(t){let e=[];ht(t,t=>{vt(e,t)}),ht(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},Tn=function(e,n){try{vt(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{vt(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Re||ze)try{wn(n)}catch{}else try{n.setAttribute(e,``)}catch{}},En=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||Ce[D(i)]))try{e.removeAttribute(i)}catch{}}},Dn=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===pn.element&&En(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},On=function(e){if(!Ne)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=y?y(e):e.nodeType;if(n===pn.processingInstruction||n===pn.comment&&Mt(un,e.data)){try{p(e)}catch{}continue}if(n===pn.element){let t=e,n=D(b?b(e):e.nodeName);try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&n!==`label`&&n!==`output`&&t.removeAttribute(`for`)}catch{}}let r=h(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},kn=function(e){let t=null,r=null;if(Le)e=`<remove></remove>`+e;else{let t=Ct(e,/^[\r\n\t ]+/);r=t&&t[0]}Dt===`application/xhtml+xml`&&nt===tt&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=x?re(e):e;if(nt===tt)try{t=new l().parseFromString(i,Dt)}catch{}if(!t||!t.documentElement){t=se.createDocument(nt,`template`,null);try{t.documentElement.innerHTML=rt?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),nt===tt?ue.call(t,E?`html`:`body`)[0]:E?t.documentElement:a},An=function(e){return ce.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},jn=function(e){return e=wt(e,fe,` `),e=wt(e,pe,` `),e=wt(e,me,` `),e},Mn=function(e){e.normalize();let t=ce.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;)n.data=jn(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&ht(r,e=>{Pn(e.content)&&Mn(e.content)})},Nn=function(e){let t=b?b(e):null;return typeof t!=`string`||D(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},Pn=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===pn.documentFragment}catch{return!1}},Fn=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function In(e,n,r){e.length!==0&&ht(e,e=>{e.call(t,n,r,kt)})}let Ln=function(e,t){return!!(Ne&&e.hasChildNodes()&&!Fn(e.firstElementChild)&&Mt(ln,e.textContent)&&Mt(ln,e.innerHTML)||Ne&&e.namespaceURI===tt&&t===`style`&&Fn(e.firstElementChild)||e.nodeType===pn.processingInstruction||Ne&&e.nodeType===pn.comment&&Mt(un,e.data))},Rn=function(e,t){if(!Ee[t]&&Hn(t)&&(Te.tagNameCheck instanceof RegExp&&Mt(Te.tagNameCheck,t)||Te.tagNameCheck instanceof Function&&Te.tagNameCheck(t)))return!1;if(We&&!qe[t]){let t=g(e),n=h(e);if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=Ge?n[i]:f(n[i],!0);t.insertBefore(r,m(e))}}}return wn(e),!0},zn=function(e,n){if(In(w.beforeSanitizeElements,e,null),e!==n&&g(e)===null)return!0;if(Nn(e))return wn(e),!0;let r=D(b?b(e):e.nodeName);if(In(w.uponSanitizeElement,e,{tagName:r,allowedTags:xe}),e!==n&&g(e)===null)return!0;if(Ln(e,r))return wn(e),!0;if(Ee[r]||!(Oe.tagCheck instanceof Function&&Oe.tagCheck(r))&&!xe[r]){let t=Rn(e,r);return t===!1&&In(w.afterSanitizeElements,e,null),t}if((y?y(e):e.nodeType)===pn.element&&!Cn(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&Mt(dn,e.innerHTML))return wn(e),!0;if(Me&&e.nodeType===pn.text){let n=jn(e.textContent);e.textContent!==n&&(vt(t.removed,{element:e.cloneNode()}),e.textContent=n)}return In(w.afterSanitizeElements,e,null),!1},Bn=function(e,t,r){if(De[t]||Ne&&t===`patchsrc`||Ne&&t===`for`&&e!==`label`&&e!==`output`||Ve&&(t===`id`||t===`name`)&&(r in n||r in jt))return!1;let i=Ce[t]||Oe.attributeCheck instanceof Function&&Oe.attributeCheck(t,e);if(!(T&&Mt(he,t))&&!(ke&&Mt(ge,t))){if(!i){if(!(Hn(e)&&(Te.tagNameCheck instanceof RegExp&&Mt(Te.tagNameCheck,e)||Te.tagNameCheck instanceof Function&&Te.tagNameCheck(e))&&(Te.attributeNameCheck instanceof RegExp&&Mt(Te.attributeNameCheck,t)||Te.attributeNameCheck instanceof Function&&Te.attributeNameCheck(t,e))||t===`is`&&Te.allowCustomizedBuiltInElements&&(Te.tagNameCheck instanceof RegExp&&Mt(Te.tagNameCheck,r)||Te.tagNameCheck instanceof Function&&Te.tagNameCheck(r))))return!1}else if(!Ze[t]&&!Mt(be,wt(r,ve,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Tt(r,`data:`)===0&&Ye[e])&&!(Ae&&!Mt(_e,wt(r,ve,``)))&&r)return!1}return!0},Vn=O({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Hn=function(e){return!Vn[xt(e)]&&Mt(ye,e)},Un=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return re(r);case`TrustedScriptURL`:return ie(r)}return r},Wn=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),Nn(e)?wn(e):_t(t.removed)}catch{Tn(n,e)}},Gn=function(e){In(w.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||Nn(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:Ce,forceKeepAttr:void 0},r=t.length,i=D(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=D(o),u=c,d=o===`value`?u:Et(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,In(w.uponSanitizeAttribute,e,n),d=n.attrValue,He&&(l===`id`||l===`name`)&&Tt(d,Ue)!==0&&(Tn(o,e),d=Ue+d),Ne&&Mt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){Tn(o,e);continue}if(l===`attributename`&&Ct(d,`href`)){Tn(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){Tn(o,e);continue}if(!je&&Mt(fn,d)){Tn(o,e);continue}if(Me&&(d=jn(d)),!Bn(i,l,d)){Tn(o,e);continue}d=Un(i,l,s,d),d!==u&&Wn(e,o,s,d)}}In(w.afterSanitizeAttributes,e,null)},Kn=function(e){let t=null,n=An(e);for(In(w.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(In(w.uponSanitizeShadowNode,t,null),zn(t,e),Gn(t),Pn(t.content)&&Kn(t.content),(y?y(t):t.nodeType)===pn.element){let e=_(t);Pn(e)&&(qn(e),Kn(e))}In(w.afterSanitizeShadowDOM,e,null)},qn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Kn(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===pn.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&D(e)===`template`){let e=n.content;Pn(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);Pn(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(rt=!e,rt&&(e=`<!-->`),typeof e!=`string`&&!Fn(e)&&(e=Rt(e),typeof e!=`string`))throw Nt(`dirty is not a string, aborting`);if(!t.isSupported)return e;Pe?(xe=Fe,Ce=Ie):Ft(n),(w.uponSanitizeElement.length>0||w.uponSanitizeAttribute.length>0)&&(xe=Lt(xe)),w.uponSanitizeAttribute.length>0&&(Ce=Lt(Ce)),t.removed=[];let c=Ge&&typeof e!=`string`&&Fn(e);if(c){On(e);let t=b?b(e):e.nodeName;if(typeof t==`string`){let n=D(t);if(!xe[n]||Ee[n])throw k(e),Nt(`root node is forbidden and cannot be sanitized in-place`)}if(Nn(e))throw k(e),Nt(`root node is clobbered and cannot be sanitized in-place`);try{qn(e)}catch(t){throw k(e),t}}else if(Fn(e))i=kn(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===pn.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),qn(a);else{if(!Re&&!Me&&!E&&e.indexOf(`<`)===-1)return x&&Be?re(e):e;if(i=kn(e),!i)return Re?null:Be?S:``}i&&Le&&wn(i.firstChild);let l=c?e:i,u=An(l);try{for(;o=u.nextNode();)zn(o,l),Gn(o),Pn(o.content)&&Kn(o.content)}catch(n){throw c&&(k(e),ht(t.removed,e=>{e.element&&Dn(e.element)})),n}if(c)return ht(t.removed,e=>{e.element&&Dn(e.element)}),Me&&Mn(e),e;if(Re){if(Me&&Mn(i),ze)for(s=le.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(Ce.shadowroot||Ce.shadowrootmode)&&(s=de.call(r,s,!0)),s}let d=E?i.outerHTML:i.innerHTML;return E&&xe[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Mt(sn,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
3
3
  `+d),Me&&(d=jn(d)),x&&Be?re(d):d},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ft(e),Pe=!0,Fe=xe,Ie=Ce},t.clearConfig=function(){kt=null,Pe=!1,Fe=null,Ie=null,x=C,S=``},t.isValidAttribute=function(e,t,n){kt||Ft({});let r=D(e),i=D(t);return Bn(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&At(w,e)&&vt(w[e],t)},t.removeHook=function(e,t){if(At(w,e)){if(t!==void 0){let n=gt(w[e],t);return n===-1?void 0:yt(w[e],n,1)[0]}return _t(w[e])}},t.removeHooks=function(e){At(w,e)&&(w[e]=[])},t.removeAllHooks=function(){w=gn()},t}var yn=vn();function bn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var xn=bn();function Sn(e){xn=e}var Cn={exec:()=>null};function wn(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function k(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(En.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Tn=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),En={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:wn(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:wn(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:wn(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:wn(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:wn(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:wn(e=>RegExp(`^ {0,${e}}>`))},Dn=/^(?:[ \t]*(?:\n|$))+/,On=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,kn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,An=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,jn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Mn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Nn=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Pn=k(Nn).replace(/bull/g,Mn).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Fn=k(Nn).replace(/bull/g,Mn).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),In=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Ln=/^[^\n]+/,Rn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,zn=k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Rn).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Bn=k(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Mn).getRegex(),Vn=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Hn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Un=k(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Hn).replace(`tag`,Vn).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Wn=e=>k(In).replace(`hr`,An).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace(`list`,e).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Vn).getRegex(),Gn=Wn(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Kn=Wn(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),qn={blockquote:k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Kn).getRegex(),code:On,def:zn,fences:kn,heading:jn,hr:An,html:Un,lheading:Pn,list:Bn,newline:Dn,paragraph:Gn,table:Cn,text:Ln},Jn=k(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,An).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Vn).getRegex(),Yn={...qn,lheading:Fn,table:Jn,paragraph:k(In).replace(`hr`,An).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Jn).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Vn).getRegex()},Xn={...qn,html:k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Hn).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Cn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:k(In).replace(`hr`,An).replace(`heading`,` *#{1,6} *[^
4
4
  ]`).replace(`lheading`,Pn).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Zn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Qn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$n=/^( {2,}|\\)\n(?!\s*$)/,er=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,tr=/[\p{P}\p{S}]/u,nr=/[\s\p{P}\p{S}]/u,rr=/[^\s\p{P}\p{S}]/u,ir=k(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,nr).getRegex(),ar=/(?!~)[\p{P}\p{S}]/u,or=/(?!~)[\s\p{P}\p{S}]/u,sr=/(?:[^\s\p{P}\p{S}]|~)/u,cr=k(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Tn?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),lr=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ur=k(lr,`u`).replace(/punct/g,tr).getRegex(),dr=k(lr,`u`).replace(/punct/g,ar).getRegex(),fr=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,pr=k(fr,`gu`).replace(/notPunctSpace/g,rr).replace(/punctSpace/g,nr).replace(/punct/g,tr).getRegex(),mr=k(fr,`gu`).replace(/notPunctSpace/g,sr).replace(/punctSpace/g,or).replace(/punct/g,ar).getRegex(),hr=k(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,rr).replace(/punctSpace/g,nr).replace(/punct/g,tr).getRegex(),gr=k(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,tr).getRegex(),_r=k(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,rr).replace(/punctSpace/g,nr).replace(/punct/g,tr).getRegex(),vr=k(/\\(punct)/,`gu`).replace(/punct/g,tr).getRegex(),yr=k(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),br=k(Hn).replace(`(?:-->|$)`,`-->`).getRegex(),xr=k(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,br).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Sr=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Cr=k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,Sr).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),wr=k(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Sr).replace(`ref`,Rn).getRegex(),Tr=k(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Rn).getRegex(),Er=k(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,wr).replace(`nolink`,Tr).getRegex(),Dr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Or={_backpedal:Cn,anyPunctuation:vr,autolink:yr,blockSkip:cr,br:$n,code:Qn,del:Cn,delLDelim:Cn,delRDelim:Cn,emStrongLDelim:ur,emStrongRDelimAst:pr,emStrongRDelimUnd:hr,escape:Zn,link:Cr,nolink:Tr,punctuation:ir,reflink:wr,reflinkSearch:Er,tag:xr,text:er,url:Cn},kr={...Or,link:k(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Sr).getRegex(),reflink:k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Sr).getRegex()},Ar={...Or,emStrongRDelimAst:mr,emStrongLDelim:dr,delLDelim:gr,delRDelim:_r,url:k(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Dr).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:k(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Dr).getRegex()},jr={...Ar,br:k($n).replace(`{2,}`,`*`).getRegex(),text:k(Ar.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Mr={normal:qn,gfm:Yn,pedantic:Xn},Nr={normal:Or,gfm:Ar,breaks:jr,pedantic:kr},Pr={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},Fr=e=>Pr[e];function Ir(e,t){if(t){if(En.escapeTest.test(e))return e.replace(En.escapeReplace,Fr)}else if(En.escapeTestNoEncode.test(e))return e.replace(En.escapeReplaceNoEncode,Fr);return e}function Lr(e){try{e=encodeURI(e).replace(En.percentDecode,`%`)}catch{return null}return e}function Rr(e,t){let n=e.replace(En.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(En.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(En.slashPipe,`|`);return n}function zr(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Br(e){let t=e.split(`
@@ -0,0 +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{r,t as i}from"./profile-store-D2pB4wB-.js";import{S as a,_ as o,d as s,f as c,g as l,h as u,m as d,p as f}from"./api-CZDct42i.js";import{a as p,g as m,i as h,n as g,o as _,r as v,t as y}from"./dialog-B43iKmfK.js";import{A as b,B as x,D as S,F as C,G as w,H as T,I as E,L as D,N as O,R as k,S as ee,T as A,U as j,X as te,Z as ne,_ as M,at as N,f as P,i as re,it as F,k as ie,o as ae,p as oe,r as I,rt as se,v as ce}from"./LazyTerminal-CeLHCKsO.js";import{t as L}from"./utils-B6KiDbIe.js";import{t as R}from"./createLucideIcon-DyMAgLa3.js";import{a as z,i as B,n as le,o as ue,r as de,s as fe,t as pe}from"./session-seed-B2YmPsU-.js";import{r as me}from"./dist-i-QevsUb.js";import{D as he,E as ge,G as _e,H as ve,J as ye,L as be,O as xe,P as Se,R as Ce,S as we,U as Te,V as Ee,W as De,X as Oe,Y as ke,Z as Ae,_ as V,a as H,at as je,b as Me,c as U,d as Ne,f as Pe,g as W,h as Fe,j as Ie,k as Le,l as Re,lt as ze,m as Be,p as Ve,u as He,w as Ue,x as We,y as Ge,z as Ke}from"./index-iPj6x3rM.js";var qe=R(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Je=R(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Ye=R(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Xe=R(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Ze=R(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),Qe=R(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),$e=R(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),et=R(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),G=e(t(),1),K=n();function q({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,K.jsxs)(`div`,{className:L(`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:L(`text-xs text-fg-muted`,n),children:t})]}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function J({children:e,note:t}){return(0,K.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function tt(){let e=V(),[t,n]=(0,G.useState)(ze());return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`This browser only`,children:`Appearance`}),(0,K.jsx)(q,{label:`Theme`,description:`Chrome, terminal, and editor restyle together.`,children:(0,K.jsxs)(le,{value:t,onValueChange:e=>{n(e),je(e)},children:[(0,K.jsx)(z,{className:`w-32`,children:(0,K.jsx)(ue,{})}),(0,K.jsxs)(de,{children:[(0,K.jsx)(B,{value:`dark`,children:`Dark`}),(0,K.jsx)(B,{value:`light`,children:`Light`}),(0,K.jsx)(B,{value:`system`,children:`System`})]})]})}),(0,K.jsx)(q,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,K.jsx)(F,{id:`ui-font-size`,type:`number`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onChange:e=>W({uiFontSize:Number(e.target.value)||Be.uiFontSize})})}),(0,K.jsx)(q,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,K.jsx)(F,{id:`terminal-font-size`,type:`number`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onChange:e=>W({terminalFontSize:Number(e.target.value)||13})})}),(0,K.jsx)(q,{label:`Density`,children:(0,K.jsxs)(le,{value:e.density,onValueChange:e=>W({density:e}),children:[(0,K.jsx)(z,{className:`w-36`,children:(0,K.jsx)(ue,{})}),(0,K.jsxs)(de,{children:[(0,K.jsx)(B,{value:`compact`,children:`Compact`}),(0,K.jsx)(B,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,K.jsx)(q,{label:`All projects in the sidebar`,description:`Show every project's sessions in the right sidebar, grouped by project.`,htmlFor:`all-project-sessions`,children:(0,K.jsx)(H,{id:`all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>W({showAllProjectSessions:e})})})]})}function nt({profile:e}){let t=D(),[n,r]=(0,G.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>I(e)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>I(e)});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(q,{label:`Icon`,description:`The glyph shown wherever this profile appears.`,children:(0,K.jsxs)(Me,{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)(Ee,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,K.jsx)(We,{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:L(`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)(Ee,{icon:null,colour:null,className:`size-4`})}),Te.map(({name:t,Icon:n})=>(0,K.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:L(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,e.icon===t&&`bg-elevated text-fg`),children:(0,K.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,K.jsx)(q,{label:`Icon colour`,description:`Any theme colour; recolours with light/dark.`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,K.jsxs)(`button`,{type:`button`,title:`Default`,onClick:()=>a(null),className:L(`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`})]}),l.map(t=>(0,K.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:L(`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:L(`size-3.5 rounded-full bg-current`,ve(t))}),(0,K.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var Y=`__none__`;function rt(){let e=r(),t=j().data?.find(t=>t.id===e),n=P(e??void 0),a=T(e??void 0),o=D(),c=k(e??``),l=S(),[u,d]=(0,G.useState)(``),[f,b]=(0,G.useState)(``),[x,C]=(0,G.useState)(!1),[w,E]=(0,G.useState)(``);if((0,G.useEffect)(()=>{t&&(d(t.name),b(t.branch_prefix))},[t]),!t)return null;let O=a.data?.default_account_id;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Profile`}),(0,K.jsxs)(q,{label:`Name`,description:`A display label. Letters, digits, dot, underscore and hyphen; must be unique.`,htmlFor:`profile-name`,children:[(0,K.jsx)(F,{id:`profile-name`,value:u,onChange:e=>d(e.target.value),className:`w-44 font-mono`}),(0,K.jsx)(m,{size:`sm`,variant:`secondary`,disabled:u===t.name||u.trim()===``||o.isPending,onClick:()=>o.mutate({id:t.id,name:u},{onError:e=>I(e)}),children:`Save`})]}),(0,K.jsxs)(q,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,K.jsx)(F,{id:`branch-prefix`,value:f,onChange:e=>b(e.target.value),placeholder:s,className:`w-44 font-mono`}),(0,K.jsx)(m,{size:`sm`,variant:`secondary`,disabled:f===t.branch_prefix||o.isPending,onClick:()=>o.mutate({id:t.id,branch_prefix:f},{onError:e=>I(e)}),children:`Save`})]}),(0,K.jsx)(nt,{profile:t}),(0,K.jsx)(q,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,K.jsxs)(le,{value:typeof O==`number`?String(O):Y,onValueChange:e=>c.mutate({default_account_id:e===Y?null:Number(e)},{onError:e=>I(e)}),children:[(0,K.jsx)(z,{className:`w-56`,children:(0,K.jsx)(ue,{})}),(0,K.jsxs)(de,{children:[(0,K.jsx)(B,{value:Y,children:`First available`}),n.data?.map(e=>(0,K.jsx)(B,{value:String(e.id),children:(0,K.jsxs)(`span`,{className:`font-mono`,children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,K.jsx)(q,{label:`Delete profile`,description:`Removes its projects, accounts (logging them out), and archived history. Non-archived sessions block deletion.`,className:`mt-4`,children:(0,K.jsx)(m,{variant:`danger`,size:`sm`,onClick:()=>C(!0),children:`Delete…`})}),(0,K.jsx)(y,{open:x,onOpenChange:e=>{e||(C(!1),E(``))},children:(0,K.jsxs)(g,{children:[(0,K.jsxs)(p,{children:[(0,K.jsxs)(_,{children:[`Delete profile `,(0,K.jsx)(`span`,{className:`font-mono`,children:t.name}),`?`]}),(0,K.jsx)(v,{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)(se,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`font-mono text-fg`,children:t.name}),` to confirm`]}),(0,K.jsx)(F,{id:`delete-confirm-name`,value:w,onChange:e=>E(e.target.value),className:`font-mono`,autoFocus:!0})]}),(0,K.jsxs)(h,{children:[(0,K.jsx)(m,{variant:`ghost`,onClick:()=>{C(!1),E(``)},children:`Cancel`}),(0,K.jsx)(m,{variant:`danger`,disabled:w!==t.name||l.isPending,onClick:()=>l.mutate(t.id,{onSuccess:()=>{be(),i.set(null)},onError:e=>{C(!1),E(``),I(e)}}),children:`Delete profile`})]})]})})]})}function it({agent:e,profileId:t,onClose:n,onCreated:r}){let i=ce(),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(``),l=ie(Se(s,150)),u=s.trim(),d=u===``||u.startsWith(`/`)||u.startsWith(`~`),f=a.trim()!==``&&d,b=()=>{!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=>I(e)})};return(0,K.jsx)(y,{open:!0,onOpenChange:e=>!e&&n(),children:(0,K.jsxs)(g,{children:[(0,K.jsxs)(p,{children:[(0,K.jsxs)(_,{children:[`Add a `,e.display_name,` account`]}),(0,K.jsxs)(v,{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(),b()},children:[(0,K.jsx)(F,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value),className:`font-mono`}),(0,K.jsx)(re,{value:s,onValueChange:c,placeholder:`import an existing config dir (optional), e.g. ~/.claude`,hints:(l.data?.entries??[]).map(e=>({value:e.path,label:e.name})),className:`font-mono`})]}),(0,K.jsxs)(h,{children:[(0,K.jsx)(m,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,K.jsxs)(m,{disabled:!f||i.isPending,onClick:b,children:[(0,K.jsx)(ke,{}),`Add account`]})]})]})})}function at({account:e,gateOpen:t,installed:n}){let r=O(),i=C(),a=A(),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(e.label);return(0,G.useEffect)(()=>d(e.label),[e.label]),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),onBlur:()=>{let t=u.trim();if(t!==e.label){if(t===``){d(e.label);return}i.mutate({id:e.id,label:t},{onError:t=>{I(t),d(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(d(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full truncate rounded-sm bg-transparent px-1 py-0.5 font-mono text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,K.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-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)(H,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>I(e)})})]}),(0,K.jsxs)(m,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s(e.stream),onError:e=>I(e)}),children:[(0,K.jsx)(Ae,{}),e.logged_in?`Re-login`:`Login`]}),(0,K.jsxs)(m,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,K.jsx)(_e,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,K.jsx)(Ge,{stream:o,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,K.jsx)(y,{open:c,onOpenChange:l,children:(0,K.jsxs)(g,{children:[(0,K.jsxs)(p,{children:[(0,K.jsxs)(_,{children:[`Delete `,(0,K.jsx)(`span`,{className:`font-mono`,children:e.label}),`?`]}),(0,K.jsx)(v,{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)(h,{children:[(0,K.jsx)(m,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,K.jsx)(m,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),I(e)}}),children:`Delete account`})]})]})})]})}function ot(){let e=r(),t=oe(),n=P(e??void 0),i=T(e??void 0),o=O(),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(null),d=i.data?.allowSkipPermissions===!0;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[],r=e.available!==!1;return(0,K.jsxs)(`div`,{className:`mb-5`,children:[(0,K.jsx)(q,{label:e.display_name,description:r?`Accounts are isolated config dirs under this profile.`:`Not installed — 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:`font-mono text-2xs text-fg-muted`,children:e.id})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,K.jsx)(at,{account:t,gateOpen:d&&e.capabilities.skip_permissions,installed:r},t.id)),(0,K.jsx)(`div`,{className:`flex`,children:(0,K.jsxs)(m,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>u(e),children:[(0,K.jsx)(ke,{}),`Add account`]})})]})]},e.id)}),s&&(0,K.jsx)(Ge,{stream:s.stream,label:s.label,onClose:()=>c(null)}),l!==null&&e!==null&&(0,K.jsx)(it,{agent:l,profileId:e,onClose:()=>u(null),onCreated:(e,t)=>{if(t){e.logged_in||a.info(`Imported without credentials — press Login to authenticate.`);return}o.mutate(e.id,{onSuccess:t=>c({stream:t.stream,label:`${e.agent_type}/${e.label}`}),onError:e=>I(e)})}})]})}function st(){let e=M(),t=E(),[n,r]=(0,G.useState)(``);return(0,G.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,K.jsx)(q,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH to find agent CLIs like claude (e.g. ~/.local/bin). Applies after the daemon restarts.`,htmlFor:`agent-path`,children:(0,K.jsx)(F,{id:`agent-path`,type:`text`,className:`w-64 font-mono text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function ct({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=pe(e,n),o=n.sessionDefaults??{},[s,c]=(0,G.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,K.jsx)(q,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,K.jsx)(F,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48 font-mono`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,K.jsx)(q,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,K.jsx)(H,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,K.jsx)(q,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`An own working copy of the base branch, instead of sharing one.`,htmlFor:`${e}-default-dir`,children:(0,K.jsx)(H,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function lt(){return(0,K.jsx)(q,{label:`Terminal scrollback`,description:`Lines kept per terminal. This browser only.`,htmlFor:`scrollback`,children:(0,K.jsx)(F,{id:`scrollback`,type:`number`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:V().terminalScrollback,onChange:e=>W({terminalScrollback:Number(e.target.value)||5e3})})})}function X({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,G.useState)(r);return(0,K.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,K.jsx)(N,{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)(m,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,K.jsx)(m,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var ut={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 dt({initial:e,onSave:t,pending:n}){let[r,i]=(0,G.useState)(e),a=r.length>0?r:u;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)(F,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:u}),(0,K.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,K.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:Ue(ut,a)})]}),(0,K.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:o.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)(m,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,K.jsx)(m,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(u),t(u)},children:`Reset to default`})]})]})}function ft(){let e=r(),t=j().data?.find(t=>t.id===e),n=T(e??void 0),i=k(e??``),[a,o]=(0,G.useState)(!1),[s,l]=(0,G.useState)(``),u=n.data?.allowSkipPermissions===!0,b=e=>i.mutate({allowSkipPermissions:e},{onSuccess:()=>{o(!1),l(``)},onError:e=>I(e)}),x=e=>t=>i.mutate({[e]:t},{onError:e=>I(e)});return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Sessions`}),(0,K.jsx)(`p`,{className:`mb-3 text-xs text-fg-secondary`,children:`Permission prompts are on by default, everywhere. Skipping them requires this profile gate, a per-account opt-in, and a per-session toggle — and the daemon re-checks all three on every launch, resume, and hand-off.`}),(0,K.jsx)(q,{label:`Allow skipping permission prompts`,description:u?`The gate is open: opted-in accounts can start prompt-free sessions.`:`The gate is closed: every session keeps its permission prompts.`,htmlFor:`gate`,children:(0,K.jsx)(H,{id:`gate`,checked:u,onCheckedChange:e=>{e?o(!0):b(!1)}})}),(0,K.jsx)(q,{label:`Capture exported env vars`,description:n.data?.captureSessionEnv===!1?`Paused: session shells spawn plain — nothing new is captured or injected. Already-captured vars are kept for when this is re-enabled.`:`Vars exported in a session terminal persist: re-injected into its new shells and agent restarts. Values stay on the daemon host.`,htmlFor:`capture-env`,children:(0,K.jsx)(H,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:i.isPending,onCheckedChange:e=>i.mutate({captureSessionEnv:e},{onError:e=>I(e)})})}),(0,K.jsx)(st,{}),(0,K.jsx)(lt,{}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`What the new-agent and new-terminal modals open with — everything stays editable per session.`,children:`New session defaults`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ct,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>i.mutate({sessionDefaults:e},{onError:e=>I(e)}),pending:i.isPending},`${e}:agent-seed`),(0,K.jsx)(ct,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>i.mutate({sessionDefaults:e},{onError:e=>I(e)}),pending:i.isPending},`${e}:terminal-seed`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`Sent to the agent as its opening message when a session starts. Leave a box empty to send no preamble.`,children:`Launch text`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(X,{id:`onboarding-template`,label:`New worktree`,description:`For a freshly created worktree. Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??f,defaultText:f,onSave:x(`onboardingTemplate`),pending:i.isPending},`${e}:onboarding`),(0,K.jsx)(X,{id:`concurrent-template`,label:`Existing / shared worktree`,description:`For a session joining a worktree other agents may already be working in.`,initial:n.data.concurrentTemplate??c,defaultText:c,onSave:x(`concurrentTemplate`),pending:i.isPending},`${e}:concurrent`),(0,K.jsx)(X,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot — its processes are gone.`,initial:n.data.restartTemplate??d,defaultText:d,onSave:x(`restartTemplate`),pending:i.isPending},`${e}:restart`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(J,{note:`How each session's tab and sidebar label is composed from its parts.`,children:`Tab title`}),n.data&&(0,K.jsx)(dt,{initial:n.data.tabTitleTemplate??"${name}",onSave:x(`tabTitleTemplate`),pending:i.isPending},`${e}:tab-title`)]}),(0,K.jsx)(y,{open:a,onOpenChange:e=>{e||(o(!1),l(``))},children:(0,K.jsxs)(g,{children:[(0,K.jsxs)(p,{children:[(0,K.jsxs)(_,{className:`flex items-center gap-2`,children:[(0,K.jsx)(Qe,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,K.jsx)(v,{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)(se,{htmlFor:`confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`font-mono text-fg`,children:t?.name}),` to confirm`]}),(0,K.jsx)(F,{id:`confirm-name`,value:s,onChange:e=>l(e.target.value),className:`font-mono`,autoFocus:!0})]}),(0,K.jsxs)(h,{children:[(0,K.jsx)(m,{variant:`ghost`,onClick:()=>{o(!1),l(``)},children:`Cancel`}),(0,K.jsx)(m,{variant:`danger`,disabled:s!==t?.name||i.isPending,onClick:()=>b(!0),children:`Open the gate`})]})]})})]})}var pt={desktop:!0,sound:!1,muted_projects:[]};function mt(){let[e,t]=(0,G.useState)(U);return(0,G.useEffect)(()=>{let e=()=>t(U());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(U())]}function ht({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 gt(){let e=r(),t=T(e??void 0),n=k(e??``),i=w(e??void 0),[a,o]=mt(),s={...pt,...t.data?.notifications??{}},c=e=>n.mutate({notifications:e},{onError:e=>I(e)}),l=()=>{typeof Notification>`u`||Notification.requestPermission().then(o)};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`When an agent flips to waiting for input`,children:`Notifications`}),(0,K.jsx)(q,{label:`Desktop notification on waiting`,description:`Shown while this window is unfocused; clicking it opens the session.`,htmlFor:`notify-desktop`,children:(0,K.jsx)(H,{id:`notify-desktop`,checked:s.desktop,onCheckedChange:e=>{e&&l(),c({...s,desktop:e})}})}),s.desktop&&(0,K.jsx)(ht,{permission:a,onRequest:l}),(0,K.jsx)(q,{label:`Sound`,htmlFor:`notify-sound`,children:(0,K.jsx)(H,{id:`notify-sound`,checked:s.sound,onCheckedChange:e=>c({...s,sound:e})})}),(0,K.jsx)(q,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,K.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[s.muted_projects.length,` muted`]})}),(0,K.jsx)(`div`,{className:`flex flex-col gap-1`,children:i.data?.map(e=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,K.jsx)(H,{checked:s.muted_projects.includes(e.id),onCheckedChange:t=>c({...s,muted_projects:t?[...s.muted_projects,e.id]:s.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function _t(){let e=V();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`This browser only`,children:`Editor`}),(0,K.jsx)(q,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,K.jsx)(F,{id:`tab-size`,type:`number`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onChange:e=>W({editorTabSize:Number(e.target.value)||2})})}),(0,K.jsx)(q,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,K.jsx)(H,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>W({editorWordWrap:e})})}),(0,K.jsx)(q,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,K.jsx)(F,{id:`editor-link-host`,type:`text`,placeholder:`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>W({editorLinkSshHost:e.target.value})})})]})}function vt({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=xe(e.nativeEvent);t&&(n(t),a(!1))},className:L(`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…`:Le(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)(Xe,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function yt(){let e=r(),t=T(e??void 0),n=k(e??``),i=t.data?.hotkeys??{},a=(e,t)=>i[e]||t,o=new Map;for(let e of ge){let t=a(e.id,e.defaultBinding);o.set(t,(o.get(t)??0)+1)}let s=(e,t)=>n.mutate({hotkeys:{...i,[e]:t}},{onError:e=>I(e)}),c=e=>{let t={...i};delete t[e],n.mutate({hotkeys:t},{onError:e=>I(e)})};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Hotkeys`}),(0,K.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed. Browser-reserved combos (⌘W, ⌘T, ⌘⇧B, …) can’t be captured by a web tab.`}),he.map(e=>{let t=ge.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=a(e.id,e.defaultBinding),n=(o.get(t)??0)>1,r=Ie(t)?`Browser-reserved — won’t fire in a tab.`:n?`Conflicts with another shortcut.`:void 0;return(0,K.jsx)(q,{label:e.label,description:r,descriptionClassName:r?`text-interrupted`:void 0,children:(0,K.jsx)(vt,{value:t,isDefault:!i[e.id],onRecord:t=>s(e.id,t),onReset:()=>c(e.id)})},e.id)})]},e)})]})}var bt=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Z=65,Q=Object.fromEntries([...bt].map((e,t)=>[e,t])),xt=`H`,St=(()=>{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 Ct(e){let t=4294967295;for(let n of e)t=St[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function wt(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function Tt(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 Et(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function Dt(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function Ot(e,t){let n=(t%Z+Z)%Z,r=``;for(let t of e){let e=Q[t];r+=e===void 0?t:bt[(e+n)%Z]}return r}async function kt(e){let t=await Et(JSON.stringify(e));return Ot(wt(t)+Ct(t),1+Math.floor(Math.random()*(Z-1)))}async function At(e){let t=e.trim(),n=t[0];if(!n||Q[n]===void 0)throw Error(`Not a settings export.`);let r=Ot(t,-((Q[n]-Q[xt]+Z)%Z));if(r.length<9||r[0]!==xt)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=Tt(i);if(Ct(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await Dt(o))}var jt=`puddle.sync-selection`;function Mt(){try{let e=JSON.parse(localStorage.getItem(jt)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return Re.map(e=>e.id)}function Nt({selected:e,onToggle:t}){return(0,K.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:Re.map(n=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(H,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function Pt(){let e=r(),t=T(e??void 0),n=j().data?.find(t=>t.id===e),i=ne(e??void 0,void 0),o=k(e??``),s=D(),c=ee(),l=Pe(),u=Ve(),[d,f]=(0,G.useState)(``),[p,h]=(0,G.useState)(``),[g,_]=(0,G.useState)(!1),[v,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(Mt),S=n?l.data?.file.profiles[n.name]:void 0,C=S?.enabled===!0,w=C&&S?S.groups:b,E=()=>({client:Fe(),theme:ze(),profileSettings:t.data??{},profile:n??{},scratchpad:i.data??[]}),O={setClient:e=>W(e),setTheme:e=>{typeof e==`string`&&je(e)},patchProfileSettings:e=>o.mutate(e,{onError:e=>I(e)}),patchProfileColumns:t=>{e&&s.mutate({id:e,...t},{onError:e=>I(e)})},createScratchpad:t=>{if(e)for(let n of t)c.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},A=(e,t)=>{n&&u.mutate({profile:n.name,entry:{enabled:e.enabled??C,groups:t,doc:Ne(t,E()),updatedAt:new Date().toISOString()}},{onError:e=>I(e)})},te=(e,t)=>{let n=t?[...w,e]:w.filter(t=>t!==e);x(n),localStorage.setItem(jt,JSON.stringify(n)),C&&A({},n)},M=async()=>{y(!0);try{let e=He(await At(d.trim()),O,{profileSettings:t.data??{},scratchpad:i.data??[]});e.length===0?a.error(`Nothing recognised to import.`):(a.success(`Imported ${e.join(`, `)}.`),f(``))}catch(e){a.error(e.message)}finally{y(!1)}},P=async()=>{y(!0);try{let e=await kt(Ne(w,E()));h(e),await navigator.clipboard?.writeText(e),a.success(`Copied to clipboard`)}finally{y(!1)}};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Sync`}),(0,K.jsx)(`p`,{className:`mb-5 text-xs text-fg-muted`,children:`Carry your settings between machines. Accounts, repositories, and anything host-specific are never included. Applies to this profile.`}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),l.data?.available===!1?(0,K.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:`Not available in this cockpit — start the UI with the puddle CLI to sync across windows.`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Mirror the selected groups through this machine’s`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:`~/.puddle`}),`, so every puddle window — any port, any host — stays in step for profiles named`,` `,(0,K.jsx)(`span`,{className:`font-mono`,children:n?.name??`…`}),`. The checklist below then applies to imports and exports alike; scratchpad entries merge and never overwrite.`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(H,{checked:C,disabled:!n||l.isLoading||u.isPending,onCheckedChange:e=>A({enabled:e},w)}),`Sync locally`]})]})]}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>_(e=>!e),className:`flex items-center gap-1 text-xs text-fg-secondary transition-colors hover:text-fg`,children:[g?(0,K.jsx)(fe,{className:`size-3.5`}):(0,K.jsx)(me,{className:`size-3.5`}),`Choose what to sync`]}),g&&(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(Nt,{selected:w,onToggle:te})})]}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,K.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:`One click builds the string from the checklist above and copies it to your clipboard.`}),(0,K.jsx)(m,{size:`sm`,disabled:v,onClick:()=>void P(),children:`Export & copy`}),p&&(0,K.jsx)(N,{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 an exported string — only the settings it carries are updated. Scratchpad entries are added alongside yours, never replacing them.`}),(0,K.jsx)(N,{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)(m,{size:`sm`,disabled:!d.trim()||v,onClick:()=>void M(),children:`Import`})})]})]})}function Ft({repo:e}){let t=x(),n=b(),[r,i]=(0,G.useState)(e.default_base_branch),[o,s]=(0,G.useState)(e.onboarding_notes??``),c=e=>I(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 font-mono text-sm text-fg`,children:e.path}),(0,K.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,K.jsxs)(m,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>a.success(`Fetched.`),onError:c}),children:[(0,K.jsx)(ye,{}),`Fetch now`]})]}),(0,K.jsxs)(q,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,K.jsx)(F,{id:`base-${e.id}`,value:r,onChange:e=>i(e.target.value),className:`w-40 font-mono`}),(0,K.jsx)(m,{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)(q,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,K.jsx)(H,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError: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)(N,{id:`notes-${e.id}`,value:o,onChange:e=>s(e.target.value),rows:4,className:`font-mono`}),(0,K.jsx)(`div`,{children:(0,K.jsx)(m,{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 font-mono text-2xs text-fg-muted`,children:e},e))})]})]})}function It(){let e=te();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{children:`Repositories`}),e.data?.length===0&&(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No repositories yet — register one from the new-project flow on the dashboard.`}),e.data?.map(e=>(0,K.jsx)(Ft,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=E();return(0,K.jsx)(q,{label:e,description:t,htmlFor:`host-${n}`,children:(0,K.jsx)(F,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>I(e)})}})})}function Lt(){let e=M(),t=E();return e.data?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(J,{note:`Affects all profiles on this host`,children:`Host`}),(0,K.jsx)(q,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,K.jsx)(F,{id:`host-displayName`,type:`text`,maxLength:64,className:`w-48`,defaultValue:e.data.displayName,onBlur:n=>{let r=n.target.value.trim();r!==e.data.displayName&&t.mutate({displayName:r},{onError:e=>I(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)(q,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,K.jsx)(H,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>I(e)})})})]}):null}var Rt=[{id:`appearance`,label:`Appearance`,icon:Oe,render:()=>(0,K.jsx)(tt,{})},{id:`profile`,label:`Profile`,icon:De,render:()=>(0,K.jsx)(rt,{})},{id:`accounts`,label:`Accounts`,icon:et,render:()=>(0,K.jsx)(ot,{})},{id:`sessions`,label:`Sessions`,icon:$e,render:()=>(0,K.jsx)(ft,{})},{id:`editor`,label:`Editor`,icon:Je,render:()=>(0,K.jsx)(_t,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Ye,render:()=>(0,K.jsx)(yt,{})},{id:`notifications`,label:`Notifications`,icon:qe,render:()=>(0,K.jsx)(gt,{})},{id:`repositories`,label:`Repositories`,icon:ae,render:()=>(0,K.jsx)(It,{})},{id:`host`,label:`Host`,icon:Ze,render:()=>(0,K.jsx)(Lt,{})},{id:`sync`,label:`Sync`,icon:ye,render:()=>(0,K.jsx)(Pt,{})}],zt={terminal:`sessions`};function Bt(){let e=Ke(),t=e===null?null:zt[e]??e,n=Rt.find(e=>e.id===t)??Rt[0];return(0,K.jsx)(y,{open:e!==null,onOpenChange:e=>!e&&be(),children:(0,K.jsxs)(g,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,K.jsx)(_,{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`}),Rt.map(({id:e,label:t,icon:r})=>(0,K.jsxs)(`button`,{onClick:()=>Ce(e),className:L(`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{Bt as SettingsDialog};