@puddle-code/cli 0.0.36 → 0.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -7
- package/dist/index.js +1 -1
- package/dist/public/assets/{Dashboard-B20Z3e4d.js → Dashboard-BXCjw9SM.js} +1 -1
- package/dist/public/assets/{EditorTabClose-DwLO7gqj.js → EditorTabClose-gU_gxiLn.js} +1 -1
- package/dist/public/assets/{LazyTerminal-CWtg2h0c.js → LazyTerminal-BChKrpra.js} +2 -2
- package/dist/public/assets/{ModelRefcount-xBAYEiob.js → ModelRefcount-Cae--3IT.js} +1 -1
- package/dist/public/assets/{PaneEditorBody-NRX5kMbo.js → PaneEditorBody-CSQAzyf8.js} +2 -2
- package/dist/public/assets/{SettingsDialog-Bb7zkQqk.js → SettingsDialog-CizksuKu.js} +1 -1
- package/dist/public/assets/{Terminal-RZY06vvA.js → Terminal-qySKxZHB.js} +2 -2
- package/dist/public/assets/Workspace-DJZzcGfM.js +7 -0
- package/dist/public/assets/{buffer-store-CRg63XiZ.js → buffer-store-CqIwU_MW.js} +2 -2
- package/dist/public/assets/{context-menu-8unK33Qy.js → context-menu-BGEpBH2s.js} +1 -1
- package/dist/public/assets/{cssMode-BNyZs5yJ.js → cssMode-DKcijDF9.js} +1 -1
- package/dist/public/assets/{editor-context-CXmEI4YQ.js → editor-context-jm-ULyse.js} +1 -1
- package/dist/public/assets/{editor-sync-DlS3PBFX.js → editor-sync-DkWFcCxD.js} +1 -1
- package/dist/public/assets/{hotkeys-BoAqfYKZ.js → hotkeys-CGVAxX-R.js} +1 -1
- package/dist/public/assets/{htmlMode-BmCd0VVy.js → htmlMode-Bxmdv7NF.js} +1 -1
- package/dist/public/assets/{index-DyI3xhOE.js → index-RBa0vitO.js} +3 -3
- package/dist/public/assets/{jsonMode-DEtsBFfw.js → jsonMode-Bssu2ihU.js} +1 -1
- package/dist/public/assets/{session-seed-CDI_3Kiu.js → session-seed-CyQ88dyB.js} +1 -1
- package/dist/public/assets/ssh-mode-BSPTO2e9.js +1 -0
- package/dist/public/assets/{tsMode-Jjq3o1yN.js → tsMode-BOL7y7DM.js} +1 -1
- package/dist/public/index.html +3 -3
- package/package.json +1 -1
- package/dist/public/assets/Workspace-DxvFcba4.js +0 -7
- package/dist/public/assets/ssh-mode-LZIS09C5.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{B as r,_ as i,c as a,f as o,x as s,y as c}from"./hotkeys-BoAqfYKZ.js";import{D as l,E as u,O as d,S as f,T as p,a as m,b as h,d as g,f as _,g as v,m as y,n as b,o as x,u as S,w as C}from"./editor-context-CXmEI4YQ.js";import{t as ee}from"./preload-helper-Czpn1I53.js";import{t as te}from"./createLucideIcon-DyMAgLa3.js";import{F as w,I as ne,J as re,N as ie,P as ae,X as oe,Y as se,a as ce}from"./index-DyI3xhOE.js";import{i as le,r as ue}from"./editor.api2-4X9Vh9Zw.js";import{a as T,c as de,d as fe,f as pe,i as me,l as he,n as ge,o as _e,r as ve,s as ye,t as E,u as be}from"./buffer-store-CRg63XiZ.js";import{a as xe,c as Se,i as Ce,l as we,n as Te,o as Ee,r as De,s as Oe}from"./editor-sync-DlS3PBFX.js";import{r as ke}from"./buffer-logic-BrpRsL1b.js";var Ae=te(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),D=e(t(),1),O=n();function je({session:e,path:t,conflict:n,model:r,onTakeDisk:i,onKeepMine:a,onSave:o}){let s=oe(),c=(0,D.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),l=(0,D.useRef)(o);l.current=o;let u=(0,D.useRef)(null),d=()=>{let e=u.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),u.current=null},f=(0,D.useRef)(d);return f.current=d,(0,D.useEffect)(()=>()=>f.current(),[]),(0,O.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,O.jsx)(`span`,{children:`This file changed on disk. Yours is on the right — merge what you want, then save.`}),(0,O.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,O.jsx)(`button`,{type:`button`,onClick:a,className:`shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Keep mine`})]}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,O.jsx)(pe,{modifiedModelPath:r.uri.toString(),originalModelPath:`puddle-disk://${encodeURIComponent(e)}/${n.mtimeMs}/${t.split(`/`).map(encodeURIComponent).join(`/`)}`,original:n.content,language:r.getLanguageId(),theme:be,keepCurrentModifiedModel:!0,loading:(0,O.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:e=>{u.current=e,e.onDidDispose(()=>{u.current=null}),e.getModifiedEditor().addCommand(le.CtrlCmd|ue.KeyS,()=>l.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,fontSize:s.editorFontSize,wordWrap:s.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}var Me=new Map,Ne=new Map;function Pe(e){for(let t of Ne.get(e)??[])t()}function Fe(e,t){Me.set(e,t),Pe(e)}function Ie(e){Me.delete(e)&&Pe(e)}function Le(e){return Me.get(e)??null}function Re(e,t){let n=Ne.get(e);return n||(n=new Set,Ne.set(e,n)),n.add(t),()=>n.delete(t)}function ze(e){return!e}function Be(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=le.CtrlCmd:e===`ctrl`?r|=le.WinCtrl:e===`alt`?r|=le.Alt:e===`shift`&&(r|=le.Shift);let i=ue[/^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 Ve(e,t){let n=Be(a(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=Be(a(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>se({editorWordWrap:ze(re().editorWordWrap)})})}function He(e,t,n,i,a){let o=a?.passive===!0,s=E(e,t,i),l=d(e,t,{root:i,live:a?.live}),f=u(e,i),[p,m]=(0,D.useState)(null),[h,g]=(0,D.useState)(!1),_=(0,D.useRef)(!1),b=(0,D.useRef)(null),x=(0,D.useRef)(null),S=(0,D.useRef)(n);S.current=n;let C=(0,D.useRef)(!1),ee=(0,D.useCallback)((e,t)=>{x.current?.cancel(),C.current=!0;try{_e(s,e,t)}finally{C.current=!1}},[s]),te=(0,D.useSyncExternalStore)((0,D.useCallback)(e=>he(s,e),[s]),()=>ve(s)),w=(0,D.useSyncExternalStore)((0,D.useCallback)(e=>Ee(s,e),[s]),()=>xe(s)),ne=(0,D.useSyncExternalStore)((0,D.useCallback)(e=>Re(s,e),[s]),()=>Le(s));(0,D.useEffect)(()=>{let n=l.data;if(!n||n.binary||n.content===null||_.current)return;_.current=!0;let a=de(s)!==void 0,o=ge(e,t,n.content,n.mtime_ms,i);m(o),!a&&we(e,t,i).then(e=>{e&&(e.base_mtime_ms===n.mtime_ms?ke(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:()=>{ke(o,e.content)&&g(!0)}}}))})},[l.data,s,e,t,i]),(0,D.useEffect)(()=>{if(!p||o)return;let n=Se(e,t,i);x.current=n;let r=p.onDidChangeContent(()=>{C.current||(n(p.getValue(),de(s)??0),Te(e,t,i))});return()=>{n.flush(),r.dispose(),x.current=null}},[p,s,e,t,i,o]),(0,D.useEffect)(()=>{!p||!w.savedElsewhere||ve(s)||l.refetch().then(e=>{ve(s)||(e.data&&e.data.content!==null&&ee(e.data.content,e.data.mtime_ms),Ce(s))})},[w.savedElsewhere,p,s]),(0,D.useEffect)(()=>{let e=l.data;!p||!e||e.content===null||!ve(s)&&e.mtime_ms!==de(s)&&ee(e.content,e.mtime_ms)},[l.data,p,s]);let re=(0,D.useCallback)((n,r)=>{me(s,n,r),x.current?.cancel(),Oe(e,t,i),De(e,t,r,i),g(!1),Ie(s)},[s,e,t,i]),ie=(0,D.useCallback)(()=>{l.refetch().then(n=>{n.data&&n.data.content!==null&&ee(n.data.content,n.data.mtime_ms),Oe(e,t,i),g(!1),Ie(s)})},[s,e,t,ee]),ae=(0,D.useCallback)((e,n)=>{f.mutate({path:t,content:e},{onSuccess:e=>re(n,e.mtime_ms),onError:e=>r.error(e instanceof Error?e.message:`Overwrite failed`)})},[f,t,re]),oe=(0,D.useCallback)(()=>{if(!p||!ve(s))return;let e=p.getValue(),n=p.getAlternativeVersionId(),i=Le(s)?.mtimeMs??de(s);f.mutate({path:t,content:e,expected_mtime_ms:i},{onSuccess:e=>re(n,e.mtime_ms),onError:t=>{t instanceof c&&t.status===409&&t.code===`stale_file`?(l.refetch().then(e=>{e.data&&e.data.content!==null&&Fe(s,{content:e.data.content,mtimeMs:e.data.mtime_ms})}),r.error(`File changed on disk (probably the agent)`,{description:`Nothing was written — your unsaved version is intact.`,duration:1/0,action:{label:`Reload`,onClick:()=>ie()},cancel:{label:`Overwrite`,onClick:()=>ae(e,n)}})):r.error(t instanceof Error?t.message:`Save failed`)}})},[p,s,f,t,re,ie,ae]),se=(0,D.useRef)(oe);se.current=oe,(0,D.useEffect)(()=>y(v(e,t,i),()=>se.current()),[e,t,i]);let ce=(0,D.useCallback)(()=>{let n=b.current,r=S.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]),le=(0,D.useCallback)(e=>{b.current=e,Ve(e,{onSave:()=>se.current()}),ce()},[ce]);(0,D.useEffect)(()=>{ce()},[n,p,ce]);let ue=(0,D.useCallback)(()=>{ie()},[ie]),T=(0,D.useCallback)(()=>{p&&ae(p.getValue(),p.getAlternativeVersionId())},[p,ae]),fe,pe=null;l.data?.binary?fe=`binary`:l.error?l.error instanceof c&&l.error.status===413?fe=`too-large`:(fe=`error`,pe=l.error instanceof Error?l.error.message:`Failed to load file`):fe=p?`ready`:`loading`;let ye=te&&w.savedElsewhere?`saved-elsewhere`:te&&w.dirtyElsewhere?`dirty-elsewhere`:null;return{status:fe,errorMessage:pe,model:p,dirty:te,restoredNotice:h,discardRestore:ue,peerBadge:ye,conflict:ne,takeDisk:ie,keepMine:T,save:oe,onMount:le}}function Ue({message:e,session:t,path:n,root:i,download:a}){return(0,O.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,O.jsx)(`span`,{children:e}),a&&(0,O.jsxs)(`button`,{type:`button`,onClick:()=>void h(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,O.jsx)(Ae,{className:`size-4`}),`Download`]})]})}function We({session:e,path:t,reveal:n,root:r}){let i=oe(),a=He(e,t,n,r),o=(0,D.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(a.status===`binary`)return(0,O.jsx)(Ue,{message:`Binary file — use Download`,session:e,path:t,root:r,download:!0});if(a.status===`too-large`)return(0,O.jsx)(Ue,{message:`File too large to edit — use Download`,session:e,path:t,root:r,download:!0});if(a.status===`error`)return(0,O.jsx)(Ue,{message:a.errorMessage??`Failed to load file`,session:e,path:t,root:r});if(a.conflict&&a.model)return(0,O.jsx)(je,{session:e,path:t,conflict:a.conflict,model:a.model,onTakeDisk:a.takeDisk,onKeepMine:a.keepMine,onSave:a.save});let s=a.peerBadge===`saved-elsewhere`?`Saved in another window`:a.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,O.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[a.restoredNotice&&(0,O.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,O.jsx)(`span`,{children:`Restored unsaved changes`}),(0,O.jsx)(`button`,{type:`button`,onClick:a.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),s&&(0,O.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:s}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1`,children:a.model&&(0,O.jsx)(fe,{path:a.model.uri.toString(),defaultValue:a.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>a.onMount(e),loading:(0,O.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:o,fontSize:i.editorFontSize,tabSize:i.editorTabSize,wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function k({children:e}){return(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function Ge(e,t){let n=(0,D.useRef)(t);n.current=t,(0,D.useEffect)(()=>(ye(e),()=>{n.current?.(),T(e)}),[e])}function Ke(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function qe({session:e,refName:t,path:n,content:r}){let i=oe(),a=(0,D.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,O.jsx)(fe,{path:Ke(`puddle-view`,e,t,n),defaultValue:r,theme:be,loading:(0,O.jsx)(k,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:a,fontSize:i.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Je({session:e,against:t,path:n,root:r}){let i=p(e,t,n,{root:r});return i.isPending?(0,O.jsx)(k,{children:`…`}):i.error?(0,O.jsx)(k,{children:i.error instanceof Error?i.error.message:`Failed to load`}):i.data.binary?(0,O.jsx)(k,{children:`Binary file — deleted`}):(0,O.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,O.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,O.jsx)(qe,{session:e,refName:t,path:n,content:i.data.content??``})})]})}function Ye({session:e,against:t,path:n,basePath:r,root:i}){let a=oe(),o=He(e,n,null,i),s=p(e,t,r,{root:i}),l=(0,D.useRef)(null);Ge(E(e,n),()=>{let e=l.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),l.current=null});let u=(0,D.useRef)(o.save);u.current=o.save;let d=(0,D.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),f=s.error instanceof c&&s.error.status===404;return o.status===`binary`||s.data?.binary?(0,O.jsx)(k,{children:`Binary file`}):o.status===`too-large`?(0,O.jsx)(k,{children:`File too large to show`}):o.status===`error`?(0,O.jsx)(k,{children:o.errorMessage??`Failed to load file`}):f?(0,O.jsx)(We,{session:e,path:n,reveal:null}):s.isPending||!o.model?(0,O.jsx)(k,{children:`…`}):s.error?(0,O.jsx)(k,{children:s.error instanceof Error?s.error.message:`Failed to load base`}):(0,O.jsx)(pe,{modifiedModelPath:o.model.uri.toString(),originalModelPath:Ke(`puddle-base`,e,t,r),original:s.data.content??``,language:o.model.getLanguageId(),theme:be,keepCurrentModifiedModel:!0,loading:(0,O.jsx)(k,{children:`…`}),onMount:e=>{l.current=e,e.onDidDispose(()=>{l.current=null}),e.getModifiedEditor().addCommand(le.CtrlCmd|ue.KeyS,()=>u.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:d,fontSize:a.editorFontSize,wordWrap:a.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Xe({session:e,path:t,root:n}){return Ge(E(e,t,n)),(0,O.jsx)(We,{session:e,path:t,reveal:null,root:n})}function Ze({session:e,against:t,entry:n,root:r}){switch(n.status){case`added`:return(0,O.jsx)(Xe,{session:e,path:n.path,root:r});case`deleted`:return(0,O.jsx)(Je,{session:e,against:t,path:n.path,root:r});case`modified`:case`renamed`:return(0,O.jsx)(Ye,{session:e,against:t,path:n.path,basePath:n.old_path??n.path,root:r});default:return null}}function Qe({session:e,sha:t,path:n}){let r=p(e,t,n);return r.isPending?(0,O.jsx)(k,{children:`…`}):r.error?(0,O.jsx)(k,{children:r.error instanceof Error?r.error.message:`Failed to load file`}):r.data.binary?(0,O.jsx)(k,{children:`Binary file`}):(0,O.jsx)(qe,{session:e,refName:t,path:n,content:r.data.content??``})}function $e({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o}){let s=oe(),c=(0,D.useRef)(null),l=(0,D.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,D.useEffect)(()=>()=>{let e=c.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),t?.modified.dispose(),c.current=null},[]),(0,O.jsx)(pe,{originalModelPath:Ke(`puddle-hist-orig`,e,t,n),modifiedModelPath:Ke(`puddle-hist-mod`,e,i,a),original:r,modified:o,theme:be,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,O.jsx)(k,{children:`…`}),onMount:e=>{c.current=e,e.onDidDispose(()=>{c.current=null})},options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:l,fontSize:s.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function et({session:e,sha:t,path:n,basePath:r}){let i=p(e,`${t}^`,r),a=p(e,t,n);return i.error instanceof c&&i.error.status===404?(0,O.jsx)(Qe,{session:e,sha:t,path:n}):i.isPending||a.isPending?(0,O.jsx)(k,{children:`…`}):i.error?(0,O.jsx)(k,{children:i.error instanceof Error?i.error.message:`Failed to load original`}):a.error?(0,O.jsx)(k,{children:a.error instanceof Error?a.error.message:`Failed to load file`}):i.data.binary||a.data.binary?(0,O.jsx)(k,{children:`Binary file`}):(0,O.jsx)($e,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:i.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:a.data.content??``})}function tt({session:e,sha:t,entry:n,isRootCommit:r}){switch(_(n.status,r)){case`added`:return(0,O.jsx)(Qe,{session:e,sha:t,path:n.path});case`deleted`:return(0,O.jsx)(Je,{session:e,against:`${t}^`,path:n.path});case`modified`:case`renamed`:return(0,O.jsx)(et,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function nt({session:e,sha:t,path:n,root:r}){let i=C(e,t,r);if(i.isPending)return(0,O.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(i.error)return(0,O.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,O.jsx)(`div`,{className:`h-full`,children:(0,O.jsx)(tt,{session:e,sha:t,entry:a,isRootCommit:i.data.parents.length===0})}):(0,O.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,O.jsx)(`span`,{className:`text-fg-secondary`,children:n}),` is not part of`,` `,(0,O.jsx)(`span`,{className:`font-mono`,children:t.slice(0,7)}),`.`]})}function rt({session:e,path:t,root:n}){let r=l(e,{root:n});if(r.isPending)return(0,O.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(r.error)return(0,O.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load diff`});let i=r.data.entries.find(e=>e.path===t);return i?(0,O.jsx)(`div`,{className:`h-full`,children:(0,O.jsx)(Ze,{session:e,against:r.data.against,entry:i,root:n})}):(0,O.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,O.jsx)(`span`,{className:`mx-1 text-fg-secondary`,children:t}),` against the base.`]})}var it=800;function at({name:e}){let t=oe(),n=i(),a=g(n,e),s=o(`editor.save`),c=(0,D.useRef)(null),l=(0,D.useRef)(null),u=(0,D.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if((0,D.useEffect)(()=>{if(n===null)return;let t=ce(t=>{S(n,e,t).catch(e=>r.error(e instanceof Error?e.message:`Draft not saved`))},it);return l.current=t,()=>{t.flush(),l.current=null}},[n,e]),n===null)return null;if(a.error)return(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:a.error instanceof Error?a.error.message:`Failed to load the draft`});if(a.data===void 0)return(0,O.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`});let d=()=>{let t=c.current;t&&(l.current?.flush(),x({name:e,content:t.getValue()}))};return(0,O.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,O.jsxs)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:[`Draft — not in any worktree; `,s,` saves it into one`]}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,O.jsx)(fe,{path:`puddle-untitled://${n}/${e}`,defaultValue:a.data.content,theme:be,keepCurrentModel:!1,loading:(0,O.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:t=>{c.current=t,m(e,t.getValue()),Ve(t,{onSave:d})},onChange:t=>{let n=t??``;m(e,n),l.current?.(n)},options:{automaticLayout:!0,fontFamily:u,fontSize:t.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function ot(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 st(e){if(Array.isArray(e))return e}function ct(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 lt(){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{B as r,_ as i,c as a,f as o,x as s,y as c}from"./hotkeys-CGVAxX-R.js";import{C as l,D as u,E as d,O as f,T as p,_ as m,a as h,d as g,f as _,h as v,k as y,n as b,o as x,p as S,x as C}from"./editor-context-jm-ULyse.js";import{t as ee}from"./preload-helper-Czpn1I53.js";import{t as te}from"./createLucideIcon-DyMAgLa3.js";import{F as w,I as ne,J as re,N as ie,P as ae,X as oe,Y as se,a as ce}from"./index-RBa0vitO.js";import{i as le,r as ue}from"./editor.api2-4X9Vh9Zw.js";import{a as T,c as de,d as fe,f as pe,i as me,l as he,n as ge,o as _e,r as ve,s as ye,t as E,u as be}from"./buffer-store-CqIwU_MW.js";import{a as xe,c as Se,i as Ce,l as we,n as Te,o as Ee,r as De,s as Oe}from"./editor-sync-DkWFcCxD.js";import{r as ke}from"./buffer-logic-BrpRsL1b.js";var Ae=te(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]),D=e(t(),1),O=n();function je({session:e,path:t,conflict:n,model:r,onTakeDisk:i,onKeepMine:a,onSave:o}){let s=oe(),c=(0,D.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),l=(0,D.useRef)(o);l.current=o;let u=(0,D.useRef)(null),d=()=>{let e=u.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),u.current=null},f=(0,D.useRef)(d);return f.current=d,(0,D.useEffect)(()=>()=>f.current(),[]),(0,O.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,O.jsx)(`span`,{children:`This file changed on disk. Yours is on the right — merge what you want, then save.`}),(0,O.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,O.jsx)(`button`,{type:`button`,onClick:a,className:`shrink-0 text-fg-muted transition-colors hover:text-fg`,children:`Keep mine`})]}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,O.jsx)(pe,{modifiedModelPath:r.uri.toString(),originalModelPath:`puddle-disk://${encodeURIComponent(e)}/${n.mtimeMs}/${t.split(`/`).map(encodeURIComponent).join(`/`)}`,original:n.content,language:r.getLanguageId(),theme:be,keepCurrentModifiedModel:!0,loading:(0,O.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:e=>{u.current=e,e.onDidDispose(()=>{u.current=null}),e.getModifiedEditor().addCommand(le.CtrlCmd|ue.KeyS,()=>l.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:c,fontSize:s.editorFontSize,wordWrap:s.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}var Me=new Map,Ne=new Map;function Pe(e){for(let t of Ne.get(e)??[])t()}function Fe(e,t){Me.set(e,t),Pe(e)}function Ie(e){Me.delete(e)&&Pe(e)}function Le(e){return Me.get(e)??null}function Re(e,t){let n=Ne.get(e);return n||(n=new Set,Ne.set(e,n)),n.add(t),()=>n.delete(t)}function ze(e){return!e}function Be(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=le.CtrlCmd:e===`ctrl`?r|=le.WinCtrl:e===`alt`?r|=le.Alt:e===`shift`&&(r|=le.Shift);let i=ue[/^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 Ve(e,t){let n=Be(a(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=Be(a(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>se({editorWordWrap:ze(re().editorWordWrap)})})}function He(e,t,n,i,a){let o=a?.passive===!0,s=E(e,t,i),l=y(e,t,{root:i,live:a?.live}),d=u(e,i),[f,p]=(0,D.useState)(null),[h,g]=(0,D.useState)(!1),_=(0,D.useRef)(!1),b=(0,D.useRef)(null),x=(0,D.useRef)(null),S=(0,D.useRef)(n);S.current=n;let C=(0,D.useRef)(!1),ee=(0,D.useCallback)((e,t)=>{x.current?.cancel(),C.current=!0;try{_e(s,e,t)}finally{C.current=!1}},[s]),te=(0,D.useSyncExternalStore)((0,D.useCallback)(e=>he(s,e),[s]),()=>ve(s)),w=(0,D.useSyncExternalStore)((0,D.useCallback)(e=>Ee(s,e),[s]),()=>xe(s)),ne=(0,D.useSyncExternalStore)((0,D.useCallback)(e=>Re(s,e),[s]),()=>Le(s));(0,D.useEffect)(()=>{let n=l.data;if(!n||n.binary||n.content===null||_.current)return;_.current=!0;let a=de(s)!==void 0,o=ge(e,t,n.content,n.mtime_ms,i);p(o),!a&&we(e,t,i).then(e=>{e&&(e.base_mtime_ms===n.mtime_ms?ke(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:()=>{ke(o,e.content)&&g(!0)}}}))})},[l.data,s,e,t,i]),(0,D.useEffect)(()=>{if(!f||o)return;let n=Se(e,t,i);x.current=n;let r=f.onDidChangeContent(()=>{C.current||(n(f.getValue(),de(s)??0),Te(e,t,i))});return()=>{n.flush(),r.dispose(),x.current=null}},[f,s,e,t,i,o]),(0,D.useEffect)(()=>{!f||!w.savedElsewhere||ve(s)||l.refetch().then(e=>{ve(s)||(e.data&&e.data.content!==null&&ee(e.data.content,e.data.mtime_ms),Ce(s))})},[w.savedElsewhere,f,s]),(0,D.useEffect)(()=>{let e=l.data;!f||!e||e.content===null||!ve(s)&&e.mtime_ms!==de(s)&&ee(e.content,e.mtime_ms)},[l.data,f,s]);let re=(0,D.useCallback)((n,r)=>{me(s,n,r),x.current?.cancel(),Oe(e,t,i),De(e,t,r,i),g(!1),Ie(s)},[s,e,t,i]),ie=(0,D.useCallback)(()=>{l.refetch().then(n=>{n.data&&n.data.content!==null&&ee(n.data.content,n.data.mtime_ms),Oe(e,t,i),g(!1),Ie(s)})},[s,e,t,ee]),ae=(0,D.useCallback)((e,n)=>{d.mutate({path:t,content:e},{onSuccess:e=>re(n,e.mtime_ms),onError:e=>r.error(e instanceof Error?e.message:`Overwrite failed`)})},[d,t,re]),oe=(0,D.useCallback)(()=>{if(!f||!ve(s))return;let e=f.getValue(),n=f.getAlternativeVersionId(),i=Le(s)?.mtimeMs??de(s);d.mutate({path:t,content:e,expected_mtime_ms:i},{onSuccess:e=>re(n,e.mtime_ms),onError:t=>{t instanceof c&&t.status===409&&t.code===`stale_file`?(l.refetch().then(e=>{e.data&&e.data.content!==null&&Fe(s,{content:e.data.content,mtimeMs:e.data.mtime_ms})}),r.error(`File changed on disk (probably the agent)`,{description:`Nothing was written — your unsaved version is intact.`,duration:1/0,action:{label:`Reload`,onClick:()=>ie()},cancel:{label:`Overwrite`,onClick:()=>ae(e,n)}})):r.error(t instanceof Error?t.message:`Save failed`)}})},[f,s,d,t,re,ie,ae]),se=(0,D.useRef)(oe);se.current=oe,(0,D.useEffect)(()=>v(m(e,t,i),()=>se.current()),[e,t,i]);let ce=(0,D.useCallback)(()=>{let n=b.current,r=S.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]),le=(0,D.useCallback)(e=>{b.current=e,Ve(e,{onSave:()=>se.current()}),ce()},[ce]);(0,D.useEffect)(()=>{ce()},[n,f,ce]);let ue=(0,D.useCallback)(()=>{ie()},[ie]),T=(0,D.useCallback)(()=>{f&&ae(f.getValue(),f.getAlternativeVersionId())},[f,ae]),fe,pe=null;l.data?.binary?fe=`binary`:l.error?l.error instanceof c&&l.error.status===413?fe=`too-large`:(fe=`error`,pe=l.error instanceof Error?l.error.message:`Failed to load file`):fe=f?`ready`:`loading`;let ye=te&&w.savedElsewhere?`saved-elsewhere`:te&&w.dirtyElsewhere?`dirty-elsewhere`:null;return{status:fe,errorMessage:pe,model:f,dirty:te,restoredNotice:h,discardRestore:ue,peerBadge:ye,conflict:ne,takeDisk:ie,keepMine:T,save:oe,onMount:le}}function Ue({message:e,session:t,path:n,root:i,download:a}){return(0,O.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,O.jsx)(`span`,{children:e}),a&&(0,O.jsxs)(`button`,{type:`button`,onClick:()=>void C(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,O.jsx)(Ae,{className:`size-4`}),`Download`]})]})}function We({session:e,path:t,reveal:n,root:r}){let i=oe(),a=He(e,t,n,r),o=(0,D.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(a.status===`binary`)return(0,O.jsx)(Ue,{message:`Binary file — use Download`,session:e,path:t,root:r,download:!0});if(a.status===`too-large`)return(0,O.jsx)(Ue,{message:`File too large to edit — use Download`,session:e,path:t,root:r,download:!0});if(a.status===`error`)return(0,O.jsx)(Ue,{message:a.errorMessage??`Failed to load file`,session:e,path:t,root:r});if(a.conflict&&a.model)return(0,O.jsx)(je,{session:e,path:t,conflict:a.conflict,model:a.model,onTakeDisk:a.takeDisk,onKeepMine:a.keepMine,onSave:a.save});let s=a.peerBadge===`saved-elsewhere`?`Saved in another window`:a.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,O.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[a.restoredNotice&&(0,O.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,O.jsx)(`span`,{children:`Restored unsaved changes`}),(0,O.jsx)(`button`,{type:`button`,onClick:a.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),s&&(0,O.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:s}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1`,children:a.model&&(0,O.jsx)(fe,{path:a.model.uri.toString(),defaultValue:a.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>a.onMount(e),loading:(0,O.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),options:{automaticLayout:!0,fontFamily:o,fontSize:i.editorFontSize,tabSize:i.editorTabSize,wordWrap:i.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function k({children:e}){return(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function Ge(e,t){let n=(0,D.useRef)(t);n.current=t,(0,D.useEffect)(()=>(ye(e),()=>{n.current?.(),T(e)}),[e])}function Ke(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function qe({session:e,refName:t,path:n,content:r}){let i=oe(),a=(0,D.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,O.jsx)(fe,{path:Ke(`puddle-view`,e,t,n),defaultValue:r,theme:be,loading:(0,O.jsx)(k,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:a,fontSize:i.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Je({session:e,against:t,path:n,root:r}){let i=d(e,t,n,{root:r});return i.isPending?(0,O.jsx)(k,{children:`…`}):i.error?(0,O.jsx)(k,{children:i.error instanceof Error?i.error.message:`Failed to load`}):i.data.binary?(0,O.jsx)(k,{children:`Binary file — deleted`}):(0,O.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,O.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,O.jsx)(qe,{session:e,refName:t,path:n,content:i.data.content??``})})]})}function Ye({session:e,against:t,path:n,basePath:r,root:i}){let a=oe(),o=He(e,n,null,i),s=d(e,t,r,{root:i}),l=(0,D.useRef)(null);Ge(E(e,n),()=>{let e=l.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),l.current=null});let u=(0,D.useRef)(o.save);u.current=o.save;let f=(0,D.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),p=s.error instanceof c&&s.error.status===404;return o.status===`binary`||s.data?.binary?(0,O.jsx)(k,{children:`Binary file`}):o.status===`too-large`?(0,O.jsx)(k,{children:`File too large to show`}):o.status===`error`?(0,O.jsx)(k,{children:o.errorMessage??`Failed to load file`}):p?(0,O.jsx)(We,{session:e,path:n,reveal:null}):s.isPending||!o.model?(0,O.jsx)(k,{children:`…`}):s.error?(0,O.jsx)(k,{children:s.error instanceof Error?s.error.message:`Failed to load base`}):(0,O.jsx)(pe,{modifiedModelPath:o.model.uri.toString(),originalModelPath:Ke(`puddle-base`,e,t,r),original:s.data.content??``,language:o.model.getLanguageId(),theme:be,keepCurrentModifiedModel:!0,loading:(0,O.jsx)(k,{children:`…`}),onMount:e=>{l.current=e,e.onDidDispose(()=>{l.current=null}),e.getModifiedEditor().addCommand(le.CtrlCmd|ue.KeyS,()=>u.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:f,fontSize:a.editorFontSize,wordWrap:a.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Xe({session:e,path:t,root:n}){return Ge(E(e,t,n)),(0,O.jsx)(We,{session:e,path:t,reveal:null,root:n})}function Ze({session:e,against:t,entry:n,root:r}){switch(n.status){case`added`:return(0,O.jsx)(Xe,{session:e,path:n.path,root:r});case`deleted`:return(0,O.jsx)(Je,{session:e,against:t,path:n.path,root:r});case`modified`:case`renamed`:return(0,O.jsx)(Ye,{session:e,against:t,path:n.path,basePath:n.old_path??n.path,root:r});default:return null}}function Qe({session:e,sha:t,path:n}){let r=d(e,t,n);return r.isPending?(0,O.jsx)(k,{children:`…`}):r.error?(0,O.jsx)(k,{children:r.error instanceof Error?r.error.message:`Failed to load file`}):r.data.binary?(0,O.jsx)(k,{children:`Binary file`}):(0,O.jsx)(qe,{session:e,refName:t,path:n,content:r.data.content??``})}function $e({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o}){let s=oe(),c=(0,D.useRef)(null),l=(0,D.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,D.useEffect)(()=>()=>{let e=c.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),t?.modified.dispose(),c.current=null},[]),(0,O.jsx)(pe,{originalModelPath:Ke(`puddle-hist-orig`,e,t,n),modifiedModelPath:Ke(`puddle-hist-mod`,e,i,a),original:r,modified:o,theme:be,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,O.jsx)(k,{children:`…`}),onMount:e=>{c.current=e,e.onDidDispose(()=>{c.current=null})},options:{readOnly:!0,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:l,fontSize:s.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function et({session:e,sha:t,path:n,basePath:r}){let i=d(e,`${t}^`,r),a=d(e,t,n);return i.error instanceof c&&i.error.status===404?(0,O.jsx)(Qe,{session:e,sha:t,path:n}):i.isPending||a.isPending?(0,O.jsx)(k,{children:`…`}):i.error?(0,O.jsx)(k,{children:i.error instanceof Error?i.error.message:`Failed to load original`}):a.error?(0,O.jsx)(k,{children:a.error instanceof Error?a.error.message:`Failed to load file`}):i.data.binary||a.data.binary?(0,O.jsx)(k,{children:`Binary file`}):(0,O.jsx)($e,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:i.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:a.data.content??``})}function tt({session:e,sha:t,entry:n,isRootCommit:r}){switch(S(n.status,r)){case`added`:return(0,O.jsx)(Qe,{session:e,sha:t,path:n.path});case`deleted`:return(0,O.jsx)(Je,{session:e,against:`${t}^`,path:n.path});case`modified`:case`renamed`:return(0,O.jsx)(et,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function nt({session:e,sha:t,path:n,root:r}){let i=p(e,t,r);if(i.isPending)return(0,O.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(i.error)return(0,O.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,O.jsx)(`div`,{className:`h-full`,children:(0,O.jsx)(tt,{session:e,sha:t,entry:a,isRootCommit:i.data.parents.length===0})}):(0,O.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,O.jsx)(`span`,{className:`text-fg-secondary`,children:n}),` is not part of`,` `,(0,O.jsx)(`span`,{className:`font-mono`,children:t.slice(0,7)}),`.`]})}function rt({session:e,path:t,root:n}){let r=f(e,{root:n});if(r.isPending)return(0,O.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(r.error)return(0,O.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load diff`});let i=r.data.entries.find(e=>e.path===t);return i?(0,O.jsx)(`div`,{className:`h-full`,children:(0,O.jsx)(Ze,{session:e,against:r.data.against,entry:i,root:n})}):(0,O.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,O.jsx)(`span`,{className:`mx-1 text-fg-secondary`,children:t}),` against the base.`]})}var it=800;function at({name:e}){let t=oe(),n=i(),a=_(n,e),s=o(`editor.save`),c=(0,D.useRef)(null),l=(0,D.useRef)(null),u=(0,D.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if((0,D.useEffect)(()=>{if(n===null)return;let t=ce(t=>{g(n,e,t).catch(e=>r.error(e instanceof Error?e.message:`Draft not saved`))},it);return l.current=t,()=>{t.flush(),l.current=null}},[n,e]),n===null)return null;if(a.error)return(0,O.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:a.error instanceof Error?a.error.message:`Failed to load the draft`});if(a.data===void 0)return(0,O.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`});let d=()=>{let t=c.current;t&&(l.current?.flush(),x({name:e,content:t.getValue()}))};return(0,O.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,O.jsxs)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:[`Draft — not in any worktree; `,s,` saves it into one`]}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,O.jsx)(fe,{path:`puddle-untitled://${n}/${e}`,defaultValue:a.data.content,theme:be,keepCurrentModel:!1,loading:(0,O.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:t=>{c.current=t,h(e,t.getValue()),Ve(t,{onSave:d})},onChange:t=>{let n=t??``;h(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 ot(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 st(e){if(Array.isArray(e))return e}function ct(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 lt(){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 ut(e,t){return st(e)||ct(e,t)||dt(e,t)||lt()}function dt(e,t){if(e){if(typeof e==`string`)return ot(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)?ot(e,t):void 0}}var ft=Object.entries,pt=Object.setPrototypeOf,mt=Object.isFrozen,ht=Object.getPrototypeOf,gt=Object.getOwnPropertyDescriptor,_t=Object.freeze,vt=Object.seal,yt=Object.create,bt=typeof Reflect<`u`&&Reflect,xt=bt.apply,St=bt.construct;_t||=function(e){return e},vt||=function(e){return e},xt||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},St||=function(e){return new e(...[...arguments].slice(1))};var Ct=Ut(Array.prototype.forEach),wt=Ut(Array.prototype.lastIndexOf),Tt=Ut(Array.prototype.pop),Et=Ut(Array.prototype.push),Dt=Ut(Array.prototype.splice),Ot=Array.isArray,kt=Ut(String.prototype.toLowerCase),At=Ut(String.prototype.toString),jt=Ut(String.prototype.match),Mt=Ut(String.prototype.replace),Nt=Ut(String.prototype.indexOf),Pt=Ut(String.prototype.trim),Ft=Ut(Number.prototype.toString),It=Ut(Boolean.prototype.toString),Lt=typeof BigInt>`u`?null:Ut(BigInt.prototype.toString),Rt=typeof Symbol>`u`?null:Ut(Symbol.prototype.toString),zt=Ut(Object.prototype.hasOwnProperty),Bt=Ut(Object.prototype.toString),Vt=Ut(RegExp.prototype.test),Ht=Wt(TypeError);function Ut(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return xt(e,t,n)}}function Wt(e){return function(){return St(e,[...arguments])}}function A(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:kt;if(pt&&pt(e,null),!Ot(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(mt(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Gt(e){for(let t=0;t<e.length;t++)zt(e,t)||(e[t]=null);return e}function Kt(e){let t=yt(null);for(let r of ft(e)){var n=ut(r,2);let i=n[0],a=n[1];zt(e,i)&&(Ot(a)?t[i]=Gt(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=Kt(a):t[i]=a)}return t}function qt(e){switch(typeof e){case`string`:return e;case`number`:return Ft(e);case`boolean`:return It(e);case`bigint`:return Lt?Lt(e):`0`;case`symbol`:return Rt?Rt(e):`Symbol()`;case`undefined`:return Bt(e);case`function`:case`object`:{if(e===null)return Bt(e);let t=e,n=Jt(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Bt(e)}return Bt(e)}default:return Bt(e)}}function Jt(e,t){for(;e!==null;){let n=gt(e,t);if(n){if(n.get)return Ut(n.get);if(typeof n.value==`function`)return Ut(n.value)}e=ht(e)}function n(){return null}return n}function Yt(e){try{return Vt(e,``),!0}catch{return!1}}var Xt=_t(`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(`.`)),Zt=_t(`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(`.`)),Qt=_t([`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`]),$t=_t([`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`]),en=_t(`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(`.`)),tn=_t([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),nn=_t([`#text`]),rn=_t(`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(`.`)),an=_t(`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(`.`)),on=_t(`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(`.`)),sn=_t([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),cn=vt(/{{[\w\W]*|^[\w\W]*}}/g),ln=vt(/<%[\w\W]*|^[\w\W]*%>/g),un=vt(/\${[\w\W]*/g),dn=vt(/^data-[\-\w.\u00B7-\uFFFF]+$/),fn=vt(/^aria-[\-\w]+$/),pn=vt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),mn=vt(/^(?:\w+script|data):/i),hn=vt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),gn=vt(/^html$/i),_n=vt(/^[a-z][.\w]*(-[.\w]+)+$/i),vn=vt(/<[/\w!]/g),yn=vt(/<[/\w]/g),bn=vt(/<\/no(script|embed|frames)/i),xn=vt(/\/>/i),Sn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Cn=function(){return typeof window>`u`?null:window},wn=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}},Tn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},En=function(e,t,n,r){return zt(e,t)&&Ot(e[t])?A(r.base?Kt(r.base):{},e[t],r.transform):n};function Dn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Cn(),t=e=>Dn(e);if(t.version=`3.4.12`,t.removed=[],!e||!e.document||e.document.nodeType!==Sn.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=Jt(d,`cloneNode`),p=Jt(d,`remove`),m=Jt(d,`nextSibling`),h=Jt(d,`childNodes`),g=Jt(d,`parentNode`),_=Jt(d,`shadowRoot`),v=Jt(d,`attributes`),y=o&&o.prototype?Jt(o.prototype,`nodeType`):null,b=o&&o.prototype?Jt(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,w=function(){if(te>0)throw Ht(`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.`)},ne=function(e){w(),te++;try{return x.createHTML(e)}finally{te--}},re=function(e){w(),te++;try{return x.createScriptURL(e)}finally{te--}},ie=function(){return ee||=(C=wn(u,i),!0),C},ae=n,oe=ae.implementation,se=ae.createNodeIterator,ce=ae.createDocumentFragment,le=ae.getElementsByTagName,ue=r.importNode,T=Tn();t.isSupported=typeof ft==`function`&&typeof g==`function`&&oe&&oe.createHTMLDocument!==void 0;let de=cn,fe=ln,pe=un,me=dn,he=fn,ge=mn,_e=hn,ve=_n,ye=pn,E=null,be=A({},[...Xt,...Zt,...Qt,...en,...nn]),xe=null,Se=A({},[...rn,...an,...on,...sn]),Ce=Object.seal(yt(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}})),we=null,Te=null,Ee=Object.seal(yt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),De=!0,Oe=!0,ke=!1,Ae=!0,D=!1,O=!0,je=!1,Me=!1,Ne=null,Pe=null,Fe=!1,Ie=!1,Le=!1,Re=!1,ze=!0,Be=!1,Ve=`user-content-`,He=!0,Ue=!1,We={},k=null,Ge=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(`.`)),Ke=null,qe=A({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Je=null,Ye=A({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Xe=`http://www.w3.org/1998/Math/MathML`,Ze=`http://www.w3.org/2000/svg`,Qe=`http://www.w3.org/1999/xhtml`,$e=Qe,et=!1,tt=null,nt=A({},[Xe,Ze,Qe],At),rt=_t([`mi`,`mo`,`mn`,`ms`,`mtext`]),it=A({},rt),at=_t([`annotation-xml`]),ot=A({},at),st=A({},[`title`,`style`,`font`,`a`,`script`]),ct=null,lt=[`application/xhtml+xml`,`text/html`],ut=null,dt=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(dt&&dt===e)return;(!e||typeof e!=`object`)&&(e={}),e=Kt(e),ct=lt.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,ut=ct===`application/xhtml+xml`?At:kt,E=En(e,`ALLOWED_TAGS`,be,{transform:ut}),xe=En(e,`ALLOWED_ATTR`,Se,{transform:ut}),tt=En(e,`ALLOWED_NAMESPACES`,nt,{transform:At}),Je=En(e,`ADD_URI_SAFE_ATTR`,Ye,{transform:ut,base:Ye}),Ke=En(e,`ADD_DATA_URI_TAGS`,qe,{transform:ut,base:qe}),k=En(e,`FORBID_CONTENTS`,Ge,{transform:ut}),we=En(e,`FORBID_TAGS`,Kt({}),{transform:ut}),Te=En(e,`FORBID_ATTR`,Kt({}),{transform:ut}),We=zt(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Kt(e.USE_PROFILES):e.USE_PROFILES:!1,De=e.ALLOW_ARIA_ATTR!==!1,Oe=e.ALLOW_DATA_ATTR!==!1,ke=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ae=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,D=e.SAFE_FOR_TEMPLATES||!1,O=e.SAFE_FOR_XML!==!1,je=e.WHOLE_DOCUMENT||!1,Ie=e.RETURN_DOM||!1,Le=e.RETURN_DOM_FRAGMENT||!1,Re=e.RETURN_TRUSTED_TYPE||!1,Fe=e.FORCE_BODY||!1,ze=e.SANITIZE_DOM!==!1,Be=e.SANITIZE_NAMED_PROPS||!1,He=e.KEEP_CONTENT!==!1,Ue=e.IN_PLACE||!1,ye=Yt(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:pn,$e=typeof e.NAMESPACE==`string`?e.NAMESPACE:Qe,it=zt(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?Kt(e.MATHML_TEXT_INTEGRATION_POINTS):A({},rt),ot=zt(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?Kt(e.HTML_INTEGRATION_POINTS):A({},at);let t=zt(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?Kt(e.CUSTOM_ELEMENT_HANDLING):yt(null);if(Ce=yt(null),zt(t,`tagNameCheck`)&&mt(t.tagNameCheck)&&(Ce.tagNameCheck=t.tagNameCheck),zt(t,`attributeNameCheck`)&&mt(t.attributeNameCheck)&&(Ce.attributeNameCheck=t.attributeNameCheck),zt(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(Ce.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),vt(Ce),D&&(Oe=!1),Le&&(Ie=!0),We&&(E=A({},nn),xe=yt(null),We.html===!0&&(A(E,Xt),A(xe,rn)),We.svg===!0&&(A(E,Zt),A(xe,an),A(xe,sn)),We.svgFilters===!0&&(A(E,Qt),A(xe,an),A(xe,sn)),We.mathMl===!0&&(A(E,en),A(xe,on),A(xe,sn))),Ee.tagCheck=null,Ee.attributeCheck=null,zt(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?Ee.tagCheck=e.ADD_TAGS:Ot(e.ADD_TAGS)&&(E===be&&(E=Kt(E)),A(E,e.ADD_TAGS,ut))),zt(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?Ee.attributeCheck=e.ADD_ATTR:Ot(e.ADD_ATTR)&&(xe===Se&&(xe=Kt(xe)),A(xe,e.ADD_ATTR,ut))),zt(e,`ADD_URI_SAFE_ATTR`)&&Ot(e.ADD_URI_SAFE_ATTR)&&A(Je,e.ADD_URI_SAFE_ATTR,ut),zt(e,`FORBID_CONTENTS`)&&Ot(e.FORBID_CONTENTS)&&(k===Ge&&(k=Kt(k)),A(k,e.FORBID_CONTENTS,ut)),zt(e,`ADD_FORBID_CONTENTS`)&&Ot(e.ADD_FORBID_CONTENTS)&&(k===Ge&&(k=Kt(k)),A(k,e.ADD_FORBID_CONTENTS,ut)),He&&(E[`#text`]=!0),je&&A(E,[`html`,`head`,`body`]),E.table&&(A(E,[`tbody`]),delete we.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Ht(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Ht(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=ne(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=ie()),x&&typeof S==`string`&&(S=ne(``)));_t&&_t(e),dt=e},gt=A({},[...Zt,...Qt,...$t]),bt=A({},[...en,...tn]),xt=function(e,t,n){return t.namespaceURI===Qe?e===`svg`:t.namespaceURI===Xe?e===`svg`&&(n===`annotation-xml`||it[n]):!!gt[e]},St=function(e,t,n){return t.namespaceURI===Qe?e===`math`:t.namespaceURI===Ze?e===`math`&&ot[n]:!!bt[e]},Ft=function(e,t,n){return t.namespaceURI===Ze&&!ot[n]||t.namespaceURI===Xe&&!it[n]?!1:!bt[e]&&(st[e]||!gt[e])},It=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:$e,tagName:`template`});let n=kt(e.tagName),r=kt(t.tagName);return tt[e.namespaceURI]?e.namespaceURI===Ze?xt(n,t,r):e.namespaceURI===Xe?St(n,t,r):e.namespaceURI===Qe?Ft(n,t,r):!!(ct===`application/xhtml+xml`&&tt[e.namespaceURI]):!1},Lt=function(e){Et(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw Ht(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},Rt=function(e){Wt(e);let t=h(e);if(t){let e=[];Ct(t,t=>{Et(e,t)}),Ct(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{}}},Bt=function(e,n){try{Et(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{Et(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Ie||Le)try{Lt(n)}catch{}else try{n.setAttribute(e,``)}catch{}},Ut=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`||xe[ut(i)]))try{e.removeAttribute(i)}catch{}}},Wt=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===Sn.element&&Ut(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},Gt=function(e){if(!O)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=y?y(e):e.nodeType;if(n===Sn.processingInstruction||n===Sn.comment&&Vt(yn,e.data)){try{p(e)}catch{}continue}if(n===Sn.element){let t=e,n=ut(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])}},On=function(e){let t=null,r=null;if(Fe)e=`<remove></remove>`+e;else{let t=jt(e,/^[\r\n\t ]+/);r=t&&t[0]}ct===`application/xhtml+xml`&&$e===Qe&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=x?ne(e):e;if($e===Qe)try{t=new l().parseFromString(i,ct)}catch{}if(!t||!t.documentElement){t=oe.createDocument($e,`template`,null);try{t.documentElement.innerHTML=et?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),$e===Qe?le.call(t,je?`html`:`body`)[0]:je?t.documentElement:a},kn=function(e){return se.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},An=function(e){return e=Mt(e,de,` `),e=Mt(e,fe,` `),e=Mt(e,pe,` `),e},jn=function(e){e.normalize();let t=se.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=An(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&Ct(r,e=>{Nn(e.content)&&jn(e.content)})},Mn=function(e){let t=b?b(e):null;return typeof t!=`string`||ut(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)},Nn=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===Sn.documentFragment}catch{return!1}},j=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function Pn(e,n,r){e.length!==0&&Ct(e,e=>{e.call(t,n,r,dt)})}let Fn=function(e,t){return!!(O&&e.hasChildNodes()&&!j(e.firstElementChild)&&Vt(vn,e.textContent)&&Vt(vn,e.innerHTML)||O&&e.namespaceURI===Qe&&t===`style`&&j(e.firstElementChild)||e.nodeType===Sn.processingInstruction||O&&e.nodeType===Sn.comment&&Vt(yn,e.data))},In=function(e,t){if(!we[t]&&Bn(t)&&(Ce.tagNameCheck instanceof RegExp&&Vt(Ce.tagNameCheck,t)||Ce.tagNameCheck instanceof Function&&Ce.tagNameCheck(t)))return!1;if(He&&!k[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=Ue?n[i]:f(n[i],!0);t.insertBefore(r,m(e))}}}return Lt(e),!0},Ln=function(e,n){if(Pn(T.beforeSanitizeElements,e,null),e!==n&&g(e)===null)return!0;if(Mn(e))return Lt(e),!0;let r=ut(b?b(e):e.nodeName);if(Pn(T.uponSanitizeElement,e,{tagName:r,allowedTags:E}),e!==n&&g(e)===null)return!0;if(Fn(e,r))return Lt(e),!0;if(we[r]||!(Ee.tagCheck instanceof Function&&Ee.tagCheck(r))&&!E[r]){let t=In(e,r);return t===!1&&Pn(T.afterSanitizeElements,e,null),t}if((y?y(e):e.nodeType)===Sn.element&&!It(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&Vt(bn,e.innerHTML))return Lt(e),!0;if(D&&e.nodeType===Sn.text){let n=An(e.textContent);e.textContent!==n&&(Et(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Pn(T.afterSanitizeElements,e,null),!1},Rn=function(e,t,r){if(Te[t]||O&&t===`patchsrc`||O&&t===`for`&&e!==`label`&&e!==`output`||ze&&(t===`id`||t===`name`)&&(r in n||r in pt))return!1;let i=xe[t]||Ee.attributeCheck instanceof Function&&Ee.attributeCheck(t,e);if(!(Oe&&Vt(me,t))&&!(De&&Vt(he,t))){if(!i){if(!(Bn(e)&&(Ce.tagNameCheck instanceof RegExp&&Vt(Ce.tagNameCheck,e)||Ce.tagNameCheck instanceof Function&&Ce.tagNameCheck(e))&&(Ce.attributeNameCheck instanceof RegExp&&Vt(Ce.attributeNameCheck,t)||Ce.attributeNameCheck instanceof Function&&Ce.attributeNameCheck(t,e))||t===`is`&&Ce.allowCustomizedBuiltInElements&&(Ce.tagNameCheck instanceof RegExp&&Vt(Ce.tagNameCheck,r)||Ce.tagNameCheck instanceof Function&&Ce.tagNameCheck(r))))return!1}else if(!Je[t]&&!Vt(ye,Mt(r,_e,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Nt(r,`data:`)===0&&Ke[e])&&!(ke&&!Vt(ge,Mt(r,_e,``)))&&r)return!1}return!0},zn=A({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Bn=function(e){return!zn[kt(e)]&&Vt(ve,e)},Vn=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ne(r);case`TrustedScriptURL`:return re(r)}return r},Hn=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),Mn(e)?Lt(e):Tt(t.removed)}catch{Bt(n,e)}},Un=function(e){Pn(T.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||Mn(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:xe,forceKeepAttr:void 0},r=t.length,i=ut(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=ut(o),u=c,d=o===`value`?u:Pt(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,Pn(T.uponSanitizeAttribute,e,n),d=n.attrValue,Be&&(l===`id`||l===`name`)&&Nt(d,Ve)!==0&&(Bt(o,e),d=Ve+d),O&&Vt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){Bt(o,e);continue}if(l===`attributename`&&jt(d,`href`)){Bt(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){Bt(o,e);continue}if(!Ae&&Vt(xn,d)){Bt(o,e);continue}if(D&&(d=An(d)),!Rn(i,l,d)){Bt(o,e);continue}d=Vn(i,l,s,d),d!==u&&Hn(e,o,s,d)}}Pn(T.afterSanitizeAttributes,e,null)},Wn=function(e){let t=null,n=kn(e);for(Pn(T.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Pn(T.uponSanitizeShadowNode,t,null),Ln(t,e),Un(t),Nn(t.content)&&Wn(t.content),(y?y(t):t.nodeType)===Sn.element){let e=_(t);Nn(e)&&(Gn(e),Wn(e))}Pn(T.afterSanitizeShadowDOM,e,null)},Gn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Wn(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===Sn.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`&&ut(e)===`template`){let e=n.content;Nn(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);Nn(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(et=!e,et&&(e=`<!-->`),typeof e!=`string`&&!j(e)&&(e=qt(e),typeof e!=`string`))throw Ht(`dirty is not a string, aborting`);if(!t.isSupported)return e;Me?(E=Ne,xe=Pe):ht(n),(T.uponSanitizeElement.length>0||T.uponSanitizeAttribute.length>0)&&(E=Kt(E)),T.uponSanitizeAttribute.length>0&&(xe=Kt(xe)),t.removed=[];let c=Ue&&typeof e!=`string`&&j(e);if(c){Gt(e);let t=b?b(e):e.nodeName;if(typeof t==`string`){let n=ut(t);if(!E[n]||we[n])throw Rt(e),Ht(`root node is forbidden and cannot be sanitized in-place`)}if(Mn(e))throw Rt(e),Ht(`root node is clobbered and cannot be sanitized in-place`);try{Gn(e)}catch(t){throw Rt(e),t}}else if(j(e))i=On(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===Sn.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),Gn(a);else{if(!Ie&&!D&&!je&&e.indexOf(`<`)===-1)return x&&Re?ne(e):e;if(i=On(e),!i)return Ie?null:Re?S:``}i&&Fe&&Lt(i.firstChild);let l=c?e:i,u=kn(l);try{for(;o=u.nextNode();)Ln(o,l),Un(o),Nn(o.content)&&Wn(o.content)}catch(n){throw c&&(Rt(e),Ct(t.removed,e=>{e.element&&Wt(e.element)})),n}if(c)return Ct(t.removed,e=>{e.element&&Wt(e.element)}),D&&jn(e),e;if(Ie){if(D&&jn(i),Le)for(s=ce.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(xe.shadowroot||xe.shadowrootmode)&&(s=ue.call(r,s,!0)),s}let d=je?i.outerHTML:i.innerHTML;return je&&E[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Vt(gn,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
3
3
|
`+d),D&&(d=An(d)),x&&Re?ne(d):d},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};ht(e),Me=!0,Ne=E,Pe=xe},t.clearConfig=function(){dt=null,Me=!1,Ne=null,Pe=null,x=C,S=``},t.isValidAttribute=function(e,t,n){dt||ht({});let r=ut(e),i=ut(t);return Rn(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&zt(T,e)&&Et(T[e],t)},t.removeHook=function(e,t){if(zt(T,e)){if(t!==void 0){let n=wt(T[e],t);return n===-1?void 0:Dt(T[e],n,1)[0]}return Tt(T[e])}},t.removeHooks=function(e){zt(T,e)&&(T[e]=[])},t.removeAllHooks=function(){T=Tn()},t}var On=Dn();function kn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var An=kn();function jn(e){An=e}var Mn={exec:()=>null};function Nn(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(Fn.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Pn=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),Fn={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:Nn(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Nn(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Nn(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Nn(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Nn(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:Nn(e=>RegExp(`^ {0,${e}}>`))},In=/^(?:[ \t]*(?:\n|$))+/,Ln=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Rn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,zn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Bn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Vn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Hn=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Un=j(Hn).replace(/bull/g,Vn).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(),Wn=j(Hn).replace(/bull/g,Vn).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(),Gn=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Kn=/^[^\n]+/,qn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Jn=j(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,qn).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Yn=j(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Vn).getRegex(),Xn=`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`,Zn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Qn=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`,Zn).replace(`tag`,Xn).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),$n=e=>j(Gn).replace(`hr`,zn).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`,Xn).getRegex(),er=$n(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),tr=$n(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),nr={blockquote:j(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,tr).getRegex(),code:Ln,def:Jn,fences:Rn,heading:Bn,hr:zn,html:Qn,lheading:Un,list:Yn,newline:In,paragraph:er,table:Mn,text:Kn},rr=j(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,zn).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`,Xn).getRegex(),ir={...nr,lheading:Wn,table:rr,paragraph:j(Gn).replace(`hr`,zn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,rr).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`,Xn).getRegex()},ar={...nr,html:j(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Zn).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:Mn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:j(Gn).replace(`hr`,zn).replace(`heading`,` *#{1,6} *[^
|
|
4
4
|
]`).replace(`lheading`,Un).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},or=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,sr=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,cr=/^( {2,}|\\)\n(?!\s*$)/,lr=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,ur=/[\p{P}\p{S}]/u,dr=/[\s\p{P}\p{S}]/u,fr=/[^\s\p{P}\p{S}]/u,pr=j(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,dr).getRegex(),mr=/(?!~)[\p{P}\p{S}]/u,hr=/(?!~)[\s\p{P}\p{S}]/u,gr=/(?:[^\s\p{P}\p{S}]|~)/u,_r=j(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Pn?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),vr=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,yr=j(vr,`u`).replace(/punct/g,ur).getRegex(),br=j(vr,`u`).replace(/punct/g,mr).getRegex(),xr=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Sr=j(xr,`gu`).replace(/notPunctSpace/g,fr).replace(/punctSpace/g,dr).replace(/punct/g,ur).getRegex(),Cr=j(xr,`gu`).replace(/notPunctSpace/g,gr).replace(/punctSpace/g,hr).replace(/punct/g,mr).getRegex(),wr=j(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,fr).replace(/punctSpace/g,dr).replace(/punct/g,ur).getRegex(),Tr=j(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,ur).getRegex(),Er=j(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,fr).replace(/punctSpace/g,dr).replace(/punct/g,ur).getRegex(),Dr=j(/\\(punct)/,`gu`).replace(/punct/g,ur).getRegex(),Or=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(),kr=j(Zn).replace(`(?:-->|$)`,`-->`).getRegex(),Ar=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`,kr).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),jr=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,Mr=j(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,jr).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Nr=j(/^!?\[(label)\]\[(ref)\]/).replace(`label`,jr).replace(`ref`,qn).getRegex(),Pr=j(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,qn).getRegex(),Fr=j(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Nr).replace(`nolink`,Pr).getRegex(),Ir=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Lr={_backpedal:Mn,anyPunctuation:Dr,autolink:Or,blockSkip:_r,br:cr,code:sr,del:Mn,delLDelim:Mn,delRDelim:Mn,emStrongLDelim:yr,emStrongRDelimAst:Sr,emStrongRDelimUnd:wr,escape:or,link:Mr,nolink:Pr,punctuation:pr,reflink:Nr,reflinkSearch:Fr,tag:Ar,text:lr,url:Mn},Rr={...Lr,link:j(/^!?\[(label)\]\((.*?)\)/).replace(`label`,jr).getRegex(),reflink:j(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,jr).getRegex()},zr={...Lr,emStrongRDelimAst:Cr,emStrongLDelim:br,delLDelim:Tr,delRDelim:Er,url:j(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Ir).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`,Ir).getRegex()},Br={...zr,br:j(cr).replace(`{2,}`,`*`).getRegex(),text:j(zr.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Vr={normal:nr,gfm:ir,pedantic:ar},Hr={normal:Lr,gfm:zr,breaks:Br,pedantic:Rr},Ur={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Wr=e=>Ur[e];function Gr(e,t){if(t){if(Fn.escapeTest.test(e))return e.replace(Fn.escapeReplace,Wr)}else if(Fn.escapeTestNoEncode.test(e))return e.replace(Fn.escapeReplaceNoEncode,Wr);return e}function Kr(e){try{e=encodeURI(e).replace(Fn.percentDecode,`%`)}catch{return null}return e}function qr(e,t){let n=e.replace(Fn.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Fn.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(Fn.slashPipe,`|`);return n}function Jr(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 Yr(e){let t=e.split(`
|
|
@@ -319,4 +319,4 @@ l0,-`+(t+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
|
|
|
319
319
|
|[ \r ]+
|
|
320
320
|
?)[ \r ]*`,Rl=`[̀-ͯ]`,zl=RegExp(Rl+`+$`),Bl=`(`+Nl+`+)|`+(Ll+`|`)+`([!-\\[\\]-‧-豈-]`+(Rl+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(Rl+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+Il)+(`|`+Fl+`)`),Vl=class{constructor(e,t){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=e,this.settings=t,this.tokenRegex=new RegExp(Bl,`g`),this.catcodes={"%":14,"~":13}}setCatcode(e,t){this.catcodes[e]=t}lex(){var e=this.input,t=this.tokenRegex.lastIndex;if(t===e.length)return new Hc(`EOF`,new Vc(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new N(`Unexpected character: '`+e[t]+`'`,new Hc(e[t],new Vc(this,t,t+1)));var r=n[6]||n[3]||(n[2]?`\\ `:` `);if(this.catcodes[r]===14){var i=e.indexOf(`
|
|
321
321
|
`,this.tokenRegex.lastIndex);return i===-1?(this.tokenRegex.lastIndex=e.length,this.settings.reportNonstrict(`commentAtEnd`,`% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)`)):this.tokenRegex.lastIndex=i+1,this.lex()}return new Hc(r,new Vc(this,t,this.tokenRegex.lastIndex))}},Hl=class{constructor(e,t){e===void 0&&(e={}),t===void 0&&(t={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=t,this.builtins=e,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new N(`Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug`);var e=this.undefStack.pop();for(var t of Object.keys(e))e[t]===void 0?delete this.current[t]:this.current[t]=e[t]}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(e){return Object.prototype.hasOwnProperty.call(this.current,e)||Object.prototype.hasOwnProperty.call(this.builtins,e)}get(e){return Object.prototype.hasOwnProperty.call(this.current,e)?this.current[e]:this.builtins[e]}set(e,t,n){if(n===void 0&&(n=!1),n){for(var r=0;r<this.undefStack.length;r++)delete this.undefStack[r][e];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][e]=t)}else{var i=this.undefStack[this.undefStack.length-1];i&&!Object.prototype.hasOwnProperty.call(i,e)&&(i[e]=this.current[e])}t==null?delete this.current[e]:this.current[e]=t}},Ul=Bc;$(`\\noexpand`,function(e){var t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}}),$(`\\expandafter`,function(e){var t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}}),$(`\\@firstoftwo`,function(e){return{tokens:e.consumeArgs(2)[0],numArgs:0}}),$(`\\@secondoftwo`,function(e){return{tokens:e.consumeArgs(2)[1],numArgs:0}}),$(`\\@ifnextchar`,function(e){var t=e.consumeArgs(3);e.consumeSpaces();var n=e.future();return t[0].length===1&&t[0][0].text===n.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}}),$(`\\@ifstar`,`\\@ifnextchar *{\\@firstoftwo{#1}}`),$(`\\TextOrMath`,function(e){var t=e.consumeArgs(2);return e.mode===`text`?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});var Wl={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};$(`\\char`,function(e){var t=e.popToken(),n,r=0;if(t.text===`'`)n=8,t=e.popToken();else if(t.text===`"`)n=16,t=e.popToken();else if(t.text==="`")if(t=e.popToken(),t.text[0]===`\\`)r=t.text.charCodeAt(1);else if(t.text===`EOF`)throw new N("\\char` missing argument");else r=t.text.charCodeAt(0);else n=10;if(n){if(r=Wl[t.text],r==null||r>=n)throw new N(`Invalid base-`+n+` digit `+t.text);for(var i;(i=Wl[e.future().text])!=null&&i<n;)r*=n,r+=i,e.popToken()}return`\\@char{`+r+`}`});var Gl=(e,t,n,r)=>{var i=e.consumeArg().tokens;if(i.length!==1)throw new N(`\\newcommand's first argument must be a macro name`);var a=i[0].text,o=e.isDefined(a);if(o&&!t)throw new N(`\\newcommand{`+a+`} attempting to redefine `+(a+`; use \\renewcommand`));if(!o&&!n)throw new N(`\\renewcommand{`+a+`} when command `+a+` does not yet exist; use \\newcommand`);var s=0;if(i=e.consumeArg().tokens,i.length===1&&i[0].text===`[`){for(var c=``,l=e.expandNextToken();l.text!==`]`&&l.text!==`EOF`;)c+=l.text,l=e.expandNextToken();if(!c.match(/^\s*[0-9]+\s*$/))throw new N(`Invalid number of arguments: `+c);s=parseInt(c),i=e.consumeArg().tokens}return o&&r||e.macros.set(a,{tokens:i,numArgs:s}),``};$(`\\newcommand`,e=>Gl(e,!1,!0,!1)),$(`\\renewcommand`,e=>Gl(e,!0,!1,!1)),$(`\\providecommand`,e=>Gl(e,!0,!0,!0)),$(`\\message`,e=>{var t=e.consumeArgs(1)[0];return console.log(t.reverse().map(e=>e.text).join(``)),``}),$(`\\errmessage`,e=>{var t=e.consumeArgs(1)[0];return console.error(t.reverse().map(e=>e.text).join(``)),``}),$(`\\show`,e=>{var t=e.popToken(),n=t.text;return console.log(t,e.macros.get(n),Ml[n],ja.math[n],ja.text[n]),``}),$(`\\bgroup`,`{`),$(`\\egroup`,`}`),$(`~`,`\\nobreakspace`),$(`\\lq`,"`"),$(`\\rq`,`'`),$(`\\aa`,`\\r a`),$(`\\AA`,`\\r A`),$(`\\textcopyright`,"\\html@mathml{\\textcircled{c}}{\\char`©}"),$(`\\copyright`,`\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}`),$(`\\textregistered`,"\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}"),$(`ℬ`,`\\mathscr{B}`),$(`ℰ`,`\\mathscr{E}`),$(`ℱ`,`\\mathscr{F}`),$(`ℋ`,`\\mathscr{H}`),$(`ℐ`,`\\mathscr{I}`),$(`ℒ`,`\\mathscr{L}`),$(`ℳ`,`\\mathscr{M}`),$(`ℛ`,`\\mathscr{R}`),$(`ℭ`,`\\mathfrak{C}`),$(`ℌ`,`\\mathfrak{H}`),$(`ℨ`,`\\mathfrak{Z}`),$(`\\Bbbk`,`\\Bbb{k}`),$(`\\llap`,`\\mathllap{\\textrm{#1}}`),$(`\\rlap`,`\\mathrlap{\\textrm{#1}}`),$(`\\clap`,`\\mathclap{\\textrm{#1}}`),$(`\\mathstrut`,`\\vphantom{(}`),$(`\\underbar`,`\\underline{\\text{#1}}`),$(`\\not`,`\\html@mathml{\\mathrel{\\mathrlap\\@not}\\nobreak}{\\char"338}`),$(`\\neq`,"\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}"),$(`\\ne`,`\\neq`),$(`≠`,`\\neq`),$(`\\notin`,"\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`∉}}"),$(`∉`,`\\notin`),$(`≘`,"\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`≘}}"),$(`≙`,"\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`≘}}"),$(`≚`,"\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`≚}}"),$(`≛`,"\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`≛}}"),$(`≝`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`≝}}"),$(`≞`,"\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`≞}}"),$(`≟`,"\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`≟}}"),$(`⟂`,`\\perp`),$(`‼`,`\\mathclose{!\\mkern-0.8mu!}`),$(`∌`,`\\notni`),$(`⌜`,`\\ulcorner`),$(`⌝`,`\\urcorner`),$(`⌞`,`\\llcorner`),$(`⌟`,`\\lrcorner`),$(`©`,`\\copyright`),$(`®`,`\\textregistered`),$(`\\ulcorner`,`\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}`),$(`\\urcorner`,`\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}`),$(`\\llcorner`,`\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}`),$(`\\lrcorner`,`\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}`),$(`\\vdots`,`{\\varvdots\\rule{0pt}{15pt}}`),$(`⋮`,`\\vdots`),$(`\\varGamma`,`\\mathit{\\Gamma}`),$(`\\varDelta`,`\\mathit{\\Delta}`),$(`\\varTheta`,`\\mathit{\\Theta}`),$(`\\varLambda`,`\\mathit{\\Lambda}`),$(`\\varXi`,`\\mathit{\\Xi}`),$(`\\varPi`,`\\mathit{\\Pi}`),$(`\\varSigma`,`\\mathit{\\Sigma}`),$(`\\varUpsilon`,`\\mathit{\\Upsilon}`),$(`\\varPhi`,`\\mathit{\\Phi}`),$(`\\varPsi`,`\\mathit{\\Psi}`),$(`\\varOmega`,`\\mathit{\\Omega}`),$(`\\substack`,`\\begin{subarray}{c}#1\\end{subarray}`),$(`\\colon`,`\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax`),$(`\\boxed`,`\\fbox{$\\displaystyle{#1}$}`),$(`\\iff`,`\\DOTSB\\;\\Longleftrightarrow\\;`),$(`\\implies`,`\\DOTSB\\;\\Longrightarrow\\;`),$(`\\impliedby`,`\\DOTSB\\;\\Longleftarrow\\;`),$(`\\dddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}`),$(`\\ddddot`,`{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}`);var Kl={",":`\\dotsc`,"\\not":`\\dotsb`,"+":`\\dotsb`,"=":`\\dotsb`,"<":`\\dotsb`,">":`\\dotsb`,"-":`\\dotsb`,"*":`\\dotsb`,":":`\\dotsb`,"\\DOTSB":`\\dotsb`,"\\coprod":`\\dotsb`,"\\bigvee":`\\dotsb`,"\\bigwedge":`\\dotsb`,"\\biguplus":`\\dotsb`,"\\bigcap":`\\dotsb`,"\\bigcup":`\\dotsb`,"\\prod":`\\dotsb`,"\\sum":`\\dotsb`,"\\bigotimes":`\\dotsb`,"\\bigoplus":`\\dotsb`,"\\bigodot":`\\dotsb`,"\\bigsqcup":`\\dotsb`,"\\And":`\\dotsb`,"\\longrightarrow":`\\dotsb`,"\\Longrightarrow":`\\dotsb`,"\\longleftarrow":`\\dotsb`,"\\Longleftarrow":`\\dotsb`,"\\longleftrightarrow":`\\dotsb`,"\\Longleftrightarrow":`\\dotsb`,"\\mapsto":`\\dotsb`,"\\longmapsto":`\\dotsb`,"\\hookrightarrow":`\\dotsb`,"\\doteq":`\\dotsb`,"\\mathbin":`\\dotsb`,"\\mathrel":`\\dotsb`,"\\relbar":`\\dotsb`,"\\Relbar":`\\dotsb`,"\\xrightarrow":`\\dotsb`,"\\xleftarrow":`\\dotsb`,"\\DOTSI":`\\dotsi`,"\\int":`\\dotsi`,"\\oint":`\\dotsi`,"\\iint":`\\dotsi`,"\\iiint":`\\dotsi`,"\\iiiint":`\\dotsi`,"\\idotsint":`\\dotsi`,"\\DOTSX":`\\dotsx`},ql=new Set([`bin`,`rel`]);$(`\\dots`,function(e){var t=`\\dotso`,n=e.expandAfterFuture().text;return n in Kl?t=Kl[n]:(n.slice(0,4)===`\\not`||n in ja.math&&ql.has(ja.math[n].group))&&(t=`\\dotsb`),t});var Jl={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};$(`\\dotso`,function(e){return e.future().text in Jl?`\\ldots\\,`:`\\ldots`}),$(`\\dotsc`,function(e){var t=e.future().text;return t in Jl&&t!==`,`?`\\ldots\\,`:`\\ldots`}),$(`\\cdots`,function(e){return e.future().text in Jl?`\\@cdots\\,`:`\\@cdots`}),$(`\\dotsb`,`\\cdots`),$(`\\dotsm`,`\\cdots`),$(`\\dotsi`,`\\!\\cdots`),$(`\\dotsx`,`\\ldots\\,`),$(`\\DOTSI`,`\\relax`),$(`\\DOTSB`,`\\relax`),$(`\\DOTSX`,`\\relax`),$(`\\tmspace`,`\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax`),$(`\\,`,`\\tmspace+{3mu}{.1667em}`),$(`\\thinspace`,`\\,`),$(`\\>`,`\\mskip{4mu}`),$(`\\:`,`\\tmspace+{4mu}{.2222em}`),$(`\\medspace`,`\\:`),$(`\\;`,`\\tmspace+{5mu}{.2777em}`),$(`\\thickspace`,`\\;`),$(`\\!`,`\\tmspace-{3mu}{.1667em}`),$(`\\negthinspace`,`\\!`),$(`\\negmedspace`,`\\tmspace-{4mu}{.2222em}`),$(`\\negthickspace`,`\\tmspace-{5mu}{.277em}`),$(`\\enspace`,`\\kern.5em `),$(`\\enskip`,`\\hskip.5em\\relax`),$(`\\quad`,`\\hskip1em\\relax`),$(`\\qquad`,`\\hskip2em\\relax`),$(`\\tag`,`\\@ifstar\\tag@literal\\tag@paren`),$(`\\tag@paren`,`\\tag@literal{({#1})}`),$(`\\tag@literal`,e=>{if(e.macros.get(`\\df@tag`))throw new N(`Multiple \\tag`);return`\\gdef\\df@tag{\\text{#1}}`}),$(`\\bmod`,`\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}`),$(`\\pod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)`),$(`\\pmod`,`\\pod{{\\rm mod}\\mkern6mu#1}`),$(`\\mod`,`\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1`),$(`\\newline`,`\\\\\\relax`),$(`\\TeX`,`\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}`);var Yl=F(wa[`Main-Regular`][84][1]-.7*wa[`Main-Regular`][65][1]);$(`\\LaTeX`,`\\textrm{\\html@mathml{`+(`L\\kern-.36em\\raisebox{`+Yl+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{LaTeX}}`),$(`\\KaTeX`,`\\textrm{\\html@mathml{`+(`K\\kern-.17em\\raisebox{`+Yl+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{KaTeX}}`),$(`\\hspace`,`\\@ifstar\\@hspacer\\@hspace`),$(`\\@hspace`,`\\hskip #1\\relax`),$(`\\@hspacer`,`\\rule{0pt}{0pt}\\hskip #1\\relax`),$(`\\ordinarycolon`,`:`),$(`\\vcentcolon`,`\\mathrel{\\mathop\\ordinarycolon}`),$(`\\dblcolon`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}`),$(`\\coloneqq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}`),$(`\\Coloneqq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}`),$(`\\coloneq`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}`),$(`\\Coloneq`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}`),$(`\\eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}`),$(`\\Eqqcolon`,`\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}`),$(`\\eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}`),$(`\\Eqcolon`,`\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}`),$(`\\colonapprox`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}`),$(`\\Colonapprox`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}`),$(`\\colonsim`,`\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}`),$(`\\Colonsim`,`\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}`),$(`∷`,`\\dblcolon`),$(`∹`,`\\eqcolon`),$(`≔`,`\\coloneqq`),$(`≕`,`\\eqqcolon`),$(`⩴`,`\\Coloneqq`),$(`\\ratio`,`\\vcentcolon`),$(`\\coloncolon`,`\\dblcolon`),$(`\\colonequals`,`\\coloneqq`),$(`\\coloncolonequals`,`\\Coloneqq`),$(`\\equalscolon`,`\\eqqcolon`),$(`\\equalscoloncolon`,`\\Eqqcolon`),$(`\\colonminus`,`\\coloneq`),$(`\\coloncolonminus`,`\\Coloneq`),$(`\\minuscolon`,`\\eqcolon`),$(`\\minuscoloncolon`,`\\Eqcolon`),$(`\\coloncolonapprox`,`\\Colonapprox`),$(`\\coloncolonsim`,`\\Colonsim`),$(`\\simcolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),$(`\\simcoloncolon`,`\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}`),$(`\\approxcolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}`),$(`\\approxcoloncolon`,`\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}`),$(`\\notni`,"\\html@mathml{\\not\\ni}{\\mathrel{\\char`∌}}"),$(`\\limsup`,`\\DOTSB\\operatorname*{lim\\,sup}`),$(`\\liminf`,`\\DOTSB\\operatorname*{lim\\,inf}`),$(`\\injlim`,`\\DOTSB\\operatorname*{inj\\,lim}`),$(`\\projlim`,`\\DOTSB\\operatorname*{proj\\,lim}`),$(`\\varlimsup`,`\\DOTSB\\operatorname*{\\overline{lim}}`),$(`\\varliminf`,`\\DOTSB\\operatorname*{\\underline{lim}}`),$(`\\varinjlim`,`\\DOTSB\\operatorname*{\\underrightarrow{lim}}`),$(`\\varprojlim`,`\\DOTSB\\operatorname*{\\underleftarrow{lim}}`),$(`\\gvertneqq`,`\\html@mathml{\\@gvertneqq}{≩}`),$(`\\lvertneqq`,`\\html@mathml{\\@lvertneqq}{≨}`),$(`\\ngeqq`,`\\html@mathml{\\@ngeqq}{≱}`),$(`\\ngeqslant`,`\\html@mathml{\\@ngeqslant}{≱}`),$(`\\nleqq`,`\\html@mathml{\\@nleqq}{≰}`),$(`\\nleqslant`,`\\html@mathml{\\@nleqslant}{≰}`),$(`\\nshortmid`,`\\html@mathml{\\@nshortmid}{∤}`),$(`\\nshortparallel`,`\\html@mathml{\\@nshortparallel}{∦}`),$(`\\nsubseteqq`,`\\html@mathml{\\@nsubseteqq}{⊈}`),$(`\\nsupseteqq`,`\\html@mathml{\\@nsupseteqq}{⊉}`),$(`\\varsubsetneq`,`\\html@mathml{\\@varsubsetneq}{⊊}`),$(`\\varsubsetneqq`,`\\html@mathml{\\@varsubsetneqq}{⫋}`),$(`\\varsupsetneq`,`\\html@mathml{\\@varsupsetneq}{⊋}`),$(`\\varsupsetneqq`,`\\html@mathml{\\@varsupsetneqq}{⫌}`),$(`\\imath`,`\\html@mathml{\\@imath}{ı}`),$(`\\jmath`,`\\html@mathml{\\@jmath}{ȷ}`),$(`\\llbracket`,"\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`⟦}}"),$(`\\rrbracket`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`⟧}}"),$(`⟦`,`\\llbracket`),$(`⟧`,`\\rrbracket`),$(`\\lBrace`,"\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`⦃}}"),$(`\\rBrace`,"\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`⦄}}"),$(`⦃`,`\\lBrace`),$(`⦄`,`\\rBrace`),$(`\\minuso`,"\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`⦵}}"),$(`⦵`,`\\minuso`),$(`\\darr`,`\\downarrow`),$(`\\dArr`,`\\Downarrow`),$(`\\Darr`,`\\Downarrow`),$(`\\lang`,`\\langle`),$(`\\rang`,`\\rangle`),$(`\\uarr`,`\\uparrow`),$(`\\uArr`,`\\Uparrow`),$(`\\Uarr`,`\\Uparrow`),$(`\\N`,`\\mathbb{N}`),$(`\\R`,`\\mathbb{R}`),$(`\\Z`,`\\mathbb{Z}`),$(`\\alef`,`\\aleph`),$(`\\alefsym`,`\\aleph`),$(`\\Alpha`,`\\mathrm{A}`),$(`\\Beta`,`\\mathrm{B}`),$(`\\bull`,`\\bullet`),$(`\\Chi`,`\\mathrm{X}`),$(`\\clubs`,`\\clubsuit`),$(`\\cnums`,`\\mathbb{C}`),$(`\\Complex`,`\\mathbb{C}`),$(`\\Dagger`,`\\ddagger`),$(`\\diamonds`,`\\diamondsuit`),$(`\\empty`,`\\emptyset`),$(`\\Epsilon`,`\\mathrm{E}`),$(`\\Eta`,`\\mathrm{H}`),$(`\\exist`,`\\exists`),$(`\\harr`,`\\leftrightarrow`),$(`\\hArr`,`\\Leftrightarrow`),$(`\\Harr`,`\\Leftrightarrow`),$(`\\hearts`,`\\heartsuit`),$(`\\image`,`\\Im`),$(`\\infin`,`\\infty`),$(`\\Iota`,`\\mathrm{I}`),$(`\\isin`,`\\in`),$(`\\Kappa`,`\\mathrm{K}`),$(`\\larr`,`\\leftarrow`),$(`\\lArr`,`\\Leftarrow`),$(`\\Larr`,`\\Leftarrow`),$(`\\lrarr`,`\\leftrightarrow`),$(`\\lrArr`,`\\Leftrightarrow`),$(`\\Lrarr`,`\\Leftrightarrow`),$(`\\Mu`,`\\mathrm{M}`),$(`\\natnums`,`\\mathbb{N}`),$(`\\Nu`,`\\mathrm{N}`),$(`\\Omicron`,`\\mathrm{O}`),$(`\\plusmn`,`\\pm`),$(`\\rarr`,`\\rightarrow`),$(`\\rArr`,`\\Rightarrow`),$(`\\Rarr`,`\\Rightarrow`),$(`\\real`,`\\Re`),$(`\\reals`,`\\mathbb{R}`),$(`\\Reals`,`\\mathbb{R}`),$(`\\Rho`,`\\mathrm{P}`),$(`\\sdot`,`\\cdot`),$(`\\sect`,`\\S`),$(`\\spades`,`\\spadesuit`),$(`\\sub`,`\\subset`),$(`\\sube`,`\\subseteq`),$(`\\supe`,`\\supseteq`),$(`\\Tau`,`\\mathrm{T}`),$(`\\thetasym`,`\\vartheta`),$(`\\weierp`,`\\wp`),$(`\\Zeta`,`\\mathrm{Z}`),$(`\\argmin`,`\\DOTSB\\operatorname*{arg\\,min}`),$(`\\argmax`,`\\DOTSB\\operatorname*{arg\\,max}`),$(`\\plim`,`\\DOTSB\\mathop{\\operatorname{plim}}\\limits`),$(`\\bra`,`\\mathinner{\\langle{#1}|}`),$(`\\ket`,`\\mathinner{|{#1}\\rangle}`),$(`\\braket`,`\\mathinner{\\langle{#1}\\rangle}`),$(`\\Bra`,`\\left\\langle#1\\right|`),$(`\\Ket`,`\\left|#1\\right\\rangle`);var Xl=e=>t=>{var n=t.consumeArg().tokens,r=t.consumeArg().tokens,i=t.consumeArg().tokens,a=t.consumeArg().tokens,o=t.macros.get(`|`),s=t.macros.get(`\\|`);t.macros.beginGroup();var c=t=>n=>{e&&(n.macros.set(`|`,o),i.length&&n.macros.set(`\\|`,s));var a=t;return!t&&i.length&&n.future().text===`|`&&(n.popToken(),a=!0),{tokens:a?i:r,numArgs:0}};t.macros.set(`|`,c(!1)),i.length&&t.macros.set(`\\|`,c(!0));var l=t.consumeArg().tokens,u=t.expandTokens([...a,...l,...n]);return t.macros.endGroup(),{tokens:u.reverse(),numArgs:0}};$(`\\bra@ket`,Xl(!1)),$(`\\bra@set`,Xl(!0)),$(`\\Braket`,`\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}`),$(`\\Set`,`\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}`),$(`\\set`,`\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}`),$(`\\angln`,`{\\angl n}`),$(`\\blue`,`\\textcolor{##6495ed}{#1}`),$(`\\orange`,`\\textcolor{##ffa500}{#1}`),$(`\\pink`,`\\textcolor{##ff00af}{#1}`),$(`\\red`,`\\textcolor{##df0030}{#1}`),$(`\\green`,`\\textcolor{##28ae7b}{#1}`),$(`\\gray`,`\\textcolor{gray}{#1}`),$(`\\purple`,`\\textcolor{##9d38bd}{#1}`),$(`\\blueA`,`\\textcolor{##ccfaff}{#1}`),$(`\\blueB`,`\\textcolor{##80f6ff}{#1}`),$(`\\blueC`,`\\textcolor{##63d9ea}{#1}`),$(`\\blueD`,`\\textcolor{##11accd}{#1}`),$(`\\blueE`,`\\textcolor{##0c7f99}{#1}`),$(`\\tealA`,`\\textcolor{##94fff5}{#1}`),$(`\\tealB`,`\\textcolor{##26edd5}{#1}`),$(`\\tealC`,`\\textcolor{##01d1c1}{#1}`),$(`\\tealD`,`\\textcolor{##01a995}{#1}`),$(`\\tealE`,`\\textcolor{##208170}{#1}`),$(`\\greenA`,`\\textcolor{##b6ffb0}{#1}`),$(`\\greenB`,`\\textcolor{##8af281}{#1}`),$(`\\greenC`,`\\textcolor{##74cf70}{#1}`),$(`\\greenD`,`\\textcolor{##1fab54}{#1}`),$(`\\greenE`,`\\textcolor{##0d923f}{#1}`),$(`\\goldA`,`\\textcolor{##ffd0a9}{#1}`),$(`\\goldB`,`\\textcolor{##ffbb71}{#1}`),$(`\\goldC`,`\\textcolor{##ff9c39}{#1}`),$(`\\goldD`,`\\textcolor{##e07d10}{#1}`),$(`\\goldE`,`\\textcolor{##a75a05}{#1}`),$(`\\redA`,`\\textcolor{##fca9a9}{#1}`),$(`\\redB`,`\\textcolor{##ff8482}{#1}`),$(`\\redC`,`\\textcolor{##f9685d}{#1}`),$(`\\redD`,`\\textcolor{##e84d39}{#1}`),$(`\\redE`,`\\textcolor{##bc2612}{#1}`),$(`\\maroonA`,`\\textcolor{##ffbde0}{#1}`),$(`\\maroonB`,`\\textcolor{##ff92c6}{#1}`),$(`\\maroonC`,`\\textcolor{##ed5fa6}{#1}`),$(`\\maroonD`,`\\textcolor{##ca337c}{#1}`),$(`\\maroonE`,`\\textcolor{##9e034e}{#1}`),$(`\\purpleA`,`\\textcolor{##ddd7ff}{#1}`),$(`\\purpleB`,`\\textcolor{##c6b9fc}{#1}`),$(`\\purpleC`,`\\textcolor{##aa87ff}{#1}`),$(`\\purpleD`,`\\textcolor{##7854ab}{#1}`),$(`\\purpleE`,`\\textcolor{##543b78}{#1}`),$(`\\mintA`,`\\textcolor{##f5f9e8}{#1}`),$(`\\mintB`,`\\textcolor{##edf2df}{#1}`),$(`\\mintC`,`\\textcolor{##e0e5cc}{#1}`),$(`\\grayA`,`\\textcolor{##f6f7f7}{#1}`),$(`\\grayB`,`\\textcolor{##f0f1f2}{#1}`),$(`\\grayC`,`\\textcolor{##e3e5e6}{#1}`),$(`\\grayD`,`\\textcolor{##d6d8da}{#1}`),$(`\\grayE`,`\\textcolor{##babec2}{#1}`),$(`\\grayF`,`\\textcolor{##888d93}{#1}`),$(`\\grayG`,`\\textcolor{##626569}{#1}`),$(`\\grayH`,`\\textcolor{##3b3e40}{#1}`),$(`\\grayI`,`\\textcolor{##21242c}{#1}`),$(`\\kaBlue`,`\\textcolor{##314453}{#1}`),$(`\\kaGreen`,`\\textcolor{##71B307}{#1}`);var Zl={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},Ql=class{constructor(e,t,n){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=t,this.expansionCount=0,this.feed(e),this.macros=new Hl(Ul,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new Vl(e,this.settings)}switchMode(e){this.mode=e}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(e){this.stack.push(e)}pushTokens(e){this.stack.push(...e)}scanArgument(e){var t,n,r;if(e){if(this.consumeSpaces(),this.future().text!==`[`)return null;t=this.popToken();var i=this.consumeArg([`]`]);r=i.tokens,n=i.end}else{var a=this.consumeArg();r=a.tokens,t=a.start,n=a.end}return this.pushToken(new Hc(`EOF`,n.loc)),this.pushTokens(r),new Hc(``,Vc.range(t,n))}consumeSpaces(){for(;this.future().text===` `;)this.stack.pop()}consumeArg(e){var t=[],n=e&&e.length>0;n||this.consumeSpaces();var r=this.future(),i,a=0,o=0;do{if(i=this.popToken(),t.push(i),i.text===`{`)++a;else if(i.text===`}`){if(--a,a===-1)throw new N(`Extra }`,i)}else if(i.text===`EOF`)throw new N(`Unexpected end of input in a macro argument, expected '`+(e&&n?e[o]:`}`)+`'`,i);if(e&&n)if((a===0||a===1&&e[o]===`{`)&&i.text===e[o]){if(++o,o===e.length){t.splice(-o,o);break}}else o=0}while(a!==0||n);return r.text===`{`&&t[t.length-1].text===`}`&&(t.pop(),t.shift()),t.reverse(),{tokens:t,start:r,end:i}}consumeArgs(e,t){if(t){if(t.length!==e+1)throw new N(`The length of delimiters doesn't match the number of args!`);for(var n=t[0],r=0;r<n.length;r++){var i=this.popToken();if(n[r]!==i.text)throw new N(`Use of the macro doesn't match its definition`,i)}}for(var a=[],o=0;o<e;o++)a.push(this.consumeArg(t&&t[o+1]).tokens);return a}countExpansion(e){if(this.expansionCount+=e,this.expansionCount>this.settings.maxExpand)throw new N(`Too many expansions: infinite loop or need to increase maxExpand setting`)}expandOnce(e){var t=this.popToken(),n=t.text,r=t.noexpand?null:this._getExpansion(n);if(r==null||e&&r.unexpandable){if(e&&r==null&&n[0]===`\\`&&!this.isDefined(n))throw new N(`Undefined control sequence: `+n);return this.pushToken(t),!1}this.countExpansion(1);var i=r.tokens,a=this.consumeArgs(r.numArgs,r.delimiters);if(r.numArgs){i=i.slice();for(var o=i.length-1;o>=0;--o){var s=i[o];if(s.text===`#`){if(o===0)throw new N(`Incomplete placeholder at end of macro body`,s);if(s=i[--o],s.text===`#`)i.splice(o+1,1);else if(/^[1-9]$/.test(s.text))i.splice(o,2,...a[s.text-1]);else throw new N(`Not a valid argument number`,s)}}}return this.pushTokens(i),i.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var e=this.stack.pop();return e.treatAsRelax&&(e.text=`\\relax`),e}}expandMacro(e){return this.macros.has(e)?this.expandTokens([new Hc(e)]):void 0}expandTokens(e){var t=[],n=this.stack.length;for(this.pushTokens(e);this.stack.length>n;)if(this.expandOnce(!0)===!1){var r=this.stack.pop();r.treatAsRelax&&=(r.noexpand=!1,!1),t.push(r)}return this.countExpansion(t.length),t}expandMacroAsText(e){var t=this.expandMacro(e);return t&&t.map(e=>e.text).join(``)}_getExpansion(e){var t=this.macros.get(e);if(t==null)return t;if(e.length===1){var n=this.lexer.catcodes[e];if(n!=null&&n!==13)return}var r=typeof t==`function`?t(this):t;if(typeof r==`string`){var i=0;if(r.includes(`#`))for(var a=r.replace(/##/g,``);a.includes(`#`+(i+1));)++i;for(var o=new Vl(r,this.settings),s=[],c=o.lex();c.text!==`EOF`;)s.push(c),c=o.lex();return s.reverse(),{tokens:s,numArgs:i}}return r}isDefined(e){return this.macros.has(e)||Object.prototype.hasOwnProperty.call(Ml,e)||Object.prototype.hasOwnProperty.call(ja.math,e)||Object.prototype.hasOwnProperty.call(ja.text,e)||Object.prototype.hasOwnProperty.call(Zl,e)}isExpandable(e){var t=this.macros.get(e);return t==null?Object.prototype.hasOwnProperty.call(Ml,e)&&!Ml[e].primitive:typeof t==`string`||typeof t==`function`||!t.unexpandable}},$l=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,eu=Object.freeze({"₊":`+`,"₋":`-`,"₌":`=`,"₍":`(`,"₎":`)`,"₀":`0`,"₁":`1`,"₂":`2`,"₃":`3`,"₄":`4`,"₅":`5`,"₆":`6`,"₇":`7`,"₈":`8`,"₉":`9`,ₐ:`a`,ₑ:`e`,ₕ:`h`,ᵢ:`i`,ⱼ:`j`,ₖ:`k`,ₗ:`l`,ₘ:`m`,ₙ:`n`,ₒ:`o`,ₚ:`p`,ᵣ:`r`,ₛ:`s`,ₜ:`t`,ᵤ:`u`,ᵥ:`v`,ₓ:`x`,ᵦ:`β`,ᵧ:`γ`,ᵨ:`ρ`,ᵩ:`ϕ`,ᵪ:`χ`,"⁺":`+`,"⁻":`-`,"⁼":`=`,"⁽":`(`,"⁾":`)`,"⁰":`0`,"¹":`1`,"²":`2`,"³":`3`,"⁴":`4`,"⁵":`5`,"⁶":`6`,"⁷":`7`,"⁸":`8`,"⁹":`9`,ᴬ:`A`,ᴮ:`B`,ᴰ:`D`,ᴱ:`E`,ᴳ:`G`,ᴴ:`H`,ᴵ:`I`,ᴶ:`J`,ᴷ:`K`,ᴸ:`L`,ᴹ:`M`,ᴺ:`N`,ᴼ:`O`,ᴾ:`P`,ᴿ:`R`,ᵀ:`T`,ᵁ:`U`,ⱽ:`V`,ᵂ:`W`,ᵃ:`a`,ᵇ:`b`,ᶜ:`c`,ᵈ:`d`,ᵉ:`e`,ᶠ:`f`,ᵍ:`g`,ʰ:`h`,ⁱ:`i`,ʲ:`j`,ᵏ:`k`,ˡ:`l`,ᵐ:`m`,ⁿ:`n`,ᵒ:`o`,ᵖ:`p`,ʳ:`r`,ˢ:`s`,ᵗ:`t`,ᵘ:`u`,ᵛ:`v`,ʷ:`w`,ˣ:`x`,ʸ:`y`,ᶻ:`z`,ᵝ:`β`,ᵞ:`γ`,ᵟ:`δ`,ᵠ:`ϕ`,ᵡ:`χ`,ᶿ:`θ`}),tu={"́":{text:`\\'`,math:`\\acute`},"̀":{text:"\\`",math:`\\grave`},"̈":{text:`\\"`,math:`\\ddot`},"̃":{text:`\\~`,math:`\\tilde`},"̄":{text:`\\=`,math:`\\bar`},"̆":{text:`\\u`,math:`\\breve`},"̌":{text:`\\v`,math:`\\check`},"̂":{text:`\\^`,math:`\\hat`},"̇":{text:`\\.`,math:`\\dot`},"̊":{text:`\\r`,math:`\\mathring`},"̋":{text:`\\H`},"̧":{text:`\\c`}},nu={á:`á`,à:`à`,ä:`ä`,ǟ:`ǟ`,ã:`ã`,ā:`ā`,ă:`ă`,ắ:`ắ`,ằ:`ằ`,ẵ:`ẵ`,ǎ:`ǎ`,â:`â`,ấ:`ấ`,ầ:`ầ`,ẫ:`ẫ`,ȧ:`ȧ`,ǡ:`ǡ`,å:`å`,ǻ:`ǻ`,ḃ:`ḃ`,ć:`ć`,ḉ:`ḉ`,č:`č`,ĉ:`ĉ`,ċ:`ċ`,ç:`ç`,ď:`ď`,ḋ:`ḋ`,ḑ:`ḑ`,é:`é`,è:`è`,ë:`ë`,ẽ:`ẽ`,ē:`ē`,ḗ:`ḗ`,ḕ:`ḕ`,ĕ:`ĕ`,ḝ:`ḝ`,ě:`ě`,ê:`ê`,ế:`ế`,ề:`ề`,ễ:`ễ`,ė:`ė`,ȩ:`ȩ`,ḟ:`ḟ`,ǵ:`ǵ`,ḡ:`ḡ`,ğ:`ğ`,ǧ:`ǧ`,ĝ:`ĝ`,ġ:`ġ`,ģ:`ģ`,ḧ:`ḧ`,ȟ:`ȟ`,ĥ:`ĥ`,ḣ:`ḣ`,ḩ:`ḩ`,í:`í`,ì:`ì`,ï:`ï`,ḯ:`ḯ`,ĩ:`ĩ`,ī:`ī`,ĭ:`ĭ`,ǐ:`ǐ`,î:`î`,ǰ:`ǰ`,ĵ:`ĵ`,ḱ:`ḱ`,ǩ:`ǩ`,ķ:`ķ`,ĺ:`ĺ`,ľ:`ľ`,ļ:`ļ`,ḿ:`ḿ`,ṁ:`ṁ`,ń:`ń`,ǹ:`ǹ`,ñ:`ñ`,ň:`ň`,ṅ:`ṅ`,ņ:`ņ`,ó:`ó`,ò:`ò`,ö:`ö`,ȫ:`ȫ`,õ:`õ`,ṍ:`ṍ`,ṏ:`ṏ`,ȭ:`ȭ`,ō:`ō`,ṓ:`ṓ`,ṑ:`ṑ`,ŏ:`ŏ`,ǒ:`ǒ`,ô:`ô`,ố:`ố`,ồ:`ồ`,ỗ:`ỗ`,ȯ:`ȯ`,ȱ:`ȱ`,ő:`ő`,ṕ:`ṕ`,ṗ:`ṗ`,ŕ:`ŕ`,ř:`ř`,ṙ:`ṙ`,ŗ:`ŗ`,ś:`ś`,ṥ:`ṥ`,š:`š`,ṧ:`ṧ`,ŝ:`ŝ`,ṡ:`ṡ`,ş:`ş`,ẗ:`ẗ`,ť:`ť`,ṫ:`ṫ`,ţ:`ţ`,ú:`ú`,ù:`ù`,ü:`ü`,ǘ:`ǘ`,ǜ:`ǜ`,ǖ:`ǖ`,ǚ:`ǚ`,ũ:`ũ`,ṹ:`ṹ`,ū:`ū`,ṻ:`ṻ`,ŭ:`ŭ`,ǔ:`ǔ`,û:`û`,ů:`ů`,ű:`ű`,ṽ:`ṽ`,ẃ:`ẃ`,ẁ:`ẁ`,ẅ:`ẅ`,ŵ:`ŵ`,ẇ:`ẇ`,ẘ:`ẘ`,ẍ:`ẍ`,ẋ:`ẋ`,ý:`ý`,ỳ:`ỳ`,ÿ:`ÿ`,ỹ:`ỹ`,ȳ:`ȳ`,ŷ:`ŷ`,ẏ:`ẏ`,ẙ:`ẙ`,ź:`ź`,ž:`ž`,ẑ:`ẑ`,ż:`ż`,Á:`Á`,À:`À`,Ä:`Ä`,Ǟ:`Ǟ`,Ã:`Ã`,Ā:`Ā`,Ă:`Ă`,Ắ:`Ắ`,Ằ:`Ằ`,Ẵ:`Ẵ`,Ǎ:`Ǎ`,Â:`Â`,Ấ:`Ấ`,Ầ:`Ầ`,Ẫ:`Ẫ`,Ȧ:`Ȧ`,Ǡ:`Ǡ`,Å:`Å`,Ǻ:`Ǻ`,Ḃ:`Ḃ`,Ć:`Ć`,Ḉ:`Ḉ`,Č:`Č`,Ĉ:`Ĉ`,Ċ:`Ċ`,Ç:`Ç`,Ď:`Ď`,Ḋ:`Ḋ`,Ḑ:`Ḑ`,É:`É`,È:`È`,Ë:`Ë`,Ẽ:`Ẽ`,Ē:`Ē`,Ḗ:`Ḗ`,Ḕ:`Ḕ`,Ĕ:`Ĕ`,Ḝ:`Ḝ`,Ě:`Ě`,Ê:`Ê`,Ế:`Ế`,Ề:`Ề`,Ễ:`Ễ`,Ė:`Ė`,Ȩ:`Ȩ`,Ḟ:`Ḟ`,Ǵ:`Ǵ`,Ḡ:`Ḡ`,Ğ:`Ğ`,Ǧ:`Ǧ`,Ĝ:`Ĝ`,Ġ:`Ġ`,Ģ:`Ģ`,Ḧ:`Ḧ`,Ȟ:`Ȟ`,Ĥ:`Ĥ`,Ḣ:`Ḣ`,Ḩ:`Ḩ`,Í:`Í`,Ì:`Ì`,Ï:`Ï`,Ḯ:`Ḯ`,Ĩ:`Ĩ`,Ī:`Ī`,Ĭ:`Ĭ`,Ǐ:`Ǐ`,Î:`Î`,İ:`İ`,Ĵ:`Ĵ`,Ḱ:`Ḱ`,Ǩ:`Ǩ`,Ķ:`Ķ`,Ĺ:`Ĺ`,Ľ:`Ľ`,Ļ:`Ļ`,Ḿ:`Ḿ`,Ṁ:`Ṁ`,Ń:`Ń`,Ǹ:`Ǹ`,Ñ:`Ñ`,Ň:`Ň`,Ṅ:`Ṅ`,Ņ:`Ņ`,Ó:`Ó`,Ò:`Ò`,Ö:`Ö`,Ȫ:`Ȫ`,Õ:`Õ`,Ṍ:`Ṍ`,Ṏ:`Ṏ`,Ȭ:`Ȭ`,Ō:`Ō`,Ṓ:`Ṓ`,Ṑ:`Ṑ`,Ŏ:`Ŏ`,Ǒ:`Ǒ`,Ô:`Ô`,Ố:`Ố`,Ồ:`Ồ`,Ỗ:`Ỗ`,Ȯ:`Ȯ`,Ȱ:`Ȱ`,Ő:`Ő`,Ṕ:`Ṕ`,Ṗ:`Ṗ`,Ŕ:`Ŕ`,Ř:`Ř`,Ṙ:`Ṙ`,Ŗ:`Ŗ`,Ś:`Ś`,Ṥ:`Ṥ`,Š:`Š`,Ṧ:`Ṧ`,Ŝ:`Ŝ`,Ṡ:`Ṡ`,Ş:`Ş`,Ť:`Ť`,Ṫ:`Ṫ`,Ţ:`Ţ`,Ú:`Ú`,Ù:`Ù`,Ü:`Ü`,Ǘ:`Ǘ`,Ǜ:`Ǜ`,Ǖ:`Ǖ`,Ǚ:`Ǚ`,Ũ:`Ũ`,Ṹ:`Ṹ`,Ū:`Ū`,Ṻ:`Ṻ`,Ŭ:`Ŭ`,Ǔ:`Ǔ`,Û:`Û`,Ů:`Ů`,Ű:`Ű`,Ṽ:`Ṽ`,Ẃ:`Ẃ`,Ẁ:`Ẁ`,Ẅ:`Ẅ`,Ŵ:`Ŵ`,Ẇ:`Ẇ`,Ẍ:`Ẍ`,Ẋ:`Ẋ`,Ý:`Ý`,Ỳ:`Ỳ`,Ÿ:`Ÿ`,Ỹ:`Ỹ`,Ȳ:`Ȳ`,Ŷ:`Ŷ`,Ẏ:`Ẏ`,Ź:`Ź`,Ž:`Ž`,Ẑ:`Ẑ`,Ż:`Ż`,ά:`ά`,ὰ:`ὰ`,ᾱ:`ᾱ`,ᾰ:`ᾰ`,έ:`έ`,ὲ:`ὲ`,ή:`ή`,ὴ:`ὴ`,ί:`ί`,ὶ:`ὶ`,ϊ:`ϊ`,ΐ:`ΐ`,ῒ:`ῒ`,ῑ:`ῑ`,ῐ:`ῐ`,ό:`ό`,ὸ:`ὸ`,ύ:`ύ`,ὺ:`ὺ`,ϋ:`ϋ`,ΰ:`ΰ`,ῢ:`ῢ`,ῡ:`ῡ`,ῠ:`ῠ`,ώ:`ώ`,ὼ:`ὼ`,Ύ:`Ύ`,Ὺ:`Ὺ`,Ϋ:`Ϋ`,Ῡ:`Ῡ`,Ῠ:`Ῠ`,Ώ:`Ώ`,Ὼ:`Ὼ`},ru=class e{constructor(e,t){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode=`math`,this.gullet=new Ql(e,t,this.mode),this.settings=t,this.leftrightDepth=0,this.nextToken=null}expect(e,t){if(t===void 0&&(t=!0),this.fetch().text!==e)throw new N(`Expected '`+e+`', got '`+this.fetch().text+`'`,this.fetch());t&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken??=this.gullet.expandNextToken(),this.nextToken}switchMode(e){this.mode=e,this.gullet.switchMode(e)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set(`\\color`,`\\textcolor`);try{var e=this.parseExpression(!1);return this.expect(`EOF`),this.settings.globalGroup||this.gullet.endGroup(),e}finally{this.gullet.endGroups()}}subparse(e){var t=this.nextToken;this.consume(),this.gullet.pushToken(new Hc(`}`)),this.gullet.pushTokens(e);var n=this.parseExpression(!1);return this.expect(`}`),this.nextToken=t,n}parseExpression(t,n){for(var r=[];;){this.mode===`math`&&this.consumeSpaces();var i=this.fetch();if(e.endOfExpression.has(i.text)||n&&i.text===n||t&&Ml[i.text]&&Ml[i.text].infix)break;var a=this.parseAtom(n);if(!a)break;a.type!==`internal`&&r.push(a)}return this.mode===`text`&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(e){for(var t=-1,n,r=0;r<e.length;r++){var i=e[r];if(i.type===`infix`){if(t!==-1)throw new N(`only one infix operator per group`,i.token);t=r,n=i.replaceWith}}if(t!==-1&&n){var a,o,s=e.slice(0,t),c=e.slice(t+1);return a=s.length===1&&s[0].type===`ordgroup`?s[0]:{type:`ordgroup`,mode:this.mode,body:s},o=c.length===1&&c[0].type===`ordgroup`?c[0]:{type:`ordgroup`,mode:this.mode,body:c},[n===`\\\\abovefrac`?this.callFunction(n,[a,e[t],o],[]):this.callFunction(n,[a,o],[])]}else return e}handleSupSubscript(e){var t=this.fetch(),n=t.text;this.consume(),this.consumeSpaces();var r;do r=this.parseGroup(e);while(r?.type===`internal`);if(!r)throw new N(`Expected group after '`+n+`'`,t);return r}formatUnsupportedCmd(e){for(var t=[],n=0;n<e.length;n++)t.push({type:`textord`,mode:`text`,text:e[n]});var r={type:`text`,mode:this.mode,body:t};return{type:`color`,mode:this.mode,color:this.settings.errorColor,body:[r]}}parseAtom(e){var t=this.parseGroup(`atom`,e);if(t?.type===`internal`||this.mode===`text`)return t;for(var n,r;;){this.consumeSpaces();var i=this.fetch();if(i.text===`\\limits`||i.text===`\\nolimits`){if(t&&t.type===`op`)t.limits=i.text===`\\limits`,t.alwaysHandleSupSub=!0;else if(t&&t.type===`operatorname`)t.alwaysHandleSupSub&&(t.limits=i.text===`\\limits`);else throw new N(`Limit controls must follow a math operator`,i);this.consume()}else if(i.text===`^`){if(n)throw new N(`Double superscript`,i);n=this.handleSupSubscript(`superscript`)}else if(i.text===`_`){if(r)throw new N(`Double subscript`,i);r=this.handleSupSubscript(`subscript`)}else if(i.text===`'`){if(n)throw new N(`Double superscript`,i);var a={type:`textord`,mode:this.mode,text:`\\prime`},o=[a];for(this.consume();this.fetch().text===`'`;)o.push(a),this.consume();this.fetch().text===`^`&&o.push(this.handleSupSubscript(`superscript`)),n={type:`ordgroup`,mode:this.mode,body:o}}else if(eu[i.text]){var s=$l.test(i.text),c=[];for(c.push(new Hc(eu[i.text])),this.consume();;){var l=this.fetch().text;if(!eu[l]||$l.test(l)!==s)break;c.unshift(new Hc(eu[l])),this.consume()}var u=this.subparse(c);s?r={type:`ordgroup`,mode:`math`,body:u}:n={type:`ordgroup`,mode:`math`,body:u}}else break}return n&&r?{type:`supsub`,mode:this.mode,base:t,sup:n,sub:r}:n?{type:`supsub`,mode:this.mode,base:t,sup:n}:r?{type:`supsub`,mode:this.mode,base:t,sub:r}:t}parseFunction(e,t){var n=this.fetch(),r=n.text,i=Ml[r];if(!i)return null;if(this.consume(),t&&t!==`atom`&&!i.allowedInArgument)throw new N(`Got function '`+r+`' with no arguments`+(t?` as `+t:``),n);if(this.mode===`text`&&!i.allowedInText)throw new N(`Can't use function '`+r+`' in text mode`,n);if(this.mode===`math`&&i.allowedInMath===!1)throw new N(`Can't use function '`+r+`' in math mode`,n);var a=this.parseArguments(r,i),o=a.args,s=a.optArgs;return this.callFunction(r,o,s,n,e)}callFunction(e,t,n,r,i){var a={funcName:e,parser:this,token:r,breakOnTokenText:i},o=Ml[e];if(o&&o.handler)return o.handler(a,t,n);throw new N(`No function handler for `+e)}parseArguments(e,t){var n=t.numOptionalArgs??0,r=t.numArgs+n;if(r===0)return{args:[],optArgs:[]};for(var i=[],a=[],o=0;o<r;o++){var s=t.argTypes?.[o],c=o<n;(`primitive`in t&&t.primitive&&s==null||t.type===`sqrt`&&o===1&&a[0]==null)&&(s=`primitive`);var l=this.parseGroupOfType(`argument to '`+e+`'`,s,c);if(c)a.push(l);else if(l!=null)i.push(l);else throw new N(`Null argument, please report this as a bug`)}return{args:i,optArgs:a}}parseGroupOfType(e,t,n){switch(t){case`color`:return this.parseColorGroup(n);case`size`:return this.parseSizeGroup(n);case`url`:return this.parseUrlGroup(n);case`math`:case`text`:return this.parseArgumentGroup(n,t);case`hbox`:var r=this.parseArgumentGroup(n,`text`);return r==null?null:{type:`styling`,mode:r.mode,body:[r],style:`text`,resetFont:!0};case`raw`:var i=this.parseStringGroup(n);return i==null?null:{type:`raw`,mode:`text`,string:i.text};case`primitive`:if(n)throw new N(`A primitive argument cannot be optional`);var a=this.parseGroup(e);if(a==null)throw new N(`Expected group as `+e,this.fetch());return a;case`original`:case void 0:return this.parseArgumentGroup(n);default:throw new N(`Unknown group type as `+e,this.fetch())}}consumeSpaces(){for(;this.fetch().text===` `;)this.consume()}parseStringGroup(e){var t=this.gullet.scanArgument(e);if(t==null)return null;for(var n=``,r;(r=this.fetch()).text!==`EOF`;)n+=r.text,this.consume();return this.consume(),t.text=n,t}parseRegexGroup(e,t){for(var n=this.fetch(),r=n,i=``,a;(a=this.fetch()).text!==`EOF`&&e.test(i+a.text);)r=a,i+=r.text,this.consume();if(i===``)throw new N(`Invalid `+t+`: '`+n.text+`'`,n);return n.range(r,i)}parseColorGroup(e){var t=this.parseStringGroup(e);if(t==null)return null;var n=/^(#[a-f0-9]{3,4}|#[a-f0-9]{6}|#[a-f0-9]{8}|[a-f0-9]{6}|[a-z]+)$/i.exec(t.text);if(!n)throw new N(`Invalid color: '`+t.text+`'`,t);var r=n[0];return/^[0-9a-f]{6}$/i.test(r)&&(r=`#`+r),{type:`color-token`,mode:this.mode,color:r}}parseSizeGroup(e){var t,n=!1;if(this.gullet.consumeSpaces(),t=!e&&this.gullet.future().text!==`{`?this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,`size`):this.parseStringGroup(e),!t)return null;!e&&t.text.length===0&&(t.text=`0pt`,n=!0);var r=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(t.text);if(!r)throw new N(`Invalid size: '`+t.text+`'`,t);var i={number:+(r[1]+r[2]),unit:r[3]};if(!aa(i))throw new N(`Invalid unit: '`+i.unit+`'`,t);return{type:`size`,mode:this.mode,value:i,isBlank:n}}parseUrlGroup(e){this.gullet.lexer.setCatcode(`%`,13),this.gullet.lexer.setCatcode(`~`,12);var t=this.parseStringGroup(e);if(this.gullet.lexer.setCatcode(`%`,14),this.gullet.lexer.setCatcode(`~`,13),t==null)return null;var n=t.text.replace(/\\([#$%&~_^{}])/g,`$1`);return{type:`url`,mode:this.mode,url:n}}parseArgumentGroup(e,t){var n=this.gullet.scanArgument(e);if(n==null)return null;var r=this.mode;t&&this.switchMode(t),this.gullet.beginGroup();var i=this.parseExpression(!1,`EOF`);this.expect(`EOF`),this.gullet.endGroup();var a={type:`ordgroup`,mode:this.mode,loc:n.loc,body:i};return t&&this.switchMode(r),a}parseGroup(e,t){var n=this.fetch(),r=n.text,i;if(r===`{`||r===`\\begingroup`){this.consume();var a=r===`{`?`}`:`\\endgroup`;this.gullet.beginGroup();var o=this.parseExpression(!1,a),s=this.fetch();this.expect(a),this.gullet.endGroup(),i={type:`ordgroup`,mode:this.mode,loc:Vc.range(n,s),body:o,semisimple:r===`\\begingroup`||void 0}}else if(i=this.parseFunction(t,e)||this.parseSymbol(),i==null&&r[0]===`\\`&&!Object.prototype.hasOwnProperty.call(Zl,r)){if(this.settings.throwOnError)throw new N(`Undefined control sequence: `+r,n);i=this.formatUnsupportedCmd(r),this.consume()}return i}formLigatures(e){for(var t=e.length-1,n=0;n<t;++n){var r=e[n];if(r.type===`textord`){var i=r.text,a=e[n+1];if(!(!a||a.type!==`textord`)){if(i===`-`&&a.text===`-`){var o=e[n+2];n+1<t&&o&&o.type===`textord`&&o.text===`-`?(e.splice(n,3,{type:`textord`,mode:`text`,loc:Vc.range(r,o),text:`---`}),t-=2):(e.splice(n,2,{type:`textord`,mode:`text`,loc:Vc.range(r,a),text:`--`}),--t)}(i===`'`||i==="`")&&a.text===i&&(e.splice(n,2,{type:`textord`,mode:`text`,loc:Vc.range(r,a),text:i+i}),--t)}}}}parseSymbol(){var e=this.fetch(),t=e.text;if(/^\\verb[^a-zA-Z]/.test(t)){this.consume();var n=t.slice(5),r=n.charAt(0)===`*`;if(r&&(n=n.slice(1)),n.length<2||n.charAt(0)!==n.slice(-1))throw new N(`\\verb assertion failed --
|
|
322
|
-
please report what input caused this bug`);return n=n.slice(1,-1),{type:`verb`,mode:`text`,body:n,star:r}}Object.prototype.hasOwnProperty.call(nu,t[0])&&!ja[this.mode][t[0]]&&(this.settings.strict&&this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Accented Unicode text character "`+t[0]+`" used in math mode`,e),t=nu[t[0]]+t.slice(1));var i=zl.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(ja[this.mode][t]){this.settings.strict&&this.mode===`math`&&$a.includes(t)&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,e);var o=ja[this.mode][t].group,s=Vc.range(e);a=Ls(o)?{type:`atom`,mode:this.mode,family:o,loc:s,text:t}:{type:o,mode:this.mode,loc:s,text:t}}else if(t.charCodeAt(0)>=128)this.settings.strict&&(Vi(t.charCodeAt(0))?this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Unicode text character "`+t[0]+`" used in math mode`,e):this.settings.reportNonstrict(`unknownSymbol`,`Unrecognized Unicode character "`+t[0]+`"`+(` (`+t.charCodeAt(0)+`)`),e)),a={type:`textord`,mode:`text`,loc:Vc.range(e),text:t};else return null;if(this.consume(),i)for(var c=0;c<i[0].length;c++){var l=i[0][c];if(!tu[l])throw new N(`Unknown accent ' `+l+`'`,e);var u=tu[l][this.mode]||tu[l].text;if(!u)throw new N(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:Vc.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};ru.endOfExpression=new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var iu=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new ru(e,t);delete n.gullet.macros.current[`\\df@tag`];var r=n.parse();if(delete n.gullet.macros.current[`\\current@color`],delete n.gullet.macros.current[`\\color`],n.gullet.macros.get(`\\df@tag`)){if(!t.displayMode)throw new N(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new Hc(`\\df@tag`)])}]}return r},au=function(e,t,n){t.textContent=``;var r=lu(e,n).toNode();t.appendChild(r)};typeof document<`u`&&document.compatMode!==`CSS1Compat`&&(typeof console<`u`&&console.warn(`Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype.`),au=function(){throw new N(`KaTeX doesn't work in quirks mode.`)});var ou=function(e,t){return lu(e,t).toMarkup()},su=function(e,t){return iu(e,new xi(t))},cu=function(e,t,n){if(n.throwOnError||!(e instanceof N))throw e;var r=K([`katex-error`],[new _a(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},lu=function(e,t){var n=new xi(t);try{return Ts(iu(e,n),e,n)}catch(t){return cu(t,e,n)}},uu={version:`0.18.1`,render:au,renderToString:ou,ParseError:N,SETTINGS_SCHEMA:_i,__parse:su,__renderToDomTree:lu,__renderToHTMLTree:function(e,t){var n=new xi(t);try{return Es(iu(e,n),e,n)}catch(t){return cu(t,e,n)}},__setFontMetrics:Da,__defineSymbol:I,__defineFunction:J,__defineMacro:$,__domTree:{Span:pa,Anchor:ma,SymbolNode:_a,SvgNode:va,PathNode:ya,LineNode:ba}},du=[[`$$`,`$$`,!0],[`\\[`,`\\]`,!0],[`\\(`,`\\)`,!1],[`$`,`$`,!1]];function fu(e){return e===`$`||e===`\\`}function pu(e,t=0){for(let[n,r,i]of du){if(!e.startsWith(n,t))continue;let a=t+n.length,o=hu(e,a,r);if(o<0)continue;let s=e.slice(a,o);if(!(s.trim()===``||/\n[ \t]*\n/.test(s))&&!(n===`$`&&!gu(s,e[o+r.length])))return{length:o+r.length-t,tex:s,display:i}}return null}function mu(e,t=0){for(let n=t;n<e.length;n++){if(!fu(e[n]))continue;let t=pu(e,n);if(t)return{...t,start:n}}return null}function hu(e,t,n){for(let r=t;r<e.length;r++){if(e.startsWith(n,r))return r;e[r]===`\\`&&r++}return-1}function gu(e,t){return!/^\s|\s$/.test(e)&&!(t!==void 0&&/\d/.test(t))}function _u(e,t,n={}){let r=uu.renderToString(e,{displayMode:t,output:`html`,throwOnError:!1,errorColor:`var(--danger)`,strict:!1,trust:!1,macros:n});return`<span class="${t?`math math-display`:`math`}" role="math" aria-label="${yu(e)}">${r}</span>`}var vu=`.math-display{display:block}`;function yu(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var bu={},xu=new oi({gfm:!0,breaks:!1,async:!1}).use({extensions:[{name:`math`,level:`inline`,start(e){let t=e.search(/\$|\\[([]/);return t<0?void 0:t},tokenizer(e){let t=pu(e);if(t)return{type:`math`,raw:e.slice(0,t.length),text:t.tex,display:t.display}},renderer(e){return _u(e.text??``,e.display===!0,bu)}}],renderer:{code({text:e,lang:t}){return t===`math`&&_u(e,!0,bu)}}});function Su(e){return bu={},xu.parse(e)}var Cu=`script, style, pre, code, kbd, samp, textarea, math, svg, .katex`,wu=/\bmathjax\b|\bkatex\b/i;function Tu(e){if(Eu(e))return!1;let t=e.body??e.documentElement;if(!t)return!1;let n=e.createTreeWalker(t,NodeFilter.SHOW_TEXT),r=[];for(;n.nextNode();){let e=n.currentNode;/[$\\]/.test(e.data)&&(e.parentElement?.closest(Cu)||r.push(e))}let i={},a=!1;for(let t of r)Du(e,t,i)&&(a=!0);return a}function Eu(e){if(e.querySelector(`.katex, math`))return!0;for(let t of e.querySelectorAll(`script`))if(wu.test(t.getAttribute(`src`)??``)||wu.test(t.textContent??``))return!0;return!1}function Du(e,t,n){let r=t.data;if(!mu(r))return!1;let i=e.createDocumentFragment(),a=e.createElement(`span`),o=0;for(let t=mu(r,0);t;t=mu(r,o)){for(t.start>o&&i.appendChild(e.createTextNode(r.slice(o,t.start))),a.innerHTML=_u(t.tex,t.display,n);a.firstChild;)i.appendChild(a.firstChild);o=t.start+t.length}return o<r.length&&i.appendChild(e.createTextNode(r.slice(o))),t.replaceWith(i),!0}function Ou({session:e,path:t,kind:n,root:r}){let i=ku(e,t,r);return i===null?null:n===`markdown`?(0,O.jsx)(Au,{session:e,path:t,text:i,root:r}):(0,O.jsx)(Nu,{session:e,path:t,text:i,root:r})}function ku(e,t,n){let r=He(e,t,null,n,{passive:!0,live:!0}).model;return(0,D.useSyncExternalStore)(r=>he(E(e,t,n),r),()=>r?.getValue()??null)}On.addHook(`afterSanitizeAttributes`,e=>{e.tagName===`A`&&/^https?:/i.test(e.getAttribute(`href`)??``)&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))});function Au({session:e,path:t,text:n,root:r}){let i=(0,D.useMemo)(()=>On.sanitize(Su(n)),[n]),a=(0,D.useRef)(null);(0,D.useEffect)(()=>{let n=a.current;if(!n)return;let i=!1,o=[];for(let a of n.querySelectorAll(`img`)){let n=ae(t,a.getAttribute(`src`)??``);n&&(a.removeAttribute(`src`),s(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(n)}${f(r)}`).then(e=>e.blob()).then(e=>{if(i)return;let t=URL.createObjectURL(e);o.push(t),a.src=t}).catch(()=>void 0))}return()=>{i=!0;for(let e of o)URL.revokeObjectURL(e)}},[i,e,t,r]);let{openFile:o}=b(),c=n=>{let i=n.target.closest(`a`);if(!i)return;let a=i.getAttribute(`href`)??``;if(/^https?:/i.test(a)||(n.preventDefault(),!n.metaKey&&!n.ctrlKey))return;let s=ae(t,a);s&&o(e,s,void 0,{...ie(s)?{view:`preview`}:{},...r===void 0?{}:{root:r}})},l=oe().editorFontSize;return(0,O.jsx)(`div`,{className:`h-full overflow-y-auto bg-ground`,children:(0,O.jsx)(`div`,{ref:a,onClick:c,style:{fontSize:l},className:`md-preview mx-auto max-w-3xl px-6 py-5 text-fg-secondary`,dangerouslySetInnerHTML:{__html:i}})})}var ju=[[`img`,`src`],[`script`,`src`],[`link[rel~="stylesheet" i]`,`href`],[`link[rel~="icon" i]`,`href`],[`source`,`src`],[`video`,`src`],[`video`,`poster`],[`audio`,`src`]],Mu=20*1024*1024;function Nu({session:e,path:t,text:n,root:r}){let[i,a]=(0,D.useState)(null),o=(0,D.useRef)(new Map),s=oe().editorFontSize;return(0,D.useEffect)(()=>{let i=!1;return Pu(e,t,n,o.current,s,r).then(e=>{i||a(e)}),()=>{i=!0}},[e,t,n,s,r]),i===null?null:(0,O.jsx)(`iframe`,{sandbox:`allow-scripts`,srcDoc:i,title:t,className:`size-full bg-paper`})}async function Pu(e,t,n,r,i,a){let o=new DOMParser().parseFromString(n,`text/html`);if(i!==void 0){let e=o.createElement(`style`);e.textContent=`:where(html) { font-size: ${i}px; }`;let t=o.head??o.documentElement;t.insertBefore(e,t.firstChild)}Tu(o)&&await Fu(o);let s=[];for(let[n,i]of ju)for(let c of o.querySelectorAll(n)){let n=ae(t,c.getAttribute(i)??``);n&&(c.removeAttribute(i),s.push(Iu(e,n,r,a).then(e=>{e&&c.setAttribute(i,e)})))}return await Promise.all(s),`<!doctype html>${o.documentElement.outerHTML}`}async function Fu(e){let{default:t}=await ee(async()=>{let{default:e}=await import(`./_virtual_katex-inline-css-DN-_JSKR.js`);return{default:e}},[]),n=e.createElement(`style`);n.textContent=`${t}\n${vu}`,(e.head??e.documentElement).appendChild(n)}function Iu(e,t,n,r){let i=n.get(t);if(i)return i;let a=s(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(t)}${f(r)}`).then(e=>e.blob()).then(async e=>e.size>Mu?null:`data:${Lu(t,e.type)};base64,${Ru(await e.arrayBuffer())}`).catch(()=>null);return n.set(t,a),a}function Lu(e,t){let n=(e.split(`/`).pop()??``).split(`.`).pop()?.toLowerCase()??``;return n===`css`?`text/css`:n===`js`||n===`mjs`?`text/javascript`:t!==``&&t!==`application/octet-stream`?t:`application/octet-stream`}function Ru(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));return btoa(n)}var zu={png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,webp:`image`,bmp:`image`,ico:`image`,avif:`image`,svg:`image`,mp4:`video`,m4v:`video`,webm:`video`,mov:`video`,mkv:`video`,avi:`video`,mp3:`audio`,wav:`audio`,ogg:`audio`,m4a:`audio`,flac:`audio`,aac:`audio`,pdf:`pdf`};function Bu(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<=0?null:zu[t.slice(n+1).toLowerCase()]??null}function Vu({session:e,path:t,kind:n,root:r}){let{url:i,error:a}=Wu(e,t,r);return a?(0,O.jsxs)(Hu,{children:[(0,O.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Couldn’t load this file.`}),(0,O.jsx)(Uu,{session:e,path:t})]}):i?n===`image`?(0,O.jsx)(Hu,{children:(0,O.jsx)(`img`,{src:i,alt:t,className:`max-h-full max-w-full object-contain`})}):n===`video`?(0,O.jsx)(Hu,{children:(0,O.jsx)(`video`,{src:i,controls:!0,className:`max-h-full max-w-full`})}):n===`audio`?(0,O.jsx)(Hu,{children:(0,O.jsx)(`audio`,{src:i,controls:!0,className:`w-full max-w-xl`})}):(0,O.jsx)(`iframe`,{src:i,title:t,className:`h-full w-full border-0 bg-ground`}):(0,O.jsx)(Hu,{children:(0,O.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`…`})})}function Hu({children:e}){return(0,O.jsx)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 overflow-auto bg-ground p-4`,children:e})}function Uu({session:e,path:t}){return(0,O.jsx)(`button`,{type:`button`,onClick:()=>void h(e,t).catch(e=>r.error(e instanceof Error?e.message:`Download failed`)),className:`rounded-md bg-elevated px-3 py-1.5 text-sm text-fg transition-colors hover:bg-border/70`,children:`Download`})}function Wu(e,t,n){let[r,i]=(0,D.useState)(null),[a,o]=(0,D.useState)(!1);return(0,D.useEffect)(()=>{let r=null,a=!1;return i(null),o(!1),s(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(t)}${f(n)}`).then(e=>e.blob()).then(e=>{a||(r=URL.createObjectURL(e),i(r))}).catch(()=>{a||o(!0)}),()=>{a=!0,r&&URL.revokeObjectURL(r)}},[e,t,n]),{url:r,error:a}}function Gu({tab:e,reveal:t}){let n=ne(e),r=e.view===`preview`||e.view===`linked`,i=e.view===`linked`?`linked:${e.session}:${e.root??``}:${e.path}`:w(e);if(n===`diff`)return(0,O.jsx)(rt,{session:e.session,path:e.path,root:e.root},w(e));if(n===`commit`&&e.sha)return(0,O.jsx)(nt,{session:e.session,sha:e.sha,path:e.path,root:e.root},w(e));if(n===`external`&&e.root!==void 0){let n=Bu(e.path);if(n)return(0,O.jsx)(Vu,{session:e.session,path:e.path,kind:n,root:e.root},w(e));let a=r?ie(e.path):null;return a?(0,O.jsx)(Ou,{session:e.session,path:e.path,kind:a,root:e.root},i):(0,O.jsx)(We,{session:e.session,path:e.path,reveal:t,root:e.root},w(e))}if(n===`untitled`)return(0,O.jsx)(at,{name:e.path},w(e));let a=Bu(e.path);if(a)return(0,O.jsx)(Vu,{session:e.session,path:e.path,kind:a},w(e));let o=r?ie(e.path):null;return o?(0,O.jsx)(Ou,{session:e.session,path:e.path,kind:o},i):(0,O.jsx)(We,{session:e.session,path:e.path,reveal:t},w(e))}export{Gu as PaneEditorBody};
|
|
322
|
+
please report what input caused this bug`);return n=n.slice(1,-1),{type:`verb`,mode:`text`,body:n,star:r}}Object.prototype.hasOwnProperty.call(nu,t[0])&&!ja[this.mode][t[0]]&&(this.settings.strict&&this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Accented Unicode text character "`+t[0]+`" used in math mode`,e),t=nu[t[0]]+t.slice(1));var i=zl.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(ja[this.mode][t]){this.settings.strict&&this.mode===`math`&&$a.includes(t)&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,e);var o=ja[this.mode][t].group,s=Vc.range(e);a=Ls(o)?{type:`atom`,mode:this.mode,family:o,loc:s,text:t}:{type:o,mode:this.mode,loc:s,text:t}}else if(t.charCodeAt(0)>=128)this.settings.strict&&(Vi(t.charCodeAt(0))?this.mode===`math`&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Unicode text character "`+t[0]+`" used in math mode`,e):this.settings.reportNonstrict(`unknownSymbol`,`Unrecognized Unicode character "`+t[0]+`"`+(` (`+t.charCodeAt(0)+`)`),e)),a={type:`textord`,mode:`text`,loc:Vc.range(e),text:t};else return null;if(this.consume(),i)for(var c=0;c<i[0].length;c++){var l=i[0][c];if(!tu[l])throw new N(`Unknown accent ' `+l+`'`,e);var u=tu[l][this.mode]||tu[l].text;if(!u)throw new N(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:Vc.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};ru.endOfExpression=new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var iu=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new ru(e,t);delete n.gullet.macros.current[`\\df@tag`];var r=n.parse();if(delete n.gullet.macros.current[`\\current@color`],delete n.gullet.macros.current[`\\color`],n.gullet.macros.get(`\\df@tag`)){if(!t.displayMode)throw new N(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new Hc(`\\df@tag`)])}]}return r},au=function(e,t,n){t.textContent=``;var r=lu(e,n).toNode();t.appendChild(r)};typeof document<`u`&&document.compatMode!==`CSS1Compat`&&(typeof console<`u`&&console.warn(`Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype.`),au=function(){throw new N(`KaTeX doesn't work in quirks mode.`)});var ou=function(e,t){return lu(e,t).toMarkup()},su=function(e,t){return iu(e,new xi(t))},cu=function(e,t,n){if(n.throwOnError||!(e instanceof N))throw e;var r=K([`katex-error`],[new _a(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},lu=function(e,t){var n=new xi(t);try{return Ts(iu(e,n),e,n)}catch(t){return cu(t,e,n)}},uu={version:`0.18.1`,render:au,renderToString:ou,ParseError:N,SETTINGS_SCHEMA:_i,__parse:su,__renderToDomTree:lu,__renderToHTMLTree:function(e,t){var n=new xi(t);try{return Es(iu(e,n),e,n)}catch(t){return cu(t,e,n)}},__setFontMetrics:Da,__defineSymbol:I,__defineFunction:J,__defineMacro:$,__domTree:{Span:pa,Anchor:ma,SymbolNode:_a,SvgNode:va,PathNode:ya,LineNode:ba}},du=[[`$$`,`$$`,!0],[`\\[`,`\\]`,!0],[`\\(`,`\\)`,!1],[`$`,`$`,!1]];function fu(e){return e===`$`||e===`\\`}function pu(e,t=0){for(let[n,r,i]of du){if(!e.startsWith(n,t))continue;let a=t+n.length,o=hu(e,a,r);if(o<0)continue;let s=e.slice(a,o);if(!(s.trim()===``||/\n[ \t]*\n/.test(s))&&!(n===`$`&&!gu(s,e[o+r.length])))return{length:o+r.length-t,tex:s,display:i}}return null}function mu(e,t=0){for(let n=t;n<e.length;n++){if(!fu(e[n]))continue;let t=pu(e,n);if(t)return{...t,start:n}}return null}function hu(e,t,n){for(let r=t;r<e.length;r++){if(e.startsWith(n,r))return r;e[r]===`\\`&&r++}return-1}function gu(e,t){return!/^\s|\s$/.test(e)&&!(t!==void 0&&/\d/.test(t))}function _u(e,t,n={}){let r=uu.renderToString(e,{displayMode:t,output:`html`,throwOnError:!1,errorColor:`var(--danger)`,strict:!1,trust:!1,macros:n});return`<span class="${t?`math math-display`:`math`}" role="math" aria-label="${yu(e)}">${r}</span>`}var vu=`.math-display{display:block}`;function yu(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var bu={},xu=new oi({gfm:!0,breaks:!1,async:!1}).use({extensions:[{name:`math`,level:`inline`,start(e){let t=e.search(/\$|\\[([]/);return t<0?void 0:t},tokenizer(e){let t=pu(e);if(t)return{type:`math`,raw:e.slice(0,t.length),text:t.tex,display:t.display}},renderer(e){return _u(e.text??``,e.display===!0,bu)}}],renderer:{code({text:e,lang:t}){return t===`math`&&_u(e,!0,bu)}}});function Su(e){return bu={},xu.parse(e)}var Cu=`script, style, pre, code, kbd, samp, textarea, math, svg, .katex`,wu=/\bmathjax\b|\bkatex\b/i;function Tu(e){if(Eu(e))return!1;let t=e.body??e.documentElement;if(!t)return!1;let n=e.createTreeWalker(t,NodeFilter.SHOW_TEXT),r=[];for(;n.nextNode();){let e=n.currentNode;/[$\\]/.test(e.data)&&(e.parentElement?.closest(Cu)||r.push(e))}let i={},a=!1;for(let t of r)Du(e,t,i)&&(a=!0);return a}function Eu(e){if(e.querySelector(`.katex, math`))return!0;for(let t of e.querySelectorAll(`script`))if(wu.test(t.getAttribute(`src`)??``)||wu.test(t.textContent??``))return!0;return!1}function Du(e,t,n){let r=t.data;if(!mu(r))return!1;let i=e.createDocumentFragment(),a=e.createElement(`span`),o=0;for(let t=mu(r,0);t;t=mu(r,o)){for(t.start>o&&i.appendChild(e.createTextNode(r.slice(o,t.start))),a.innerHTML=_u(t.tex,t.display,n);a.firstChild;)i.appendChild(a.firstChild);o=t.start+t.length}return o<r.length&&i.appendChild(e.createTextNode(r.slice(o))),t.replaceWith(i),!0}function Ou({session:e,path:t,kind:n,root:r}){let i=ku(e,t,r);return i===null?null:n===`markdown`?(0,O.jsx)(Au,{session:e,path:t,text:i,root:r}):(0,O.jsx)(Nu,{session:e,path:t,text:i,root:r})}function ku(e,t,n){let r=He(e,t,null,n,{passive:!0,live:!0}).model;return(0,D.useSyncExternalStore)(r=>he(E(e,t,n),r),()=>r?.getValue()??null)}On.addHook(`afterSanitizeAttributes`,e=>{e.tagName===`A`&&/^https?:/i.test(e.getAttribute(`href`)??``)&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))});function Au({session:e,path:t,text:n,root:r}){let i=(0,D.useMemo)(()=>On.sanitize(Su(n)),[n]),a=(0,D.useRef)(null);(0,D.useEffect)(()=>{let n=a.current;if(!n)return;let i=!1,o=[];for(let a of n.querySelectorAll(`img`)){let n=ae(t,a.getAttribute(`src`)??``);n&&(a.removeAttribute(`src`),s(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(n)}${l(r)}`).then(e=>e.blob()).then(e=>{if(i)return;let t=URL.createObjectURL(e);o.push(t),a.src=t}).catch(()=>void 0))}return()=>{i=!0;for(let e of o)URL.revokeObjectURL(e)}},[i,e,t,r]);let{openFile:o}=b(),c=n=>{let i=n.target.closest(`a`);if(!i)return;let a=i.getAttribute(`href`)??``;if(/^https?:/i.test(a)||(n.preventDefault(),!n.metaKey&&!n.ctrlKey))return;let s=ae(t,a);s&&o(e,s,void 0,{...ie(s)?{view:`preview`}:{},...r===void 0?{}:{root:r}})},u=oe().editorFontSize;return(0,O.jsx)(`div`,{className:`h-full overflow-y-auto bg-ground`,children:(0,O.jsx)(`div`,{ref:a,onClick:c,style:{fontSize:u},className:`md-preview mx-auto max-w-3xl px-6 py-5 text-fg-secondary`,dangerouslySetInnerHTML:{__html:i}})})}var ju=[[`img`,`src`],[`script`,`src`],[`link[rel~="stylesheet" i]`,`href`],[`link[rel~="icon" i]`,`href`],[`source`,`src`],[`video`,`src`],[`video`,`poster`],[`audio`,`src`]],Mu=20*1024*1024;function Nu({session:e,path:t,text:n,root:r}){let[i,a]=(0,D.useState)(null),o=(0,D.useRef)(new Map),s=oe().editorFontSize;return(0,D.useEffect)(()=>{let i=!1;return Pu(e,t,n,o.current,s,r).then(e=>{i||a(e)}),()=>{i=!0}},[e,t,n,s,r]),i===null?null:(0,O.jsx)(`iframe`,{sandbox:`allow-scripts`,srcDoc:i,title:t,className:`size-full bg-paper`})}async function Pu(e,t,n,r,i,a){let o=new DOMParser().parseFromString(n,`text/html`);if(i!==void 0){let e=o.createElement(`style`);e.textContent=`:where(html) { font-size: ${i}px; }`;let t=o.head??o.documentElement;t.insertBefore(e,t.firstChild)}Tu(o)&&await Fu(o);let s=[];for(let[n,i]of ju)for(let c of o.querySelectorAll(n)){let n=ae(t,c.getAttribute(i)??``);n&&(c.removeAttribute(i),s.push(Iu(e,n,r,a).then(e=>{e&&c.setAttribute(i,e)})))}return await Promise.all(s),`<!doctype html>${o.documentElement.outerHTML}`}async function Fu(e){let{default:t}=await ee(async()=>{let{default:e}=await import(`./_virtual_katex-inline-css-DN-_JSKR.js`);return{default:e}},[]),n=e.createElement(`style`);n.textContent=`${t}\n${vu}`,(e.head??e.documentElement).appendChild(n)}function Iu(e,t,n,r){let i=n.get(t);if(i)return i;let a=s(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(t)}${l(r)}`).then(e=>e.blob()).then(async e=>e.size>Mu?null:`data:${Lu(t,e.type)};base64,${Ru(await e.arrayBuffer())}`).catch(()=>null);return n.set(t,a),a}function Lu(e,t){let n=(e.split(`/`).pop()??``).split(`.`).pop()?.toLowerCase()??``;return n===`css`?`text/css`:n===`js`||n===`mjs`?`text/javascript`:t!==``&&t!==`application/octet-stream`?t:`application/octet-stream`}function Ru(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r)n+=String.fromCharCode(...t.subarray(e,e+r));return btoa(n)}var zu={png:`image`,jpg:`image`,jpeg:`image`,gif:`image`,webp:`image`,bmp:`image`,ico:`image`,avif:`image`,svg:`image`,mp4:`video`,m4v:`video`,webm:`video`,mov:`video`,mkv:`video`,avi:`video`,mp3:`audio`,wav:`audio`,ogg:`audio`,m4a:`audio`,flac:`audio`,aac:`audio`,pdf:`pdf`};function Bu(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<=0?null:zu[t.slice(n+1).toLowerCase()]??null}function Vu({session:e,path:t,kind:n,root:r}){let{url:i,error:a}=Wu(e,t,r);return a?(0,O.jsxs)(Hu,{children:[(0,O.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Couldn’t load this file.`}),(0,O.jsx)(Uu,{session:e,path:t})]}):i?n===`image`?(0,O.jsx)(Hu,{children:(0,O.jsx)(`img`,{src:i,alt:t,className:`max-h-full max-w-full object-contain`})}):n===`video`?(0,O.jsx)(Hu,{children:(0,O.jsx)(`video`,{src:i,controls:!0,className:`max-h-full max-w-full`})}):n===`audio`?(0,O.jsx)(Hu,{children:(0,O.jsx)(`audio`,{src:i,controls:!0,className:`w-full max-w-xl`})}):(0,O.jsx)(`iframe`,{src:i,title:t,className:`h-full w-full border-0 bg-ground`}):(0,O.jsx)(Hu,{children:(0,O.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`…`})})}function Hu({children:e}){return(0,O.jsx)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 overflow-auto bg-ground p-4`,children:e})}function Uu({session:e,path:t}){return(0,O.jsx)(`button`,{type:`button`,onClick:()=>void C(e,t).catch(e=>r.error(e instanceof Error?e.message:`Download failed`)),className:`rounded-md bg-elevated px-3 py-1.5 text-sm text-fg transition-colors hover:bg-border/70`,children:`Download`})}function Wu(e,t,n){let[r,i]=(0,D.useState)(null),[a,o]=(0,D.useState)(!1);return(0,D.useEffect)(()=>{let r=null,a=!1;return i(null),o(!1),s(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(t)}${l(n)}`).then(e=>e.blob()).then(e=>{a||(r=URL.createObjectURL(e),i(r))}).catch(()=>{a||o(!0)}),()=>{a=!0,r&&URL.revokeObjectURL(r)}},[e,t,n]),{url:r,error:a}}function Gu({tab:e,reveal:t}){let n=ne(e),r=e.view===`preview`||e.view===`linked`,i=e.view===`linked`?`linked:${e.session}:${e.root??``}:${e.path}`:w(e);if(n===`diff`)return(0,O.jsx)(rt,{session:e.session,path:e.path,root:e.root},w(e));if(n===`commit`&&e.sha)return(0,O.jsx)(nt,{session:e.session,sha:e.sha,path:e.path,root:e.root},w(e));if(n===`external`&&e.root!==void 0){let n=Bu(e.path);if(n)return(0,O.jsx)(Vu,{session:e.session,path:e.path,kind:n,root:e.root},w(e));let a=r?ie(e.path):null;return a?(0,O.jsx)(Ou,{session:e.session,path:e.path,kind:a,root:e.root},i):(0,O.jsx)(We,{session:e.session,path:e.path,reveal:t,root:e.root},w(e))}if(n===`untitled`)return(0,O.jsx)(at,{name:e.path},w(e));let a=Bu(e.path);if(a)return(0,O.jsx)(Vu,{session:e.session,path:e.path,kind:a},w(e));let o=r?ie(e.path):null;return o?(0,O.jsx)(Ou,{session:e.session,path:e.path,kind:o},i):(0,O.jsx)(We,{session:e.session,path:e.path,reveal:t},w(e))}export{Gu as PaneEditorBody};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{A as r,B as i,F as a,M as o,N as s,P as c,_ as l,a as u,d,h as f,i as p,j as m,n as h,t as g}from"./hotkeys-BoAqfYKZ.js";import{a as _,g as v,i as y,n as b,o as x,r as S,t as C}from"./dialog-B43iKmfK.js";import{a as w,c as T,i as E,l as D,o as ee,r as O,s as k}from"./LazyTerminal-CWtg2h0c.js";import{t as A}from"./utils-B6KiDbIe.js";import{t as j}from"./createLucideIcon-DyMAgLa3.js";import{a as M,i as N,n as te,o as P,r as F,s as ne,t as re}from"./session-seed-CDI_3Kiu.js";import{r as ie}from"./dist-i-QevsUb.js";import{$ as ae,$t as I,Bt as oe,Cn as se,Dn as ce,Dt as le,Et as ue,G as de,Gt as fe,H as pe,J as me,K as he,Kt as ge,Nt as _e,Ot as ve,Pt as ye,Q as be,Qt as xe,R as L,Rt as Se,St as Ce,Tt as we,U as Te,Ut as Ee,V as R,W as De,X as z,Xt as Oe,Y as B,Yt as ke,an as V,bt as Ae,en as H,et as je,fn as Me,ht as Ne,in as U,mt as Pe,ot as Fe,pn as Ie,pt as Le,q as Re,qt as ze,r as Be,rn as Ve,rt as He,sn as Ue,tn as W,tt as We,vt as Ge,xt as Ke,yt as qe,zt as Je}from"./index-DyI3xhOE.js";var Ye=j(`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`}]]),Xe=j(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Ze=j(`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`}]]),Qe=j(`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`}]]),$e=j(`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`}]]),et=j(`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`}]]),tt=j(`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`}]]),nt=j(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),G=e(t(),1),K=n();function q({id:e,value:t,min:n,max:r,step:i,className:a,onCommit:o}){let[s,c]=(0,G.useState)(String(t));return(0,G.useEffect)(()=>c(String(t)),[t]),(0,K.jsx)(T,{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 J({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,K.jsxs)(`div`,{className:A(`flex items-center gap-4 py-2.5`,a),children:[(0,K.jsxs)(`label`,{htmlFor:r,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,K.jsx)(`span`,{className:A(`text-xs text-fg-muted`,n),children:t})]}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function Y({children:e,note:t}){return(0,K.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function rt(){let e=z(),[t,n]=(0,G.useState)(ce());return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Appearance`}),(0,K.jsx)(J,{label:`Theme`,children:(0,K.jsxs)(te,{value:t,onValueChange:e=>{n(e),se(e)},children:[(0,K.jsx)(M,{className:`w-32`,children:(0,K.jsx)(P,{})}),(0,K.jsxs)(F,{children:[(0,K.jsx)(N,{value:`dark`,children:`Dark`}),(0,K.jsx)(N,{value:`light`,children:`Light`}),(0,K.jsx)(N,{value:`system`,children:`System`})]})]})}),(0,K.jsx)(J,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,K.jsx)(q,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>B({uiFontSize:e})})}),(0,K.jsx)(J,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,K.jsx)(q,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>B({terminalFontSize:e})})}),(0,K.jsx)(J,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,K.jsx)(q,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>B({editorFontSize:e})})}),(0,K.jsx)(J,{label:`Density`,children:(0,K.jsxs)(te,{value:e.density,onValueChange:e=>B({density:e}),children:[(0,K.jsx)(M,{className:`w-36`,children:(0,K.jsx)(P,{})}),(0,K.jsxs)(F,{children:[(0,K.jsx)(N,{value:`compact`,children:`Compact`}),(0,K.jsx)(N,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,K.jsx)(J,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,K.jsx)(L,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>B({projectBasedLayout:e})})}),(0,K.jsx)(J,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,K.jsx)(L,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>B({showAllProjectSessions:e})})})]})}function it({profile:e}){let t=H(),[n,r]=(0,G.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>E(e)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>E(e)});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(J,{label:`Icon`,children:(0,K.jsxs)(ae,{open:n,onOpenChange:r,children:[(0,K.jsx)(We,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,className:`flex size-9 items-center justify-center rounded-md text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(Ge,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,K.jsx)(je,{align:`end`,className:`w-72`,children:(0,K.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,K.jsx)(`button`,{type:`button`,title:`Default`,onClick:()=>i(null),className:A(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,!e.icon&&`bg-elevated text-fg`),children:(0,K.jsx)(Ge,{icon:null,colour:null,className:`size-4`})}),Ae.map(({name:t,Icon:n})=>(0,K.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:A(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,e.icon===t&&`bg-elevated text-fg`),children:(0,K.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,K.jsx)(J,{label:`Icon colour`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,K.jsxs)(`button`,{type:`button`,title:`Default`,onClick:()=>a(null),className:A(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,!e.icon_colour&&`bg-elevated`),children:[(0,K.jsx)(`span`,{className:`size-3.5 rounded-full bg-fg-muted`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Default colour`})]}),c.map(t=>(0,K.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:A(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,e.icon_colour===t&&`bg-elevated`),children:[(0,K.jsx)(`span`,{className:A(`size-3.5 rounded-full bg-current`,qe(t))}),(0,K.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var X=`__none__`;function at(){let e=l(),t=V().data?.find(t=>t.id===e),n=_e(e??void 0),r=U(e??void 0),i=H(),a=W(e??``),o=fe(),[s,c]=(0,G.useState)(``),[u,d]=(0,G.useState)(``),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(``);if((0,G.useEffect)(()=>{t&&(c(t.name),d(t.branch_prefix))},[t]),!t)return null;let w=r.data?.default_account_id;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Profile`}),(0,K.jsxs)(J,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,K.jsx)(T,{id:`profile-name`,value:s,onChange:e=>c(e.target.value),className:`w-44`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:s===t.name||s.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:s},{onError:e=>E(e)}),children:`Save`})]}),(0,K.jsxs)(J,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,K.jsx)(T,{id:`branch-prefix`,value:u,onChange:e=>d(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:u===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:u},{onError:e=>E(e)}),children:`Save`})]}),(0,K.jsx)(it,{profile:t}),(0,K.jsx)(J,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,K.jsxs)(te,{value:typeof w==`number`?String(w):X,onValueChange:e=>a.mutate({default_account_id:e===X?null:Number(e)},{onError:e=>E(e)}),children:[(0,K.jsx)(M,{className:`w-56`,children:(0,K.jsx)(P,{})}),(0,K.jsxs)(F,{children:[(0,K.jsx)(N,{value:X,children:`First available`}),n.data?.map(e=>(0,K.jsx)(N,{value:String(e.id),children:(0,K.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,K.jsx)(J,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,K.jsx)(v,{variant:`danger`,size:`sm`,onClick:()=>m(!0),children:`Delete…`})}),(0,K.jsx)(C,{open:p,onOpenChange:e=>{e||(m(!1),g(``))},children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Delete profile `,(0,K.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,K.jsx)(S,{children:`Everything this profile owns goes with it: projects, workspace layouts, accounts and their credential directories, and archived session history. Branches, repositories, and terminal logs on disk are untouched. This cannot be undone.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(k,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,K.jsx)(T,{id:`delete-confirm-name`,value:h,onChange:e=>g(e.target.value),autoFocus:!0})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>{m(!1),g(``)},children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:h!==t.name||o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>{Le(),f.set(null)},onError:e=>{m(!1),g(``),E(e)}}),children:`Delete profile`})]})]})})]})}function ot({agent:e,profileId:t,onClose:n,onCreated:r}){let i=Je(),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(``),l=ge(Fe(s,150)),u=s.trim(),d=u===``||u.startsWith(`/`)||u.startsWith(`~`),f=a.trim()!==``&&d,p=()=>{!f||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...u===``?{}:{import_dir:u}},{onSuccess:e=>{n(),r(e,u!==``)},onError:e=>E(e)})};return(0,K.jsx)(C,{open:!0,onOpenChange:e=>!e&&n(),children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Add a `,e.display_name,` account`]}),(0,K.jsxs)(S,{children:[`Accounts are isolated config dirs under this profile. Naming one is enough — Puddle creates it and takes you straight to `,e.display_name,`’s login. To reuse an account you already have on this machine, give its config directory: it is copied in and the original is never touched.`]})]}),(0,K.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,K.jsx)(T,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,K.jsx)(O,{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,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,K.jsxs)(v,{disabled:!f||i.isPending,onClick:p,children:[(0,K.jsx)(ue,{}),`Add account`]})]})]})})}function st({account:e,gateOpen:t,installed:n}){let r=Oe(),i=xe(),a=Ee(),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(e.label),f=(0,G.useRef)(null);return(0,G.useEffect)(()=>d(e.label),[e.label]),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{ref:f,value:u,onChange:e=>d(e.target.value),onBlur:()=>{let t=u.trim();if(t!==e.label){if(t===``){d(e.label);return}i.mutate({id:e.id,label:t},{onError:t=>{E(t),d(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(d(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full min-w-0 truncate rounded-sm bg-transparent px-1 py-0.5 text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,K.jsxs)(`button`,{type:`button`,title:`Rename account`,onClick:()=>{f.current?.focus(),f.current?.select()},className:`shrink-0 rounded-sm p-0.5 text-fg-muted transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(w,{className:`size-3`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Rename account`})]})]}),(0,K.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,K.jsx)(L,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>E(e)})})]}),(0,K.jsxs)(v,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>E(e)}),children:[(0,K.jsx)(ve,{}),e.logged_in?`Re-login`:`Login`]}),(0,K.jsxs)(v,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,K.jsx)(Ce,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,K.jsx)(be,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,K.jsx)(C,{open:c,onOpenChange:l,children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Delete `,(0,K.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,K.jsx)(S,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),E(e)}}),children:`Delete account`})]})]})})]})}function ct(){let e=l(),t=ye(),n=_e(e??void 0),r=U(e??void 0),a=Oe(),[o,s]=(0,G.useState)(null),[c,u]=(0,G.useState)(null),d=r.data?.allowSkipPermissions===!0;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[],r=e.available!==!1;return(0,K.jsxs)(`div`,{className:`mb-5`,children:[(0,K.jsx)(J,{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,K.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.id})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,K.jsx)(st,{account:t,gateOpen:d&&e.capabilities.skip_permissions,installed:r},t.id)),(0,K.jsx)(`div`,{className:`flex`,children:(0,K.jsxs)(v,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>u(e),children:[(0,K.jsx)(ue,{}),`Add account`]})})]})]},e.id)}),o&&(0,K.jsx)(be,{stream:o.stream,label:o.label,hint:o.hint,onClose:()=>s(null)}),c!==null&&e!==null&&(0,K.jsx)(ot,{agent:c,profileId:e,onClose:()=>u(null),onCreated:(e,t)=>{if(t){e.logged_in||i.info(`Imported without credentials — press Login to authenticate.`);return}a.mutate(e.id,{onSuccess:t=>s({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>E(e)})}})]})}function lt(){let e=Se(),t=I(),[n,r]=(0,G.useState)(``);return(0,G.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,K.jsx)(J,{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,K.jsx)(T,{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=re(e,n),o=n.sessionDefaults??{},[s,c]=(0,G.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,K.jsx)(J,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,K.jsx)(T,{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,K.jsx)(J,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,K.jsx)(L,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,K.jsx)(J,{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,K.jsx)(L,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function dt(){return(0,K.jsx)(J,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,K.jsx)(q,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:z().terminalScrollback,onCommit:e=>B({terminalScrollback:e})})})}function ft({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,G.useState)(r);return(0,K.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,K.jsx)(D,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,K.jsx)(v,{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,G.useState)(e),o=r.length>0?r:s;return(0,K.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,K.jsx)(T,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:s}),(0,K.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,K.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:He(pt,o)})]}),(0,K.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:a.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,K.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,K.jsx)(v,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(s),t(s)},children:`Reset to default`})]})]})}function ht(){let e=l(),t=V().data?.find(t=>t.id===e),n=U(e??void 0),i=W(e??``),[a,s]=(0,G.useState)(!1),[c,u]=(0,G.useState)(``),d=n.data?.allowSkipPermissions===!0,f=e=>i.mutate({allowSkipPermissions:e},{onSuccess:()=>{s(!1),u(``)},onError:e=>E(e)}),p=e=>t=>i.mutate({[e]:t},{onError:e=>E(e)});return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Sessions`}),(0,K.jsx)(J,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,K.jsx)(L,{id:`gate`,checked:d,onCheckedChange:e=>{e?s(!0):f(!1)}})}),(0,K.jsx)(J,{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,K.jsx)(L,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:i.isPending,onCheckedChange:e=>i.mutate({captureSessionEnv:e},{onError:e=>E(e)})})}),(0,K.jsx)(lt,{}),(0,K.jsx)(dt,{}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{children:`New session defaults`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ut,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>i.mutate({sessionDefaults:e},{onError:e=>E(e)}),pending:i.isPending},`${e}:agent-seed`),(0,K.jsx)(ut,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>i.mutate({sessionDefaults:e},{onError:e=>E(e)}),pending:i.isPending},`${e}:terminal-seed`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{note:`Sent to agent as opening message when a session (re)starts. You can make this empty.`,children:`Launch text`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ft,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??m,defaultText:m,onSave:p(`onboardingTemplate`),pending:i.isPending},`${e}:onboarding`),(0,K.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??r,defaultText:r,onSave:p(`concurrentTemplate`),pending:i.isPending},`${e}:concurrent`),(0,K.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??o,defaultText:o,onSave:p(`restartTemplate`),pending:i.isPending},`${e}:restart`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{children:`Tab title`}),n.data&&(0,K.jsx)(mt,{initial:n.data.tabTitleTemplate||"${name}",onSave:p(`tabTitleTemplate`),pending:i.isPending},`${e}:tab-title`)]}),(0,K.jsx)(C,{open:a,onOpenChange:e=>{e||(s(!1),u(``))},children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{className:`flex items-center gap-2`,children:[(0,K.jsx)(et,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,K.jsx)(S,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,K.jsx)(`p`,{children:`A prompt-free agent acts unattended, with your credentials, inside its worktree — and nothing technically stops a shell command from reaching outside it. It can:`}),(0,K.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,K.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,K.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,K.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,K.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,K.jsx)(`p`,{children:`Only open this gate if every account you opt in runs work you would trust a colleague to run unsupervised on this machine.`}),(0,K.jsx)(`p`,{className:`text-fg-muted`,children:`Opening it also records the agent’s own bypass-permissions acceptance for this profile’s accounts, so the skip actually takes effect.`})]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(k,{htmlFor:`confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,K.jsx)(T,{id:`confirm-name`,value:c,onChange:e=>u(e.target.value),autoFocus:!0})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>{s(!1),u(``)},children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:c!==t?.name||i.isPending,onClick:()=>f(!0),children:`Open the gate`})]})]})})]})}var gt={desktop:!0,sound:!1,muted_projects:[]};function _t(){let[e,t]=(0,G.useState)(R);return(0,G.useEffect)(()=>{let e=()=>t(R());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(R())]}function vt({permission:e,onRequest:t}){return e===`granted`?null:(0,K.jsxs)(`p`,{className:`pb-2 text-xs text-warning`,children:[e==="default"&&(0,K.jsxs)(K.Fragment,{children:[`The browser has not been asked for permission yet, so nothing will show —`,` `,(0,K.jsx)(`button`,{type:`button`,onClick:t,className:`underline underline-offset-2 transition-colors hover:text-fg`,children:`request it now`}),`.`]}),e===`denied`&&`Blocked by the browser — allow notifications for this site in its site settings, then return here.`,e===`unsupported`&&`This browser cannot show desktop notifications.`]})}function yt(){let e=l(),t=U(e??void 0),n=W(e??``),r=Ue(e??void 0),[i,a]=_t(),o={...gt,...t.data?.notifications??{}},s=e=>n.mutate({notifications:e},{onError:e=>E(e)}),c=()=>{typeof Notification>`u`||Notification.requestPermission().then(a)};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Notifications`}),(0,K.jsx)(J,{label:`Desktop notification on waiting`,htmlFor:`notify-desktop`,children:(0,K.jsx)(L,{id:`notify-desktop`,checked:o.desktop,onCheckedChange:e=>{e&&c(),s({...o,desktop:e})}})}),o.desktop&&(0,K.jsx)(vt,{permission:i,onRequest:c}),(0,K.jsx)(J,{label:`Sound`,htmlFor:`notify-sound`,children:(0,K.jsx)(L,{id:`notify-sound`,checked:o.sound,onCheckedChange:e=>s({...o,sound:e})})}),(0,K.jsx)(J,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,K.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[o.muted_projects.length,` muted`]})}),(0,K.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.data?.map(e=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,K.jsx)(L,{checked:o.muted_projects.includes(e.id),onCheckedChange:t=>s({...o,muted_projects:t?[...o.muted_projects,e.id]:o.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function bt(){let e=z();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Editor`}),(0,K.jsx)(J,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,K.jsx)(q,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>B({editorTabSize:e})})}),(0,K.jsx)(J,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,K.jsx)(L,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>B({editorWordWrap:e})})}),(0,K.jsx)(J,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,K.jsx)(T,{id:`editor-link-host`,type:`text`,placeholder:Be.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>B({editorLinkSshHost:e.target.value})})})]})}function xt({value:e,isDefault:t,onRecord:n,onReset:r}){let[i,a]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>a(!0),onBlur:()=>a(!1),onKeyDown:e=>{if(!i)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){a(!1);return}let t=p(e.nativeEvent);t&&(n(t),a(!1))},className:A(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,i?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:i?`Press keys…`:u(e)}),!t&&(0,K.jsxs)(`button`,{type:`button`,title:`Reset to default`,onClick:r,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(Qe,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function St(){let e=l(),t=U(e??void 0),n=W(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of g){let t=i(e.id,d(e));a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>E(e)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>E(e)})};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Hotkeys`}),(0,K.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),(0,K.jsx)(J,{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,K.jsx)(L,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>E(e)})})}),h.map(e=>{let t=g.filter(t=>t.group===e);return t.length===0?null:(0,K.jsxs)(`div`,{className:`mb-5`,children:[(0,K.jsx)(`div`,{className:`mb-1 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e}),t.map(e=>{let t=i(e.id,d(e)),n=(a.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,K.jsx)(J,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,K.jsx)(xt,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(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 de.map(e=>e.id)}function It({selected:e,onToggle:t}){return(0,K.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:de.map(n=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(L,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function Lt(){let e=l(),t=U(e??void 0),n=V().data?.find(t=>t.id===e),r=Ie(e??void 0,void 0),a=W(e??``),o=H(),s=oe(),c=Te(),u=De(),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(!1),[_,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(Ft),S=n&&c.data?pe(c.data.file,n.name):void 0,C=S?.enabled===!0,w=C&&S?S.groups:b,T=()=>({client:me(),theme:ce(),profileSettings:t.data??{},profile:n??{},scratchpad:r.data??[]}),ee={setClient:e=>B(e),setTheme:e=>{typeof e==`string`&&se(e)},patchProfileSettings:e=>a.mutate(e,{onError:e=>E(e)}),patchProfileColumns:t=>{e&&o.mutate({id:e,...t},{onError:e=>E(e)})},createScratchpad:t=>{if(e)for(let n of t)s.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},O=(e,t)=>{n&&u.mutate({profile:n.name,entry:{enabled:e.enabled??C,groups:t,doc:Re(t,T()),updatedAt:new Date().toISOString()}},{onError:e=>E(e)})},k=(e,t)=>{let n=t?[...w,e]:w.filter(t=>t!==e);x(n),localStorage.setItem(Pt,JSON.stringify(n)),C&&O({},n)},A=async()=>{y(!0);try{let e=he(await Nt(d.trim()),ee,{profileSettings:t.data??{},scratchpad:r.data??[]});e.length===0?i.error(`Nothing recognised to import.`):(i.success(`Imported ${e.join(`, `)}.`),f(``))}catch(e){i.error(e.message)}finally{y(!1)}},j=async()=>{y(!0);try{let e=await Mt(Re(w,T()));m(e),await navigator.clipboard?.writeText(e),i.success(`Copied to clipboard`)}finally{y(!1)}};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Sync`}),(0,K.jsx)(`p`,{className:`mb-5 text-xs text-fg-muted`,children:`Carry your settings between machines. Accounts, repositories, and anything host-specific are never included. Applies to this profile.`}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),c.data?.available===!1?(0,K.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:`Not available in this cockpit — start the UI with the Puddle CLI to sync across windows.`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Sync selected groups through this machine’s`,` `,(0,K.jsx)(`span`,{className:`text-fg-secondary`,children:`~/.puddle`}),`, so every Puddle window stays in step for profiles named`,` `,(0,K.jsx)(`span`,{className:`text-fg-secondary`,children:n?.name??`…`}),`.`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(L,{checked:C,disabled:!n||c.isLoading||u.isPending,onCheckedChange:e=>O({enabled:e},w)}),`Sync locally`]})]})]}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`flex items-center gap-1 text-xs text-fg-secondary transition-colors hover:text-fg`,children:[h?(0,K.jsx)(ne,{className:`size-3.5`}):(0,K.jsx)(ie,{className:`size-3.5`}),`Choose what to sync`]}),h&&(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(It,{selected:w,onToggle:k})})]}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,K.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:`Builds a Puddle magic string that encodes settings from the checklist above.`}),(0,K.jsx)(v,{size:`sm`,disabled:_,onClick:()=>void j(),children:`Export & copy`}),p&&(0,K.jsx)(D,{readOnly:!0,value:p,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`mt-2 resize-y font-mono text-xs`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,K.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste a Puddle magic string to import its settings.`}),(0,K.jsx)(D,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:`Paste a settings export…`,rows:3,spellCheck:!1,className:`resize-y font-mono text-xs`}),(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(v,{size:`sm`,disabled:!d.trim()||_,onClick:()=>void A(),children:`Import`})})]})]})}function Rt({repo:e}){let t=Ve(),n=ze(),[r,a]=(0,G.useState)(e.default_base_branch),[o,s]=(0,G.useState)(e.onboarding_notes??``),c=e=>E(e);return(0,K.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.path}),(0,K.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,K.jsxs)(v,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>i.success(`Fetched.`),onError:c}),children:[(0,K.jsx)(we,{}),`Fetch now`]})]}),(0,K.jsxs)(J,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,K.jsx)(T,{id:`base-${e.id}`,value:r,onChange:e=>a(e.target.value),className:`w-40`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:r===e.default_base_branch||t.isPending,onClick:()=>t.mutate({id:e.id,default_base_branch:r},{onError:c}),children:`Save`})]}),(0,K.jsx)(J,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,K.jsx)(L,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:c})})}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Standing setup rules, injected into every fresh worktree. Agents update them via .puddle/onboarding-notes.md.`})]}),(0,K.jsx)(D,{id:`notes-${e.id}`,value:o,onChange:e=>s(e.target.value),rows:4}),(0,K.jsx)(`div`,{children:(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:o===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:o},{onError:c}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,K.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Orphan worktrees — directories no session claims. Puddle never deletes these automatically; remove them by hand if unwanted.`}),(0,K.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,K.jsx)(`li`,{className:`truncate text-2xs text-fg-muted`,children:e},e))})]})]})}function zt(){let e=Me();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Projects`}),e.data?.length===0&&(0,K.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,K.jsx)(Rt,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=I();return(0,K.jsx)(J,{label:e,description:t,htmlFor:`host-${n}`,children:(0,K.jsx)(T,{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=>E(e)})}})})}function Bt(){let e=Se(),t=I(),n=ke();return e.data?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{note:`Affects all profiles on this host`,children:`Host`}),(0,K.jsx)(J,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,K.jsx)(T,{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=>E(e)})}})}),(0,K.jsx)($,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,K.jsx)($,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,K.jsx)($,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,K.jsx)($,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,K.jsx)(J,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,K.jsx)(L,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>E(e)})})})]}):null}var Vt=[{id:`appearance`,label:`Appearance`,icon:le,render:()=>(0,K.jsx)(rt,{})},{id:`profile`,label:`Profile`,icon:Ke,render:()=>(0,K.jsx)(at,{})},{id:`accounts`,label:`Accounts`,icon:nt,render:()=>(0,K.jsx)(ct,{})},{id:`sessions`,label:`Sessions`,icon:tt,render:()=>(0,K.jsx)(ht,{})},{id:`editor`,label:`Editor`,icon:Xe,render:()=>(0,K.jsx)(bt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Ze,render:()=>(0,K.jsx)(St,{})},{id:`notifications`,label:`Notifications`,icon:Ye,render:()=>(0,K.jsx)(yt,{})},{id:`projects`,label:`Projects`,icon:ee,render:()=>(0,K.jsx)(zt,{})},{id:`host`,label:`Host`,icon:$e,render:()=>(0,K.jsx)(Bt,{})},{id:`sync`,label:`Sync`,icon:we,render:()=>(0,K.jsx)(Lt,{})}],Ht={terminal:`sessions`,repositories:`projects`};function Ut(){let e=Ne(),t=e===null?null:Ht[e]??e,n=Vt.find(e=>e.id===t)??Vt[0];return(0,K.jsx)(C,{open:e!==null,onOpenChange:e=>!e&&Le(),children:(0,K.jsxs)(b,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,K.jsx)(x,{className:`sr-only`,children:`Settings`}),(0,K.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,K.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),Vt.map(({id:e,label:t,icon:r})=>(0,K.jsxs)(`button`,{onClick:()=>Pe(e),className:A(`flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors`,e===n.id?`bg-elevated text-fg`:`text-fg-secondary hover:bg-elevated hover:text-fg`),children:[(0,K.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]}),(0,K.jsx)(`div`,{className:`overflow-y-auto p-5`,children:n.render()})]})})}export{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{A as r,B as i,F as a,M as o,N as s,P as c,_ as l,a as u,d,h as f,i as p,j as m,n as h,t as g}from"./hotkeys-CGVAxX-R.js";import{a as _,g as v,i as y,n as b,o as x,r as S,t as C}from"./dialog-B43iKmfK.js";import{a as w,c as T,i as E,l as D,o as ee,r as O,s as k}from"./LazyTerminal-BChKrpra.js";import{t as A}from"./utils-B6KiDbIe.js";import{t as j}from"./createLucideIcon-DyMAgLa3.js";import{a as M,i as N,n as te,o as P,r as F,s as ne,t as re}from"./session-seed-CyQ88dyB.js";import{r as ie}from"./dist-i-QevsUb.js";import{$ as ae,$t as I,Bt as oe,Cn as se,Dn as ce,Dt as le,Et as ue,G as de,Gt as fe,H as pe,J as me,K as he,Kt as ge,Nt as _e,Ot as ve,Pt as ye,Q as be,Qt as xe,R as L,Rt as Se,St as Ce,Tt as we,U as Te,Ut as Ee,V as R,W as De,X as z,Xt as Oe,Y as B,Yt as ke,an as V,bt as Ae,en as H,et as je,fn as Me,ht as Ne,in as U,mt as Pe,ot as Fe,pn as Ie,pt as Le,q as Re,qt as ze,r as Be,rn as Ve,rt as He,sn as Ue,tn as W,tt as We,vt as Ge,xt as Ke,yt as qe,zt as Je}from"./index-RBa0vitO.js";var Ye=j(`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`}]]),Xe=j(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Ze=j(`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`}]]),Qe=j(`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`}]]),$e=j(`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`}]]),et=j(`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`}]]),tt=j(`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`}]]),nt=j(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),G=e(t(),1),K=n();function q({id:e,value:t,min:n,max:r,step:i,className:a,onCommit:o}){let[s,c]=(0,G.useState)(String(t));return(0,G.useEffect)(()=>c(String(t)),[t]),(0,K.jsx)(T,{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 J({label:e,description:t,descriptionClassName:n,htmlFor:r,children:i,className:a}){return(0,K.jsxs)(`div`,{className:A(`flex items-center gap-4 py-2.5`,a),children:[(0,K.jsxs)(`label`,{htmlFor:r,className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,K.jsx)(`span`,{className:`text-sm text-fg`,children:e}),t&&(0,K.jsx)(`span`,{className:A(`text-xs text-fg-muted`,n),children:t})]}),(0,K.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:i})]})}function Y({children:e,note:t}){return(0,K.jsxs)(`div`,{className:`mb-2 flex flex-col gap-0.5`,children:[(0,K.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:e}),t&&(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t})]})}function rt(){let e=z(),[t,n]=(0,G.useState)(ce());return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Appearance`}),(0,K.jsx)(J,{label:`Theme`,children:(0,K.jsxs)(te,{value:t,onValueChange:e=>{n(e),se(e)},children:[(0,K.jsx)(M,{className:`w-32`,children:(0,K.jsx)(P,{})}),(0,K.jsxs)(F,{children:[(0,K.jsx)(N,{value:`dark`,children:`Dark`}),(0,K.jsx)(N,{value:`light`,children:`Light`}),(0,K.jsx)(N,{value:`system`,children:`System`})]})]})}),(0,K.jsx)(J,{label:`UI font size`,htmlFor:`ui-font-size`,children:(0,K.jsx)(q,{id:`ui-font-size`,min:12,max:24,step:.5,className:`w-20 tabular-nums`,value:e.uiFontSize,onCommit:e=>B({uiFontSize:e})})}),(0,K.jsx)(J,{label:`Terminal font size`,htmlFor:`terminal-font-size`,children:(0,K.jsx)(q,{id:`terminal-font-size`,min:9,max:24,className:`w-20 tabular-nums`,value:e.terminalFontSize,onCommit:e=>B({terminalFontSize:e})})}),(0,K.jsx)(J,{label:`Editor font size`,htmlFor:`editor-font-size`,children:(0,K.jsx)(q,{id:`editor-font-size`,min:9,max:32,step:.5,className:`w-20 tabular-nums`,value:e.editorFontSize,onCommit:e=>B({editorFontSize:e})})}),(0,K.jsx)(J,{label:`Density`,children:(0,K.jsxs)(te,{value:e.density,onValueChange:e=>B({density:e}),children:[(0,K.jsx)(M,{className:`w-36`,children:(0,K.jsx)(P,{})}),(0,K.jsxs)(F,{children:[(0,K.jsx)(N,{value:`compact`,children:`Compact`}),(0,K.jsx)(N,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,K.jsx)(J,{label:`Project-based layout`,description:`Editor layouts are separated across projects.`,htmlFor:`project-based-layout`,children:(0,K.jsx)(L,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>B({projectBasedLayout:e})})}),(0,K.jsx)(J,{label:`All projects in the session list`,description:`Right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,K.jsx)(L,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>B({showAllProjectSessions:e})})})]})}function it({profile:e}){let t=H(),[n,r]=(0,G.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>E(e)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>E(e)});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(J,{label:`Icon`,children:(0,K.jsxs)(ae,{open:n,onOpenChange:r,children:[(0,K.jsx)(We,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,className:`flex size-9 items-center justify-center rounded-md text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(Ge,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,K.jsx)(je,{align:`end`,className:`w-72`,children:(0,K.jsxs)(`div`,{className:`grid grid-cols-8 gap-1`,children:[(0,K.jsx)(`button`,{type:`button`,title:`Default`,onClick:()=>i(null),className:A(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,!e.icon&&`bg-elevated text-fg`),children:(0,K.jsx)(Ge,{icon:null,colour:null,className:`size-4`})}),Ae.map(({name:t,Icon:n})=>(0,K.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:A(`flex h-8 items-center justify-center rounded-md text-fg-secondary transition-colors hover:bg-elevated hover:text-fg`,e.icon===t&&`bg-elevated text-fg`),children:(0,K.jsx)(n,{className:`size-4`})},t))]})})]})}),(0,K.jsx)(J,{label:`Icon colour`,children:(0,K.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,K.jsxs)(`button`,{type:`button`,title:`Default`,onClick:()=>a(null),className:A(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,!e.icon_colour&&`bg-elevated`),children:[(0,K.jsx)(`span`,{className:`size-3.5 rounded-full bg-fg-muted`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Default colour`})]}),c.map(t=>(0,K.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:A(`flex size-7 items-center justify-center rounded-md transition-colors hover:bg-elevated`,e.icon_colour===t&&`bg-elevated`),children:[(0,K.jsx)(`span`,{className:A(`size-3.5 rounded-full bg-current`,qe(t))}),(0,K.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var X=`__none__`;function at(){let e=l(),t=V().data?.find(t=>t.id===e),n=_e(e??void 0),r=U(e??void 0),i=H(),a=W(e??``),o=fe(),[s,c]=(0,G.useState)(``),[u,d]=(0,G.useState)(``),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(``);if((0,G.useEffect)(()=>{t&&(c(t.name),d(t.branch_prefix))},[t]),!t)return null;let w=r.data?.default_account_id;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Profile`}),(0,K.jsxs)(J,{label:`Name`,description:`Letters, digits, dot, underscore and hyphen.`,htmlFor:`profile-name`,children:[(0,K.jsx)(T,{id:`profile-name`,value:s,onChange:e=>c(e.target.value),className:`w-44`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:s===t.name||s.trim()===``||i.isPending,onClick:()=>i.mutate({id:t.id,name:s},{onError:e=>E(e)}),children:`Save`})]}),(0,K.jsxs)(J,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,K.jsx)(T,{id:`branch-prefix`,value:u,onChange:e=>d(e.target.value),placeholder:`no prefix`,className:`w-44`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:u===t.branch_prefix||i.isPending,onClick:()=>i.mutate({id:t.id,branch_prefix:u},{onError:e=>E(e)}),children:`Save`})]}),(0,K.jsx)(it,{profile:t}),(0,K.jsx)(J,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,K.jsxs)(te,{value:typeof w==`number`?String(w):X,onValueChange:e=>a.mutate({default_account_id:e===X?null:Number(e)},{onError:e=>E(e)}),children:[(0,K.jsx)(M,{className:`w-56`,children:(0,K.jsx)(P,{})}),(0,K.jsxs)(F,{children:[(0,K.jsx)(N,{value:X,children:`First available`}),n.data?.map(e=>(0,K.jsx)(N,{value:String(e.id),children:(0,K.jsxs)(`span`,{children:[e.agent_type,`/`,e.label]})},e.id))]})]})}),(0,K.jsx)(J,{label:`Delete profile`,description:`Non-archived sessions block deletion.`,className:`mt-4`,children:(0,K.jsx)(v,{variant:`danger`,size:`sm`,onClick:()=>m(!0),children:`Delete…`})}),(0,K.jsx)(C,{open:p,onOpenChange:e=>{e||(m(!1),g(``))},children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Delete profile `,(0,K.jsx)(`span`,{className:`text-fg`,children:t.name}),`?`]}),(0,K.jsx)(S,{children:`Everything this profile owns goes with it: projects, workspace layouts, accounts and their credential directories, and archived session history. Branches, repositories, and terminal logs on disk are untouched. This cannot be undone.`})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(k,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`text-fg`,children:t.name}),` to confirm`]}),(0,K.jsx)(T,{id:`delete-confirm-name`,value:h,onChange:e=>g(e.target.value),autoFocus:!0})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>{m(!1),g(``)},children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:h!==t.name||o.isPending,onClick:()=>o.mutate(t.id,{onSuccess:()=>{Le(),f.set(null)},onError:e=>{m(!1),g(``),E(e)}}),children:`Delete profile`})]})]})})]})}function ot({agent:e,profileId:t,onClose:n,onCreated:r}){let i=Je(),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(``),l=ge(Fe(s,150)),u=s.trim(),d=u===``||u.startsWith(`/`)||u.startsWith(`~`),f=a.trim()!==``&&d,p=()=>{!f||i.isPending||i.mutate({profile_id:t,agent_type:e.id,label:a.trim(),...u===``?{}:{import_dir:u}},{onSuccess:e=>{n(),r(e,u!==``)},onError:e=>E(e)})};return(0,K.jsx)(C,{open:!0,onOpenChange:e=>!e&&n(),children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Add a `,e.display_name,` account`]}),(0,K.jsxs)(S,{children:[`Accounts are isolated config dirs under this profile. Naming one is enough — Puddle creates it and takes you straight to `,e.display_name,`’s login. To reuse an account you already have on this machine, give its config directory: it is copied in and the original is never touched.`]})]}),(0,K.jsxs)(`form`,{className:`flex flex-col gap-3`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,K.jsx)(T,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value)}),(0,K.jsx)(O,{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,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:n,children:`Cancel`}),(0,K.jsxs)(v,{disabled:!f||i.isPending,onClick:p,children:[(0,K.jsx)(ue,{}),`Add account`]})]})]})})}function st({account:e,gateOpen:t,installed:n}){let r=Oe(),i=xe(),a=Ee(),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(e.label),f=(0,G.useRef)(null);return(0,G.useEffect)(()=>d(e.label),[e.label]),(0,K.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md bg-surface px-3 py-2`,children:[(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,K.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,K.jsx)(`input`,{ref:f,value:u,onChange:e=>d(e.target.value),onBlur:()=>{let t=u.trim();if(t!==e.label){if(t===``){d(e.label);return}i.mutate({id:e.id,label:t},{onError:t=>{E(t),d(e.label)}})}},onKeyDown:t=>{t.key===`Enter`?t.currentTarget.blur():t.key===`Escape`&&(d(e.label),t.currentTarget.blur())},"aria-label":`Account name`,className:`-mx-1 block w-full min-w-0 truncate rounded-sm bg-transparent px-1 py-0.5 text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(0,K.jsxs)(`button`,{type:`button`,title:`Rename account`,onClick:()=>{f.current?.focus(),f.current?.select()},className:`shrink-0 rounded-sm p-0.5 text-fg-muted transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(w,{className:`size-3`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Rename account`})]})]}),(0,K.jsx)(`span`,{className:`text-2xs ${e.logged_in?`text-success`:`text-warning`}`,children:e.logged_in?`logged in`:`not logged in`})]}),t&&(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-secondary`,children:[`skip prompts`,(0,K.jsx)(L,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>E(e)})})]}),(0,K.jsxs)(v,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s({stream:e.stream,hint:e.hint}),onError:e=>E(e)}),children:[(0,K.jsx)(ve,{}),e.logged_in?`Re-login`:`Login`]}),(0,K.jsxs)(v,{size:`icon`,variant:`ghost`,className:`size-7 text-fg-muted hover:text-danger`,onClick:()=>l(!0),children:[(0,K.jsx)(Ce,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,K.jsx)(be,{stream:o.stream,hint:o.hint,label:`${e.agent_type}/${e.label}`,onClose:()=>s(null)}),(0,K.jsx)(C,{open:c,onOpenChange:l,children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{children:[`Delete `,(0,K.jsx)(`span`,{className:`text-fg`,children:e.label}),`?`]}),(0,K.jsx)(S,{children:`Removes the account, its archived session history, and its credential directory — this logs the account out. Non-archived sessions block deletion.`})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>l(!1),children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:a.isPending,onClick:()=>a.mutate(e.id,{onSuccess:()=>l(!1),onError:e=>{l(!1),E(e)}}),children:`Delete account`})]})]})})]})}function ct(){let e=l(),t=ye(),n=_e(e??void 0),r=U(e??void 0),a=Oe(),[o,s]=(0,G.useState)(null),[c,u]=(0,G.useState)(null),d=r.data?.allowSkipPermissions===!0;return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Accounts`}),t.data?.map(e=>{let t=n.data?.filter(t=>t.agent_type===e.id)??[],r=e.available!==!1;return(0,K.jsxs)(`div`,{className:`mb-5`,children:[(0,K.jsx)(J,{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,K.jsx)(`span`,{className:`text-2xs text-fg-muted`,children:e.id})}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[t.map(t=>(0,K.jsx)(st,{account:t,gateOpen:d&&e.capabilities.skip_permissions,installed:r},t.id)),(0,K.jsx)(`div`,{className:`flex`,children:(0,K.jsxs)(v,{type:`button`,size:`sm`,variant:`secondary`,disabled:!r,onClick:()=>u(e),children:[(0,K.jsx)(ue,{}),`Add account`]})})]})]},e.id)}),o&&(0,K.jsx)(be,{stream:o.stream,label:o.label,hint:o.hint,onClose:()=>s(null)}),c!==null&&e!==null&&(0,K.jsx)(ot,{agent:c,profileId:e,onClose:()=>u(null),onCreated:(e,t)=>{if(t){e.logged_in||i.info(`Imported without credentials — press Login to authenticate.`);return}a.mutate(e.id,{onSuccess:t=>s({stream:t.stream,label:`${e.agent_type}/${e.label}`,hint:t.hint}),onError:e=>E(e)})}})]})}function lt(){let e=Se(),t=I(),[n,r]=(0,G.useState)(``);return(0,G.useEffect)(()=>{e.data&&r(e.data.agentPath)},[e.data]),(0,K.jsx)(J,{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,K.jsx)(T,{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=re(e,n),o=n.sessionDefaults??{},[s,c]=(0,G.useState)(a.baseBranch),l=t=>r({...o,[e]:{...o[e],...t}});return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mb-1 mt-4 text-xs font-medium uppercase tracking-wide text-fg-gold`,children:t}),(0,K.jsx)(J,{label:`Base branch`,description:`Blank = the repository's default base branch.`,htmlFor:`${e}-default-base`,children:(0,K.jsx)(T,{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,K.jsx)(J,{label:`Separate branch`,description:`Start on a fresh branch off the base, in its own directory.`,htmlFor:`${e}-default-branch`,children:(0,K.jsx)(L,{id:`${e}-default-branch`,checked:a.separateBranch,disabled:i,onCheckedChange:e=>l({separateBranch:e})})}),(0,K.jsx)(J,{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,K.jsx)(L,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function dt(){return(0,K.jsx)(J,{label:`Terminal scrollback`,htmlFor:`scrollback`,children:(0,K.jsx)(q,{id:`scrollback`,min:500,max:1e5,step:500,className:`w-28 tabular-nums`,value:z().terminalScrollback,onCommit:e=>B({terminalScrollback:e})})})}function ft({id:e,label:t,description:n,initial:r,defaultText:i,onSave:a,pending:o}){let[s,c]=(0,G.useState)(r);return(0,K.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:e,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[t,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n})]}),(0,K.jsx)(D,{id:e,value:s,onChange:e=>c(e.target.value),rows:6,className:`font-mono`}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:s===r||o,onClick:()=>a(s),children:`Save`}),(0,K.jsx)(v,{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,G.useState)(e),o=r.length>0?r:s;return(0,K.jsxs)(`div`,{className:`mt-3 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:`tab-title-template`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Template`,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Compose the label from the parts below. Empty falls back to the default.`})]}),(0,K.jsx)(T,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:s}),(0,K.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,K.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:He(pt,o)})]}),(0,K.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:a.map(([e,t])=>(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(`dt`,{className:`w-24 shrink-0 font-mono text-fg-secondary`,children:`\${${e}}`}),(0,K.jsx)(`dd`,{className:`text-fg-muted`,children:t})]},e))}),(0,K.jsxs)(`div`,{className:`flex gap-2`,children:[(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:r===e||n,onClick:()=>t(r),children:`Save`}),(0,K.jsx)(v,{size:`sm`,variant:`ghost`,disabled:r==="${name}"||n,onClick:()=>{i(s),t(s)},children:`Reset to default`})]})]})}function ht(){let e=l(),t=V().data?.find(t=>t.id===e),n=U(e??void 0),i=W(e??``),[a,s]=(0,G.useState)(!1),[c,u]=(0,G.useState)(``),d=n.data?.allowSkipPermissions===!0,f=e=>i.mutate({allowSkipPermissions:e},{onSuccess:()=>{s(!1),u(``)},onError:e=>E(e)}),p=e=>t=>i.mutate({[e]:t},{onError:e=>E(e)});return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Sessions`}),(0,K.jsx)(J,{label:`Skip permission prompts`,htmlFor:`gate`,children:(0,K.jsx)(L,{id:`gate`,checked:d,onCheckedChange:e=>{e?s(!0):f(!1)}})}),(0,K.jsx)(J,{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,K.jsx)(L,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:i.isPending,onCheckedChange:e=>i.mutate({captureSessionEnv:e},{onError:e=>E(e)})})}),(0,K.jsx)(lt,{}),(0,K.jsx)(dt,{}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{children:`New session defaults`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ut,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>i.mutate({sessionDefaults:e},{onError:e=>E(e)}),pending:i.isPending},`${e}:agent-seed`),(0,K.jsx)(ut,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>i.mutate({sessionDefaults:e},{onError:e=>E(e)}),pending:i.isPending},`${e}:terminal-seed`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{note:`Sent to agent as opening message when a session (re)starts. You can make this empty.`,children:`Launch text`}),n.data&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ft,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??m,defaultText:m,onSave:p(`onboardingTemplate`),pending:i.isPending},`${e}:onboarding`),(0,K.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??r,defaultText:r,onSave:p(`concurrentTemplate`),pending:i.isPending},`${e}:concurrent`),(0,K.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??o,defaultText:o,onSave:p(`restartTemplate`),pending:i.isPending},`${e}:restart`)]})]}),(0,K.jsxs)(`div`,{className:`mt-5`,children:[(0,K.jsx)(Y,{children:`Tab title`}),n.data&&(0,K.jsx)(mt,{initial:n.data.tabTitleTemplate||"${name}",onSave:p(`tabTitleTemplate`),pending:i.isPending},`${e}:tab-title`)]}),(0,K.jsx)(C,{open:a,onOpenChange:e=>{e||(s(!1),u(``))},children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{className:`flex items-center gap-2`,children:[(0,K.jsx)(et,{className:`size-5 text-danger`}),`Run agents without permission prompts?`]}),(0,K.jsx)(S,{asChild:!0,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-2 text-sm`,children:[(0,K.jsx)(`p`,{children:`A prompt-free agent acts unattended, with your credentials, inside its worktree — and nothing technically stops a shell command from reaching outside it. It can:`}),(0,K.jsxs)(`ul`,{className:`list-disc pl-5 text-fg-secondary`,children:[(0,K.jsx)(`li`,{children:`run any shell command without asking first,`}),(0,K.jsx)(`li`,{children:`modify, delete, or exfiltrate files your user can reach,`}),(0,K.jsx)(`li`,{children:`install dependencies and execute the network requests they make,`}),(0,K.jsx)(`li`,{children:`push branches or call remote APIs with the credentials it finds.`})]}),(0,K.jsx)(`p`,{children:`Only open this gate if every account you opt in runs work you would trust a colleague to run unsupervised on this machine.`}),(0,K.jsx)(`p`,{className:`text-fg-muted`,children:`Opening it also records the agent’s own bypass-permissions acceptance for this profile’s accounts, so the skip actually takes effect.`})]})})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,K.jsxs)(k,{htmlFor:`confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`text-fg`,children:t?.name}),` to confirm`]}),(0,K.jsx)(T,{id:`confirm-name`,value:c,onChange:e=>u(e.target.value),autoFocus:!0})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>{s(!1),u(``)},children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:c!==t?.name||i.isPending,onClick:()=>f(!0),children:`Open the gate`})]})]})})]})}var gt={desktop:!0,sound:!1,muted_projects:[]};function _t(){let[e,t]=(0,G.useState)(R);return(0,G.useEffect)(()=>{let e=()=>t(R());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(R())]}function vt({permission:e,onRequest:t}){return e===`granted`?null:(0,K.jsxs)(`p`,{className:`pb-2 text-xs text-warning`,children:[e==="default"&&(0,K.jsxs)(K.Fragment,{children:[`The browser has not been asked for permission yet, so nothing will show —`,` `,(0,K.jsx)(`button`,{type:`button`,onClick:t,className:`underline underline-offset-2 transition-colors hover:text-fg`,children:`request it now`}),`.`]}),e===`denied`&&`Blocked by the browser — allow notifications for this site in its site settings, then return here.`,e===`unsupported`&&`This browser cannot show desktop notifications.`]})}function yt(){let e=l(),t=U(e??void 0),n=W(e??``),r=Ue(e??void 0),[i,a]=_t(),o={...gt,...t.data?.notifications??{}},s=e=>n.mutate({notifications:e},{onError:e=>E(e)}),c=()=>{typeof Notification>`u`||Notification.requestPermission().then(a)};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Notifications`}),(0,K.jsx)(J,{label:`Desktop notification on waiting`,htmlFor:`notify-desktop`,children:(0,K.jsx)(L,{id:`notify-desktop`,checked:o.desktop,onCheckedChange:e=>{e&&c(),s({...o,desktop:e})}})}),o.desktop&&(0,K.jsx)(vt,{permission:i,onRequest:c}),(0,K.jsx)(J,{label:`Sound`,htmlFor:`notify-sound`,children:(0,K.jsx)(L,{id:`notify-sound`,checked:o.sound,onCheckedChange:e=>s({...o,sound:e})})}),(0,K.jsx)(J,{label:`Muted projects`,description:`No notifications from these projects.`,children:(0,K.jsxs)(`span`,{className:`text-2xs text-fg-muted tabular-nums`,children:[o.muted_projects.length,` muted`]})}),(0,K.jsx)(`div`,{className:`flex flex-col gap-1`,children:r.data?.map(e=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-2 py-1 text-sm text-fg-secondary hover:bg-elevated`,children:[(0,K.jsx)(L,{checked:o.muted_projects.includes(e.id),onCheckedChange:t=>s({...o,muted_projects:t?[...o.muted_projects,e.id]:o.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function bt(){let e=z();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Editor`}),(0,K.jsx)(J,{label:`Tab size`,description:`Spaces per indent level.`,htmlFor:`tab-size`,children:(0,K.jsx)(q,{id:`tab-size`,min:1,max:8,className:`w-20 tabular-nums`,value:e.editorTabSize,onCommit:e=>B({editorTabSize:e})})}),(0,K.jsx)(J,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,K.jsx)(L,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>B({editorWordWrap:e})})}),(0,K.jsx)(J,{label:`SSH host for editor links`,description:`Used for vscode:// and cursor:// remote links until the CLI supplies it automatically.`,htmlFor:`editor-link-host`,children:(0,K.jsx)(T,{id:`editor-link-host`,type:`text`,placeholder:Be.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>B({editorLinkSshHost:e.target.value})})})]})}function xt({value:e,isDefault:t,onRecord:n,onReset:r}){let[i,a]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>a(!0),onBlur:()=>a(!1),onKeyDown:e=>{if(!i)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){a(!1);return}let t=p(e.nativeEvent);t&&(n(t),a(!1))},className:A(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,i?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:i?`Press keys…`:u(e)}),!t&&(0,K.jsxs)(`button`,{type:`button`,title:`Reset to default`,onClick:r,className:`rounded-md p-1 text-fg-gold transition-colors hover:bg-elevated hover:text-fg`,children:[(0,K.jsx)(Qe,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function St(){let e=l(),t=U(e??void 0),n=W(e??``),r=t.data?.hotkeys??{},i=(e,t)=>r[e]||t,a=new Map;for(let e of g){let t=i(e.id,d(e));a.set(t,(a.get(t)??0)+1)}let o=(e,t)=>n.mutate({hotkeys:{...r,[e]:t}},{onError:e=>E(e)}),s=e=>{let t={...r};delete t[e],n.mutate({hotkeys:t},{onError:e=>E(e)})};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Hotkeys`}),(0,K.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:`Per-profile keyboard shortcuts. Filetree navigation and terminal line-edits are fixed.`}),(0,K.jsx)(J,{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,K.jsx)(L,{id:`terminal-app-shortcuts`,checked:t.data?.terminalAppShortcuts!==!1,disabled:n.isPending,onCheckedChange:e=>n.mutate({terminalAppShortcuts:e},{onError:e=>E(e)})})}),h.map(e=>{let t=g.filter(t=>t.group===e);return t.length===0?null:(0,K.jsxs)(`div`,{className:`mb-5`,children:[(0,K.jsx)(`div`,{className:`mb-1 text-2xs font-medium uppercase tracking-wide text-fg-gold`,children:e}),t.map(e=>{let t=i(e.id,d(e)),n=(a.get(t)??0)>1?`Conflicts with another shortcut.`:void 0;return(0,K.jsx)(J,{label:e.label,description:n,descriptionClassName:n?`text-interrupted`:void 0,children:(0,K.jsx)(xt,{value:t,isDefault:!r[e.id],onRecord:t=>o(e.id,t),onReset:()=>s(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 de.map(e=>e.id)}function It({selected:e,onToggle:t}){return(0,K.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:de.map(n=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(L,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function Lt(){let e=l(),t=U(e??void 0),n=V().data?.find(t=>t.id===e),r=Ie(e??void 0,void 0),a=W(e??``),o=H(),s=oe(),c=Te(),u=De(),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(!1),[_,y]=(0,G.useState)(!1),[b,x]=(0,G.useState)(Ft),S=n&&c.data?pe(c.data.file,n.name):void 0,C=S?.enabled===!0,w=C&&S?S.groups:b,T=()=>({client:me(),theme:ce(),profileSettings:t.data??{},profile:n??{},scratchpad:r.data??[]}),ee={setClient:e=>B(e),setTheme:e=>{typeof e==`string`&&se(e)},patchProfileSettings:e=>a.mutate(e,{onError:e=>E(e)}),patchProfileColumns:t=>{e&&o.mutate({id:e,...t},{onError:e=>E(e)})},createScratchpad:t=>{if(e)for(let n of t)s.mutate({profile_id:e,scope:`profile`,title:n.title??void 0,body:n.body,tags:n.tags,agent_type:n.agent_type??void 0})}},O=(e,t)=>{n&&u.mutate({profile:n.name,entry:{enabled:e.enabled??C,groups:t,doc:Re(t,T()),updatedAt:new Date().toISOString()}},{onError:e=>E(e)})},k=(e,t)=>{let n=t?[...w,e]:w.filter(t=>t!==e);x(n),localStorage.setItem(Pt,JSON.stringify(n)),C&&O({},n)},A=async()=>{y(!0);try{let e=he(await Nt(d.trim()),ee,{profileSettings:t.data??{},scratchpad:r.data??[]});e.length===0?i.error(`Nothing recognised to import.`):(i.success(`Imported ${e.join(`, `)}.`),f(``))}catch(e){i.error(e.message)}finally{y(!1)}},j=async()=>{y(!0);try{let e=await Mt(Re(w,T()));m(e),await navigator.clipboard?.writeText(e),i.success(`Copied to clipboard`)}finally{y(!1)}};return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Sync`}),(0,K.jsx)(`p`,{className:`mb-5 text-xs text-fg-muted`,children:`Carry your settings between machines. Accounts, repositories, and anything host-specific are never included. Applies to this profile.`}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Sync locally`}),c.data?.available===!1?(0,K.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:`Not available in this cockpit — start the UI with the Puddle CLI to sync across windows.`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:[`Sync selected groups through this machine’s`,` `,(0,K.jsx)(`span`,{className:`text-fg-secondary`,children:`~/.puddle`}),`, so every Puddle window stays in step for profiles named`,` `,(0,K.jsx)(`span`,{className:`text-fg-secondary`,children:n?.name??`…`}),`.`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(L,{checked:C,disabled:!n||c.isLoading||u.isPending,onCheckedChange:e=>O({enabled:e},w)}),`Sync locally`]})]})]}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsxs)(`button`,{type:`button`,onClick:()=>g(e=>!e),className:`flex items-center gap-1 text-xs text-fg-secondary transition-colors hover:text-fg`,children:[h?(0,K.jsx)(ne,{className:`size-3.5`}):(0,K.jsx)(ie,{className:`size-3.5`}),`Choose what to sync`]}),h&&(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(It,{selected:w,onToggle:k})})]}),(0,K.jsxs)(`div`,{className:`mb-6`,children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Export`}),(0,K.jsx)(`p`,{className:`mb-2 mt-1 text-xs text-fg-muted`,children:`Builds a Puddle magic string that encodes settings from the checklist above.`}),(0,K.jsx)(v,{size:`sm`,disabled:_,onClick:()=>void j(),children:`Export & copy`}),p&&(0,K.jsx)(D,{readOnly:!0,value:p,rows:3,spellCheck:!1,onFocus:e=>e.currentTarget.select(),className:`mt-2 resize-y font-mono text-xs`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:`Import`}),(0,K.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:`Paste a Puddle magic string to import its settings.`}),(0,K.jsx)(D,{value:d,onChange:e=>f(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:`Paste a settings export…`,rows:3,spellCheck:!1,className:`resize-y font-mono text-xs`}),(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(v,{size:`sm`,disabled:!d.trim()||_,onClick:()=>void A(),children:`Import`})})]})]})}function Rt({repo:e}){let t=Ve(),n=ze(),[r,a]=(0,G.useState)(e.default_base_branch),[o,s]=(0,G.useState)(e.onboarding_notes??``),c=e=>E(e);return(0,K.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface p-3`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm text-fg`,children:e.path}),(0,K.jsx)(`span`,{className:`shrink-0 text-2xs text-fg-muted tabular-nums`,children:e.last_fetched_at?`fetched ${new Date(e.last_fetched_at).toLocaleString()}`:`never fetched`}),(0,K.jsxs)(v,{size:`sm`,variant:`ghost`,disabled:n.isPending,onClick:()=>n.mutate(e.id,{onSuccess:()=>i.success(`Fetched.`),onError:c}),children:[(0,K.jsx)(we,{}),`Fetch now`]})]}),(0,K.jsxs)(J,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,K.jsx)(T,{id:`base-${e.id}`,value:r,onChange:e=>a(e.target.value),className:`w-40`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:r===e.default_base_branch||t.isPending,onClick:()=>t.mutate({id:e.id,default_base_branch:r},{onError:c}),children:`Save`})]}),(0,K.jsx)(J,{label:`Periodic fetch`,description:`Fetched on open and on the daemon's interval while sessions are active.`,htmlFor:`fetch-${e.id}`,className:`py-1.5`,children:(0,K.jsx)(L,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:c})})}),(0,K.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-1.5`,children:[(0,K.jsxs)(`label`,{htmlFor:`notes-${e.id}`,className:`flex flex-col gap-0.5 text-sm text-fg`,children:[`Onboarding notes`,(0,K.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Standing setup rules, injected into every fresh worktree. Agents update them via .puddle/onboarding-notes.md.`})]}),(0,K.jsx)(D,{id:`notes-${e.id}`,value:o,onChange:e=>s(e.target.value),rows:4}),(0,K.jsx)(`div`,{children:(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:o===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:o},{onError:c}),children:`Save notes`})})]}),e.orphan_worktrees.length>0&&(0,K.jsxs)(`div`,{className:`mt-3 rounded-md bg-elevated p-2`,children:[(0,K.jsx)(`p`,{className:`text-xs text-fg-secondary`,children:`Orphan worktrees — directories no session claims. Puddle never deletes these automatically; remove them by hand if unwanted.`}),(0,K.jsx)(`ul`,{className:`mt-1 flex flex-col gap-0.5`,children:e.orphan_worktrees.map(e=>(0,K.jsx)(`li`,{className:`truncate text-2xs text-fg-muted`,children:e},e))})]})]})}function zt(){let e=Me();return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Projects`}),e.data?.length===0&&(0,K.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,K.jsx)(Rt,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=I();return(0,K.jsx)(J,{label:e,description:t,htmlFor:`host-${n}`,children:(0,K.jsx)(T,{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=>E(e)})}})})}function Bt(){let e=Se(),t=I(),n=ke();return e.data?(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{note:`Affects all profiles on this host`,children:`Host`}),(0,K.jsx)(J,{label:`Display name`,description:`Shown in place of the hostname across the UI. Leave blank for the hostname.`,htmlFor:`host-displayName`,children:(0,K.jsx)(T,{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=>E(e)})}})}),(0,K.jsx)($,{label:`Fetch interval (minutes)`,description:`Periodic git fetch for repos with active sessions.`,field:`fetchIntervalMinutes`,config:e.data,min:1}),(0,K.jsx)($,{label:`Log size cap (bytes)`,description:`Per-terminal on-disk log cap.`,field:`logMaxBytes`,config:e.data,min:65536,step:1048576}),(0,K.jsx)($,{label:`Replay size (bytes)`,description:`Log tail sent to a terminal on attach.`,field:`replayBytes`,config:e.data,min:1024,step:65536}),(0,K.jsx)($,{label:`UI-state retention (days)`,description:`Stale workspace snapshots are swept at boot.`,field:`uiStateRetentionDays`,config:e.data,min:1}),(0,K.jsx)(J,{label:`Auto-resume`,description:`Resume interrupted sessions automatically after a daemon restart.`,htmlFor:`host-autoResume`,children:(0,K.jsx)(L,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>E(e)})})})]}):null}var Vt=[{id:`appearance`,label:`Appearance`,icon:le,render:()=>(0,K.jsx)(rt,{})},{id:`profile`,label:`Profile`,icon:Ke,render:()=>(0,K.jsx)(at,{})},{id:`accounts`,label:`Accounts`,icon:nt,render:()=>(0,K.jsx)(ct,{})},{id:`sessions`,label:`Sessions`,icon:tt,render:()=>(0,K.jsx)(ht,{})},{id:`editor`,label:`Editor`,icon:Xe,render:()=>(0,K.jsx)(bt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Ze,render:()=>(0,K.jsx)(St,{})},{id:`notifications`,label:`Notifications`,icon:Ye,render:()=>(0,K.jsx)(yt,{})},{id:`projects`,label:`Projects`,icon:ee,render:()=>(0,K.jsx)(zt,{})},{id:`host`,label:`Host`,icon:$e,render:()=>(0,K.jsx)(Bt,{})},{id:`sync`,label:`Sync`,icon:we,render:()=>(0,K.jsx)(Lt,{})}],Ht={terminal:`sessions`,repositories:`projects`};function Ut(){let e=Ne(),t=e===null?null:Ht[e]??e,n=Vt.find(e=>e.id===t)??Vt[0];return(0,K.jsx)(C,{open:e!==null,onOpenChange:e=>!e&&Le(),children:(0,K.jsxs)(b,{wide:!0,className:`grid h-[34rem] grid-cols-[14rem_1fr] gap-0 overflow-hidden p-0`,children:[(0,K.jsx)(x,{className:`sr-only`,children:`Settings`}),(0,K.jsxs)(`nav`,{className:`flex flex-col gap-1 bg-surface p-2.5 pr-6`,children:[(0,K.jsx)(`span`,{className:`px-2.5 py-2 text-2xs font-medium uppercase tracking-wide text-fg-muted`,children:`Settings`}),Vt.map(({id:e,label:t,icon:r})=>(0,K.jsxs)(`button`,{onClick:()=>Pe(e),className:A(`flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm transition-colors`,e===n.id?`bg-elevated text-fg`:`text-fg-secondary hover:bg-elevated hover:text-fg`),children:[(0,K.jsx)(r,{className:`size-4 shrink-0`}),t]},e))]}),(0,K.jsx)(`div`,{className:`overflow-y-auto p-5`,children:n.render()})]})})}export{Ut as SettingsDialog};
|