@puddle-code/cli 0.4.13 → 0.4.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -16
- package/dist/index.js +5 -3
- package/dist/public/assets/App-Dlrlhlup.js +9 -0
- package/dist/public/assets/{Dashboard-DyNOxwSR.js → Dashboard-B2o7orBK.js} +1 -1
- package/dist/public/assets/{LazyTerminal-BjT3haSN.js → LazyTerminal-D4QV7VEc.js} +2 -2
- package/dist/public/assets/{NotebookWidget-CPhHup1W.js → NotebookWidget-CH5zoEVV.js} +1 -1
- package/dist/public/assets/{PaneEditorBody-DCGP8CyB.js → PaneEditorBody-DESTR4r3.js} +7 -7
- package/dist/public/assets/{ReleaseNotesDialog-BD0uYU6B.js → ReleaseNotesDialog-jEU0I1rq.js} +1 -1
- package/dist/public/assets/Ripple-BM7RYwkx.css +1 -0
- package/dist/public/assets/Ripple-DxqgViCr.js +12 -0
- package/dist/public/assets/SettingsDialog-BcWnMD7A.js +8 -0
- package/dist/public/assets/Terminal-Gq862tY-.js +65 -0
- package/dist/public/assets/{Workspace-CjOdyZwS.js → Workspace-DVji-hSU.js} +6 -6
- package/dist/public/assets/{_virtual_notebook-widget-runtime-BDEYw1H-.js → _virtual_notebook-widget-runtime-RX_hqyhn.js} +1 -1
- package/dist/public/assets/{expanding-content-xApnlOBO.js → expanding-content-CKyt4o9s.js} +1 -1
- package/dist/public/assets/forward-link-BfAPpjGN.js +1 -0
- package/dist/public/assets/{index-MjsHIzAR.js → index-Cg9SFK_d.js} +2 -2
- package/dist/public/assets/{index-BfQvnKtf.css → index-D_XpA70m.css} +1 -1
- package/dist/public/assets/{markdown-BaCjN652.js → markdown-Cseepnv3.js} +1 -1
- package/dist/public/assets/notification-delivery-B-zt57w8.js +1 -0
- package/dist/public/assets/preferences-xuDDL7Pm.js +1 -0
- package/dist/public/assets/render-rich-content-DAJtX81B.js +4 -0
- package/dist/public/assets/selection-actions-DMOj1EOB.js +1 -0
- package/dist/public/assets/use-ui-state-TZnzSo9V.js +1 -0
- package/dist/public/assets/ws-DjQ6OZLM.js +1 -0
- package/dist/public/index.html +2 -2
- package/package.json +1 -1
- package/dist/public/assets/App-BOGDHWlW.js +0 -23
- package/dist/public/assets/Ripple-B-wG6_Xj.js +0 -7
- package/dist/public/assets/Ripple-V2kU3kad.css +0 -1
- package/dist/public/assets/SettingsDialog-DwWcTOGl.js +0 -8
- package/dist/public/assets/Terminal-DzImIFH4.js +0 -65
- package/dist/public/assets/desktop-Bl69_YmL.js +0 -1
- package/dist/public/assets/forward-link-CAXhnLYS.js +0 -1
- package/dist/public/assets/link-buffer-DcFk9vqt.js +0 -1
- package/dist/public/assets/notification-delivery-14yN_sWJ.js +0 -1
- package/dist/public/assets/preferences-DC7PJ3Go.js +0 -1
- package/dist/public/assets/render-rich-content-Dvum-lQy.js +0 -4
- package/dist/public/assets/use-ui-state-CyfRHVgg.js +0 -1
- package/dist/public/assets/ws-CS9chtfK.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{A as n,X as r,a as i,d as a,et as o,f as s,j as c,o as l,v as u}from"./auth-C3ruG3fE.js";import{t as d}from"./jsx-runtime-By8HlURe.js";import{r as f}from"./index-Cg9SFK_d.js";import{n as p}from"./api-CULxlzTe.js";import{t as m}from"./ws-DjQ6OZLM.js";import{t as h}from"./createLucideIcon-C9A1vLE-.js";import{n as g}from"./dist-BOS6OKSE.js";import{t as _}from"./button-DtByPSFL.js";import{t as v}from"./copy-D0Theg4Q.js";import{t as y}from"./x-DV6-RYI2.js";var b=h(`clipboard-paste`,[[`path`,{d:`M11 14h10`,key:`1w8e9d`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v1.344`,key:`1e62lh`}],[`path`,{d:`m17 18 4-4-4-4`,key:`z2g111`}],[`path`,{d:`M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113`,key:`bjbb7m`}],[`rect`,{x:`8`,y:`2`,width:`8`,height:`4`,rx:`1`,key:`ublpy`}]]),x=h(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]);function S(){return f.get()}var C=n.options.join(`,`),w=a.imageBytes,T=20*1024*1024;async function E(e,t,r){r?.throwIfAborted();let i=n.safeParse(e.type);if(!i.success)throw Error(`Choose a PNG, JPEG, GIF or WebP image.`);if(e.size===0)throw Error(`This image is empty.`);if(e.size>T)throw Error(`Choose an image smaller than 20 MiB.`);if(!t||e.size<=w)return{blob:e,mime:i.data,resized:!1};if(i.data===`image/gif`)throw Error(`Choose a GIF no larger than 4 MiB for remote access.`);let a=await createImageBitmap(e);try{r?.throwIfAborted();let e=document.createElement(`canvas`),t=e.getContext(`2d`);if(!t)throw Error(`Could not prepare this image.`);let o=i.data===`image/jpeg`?`image/jpeg`:`image/webp`,s=Math.min(1,2048/Math.max(a.width,a.height));for(let i=0;i<8;i++){e.width=Math.max(1,Math.round(a.width*s)),e.height=Math.max(1,Math.round(a.height*s)),t.drawImage(a,0,0,e.width,e.height);for(let t of[.85,.7,.55]){let i=await new Promise(n=>e.toBlob(n,o,t));if(r?.throwIfAborted(),i&&i.size<=w)return{blob:i,mime:n.parse(i.type),resized:!0}}s*=.75}throw Error(`This image is too large to attach remotely. Choose a smaller image.`)}finally{a.close()}}var D=new WeakSet,ee=Math.floor((u.requestBytes-1024)*3/4);async function O(e,t,n,i,l,u,d){let f=e.generation,p=()=>{if(u?.throwIfAborted(),l(),e.generation!==f)throw Error(`The connection changed; the image upload was interrupted.`)};if(p(),!n.size||n.size>a.imageBytes)throw Error(`The prepared image must be no larger than 4 MiB.`);if(D.has(e))throw Error(`An image upload is already in progress.`);D.add(e);let m=crypto.randomUUID(),h=`/api/worktrees/${t}/paste-upload`,g=!1,_=!1,v=async(t,n,r)=>{p();let i=await e.request(t,n,r,u),a=await i.json();if(p(),!i.ok){let e=o.safeParse(a);throw Error(e.success?e.data.error.message:`The image upload failed.`)}return a},y=e=>v(`POST`,h,e),b=async e=>{let t=new Uint8Array(await e.arrayBuffer());return p(),btoa(Array.from(t,e=>String.fromCharCode(e)).join(``))};try{let e=r.parse(await v(`GET`,`/api/version`));if(d?.(0,n.size),!e.remote_image_uploads){if(n.size>ee)throw Error(`Update the host connector to upload images larger than 191 KiB.`);let e=await b(n),r=c.parse(await v(`POST`,`/api/worktrees/${t}/paste`,{mime:i,data:e}));return d?.(n.size,n.size),r}if(g=!0,s.parse(await y({action:`start`,upload:m,mime:i,size:n.size})).received!==0)throw Error(`Invalid image upload acknowledgement.`);for(let e=0;e<n.size;e+=a.chunkBytes){let t=n.slice(e,e+a.chunkBytes),r=await b(t),i=s.parse(await y({action:`chunk`,upload:m,offset:e,data:r}));if(i.received!==e+t.size)throw Error(`Invalid image upload acknowledgement.`);d?.(i.received,n.size)}let o=c.parse(await y({action:`finish`,upload:m}));return _=!0,o}finally{if(g&&!_&&e.generation===f)try{l(),e.request(`POST`,h,{action:`cancel`,upload:m}).catch(()=>{})}catch{}D.delete(e)}}function k(e,t,n){if(t.startsWith(`login-`)||t===`home`)return!1;let r=Array.from(e.clipboardData?.items??[]);if(r.some(e=>e.type===`text/plain`))return!1;let i=r.find(e=>e.kind===`file`&&e.type.startsWith(`image/`));if(!i)return!1;let a=i.getAsFile();return a?(A(a,t,n).then(({resized:e})=>{e&&g(`Image resized for remote access`)}).catch(e=>{g.error(e instanceof Error?`Image paste failed: ${e.message}`:`Image paste failed`)}),!0):!1}async function A(e,t,n,r={}){if(t.startsWith(`login-`)||t===`home`)throw Error(`Open a project terminal to attach an image.`);let i=l(),a=i?.generation,o=()=>{if(l()!==i||i?.generation!==a||!m.isConnected())throw Error(`The terminal connection changed; the image was not inserted.`)};r.signal?.throwIfAborted(),o(),r.onProgress?.({stage:`preparing`});let{blob:s,mime:u,resized:d}=await E(e,i!==null,r.signal);o();let f=i?await O(i,t,s,u,o,r.signal,(e,t)=>r.onProgress?.(e===t?{stage:`saving`}:{stage:`uploading`,received:e,total:t})):await(async()=>{let e=await j(s);return o(),r.signal?.throwIfAborted(),c.parse(await p(`POST`,`/api/worktrees/${t}/paste`,{mime:u,data:e}))})();return r.signal?.throwIfAborted(),o(),r.onProgress?.({stage:`inserting`}),r.insert?r.insert(`${f.path} `):i?await i.input(t,n,`${f.path} `):m.write(t,n,`${f.path} `),{resized:d}}function j(e){return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result).replace(/^data:[^,]*,/,``)),r.onerror=()=>n(r.error??Error(`could not read the clipboard image`)),r.readAsDataURL(e)})}var M=e(t(),1),N={ctrl:1,alt:2,shift:4},P=/^(?:\[[ABCD]|O[ABCD]|\[1;([2-8])[ABCD])$/,F=e=>e.startsWith(`\x1B`)?P.exec(e.slice(1)):null;function I(e){return!e.startsWith(`\x1B`)||e===`\x1B`||F(e)!==null||e===`\x1B[Z`}function L(e,t){if(!t)return e;let n=(t&N.ctrl)!==0,r=(t&N.alt)!==0,i=(t&N.shift)!==0,a=!!i|(r?2:0)|(n?4:0),o=F(e);if(o)return`\x1b[1;${1+(a|(o[1]?Number(o[1])-1:0))}${e.slice(-1)}`;if(!I(e))return e;if(e===` `||e===`\x1B[Z`)return i||e===`\x1B[Z`?`\x1B[Z`:` `;if(e===`\r`&&i)return`\x1b[13;${1+a}u`;if(i&&e.length===1){let t="`1234567890-=[]\\;',./".indexOf(e);t===-1?/[a-z]/.test(e)&&(e=e.toUpperCase()):e=`~!@#$%^&*()_+{}|:"<>?`[t]}if(n&&e.length===1){let t=e.toUpperCase().charCodeAt(0);t>=64&&t<=95?e=String.fromCharCode(t-64):e===` `?e=`\0`:e===`?`&&(e=``)}return r?`\x1b${e}`:e}function te(e){return e.length===3&&(e.startsWith(`\x1B[`)||e.startsWith(`\x1BO`))&&`ABCD`.includes(e[2])}var R=new Map,z=new Map,B=new Map,V=new Map,H=new Set,U=e=>(H.add(e),()=>{H.delete(e)}),W=()=>{for(let e of H)e()},G=(e,t)=>i(JSON.stringify([e,t]));function K(e,t){return(0,M.useSyncExternalStore)(U,()=>R.has(G(e,t)))}function q(e,t,n,r,i){let a=G(e,t);return R.set(a,n),r&&z.set(a,r),i?B.set(a,i):B.delete(a),W(),()=>{R.get(a)===n&&(R.delete(a),z.delete(a),B.delete(a),V.delete(a),W())}}function J(e,t){z.get(G(e,t))?.()}function Y(e,t){return(0,M.useSyncExternalStore)(U,()=>V.get(G(e,t))??0)}function X(e,t,n){let r=G(e,t);V.set(r,(V.get(r)??0)^n),W()}function Z(e,t,n){let r=G(e,t),i=V.get(r)??0;return!i||!I(n)?n:(V.delete(r),W(),L(n,i))}async function ne(e,t,n,r=!1){let i=G(e,t),a=R.get(i);if(!a)throw Error(`Wait for the terminal to attach; nothing was sent`);let o=r?`${a(n)}\r`:Z(e,t,n);!r&&te(o)&&B.get(i)?.()&&(o=`\x1bO${o.slice(-1)}`),await Q(e,t,o)}async function re(e,t,n){let r=G(e,t),i=R.get(r),a=l(),o=a?.generation;if(!i||!n()||!m.isConnected())throw Error(`Wait for the terminal to attach; nothing was pasted.`);let s;try{let n=navigator.clipboard.readText();J(e,t),s=await n}catch{throw Error(`Could not read the clipboard. Allow clipboard access or use your keyboard’s Paste action.`)}if(!n()||R.get(r)!==i||l()!==a||a?.generation!==o||!m.isConnected())throw Error(`The terminal changed; nothing was pasted. Try again in the active terminal.`);s&&await Q(e,t,i(s))}async function Q(e,t,n){let r=l();if(r)await r.input(e,t,n);else{if(!m.isConnected())throw Error(`Terminal is disconnected; nothing was sent`);m.write(e,t,n)}}var $=d();function ie({text:e,label:t,clear:n,paste:r}){let[i,a]=(0,M.useState)(!1);return(0,$.jsxs)(`div`,{role:`toolbar`,"aria-label":t,onPointerDown:e=>e.preventDefault(),className:`absolute right-2 top-2 z-20 flex gap-1 rounded-md bg-elevated p-1 shadow-lg`,children:[(0,$.jsxs)(_,{variant:`ghost`,size:`sm`,disabled:!e||i,onClick:async()=>{try{await navigator.clipboard.writeText(e),n()}catch{g.error(`Could not copy the selection. Try again.`)}},children:[(0,$.jsx)(v,{}),` Copy`]}),r&&(0,$.jsxs)(_,{variant:`ghost`,size:`sm`,disabled:i,onClick:async()=>{if(!i){a(!0);try{await r(),n()}catch(e){g.error(e instanceof Error?e.message:`Could not paste. Try again.`)}finally{a(!1)}}},children:[(0,$.jsx)(b,{}),` Paste`]}),(0,$.jsx)(_,{variant:`ghost`,size:`icon`,"aria-label":`Clear selection`,disabled:i,onClick:n,children:(0,$.jsx)(y,{})})]})}export{q as a,K as c,k as d,A as f,x as h,re as i,Y as l,S as m,Z as n,ne as o,C as p,J as r,X as s,ie as t,N as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{E as n,lt as r,w as i}from"./protocol-support-BwRR1kRO.js";import{F as a}from"./auth-C3ruG3fE.js";import{t as o}from"./jsx-runtime-By8HlURe.js";import{y as s}from"./ws-DjQ6OZLM.js";import{n as c,t as l}from"./createLucideIcon-C9A1vLE-.js";import{C as u,E as d,T as f,_ as p,g as ee,v as m,x as h,y as te}from"./dialog-DtvE8ATK.js";import{a as g,r as _}from"./dist-DZg8Dwbr.js";import{_ as v,b as y,g as b,p as x,s as S,v as ne,y as re}from"./dist-Dac0re_p.js";import{i as ie}from"./dist-BeQvHdsz.js";import{c as ae,n as oe}from"./switch-DYr-iPWY.js";import{a as C,n as se,o as w}from"./preview-kind-CPkO-rSz.js";import{t as ce}from"./debounce-B9DrqirV.js";var T=e(t(),1),E=o(),[D,le]=f(`Tooltip`,[y]),O=y(),ue=`TooltipProvider`,de=700,fe=`tooltip.open`,[pe,k]=D(ue),me=e=>{let{__scopeTooltip:t,delayDuration:n=de,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=T.useRef(!0),s=T.useRef(!1),c=T.useRef(0);return T.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,E.jsx)(pe,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:T.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:T.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:T.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};me.displayName=ue;var A=`Tooltip`,[he,j]=D(A),ge=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=k(A,e.__scopeTooltip),l=O(t),[u,d]=T.useState(null),f=te(),p=T.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=T.useRef(!1),[_,v]=ee({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(fe))):c.onClose(),a?.(e)},caller:A}),y=T.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=T.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=T.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=T.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return T.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,E.jsx)(re,{...l,children:(0,E.jsx)(he,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:T.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:T.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};ge.displayName=A;var M=`TooltipTrigger`,_e=T.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=j(M,n),a=k(M,n),o=O(n),s=g(t,T.useRef(null),i.onTriggerChange),c=T.useRef(!1),l=T.useRef(!1),f=T.useCallback(()=>c.current=!1,[]);return T.useEffect(()=>()=>document.removeEventListener(`pointerup`,f),[f]),(0,E.jsx)(b,{asChild:!0,...o,children:(0,E.jsx)(u.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:d(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:d(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:d(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,f,{once:!0})}),onFocus:d(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:d(e.onBlur,i.onClose),onClick:d(e.onClick,i.onClose)})})});_e.displayName=M;var N=`TooltipPortal`,[ve,ye]=D(N,{forceMount:void 0}),be=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=j(N,t);return(0,E.jsx)(ve,{scope:t,forceMount:n,children:(0,E.jsx)(p,{present:n||a.open,children:(0,E.jsx)(m,{asChild:!0,container:i,children:r})})})};be.displayName=N;var P=`TooltipContent`,xe=T.forwardRef((e,t)=>{let n=ye(P,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=j(P,e.__scopeTooltip);return(0,E.jsx)(p,{present:r||o.open,children:o.disableHoverableContent?(0,E.jsx)(Ee,{side:i,...a,ref:t}):(0,E.jsx)(Se,{side:i,...a,ref:t})})}),Se=T.forwardRef((e,t)=>{let n=j(P,e.__scopeTooltip),r=k(P,e.__scopeTooltip),i=T.useRef(null),a=g(t,i),[o,s]=T.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=T.useCallback(()=>{s(null),d(!1)},[d]),p=T.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Ae(r,ke(r,n.getBoundingClientRect())),a=je(t.getBoundingClientRect()),o=Ne([...i,...a]);s(o),d(!0)},[d]);return T.useEffect(()=>()=>f(),[f]),T.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),T.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Me(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,E.jsx)(Ee,{...e,ref:a})}),[Ce,we]=D(A,{isInside:!1}),Te=_(`TooltipContent`),Ee=T.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=j(P,n),l=O(n),{onClose:u}=c;return T.useEffect(()=>(document.addEventListener(fe,u),()=>document.removeEventListener(fe,u)),[u]),T.useEffect(()=>{if(c.trigger){let e=e=>{e.target instanceof Node&&e.target.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,E.jsx)(h,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,E.jsxs)(ne,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,E.jsx)(Te,{children:r}),(0,E.jsx)(Ce,{scope:n,isInside:!0,children:(0,E.jsx)(ie,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});xe.displayName=P;var De=`TooltipArrow`,Oe=T.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=O(n);return we(De,n).isInside?null:(0,E.jsx)(v,{...i,...r,ref:t})});Oe.displayName=De;function ke(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Ae(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function je(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Me(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Ne(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Pe(t)}function Pe(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Fe=me,Ie=ge,Le=_e,Re=be,ze=xe,Be=Fe,Ve=Ie,He=Le;function Ue({className:e,sideOffset:t=4,...n}){return(0,E.jsx)(Re,{children:(0,E.jsx)(ze,{sideOffset:t,className:c(`z-50 overflow-hidden px-2 py-1 text-xs text-fg`,S,x,`overlay-tooltip-motion`,e),...n})})}var We=l(`triangle-alert`,[[`path`,{d:`m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3`,key:`wmoenq`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]);function Ge({initial:e,maxLength:t,className:n,fitContent:r=!1,onCommit:i,onCancel:a}){let[o,s]=(0,T.useState)(e),l=(0,E.jsx)(`input`,{autoFocus:!0,value:o,maxLength:t,onFocus:e=>e.currentTarget.select(),onChange:e=>s(e.target.value),onBlur:()=>i(o),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?i(o):e.key===`Escape`&&a()},className:c(`bg-transparent outline-none`,r?`col-start-1 row-start-1 w-0 min-w-full p-0`:n)});return r?(0,E.jsxs)(`span`,{className:c(`inline-grid min-w-px`,n),children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,className:`invisible col-start-1 row-start-1 whitespace-pre`,children:o||``}),l]}):l}function Ke(e){return{onClick:e=>{e.detail===2&&e.preventDefault()},onDoubleClick:t=>{t.preventDefault(),e()}}}var F=null;function qe(e){return F=e,()=>{F===e&&(F=null)}}function Je(){F?.()}var I=null;function Ye(e){return I=e,()=>{I===e&&(I=null)}}async function Xe(e){if(!I)throw Error(`Open a project before opening a path.`);await I(e)}function Ze(){let e=r(s()??void 0).data?.tabTitleTemplate;return(0,T.useCallback)(t=>oe(t,e),[e])}var Qe=(0,T.createContext)({open:()=>void 0,handler:null,setHandler:()=>void 0});function $e({children:e}){let[t,n]=(0,T.useState)(null),r=(0,T.useCallback)(e=>n(()=>e),[]),i=(0,T.useCallback)(e=>t?.(e),[t]),a=(0,T.useMemo)(()=>({open:i,handler:t,setHandler:r}),[i,t,r]);return(0,E.jsx)(Qe.Provider,{value:a,children:e})}function et(){return(0,T.useContext)(Qe)}function tt({className:e,strokeScale:t=1}){return(0,E.jsxs)(`svg`,{viewBox:`0 0 24 24`,className:e,fill:`none`,stroke:`currentColor`,strokeWidth:1.8*t,strokeLinecap:`round`,"aria-hidden":!0,children:[(0,E.jsx)(`line`,{x1:`12`,y1:`12`,x2:`22`,y2:`12`}),(0,E.jsx)(`line`,{x1:`12`,y1:`12`,x2:`17`,y2:`20.66`}),(0,E.jsx)(`line`,{x1:`12`,y1:`12`,x2:`7`,y2:`20.66`}),(0,E.jsx)(`line`,{x1:`12`,y1:`12`,x2:`2`,y2:`12`}),(0,E.jsx)(`line`,{x1:`12`,y1:`12`,x2:`7`,y2:`3.34`}),(0,E.jsx)(`line`,{x1:`12`,y1:`12`,x2:`17`,y2:`3.34`}),(0,E.jsx)(`line`,{x1:`12`,y1:`12`,x2:`17.63`,y2:`15.25`}),(0,E.jsx)(`line`,{x1:`12`,y1:`12`,x2:`12`,y2:`18.5`}),(0,E.jsx)(`line`,{x1:`12`,y1:`12`,x2:`6.37`,y2:`15.25`}),(0,E.jsx)(`line`,{x1:`12`,y1:`12`,x2:`6.37`,y2:`8.75`}),(0,E.jsx)(`line`,{x1:`12`,y1:`12`,x2:`12`,y2:`5.5`}),(0,E.jsx)(`line`,{x1:`12`,y1:`12`,x2:`17.63`,y2:`8.75`})]})}function nt({className:e,strokeScale:t=1}){return(0,E.jsxs)(`svg`,{viewBox:`0 0 24 24`,className:e,fill:`none`,stroke:`currentColor`,strokeWidth:1.6*t,"aria-hidden":!0,children:[(0,E.jsx)(`ellipse`,{cx:`12`,cy:`12`,rx:`4`,ry:`9`}),(0,E.jsx)(`ellipse`,{cx:`12`,cy:`12`,rx:`4`,ry:`9`,transform:`rotate(60 12 12)`}),(0,E.jsx)(`ellipse`,{cx:`12`,cy:`12`,rx:`4`,ry:`9`,transform:`rotate(120 12 12)`})]})}function rt({className:e,strokeScale:t=1}){return(0,E.jsxs)(`svg`,{viewBox:`0 0 24 24`,className:e,fill:`none`,stroke:`currentColor`,strokeWidth:1.8*t,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,E.jsx)(`path`,{d:`M8 4H4v16h4`}),(0,E.jsx)(`path`,{d:`M16 4h4v16h-4`}),(0,E.jsx)(`rect`,{x:`10.5`,y:`10.5`,width:`3`,height:`3`,fill:`currentColor`,stroke:`none`})]})}function it({className:e}){return(0,E.jsx)(`svg`,{viewBox:`0 0 24 24`,className:e,fill:`currentColor`,"aria-hidden":!0,children:(0,E.jsx)(`path`,{d:`M12 1.5c0 5.8 4.7 10.5 10.5 10.5C16.7 12 12 16.7 12 22.5 12 16.7 7.3 12 1.5 12 7.3 12 12 7.3 12 1.5Z`})})}function at({type:e,className:t,strokeScale:n=1}){switch(e){case`claude-code`:return(0,E.jsx)(tt,{className:t,strokeScale:n});case`codex`:return(0,E.jsx)(nt,{className:t,strokeScale:n});case`opencode`:return(0,E.jsx)(rt,{className:t,strokeScale:n});case`gemini-cli`:return(0,E.jsx)(it,{className:t});default:return(0,E.jsx)(ae,{className:t,strokeWidth:2*n})}}var L=new Set,R=!1,ot=null;function st(){for(let e of L)e()}function ct(e){return L.add(e),()=>L.delete(e)}function lt(e){R!==e&&(R=e,st())}function ut(){lt(!R)}function dt(){return(0,T.useSyncExternalStore)(ct,()=>R)}function ft(e){ot=e,st()}function pt(){return(0,T.useSyncExternalStore)(ct,()=>ot)}function z(){return crypto.randomUUID()}function B(e){return e.type===`terminal`?`term:${e.session}`:`editor:${C(e.tab)}`}function V(e,t){return B(e)===B(t)}function mt(e){return e.type===`terminal`}function ht(e){return e.type===`editor`&&(e.tab.view===`linked`||e.tab.view===`locked`)}function H(e=[],t){let n=e.map(B),r=t&&n.includes(t)?t:n.length>0?n[0]:null;return{kind:`leaf`,id:z(),tabs:e,activeKey:r,previewKey:null}}function U(e,t,n){return{kind:`split`,id:z(),direction:e,children:t,sizes:n??t.map(()=>100/Math.max(1,t.length))}}function W(e,t){if(e.kind===`leaf`)return e.id===t?e:null;for(let n of e.children){let e=W(n,t);if(e)return e}return null}function G(e,t){if(e.kind===`leaf`)return e.tabs.some(e=>B(e)===t)?e:null;for(let n of e.children){let e=G(n,t);if(e)return e}return null}function K(e){return e.kind===`leaf`?[e]:e.children.flatMap(K)}function q(e){return K(e).flatMap(e=>e.tabs)}function gt(e){return e.kind===`leaf`?[e.id]:[e.id,...e.children.flatMap(gt)]}function _t(e){let t=gt(e);return new Set(t).size!==t.length}function vt(e){return e.kind===`leaf`?{...e,id:z()}:{...e,id:z(),children:e.children.map(vt)}}function yt(e){if(!_t(e))return e;let t=new Set,n=e=>{let r=t.has(e.id)?z():e.id;return t.add(r),e.kind===`leaf`?{...e,id:r}:{...e,id:r,children:e.children.map(n)}};return n(e)}function bt(e){let t=e.tabs.map(B),n=e.activeKey&&t.includes(e.activeKey)?e.activeKey:t[0]??null,r=e.previewKey&&t.includes(e.previewKey)?e.previewKey:null;return n===e.activeKey&&r===(e.previewKey??null)?e:{...e,activeKey:n,previewKey:r}}function J(e){if(e.kind===`leaf`)return bt(e);let t=e.children.map(J),n=[],r=[];t.forEach((t,i)=>{let a=e.sizes[i]??1;if(t.kind===`split`&&t.direction===e.direction){let e=t.sizes.reduce((e,t)=>e+t,0)||t.children.length;t.children.forEach((i,o)=>{n.push(i),r.push(a*(t.sizes[o]??1)/e)})}else n.push(t),r.push(a)});let i=[],a=[];return n.forEach((e,t)=>{e.kind===`leaf`&&e.tabs.length===0||(i.push(e),a.push(r[t]??1))}),i.length===0?H([]):i.length===1?i[0]:{...e,children:i,sizes:a}}function Y(e,t,n){return e.kind===`leaf`?e.id===t?n(e):e:{...e,children:e.children.map(e=>Y(e,t,n))}}function xt(e,t,n){return Y(e,t,e=>{if(!e.tabs.some(e=>B(e)===n))return e;let t=e.tabs.filter(e=>B(e)!==n),r=e.activeKey===n?St(e,n):e.activeKey;return{...e,tabs:t,activeKey:r}})}function St(e,t){let n=e.tabs.findIndex(e=>B(e)===t);if(n===-1)return e.activeKey;let r=e.tabs.filter(e=>B(e)!==t);return r.length===0?null:B(r[Math.min(n,r.length-1)])}function Ct(e,t,n){let r=e.tabs.filter(e=>!V(e,t)),i=n===void 0?r.length:Math.max(0,Math.min(n,r.length)),a=[...r.slice(0,i),t,...r.slice(i)];return{...e,tabs:a,activeKey:B(t)}}function wt(e,t,n,r){let i=n===`left`||n===`right`?`row`:`col`,a=n===`left`||n===`top`;return J(Y(e,t,e=>{let t=H([r]);return U(i,a?[t,e]:[e,t],[50,50])}))}function Tt(e,t){let{fromLeafId:n,toLeafId:r,edge:i}=t;if(n===r)return e;let a=W(e,n),o=W(e,r);if(!a||!o)return e;if(i===`center`){let t=e=>e.kind===`leaf`?e.id===n?o:e.id===r?a:e:{...e,children:e.children.map(t)};return t(e)}let s=J(Y(e,n,e=>({...e,tabs:[],activeKey:null,previewKey:null}))),c=i===`left`||i===`right`?`row`:`col`,l=i===`left`||i===`top`;return J(Y(s,r,e=>U(c,l?[a,e]:[e,a],[50,50])))}function Et(e,t){let{ref:n,toLeafId:r,edge:i}=t,a=B(n),o=t.copy===!0&&!mt(n),s=t.index;if(i===`center`&&s!==void 0){let t=W(e,r)?.tabs.findIndex(e=>B(e)===a)??-1;t!==-1&&t<s&&--s}let c=o?e:xt(e,t.fromLeafId,a);if(i===`center`){let e=Y(c,r,e=>Ct(e,n,s));return!W(e,r)&&!G(e,a)?X(J(Dt(e,n)),a):X(J(e),a)}return W(c,r)?X(wt(c,r,i,n),a):J(H([n]))}function Dt(e,t){let n=K(e)[0];return n?Y(e,n.id,e=>Ct(e,t)):H([t])}function Ot(e,t,n){return J(Y(e,t,e=>e.tabs.some(e=>B(e)===n)?{...e,tabs:e.tabs.filter(e=>B(e)!==n),activeKey:e.activeKey===n?St(e,n):e.activeKey}:e))}function kt(e,t,n){let r=B(n);return J(Y(e,t,e=>{let t=e.previewKey===r?null:e.previewKey;return e.tabs.some(e=>V(e,n))?{...e,activeKey:r,previewKey:t}:{...e,tabs:[...e.tabs,n],activeKey:r,previewKey:t}}))}function At(e,t,n){let r=B(n);return J(Y(e,t,e=>e.tabs.some(e=>B(e)===r)?{...e,tabs:e.tabs.map(e=>B(e)===r?n:e),previewKey:e.previewKey===r?null:e.previewKey}:{...e,tabs:[...e.tabs,n]}))}function jt(e,t,n){let r=B(n);return Y(e,t,e=>({...e,tabs:e.tabs.map(e=>B(e)===r?n:e)}))}function Mt(e,t,n){let r=C(t),i=e=>e.kind===`split`?{...e,children:e.children.map(i)}:{...e,tabs:e.tabs.map(e=>e.type===`editor`&&C(e.tab)===r?{...e,tab:{...e.tab,compile_mode:n}}:e)};return i(e)}function Nt(e,t){return e.type!==`editor`||t.type!==`editor`||e.tab.view!==`preview`||t.tab.view!==void 0||se(t.tab.path)===null?t:{...t,tab:{...t.tab,view:`preview`}}}function Pt(e,t,n){let r=B(n);return J(Y(e,t,e=>{if(e.tabs.some(e=>V(e,n)))return{...e,activeKey:r};let t=e.previewKey?e.tabs.findIndex(t=>B(t)===e.previewKey):-1,i=t>=0?e.tabs[t]:void 0,a=e.tabs.length>1&&i!==void 0&&!mt(i)&&!ht(i),o=i?Nt(i,n):n,s=a?e.tabs.map((e,n)=>n===t?o:e):[...e.tabs,o];return{...e,tabs:s,activeKey:r,previewKey:r}}))}function X(e,t){let n=e=>e.kind===`leaf`?e.previewKey===t?{...e,previewKey:null}:e:{...e,children:e.children.map(n)};return n(e)}function Ft(e,t,n,r){return Y(e,t,e=>{let t=e.tabs.findIndex(e=>e.type===`editor`&&B(e)===n),i=t>=0?e.tabs[t]:void 0;if(i===void 0||i.type!==`editor`)return e;let a={...i,tab:{...i.tab,view:r}},o=B(a);if(o===n)return{...e,tabs:e.tabs.map((e,n)=>n===t?a:e)};let s=e.tabs.some((e,n)=>n!==t&&B(e)===o),c=s?e.tabs.filter((e,n)=>n!==t):e.tabs.map((e,n)=>n===t?a:e);return{...e,tabs:c,activeKey:e.activeKey===n?o:e.activeKey,previewKey:e.previewKey===n?s?null:o:e.previewKey??null}})}function It(e,t){let n=w(e);return n!==`commit`&&n!==`untitled`&&e.session===t.session&&e.path===t.path&&e.root===t.root}function Lt(e,t,n){if(n===t.path)return e;let r=!1,i=e=>{if(e.kind===`split`){let t=e.children.map(i);return t.some((t,n)=>t!==e.children[n])?{...e,children:t}:e}let a=new Map,o=!1,s=e.tabs.map(e=>{if(e.type!==`editor`||!It(e.tab,t))return e;let r={...e,tab:{...e.tab,path:n}};return a.set(B(e),B(r)),o=!0,r});if(!o)return e;r=!0;let c=e.activeKey,l=e.previewKey??null;return{...e,tabs:s,activeKey:c===null?null:a.get(c)??c,previewKey:l===null?null:a.get(l)??l}},a=i(e);return r?a:e}function Rt(e){if(e.type!==`editor`)return null;let t=e.tab,n=w(t);return n!==`file`&&n!==`external`||t.view===`linked`||t.view===`locked`||se(t.path)===null?null:t}function zt(e,t){let n=Rt(t);if(!n)return e;let r=!1,i=e=>{if(e.kind===`split`)return{...e,children:e.children.map(i)};let t=!1,a=e.tabs.map(e=>{if(e.type!==`editor`||!ht(e))return e;let r=e.tab;return r.session===n.session&&r.path===n.path&&(r.root??``)===(n.root??``)&&w(r)===w(n)?e:(t=!0,{type:`editor`,tab:{session:n.session,path:n.path,...n.kind===void 0?{}:{kind:n.kind},...n.root===void 0?{}:{root:n.root},view:r.view}})});return t?(r=!0,{...e,tabs:a}):e},a=i(e);return r?a:e}function Bt(e,t){return e.session===t.session&&e.path===t.path&&(e.root??``)===(t.root??``)&&w(e)===w(t)}function Vt(e,t,n){let r=K(e).flatMap(e=>e.tabs.flatMap(n=>n.type!==`editor`||n.tab.view===`linked`||n.tab.view===`locked`||!Bt(n.tab,t)?[]:[{leafId:e.id,ref:n}]));return r.find(({leafId:e})=>e===n)??r.find(({ref:e})=>(e.tab.view??`source`)===`source`)??r[0]??null}function Ht(e,t,n){return Y(e,t,e=>e.tabs.some(e=>B(e)===n)?{...e,activeKey:n}:e)}function Ut(e,t,n){function r(e){return e.kind===`leaf`?e:e.id===t&&n.length===e.children.length?{...e,children:e.children.map(r),sizes:[...n]}:{...e,children:e.children.map(r)}}return r(e)}function Wt(e){let t=e.type===`terminal`?e.session:e.tab.session;return t===`00000000-0000-0000-0000-000000000000`?null:t}function Gt(e){return t=>{let n=Wt(t);return n===null||e.has(n)}}function Z(e,t){let n=e=>e.kind===`leaf`?{...e,tabs:e.tabs.filter(t)}:{...e,children:e.children.map(n)};return J(n(e))}function Kt(e){let t=new Set,n=[];for(let r of e){let e=J(Z(r,e=>!t.has(B(e)))),i=q(e);if(i.length!==0){for(let e of i)t.add(B(e));n.push(e)}}return n.length===0?H([]):yt(n.length===1?n[0]:J(U(`row`,n)))}function qt(e){let t=e.editor_tabs.map(e=>({type:`editor`,tab:e})),n=e.session_tabs.map(e=>({type:`terminal`,session:e})),r=e.active_editor_tab?B({type:`editor`,tab:e.active_editor_tab}):null,i=e.active_session?`term:${e.active_session}`:null;if(t.length===0&&n.length===0)return H([]);if(t.length===0)return H(n,i);if(n.length===0)return H(t,r);let a=e.layout,o=typeof a.editor==`number`?a.editor:40,s=typeof a.session==`number`?a.session:60;return J(U(`col`,[H(t,r),H(n,i)],[o,s]))}function Jt(e){return JSON.stringify(Yt(e))}function Yt(e){return e===null?null:e.kind===`leaf`?e.tabs.length===0?null:{t:e.tabs.map(B)}:{d:e.direction,s:e.sizes.map(e=>Math.round(e*10)/10),c:e.children.map(Yt)}}var Q=new Set,$=!1,Xt=null;function Zt(){for(let e of Q)e()}function Qt(e){return Q.add(e),()=>Q.delete(e)}function $t(e){$!==e&&($=e,Zt())}function en(){$t(!$)}function tn(){return(0,T.useSyncExternalStore)(Qt,()=>$)}function nn(e){Xt=e,Zt()}function rn(){return(0,T.useSyncExternalStore)(Qt,()=>Xt)}var an={layout_tree:null,active_session:null,layout_ref:null};function on(e){return e.type===`terminal`?e.session:e.tab.session}function sn(e,t){let n=new Set;for(let[r,i]of Object.entries(e))if(!(r===t||!i.layout_tree))for(let e of q(i.layout_tree))e.type===`terminal`&&n.add(e.session);return[...n]}function cn(e,t){let n=e.project_layouts[t];return{...e,layout_tree:n?.layout_tree??null,active_session:n?.active_session??null,layout_ref:n?.layout_ref??null,session_tabs:[],editor_tabs:[],active_editor_tab:null}}function ln(e,t,n){return n?{loaded:e.loaded,snapshot:cn(e.snapshot,t),current:()=>cn(e.current(),t),update(n){let r={},i={...n};if(`layout_tree`in n&&(r.layout_tree=n.layout_tree??null,delete i.layout_tree),`active_session`in n&&(r.active_session=n.active_session??null,delete i.active_session),`layout_ref`in n&&(r.layout_ref=n.layout_ref??null,delete i.layout_ref),Object.keys(r).length>0){let n=e.current().project_layouts;i.project_layouts={...n,[t]:{...n[t]??an,...r}}}Object.keys(i).length>0&&e.update(i)}}:e}function un(e,t,n,r){let i=e.layout_tree??qt(e),a={};for(let o of t)a[o]={layout_tree:vt(Z(i,e=>{let i=on(e);return i===`00000000-0000-0000-0000-000000000000`?o===(r??t[0]):n.get(i)===o})),active_session:e.active_session!==null&&n.get(e.active_session)===o?e.active_session:null,layout_ref:null};return{layout_mode:`project`,project_layouts:a}}function dn(e,t,n={}){return{...e,...t,...n}}function fn(e,t,n){let r=t.layout_tree?Z(t.layout_tree,e=>{let t=on(e);return t===`00000000-0000-0000-0000-000000000000`||n.alive.has(t)}):null,i=t.active_session!==null&&n.alive.has(t.active_session)?t.active_session:null;if(t.scope===`profile`)return{projectBased:!1,patch:{layout_mode:`profile`,layout_tree:r,active_session:i,layout_ref:t.id}};let a=t.project_id??n.currentProject??n.projectIds[0]??``,o={layout_tree:r,active_session:i,layout_ref:t.id};if((e.layout_mode??`profile`)===`project`)return{projectBased:!0,patch:{project_layouts:{...e.project_layouts,[a]:o}}};let s=un(e,n.projectIds,n.sessionProject,a);return{projectBased:!0,patch:{...s,project_layouts:dn(s.project_layouts??{},e.project_layouts,{[a]:o})}}}function pn(e,t){let n=e.project_layouts,r=[...t.filter(e=>e in n),...Object.keys(n).filter(e=>!t.includes(e))].map(e=>n[e]);return{layout_mode:`profile`,project_layouts:{},layout_tree:Kt(r.map(e=>e.layout_tree).filter(e=>e!==null)),active_session:r.map(e=>e.active_session).find(e=>e!==null)??null,layout_ref:null}}var mn=2e3,hn=a.parse({});function gn(e){return`puddle.ws.${e}`}function _n(e){if(e===null)return{kind:`absent`};try{return{kind:`present`,snapshot:a.parse(JSON.parse(e))}}catch{return{kind:`corrupt`}}}function vn(){let e=s(),[t,r]=(0,T.useState)(!1),[a,o]=(0,T.useState)(hn),c=(0,T.useRef)(a);c.current=a;let l=(0,T.useRef)(null),u=(0,T.useMemo)(()=>ce((e,t)=>{n(e,t).catch(e=>console.warn(`ui-state save failed: ${e.message}`))},mn),[]);return(0,T.useEffect)(()=>{if(e===null){l.current=null;return}let t=gn(e);l.current=t;let n=!1;r(!1),o(hn);let a;try{a=_n(sessionStorage.getItem(t)),a.kind===`corrupt`&&sessionStorage.removeItem(t)}catch(e){console.warn(`ui-state read failed: ${e.message}`),a={kind:`absent`}}return a.kind===`present`?(o(a.snapshot),r(!0)):i(e).then(e=>{n||(e&&o(e.ui_state),r(!0))}).catch(e=>{console.warn(`ui-state load failed: ${e.message}`),n||r(!0)}),()=>{n=!0,u.flush()}},[e,u]),{loaded:t,snapshot:a,current:()=>c.current,update(t){if(e===null)return;let n={...c.current,...t};c.current=n,o(n);let r=l.current??gn(e);u(e,n);try{sessionStorage.setItem(r,JSON.stringify(n))}catch(e){console.warn(`ui-state write failed: ${e.message}`)}}}}export{Je as $,H as A,B,Tt as C,Ht as D,q as E,Ut as F,pt as G,ft as H,zt as I,$e as J,dt as K,Mt as L,X as M,Z as N,G as O,Lt as P,Ye as Q,Ft as R,yt as S,W as T,lt as U,jt as V,ut as W,Ze as X,et as Y,Xe as Z,kt as _,dn as a,Ue as at,qt as b,un as c,$t as d,qe as et,en as f,At as g,Jt as h,fn as i,Ve as it,Pt as j,Rt as k,pn as l,tn as m,vn as n,Ke as nt,sn as o,Be as ot,rn as p,at as q,gn as r,We as rt,ln as s,He as st,_n as t,Ge as tt,nn as u,K as v,Et as w,Ot as x,Gt as y,Vt as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{i as n,n as r,o as i,r as a}from"./auth-C3ruG3fE.js";import{n as o}from"./dist-BOS6OKSE.js";var s=e(t(),1);function c(){return window.puddleDesktop}function l(){let[e,t]=(0,s.useState)({fullScreen:!1,animate:!1});return(0,s.useEffect)(()=>{let e=c();if(!e)return;let n=!0;e.isFullScreen?.()?.then(e=>{n&&t({fullScreen:e,animate:!1})});let r=e.onFullScreenChange?.(e=>t({fullScreen:e,animate:!0}));return()=>{n=!1,r?.()}},[]),e}var u=n(`puddle.profile-id`);function d(){let e=(0,s.useSyncExternalStore)(u.subscribe,u.get);return e!==null&&/^[0-9a-f]{10}$/.test(e)?e:null}function f(e){window.location.pathname!==`/`&&window.history.replaceState(null,``,`/`),u.set(e)}var p=[`Layout & tabs`,`Projects`,`Editor`,`Left sidebar`,`Right sidebar`],m=Array.from({length:10},(e,t)=>({id:`project.switch${t}`,label:`Switch to project ${t+1}`,group:`Projects`,defaultBinding:`meta+Digit${t}`})),h=[...m,{id:`host.peek`,label:`Show host identity (hold)`,group:`Layout & tabs`,defaultBinding:typeof navigator<`u`&&/Mac/.test(navigator.platform)?`alt+meta+Slash`:`ctrl+alt+Slash`,hold:!0},{id:`palette.toggle`,label:`Command palette`,group:`Layout & tabs`,defaultBinding:`meta+KeyK`},{id:`tab.close`,label:`Close current tab`,group:`Layout & tabs`,defaultBinding:`ctrl+alt+KeyW`,desktopBinding:`meta+KeyW`},{id:`tab.reopen`,label:`Reopen last closed tab`,group:`Layout & tabs`,defaultBinding:`ctrl+alt+KeyT`,desktopBinding:`shift+meta+KeyT`},{id:`tab.newUntitled`,label:`New untitled file`,group:`Layout & tabs`,defaultBinding:`ctrl+alt+KeyN`,desktopBinding:`meta+KeyN`},{id:`tab.next`,label:`Next tab in pane`,group:`Layout & tabs`,defaultBinding:`ctrl+alt+BracketRight`,desktopBinding:`ctrl+Tab`},{id:`tab.prev`,label:`Previous tab in pane`,group:`Layout & tabs`,defaultBinding:`ctrl+alt+BracketLeft`,desktopBinding:`ctrl+shift+Tab`},{id:`window.close`,label:`Close window`,group:`Layout & tabs`,defaultBinding:`meta+KeyW`,desktopBinding:`shift+meta+KeyW`},{id:`sidebar.left`,label:`Toggle left sidebar`,group:`Layout & tabs`,defaultBinding:`alt+meta+Comma`,desktopBinding:`meta+KeyB`},{id:`sidebar.right`,label:`Toggle right sidebar`,group:`Layout & tabs`,defaultBinding:`alt+meta+Period`,desktopBinding:`shift+meta+KeyB`},{id:`editor.save`,label:`Save`,group:`Editor`,defaultBinding:`meta+KeyS`,editor:!0},{id:`editor.wordWrap`,label:`Toggle word wrap`,group:`Editor`,defaultBinding:`alt+KeyZ`,editor:!0},{id:`nav.files`,label:`Open Files`,group:`Left sidebar`,defaultBinding:`alt+meta+KeyE`},{id:`nav.search`,label:`Open Search`,group:`Left sidebar`,defaultBinding:`alt+meta+KeyF`},{id:`nav.changes`,label:`Open Changes`,group:`Left sidebar`,defaultBinding:`alt+meta+KeyV`},{id:`nav.worktrees`,label:`Open Worktrees`,group:`Left sidebar`,defaultBinding:`alt+meta+KeyB`},{id:`session.newAgent`,label:`New agent`,group:`Right sidebar`,defaultBinding:`ctrl+alt+Backquote`,desktopBinding:`meta+KeyT`},{id:`session.newTerminal`,label:`New terminal`,group:`Right sidebar`,defaultBinding:`ctrl+Backquote`},{id:`scratchpad.toggle`,label:`Toggle Scratchpad`,group:`Right sidebar`,defaultBinding:`alt+meta+KeyS`},{id:`layouts.toggle`,label:`Toggle Layouts`,group:`Right sidebar`,defaultBinding:`alt+meta+KeyL`}],g=new Map(h.map(e=>[e.id,e])),_=typeof window<`u`&&c()!==void 0;function v(e,t=_){return t&&e.desktopBinding?e.desktopBinding:e.defaultBinding}function y(e){let t=e.code;if(!t||/^(Control|Alt|Shift|Meta)(Left|Right)$/.test(t))return null;let n=[];return e.ctrlKey&&n.push(`ctrl`),e.altKey&&n.push(`alt`),e.shiftKey&&n.push(`shift`),e.metaKey&&n.push(`meta`),n.length===0?null:(n.push(t),n.join(`+`))}var b={ctrl:`⌃`,alt:`⌥`,shift:`⇧`,meta:`⌘`},x={Comma:`,`,Period:`.`,Backquote:"`",Slash:`/`,Backslash:`\\`,Minus:`-`,Equal:`=`,Space:`␣`,Enter:`↵`,Escape:`Esc`,Tab:`⇥`,BracketLeft:`[`,BracketRight:`]`};function S(e){return e.startsWith(`Key`)?e.slice(3):e.startsWith(`Digit`)?e.slice(5):x[e]??e}function C(e){if(!e)return`—`;let t=e.split(`+`),n=t.pop()??``;return t.map(e=>b[e]??e).join(``)+S(n)}var w=new Map;function T(e,t){return w.set(e,t),()=>{w.get(e)===t&&w.delete(e)}}var E=e=>w.get(e),D=e=>g.get(e);function O(e,t){return e.hold===!0||e.id===`editor.save`||t&&e.editor!==!0}var k={},A=new Set,j=M();function M(){let e={};for(let t of h)e[t.id]=k[t.id]||v(t);return e}function N(e){k=e??{},j=M(),A.forEach(e=>e())}var P=e=>j[e]??``;function F(e){for(let[t,n]of Object.entries(j))if(n===e)return t}function I(e){return C(L()[e]??``)}function L(){return(0,s.useSyncExternalStore)(e=>(A.add(e),()=>A.delete(e)),()=>j)}var R=500,z=1e4;function B(e,t){return`${e} ${t}`}var V=new class{ws=null;open=!1;backoff=R;reconnectTimer=null;theme=null;terminals=new Map;notificationListeners=new Set;statusListeners=new Set;renameListeners=new Set;accountListeners=new Set;switchListeners=new Set;sessionsChangedListeners=new Set;hostUpdatesListeners=new Set;connectionListeners=new Set;shellWaiters=new Map;attach(e,t,n,r,i){let a={session:e,term:t,cols:n,rows:r,handlers:i,ready:!1,live:!1,pendingResize:!1};return this.terminals.set(B(e,t),a),this.ensureConnected(),this.open&&this.send({t:`attach`,session:e,term:t,cols:n,rows:r}),()=>this.detach(e,t)}detach(e,t){this.terminals.delete(B(e,t))&&this.open&&this.send({t:`detach`,session:e,term:t})}write(e,t,n){this.open&&this.terminals.get(B(e,t))?.ready&&this.send({t:`stdin`,session:e,term:t,data:n})}resize(e,t,n,r){let i=this.terminals.get(B(e,t));i&&(i.cols=n,i.rows=r,this.open&&i.ready?this.send({t:`resize`,session:e,term:t,cols:n,rows:r}):i.pendingResize=!0)}spawnShell(e){return this.ensureConnected(),this.open?new Promise((t,n)=>{let r=this.shellWaiters.get(e)??[];r.push({resolve:t,reject:n}),this.shellWaiters.set(e,r),this.open&&this.send({t:`spawn-shell`,session:e})}):Promise.reject(Error(`Connection is unavailable`))}killShell(e,t){this.open&&this.send({t:`kill-shell`,session:e,term:t})}onStatus(e){return this.statusListeners.add(e),this.ensureConnected(),()=>this.statusListeners.delete(e)}onAgentNotification(e){return this.notificationListeners.add(e),this.ensureConnected(),()=>this.notificationListeners.delete(e)}onRenamed(e){return this.renameListeners.add(e),this.ensureConnected(),()=>this.renameListeners.delete(e)}onAccount(e){return this.accountListeners.add(e),this.ensureConnected(),()=>this.accountListeners.delete(e)}onSessionSwitched(e){return this.switchListeners.add(e),this.ensureConnected(),()=>this.switchListeners.delete(e)}onSessionsChanged(e){return this.sessionsChangedListeners.add(e),this.ensureConnected(),()=>this.sessionsChangedListeners.delete(e)}onConnectionChange(e){return this.connectionListeners.add(e),()=>this.connectionListeners.delete(e)}onHostUpdatesChanged(e){return this.hostUpdatesListeners.add(e),this.ensureConnected(),()=>this.hostUpdatesListeners.delete(e)}isConnected(){return this.open}reportTheme(e,t){this.theme&&this.theme.fg===e&&this.theme.bg===t||(this.theme={fg:e,bg:t},this.open&&this.send({t:`theme`,fg:e,bg:t}))}reset(){this.ws?.close()}switchHost(){let e=this.ws;this.ws=null,this.open=!1,this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.reconnectTimer=null,this.terminals.clear();for(let e of this.shellWaiters.values())for(let t of e)t.reject(Error(`Host changed`));this.shellWaiters.clear(),e?.close();for(let e of this.connectionListeners)e(!1)}ensureConnected(){this.ws||this.reconnectTimer||this.connect()}connect(){let e=a.get(),t=i();if(!e&&!t)return;let n=window.location.protocol===`https:`?`wss`:`ws`,o=t?t.socket():new WebSocket(`${n}://${window.location.host}/ws`);this.ws=o,o.addEventListener(`open`,()=>{if(this.ws!==o){o.close();return}t||o.send(JSON.stringify({t:`auth`,token:e}))}),o.addEventListener(`message`,e=>{if(this.ws!==o)return;let t;try{t=JSON.parse(String(e.data))}catch{return}if(t.t===`authenticated`){if(this.open)return;this.open=!0,this.backoff=R,this.send({t:`subscribe-status`}),this.theme&&this.send({t:`theme`,...this.theme});for(let e of this.terminals.values()){e.ready=!1,e.pendingResize=!1;let{session:t,term:n,cols:r,rows:i}=e;this.send({t:`attach`,session:t,term:n,cols:r,rows:i})}for(let e of this.connectionListeners)e(!0)}else this.open&&this.handle(t)}),o.addEventListener(`close`,e=>{if(this.ws!==o)return;let t=this.open;this.open=!1,this.ws=null;for(let e of this.shellWaiters.values())for(let t of e)t.reject(Error(`Connection lost; operation outcome is unknown`));if(this.shellWaiters.clear(),t)for(let e of this.connectionListeners)e(!1);if(e.code===4401&&e.reason===`browser_rejected`){r();return}this.scheduleReconnect()})}scheduleReconnect(){this.reconnectTimer||this.terminals.size===0&&this.statusListeners.size===0&&this.notificationListeners.size===0&&this.renameListeners.size===0&&this.accountListeners.size===0&&this.switchListeners.size===0&&this.sessionsChangedListeners.size===0||(this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},this.backoff),this.backoff=Math.min(this.backoff*2,z))}send(e){this.open&&this.ws?.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify(e))}handle(e){switch(e.t){case`agent-notification`:for(let t of this.notificationListeners)t(e);break;case`replay`:{let t=this.terminals.get(B(e.session,e.term));if(!t)break;if(t.ready=!0,t.pendingResize){t.pendingResize=!1;let{session:e,term:n,cols:r,rows:i}=t;this.send({t:`resize`,session:e,term:n,cols:r,rows:i})}t.handlers.onData(e.data,e.t);break}case`output`:this.terminals.get(B(e.session,e.term))?.handlers.onData(e.data,e.t);break;case`exit`:{let t=this.terminals.get(B(e.session,e.term));t&&(t.ready=!1,t.handlers.onExit?.(e.code)),e.term===`agent`&&t&&(t.live=!1);break}case`status`:{let t=[`starting`,`running`,`waiting_input`].includes(e.status);for(let n of this.terminals.values())if(!(n.session!==e.session||n.term!==`agent`)){if(t&&!n.live){n.ready=!1,n.pendingResize=!1;let{session:e,term:t,cols:r,rows:i}=n;this.send({t:`attach`,session:e,term:t,cols:r,rows:i})}n.live=t}for(let t of this.statusListeners)t({session:e.session,status:e.status,last_activity_at:e.last_activity_at});break}case`renamed`:for(let t of this.renameListeners)t({session:e.session,title:e.title,agent_title:e.agent_title,osc_title:e.osc_title});break;case`account`:for(let t of this.accountListeners)t({account_id:e.account_id,profile_id:e.profile_id,logged_in:e.logged_in});break;case`session-switched`:for(let t of this.switchListeners)t(e);break;case`sessions-changed`:for(let t of this.sessionsChangedListeners)t(e);break;case`host-updates-changed`:for(let e of this.hostUpdatesListeners)e();break;case`shell-spawned`:{let t=this.shellWaiters.get(e.session)?.shift();t&&t.resolve(e.term);break}case`notice`:(e.level===`warning`?o.warning:o.error)(e.title,{...e.detail===void 0?{}:{description:e.detail},duration:12e3});break;case`error`:o.error(`Connection error`,{description:e.message});break}}};export{u as _,F as a,c as b,D as c,O as d,T as f,I as g,L as h,m as i,E as l,v as m,h as n,y as o,N as p,p as r,C as s,V as t,P as u,f as v,l as x,d as y};
|
package/dist/public/index.html
CHANGED
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
// Storage disabled or unreadable: the module's own init still runs.
|
|
48
48
|
}
|
|
49
49
|
</script>
|
|
50
|
-
<script type="module" crossorigin src="/assets/index-
|
|
50
|
+
<script type="module" crossorigin src="/assets/index-Cg9SFK_d.js"></script>
|
|
51
51
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-QTnfLwEv.js">
|
|
52
52
|
<link rel="modulepreload" crossorigin href="/assets/react-CZI7_Jkm.js">
|
|
53
53
|
<link rel="modulepreload" crossorigin href="/assets/react-dom-cJyBB_A4.js">
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
<link rel="modulepreload" crossorigin href="/assets/theme-swfNLod9.js">
|
|
57
57
|
<link rel="modulepreload" crossorigin href="/assets/jsx-runtime-By8HlURe.js">
|
|
58
58
|
<link rel="modulepreload" crossorigin href="/assets/preload-helper-Czpn1I53.js">
|
|
59
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
59
|
+
<link rel="stylesheet" crossorigin href="/assets/index-D_XpA70m.css">
|
|
60
60
|
</head>
|
|
61
61
|
<body>
|
|
62
62
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@puddle-code/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.15",
|
|
4
4
|
"description": "puddle \u2014 self-hosted orchestrator for CLI coding agents: serves the cockpit UI and connects it to local or SSH hosts.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/PerceptronV/puddle-code#readme",
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ReleaseNotesDialog-BD0uYU6B.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-CZI7_Jkm.js","assets/jsx-runtime-By8HlURe.js","assets/purify.es-D8QhFVkO.js","assets/dialog-DtvE8ATK.js","assets/react-dom-cJyBB_A4.js","assets/createLucideIcon-C9A1vLE-.js","assets/dist-DZg8Dwbr.js","assets/x-DV6-RYI2.js","assets/dialog-BX0tebJL.css","assets/queue-BlrQxHDl.js","assets/markdown-it-CWoG9_Dn.js","assets/markdown-BaCjN652.js","assets/math-CSw6sgCC.js","assets/math-delimiters-BCnTi7Ii.js","assets/SettingsDialog-DwWcTOGl.js","assets/protocol-support-BwRR1kRO.js","assets/auth-C3ruG3fE.js","assets/api-CULxlzTe.js","assets/LazyTerminal-BjT3haSN.js","assets/preload-helper-Czpn1I53.js","assets/dist-Dac0re_p.js","assets/notification-delivery-14yN_sWJ.js","assets/theme-swfNLod9.js","assets/desktop-Bl69_YmL.js","assets/switch-DYr-iPWY.js","assets/dist-BeQvHdsz.js","assets/ws-CS9chtfK.js","assets/dist-BOS6OKSE.js","assets/notification-delivery-BZzMYzIP.css","assets/client-settings-BdKglwtW.js","assets/index-MjsHIzAR.js","assets/index-BfQvnKtf.css","assets/button-DtByPSFL.js","assets/select-CGxTz4dh.js","assets/chevron-down-HQLVE6o5.js","assets/code-Cf4ftdOa.js","assets/rotate-ccw-BI2k_h3A.js","assets/control-tray-c9uXOo-i.js","assets/control-tray-CG26TqqQ.css","assets/errors-efDAjyqa.js","assets/use-debounced-value-C86N-mOK.js","assets/popover-D5HmbdQ7.js","assets/CompilationCommandForm-DQjUhaHj.js","assets/SettingsDialog-CJX0gDhJ.css","assets/Dashboard-DyNOxwSR.js","assets/session-order-iVRWTB-C.js","assets/motion-Bd_MB9cH.js","assets/dist-B8heQ9Kq.js","assets/archive-i9DnVa-v.js","assets/expanding-content-xApnlOBO.js","assets/square-terminal-CIkfNq3I.js","assets/Workspace-CjOdyZwS.js","assets/forward-link-CAXhnLYS.js","assets/media-refresh-store-CYiYB60R.js","assets/use-ui-state-CyfRHVgg.js","assets/preview-kind-CPkO-rSz.js","assets/debounce-B9DrqirV.js","assets/arrow-down-CtYa-Aya.js","assets/whole-word-BJjKpISQ.js","assets/preferences-DC7PJ3Go.js","assets/copy-D0Theg4Q.js","assets/link-buffer-DcFk9vqt.js","assets/waves-horizontal-CLDJf7Dd.js","assets/view-state-store-DVvLMbeY.js","assets/drafts-B_tChlzR.js","assets/buffer-logic-BAkSBQT7.js","assets/scroll-restoration-wdDB8mmu.js","assets/Workspace-CuAYZ1-B.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./react-dom-cJyBB_A4.js";import{$ as r,A as i,At as a,B as o,Bt as s,C as c,E as l,Et as u,Ft as d,G as f,Gt as p,H as m,Ht as h,I as g,It as _,Jt as v,Kt as y,L as b,Lt as x,Mt as S,O as C,Ot as ee,Q as te,Rt as w,St as T,T as E,Ut as D,Vt as O,Z as k,at as ne,c as re,ct as ie,dt as ae,ft as oe,it as se,j as ce,k as le,kt as ue,lt as de,nt as fe,o as pe,q as me,qt as he,rt as ge,ut as _e,vt as ve,w as ye,zt as be}from"./protocol-support-BwRR1kRO.js";import{$ as xe,F as Se,K as Ce,Q as we,T as Te,Y as Ee,o as A,p as De,r as Oe,z as ke}from"./auth-C3ruG3fE.js";import{a as Ae,c as je,i as Me,o as Ne,u as Pe}from"./LazyTerminal-BjT3haSN.js";import{C as Fe,D as Ie,E as Le,N as Re,P as ze,T as Be,_ as Ve,a as He,d as Ue,g as We,h as Ge,i as Ke,j as qe,k as Je,l as Ye,m as Xe,o as Ze,p as Qe,s as $e,t as et,u as tt,w as nt}from"./notification-delivery-14yN_sWJ.js";import{i as rt,r as it,t as at}from"./client-settings-BdKglwtW.js";import{c as ot,n as st,r as ct,s as lt,t as ut}from"./theme-swfNLod9.js";import{t as dt}from"./jsx-runtime-By8HlURe.js";import{t as ft}from"./preload-helper-Czpn1I53.js";import{n as j}from"./api-CULxlzTe.js";import{n as pt,t as M}from"./desktop-Bl69_YmL.js";import{t as mt}from"./forward-link-CAXhnLYS.js";import{C as ht,S as gt,_ as _t,a as vt,b as N,c as yt,f as bt,h as xt,o as St,r as Ct,s as wt,v as Tt,w as Et,x as Dt,y as Ot}from"./session-order-iVRWTB-C.js";import{t as kt}from"./motion-Bd_MB9cH.js";import{n as P,t as F}from"./createLucideIcon-C9A1vLE-.js";import{o as At,r as jt,s as Mt,t as Nt}from"./dialog-DtvE8ATK.js";import{n as I,t as Pt}from"./dist-BOS6OKSE.js";import{a as Ft,h as L,i as R,o as It}from"./dist-Dac0re_p.js";import{n as Lt,r as Rt}from"./dist-BeQvHdsz.js";import{$ as zt,G as Bt,J as Vt,K as Ht,U as Ut,W as Wt,X as Gt,Y as Kt,Z as qt,at as z,d as Jt,et as Yt,f as Xt,h as B,i as Zt,it as V,m as Qt,nt as $t,ot as en,p as tn,q as nn,r as rn,rt as an,st as H,t as on,tt as sn}from"./use-ui-state-CyfRHVgg.js";import{n as cn,t as U}from"./button-DtByPSFL.js";import{c as ln,d as un,i as W,l as dn,o as fn,t as pn,u as mn}from"./switch-DYr-iPWY.js";import{t as hn}from"./copy-D0Theg4Q.js";import{n as gn,r as _n,t as vn}from"./expanding-content-xApnlOBO.js";import{t as yn}from"./square-terminal-CIkfNq3I.js";import{_ as bn,a as xn,c as Sn,d as G,f as Cn,g as wn,h as Tn,i as En,m as Dn,s as On,t as K,u as kn,v as q}from"./ws-CS9chtfK.js";import{t as An}from"./control-tray-c9uXOo-i.js";import{n as J}from"./errors-efDAjyqa.js";import{a as jn,c as Mn,i as Nn,n as Pn,o as Fn,r as In,s as Ln}from"./command--8Svn0Z-.js";import{n as Rn,r as zn,t as Bn}from"./popover-D5HmbdQ7.js";import{n as Vn,r as Hn,t as Un}from"./queue-BlrQxHDl.js";var Y=e(t(),1),X=dt();function Wn(){let[e,t]=(0,Y.useState)(`Opening forwarded application…`);return(0,Y.useEffect)(()=>{if(!/^\/forward\/([^/]+)\/(\d+)$/.exec(window.location.pathname)){t(`This forwarding link is invalid.`);return}let e=!0;return mt(new URL(window.location.href)).then(t=>{e&&window.location.replace(t)}).catch(()=>{e&&t(`The application is unavailable. Reconnect to Puddle and open this link again.`)}),()=>{e=!1}},[]),(0,X.jsx)(`p`,{className:`p-8 text-sm text-fg-secondary`,children:e})}var Gn=class extends v{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new a({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=Kn(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=Kn(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=Kn(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=Kn(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){_.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>s(t,e))}findAll(e={}){return this.getAll().filter(t=>s(e,t))}notify(e){_.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return _.batch(()=>Promise.all(e.map(e=>e.continue().catch(h))))}};function Kn(e){return e.options.scope?.id}var qn=class extends v{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??be(r,t),a=this.get(i);return a||(a=new S({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){_.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>O(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>O(e,t)):t}notify(e){_.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){_.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){_.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Jn=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new qn,this.#t=e.mutationCache||new Gn,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=he.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=d.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(p(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=x(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return _.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;_.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return _.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=_.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(h).catch(h)}invalidateQueries(e,t={}){return _.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=_.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(h)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(h)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(p(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(h).catch(h)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(h).catch(h)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return d.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(w(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{D(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(w(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{D(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=be(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===y&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Yn=class extends Y.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidUpdate(e){this.state.error!==null&&e.resetOn!==this.props.resetOn&&this.setState({error:null})}componentDidCatch(e,t){console.error(`Puddle: the ${this.props.scope} crashed`,e,t.componentStack)}render(){let{error:e}=this.state;return e===null?this.props.children:(0,X.jsxs)(`div`,{className:`flex h-full min-h-40 flex-col items-center justify-center gap-4 px-8 py-10 text-center`,children:[(0,X.jsxs)(`p`,{className:`text-sm text-fg`,children:[`The `,this.props.scope,` stopped rendering.`]}),(0,X.jsx)(`p`,{className:`max-w-lg font-mono text-2xs leading-relaxed text-interrupted`,children:e.message||String(e)}),(0,X.jsx)(`p`,{className:`max-w-sm text-2xs leading-relaxed text-fg-muted`,children:`Your sessions and their worktrees are on the daemon and untouched; the layout is saved. The console has the full stack.`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>this.setState({error:null}),className:`text-2xs font-medium text-fg-gold transition-colors hover:underline`,children:`Try again`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`text-2xs text-fg-muted transition-colors hover:text-fg`,children:`Reload`})]})]})}};function Xn(){return(0,X.jsx)(Pt,{theme:(0,Y.useSyncExternalStore)(lt,ct),position:`bottom-right`,toastOptions:{style:{background:`var(--bg-elevated)`,border:`none`,boxShadow:`var(--ui-overlay-shadow)`,borderRadius:`var(--ui-surface-radius)`,outline:`1px solid var(--border)`,color:`var(--text-primary)`},classNames:{description:`whitespace-pre-wrap break-words font-mono text-2xs leading-snug max-h-40 overflow-y-auto`}}})}function Zn(){return(0,X.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,X.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-24`,children:[(0,X.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 text-sm leading-relaxed text-fg-secondary`,children:[(0,X.jsxs)(`p`,{children:[`Authorise this browser by running`,` `,(0,X.jsx)(`span`,{className:`font-mono text-accent`,children:`puddle launch`}),` in a terminal.`]}),(0,X.jsx)(`p`,{children:`Use the link it opens. Your sessions, drafts and layouts stay in place.`})]})]})})}var Qn=e(n(),1),$n=`a, button, [role="button"], [role="slider"], input, select, textarea, summary, label, [onclick], .cursor-pointer`,er=`.monaco-editor`;function tr(e,t){return e?.closest(er)&&!e.closest(t)?`text`:e?.closest($n)?`interactive`:`default`}function nr(e,t=`.no-custom-caret`){(0,Y.useEffect)(()=>{let n=e.current;if(!n)return;let r=window.matchMedia(`(pointer: fine)`),i=0,a=null,o=null,s=!0,c=!1,l=new MutationObserver(()=>d()),u=()=>{a&&!i&&(i=requestAnimationFrame(p))},d=()=>{s=!0,c=!0,u()},f=()=>{cancelAnimationFrame(i),i=0,a=null,o=null,s=!0,l.disconnect(),n.style.opacity=`0`},p=()=>{if(i=0,!a)return;let{x:e,y:u}=a,d=c?document.elementFromPoint(e,u):a.target;if(a.target=d,c=!1,d instanceof HTMLIFrameElement||!r.matches){f();return}if(n.style.transform=`translate3d(${e}px, ${u}px, 0) translate(-50%, -50%)`,n.style.opacity=`1`,!s&&d===o)return;if(s=!1,o=d,l.disconnect(),d&&d!==n&&!n.contains(d)){l.observe(d,{attributes:!0,childList:!0});for(let e of d.childNodes)e.nodeType===Node.TEXT_NODE&&l.observe(e,{characterData:!0});for(let e=d.parentElement;e;e=e.parentElement)l.observe(e,{attributes:!0,childList:!0})}l.observe(document.head,{attributes:!0,childList:!0,characterData:!0,subtree:!0});let p=d?.closest(er),m=tr(d,t),h=m===`text`,g=m===`interactive`,_=h;if(h&&p){let e=getComputedStyle(p);n.style.setProperty(`--custom-cursor-caret-height`,`${Math.round(Number.parseFloat(e.fontSize)*1.3)}px`)}else if(!g&&d&&!d.closest(t)&&Array.from(d.childNodes).some(e=>e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())){let e=getComputedStyle(d);e.userSelect!==`none`&&(_=!0,n.style.setProperty(`--custom-cursor-caret-height`,`${Math.round(Number.parseFloat(e.fontSize)*1.3)}px`))}n.classList.toggle(`is-interactive`,g),n.classList.toggle(`is-text`,_)},m=e=>{if(e.pointerType===`touch`||!r.matches){f();return}a={x:e.clientX,y:e.clientY,target:e.target instanceof Element?e.target:null},c=!1,u()},h=()=>{r.matches?d():f()};return window.addEventListener(`pointermove`,m,{passive:!0}),document.documentElement.addEventListener(`pointerleave`,f),window.addEventListener(`blur`,f),window.addEventListener(`resize`,d),document.addEventListener(`scroll`,d,!0),document.addEventListener(`focusin`,d),document.addEventListener(`focusout`,d),document.addEventListener(`pointerdown`,d),document.addEventListener(`pointerup`,d),r.addEventListener(`change`,h),document.fonts.addEventListener(`loadingdone`,d),()=>{window.removeEventListener(`pointermove`,m),document.documentElement.removeEventListener(`pointerleave`,f),window.removeEventListener(`blur`,f),window.removeEventListener(`resize`,d),document.removeEventListener(`scroll`,d,!0),document.removeEventListener(`focusin`,d),document.removeEventListener(`focusout`,d),document.removeEventListener(`pointerdown`,d),document.removeEventListener(`pointerup`,d),r.removeEventListener(`change`,h),document.fonts.removeEventListener(`loadingdone`,d),f()}},[t,e])}var rr=[`top`,`right`,`bottom`,`left`];function ir(){let e=(0,Y.useRef)(null);return nr(e),(0,X.jsx)(`div`,{ref:e,className:`custom-cursor drafting-cursor`,"aria-hidden":`true`,children:rr.map(e=>(0,X.jsx)(`span`,{className:`drafting-cursor-tick`,"data-side":e},e))})}function ar(){let e=(0,Y.useRef)(null);return nr(e),(0,X.jsx)(`div`,{ref:e,className:`custom-cursor invert-cursor`,"aria-hidden":`true`})}var or=`h1, h2, h3, h4, h5, h6, .no-rangefinder-caret`,Z=40.5,Q=4.05,sr=Q*Math.sqrt(3)/2;function cr(){let e=[],t=[],n=Z/2,r=Math.ceil(n/sr)+1,i=e=>Math.round(e*100)/100,a=e=>`M${e.map(([e,t])=>`${i(e)} ${i(t)}`).join(`L`)}Z`;for(let i=-r;i<r;i+=1){let o=n+i*sr,s=o+sr,c=(i%2+2)%2*(Q/2);for(let i=-r;i<r;i+=1){let r=n+i*Q+c,l=[[r+Q/2,o],[r,s],[r+Q,s]],u=[[r+Q/2,o],[r+3*Q/2,o],[r+Q,s]],d=e=>{let t=e.map(([e])=>e),n=e.map(([,e])=>e);return Math.max(...t)>0&&Math.min(...t)<Z&&Math.max(...n)>0&&Math.min(...n)<Z};d(l)&&e.push(a(l)),d(u)&&t.push(a(u))}}return{light:e.join(``),dark:t.join(``)}}var lr=cr();function ur(){let e=(0,Y.useRef)(null);return nr(e,or),(0,X.jsx)(`div`,{ref:e,className:`custom-cursor rangefinder-cursor`,"aria-hidden":`true`,children:(0,X.jsxs)(`svg`,{className:`rangefinder-cursor-facets`,viewBox:`0 0 ${Z} ${Z}`,focusable:`false`,children:[(0,X.jsx)(`path`,{className:`rangefinder-cursor-facet-light`,d:lr.light}),(0,X.jsx)(`path`,{className:`rangefinder-cursor-facet-dark`,d:lr.dark})]})})}function dr(){let{cursorPackage:e}=rt(),t=null;switch(e){case`rangefinder`:t=(0,X.jsx)(ur,{});break;case`drafting`:t=(0,X.jsx)(ir,{});break;case`invert`:t=(0,X.jsx)(ar,{});break;case`system`:return null}return(0,Qn.createPortal)(t,document.body)}var fr=F(`corner-down-left`,[[`path`,{d:`M20 4v7a4 4 0 0 1-4 4H4`,key:`6o5b7l`}],[`path`,{d:`m9 10-5 5 5 5`,key:`1kshq7`}]]),pr=F(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),mr=F(`monitor-cog`,[[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`m14.305 7.53.923-.382`,key:`1mlnsw`}],[`path`,{d:`m15.228 4.852-.923-.383`,key:`82mpwg`}],[`path`,{d:`m16.852 3.228-.383-.924`,key:`ln4sir`}],[`path`,{d:`m16.852 8.772-.383.923`,key:`1dejw0`}],[`path`,{d:`m19.148 3.228.383-.924`,key:`192kgf`}],[`path`,{d:`m19.53 9.696-.382-.924`,key:`fiavlr`}],[`path`,{d:`m20.772 4.852.924-.383`,key:`1j8mgp`}],[`path`,{d:`m20.772 7.148.924.383`,key:`zix9be`}],[`path`,{d:`M22 13v2a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7`,key:`1tnzv8`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}]]),hr=F(`notebook-pen`,[[`path`,{d:`M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4`,key:`re6nr2`}],[`path`,{d:`M2 6h4`,key:`aawbzj`}],[`path`,{d:`M2 10h4`,key:`l0bgd4`}],[`path`,{d:`M2 14h4`,key:`1gsvsf`}],[`path`,{d:`M2 18h4`,key:`1bu2t1`}],[`path`,{d:`M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z`,key:`pqwjuv`}]]),gr=F(`save`,[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]),_r=F(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),vr=F(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]);function yr(){let e=_e(),t=b(),[n,r]=(0,Y.useState)(``),[i,a]=(0,Y.useState)(ke),o=()=>{n.trim()&&t.mutate({name:n.trim(),branch_prefix:i.trim()},{onSuccess:e=>bn(e.id)})},s=(e.data?.length??0)>0;return(0,X.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-ground`,children:(0,X.jsxs)(`div`,{className:`flex w-full max-w-md flex-col gap-10 px-8 pb-16`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`h1`,{className:`font-mono text-2xl font-semibold text-fg`,children:`Puddle`}),(0,X.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Who is working?`})]}),s&&(0,X.jsx)(`div`,{className:`flex flex-col`,children:e.data.map(e=>(0,X.jsxs)(`button`,{onClick:()=>bn(e.id),className:`flex items-center gap-3 rounded-md px-3 py-2.5 text-left transition-colors hover:bg-elevated active:bg-border/70`,children:[(0,X.jsx)(Je,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,X.jsx)(`span`,{className:P(`text-base`,Ae(e.icon_colour)||`text-fg`),style:Ne(e.icon_colour),children:e.name}),e.branch_prefix&&(0,X.jsxs)(`span`,{className:`ml-auto text-2xs text-fg-muted`,children:[e.branch_prefix,`…`]})]},e.id))}),(0,X.jsxs)(`form`,{className:`flex flex-col gap-5`,onSubmit:e=>{e.preventDefault(),o()},children:[s&&(0,X.jsx)(`p`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`or create a profile`}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(Pe,{htmlFor:`profile-name`,children:`Name`}),(0,X.jsx)(R,{id:`profile-name`,placeholder:`e.g. alice`,value:n,onChange:e=>r(e.target.value),className:`h-10`,autoFocus:!s})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(Pe,{htmlFor:`branch-prefix`,children:`Branch prefix`}),(0,X.jsx)(R,{id:`branch-prefix`,placeholder:`no prefix`,value:i,onChange:e=>a(e.target.value),className:`h-10`})]}),t.error&&(0,X.jsx)(`p`,{className:`text-xs text-danger`,children:t.error.message}),(0,X.jsx)(U,{type:`submit`,size:`lg`,className:`self-start px-6`,disabled:!n.trim()||t.isPending,children:`Create profile`})]})]})})}function br({kind:e,colour:t,onRename:n,onColour:r,custom:i=!0,pending:a=!1,onUpdates:o}){let[s,c]=(0,Y.useState)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(St,{children:[(0,X.jsxs)(wt,{onSelect:n,children:[(0,X.jsx)(je,{}),`Rename `,e]}),(0,X.jsxs)(wt,{onSelect:()=>c(!0),children:[(0,X.jsx)(mn,{}),`Change `,e,` colour`]}),o&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(yt,{}),(0,X.jsxs)(wt,{onSelect:o,children:[(0,X.jsx)(dn,{}),`Host updates`]})]})]}),(0,X.jsx)(Nt,{open:s,onOpenChange:c,children:(0,X.jsxs)(jt,{children:[(0,X.jsx)(At,{children:(0,X.jsx)(Mt,{children:e===`host`?`Host accent`:`Profile colour`})}),(0,X.jsx)(Me,{value:t,onChange:r,onCustomChange:i?r:void 0,disabled:a,label:e===`host`?`Host accent`:`Profile colour`})]})})]})}function xr(){let e=k(),{icon:t}=Ie(),n=q(),r=Dn()[`host.peek`],{showHostOnFocus:i}=rt(),[a,o]=(0,Y.useState)(null),s=/Mac/.test(navigator.platform),c=(0,Y.useRef)(!1),l=(0,Y.useRef)(-1/0);return(0,Y.useEffect)(()=>{let e,t=document.hidden||!document.hasFocus(),n=-1/0,a,u=()=>{clearTimeout(e),e=void 0},d=()=>{u(),c.current=!1,o(null)},f=()=>{t=!0,d()},p=()=>{if(document.hidden)return;let r=performance.now(),a=r-l.current>=(s?750:250);l.current=r;let f=t;t=!1,!(!f||!a||!i||c.current)&&(n=r,u(),o(`focus`),e=setTimeout(()=>{if(!s||kt())return d();o(`focus-closing`),e=setTimeout(d,120)},s?400:1200))},m=t=>{t instanceof KeyboardEvent&&[`Meta`,`Alt`,`Control`,`Shift`].includes(t.key)||t.type===`pointerdown`&&performance.now()-n<100||e!==void 0&&d()},h=r?.split(`+`)??[],g=h.at(-1),_={Meta:`meta`,Control:`ctrl`,Alt:`alt`,Shift:`shift`},v=e=>{c.current&&(e.key===`Escape`&&(e.preventDefault(),e.stopPropagation()),(e.type===`keyup`&&(e.code===g||h.includes(_[e.key]??_[e.code.replace(/(Left|Right)$/,``)]??``))||e.key===`Escape`||h.includes(`meta`)&&!e.metaKey||h.includes(`ctrl`)&&!e.ctrlKey||h.includes(`alt`)&&!e.altKey||h.includes(`shift`)&&!e.shiftKey)&&d())},y=()=>{document.hidden?f():p()},b=G(`host.peek`,()=>{c.current||document.hidden||(u(),c.current=!0,o(`shortcut`))});window.addEventListener(`keyup`,v,!0),window.addEventListener(`keydown`,v,!0),window.addEventListener(`blur`,f),window.addEventListener(`pagehide`,f),window.addEventListener(`focus`,p),window.addEventListener(`keydown`,m,!0),window.addEventListener(`pointerdown`,m,!0),window.addEventListener(`wheel`,m,{passive:!0,capture:!0}),document.addEventListener(`visibilitychange`,y);let x=M()?.onWindowFocusChange?.(e=>{let n=e!==a;a=e,e?n&&(t=!0,p()):f()});return()=>{x?.(),b(),window.removeEventListener(`keyup`,v,!0),window.removeEventListener(`keydown`,v,!0),window.removeEventListener(`blur`,f),window.removeEventListener(`pagehide`,f),window.removeEventListener(`focus`,p),window.removeEventListener(`keydown`,m,!0),window.removeEventListener(`pointerdown`,m,!0),window.removeEventListener(`wheel`,m,!0),document.removeEventListener(`visibilitychange`,y),d()}},[r,s,n,i]),a?(0,Qn.createPortal)((0,X.jsx)(`div`,{"data-host-peek":!0,"data-state":a===`focus-closing`?`closed`:a===`focus`&&s?`instant-open`:`open`,className:`overlay-backdrop-motion fixed inset-0 z-[200] flex items-center justify-center p-8 text-fg backdrop-blur-[8px]`,style:a===`shortcut`?void 0:{pointerEvents:`none`,...a===`focus-closing`?{animationFillMode:`forwards`,opacity:0}:{}},onPointerDown:e=>e.preventDefault(),role:`status`,"aria-live":`polite`,children:(0,X.jsxs)(`div`,{className:`flex max-w-full flex-col items-center gap-6 px-12 py-10 text-center`,children:[(0,X.jsx)(Le,{icon:t,className:`size-[clamp(4.5rem,13.5vmin,10.5rem)] shrink-0`}),(0,X.jsx)(`span`,{className:`max-w-full break-words font-sans text-[clamp(0.8333rem,1.75vw,1.75rem)] leading-tight font-medium`,children:E(e.data)??`Host`})]})}),document.body):null}function Sr(){let e=m().data?.protocol,t=e!==void 0&&(e.major>25||e.major===25&&e.minor>=5),{data:n}=u({queryKey:[`storage`],queryFn:()=>j(`GET`,`/api/storage`),enabled:t&&!A(),refetchInterval:1e4,retry:!1});if(!t||A()||!n)return null;let r=n.volumes.filter(e=>e.level!==`ok`);if(!n.logs_degraded&&!n.database_degraded&&r.length===0)return null;let i=r.some(e=>e.level===`critical`);return(0,X.jsxs)(`div`,{role:`status`,className:`flex shrink-0 items-start gap-2 px-3 py-2 text-xs text-warning`,children:[(0,X.jsx)(an,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[n.database_degraded&&(0,X.jsx)(`p`,{children:`Storage is full. Changes cannot be saved. Live session status may be unsaved.`}),n.logs_degraded&&(0,X.jsx)(`p`,{children:`Terminal history is temporarily not being saved. Live terminals remain connected.`}),i&&(0,X.jsx)(`p`,{children:`Storage is critically low. Free space or inodes before starting new sessions or worktrees.`}),r.length>0&&(0,X.jsx)(fn,{summary:`${r.length} storage ${r.length===1?`location needs`:`locations need`} attention`,children:(0,X.jsx)(`div`,{className:`max-h-32 overflow-y-auto pl-4`,children:r.map(e=>(0,X.jsxs)(`p`,{className:`break-all text-fg-secondary`,children:[e.level===`unknown`?`Could not check storage`:`Low storage`,` at`,` `,e.path,e.available_bytes!==null&&` · ${Math.round(e.available_bytes/1024**2).toLocaleString()} MiB available`,e.available_inodes!==null&&` · ${e.available_inodes.toLocaleString()} inodes available`]},e.path))})})]})]})}var Cr=new class{transport;reload;pause;phase=`idle`;pending=null;constructor(e=fetch,t=()=>window.location.reload(),n=e=>new Promise(t=>setTimeout(t,e))){this.transport=e,this.reload=t,this.pause=n}refresh(e=12e4){return this.pending||=this.run(e).finally(()=>{this.pending=null}),this.pending}async run(e){this.phase=`requesting`;let t={authorization:`Bearer ${Oe.get()??``}`,"content-type":`application/json`};try{let n=await this.transport(`/cockpit/refresh`,{method:`POST`,headers:t,signal:AbortSignal.timeout(1e4),body:JSON.stringify({refreshId:crypto.randomUUID()})});if(n.status!==202)throw Error(`refresh rejected`);let r=Te.parse(await n.json());this.phase=`waiting`;let i=Date.now()+e;for(;Date.now()<i;){await this.pause(1e3);try{let e=await this.transport(`/cockpit/status`,{headers:t,cache:`no-store`,signal:AbortSignal.timeout(3e3)});if(!e.ok)continue;let n=De.parse(await e.json());if(n.instance===r.instance||n.refreshId!==r.refreshId||n.upstream!==`ready`)continue;return this.phase=`complete`,this.reload(),!0}catch{}}}catch{}return this.phase=`failed`,!1}},wr=null;function Tr(e){return wr=e,()=>{wr===e&&(wr=null)}}function Er(){wr?.()}var Dr=new Set;function Or(){return[...Dr].flatMap(e=>e())}function kr({onNewSession:e,onNewProject:t}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(`commands`),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(!1),f=ht(),p=Et(),m=q(),h=p.id,g=oe(m??void 0),_=de(m??void 0),v=T(h),y=Gt();(0,Y.useEffect)(()=>G(`palette.toggle`,()=>r(e=>!e)),[]),(0,Y.useEffect)(()=>Yt(()=>r(!0)),[]),(0,Y.useEffect)(()=>{n||(a(`commands`),s(``),l(null),d(!1))},[n]);let b=(0,Y.useMemo)(()=>{let n=[],r=Ct((g.data??[]).filter(e=>!e.archived),_.data?.projectOrder??[]);for(let e of r)n.push({id:`project-${e.id}`,group:`Projects`,label:e.name,icon:_n,keywords:`switch project open`,run:()=>void f(`/project/${e.id}`)});for(let e of v.data??[])e.status!==`archived`&&n.push({id:`session-${e.id}`,group:`Sessions`,label:y(e),icon:yn,keywords:`switch session ${e.branch}`,run:()=>void f(`/project/${e.project_id}/session/${e.id}`)});return h!==void 0&&e&&n.push({id:`new-agent`,group:`Actions`,label:`New agent`,icon:un,keywords:`new agent create start session`,run:()=>e()},{id:`new-terminal`,group:`Actions`,label:`New terminal`,icon:yn,keywords:`new terminal create start shell session`,run:()=>e({kind:`terminal`})}),h!==void 0&&n.push({id:`open-path`,group:`Actions`,label:`Open path`,icon:_n,keywords:`open path file directory folder editor tree browse absolute relative home`,closeOnRun:!1,run:()=>{s(``),l(null),a(`path`)}}),t&&n.push({id:`new-project`,group:`Actions`,label:`New project`,icon:Rt,keywords:`new project open create repository repo workspace`,run:t}),n.push({id:`theme-dark`,group:`Theme`,label:`Switch theme: dark`,icon:Re,keywords:`switch theme dark appearance`,run:()=>void ut(`dark`)},{id:`theme-light`,group:`Theme`,label:`Switch theme: light`,icon:qe,keywords:`switch theme light appearance`,run:()=>void ut(`light`)},{id:`theme-system`,group:`Theme`,label:`Switch theme: system`,icon:mr,keywords:`switch theme system appearance`,run:()=>void ut(`system`)},{id:`open-settings`,group:`Actions`,label:`Settings`,icon:vr,keywords:`open settings preferences options configure`,run:()=>W()},{id:`switch-profile`,group:`Actions`,label:`Switch profile`,icon:ln,keywords:`switch profile identity user change`,run:()=>wn.set(null)},{id:`refresh-connection`,group:`Actions`,label:`Refresh connection`,icon:dn,keywords:`refresh connection reconnect restart cockpit tunnel ssh daemon`,run:()=>Er()}),[...n,...Or()]},[g.data,_.data?.projectOrder,v.data,h,f,e,t,y]),x=(0,Y.useMemo)(()=>{let e=new Map;for(let t of b){let n=e.get(t.group)??[];n.push(t),e.set(t.group,n)}return[...e.entries()]},[b]),S=async()=>{let e=o.trim();if(!(e===``||u)){d(!0),l(null);try{await qt(e),r(!1)}catch(e){l(e instanceof Error?e.message:`Could not open that path.`)}finally{d(!1)}}};return(0,X.jsxs)(Pn,{open:n,onOpenChange:r,children:[(0,X.jsx)(jn,{value:o,onValueChange:e=>{s(e),l(null)},placeholder:i===`path`?`Enter a path…`:`Type a command or search…`,onKeyDown:e=>{i===`path`&&(e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),S()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),a(`commands`),s(``),l(null)))}}),i===`path`?(0,X.jsx)(Ln,{children:(0,X.jsxs)(`div`,{className:`px-3 py-3 text-xs text-fg-muted`,children:[(0,X.jsx)(`p`,{children:`Relative paths start from the bound worktree or project. Absolute and ~ paths work too.`}),(0,X.jsx)(`p`,{className:c?`mt-2 text-danger`:`mt-2`,"aria-live":`polite`,children:c??(u?`Opening…`:`Press Enter to open.`)})]})}):(0,X.jsxs)(Ln,{children:[(0,X.jsx)(In,{children:`Nothing matches.`}),x.map(([e,t])=>(0,X.jsx)(Nn,{heading:e,children:t.map(e=>{let t=e.icon;return(0,X.jsxs)(Fn,{value:`${e.label} ${e.keywords??``}`,onSelect:()=>{e.closeOnRun!==!1&&r(!1),e.run()},children:[t&&(0,X.jsx)(t,{}),e.label,e.shortcut&&(0,X.jsx)(Mn,{children:e.shortcut})]},e.id)})},e))]})]})}function Ar(){let e=document.activeElement;return e instanceof Element&&e.closest(`.xterm`)!==null}function jr(){let e=document.activeElement;return e instanceof Element&&e.closest(`.monaco-editor`)!==null}function Mr(){let e=de(q()??void 0).data?.hotkeys;return(0,Y.useEffect)(()=>{Cn(e&&typeof e==`object`?e:void 0)},[e]),(0,Y.useEffect)(()=>G(`window.close`,()=>{let e=M();e?.closeWindow?e.closeWindow():window.close()}),[]),(0,Y.useEffect)(()=>{let e=e=>{if(e.target instanceof Element&&e.target.closest(`[data-hotkey-recording]`))return;let t=xn(e);if(!t)return;let n=En(t);if(!n)return;let r=On(n);if(!r||!kn(r,jr()))return;let i=Sn(n);i&&(e.preventDefault(),e.stopPropagation(),(!r.hold||!e.repeat)&&i())},t=e=>{let t=xn(e);if(!t)return;let n=En(t);if(!n)return;let r=On(n);if(!r||r.editor&&jr()||r.deferInTerminal&&Ar())return;let i=Sn(n);i&&(e.preventDefault(),i())};return window.addEventListener(`keydown`,e,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`keydown`,e,!0),window.removeEventListener(`keydown`,t)}},[]),null}var Nr=4e3;function Pr(){let[e,t]=(0,Y.useState)(`hidden`),n=(0,Y.useRef)(e);n.current=e,(0,Y.useEffect)(()=>{let e=null,r=K.onConnectionChange(r=>{if(r){e!==null&&clearTimeout(e),e=null,n.current===`lost`&&t(`hidden`);return}e!==null||n.current!==`hidden`||(e=setTimeout(()=>{e=null,n.current===`hidden`&&t(`lost`)},Nr))});return()=>{r(),e!==null&&clearTimeout(e)}},[]);let r=(0,Y.useCallback)(async()=>{n.current!==`refreshing`&&(t(`refreshing`),await Cr.refresh()||(I.error(`The cockpit has not come back — it may need a terminal (ssh re-auth): puddle refresh`),t(K.isConnected()?`hidden`:`lost`)))},[]);return(0,Y.useEffect)(()=>Tr(()=>void r()),[r]),e===`hidden`?null:(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 bg-elevated px-3 py-2`,children:[(0,X.jsx)(`span`,{className:`text-xs text-fg-secondary`,children:e===`refreshing`?`Restarting the cockpit.`:`Connection to the daemon lost.`}),e===`lost`&&(0,X.jsxs)(U,{size:`sm`,className:`ml-auto`,onClick:()=>void r(),children:[(0,X.jsx)(dn,{}),`Refresh connection`]})]})}function Fr({label:e,percentage:t,hint:n}){let r=Math.max(0,Math.min(100,t));return(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`w-24 shrink-0 truncate text-2xs text-fg-muted`,title:e,children:e}),(0,X.jsx)(`span`,{className:`relative h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-border`,children:(0,X.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full ${r>=90?`bg-danger`:r>=75?`bg-warning`:`bg-action`}`,style:{width:`${r}%`}})}),(0,X.jsxs)(`span`,{className:`shrink-0 text-2xs tabular-nums text-fg-muted`,children:[Math.round(r),`%`,n?` · ${n}`:``]})]})}function Ir(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Lr(e){if(e===null)return`never`;let t=new Date(e).getTime(),n=Math.max(0,Math.round((Date.now()-t)/1e3));if(n<60)return`just now`;let r=Math.round(n/60);if(r<60)return`${r}m ago`;let i=Math.round(r/60);return i<24?`${i}h ago`:`${Math.round(i/24)}d ago`}function Rr({account:e,onLogin:t,onStartSession:n,installed:r=!0}){let i=C(e.id),a=e.logged_in?n:r?t:null,o=i.data?.subscription;return(0,X.jsxs)(`div`,{className:`rounded-md px-2 py-2 transition-colors hover:bg-elevated`,children:[(0,X.jsxs)(`button`,{type:`button`,disabled:a===null,onClick:()=>a?.(),className:`flex w-full items-center gap-3 text-left disabled:cursor-default`,children:[(0,X.jsx)(`span`,{className:`size-2 shrink-0 rounded-full ${e.logged_in?`bg-success`:`bg-idle`}`,"aria-hidden":!0}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block truncate text-sm text-fg`,children:e.label}),(0,X.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[e.logged_in?`logged in`:`logged out`,i.data&&(0,X.jsxs)(X.Fragment,{children:[` · `,i.data.session_count,` session`,i.data.session_count===1?``:`s`,i.data.active_session_count>0&&` (${i.data.active_session_count} active)`,` · `,`last `,Lr(i.data.last_activity_at)]})]}),i.data?.agent_usage&&(0,X.jsxs)(`span`,{className:`block text-2xs text-fg-muted`,children:[Ir(i.data.agent_usage.input_tokens),` in ·`,` `,Ir(i.data.agent_usage.output_tokens),` out ·`,` `,Ir(i.data.agent_usage.cache_read_input_tokens),` cached ·`,` `,i.data.agent_usage.message_count,` msgs`]}),i.data?.live_usage?.context_used_percentage!=null&&(0,X.jsx)(`span`,{className:`mt-1 block`,children:(0,X.jsx)(Fr,{label:`context`,percentage:i.data.live_usage.context_used_percentage})})]}),(0,X.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted`,children:r?e.logged_in?n?`new agent`:``:(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-warning`,children:[(0,X.jsx)(ze,{className:`size-3`}),`sign in`]}):`unavailable`})]}),o!=null&&o.windows.length>0&&(0,X.jsx)(`div`,{className:`mt-2 flex flex-col gap-1 pl-5`,children:o.windows.map(e=>(0,X.jsx)(Fr,{label:e.label,percentage:e.used_percentage,hint:e.resets==null?void 0:`resets ${e.resets}`},e.key))})]})}function zr(){let[e,t]=(0,Y.useState)(!1),[n,a]=(0,Y.useState)(!1),o=q(),s=_e(),c=se(),l=s.data?.find(e=>e.id===o),u=le(o??void 0),d=i(),f=r(),{open:p,handler:m}=Kt(),[h,g]=(0,Y.useState)(null),_=e=>f.mutate(e.id,{onSuccess:t=>g({stream:t.stream,label:`${e.agent_type}/${e.label}`}),onError:e=>J(e)}),v=e=>{t(!1),p({accountId:e.id})},y=e=>{a(!1);let t=e.trim();!o||!t||t===l?.name||c.mutate({id:o,name:t},{onError:e=>J(e)})},b=`profile-trigger font-sans compact:h-7 compact:px-1.5`;return n&&l?(0,X.jsxs)(`div`,{className:cn({variant:`ghost`,size:`sm`,className:b}),style:Ne(l.icon_colour),children:[(0,X.jsx)(Je,{icon:l.icon,colour:l.icon_colour}),(0,X.jsx)(sn,{initial:l.name,maxLength:100,fitContent:!0,className:Ae(l.icon_colour),onCommit:y,onCancel:()=>a(!1)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(vt,{onOpenChange:e=>{e&&t(!1)},children:[(0,X.jsxs)(Bn,{open:e,onOpenChange:t,children:[(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(zn,{asChild:!0,children:(0,X.jsx)(bt,{asChild:!0,children:(0,X.jsxs)(U,{variant:`ghost`,size:`sm`,className:b,children:[(0,X.jsx)(Je,{icon:l?.icon,colour:l?.icon_colour}),(0,X.jsx)(`span`,{className:Ae(l?.icon_colour),style:Ne(l?.icon_colour),...$t(()=>{t(!1),a(!0)}),children:l?.name??`…`})]})})})}),(0,X.jsx)(z,{children:`Profile`})]}),(0,X.jsxs)(Rn,{className:`w-[28rem] max-w-[calc(100vw-1rem)]`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(d.data??[]).map(e=>{let t=u.data?.filter(t=>t.agent_type===e.id)??[];if(t.length===0)return null;let n=e.available!==!1;return(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsxs)(`span`,{className:`px-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:[e.display_name,!n&&(0,X.jsxs)(`span`,{className:`ml-2 normal-case tracking-normal text-fg-muted`,children:[`not installed — no `,e.binary??e.id,` on PATH`]})]}),t.map(e=>(0,X.jsx)(Rr,{account:e,onLogin:()=>_(e),onStartSession:m&&n?()=>v(e):null,installed:n},e.id))]},e.id)}),u.data?.length===0&&(0,X.jsx)(`p`,{className:`px-2 text-sm text-fg-muted`,children:`No accounts yet — add one in settings.`})]}),(0,X.jsxs)(`div`,{className:`mt-4 flex items-center gap-2`,children:[(0,X.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>{t(!1),W(`accounts`)},children:[(0,X.jsx)(Rt,{}),`Add account`]}),(0,X.jsxs)(U,{variant:`ghost`,size:`sm`,className:`ml-auto`,onClick:()=>{t(!1),wn.set(null)},children:[(0,X.jsx)(_r,{}),`Switch profile`]})]})]})]}),(0,X.jsx)(br,{kind:`profile`,colour:l?.icon_colour,onRename:()=>{t(!1),a(!0)},onColour:e=>{o&&c.mutate({id:o,icon_colour:e},{onError:J})},pending:c.isPending||!o})]}),h&&(0,X.jsx)(Fe,{stream:h.stream,label:h.label,onClose:()=>g(null)})]})}var Br=`desktop-update`;function Vr(){let e=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{let t=M();if(t?.updateReady===void 0||t.onUpdateReady===void 0)return;let n=t=>{e.current!==t&&(e.current=t,I(`Puddle ${t} is downloaded and ready.`,{id:Br,duration:1/0,closeButton:!0,action:{label:`Restart to update`,onClick:()=>{M()?.installUpdate?.(),I.loading(`Restarting into Puddle ${t}…`,{id:`${Br}-restarting`,duration:1/0})}}}))};return t.updateReady().then(e=>{e!==null&&n(e)}),t.onUpdateReady(n)},[]),null}var Hr=new We;function Ur({onReview:e}={}){let t=Xe(),n=Ue(),r=E(k().data),i=Ge();return Qe(),(0,Y.useEffect)(()=>{if(!(!n||!r||t.isError))for(let n of Hr.take(i,Ve(t.data))){let t=n.component===`daemon`?`Daemon`:`Runtime software`,a=`host-update-${i}-${n.component}-${n.version}`;I(`${r}: ${t} ${n.version} is available.`,{id:a,duration:1/0,closeButton:!0,action:{label:`Review update`,onClick:e??(()=>W(`host`))}})}},[t.data,t.isError,r,n,i,e]),null}function Wr({hostKey:e,enabled:t=!0}){let n=u({queryKey:[`host`],queryFn:async({signal:e})=>Ce.parse(await j(`GET`,`/api/host`,void 0,e)),staleTime:1/0,enabled:t&&!e,retry:!1}),r=e??(n.data?Un(n.data):void 0),i=A(),a=i?.generation,o=u({queryKey:[`release-notes`,r],queryFn:async({signal:e})=>{let t=Ee.parse(await j(`GET`,`/api/release-notes`,void 0,e));if(A()!==i||i?.generation!==a)throw Error(`Release notes connection changed`);return t},enabled:t&&!!r,staleTime:1/0,retry:!1});return(0,Y.useEffect)(()=>{t&&r&&o.data&&!o.isError&&Hn(r,o.data)},[t,r,o.data,o.isError]),null}var Gr=(0,Y.lazy)(()=>ft(()=>import(`./ReleaseNotesDialog-BD0uYU6B.js`).then(e=>({default:e.ReleaseNotesDialog})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])));function Kr({remote:e=!1}){let t=(0,Y.useSyncExternalStore)(Vn.subscribe,Vn.snapshot)[0];return(0,Y.useEffect)(()=>{let t=e?[`cockpit`,`remote`]:[`cockpit`];Vn.enqueue(`browser`,t.map(e=>({component:e,version:`0.4.13`,markdown:`## [0.4.13] — 2026-11-06
|
|
3
|
-
|
|
4
|
-
Include the cockpit fixes from v0.4.12, whose release workflow failed before publication.
|
|
5
|
-
|
|
6
|
-
### Cockpit
|
|
7
|
-
|
|
8
|
-
#### Fixed
|
|
9
|
-
|
|
10
|
-
- Use the lighter file-hover fill for accented form fields and inactive switches, preserving default controls and stronger island borders.
|
|
11
|
-
|
|
12
|
-
- Preserve the original default theme and soften preset/custom accent backgrounds to one-third strength. Keep reading areas and active tabs untinted, match pane frames to sidebars, and strengthen accent borders beyond all background layers.
|
|
13
|
-
|
|
14
|
-
- Keep Ripple active for Codex and other alternate-screen agents, rendering current screen contents with copyable text, Mermaid and LaTeX while preserving native CLI controls.
|
|
15
|
-
|
|
16
|
-
- Clicking, tapping or scrolling closed session transcripts no longer raises connection errors from restored terminal mouse reporting.
|
|
17
|
-
|
|
18
|
-
### Daemon
|
|
19
|
-
|
|
20
|
-
#### Fixed
|
|
21
|
-
|
|
22
|
-
- Restore selective component releases by validating packaged continuity against the manifest’s published daemon and runtime versions, including checksum-verified retained runtime downloads.
|
|
23
|
-
`})))},[e]),t?(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(Gr,{current:t})}):null}function qr(){let e=q(),t=_e().data?.find(t=>t.id===e),n=de(e??void 0),r=ve(e??void 0,void 0),i=rt(),a=Ze(),s=$e(),c=ne(e??``),l=se(),u=o(),[d,f]=(0,Y.useReducer)(e=>e+1,0);(0,Y.useEffect)(()=>lt(()=>f()),[]);let p=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{p.current=null},[t?.name]);let m=a.data?.available===!0?a.data.file:void 0,h=t!==void 0&&e!==null&&n.data!==void 0&&r.data!==void 0&&m!==void 0,g=t&&m?He(m,t.name):void 0,_=c.isPending||l.isPending||u.isPending||s.isPending||n.isFetching||r.isFetching;(0,Y.useEffect)(()=>{if(!h||!g?.enabled||_)return;let a={client:i,theme:ot(),profileSettings:n.data,profile:t,scratchpad:r.data},o={setClient:e=>it(e),setTheme:e=>{typeof e==`string`&&ut(e)},patchProfileSettings:e=>c.mutate(e),patchProfileColumns:t=>l.mutate({id:e,...t}),createScratchpad:t=>{for(let n of t)u.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},d=JSON.stringify(g.doc);if(p.current!==d){p.current=d,Ye(g.doc,o,a,g.groups);return}let f=tt(g.groups,a),m=JSON.stringify(f);m!==d&&(p.current=m,s.mutate({profile:t.name,entry:{...g,doc:f,updatedAt:new Date().toISOString()}}))})}function Jr(e){let t=t=>{let n=xe.safeParse(t);n.success&&e(n.data)},n=M()?.onNotificationClick?.((e,n)=>t(n)),r=e=>{e.data?.t===`notification-click`&&t(e.data.target)};return navigator.serviceWorker?.addEventListener(`message`,r),()=>{n?.(),navigator.serviceWorker?.removeEventListener(`message`,r)}}var Yr=5e3,Xr=`[data-notification-session]`;function Zr(e){let t=null,n=()=>{t=null},r=e=>e.target instanceof Element?e.target.closest(Xr):null,i=e=>{if(!e.isTrusted)return;let n=r(e),i=n?.dataset.notificationSession;t=n&&i?{element:n,session:i,at:performance.now()}:null},a=e=>{r(e)!==t?.element&&n()},o=[`pointerdown`,`keydown`,`input`,`paste`];for(let t of o)e.addEventListener(t,i,!0);return e.addEventListener(`focusin`,a,!0),e.addEventListener(`visibilitychange`,n),e.defaultView?.addEventListener(`blur`,n),{isInteracting(n){return t!==null&&t.session===n&&performance.now()-t.at<Yr&&e.visibilityState===`visible`&&e.hasFocus()&&t.element.isConnected&&t.element.dataset.notificationSession===n&&t.element.getClientRects().length>0},dispose(){n();for(let t of o)e.removeEventListener(t,i,!0);e.removeEventListener(`focusin`,a,!0),e.removeEventListener(`visibilitychange`,n),e.defaultView?.removeEventListener(`blur`,n)}}}var Qr=new Set,$r=e=>!!e&&Qr.has(e),ei=we.parse({});function ti(e){return e.prefs.muted_projects.includes(e.projectId)?{desktop:!1,sound:!1}:{desktop:e.prefs.desktop&&(e.permission===`granted`||e.permission===`unverified`)&&(e.prefs.when_focused||!e.sessionFocused),sound:e.prefs.sound}}function ni(e,t){for(let[,n]of e.getQueriesData({queryKey:[`sessions`]})){let e=n?.find(e=>e.id===t);if(e)return e}for(let[,n]of e.getQueriesData({queryKey:[`project`]})){let e=n?.sessions.find(e=>e.id===t);if(e)return e}}function ri(e){return e.title??e.agent_title??e.osc_title??e.id.slice(0,8)}function ii(){try{let e=new AudioContext,t=e.createGain();t.gain.value=.04,t.connect(e.destination);for(let[n,r]of[[880,0],[1318.5,.09]]){let i=e.createOscillator();i.type=`sine`,i.frequency.value=n,i.connect(t),i.start(e.currentTime+r),i.stop(e.currentTime+r+.12)}setTimeout(()=>void e.close(),400)}catch{}}function ai(){let e=ht(),t=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let e=Zr(document);return t.current=e,()=>{t.current=null,e.dispose()}},[]),(0,Y.useEffect)(()=>Jr(t=>{t.host||e(`/project/${t.project}/session/${t.session}`,{state:{notificationSession:t.session}})}),[e]),oi(t=>{e(`/project/${t.project_id}/session/${t.id}`,{state:{notificationSession:t.id}})},e=>t.current?.isInteracting(e.id)??!1)}function oi(e,t=()=>document.hasFocus()){let n=ue(),r=(0,Y.useRef)(e);r.current=e;let i=(0,Y.useRef)(t);i.current=t;let a=E(k().data)??`Puddle`,o=(0,Y.useRef)(a);(0,Y.useEffect)(()=>{document.title===o.current&&(document.title=a),o.current=a},[a]),(0,Y.useEffect)(()=>{let e=new Set,t=()=>{document.title=e.size>0?`(${e.size}) ${o.current}`:o.current},a=!0,s=async e=>{let t=ni(n,e.session);if(!t)try{t=(await c(n)).find(t=>t.id===e.session)}catch{return}if(!a||!t)return;let s=t,l,u;try{let e=await n.fetchQuery({queryKey:[`project`,s.project_id],queryFn:()=>j(`GET`,`/api/projects/${s.project_id}`),staleTime:1e4});if(!a)return;u=e.project;let t=u.profile_id,r=await n.fetchQuery({queryKey:[`profile-settings`,t],queryFn:()=>j(`GET`,`/api/profiles/${t}/settings`),staleTime:1e4});l=we.catch(ei).parse(r.notifications??{})}catch{return}if(!a)return;let d=ti({prefs:l,projectId:s.project_id,sessionFocused:i.current(s),permission:Ke()});d.sound&&ii(),d.desktop&&!$r(A()?.scope)&&await et({id:e.id?`puddle-event-${e.id}`:`puddle-agent-${s.id}`,title:e.content?.title??ri(s).slice(0,160),body:e.content?.body??(e.reason===`exited`?`Agent finished running`:`Waiting for your input`),target:{project:s.project_id,session:s.id,...A()?.notificationHost?{host:A().notificationHost}:{}}},()=>{a&&r.current(s)},{host:o.current,project:u})},l=K.onAgentNotification(e=>{s(e)}),u=K.onStatus(r=>{let i=e.has(r.session);r.status===`waiting_input`?e.add(r.session):e.delete(r.session),t(),!(r.status!==`waiting_input`||i)&&n.fetchQuery({queryKey:[`version`],queryFn:()=>j(`GET`,`/api/version`),staleTime:1/0}).then(e=>{if(!(e.protocol.major>22||e.protocol.major===22&&e.protocol.minor>=3))return s({session:r.session,reason:`waiting_input`})}).catch(()=>{})});return()=>{a=!1,u(),l(),document.title=o.current}},[n])}function si({initial:e,defaultScope:t,allowProject:n=!0,agents:r,onSave:i,onCancel:a}){let[o,s]=(0,Y.useState)(e?.title??``),[c,l]=(0,Y.useState)(e?.body??``),[u,d]=(0,Y.useState)(n?e?.scope??t:`profile`),[f,p]=(0,Y.useState)((e?.tags??[]).join(`, `)),[m,h]=(0,Y.useState)(e?.agent_type??null),g=()=>{let e=c.trim();e&&i({title:o.trim()||null,body:e,scope:u,tags:f.split(`,`).map(e=>e.trim()).filter(Boolean),agent_type:m})};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(R,{value:o,placeholder:`Title (optional)`,spellCheck:!1,onChange:e=>s(e.target.value),onKeyDown:e=>e.stopPropagation(),className:`h-9 text-sm font-medium`}),(0,X.jsx)(Ft,{autoFocus:!0,value:c,placeholder:`Prompt or note…`,spellCheck:!1,rows:10,onChange:e=>l(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`?a():e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&g()},className:`resize-y text-sm leading-relaxed`}),(0,X.jsx)(R,{value:f,placeholder:`tags, comma, separated`,spellCheck:!1,onChange:e=>p(e.target.value),onKeyDown:e=>e.stopPropagation(),className:`h-8 text-xs`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,X.jsxs)(`label`,{className:`flex items-center gap-1.5 text-2xs text-fg-secondary`,children:[(0,X.jsx)(pn,{checked:u===`profile`,onCheckedChange:e=>d(e?`profile`:`project`)}),`Profile-wide`]}),(0,X.jsx)(`div`,{className:`ml-auto flex items-center gap-1`,children:r.map(e=>(0,X.jsxs)(`button`,{type:`button`,title:e.display_name,"aria-pressed":m===e.id,onClick:()=>h(t=>t===e.id?null:e.id),className:P(`rounded-md p-1 transition-colors`,m===e.id?`bg-surface text-fg`:`text-fg-gold hover:bg-surface hover:text-fg`),children:[(0,X.jsx)(nn,{type:e.id,className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:e.display_name})]},e.id))})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,X.jsx)(U,{variant:`ghost`,size:`sm`,onClick:a,children:`Cancel`}),(0,X.jsx)(U,{size:`sm`,disabled:!c.trim(),onClick:g,children:`Save`})]})]})}function ci(){let e=Ht(),t=q(),n=Et().id,r=ve(t??void 0,n).data??[],a=i().data??[],s=o(),c=ie(),l=me(),u=Bt(),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(null);(0,Y.useEffect)(()=>G(`scratchpad.toggle`,Wt),[]),(0,Y.useEffect)(()=>{e||(f(null),m(null),g(null))},[e]);let x=(0,Y.useMemo)(()=>[...new Set(r.flatMap(e=>e.tags))].sort((e,t)=>e.localeCompare(t)),[r]),S=(0,Y.useMemo)(()=>[...new Set(r.map(e=>e.agent_type).filter(e=>e!==null))],[r]),C=p!==null||h!==null,ee=r.filter(e=>(p===null||e.tags.includes(p))&&(h===null||e.agent_type===h)),te=C?ee:y??r,w=e=>{t&&(s.mutate({profile_id:t,scope:e.scope,project_id:e.scope===`project`?n:void 0,title:e.title??void 0,body:e.body,tags:e.tags,agent_type:e.agent_type??void 0}),f(null))},T=(e,t)=>{c.mutate({id:e,scope:t.scope,project_id:t.scope===`project`?n??null:null,title:t.title,body:t.body,tags:t.tags,agent_type:t.agent_type}),f(null)},E=(e,t)=>{let n=y??r,i=n.findIndex(t=>t.id===e),a=n.findIndex(e=>e.id===t);if(i===-1||a===-1||i===a)return;let o=n.slice(),[s]=o.splice(i,1);o.splice(a,0,s),b(o)},D=()=>{let e=_,t=y;if(v(null),b(null),e===null||!t)return;let n=t.findIndex(t=>t.id===e);if(n===-1)return;let r=t[n-1],i=t[n+1],a=r?i?(r.position+i.position)/2:r.position+1:(i?i.position:0)-1;c.mutate({id:e,position:a})},O=e=>{navigator.clipboard?.writeText(e.body),I.success(`Copied to clipboard`)};return(0,X.jsxs)(Bn,{open:e,onOpenChange:Ut,children:[(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(zn,{asChild:!0,children:(0,X.jsxs)(U,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,X.jsx)(hr,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Scratchpad`})]})})}),(0,X.jsx)(z,{children:`Scratchpad`})]}),(0,X.jsxs)(Rn,{className:`w-[34rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,X.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Scratchpad`}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>f(d===`new`?null:`new`),className:P(It,`ml-auto`),children:[(0,X.jsx)(Rt,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`New entry`})]})]}),(x.length>0||S.length>0)&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:[x.map(e=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>m(t=>t===e?null:e),className:P(`rounded-full px-2 py-0.5 text-2xs transition-colors`,p===e?`bg-action text-action-ink`:`bg-surface text-fg-secondary hover:text-fg`),children:e},e)),S.map(e=>(0,X.jsx)(`button`,{type:`button`,"aria-pressed":h===e,onClick:()=>g(t=>t===e?null:e),className:P(`rounded-md p-1 transition-colors`,h===e?`bg-action text-action-ink`:`text-fg-gold hover:bg-surface`),children:(0,X.jsx)(nn,{type:e,className:`size-3.5`})},e))]}),(0,X.jsxs)(`div`,{className:`no-scrollbar max-h-[65vh] overflow-y-auto px-2 pb-3`,children:[(0,X.jsx)(vn,{expanded:d===`new`,children:d===`new`&&(0,X.jsx)(`div`,{className:`px-3 py-2`,children:(0,X.jsx)(si,{defaultScope:n?`project`:`profile`,allowProject:n!==void 0,agents:a,onSave:w,onCancel:()=>f(null)})})}),te.length===0&&d!==`new`&&(0,X.jsx)(`p`,{className:`px-3 py-3 text-sm text-fg-muted`,children:C?`Nothing matches this filter.`:`No entries yet — press + to add a reusable prompt or note.`}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:te.map(e=>(0,X.jsx)(`li`,{draggable:!C&&d===null,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,v(e.id)},onDragOver:t=>{_!==null&&(t.preventDefault(),_!==e.id&&E(_,e.id))},onDragEnd:D,className:P(`transition-opacity`,_===e.id&&`opacity-50`),children:(0,X.jsx)(vn,{expanded:d===e.id,children:d===e.id?(0,X.jsx)(`div`,{className:`px-3 py-2`,children:(0,X.jsx)(si,{initial:e,defaultScope:e.scope,allowProject:n!==void 0||e.scope===`project`,agents:a,onSave:t=>T(e.id,t),onCancel:()=>f(null)})}):(0,X.jsx)(li,{entry:e,onInsert:u?()=>{u(e.body),Ut(!1)}:null,onCopy:()=>O(e),onEdit:()=>f(e.id),onDelete:()=>l.mutate(e.id)})})},e.id))})]})]})]})}function li({entry:e,onInsert:t,onCopy:n,onEdit:r,onDelete:i}){let[a,o]=(0,Y.useState)(!1);return(0,X.jsxs)(`div`,{onClick:e=>{e.target.closest(`button`)||r()},className:`cursor-pointer rounded-md px-3 py-2.5 transition-colors hover:bg-surface`,children:[e.title&&(0,X.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.title}),(0,X.jsx)(`p`,{className:P(`line-clamp-3 whitespace-pre-wrap text-sm text-fg-secondary`,e.title&&`mt-0.5`),children:e.body}),a?(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:`Delete this entry? This can’t be undone.`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{o(!1),i()},className:P(L,`text-danger`),children:`Delete`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>o(!1),className:L,children:`Cancel`})]}):(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:e.scope===`profile`?`Profile-wide`:`Project`}),e.agent_type&&(0,X.jsx)(nn,{type:e.agent_type,className:`size-3 text-fg-gold`}),e.tags.map(e=>(0,X.jsx)(`span`,{className:`rounded-full bg-surface px-1.5 text-2xs text-fg-secondary`,children:e},e)),(0,X.jsxs)(An,{label:`Scratchpad entry actions`,className:`ml-auto`,children:[t&&(0,X.jsx)(ui,{icon:fr,label:`Insert into focused terminal`,onClick:t}),(0,X.jsx)(ui,{icon:hn,label:`Copy`,onClick:n}),(0,X.jsx)(ui,{icon:je,label:`Edit`,onClick:r}),(0,X.jsx)(ui,{icon:Lt,label:`Delete`,onClick:()=>o(!0)})]})]})]})}function ui({icon:e,label:t,onClick:n}){return(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:n,className:It,children:[(0,X.jsx)(e,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,X.jsx)(z,{children:t})]})}var di=Se.parse({});function fi(e,t){let[n,r]=(0,Y.useState)(null),i=ce(t).data,a=oe(e??void 0,t&&e!==null).data;return(0,Y.useEffect)(()=>{if(!t||e===null){r(null);return}let n=!1,i;try{i=on(sessionStorage.getItem(rn(e)))}catch{i={kind:`absent`}}if(i.kind===`present`){r(i.snapshot);return}return ye(e).then(e=>{n||r(e?e.ui_state:di)}).catch(()=>{n||r(di)}),()=>{n=!0}},[t,e]),(0,Y.useMemo)(()=>{if(!t||e===null||n===null)return null;let o=t=>{if(!i||!a)return!1;let{patch:o,projectBased:s}=Zt(n,t,{alive:new Set(i.filter(e=>e.status!==`archived`).map(e=>e.id)),sessionProject:new Map(i.map(e=>[e.id,e.project_id])),projectIds:a.map(e=>e.id),currentProject:null}),c={...n,...o};r(c),l(e,c).catch(e=>console.warn(`ui-state save failed: ${e.message}`));try{sessionStorage.setItem(rn(e),JSON.stringify(c))}catch(e){console.warn(`ui-state write failed: ${e.message}`)}return at().projectBasedLayout!==s&&it({projectBasedLayout:s}),!0},s=Object.fromEntries(Object.entries(n.project_layouts).map(([e,t])=>[e,{layoutRef:t.layout_ref,signature:B(t.layout_tree)}]));return(n.layout_mode??`profile`)===`project`?{headless:!0,scope:`project`,projectId:``,layoutRef:null,signature:B(null),slices:s,capture:()=>({layout_tree:null,active_session:null}),apply:o}:{scope:`profile`,projectId:``,layoutRef:n.layout_ref,signature:B(n.layout_tree),slices:s,capture:()=>({layout_tree:n.layout_tree,active_session:n.active_session}),apply:o}},[t,e,n,i,a])}var pi=B(null);function mi(){let e=Qt(),t=ht(),n=q(),r=tn(),i=fi(n,e&&r===null),a=r??i,o=te(n??void 0,void 0).data??[],s=oe(n??void 0,e&&n!==null).data??[],c=g(),l=ge(),u=f(),[d,p]=(0,Y.useState)(``),[m,h]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(null);(0,Y.useEffect)(()=>G(`layouts.toggle`,Xt),[]),(0,Y.useEffect)(()=>{e||(p(``),h(!1),v(null))},[e]);let y=a?.headless===!0,b=a===null||y?null:o.find(e=>e.id===a.layoutRef)??null,x=a!==null&&!y&&(b===null?a.signature!==pi:B(b.layout_tree)!==a.signature),S=e=>{let t=a?.slices?.[e];if(!t)return!1;let n=t.layoutRef===null?null:o.find(e=>e.id===t.layoutRef)??null;return n?B(n.layout_tree)!==t.signature:t.signature!==pi},C=e=>a===null?!1:e.scope===`profile`?a.scope===`profile`&&x:e.project_id===null?!1:a.scope===`project`?!y&&e.project_id===a.projectId?x:S(e.project_id):x||S(e.project_id),ee=e=>b!==null&&e.id===b.id,w=e=>(e===null?void 0:s.find(t=>t.id===e)?.name)??`Project`,T=a!==null&&!y&&a.scope===`project`?o.filter(e=>e.scope===`profile`||e.project_id===a.projectId):o,E=[...T.some(e=>e.scope===`profile`)?[{key:`profile`,name:`Profile-wide`}]:[],...[...new Set(T.flatMap(e=>e.project_id===null?[]:[e.project_id]))].map(e=>({key:e,name:w(e)})).sort((e,t)=>e.name.localeCompare(t.name))],D=_===null?T:_===`profile`?T.filter(e=>e.scope===`profile`):T.filter(e=>e.project_id===_),O=e=>a!==null&&e.scope===a.scope&&(a.scope===`profile`||e.project_id===a.projectId),k=(e,t,r)=>{!a||!n||c.mutate({profile_id:n,scope:a.scope,project_id:a.scope===`project`?a.projectId:void 0,name:e,...t},{onSuccess:e=>{r&&a.apply(e)},onError:e=>J(e)})},ne=e=>{if(!a)return;let t=O(e)?e:o.find(t=>t.name===e.name&&O(t));if(!t){k(e.name,a.capture(),!0);return}l.mutate({id:t.id,...a.capture()},{onSuccess:e=>a.apply(e),onError:e=>J(e)})},re=(e,t)=>k(t,{layout_tree:e.layout_tree,active_session:e.active_session},!1),ie=e=>{if(a){if(!a.apply(e)){I.error(`Workspace is still loading — try again in a moment`);return}e.project_id!==null&&e.project_id!==a.projectId&&t(`/project/${e.project_id}`),Jt(!1)}};return(0,X.jsxs)(Bn,{open:e,onOpenChange:Jt,children:[(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsx)(zn,{asChild:!0,children:(0,X.jsxs)(U,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,children:[(0,X.jsx)(pr,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Layouts`})]})})}),(0,X.jsx)(z,{children:`Layouts`})]}),(0,X.jsxs)(Rn,{className:`w-[26rem] max-w-[calc(100vw-1rem)] p-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-5 pb-2 pt-4`,children:[(0,X.jsx)(`span`,{className:`text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:`Layouts`}),a!==null&&!y&&(0,X.jsxs)(`button`,{type:`button`,onClick:()=>h(e=>!e),className:P(`inline-flex size-[var(--ui-control-height)] shrink-0 cursor-pointer items-center justify-center rounded-[var(--ui-radius)] text-fg transition-colors hover:bg-elevated disabled:pointer-events-none disabled:opacity-50`,`ml-auto`),children:[(0,X.jsx)(Rt,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Save the current layout as a new layout`})]})]}),(0,X.jsx)(vn,{expanded:a!==null&&!y&&(b===null||m),children:a===null?(0,X.jsx)(`p`,{className:`px-5 pb-3 text-sm text-fg-muted`,children:`Loading the profile’s layout state…`}):y?(0,X.jsx)(`p`,{className:`px-5 pb-3 text-sm text-fg-muted`,children:`Project-based layout is on — every project keeps its own layout. Open a project to name or save it; loading works from here.`}):(b===null||m)&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 px-5 pb-3`,children:[b===null&&(0,X.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:`Unnamed layout`}),(0,X.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:a.scope===`profile`?`Profile-wide`:`Project`}),(0,X.jsx)(`span`,{className:`ml-auto text-2xs text-interrupted`,children:`Unsaved`})]}),(0,X.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:e=>{e.preventDefault();let t=d.trim();t&&(k(t,a.capture(),!0),p(``),h(!1))},children:[(0,X.jsx)(R,{autoFocus:m,value:d,placeholder:b===null?`Name this layout…`:`Save as a new layout…`,spellCheck:!1,onChange:e=>p(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&h(!1)},className:`h-8 flex-1 text-sm`}),(0,X.jsx)(U,{size:`sm`,type:`submit`,disabled:!d.trim(),children:`Save`}),b!==null&&(0,X.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>h(!1),children:`Cancel`})]})]})}),E.length>1&&(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 px-5 pb-2`,children:E.map(e=>(0,X.jsx)(_i,{active:_===e.key,onClick:()=>v(t=>t===e.key?null:e.key),children:e.name},e.key))}),(0,X.jsxs)(`div`,{className:`no-scrollbar max-h-[60vh] overflow-y-auto px-2 pb-3`,children:[D.length===0&&(0,X.jsx)(`p`,{className:`px-3 py-3 text-sm text-fg-muted`,children:_===null?`No layouts yet — name and save the current layout to keep it.`:`Nothing matches this filter.`}),(0,X.jsx)(`ul`,{className:`flex flex-col`,children:D.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsx)(hi,{layout:e,projectLabel:e.scope===`profile`?null:w(e.project_id),isCurrent:ee(e),dirty:x,loadable:a!==null,savable:a!==null&&!y,confirmBeforeLoad:C(e),overwrites:O(e),onLoad:()=>ie(e),onRename:t=>l.mutate({id:e.id,name:t}),onDelete:()=>u.mutate(e.id),onSaveAs:()=>ne(e),onDuplicate:t=>re(e,t)})},e.id))})]})]})]})}function hi({layout:e,projectLabel:t,isCurrent:n,dirty:r,loadable:i,savable:a,confirmBeforeLoad:o,overwrites:s,onLoad:c,onRename:l,onDelete:u,onSaveAs:d,onDuplicate:f}){let[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(e.name),y=()=>{if(!(!i||h!==null)){if(o&&p!==`load`){m(`load`);return}m(null),c()}},b=t=>{m(null),v(t===`rename`?e.name:`${e.name} copy`),g(t)},x=()=>{if(n){d();return}m(`save`)},S=n?r?`unsaved`:`active`:null;return(0,X.jsxs)(`div`,{onClick:e=>{e.target.closest(`button, input`)||y()},className:P(`rounded-md px-3 py-2.5 transition-colors`,i&&`cursor-pointer hover:bg-surface`),children:[h===null?(0,X.jsxs)(`p`,{className:P(`flex items-baseline gap-2 text-sm font-medium`,S===`active`?`text-success`:S===`unsaved`?`text-interrupted`:`text-fg`),children:[e.name,S!==null&&(0,X.jsx)(`span`,{className:`text-2xs font-normal`,children:S===`active`?`Active`:`Unsaved`})]}):(0,X.jsxs)(`form`,{className:`flex items-center gap-1.5`,onSubmit:t=>{t.preventDefault();let n=_.trim();n&&(h===`rename`?n!==e.name&&l(n):f(n)),g(null)},children:[(0,X.jsx)(R,{autoFocus:!0,value:_,spellCheck:!1,onChange:e=>v(e.target.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&g(null)},className:`h-7 flex-1 text-sm`}),(0,X.jsx)(U,{size:`sm`,type:`submit`,disabled:!_.trim(),children:h===`rename`?`Rename`:`Save`})]}),p===`save`?(0,X.jsx)(gi,{question:s?`Overwrite “${e.name}” with the current layout?`:`Save the current layout as “${e.name}” here?`,verb:s?`Overwrite`:`Save`,onConfirm:()=>{m(null),d()},onCancel:()=>m(null)}):p===`delete`?(0,X.jsx)(gi,{question:`Delete this layout? This can’t be undone.`,verb:`Delete`,onConfirm:()=>{m(null),u()},onCancel:()=>m(null)}):p===`load`?(0,X.jsx)(gi,{question:`Loading discards unsaved layout changes.`,verb:`Load`,onConfirm:y,onCancel:()=>m(null)}):(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[t!==null&&(0,X.jsx)(`span`,{className:`text-2xs uppercase tracking-wide text-fg-muted`,children:t}),(0,X.jsxs)(An,{label:`Layout actions`,className:`ml-auto`,children:[a&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(vi,{icon:gr,label:n?`Save`:`Save the current layout as “${e.name}”`,onClick:x}),(0,X.jsx)(vi,{icon:hn,label:`Duplicate`,onClick:()=>b(`duplicate`)})]}),(0,X.jsx)(vi,{icon:je,label:`Rename`,onClick:()=>b(`rename`)}),(0,X.jsx)(vi,{icon:Lt,label:`Delete`,onClick:()=>m(`delete`)})]})]})]})}function gi({question:e,verb:t,onConfirm:n,onCancel:r}){return(0,X.jsxs)(`div`,{className:`mt-2 flex items-center gap-3`,children:[(0,X.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e}),(0,X.jsx)(`button`,{type:`button`,onClick:n,className:P(L,`text-danger`),children:t}),(0,X.jsx)(`button`,{type:`button`,onClick:r,className:L,children:`Cancel`})]})}function _i({active:e,onClick:t,children:n}){return(0,X.jsx)(`button`,{type:`button`,"aria-pressed":e,onClick:t,className:P(`rounded-full px-2 py-0.5 text-2xs transition-colors`,e?`bg-action text-action-ink`:`bg-surface text-fg-secondary hover:text-fg`),children:n})}function vi({icon:e,label:t,onClick:n}){return(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,onClick:n,className:It,children:[(0,X.jsx)(e,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:t})]})}),(0,X.jsx)(z,{children:t})]})}var $=M()!==void 0&&/Mac/.test(navigator.platform),yi=(0,Y.lazy)(()=>ft(()=>import(`./SettingsDialog-DwWcTOGl.js`).then(e=>({default:e.SettingsDialog})),__vite__mapDeps([16,1,2,17,18,3,19,20,21,7,5,6,8,9,10,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45])));function bi(){let e=ue();(0,Y.useEffect)(()=>{let t=t=>{for(let[n,r]of e.getQueriesData({queryKey:[`sessions`]}))r&&e.setQueryData(n,r.map(t));for(let[n,r]of e.getQueriesData({queryKey:[`project`]}))r&&e.setQueryData(n,{...r,sessions:r.sessions.map(t)})},n=K.onStatus(e=>t(t=>t.id===e.session?{...t,status:e.status,last_activity_at:e.last_activity_at}:t)),r=K.onRenamed(e=>t(t=>t.id===e.session?{...t,title:e.title,agent_title:`agent_title`in e?e.agent_title:t.agent_title,osc_title:`osc_title`in e?e.osc_title:t.osc_title}:t)),i=K.onAccount(t=>{for(let[n,r]of e.getQueriesData({queryKey:[`accounts`]}))r&&e.setQueryData(n,r.map(e=>e.id===t.account_id?{...e,logged_in:t.logged_in}:e))}),a=t=>{e.invalidateQueries({queryKey:[`sessions`]});for(let n of t)e.invalidateQueries({queryKey:[`project`,n]})},o=K.onSessionsChanged(e=>a(e.project_ids)),s=K.onSessionSwitched(e=>a([e.target_project]));return()=>{n(),r(),i(),o(),s()}},[e])}function xi(){let e=q(),t=ne(e??``),n=m().data?.protocol,r=Ie(),i=k(),a=fe(),[o,s]=(0,Y.useState)(!1),c=E(i.data),l=e=>{s(!1);let t=e.trim();t!==c&&a.mutate({displayName:t===i.data?.hostname?``:t},{onError:e=>J(e)})},u=(0,X.jsx)(Le,{icon:r.icon}),d=P(`host-identity flex h-full shrink-0 items-center gap-2 px-4`,$&&`[-webkit-app-region:no-drag]`),f=`truncate font-sans text-xs font-normal`;return o&&c!==void 0?(0,X.jsxs)(`div`,{className:d,children:[u,(0,X.jsx)(sn,{initial:i.data?.displayName??c,maxLength:64,className:P(f,`w-40`),onCommit:l,onCancel:()=>s(!1)})]}):(0,X.jsxs)(vt,{children:[(0,X.jsx)(bt,{asChild:!0,children:(0,X.jsxs)(Tt,{to:`/`,className:P(d,`hover:bg-elevated focus-visible:bg-elevated`),title:`All projects`,children:[u,c!==void 0&&(0,X.jsx)(`span`,{className:f,...$t(()=>s(!0)),children:c})]})}),(0,X.jsx)(br,{kind:`host`,colour:r.colour,onRename:()=>s(!0),onColour:n=>{e&&t.mutate({hostColour:n},{onError:J})},pending:t.isPending||!e,custom:pe(n),onUpdates:()=>W(`host`)})]})}function Si(){let e=Et(),t=Tn(`palette.toggle`),n=ae(e.id).data?.project,r=n!==void 0&&n.id===e.id?n.name:void 0;return(0,X.jsx)(`button`,{type:`button`,onClick:zt,className:P(`flex h-full min-w-0 w-full cursor-pointer items-center justify-center gap-2 bg-transparent px-2 font-normal text-fg-muted transition-colors hover:bg-elevated focus-visible:bg-elevated`,$&&`[-webkit-app-region:no-drag]`),children:(0,X.jsxs)(`span`,{className:P(`pointer-events-none absolute left-1/2 top-1/2 flex max-w-[40%] -translate-x-1/2 -translate-y-1/2 items-center gap-2`,r&&Ae(n?.colour)),style:r?Ne(n?.colour):void 0,children:[(0,X.jsx)(`span`,{className:`truncate text-xs`,children:r??`Puddle`}),(0,X.jsx)(`span`,{className:`shrink-0 text-2xs`,children:t})]})})}function Ci(){let e=Ie(),{fullScreen:t,animate:n}=pt(),r=$&&!t;return(0,X.jsxs)(`header`,{"data-host-colour":e.colour??void 0,onClick:e=>{let t=e.target;e.currentTarget.contains(t)&&(t.closest(`[data-header-section], [aria-label="Workspace controls"], button, a, input`)||zt())},className:P(`host-header island-outline relative grid shrink-0 cursor-pointer grid-cols-[auto_1px_minmax(0,1fr)_1px_auto] items-center overflow-hidden rounded-[var(--ui-surface-radius)] bg-surface`,`h-9`,!$&&`mx-1.5 mt-1.5`,r&&`pl-[84px] [-webkit-app-region:drag]`,n&&`transition-[padding] duration-200 ease-out`),children:[r&&(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-[84px] top-1/2 h-5 w-px -translate-y-1/2 bg-border`}),(0,X.jsx)(`div`,{"data-header-section":!0,className:`flex h-full min-w-0 cursor-default items-center overflow-hidden`,children:(0,X.jsx)(xi,{})}),(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`h-5 w-px bg-border`}),(0,X.jsx)(Si,{}),(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`h-5 w-px bg-border`}),(0,X.jsxs)(An,{label:`Workspace controls`,className:P(`shell-header-actions h-full justify-self-end rounded-none!`,$&&`[-webkit-app-region:no-drag]`),children:[(0,X.jsxs)(V,{children:[(0,X.jsx)(H,{asChild:!0,children:(0,X.jsxs)(U,{variant:`ghost`,size:`icon`,className:`compact:h-7 compact:w-7`,onClick:()=>W(),children:[(0,X.jsx)(vr,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Settings`})]})}),(0,X.jsx)(z,{children:`Settings`})]}),(0,X.jsx)(mi,{}),(0,X.jsx)(ci,{}),(0,X.jsx)(zr,{})]})]})}function wi(){bi(),qr(),ai();let{handler:e}=Kt(),t=q(),{pathname:n}=gt(),[r,i]=(0,Y.useState)(!1),a=m(),o=a.data!==void 0&&re(a.data.protocol);return(0,Y.useEffect)(()=>{if(!o)return;let e=()=>{let e=st();K.reportTheme(e(`--text-primary`),e(`--bg-base`))};return e(),lt(e)},[o]),(0,X.jsxs)(`div`,{className:`flex h-screen flex-col overflow-hidden overscroll-y-none bg-ground`,children:[(0,X.jsx)(Be,{}),(0,X.jsx)(nt,{}),(0,X.jsx)(xr,{}),(0,X.jsx)(Ci,{}),(0,X.jsx)(`main`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(Yn,{resetOn:n,scope:n.startsWith(`/project/`)?`workspace`:`view`,children:(0,X.jsx)(xt,{className:`h-full`,motionKey:n.startsWith(`/project/`)?`workspace`:n,children:(0,X.jsx)(Ot,{})})})}),(0,X.jsx)(Sr,{}),(0,X.jsx)(Pr,{}),(0,X.jsx)(Vr,{}),(0,X.jsx)(Ur,{}),(0,X.jsx)(Wr,{}),(0,X.jsx)(Kr,{}),(0,X.jsx)(kr,{onNewSession:e??void 0,onNewProject:()=>i(!0)}),t!==null&&(0,X.jsx)(gn,{profileId:t,open:r,onOpenChange:i}),(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(yi,{})}),(0,X.jsx)(Mr,{})]})}function Ti(){return(0,X.jsx)(Vt,{children:(0,X.jsx)(wi,{})})}var Ei=(0,Y.lazy)(()=>ft(()=>import(`./Dashboard-DyNOxwSR.js`).then(e=>({default:e.Dashboard})),__vite__mapDeps([46,1,2,17,18,3,19,20,21,7,5,6,8,9,10,22,47,48,31,49,34,50,51,42,52,28,25,29,41]))),Di=(0,Y.lazy)(()=>ft(()=>import(`./Workspace-CjOdyZwS.js`).then(e=>({default:e.Workspace})),__vite__mapDeps([53,1,2,6,17,18,3,19,20,21,7,5,8,9,10,22,31,32,24,33,54,25,55,29,49,47,48,27,56,26,57,28,58,34,50,59,60,35,36,61,62,63,52,64,39,40,41,65,66,67,68,44,69]))),Oi=new Jn({defaultOptions:{queries:{retry:1,staleTime:5e3}},mutationCache:new Gn({onError:e=>J(e)})});function ki(){let e=q(),t=_e(),n=e!==null&&t.data!==void 0&&!t.data.some(t=>t.id===e),r=e===null||n;return(0,X.jsx)(xt,{className:`h-screen`,motionKey:r?`profiles`:`cockpit`,children:r?(0,X.jsx)(yr,{}):(0,X.jsx)(_t,{useTransitions:!1,children:(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(Dt,{children:(0,X.jsxs)(N,{element:(0,X.jsx)(Ti,{}),children:[(0,X.jsx)(N,{path:`/`,element:(0,X.jsx)(Ei,{})}),(0,X.jsx)(N,{path:`/project/:id`,element:(0,X.jsx)(Di,{})}),(0,X.jsx)(N,{path:`/project/:id/session/:sid`,element:(0,X.jsx)(Di,{})})]})})})})})}function Ai(){let e=(0,Y.useSyncExternalStore)(Oe.subscribe,Oe.get);return(0,X.jsx)(ee,{client:Oi,children:(0,X.jsxs)(en,{delayDuration:300,children:[(0,X.jsx)(dr,{}),(0,X.jsx)(Yn,{scope:`app`,children:e?window.location.pathname.startsWith(`/forward/`)?(0,X.jsx)(Wn,{}):(0,X.jsx)(ki,{}):(0,X.jsx)(Zn,{})}),(0,X.jsx)(Xn,{})]})})}export{Ai as App};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{r as n,s as r}from"./theme-swfNLod9.js";import{t as i}from"./jsx-runtime-By8HlURe.js";import{t as a}from"./purify.es-D8QhFVkO.js";import"./katex.min-ZqdHjttS.js";import{n as o}from"./forward-link-CAXhnLYS.js";import{t as s}from"./button-DtByPSFL.js";import{t as c}from"./arrow-down-CtYa-Aya.js";import{t as l}from"./square-terminal-CIkfNq3I.js";import{t as u}from"./waves-horizontal-CLDJf7Dd.js";import{t as d}from"./control-tray-c9uXOo-i.js";import{n as f}from"./errors-efDAjyqa.js";import{n as p}from"./markdown-BaCjN652.js";import{n as m,r as h}from"./link-buffer-DcFk9vqt.js";import{n as g,r as _,t as v}from"./render-rich-content-Dvum-lQy.js";var y=e(t(),1),b=32768;function x(e,t){let n=e.length,r=Math.min(600,Math.floor(b/(t+1))),i=Math.max(0,n-r);for(;i<n&&e.getLine(i)?.isWrapped;)i++;let a=[],o=new Map,s=0,c=0;for(let r=i;r<n;r++){let n=m(e,r,t);if(!n)break;let i=!1,l=n.text.split(``).map((t,a)=>{let o=n.cells[a];return e.getLine(r)?.getCell(o.col)?.isInvisible?.()?(i=!0,` `):t}).join(``),u=e.getLine(r+1)?.isWrapped?l:l.trimEnd();if(s+u.length+1>32768)break;s+=u.length+1,!n.isWrapped&&a.length&&c++,o.set(r,{offset:c,cells:n.cells,length:u.length,concealed:i}),c+=u.length,n.isWrapped&&a.length?a[a.length-1]+=u:a.push(u)}let l=a.join(`
|
|
2
|
-
`).trimEnd(),u=[],d=0;for(let r of g(e,t,i,n-i)){let e=o.get(r.start.row),t=o.get(r.end.row);if(!e||!t||[...o.entries()].some(([e,t])=>e>=r.start.row&&e<=r.end.row&&t.concealed))continue;let n=e.cells.findIndex(e=>e.col>=r.start.col),i=t.cells.findLastIndex(e=>e.col<=r.end.col)+1;if(n<0||i===0)continue;let a=e.offset+Math.min(e.length,n),s=Math.min(l.length,t.offset+Math.min(t.length,i));a<d||s<=a||(a>d&&u.push({kind:`text`,source:l.slice(d,a)}),u.push({kind:r.kind,source:r.source,display:r.display}),d=s)}return d<l.length&&u.push({kind:`text`,source:l.slice(d)}),{text:l,truncated:i>0,alternate:e.type===`alternate`,parts:u}}function S(e,t=!1,n=!1){let r=e.split(`
|
|
3
|
-
`),i=[],a=[],o=()=>{a.length&&i.push(p(a.join(`
|
|
4
|
-
`))),a=[]};for(let e=0;e<r.length;e++){let t=r[e],n=/^\s*(`{3,}|~{3,})(.*)$/.exec(t);if(n){o();let a=[t],s=!1;for(;++e<r.length;){let t=r[e];a.push(t);let i=/^\s*(`{3,}|~{3,})\s*$/.exec(t);if(i&&i[1][0]===n[1][0]&&i[1].length>=n[1].length){s=!0;break}}i.push(s?p(a.join(`
|
|
5
|
-
`)):C(a.join(`
|
|
6
|
-
`)))}else if(/^(?: {4}|\t)|[\u2500-\u257f]|\S {2,}\S/.test(t)){o();let n=[t];for(;e+1<r.length&&/^(?: {4}|\t)|[\u2500-\u257f]|\S {2,}\S/.test(r[e+1]);)n.push(r[++e]);i.push(C(n.join(`
|
|
7
|
-
`)))}else a.push(t)}o();let s=i.join(``);return t&&(s=s.replace(/^<p>([\s\S]*?)<\/p>\n?/,`$1`)),n&&(s=s.replace(/<p>((?:(?!<p>)[\s\S])*)<\/p>\n?$/,`$1`)),t&&/^\s/.test(e)&&(s=` ${s}`),n&&/\s$/.test(e)&&(s+=` `),s}function C(e){return`<pre><code>${e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}</code></pre>`}var w=i();function T({part:e,theme:t,active:n}){let r=(0,y.useRef)(null),{kind:i,source:a,display:o}=e;return(0,y.useEffect)(()=>{let e=r.current;if(!e||!n)return;let s=new AbortController;return e.textContent=a,v(e,{kind:i,source:a,display:o},t,s.signal).catch(()=>{s.signal.aborted||(e.textContent=a)}),()=>s.abort()},[a,i,o,t,n]),(0,w.jsx)(`span`,{ref:r,"data-ripple-rich":i,className:o?`ripple-rich-display`:void 0})}function E({terminal:e,stream:t,active:i,onDisable:p}){let[m,g]=(0,y.useState)(()=>x(e.buffer.active,e.cols)),v=(0,y.useRef)(null),b=(0,y.useRef)(!0),C=(0,y.useRef)(0),[E,D]=(0,y.useState)(!0),O=(0,y.useSyncExternalStore)(r,n,n);(0,y.useEffect)(()=>{if(!i)return;let t,n=(n=!1)=>{clearTimeout(t),t=void 0;let r=window.getSelection(),i=r&&!r.isCollapsed&&v.current?.contains(r.anchorNode);if(!n&&(!b.current||i))return;let a=x(e.buffer.active,e.cols);g(e=>e.text===a.text&&e.truncated===a.truncated&&e.alternate===a.alternate?e:a)},r=()=>{t??=setTimeout(n,120)},a=[e.onWriteParsed(r),e.onResize(r),e.buffer.onBufferChange(()=>{b.current=!0,D(!0),n(!0)})];return document.addEventListener(`selectionchange`,r),n(!0),()=>{clearTimeout(t),document.removeEventListener(`selectionchange`,r),a.forEach(e=>e.dispose())}},[e,i]);let k=(0,y.useMemo)(()=>m.parts.map((e,t)=>{let n=m.parts[t-1],r=m.parts[t+1];return e.kind===`text`?{__html:a.sanitize(S(e.source,n?.kind===`math`&&!n.display,r?.kind===`math`&&!r.display))}:null}),[m.parts]);return(0,y.useLayoutEffect)(()=>{let e=v.current,t=e?.firstElementChild;if(!e||!t||!i)return;let n=()=>{b.current&&(e.scrollTop=e.scrollHeight)},r=new ResizeObserver(n);return r.observe(t),n(),()=>r.disconnect()},[m,i]),(0,w.jsxs)(`section`,{className:`ripple`,"data-alternate":m.alternate,"aria-label":`Ripple reading view`,children:[(0,w.jsxs)(`div`,{className:`ripple-toolbar`,children:[(0,w.jsxs)(`span`,{className:`flex items-center gap-2 text-sm`,children:[(0,w.jsx)(u,{className:`size-4`}),` Ripple`,` `,(0,w.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Experimental`})]}),(0,w.jsxs)(d,{label:`Ripple controls`,children:[(0,w.jsx)(s,{variant:`ghost`,size:`sm`,onClick:()=>e.focus(),children:`Type in CLI`}),(0,w.jsxs)(s,{variant:`ghost`,size:`sm`,onClick:p,children:[(0,w.jsx)(l,{}),` CLI only`]})]})]}),(0,w.jsx)(`div`,{ref:v,className:`ripple-scroll`,tabIndex:0,"aria-label":`Readable terminal output`,onWheel:()=>{C.current=Date.now()+1e3},onPointerDown:()=>{C.current=Date.now()+1e3},onPointerMove:e=>{e.buttons&&(C.current=Date.now()+1e3)},onKeyDown:e=>{[`ArrowUp`,`ArrowDown`,`PageUp`,`PageDown`,`Home`,`End`,` `].includes(e.key)&&(C.current=Date.now()+1e3)},onScroll:t=>{let n=t.currentTarget,r=b.current,i=n.scrollHeight-n.scrollTop-n.clientHeight<32;(i||Date.now()<C.current)&&(b.current=i),D(b.current),!r&&b.current&&g(x(e.buffer.active,e.cols))},onClick:e=>{let n=e.target.closest(`a`);if(!n)return;e.preventDefault();let r=n.getAttribute(`href`);r&&/^https?:\/\//i.test(r)&&o(_(r,t,h()!==null)).catch(f)},children:(0,w.jsxs)(`div`,{className:`ripple-content`,children:[m.alternate&&(0,w.jsx)(`p`,{className:`ripple-note`,children:`Current CLI screen · Scroll in the CLI below to bring earlier output into view.`}),m.truncated&&(0,w.jsx)(`p`,{className:`ripple-note`,children:`Recent output · Full history is available in the CLI.`}),m.text?(0,w.jsx)(`div`,{className:`ripple-prose`,children:m.parts.map((e,t)=>e.kind===`text`?(0,w.jsx)(`div`,{className:`ripple-text`,dangerouslySetInnerHTML:k[t]},t):(0,w.jsx)(T,{part:e,theme:O,active:i},t))}):(0,w.jsx)(`p`,{className:`ripple-note`,children:`Agent output will appear here. Type and approve requests in the CLI below.`})]})}),!E&&(0,w.jsxs)(s,{className:`ripple-latest`,variant:`secondary`,size:`sm`,onClick:()=>{b.current=!0,D(!0),g(x(e.buffer.active,e.cols)),v.current&&(v.current.scrollTop=v.current.scrollHeight)},children:[(0,w.jsx)(c,{}),` Latest output`]})]})}export{E as Ripple};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.puddle-terminal-ripple{flex-direction:column;gap:.75rem;min-height:0;display:flex}.puddle-terminal-ripple>.ripple-native{flex:0 0 38%;min-height:0;position:relative}.ripple{min-height:0;color:var(--text-primary);font-family:var(--font-sans);flex-direction:column;flex:1;display:flex;position:relative}.ripple-toolbar{flex-wrap:wrap;justify-content:space-between;align-items:center;gap:.25rem;padding:.25rem .75rem;display:flex}.ripple-scroll{overscroll-behavior:contain;scrollbar-gutter:stable;overflow-anchor:none;flex:1;min-height:0;overflow:auto}.ripple-content{overflow-wrap:anywhere;max-width:48rem;margin-inline:auto;padding:1.25rem clamp(1rem,4%,3rem) 2.5rem;line-height:1.7}.ripple-note{color:var(--text-muted);margin-block:0 1.25rem;font-size:.75rem}.ripple-text{display:contents}.ripple-rich-display{margin-block:1rem;display:block;overflow-x:auto}.ripple-rich-display svg{max-width:100%;height:auto;margin-inline:auto;display:block}.ripple-prose .katex{font-size:1.1em}.ripple-prose .katex-error,.ripple-prose .mermaid-error{color:var(--danger)}.ripple-prose :is(p,ul,ol,pre,blockquote,table){margin-block:0 1rem}.ripple-prose :is(h1,h2,h3,h4,h5,h6){margin-block:1.5rem .75rem;font-weight:600;line-height:1.4}.ripple-prose h1{font-size:1.5em}.ripple-prose h2{font-size:1.25em}.ripple-prose ul{padding-left:1.5rem;list-style:outside}.ripple-prose ol{padding-left:1.5rem;list-style:decimal}.ripple-prose blockquote{color:var(--text-secondary);padding-left:1rem}.ripple-prose a{color:var(--text-gold);cursor:pointer;text-decoration:underline}.ripple-prose code{font-family:var(--font-mono);font-size:.85em}.ripple-prose pre{white-space:pre;line-height:1.5;overflow:auto}.ripple-prose th,.ripple-prose td{text-align:left;padding:.25rem .75rem}.ripple-prose hr{border:0;margin-block:1.5rem}.ripple-latest{position:absolute;bottom:.5rem;left:50%;transform:translate(-50%)}
|