@puddle-code/cli 0.0.42 → 0.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/CHANGELOG.md +7 -4
  2. package/dist/index.js +41 -11
  3. package/dist/public/assets/{Dashboard-BTrJV1ZL.js → Dashboard-CVuyy1FW.js} +1 -1
  4. package/dist/public/assets/{EditorTabClose-DQ6zIRnK.js → EditorTabClose-Dltbo1Dg.js} +1 -1
  5. package/dist/public/assets/{LazyTerminal-BaxoOzC-.js → LazyTerminal-dx89528B.js} +2 -2
  6. package/dist/public/assets/{ModelRefcount-DOfCr-GB.js → ModelRefcount-CCLXoHn3.js} +1 -1
  7. package/dist/public/assets/{PaneEditorBody-S9haVBER.js → PaneEditorBody-BEq9lIXk.js} +1 -1
  8. package/dist/public/assets/{SettingsDialog-C4zj9xpa.js → SettingsDialog-cXSqHb2k.js} +1 -1
  9. package/dist/public/assets/Terminal-2XYN3IO5.js +117 -0
  10. package/dist/public/assets/Workspace-DEEiDdYw.js +7 -0
  11. package/dist/public/assets/{buffer-store-lRf0Css5.js → buffer-store-kyNS3Ffy.js} +3 -3
  12. package/dist/public/assets/{context-menu-BvognaUc.js → context-menu-DsXFpYcn.js} +1 -1
  13. package/dist/public/assets/{cssMode-Dc1ahC7j.js → cssMode-CfVFZjxa.js} +1 -1
  14. package/dist/public/assets/{editor-sync-D8bMPmSR.js → editor-sync-1UzWDCzn.js} +1 -1
  15. package/dist/public/assets/file-links-xHzwSI4k.js +1 -0
  16. package/dist/public/assets/{htmlMode-DAayVS36.js → htmlMode-CwjicKNM.js} +1 -1
  17. package/dist/public/assets/index-BYC57b5y.js +10 -0
  18. package/dist/public/assets/index-Cs421fXN.css +2 -0
  19. package/dist/public/assets/{jsonMode-B7Y1ZN6D.js → jsonMode-B9Rj1ARB.js} +1 -1
  20. package/dist/public/assets/{session-seed-DSCaVN9j.js → session-seed-2cbwtTKV.js} +1 -1
  21. package/dist/public/assets/{tsMode-CBG_jsQ8.js → tsMode-gVybv0cY.js} +1 -1
  22. package/dist/public/index.html +3 -3
  23. package/package.json +1 -1
  24. package/dist/public/assets/Terminal-7PIU9bCC.js +0 -117
  25. package/dist/public/assets/Workspace-lnshKyvd.js +0 -7
  26. package/dist/public/assets/index-DpDy4sdB.js +0 -10
  27. package/dist/public/assets/index-fOB6mfj_.css +0 -2
  28. package/dist/public/assets/ssh-mode-Cy629wWo.js +0 -1
@@ -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{Bt as r,I as i,_ as a,c as o,f as s,xt as c,yt as l}from"./hotkeys-CA5Pxll4.js";import{A as u,C as d,E as f,M as p,N as m,O as h,R as g,T as _,_ as v,a as y,d as b,f as x,h as S,j as C,n as ee,o as te,p as ne,x as re}from"./editor-context-A7YnYVrw.js";import{t as ie}from"./preload-helper-Czpn1I53.js";import{F as ae,I as oe,J as se,N as ce,P as le,X as ue,Y as de,a as w,ft as fe}from"./index-DpDy4sdB.js";import{c as pe,i as me,p as he,r as ge}from"./editor.api2-4X9Vh9Zw.js";import{a as _e,c as ve,d as ye,f as be,i as xe,l as Se,n as Ce,o as we,r as T,s as Te,t as Ee,u as De}from"./buffer-store-lRf0Css5.js";import{a as Oe,c as ke,i as Ae,l as je,n as Me,o as Ne,r as Pe,s as Fe}from"./editor-sync-D8bMPmSR.js";import{r as Ie}from"./buffer-logic-BrpRsL1b.js";var E=e(t(),1),Le=new Map,Re=new Map,ze=1;function Be(e){for(let t of Re.get(e)??[])t()}function Ve(e,t){Le.set(e,t),Be(e)}function He(e){let t={phase:`unresolved`,revision:ze++};return Ve(e,t),t}function Ue(e){let t=Le.get(e);return!t||t.phase!==`unresolved`&&t.phase!==`load-error`?null:(Ve(e,{phase:`loading`,revision:t.revision}),t.revision)}function We(e,t,n,r){let i=Le.get(e);return!i||i.phase!==`loading`||i.revision!==t?!1:(Ve(e,{phase:`opening`,revision:t,content:n,mtimeMs:r}),!0)}function Ge(e,t){let n=Le.get(e);return!n||n.phase!==`opening`||n.revision!==t?!1:(Ve(e,{...n,phase:`comparing`}),!0)}function Ke(e,t,n){let r=Le.get(e);return!r||r.phase!==`loading`||r.revision!==t?!1:(Ve(e,{phase:`load-error`,revision:t,message:n}),!0)}function qe(e,t){return t&&e?.phase===`unresolved`}function Je(e){return e?.phase===`comparing`?e.mtimeMs:void 0}function Ye(e){return e?.phase===`loading`||e?.phase===`load-error`||e?.phase===`opening`}function Xe(e){return e.phase===`opening`||e.phase===`comparing`}function Ze(e){Le.delete(e)&&Be(e)}function Qe(e){return Le.get(e)??null}function $e(e,t){let n=Re.get(e);return n||(n=new Set,Re.set(e,n)),n.add(t),()=>n.delete(t)}var D=n();function et({session:e,path:t,conflict:n,model:r,onTakeDisk:i,onKeepMine:a,onSave:o,onReady:s}){let c=ue(),l=(0,E.useId)(),u=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),d=(0,E.useRef)(o);d.current=o;let f=(0,E.useRef)(null),p=()=>{let e=f.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),f.current=null},m=(0,E.useRef)(p);return m.current=p,(0,E.useEffect)(()=>()=>m.current(),[]),(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,D.jsx)(`span`,{children:`This file changed on disk. Yours is on the right — merge what you want, then save.`}),(0,D.jsx)(`button`,{type:`button`,onClick:i,className:`ml-auto shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Take the disk version`}),(0,D.jsx)(`button`,{type:`button`,onClick:a,disabled:n.phase!==`comparing`,className:`shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Keep mine`})]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(be,{modifiedModelPath:r.uri.toString(),originalModelPath:`puddle-disk://${encodeURIComponent(e)}/${n.mtimeMs}/${encodeURIComponent(l)}/${t.split(`/`).map(encodeURIComponent).join(`/`)}`,original:n.content,language:r.getLanguageId(),theme:De,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:e=>{f.current=e,e.onDidDispose(()=>{f.current=null}),e.getModifiedEditor().addCommand(me.CtrlCmd|ge.KeyS,()=>d.current()),s?.(n.revision)},options:{readOnly:n.phase!==`comparing`,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,fontSize:c.editorFontSize,wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function tt({session:e,path:t,buffer:n,focused:r}){let i=n.conflict;return!i||i.phase===`unresolved`?null:Xe(i)&&n.model?(0,D.jsx)(et,{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,D.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,D.jsx)(`span`,{children:`The disk version could not be loaded.`}),(0,D.jsx)(`span`,{className:`max-w-lg text-xs text-fg-secondary`,children:i.message}),(0,D.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,D.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:`Loading the disk version…`})}function nt(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function rt(e,t,n){return nt(e/Math.max(1,t-n))}function it(e,t,n){return nt(e)*Math.max(0,t-n)}function at(e,t){return JSON.stringify([e,t.session,t.root??null,t.path])}var ot=new class{positions=new Map;listeners=new Map;revision=0;publish(e,t,n){let r={ratio:nt(n),revision:++this.revision},i=at(e,t);this.positions.set(i,r);for(let e of this.listeners.get(i)??[])e(r);return r}get(e,t){return this.positions.get(at(e,t))}subscribe(e,t,n){let r=at(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)}}};function st(e){let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},dispose:()=>{t!==null&&cancelAnimationFrame(t),t=null}}}function ct(e,t){if(t.driver&&t.receiver)throw Error(`a preview scroll surface cannot be both driver and receiver`);let n=t.store??ot,r,i=()=>void 0,a,o=t=>{r=t,e.scrollTop=it(t.ratio,e.scrollHeight,e.clientHeight)};t.receiver?i=n.subscribe(t.channel,t.target,o):t.driver&&(a=st(()=>{n.publish(t.channel,t.target,rt(e.scrollTop,e.scrollHeight,e.clientHeight))}),e.addEventListener(`scroll`,a.schedule,{passive:!0}),a.schedule());let s=new ResizeObserver(()=>{t.receiver&&r?o(r):t.driver&&a?.schedule()});for(let e of t.resizeElements??[])s.observe(e);return()=>{t.driver&&a&&e.removeEventListener(`scroll`,a.schedule),i(),s.disconnect(),a?.dispose()}}function lt(e,t,n){if(t.driver&&t.receiver)throw Error(`a Monaco scroll surface cannot be both driver and receiver`);let r=t.store??ot,i=[],a,o=()=>void 0,s,c=()=>e.getLayoutInfo().height,l=t=>{a=t,e.setScrollTop(it(t.ratio,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)))):t.driver&&(s=st(()=>{r.publish(t.channel,t.target,rt(e.getScrollTop(),e.getScrollHeight(),c()))}),i.push(e.onDidScrollChange(s.schedule)),i.push(e.onDidChangeModel(s.schedule)),i.push(e.onDidLayoutChange(s.schedule)),s.schedule()),()=>{o();for(let e of i)e.dispose();s?.dispose()}}function ut(e){return!e}function dt(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=me.CtrlCmd:e===`ctrl`?r|=me.WinCtrl:e===`alt`?r|=me.Alt:e===`shift`&&(r|=me.Shift);let i=ge[/^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 O(e,t){let n=dt(o(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=dt(o(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>de({editorWordWrap:ut(se().editorWordWrap)})})}function ft(e){return`file-conflict:${e}`}function pt(e,t,n,i,a){let o=a?.passive===!0,s=a?.focused??!0,c=Ee(e,t,i),u=m(e,t,{root:i,live:a?.live}),d=C(e,i),[f,p]=(0,E.useState)(null),[h,g]=(0,E.useState)(!1),_=(0,E.useRef)(!1),y=(0,E.useRef)(null),b=(0,E.useRef)(null),x=(0,E.useRef)(n);x.current=n;let ee=(0,E.useRef)(!1),te=(0,E.useCallback)((e,t)=>{b.current?.cancel(),ee.current=!0;try{we(c,e,t)}finally{ee.current=!1}},[c]),ne=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>Se(c,e),[c]),()=>T(c)),re=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>Ne(c,e),[c]),()=>Oe(c)),ie=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>$e(c,e),[c]),()=>Qe(c));(0,E.useEffect)(()=>{let n=u.data;if(!n||n.binary||n.content===null||_.current)return;_.current=!0;let a=ve(c)!==void 0,o=Ce(e,t,n.content,n.mtime_ms,i);p(o),!a&&je(e,t,i).then(e=>{e&&(e.base_mtime_ms===n.mtime_ms?Ie(o,e.content)&&g(!0):r(`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:()=>{Ie(o,e.content)&&g(!0)}}}))})},[u.data,c,e,t,i]),(0,E.useEffect)(()=>{if(!f||o)return;let n=ke(e,t,i);b.current=n;let r=f.onDidChangeContent(()=>{ee.current||(n(f.getValue(),ve(c)??0),Me(e,t,i))});return()=>{n.flush(),r.dispose(),b.current=null}},[f,c,e,t,i,o]),(0,E.useEffect)(()=>{!f||!re.savedElsewhere||T(c)||u.refetch().then(e=>{T(c)||(e.data&&e.data.content!==null&&te(e.data.content,e.data.mtime_ms),Ae(c))})},[re.savedElsewhere,f,c]),(0,E.useEffect)(()=>{let e=u.data;!f||!e||e.content===null||!T(c)&&e.mtime_ms!==ve(c)&&te(e.content,e.mtime_ms)},[u.data,f,c]);let ae=(0,E.useCallback)((n,r)=>{xe(c,n,r),b.current?.cancel(),Fe(e,t,i),Pe(e,t,r,i),g(!1),Ze(c)},[c,e,t,i]),oe=(0,E.useCallback)(()=>{let e=Ue(c);e!==null&&(r.dismiss(ft(c)),u.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.`);We(c,e,n.content,n.mtime_ms)}).catch(t=>{Ke(c,e,t instanceof Error?t.message:`The disk version did not load.`)}))},[u,c]),se=(0,E.useRef)(oe);se.current=oe,(0,E.useEffect)(()=>{if(!qe(ie,s))return;let e=ft(c);return r(`File changed on disk`,{id:e,description:`Nothing was written — your unsaved version is intact.`,duration:1/0,closeButton:!0,action:{label:`Compare`,onClick:()=>se.current()}}),()=>{r.dismiss(e)}},[ie,s,c]);let ce=(0,E.useCallback)(()=>{u.refetch().then(n=>{n.data&&n.data.content!==null&&te(n.data.content,n.data.mtime_ms),Fe(e,t,i),g(!1),Ze(c)})},[c,e,t,te]),le=(0,E.useCallback)((e,n)=>{d.mutate({path:t,content:e},{onSuccess:e=>ae(n,e.mtime_ms),onError:e=>r.error(e instanceof Error?e.message:`Overwrite failed`)})},[d,t,ae]),ue=(0,E.useCallback)(()=>{if(!f||!T(c))return;let e=f.getValue(),n=f.getAlternativeVersionId();if(Ye(Qe(c)))return;let i=Je(Qe(c))??ve(c);d.mutate({path:t,content:e,expected_mtime_ms:i},{onSuccess:e=>ae(n,e.mtime_ms),onError:e=>{e instanceof l&&e.status===409&&e.code===`stale_file`?He(c):r.error(e instanceof Error?e.message:`Save failed`)}})},[f,c,d,t,ae]),de=(0,E.useRef)(ue);de.current=ue,(0,E.useEffect)(()=>S(v(e,t,i),()=>de.current()),[e,t,i]);let w=(0,E.useCallback)(()=>{let n=y.current,r=x.current;i===void 0&&(!n||!r||r.session!==e||r.path!==t||(n.revealLineInCenter(r.line),n.setPosition({lineNumber:r.line,column:r.column??1}),n.focus()))},[e,t,i]),fe=(0,E.useCallback)(e=>{y.current=e,O(e,{onSave:()=>de.current()}),w()},[w]);(0,E.useEffect)(()=>{w()},[n,f,w]);let pe=(0,E.useCallback)(()=>{ce()},[ce]),me=(0,E.useCallback)(()=>{!f||Qe(c)?.phase!==`comparing`||le(f.getValue(),f.getAlternativeVersionId())},[f,c,le]),he=(0,E.useCallback)(e=>{Ge(c,e)},[c]),ge,_e=null;u.data?.binary?ge=`binary`:u.error?u.error instanceof l&&u.error.status===413?ge=`too-large`:(ge=`error`,_e=u.error instanceof Error?u.error.message:`Failed to load file`):ge=f?`ready`:`loading`;let ye=ne&&re.savedElsewhere?`saved-elsewhere`:ne&&re.dirtyElsewhere?`dirty-elsewhere`:null;return{status:ge,errorMessage:_e,model:f,dirty:ne,restoredNotice:h,discardRestore:pe,peerBadge:ye,conflict:ie,takeDisk:ce,keepMine:me,compare:oe,comparisonReady:he,save:ue,onMount:fe}}function mt(e,t,n,r){for(let i of e)if(yt([i],n).some(e=>(r===void 0||e.kind===r)&&t>=e.startLineNumber&&t<=e.endLineNumber))return i;return null}function ht(e,t){return _t(e.modifiedStartLineNumber,e.modifiedEndLineNumber)>0?Math.min(t,e.modifiedEndLineNumber):Math.max(0,Math.min(t,e.modifiedStartLineNumber-1))}function gt(e){let t=_t(e.originalStartLineNumber,e.originalEndLineNumber),n=_t(e.modifiedStartLineNumber,e.modifiedEndLineNumber);return Math.max(5,Math.min(14,t+n+4))}function _t(e,t){return t===0?0:Math.max(0,t-e+1)}function vt(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 yt(e,t){let n=[];for(let r of e){let e=_t(r.originalStartLineNumber,r.originalEndLineNumber),i=_t(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(vt(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(vt(r.modifiedStartLineNumber+i,t))}return n}var bt=28,xt=[[`puddle-dirty-added`,`added`],[`puddle-dirty-modified`,`modified`],[`puddle-dirty-deleted-before`,`deleted-before`],[`puddle-dirty-deleted-after`,`deleted-after`]];function St(e){if(e){for(let[t,n]of xt)if(e.classList.contains(t)||e.closest(`.${t}`))return n}}function Ct({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,he.ScrollType.Immediate)},u=(i,s)=>{if(a?.anchorLine===i){c();return}c();let u=e.getOption(he.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(`click`,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:ht(s,n.getLineCount()),heightInPx:bt+gt(s)*u,domNode:d,marginDomNode:g,suppressMouseDown:!1},v=``;e.changeViewZones(e=>{v=e.addZone(_)});let y={anchorLine:i,change:s,zone:_,zoneId:v,frame:null,diffEditor:null};a=y,y.frame=requestAnimationFrame(()=>{if(y.frame=null,o||a!==y)return;let r=he.createDiffEditor(h,{readOnly:!0,domReadOnly:!0,originalEditable:!1,renderSideBySide:!1,renderMarginRevertIcon:!1,renderOverviewRuler:!1,enableSplitViewResizing:!1,isInEmbeddedEditor:!0,automaticLayout:!0,fontFamily:e.getOption(he.EditorOption.fontFamily),fontSize:e.getOption(he.EditorOption.fontSize),lineHeight:u,minimap:{enabled:!1},glyphMargin:!1,folding:!1,scrollBeyondLastLine:!1,fixedOverflowWidgets:!0,hideUnchangedRegions:{enabled:!0,minimumLineCount:0,contextLineCount:2,revealLineCount:3}});y.diffEditor=r,r.setModel({original:t,modified:n}),r.onDidUpdateDiff(()=>l(y)),l(y)}),e.revealLineInCenter(Math.max(1,Math.min(n.getLineCount(),s.modifiedStartLineNumber)))},d=e.onMouseDown(e=>{if(!e.event.leftButton||e.target.type!==he.MouseTargetType.GUTTER_LINE_DECORATIONS||e.target.position===null)return;let t=e.target.position.lineNumber,r=mt(i,t,n.getLineCount(),St(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=mt(t,r.anchorLine,n.getLineCount());if(!o){c();return}r.change=o,r.zone.afterLineNumber=ht(o,n.getLineCount()),r.zone.heightInPx=bt+gt(o)*e.getOption(he.EditorOption.lineHeight);try{e.changeViewZones(e=>e.layoutZone(r.zoneId))}catch{c();return}l(r)},dispose(){o=!0,d.dispose(),c()}}}var wt={added:`puddle-dirty-added`,modified:`puddle-dirty-modified`,"deleted-before":`puddle-dirty-deleted-before`,"deleted-after":`puddle-dirty-deleted-after`};function Tt(e,t,n,r){let a=i(),o=h(e,t,{root:n,enabled:a.data!==void 0&&fe(a.data.protocol)&&r!==null}),[s,c]=(0,E.useState)(null),l=(0,E.useCallback)(e=>{c(e)},[]);return(0,E.useEffect)(()=>{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=he.createModel(e.exists?e.content??``:``,r.getLanguageId()),a=he.createDiffEditor(n,{readOnly:!0,automaticLayout:!1,renderSideBySide:!1,minimap:{enabled:!1}}),c=s.createDecorationsCollection();a.setModel({original:i,modified:r});let l=Ct({editor:s,original:i,modified:r,path:t}),u=()=>{let e=a.getLineChanges();e&&(l.update(e),c.set(yt(e,r.getLineCount()).map(e=>({range:new pe(e.startLineNumber,1,e.endLineNumber,1),options:{isWholeLine:!0,linesDecorationsClassName:wt[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 Et({message:e,session:t,path:n,root:i,download:a}){return(0,D.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,D.jsx)(`span`,{children:e}),a&&(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void re(t,n,i).catch(e=>r.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,D.jsx)(g,{className:`size-4`}),`Download`]})]})}function Dt({session:e,path:t,reveal:n,root:r,focused:i=!0,scrollDriver:a=!1,lockedReceiver:o=!1,scrollChannel:s=`profile`}){let c=ue(),l=pt(e,t,n,r,{focused:i}),u=Tt(e,t,r,l.model),d=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),[f,p]=(0,E.useState)(null),m=(0,E.useMemo)(()=>({session:e,path:t,root:r}),[e,t,r]),h=l.conflict!==null&&l.conflict.phase!==`unresolved`;if((0,E.useEffect)(()=>{if(!(!f||!l.model||h))return lt(f,{channel:s,target:m,driver:a,receiver:o},he.ScrollType.Immediate)},[f,l.model,h,s,m,a,o]),l.conflict&&l.conflict.phase!==`unresolved`)return(0,D.jsx)(tt,{session:e,path:t,buffer:l,focused:i});if(l.status===`binary`)return(0,D.jsx)(Et,{message:`Binary file — use Download`,session:e,path:t,root:r,download:!0});if(l.status===`too-large`)return(0,D.jsx)(Et,{message:`File too large to edit — use Download`,session:e,path:t,root:r,download:!0});if(l.status===`error`)return(0,D.jsx)(Et,{message:l.errorMessage??`Failed to load file`,session:e,path:t,root:r});let g=l.peerBadge===`saved-elsewhere`?`Saved in another window`:l.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[l.restoredNotice&&(0,D.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,D.jsx)(`span`,{children:`Restored unsaved changes`}),(0,D.jsx)(`button`,{type:`button`,onClick:l.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),g&&(0,D.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:g}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:l.model&&(0,D.jsx)(ye,{path:l.model.uri.toString(),defaultValue:l.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>{l.onMount(e),u(e),p(e)},loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:d,fontSize:c.editorFontSize,tabSize:c.editorTabSize,wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},glyphMargin:!1,lineDecorationsWidth:10,fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function k({children:e}){return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function Ot(e,t){let n=(0,E.useRef)(t);n.current=t,(0,E.useEffect)(()=>(Te(e),()=>{n.current?.(),_e(e)}),[e])}function kt(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function At({session:e,refName:t,path:n,content:r}){let i=ue(),a=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,D.jsx)(ye,{path:kt(`puddle-view`,e,t,n),defaultValue:r,theme:De,loading:(0,D.jsx)(k,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:a,fontSize:i.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function jt({session:e,against:t,path:n,root:r,indexBase:i=!1}){let a=f(e,t,n,{root:r,enabled:!i}),o=u(e,n,{root:r,enabled:i}),s=i?o:a;return s.isPending?(0,D.jsx)(k,{children:`…`}):s.error?(0,D.jsx)(k,{children:s.error instanceof Error?s.error.message:`Failed to load`}):s.data.binary?(0,D.jsx)(k,{children:`Binary file — deleted`}):(0,D.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,D.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(At,{session:e,refName:`${t}:${r??``}`,path:n,content:s.data.content??``})})]})}function Mt({session:e,against:t,path:n,basePath:r,root:i,indexBase:a=!1,focused:o=!0}){let s=ue(),c=pt(e,n,null,i,{focused:o}),d=f(e,t,r,{root:i,enabled:!a}),p=u(e,r,{root:i,enabled:a}),m=a?p:d,h=(0,E.useRef)(null);Ot(Ee(e,n,i),()=>{let e=h.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),h.current=null});let g=(0,E.useRef)(c.save);g.current=c.save;let _=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),v=m.error instanceof l&&m.error.status===404;return c.conflict&&c.conflict.phase!==`unresolved`?(0,D.jsx)(tt,{session:e,path:n,buffer:c,focused:o}):c.status===`binary`||m.data?.binary?(0,D.jsx)(k,{children:`Binary file`}):c.status===`too-large`?(0,D.jsx)(k,{children:`File too large to show`}):c.status===`error`?(0,D.jsx)(k,{children:c.errorMessage??`Failed to load file`}):v||a&&p.data&&!p.data.exists?(0,D.jsx)(Dt,{session:e,path:n,reveal:null,root:i,focused:o}):m.isPending||!c.model?(0,D.jsx)(k,{children:`…`}):m.error?(0,D.jsx)(k,{children:m.error instanceof Error?m.error.message:`Failed to load base`}):(0,D.jsx)(be,{modifiedModelPath:c.model.uri.toString(),originalModelPath:kt(`puddle-base`,e,`${t}:${i??``}`,r),original:m.data.content??``,language:c.model.getLanguageId(),theme:De,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(k,{children:`…`}),onMount:e=>{h.current=e,e.onDidDispose(()=>{h.current=null}),e.getModifiedEditor().addCommand(me.CtrlCmd|ge.KeyS,()=>g.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:_,fontSize:s.editorFontSize,wordWrap:s.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Nt({session:e,against:t,entry:n,root:r}){let i=ue(),a=n.old_path??n.path,o=f(e,t,a,{root:r,enabled:n.status!==`added`}),s=u(e,n.path,{root:r,enabled:n.status!==`deleted`}),c=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(n.status===`deleted`)return(0,D.jsx)(jt,{session:e,against:t,path:a,root:r});if(s.isPending||n.status!==`added`&&o.isPending)return(0,D.jsx)(k,{children:`…`});if(s.error||o.error){let e=s.error??o.error;return(0,D.jsx)(k,{children:e instanceof Error?e.message:`Failed to load staged content`})}return s.data.binary||o.data?.binary?(0,D.jsx)(k,{children:`Binary file`}):n.status===`added`?(0,D.jsx)(At,{session:e,refName:`index:${r??``}`,path:n.path,content:s.data.content??``}):o.data?(0,D.jsx)(be,{originalModelPath:kt(`puddle-head`,e,`${t}:${r??``}`,a),modifiedModelPath:kt(`puddle-index`,e,`${t}:${r??``}`,n.path),original:o.data.content??``,modified:s.data.content??``,theme:De,loading:(0,D.jsx)(k,{children:`…`}),options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,fontSize:i.editorFontSize,wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}}):(0,D.jsx)(k,{children:`Failed to load HEAD content`})}function Pt({session:e,path:t,root:n,focused:r}){return Ot(Ee(e,t,n)),(0,D.jsx)(Dt,{session:e,path:t,reveal:null,root:n,focused:r})}function Ft({session:e,against:t,entry:n,root:r,area:i,focused:a=!0}){if(i===`staged`)return(0,D.jsx)(Nt,{session:e,against:t,entry:n,root:r});switch(n.status){case`added`:return(0,D.jsx)(Pt,{session:e,path:n.path,root:r,focused:a});case`deleted`:return(0,D.jsx)(jt,{session:e,against:t,path:n.path,root:r,indexBase:i===`unstaged`});case`modified`:case`renamed`:return(0,D.jsx)(Mt,{session:e,against:t,path:n.path,basePath:n.old_path??n.path,root:r,indexBase:i===`unstaged`,focused:a});default:return null}}function It({session:e,sha:t,path:n,root:r}){let i=f(e,t,n,{root:r});return i.isPending?(0,D.jsx)(k,{children:`…`}):i.error?(0,D.jsx)(k,{children:i.error instanceof Error?i.error.message:`Failed to load file`}):i.data.binary?(0,D.jsx)(k,{children:`Binary file`}):(0,D.jsx)(At,{session:e,refName:`${t}:${r??``}`,path:n,content:i.data.content??``})}function Lt({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o,root:s}){let c=ue(),l=(0,E.useRef)(null),u=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,E.useEffect)(()=>()=>{let e=l.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),t?.modified.dispose(),l.current=null},[]),(0,D.jsx)(be,{originalModelPath:kt(`puddle-hist-orig`,e,`${t}:${s??``}`,n),modifiedModelPath:kt(`puddle-hist-mod`,e,`${i}:${s??``}`,a),original:r,modified:o,theme:De,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(k,{children:`…`}),onMount:e=>{l.current=e,e.onDidDispose(()=>{l.current=null})},options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,fontSize:c.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Rt({session:e,sha:t,path:n,basePath:r,root:i}){let a=f(e,`${t}^`,r,{root:i}),o=f(e,t,n,{root:i});return a.error instanceof l&&a.error.status===404?(0,D.jsx)(It,{session:e,sha:t,path:n,root:i}):a.isPending||o.isPending?(0,D.jsx)(k,{children:`…`}):a.error?(0,D.jsx)(k,{children:a.error instanceof Error?a.error.message:`Failed to load original`}):o.error?(0,D.jsx)(k,{children:o.error instanceof Error?o.error.message:`Failed to load file`}):a.data.binary||o.data.binary?(0,D.jsx)(k,{children:`Binary file`}):(0,D.jsx)(Lt,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:a.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:o.data.content??``,root:i})}function zt({session:e,sha:t,entry:n,isRootCommit:r,root:i}){switch(ne(n.status,r)){case`added`:return(0,D.jsx)(It,{session:e,sha:t,path:n.path,root:i});case`deleted`:return(0,D.jsx)(jt,{session:e,against:`${t}^`,path:n.path,root:i});case`modified`:case`renamed`:return(0,D.jsx)(Rt,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path,root:i});default:return null}}function Bt({session:e,sha:t,path:n,root:r}){let i=_(e,t,r);if(i.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(i.error)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:i.error instanceof Error?i.error.message:`Failed to load commit`});let a=i.data.files.find(e=>e.path===n);return a?(0,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(zt,{session:e,sha:t,entry:a,isRootCommit:i.data.parents.length===0,root:r})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,D.jsx)(`span`,{className:`text-fg-secondary`,children:n}),` is not part of`,` `,(0,D.jsx)(`span`,{className:`font-mono`,children:t.slice(0,7)}),`.`]})}function Vt({session:e,path:t,root:n,area:r,focused:i=!0}){let a=p(e,{root:n,against:r===void 0?`base`:`head`,area:r});if(a.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(a.error)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:a.error instanceof Error?a.error.message:`Failed to load diff`});let o=a.data.entries.find(e=>e.path===t);return o?(0,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(Ft,{session:e,against:a.data.against,entry:o,root:n,area:r,focused:i})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,D.jsx)(`span`,{className:`mx-1 text-fg-secondary`,children:t}),` against the base.`]})}var Ht=800;function Ut({name:e}){let t=ue(),n=a(),i=x(n,e),o=s(`editor.save`),c=(0,E.useRef)(null),l=(0,E.useRef)(null),u=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if((0,E.useEffect)(()=>{if(n===null)return;let t=w(t=>{b(n,e,t).catch(e=>r.error(e instanceof Error?e.message:`Draft not saved`))},Ht);return l.current=t,()=>{t.flush(),l.current=null}},[n,e]),n===null)return null;if(i.error)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:i.error instanceof Error?i.error.message:`Failed to load the draft`});if(i.data===void 0)return(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`});let d=()=>{let t=c.current;t&&(l.current?.flush(),te({name:e,content:t.getValue()}))};return(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,D.jsxs)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:[`Draft — not in any worktree; `,o,` saves it into one`]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(ye,{path:`puddle-untitled://${n}/${e}`,defaultValue:i.data.content,theme:De,keepCurrentModel:!1,loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:t=>{c.current=t,y(e,t.getValue()),O(t,{onSave:d})},onChange:t=>{let n=t??``;y(e,n),l.current?.(n)},options:{automaticLayout:!0,fontFamily:u,fontSize:t.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1,wordWrap:t.editorWordWrap?`on`:`off`}})})]})}function Wt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Gt(e){if(Array.isArray(e))return e}function Kt(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function qt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{Bt as r,I as i,_ as a,c as o,f as s,xt as c,yt as l}from"./hotkeys-CA5Pxll4.js";import{A as u,C as d,E as f,M as p,N as m,O as h,R as g,T as _,_ as v,a as y,d as b,f as x,h as S,j as C,n as ee,o as te,p as ne,x as re}from"./editor-context-A7YnYVrw.js";import{t as ie}from"./preload-helper-Czpn1I53.js";import{F as ae,I as oe,J as se,N as ce,P as le,X as ue,Y as de,a as w,pt as fe}from"./index-BYC57b5y.js";import{c as pe,i as me,p as he,r as ge}from"./editor.api2-4X9Vh9Zw.js";import{a as _e,c as ve,d as ye,f as be,i as xe,l as Se,n as Ce,o as we,r as T,s as Te,t as Ee,u as De}from"./buffer-store-kyNS3Ffy.js";import{a as Oe,c as ke,i as Ae,l as je,n as Me,o as Ne,r as Pe,s as Fe}from"./editor-sync-1UzWDCzn.js";import{r as Ie}from"./buffer-logic-BrpRsL1b.js";var E=e(t(),1),Le=new Map,Re=new Map,ze=1;function Be(e){for(let t of Re.get(e)??[])t()}function Ve(e,t){Le.set(e,t),Be(e)}function He(e){let t={phase:`unresolved`,revision:ze++};return Ve(e,t),t}function Ue(e){let t=Le.get(e);return!t||t.phase!==`unresolved`&&t.phase!==`load-error`?null:(Ve(e,{phase:`loading`,revision:t.revision}),t.revision)}function We(e,t,n,r){let i=Le.get(e);return!i||i.phase!==`loading`||i.revision!==t?!1:(Ve(e,{phase:`opening`,revision:t,content:n,mtimeMs:r}),!0)}function Ge(e,t){let n=Le.get(e);return!n||n.phase!==`opening`||n.revision!==t?!1:(Ve(e,{...n,phase:`comparing`}),!0)}function Ke(e,t,n){let r=Le.get(e);return!r||r.phase!==`loading`||r.revision!==t?!1:(Ve(e,{phase:`load-error`,revision:t,message:n}),!0)}function qe(e,t){return t&&e?.phase===`unresolved`}function Je(e){return e?.phase===`comparing`?e.mtimeMs:void 0}function Ye(e){return e?.phase===`loading`||e?.phase===`load-error`||e?.phase===`opening`}function Xe(e){return e.phase===`opening`||e.phase===`comparing`}function Ze(e){Le.delete(e)&&Be(e)}function Qe(e){return Le.get(e)??null}function $e(e,t){let n=Re.get(e);return n||(n=new Set,Re.set(e,n)),n.add(t),()=>n.delete(t)}var D=n();function et({session:e,path:t,conflict:n,model:r,onTakeDisk:i,onKeepMine:a,onSave:o,onReady:s}){let c=ue(),l=(0,E.useId)(),u=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),d=(0,E.useRef)(o);d.current=o;let f=(0,E.useRef)(null),p=()=>{let e=f.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),f.current=null},m=(0,E.useRef)(p);return m.current=p,(0,E.useEffect)(()=>()=>m.current(),[]),(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,D.jsx)(`span`,{children:`This file changed on disk. Yours is on the right — merge what you want, then save.`}),(0,D.jsx)(`button`,{type:`button`,onClick:i,className:`ml-auto shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Take the disk version`}),(0,D.jsx)(`button`,{type:`button`,onClick:a,disabled:n.phase!==`comparing`,className:`shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Keep mine`})]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(be,{modifiedModelPath:r.uri.toString(),originalModelPath:`puddle-disk://${encodeURIComponent(e)}/${n.mtimeMs}/${encodeURIComponent(l)}/${t.split(`/`).map(encodeURIComponent).join(`/`)}`,original:n.content,language:r.getLanguageId(),theme:De,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:e=>{f.current=e,e.onDidDispose(()=>{f.current=null}),e.getModifiedEditor().addCommand(me.CtrlCmd|ge.KeyS,()=>d.current()),s?.(n.revision)},options:{readOnly:n.phase!==`comparing`,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,fontSize:c.editorFontSize,wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function tt({session:e,path:t,buffer:n,focused:r}){let i=n.conflict;return!i||i.phase===`unresolved`?null:Xe(i)&&n.model?(0,D.jsx)(et,{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,D.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,D.jsx)(`span`,{children:`The disk version could not be loaded.`}),(0,D.jsx)(`span`,{className:`max-w-lg text-xs text-fg-secondary`,children:i.message}),(0,D.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,D.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:`Loading the disk version…`})}function nt(e){return Number.isFinite(e)?Math.min(1,Math.max(0,e)):0}function rt(e,t,n){return nt(e/Math.max(1,t-n))}function it(e,t,n){return nt(e)*Math.max(0,t-n)}function at(e,t){return JSON.stringify([e,t.session,t.root??null,t.path])}var ot=new class{positions=new Map;listeners=new Map;revision=0;publish(e,t,n){let r={ratio:nt(n),revision:++this.revision},i=at(e,t);this.positions.set(i,r);for(let e of this.listeners.get(i)??[])e(r);return r}get(e,t){return this.positions.get(at(e,t))}subscribe(e,t,n){let r=at(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)}}};function st(e){let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},dispose:()=>{t!==null&&cancelAnimationFrame(t),t=null}}}function ct(e,t){if(t.driver&&t.receiver)throw Error(`a preview scroll surface cannot be both driver and receiver`);let n=t.store??ot,r,i=()=>void 0,a,o=t=>{r=t,e.scrollTop=it(t.ratio,e.scrollHeight,e.clientHeight)};t.receiver?i=n.subscribe(t.channel,t.target,o):t.driver&&(a=st(()=>{n.publish(t.channel,t.target,rt(e.scrollTop,e.scrollHeight,e.clientHeight))}),e.addEventListener(`scroll`,a.schedule,{passive:!0}),a.schedule());let s=new ResizeObserver(()=>{t.receiver&&r?o(r):t.driver&&a?.schedule()});for(let e of t.resizeElements??[])s.observe(e);return()=>{t.driver&&a&&e.removeEventListener(`scroll`,a.schedule),i(),s.disconnect(),a?.dispose()}}function lt(e,t,n){if(t.driver&&t.receiver)throw Error(`a Monaco scroll surface cannot be both driver and receiver`);let r=t.store??ot,i=[],a,o=()=>void 0,s,c=()=>e.getLayoutInfo().height,l=t=>{a=t,e.setScrollTop(it(t.ratio,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)))):t.driver&&(s=st(()=>{r.publish(t.channel,t.target,rt(e.getScrollTop(),e.getScrollHeight(),c()))}),i.push(e.onDidScrollChange(s.schedule)),i.push(e.onDidChangeModel(s.schedule)),i.push(e.onDidLayoutChange(s.schedule)),s.schedule()),()=>{o();for(let e of i)e.dispose();s?.dispose()}}function ut(e){return!e}function dt(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=me.CtrlCmd:e===`ctrl`?r|=me.WinCtrl:e===`alt`?r|=me.Alt:e===`shift`&&(r|=me.Shift);let i=ge[/^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 O(e,t){let n=dt(o(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=dt(o(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>de({editorWordWrap:ut(se().editorWordWrap)})})}function ft(e){return`file-conflict:${e}`}function pt(e,t,n,i,a){let o=a?.passive===!0,s=a?.focused??!0,c=Ee(e,t,i),u=m(e,t,{root:i,live:a?.live}),d=C(e,i),[f,p]=(0,E.useState)(null),[h,g]=(0,E.useState)(!1),_=(0,E.useRef)(!1),y=(0,E.useRef)(null),b=(0,E.useRef)(null),x=(0,E.useRef)(n);x.current=n;let ee=(0,E.useRef)(!1),te=(0,E.useCallback)((e,t)=>{b.current?.cancel(),ee.current=!0;try{we(c,e,t)}finally{ee.current=!1}},[c]),ne=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>Se(c,e),[c]),()=>T(c)),re=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>Ne(c,e),[c]),()=>Oe(c)),ie=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>$e(c,e),[c]),()=>Qe(c));(0,E.useEffect)(()=>{let n=u.data;if(!n||n.binary||n.content===null||_.current)return;_.current=!0;let a=ve(c)!==void 0,o=Ce(e,t,n.content,n.mtime_ms,i);p(o),!a&&je(e,t,i).then(e=>{e&&(e.base_mtime_ms===n.mtime_ms?Ie(o,e.content)&&g(!0):r(`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:()=>{Ie(o,e.content)&&g(!0)}}}))})},[u.data,c,e,t,i]),(0,E.useEffect)(()=>{if(!f||o)return;let n=ke(e,t,i);b.current=n;let r=f.onDidChangeContent(()=>{ee.current||(n(f.getValue(),ve(c)??0),Me(e,t,i))});return()=>{n.flush(),r.dispose(),b.current=null}},[f,c,e,t,i,o]),(0,E.useEffect)(()=>{!f||!re.savedElsewhere||T(c)||u.refetch().then(e=>{T(c)||(e.data&&e.data.content!==null&&te(e.data.content,e.data.mtime_ms),Ae(c))})},[re.savedElsewhere,f,c]),(0,E.useEffect)(()=>{let e=u.data;!f||!e||e.content===null||!T(c)&&e.mtime_ms!==ve(c)&&te(e.content,e.mtime_ms)},[u.data,f,c]);let ae=(0,E.useCallback)((n,r)=>{xe(c,n,r),b.current?.cancel(),Fe(e,t,i),Pe(e,t,r,i),g(!1),Ze(c)},[c,e,t,i]),oe=(0,E.useCallback)(()=>{let e=Ue(c);e!==null&&(r.dismiss(ft(c)),u.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.`);We(c,e,n.content,n.mtime_ms)}).catch(t=>{Ke(c,e,t instanceof Error?t.message:`The disk version did not load.`)}))},[u,c]),se=(0,E.useRef)(oe);se.current=oe,(0,E.useEffect)(()=>{if(!qe(ie,s))return;let e=ft(c);return r(`File changed on disk`,{id:e,description:`Nothing was written — your unsaved version is intact.`,duration:1/0,closeButton:!0,action:{label:`Compare`,onClick:()=>se.current()}}),()=>{r.dismiss(e)}},[ie,s,c]);let ce=(0,E.useCallback)(()=>{u.refetch().then(n=>{n.data&&n.data.content!==null&&te(n.data.content,n.data.mtime_ms),Fe(e,t,i),g(!1),Ze(c)})},[c,e,t,te]),le=(0,E.useCallback)((e,n)=>{d.mutate({path:t,content:e},{onSuccess:e=>ae(n,e.mtime_ms),onError:e=>r.error(e instanceof Error?e.message:`Overwrite failed`)})},[d,t,ae]),ue=(0,E.useCallback)(()=>{if(!f||!T(c))return;let e=f.getValue(),n=f.getAlternativeVersionId();if(Ye(Qe(c)))return;let i=Je(Qe(c))??ve(c);d.mutate({path:t,content:e,expected_mtime_ms:i},{onSuccess:e=>ae(n,e.mtime_ms),onError:e=>{e instanceof l&&e.status===409&&e.code===`stale_file`?He(c):r.error(e instanceof Error?e.message:`Save failed`)}})},[f,c,d,t,ae]),de=(0,E.useRef)(ue);de.current=ue,(0,E.useEffect)(()=>S(v(e,t,i),()=>de.current()),[e,t,i]);let w=(0,E.useCallback)(()=>{let n=y.current,r=x.current;i===void 0&&(!n||!r||r.session!==e||r.path!==t||(n.revealLineInCenter(r.line),n.setPosition({lineNumber:r.line,column:r.column??1}),n.focus()))},[e,t,i]),fe=(0,E.useCallback)(e=>{y.current=e,O(e,{onSave:()=>de.current()}),w()},[w]);(0,E.useEffect)(()=>{w()},[n,f,w]);let pe=(0,E.useCallback)(()=>{ce()},[ce]),me=(0,E.useCallback)(()=>{!f||Qe(c)?.phase!==`comparing`||le(f.getValue(),f.getAlternativeVersionId())},[f,c,le]),he=(0,E.useCallback)(e=>{Ge(c,e)},[c]),ge,_e=null;u.data?.binary?ge=`binary`:u.error?u.error instanceof l&&u.error.status===413?ge=`too-large`:(ge=`error`,_e=u.error instanceof Error?u.error.message:`Failed to load file`):ge=f?`ready`:`loading`;let ye=ne&&re.savedElsewhere?`saved-elsewhere`:ne&&re.dirtyElsewhere?`dirty-elsewhere`:null;return{status:ge,errorMessage:_e,model:f,dirty:ne,restoredNotice:h,discardRestore:pe,peerBadge:ye,conflict:ie,takeDisk:ce,keepMine:me,compare:oe,comparisonReady:he,save:ue,onMount:fe}}function mt(e,t,n,r){for(let i of e)if(yt([i],n).some(e=>(r===void 0||e.kind===r)&&t>=e.startLineNumber&&t<=e.endLineNumber))return i;return null}function ht(e,t){return _t(e.modifiedStartLineNumber,e.modifiedEndLineNumber)>0?Math.min(t,e.modifiedEndLineNumber):Math.max(0,Math.min(t,e.modifiedStartLineNumber-1))}function gt(e){let t=_t(e.originalStartLineNumber,e.originalEndLineNumber),n=_t(e.modifiedStartLineNumber,e.modifiedEndLineNumber);return Math.max(5,Math.min(14,t+n+4))}function _t(e,t){return t===0?0:Math.max(0,t-e+1)}function vt(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 yt(e,t){let n=[];for(let r of e){let e=_t(r.originalStartLineNumber,r.originalEndLineNumber),i=_t(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(vt(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(vt(r.modifiedStartLineNumber+i,t))}return n}var bt=28,xt=[[`puddle-dirty-added`,`added`],[`puddle-dirty-modified`,`modified`],[`puddle-dirty-deleted-before`,`deleted-before`],[`puddle-dirty-deleted-after`,`deleted-after`]];function St(e){if(e){for(let[t,n]of xt)if(e.classList.contains(t)||e.closest(`.${t}`))return n}}function Ct({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,he.ScrollType.Immediate)},u=(i,s)=>{if(a?.anchorLine===i){c();return}c();let u=e.getOption(he.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:ht(s,n.getLineCount()),heightInPx:bt+gt(s)*u,domNode:d,marginDomNode:g,suppressMouseDown:!1},v=``;e.changeViewZones(e=>{v=e.addZone(_)});let y={anchorLine:i,change:s,zone:_,zoneId:v,frame:null,diffEditor:null};a=y,y.frame=requestAnimationFrame(()=>{if(y.frame=null,o||a!==y)return;let r=he.createDiffEditor(h,{readOnly:!0,domReadOnly:!0,originalEditable:!1,renderSideBySide:!1,renderMarginRevertIcon:!1,renderOverviewRuler:!1,enableSplitViewResizing:!1,isInEmbeddedEditor:!0,automaticLayout:!0,fontFamily:e.getOption(he.EditorOption.fontFamily),fontSize:e.getOption(he.EditorOption.fontSize),lineHeight:u,minimap:{enabled:!1},glyphMargin:!1,folding:!1,scrollBeyondLastLine:!1,fixedOverflowWidgets:!0,hideUnchangedRegions:{enabled:!0,minimumLineCount:0,contextLineCount:2,revealLineCount:3}});y.diffEditor=r,r.setModel({original:t,modified:n}),r.onDidUpdateDiff(()=>l(y)),l(y)}),e.revealLineInCenter(Math.max(1,Math.min(n.getLineCount(),s.modifiedStartLineNumber)))},d=e.onMouseDown(e=>{if(!e.event.leftButton||e.target.type!==he.MouseTargetType.GUTTER_LINE_DECORATIONS||e.target.position===null)return;let t=e.target.position.lineNumber,r=mt(i,t,n.getLineCount(),St(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=mt(t,r.anchorLine,n.getLineCount());if(!o){c();return}r.change=o,r.zone.afterLineNumber=ht(o,n.getLineCount()),r.zone.heightInPx=bt+gt(o)*e.getOption(he.EditorOption.lineHeight);try{e.changeViewZones(e=>e.layoutZone(r.zoneId))}catch{c();return}l(r)},dispose(){o=!0,d.dispose(),c()}}}var wt={added:`puddle-dirty-added`,modified:`puddle-dirty-modified`,"deleted-before":`puddle-dirty-deleted-before`,"deleted-after":`puddle-dirty-deleted-after`};function Tt(e,t,n,r){let a=i(),o=h(e,t,{root:n,enabled:a.data!==void 0&&fe(a.data.protocol)&&r!==null}),[s,c]=(0,E.useState)(null),l=(0,E.useCallback)(e=>{c(e)},[]);return(0,E.useEffect)(()=>{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=he.createModel(e.exists?e.content??``:``,r.getLanguageId()),a=he.createDiffEditor(n,{readOnly:!0,automaticLayout:!1,renderSideBySide:!1,minimap:{enabled:!1}}),c=s.createDecorationsCollection();a.setModel({original:i,modified:r});let l=Ct({editor:s,original:i,modified:r,path:t}),u=()=>{let e=a.getLineChanges();e&&(l.update(e),c.set(yt(e,r.getLineCount()).map(e=>({range:new pe(e.startLineNumber,1,e.endLineNumber,1),options:{isWholeLine:!0,linesDecorationsClassName:wt[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 Et({message:e,session:t,path:n,root:i,download:a}){return(0,D.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,D.jsx)(`span`,{children:e}),a&&(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void re(t,n,i).catch(e=>r.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,D.jsx)(g,{className:`size-4`}),`Download`]})]})}function Dt({session:e,path:t,reveal:n,root:r,focused:i=!0,scrollDriver:a=!1,lockedReceiver:o=!1,scrollChannel:s=`profile`}){let c=ue(),l=pt(e,t,n,r,{focused:i}),u=Tt(e,t,r,l.model),d=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),[f,p]=(0,E.useState)(null),m=(0,E.useMemo)(()=>({session:e,path:t,root:r}),[e,t,r]),h=l.conflict!==null&&l.conflict.phase!==`unresolved`;if((0,E.useEffect)(()=>{if(!(!f||!l.model||h))return lt(f,{channel:s,target:m,driver:a,receiver:o},he.ScrollType.Immediate)},[f,l.model,h,s,m,a,o]),l.conflict&&l.conflict.phase!==`unresolved`)return(0,D.jsx)(tt,{session:e,path:t,buffer:l,focused:i});if(l.status===`binary`)return(0,D.jsx)(Et,{message:`Binary file — use Download`,session:e,path:t,root:r,download:!0});if(l.status===`too-large`)return(0,D.jsx)(Et,{message:`File too large to edit — use Download`,session:e,path:t,root:r,download:!0});if(l.status===`error`)return(0,D.jsx)(Et,{message:l.errorMessage??`Failed to load file`,session:e,path:t,root:r});let g=l.peerBadge===`saved-elsewhere`?`Saved in another window`:l.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[l.restoredNotice&&(0,D.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,D.jsx)(`span`,{children:`Restored unsaved changes`}),(0,D.jsx)(`button`,{type:`button`,onClick:l.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),g&&(0,D.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:g}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:l.model&&(0,D.jsx)(ye,{path:l.model.uri.toString(),defaultValue:l.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>{l.onMount(e),u(e),p(e)},loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:d,fontSize:c.editorFontSize,tabSize:c.editorTabSize,wordWrap:c.editorWordWrap?`on`:`off`,minimap:{enabled:!1},glyphMargin:!1,lineDecorationsWidth:10,fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function k({children:e}){return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function Ot(e,t){let n=(0,E.useRef)(t);n.current=t,(0,E.useEffect)(()=>(Te(e),()=>{n.current?.(),_e(e)}),[e])}function kt(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function At({session:e,refName:t,path:n,content:r}){let i=ue(),a=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,D.jsx)(ye,{path:kt(`puddle-view`,e,t,n),defaultValue:r,theme:De,loading:(0,D.jsx)(k,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:a,fontSize:i.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function jt({session:e,against:t,path:n,root:r,indexBase:i=!1}){let a=f(e,t,n,{root:r,enabled:!i}),o=u(e,n,{root:r,enabled:i}),s=i?o:a;return s.isPending?(0,D.jsx)(k,{children:`…`}):s.error?(0,D.jsx)(k,{children:s.error instanceof Error?s.error.message:`Failed to load`}):s.data.binary?(0,D.jsx)(k,{children:`Binary file — deleted`}):(0,D.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,D.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(At,{session:e,refName:`${t}:${r??``}`,path:n,content:s.data.content??``})})]})}function Mt({session:e,against:t,path:n,basePath:r,root:i,indexBase:a=!1,focused:o=!0}){let s=ue(),c=pt(e,n,null,i,{focused:o}),d=f(e,t,r,{root:i,enabled:!a}),p=u(e,r,{root:i,enabled:a}),m=a?p:d,h=(0,E.useRef)(null);Ot(Ee(e,n,i),()=>{let e=h.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),h.current=null});let g=(0,E.useRef)(c.save);g.current=c.save;let _=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),v=m.error instanceof l&&m.error.status===404;return c.conflict&&c.conflict.phase!==`unresolved`?(0,D.jsx)(tt,{session:e,path:n,buffer:c,focused:o}):c.status===`binary`||m.data?.binary?(0,D.jsx)(k,{children:`Binary file`}):c.status===`too-large`?(0,D.jsx)(k,{children:`File too large to show`}):c.status===`error`?(0,D.jsx)(k,{children:c.errorMessage??`Failed to load file`}):v||a&&p.data&&!p.data.exists?(0,D.jsx)(Dt,{session:e,path:n,reveal:null,root:i,focused:o}):m.isPending||!c.model?(0,D.jsx)(k,{children:`…`}):m.error?(0,D.jsx)(k,{children:m.error instanceof Error?m.error.message:`Failed to load base`}):(0,D.jsx)(be,{modifiedModelPath:c.model.uri.toString(),originalModelPath:kt(`puddle-base`,e,`${t}:${i??``}`,r),original:m.data.content??``,language:c.model.getLanguageId(),theme:De,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(k,{children:`…`}),onMount:e=>{h.current=e,e.onDidDispose(()=>{h.current=null}),e.getModifiedEditor().addCommand(me.CtrlCmd|ge.KeyS,()=>g.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:_,fontSize:s.editorFontSize,wordWrap:s.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Nt({session:e,against:t,entry:n,root:r}){let i=ue(),a=n.old_path??n.path,o=f(e,t,a,{root:r,enabled:n.status!==`added`}),s=u(e,n.path,{root:r,enabled:n.status!==`deleted`}),c=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(n.status===`deleted`)return(0,D.jsx)(jt,{session:e,against:t,path:a,root:r});if(s.isPending||n.status!==`added`&&o.isPending)return(0,D.jsx)(k,{children:`…`});if(s.error||o.error){let e=s.error??o.error;return(0,D.jsx)(k,{children:e instanceof Error?e.message:`Failed to load staged content`})}return s.data.binary||o.data?.binary?(0,D.jsx)(k,{children:`Binary file`}):n.status===`added`?(0,D.jsx)(At,{session:e,refName:`index:${r??``}`,path:n.path,content:s.data.content??``}):o.data?(0,D.jsx)(be,{originalModelPath:kt(`puddle-head`,e,`${t}:${r??``}`,a),modifiedModelPath:kt(`puddle-index`,e,`${t}:${r??``}`,n.path),original:o.data.content??``,modified:s.data.content??``,theme:De,loading:(0,D.jsx)(k,{children:`…`}),options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,fontSize:i.editorFontSize,wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}}):(0,D.jsx)(k,{children:`Failed to load HEAD content`})}function Pt({session:e,path:t,root:n,focused:r}){return Ot(Ee(e,t,n)),(0,D.jsx)(Dt,{session:e,path:t,reveal:null,root:n,focused:r})}function Ft({session:e,against:t,entry:n,root:r,area:i,focused:a=!0}){if(i===`staged`)return(0,D.jsx)(Nt,{session:e,against:t,entry:n,root:r});switch(n.status){case`added`:return(0,D.jsx)(Pt,{session:e,path:n.path,root:r,focused:a});case`deleted`:return(0,D.jsx)(jt,{session:e,against:t,path:n.path,root:r,indexBase:i===`unstaged`});case`modified`:case`renamed`:return(0,D.jsx)(Mt,{session:e,against:t,path:n.path,basePath:n.old_path??n.path,root:r,indexBase:i===`unstaged`,focused:a});default:return null}}function It({session:e,sha:t,path:n,root:r}){let i=f(e,t,n,{root:r});return i.isPending?(0,D.jsx)(k,{children:`…`}):i.error?(0,D.jsx)(k,{children:i.error instanceof Error?i.error.message:`Failed to load file`}):i.data.binary?(0,D.jsx)(k,{children:`Binary file`}):(0,D.jsx)(At,{session:e,refName:`${t}:${r??``}`,path:n,content:i.data.content??``})}function Lt({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o,root:s}){let c=ue(),l=(0,E.useRef)(null),u=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,E.useEffect)(()=>()=>{let e=l.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),t?.modified.dispose(),l.current=null},[]),(0,D.jsx)(be,{originalModelPath:kt(`puddle-hist-orig`,e,`${t}:${s??``}`,n),modifiedModelPath:kt(`puddle-hist-mod`,e,`${i}:${s??``}`,a),original:r,modified:o,theme:De,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(k,{children:`…`}),onMount:e=>{l.current=e,e.onDidDispose(()=>{l.current=null})},options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,fontSize:c.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Rt({session:e,sha:t,path:n,basePath:r,root:i}){let a=f(e,`${t}^`,r,{root:i}),o=f(e,t,n,{root:i});return a.error instanceof l&&a.error.status===404?(0,D.jsx)(It,{session:e,sha:t,path:n,root:i}):a.isPending||o.isPending?(0,D.jsx)(k,{children:`…`}):a.error?(0,D.jsx)(k,{children:a.error instanceof Error?a.error.message:`Failed to load original`}):o.error?(0,D.jsx)(k,{children:o.error instanceof Error?o.error.message:`Failed to load file`}):a.data.binary||o.data.binary?(0,D.jsx)(k,{children:`Binary file`}):(0,D.jsx)(Lt,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:a.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:o.data.content??``,root:i})}function zt({session:e,sha:t,entry:n,isRootCommit:r,root:i}){switch(ne(n.status,r)){case`added`:return(0,D.jsx)(It,{session:e,sha:t,path:n.path,root:i});case`deleted`:return(0,D.jsx)(jt,{session:e,against:`${t}^`,path:n.path,root:i});case`modified`:case`renamed`:return(0,D.jsx)(Rt,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path,root:i});default:return null}}function Bt({session:e,sha:t,path:n,root:r}){let i=_(e,t,r);if(i.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(i.error)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:i.error instanceof Error?i.error.message:`Failed to load commit`});let a=i.data.files.find(e=>e.path===n);return a?(0,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(zt,{session:e,sha:t,entry:a,isRootCommit:i.data.parents.length===0,root:r})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,D.jsx)(`span`,{className:`text-fg-secondary`,children:n}),` is not part of`,` `,(0,D.jsx)(`span`,{className:`font-mono`,children:t.slice(0,7)}),`.`]})}function Vt({session:e,path:t,root:n,area:r,focused:i=!0}){let a=p(e,{root:n,against:r===void 0?`base`:`head`,area:r});if(a.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(a.error)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:a.error instanceof Error?a.error.message:`Failed to load diff`});let o=a.data.entries.find(e=>e.path===t);return o?(0,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(Ft,{session:e,against:a.data.against,entry:o,root:n,area:r,focused:i})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,D.jsx)(`span`,{className:`mx-1 text-fg-secondary`,children:t}),` against the base.`]})}var Ht=800;function Ut({name:e}){let t=ue(),n=a(),i=x(n,e),o=s(`editor.save`),c=(0,E.useRef)(null),l=(0,E.useRef)(null),u=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if((0,E.useEffect)(()=>{if(n===null)return;let t=w(t=>{b(n,e,t).catch(e=>r.error(e instanceof Error?e.message:`Draft not saved`))},Ht);return l.current=t,()=>{t.flush(),l.current=null}},[n,e]),n===null)return null;if(i.error)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:i.error instanceof Error?i.error.message:`Failed to load the draft`});if(i.data===void 0)return(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`});let d=()=>{let t=c.current;t&&(l.current?.flush(),te({name:e,content:t.getValue()}))};return(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,D.jsxs)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:[`Draft — not in any worktree; `,o,` saves it into one`]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(ye,{path:`puddle-untitled://${n}/${e}`,defaultValue:i.data.content,theme:De,keepCurrentModel:!1,loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:t=>{c.current=t,y(e,t.getValue()),O(t,{onSave:d})},onChange:t=>{let n=t??``;y(e,n),l.current?.(n)},options:{automaticLayout:!0,fontFamily:u,fontSize:t.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1,wordWrap:t.editorWordWrap?`on`:`off`}})})]})}function Wt(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Gt(e){if(Array.isArray(e))return e}function Kt(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function qt(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Jt(e,t){return Gt(e)||Kt(e,t)||Yt(e,t)||qt()}function Yt(e,t){if(e){if(typeof e==`string`)return Wt(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Wt(e,t):void 0}}var Xt=Object.entries,Zt=Object.setPrototypeOf,Qt=Object.isFrozen,$t=Object.getPrototypeOf,en=Object.getOwnPropertyDescriptor,tn=Object.freeze,nn=Object.seal,rn=Object.create,an=typeof Reflect<`u`&&Reflect,on=an.apply,sn=an.construct;tn||=function(e){return e},nn||=function(e){return e},on||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},sn||=function(e){return new e(...[...arguments].slice(1))};var cn=On(Array.prototype.forEach),ln=On(Array.prototype.lastIndexOf),un=On(Array.prototype.pop),dn=On(Array.prototype.push),fn=On(Array.prototype.splice),pn=Array.isArray,mn=On(String.prototype.toLowerCase),hn=On(String.prototype.toString),gn=On(String.prototype.match),_n=On(String.prototype.replace),vn=On(String.prototype.indexOf),yn=On(String.prototype.trim),bn=On(Number.prototype.toString),xn=On(Boolean.prototype.toString),Sn=typeof BigInt>`u`?null:On(BigInt.prototype.toString),Cn=typeof Symbol>`u`?null:On(Symbol.prototype.toString),wn=On(Object.prototype.hasOwnProperty),Tn=On(Object.prototype.toString),En=On(RegExp.prototype.test),Dn=kn(TypeError);function On(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return on(e,t,n)}}function kn(e){return function(){return sn(e,[...arguments])}}function A(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:mn;if(Zt&&Zt(e,null),!pn(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(Qt(t)||(t[r]=e),i=e)}e[i]=!0}return e}function An(e){for(let t=0;t<e.length;t++)wn(e,t)||(e[t]=null);return e}function jn(e){let t=rn(null);for(let r of Xt(e)){var n=Jt(r,2);let i=n[0],a=n[1];wn(e,i)&&(pn(a)?t[i]=An(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=jn(a):t[i]=a)}return t}function Mn(e){switch(typeof e){case`string`:return e;case`number`:return bn(e);case`boolean`:return xn(e);case`bigint`:return Sn?Sn(e):`0`;case`symbol`:return Cn?Cn(e):`Symbol()`;case`undefined`:return Tn(e);case`function`:case`object`:{if(e===null)return Tn(e);let t=e,n=Nn(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Tn(e)}return Tn(e)}default:return Tn(e)}}function Nn(e,t){for(;e!==null;){let n=en(e,t);if(n){if(n.get)return On(n.get);if(typeof n.value==`function`)return On(n.value)}e=$t(e)}function n(){return null}return n}function Pn(e){try{return En(e,``),!0}catch{return!1}}var Fn=tn(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),In=tn(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),Ln=tn([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),Rn=tn([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),zn=tn(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),Bn=tn([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Vn=tn([`#text`]),Hn=tn(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Un=tn(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Wn=tn(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),Gn=tn([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Kn=nn(/{{[\w\W]*|^[\w\W]*}}/g),qn=nn(/<%[\w\W]*|^[\w\W]*%>/g),Jn=nn(/\${[\w\W]*/g),Yn=nn(/^data-[\-\w.\u00B7-\uFFFF]+$/),Xn=nn(/^aria-[\-\w]+$/),Zn=nn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Qn=nn(/^(?:\w+script|data):/i),$n=nn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),er=nn(/^html$/i),tr=nn(/^[a-z][.\w]*(-[.\w]+)+$/i),nr=nn(/<[/\w!]/g),rr=nn(/<[/\w]/g),ir=nn(/<\/no(script|embed|frames)/i),ar=nn(/\/>/i),or={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},sr=function(){return typeof window>`u`?null:window},cr=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},lr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},ur=function(e,t,n,r){return wn(e,t)&&pn(e[t])?A(r.base?jn(r.base):{},e[t],r.transform):n};function dr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:sr(),t=e=>dr(e);if(t.version=`3.4.12`,t.removed=[],!e||!e.document||e.document.nodeType!==or.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=Nn(d,`cloneNode`),p=Nn(d,`remove`),m=Nn(d,`nextSibling`),h=Nn(d,`childNodes`),g=Nn(d,`parentNode`),_=Nn(d,`shadowRoot`),v=Nn(d,`attributes`),y=o&&o.prototype?Nn(o.prototype,`nodeType`):null,b=o&&o.prototype?Nn(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,C,ee=!1,te=0,ne=function(){if(te>0)throw Dn(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},re=function(e){ne(),te++;try{return x.createHTML(e)}finally{te--}},ie=function(e){ne(),te++;try{return x.createScriptURL(e)}finally{te--}},ae=function(){return ee||=(C=cr(u,i),!0),C},oe=n,se=oe.implementation,ce=oe.createNodeIterator,le=oe.createDocumentFragment,ue=oe.getElementsByTagName,de=r.importNode,w=lr();t.isSupported=typeof Xt==`function`&&typeof g==`function`&&se&&se.createHTMLDocument!==void 0;let fe=Kn,pe=qn,me=Jn,he=Yn,ge=Xn,_e=Qn,ve=$n,ye=tr,be=Zn,xe=null,Se=A({},[...Fn,...In,...Ln,...zn,...Vn]),Ce=null,we=A({},[...Hn,...Un,...Wn,...Gn]),T=Object.seal(rn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Te=null,Ee=null,De=Object.seal(rn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Oe=!0,ke=!0,Ae=!1,je=!0,Me=!1,Ne=!0,Pe=!1,Fe=!1,Ie=null,E=null,Le=!1,Re=!1,ze=!1,Be=!1,Ve=!0,He=!1,Ue=`user-content-`,We=!0,Ge=!1,Ke={},qe=null,Je=A({},`annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Ye=null,Xe=A({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Ze=null,Qe=A({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),$e=`http://www.w3.org/1998/Math/MathML`,D=`http://www.w3.org/2000/svg`,et=`http://www.w3.org/1999/xhtml`,tt=et,nt=!1,rt=null,it=A({},[$e,D,et],hn),at=tn([`mi`,`mo`,`mn`,`ms`,`mtext`]),ot=A({},at),st=tn([`annotation-xml`]),ct=A({},st),lt=A({},[`title`,`style`,`font`,`a`,`script`]),ut=null,dt=[`application/xhtml+xml`,`text/html`],O=null,ft=null,pt=n.createElement(`form`),mt=function(e){return e instanceof RegExp||e instanceof Function},ht=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ft&&ft===e)return;(!e||typeof e!=`object`)&&(e={}),e=jn(e),ut=dt.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,O=ut===`application/xhtml+xml`?hn:mn,xe=ur(e,`ALLOWED_TAGS`,Se,{transform:O}),Ce=ur(e,`ALLOWED_ATTR`,we,{transform:O}),rt=ur(e,`ALLOWED_NAMESPACES`,it,{transform:hn}),Ze=ur(e,`ADD_URI_SAFE_ATTR`,Qe,{transform:O,base:Qe}),Ye=ur(e,`ADD_DATA_URI_TAGS`,Xe,{transform:O,base:Xe}),qe=ur(e,`FORBID_CONTENTS`,Je,{transform:O}),Te=ur(e,`FORBID_TAGS`,jn({}),{transform:O}),Ee=ur(e,`FORBID_ATTR`,jn({}),{transform:O}),Ke=wn(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?jn(e.USE_PROFILES):e.USE_PROFILES:!1,Oe=e.ALLOW_ARIA_ATTR!==!1,ke=e.ALLOW_DATA_ATTR!==!1,Ae=e.ALLOW_UNKNOWN_PROTOCOLS||!1,je=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Me=e.SAFE_FOR_TEMPLATES||!1,Ne=e.SAFE_FOR_XML!==!1,Pe=e.WHOLE_DOCUMENT||!1,Re=e.RETURN_DOM||!1,ze=e.RETURN_DOM_FRAGMENT||!1,Be=e.RETURN_TRUSTED_TYPE||!1,Le=e.FORCE_BODY||!1,Ve=e.SANITIZE_DOM!==!1,He=e.SANITIZE_NAMED_PROPS||!1,We=e.KEEP_CONTENT!==!1,Ge=e.IN_PLACE||!1,be=Pn(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Zn,tt=typeof e.NAMESPACE==`string`?e.NAMESPACE:et,ot=wn(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?jn(e.MATHML_TEXT_INTEGRATION_POINTS):A({},at),ct=wn(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?jn(e.HTML_INTEGRATION_POINTS):A({},st);let t=wn(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?jn(e.CUSTOM_ELEMENT_HANDLING):rn(null);if(T=rn(null),wn(t,`tagNameCheck`)&&mt(t.tagNameCheck)&&(T.tagNameCheck=t.tagNameCheck),wn(t,`attributeNameCheck`)&&mt(t.attributeNameCheck)&&(T.attributeNameCheck=t.attributeNameCheck),wn(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(T.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),nn(T),Me&&(ke=!1),ze&&(Re=!0),Ke&&(xe=A({},Vn),Ce=rn(null),Ke.html===!0&&(A(xe,Fn),A(Ce,Hn)),Ke.svg===!0&&(A(xe,In),A(Ce,Un),A(Ce,Gn)),Ke.svgFilters===!0&&(A(xe,Ln),A(Ce,Un),A(Ce,Gn)),Ke.mathMl===!0&&(A(xe,zn),A(Ce,Wn),A(Ce,Gn))),De.tagCheck=null,De.attributeCheck=null,wn(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?De.tagCheck=e.ADD_TAGS:pn(e.ADD_TAGS)&&(xe===Se&&(xe=jn(xe)),A(xe,e.ADD_TAGS,O))),wn(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?De.attributeCheck=e.ADD_ATTR:pn(e.ADD_ATTR)&&(Ce===we&&(Ce=jn(Ce)),A(Ce,e.ADD_ATTR,O))),wn(e,`ADD_URI_SAFE_ATTR`)&&pn(e.ADD_URI_SAFE_ATTR)&&A(Ze,e.ADD_URI_SAFE_ATTR,O),wn(e,`FORBID_CONTENTS`)&&pn(e.FORBID_CONTENTS)&&(qe===Je&&(qe=jn(qe)),A(qe,e.FORBID_CONTENTS,O)),wn(e,`ADD_FORBID_CONTENTS`)&&pn(e.ADD_FORBID_CONTENTS)&&(qe===Je&&(qe=jn(qe)),A(qe,e.ADD_FORBID_CONTENTS,O)),We&&(xe[`#text`]=!0),Pe&&A(xe,[`html`,`head`,`body`]),xe.table&&(A(xe,[`tbody`]),delete Te.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Dn(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Dn(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=re(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=ae()),x&&typeof S==`string`&&(S=re(``)));tn&&tn(e),ft=e},gt=A({},[...In,...Ln,...Rn]),_t=A({},[...zn,...Bn]),vt=function(e,t,n){return t.namespaceURI===et?e===`svg`:t.namespaceURI===$e?e===`svg`&&(n===`annotation-xml`||ot[n]):!!gt[e]},yt=function(e,t,n){return t.namespaceURI===et?e===`math`:t.namespaceURI===D?e===`math`&&ct[n]:!!_t[e]},bt=function(e,t,n){return t.namespaceURI===D&&!ct[n]||t.namespaceURI===$e&&!ot[n]?!1:!_t[e]&&(lt[e]||!gt[e])},xt=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:tt,tagName:`template`});let n=mn(e.tagName),r=mn(t.tagName);return rt[e.namespaceURI]?e.namespaceURI===D?vt(n,t,r):e.namespaceURI===$e?yt(n,t,r):e.namespaceURI===et?bt(n,t,r):!!(ut===`application/xhtml+xml`&&rt[e.namespaceURI]):!1},St=function(e){dn(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw Dn(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},Ct=function(e){Et(e);let t=h(e);if(t){let e=[];cn(t,t=>{dn(e,t)}),cn(e,e=>{try{p(e)}catch{}})}let n=v(e);if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;if(typeof i==`string`)try{e.removeAttribute(i)}catch{}}},wt=function(e,n){try{dn(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{dn(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Re||ze)try{St(n)}catch{}else try{n.setAttribute(e,``)}catch{}},Tt=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;if(!(typeof i!=`string`||Ce[O(i)]))try{e.removeAttribute(i)}catch{}}},Et=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===or.element&&Tt(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},Dt=function(e){if(!Ne)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=y?y(e):e.nodeType;if(n===or.processingInstruction||n===or.comment&&En(rr,e.data)){try{p(e)}catch{}continue}if(n===or.element){let t=e,n=O(b?b(e):e.nodeName);try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&n!==`label`&&n!==`output`&&t.removeAttribute(`for`)}catch{}}let r=h(e);if(r)for(let e=r.length-1;e>=0;--e)t.push(r[e])}},k=function(e){let t=null,r=null;if(Le)e=`<remove></remove>`+e;else{let t=gn(e,/^[\r\n\t ]+/);r=t&&t[0]}ut===`application/xhtml+xml`&&tt===et&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=x?re(e):e;if(tt===et)try{t=new l().parseFromString(i,ut)}catch{}if(!t||!t.documentElement){t=se.createDocument(tt,`template`,null);try{t.documentElement.innerHTML=nt?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),tt===et?ue.call(t,Pe?`html`:`body`)[0]:Pe?t.documentElement:a},Ot=function(e){return ce.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},kt=function(e){return e=_n(e,fe,` `),e=_n(e,pe,` `),e=_n(e,me,` `),e},At=function(e){e.normalize();let t=ce.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;)n.data=kt(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&cn(r,e=>{Mt(e.content)&&At(e.content)})},jt=function(e){let t=b?b(e):null;return typeof t!=`string`||O(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(e)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==y(e)||e.childNodes!==h(e)},Mt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===or.documentFragment}catch{return!1}},Nt=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function Pt(e,n,r){e.length!==0&&cn(e,e=>{e.call(t,n,r,ft)})}let Ft=function(e,t){return!!(Ne&&e.hasChildNodes()&&!Nt(e.firstElementChild)&&En(nr,e.textContent)&&En(nr,e.innerHTML)||Ne&&e.namespaceURI===et&&t===`style`&&Nt(e.firstElementChild)||e.nodeType===or.processingInstruction||Ne&&e.nodeType===or.comment&&En(rr,e.data))},It=function(e,t){if(!Te[t]&&Bt(t)&&(T.tagNameCheck instanceof RegExp&&En(T.tagNameCheck,t)||T.tagNameCheck instanceof Function&&T.tagNameCheck(t)))return!1;if(We&&!qe[t]){let t=g(e),n=h(e);if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=Ge?n[i]:f(n[i],!0);t.insertBefore(r,m(e))}}}return St(e),!0},Lt=function(e,n){if(Pt(w.beforeSanitizeElements,e,null),e!==n&&g(e)===null)return!0;if(jt(e))return St(e),!0;let r=O(b?b(e):e.nodeName);if(Pt(w.uponSanitizeElement,e,{tagName:r,allowedTags:xe}),e!==n&&g(e)===null)return!0;if(Ft(e,r))return St(e),!0;if(Te[r]||!(De.tagCheck instanceof Function&&De.tagCheck(r))&&!xe[r]){let t=It(e,r);return t===!1&&Pt(w.afterSanitizeElements,e,null),t}if((y?y(e):e.nodeType)===or.element&&!xt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&En(ir,e.innerHTML))return St(e),!0;if(Me&&e.nodeType===or.text){let n=kt(e.textContent);e.textContent!==n&&(dn(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Pt(w.afterSanitizeElements,e,null),!1},Rt=function(e,t,r){if(Ee[t]||Ne&&t===`patchsrc`||Ne&&t===`for`&&e!==`label`&&e!==`output`||Ve&&(t===`id`||t===`name`)&&(r in n||r in pt))return!1;let i=Ce[t]||De.attributeCheck instanceof Function&&De.attributeCheck(t,e);if(!(ke&&En(he,t))&&!(Oe&&En(ge,t))){if(!i){if(!(Bt(e)&&(T.tagNameCheck instanceof RegExp&&En(T.tagNameCheck,e)||T.tagNameCheck instanceof Function&&T.tagNameCheck(e))&&(T.attributeNameCheck instanceof RegExp&&En(T.attributeNameCheck,t)||T.attributeNameCheck instanceof Function&&T.attributeNameCheck(t,e))||t===`is`&&T.allowCustomizedBuiltInElements&&(T.tagNameCheck instanceof RegExp&&En(T.tagNameCheck,r)||T.tagNameCheck instanceof Function&&T.tagNameCheck(r))))return!1}else if(!Ze[t]&&!En(be,_n(r,ve,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&vn(r,`data:`)===0&&Ye[e])&&!(Ae&&!En(_e,_n(r,ve,``)))&&r)return!1}return!0},zt=A({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Bt=function(e){return!zt[mn(e)]&&En(ye,e)},Vt=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return re(r);case`TrustedScriptURL`:return ie(r)}return r},Ht=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),jt(e)?St(e):un(t.removed)}catch{wt(n,e)}},Ut=function(e){Pt(w.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||jt(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:Ce,forceKeepAttr:void 0},r=t.length,i=O(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=O(o),u=c,d=o===`value`?u:yn(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,Pt(w.uponSanitizeAttribute,e,n),d=n.attrValue,He&&(l===`id`||l===`name`)&&vn(d,Ue)!==0&&(wt(o,e),d=Ue+d),Ne&&En(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){wt(o,e);continue}if(l===`attributename`&&gn(d,`href`)){wt(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){wt(o,e);continue}if(!je&&En(ar,d)){wt(o,e);continue}if(Me&&(d=kt(d)),!Rt(i,l,d)){wt(o,e);continue}d=Vt(i,l,s,d),d!==u&&Ht(e,o,s,d)}}Pt(w.afterSanitizeAttributes,e,null)},Wt=function(e){let t=null,n=Ot(e);for(Pt(w.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Pt(w.uponSanitizeShadowNode,t,null),Lt(t,e),Ut(t),Mt(t.content)&&Wt(t.content),(y?y(t):t.nodeType)===or.element){let e=_(t);Mt(e)&&(Gt(e),Wt(e))}Pt(w.afterSanitizeShadowDOM,e,null)},Gt=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Wt(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===or.element,i=h(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=b?b(n):null;if(typeof e==`string`&&O(e)===`template`){let e=n.content;Mt(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);Mt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(nt=!e,nt&&(e=`<!-->`),typeof e!=`string`&&!Nt(e)&&(e=Mn(e),typeof e!=`string`))throw Dn(`dirty is not a string, aborting`);if(!t.isSupported)return e;Fe?(xe=Ie,Ce=E):ht(n),(w.uponSanitizeElement.length>0||w.uponSanitizeAttribute.length>0)&&(xe=jn(xe)),w.uponSanitizeAttribute.length>0&&(Ce=jn(Ce)),t.removed=[];let c=Ge&&typeof e!=`string`&&Nt(e);if(c){Dt(e);let t=b?b(e):e.nodeName;if(typeof t==`string`){let n=O(t);if(!xe[n]||Te[n])throw Ct(e),Dn(`root node is forbidden and cannot be sanitized in-place`)}if(jt(e))throw Ct(e),Dn(`root node is clobbered and cannot be sanitized in-place`);try{Gt(e)}catch(t){throw Ct(e),t}}else if(Nt(e))i=k(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===or.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Gt(a);else{if(!Re&&!Me&&!Pe&&e.indexOf(`<`)===-1)return x&&Be?re(e):e;if(i=k(e),!i)return Re?null:Be?S:``}i&&Le&&St(i.firstChild);let l=c?e:i,u=Ot(l);try{for(;o=u.nextNode();)Lt(o,l),Ut(o),Mt(o.content)&&Wt(o.content)}catch(n){throw c&&(Ct(e),cn(t.removed,e=>{e.element&&Et(e.element)})),n}if(c)return cn(t.removed,e=>{e.element&&Et(e.element)}),Me&&At(e),e;if(Re){if(Me&&At(i),ze)for(s=le.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(Ce.shadowroot||Ce.shadowrootmode)&&(s=de.call(r,s,!0)),s}let d=Pe?i.outerHTML:i.innerHTML;return Pe&&xe[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&En(er,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
3
3
  `+d),Me&&(d=kt(d)),x&&Be?re(d):d},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ht(e),Fe=!0,Ie=xe,E=Ce},t.clearConfig=function(){ft=null,Fe=!1,Ie=null,E=null,x=C,S=``},t.isValidAttribute=function(e,t,n){ft||ht({});let r=O(e),i=O(t);return Rt(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&wn(w,e)&&dn(w[e],t)},t.removeHook=function(e,t){if(wn(w,e)){if(t!==void 0){let n=ln(w[e],t);return n===-1?void 0:fn(w[e],n,1)[0]}return un(w[e])}},t.removeHooks=function(e){wn(w,e)&&(w[e]=[])},t.removeAllHooks=function(){w=lr()},t}var fr=dr();function pr(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var mr=pr();function hr(e){mr=e}var gr={exec:()=>null};function _r(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function j(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(yr.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var vr=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),yr={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:_r(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:_r(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:_r(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:_r(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:_r(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:_r(e=>RegExp(`^ {0,${e}}>`))},br=/^(?:[ \t]*(?:\n|$))+/,xr=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Sr=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Cr=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,wr=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Tr=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Er=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Dr=j(Er).replace(/bull/g,Tr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Or=j(Er).replace(/bull/g,Tr).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}(?:\s|$)/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),kr=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Ar=/^[^\n]+/,jr=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Mr=j(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,jr).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Nr=j(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Tr).getRegex(),Pr=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,Fr=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ir=j(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Fr).replace(`tag`,Pr).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Lr=e=>j(kr).replace(`hr`,Cr).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace(`list`,e).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Pr).getRegex(),Rr=Lr(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),zr=Lr(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Br={blockquote:j(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,zr).getRegex(),code:xr,def:Mr,fences:Sr,heading:wr,hr:Cr,html:Ir,lheading:Dr,list:Nr,newline:br,paragraph:Rr,table:gr,text:Ar},Vr=j(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,Cr).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Pr).getRegex(),Hr={...Br,lheading:Or,table:Vr,paragraph:j(kr).replace(`hr`,Cr).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Vr).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~~~)[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,Pr).getRegex()},Ur={...Br,html:j(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Fr).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:gr,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:j(kr).replace(`hr`,Cr).replace(`heading`,` *#{1,6} *[^
4
4
  ]`).replace(`lheading`,Dr).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Wr=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Gr=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Kr=/^( {2,}|\\)\n(?!\s*$)/,qr=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Jr=/[\p{P}\p{S}]/u,Yr=/[\s\p{P}\p{S}]/u,Xr=/[^\s\p{P}\p{S}]/u,Zr=j(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Yr).getRegex(),Qr=/(?!~)[\p{P}\p{S}]/u,$r=/(?!~)[\s\p{P}\p{S}]/u,ei=/(?:[^\s\p{P}\p{S}]|~)/u,ti=j(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,vr?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),ni=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ri=j(ni,`u`).replace(/punct/g,Jr).getRegex(),ii=j(ni,`u`).replace(/punct/g,Qr).getRegex(),ai=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,oi=j(ai,`gu`).replace(/notPunctSpace/g,Xr).replace(/punctSpace/g,Yr).replace(/punct/g,Jr).getRegex(),si=j(ai,`gu`).replace(/notPunctSpace/g,ei).replace(/punctSpace/g,$r).replace(/punct/g,Qr).getRegex(),ci=j(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Xr).replace(/punctSpace/g,Yr).replace(/punct/g,Jr).getRegex(),li=j(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,Jr).getRegex(),ui=j(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Xr).replace(/punctSpace/g,Yr).replace(/punct/g,Jr).getRegex(),di=j(/\\(punct)/,`gu`).replace(/punct/g,Jr).getRegex(),fi=j(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),pi=j(Fr).replace(`(?:-->|$)`,`-->`).getRegex(),mi=j(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,pi).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),hi=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,gi=j(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,hi).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),_i=j(/^!?\[(label)\]\[(ref)\]/).replace(`label`,hi).replace(`ref`,jr).getRegex(),vi=j(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,jr).getRegex(),yi=j(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,_i).replace(`nolink`,vi).getRegex(),bi=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,xi={_backpedal:gr,anyPunctuation:di,autolink:fi,blockSkip:ti,br:Kr,code:Gr,del:gr,delLDelim:gr,delRDelim:gr,emStrongLDelim:ri,emStrongRDelimAst:oi,emStrongRDelimUnd:ci,escape:Wr,link:gi,nolink:vi,punctuation:Zr,reflink:_i,reflinkSearch:yi,tag:mi,text:qr,url:gr},Si={...xi,link:j(/^!?\[(label)\]\((.*?)\)/).replace(`label`,hi).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,hi).getRegex()},Ci={...xi,emStrongRDelimAst:si,emStrongLDelim:ii,delLDelim:li,delRDelim:ui,url:j(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,bi).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:j(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,bi).getRegex()},wi={...Ci,br:j(Kr).replace(`{2,}`,`*`).getRegex(),text:j(Ci.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Ti={normal:Br,gfm:Hr,pedantic:Ur},Ei={normal:xi,gfm:Ci,breaks:wi,pedantic:Si},Di={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},Oi=e=>Di[e];function ki(e,t){if(t){if(yr.escapeTest.test(e))return e.replace(yr.escapeReplace,Oi)}else if(yr.escapeTestNoEncode.test(e))return e.replace(yr.escapeReplaceNoEncode,Oi);return e}function Ai(e){try{e=encodeURI(e).replace(yr.percentDecode,`%`)}catch{return null}return e}function ji(e,t){let n=e.replace(yr.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(yr.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(yr.slashPipe,`|`);return n}function Mi(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Ni(e){let t=e.split(`
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{$ as r,At as i,B as a,Bt as o,C as s,Ft as c,G as l,H as u,L as d,Mt as f,Nt as p,O as m,P as h,Pt as g,Q as _,U as v,X as y,Y as b,_ as x,a as ee,d as te,dt as S,ft as ne,h as C,i as w,it as T,jt as E,k as re,n as D,ot as ie,q as ae,rt as O,t as oe,tt as se,w as ce}from"./hotkeys-CA5Pxll4.js";import{a as k,g as A,i as j,n as M,o as N,r as P,t as F}from"./dialog-B43iKmfK.js";import{a as le,c as I,i as L,l as R,o as ue,r as de,s as fe}from"./LazyTerminal-BaxoOzC-.js";import{t as z}from"./utils-B6KiDbIe.js";import{t as B}from"./createLucideIcon-DyMAgLa3.js";import{a as V,i as H,n as U,o as pe,r as me,s as he,t as ge}from"./session-seed-DSCaVN9j.js";import{r as _e}from"./dist-i-QevsUb.js";import{$ as ve,Ct as ye,Dt as be,Et as xe,G as Se,H as Ce,J as we,K as Te,Lt as Ee,Ot as De,Q as Oe,R as W,St as ke,U as Ae,V as je,Vt as Me,W as Ne,X as Pe,Y as G,bt as Fe,et as Ie,gt as Le,ht as Re,kt as ze,mt as Be,ot as Ve,q as He,r as Ue,rt as We,tt as Ge,xt as Ke,yt as qe}from"./index-DpDy4sdB.js";var Je=B(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Ye=B(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Xe=B(`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`}]]),Ze=B(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Qe=B(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),$e=B(`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`}]]),et=B(`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`}]]),tt=B(`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(t(),1),q=n();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)(I,{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:z(`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:z(`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 nt(){let e=Pe(),[t,n]=(0,K.useState)(Me());return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Appearance`}),(0,q.jsx)(Y,{label:`Theme`,children:(0,q.jsxs)(U,{value:t,onValueChange:e=>{n(e),Ee(e)},children:[(0,q.jsx)(V,{className:`w-32`,children:(0,q.jsx)(pe,{})}),(0,q.jsxs)(me,{children:[(0,q.jsx)(H,{value:`dark`,children:`Dark`}),(0,q.jsx)(H,{value:`light`,children:`Light`}),(0,q.jsx)(H,{value:`system`,children:`System`})]})]})}),(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=>G({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=>G({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=>G({editorFontSize:e})})}),(0,q.jsx)(Y,{label:`Density`,children:(0,q.jsxs)(U,{value:e.density,onValueChange:e=>G({density:e}),children:[(0,q.jsx)(V,{className:`w-36`,children:(0,q.jsx)(pe,{})}),(0,q.jsxs)(me,{children:[(0,q.jsx)(H,{value:`compact`,children:`Compact`}),(0,q.jsx)(H,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,q.jsx)(Y,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,q.jsx)(W,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>G({projectBasedLayout:e})})}),(0,q.jsx)(Y,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,q.jsx)(W,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>G({showAllProjectSessions:e})})})]})}function rt({profile:e}){let t=_(),[n,r]=(0,K.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>L(e)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>L(e)});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Icon`,children:(0,q.jsxs)(ve,{open:n,onOpenChange:r,children:[(0,q.jsx)(Ge,{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)(qe,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,q.jsx)(Ie,{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:z(`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)(qe,{icon:null,colour:null,className:`size-4`})}),Ke.map(({name:t,Icon:n})=>(0,q.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:z(`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.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,q.jsxs)(`button`,{type:`button`,title:`Default`,onClick:()=>a(null),className:z(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,!e.icon_colour&&`bg-elevated`),children:[(0,q.jsx)(`span`,{className:`size-3.5 rounded-full bg-fg-muted`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Default colour`})]}),g.map(t=>(0,q.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:z(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,e.icon_colour===t&&`bg-elevated`),children:[(0,q.jsx)(`span`,{className:z(`size-3.5 rounded-full bg-current`,Fe(t))}),(0,q.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var it=`__none__`;function at(){let e=x(),t=T().data?.find(t=>t.id===e),n=s(e??void 0),i=O(e??void 0),o=_(),c=r(e??``),l=a(),[u,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(``),[m,h]=(0,K.useState)(!1),[g,v]=(0,K.useState)(``);if((0,K.useEffect)(()=>{t&&(d(t.name),p(t.branch_prefix))},[t]),!t)return null;let y=i.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)(I,{id:`profile-name`,value:u,onChange:e=>d(e.target.value),className:`w-44`}),(0,q.jsx)(A,{size:`sm`,variant:`secondary`,disabled:u===t.name||u.trim()===``||o.isPending,onClick:()=>o.mutate({id:t.id,name:u},{onError:e=>L(e)}),children:`Save`})]}),(0,q.jsxs)(Y,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,q.jsx)(I,{id:`branch-prefix`,value:f,onChange:e=>p(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,q.jsx)(A,{size:`sm`,variant:`secondary`,disabled:f===t.branch_prefix||o.isPending,onClick:()=>o.mutate({id:t.id,branch_prefix:f},{onError:e=>L(e)}),children:`Save`})]}),(0,q.jsx)(rt,{profile:t}),(0,q.jsx)(Y,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,q.jsxs)(U,{value:typeof y==`number`?String(y):it,onValueChange:e=>c.mutate({default_account_id:e===it?null:Number(e)},{onError:e=>L(e)}),children:[(0,q.jsx)(V,{className:`w-56`,children:(0,q.jsx)(pe,{})}),(0,q.jsxs)(me,{children:[(0,q.jsx)(H,{value:it,children:`First available`}),n.data?.map(e=>(0,q.jsx)(H,{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)(A,{variant:`danger`,size:`sm`,onClick:()=>h(!0),children:`Delete…`})}),(0,q.jsx)(F,{open:m,onOpenChange:e=>{e||(h(!1),v(``))},children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(k,{children:[(0,q.jsxs)(N,{children:[`Delete profile `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,q.jsx)(P,{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)(fe,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,q.jsx)(I,{id:`delete-confirm-name`,value:g,onChange:e=>v(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(j,{children:[(0,q.jsx)(A,{variant:`ghost`,onClick:()=>{h(!1),v(``)},children:`Cancel`}),(0,q.jsx)(A,{variant:`danger`,disabled:g!==t.name||l.isPending,onClick:()=>l.mutate(t.id,{onSuccess:()=>{Be(),C.set(null)},onError:e=>{h(!1),v(``),L(e)}}),children:`Delete profile`})]})]})})]})}function ot({agent:e,profileId:t,onClose:n,onCreated:r}){let i=re(),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),l=u(Ve(s,150)),d=s.trim(),f=d===``||d.startsWith(`/`)||d.startsWith(`~`),p=a.trim()!==``&&f,m=()=>{!p||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...d===``?{}:{import_dir:d}},{onSuccess:e=>{n(),r(e,d!==``)},onError:e=>L(e)})};return(0,q.jsx)(F,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(k,{children:[(0,q.jsxs)(N,{children:[`Add a `,e.display_name,` account`]}),(0,q.jsxs)(P,{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(),m()},children:[(0,q.jsx)(I,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(de,{value:s,onValueChange:c,placeholder:`(optional) existing config dir, e.g. ~/.claude`,hints:(l.data?.entries??[]).map(e=>({value:e.path,label:e.name}))})]}),(0,q.jsxs)(j,{children:[(0,q.jsx)(A,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,q.jsxs)(A,{disabled:!p||i.isPending,onClick:m,children:[(0,q.jsx)(be,{}),`Add account`]})]})]})})}function st({account:e,gateOpen:t,installed:n}){let r=ae(),i=b(),a=d(),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1),[u,f]=(0,K.useState)(e.label),p=(0,K.useRef)(null);return(0,K.useEffect)(()=>f(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:p,value:u,onChange:e=>f(e.target.value),onBlur:()=>{let t=u.trim();if(t!==e.label){if(t===``){f(e.label);return}i.mutate({id:e.id,label:t},{onError:t=>{L(t),f(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(f(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:()=>{p.current?.focus(),p.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)(le,{className:`size-3`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Rename account`})]})]}),(0,q.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,q.jsx)(W,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>L(e)})})]}),(0,q.jsxs)(A,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>L(e)}),children:[(0,q.jsx)(ze,{}),e.logged_in?`Re-login`:`Login`]}),(0,q.jsxs)(A,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,q.jsx)(ye,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,q.jsx)(Oe,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,q.jsx)(F,{open:c,onOpenChange:l,children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(k,{children:[(0,q.jsxs)(N,{children:[`Delete `,(0,q.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,q.jsx)(P,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,q.jsxs)(j,{children:[(0,q.jsx)(A,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,q.jsx)(A,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),L(e)}}),children:`Delete account`})]})]})})]})}function ct(){let e=x(),t=ce(),n=s(e??void 0),r=O(e??void 0),i=ae(),[a,c]=(0,K.useState)(null),[l,u]=(0,K.useState)(null),d=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)(st,{account:t,gateOpen:d&&e.capabilities.skip_permissions,installed:r},t.id)),(0,q.jsx)(`div`,{className:`flex`,children:(0,q.jsxs)(A,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>u(e),children:[(0,q.jsx)(be,{}),`Add account`]})})]})]},e.id)}),a&&(0,q.jsx)(Oe,{stream:a.stream,label:a.label,hint:a.hint,onClose:()=>c(null)}),l!==null&&e!==null&&(0,q.jsx)(ot,{agent:l,profileId:e,onClose:()=>u(null),onCreated:(e,t)=>{if(t){e.logged_in||o.info(`Imported without credentials — press Login to authenticate.`);return}i.mutate(e.id,{onSuccess:t=>c({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>L(e)})}})]})}function lt(){let e=m(),t=y(),[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)(I,{id:`agent-path`,type:`text`,className:`w-64 text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function ut({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=ge(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)(I,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,q.jsx)(Y,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,q.jsx)(W,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,q.jsx)(Y,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`Start on working copy of the selected branch instead of sharing one directory.`,htmlFor:`${e}-default-dir`,children:(0,q.jsx)(W,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function dt(){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:Pe().terminalScrollback,onCommit:e=>G({terminalScrollback:e})})})}function ft({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)(R,{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)(A,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,q.jsx)(A,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var pt={id:`4f3c2b1a-7e6d-5c4b-3a2f-1e0d9c8b7a6f`,title:null,agent_title:`Refactor the auth flow`,osc_title:`claude`,branch:`alice/refactor-auth`,worktree_path:`/home/alice/code/app--refactor-auth`,status:`waiting_input`,agent_type:`claude-code`};function mt({initial:e,onSave:t,pending:n}){let[r,i]=(0,K.useState)(e),a=r.length>0?r:p;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)(I,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:p}),(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,q.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:We(pt,a)})]}),(0,q.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:c.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)(A,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,q.jsx)(A,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(p),t(p)},children:`Reset to default`})]})]})}function ht(){let e=x(),t=T().data?.find(t=>t.id===e),n=O(e??void 0),a=r(e??``),[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(``),u=n.data?.allowSkipPermissions===!0,d=e=>a.mutate({allowSkipPermissions:e},{onSuccess:()=>{s(!1),l(``)},onError:e=>L(e)}),p=e=>t=>a.mutate({[e]:t},{onError:e=>L(e)});return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sessions`}),(0,q.jsx)(Y,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,q.jsx)(W,{id:`gate`,checked:u,onCheckedChange:e=>{e?s(!0):d(!1)}})}),(0,q.jsx)(Y,{label:`Capture exported env variables`,description:n.data?.captureSessionEnv===!1?`No variables are captured or injected; already-captured variabless are kept for when this is re-enabled.`:`Variables exported in a session persist and are re-injected upon terminal and agent restarts.`,htmlFor:`capture-env`,children:(0,q.jsx)(W,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:a.isPending,onCheckedChange:e=>a.mutate({captureSessionEnv:e},{onError:e=>L(e)})})}),(0,q.jsx)(lt,{}),(0,q.jsx)(dt,{}),(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)(ut,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>a.mutate({sessionDefaults:e},{onError:e=>L(e)}),pending:a.isPending},`${e}:agent-seed`),(0,q.jsx)(ut,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>a.mutate({sessionDefaults:e},{onError:e=>L(e)}),pending:a.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)(ft,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??E,defaultText:E,onSave:p(`onboardingTemplate`),pending:a.isPending},`${e}:onboarding`),(0,q.jsx)(ft,{id:`concurrent-template`,label:`Existing / shared worktree`,description:`For a session joining a worktree other agents may already be working in.`,initial:n.data.concurrentTemplate??i,defaultText:i,onSave:p(`concurrentTemplate`),pending:a.isPending},`${e}:concurrent`),(0,q.jsx)(ft,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??f,defaultText:f,onSave:p(`restartTemplate`),pending:a.isPending},`${e}:restart`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`Tab title`}),n.data&&(0,q.jsx)(mt,{initial:n.data.tabTitleTemplate||"${name}",onSave:p(`tabTitleTemplate`),pending:a.isPending},`${e}:tab-title`)]}),(0,q.jsx)(F,{open:o,onOpenChange:e=>{e||(s(!1),l(``))},children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(k,{children:[(0,q.jsxs)(N,{className:`flex items-center gap-2`,children:[(0,q.jsx)($e,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,q.jsx)(P,{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)(fe,{htmlFor:`confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,q.jsx)(I,{id:`confirm-name`,value:c,onChange:e=>l(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(j,{children:[(0,q.jsx)(A,{variant:`ghost`,onClick:()=>{s(!1),l(``)},children:`Cancel`}),(0,q.jsx)(A,{variant:`danger`,disabled:c!==t?.name||a.isPending,onClick:()=>d(!0),children:`Open the gate`})]})]})})]})}var gt={desktop:!0,sound:!1,muted_projects:[]};function _t(){let[e,t]=(0,K.useState)(je);return(0,K.useEffect)(()=>{let e=()=>t(je());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(je())]}function vt({permission:e,onRequest:t}){return e===`granted`?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 yt(){let e=x(),t=O(e??void 0),n=r(e??``),i=ie(e??void 0),[a,o]=_t(),s={...gt,...t.data?.notifications??{}},c=e=>n.mutate({notifications:e},{onError:e=>L(e)}),l=()=>{typeof Notification>`u`||Notification.requestPermission().then(o)};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Notifications`}),(0,q.jsx)(Y,{label:`Desktop notification on waiting`,htmlFor:`notify-desktop`,children:(0,q.jsx)(W,{id:`notify-desktop`,checked:s.desktop,onCheckedChange:e=>{e&&l(),c({...s,desktop:e})}})}),s.desktop&&(0,q.jsx)(vt,{permission:a,onRequest:l}),(0,q.jsx)(Y,{label:`Sound`,htmlFor:`notify-sound`,children:(0,q.jsx)(W,{id:`notify-sound`,checked:s.sound,onCheckedChange:e=>c({...s,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:[s.muted_projects.length,` muted`]})}),(0,q.jsx)(`div`,{className:`flex flex-col gap-1`,children:i.data?.map(e=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,q.jsx)(W,{checked:s.muted_projects.includes(e.id),onCheckedChange:t=>c({...s,muted_projects:t?[...s.muted_projects,e.id]:s.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function bt(){let e=Pe();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=>G({editorTabSize:e})})}),(0,q.jsx)(Y,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,q.jsx)(W,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>G({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)(I,{id:`editor-link-host`,type:`text`,placeholder:Ue.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>G({editorLinkSshHost:e.target.value})})})]})}function xt({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`,onClick:()=>a(!0),onBlur:()=>a(!1),onKeyDown:e=>{if(!i)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){a(!1);return}let t=w(e.nativeEvent);t&&(n(t),a(!1))},className:z(`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…`:ee(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)(Ze,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function St(){let e=x(),t=O(e??void 0),n=r(e??``),i=t.data?.hotkeys??{},a=(e,t)=>i[e]||t,o=new Map;for(let e of oe){let t=a(e.id,te(e));o.set(t,(o.get(t)??0)+1)}let s=(e,t)=>n.mutate({hotkeys:{...i,[e]:t}},{onError:e=>L(e)}),c=e=>{let t={...i};delete t[e],n.mutate({hotkeys:t},{onError:e=>L(e)})};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Hotkeys`}),(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),(0,q.jsx)(Y,{label:`App shortcuts in terminals`,description:t.data?.terminalAppShortcuts===!1?`A focused terminal receives these keys instead.`:`The shortcuts below work while a terminal is focused.`,htmlFor:`terminal-app-shortcuts`,className:`mb-4`,children:(0,q.jsx)(W,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>L(e)})})}),D.map(e=>{let t=oe.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=a(e.id,te(e)),n=(o.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)(xt,{value:t,isDefault:!i[e.id],onRecord:t=>s(e.id,t),onReset:()=>c(e.id)})},e.id)})]},e)})]})}var Ct=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Z=65,Q=Object.fromEntries([...Ct].map((e,t)=>[e,t])),wt=`H`,Tt=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let n=t;for(let e=0;e<8;e+=1)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function Et(e){let t=4294967295;for(let n of e)t=Tt[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function Dt(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function Ot(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}async function kt(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function At(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function jt(e,t){let n=(t%Z+Z)%Z,r=``;for(let t of e){let e=Q[t];r+=e===void 0?t:Ct[(e+n)%Z]}return r}async function Mt(e){let t=await kt(JSON.stringify(e));return jt(Dt(t)+Et(t),1+Math.floor(Math.random()*(Z-1)))}async function Nt(e){let t=e.trim(),n=t[0];if(!n||Q[n]===void 0)throw Error(`Not a settings export.`);let r=jt(t,-((Q[n]-Q[wt]+Z)%Z));if(r.length<9||r[0]!==wt)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=Ot(i);if(Et(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await At(o))}var Pt=`puddle.sync-selection`;function Ft(){try{let e=JSON.parse(localStorage.getItem(Pt)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return Se.map(e=>e.id)}function It({selected:e,onToggle:t}){return(0,q.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:Se.map(n=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(W,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function Lt(){let e=x(),t=O(e??void 0),n=T().data?.find(t=>t.id===e),i=ne(e??void 0,void 0),a=r(e??``),s=_(),c=h(),l=Ae(),u=Ne(),[d,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(``),[g,v]=(0,K.useState)(!1),[y,b]=(0,K.useState)(!1),[ee,te]=(0,K.useState)(Ft),S=n&&l.data?Ce(l.data.file,n.name):void 0,C=S?.enabled===!0,w=C&&S?S.groups:ee,E=()=>({client:we(),theme:Me(),profileSettings:t.data??{},profile:n??{},scratchpad:i.data??[]}),re={setClient:e=>G(e),setTheme:e=>{typeof e==`string`&&Ee(e)},patchProfileSettings:e=>a.mutate(e,{onError:e=>L(e)}),patchProfileColumns:t=>{e&&s.mutate({id:e,...t},{onError:e=>L(e)})},createScratchpad:t=>{if(e)for(let n of t)c.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},D=(e,t)=>{n&&u.mutate({profile:n.name,entry:{enabled:e.enabled??C,groups:t,doc:He(t,E()),updatedAt:new Date().toISOString()}},{onError:e=>L(e)})},ie=(e,t)=>{let n=t?[...w,e]:w.filter(t=>t!==e);te(n),localStorage.setItem(Pt,JSON.stringify(n)),C&&D({},n)},ae=async()=>{b(!0);try{let e=Te(await Nt(d.trim()),re,{profileSettings:t.data??{},scratchpad:i.data??[]});e.length===0?o.error(`Nothing recognised to import.`):(o.success(`Imported ${e.join(`, `)}.`),f(``))}catch(e){o.error(e.message)}finally{b(!1)}},oe=async()=>{b(!0);try{let e=await Mt(He(w,E()));m(e),await navigator.clipboard?.writeText(e),o.success(`Copied to clipboard`)}finally{b(!1)}};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sync`}),(0,q.jsx)(`p`,{className:`mb-5 text-xs text-fg-muted`,children:`Carry your settings between machines. Accounts, repositories, and anything host-specific are never included. Applies to this profile.`}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),l.data?.available===!1?(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:`Not available in this cockpit — start the UI with the Puddle CLI to sync across windows.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Sync selected groups through this machine’s`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:`~/.puddle`}),`, so every Puddle window stays in step for profiles named`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:n?.name??`…`}),`.`]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(W,{checked:C,disabled:!n||l.isLoading||u.isPending,onCheckedChange:e=>D({enabled:e},w)}),`Sync locally`]})]})]}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>v(e=>!e),className:`flex items-center gap-1 text-xs text-fg-secondary transition-colors hover:text-fg`,children:[g?(0,q.jsx)(he,{className:`size-3.5`}):(0,q.jsx)(_e,{className:`size-3.5`}),`Choose what to sync`]}),g&&(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(It,{selected:w,onToggle:ie})})]}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,q.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:`Builds a Puddle magic string that encodes settings from the checklist above.`}),(0,q.jsx)(A,{size:`sm`,disabled:y,onClick:()=>void oe(),children:`Export & copy`}),p&&(0,q.jsx)(R,{readOnly:!0,value:p,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`mt-2 resize-y font-mono text-xs`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,q.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste a Puddle magic string to import its settings.`}),(0,q.jsx)(R,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:`Paste a settings export…`,rows:3,spellCheck:!1,className:`resize-y font-mono text-xs`}),(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(A,{size:`sm`,disabled:!d.trim()||y,onClick:()=>void ae(),children:`Import`})})]})]})}function Rt({repo:e}){let t=se(),n=v(),[r,i]=(0,K.useState)(e.default_base_branch),[a,s]=(0,K.useState)(e.onboarding_notes??``),c=e=>L(e);return(0,q.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.path}),(0,q.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,q.jsxs)(A,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>o.success(`Fetched.`),onError:c}),children:[(0,q.jsx)(xe,{}),`Fetch now`]})]}),(0,q.jsxs)(Y,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,q.jsx)(I,{id:`base-${e.id}`,value:r,onChange:e=>i(e.target.value),className:`w-40`}),(0,q.jsx)(A,{size:`sm`,variant:`secondary`,disabled:r===e.default_base_branch||t.isPending,onClick:()=>t.mutate({id:e.id,default_base_branch:r},{onError:c}),children:`Save`})]}),(0,q.jsx)(Y,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,q.jsx)(W,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:c})})}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Standing setup rules, injected into every fresh worktree. Agents update them via .puddle/onboarding-notes.md.`})]}),(0,q.jsx)(R,{id:`notes-${e.id}`,value:a,onChange:e=>s(e.target.value),rows:4}),(0,q.jsx)(`div`,{children:(0,q.jsx)(A,{size:`sm`,variant:`secondary`,disabled:a===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:a},{onError:c}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,q.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,q.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Orphan worktrees — directories no session claims. Puddle never deletes these automatically; remove them by hand if unwanted.`}),(0,q.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,q.jsx)(`li`,{className:`truncate text-2xs text-fg-muted`,children:e},e))})]})]})}function zt(){let e=S();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Projects`}),e.data?.length===0&&(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No projects yet — create one from the dashboard, pointing at a repository.`}),e.data?.map(e=>(0,q.jsx)(Rt,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=y();return(0,q.jsx)(Y,{label:e,description:t,htmlFor:`host-${n}`,children:(0,q.jsx)(I,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{if(e.target.value.trim()===``){e.target.value=String(r[n]);return}let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>L(e)})}})})}function Bt(){let e=m(),t=y(),n=l();return e.data?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{note:`Affects all profiles on this host`,children:`Host`}),(0,q.jsx)(Y,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,q.jsx)(I,{id:`host-displayName`,type:`text`,maxLength:64,className:`w-48`,placeholder:n.data?.hostname,defaultValue:e.data.displayName,onBlur:n=>{let r=n.target.value.trim();r!==e.data.displayName&&t.mutate({displayName:r},{onError:e=>L(e)})}})}),(0,q.jsx)($,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,q.jsx)($,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,q.jsx)($,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,q.jsx)($,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,q.jsx)(Y,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,q.jsx)(W,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>L(e)})})})]}):null}var Vt=[{id:`appearance`,label:`Appearance`,icon:De,render:()=>(0,q.jsx)(nt,{})},{id:`profile`,label:`Profile`,icon:ke,render:()=>(0,q.jsx)(at,{})},{id:`accounts`,label:`Accounts`,icon:tt,render:()=>(0,q.jsx)(ct,{})},{id:`sessions`,label:`Sessions`,icon:et,render:()=>(0,q.jsx)(ht,{})},{id:`editor`,label:`Editor`,icon:Ye,render:()=>(0,q.jsx)(bt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Xe,render:()=>(0,q.jsx)(St,{})},{id:`notifications`,label:`Notifications`,icon:Je,render:()=>(0,q.jsx)(yt,{})},{id:`projects`,label:`Projects`,icon:ue,render:()=>(0,q.jsx)(zt,{})},{id:`host`,label:`Host`,icon:Qe,render:()=>(0,q.jsx)(Bt,{})},{id:`sync`,label:`Sync`,icon:xe,render:()=>(0,q.jsx)(Lt,{})}],Ht={terminal:`sessions`,repositories:`projects`};function Ut(){let e=Le(),t=e===null?null:Ht[e]??e,n=Vt.find(e=>e.id===t)??Vt[0];return(0,q.jsx)(F,{open:e!==null,onOpenChange:e=>!e&&Be(),children:(0,q.jsxs)(M,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,q.jsx)(N,{className:`sr-only`,children:`Settings`}),(0,q.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,q.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),Vt.map(({id:e,label:t,icon:r})=>(0,q.jsxs)(`button`,{onClick:()=>Re(e),className:z(`flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors`,e===n.id?`bg-elevated text-fg`:`text-fg-secondary hover:bg-elevated hover:text-fg`),children:[(0,q.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]}),(0,q.jsx)(`div`,{className:`overflow-y-auto p-5`,children:n.render()})]})})}export{Ut as SettingsDialog};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{$ as r,At as i,B as a,Bt as o,C as s,Ft as c,G as l,H as u,L as d,Mt as f,Nt as p,O as m,P as h,Pt as g,Q as _,U as v,X as y,Y as b,_ as x,a as ee,d as te,dt as S,ft as ne,h as C,i as w,it as T,jt as E,k as re,n as D,ot as ie,q as ae,rt as O,t as oe,tt as se,w as ce}from"./hotkeys-CA5Pxll4.js";import{a as k,g as A,i as j,n as M,o as N,r as P,t as F}from"./dialog-B43iKmfK.js";import{a as le,c as I,i as L,l as R,o as ue,r as de,s as fe}from"./LazyTerminal-dx89528B.js";import{t as z}from"./utils-B6KiDbIe.js";import{t as B}from"./createLucideIcon-DyMAgLa3.js";import{a as V,i as H,n as U,o as pe,r as me,s as he,t as ge}from"./session-seed-2cbwtTKV.js";import{r as _e}from"./dist-i-QevsUb.js";import{$ as ve,At as ye,Ct as be,Dt as xe,G as Se,H as Ce,Ht as we,J as Te,K as Ee,Ot as De,Q as Oe,R as W,Rt as ke,St as Ae,U as je,V as Me,W as Ne,X as Pe,Y as G,_t as Fe,bt as Ie,et as Le,gt as Re,ht as ze,kt as Be,q as Ve,r as He,rt as Ue,st as We,tt as Ge,wt as Ke,xt as qe}from"./index-BYC57b5y.js";var Je=B(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Ye=B(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Xe=B(`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`}]]),Ze=B(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Qe=B(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),$e=B(`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`}]]),et=B(`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`}]]),tt=B(`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(t(),1),q=n();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)(I,{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:z(`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:z(`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 nt(){let e=Pe(),[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)(U,{value:t,onValueChange:e=>{n(e),ke(e)},children:[(0,q.jsx)(V,{className:`w-32`,children:(0,q.jsx)(pe,{})}),(0,q.jsxs)(me,{children:[(0,q.jsx)(H,{value:`dark`,children:`Dark`}),(0,q.jsx)(H,{value:`light`,children:`Light`}),(0,q.jsx)(H,{value:`system`,children:`System`})]})]})}),(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=>G({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=>G({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=>G({editorFontSize:e})})}),(0,q.jsx)(Y,{label:`Density`,children:(0,q.jsxs)(U,{value:e.density,onValueChange:e=>G({density:e}),children:[(0,q.jsx)(V,{className:`w-36`,children:(0,q.jsx)(pe,{})}),(0,q.jsxs)(me,{children:[(0,q.jsx)(H,{value:`compact`,children:`Compact`}),(0,q.jsx)(H,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,q.jsx)(Y,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,q.jsx)(W,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>G({projectBasedLayout:e})})}),(0,q.jsx)(Y,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,q.jsx)(W,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>G({showAllProjectSessions:e})})})]})}function rt({profile:e}){let t=_(),[n,r]=(0,K.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>L(e)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>L(e)});return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Y,{label:`Icon`,children:(0,q.jsxs)(ve,{open:n,onOpenChange:r,children:[(0,q.jsx)(Ge,{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)(Ie,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,q.jsx)(Le,{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:z(`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)(Ie,{icon:null,colour:null,className:`size-4`})}),Ae.map(({name:t,Icon:n})=>(0,q.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:z(`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.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,q.jsxs)(`button`,{type:`button`,title:`Default`,onClick:()=>a(null),className:z(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,!e.icon_colour&&`bg-elevated`),children:[(0,q.jsx)(`span`,{className:`size-3.5 rounded-full bg-fg-muted`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Default colour`})]}),g.map(t=>(0,q.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:z(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,e.icon_colour===t&&`bg-elevated`),children:[(0,q.jsx)(`span`,{className:z(`size-3.5 rounded-full bg-current`,qe(t))}),(0,q.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var it=`__none__`;function at(){let e=x(),t=T().data?.find(t=>t.id===e),n=s(e??void 0),i=O(e??void 0),o=_(),c=r(e??``),l=a(),[u,d]=(0,K.useState)(``),[f,p]=(0,K.useState)(``),[m,h]=(0,K.useState)(!1),[g,v]=(0,K.useState)(``);if((0,K.useEffect)(()=>{t&&(d(t.name),p(t.branch_prefix))},[t]),!t)return null;let y=i.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)(I,{id:`profile-name`,value:u,onChange:e=>d(e.target.value),className:`w-44`}),(0,q.jsx)(A,{size:`sm`,variant:`secondary`,disabled:u===t.name||u.trim()===``||o.isPending,onClick:()=>o.mutate({id:t.id,name:u},{onError:e=>L(e)}),children:`Save`})]}),(0,q.jsxs)(Y,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,q.jsx)(I,{id:`branch-prefix`,value:f,onChange:e=>p(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,q.jsx)(A,{size:`sm`,variant:`secondary`,disabled:f===t.branch_prefix||o.isPending,onClick:()=>o.mutate({id:t.id,branch_prefix:f},{onError:e=>L(e)}),children:`Save`})]}),(0,q.jsx)(rt,{profile:t}),(0,q.jsx)(Y,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,q.jsxs)(U,{value:typeof y==`number`?String(y):it,onValueChange:e=>c.mutate({default_account_id:e===it?null:Number(e)},{onError:e=>L(e)}),children:[(0,q.jsx)(V,{className:`w-56`,children:(0,q.jsx)(pe,{})}),(0,q.jsxs)(me,{children:[(0,q.jsx)(H,{value:it,children:`First available`}),n.data?.map(e=>(0,q.jsx)(H,{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)(A,{variant:`danger`,size:`sm`,onClick:()=>h(!0),children:`Delete…`})}),(0,q.jsx)(F,{open:m,onOpenChange:e=>{e||(h(!1),v(``))},children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(k,{children:[(0,q.jsxs)(N,{children:[`Delete profile `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,q.jsx)(P,{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)(fe,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,q.jsx)(I,{id:`delete-confirm-name`,value:g,onChange:e=>v(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(j,{children:[(0,q.jsx)(A,{variant:`ghost`,onClick:()=>{h(!1),v(``)},children:`Cancel`}),(0,q.jsx)(A,{variant:`danger`,disabled:g!==t.name||l.isPending,onClick:()=>l.mutate(t.id,{onSuccess:()=>{ze(),C.set(null)},onError:e=>{h(!1),v(``),L(e)}}),children:`Delete profile`})]})]})})]})}function ot({agent:e,profileId:t,onClose:n,onCreated:r}){let i=re(),[a,o]=(0,K.useState)(``),[s,c]=(0,K.useState)(``),l=u(We(s,150)),d=s.trim(),f=d===``||d.startsWith(`/`)||d.startsWith(`~`),p=a.trim()!==``&&f,m=()=>{!p||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...d===``?{}:{import_dir:d}},{onSuccess:e=>{n(),r(e,d!==``)},onError:e=>L(e)})};return(0,q.jsx)(F,{open:!0,onOpenChange:e=>!e&&n(),children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(k,{children:[(0,q.jsxs)(N,{children:[`Add a `,e.display_name,` account`]}),(0,q.jsxs)(P,{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(),m()},children:[(0,q.jsx)(I,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,q.jsx)(de,{value:s,onValueChange:c,placeholder:`(optional) existing config dir, e.g. ~/.claude`,hints:(l.data?.entries??[]).map(e=>({value:e.path,label:e.name}))})]}),(0,q.jsxs)(j,{children:[(0,q.jsx)(A,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,q.jsxs)(A,{disabled:!p||i.isPending,onClick:m,children:[(0,q.jsx)(De,{}),`Add account`]})]})]})})}function st({account:e,gateOpen:t,installed:n}){let r=ae(),i=b(),a=d(),[o,s]=(0,K.useState)(null),[c,l]=(0,K.useState)(!1),[u,f]=(0,K.useState)(e.label),p=(0,K.useRef)(null);return(0,K.useEffect)(()=>f(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:p,value:u,onChange:e=>f(e.target.value),onBlur:()=>{let t=u.trim();if(t!==e.label){if(t===``){f(e.label);return}i.mutate({id:e.id,label:t},{onError:t=>{L(t),f(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(f(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:()=>{p.current?.focus(),p.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)(le,{className:`size-3`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Rename account`})]})]}),(0,q.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,q.jsx)(W,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>L(e)})})]}),(0,q.jsxs)(A,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>L(e)}),children:[(0,q.jsx)(ye,{}),e.logged_in?`Re-login`:`Login`]}),(0,q.jsxs)(A,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,q.jsx)(Ke,{}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,q.jsx)(Oe,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,q.jsx)(F,{open:c,onOpenChange:l,children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(k,{children:[(0,q.jsxs)(N,{children:[`Delete `,(0,q.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,q.jsx)(P,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,q.jsxs)(j,{children:[(0,q.jsx)(A,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,q.jsx)(A,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),L(e)}}),children:`Delete account`})]})]})})]})}function ct(){let e=x(),t=ce(),n=s(e??void 0),r=O(e??void 0),i=ae(),[a,c]=(0,K.useState)(null),[l,u]=(0,K.useState)(null),d=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)(st,{account:t,gateOpen:d&&e.capabilities.skip_permissions,installed:r},t.id)),(0,q.jsx)(`div`,{className:`flex`,children:(0,q.jsxs)(A,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>u(e),children:[(0,q.jsx)(De,{}),`Add account`]})})]})]},e.id)}),a&&(0,q.jsx)(Oe,{stream:a.stream,label:a.label,hint:a.hint,onClose:()=>c(null)}),l!==null&&e!==null&&(0,q.jsx)(ot,{agent:l,profileId:e,onClose:()=>u(null),onCreated:(e,t)=>{if(t){e.logged_in||o.info(`Imported without credentials — press Login to authenticate.`);return}i.mutate(e.id,{onSuccess:t=>c({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>L(e)})}})]})}function lt(){let e=m(),t=y(),[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)(I,{id:`agent-path`,type:`text`,className:`w-64 text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function ut({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=ge(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)(I,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48`,value:s,onChange:e=>c(e.target.value),onBlur:()=>{s.trim()!==a.baseBranch&&l({baseBranch:s.trim()})}})}),(0,q.jsx)(Y,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,q.jsx)(W,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,q.jsx)(Y,{label:`Separate directory`,description:a.separateBranch?`Always on while a separate branch is used.`:`Start on working copy of the selected branch instead of sharing one directory.`,htmlFor:`${e}-default-dir`,children:(0,q.jsx)(W,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function dt(){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:Pe().terminalScrollback,onCommit:e=>G({terminalScrollback:e})})})}function ft({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)(R,{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)(A,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,q.jsx)(A,{size:`sm`,variant:`ghost`,disabled:s===i||o,onClick:()=>{c(i),a(i)},children:`Reset to default`})]})]})}var pt={id:`4f3c2b1a-7e6d-5c4b-3a2f-1e0d9c8b7a6f`,title:null,agent_title:`Refactor the auth flow`,osc_title:`claude`,branch:`alice/refactor-auth`,worktree_path:`/home/alice/code/app--refactor-auth`,status:`waiting_input`,agent_type:`claude-code`};function mt({initial:e,onSave:t,pending:n}){let[r,i]=(0,K.useState)(e),a=r.length>0?r:p;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)(I,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:p}),(0,q.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,q.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:Ue(pt,a)})]}),(0,q.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:c.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)(A,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,q.jsx)(A,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(p),t(p)},children:`Reset to default`})]})]})}function ht(){let e=x(),t=T().data?.find(t=>t.id===e),n=O(e??void 0),a=r(e??``),[o,s]=(0,K.useState)(!1),[c,l]=(0,K.useState)(``),u=n.data?.allowSkipPermissions===!0,d=e=>a.mutate({allowSkipPermissions:e},{onSuccess:()=>{s(!1),l(``)},onError:e=>L(e)}),p=e=>t=>a.mutate({[e]:t},{onError:e=>L(e)});return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sessions`}),(0,q.jsx)(Y,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,q.jsx)(W,{id:`gate`,checked:u,onCheckedChange:e=>{e?s(!0):d(!1)}})}),(0,q.jsx)(Y,{label:`Capture exported env variables`,description:n.data?.captureSessionEnv===!1?`No variables are captured or injected; already-captured variabless are kept for when this is re-enabled.`:`Variables exported in a session persist and are re-injected upon terminal and agent restarts.`,htmlFor:`capture-env`,children:(0,q.jsx)(W,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:a.isPending,onCheckedChange:e=>a.mutate({captureSessionEnv:e},{onError:e=>L(e)})})}),(0,q.jsx)(lt,{}),(0,q.jsx)(dt,{}),(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)(ut,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>a.mutate({sessionDefaults:e},{onError:e=>L(e)}),pending:a.isPending},`${e}:agent-seed`),(0,q.jsx)(ut,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>a.mutate({sessionDefaults:e},{onError:e=>L(e)}),pending:a.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)(ft,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??E,defaultText:E,onSave:p(`onboardingTemplate`),pending:a.isPending},`${e}:onboarding`),(0,q.jsx)(ft,{id:`concurrent-template`,label:`Existing / shared worktree`,description:`For a session joining a worktree other agents may already be working in.`,initial:n.data.concurrentTemplate??i,defaultText:i,onSave:p(`concurrentTemplate`),pending:a.isPending},`${e}:concurrent`),(0,q.jsx)(ft,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??f,defaultText:f,onSave:p(`restartTemplate`),pending:a.isPending},`${e}:restart`)]})]}),(0,q.jsxs)(`div`,{className:`mt-5`,children:[(0,q.jsx)(X,{children:`Tab title`}),n.data&&(0,q.jsx)(mt,{initial:n.data.tabTitleTemplate||"${name}",onSave:p(`tabTitleTemplate`),pending:a.isPending},`${e}:tab-title`)]}),(0,q.jsx)(F,{open:o,onOpenChange:e=>{e||(s(!1),l(``))},children:(0,q.jsxs)(M,{children:[(0,q.jsxs)(k,{children:[(0,q.jsxs)(N,{className:`flex items-center gap-2`,children:[(0,q.jsx)($e,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,q.jsx)(P,{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)(fe,{htmlFor:`confirm-name`,children:[`Type `,(0,q.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,q.jsx)(I,{id:`confirm-name`,value:c,onChange:e=>l(e.target.value),autoFocus:!0})]}),(0,q.jsxs)(j,{children:[(0,q.jsx)(A,{variant:`ghost`,onClick:()=>{s(!1),l(``)},children:`Cancel`}),(0,q.jsx)(A,{variant:`danger`,disabled:c!==t?.name||a.isPending,onClick:()=>d(!0),children:`Open the gate`})]})]})})]})}var gt={desktop:!0,sound:!1,muted_projects:[]};function _t(){let[e,t]=(0,K.useState)(Me);return(0,K.useEffect)(()=>{let e=()=>t(Me());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(Me())]}function vt({permission:e,onRequest:t}){return e===`granted`?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 yt(){let e=x(),t=O(e??void 0),n=r(e??``),i=ie(e??void 0),[a,o]=_t(),s={...gt,...t.data?.notifications??{}},c=e=>n.mutate({notifications:e},{onError:e=>L(e)}),l=()=>{typeof Notification>`u`||Notification.requestPermission().then(o)};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Notifications`}),(0,q.jsx)(Y,{label:`Desktop notification on waiting`,htmlFor:`notify-desktop`,children:(0,q.jsx)(W,{id:`notify-desktop`,checked:s.desktop,onCheckedChange:e=>{e&&l(),c({...s,desktop:e})}})}),s.desktop&&(0,q.jsx)(vt,{permission:a,onRequest:l}),(0,q.jsx)(Y,{label:`Sound`,htmlFor:`notify-sound`,children:(0,q.jsx)(W,{id:`notify-sound`,checked:s.sound,onCheckedChange:e=>c({...s,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:[s.muted_projects.length,` muted`]})}),(0,q.jsx)(`div`,{className:`flex flex-col gap-1`,children:i.data?.map(e=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,q.jsx)(W,{checked:s.muted_projects.includes(e.id),onCheckedChange:t=>c({...s,muted_projects:t?[...s.muted_projects,e.id]:s.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function bt(){let e=Pe();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=>G({editorTabSize:e})})}),(0,q.jsx)(Y,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,q.jsx)(W,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>G({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)(I,{id:`editor-link-host`,type:`text`,placeholder:He.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>G({editorLinkSshHost:e.target.value})})})]})}function xt({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`,onClick:()=>a(!0),onBlur:()=>a(!1),onKeyDown:e=>{if(!i)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){a(!1);return}let t=w(e.nativeEvent);t&&(n(t),a(!1))},className:z(`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…`:ee(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)(Ze,{className:`size-3.5`}),(0,q.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function St(){let e=x(),t=O(e??void 0),n=r(e??``),i=t.data?.hotkeys??{},a=(e,t)=>i[e]||t,o=new Map;for(let e of oe){let t=a(e.id,te(e));o.set(t,(o.get(t)??0)+1)}let s=(e,t)=>n.mutate({hotkeys:{...i,[e]:t}},{onError:e=>L(e)}),c=e=>{let t={...i};delete t[e],n.mutate({hotkeys:t},{onError:e=>L(e)})};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Hotkeys`}),(0,q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),(0,q.jsx)(Y,{label:`App shortcuts in terminals`,description:t.data?.terminalAppShortcuts===!1?`A focused terminal receives these keys instead.`:`The shortcuts below work while a terminal is focused.`,htmlFor:`terminal-app-shortcuts`,className:`mb-4`,children:(0,q.jsx)(W,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>L(e)})})}),D.map(e=>{let t=oe.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=a(e.id,te(e)),n=(o.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)(xt,{value:t,isDefault:!i[e.id],onRecord:t=>s(e.id,t),onReset:()=>c(e.id)})},e.id)})]},e)})]})}var Ct=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Z=65,Q=Object.fromEntries([...Ct].map((e,t)=>[e,t])),wt=`H`,Tt=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let n=t;for(let e=0;e<8;e+=1)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function Et(e){let t=4294967295;for(let n of e)t=Tt[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function Dt(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function Ot(e){let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e+=1)n[e]=t.charCodeAt(e);return n}async function kt(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function At(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function jt(e,t){let n=(t%Z+Z)%Z,r=``;for(let t of e){let e=Q[t];r+=e===void 0?t:Ct[(e+n)%Z]}return r}async function Mt(e){let t=await kt(JSON.stringify(e));return jt(Dt(t)+Et(t),1+Math.floor(Math.random()*(Z-1)))}async function Nt(e){let t=e.trim(),n=t[0];if(!n||Q[n]===void 0)throw Error(`Not a settings export.`);let r=jt(t,-((Q[n]-Q[wt]+Z)%Z));if(r.length<9||r[0]!==wt)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=Ot(i);if(Et(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await At(o))}var Pt=`puddle.sync-selection`;function Ft(){try{let e=JSON.parse(localStorage.getItem(Pt)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return Se.map(e=>e.id)}function It({selected:e,onToggle:t}){return(0,q.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:Se.map(n=>(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(W,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function Lt(){let e=x(),t=O(e??void 0),n=T().data?.find(t=>t.id===e),i=ne(e??void 0,void 0),a=r(e??``),s=_(),c=h(),l=je(),u=Ne(),[d,f]=(0,K.useState)(``),[p,m]=(0,K.useState)(``),[g,v]=(0,K.useState)(!1),[y,b]=(0,K.useState)(!1),[ee,te]=(0,K.useState)(Ft),S=n&&l.data?Ce(l.data.file,n.name):void 0,C=S?.enabled===!0,w=C&&S?S.groups:ee,E=()=>({client:Te(),theme:we(),profileSettings:t.data??{},profile:n??{},scratchpad:i.data??[]}),re={setClient:e=>G(e),setTheme:e=>{typeof e==`string`&&ke(e)},patchProfileSettings:e=>a.mutate(e,{onError:e=>L(e)}),patchProfileColumns:t=>{e&&s.mutate({id:e,...t},{onError:e=>L(e)})},createScratchpad:t=>{if(e)for(let n of t)c.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},D=(e,t)=>{n&&u.mutate({profile:n.name,entry:{enabled:e.enabled??C,groups:t,doc:Ve(t,E()),updatedAt:new Date().toISOString()}},{onError:e=>L(e)})},ie=(e,t)=>{let n=t?[...w,e]:w.filter(t=>t!==e);te(n),localStorage.setItem(Pt,JSON.stringify(n)),C&&D({},n)},ae=async()=>{b(!0);try{let e=Ee(await Nt(d.trim()),re,{profileSettings:t.data??{},scratchpad:i.data??[]});e.length===0?o.error(`Nothing recognised to import.`):(o.success(`Imported ${e.join(`, `)}.`),f(``))}catch(e){o.error(e.message)}finally{b(!1)}},oe=async()=>{b(!0);try{let e=await Mt(Ve(w,E()));m(e),await navigator.clipboard?.writeText(e),o.success(`Copied to clipboard`)}finally{b(!1)}};return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Sync`}),(0,q.jsx)(`p`,{className:`mb-5 text-xs text-fg-muted`,children:`Carry your settings between machines. Accounts, repositories, and anything host-specific are never included. Applies to this profile.`}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),l.data?.available===!1?(0,q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:`Not available in this cockpit — start the UI with the Puddle CLI to sync across windows.`}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Sync selected groups through this machine’s`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:`~/.puddle`}),`, so every Puddle window stays in step for profiles named`,` `,(0,q.jsx)(`span`,{className:`text-fg-secondary`,children:n?.name??`…`}),`.`]}),(0,q.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,q.jsx)(W,{checked:C,disabled:!n||l.isLoading||u.isPending,onCheckedChange:e=>D({enabled:e},w)}),`Sync locally`]})]})]}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:()=>v(e=>!e),className:`flex items-center gap-1 text-xs text-fg-secondary transition-colors hover:text-fg`,children:[g?(0,q.jsx)(he,{className:`size-3.5`}):(0,q.jsx)(_e,{className:`size-3.5`}),`Choose what to sync`]}),g&&(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(It,{selected:w,onToggle:ie})})]}),(0,q.jsxs)(`div`,{className:`mb-6`,children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,q.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:`Builds a Puddle magic string that encodes settings from the checklist above.`}),(0,q.jsx)(A,{size:`sm`,disabled:y,onClick:()=>void oe(),children:`Export & copy`}),p&&(0,q.jsx)(R,{readOnly:!0,value:p,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`mt-2 resize-y font-mono text-xs`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,q.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste a Puddle magic string to import its settings.`}),(0,q.jsx)(R,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:`Paste a settings export…`,rows:3,spellCheck:!1,className:`resize-y font-mono text-xs`}),(0,q.jsx)(`div`,{className:`mt-2`,children:(0,q.jsx)(A,{size:`sm`,disabled:!d.trim()||y,onClick:()=>void ae(),children:`Import`})})]})]})}function Rt({repo:e}){let t=se(),n=v(),[r,i]=(0,K.useState)(e.default_base_branch),[a,s]=(0,K.useState)(e.onboarding_notes??``),c=e=>L(e);return(0,q.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.path}),(0,q.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,q.jsxs)(A,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>o.success(`Fetched.`),onError:c}),children:[(0,q.jsx)(xe,{}),`Fetch now`]})]}),(0,q.jsxs)(Y,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,q.jsx)(I,{id:`base-${e.id}`,value:r,onChange:e=>i(e.target.value),className:`w-40`}),(0,q.jsx)(A,{size:`sm`,variant:`secondary`,disabled:r===e.default_base_branch||t.isPending,onClick:()=>t.mutate({id:e.id,default_base_branch:r},{onError:c}),children:`Save`})]}),(0,q.jsx)(Y,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,q.jsx)(W,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:c})})}),(0,q.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,q.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,q.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Standing setup rules, injected into every fresh worktree. Agents update them via .puddle/onboarding-notes.md.`})]}),(0,q.jsx)(R,{id:`notes-${e.id}`,value:a,onChange:e=>s(e.target.value),rows:4}),(0,q.jsx)(`div`,{children:(0,q.jsx)(A,{size:`sm`,variant:`secondary`,disabled:a===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:a},{onError:c}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,q.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,q.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Orphan worktrees — directories no session claims. Puddle never deletes these automatically; remove them by hand if unwanted.`}),(0,q.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,q.jsx)(`li`,{className:`truncate text-2xs text-fg-muted`,children:e},e))})]})]})}function zt(){let e=S();return(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{children:`Projects`}),e.data?.length===0&&(0,q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:`No projects yet — create one from the dashboard, pointing at a repository.`}),e.data?.map(e=>(0,q.jsx)(Rt,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=y();return(0,q.jsx)(Y,{label:e,description:t,htmlFor:`host-${n}`,children:(0,q.jsx)(I,{id:`host-${n}`,type:`number`,min:i,step:a,className:`w-32 tabular-nums`,defaultValue:r[n],onBlur:e=>{if(e.target.value.trim()===``){e.target.value=String(r[n]);return}let t=Number(e.target.value);Number.isFinite(t)&&t!==r[n]&&o.mutate({[n]:t},{onError:e=>L(e)})}})})}function Bt(){let e=m(),t=y(),n=l();return e.data?(0,q.jsxs)(`div`,{children:[(0,q.jsx)(X,{note:`Affects all profiles on this host`,children:`Host`}),(0,q.jsx)(Y,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,q.jsx)(I,{id:`host-displayName`,type:`text`,maxLength:64,className:`w-48`,placeholder:n.data?.hostname,defaultValue:e.data.displayName,onBlur:n=>{let r=n.target.value.trim();r!==e.data.displayName&&t.mutate({displayName:r},{onError:e=>L(e)})}})}),(0,q.jsx)($,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,q.jsx)($,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,q.jsx)($,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,q.jsx)($,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,q.jsx)(Y,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,q.jsx)(W,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>L(e)})})})]}):null}var Vt=[{id:`appearance`,label:`Appearance`,icon:Be,render:()=>(0,q.jsx)(nt,{})},{id:`profile`,label:`Profile`,icon:be,render:()=>(0,q.jsx)(at,{})},{id:`accounts`,label:`Accounts`,icon:tt,render:()=>(0,q.jsx)(ct,{})},{id:`sessions`,label:`Sessions`,icon:et,render:()=>(0,q.jsx)(ht,{})},{id:`editor`,label:`Editor`,icon:Ye,render:()=>(0,q.jsx)(bt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Xe,render:()=>(0,q.jsx)(St,{})},{id:`notifications`,label:`Notifications`,icon:Je,render:()=>(0,q.jsx)(yt,{})},{id:`projects`,label:`Projects`,icon:ue,render:()=>(0,q.jsx)(zt,{})},{id:`host`,label:`Host`,icon:Qe,render:()=>(0,q.jsx)(Bt,{})},{id:`sync`,label:`Sync`,icon:xe,render:()=>(0,q.jsx)(Lt,{})}],Ht={terminal:`sessions`,repositories:`projects`};function Ut(){let e=Fe(),t=e===null?null:Ht[e]??e,n=Vt.find(e=>e.id===t)??Vt[0];return(0,q.jsx)(F,{open:e!==null,onOpenChange:e=>!e&&ze(),children:(0,q.jsxs)(M,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,q.jsx)(N,{className:`sr-only`,children:`Settings`}),(0,q.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,q.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),Vt.map(({id:e,label:t,icon:r})=>(0,q.jsxs)(`button`,{onClick:()=>Re(e),className:z(`flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors`,e===n.id?`bg-elevated text-fg`:`text-fg-secondary hover:bg-elevated hover:text-fg`),children:[(0,q.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]}),(0,q.jsx)(`div`,{className:`overflow-y-auto p-5`,children:n.render()})]})})}export{Ut as SettingsDialog};