@puddle-code/cli 0.5.7 → 0.5.9
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 +6 -16
- package/dist/host-control.mjs +3 -1
- package/dist/index.js +8 -4
- package/dist/public/assets/App-1ly-pQYt.js +15 -0
- package/dist/public/assets/{CompilationCommandForm-BkQcFUoa.js → CompilationCommandForm--aglvHpg.js} +1 -1
- package/dist/public/assets/Dashboard-CLdNA8WP.js +1 -0
- package/dist/public/assets/DraftRecovery-Da7OryXQ.js +1 -0
- package/dist/public/assets/{EditorTabClose-fs9t84tp.js → EditorTabClose-CQ73_M1i.js} +1 -1
- package/dist/public/assets/{FileCloseScope-BS5YFuzv.js → FileCloseScope-B527gWqW.js} +1 -1
- package/dist/public/assets/{FileEditorSettingsMenu-DUpeKKAz.js → FileEditorSettingsMenu-X23c7860.js} +1 -1
- package/dist/public/assets/{HuddlePane-CFYGRv0M.js → HuddlePane-BLBAcqwy.js} +1 -1
- package/dist/public/assets/{LazyTerminal-DRIHw2iz.js → LazyTerminal-Cu5V6ejk.js} +2 -2
- package/dist/public/assets/{NotebookWidget-O9o5XL61.js → NotebookWidget-CXmf3IRw.js} +1 -1
- package/dist/public/assets/{PaneEditorBody-gYNeVTlY.js → PaneEditorBody-DdnVw9lV.js} +19 -19
- package/dist/public/assets/{PdfViewer-BC-g7S60.js → PdfViewer-CSMNKPo1.js} +1 -1
- package/dist/public/assets/{ReadOnlyDiff-DVzIKTvw.js → ReadOnlyDiff-BwUPy5CW.js} +1 -1
- package/dist/public/assets/{Ripple-B_d76mLT.js → Ripple-D1mXgP5b.js} +1 -1
- package/dist/public/assets/{SettingsDialog-BgmpTW4O.js → SettingsDialog-Dxyi7dhn.js} +1 -1
- package/dist/public/assets/{Terminal-_I1S2ZXt.js → Terminal-J5WMTjuY.js} +3 -3
- package/dist/public/assets/Workspace-DQDh6TQ7.js +20 -0
- package/dist/public/assets/{api-BLc59FAZ.js → api-DhfvolrJ.js} +1 -1
- package/dist/public/assets/{auth-tYM1depE.js → auth-BPXeEntX.js} +1 -1
- package/dist/public/assets/{colour-picker-cDlTcc8M.js → colour-picker-Dwq4M4eT.js} +1 -1
- package/dist/public/assets/{content-state-BO1TLd_9.js → content-state-PQEVgsS8.js} +1 -1
- package/dist/public/assets/{context-C632GWyy.js → context-CvPVX4oN.js} +1 -1
- package/dist/public/assets/context-menu-CaNn4t1W.js +1 -0
- package/dist/public/assets/{drafts-wug-3Dad.js → drafts-CqDYmkTF.js} +1 -1
- package/dist/public/assets/{editor-context-CR20pm26.js → editor-context-Bijx3uIG.js} +1 -1
- package/dist/public/assets/{editor-links-DFaQQsK-.js → editor-links-Djdkea3i.js} +1 -1
- package/dist/public/assets/{editor-sync-CVFWKRes.js → editor-sync-C6zSf7t5.js} +1 -1
- package/dist/public/assets/{errors-CV02t999.js → errors-SnGDjajv.js} +1 -1
- package/dist/public/assets/{expanding-content-CQQYN3yg.js → expanding-content-CKYjs3iT.js} +1 -1
- package/dist/public/assets/{file-editor-settings-DXGv9vrt.js → file-editor-settings-XayiLMfU.js} +1 -1
- package/dist/public/assets/{file-links-JFyQw_0a.js → file-links-CEjYCLBn.js} +1 -1
- package/dist/public/assets/{forward-link-Kt311XAU.js → forward-link-BT0QTRVB.js} +1 -1
- package/dist/public/assets/{hotkeys-ChnvTHTH.js → hotkeys-B417biB9.js} +1 -1
- package/dist/public/assets/{index-Cif1X6lX.css → index-CbJEmhvZ.css} +1 -1
- package/dist/public/assets/{index-Dp1Lhq2t.js → index-DTGZfxsX.js} +3 -3
- package/dist/public/assets/{local-store-3IuC2qMo.js → local-store-DKFKEHML.js} +1 -1
- package/dist/public/assets/{notification-delivery-DWIF1cHd.js → notification-delivery-yJcsFWYx.js} +1 -1
- package/dist/public/assets/{preferences-sJF-HcJf.js → preferences-BP2Incj1.js} +1 -1
- package/dist/public/assets/{profile-icons-CFPzzic1.js → profile-icons-BmQVYS_o.js} +1 -1
- package/dist/public/assets/{profile-store-BDrSK8Qs.js → profile-store-BnferXV3.js} +1 -1
- package/dist/public/assets/{project-actions-DsWg9uGZ.js → project-actions-DX_j3cML.js} +1 -1
- package/dist/public/assets/{project-drag-B0ojbuY7.js → project-drag-DZbLfoWj.js} +1 -1
- package/dist/public/assets/{protocol-support-C2shbX3-.js → protocol-support-DIWnYJkt.js} +1 -1
- package/dist/public/assets/{queries-essOjrjZ.js → queries-C9DYtGQW.js} +1 -1
- package/dist/public/assets/{render-rich-content-DlSv3j1S.js → render-rich-content-Br9yR6jZ.js} +1 -1
- package/dist/public/assets/{scroll-restoration-Bt7-rGXy.js → scroll-restoration-C-VTTLs8.js} +1 -1
- package/dist/public/assets/{selection-actions-Bis7oo_z.js → selection-actions-DX3EnNRv.js} +1 -1
- package/dist/public/assets/{session-display-Bxz8xi3w.js → session-display-DHxCigRa.js} +1 -1
- package/dist/public/assets/session-order-BK0vJanT.js +1 -0
- package/dist/public/assets/{state-BoqmEoqv.js → state-BegCSQn_.js} +1 -1
- package/dist/public/assets/use-arrangement-ready-CMe547fb.js +1 -0
- package/dist/public/assets/{use-desktop-state-CS5BxWes.js → use-desktop-state-xeH1nq63.js} +2 -2
- package/dist/public/assets/{view-state-store-gvFpSJG_.js → view-state-store-Cr1BaTzj.js} +1 -1
- package/dist/public/assets/{window-context-Euxqnh6S.js → window-context-DddmcmmO.js} +2 -2
- package/dist/public/assets/{ws-Du8jZ4aQ.js → ws-fD2y3o7n.js} +1 -1
- package/dist/public/index.html +5 -5
- package/dist/pudl.js +3 -1
- package/package.json +1 -1
- package/dist/public/assets/App-CYkXXLs2.js +0 -25
- package/dist/public/assets/Dashboard-03re-W2v.js +0 -1
- package/dist/public/assets/DraftRecovery-tIdw_B9k.js +0 -1
- package/dist/public/assets/Workspace-DjRRDhFc.js +0 -20
- package/dist/public/assets/dist-CaMNiZN8.js +0 -1
- package/dist/public/assets/session-order-DsJCcSqx.js +0 -1
- package/dist/public/assets/use-arrangement-ready-CovEzBp-.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
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{t as n}from"./jsx-runtime-ffCh33zF.js";import{W as r}from"./local-store-3IuC2qMo.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{n as a}from"./api-BLc59FAZ.js";import{n as o}from"./dist-DMpqv5CF.js";import{t as s}from"./createLucideIcon-DyMAgLa3.js";import{t as c}from"./control-tray-jUtkASPS.js";import{r as l,t as u}from"./view-state-store-gvFpSJG_.js";import{t as d}from"./zoom-intent-vemBFIak.js";import{t as f}from"./scroll-restoration-Bt7-rGXy.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=n();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:n,root:i,onRevealSource:s,onDownload:c}){let u=l(`pdf`,[t,i,n]),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:n,root:i,page:e,x:c,y:l});s(r.parse(o))}catch(e){o.error(e instanceof Error?e.message:`Couldn’t locate the TeX source`)}},[s,n,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};
|
|
2
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{W as r}from"./local-store-DKFKEHML.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{n as a}from"./api-DhfvolrJ.js";import{n as o}from"./dist-DMpqv5CF.js";import{t as s}from"./createLucideIcon-DyMAgLa3.js";import{t as c}from"./control-tray-jUtkASPS.js";import{r as l,t as u}from"./view-state-store-Cr1BaTzj.js";import{t as d}from"./zoom-intent-vemBFIak.js";import{t as f}from"./scroll-restoration-C-VTTLs8.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=n();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:n,root:i,onRevealSource:s,onDownload:c}){let u=l(`pdf`,[t,i,n]),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:n,root:i,page:e,x:c,y:l});s(r.parse(o))}catch(e){o.error(e instanceof Error?e.message:`Couldn’t locate the TeX source`)}},[s,n,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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{C as r,x as i}from"./protocol-support-C2shbX3-.js";import{Gt as a,Jt as o,Kt as s,Xt as c,Yt as l,fn as u,mn as d,qt as f,r as p}from"./local-store-3IuC2qMo.js";import{r as m,t as h}from"./client-settings-BdKglwtW.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-BLc59FAZ.js";import{n as C}from"./window-context-Euxqnh6S.js";import{at as ee,b as w,ot as T,st as E,vt as D}from"./queries-essOjrjZ.js";import{I as O,O as k,P as A,R as j,S as te,V as M,Y as ne,_ as re,d as ie,f as ae,g as N,h as oe,i as se,m as ce,p as le,s as ue,u as de,v as fe,w as pe,x as me,y as P,z as F}from"./editor-context-CR20pm26.js";import{n as he}from"./motion-Bd_MB9cH.js";import{n as I}from"./dist-DMpqv5CF.js";import{t as ge}from"./createLucideIcon-DyMAgLa3.js";import{t as _e}from"./disclosure-oYVpfMYO.js";import{i as ve,t as ye}from"./profile-store-BDrSK8Qs.js";import{l as L}from"./hotkeys-ChnvTHTH.js";import{t as be}from"./content-state-BO1TLd_9.js";import{a as R,i as xe,n as z,r as B}from"./languages-O6mK4sJI.js";import{i as Se,n as V}from"./file-editor-settings-DXGv9vrt.js";import{r as Ce,t as we}from"./view-state-store-gvFpSJG_.js";import{o as Te,s as Ee}from"./source-anchor-map-BNxSa_bJ.js";import{a as De,i as Oe,n as ke,t as Ae}from"./drafts-wug-3Dad.js";import{a as je,c as Me,i as Ne,n as Pe,o as Fe,r as Ie}from"./editor-sync-CVFWKRes.js";import{r as Le}from"./buffer-logic-D9FvoilV.js";import{c as Re,d as H,f as U,i as W,l as ze,o as Be,p as Ve,r as He,s as Ue,t as We,u as Ge}from"./buffer-store-OTFEYxTw.js";var Ke=ge(`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`}]]),G=e(t(),1);function K(e){return{tabSize:e,insertSpaces:!0,detectIndentation:!1}}var qe=new we(500,`code`),Je=new we(500,`diff`);function Ye(e){let t={...e.contributionsState};return delete t[`editor.contrib.wordHighlighter`],{...e,contributionsState:t}}function Xe(e,t){let n=(0,G.useRef)(null),r=(0,G.useRef)(null);return(0,G.useLayoutEffect)(()=>(n.current&&(r.current=t(n.current,e)),()=>{r.current?.(),r.current=null}),[e,t]),(0,G.useCallback)(i=>{r.current?.(),n.current=i,i.onDidDispose(()=>{n.current===i&&(n.current=null)}),r.current=t(i,e)},[e,t])}function Ze(e,t){let n=qe.get(t);n&&e.restoreViewState(n);let r=()=>{if(!e.getModel())return;let n=e.saveViewState();n&&qe.set(t,Ye(n))},i=[e.onDidScrollChange(r),e.onDidChangeCursorSelection(r)];return()=>{r(),i.forEach(e=>e.dispose())}}function Qe(e,t){let n=Je.get(t),r=n!==void 0,i=()=>{if(r||!e.getModel())return;let n=e.saveViewState();n&&Je.set(t,{...n,original:n.original&&Ye(n.original),modified:n.modified&&Ye(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 $e(e){return Xe(Ce(`code`,e),Ze)}function q(e){return Xe(Ce(`diff`,e),Qe)}var J=n();function et({conflict:e}){let[t,n]=(0,G.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)(_e,{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=V(),[l,u]=(0,G.useState)(!1),d=q([`conflict`,r.uri.toString()]),f=(0,G.useId)(),p=(0,G.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),m=(0,G.useRef)(o);m.current=o;let h=(0,G.useRef)(null),g=()=>{let e=h.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),h.current=null},_=(0,G.useRef)(g);return _.current=g,(0,G.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)(R,{modifiedModelPath:r.uri.toString(),originalModelPath:`puddle-disk://${encodeURIComponent(e)}/${n.mtimeMs}/${encodeURIComponent(f)}/${t.split(`/`).map(encodeURIComponent).join(`/`)}`,original:n.content,language:c.editorLanguage??z(t),theme:B,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,...K(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:P(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 we(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=Te(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?Ee(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,c]=await Promise.all([i(Object.entries(n.files)),i(Object.entries(n.document.components).map(([e,t])=>[e,d(t)]))]);return{source:n,baseline:f.parse({...e,format:1,digest:r,files:o,components:c})}}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))&&d(e.components)===d(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,n,i){let a=n===void 0?/^\.puddle\/huddle\/([a-f0-9]{32})\/(huddle|layout)\.json$/.exec(t):null,o=!!a&&!p(),s=w(),l=ve(),d=wt(),f=o&&r(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:f}),h=F(e,n),g=D(),_=l&&m.data&&a?{profile:l,scope:d,project_id:m.data.project_id,worktree:m.data.worktree_path,huddle_id:a[1]}:void 0,v=[`huddle-source`,_?.scope,l,_?.project_id,_?.worktree,_?.huddle_id],y=()=>{if(!_||p()||ye()!==_.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":{}}
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{C as r,x as i}from"./protocol-support-DIWnYJkt.js";import{Gt as a,Jt as o,Kt as s,Xt as c,Yt as l,fn as u,mn as d,qt as f,r as p}from"./local-store-DKFKEHML.js";import{r as m,t as h}from"./client-settings-BdKglwtW.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-DhfvolrJ.js";import{n as C}from"./window-context-DddmcmmO.js";import{at as ee,b as w,ot as T,st as E,vt as D}from"./queries-C9DYtGQW.js";import{I as O,O as k,P as A,R as j,S as te,V as M,Y as ne,_ as re,d as ie,f as ae,g as N,h as oe,i as se,m as ce,p as le,s as ue,u as de,v as fe,w as pe,x as me,y as P,z as F}from"./editor-context-Bijx3uIG.js";import{n as he}from"./motion-Bd_MB9cH.js";import{n as I}from"./dist-DMpqv5CF.js";import{t as ge}from"./createLucideIcon-DyMAgLa3.js";import{t as _e}from"./disclosure-oYVpfMYO.js";import{i as ve,t as ye}from"./profile-store-BnferXV3.js";import{l as L}from"./hotkeys-B417biB9.js";import{t as be}from"./content-state-PQEVgsS8.js";import{a as R,i as xe,n as z,r as B}from"./languages-O6mK4sJI.js";import{i as Se,n as V}from"./file-editor-settings-XayiLMfU.js";import{r as Ce,t as we}from"./view-state-store-Cr1BaTzj.js";import{o as Te,s as Ee}from"./source-anchor-map-BNxSa_bJ.js";import{a as De,i as Oe,n as ke,t as Ae}from"./drafts-CqDYmkTF.js";import{a as je,c as Me,i as Ne,n as Pe,o as Fe,r as Ie}from"./editor-sync-C6zSf7t5.js";import{r as Le}from"./buffer-logic-D9FvoilV.js";import{c as Re,d as H,f as U,i as W,l as ze,o as Be,p as Ve,r as He,s as Ue,t as We,u as Ge}from"./buffer-store-OTFEYxTw.js";var Ke=ge(`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`}]]),G=e(t(),1);function K(e){return{tabSize:e,insertSpaces:!0,detectIndentation:!1}}var qe=new we(500,`code`),Je=new we(500,`diff`);function Ye(e){let t={...e.contributionsState};return delete t[`editor.contrib.wordHighlighter`],{...e,contributionsState:t}}function Xe(e,t){let n=(0,G.useRef)(null),r=(0,G.useRef)(null);return(0,G.useLayoutEffect)(()=>(n.current&&(r.current=t(n.current,e)),()=>{r.current?.(),r.current=null}),[e,t]),(0,G.useCallback)(i=>{r.current?.(),n.current=i,i.onDidDispose(()=>{n.current===i&&(n.current=null)}),r.current=t(i,e)},[e,t])}function Ze(e,t){let n=qe.get(t);n&&e.restoreViewState(n);let r=()=>{if(!e.getModel())return;let n=e.saveViewState();n&&qe.set(t,Ye(n))},i=[e.onDidScrollChange(r),e.onDidChangeCursorSelection(r)];return()=>{r(),i.forEach(e=>e.dispose())}}function Qe(e,t){let n=Je.get(t),r=n!==void 0,i=()=>{if(r||!e.getModel())return;let n=e.saveViewState();n&&Je.set(t,{...n,original:n.original&&Ye(n.original),modified:n.modified&&Ye(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 $e(e){return Xe(Ce(`code`,e),Ze)}function q(e){return Xe(Ce(`diff`,e),Qe)}var J=n();function et({conflict:e}){let[t,n]=(0,G.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)(_e,{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=V(),[l,u]=(0,G.useState)(!1),d=q([`conflict`,r.uri.toString()]),f=(0,G.useId)(),p=(0,G.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),m=(0,G.useRef)(o);m.current=o;let h=(0,G.useRef)(null),g=()=>{let e=h.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),h.current=null},_=(0,G.useRef)(g);return _.current=g,(0,G.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)(R,{modifiedModelPath:r.uri.toString(),originalModelPath:`puddle-disk://${encodeURIComponent(e)}/${n.mtimeMs}/${encodeURIComponent(f)}/${t.split(`/`).map(encodeURIComponent).join(`/`)}`,original:n.content,language:c.editorLanguage??z(t),theme:B,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,...K(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:P(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 we(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=Te(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?Ee(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,c]=await Promise.all([i(Object.entries(n.files)),i(Object.entries(n.document.components).map(([e,t])=>[e,d(t)]))]);return{source:n,baseline:f.parse({...e,format:1,digest:r,files:o,components:c})}}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))&&d(e.components)===d(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,n,i){let a=n===void 0?/^\.puddle\/huddle\/([a-f0-9]{32})\/(huddle|layout)\.json$/.exec(t):null,o=!!a&&!p(),s=w(),l=ve(),d=wt(),f=o&&r(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:f}),h=F(e,n),g=D(),_=l&&m.data&&a?{profile:l,scope:d,project_id:m.data.project_id,worktree:m.data.worktree_path,huddle_id:a[1]}:void 0,v=[`huddle-source`,_?.scope,l,_?.project_id,_?.worktree,_?.huddle_id],y=()=>{if(!_||p()||ye()!==_.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
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:f&&!!_,retry:!1,refetchOnWindowFocus:!0,...i?{refetchInterval:ee(3e3)}:{}}),O=e=>e instanceof S&&e.code===`huddle_definition_invalid`,k=f&&O(C.error),A=M(e,t,{root:n,live:!f&&i,enabled:k||!f&&(!o||!!s.data)}),j=T({retry:!1,mutationFn:async n=>{if(!f){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=c.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:f,file:{data:k?A.data?{...A.data,repair:!0}:void 0:f?C.data?b(C.data):void 0:A.data,error:k?A.error:f?C.error??m.error:A.error??(o?s.error:null),refetch:async e=>{if(!f)return{data:(await A.refetch(e)).data};try{let t=await C.refetch({...e,throwOnError:!0});return{data:t.data?b(t.data):void 0}}catch(t){if(!O(t))throw t;let n=await A.refetch(e);return{data:n.data?{...n.data,repair:!0}:void 0}}}},saveMutation:j}}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(L(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=Dt(L(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>{if(t.fileSettingsKey){let e=Se.get(t.fileSettingsKey).wordWrap??h().editorWordWrap;Se.update(t.fileSettingsKey,{wordWrap:Et(e)})}else m({editorWordWrap:Et(h().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,i){let a=i?.passive===!0,s=ve(),c=i?.focused??!0,{fileSettingsKey:u}=V(),d=We(e,t,r),{file:f,saveMutation:p,guarded:m}=Tt(e,t,r,i?.live),[h,g]=(0,G.useState)(null),[_,v]=(0,G.useState)(!1),y=(0,G.useRef)(!1),b=(0,G.useRef)(null),x=(0,G.useRef)(null),ee=(0,G.useRef)(n);ee.current=n;let w=(0,G.useRef)(!1),T=(0,G.useCallback)((e,t,n)=>{x.current?.cancel(),w.current=!0;try{Re(d,e,t,n)}finally{w.current=!1}},[d]),E=(0,G.useSyncExternalStore)((0,G.useCallback)(e=>Ve(d,e),[d]),()=>W(d)),D=(0,G.useSyncExternalStore)((0,G.useCallback)(e=>Fe(d,e),[d]),()=>je(d)),O=(0,G.useSyncExternalStore)((0,G.useCallback)(e=>pe(d,e),[d]),()=>N(d));(0,G.useEffect)(()=>{let n=f.data;if(!n||n.binary||n.content===null||y.current)return;y.current=!0;let i=H(d)!==void 0,a=s&&C()?be(s).buffer({session:e,path:t,root:r}):void 0,c=He(e,t,n.content,a?.baseMtimeMs??n.mtime_ms,r,a?o(a.baseRevision):n.baseRevision),l=c.getValue();if(g(c),!i){if(a){Le(c,a.content)&&v(!0);return}De(e,t,r).then(i=>{if(!i||c.isDisposed())return;let a=W(d)?`offer`:ke(i,l,n.mtime_ms,n.baseRevision);a===`discard`?Ae(e,t,r):a===`restore`?(ze(d,i.base_mtime_ms,i.baseRevision),Le(c,i.content)&&v(!0)):I(`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:()=>{c.isDisposed()||(ze(d,i.base_mtime_ms,i.baseRevision),Le(c,i.content)&&v(!0))}}})})}},[f.data,d,e,t,r,s]),(0,G.useEffect)(()=>{if(!s||!h||!C())return;let n=be(s),i={session:e,path:t,root:r},a=n.registerBuffer(i,()=>h.isDisposed()?n.buffer(i)??null:W(d)?{...i,content:h.getValue(),baseMtimeMs:H(d)??0,...U(d)?{baseRevision:U(d)}:{}}:null),o=Ve(d,()=>n.bufferChanged(i));return n.bufferChanged(i),()=>{a(),o()}},[s,h,d,e,t,r]),(0,G.useEffect)(()=>{if(!h||a)return;let n=Oe(e,t,r),i=Me(e,t,r,n.cancel);x.current=n;let o=h.onDidChangeContent(()=>{w.current||(n(h.getValue(),H(d)??0,U(d)),Pe(e,t,r))});return()=>{i(),n.flush(),o.dispose(),x.current=null}},[h,d,e,t,r,a]),(0,G.useEffect)(()=>{!h||!D.savedElsewhere||W(d)||f.refetch().then(e=>{W(d)||(e.data&&e.data.content!==null&&T(e.data.content,e.data.mtime_ms,e.data.baseRevision),Ne(d))})},[D.savedElsewhere,h,d]),(0,G.useEffect)(()=>{let e=f.data;!h||!e||e.content===null||!W(d)&&(e.mtime_ms!==H(d)||!l(e.baseRevision,U(d)))&&T(e.content,e.mtime_ms,e.baseRevision)},[f.data,h,d]);let k=(0,G.useCallback)((n,i,a)=>{Be(d,n,i,a),x.current?.cancel(),W(d)&&h?(x.current?.(h.getValue(),i,a),x.current?.flush()):Ae(e,t,r),Ie(e,t,i,r),v(!1),ae(d)},[d,e,t,r,h]),A=(0,G.useCallback)(()=>{let e=ie(d);e!==null&&(I.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.`);oe(d,e,n.content,n.mtime_ms,n.baseRevision,n.captured,U(d),n.repair)}).catch(t=>{re(d,e,t instanceof Error?t.message:`The disk version did not load.`)}))},[f,d]),j=(0,G.useRef)(A);j.current=A,(0,G.useEffect)(()=>{if(!te(O,c))return;let e=jt(d);return I(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()}}),()=>{I.dismiss(e)}},[O,c,d]);let M=(0,G.useCallback)(()=>{let n=N(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&&N(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&&N(d)?.revision!==n.revision||(T(a.content,o.mtime_ms,a.baseRevision),Ae(e,t,r),v(!1),ae(d))}).catch(n=>{n instanceof S&&n.code===`stale_file`?me(d,{session:e,path:t,root:r}):I.error(n instanceof Error?n.message:`Reload failed`)})},[d,e,t,r,f,p,T,m]),ne=(0,G.useCallback)((e,n)=>{p.mutate({path:t,content:e},{onSuccess:e=>k(n,e.mtime_ms),onError:e=>I.error(e instanceof Error?e.message:`Overwrite failed`)})},[p,t,k]),de=(0,G.useCallback)(async()=>{let n=N(d);if(n&&n.phase!==`comparing`)return!1;if(!h||!W(d)&&!n)return!0;let i=h.getValue(),a=h.getAlternativeVersionId();if(ce(N(d)))return!1;let o=le(N(d))??H(d);try{let e=await p.mutateAsync({path:t,content:i,expected_mtime_ms:o,baseRevision:n?.phase===`comparing`?n.baseRevision:U(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}),I.error(n instanceof Error?n.message:`Save failed`)),!1}},[h,d,p,e,t,r,k,m]),P=(0,G.useRef)(de);P.current=de,(0,G.useEffect)(()=>se(ue(e,t,r),()=>P.current(),{session:e,path:t,...r===void 0?{}:{root:r}}),[e,t,r]);let F=(0,G.useCallback)(()=>{let n=b.current,i=ee.current;!n||!i||!c||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,c]),he=(0,G.useCallback)(e=>{b.current=e,Ot(e,{onSave:()=>P.current(),fileSettingsKey:u}),F()},[F,u]);(0,G.useEffect)(()=>{F()},[n,h,F]);let ge=(0,G.useCallback)(()=>{M()},[M]),_e=(0,G.useCallback)(()=>{if(!(!h||N(d)?.phase!==`comparing`)){if(m||U(d)){P.current();return}ne(h.getValue(),h.getAlternativeVersionId())}},[h,d,ne,m]),ye=(0,G.useCallback)(e=>{fe(d,e)},[d]),L,R=null;f.data?.binary?L=`binary`:m&&h&&E?L=`ready`:f.error?f.error instanceof S&&f.error.status===413?L=`too-large`:(L=`error`,R=f.error instanceof Error?f.error.message:`Failed to load file`):L=h?`ready`:`loading`;let xe=E&&D.savedElsewhere?`saved-elsewhere`:E&&D.dirtyElsewhere?`dirty-elsewhere`:null;return{status:L,errorMessage:R,model:h,dirty:E,restoredNotice:_,discardRestore:ge,peerBadge:xe,conflict:O,takeDisk:M,keepMine:_e,compare:A,comparisonReady:ye,save:de,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,r){let a=w(),o=O(e,t,{root:n,enabled:a.data!==void 0&&i(a.data.protocol)&&r!==null}),[s,c]=(0,G.useState)(null),l=(0,G.useCallback)(e=>{c(e)},[]);return(0,G.useLayoutEffect)(()=>{let e=o.data;if(!s||!r||!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 i=y.createModel(e.exists?e.content??``:``,r.getLanguageId()),a=y.createDiffEditor(n,{readOnly:!0,automaticLayout:!1,renderSideBySide:!1,minimap:{enabled:!1}}),c=s.createDecorationsCollection();a.setModel({original:i,modified:r});let l=Vt({editor:s,original:i,modified:r,path:t}),u=()=>{let e=a.getLineChanges();e&&(l.update(e),c.set(Lt(e,r.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(),i.dispose(),n.remove()}},[s,r,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 k(t,n,r).catch(e=>I.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)(ne,{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=V(),l=he(),u=$e([e,r,t]),d=Mt(e,t,n,r,{focused:i}),f=de(e,t,r),p=Ut(e,t,r,d.model),m=(0,G.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),[h,_]=(0,G.useState)(null),v=(0,G.useMemo)(()=>({session:e,path:t,root:r}),[e,t,r]),b=d.conflict!==null&&d.conflict.phase!==`unresolved`;if((0,G.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,G.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)(xe,{path:d.model.uri.toString(),language:c.editorLanguage??z(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,...K(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,G.useRef)(t);n.current=t,(0,G.useEffect)(()=>(Ge(e),()=>{n.current?.(),Ue(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=V(),a=$e([e,t,n]),o=(0,G.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,J.jsx)(xe,{path:$(`puddle-view`,e,t,n),language:i.editorLanguage??z(n),defaultValue:r,theme:B,saveViewState:!1,onMount:a,loading:(0,J.jsx)(Q,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:o,fontSize:i.editorFontSize,...K(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=A(e,t,n,{root:r,enabled:!i}),o=j(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=V(),c=q([e,i,t,a,n]),l=Mt(e,n,null,i,{focused:o}),u=A(e,t,r,{root:i,enabled:!a}),d=j(e,r,{root:i,enabled:a}),f=a?d:u,p=(0,G.useRef)(null);Kt(We(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,G.useRef)(l.save);m.current=l.save;let h=(0,G.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)(R,{modifiedModelPath:l.model.uri.toString(),originalModelPath:$(`puddle-base`,e,`${t}:${i??``}`,r),original:f.data.content??``,language:s.editorLanguage??z(n),theme:B,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,...K(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=V(),a=q([e,r,t,`staged`,n.path]),o=n.old_path??n.path,s=A(e,t,o,{root:r,enabled:n.status!==`added`}),c=j(e,n.path,{root:r,enabled:n.status!==`deleted`}),l=(0,G.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)(R,{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??z(n.path),onMount:a,theme:B,loading:(0,J.jsx)(Q,{children:`…`}),options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:l,fontSize:i.editorFontSize,...K(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(We(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,G.useId)(),l=V(),u=q([e,s,t,n,i,a]),d=(0,G.useRef)(null),f=(0,G.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,G.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)(R,{originalModelPath:$(`puddle-revision-original`,e,`${c}:${t}:${s??``}`,n),modifiedModelPath:$(`puddle-revision-modified`,e,`${c}:${i}:${s??``}`,a),language:l.editorLanguage??z(a),original:r,modified:o,theme:B,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,...K(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,Ke as g,K as h,Q as i,dt as l,$e as m,Jt as n,Gt as o,nt as p,Qt as r,Mt as s,$t as t,rt as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{r,s as i}from"./theme-swfNLod9.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{t as n}from"./jsx-runtime-ffCh33zF.js";import{r,s as i}from"./theme-swfNLod9.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-SnGDjajv.js";import{n as c}from"./markdown-Dj7Cr7RL.js";import{n as l,r as u}from"./preferences-BP2Incj1.js";import{i as d,l as f,o as p,s as m,t as h}from"./file-links-CEjYCLBn.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-Br9yR6jZ.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,...r.rawSource!==void 0&&{rawSource:r.rawSource}}),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(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import{t as n}from"./react-CZI7_Jkm.js";import{t as r}from"./jsx-runtime-ffCh33zF.js";import{n as i,o as a,u as o}from"./protocol-support-C2shbX3-.js";import{A as s,Cn as c,D as l,Dn as u,Mn as d,O as f,Sn as p,Tn as m,bn as h,j as g,k as _,xn as v}from"./local-store-3IuC2qMo.js";import{i as y,r as b}from"./LazyTerminal-DRIHw2iz.js";import{A as x,C as S,E as C,O as w,S as ee,_ as T,a as te,b as ne,c as re,d as ie,f as ae,i as oe,j as se,k as ce,l as le,m as ue,n as de,o as fe,r as pe,s as me,t as he,u as ge,v as _e,x as ve,y as ye}from"./notification-delivery-DWIF1cHd.js";import{a as be,i as xe,r as E,t as Se}from"./client-settings-BdKglwtW.js";import{i as Ce}from"./editor-links-DFaQQsK-.js";import{c as we,t as Te}from"./theme-swfNLod9.js";import{n as Ee,t as De}from"./api-BLc59FAZ.js";import{a as Oe}from"./window-context-Euxqnh6S.js";import{D as ke,E as Ae,H as je,I as Me,L as D,N as Ne,P as Pe,V as O,W as Fe,X as Ie,Y as Le,b as Re,c as ze,f as Be,j as Ve,k as He,p as Ue,r as We,s as Ge,st as Ke,v as qe,vt as Je,w as Ye,x as Xe,z as Ze}from"./queries-essOjrjZ.js";import{a as Qe,n as $e}from"./use-desktop-state-CS5BxWes.js";import{t as k}from"./utils-B6KiDbIe.js";import{a as A,i as j,n as et,o as tt,r as M,s as N,t as P}from"./dialog-DfdBRe6G.js";import{n as F}from"./dist-DMpqv5CF.js";import{t as nt}from"./x-CbfJFzGo.js";import{a as I,i as L,n as R,r as z,t as B}from"./select-DHaYbZVV.js";import{t as V}from"./button-BNH9tKwf.js";import{n as H,r as rt}from"./chevron-right-6pjfw_yV.js";import{a as it,o as at,t as ot}from"./colour-picker-cDlTcc8M.js";import{t as st}from"./createLucideIcon-DyMAgLa3.js";import{t as ct}from"./profile-icons-CFPzzic1.js";import{n as lt,t as ut}from"./shield-check-CY69Ons-.js";import{i as dt,r as ft,t as U}from"./switch-DZ2lisDt.js";import{t as pt}from"./code-DRWf9a5s.js";import{n as mt,t as ht}from"./disclosure-oYVpfMYO.js";import{t as gt}from"./rotate-ccw-CNjR2LSi.js";import{t as _t}from"./trash-2-WYPJMQLN.js";import{a as vt,i as yt,n as bt,r as xt,t as St}from"./session-display-Bxz8xi3w.js";import{i as W,n as Ct}from"./profile-store-BDrSK8Qs.js";import{a as wt,n as Tt,o as Et,p as Dt,t as Ot}from"./hotkeys-ChnvTHTH.js";import{t as kt}from"./control-tray-jUtkASPS.js";import{n as G}from"./errors-CV02t999.js";import{t as At}from"./use-debounced-value-C86N-mOK.js";import{n as jt,r as Mt,t as Nt}from"./popover-CNEMQBFf.js";import{t as Pt}from"./preferences-sJF-HcJf.js";import{a as Ft,o as It,r as Lt,t as Rt,u as zt}from"./CompilationCommandForm-BkQcFUoa.js";var Bt=st(`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=st(`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=st(`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=st(`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=r();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)(H,{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:k(`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:k(`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)(U,{id:`ripple-enabled`,checked:xe().rippleEnabled===!0,onCheckedChange:e=>{E({rippleEnabled:e}),Pt()}})})}function Gt(){let e=xe(),[t,n]=(0,K.useState)(we());return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Appearance`}),(0,q.jsx)(Y,{label:`Theme`,children:(0,q.jsxs)(B,{value:t,onValueChange:e=>{n(e),Te(e)},children:[(0,q.jsx)(L,{className:`w-32`,children:(0,q.jsx)(I,{})}),(0,q.jsxs)(R,{children:[(0,q.jsx)(z,{value:`dark`,children:`Dark`}),(0,q.jsx)(z,{value:`light`,children:`Light`}),(0,q.jsx)(z,{value:`system`,children:`System`})]})]})}),(0,q.jsx)(Y,{label:`Cursor style`,children:(0,q.jsxs)(B,{value:e.cursorPackage,onValueChange:e=>E({cursorPackage:e}),children:[(0,q.jsx)(L,{className:`w-36`,children:(0,q.jsx)(I,{})}),(0,q.jsx)(R,{children:be.map(e=>(0,q.jsx)(z,{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)(B,{value:e.density,onValueChange:e=>E({density:e}),children:[(0,q.jsx)(L,{className:`w-36`,children:(0,q.jsx)(I,{})}),(0,q.jsxs)(R,{children:[(0,q.jsx)(z,{value:`compact`,children:`Compact`}),(0,q.jsx)(z,{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)(U,{id:`project-based-layout`,checked:$e(e.projectBasedLayout)??e.projectBasedLayout,onCheckedChange:e=>{Qe(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)(U,{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)(U,{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)(U,{id:`show-host-on-focus`,checked:e.showHostOnFocus,onCheckedChange:e=>E({showHostOnFocus:e})})})]})}function Kt({profile:e}){let t=Me(),[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)(ce,{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:k(`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)(ce,{icon:null,colour:null,className:`size-4`})}),ct.map(({name:t,Icon:n})=>(0,q.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:k(`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)(ot,{onCustomChange:a,value:e.icon_colour,onChange:a,label:`Icon colour`})})]})}var qt=`__none__`;function Jt(){let e=W(),t=je().data?.find(t=>t.id===e),n=Ge(e??void 0),r=O(e??void 0),i=Me(),a=D(e??``),o=Ye(),[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)(H,{id:`profile-name`,value:s,onChange:e=>c(e.target.value),className:`w-44`}),(0,q.jsx)(V,{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)(H,{id:`branch-prefix`,value:l,onChange:e=>u(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,q.jsx)(V,{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)(B,{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)(L,{className:`w-56`,children:(0,q.jsx)(I,{})}),(0,q.jsxs)(R,{children:[(0,q.jsx)(z,{value:qt,children:`First available`}),n.data?.map(e=>(0,q.jsx)(z,{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)(V,{variant:`danger`,size:`sm`,onClick:()=>f(!0),children:`Delete…`})}),(0,q.jsx)(P,{open:d,onOpenChange:e=>{e||(f(!1),m(``))},children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(tt,{children:[(0,q.jsxs)(N,{children:[`Delete profile `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,q.jsx)(j,{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)(at,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,q.jsx)(H,{id:`delete-confirm-name`,value:p,onChange:e=>m(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(A,{children:[(0,q.jsx)(V,{variant:`ghost`,onClick:()=>{f(!1),m(``)},children:`Cancel`}),(0,q.jsx)(V,{variant:`danger`,disabled:p!==t.name||o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>{bt(),Ct.set(null)},onError:e=>{f(!1),m(``),G(e)}}),children:`Delete profile`})]})]})})]})}function Yt({agent:e,profileId:t,onClose:n,onCreated:r}){let i=Ue(),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),l=Ae(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)(P,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(tt,{children:[(0,q.jsxs)(N,{children:[`Add a `,e.display_name,` account`]}),(0,q.jsxs)(j,{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)(H,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(b,{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)(A,{children:[(0,q.jsx)(V,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,q.jsxs)(V,{disabled:!f||i.isPending,onClick:p,children:[(0,q.jsx)(mt,{}),`Add account`]})]})]})})}function Xt({account:e,gateOpen:t,installed:n}){let r=Ve(),i=Ne(),a=Xe(),[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)(it,{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)(U,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>G(e)})})]}),(0,q.jsxs)(V,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>G(e)}),children:[(0,q.jsx)(se,{}),e.logged_in?`Re-login`:`Login`]}),(0,q.jsxs)(V,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,q.jsx)(_t,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,q.jsx)(S,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,q.jsx)(P,{open:c,onOpenChange:l,children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(tt,{children:[(0,q.jsxs)(N,{children:[`Delete `,(0,q.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,q.jsx)(j,{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)(A,{children:[(0,q.jsx)(V,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,q.jsx)(V,{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=W(),t=ze(),n=Ge(e??void 0),r=O(e??void 0),i=Ve(),[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)(V,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>c(e),children:[(0,q.jsx)(mt,{}),`Add account`]})})]})]},e.id)}),a&&(0,q.jsx)(S,{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||F.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=Be(),t=Pe(),[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)(H,{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)(H,{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)(U,{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)(U,{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:xe().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)(rt,{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)(V,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,q.jsx)(V,{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:c;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)(H,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:c}),(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,q.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:St(nn,a)})]}),(0,q.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:m.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)(V,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,q.jsx)(V,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(c),t(c)},children:`Reset to default`})]})]})}function an(){let e=W(),t=je().data?.find(t=>t.id===e),n=O(e??void 0),r=D(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)(U,{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)(U,{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??v,defaultText:v,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??h,defaultText:h,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??p,defaultText:p,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)(P,{open:i,onOpenChange:e=>{e||(a(!1),s(``))},children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(tt,{children:[(0,q.jsxs)(N,{className:`flex items-center gap-2`,children:[(0,q.jsx)(Vt,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,q.jsx)(j,{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)(at,{htmlFor:`confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,q.jsx)(H,{id:`confirm-name`,value:o,onChange:e=>s(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(A,{children:[(0,q.jsx)(V,{variant:`ghost`,onClick:()=>{a(!1),s(``)},children:`Cancel`}),(0,q.jsx)(V,{variant:`danger`,disabled:o!==t?.name||r.isPending,onClick:()=>l(!0),children:`Open the gate`})]})]})})]})}var on=d.parse({});function sn(){let[e,t]=(0,K.useState)(oe);return(0,K.useEffect)(()=>{let e=()=>t(oe());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(oe())]}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=W(),t=O(e??void 0),n=D(e??``),r=Fe(e??void 0),[i,a]=sn(),o=pe(),[s,c]=(0,K.useState)(!1);(0,K.useEffect)(()=>{de();let e=()=>void de();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]);let l=d.catch(on).parse(t.data?.notifications??{}),u=e=>n.mutate({notifications:e},{onError:e=>G(e)}),f=()=>{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)(U,{id:`notify-desktop`,checked:l.desktop,onCheckedChange:e=>{e&&f(),u({...l,desktop:e})}})}),l.desktop&&(0,q.jsx)(cn,{permission:i,onRequest:f}),(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)(U,{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)(V,{variant:`ghost`,disabled:s,onClick:()=>{c(!0),(async()=>{!Oe()?.showNotification&&typeof Notification<`u`&&Notification.permission==="default"&&(await Notification.requestPermission(),a()),await he({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)(U,{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)(U,{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=W(),t=i(Re().data?.protocol),n=Ft(t&&e!==null),[r,a]=(0,K.useState)(null),o=n.data?.providers??[],s=o.find(e=>e.id===r)??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)(B,{value:s.id,onValueChange:a,children:[(0,q.jsx)(L,{id:`compilation-language`,className:`w-48`,children:(0,q.jsx)(I,{})}),(0,q.jsx)(R,{children:o.map(e=>(0,q.jsx)(z,{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=Je();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=xe();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)(U,{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)(H,{id:`editor-link-host`,type:`text`,placeholder:Ce.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:k(`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)(gt,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function mn(){let e=W(),t=O(e??void 0),n=D(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)(U,{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)(``),l=(0,K.useRef)(0),u=(0,K.useRef)(null);(0,K.useEffect)(()=>()=>{l.current+=1},[]),(0,K.useEffect)(()=>{if(n)return;let e=!0;return u.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&&(u.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,u.current=null}},[n]);let d=(0,K.useRef)(t);return(0,K.useEffect)(()=>{d.current=t},[t]),(0,K.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>{l.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=l.current,i=!1,a,o=async()=>{try{if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);let{ready:e}=_.parse(await Ee(`POST`,`/frontend/remote/registration`,{service:n.request.service,code:n.code}));if(i||t!==l.current)return;if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);e?(r(null),await d.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!==l.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||!u.current)){c(``);try{let{code:e,challenge:a}=u.current,o=f.safeParse({service:t.trim(),app:n.trim(),label:i.trim(),challenge:a,expires:Date.now()+s.invitationMs});if(!o.success)throw Error(`Enter a host name and exact HTTPS application and relay origins.`);let c=o.data,d=`${c.app}/#register=${encodeURIComponent(JSON.stringify(c))}`;l.current+=1,u.current=null,r({request:c,code:e,url:d}),window.open(d,`_blank`,`noopener,noreferrer`)}catch(e){c(e instanceof Error?e.message:`Could not start sign-in.`)}}},cancel:()=>{l.current+=1,u.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)(H,{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)(H,{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)(H,{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)(V,{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)(V,{type:`submit`,disabled:m||!d.trim()||!s||!l,children:r?`Enabling…`:p.preparing?`Preparing sign-in…`:`Sign in and enable`}),o&&(0,q.jsx)(V,{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
|
|
1
|
+
import{r as e,t}from"./rolldown-runtime-QTnfLwEv.js";import{t as n}from"./react-CZI7_Jkm.js";import{t as r}from"./jsx-runtime-ffCh33zF.js";import{n as i,o as a,u as o}from"./protocol-support-DIWnYJkt.js";import{A as s,Cn as c,D as l,Dn as u,Mn as d,O as f,Sn as p,Tn as m,bn as h,j as g,k as _,xn as v}from"./local-store-DKFKEHML.js";import{i as y,r as b}from"./LazyTerminal-Cu5V6ejk.js";import{A as x,C as S,E as C,O as w,S as ee,_ as T,a as te,b as ne,c as re,d as ie,f as ae,i as oe,j as se,k as ce,l as le,m as ue,n as de,o as fe,r as pe,s as me,t as he,u as ge,v as _e,x as ve,y as ye}from"./notification-delivery-yJcsFWYx.js";import{a as be,i as xe,r as E,t as Se}from"./client-settings-BdKglwtW.js";import{i as Ce}from"./editor-links-Djdkea3i.js";import{c as we,t as Te}from"./theme-swfNLod9.js";import{n as Ee,t as De}from"./api-DhfvolrJ.js";import{a as Oe}from"./window-context-DddmcmmO.js";import{D as ke,E as Ae,H as je,I as Me,L as D,N as Ne,P as Pe,V as O,W as Fe,X as Ie,Y as Le,b as Re,c as ze,f as Be,j as Ve,k as He,p as Ue,r as We,s as Ge,st as Ke,v as qe,vt as Je,w as Ye,x as Xe,z as Ze}from"./queries-C9DYtGQW.js";import{a as Qe,n as $e}from"./use-desktop-state-xeH1nq63.js";import{t as k}from"./utils-B6KiDbIe.js";import{a as A,i as j,n as et,o as tt,r as M,s as N,t as P}from"./dialog-DfdBRe6G.js";import{n as F}from"./dist-DMpqv5CF.js";import{t as nt}from"./x-CbfJFzGo.js";import{a as I,i as L,n as R,r as z,t as B}from"./select-DHaYbZVV.js";import{t as V}from"./button-BNH9tKwf.js";import{n as H,r as rt}from"./chevron-right-6pjfw_yV.js";import{a as it,o as at,t as ot}from"./colour-picker-Dwq4M4eT.js";import{t as st}from"./createLucideIcon-DyMAgLa3.js";import{t as ct}from"./profile-icons-BmQVYS_o.js";import{n as lt,t as ut}from"./shield-check-CY69Ons-.js";import{i as dt,r as ft,t as U}from"./switch-DZ2lisDt.js";import{t as pt}from"./code-DRWf9a5s.js";import{n as mt,t as ht}from"./disclosure-oYVpfMYO.js";import{t as gt}from"./rotate-ccw-CNjR2LSi.js";import{t as _t}from"./trash-2-WYPJMQLN.js";import{a as vt,i as yt,n as bt,r as xt,t as St}from"./session-display-DHxCigRa.js";import{i as W,n as Ct}from"./profile-store-BnferXV3.js";import{a as wt,n as Tt,o as Et,p as Dt,t as Ot}from"./hotkeys-B417biB9.js";import{t as kt}from"./control-tray-jUtkASPS.js";import{n as G}from"./errors-SnGDjajv.js";import{t as At}from"./use-debounced-value-C86N-mOK.js";import{n as jt,r as Mt,t as Nt}from"./popover-CNEMQBFf.js";import{t as Pt}from"./preferences-BP2Incj1.js";import{a as Ft,o as It,r as Lt,t as Rt,u as zt}from"./CompilationCommandForm--aglvHpg.js";var Bt=st(`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=st(`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=st(`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=st(`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=r();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)(H,{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:k(`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:k(`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)(U,{id:`ripple-enabled`,checked:xe().rippleEnabled===!0,onCheckedChange:e=>{E({rippleEnabled:e}),Pt()}})})}function Gt(){let e=xe(),[t,n]=(0,K.useState)(we());return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Appearance`}),(0,q.jsx)(Y,{label:`Theme`,children:(0,q.jsxs)(B,{value:t,onValueChange:e=>{n(e),Te(e)},children:[(0,q.jsx)(L,{className:`w-32`,children:(0,q.jsx)(I,{})}),(0,q.jsxs)(R,{children:[(0,q.jsx)(z,{value:`dark`,children:`Dark`}),(0,q.jsx)(z,{value:`light`,children:`Light`}),(0,q.jsx)(z,{value:`system`,children:`System`})]})]})}),(0,q.jsx)(Y,{label:`Cursor style`,children:(0,q.jsxs)(B,{value:e.cursorPackage,onValueChange:e=>E({cursorPackage:e}),children:[(0,q.jsx)(L,{className:`w-36`,children:(0,q.jsx)(I,{})}),(0,q.jsx)(R,{children:be.map(e=>(0,q.jsx)(z,{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)(B,{value:e.density,onValueChange:e=>E({density:e}),children:[(0,q.jsx)(L,{className:`w-36`,children:(0,q.jsx)(I,{})}),(0,q.jsxs)(R,{children:[(0,q.jsx)(z,{value:`compact`,children:`Compact`}),(0,q.jsx)(z,{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)(U,{id:`project-based-layout`,checked:$e(e.projectBasedLayout)??e.projectBasedLayout,onCheckedChange:e=>{Qe(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)(U,{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)(U,{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)(U,{id:`show-host-on-focus`,checked:e.showHostOnFocus,onCheckedChange:e=>E({showHostOnFocus:e})})})]})}function Kt({profile:e}){let t=Me(),[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)(ce,{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:k(`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)(ce,{icon:null,colour:null,className:`size-4`})}),ct.map(({name:t,Icon:n})=>(0,q.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:k(`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)(ot,{onCustomChange:a,value:e.icon_colour,onChange:a,label:`Icon colour`})})]})}var qt=`__none__`;function Jt(){let e=W(),t=je().data?.find(t=>t.id===e),n=Ge(e??void 0),r=O(e??void 0),i=Me(),a=D(e??``),o=Ye(),[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)(H,{id:`profile-name`,value:s,onChange:e=>c(e.target.value),className:`w-44`}),(0,q.jsx)(V,{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)(H,{id:`branch-prefix`,value:l,onChange:e=>u(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,q.jsx)(V,{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)(B,{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)(L,{className:`w-56`,children:(0,q.jsx)(I,{})}),(0,q.jsxs)(R,{children:[(0,q.jsx)(z,{value:qt,children:`First available`}),n.data?.map(e=>(0,q.jsx)(z,{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)(V,{variant:`danger`,size:`sm`,onClick:()=>f(!0),children:`Delete…`})}),(0,q.jsx)(P,{open:d,onOpenChange:e=>{e||(f(!1),m(``))},children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(tt,{children:[(0,q.jsxs)(N,{children:[`Delete profile `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,q.jsx)(j,{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)(at,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,q.jsx)(H,{id:`delete-confirm-name`,value:p,onChange:e=>m(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(A,{children:[(0,q.jsx)(V,{variant:`ghost`,onClick:()=>{f(!1),m(``)},children:`Cancel`}),(0,q.jsx)(V,{variant:`danger`,disabled:p!==t.name||o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>{bt(),Ct.set(null)},onError:e=>{f(!1),m(``),G(e)}}),children:`Delete profile`})]})]})})]})}function Yt({agent:e,profileId:t,onClose:n,onCreated:r}){let i=Ue(),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),l=Ae(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)(P,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(tt,{children:[(0,q.jsxs)(N,{children:[`Add a `,e.display_name,` account`]}),(0,q.jsxs)(j,{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)(H,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(b,{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)(A,{children:[(0,q.jsx)(V,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,q.jsxs)(V,{disabled:!f||i.isPending,onClick:p,children:[(0,q.jsx)(mt,{}),`Add account`]})]})]})})}function Xt({account:e,gateOpen:t,installed:n}){let r=Ve(),i=Ne(),a=Xe(),[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)(it,{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)(U,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>G(e)})})]}),(0,q.jsxs)(V,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>G(e)}),children:[(0,q.jsx)(se,{}),e.logged_in?`Re-login`:`Login`]}),(0,q.jsxs)(V,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,q.jsx)(_t,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,q.jsx)(S,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,q.jsx)(P,{open:c,onOpenChange:l,children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(tt,{children:[(0,q.jsxs)(N,{children:[`Delete `,(0,q.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,q.jsx)(j,{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)(A,{children:[(0,q.jsx)(V,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,q.jsx)(V,{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=W(),t=ze(),n=Ge(e??void 0),r=O(e??void 0),i=Ve(),[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)(V,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>c(e),children:[(0,q.jsx)(mt,{}),`Add account`]})})]})]},e.id)}),a&&(0,q.jsx)(S,{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||F.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=Be(),t=Pe(),[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)(H,{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)(H,{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)(U,{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)(U,{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:xe().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)(rt,{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)(V,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,q.jsx)(V,{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:c;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)(H,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:c}),(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,q.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:St(nn,a)})]}),(0,q.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:m.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)(V,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,q.jsx)(V,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(c),t(c)},children:`Reset to default`})]})]})}function an(){let e=W(),t=je().data?.find(t=>t.id===e),n=O(e??void 0),r=D(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)(U,{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)(U,{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??v,defaultText:v,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??h,defaultText:h,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??p,defaultText:p,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)(P,{open:i,onOpenChange:e=>{e||(a(!1),s(``))},children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(tt,{children:[(0,q.jsxs)(N,{className:`flex items-center gap-2`,children:[(0,q.jsx)(Vt,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,q.jsx)(j,{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)(at,{htmlFor:`confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,q.jsx)(H,{id:`confirm-name`,value:o,onChange:e=>s(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(A,{children:[(0,q.jsx)(V,{variant:`ghost`,onClick:()=>{a(!1),s(``)},children:`Cancel`}),(0,q.jsx)(V,{variant:`danger`,disabled:o!==t?.name||r.isPending,onClick:()=>l(!0),children:`Open the gate`})]})]})})]})}var on=d.parse({});function sn(){let[e,t]=(0,K.useState)(oe);return(0,K.useEffect)(()=>{let e=()=>t(oe());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(oe())]}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=W(),t=O(e??void 0),n=D(e??``),r=Fe(e??void 0),[i,a]=sn(),o=pe(),[s,c]=(0,K.useState)(!1);(0,K.useEffect)(()=>{de();let e=()=>void de();return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]);let l=d.catch(on).parse(t.data?.notifications??{}),u=e=>n.mutate({notifications:e},{onError:e=>G(e)}),f=()=>{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)(U,{id:`notify-desktop`,checked:l.desktop,onCheckedChange:e=>{e&&f(),u({...l,desktop:e})}})}),l.desktop&&(0,q.jsx)(cn,{permission:i,onRequest:f}),(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)(U,{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)(V,{variant:`ghost`,disabled:s,onClick:()=>{c(!0),(async()=>{!Oe()?.showNotification&&typeof Notification<`u`&&Notification.permission==="default"&&(await Notification.requestPermission(),a()),await he({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)(U,{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)(U,{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=W(),t=i(Re().data?.protocol),n=Ft(t&&e!==null),[r,a]=(0,K.useState)(null),o=n.data?.providers??[],s=o.find(e=>e.id===r)??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)(B,{value:s.id,onValueChange:a,children:[(0,q.jsx)(L,{id:`compilation-language`,className:`w-48`,children:(0,q.jsx)(I,{})}),(0,q.jsx)(R,{children:o.map(e=>(0,q.jsx)(z,{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=Je();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=xe();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)(U,{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)(H,{id:`editor-link-host`,type:`text`,placeholder:Ce.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:k(`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)(gt,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function mn(){let e=W(),t=O(e??void 0),n=D(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)(U,{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)(``),l=(0,K.useRef)(0),u=(0,K.useRef)(null);(0,K.useEffect)(()=>()=>{l.current+=1},[]),(0,K.useEffect)(()=>{if(n)return;let e=!0;return u.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&&(u.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,u.current=null}},[n]);let d=(0,K.useRef)(t);return(0,K.useEffect)(()=>{d.current=t},[t]),(0,K.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>{l.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=l.current,i=!1,a,o=async()=>{try{if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);let{ready:e}=_.parse(await Ee(`POST`,`/frontend/remote/registration`,{service:n.request.service,code:n.code}));if(i||t!==l.current)return;if(n.request.expires<=Date.now())throw Error(`Sign-in expired. Try again.`);e?(r(null),await d.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!==l.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||!u.current)){c(``);try{let{code:e,challenge:a}=u.current,o=f.safeParse({service:t.trim(),app:n.trim(),label:i.trim(),challenge:a,expires:Date.now()+s.invitationMs});if(!o.success)throw Error(`Enter a host name and exact HTTPS application and relay origins.`);let c=o.data,d=`${c.app}/#register=${encodeURIComponent(JSON.stringify(c))}`;l.current+=1,u.current=null,r({request:c,code:e,url:d}),window.open(d,`_blank`,`noopener,noreferrer`)}catch(e){c(e instanceof Error?e.message:`Could not start sign-in.`)}}},cancel:()=>{l.current+=1,u.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)(H,{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)(H,{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)(H,{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)(V,{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)(V,{type:`submit`,disabled:m||!d.trim()||!s||!l,children:r?`Enabling…`:p.preparing?`Preparing sign-in…`:`Sign in and enable`}),o&&(0,q.jsx)(V,{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
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
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
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(`
|