@puddle-code/cli 0.5.0 → 0.5.4
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 +3 -43
- package/README.md +10 -10
- package/dist/host-control.mjs +4070 -448
- package/dist/index.js +4701 -910
- package/dist/install-cli.sh +2 -2
- package/dist/install.sh +10 -6
- package/dist/public/assets/App-bTB2uhzH.js +9 -0
- package/dist/public/assets/{CompilationCommandForm-D7uBn2um.js → CompilationCommandForm-DXHvwQ8Y.js} +1 -1
- package/dist/public/assets/Dashboard-DgJMsE3L.js +1 -0
- package/dist/public/assets/DraftRecovery-B8Ld4_1b.js +1 -0
- package/dist/public/assets/EditorTabClose-CGYLU9GK.js +1 -0
- package/dist/public/assets/FileCloseScope-DoZ0oLf8.js +1 -0
- package/dist/public/assets/{FileEditorSettingsMenu-DnMJu5pC.js → FileEditorSettingsMenu-BbRHII96.js} +1 -1
- package/dist/public/assets/HuddlePane-LF3pjMQM.js +219 -0
- package/dist/public/assets/LazyTerminal-BEOPZDJH.js +2 -0
- package/dist/public/assets/ModelRefcount-CWfA9XXu.js +1 -0
- package/dist/public/assets/{NotebookWidget-DlpLANDa.js → NotebookWidget-BDdx0BOy.js} +1 -1
- package/dist/public/assets/PaneEditorBody-C1uu9cRG.js +284 -0
- package/dist/public/assets/PdfViewer-DLCPKybn.js +2 -0
- package/dist/public/assets/ReadOnlyDiff-C7ZSVRt-.js +2 -0
- package/dist/public/assets/{ReleaseNotesDialog-sQVKJ6dm.js → ReleaseNotesDialog-B9fRaZNN.js} +1 -1
- package/dist/public/assets/Ripple-BBMjOG3U.css +1 -0
- package/dist/public/assets/{Ripple-CLkhZZWa.js → Ripple-Dzg6tdOM.js} +1 -1
- package/dist/public/assets/SettingsDialog-Cwm4tMf3.js +8 -0
- package/dist/public/assets/{Terminal-C3TQK74f.js → Terminal-BxoyAAEW.js} +20 -20
- package/dist/public/assets/Workspace-1x4PD8Q7.js +20 -0
- package/dist/public/assets/{api--n1Ha6tG.js → api-CrP4jl9e.js} +1 -1
- package/dist/public/assets/auth-1SSLu56b.js +1 -0
- package/dist/public/assets/{buffer-logic-BAkSBQT7.js → buffer-logic-D9FvoilV.js} +1 -1
- package/dist/public/assets/buffer-store-OTFEYxTw.js +1 -0
- package/dist/public/assets/colour-picker-DZdAiaVI.js +1 -0
- package/dist/public/assets/content-state-CROLtMfN.js +1 -0
- package/dist/public/assets/{context-BRrQlmgI.js → context-NsaMZKAN.js} +1 -1
- package/dist/public/assets/disclosure-CpSwsC7J.js +1 -0
- package/dist/public/assets/drafts-CBbjQQbz.js +1 -0
- package/dist/public/assets/editor-context-T5zIHY3K.js +5 -0
- package/dist/public/assets/{editor-sync-C5CgYn_q.js → editor-sync-BOfDr2yY.js} +1 -1
- package/dist/public/assets/{errors-DWF9D4n6.js → errors-CviT-mvB.js} +1 -1
- package/dist/public/assets/expanding-content-Cbt69Y_L.js +1 -0
- package/dist/public/assets/{file-editor-settings-1cj6VRxs.js → file-editor-settings-BXTs1F7S.js} +1 -1
- package/dist/public/assets/{file-links-BEPA2kg5.js → file-links-CgOYgoMC.js} +1 -1
- package/dist/public/assets/forward-link-qOyuWj08.js +1 -0
- package/dist/public/assets/hotkeys-nP8gYtE7.js +1 -0
- package/dist/public/assets/index-BB_BPKbu.css +2 -0
- package/dist/public/assets/index-LRHyaDMJ.js +10 -0
- package/dist/public/assets/local-store-Dy1Cd8sn.js +276 -0
- package/dist/public/assets/{markdown-Cseepnv3.js → markdown-Dj7Cr7RL.js} +4 -4
- package/dist/public/assets/notification-delivery-D99P0nLs.js +1 -0
- package/dist/public/assets/{preferences-Dy_61zsm.js → preferences-CvSHA-AA.js} +1 -1
- package/dist/public/assets/profile-icons-BI2xFWcB.js +1 -0
- package/dist/public/assets/{profile-store-CarO9MCP.js → profile-store-D4lZiXgL.js} +2 -2
- package/dist/public/assets/{project-actions-Zt9oqLe5.js → project-actions-Ck504AFM.js} +1 -1
- package/dist/public/assets/project-drag-BnkK15qk.js +1 -0
- package/dist/public/assets/{protocol-support-BUdL5Q-x.js → protocol-support-iXloAH0N.js} +1 -1
- package/dist/public/assets/queries-BSkHGZG8.js +1 -0
- package/dist/public/assets/queue-4USHmW_D.js +3 -0
- package/dist/public/assets/{render-rich-content-BULX1bwr.js → render-rich-content-fo4uQVWR.js} +1 -1
- package/dist/public/assets/save-BT7q_AMN.js +1 -0
- package/dist/public/assets/{scroll-restoration-Bl3jxJsC.js → scroll-restoration-C_ly1bKS.js} +1 -1
- package/dist/public/assets/selection-actions-BeE1dYsZ.js +1 -0
- package/dist/public/assets/session-display-BUDNzNmg.js +1 -0
- package/dist/public/assets/session-order-b3nCJcCG.js +1 -0
- package/dist/public/assets/shield-check-CY69Ons-.js +1 -0
- package/dist/public/assets/source-anchor-map-BNxSa_bJ.js +1 -0
- package/dist/public/assets/square-terminal-CrlDquCd.js +1 -0
- package/dist/public/assets/state-CuUqRNo7.js +1 -0
- package/dist/public/assets/switch-CGrhQUXr.js +1 -0
- package/dist/public/assets/tooltip-Ek-eHPZu.js +1 -0
- package/dist/public/assets/trash-2-WYPJMQLN.js +1 -0
- package/dist/public/assets/{use-arrangement-ready-D18CpR8E.js → use-arrangement-ready-1vmV5np6.js} +1 -1
- package/dist/public/assets/use-desktop-state-CBTzsmlz.js +2 -0
- package/dist/public/assets/view-state-store-Dqk7M5ei.js +1 -0
- package/dist/public/assets/ws-CDXOuBYB.js +1 -0
- package/dist/public/assets/zoom-intent-vemBFIak.js +1 -0
- package/dist/public/index.html +8 -8
- package/dist/public/manifest.webmanifest +1 -1
- package/dist/public/notification-worker.js +1 -1
- package/dist/pudl.js +5816 -600
- package/package.json +2 -2
- package/dist/public/assets/App-ESs-lBsA.js +0 -49
- package/dist/public/assets/Dashboard-DWwOy6bQ.js +0 -1
- package/dist/public/assets/DraftRecovery-DO-ymSIW.js +0 -1
- package/dist/public/assets/EditorTabClose-DEizui0i.js +0 -1
- package/dist/public/assets/FileCloseScope-DKbSgHF2.js +0 -1
- package/dist/public/assets/LazyTerminal-B0GmOiTE.js +0 -2
- package/dist/public/assets/ModelRefcount-DBzR9UEq.js +0 -1
- package/dist/public/assets/PaneEditorBody-DRZ6NrJ1.js +0 -284
- package/dist/public/assets/PdfViewer-B3z9sh0x.js +0 -2
- package/dist/public/assets/Ripple-C8HPFMGB.css +0 -1
- package/dist/public/assets/SettingsDialog-DBUHpb9S.js +0 -8
- package/dist/public/assets/Workspace-D_NxUGYW.js +0 -20
- package/dist/public/assets/auth-eu0vmKkB.js +0 -1
- package/dist/public/assets/buffer-store-CBhXNRZm.js +0 -1
- package/dist/public/assets/content-state-BDt3NnGs.js +0 -1
- package/dist/public/assets/drafts-CCenbr5J.js +0 -1
- package/dist/public/assets/editor-links-qwyINDCv.js +0 -1
- package/dist/public/assets/expanding-content-BUkS1Qk4.js +0 -1
- package/dist/public/assets/forward-link-CcmVXHkx.js +0 -1
- package/dist/public/assets/index-Botodnry.js +0 -10
- package/dist/public/assets/index-rjm6DMrz.css +0 -2
- package/dist/public/assets/local-store-8IcyY3pd.js +0 -64
- package/dist/public/assets/notification-delivery-CWj1p0u-.js +0 -1
- package/dist/public/assets/project-drag-Bqy-V-45.js +0 -1
- package/dist/public/assets/queries-DnuokC1N.js +0 -1
- package/dist/public/assets/queue-BlrQxHDl.js +0 -3
- package/dist/public/assets/selection-actions-BSqrsD_7.js +0 -1
- package/dist/public/assets/session-order-CCDTBSiH.js +0 -1
- package/dist/public/assets/switch-BsUkvj8j.js +0 -1
- package/dist/public/assets/trash-2-DQeNROsF.js +0 -1
- package/dist/public/assets/use-desktop-state-Dw9EfOjg.js +0 -2
- package/dist/public/assets/view-state-store-CY9DI6-i.js +0 -1
- package/dist/public/assets/ws-DH0dKRnO.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pdf-EQHMWEbX.js","assets/preload-helper-Czpn1I53.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{U as n}from"./local-store-Dy1Cd8sn.js";import{t as r}from"./jsx-runtime-By8HlURe.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{n as a}from"./api-CrP4jl9e.js";import{n as o}from"./dist-BOS6OKSE.js";import{t as s}from"./createLucideIcon-DyMAgLa3.js";import{t as c}from"./control-tray-CjoJunx1.js";import{r as l,t as u}from"./view-state-store-Dqk7M5ei.js";import{t as d}from"./zoom-intent-vemBFIak.js";import{t as f}from"./scroll-restoration-C_ly1bKS.js";var p=s(`zoom-in`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),m=s(`zoom-out`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),h=e(t(),1),g=r();function _({page:e,scale:t}){let n=(0,h.useRef)(null),r=(0,h.useRef)(null),a=(0,h.useRef)(t);return a.current=t,(0,h.useLayoutEffect)(()=>{r.current?.update({viewport:e.getViewport({scale:t})})},[e,t]),(0,h.useEffect)(()=>{let t=n.current;if(!t)return;let o=!1,s=null;return i(async()=>{let{TextLayer:e}=await import(`./pdf-EQHMWEbX.js`);return{TextLayer:e}},__vite__mapDeps([0,1])).then(async({TextLayer:n})=>{o||(s=new n({textContentSource:e.streamTextContent(),container:t,viewport:e.getViewport({scale:a.current})}),await s.render(),!o&&(s.update({viewport:e.getViewport({scale:a.current})}),r.current=s))}).catch(e=>{o||(t.replaceChildren(),console.warn(`Couldn’t render PDF text`,e))}),()=>{o=!0,s?.cancel(),r.current=null,t.replaceChildren()}},[e]),(0,g.jsx)(`div`,{ref:n,className:`pdf-text-layer`,style:{"--total-scale-factor":t*e.userUnit}})}function v(e,t){let n=e.getBoundingClientRect(),r=t?.clientX??n.left+e.clientWidth/2,i=t?.clientY??n.top+e.clientHeight/2,a=null,o=1/0;for(let t of e.querySelectorAll(`[data-pdf-page]`)){let e=t.getBoundingClientRect(),n=Math.max(e.top-i,i-e.bottom,0);n<o&&(a=t,o=n)}if(!a)return null;let s=a.getBoundingClientRect();return!s.width||!s.height?null:{page:a,clientX:r,clientY:i,x:(r-s.left)/s.width,y:(i-s.top)/s.height}}function y(e,t){if(!e.contains(t.page))return;let n=t.page.getBoundingClientRect();e.scrollLeft+=n.left+t.x*n.width-t.clientX,e.scrollTop+=n.top+t.y*n.height-t.clientY}var b=[.5,.75,1,1.25,1.5,2,3],x=b[0],S=b.at(-1);function C(e){return A(e,x,S)}function w(e,t){return C(e*Math.exp(-t*.01))}function T(e,t,n){return C(t<=0||n<=0?e:n/t*e)}function E(e){let t=Math.round(C(e)*1e3)/10;return`${Number.isInteger(t)?t.toFixed(0):t.toFixed(1)}%`}function D(e,t){return t===`in`?b.find(t=>t>e+2**-52)??b.at(-1):[...b].reverse().find(t=>t<e-2**-52)??b[0]}function O(e,t,n,r=12e6){let i=Math.max(1,Math.min(n||1,2.5)),a=e*t;return a<=0||r<=0?1:Math.max(.25,Math.min(i,Math.sqrt(r/a)))}function k(e,t,n,r,i){if(n.width<=0||n.height<=0||r<=0||i<=0)return null;let a=A(e-n.left,0,n.width),o=A(t-n.top,0,n.height);return{x:a/n.width*r,y:o/n.height*i}}function A(e,t,n){return Math.min(n,Math.max(t,e))}var j=null,M=new u(500,`pdf-zoom`);function N({blob:e,session:t,path:r,root:i,onRevealSource:s,onDownload:c}){let u=l(`pdf`,[t,i,r]),p=(0,h.useRef)(null),m=(0,h.useRef)(null),_=(0,h.useRef)(null),b=(0,h.useRef)(null),[E,O]=(0,h.useState)(()=>M.get(u)??1),k=(0,h.useRef)(E),A=(0,h.useRef)(!1),[j,N]=(0,h.useState)(null),[z,W]=(0,h.useState)(!1),G=B(p);(0,h.useLayoutEffect)(()=>{let e=p.current,t=m.current;if(!e||!t||!j)return;let n=f(e,t,u,()=>t.isConnected&&!A.current&&t.querySelectorAll(`[data-scroll-ready="true"]`).length===j.numPages);return _.current=n,()=>{n.dispose(),_.current=null}},[j,u,G!==null]),(0,h.useLayoutEffect)(()=>{let e=p.current,t=b.current;e&&t&&y(e,t),b.current=null,A.current=!1,t&&_.current?.capture()},[E]);let K=(0,h.useCallback)((e,t)=>{let n=C(e);if(Math.abs(n-k.current)<2**-52)return;let r=p.current;b.current=r?v(r,t):null,k.current=n,M.set(u,n),A.current=!0,O(n)},[u]);(0,h.useEffect)(()=>{let e=p.current;if(!e)return;let t=null,n=!1,r=d(e.ownerDocument.defaultView),i=t=>{let i=r.wheel(t);if(i===`pan`&&!n||(t.preventDefault(),i!==`zoom`||n))return;let a=F(t,e.clientHeight);K(w(k.current,a),t)},a=e=>{if(e.touches.length!==2){t=null;return}e.preventDefault(),n=!0,t={anchor:L(e.touches),distance:I(e.touches),zoom:k.current}},o=e=>{(n||r.panBlocked()||e.metaKey||e.ctrlKey)&&e.preventDefault(),!(!t||e.touches.length!==2)&&(r.suppressPan(),K(T(t.zoom,t.distance,I(e.touches)),t.anchor))},s=e=>{e.touches.length<2&&(t=null),e.touches.length===0&&(n&&r.suppressPan(),n=!1)};return e.addEventListener(`wheel`,i,{passive:!1}),e.addEventListener(`touchstart`,a,{passive:!1}),e.addEventListener(`touchmove`,o,{passive:!1}),e.addEventListener(`touchend`,s,{passive:!0}),e.addEventListener(`touchcancel`,s,{passive:!0}),()=>{r.dispose(),e.removeEventListener(`wheel`,i),e.removeEventListener(`touchstart`,a),e.removeEventListener(`touchmove`,o),e.removeEventListener(`touchend`,s),e.removeEventListener(`touchcancel`,s)}},[K]),(0,h.useEffect)(()=>{let t=!1,n=null,r=null;return N(null),W(!1),Promise.all([U(),e.arrayBuffer()]).then(([e,r])=>t?null:(n=e.getDocument({data:r}),n.promise)).then(e=>{if(e){if(r=e,t){n?.destroy();return}N(e)}}).catch(e=>{!t&&!H(e)&&W(!0)}),()=>{t=!0,N(null),r&&r.cleanup(),n&&n.destroy()}},[e]);let q=(0,h.useCallback)(async(e,c,l)=>{if(s)try{let o=await a(`POST`,`/api/latex/synctex`,{session:t,path:r,root:i,page:e,x:c,y:l});s(n.parse(o))}catch(e){o.error(e instanceof Error?e.message:`Couldn’t locate the TeX source`)}},[s,r,i,t]);return z?(0,g.jsxs)(V,{children:[(0,g.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Couldn’t display this PDF.`}),c&&(0,g.jsx)(`button`,{type:`button`,onClick:c,className:`rounded-md bg-elevated px-3 py-1.5 text-sm text-fg transition-colors hover:bg-border/70`,children:`Download`})]}):(0,g.jsxs)(`div`,{className:`relative h-full w-full bg-ground`,children:[(0,g.jsx)(`div`,{ref:p,role:`region`,"aria-label":`PDF document`,className:`h-full w-full overflow-auto [overflow-anchor:none]`,children:!j||G===null?(0,g.jsx)(V,{children:(0,g.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Loading PDF…`})}):(0,g.jsx)(`div`,{ref:m,className:`flex min-h-full w-max min-w-full flex-col items-center gap-4 p-4`,children:Array.from({length:j.numPages},(e,t)=>(0,g.jsx)(R,{document:j,pageNumber:t+1,availableWidth:G*E,scrollRoot:p.current,inverseSearch:s?q:void 0},t+1))})}),j&&G!==null&&(0,g.jsx)(P,{zoom:E,minimum:x,maximum:S,onZoomOut:()=>K(D(E,`out`)),onReset:()=>K(1),onZoomIn:()=>K(D(E,`in`))})]})}function P({zoom:e,minimum:t,maximum:n,onZoomOut:r,onReset:i,onZoomIn:a}){let o=E(e);return(0,g.jsxs)(c,{variant:`overlay`,label:`PDF zoom`,className:`absolute right-1.5 top-1.5 z-10 shadow-sm`,children:[(0,g.jsx)(`button`,{type:`button`,disabled:e<=t,onClick:r,className:`cursor-pointer rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg disabled:cursor-default disabled:opacity-40`,"aria-label":`Zoom out`,title:`Zoom out`,children:(0,g.jsx)(m,{className:`size-3.5`})}),(0,g.jsx)(`button`,{type:`button`,onClick:i,className:`min-w-12 cursor-pointer rounded-sm px-1.5 py-1 font-mono text-[11px] tabular-nums text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,"aria-label":`Zoom ${o}; reset to fit width`,title:`Reset to fit width`,children:o}),(0,g.jsx)(`button`,{type:`button`,disabled:e>=n,onClick:a,className:`cursor-pointer rounded-sm p-1 text-fg-muted transition-colors hover:bg-elevated hover:text-fg disabled:cursor-default disabled:opacity-40`,"aria-label":`Zoom in`,title:`Zoom in`,children:(0,g.jsx)(p,{className:`size-3.5`})})]})}function F(e,t){return e.deltaMode===WheelEvent.DOM_DELTA_LINE?e.deltaY*16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?e.deltaY*t:e.deltaY}function I(e){let t=e.item(0),n=e.item(1);return!t||!n?0:Math.hypot(n.clientX-t.clientX,n.clientY-t.clientY)}function L(e){let t=e.item(0),n=e.item(1);if(!(!t||!n))return{clientX:(t.clientX+n.clientX)/2,clientY:(t.clientY+n.clientY)/2}}function R({document:e,pageNumber:t,availableWidth:n,scrollRoot:r,inverseSearch:i}){let a=(0,h.useRef)(null),o=(0,h.useRef)(null),s=(0,h.useRef)(null),[c,l]=(0,h.useState)(null),[u,d]=(0,h.useState)(null),[f,p]=(0,h.useState)(!1),m=z(a,r,t<=2);(0,h.useEffect)(()=>{let n=!1,r=null;return l(null),d(null),p(!1),e.getPage(t).then(e=>{if(r=e,n){e.cleanup();return}let t=e.getViewport({scale:1});d({width:t.width,height:t.height}),l(e)}).catch(e=>{!n&&!H(e)&&p(!0)}),()=>{n=!0,s.current?.cancel(),s.current=null,r?.cleanup()}},[e,t]),(0,h.useEffect)(()=>{let e=o.current;if(!e||!c||!u||!m)return;let t=n/u.width,r=c.getViewport({scale:t}),i=O(r.width,r.height,window.devicePixelRatio||1),a=c.getViewport({scale:t*i});s.current?.cancel(),e.width=Math.max(1,Math.floor(a.width)),e.height=Math.max(1,Math.floor(a.height)),e.style.width=`${r.width}px`,e.style.height=`${r.height}px`;let l=c.render({canvas:e,viewport:a});return s.current=l,l.promise.catch(e=>{H(e)||p(!0)}).finally(()=>{s.current===l&&(s.current=null)}),()=>{l.cancel(),s.current===l&&(s.current=null)}},[n,c,u,m]);let v=e=>{if(!e.metaKey&&!e.ctrlKey||!i||!u)return;let n=k(e.clientX,e.clientY,e.currentTarget.getBoundingClientRect(),u.width,u.height);n&&(e.preventDefault(),i(t,n.x,n.y))};if(f)return(0,g.jsxs)(`p`,{"data-scroll-ready":`true`,className:`py-8 text-xs text-fg-muted`,children:[`Couldn’t render page `,t,`.`]});let y=Math.round(u?n/u.width*u.height:n*1.3);return(0,g.jsxs)(`div`,{ref:a,"data-scroll-ready":u!==null,"data-pdf-page":t,className:`relative shrink-0 bg-elevated shadow-sm`,style:{width:n,height:y},"aria-label":`PDF page ${t}`,onClick:v,title:i?`Command-click to open the corresponding TeX source`:void 0,children:[(0,g.jsx)(`canvas`,{ref:o,className:`block`}),c&&u&&m&&(0,g.jsx)(_,{page:c,scale:n/u.width})]})}function z(e,t,n){let[r,i]=(0,h.useState)(n);return(0,h.useEffect)(()=>{if(r)return;let n=e.current;if(!n)return;let a=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(i(!0),a.disconnect())},{root:t,rootMargin:`100% 0px`});return a.observe(n),()=>a.disconnect()},[r,e,t]),r}function B(e){let[t,n]=(0,h.useState)(null);return(0,h.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=0,i=()=>{cancelAnimationFrame(r),r=requestAnimationFrame(()=>{t.clientWidth>32&&n(t.clientWidth-32)})};i();let a=new ResizeObserver(i);return a.observe(t),()=>{cancelAnimationFrame(r),a.disconnect()}},[e]),t}function V({children:e}){return(0,g.jsx)(`div`,{className:`flex h-full min-h-32 w-full flex-col items-center justify-center gap-3 p-4`,children:e})}function H(e){return e instanceof Error&&(e.name===`RenderingCancelledException`||e.name===`AbortException`)}async function U(){return j??=Promise.all([i(()=>import(`./pdf-EQHMWEbX.js`),__vite__mapDeps([0,1])),i(()=>import(`./pdf.worker.min-C8Ts8bNu.js`),[])]).then(([e,t])=>(e.GlobalWorkerOptions.workerSrc=t.default,e)).catch(e=>{throw j=null,e}),j}export{N as PdfViewer};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{C as n,x as r}from"./protocol-support-iXloAH0N.js";import{Gt as i,Ht as a,Kt as o,Ut as s,Wt as c,dn as l,ln as u,qt as d,r as f}from"./local-store-Dy1Cd8sn.js";import{r as p,t as m}from"./client-settings-BdKglwtW.js";import{t as h}from"./jsx-runtime-By8HlURe.js";import{a as g,c as _,i as v,p as y,r as b}from"./editor.api2-Cyagyq8b.js";import{n as x,t as S}from"./api-CrP4jl9e.js";import{i as ee,o as C,t as te}from"./profile-store-D4lZiXgL.js";import{b as w,ht as T,it as E,nt as D,rt as O}from"./queries-BSkHGZG8.js";import{I as k,O as A,P as j,R as M,S as ne,V as re,Y as N,_ as ie,d as ae,f as oe,g as P,h as se,i as ce,m as le,p as ue,s as de,u as F,v as fe,w as pe,x as me,y as I,z as he}from"./editor-context-T5zIHY3K.js";import{n as ge}from"./motion-Bd_MB9cH.js";import{n as L}from"./dist-BOS6OKSE.js";import{t as _e}from"./createLucideIcon-DyMAgLa3.js";import{t as ve}from"./disclosure-CpSwsC7J.js";import{l as R}from"./hotkeys-nP8gYtE7.js";import{t as ye}from"./content-state-CROLtMfN.js";import{a as z,i as be,n as B,r as V}from"./languages-O6mK4sJI.js";import{i as xe,n as H}from"./file-editor-settings-BXTs1F7S.js";import{r as Se,t as Ce}from"./view-state-store-Dqk7M5ei.js";import{o as we,s as Te}from"./source-anchor-map-BNxSa_bJ.js";import{a as Ee,i as De,n as Oe,t as ke}from"./drafts-CBbjQQbz.js";import{a as Ae,c as je,i as Me,n as Ne,o as Pe,r as Fe}from"./editor-sync-BOfDr2yY.js";import{r as Ie}from"./buffer-logic-D9FvoilV.js";import{c as Le,d as U,f as W,i as G,l as Re,o as ze,p as Be,r as Ve,s as He,t as Ue,u as We}from"./buffer-store-OTFEYxTw.js";var Ge=_e(`combine`,[[`path`,{d:`M14 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1`,key:`1l7d7l`}],[`path`,{d:`M19 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1`,key:`9955pe`}],[`path`,{d:`m7 15 3 3`,key:`4hkfgk`}],[`path`,{d:`m7 21 3-3H5a2 2 0 0 1-2-2v-2`,key:`1xljwe`}],[`rect`,{x:`14`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1cdgtw`}],[`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1`,key:`zi3rio`}]]),K=e(t(),1);function q(e){return{tabSize:e,insertSpaces:!0,detectIndentation:!1}}var Ke=new Ce(500,`code`),qe=new Ce(500,`diff`);function Je(e){let t={...e.contributionsState};return delete t[`editor.contrib.wordHighlighter`],{...e,contributionsState:t}}function Ye(e,t){let n=(0,K.useRef)(null),r=(0,K.useRef)(null);return(0,K.useLayoutEffect)(()=>(n.current&&(r.current=t(n.current,e)),()=>{r.current?.(),r.current=null}),[e,t]),(0,K.useCallback)(i=>{r.current?.(),n.current=i,i.onDidDispose(()=>{n.current===i&&(n.current=null)}),r.current=t(i,e)},[e,t])}function Xe(e,t){let n=Ke.get(t);n&&e.restoreViewState(n);let r=()=>{if(!e.getModel())return;let n=e.saveViewState();n&&Ke.set(t,Je(n))},i=[e.onDidScrollChange(r),e.onDidChangeCursorSelection(r)];return()=>{r(),i.forEach(e=>e.dispose())}}function Ze(e,t){let n=qe.get(t),r=n!==void 0,i=()=>{if(r||!e.getModel())return;let n=e.saveViewState();n&&qe.set(t,{...n,original:n.original&&Je(n.original),modified:n.modified&&Je(n.modified)})};n&&e.restoreViewState(n);let a=[e.onDidUpdateDiff(()=>{r&&(r=!1,n&&e.restoreViewState(n))}),...[e.getOriginalEditor(),e.getModifiedEditor()].flatMap(e=>[e.onDidScrollChange(i),e.onDidChangeCursorSelection(i)])];return()=>{i(),a.forEach(e=>e.dispose())}}function Qe(e){return Ye(Se(`code`,e),Xe)}function $e(e){return Ye(Se(`diff`,e),Ze)}var J=h();function et({conflict:e}){let[t,n]=(0,K.useState)(null),r=e.baseRevision,i=e.previousRevision;if(!r||!e.captured)return null;let a=[...new Set([...Object.keys(i?.files??{}),...Object.keys(r.files)])].filter(e=>i?.files[e]!==r.files[e]).sort(),o=[...new Set([...Object.keys(i?.components??{}),...Object.keys(r.components)])].filter(e=>i?.components[e]!==r.components[e]).sort();return(0,J.jsxs)(ve,{className:`shrink-0 px-3 py-2 text-xs text-fg-secondary`,summary:`Huddle source review · ${a.length} ${a.length===1?`file`:`files`} · ${o.length} ${o.length===1?`contract`:`contracts`}`,children:[!i&&(0,J.jsx)(`p`,{className:`py-2`,children:`This draft has no captured baseline. Review the current source before saving.`}),(0,J.jsx)(`p`,{className:`py-2`,children:`Saving uses this captured revision. Further changes require another review.`}),(0,J.jsx)(`div`,{className:`flex max-h-32 flex-wrap gap-2 overflow-auto`,children:a.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`rounded px-2 py-1 hover:bg-elevated`,onClick:()=>n({kind:`file`,path:e}),children:[e,r.files[e]?``:` · removed`]},e))}),(0,J.jsx)(`div`,{className:`flex max-h-32 flex-wrap gap-2 overflow-auto`,children:o.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`rounded px-2 py-1 hover:bg-elevated`,onClick:()=>n({kind:`contract`,path:e}),children:[e,` · contract`,r.components[e]?``:` · removed`]},e))}),t&&(0,J.jsxs)(`div`,{className:`py-2`,children:[(0,J.jsxs)(`p`,{children:[t.path,` · captured `,t.kind]}),(0,J.jsx)(`pre`,{className:`max-h-48 overflow-auto whitespace-pre-wrap p-2 text-fg`,children:(t.kind===`file`?e.captured.files[t.path]:JSON.stringify(e.captured.document.components[t.path],null,2))??`Removed from this capture.`})]})]})}function tt({session:e,path:t,conflict:n,model:r,onTakeDisk:i,onKeepMine:a,onSave:o,onReady:s}){let c=H(),[l,u]=(0,K.useState)(!1),d=$e([`conflict`,r.uri.toString()]),f=(0,K.useId)(),p=(0,K.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),m=(0,K.useRef)(o);m.current=o;let h=(0,K.useRef)(null),g=()=>{let e=h.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),h.current=null},_=(0,K.useRef)(g);return _.current=g,(0,K.useEffect)(()=>()=>_.current(),[]),(0,J.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,J.jsx)(`span`,{children:n.repair?`The huddle cannot be captured. Saving repairs only this file with a file-change check; review the remaining source afterwards.`:n.huddle?`Review the huddle source, reconcile your file, then save.`:`This file changed on disk. Yours is on the right — merge what you want, then save.`}),(0,J.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>{let e=h.current,t=e?.getModel();e?.setModel(null),u(!0),i().finally(()=>{e&&h.current===e&&t?e.setModel(t):t?.original.dispose(),u(!1)})},className:`ml-auto shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Take the disk version`}),(0,J.jsx)(`button`,{type:`button`,onClick:a,disabled:l||n.phase!==`comparing`,className:`shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Keep mine`})]}),(0,J.jsx)(et,{conflict:n}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,J.jsx)(z,{modifiedModelPath:r.uri.toString(),originalModelPath:`puddle-disk://${encodeURIComponent(e)}/${n.mtimeMs}/${encodeURIComponent(f)}/${t.split(`/`).map(encodeURIComponent).join(`/`)}`,original:n.content,language:c.editorLanguage??B(t),theme:V,keepCurrentModifiedModel:!0,loading:(0,J.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:e=>{d(e),h.current=e,e.onDidDispose(()=>{h.current=null}),e.getModifiedEditor().addCommand(v.CtrlCmd|b.KeyS,()=>m.current()),s?.(n.revision)},options:{readOnly:n.phase!==`comparing`,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:p,fontSize:c.editorFontSize,...q(c.editorTabSize),wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function nt({session:e,path:t,buffer:n,focused:r}){let i=n.conflict;return!i||i.phase===`unresolved`?null:I(i)&&n.model?(0,J.jsx)(tt,{session:e,path:t,conflict:i,model:n.model,onTakeDisk:n.takeDisk,onKeepMine:n.keepMine,onSave:n.save,onReady:r?n.comparisonReady:void 0}):i.phase===`load-error`?(0,J.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground px-4 text-center text-sm text-fg-muted`,children:[(0,J.jsx)(`span`,{children:`The disk version could not be loaded.`}),(0,J.jsx)(`span`,{className:`max-w-lg text-xs text-fg-secondary`,children:i.message}),(0,J.jsx)(`button`,{type:`button`,onClick:n.compare,className:`rounded-md bg-elevated px-3 py-1.5 text-xs text-fg-secondary transition-colors hover:bg-border hover:text-fg`,children:`Retry compare`})]}):(0,J.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:`Loading the disk version…`})}function rt(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function it(e,t,n){return rt(e/Math.max(1,t-n))}function at(e,t,n){return rt(e)*Math.max(0,t-n)}function ot(e,t){return JSON.stringify([e,t.session,t.root??null,t.path])}var st=new class{positions=new Map;listeners=new Map;revision=0;publish(e,t,n,r=null){let i={ratio:rt(n),sourceLine:r!==null&&Number.isFinite(r)?Math.max(1,r):null,revision:++this.revision},a=ot(e,t);this.positions.set(a,i);for(let e of this.listeners.get(a)??[])e(i);return i}get(e,t){return this.positions.get(ot(e,t))}subscribe(e,t,n){let r=ot(e,t),i=this.listeners.get(r);i||(i=new Set,this.listeners.set(r,i)),i.add(n);let a=this.positions.get(r);return a&&n(a),()=>{i?.delete(n),i?.size===0&&this.listeners.delete(r)}}},ct=new Ce(500,`preview-view`);function lt(e){let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},dispose:()=>{t!==null&&cancelAnimationFrame(t),t=null}}}function ut(e,t,n,r){let i=Math.max(0,t-n);if(e.ratio<=0)return 0;if(e.ratio>=1)return i;if(e.sourceLine!==null&&r){let t=we(r,e.sourceLine);if(t!==null)return Math.min(i,Math.max(0,t))}return at(e.ratio,t,n)}function dt(e,t){if(t.driver&&t.receiver)throw Error(`a preview scroll surface cannot be both driver and receiver`);let n=t.store??st,r=t.viewKey?ct.get(t.viewKey):void 0,i=t.sourceAnchors?.(),a=()=>void 0,o,s=n=>{r=n,t.viewKey&&ct.set(t.viewKey,n),e.scrollTop=ut(n,e.scrollHeight,e.clientHeight,i)};r&&s(r);let c=()=>{if(e.clientHeight<=0)return;let a=it(e.scrollTop,e.scrollHeight,e.clientHeight),o=i?Te(i,e.scrollTop):null;r={ratio:a,sourceLine:o,revision:0},t.viewKey&&ct.set(t.viewKey,r),t.driver&&n.publish(t.channel,t.target,a,o)};t.receiver?a=n.subscribe(t.channel,t.target,s):(t.driver||t.viewKey)&&(o=lt(c),e.addEventListener(`scroll`,o.schedule,{passive:!0}),o.schedule());let l=new ResizeObserver(()=>{i=t.sourceAnchors?.(),r?s(r):o?.schedule()});for(let e of t.resizeElements??[])l.observe(e);return()=>{o&&(c(),e.removeEventListener(`scroll`,o.schedule)),a(),l.disconnect(),o?.dispose()}}function ft(e,t){let n=e.getModel()?.getLineCount()??0;if(n===0)return null;let r=1,i=n;for(;r<i;){let n=Math.ceil((r+i)/2);e.getTopForLineNumber(n)<=t?r=n:i=n-1}let a=e.getTopForLineNumber(r),o=r<n?e.getTopForLineNumber(r+1):e.getScrollHeight();return o<=a?r:r+Math.min(1,Math.max(0,(t-a)/(o-a)))}function pt(e,t){let n=e.getModel()?.getLineCount()??0;if(n===0||!Number.isFinite(t))return null;let r=Math.min(n+1,Math.max(1,t)),i=Math.floor(r);if(i>n)return e.getScrollHeight();let a=i+1,o=e.getTopForLineNumber(i),s=a<=n?e.getTopForLineNumber(a):e.getScrollHeight();return o+(r-i)*(s-o)}function mt(e,t,n){if(t.driver&&t.receiver)throw Error(`a Monaco scroll surface cannot be both driver and receiver`);let r=t.store??st,i=[],a,o=()=>void 0,s,c=()=>e.getLayoutInfo().height,l=t=>{a=t;let r=t.ratio>0&&t.ratio<1&&t.sourceLine!==null?pt(e,t.sourceLine):null;e.setScrollTop(r??ut(t,e.getScrollHeight(),c()),n)};return t.receiver?(o=r.subscribe(t.channel,t.target,l),i.push(e.onDidChangeModel(()=>a&&l(a))),i.push(e.onDidLayoutChange(()=>a&&l(a))),i.push(e.onDidContentSizeChange(()=>a&&l(a)))):t.driver&&(s=lt(()=>{let n=it(e.getScrollTop(),e.getScrollHeight(),c());r.publish(t.channel,t.target,n,ft(e,e.getScrollTop()))}),i.push(e.onDidScrollChange(s.schedule)),i.push(e.onDidChangeModel(s.schedule)),i.push(e.onDidChangeModelContent(s.schedule)),i.push(e.onDidLayoutChange(s.schedule)),i.push(e.onDidContentSizeChange(s.schedule)),s.schedule()),()=>{o();for(let e of i)e.dispose();s?.dispose()}}var ht=new TextEncoder;async function gt(e){let t=await crypto.subtle.digest(`SHA-256`,ht.encode(e));return Array.from(new Uint8Array(t),e=>e.toString(16).padStart(2,`0`)).join(``)}async function _t(e,t){let n=s(e.huddle_id,t),r=await gt(a(n.files,n.document.components));if(r!==n.document.digest)throw Error(`Huddle source does not match its captured digest`);let i=async e=>Object.fromEntries(await Promise.all(e.map(async([e,t])=>[e,await gt(t)]))),[o,u]=await Promise.all([i(Object.entries(n.files)),i(Object.entries(n.document.components).map(([e,t])=>[e,l(t)]))]);return{source:n,baseline:c.parse({...e,format:1,digest:r,files:o,components:u})}}function Y(e){return JSON.stringify([e.scope,e.profile,e.project_id,e.worktree,e.huddle_id])}function vt(e,t,n){return Y(e)!==Y(t)||Object.entries(e.files).some(([e,r])=>e!==n&&t.files[e]!==void 0&&t.files[e]!==r)?!1:n===`huddle.json`||Object.entries(t.files).every(([t,r])=>t===n||e.files[t]===r)&&Object.keys(e.files).every(e=>e===n||Object.hasOwn(t.files,e))&&l(e.components)===l(t.components)}var yt=new Map,X=new Map,bt=e=>`${Y(e)}:${e.digest}`;function xt(e,t){let n=e;for(let e=0;e<512;e++){let e=X.get(bt(n));if(!e||e.digest===n.digest||e.files[t]!==n.files[t])break;n=e}return n}function St(e,t,n){if(!(e.digest===t.digest||!vt(e,t,n)))for(X.set(bt(e),t);X.size>512;)X.delete(X.keys().next().value)}async function Ct(e,t){let n=yt.get(e),r=(n?n.catch(()=>{}):Promise.resolve()).then(t);yt.set(e,r);try{return await r}finally{yt.get(e)===r&&yt.delete(e)}}function wt(){return C()?.hostId??window.location.origin}function Tt(e,t,r,i){let a=r===void 0?/^\.puddle\/huddle\/([a-f0-9]{32})\/(huddle|layout)\.json$/.exec(t):null,o=!!a&&!f(),s=w(),c=ee(),l=wt(),p=o&&n(s.data?.protocol,{major:28,minor:11}),m=E({queryKey:[`session`,e],queryFn:async({signal:t})=>u.parse(await x(`GET`,`/api/sessions/${e}`,void 0,t)),enabled:p}),h=he(e,r),g=T(),_=c&&m.data&&a?{profile:c,scope:l,project_id:m.data.project_id,worktree:m.data.worktree_path,huddle_id:a[1]}:void 0,v=[`huddle-source`,_?.scope,c,_?.project_id,_?.worktree,_?.huddle_id],y=()=>{if(!_||f()||te()!==_.profile||wt()!==_.scope)throw Error(`The huddle source connection changed`)},b=e=>{let n=`${a[2]}.json`,r=e.source.files[n]??`{"format":1,"nodes":{}}
|
|
2
|
+
`;return{path:t,content:r,binary:!1,size:new TextEncoder().encode(r).length,mtime_ms:e.source.files[n]===void 0?-1:0,baseRevision:e.baseline,captured:e.source}},C=E({queryKey:v,queryFn:async({signal:e})=>{y();let{profile:t,scope:n,huddle_id:r,...i}=_,a=await x(`GET`,`/api/huddle/${t}/definitions/${r}/source?${new URLSearchParams(i)}`,void 0,e),o=await _t(_,a);return y(),o},enabled:p&&!!_,retry:!1,refetchOnWindowFocus:!0,...i?{refetchInterval:D(3e3)}:{}}),k=e=>e instanceof S&&e.code===`huddle_definition_invalid`,A=p&&k(C.error),j=re(e,t,{root:r,live:!p&&i,enabled:A||!p&&(!o||!!s.data)}),M=O({retry:!1,mutationFn:async n=>{if(!p){if(n.baseRevision)throw Error(`This captured huddle draft requires a host with source-save support`);let{baseRevision:e,repairReview:t,...r}=n;return h.mutateAsync(r)}y();let r=d.safeParse({file:`${a[2]}.json`,content:n.content});if(!r.success)throw new S(400,`invalid_huddle_source`,`Save requires a supported huddle JSON document without unknown fields`);let i=r.data;if(i.file===`huddle.json`&&JSON.parse(i.content).id!==_.huddle_id)throw new S(400,`huddle_identity_changed`,`A saved huddle must keep its directory id`);if(n.repairReview){if(n.expected_mtime_ms===void 0)throw Error(`Review the file before repairing it`);return Ct(Y(_),async()=>{y();let r=await h.mutateAsync({path:t,content:i.content,expected_mtime_ms:n.expected_mtime_ms});y();let a=[`wt-file`,e,t];return await g.cancelQueries({queryKey:a,exact:!0}),y(),g.setQueryData(a,{path:t,content:i.content,binary:!1,size:new TextEncoder().encode(i.content).length,mtime_ms:r.mtime_ms}),g.invalidateQueries({queryKey:v}),r})}if(!n.baseRevision||Y(n.baseRevision)!==Y(_))throw new S(409,`huddle_source_changed`,`Review current huddle source before saving this draft`);return Ct(Y(n.baseRevision),async()=>{y();let r=xt(n.baseRevision,i.file),{profile:a,scope:o,huddle_id:s,...c}=_,l=await x(`PUT`,`/api/huddle/${a}/definitions/${s}/source`,{...c,expected_digest:r.digest,edit:i}),u=await _t(_,l);if(y(),u.source.files[i.file]!==i.content)throw Error(`Huddle source changed after publication; review it before another save`);return await g.cancelQueries({queryKey:v,exact:!0}),y(),St(r,u.baseline,i.file),g.setQueryData(v,u),g.invalidateQueries({queryKey:[`huddle-document`]}),g.invalidateQueries({queryKey:[`wt-file`,e,t]}),g.invalidateQueries({queryKey:[`wt-diff`,e]}),{mtime_ms:0,baseRevision:u.baseline}})}});return{guarded:p,file:{data:A?j.data?{...j.data,repair:!0}:void 0:p?C.data?b(C.data):void 0:j.data,error:A?j.error:p?C.error??m.error:j.error??(o?s.error:null),refetch:async e=>{if(!p)return{data:(await j.refetch(e)).data};try{let t=await C.refetch({...e,throwOnError:!0});return{data:t.data?b(t.data):void 0}}catch(t){if(!k(t))throw t;let n=await j.refetch(e);return{data:n.data?{...n.data,repair:!0}:void 0}}}},saveMutation:M}}function Et(e){return!e}function Dt(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=v.CtrlCmd:e===`ctrl`?r|=v.WinCtrl:e===`alt`?r|=v.Alt:e===`shift`&&(r|=v.Shift);let i=b[/^Key[A-Z]$/.test(n)?`Key${n.slice(3)}`:/^Digit[0-9]$/.test(n)?`Digit${n.slice(5)}`:n];return typeof i==`number`?r|i:null}function Ot(e,t){let n=Dt(R(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=Dt(R(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>{if(t.fileSettingsKey){let e=xe.get(t.fileSettingsKey).wordWrap??m().editorWordWrap;xe.update(t.fileSettingsKey,{wordWrap:Et(e)})}else p({editorWordWrap:Et(m().editorWordWrap)})}})}var kt=new WeakSet;function At(e){return kt.has(e)?!1:(kt.add(e),!0)}function jt(e){return`file-conflict:${e}`}function Mt(e,t,n,r,a){let s=a?.passive===!0,c=ee(),l=a?.focused??!0,{fileSettingsKey:u}=H(),d=Ue(e,t,r),{file:f,saveMutation:p,guarded:m}=Tt(e,t,r,a?.live),[h,g]=(0,K.useState)(null),[_,v]=(0,K.useState)(!1),y=(0,K.useRef)(!1),b=(0,K.useRef)(null),x=(0,K.useRef)(null),te=(0,K.useRef)(n);te.current=n;let w=(0,K.useRef)(!1),T=(0,K.useCallback)((e,t,n)=>{x.current?.cancel(),w.current=!0;try{Le(d,e,t,n)}finally{w.current=!1}},[d]),E=(0,K.useSyncExternalStore)((0,K.useCallback)(e=>Be(d,e),[d]),()=>G(d)),D=(0,K.useSyncExternalStore)((0,K.useCallback)(e=>Pe(d,e),[d]),()=>Ae(d)),O=(0,K.useSyncExternalStore)((0,K.useCallback)(e=>pe(d,e),[d]),()=>P(d));(0,K.useEffect)(()=>{let n=f.data;if(!n||n.binary||n.content===null||y.current)return;y.current=!0;let a=U(d)!==void 0,o=c&&C()?ye(c).buffer({session:e,path:t,root:r}):void 0,s=Ve(e,t,n.content,o?.baseMtimeMs??n.mtime_ms,r,o?i(o.baseRevision):n.baseRevision),l=s.getValue();if(g(s),!a){if(o){Ie(s,o.content)&&v(!0);return}Ee(e,t,r).then(i=>{if(!i||s.isDisposed())return;let a=G(d)?`offer`:Oe(i,l,n.mtime_ms,n.baseRevision);a===`discard`?ke(e,t,r):a===`restore`?(Re(d,i.base_mtime_ms,i.baseRevision),Ie(s,i.content)&&v(!0)):L(`This file has an unsaved draft from an earlier version.`,{description:`The file changed on disk since the draft was saved.`,duration:12e3,action:{label:`Restore draft`,onClick:()=>{s.isDisposed()||(Re(d,i.base_mtime_ms,i.baseRevision),Ie(s,i.content)&&v(!0))}}})})}},[f.data,d,e,t,r,c]),(0,K.useEffect)(()=>{if(!c||!h||!C())return;let n=ye(c),i={session:e,path:t,root:r},a=n.registerBuffer(i,()=>h.isDisposed()?n.buffer(i)??null:G(d)?{...i,content:h.getValue(),baseMtimeMs:U(d)??0,...W(d)?{baseRevision:W(d)}:{}}:null),o=Be(d,()=>n.bufferChanged(i));return n.bufferChanged(i),()=>{a(),o()}},[c,h,d,e,t,r]),(0,K.useEffect)(()=>{if(!h||s)return;let n=De(e,t,r),i=je(e,t,r,n.cancel);x.current=n;let a=h.onDidChangeContent(()=>{w.current||(n(h.getValue(),U(d)??0,W(d)),Ne(e,t,r))});return()=>{i(),n.flush(),a.dispose(),x.current=null}},[h,d,e,t,r,s]),(0,K.useEffect)(()=>{!h||!D.savedElsewhere||G(d)||f.refetch().then(e=>{G(d)||(e.data&&e.data.content!==null&&T(e.data.content,e.data.mtime_ms,e.data.baseRevision),Me(d))})},[D.savedElsewhere,h,d]),(0,K.useEffect)(()=>{let e=f.data;!h||!e||e.content===null||!G(d)&&(e.mtime_ms!==U(d)||!o(e.baseRevision,W(d)))&&T(e.content,e.mtime_ms,e.baseRevision)},[f.data,h,d]);let k=(0,K.useCallback)((n,i,a)=>{ze(d,n,i,a),x.current?.cancel(),G(d)&&h?(x.current?.(h.getValue(),i,a),x.current?.flush()):ke(e,t,r),Fe(e,t,i,r),v(!1),oe(d)},[d,e,t,r,h]),A=(0,K.useCallback)(()=>{let e=ae(d);e!==null&&(L.dismiss(jt(d)),f.refetch({throwOnError:!0}).then(t=>{let n=t.data;if(!n)throw Error(`The disk version did not load.`);if(n.content===null)throw Error(`The file on disk is binary and cannot be compared as text.`);se(d,e,n.content,n.mtime_ms,n.baseRevision,n.captured,W(d),n.repair)}).catch(t=>{ie(d,e,t instanceof Error?t.message:`The disk version did not load.`)}))},[f,d]),j=(0,K.useRef)(A);j.current=A,(0,K.useEffect)(()=>{if(!ne(O,l))return;let e=jt(d);return L(O?.huddle?`Review huddle source before saving`:`File changed on disk`,{id:e,description:O?.uncertain?`The save outcome is uncertain. Your draft is retained; inspect source before another save.`:`Your unsaved version is intact. Compare it with the current source.`,duration:1/0,closeButton:!0,action:{label:`Compare`,onClick:()=>j.current()}}),()=>{L.dismiss(e)}},[O,l,d]);let M=(0,K.useCallback)(()=>{let n=P(d);return f.refetch({throwOnError:!0}).then(async i=>{let a=i.data;if(!a||a.content===null)throw Error(`The file on disk could not be loaded as text.`);if(n&&P(d)?.revision!==n.revision)return;let o=n&&!m?await p.mutateAsync({path:t,content:a.content,expected_mtime_ms:a.mtime_ms}):a;n&&P(d)?.revision!==n.revision||(T(a.content,o.mtime_ms,a.baseRevision),ke(e,t,r),v(!1),oe(d))}).catch(n=>{n instanceof S&&n.code===`stale_file`?me(d,{session:e,path:t,root:r}):L.error(n instanceof Error?n.message:`Reload failed`)})},[d,e,t,r,f,p,T,m]),re=(0,K.useCallback)((e,n)=>{p.mutate({path:t,content:e},{onSuccess:e=>k(n,e.mtime_ms),onError:e=>L.error(e instanceof Error?e.message:`Overwrite failed`)})},[p,t,k]),N=(0,K.useCallback)(async()=>{let n=P(d);if(n&&n.phase!==`comparing`)return!1;if(!h||!G(d)&&!n)return!0;let i=h.getValue(),a=h.getAlternativeVersionId();if(le(P(d)))return!1;let o=ue(P(d))??U(d);try{let e=await p.mutateAsync({path:t,content:i,expected_mtime_ms:o,baseRevision:n?.phase===`comparing`?n.baseRevision:W(d),repairReview:n?.phase===`comparing`&&n.repair});return k(a,e.mtime_ms,e.baseRevision),!0}catch(n){return n instanceof S&&n.status===409&&[`stale_file`,`huddle_source_changed`,`huddle_definition_invalid`].includes(n.code)?me(d,{session:e,path:t,root:r},{huddle:m}):(m&&!(n instanceof S&&n.status<500)&&me(d,{session:e,path:t,root:r},{huddle:!0,uncertain:!0}),L.error(n instanceof Error?n.message:`Save failed`)),!1}},[h,d,p,e,t,r,k,m]),F=(0,K.useRef)(N);F.current=N,(0,K.useEffect)(()=>ce(de(e,t,r),()=>F.current(),{session:e,path:t,...r===void 0?{}:{root:r}}),[e,t,r]);let I=(0,K.useCallback)(()=>{let n=b.current,i=te.current;!n||!i||!l||i.session!==e||i.path!==t||(i.root??void 0)!==(r??void 0)||At(i)&&(n.revealLineInCenter(i.line),n.setPosition({lineNumber:i.line,column:i.column??1}),n.focus())},[e,t,r,l]),he=(0,K.useCallback)(e=>{b.current=e,Ot(e,{onSave:()=>F.current(),fileSettingsKey:u}),I()},[I,u]);(0,K.useEffect)(()=>{I()},[n,h,I]);let ge=(0,K.useCallback)(()=>{M()},[M]),_e=(0,K.useCallback)(()=>{if(!(!h||P(d)?.phase!==`comparing`)){if(m||W(d)){F.current();return}re(h.getValue(),h.getAlternativeVersionId())}},[h,d,re,m]),ve=(0,K.useCallback)(e=>{fe(d,e)},[d]),R,z=null;f.data?.binary?R=`binary`:m&&h&&E?R=`ready`:f.error?f.error instanceof S&&f.error.status===413?R=`too-large`:(R=`error`,z=f.error instanceof Error?f.error.message:`Failed to load file`):R=h?`ready`:`loading`;let be=E&&D.savedElsewhere?`saved-elsewhere`:E&&D.dirtyElsewhere?`dirty-elsewhere`:null;return{status:R,errorMessage:z,model:h,dirty:E,restoredNotice:_,discardRestore:ge,peerBadge:be,conflict:O,takeDisk:M,keepMine:_e,compare:A,comparisonReady:ve,save:N,onMount:he}}function Nt(e,t,n,r){for(let i of e)if(Lt([i],n).some(e=>(r===void 0||e.kind===r)&&t>=e.startLineNumber&&t<=e.endLineNumber))return i;return null}function Pt(e,t){return Z(e.modifiedStartLineNumber,e.modifiedEndLineNumber)>0?Math.min(t,e.modifiedEndLineNumber):Math.max(0,Math.min(t,e.modifiedStartLineNumber-1))}function Ft(e){let t=Z(e.originalStartLineNumber,e.originalEndLineNumber),n=Z(e.modifiedStartLineNumber,e.modifiedEndLineNumber);return Math.max(5,Math.min(14,t+n+4))}function Z(e,t){return t===0?0:Math.max(0,t-e+1)}function It(e,t){if(e>t)return{startLineNumber:Math.max(1,t),endLineNumber:Math.max(1,t),kind:`deleted-after`};let n=Math.max(1,e);return{startLineNumber:n,endLineNumber:n,kind:`deleted-before`}}function Lt(e,t){let n=[];for(let r of e){let e=Z(r.originalStartLineNumber,r.originalEndLineNumber),i=Z(r.modifiedStartLineNumber,r.modifiedEndLineNumber);if(e===0&&i>0){n.push({startLineNumber:r.modifiedStartLineNumber,endLineNumber:r.modifiedEndLineNumber,kind:`added`});continue}if(i===0&&e>0){n.push(It(r.modifiedStartLineNumber,t));continue}let a=Math.min(e,i);a>0&&n.push({startLineNumber:r.modifiedStartLineNumber,endLineNumber:r.modifiedStartLineNumber+a-1,kind:`modified`}),i>a&&n.push({startLineNumber:r.modifiedStartLineNumber+a,endLineNumber:r.modifiedEndLineNumber,kind:`added`}),e>a&&n.push(It(r.modifiedStartLineNumber+i,t))}return n}var Rt=28,zt=[[`puddle-dirty-added`,`added`],[`puddle-dirty-modified`,`modified`],[`puddle-dirty-deleted-before`,`deleted-before`],[`puddle-dirty-deleted-after`,`deleted-after`]];function Bt(e){if(e){for(let[t,n]of zt)if(e.classList.contains(t)||e.closest(`.${t}`))return n}}function Vt({editor:e,original:t,modified:n,path:r}){let i=[],a=null,o=!1,s=t=>{try{e.changeViewZones(e=>e.removeZone(t))}catch{}},c=()=>{let e=a;e&&(a=null,e.frame!==null&&cancelAnimationFrame(e.frame),e.diffEditor&&(e.diffEditor.setModel(null),e.diffEditor.dispose()),s(e.zoneId))},l=e=>{let t=e.diffEditor;if(!t)return;let r=Math.max(1,Math.min(n.getLineCount(),e.change.modifiedStartLineNumber));t.getModifiedEditor().revealLineInCenter(r,y.ScrollType.Immediate)},u=(i,s)=>{if(a?.anchorLine===i){c();return}c();let u=e.getOption(y.EditorOption.lineHeight),d=document.createElement(`div`);d.className=`puddle-dirty-peek`;let f=document.createElement(`div`);f.className=`puddle-dirty-peek-header`;let p=document.createElement(`span`);p.className=`puddle-dirty-peek-title`,p.textContent=`${r.split(`/`).pop()??r} · Local changes against HEAD`;let m=document.createElement(`button`);m.type=`button`,m.className=`puddle-dirty-peek-close`,m.setAttribute(`aria-label`,`Close inline change`),m.title=`Close inline change`,m.textContent=`×`,m.addEventListener(`pointerdown`,e=>{e.preventDefault(),e.stopPropagation(),c()}),m.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),c()});let h=document.createElement(`div`);h.className=`puddle-dirty-peek-editor`,f.append(p,m),d.append(f,h);let g=document.createElement(`div`);g.className=`puddle-dirty-peek-margin`;let _={afterLineNumber:Pt(s,n.getLineCount()),heightInPx:Rt+Ft(s)*u,domNode:d,marginDomNode:g,suppressMouseDown:!1},v=``;e.changeViewZones(e=>{v=e.addZone(_)});let b={anchorLine:i,change:s,zone:_,zoneId:v,frame:null,diffEditor:null};a=b,b.frame=requestAnimationFrame(()=>{if(b.frame=null,o||a!==b)return;let r=y.createDiffEditor(h,{readOnly:!0,domReadOnly:!0,originalEditable:!1,renderSideBySide:!1,renderMarginRevertIcon:!1,renderOverviewRuler:!1,enableSplitViewResizing:!1,isInEmbeddedEditor:!0,automaticLayout:!0,fontFamily:e.getOption(y.EditorOption.fontFamily),fontSize:e.getOption(y.EditorOption.fontSize),lineHeight:u,minimap:{enabled:!1},glyphMargin:!1,folding:!1,scrollBeyondLastLine:!1,fixedOverflowWidgets:!0,hideUnchangedRegions:{enabled:!0,minimumLineCount:0,contextLineCount:2,revealLineCount:3}});b.diffEditor=r,r.setModel({original:t,modified:n}),r.onDidUpdateDiff(()=>l(b)),l(b)}),e.revealLineInCenter(Math.max(1,Math.min(n.getLineCount(),s.modifiedStartLineNumber)))},d=e.onMouseDown(e=>{if(!e.event.leftButton||e.target.type!==y.MouseTargetType.GUTTER_LINE_DECORATIONS||e.target.position===null)return;let t=e.target.position.lineNumber,r=Nt(i,t,n.getLineCount(),Bt(e.target.element));r&&(e.event.preventDefault(),e.event.stopPropagation(),u(t,r))});return{update(t){if(i=t,!a)return;let r=a,o=Nt(t,r.anchorLine,n.getLineCount());if(!o){c();return}r.change=o,r.zone.afterLineNumber=Pt(o,n.getLineCount()),r.zone.heightInPx=Rt+Ft(o)*e.getOption(y.EditorOption.lineHeight);try{e.changeViewZones(e=>e.layoutZone(r.zoneId))}catch{c();return}l(r)},dispose(){o=!0,d.dispose(),c()}}}var Ht={added:`puddle-dirty-added`,modified:`puddle-dirty-modified`,"deleted-before":`puddle-dirty-deleted-before`,"deleted-after":`puddle-dirty-deleted-after`};function Ut(e,t,n,i){let a=w(),o=k(e,t,{root:n,enabled:a.data!==void 0&&r(a.data.protocol)&&i!==null}),[s,c]=(0,K.useState)(null),l=(0,K.useCallback)(e=>{c(e)},[]);return(0,K.useLayoutEffect)(()=>{let e=o.data;if(!s||!i||!e||e.repository===null||e.ignored||e.binary)return;let n=document.createElement(`div`);n.className=`puddle-hidden-diff-controller`,document.body.appendChild(n);let r=y.createModel(e.exists?e.content??``:``,i.getLanguageId()),a=y.createDiffEditor(n,{readOnly:!0,automaticLayout:!1,renderSideBySide:!1,minimap:{enabled:!1}}),c=s.createDecorationsCollection();a.setModel({original:r,modified:i});let l=Vt({editor:s,original:r,modified:i,path:t}),u=()=>{let e=a.getLineChanges();e&&(l.update(e),c.set(Lt(e,i.getLineCount()).map(e=>({range:new _(e.startLineNumber,1,e.endLineNumber,1),options:{isWholeLine:!0,linesDecorationsClassName:Ht[e.kind]}}))))},d=a.onDidUpdateDiff(u);return u(),()=>{d.dispose(),l.dispose(),c.clear(),a.setModel(null),a.dispose(),r.dispose(),n.remove()}},[s,i,o.data]),l}function Wt({message:e,session:t,path:n,root:r,download:i}){return(0,J.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,J.jsx)(`span`,{children:e}),i&&(0,J.jsxs)(`button`,{type:`button`,onClick:()=>void A(t,n,r).catch(e=>L.error(e instanceof Error?e.message:`Download failed`)),className:`flex items-center gap-1.5 text-fg-secondary transition-colors hover:text-fg`,children:[(0,J.jsx)(N,{className:`size-4`}),`Download`]})]})}function Gt({session:e,path:t,reveal:n,root:r,focused:i=!0,scrollDriver:a=!1,scrollReceiver:o=!1,scrollChannel:s=`profile`}){let c=H(),l=ge(),u=Qe([e,r,t]),d=Mt(e,t,n,r,{focused:i}),f=F(e,t,r),p=Ut(e,t,r,d.model),m=(0,K.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),[h,_]=(0,K.useState)(null),v=(0,K.useMemo)(()=>({session:e,path:t,root:r}),[e,t,r]),b=d.conflict!==null&&d.conflict.phase!==`unresolved`;if((0,K.useEffect)(()=>{if(!(!h||!d.model||b))return mt(h,{channel:s,target:v,driver:a,receiver:o},y.ScrollType.Immediate)},[h,d.model,b,s,v,a,o]),(0,K.useEffect)(()=>{let e=d.model;e&&y.setModelMarkers(e,`puddle-compilation`,f.map(t=>{let n=Math.min(t.line,e.getLineCount()),r=e.getLineMaxColumn(n),i=Math.min(t.column??1,r),a=t.end_line??n,o=Math.max(n,Math.min(a,e.getLineCount())),s=e.getLineMaxColumn(o),c=Math.min(t.end_column??(t.column?i+1:s),s);return{severity:t.severity===`error`?g.Error:t.severity===`warning`?g.Warning:g.Info,message:t.message,source:`Puddle compilation`,startLineNumber:n,startColumn:i,endLineNumber:o,endColumn:Math.max(i,c)}}))},[d.model,f]),d.conflict&&d.conflict.phase!==`unresolved`)return(0,J.jsx)(nt,{session:e,path:t,buffer:d,focused:i});if(d.status===`binary`)return(0,J.jsx)(Wt,{message:`Binary file — use Download`,session:e,path:t,root:r,download:!0});if(d.status===`too-large`)return(0,J.jsx)(Wt,{message:`File too large to edit — use Download`,session:e,path:t,root:r,download:!0});if(d.status===`error`)return(0,J.jsx)(Wt,{message:d.errorMessage??`Failed to load file`,session:e,path:t,root:r});let x=d.peerBadge===`saved-elsewhere`?`Saved in another window`:d.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,J.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[d.restoredNotice&&(0,J.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,J.jsx)(`span`,{children:`Restored unsaved changes`}),(0,J.jsx)(`button`,{type:`button`,onClick:d.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),x&&(0,J.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:x}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1 pl-1`,children:d.model&&(0,J.jsx)(be,{path:d.model.uri.toString(),language:c.editorLanguage??B(t),defaultValue:d.model.getValue(),theme:`puddle`,keepCurrentModel:!0,saveViewState:!1,onMount:e=>{u(e),d.onMount(e),p(e),_(e)},loading:(0,J.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{cursorBlinking:l?`solid`:`blink`,cursorSmoothCaretAnimation:`off`,smoothScrolling:!1,automaticLayout:!0,fontFamily:m,fontSize:c.editorFontSize,...q(c.editorTabSize),wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},glyphMargin:!1,lineNumbersMinChars:1,lineDecorationsWidth:5,fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function Q({children:e}){return(0,J.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function Kt(e,t){let n=(0,K.useRef)(t);n.current=t,(0,K.useEffect)(()=>(We(e),()=>{n.current?.(),He(e)}),[e])}function $(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function qt({session:e,refName:t,path:n,content:r}){let i=H(),a=Qe([e,t,n]),o=(0,K.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,J.jsx)(be,{path:$(`puddle-view`,e,t,n),language:i.editorLanguage??B(n),defaultValue:r,theme:V,saveViewState:!1,onMount:a,loading:(0,J.jsx)(Q,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:o,fontSize:i.editorFontSize,...q(i.editorTabSize),wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Jt({session:e,against:t,path:n,root:r,indexBase:i=!1}){let a=j(e,t,n,{root:r,enabled:!i}),o=M(e,n,{root:r,enabled:i}),s=i?o:a;return s.isPending?(0,J.jsx)(Q,{children:`…`}):s.error?(0,J.jsx)(Q,{children:s.error instanceof Error?s.error.message:`Failed to load`}):s.data.binary?(0,J.jsx)(Q,{children:`Binary file — deleted`}):(0,J.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,J.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,J.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,J.jsx)(qt,{session:e,refName:`${t}:${r??``}`,path:n,content:s.data.content??``})})]})}function Yt({session:e,against:t,path:n,basePath:r,root:i,indexBase:a=!1,focused:o=!0}){let s=H(),c=$e([e,i,t,a,n]),l=Mt(e,n,null,i,{focused:o}),u=j(e,t,r,{root:i,enabled:!a}),d=M(e,r,{root:i,enabled:a}),f=a?d:u,p=(0,K.useRef)(null);Kt(Ue(e,n,i),()=>{let e=p.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),p.current=null});let m=(0,K.useRef)(l.save);m.current=l.save;let h=(0,K.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),g=f.error instanceof S&&f.error.status===404;return l.conflict&&l.conflict.phase!==`unresolved`?(0,J.jsx)(nt,{session:e,path:n,buffer:l,focused:o}):l.status===`binary`||f.data?.binary?(0,J.jsx)(Q,{children:`Binary file`}):l.status===`too-large`?(0,J.jsx)(Q,{children:`File too large to show`}):l.status===`error`?(0,J.jsx)(Q,{children:l.errorMessage??`Failed to load file`}):g||a&&d.data&&!d.data.exists?(0,J.jsx)(Gt,{session:e,path:n,reveal:null,root:i,focused:o}):f.isPending||!l.model?(0,J.jsx)(Q,{children:`…`}):f.error?(0,J.jsx)(Q,{children:f.error instanceof Error?f.error.message:`Failed to load base`}):(0,J.jsx)(z,{modifiedModelPath:l.model.uri.toString(),originalModelPath:$(`puddle-base`,e,`${t}:${i??``}`,r),original:f.data.content??``,language:s.editorLanguage??B(n),theme:V,keepCurrentModifiedModel:!0,loading:(0,J.jsx)(Q,{children:`…`}),onMount:e=>{c(e),p.current=e,e.onDidDispose(()=>{p.current=null}),e.getModifiedEditor().addCommand(v.CtrlCmd|b.KeyS,()=>m.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:h,fontSize:s.editorFontSize,...q(s.editorTabSize),wordWrap:s.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Xt({session:e,against:t,entry:n,root:r}){let i=H(),a=$e([e,r,t,`staged`,n.path]),o=n.old_path??n.path,s=j(e,t,o,{root:r,enabled:n.status!==`added`}),c=M(e,n.path,{root:r,enabled:n.status!==`deleted`}),l=(0,K.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(n.status===`deleted`)return(0,J.jsx)(Jt,{session:e,against:t,path:o,root:r});if(c.isPending||n.status!==`added`&&s.isPending)return(0,J.jsx)(Q,{children:`…`});if(c.error||s.error){let e=c.error??s.error;return(0,J.jsx)(Q,{children:e instanceof Error?e.message:`Failed to load staged content`})}return c.data.binary||s.data?.binary?(0,J.jsx)(Q,{children:`Binary file`}):n.status===`added`?(0,J.jsx)(qt,{session:e,refName:`index:${r??``}`,path:n.path,content:c.data.content??``}):s.data?(0,J.jsx)(z,{originalModelPath:$(`puddle-head`,e,`${t}:${r??``}`,o),modifiedModelPath:$(`puddle-index`,e,`${t}:${r??``}`,n.path),original:s.data.content??``,modified:c.data.content??``,language:i.editorLanguage??B(n.path),onMount:a,theme:V,loading:(0,J.jsx)(Q,{children:`…`}),options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:l,fontSize:i.editorFontSize,...q(i.editorTabSize),wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}}):(0,J.jsx)(Q,{children:`Failed to load HEAD content`})}function Zt({session:e,path:t,root:n,focused:r}){return Kt(Ue(e,t,n)),(0,J.jsx)(Gt,{session:e,path:t,reveal:null,root:n,focused:r})}function Qt({session:e,against:t,entry:n,root:r,area:i,focused:a=!0}){if(i===`staged`)return(0,J.jsx)(Xt,{session:e,against:t,entry:n,root:r});switch(n.status){case`added`:return(0,J.jsx)(Zt,{session:e,path:n.path,root:r,focused:a});case`deleted`:return(0,J.jsx)(Jt,{session:e,against:t,path:n.path,root:r,indexBase:i===`unstaged`});case`modified`:case`renamed`:return(0,J.jsx)(Yt,{session:e,against:t,path:n.path,basePath:n.old_path??n.path,root:r,indexBase:i===`unstaged`,focused:a});default:return null}}function $t({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o,root:s}){let c=(0,K.useId)(),l=H(),u=$e([e,s,t,n,i,a]),d=(0,K.useRef)(null),f=(0,K.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,K.useEffect)(()=>()=>{let e=d.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),t?.modified.dispose(),d.current=null},[]),(0,J.jsx)(z,{originalModelPath:$(`puddle-revision-original`,e,`${c}:${t}:${s??``}`,n),modifiedModelPath:$(`puddle-revision-modified`,e,`${c}:${i}:${s??``}`,a),language:l.editorLanguage??B(a),original:r,modified:o,theme:V,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,J.jsx)(Q,{children:`…`}),onMount:e=>{u(e),d.current=e,e.onDidDispose(()=>{d.current=null})},options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:f,fontSize:l.editorFontSize,...q(l.editorTabSize),wordWrap:l.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}export{qt as a,Ot as c,st as d,ct as f,Ge as g,q as h,Q as i,dt as l,Qe as m,Jt as n,Gt as o,nt as p,Qt as r,Mt as s,$t as t,rt as u};
|
package/dist/public/assets/{ReleaseNotesDialog-sQVKJ6dm.js → ReleaseNotesDialog-B9fRaZNN.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-By8HlURe.js";import{t as r}from"./purify.es-D8QhFVkO.js";import{i,o as a,r as o,s,t as c}from"./dialog-CTN-Lln6.js";import{a as l,i as u,n as d}from"./queue-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-By8HlURe.js";import{t as r}from"./purify.es-D8QhFVkO.js";import{i,o as a,r as o,s,t as c}from"./dialog-CTN-Lln6.js";import{a as l,i as u,n as d}from"./queue-4USHmW_D.js";import{t as f}from"./markdown-Dj7Cr7RL.js";var p=e(t(),1),m=n();function h({markdown:e}){let t=(0,p.useId)().replace(/[^A-Za-z0-9_-]/g,``),n=(0,p.useMemo)(()=>{let n=r.sanitize(f(e,t),{RETURN_DOM_FRAGMENT:!0,USE_PROFILES:{html:!0},FORBID_TAGS:[`img`,`video`,`audio`,`source`,`iframe`,`object`,`embed`,`style`,`form`],FORBID_ATTR:[`style`,`src`,`srcset`,`poster`,`action`]});for(let e of n.querySelectorAll(`a`)){let t=e.getAttribute(`href`)??``;/^https?:\/\//i.test(t)?(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`)):t.startsWith(`#`)||e.removeAttribute(`href`)}let i=document.createElement(`div`);return i.append(n),{__html:i.innerHTML}},[e,t]);return(0,m.jsx)(`div`,{className:`md-preview text-sm text-fg-secondary`,onClick:e=>{let t=e.target.closest(`a`)?.getAttribute(`href`);if(t?.startsWith(`#`)){e.preventDefault();try{e.currentTarget.closest(`[role="dialog"]`)?.querySelector(`#${CSS.escape(decodeURIComponent(t.slice(1)))}`)?.scrollIntoView({block:`nearest`})}catch{}}},dangerouslySetInnerHTML:n})}function g(){let[e,t]=(0,p.useState)(!1);return(0,p.useLayoutEffect)(()=>{let e=()=>{let e=Array.from(document.querySelectorAll(`[role="dialog"], [role="alertdialog"], dialog[open]`)).some(e=>!e.hasAttribute(`data-release-notes`)&&!e.hidden&&e.getAttribute(`data-state`)!==`closed`);t(!e)},n=new MutationObserver(e);return n.observe(document.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-state`,`hidden`,`open`,`role`]}),e(),()=>n.disconnect()},[]),e}function _({group:e}){return(0,p.useEffect)(()=>d.presented(e),[e]),null}function v({current:e}){let t=g(),n=l.flatMap(t=>{let n=e.entries.find(e=>e.component===t);return n?[n]:[]});return t?(0,m.jsx)(c,{open:!0,onOpenChange:t=>{t||d.dismiss(e)},children:(0,m.jsxs)(o,{wide:!0,className:`gap-6`,"data-release-notes":``,children:[(0,m.jsx)(_,{group:e}),(0,m.jsxs)(a,{children:[(0,m.jsxs)(s,{children:[`What’s new in `,e.version]}),(0,m.jsxs)(i,{children:[n.map(e=>u[e.component]).join(` · `),` release notes`]})]}),(0,m.jsx)(`nav`,{"aria-label":`Release note sections`,className:`flex flex-wrap gap-x-5 gap-y-2 text-sm`,children:n.map(e=>(0,m.jsx)(`a`,{className:`text-fg-muted hover:text-fg`,href:`#${e.component}`,onClick:t=>{t.preventDefault(),t.currentTarget.closest(`[role="dialog"]`)?.querySelector(`#${e.component}`)?.scrollIntoView({block:`nearest`})},children:u[e.component]},e.component))}),n.map(e=>(0,m.jsx)(`section`,{id:e.component,"aria-label":u[e.component],children:(0,m.jsx)(h,{markdown:e.markdown})},e.component))]})}):null}export{v as ReleaseNotesDialog};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.puddle-terminal-ripple{--ripple-gutter:0rem;width:calc(100% + var(--ripple-gutter));padding-right:var(--ripple-gutter);isolation:isolate;overflow:hidden}.puddle-terminal-ripple>.ripple-native{z-index:0;min-height:0;position:relative}.ripple{inset:0 var(--ripple-gutter) auto 0;z-index:2;--ripple-grip-width:1rem;background:var(--bg-base);min-height:0;color:var(--text-primary);font-family:var(--font-sans);flex-direction:column;flex:1;display:flex;position:absolute}.ripple-scroll{touch-action:pan-x pinch-zoom;overscroll-behavior:contain;overflow-anchor:none;flex:1;min-height:0;overflow:clip}.ripple-content{overflow-wrap:anywhere;width:100%;padding:.5rem .75rem 1rem;line-height:1.55}.ripple-note{color:var(--text-muted);margin-block:0 1.25rem;font-size:.75rem}.ripple-text{display:contents}.ripple-user-turn{border-radius:var(--ui-surface-radius);background:var(--explorer-hover);white-space:normal;width:fit-content;max-width:85%;margin:0 0 1rem auto;padding:.6rem .9rem}.ripple-user-turn>:last-child,.ripple-prose>:last-child,.ripple-prose .ripple-text>:last-child{margin-bottom:0}.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,.ripple-prose [data-ripple-kind=url]{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 pre.ripple-terminal-art{line-height:1}.ripple-prose th,.ripple-prose td{text-align:left;padding:.25rem .75rem}.ripple-prose hr{border:0;margin-block:1.5rem}.ripple-boundary{bottom:-.875rem;right:calc(-1 * var(--ripple-gutter));width:var(--ripple-grip-width);border-radius:var(--ui-radius);background:var(--bg-base);height:1.75rem;color:var(--text-muted);cursor:row-resize;touch-action:none;-webkit-user-select:none;user-select:none;place-items:center;display:grid;position:absolute}.ripple-boundary:hover,.ripple-boundary:focus-visible{color:var(--text-primary);background:var(--bg-elevated)}.ripple-prose [data-ripple-summary],.ripple-prose [data-valid-file=true]{cursor:pointer}.ripple-prose [data-valid-file=true]:hover{text-decoration:underline}.ripple-prose [data-ripple-summary]:hover{opacity:.7}.ripple-scroll,.ripple-prose pre,.ripple-rich-display{scrollbar-width:none}.ripple-scroll::-webkit-scrollbar{display:none}.ripple-prose pre::-webkit-scrollbar{display:none}.ripple-rich-display::-webkit-scrollbar{display:none}.ripple-boundary[data-edge=top]{bottom:-1.75rem}.ripple-boundary[data-edge=bottom]{bottom:0}@media (pointer:fine){.puddle-terminal-ripple{--ripple-gutter:.5rem}}.phone-terminal .puddle-terminal-ripple{--ripple-gutter:.25rem}@media (pointer:coarse){.ripple{--ripple-grip-width:2.75rem}.ripple-boundary{-webkit-touch-callout:none;height:2.75rem;bottom:-1.375rem}.ripple-boundary[data-edge=top]{bottom:-2.75rem}.ripple-boundary[data-edge=bottom]{bottom:0}}.ripple-input{cursor:text;touch-action:pan-x pinch-zoom;background:var(--bg-base);max-height:100%;color:var(--text-primary);flex:none;position:relative;overflow:clip}.ripple-input-row{white-space:pre;height:1lh}.ripple-input-row>span{vertical-align:top;display:inline-block}.ripple-input-caret{pointer-events:none;border-left:2px solid var(--text-primary);opacity:.45;position:absolute}.ripple-input-caret[data-focused=true]{opacity:1}.ripple-input-caret[data-visible=false]{visibility:hidden}.ripple-input-composition{white-space:pre;background:var(--bg-base);color:var(--text-primary);text-decoration:underline;position:absolute}.xterm .xterm-helper-textarea.ripple-input-target{left:var(--ripple-input-left)!important;top:var(--ripple-input-top)!important;height:var(--ripple-input-height)!important}
|
|
@@ -1,4 +1,4 @@
|
|
|
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{t as o}from"./createLucideIcon-DyMAgLa3.js";import{n as s}from"./errors-
|
|
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{t as o}from"./createLucideIcon-DyMAgLa3.js";import{n as s}from"./errors-CviT-mvB.js";import{n as c}from"./markdown-Dj7Cr7RL.js";import{n as l,r as u}from"./preferences-CvSHA-AA.js";import{i as d,l as f,o as p,s as m,t as h}from"./file-links-CgOYgoMC.js";import{a as g,c as _,d as v,i as y,l as b,n as x,o as S,r as C,s as w,t as T,u as E}from"./render-rich-content-fo4uQVWR.js";var D=o(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),O=e(t(),1);function k(e,t){let n=e.rows.find(e=>t>=e.start&&t<e.start+e.columns.length),r=n?.columns[t-n.start];return n&&r!==void 0?{row:n.row,col:r,line:n.text,cols:e.cols,viewport:e.viewport,bufferType:e.bufferType}:null}function A(e,t,n,r){let i=Number(e.dataset.rippleStart),a=Number(e.dataset.rippleEnd);if(!Number.isInteger(i)||!Number.isInteger(a)||i<0||a>r.length)return null;let o=r.slice(i,a),s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),c=0,l;for(;l=s.nextNode();){let e=l.textContent??``,r=o.indexOf(e,c);if(r<0)return null;if(l===t)return i+r+n;c=r+e.length}return null}function j(e,t,n,r){let i=e.ownerDocument,a=i.caretPositionFromPoint?.(n,r),o=a?null:i.caretRangeFromPoint?.(n,r),s=a?.offsetNode??o?.startContainer,c=a?.offset??o?.startOffset;if(!s||s.nodeType!==Node.TEXT_NODE||c===void 0||!e.contains(s))return null;let l=s.parentElement?.closest(`[data-ripple-start]`);if(!l||!e.contains(l)||l.closest(`.katex,[data-ripple-rich]`))return null;let u=s;for(let e of[c,c-1]){if(e<0||e>=u.length)continue;/[\uDC00-\uDFFF]/.test(u.data[e])&&e>0&&e--;let a=i.createRange();if(a.setStart(u,e),a.setEnd(u,Math.min(u.length,e+(u.data.codePointAt(e)>65535?2:1))),[...a.getClientRects()].some(e=>n>=e.left-1&&n<=e.right+1&&r>=e.top&&r<=e.bottom))return A(l,u,e,t)}return null}function M(e,t){let n=e.buffer.active;return e.cols===t.cols&&n.type===t.bufferType&&n.viewportY===t.viewport&&n.getLine(t.row)?.translateToString(!0)===t.line}function N(e,t,n={}){if(e.modes.mouseTrackingMode===`none`||!M(e,t))return!1;let r=e.buffer.active,i=e.element?.querySelector(`.xterm-screen`);if(!i)return!1;let a=i.getBoundingClientRect(),o=a.left+(t.col+.5)*a.width/e.cols,s=a.top+(t.row-r.viewportY+.5)*a.height/e.rows;if(s<a.top||s>=a.bottom)return!1;let c={bubbles:!0,cancelable:!0,button:0,clientX:o,clientY:s,shiftKey:n.shiftKey,ctrlKey:n.ctrlKey,altKey:n.altKey,metaKey:n.metaKey};return i.dispatchEvent(new MouseEvent(`mousedown`,{...c,buttons:1})),i.dispatchEvent(new MouseEvent(`mouseup`,{...c,buttons:0})),!0}var P=[`black`,`red`,`green`,`yellow`,`blue`,`magenta`,`cyan`,`white`,`brightBlack`,`brightRed`,`brightGreen`,`brightYellow`,`brightBlue`,`brightMagenta`,`brightCyan`,`brightWhite`];function F(e,t,n,r){if(t){if(r?.[e])return r[e];if(e<16){let t=n[P[e]];return t&&/^#[\da-f]{6}$/i.test(t)?t:void 0}if(e<232){let t=[0,95,135,175,215,255],n=e-16;e=t[Math.floor(n/36)]<<16|t[Math.floor(n/6)%6]<<8|t[n%6]}else{let t=8+(e-232)*10;e=t<<16|t<<8|t}}return`#${(e&16777215).toString(16).padStart(6,`0`)}`}function I(e){let t=[1,3,5].map(t=>{let n=parseInt(e.slice(t,t+2),16)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4});return t[0]*.2126+t[1]*.7152+t[2]*.0722}function L(e,t,n){if(!e||e.isInvisible?.())return``;let r=[];e.isBold?.()&&r.push(`font-weight:700`),e.isItalic?.()&&r.push(`font-style:italic`);let i=[e.isUnderline?.()?`underline`:``,e.isStrikethrough?.()?`line-through`:``,e.isOverline?.()?`overline`:``].filter(Boolean);i.length&&r.push(`text-decoration:${i.join(` `)}`);let a=e;if(e.isUnderline?.()){let i=[`solid`,`solid`,`double`,`wavy`,`dotted`,`dashed`][a.getUnderlineStyle?.()??1];if(i&&r.push(`text-decoration-style:${i}`),a.isUnderlineColorPalette?.()||a.isUnderlineColorRGB?.()){let i=a.getUnderlineColor();n?.boldBright&&e.isBold?.()&&a.isUnderlineColorPalette?.()&&i<8&&(i+=8);let o=F(i,!!a.isUnderlineColorPalette?.(),t,n?.ansi);o&&r.push(`text-decoration-color:${o}`)}}e.isDim?.()&&r.push(`opacity:0.5`);let o=e.getFgColor?.();n?.boldBright&&e.isBold?.()&&e.isFgPalette?.()&&o<8&&(o+=8);let s=e.isFgDefault?.()===!1||e.isFgPalette?.()||e.isFgRGB?.()?F(o,!!e.isFgPalette(),t,n?.ansi):void 0,c=e.isBgDefault?.()===!1||e.isBgPalette?.()||e.isBgRGB?.()?F(e.getBgColor(),!!e.isBgPalette(),t,n?.ansi):void 0;if(e.isInverse?.()&&([s,c]=[c??t.background,s??t.foreground]),c?.toLowerCase()===t.background?.toLowerCase()&&(c=void 0),!s&&c&&/^#([\da-f]{2})\1\1$/i.test(c)&&/^#[\da-f]{6}$/i.test(t.foreground??``)){let e=I(t.foreground),n=I(c);(Math.max(e,n)+.05)/(Math.min(e,n)+.05)<4.5&&(c=void 0)}return s&&/^#[\da-f]{6}$/i.test(s)&&r.push(`color:${s}`),c&&/^#[\da-f]{6}$/i.test(c)&&r.push(`background-color:${c}`),(c||i.length)&&r.push(`white-space:break-spaces`),r.join(`;`)}function R(e,t,n=[],r=!1){if(r){let n=[],r=0;for(let e of t)e.start>r&&n.push({start:r,end:e.start,css:``}),n.push(e),r=e.end;r<e.length&&n.push({start:r,end:e.length,css:``}),t=n}let i=`ripple`;for(;e.includes(i);)i+=`_`;let a=new Map,o=e.split(`
|
|
2
2
|
`),s=new Set,c=e=>e.includes(`|`)&&/^[\s|:-]+$/.test(e)&&e.includes(`-`);o.forEach((e,t)=>{if(!(!c(e)||!o[t-1]?.includes(`|`))){s.add(t-1);for(let e=t+1;e<o.length&&o[e].includes(`|`);e++)s.add(e)}});let l=0,u=o.map((e,o)=>{let u=n[o]??0,d=u>0,f=l;if(l+=e.length+1,/^\s*(`{3,}|~{3,})/.test(e)||c(e))return e;let p=e.trim()?/^(\s*(?:(?:[•●⏺✦›❯*-]|\d+[.)])\s+)?(?:#{1,6}\s+|>\s+)?)/.exec(e.slice(u))[0].length+u:0,m=[];if(s.has(o)){let t=0;for(let n=0;n<e.length;n++)e[n]!==`|`||e[n-1]===`\\`||(m.push({start:f+t,end:f+n}),t=n+1);m.push({start:f+t,end:f+e.length})}let h=m.length?t.flatMap(e=>m.filter(t=>e.start<t.end&&e.end>t.start).map(t=>({...e,start:Math.max(e.start,t.start),end:Math.min(e.end,t.end)}))):t;for(let t of h.toReversed()){let n=Math.max(p,u,t.start-f),o=Math.min(e.length,t.end-f);if(o<=n)continue;let s=e.slice(n,o);if((d||!t.css.includes(`white-space:`))&&(n+=s.length-s.trimStart().length,o-=s.length-s.trimEnd().length),o<=n)continue;let c=`${i}${a.size}\uE001`,l=d&&t.css.includes(`background-color:`)?t.css.split(`;`).filter(e=>!/^(?:background-color|white-space):/.test(e)).join(`;`):t.css,m=t.href&&/^https?:\/\//i.test(t.href)?t.href.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`):void 0,h=r?` data-ripple-start="${f+n}" data-ripple-end="${f+o}"`:``,g=l?` style="${l}"`:``;a.set(c,m?`<a href="${m}"${h}${g}>`:`<span${h}${t.action===void 0?``:` data-ripple-action="${t.action}" data-ripple-kind="${t.actionKind}" role="${t.actionRole}" tabindex="0"`}${g}>`);let _=`${i}${a.size}\uE001`;a.set(_,m?`</a>`:`</span>`),e=e.slice(0,n)+c+e.slice(n,o)+_+e.slice(o)}return d?e.trimEnd():e}).join(`
|
|
3
3
|
`),d=`${i}\\d+\uE001`,f=`${encodeURIComponent(i)}\\d+%EE%80%81`,p=RegExp(`${d}|${f}`,`gi`);return{text:u,cleanLink:e=>e.replace(p,``),restore:e=>(e=e.replace(/<[^>]*>/g,e=>e.replace(p,``)),e.replace(new RegExp(d,`g`),e=>a.get(e)??e))}}function z(e,t,n,r,i){let a=[],o=new Set,s={url:0,file:0},c=(e,t,n)=>{let r=i(e,!1),c=i(t,!0);if(r===void 0||c===void 0||c<=r)return;let l=`${n.kind}:${r}:${c}`;o.has(l)||s[n.kind]>=(n.kind===`file`?128:64)||(o.add(l),s[n.kind]++,a.push({...n,start:r,end:c}))};for(let i=n;i<r;i++){let n=e.getLine(i)?.translateToString(!0)??``;if(s.url<64&&(v(n).length||/https?:\/\//i.test(n)))for(let n of E(e,i,t))c(n.start,n.end,{kind:`url`,uri:n.candidate.uri});if(s.file<128&&m(n).length)for(let n of p(e,i,t))c(n.start,n.end,{kind:`file`,candidates:[n.candidate]})}let l=[];for(let e of a.sort((e,t)=>Number(t.kind===`url`)-Number(e.kind===`url`)||t.end-t.start-(e.end-e.start)))e.kind!==`file`&&(l.some(t=>e.start<t.end&&e.end>t.start)||l.push(e));let u=a.filter(e=>e.kind===`file`),d=[...new Set(u.flatMap(({start:e,end:t})=>[e,t]))].sort((e,t)=>e-t);for(let e=0;e<d.length-1;e++){let t=d[e],n=d[e+1];if(l.some(e=>t<e.end&&n>e.start))continue;let r=u.filter(e=>e.start<=t&&e.end>=n).flatMap(e=>e.candidates);r.length&&l.push({kind:`file`,start:t,end:n,candidates:r})}return l.sort((e,t)=>e.start-t.start)}function B(e,t){if(!t.length)return e;let n=[...new Set([...e,...t].flatMap(({start:e,end:t})=>[e,t]))].sort((e,t)=>e-t),r=[],i=0,a=0;for(let o=0;o<n.length-1;o++){let s=n[o],c=n[o+1];for(;e[i]&&e[i].end<=s;)i++;for(;t[a]&&t[a].end<=s;)a++;let l=e[i]&&e[i].start<=s?e[i]:void 0,u=t[a]&&t[a].start<=s?a:-1;!l&&u<0||r.push({...l,start:s,end:c,css:l?.css??``,...u>=0&&!l?.href?{action:u,actionKind:t[u].kind,actionRole:`link`}:{}})}return r}var V=32768;function H(e,t,n,r={},i){let a=Math.min(e.length,n?.last??e.length),o=Math.min(600,Math.floor(V/(t+1))),s=Math.max(0,n?.first??0,a-o);for(;!n&&s<a&&e.getLine(s)?.isWrapped;)s++;let c=[],l=new Map,u=0,d=0,p=[];for(let o=s;o<a;o++){let a=f(e,o,t,n);if(!a)break;let s=!1,m=a.text.split(``).map((t,n)=>{let r=a.cells[n];return e.getLine(o)?.getCell(r.col)?.isInvisible?.()?(s=!0,` `):t}).join(``),h=e.getLine(o+1)?.isWrapped?m.length:m.trimEnd().length;for(let t=m.length-1;t>=h;t--){let n=e.getLine(o)?.getCell(a.cells[t].col);if(n&&!n.isInvisible?.()&&L(n,r,i).includes(`white-space:`)){h=t+1;break}}let g=m.slice(0,h);if(u+g.length+1>32768)break;u+=g.length+1,!a.isWrapped&&c.length&&d++;for(let t=0;t<g.length;t++){let n=e.getLine(o)?.getCell(a.cells[t].col),s=L(n,r,i),c=n&&i?.link?.(n);if(!s&&!c)continue;let l=p.at(-1),u=d+t;l&&l.end===u&&l.css===s&&l.href===c?l.end++:p.push({start:u,end:u+1,css:s,...c&&{href:c}})}l.set(o,{offset:d,cells:a.cells,length:g.length,concealed:s}),d+=g.length,a.isWrapped&&c.length?c[c.length-1]+=g:c.push(g)}let m=c.join(`
|
|
4
4
|
`),h=m.slice(0,Math.max(m.trimEnd().length,p.at(-1)?.end??0)),g=z(e,t,s,a,(t,n)=>{let r=l.get(t.row);if(!r||r.concealed)return;let i=n?r.cells.findLastIndex(e=>e.col<=t.col):r.cells.findIndex(e=>e.col===t.col);if(i<0||i>=r.length)return;let a=r.cells[i].col,o=e.getLine(t.row)?.getCell(a)?.getWidth()??1;if(!(t.col>=a+Math.max(1,o)))return r.offset+i+ +!!n});p=B(p,g);let _=[],v=(e,t)=>{let r=p.filter(n=>n.end>e&&n.start<t).map(n=>({...n,start:Math.max(e,n.start)-e,end:Math.min(t,n.end)-e}));_.push({kind:`text`,source:h.slice(e,t),...n&&{offset:e},...r.length?{styles:r}:{}})},y=0;for(let r of C(e,t,s,a-s,n)){let e=l.get(r.start.row),t=l.get(r.end.row);if(!e||!t||[...l.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),o=Math.min(h.length,t.offset+Math.min(t.length,i));a<y||o<=a||(a>y&&v(y,a),_.push({kind:r.kind,source:r.source,display:r.display}),y=o)}return y<h.length&&v(y,h.length),{text:h,truncated:s>0,alternate:e.type===`alternate`,parts:_,...g.length?{actions:g}:{},...n&&{sourceMap:{cols:t,viewport:e.viewportY,bufferType:e.type,rows:[...l.entries()].filter(([,e])=>!e.concealed).map(([t,n])=>({row:t,start:n.offset,columns:n.cells.slice(0,n.length).map(e=>e.col),text:e.getLine(t)?.translateToString(!0)??``}))}},...i&&{foreground:r.foreground,background:r.background}}}function U(e,t=!1,n=!1,r={}){let i=e.split(`
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import{t as n}from"./react-CZI7_Jkm.js";import{n as r,o as i,u as a}from"./protocol-support-iXloAH0N.js";import{A as o,D as s,E as c,O as l,Sn as u,_n as d,bn as f,k as p,kn as m,vn as h,wn as g,yn as _}from"./local-store-Dy1Cd8sn.js";import{i as v,r as y}from"./LazyTerminal-BEOPZDJH.js";import{A as b,C as x,E as S,O as C,S as w,_ as ee,a as T,b as te,c as ne,d as re,f as ie,i as ae,j as oe,k as se,l as ce,m as le,n as ue,o as de,r as fe,s as pe,t as me,u as he,v as ge,x as _e,y as ve}from"./notification-delivery-D99P0nLs.js";import{a as ye,i as be,r as E,t as xe}from"./client-settings-BdKglwtW.js";import{c as Se,t as Ce}from"./theme-swfNLod9.js";import{t as we}from"./jsx-runtime-By8HlURe.js";import{r as Te}from"./index-LRHyaDMJ.js";import{n as Ee,t as De}from"./api-CrP4jl9e.js";import{i as D,l as Oe,n as ke}from"./profile-store-D4lZiXgL.js";import{D as Ae,E as je,H as Me,I as Ne,L as O,N as Pe,P as Fe,V as k,W as Ie,X as Le,Y as Re,b as ze,c as Be,f as Ve,ht as He,it as Ue,j as We,k as Ge,p as Ke,r as qe,s as Je,v as Ye,w as Xe,x as Ze,z as Qe}from"./queries-BSkHGZG8.js";import{a as $e,n as et}from"./use-desktop-state-CBTzsmlz.js";import{t as A}from"./utils-B6KiDbIe.js";import{a as j,i as M,n as tt,o as nt,r as N,s as P,t as F}from"./dialog-CTN-Lln6.js";import{n as I}from"./dist-BOS6OKSE.js";import{t as rt}from"./x-CbfJFzGo.js";import{a as L,i as R,n as z,r as B,t as V}from"./select-DzQdQNsv.js";import{t as H}from"./button-D-qeQvl5.js";import{n as U,r as it}from"./chevron-right-DUkOv15w.js";import{a as at,o as ot,t as st}from"./colour-picker-DZdAiaVI.js";import{t as ct}from"./createLucideIcon-DyMAgLa3.js";import{t as lt}from"./profile-icons-BI2xFWcB.js";import{n as ut,t as dt}from"./shield-check-CY69Ons-.js";import{i as ft,r as pt,t as W}from"./switch-CGrhQUXr.js";import{t as mt}from"./code-DRWf9a5s.js";import{n as ht,t as gt}from"./disclosure-CpSwsC7J.js";import{t as _t}from"./rotate-ccw-CNjR2LSi.js";import{t as vt}from"./trash-2-WYPJMQLN.js";import{a as yt,i as bt,n as xt,r as St,t as Ct}from"./session-display-BUDNzNmg.js";import{a as wt,n as Tt,o as Et,p as Dt,t as Ot}from"./hotkeys-nP8gYtE7.js";import{t as kt}from"./control-tray-CjoJunx1.js";import{n as G}from"./errors-CviT-mvB.js";import{t as At}from"./use-debounced-value-C86N-mOK.js";import{n as jt,r as Mt,t as Nt}from"./popover-Okyclsx8.js";import{t as Pt}from"./preferences-CvSHA-AA.js";import{a as Ft,o as It,r as Lt,t as Rt,u as zt}from"./CompilationCommandForm-DXHvwQ8Y.js";var Bt=ct(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Vt=ct(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),Ht=ct(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),Ut=ct(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),K=e(n(),1),q=we();function J({id:e,value:t,min:n,max:r,step:i,className:a,onCommit:o}){let[s,c]=(0,K.useState)(String(t));return(0,K.useEffect)(()=>c(String(t)),[t]),(0,q.jsx)(U,{id:e,type:`number`,min:n,max:r,step:i,className:a,value:s,onChange:e=>c(e.target.value),onBlur:()=>{let e=Number(s);if(s.trim()===``||!Number.isFinite(e)){c(String(t));return}let i=Math.min(r??e,Math.max(n??e,e));c(String(i)),i!==t&&o(i)},onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}})}function Y({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,q.jsxs)(`div`,{className:A(`flex items-center gap-4 py-2.5`,a),children:[(0,q.jsxs)(`label`,{htmlFor:r,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,q.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:A(`text-xs text-fg-muted`,n),children:t})]}),(0,q.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function X({children:e,note:t}){return(0,q.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,q.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function Wt(){return(0,q.jsx)(Y,{label:`Ripple (experimental)`,description:`Start with Ripple covering output and input. When off, start with the full CLI. Drag the handle to adjust either view.`,htmlFor:`ripple-enabled`,children:(0,q.jsx)(W,{id:`ripple-enabled`,checked:be().rippleEnabled===!0,onCheckedChange:e=>{E({rippleEnabled:e}),Pt()}})})}function Gt(){let e=be(),[t,n]=(0,K.useState)(Se());return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Appearance`}),(0,q.jsx)(Y,{label:`Theme`,children:(0,q.jsxs)(V,{value:t,onValueChange:e=>{n(e),Ce(e)},children:[(0,q.jsx)(R,{className:`w-32`,children:(0,q.jsx)(L,{})}),(0,q.jsxs)(z,{children:[(0,q.jsx)(B,{value:`dark`,children:`Dark`}),(0,q.jsx)(B,{value:`light`,children:`Light`}),(0,q.jsx)(B,{value:`system`,children:`System`})]})]})}),(0,q.jsx)(Y,{label:`Cursor style`,children:(0,q.jsxs)(V,{value:e.cursorPackage,onValueChange:e=>E({cursorPackage:e}),children:[(0,q.jsx)(R,{className:`w-36`,children:(0,q.jsx)(L,{})}),(0,q.jsx)(z,{children:ye.map(e=>(0,q.jsx)(B,{value:e.id,children:e.label},e.id))})]})}),(0,q.jsx)(Y,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,q.jsx)(J,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>E({uiFontSize:e})})}),(0,q.jsx)(Y,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,q.jsx)(J,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>E({terminalFontSize:e})})}),(0,q.jsx)(Y,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,q.jsx)(J,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>E({editorFontSize:e})})}),(0,q.jsx)(Y,{label:`Density`,children:(0,q.jsxs)(V,{value:e.density,onValueChange:e=>E({density:e}),children:[(0,q.jsx)(R,{className:`w-36`,children:(0,q.jsx)(L,{})}),(0,q.jsxs)(z,{children:[(0,q.jsx)(B,{value:`compact`,children:`Compact`}),(0,q.jsx)(B,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,q.jsx)(Y,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,q.jsx)(W,{id:`project-based-layout`,checked:et(e.projectBasedLayout)??e.projectBasedLayout,onCheckedChange:e=>{$e(e),E({projectBasedLayout:e})}})}),(0,q.jsx)(Y,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,q.jsx)(W,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>E({showAllProjectSessions:e})})}),(0,q.jsx)(Wt,{}),(0,q.jsx)(Y,{label:`Reduced animation and motion`,htmlFor:`reduce-motion`,children:(0,q.jsx)(W,{id:`reduce-motion`,checked:e.reduceMotion,onCheckedChange:e=>E({reduceMotion:e})})}),(0,q.jsx)(Y,{label:`Show host when returning to the window`,description:`Briefly show the host icon and name when this window or browser tab regains focus.`,htmlFor:`show-host-on-focus`,children:(0,q.jsx)(W,{id:`show-host-on-focus`,checked:e.showHostOnFocus,onCheckedChange:e=>E({showHostOnFocus:e})})})]})}function Kt({profile:e}){let t=Ne(),[n,r]=(0,K.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>G(e)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>G(e)});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Icon`,children:(0,q.jsxs)(Nt,{open:n,onOpenChange:r,children:[(0,q.jsx)(Mt,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,className:`flex size-9 items-center justify-center rounded-md text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(se,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,q.jsx)(jt,{align:`end`,className:`w-72`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,title:`Default`,onClick:()=>i(null),className:A(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,!e.icon&&`bg-elevated text-fg`),children:(0,q.jsx)(se,{icon:null,colour:null,className:`size-4`})}),lt.map(({name:t,Icon:n})=>(0,q.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:A(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,e.icon===t&&`bg-elevated text-fg`),children:(0,q.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,q.jsx)(Y,{label:`Icon colour`,children:(0,q.jsx)(st,{onCustomChange:a,value:e.icon_colour,onChange:a,label:`Icon colour`})})]})}var qt=`__none__`;function Jt(){let e=D(),t=Me().data?.find(t=>t.id===e),n=Je(e??void 0),r=k(e??void 0),i=Ne(),a=O(e??``),o=Xe(),[s,c]=(0,K.useState)(``),[l,u]=(0,K.useState)(``),[d,f]=(0,K.useState)(!1),[p,m]=(0,K.useState)(``);if((0,K.useEffect)(()=>{t&&(c(t.name),u(t.branch_prefix))},[t]),!t)return null;let h=r.data?.default_account_id;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Profile`}),(0,q.jsxs)(Y,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,q.jsx)(U,{id:`profile-name`,value:s,onChange:e=>c(e.target.value),className:`w-44`}),(0,q.jsx)(H,{size:`sm`,variant:`secondary`,disabled:s===t.name||s.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:s},{onError:e=>G(e)}),children:`Save`})]}),(0,q.jsxs)(Y,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,q.jsx)(U,{id:`branch-prefix`,value:l,onChange:e=>u(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,q.jsx)(H,{size:`sm`,variant:`secondary`,disabled:l===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:l},{onError:e=>G(e)}),children:`Save`})]}),(0,q.jsx)(Kt,{profile:t}),(0,q.jsx)(Y,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,q.jsxs)(V,{value:typeof h==`number`?String(h):qt,onValueChange:e=>a.mutate({default_account_id:e===qt?null:Number(e)},{onError:e=>G(e)}),children:[(0,q.jsx)(R,{className:`w-56`,children:(0,q.jsx)(L,{})}),(0,q.jsxs)(z,{children:[(0,q.jsx)(B,{value:qt,children:`First available`}),n.data?.map(e=>(0,q.jsx)(B,{value:String(e.id),children:(0,q.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,q.jsx)(Y,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,q.jsx)(H,{variant:`danger`,size:`sm`,onClick:()=>f(!0),children:`Delete…`})}),(0,q.jsx)(F,{open:d,onOpenChange:e=>{e||(f(!1),m(``))},children:(0,q.jsxs)(N,{children:[(0,q.jsxs)(nt,{children:[(0,q.jsxs)(P,{children:[`Delete profile `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,q.jsx)(M,{children:`Everything this profile owns goes with it: projects, workspace layouts, accounts and their credential directories, and archived session history. Branches, repositories, and terminal logs on disk are untouched. This cannot be undone.`})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(ot,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,q.jsx)(U,{id:`delete-confirm-name`,value:p,onChange:e=>m(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(j,{children:[(0,q.jsx)(H,{variant:`ghost`,onClick:()=>{f(!1),m(``)},children:`Cancel`}),(0,q.jsx)(H,{variant:`danger`,disabled:p!==t.name||o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>{xt(),ke.set(null)},onError:e=>{f(!1),m(``),G(e)}}),children:`Delete profile`})]})]})})]})}function Yt({agent:e,profileId:t,onClose:n,onCreated:r}){let i=Ke(),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),l=je(At(s,150)),u=s.trim(),d=u===``||u.startsWith(`/`)||u.startsWith(`~`),f=a.trim()!==``&&d,p=()=>{!f||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...u===``?{}:{import_dir:u}},{onSuccess:e=>{n(),r(e,u!==``)},onError:e=>G(e)})};return(0,q.jsx)(F,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(N,{children:[(0,q.jsxs)(nt,{children:[(0,q.jsxs)(P,{children:[`Add a `,e.display_name,` account`]}),(0,q.jsxs)(M,{children:[`Accounts are isolated config dirs under this profile. Naming one is enough — Puddle creates it and takes you straight to `,e.display_name,`’s login. To reuse an account you already have on this machine, give its config directory: it is copied in and the original is never touched.`]})]}),(0,q.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,q.jsx)(U,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(y,{value:s,onValueChange:c,placeholder:`(optional) existing config dir, e.g. ~/.claude`,hints:(l.data?.entries??[]).map(e=>({value:e.path,label:e.name}))})]}),(0,q.jsxs)(j,{children:[(0,q.jsx)(H,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,q.jsxs)(H,{disabled:!f||i.isPending,onClick:p,children:[(0,q.jsx)(ht,{}),`Add account`]})]})]})})}function Xt({account:e,gateOpen:t,installed:n}){let r=We(),i=Pe(),a=Ze(),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1),[u,d]=(0,K.useState)(e.label),f=(0,K.useRef)(null);return(0,K.useEffect)(()=>d(e.label),[e.label]),(0,q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(`input`,{ref:f,value:u,onChange:e=>d(e.target.value),onBlur:()=>{let t=u.trim();if(t!==e.label){if(t===``){d(e.label);return}i.mutate({id:e.id,label:t},{onError:t=>{G(t),d(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(d(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full min-w-0 truncate rounded-sm bg-transparent px-1 py-0.5 text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,q.jsxs)(`button`,{type:`button`,title:`Rename account`,onClick:()=>{f.current?.focus(),f.current?.select()},className:`shrink-0 rounded-sm p-0.5 text-fg-muted transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(at,{className:`size-3`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Rename account`})]})]}),(0,q.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,q.jsx)(W,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>G(e)})})]}),(0,q.jsxs)(H,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>G(e)}),children:[(0,q.jsx)(oe,{}),e.logged_in?`Re-login`:`Login`]}),(0,q.jsxs)(H,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,q.jsx)(vt,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,q.jsx)(x,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,q.jsx)(F,{open:c,onOpenChange:l,children:(0,q.jsxs)(N,{children:[(0,q.jsxs)(nt,{children:[(0,q.jsxs)(P,{children:[`Delete `,(0,q.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,q.jsx)(M,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,q.jsxs)(j,{children:[(0,q.jsx)(H,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,q.jsx)(H,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),G(e)}}),children:`Delete account`})]})]})})]})}function Zt(){let e=D(),t=Be(),n=Je(e??void 0),r=k(e??void 0),i=We(),[a,o]=(0,K.useState)(null),[s,c]=(0,K.useState)(null),l=r.data?.allowSkipPermissions===!0;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[],r=e.available!==!1;return(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(Y,{label:e.display_name,description:r?`Accounts are initialised in config dirs owned by this profile.`:`No ${e.binary??e.id} on the daemon’s PATH. Install it or add its directory to the agent search path in Sessions.`,className:`py-1`,children:(0,q.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.id})}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,q.jsx)(Xt,{account:t,gateOpen:l&&e.capabilities.skip_permissions,installed:r},t.id)),(0,q.jsx)(`div`,{className:`flex`,children:(0,q.jsxs)(H,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>c(e),children:[(0,q.jsx)(ht,{}),`Add account`]})})]})]},e.id)}),a&&(0,q.jsx)(x,{stream:a.stream,label:a.label,hint:a.hint,onClose:()=>o(null)}),s!==null&&e!==null&&(0,q.jsx)(Yt,{agent:s,profileId:e,onClose:()=>c(null),onCreated:(e,t)=>{if(t){e.logged_in||I.info(`Imported without credentials — press Login to authenticate.`);return}i.mutate(e.id,{onSuccess:t=>o({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>G(e)})}})]})}function Qt(){let e=Ve(),t=Fe(),[n,r]=(0,K.useState)(``);return(0,K.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,q.jsx)(Y,{label:`Agent search path (host-wide)`,description:`Colon-separated dirs the daemon prepends to PATH; helps find agent CLIs like claude (e.g. ~/.local/bin).`,htmlFor:`agent-path`,children:(0,q.jsx)(U,{id:`agent-path`,type:`text`,className:`w-64 text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function $t({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=zt(e,n),o=n.sessionDefaults??{},[s,c]=(0,K.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,q.jsx)(Y,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,q.jsx)(U,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,q.jsx)(Y,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,q.jsx)(W,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,q.jsx)(Y,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`Start on working copy of the selected branch instead of sharing one directory.`,htmlFor:`${e}-default-dir`,children:(0,q.jsx)(W,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function en(){return(0,q.jsx)(Y,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,q.jsx)(J,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:be().terminalScrollback,onCommit:e=>E({terminalScrollback:e})})})}function tn({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,K.useState)(r);return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,q.jsx)(it,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(H,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,q.jsx)(H,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var nn={id:`4f3c2b1a-7e6d-5c4b-3a2f-1e0d9c8b7a6f`,title:null,agent_title:`Refactor the auth flow`,osc_title:`claude`,branch:`alice/refactor-auth`,worktree_path:`/home/alice/code/app--refactor-auth`,status:`waiting_input`,agent_type:`claude-code`};function rn({initial:e,onSave:t,pending:n}){let[r,i]=(0,K.useState)(e),a=r.length>0?r:f;return(0,q.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,q.jsx)(U,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:f}),(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,q.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:Ct(nn,a)})]}),(0,q.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:u.map(([e,t])=>(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,q.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(H,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,q.jsx)(H,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(f),t(f)},children:`Reset to default`})]})]})}function an(){let e=D(),t=Me().data?.find(t=>t.id===e),n=k(e??void 0),r=O(e??``),[i,a]=(0,K.useState)(!1),[o,s]=(0,K.useState)(``),c=n.data?.allowSkipPermissions===!0,l=e=>r.mutate({allowSkipPermissions:e},{onSuccess:()=>{a(!1),s(``)},onError:e=>G(e)}),u=e=>t=>r.mutate({[e]:t},{onError:e=>G(e)});return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sessions`}),(0,q.jsx)(Y,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,q.jsx)(W,{id:`gate`,checked:c,onCheckedChange:e=>{e?a(!0):l(!1)}})}),(0,q.jsx)(Y,{label:`Capture exported env variables`,description:n.data?.captureSessionEnv===!1?`No variables are captured or injected; already-captured variabless are kept for when this is re-enabled.`:`Variables exported in a session persist and are re-injected upon terminal and agent restarts.`,htmlFor:`capture-env`,children:(0,q.jsx)(W,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:r.isPending,onCheckedChange:e=>r.mutate({captureSessionEnv:e},{onError:e=>G(e)})})}),(0,q.jsx)(Qt,{}),(0,q.jsx)(en,{}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`New session defaults`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)($t,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>G(e)}),pending:r.isPending},`${e}:agent-seed`),(0,q.jsx)($t,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>r.mutate({sessionDefaults:e},{onError:e=>G(e)}),pending:r.isPending},`${e}:terminal-seed`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{note:`Sent to agent as opening message when a session (re)starts. You can make this empty.`,children:`Launch text`}),n.data&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(tn,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??h,defaultText:h,onSave:u(`onboardingTemplate`),pending:r.isPending},`${e}:onboarding`),(0,q.jsx)(tn,{id:`concurrent-template`,label:`Existing / shared worktree`,description:`For a session joining a worktree other agents may already be working in.`,initial:n.data.concurrentTemplate??d,defaultText:d,onSave:u(`concurrentTemplate`),pending:r.isPending},`${e}:concurrent`),(0,q.jsx)(tn,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??_,defaultText:_,onSave:u(`restartTemplate`),pending:r.isPending},`${e}:restart`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`Tab title`}),n.data&&(0,q.jsx)(rn,{initial:n.data.tabTitleTemplate||"${name}",onSave:u(`tabTitleTemplate`),pending:r.isPending},`${e}:tab-title`)]}),(0,q.jsx)(F,{open:i,onOpenChange:e=>{e||(a(!1),s(``))},children:(0,q.jsxs)(N,{children:[(0,q.jsxs)(nt,{children:[(0,q.jsxs)(P,{className:`flex items-center gap-2`,children:[(0,q.jsx)(Vt,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,q.jsx)(M,{asChild:!0,children:(0,q.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,q.jsx)(`p`,{children:`A prompt-free agent acts unattended, with your credentials, inside its worktree — and nothing technically stops a shell command from reaching outside it. It can:`}),(0,q.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,q.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,q.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,q.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,q.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,q.jsx)(`p`,{children:`Only open this gate if every account you opt in runs work you would trust a colleague to run unsupervised on this machine.`}),(0,q.jsx)(`p`,{className:`text-fg-muted`,children:`Opening it also records the agent’s own bypass-permissions acceptance for this profile’s accounts, so the skip actually takes effect.`})]})})]}),(0,q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,q.jsxs)(ot,{htmlFor:`confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,q.jsx)(U,{id:`confirm-name`,value:o,onChange:e=>s(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(j,{children:[(0,q.jsx)(H,{variant:`ghost`,onClick:()=>{a(!1),s(``)},children:`Cancel`}),(0,q.jsx)(H,{variant:`danger`,disabled:o!==t?.name||r.isPending,onClick:()=>l(!0),children:`Open the gate`})]})]})})]})}var on=m.parse({});function sn(){let[e,t]=(0,K.useState)(ae);return(0,K.useEffect)(()=>{let e=()=>t(ae());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(ae())]}function cn({permission:e,onRequest:t}){return e===`granted`||e===`unverified`?null:(0,q.jsxs)(`p`,{className:`pb-2 text-xs text-warning`,children:[e==="default"&&(0,q.jsxs)(q.Fragment,{children:[`The browser has not been asked for permission yet, so nothing will show —`,` `,(0,q.jsx)(`button`,{type:`button`,onClick:t,className:`underline underline-offset-2 transition-colors hover:text-fg`,children:`request it now`}),`.`]}),e===`denied`&&`Blocked by the browser — allow notifications for this site in its site settings, then return here.`,e===`unsupported`&&`This browser cannot show desktop notifications.`]})}function ln(){let e=D(),t=k(e??void 0),n=O(e??``),r=Ie(e??void 0),[i,a]=sn(),o=fe(),[s,c]=(0,K.useState)(!1);(0,K.useEffect)(()=>{ue();let e=()=>void ue();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]);let l=m.catch(on).parse(t.data?.notifications??{}),u=e=>n.mutate({notifications:e},{onError:e=>G(e)}),d=()=>{Oe()?.showNotification||typeof Notification>`u`||Notification.requestPermission().then(a)};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Notifications`}),(0,q.jsx)(Y,{label:`Agent notifications`,htmlFor:`notify-desktop`,children:(0,q.jsx)(W,{id:`notify-desktop`,checked:l.desktop,onCheckedChange:e=>{e&&d(),u({...l,desktop:e})}})}),l.desktop&&(0,q.jsx)(cn,{permission:i,onRequest:d}),(0,q.jsx)(Y,{label:`Notify while interacting with a session`,htmlFor:`notify-focused`,description:`When off, typing or clicking in a session silences its desktop alerts for five seconds. Mobile Web Push is configured separately on each device.`,children:(0,q.jsx)(W,{id:`notify-focused`,checked:l.when_focused,onCheckedChange:e=>u({...l,when_focused:e})})}),(0,q.jsx)(Y,{label:`Test delivery`,description:`Send a notification to check this device’s permissions.`,children:(0,q.jsx)(H,{variant:`ghost`,disabled:s,onClick:()=>{c(!0),(async()=>{!Oe()?.showNotification&&typeof Notification<`u`&&Notification.permission==="default"&&(await Notification.requestPermission(),a()),await me({id:`puddle-test`,title:`Puddle`,body:`Notifications are working on this device.`},()=>{})})().catch(G).finally(()=>c(!1))},children:s?`Sending…`:`Send test`})}),(0,q.jsx)(`p`,{role:`status`,className:`pb-2 text-xs text-fg-muted`,children:o.state===`shown`?`The system accepted the notification. Banner visibility also depends on Focus / Do Not Disturb.`:o.message??`Delivery has not been tested on this device.`}),(0,q.jsx)(Y,{label:`Sound`,htmlFor:`notify-sound`,children:(0,q.jsx)(W,{id:`notify-sound`,checked:l.sound,onCheckedChange:e=>u({...l,sound:e})})}),(0,q.jsx)(Y,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,q.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[l.muted_projects.length,` muted`]})}),(0,q.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.data?.map(e=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,q.jsx)(W,{checked:l.muted_projects.includes(e.id),onCheckedChange:t=>u({...l,muted_projects:t?[...l.muted_projects,e.id]:l.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function un(){let e=D(),t=r(ze().data?.protocol),n=Ft(t&&e!==null),[i,a]=(0,K.useState)(null),o=n.data?.providers??[],s=o.find(e=>e.id===i)??o[0];return!t||!e?null:(0,q.jsxs)(`div`,{className:`mt-8`,children:[(0,q.jsx)(X,{note:`Defaults for this profile on the connected host. Individual files can override them from their tab menu.`,children:`Compilation & running code`}),n.isLoading?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Loading languages…`}):n.isError?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:`Couldn’t load languages.`}):s?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Language`,htmlFor:`compilation-language`,children:(0,q.jsxs)(V,{value:s.id,onValueChange:a,children:[(0,q.jsx)(R,{id:`compilation-language`,className:`w-48`,children:(0,q.jsx)(L,{})}),(0,q.jsx)(z,{children:o.map(e=>(0,q.jsx)(B,{value:e.id,detail:e.available?void 0:`Not installed`,children:e.display_name},e.id))})]})}),!s.available&&(0,q.jsxs)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:[`No supported `,s.display_name,` tool is installed on this host. Saved commands apply when a supported tool is available.`]}),(0,q.jsx)(dn,{request:{profile_id:e,provider:s.id}},`${e}:${s.id}`)]}):(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No languages advertised by this host.`})]})}function dn({request:e}){let t=It(e),n=He();return t.isLoading?(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`Loading commands…`}):t.isError?(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t.error instanceof Error?t.error.message:`Couldn’t load commands`}):t.data?(0,q.jsx)(Rt,{settings:t.data,onSave:async t=>{for(let r of t){let t=await Lt({...e,...r});n.setQueryData([`compilation-defaults`,e],t),await n.invalidateQueries({queryKey:[`compilation-settings`]})}}}):null}function fn(){let e=be();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Editor`}),(0,q.jsx)(Y,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,q.jsx)(J,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>E({editorTabSize:e})})}),(0,q.jsx)(Y,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,q.jsx)(W,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>E({editorWordWrap:e})})}),(0,q.jsx)(Y,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,q.jsx)(U,{id:`editor-link-host`,type:`text`,placeholder:Te.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>E({editorLinkSshHost:e.target.value})})}),(0,q.jsx)(un,{})]})}function pn({value:e,isDefault:t,onRecord:n,onReset:r}){let[i,a]=(0,K.useState)(!1);return(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(`button`,{type:`button`,"data-hotkey-recording":i||void 0,onClick:()=>a(!0),onBlur:()=>a(!1),onKeyDown:e=>{if(!i)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){a(!1);return}let t=wt(e.nativeEvent);t&&(n(t),a(!1))},className:A(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,i?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:i?`Press keys…`:Et(e)}),!t&&(0,q.jsxs)(`button`,{type:`button`,title:`Reset to default`,onClick:r,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(_t,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function mn(){let e=D(),t=k(e??void 0),n=O(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of Ot){let t=i(e.id,Dt(e));a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>G(e)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>G(e)})};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Hotkeys`}),(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),(0,q.jsx)(Y,{label:`App shortcuts in terminals`,description:t.data?.terminalAppShortcuts===!1?`A focused terminal receives these keys instead.`:`The shortcuts below work while a terminal is focused.`,htmlFor:`terminal-app-shortcuts`,className:`mb-4`,children:(0,q.jsx)(W,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>G(e)})})}),Tt.map(e=>{let t=Ot.filter(t=>t.group===e);return t.length===0?null:(0,q.jsxs)(`div`,{className:`mb-5`,children:[(0,q.jsx)(`div`,{className:`mb-1 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e}),t.map(e=>{let t=i(e.id,Dt(e)),n=(a.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,q.jsx)(Y,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,q.jsx)(pn,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(e.id)})},e.id)})]},e)})]})}var hn=e=>[...e].map(e=>e.toString(16).padStart(2,`0`)).join(``);function gn(e,t){let[n,r]=(0,K.useState)(null),[i,a]=(0,K.useState)(!0),[o,c]=(0,K.useState)(``),u=(0,K.useRef)(0),d=(0,K.useRef)(null);(0,K.useEffect)(()=>()=>{u.current+=1},[]),(0,K.useEffect)(()=>{if(n)return;let e=!0;return d.current=null,a(!0),(async()=>{try{let t=hn(crypto.getRandomValues(new Uint8Array(32))),n=hn(new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(t))));e&&(d.current={code:t,challenge:n})}catch(t){e&&c(t instanceof Error?t.message:`Could not prepare sign-in.`)}finally{e&&a(!1)}})(),()=>{e=!1,d.current=null}},[n]);let f=(0,K.useRef)(t);return(0,K.useEffect)(()=>{f.current=t},[t]),(0,K.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>{u.current+=1,r(null),c(`Sign-in expired. Try again.`)},Math.max(0,n.request.expires-Date.now()));return()=>clearTimeout(e)},[n]),(0,K.useEffect)(()=>{if(!n||e)return;let t=u.current,i=!1,a,o=async()=>{try{if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);let{ready:e}=l.parse(await Ee(`POST`,`/frontend/remote/registration`,{service:n.request.service,code:n.code}));if(i||t!==u.current)return;if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);e?(r(null),await f.current({t:`enable`,registration:{service:n.request.service,app:n.request.app,code:n.code}})):a=setTimeout(()=>void o(),2e3)}catch(e){if(i||t!==u.current)return;r(null),c(e instanceof Error?e.message:`Sign-in failed. Try again.`)}};return a=setTimeout(()=>void o(),2e3),()=>{i=!0,clearTimeout(a)}},[n,e]),{attempt:n,preparing:i,error:o,begin:(t,n,i)=>{if(!(e||!d.current)){c(``);try{let{code:e,challenge:a}=d.current,o=s.safeParse({service:t.trim(),app:n.trim(),label:i.trim(),challenge:a,expires:Date.now()+p.invitationMs});if(!o.success)throw Error(`Enter a host name and exact HTTPS application and relay origins.`);let c=o.data,l=`${c.app}/#register=${encodeURIComponent(JSON.stringify(c))}`;u.current+=1,d.current=null,r({request:c,code:e,url:l}),window.open(l,`_blank`,`noopener,noreferrer`)}catch(e){c(e instanceof Error?e.message:`Could not start sign-in.`)}}},cancel:()=>{u.current+=1,d.current=null,a(!0),r(null)}}}function _n({service:e=`https://charles.waddlelabs.ai`,app:t=`https://puddle.waddlelabs.ai`,hostName:n,busy:r,disabled:i,enable:a,cancel:o}){let[s,c]=(0,K.useState)(e),[l,u]=(0,K.useState)(t),[d,f]=(0,K.useState)(n),p=gn(i,a),m=i||p.preparing||!!p.attempt;return(0,q.jsxs)(`form`,{className:`mt-4 space-y-4`,onSubmit:e=>{e.preventDefault(),m||p.begin(s,l,d)},children:[(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Application origin`,(0,q.jsx)(U,{type:`url`,required:!0,value:l,onChange:e=>u(e.target.value),placeholder:`https://app.example.com`,autoComplete:`off`,disabled:m})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Relay origin`,(0,q.jsx)(U,{type:`url`,required:!0,value:s,onChange:e=>c(e.target.value),placeholder:`https://relay.example.com`,autoComplete:`off`,disabled:m})]}),(0,q.jsxs)(`label`,{className:`grid gap-1.5 text-sm`,children:[`Host name`,(0,q.jsx)(U,{required:!0,maxLength:80,value:d,onChange:e=>f(e.target.value),disabled:m})]}),o&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Saving a new registration revokes existing browser approvals and invitations.`}),p.error&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:p.error}),p.attempt?(0,q.jsxs)(`div`,{className:`space-y-3 text-sm`,children:[(0,q.jsxs)(`p`,{role:`status`,children:[`Confirm this host in your browser. Match request`,` `,(0,q.jsx)(`strong`,{className:`font-mono`,children:p.attempt.request.challenge.slice(0,8).toUpperCase()}),`. Sign-in expires in five minutes.`]}),(0,q.jsx)(`a`,{href:p.attempt.url,target:`_blank`,rel:`noreferrer`,className:`text-accent hover:opacity-80`,children:`Continue in browser ↗`}),(0,q.jsx)(H,{type:`button`,variant:`ghost`,onClick:p.cancel,children:`Cancel sign-in`})]}):(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,q.jsx)(H,{type:`submit`,disabled:m||!d.trim()||!s||!l,children:r?`Enabling…`:p.preparing?`Preparing sign-in…`:`Sign in and enable`}),o&&(0,q.jsx)(H,{type:`button`,variant:`ghost`,disabled:m,onClick:o,children:`Cancel`})]})]})}var vn=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),Z=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),yn=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),bn=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),xn=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Sn=t((e=>{var t=Z().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),Cn=t((e=>{var t=Z().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),wn=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),Tn=t((e=>{var t=yn(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),En=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Dn=t((e=>{var t=En();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),On=t(((e,t)=>{var n=Dn();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),kn=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),An=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
|
|
2
|
+
]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^[0-9]+$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),Q=t((e=>{var t=kn(),n=An();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),jn=t((e=>{var t=Z(),n=Tn(),r=yn(),i=Q(),a=kn(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),Mn=t((e=>{var t=Z(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),Nn=t(((e,t)=>{var n=Q();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),Pn=t(((e,t)=>{var n=Q(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),Fn=t(((e,t)=>{var n=Q();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),In=t(((e,t)=>{var n=Q(),r=Z();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
|
|
3
|
+
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),Ln=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),Rn=t((e=>{var t=Q(),n=Nn(),r=Pn(),i=Fn(),a=In(),o=An(),s=Z(),c=Ln();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
|
|
4
|
+
Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),zn=t((e=>{var t=Z(),n=yn(),r=bn(),i=xn(),a=Sn(),o=Cn(),s=wn(),c=Tn(),l=On(),u=jn(),d=Mn(),f=Q(),p=Rn();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
|
|
5
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
6
|
+
Minimum version required to store current data is: `+c+`.
|
|
7
|
+
`);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),Bn=t((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),Vn=t((e=>{var t=Bn();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),Hn=t((e=>{var t=Bn();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
|
|
8
|
+
`;return typeof a==`function`&&a(null,p),p}})),Un=e(t((e=>{var t=vn(),n=zn(),r=Vn(),i=Hn();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1);function Wn({value:e,label:t}){let n=(0,K.useMemo)(()=>{try{let{modules:t}=Un.create(e),n=[];for(let e=0;e<t.size;e+=1)for(let r=0;r<t.size;r+=1)t.get(e,r)&&n.push(`M${r+4} ${e+4}h1v1h-1z`);return{size:t.size+8,path:n.join(``)}}catch{return null}},[e]);return n?(0,q.jsx)(`svg`,{role:`img`,"aria-label":t,"data-theme":`light`,className:`block h-auto max-w-full rounded-lg bg-paper text-fg`,xmlns:`http://www.w3.org/2000/svg`,width:280,height:280,viewBox:`0 0 ${n.size} ${n.size}`,shapeRendering:`crispEdges`,children:(0,q.jsx)(`path`,{fill:`currentColor`,d:n.path})}):(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`QR code unavailable. Use the pairing link.`})}function Gn({url:e,expires:t,dismiss:n}){let[r,i]=(0,K.useState)(``);return(0,K.useEffect)(()=>{let e=setTimeout(n,Math.max(0,t-Date.now()));return()=>clearTimeout(e)},[t,n]),(0,q.jsxs)(`section`,{className:`mt-5 space-y-3`,"aria-label":`Pairing invitation`,children:[(0,q.jsxs)(`p`,{className:`text-sm text-fg-secondary`,children:[`Scan or open this link on the new browser, then approve its exact identity below. Expires`,` `,new Date(t).toLocaleTimeString(),`.`]}),(0,q.jsx)(Wn,{value:e,label:`Pairing invitation QR code`}),(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,q.jsx)(H,{variant:`secondary`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>i(`Pairing link copied.`)).catch(()=>i(`Could not copy. Open the pairing link or scan the QR code.`))},children:`Copy pairing link`}),(0,q.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`px-2 text-sm text-fg hover:opacity-80`,children:`Open pairing link ↗`}),(0,q.jsx)(H,{variant:`ghost`,onClick:n,children:`Hide invitation`})]}),r&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,role:`status`,children:r})]})}function Kn({devices:e,now:t,currentDevice:n,...r}){let i=e.filter(e=>e.status!==`revoked`).sort((e,t)=>Number(t.status===`pending`)-Number(e.status===`pending`));return(0,q.jsxs)(`div`,{className:`grid gap-2`,children:[i.length===0&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`No browsers yet. Create a pairing invitation to add one.`}),i.map(e=>(0,q.jsx)(qn,{device:e,now:t,current:e.id===n,...r},e.id))]})}function qn({device:e,now:t,current:n,busy:r,approve:i,revoke:a,maintenance:o}){let s=e.status===`pending`,c=e.status===`approved`?Math.min(e.expires,e.lastUsed+p.idleMs):e.expires,l=c<=t,u=l?`Expired`:s?`Awaiting approval`:`Approved`,d=(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`p`,{className:`truncate text-sm text-fg`,title:e.label,children:e.label}),(0,q.jsxs)(`p`,{className:A(`text-2xs`,l?`text-fg-muted`:s?`text-warning`:`text-success`),children:[u,n&&(0,q.jsx)(`span`,{className:`text-fg-muted`,children:` · this browser`})]})]}),f=(0,q.jsxs)(`div`,{className:`mt-2 space-y-1 text-2xs text-fg-muted`,children:[(0,q.jsx)(`code`,{className:`block break-all text-fg-secondary`,children:e.peer}),(0,q.jsxs)(`p`,{children:[l?`Expired`:`Expires`,` `,new Date(c).toLocaleString()]})]});return(0,q.jsxs)(`article`,{"aria-label":e.label,className:`min-w-0 rounded-[var(--ui-radius)] bg-ground px-3 py-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[s?d:(0,q.jsx)(gt,{className:`min-w-0 flex-1`,summary:d,summaryClassName:`flex-row-reverse gap-2 [&>svg]:m-2`,children:f}),s&&!l&&(0,q.jsxs)(H,{variant:`secondary`,size:`sm`,disabled:r,onClick:()=>i(e.id),"aria-label":`Approve ${e.label}`,children:[(0,q.jsx)(dt,{}),` Approve`]}),(0,q.jsx)(H,{variant:`ghost`,size:`icon`,className:`shrink-0 text-fg-muted`,disabled:r,"aria-label":`Revoke ${e.label}`,title:`Revoke browser`,onClick:()=>a(e.id),children:(0,q.jsx)(vt,{})})]}),s&&f,!s&&!l&&o&&(0,q.jsx)(H,{variant:`ghost`,size:`sm`,className:`mt-2`,disabled:r,onClick:()=>o(e.id,!e.maintenance),"aria-label":`${e.maintenance?`Revoke`:`Allow`} host maintenance for ${e.label}`,children:e.maintenance?`Revoke host maintenance`:`Allow host maintenance`})]})}function Jn({devices:e,now:t,busy:n,act:r,canManageMaintenance:i}){return(0,q.jsx)(gt,{className:`mt-6 text-sm`,summary:`Connected browsers`,summaryClassName:`py-2`,children:(0,q.jsxs)(`section`,{className:`space-y-3 pt-2`,"aria-label":`Browsers`,children:[(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Approval grants terminal control of this host. Compare the identity with the browser requesting access.`}),(0,q.jsx)(Kn,{devices:e,now:t,busy:n,approve:e=>void r({t:`approve`,id:e}),revoke:e=>void r({t:`revoke`,id:e}),maintenance:i?(e,t)=>void r({t:`maintenance`,id:e,enabled:t}):void 0}),(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Revocation detaches viewers; agents continue running. Browsers expire after 30 days of inactivity or 90 days overall.`}),i&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`Host maintenance separately allows daemon and runtime software updates. Updates can affect every profile on this host. Pairing alone does not grant it or permission to restart other profiles' runtimes.`})]})})}function Yn({open:e,busy:t,error:n,onOpenChange:r,onConfirm:i}){return(0,q.jsx)(F,{open:e,onOpenChange:e=>!t&&r(e),children:(0,q.jsxs)(N,{children:[(0,q.jsx)(P,{children:`Delete this profile’s remote registration?`}),(0,q.jsx)(M,{children:`Disable remote access, remove the saved registration for this profile and revoke its browser approval and invitation. Agents keep running. Connecting again requires a new registration code and fresh browser approvals.`}),(0,q.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`This also removes this registration from its account’s remote host list. If the service is unavailable, removal finishes when it reconnects.`}),n&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:n}),(0,q.jsxs)(j,{children:[(0,q.jsx)(H,{variant:`ghost`,disabled:t,onClick:()=>r(!1),children:`Cancel`}),(0,q.jsx)(H,{variant:`danger`,disabled:t,onClick:i,children:t?`Deleting…`:`Delete registration`})]})]})})}function Xn(){let e=He(),t=Ge(),n=D(),r=Me().data?.find(e=>e.id===n)?.name??`this profile`,i=`/frontend/remote?profile=${encodeURIComponent(n??``)}`,[a,s]=(0,K.useState)(!1),[l,u]=(0,K.useState)(``),[d,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)(!1),[_,v]=(0,K.useState)(!1),[y,b]=(0,K.useState)(null),x=(0,K.useCallback)(()=>b(null),[]),S=Ue({queryKey:[`frontend-remote`,n],queryFn:async()=>c.parse(await Ee(`GET`,i)),refetchInterval:!a&&5e3,refetchOnWindowFocus:!a,refetchOnReconnect:!a,retry:!1,gcTime:0,enabled:!!n}),C=async t=>{if(a||!n)return!1;s(!0),f(``),u(``);try{if(e.isFetching({queryKey:[`frontend-remote`,n],exact:!0})){let e=await S.refetch({cancelRefetch:!1});if(e.isError)throw e.error}let r=o.parse(await Ee(`POST`,i,t));return t.t===`pair`&&r.url&&r.invitation?b({url:r.url,expires:r.invitation.expires}):(u({enable:`Remote access enabled.`,approve:`Browser approved.`,revoke:`Browser revoked.`,disable:`Remote access disabled. Agents continue running.`,delete_registration:`Registration deleted from this host. Agents continue running.`,reset:`Host identity rotated and all browsers revoked. Enable access and pair again.`,status:`Status refreshed.`,devices:`Browsers refreshed.`,pair:`Invitation created.`,maintenance:t.t===`maintenance`&&t.enabled?`Host maintenance allowed for this browser.`:`Host maintenance revoked for this browser.`}[t.t]),(t.t===`disable`||t.t===`reset`||t.t===`enable`||t.t===`delete_registration`)&&x()),(t.t===`enable`||t.t===`delete_registration`)&&m(!1),g(!1),v(!1),await S.refetch(),!0}catch(e){return f(e instanceof Error?e.message:`Host operation failed. Refresh status before retrying.`),await S.refetch(),!1}finally{s(!1)}},w=S.data,ee=S.error instanceof De&&S.error.status===404,T=a||S.isError;return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{note:`${r} on ${t.data?.displayName||t.data?.hostname||`this host`} · only this profile’s projects and sessions`,children:`Remote access`}),(0,q.jsxs)(`div`,{className:`mt-5 flex items-center justify-between gap-3`,children:[(0,q.jsx)(`span`,{role:`status`,className:`text-sm font-medium`,children:S.isError?`Status unavailable`:w?w.availability===`ready`?w.configured?w.enabled?w.connected?`Connected to relay`:`Enabled · relay disconnected`:`Disabled`:`Not configured`:`Daemon upgrade required`:`Checking remote access…`}),(0,q.jsxs)(H,{variant:`ghost`,size:`sm`,disabled:a,onClick:()=>void S.refetch({cancelRefetch:!1}),children:[(0,q.jsx)(pt,{}),`Refresh status`]})]}),S.isError&&(0,q.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:ee?`This frontend does not provide remote controls. Update Puddle and reopen this window.`:S.error.message}),d&&!_&&(0,q.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:d}),l&&(0,q.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-fg-secondary`,children:l}),w?.availability!==void 0&&w.availability!==`ready`&&(0,q.jsx)(`p`,{className:`mt-3 text-sm text-fg-secondary`,children:`Update the daemon on this host, then refresh status to set up mobile access.`}),w?.availability===`ready`&&(0,q.jsxs)(q.Fragment,{children:[!w.enabled&&w.supervisor&&(!w.configured||p)?(0,q.jsx)(_n,{service:w.service,app:w.app,hostName:`${t.data?.displayName||t.data?.hostname||`My host`} · ${r}`,busy:a,disabled:T,enable:C,cancel:w.configured?()=>m(!1):void 0},w.host??`new`):w.configured?(0,q.jsxs)(`dl`,{className:`mt-4 space-y-2 text-xs text-fg-secondary`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{className:`text-fg-muted`,children:`Application`}),(0,q.jsx)(`dd`,{className:`break-all`,children:(0,q.jsxs)(`a`,{href:w.app,target:`_blank`,rel:`noreferrer`,className:`hover:text-fg`,children:[w.app,` ↗`]})})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{className:`text-fg-muted`,children:`Relay`}),(0,q.jsx)(`dd`,{className:`break-all`,children:w.service})]}),w.peer&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`dt`,{className:`text-fg-muted`,children:`Host identity`}),(0,q.jsx)(`dd`,{className:`break-all font-mono`,children:w.peer})]})]}):null,!w.enabled&&!w.supervisor&&(0,q.jsx)(`p`,{className:`mt-4 text-sm text-fg-secondary`,children:`This host needs persistent systemd or launchd supervision before access can be enabled here. For another supervisor, configure both the daemon and connector using the remote CLI commands.`}),w.configured&&(0,q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,role:`group`,"aria-label":`Registration actions`,children:[!w.enabled&&w.supervisor&&!p&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(H,{disabled:T,onClick:()=>void C({t:`enable`}),children:`Enable remote access`}),(0,q.jsx)(H,{variant:`ghost`,disabled:T,onClick:()=>m(!0),children:`Change registration`})]}),w.enabled&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(H,{disabled:T,onClick:()=>void C({t:`pair`}),children:`Pair a browser`}),(0,q.jsx)(H,{variant:`ghost`,disabled:T,onClick:()=>void C({t:`disable`}),children:`Disable remote access`})]}),w.canDeleteRegistration&&(0,q.jsx)(H,{variant:`ghost`,disabled:T,onClick:()=>{f(``),v(!0)},children:`Delete registration`})]}),y&&w.enabled&&(0,q.jsx)(Gn,{...y,dismiss:x}),w.configured&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Jn,{devices:w.devices,now:S.dataUpdatedAt,busy:T,act:C,canManageMaintenance:w.canManageMaintenance===!0}),(0,q.jsxs)(gt,{className:`text-sm`,summary:`Host identity recovery`,summaryClassName:`py-2`,children:[(0,q.jsx)(`p`,{className:`my-3 text-xs text-fg-muted`,children:`Rotate a lost or compromised host identity. This profile’s browser approvals and invitations will be revoked.`}),(0,q.jsx)(H,{variant:`ghost`,disabled:T,onClick:()=>g(!0),children:`Reset host identity…`})]})]})]}),(0,q.jsx)(F,{open:h,onOpenChange:e=>!a&&g(e),children:(0,q.jsxs)(N,{children:[(0,q.jsx)(P,{children:`Reset this profile’s remote identity?`}),(0,q.jsx)(M,{children:`Disable remote access, rotate the host identity and revoke this profile’s paired browsers and invitation. Agents keep running. Enable access and pair each browser again afterwards.`}),(0,q.jsxs)(j,{children:[(0,q.jsx)(H,{variant:`ghost`,disabled:a,onClick:()=>g(!1),children:`Cancel`}),(0,q.jsx)(H,{variant:`danger`,disabled:a,onClick:()=>void C({t:`reset`}),children:`Reset host identity`})]})]})}),(0,q.jsx)(Yn,{open:_,busy:a,error:d,onOpenChange:v,onConfirm:()=>void C({t:`delete_registration`})})]})}var Zn=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,$=65,Qn=Object.fromEntries([...Zn].map((e,t)=>[e,t])),$n=`H`,er=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let n=t;for(let e=0;e<8;e+=1)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function tr(e){let t=4294967295;for(let n of e)t=er[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function nr(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function rr(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}async function ir(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function ar(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function or(e,t){let n=(t%$+$)%$,r=``;for(let t of e){let e=Qn[t];r+=e===void 0?t:Zn[(e+n)%$]}return r}async function sr(e){let t=await ir(JSON.stringify(e));return or(nr(t)+tr(t),1+Math.floor(Math.random()*($-1)))}async function cr(e){let t=e.trim(),n=t[0];if(!n||Qn[n]===void 0)throw Error(`Not a settings export.`);let r=or(t,-((Qn[n]-Qn[$n]+$)%$));if(r.length<9||r[0]!==$n)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=rr(i);if(tr(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await ar(o))}var lr=`puddle.sync-selection`;function ur(){try{let e=JSON.parse(localStorage.getItem(lr)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return ne.map(e=>e.id)}function dr({selected:e,onToggle:t}){return(0,q.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:ne.map(n=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(W,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function fr(){let e=D(),t=k(e??void 0),n=Me().data?.find(t=>t.id===e),r=Le(e??void 0,void 0),i=O(e??``),a=Ne(),o=Ye(),s=de(),c=pe(),[l,u]=(0,K.useState)(``),[d,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(!1),[h,g]=(0,K.useState)(ur),_=n&&s.data?T(s.data.file,n.name):void 0,v=_?.enabled===!0,y=v&&_?_.groups:h,b=()=>({client:xe(),theme:Se(),profileSettings:t.data??{},profile:n??{},scratchpad:r.data??[]}),x={setClient:e=>E(e),setTheme:e=>{typeof e==`string`&&Ce(e)},patchProfileSettings:e=>i.mutate(e,{onError:e=>G(e)}),patchProfileColumns:t=>{e&&a.mutate({id:e,...t},{onError:e=>G(e)})},createScratchpad:t=>{if(e)for(let n of t)o.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},S=(e,t)=>{n&&c.mutate({profile:n.name,entry:{enabled:e.enabled??v,groups:t,doc:he(t,b()),updatedAt:new Date().toISOString()}},{onError:e=>G(e)})},C=(e,t)=>{let n=t?[...y,e]:y.filter(t=>t!==e);g(n),localStorage.setItem(lr,JSON.stringify(n)),v&&S({},n)},w=async()=>{m(!0);try{let e=ce(await cr(l.trim()),x,{profileSettings:t.data??{},scratchpad:r.data??[]});e.length===0?I.error(`Nothing recognised to import.`):(I.success(`Imported ${e.join(`, `)}.`),u(``))}catch(e){I.error(e.message)}finally{m(!1)}},ee=async()=>{m(!0);try{let e=await sr(he(y,b()));f(e),await navigator.clipboard?.writeText(e),I.success(`Copied to clipboard`)}finally{m(!1)}};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sync`}),(0,q.jsx)(`p`,{className:`mb-5 text-xs text-fg-muted`,children:`Carry your settings between machines. Accounts, repositories, and anything host-specific are never included. Applies to this profile.`}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),s.data?.available===!1?(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:`Not available in this frontend — start the UI with the Puddle CLI to sync across windows.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Sync selected groups through this machine’s`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:`~/.puddle`}),`, so every Puddle window stays in step for profiles named`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:n?.name??`…`}),`.`]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(W,{checked:v,disabled:!n||s.isLoading||c.isPending,onCheckedChange:e=>S({enabled:e},y)}),`Sync locally`]})]})]}),(0,q.jsx)(gt,{className:`mb-6`,summary:`Choose what to sync`,summaryClassName:`text-xs`,children:(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(dr,{selected:y,onToggle:C})})}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,q.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:`Builds a Puddle magic string that encodes settings from the checklist above.`}),(0,q.jsx)(H,{size:`sm`,disabled:p,onClick:()=>void ee(),children:`Export & copy`}),d&&(0,q.jsx)(it,{readOnly:!0,value:d,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`mt-2 resize-y font-mono text-xs`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,q.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste a Puddle magic string to import its settings.`}),(0,q.jsx)(it,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:`Paste a settings export…`,rows:3,spellCheck:!1,className:`resize-y font-mono text-xs`}),(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(H,{size:`sm`,disabled:!l.trim()||p,onClick:()=>void w(),children:`Import`})})]})]})}function pr(){return(0,q.jsxs)(`div`,{className:`space-y-8`,children:[(0,q.jsx)(Xn,{},D()),(0,q.jsx)(fr,{})]})}function mr({repo:e}){let t=Qe(),n=Ae(),r=a(ze().data?.protocol),[i,o]=(0,K.useState)(e.default_base_branch),[s,c]=(0,K.useState)(e.onboarding_notes??``),l=e=>G(e);return(0,q.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.path}),(0,q.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,q.jsxs)(H,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>I.success(`Fetched.`),onError:l}),children:[(0,q.jsx)(pt,{}),`Fetch now`]})]}),(0,q.jsxs)(Y,{label:`Default base branch`,description:r?`Blank = the branch checked out at the clone location when each agent or terminal is created.`:`Choose a branch. Update the host to allow a blank default that follows the clone.`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,q.jsx)(U,{id:`base-${e.id}`,placeholder:r?`current clone branch`:void 0,value:i,onChange:e=>o(e.target.value),className:`w-40`}),(0,q.jsx)(H,{size:`sm`,variant:`secondary`,disabled:i.trim()===e.default_base_branch||t.isPending||!r&&!i.trim(),onClick:()=>t.mutate({id:e.id,default_base_branch:i.trim()},{onError:l,onSuccess:()=>o(i.trim())}),children:`Save`})]}),(0,q.jsx)(Y,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,q.jsx)(W,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:l})})}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Standing setup rules, injected into every fresh worktree. Agents update them via .puddle/onboarding-notes.md.`})]}),(0,q.jsx)(it,{id:`notes-${e.id}`,value:s,onChange:e=>c(e.target.value),rows:4}),(0,q.jsx)(`div`,{children:(0,q.jsx)(H,{size:`sm`,variant:`secondary`,disabled:s===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:s},{onError:l}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,q.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,q.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Orphan worktrees — directories no session claims. Puddle never deletes these automatically; remove them by hand if unwanted.`}),(0,q.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,q.jsx)(`li`,{className:`truncate text-2xs text-fg-muted`,children:e},e))})]})]})}function hr(){let e=Re();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Projects`}),e.data?.length===0&&(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No projects yet — create one from the dashboard, pointing at a repository.`}),e.data?.map(e=>(0,q.jsx)(mr,{repo:e},e.id))]})}function gr(){let e=D(),t=ze(),n=k(e??void 0),r=O(e??``),[a,o]=(0,K.useState)(!1);if(!e||!n.data)return null;let s=n.data.hostIcon,c=n.data.hostColour,l=e=>{r.mutate({hostIcon:e},{onError:G}),o(!1)},u=e=>r.mutate({hostColour:e},{onError:G});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Icon`,children:(0,q.jsxs)(Nt,{open:a,onOpenChange:o,children:[(0,q.jsx)(Mt,{asChild:!0,children:(0,q.jsxs)(`button`,{type:`button`,"data-host-colour":c??void 0,className:`host-identity flex size-9 items-center justify-center rounded-md transition-colors hover:bg-elevated hover:text-fg`,children:[(0,q.jsx)(S,{icon:s,className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Choose a host icon`})]})}),(0,q.jsx)(jt,{align:`end`,className:`w-72`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,q.jsx)(`button`,{type:`button`,title:`Default host icon`,"aria-pressed":!s,onClick:()=>l(null),className:A(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,!s&&`bg-nav-selection text-nav-selection-ink`),children:(0,q.jsx)(S,{icon:null,className:`size-4`})}),C.map(({name:e,Icon:t})=>(0,q.jsx)(`button`,{type:`button`,title:e,"aria-pressed":s===e,onClick:()=>l(e),className:A(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,s===e&&`bg-nav-selection text-nav-selection-ink`),children:(0,q.jsx)(t,{className:`size-4`})},e))]})})]})}),(0,q.jsx)(Y,{label:`Accent`,children:(0,q.jsx)(st,{onCustomChange:i(t.data?.protocol)?u:void 0,value:c,onChange:u,label:`Host accent`})})]})}function _r({status:e,reply:t,disabled:n,offlineDisabled:r,act:i}){let a=e.result?.operation;if(!a)return null;let o={id:a.id,revision:a.revision},s=_e(e,t),c=ve(e),l=t?.ok&&t.operation?.id===a.id&&t.operation.revision===a.revision?t.review:void 0,u=g(a.phase);return(0,q.jsxs)(`div`,{className:`mt-5 space-y-3 text-sm`,children:[(0,q.jsxs)(`p`,{role:`status`,className:`font-medium`,children:[e.observation===`recorded`&&`Recorded status: `,te[a.phase]]}),e.observation===`recorded`&&(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Last recorded change: `,new Date(a.updated_at).toLocaleString(),`. This record does not confirm current service health or runtime adoption.`]}),(0,q.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:a.targets.map(({component:e,version:t})=>`${e===`daemon`?`Daemon`:`Runtime software`} ${t}`).join(` · `)}),a.message&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.message}),s&&(0,q.jsxs)(`p`,{className:`text-xs text-fg-secondary`,children:[`Existing persistent runtimes keep running.`,` `,a.targets.some(({component:e})=>e===`daemon`)?`This window briefly reconnects while the daemon is replaced.`:`New runtimes will use the updated software.`]}),l&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`text-xs text-fg-secondary`,children:[`Daemon-owned work affected: `,l.affected.terminals,` terminals,`,` `,l.affected.notebooks,` notebook kernels, `,l.affected.compilation,` compilation jobs/watchers, `,l.affected.programmes,` programmes.`]}),l.interruption_fingerprint&&(0,q.jsx)(`p`,{className:`text-xs text-warning`,children:`Applying interrupts the listed work. Shell jobs and in-memory kernel state will be lost; interrupted programmes are not replayed.`}),l.blockers.filter(({code:e})=>e!==`interruption_approval_required`).map(({code:e},t)=>(0,q.jsx)(`p`,{className:`text-xs text-warning`,children:e===`runtime_lifetime_unverified`?`A runtime has a limited or unverified host lifetime. Daemon replacement is blocked while it runs. Updating also requires a supported host service manager.`:`Check failed: ${(e===`cockpit_incompatible`?`frontend_incompatible`:e).replaceAll(`_`,` `)}`},`${e}-${t}`)),l.more_blockers>0&&(0,q.jsxs)(`p`,{className:`text-xs text-warning`,children:[l.more_blockers,` additional checks failed.`]})]}),(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[c&&(0,q.jsx)(H,{size:`sm`,disabled:r,onClick:()=>i(c),children:`Continue recovery on host`}),ge(a)&&(0,q.jsx)(H,{variant:`ghost`,size:`sm`,disabled:n,onClick:()=>i({action:`inspect`,reference:o}),children:l?`Check again`:`Review impact`}),s&&(0,q.jsx)(H,{size:`sm`,variant:s.interruption_approval?`danger`:`default`,disabled:n,onClick:()=>i(s),children:s.interruption_approval?`Interrupt listed work and apply`:`Apply update`}),!u&&!a.dispatched&&(0,q.jsx)(H,{variant:`ghost`,size:`sm`,disabled:n,onClick:()=>i({action:`cancel`,reference:o}),children:`Cancel update`}),!u&&a.dispatched&&e.capabilities.verify_completion&&(0,q.jsx)(H,{variant:`ghost`,size:`sm`,disabled:n,onClick:()=>i({action:`recover`,reference:o,strategy:`verify-completion`}),children:`Verify completion`}),a.phase===`recovery_required`&&e.capabilities.continue_recovery&&(0,q.jsx)(H,{size:`sm`,disabled:n,onClick:()=>i({action:`recover`,reference:o,strategy:`continue`}),children:`Continue recovery`})]}),c&&(0,q.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Recovery checks this update on the host before continuing unfinished steps. Keep this window open until the host accepts the request; accepted recovery runs independently.`}),a.dispatched&&!u&&(0,q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:`The host accepted this operation. Status will refresh as it reconnects. Recovery actions are explicit; applying is never repeated automatically.`})]})}function vr(){let e=le(),t=re(),n=ie(),r=qe(Ge().data)??`this host`;if(!t)return null;let i=e.data,a=i?.catalogue,o=a?.releases,s=ee(i),c=e.error instanceof De&&e.error.status===404,l=n.busy||e.isError||i?.availability!==`ready`,u=n.data&&!n.data.ok?n.data:i?.result&&!i.result.ok?i.result:null;return(0,q.jsxs)(`section`,{className:`mb-8`,"aria-label":`Host updates`,children:[(0,q.jsx)(X,{note:`Updates run on ${r}`,children:`Updates`}),(0,q.jsx)(Y,{label:`Daemon`,description:i?.observation===`recorded`?i.daemon_version?`Last connected version: ${i.daemon_version}`:`Version unavailable`:a?.daemon_version??i?.daemon_version??`Version unavailable`,children:(0,q.jsx)(H,{variant:`ghost`,size:`sm`,disabled:e.isFetching,onClick:()=>void e.refetch({cancelRefetch:!1}),children:e.isFetching?`Refreshing…`:`Refresh status`})}),a&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Default runtime software`,description:`New runtimes use this build. Existing runtimes retain their current build.`,children:(0,q.jsx)(`span`,{className:`text-xs tabular-nums`,children:a.runtime_default?.version??`Unavailable`})}),a.runtimes.versions.length>0&&(0,q.jsxs)(`div`,{className:`my-3 space-y-1 text-xs text-fg-secondary`,children:[(0,q.jsx)(`p`,{className:`font-medium`,children:`Existing runtimes`}),a.runtimes.versions.map(e=>(0,q.jsxs)(`p`,{children:[e.version,`: `,e.running,` connected · `,e.starting,` starting ·`,` `,e.unavailable,` unavailable`]},`${e.version}-${e.protocol.major}-${e.protocol.minor}`))]}),!a.runtimes.complete&&(0,q.jsx)(`p`,{className:`my-2 text-xs text-warning`,children:`Runtime inventory is incomplete. Update review checks compatibility separately.`})]}),!i&&!e.isError&&(0,q.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:`Checking host updates…`}),e.isError&&(0,q.jsx)(`p`,{role:`alert`,className:`text-sm text-warning`,children:c?`Update this frontend and reopen the window to manage host updates.`:`Host status is unavailable. The last observation may be out of date. Refresh status before another action.`}),i?.availability===`upgrade_required`&&(0,q.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`This daemon needs an upgrade before frontend update controls are available.`}),i?.availability===`unavailable`&&(0,q.jsxs)(`p`,{role:`status`,className:`text-sm text-fg-secondary`,children:[i.observation===`recorded`?`The daemon is unavailable. Showing the update record from this host.`:`Waiting for the daemon to reconnect.`,` `,`No update action will be repeated.`]}),o&&(0,q.jsxs)(`div`,{className:`my-4 space-y-1 text-xs text-fg-secondary`,children:[(0,q.jsx)(`p`,{children:o.state===`unconfigured`?`No release source is configured on this host.`:o.state===`checking`?`Checking for releases…`:o.state===`failed`?`Release check failed. Showing the last known result.`:`Release check completed.`}),o.latest&&(0,q.jsxs)(`p`,{children:[`Latest known release: `,o.latest.version,!o.components&&!o.latest.host_asset&&` · No package available for this host`]}),o.components&&(0,q.jsxs)(`p`,{children:[`Latest daemon: `,o.components.daemon.version,!o.components.daemon.host_asset&&` (unavailable for this host)`,` · `,`Runtime: `,o.components.runtime.version,!o.components.runtime.host_asset&&` (unavailable for this host)`]}),o.succeeded_at!==null&&(0,q.jsxs)(`p`,{children:[`Last successful check: `,new Date(o.succeeded_at).toLocaleString()]})]}),s.length>0&&(0,q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[s.map(e=>(0,q.jsxs)(H,{size:`sm`,disabled:l||w(i),onClick:()=>n.act({action:`prepare`,targets:[e]}),children:[`Prepare `,e.component===`daemon`?`daemon`:`runtime software`,` `,e.version]},e.component)),s.length>1&&(0,q.jsx)(H,{size:`sm`,variant:`ghost`,disabled:l||w(i),onClick:()=>n.act({action:`prepare`,targets:s}),children:`Prepare both`})]}),s.length>0&&(0,q.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:`Preparation downloads and verifies the release. Review its impact before applying.`}),n.busy&&(0,q.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-fg-secondary`,children:n.variables?.action===`prepare`?`Preparing update…`:`Waiting for the host…`}),n.isError&&(0,q.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-warning`,children:`The response was lost or unavailable. Status is being checked; the action has not been repeated.`}),u&&(0,q.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-warning`,children:u.code===`conflict`?`The host changed since review. Refresh status and review again.`:`The host could not complete the request (${u.code}). Refresh status before another action.`}),i&&(0,q.jsx)(_r,{status:i,reply:n.data,disabled:l,offlineDisabled:n.busy||e.isError,act:n.act})]})}function yr({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=Fe();return(0,q.jsx)(Y,{label:e,description:t,htmlFor:`host-${n}`,children:(0,q.jsx)(U,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{if(e.target.value.trim()===``){e.target.value=String(r[n]);return}let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>G(e)})}})})}function br(){let e=Ve(),t=Fe(),n=Ge(),r=ze().data?.protocol,i=r&&(r.major>25||r.major===25&&r.minor>=6);return e.data?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(vr,{}),(0,q.jsx)(X,{note:`Icon and accent are per profile and not synced; other settings affect all profiles.`,children:`Host`}),(0,q.jsx)(Y,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,q.jsx)(U,{id:`host-displayName`,type:`text`,maxLength:64,className:`w-48`,placeholder:n.data?.hostname,defaultValue:e.data.displayName,onBlur:n=>{let r=n.target.value.trim();r!==e.data.displayName&&t.mutate({displayName:r},{onError:e=>G(e)})}})}),(0,q.jsx)(gr,{}),(0,q.jsx)(yr,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,q.jsx)(yr,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),i&&(0,q.jsx)(yr,{label:`Bulk log retention (days)`,description:`Older inactive terminal logs keep only their replay tail. Archived restoration and shell history are preserved. Set 0 to disable age-based cleanup.`,field:`logRetentionDays`,config:e.data,min:0}),(0,q.jsx)(yr,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,q.jsx)(yr,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,q.jsx)(Y,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,q.jsx)(W,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>G(e)})})})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(gr,{}),(0,q.jsx)(vr,{})]})}var xr=[{id:`appearance`,label:`Appearance`,icon:ft,render:()=>(0,q.jsx)(Gt,{})},{id:`profile`,label:`Profile`,icon:yt,render:()=>(0,q.jsx)(Jt,{})},{id:`accounts`,label:`Accounts`,icon:Ut,render:()=>(0,q.jsx)(Zt,{})},{id:`sessions`,label:`Sessions`,icon:Ht,render:()=>(0,q.jsx)(an,{})},{id:`editor`,label:`Editor`,icon:mt,render:()=>(0,q.jsx)(fn,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Bt,render:()=>(0,q.jsx)(mn,{})},{id:`notifications`,label:`Notifications`,icon:ut,render:()=>(0,q.jsx)(ln,{})},{id:`projects`,label:`Projects`,icon:v,render:()=>(0,q.jsx)(hr,{})},{id:`host`,label:`Host`,icon:b,render:()=>(0,q.jsx)(br,{})},{id:`remote-sync`,label:`Remote & Sync`,icon:pt,render:()=>(0,q.jsx)(pr,{})}],Sr={terminal:`sessions`,repositories:`projects`,remote:`remote-sync`,sync:`remote-sync`};function Cr(){let e=bt(),t=e===null?null:Sr[e]??e,n=xr.find(e=>e.id===t)??xr[0];return(0,q.jsx)(F,{open:e!==null,onOpenChange:e=>!e&&xt(),children:(0,q.jsxs)(N,{wide:!0,surface:!1,showCloseButton:!1,className:`grid h-[34rem] grid-cols-[14rem_minmax(0,1fr)] items-start gap-[var(--ui-surface-gap)] overflow-visible p-0`,children:[(0,q.jsx)(`nav`,{className:`max-h-full min-h-0 overflow-y-auto rounded-[var(--ui-surface-radius)] shadow-2xl`,children:(0,q.jsxs)(kt,{label:`Settings sections`,variant:`selection`,vertical:!0,className:`settings-navigation`,children:[(0,q.jsxs)(`div`,{className:`flex w-full items-center justify-between px-2.5 py-1.5`,children:[(0,q.jsx)(P,{className:`text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),(0,q.jsxs)(tt,{className:`flex items-center rounded-md p-1.5 text-fg transition-colors hover:bg-ground`,children:[(0,q.jsx)(rt,{className:`size-4`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]}),xr.map(({id:e,label:t,icon:r})=>(0,q.jsxs)(`button`,{type:`button`,"data-tray-slot":!0,"aria-current":e===n.id?`page`:void 0,onClick:()=>St(e),className:`text-left text-sm transition-colors`,children:[(0,q.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]})}),(0,q.jsx)(`div`,{className:`island-outline h-full min-h-0 overflow-y-auto rounded-[var(--ui-surface-radius)] bg-surface p-5 shadow-2xl`,children:n.render()})]})})}export{Cr as SettingsDialog};
|