@puddle-code/cli 0.0.25 → 0.0.27
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 +12 -66
- package/dist/index.js +13 -13
- package/dist/public/assets/{Dashboard-6o1ejKoK.js → Dashboard-CnreZDWT.js} +1 -1
- package/dist/public/assets/{EditorTabClose-BgK6C2jA.js → EditorTabClose-Cf6Ithkd.js} +1 -1
- package/dist/public/assets/{LazyTerminal-CDBfqZwZ.js → LazyTerminal-CBUKfCRA.js} +2 -2
- package/dist/public/assets/{ModelRefcount-xKqoegmi.js → ModelRefcount-BlBx1A4I.js} +1 -1
- package/dist/public/assets/{PaneEditorBody-BUd9HdMX.js → PaneEditorBody-yHuXb_2i.js} +2 -2
- package/dist/public/assets/SettingsDialog-D0Dg6hYk.js +1 -0
- package/dist/public/assets/{Terminal-wqPSeGSJ.js → Terminal-B7B5s9of.js} +17 -17
- package/dist/public/assets/Workspace-1pzIYqz0.js +7 -0
- package/dist/public/assets/{buffer-store-DbSmSAdC.js → buffer-store-ZpUFG5SK.js} +2 -2
- package/dist/public/assets/{context-menu-PMB0-xF7.js → context-menu-BqdZKIwP.js} +1 -1
- package/dist/public/assets/{cssMode-E7KJQLQr.js → cssMode-Bx7_D8TV.js} +1 -1
- package/dist/public/assets/{editor-sync-BOsmDr0F.js → editor-sync-BnwyuZGE.js} +1 -1
- package/dist/public/assets/hotkeys-VY-O_esT.js +1 -0
- package/dist/public/assets/{htmlMode-CogIKVWT.js → htmlMode-DIhfisqE.js} +1 -1
- package/dist/public/assets/index-C4dEk1bI.js +10 -0
- package/dist/public/assets/index-CBZ-vDvn.css +2 -0
- package/dist/public/assets/{jsonMode-GTuB6qz9.js → jsonMode-CUZib3Ic.js} +1 -1
- package/dist/public/assets/preview-kind-BKn8hI4T.js +1 -0
- package/dist/public/assets/{session-seed-BdQ_tCMQ.js → session-seed-c86Sck-7.js} +1 -1
- package/dist/public/assets/ssh-mode-zTe6dpiB.js +1 -0
- package/dist/public/assets/{tsMode-ChphGxQc.js → tsMode-D0SpNQhC.js} +1 -1
- package/dist/public/index.html +42 -5
- package/package.json +1 -1
- package/dist/public/assets/SettingsDialog-D8tgroEU.js +0 -1
- package/dist/public/assets/Workspace-B1OSrzoE.js +0 -7
- package/dist/public/assets/hotkeys-Bmah7TAT.js +0 -1
- package/dist/public/assets/index-BKVDB6Tt.css +0 -2
- package/dist/public/assets/index-BytCIda4.js +0 -10
- package/dist/public/assets/preview-kind-CsZyJGBK.js +0 -1
- package/dist/public/assets/ssh-mode-CcChY6en.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{c as r,f as i,g as a}from"./hotkeys-Bmah7TAT.js";import{C as o,D as s,E as c,T as l,c as u,f as d,i as f,m as p,n as m,p as h,s as g,t as _,w as v,x as y,y as b}from"./preview-kind-CsZyJGBK.js";import{t as x}from"./preload-helper-Czpn1I53.js";import{S,r as C,t as ee}from"./api-B3lAdmrV.js";import{t as te}from"./createLucideIcon-DyMAgLa3.js";import{G as ne,K as re,M as ie,W as ae,a as oe,j as se}from"./index-BytCIda4.js";import{i as ce,r as le}from"./editor.api2-4X9Vh9Zw.js";import{a as ue,c as de,d as w,f as fe,i as pe,l as me,n as he,o as ge,r as _e,s as ve,t as ye,u as be}from"./buffer-store-DbSmSAdC.js";import{a as T,c as xe,i as Se,l as Ce,n as we,o as Te,r as Ee,s as De}from"./editor-sync-BOsmDr0F.js";import{r as Oe}from"./buffer-logic-BrpRsL1b.js";var ke=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`}]]),E=e(t(),1);function Ae(e){return!e}function je(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=ce.CtrlCmd:e===`ctrl`?r|=ce.WinCtrl:e===`alt`?r|=ce.Alt:e===`shift`&&(r|=ce.Shift);let i=le[/^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 Me(e,t){let n=je(r(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let i=je(r(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:i===null?[]:[i],run:()=>ne({editorWordWrap:Ae(ae().editorWordWrap)})})}function Ne(e,t,n,r){let i=ye(e,t,r),a=s(e,t,{root:r}),o=l(e,r),[c,u]=(0,E.useState)(null),[d,f]=(0,E.useState)(!1),p=(0,E.useRef)(!1),m=(0,E.useRef)(null),h=(0,E.useRef)(null),g=(0,E.useRef)(n);g.current=n;let _=(0,E.useRef)(!1),v=(0,E.useCallback)((e,t)=>{h.current?.cancel(),_.current=!0;try{ge(i,e,t)}finally{_.current=!1}},[i]),y=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>me(i,e),[i]),()=>_e(i)),b=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>Te(i,e),[i]),()=>T(i));(0,E.useEffect)(()=>{let n=a.data;if(!n||n.binary||n.content===null||p.current)return;p.current=!0;let o=de(i)!==void 0,s=he(e,t,n.content,n.mtime_ms,r);u(s),!o&&Ce(e,t,r).then(e=>{e&&(e.base_mtime_ms===n.mtime_ms?Oe(s,e.content)&&f(!0):S(`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:()=>{Oe(s,e.content)&&f(!0)}}}))})},[a.data,i,e,t,r]),(0,E.useEffect)(()=>{if(!c)return;let n=xe(e,t,r);h.current=n;let a=c.onDidChangeContent(()=>{_.current||(n(c.getValue(),de(i)??0),we(e,t,r))});return()=>{n.flush(),a.dispose(),h.current=null}},[c,i,e,t,r]),(0,E.useEffect)(()=>{!c||!b.savedElsewhere||_e(i)||a.refetch().then(e=>{_e(i)||(e.data&&e.data.content!==null&&v(e.data.content,e.data.mtime_ms),Se(i))})},[b.savedElsewhere,c,i]),(0,E.useEffect)(()=>{let e=a.data;!c||!e||e.content===null||!_e(i)&&e.mtime_ms!==de(i)&&v(e.content,e.mtime_ms)},[a.data,c,i]);let x=(0,E.useCallback)((n,a)=>{pe(i,n,a),h.current?.cancel(),De(e,t,r),Ee(e,t,a,r),f(!1)},[i,e,t,r]),C=(0,E.useCallback)(()=>{a.refetch().then(n=>{n.data&&n.data.content!==null&&v(n.data.content,n.data.mtime_ms),De(e,t,r),f(!1)})},[i,e,t,v]),te=(0,E.useCallback)((e,n)=>{o.mutate({path:t,content:e},{onSuccess:e=>x(n,e.mtime_ms),onError:e=>S.error(e instanceof Error?e.message:`Overwrite failed`)})},[o,t,x]),ne=(0,E.useCallback)(()=>{if(!c||!_e(i))return;let e=c.getValue(),n=c.getAlternativeVersionId();o.mutate({path:t,content:e,expected_mtime_ms:de(i)},{onSuccess:e=>x(n,e.mtime_ms),onError:t=>{t instanceof ee&&t.status===409&&t.code===`stale_file`?S.error(`File changed on disk (probably the agent)`,{duration:1/0,action:{label:`Reload`,onClick:()=>C()},cancel:{label:`Overwrite`,onClick:()=>te(e,n)}}):S.error(t instanceof Error?t.message:`Save failed`)}})},[c,i,o,t,x,C,te]),re=(0,E.useRef)(ne);re.current=ne;let ie=(0,E.useCallback)(()=>{let n=m.current,i=g.current;r===void 0&&(!n||!i||i.session!==e||i.path!==t||(n.revealLineInCenter(i.line),n.setPosition({lineNumber:i.line,column:i.column??1}),n.focus()))},[e,t,r]),ae=(0,E.useCallback)(e=>{m.current=e,Me(e,{onSave:()=>re.current()}),ie()},[ie]);(0,E.useEffect)(()=>{ie()},[n,c,ie]);let oe=(0,E.useCallback)(()=>{C()},[C]),se,ce=null;a.data?.binary?se=`binary`:a.error?a.error instanceof ee&&a.error.status===413?se=`too-large`:(se=`error`,ce=a.error instanceof Error?a.error.message:`Failed to load file`):se=c?`ready`:`loading`;let le=y&&b.savedElsewhere?`saved-elsewhere`:y&&b.dirtyElsewhere?`dirty-elsewhere`:null;return{status:se,errorMessage:ce,model:c,dirty:y,restoredNotice:d,discardRestore:oe,peerBadge:le,save:ne,onMount:ae}}var D=n();function Pe({message:e,session:t,path:n,root:r,download:i}){return(0,D.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,D.jsx)(`span`,{children:e}),i&&(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void b(t,n,r).catch(e=>S.error(e instanceof Error?e.message:`Download failed`)),className:`flex items-center gap-1.5 text-fg-secondary transition-colors hover:text-fg`,children:[(0,D.jsx)(ke,{className:`size-4`}),`Download`]})]})}function Fe({session:e,path:t,reveal:n,root:r}){let i=re(),a=Ne(e,t,n,r),o=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(a.status===`binary`)return(0,D.jsx)(Pe,{message:`Binary file — use Download`,session:e,path:t,root:r,download:!0});if(a.status===`too-large`)return(0,D.jsx)(Pe,{message:`File too large to edit — use Download`,session:e,path:t,root:r,download:!0});if(a.status===`error`)return(0,D.jsx)(Pe,{message:a.errorMessage??`Failed to load file`,session:e,path:t,root:r});let s=a.peerBadge===`saved-elsewhere`?`Saved in another window`:a.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[a.restoredNotice&&(0,D.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,D.jsx)(`span`,{children:`Restored unsaved changes`}),(0,D.jsx)(`button`,{type:`button`,onClick:a.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),s&&(0,D.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:s}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:a.model&&(0,D.jsx)(w,{path:a.model.uri.toString(),defaultValue:a.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>a.onMount(e),loading:(0,D.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 Ie({children:e}){return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function Le(e,t){let n=(0,E.useRef)(t);n.current=t,(0,E.useEffect)(()=>(ve(e),()=>{n.current?.(),ue(e)}),[e])}function Re(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function ze({session:e,refName:t,path:n,content:r}){let i=re(),a=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,D.jsx)(w,{path:Re(`puddle-view`,e,t,n),defaultValue:r,theme:be,loading:(0,D.jsx)(Ie,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:a,fontSize:i.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Be({session:e,against:t,path:n,root:r}){let i=v(e,t,n,{root:r});return i.isPending?(0,D.jsx)(Ie,{children:`…`}):i.error?(0,D.jsx)(Ie,{children:i.error instanceof Error?i.error.message:`Failed to load`}):i.data.binary?(0,D.jsx)(Ie,{children:`Binary file — deleted`}):(0,D.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,D.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(ze,{session:e,refName:t,path:n,content:i.data.content??``})})]})}function Ve({session:e,against:t,path:n,basePath:r,root:i}){let a=re(),o=Ne(e,n,null,i),s=v(e,t,r,{root:i}),c=(0,E.useRef)(null);Le(ye(e,n),()=>{let e=c.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),c.current=null});let l=(0,E.useRef)(o.save);l.current=o.save;let u=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),d=s.error instanceof ee&&s.error.status===404;return o.status===`binary`||s.data?.binary?(0,D.jsx)(Ie,{children:`Binary file`}):o.status===`too-large`?(0,D.jsx)(Ie,{children:`File too large to show`}):o.status===`error`?(0,D.jsx)(Ie,{children:o.errorMessage??`Failed to load file`}):d?(0,D.jsx)(Fe,{session:e,path:n,reveal:null}):s.isPending||!o.model?(0,D.jsx)(Ie,{children:`…`}):s.error?(0,D.jsx)(Ie,{children:s.error instanceof Error?s.error.message:`Failed to load base`}):(0,D.jsx)(fe,{modifiedModelPath:o.model.uri.toString(),originalModelPath:Re(`puddle-base`,e,t,r),original:s.data.content??``,language:o.model.getLanguageId(),theme:be,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(Ie,{children:`…`}),onMount:e=>{c.current=e,e.onDidDispose(()=>{c.current=null}),e.getModifiedEditor().addCommand(ce.CtrlCmd|le.KeyS,()=>l.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,fontSize:a.editorFontSize,wordWrap:a.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function He({session:e,path:t,root:n}){return Le(ye(e,t,n)),(0,D.jsx)(Fe,{session:e,path:t,reveal:null,root:n})}function Ue({session:e,against:t,entry:n,root:r}){switch(n.status){case`added`:return(0,D.jsx)(He,{session:e,path:n.path,root:r});case`deleted`:return(0,D.jsx)(Be,{session:e,against:t,path:n.path,root:r});case`modified`:case`renamed`:return(0,D.jsx)(Ve,{session:e,against:t,path:n.path,basePath:n.old_path??n.path,root:r});default:return null}}function We({session:e,sha:t,path:n}){let r=v(e,t,n);return r.isPending?(0,D.jsx)(Ie,{children:`…`}):r.error?(0,D.jsx)(Ie,{children:r.error instanceof Error?r.error.message:`Failed to load file`}):r.data.binary?(0,D.jsx)(Ie,{children:`Binary file`}):(0,D.jsx)(ze,{session:e,refName:t,path:n,content:r.data.content??``})}function Ge({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o}){let s=re(),c=(0,E.useRef)(null),l=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,E.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,D.jsx)(fe,{originalModelPath:Re(`puddle-hist-orig`,e,t,n),modifiedModelPath:Re(`puddle-hist-mod`,e,i,a),original:r,modified:o,theme:be,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(Ie,{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 Ke({session:e,sha:t,path:n,basePath:r}){let i=v(e,`${t}^`,r),a=v(e,t,n);return i.error instanceof ee&&i.error.status===404?(0,D.jsx)(We,{session:e,sha:t,path:n}):i.isPending||a.isPending?(0,D.jsx)(Ie,{children:`…`}):i.error?(0,D.jsx)(Ie,{children:i.error instanceof Error?i.error.message:`Failed to load original`}):a.error?(0,D.jsx)(Ie,{children:a.error instanceof Error?a.error.message:`Failed to load file`}):i.data.binary||a.data.binary?(0,D.jsx)(Ie,{children:`Binary file`}):(0,D.jsx)(Ge,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:i.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:a.data.content??``})}function qe({session:e,sha:t,entry:n,isRootCommit:r}){switch(p(n.status,r)){case`added`:return(0,D.jsx)(We,{session:e,sha:t,path:n.path});case`deleted`:return(0,D.jsx)(Be,{session:e,against:`${t}^`,path:n.path});case`modified`:case`renamed`:return(0,D.jsx)(Ke,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function Je({session:e,sha:t,path:n,root:r}){let i=o(e,t,r);if(i.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(i.error)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:i.error instanceof Error?i.error.message:`Failed to load commit`});let a=i.data.files.find(e=>e.path===n);return a?(0,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(qe,{session:e,sha:t,entry:a,isRootCommit:i.data.parents.length===0})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,D.jsx)(`span`,{className:`font-mono`,children:n}),` is not part of `,t.slice(0,7),`.`]})}function Ye({session:e,path:t,root:n}){let r=c(e,{root:n});if(r.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(r.error)return(0,D.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,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(Ue,{session:e,against:r.data.against,entry:i,root:n})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,D.jsx)(`span`,{className:`mx-1 font-mono`,children:t}),` against the base.`]})}var Xe=800;function Ze({name:e}){let t=re(),n=a(),r=h(n,e),o=i(`editor.save`),s=(0,E.useRef)(null),c=(0,E.useRef)(null),l=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if((0,E.useEffect)(()=>{if(n===null)return;let t=oe(t=>{d(n,e,t).catch(e=>S.error(e instanceof Error?e.message:`Draft not saved`))},Xe);return c.current=t,()=>{t.flush(),c.current=null}},[n,e]),n===null)return null;if(r.error)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:r.error instanceof Error?r.error.message:`Failed to load the draft`});if(r.data===void 0)return(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`});let f=()=>{let t=s.current;t&&(c.current?.flush(),u({name:e,content:t.getValue()}))};return(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,D.jsxs)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:[`Draft — not in any worktree; `,o,` saves it into one`]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(w,{path:`puddle-untitled://${n}/${e}`,defaultValue:r.data.content,theme:be,keepCurrentModel:!1,loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:t=>{s.current=t,g(e,t.getValue()),Me(t,{onSave:f})},onChange:t=>{let n=t??``;g(e,n),c.current?.(n)},options:{automaticLayout:!0,fontFamily:l,fontSize:t.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function Qe(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 $e(e){if(Array.isArray(e))return e}function et(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 tt(){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{_ as r,c as i,f as a}from"./hotkeys-VY-O_esT.js";import{C as o,D as s,E as c,T as l,c as u,f as d,i as f,m as p,n as m,p as h,s as g,t as _,w as v,x as y,y as b}from"./preview-kind-BKn8hI4T.js";import{t as x}from"./preload-helper-Czpn1I53.js";import{S,r as C,t as ee}from"./api-B3lAdmrV.js";import{t as te}from"./createLucideIcon-DyMAgLa3.js";import{G as ne,K as re,M as ie,N as ae,a as oe,q as se}from"./index-C4dEk1bI.js";import{i as ce,r as le}from"./editor.api2-4X9Vh9Zw.js";import{a as ue,c as de,d as w,f as fe,i as pe,l as me,n as he,o as ge,r as _e,s as ve,t as ye,u as be}from"./buffer-store-ZpUFG5SK.js";import{a as T,c as xe,i as Se,l as Ce,n as we,o as Te,r as Ee,s as De}from"./editor-sync-BnwyuZGE.js";import{r as Oe}from"./buffer-logic-BrpRsL1b.js";var ke=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`}]]),E=e(t(),1);function Ae(e){return!e}function je(e){let t=e.split(`+`),n=t.pop()??``,r=0;for(let e of t)e===`meta`?r|=ce.CtrlCmd:e===`ctrl`?r|=ce.WinCtrl:e===`alt`?r|=ce.Alt:e===`shift`&&(r|=ce.Shift);let i=le[/^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 Me(e,t){let n=je(i(`editor.save`));n!==null&&e.addCommand(n,()=>t.onSave());let r=je(i(`editor.wordWrap`));e.addAction({id:`puddle.toggleWordWrap`,label:`Toggle Word Wrap`,keybindings:r===null?[]:[r],run:()=>re({editorWordWrap:Ae(ne().editorWordWrap)})})}function Ne(e,t,n,r){let i=ye(e,t,r),a=s(e,t,{root:r}),o=l(e,r),[c,u]=(0,E.useState)(null),[d,f]=(0,E.useState)(!1),p=(0,E.useRef)(!1),m=(0,E.useRef)(null),h=(0,E.useRef)(null),g=(0,E.useRef)(n);g.current=n;let _=(0,E.useRef)(!1),v=(0,E.useCallback)((e,t)=>{h.current?.cancel(),_.current=!0;try{ge(i,e,t)}finally{_.current=!1}},[i]),y=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>me(i,e),[i]),()=>_e(i)),b=(0,E.useSyncExternalStore)((0,E.useCallback)(e=>Te(i,e),[i]),()=>T(i));(0,E.useEffect)(()=>{let n=a.data;if(!n||n.binary||n.content===null||p.current)return;p.current=!0;let o=de(i)!==void 0,s=he(e,t,n.content,n.mtime_ms,r);u(s),!o&&Ce(e,t,r).then(e=>{e&&(e.base_mtime_ms===n.mtime_ms?Oe(s,e.content)&&f(!0):S(`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:()=>{Oe(s,e.content)&&f(!0)}}}))})},[a.data,i,e,t,r]),(0,E.useEffect)(()=>{if(!c)return;let n=xe(e,t,r);h.current=n;let a=c.onDidChangeContent(()=>{_.current||(n(c.getValue(),de(i)??0),we(e,t,r))});return()=>{n.flush(),a.dispose(),h.current=null}},[c,i,e,t,r]),(0,E.useEffect)(()=>{!c||!b.savedElsewhere||_e(i)||a.refetch().then(e=>{_e(i)||(e.data&&e.data.content!==null&&v(e.data.content,e.data.mtime_ms),Se(i))})},[b.savedElsewhere,c,i]),(0,E.useEffect)(()=>{let e=a.data;!c||!e||e.content===null||!_e(i)&&e.mtime_ms!==de(i)&&v(e.content,e.mtime_ms)},[a.data,c,i]);let x=(0,E.useCallback)((n,a)=>{pe(i,n,a),h.current?.cancel(),De(e,t,r),Ee(e,t,a,r),f(!1)},[i,e,t,r]),C=(0,E.useCallback)(()=>{a.refetch().then(n=>{n.data&&n.data.content!==null&&v(n.data.content,n.data.mtime_ms),De(e,t,r),f(!1)})},[i,e,t,v]),te=(0,E.useCallback)((e,n)=>{o.mutate({path:t,content:e},{onSuccess:e=>x(n,e.mtime_ms),onError:e=>S.error(e instanceof Error?e.message:`Overwrite failed`)})},[o,t,x]),ne=(0,E.useCallback)(()=>{if(!c||!_e(i))return;let e=c.getValue(),n=c.getAlternativeVersionId();o.mutate({path:t,content:e,expected_mtime_ms:de(i)},{onSuccess:e=>x(n,e.mtime_ms),onError:t=>{t instanceof ee&&t.status===409&&t.code===`stale_file`?S.error(`File changed on disk (probably the agent)`,{duration:1/0,action:{label:`Reload`,onClick:()=>C()},cancel:{label:`Overwrite`,onClick:()=>te(e,n)}}):S.error(t instanceof Error?t.message:`Save failed`)}})},[c,i,o,t,x,C,te]),re=(0,E.useRef)(ne);re.current=ne;let ie=(0,E.useCallback)(()=>{let n=m.current,i=g.current;r===void 0&&(!n||!i||i.session!==e||i.path!==t||(n.revealLineInCenter(i.line),n.setPosition({lineNumber:i.line,column:i.column??1}),n.focus()))},[e,t,r]),ae=(0,E.useCallback)(e=>{m.current=e,Me(e,{onSave:()=>re.current()}),ie()},[ie]);(0,E.useEffect)(()=>{ie()},[n,c,ie]);let oe=(0,E.useCallback)(()=>{C()},[C]),se,ce=null;a.data?.binary?se=`binary`:a.error?a.error instanceof ee&&a.error.status===413?se=`too-large`:(se=`error`,ce=a.error instanceof Error?a.error.message:`Failed to load file`):se=c?`ready`:`loading`;let le=y&&b.savedElsewhere?`saved-elsewhere`:y&&b.dirtyElsewhere?`dirty-elsewhere`:null;return{status:se,errorMessage:ce,model:c,dirty:y,restoredNotice:d,discardRestore:oe,peerBadge:le,save:ne,onMount:ae}}var D=n();function Pe({message:e,session:t,path:n,root:r,download:i}){return(0,D.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 bg-ground text-sm text-fg-muted`,children:[(0,D.jsx)(`span`,{children:e}),i&&(0,D.jsxs)(`button`,{type:`button`,onClick:()=>void b(t,n,r).catch(e=>S.error(e instanceof Error?e.message:`Download failed`)),className:`flex items-center gap-1.5 text-fg-secondary transition-colors hover:text-fg`,children:[(0,D.jsx)(ke,{className:`size-4`}),`Download`]})]})}function Fe({session:e,path:t,reveal:n,root:r}){let i=se(),a=Ne(e,t,n,r),o=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if(a.status===`binary`)return(0,D.jsx)(Pe,{message:`Binary file — use Download`,session:e,path:t,root:r,download:!0});if(a.status===`too-large`)return(0,D.jsx)(Pe,{message:`File too large to edit — use Download`,session:e,path:t,root:r,download:!0});if(a.status===`error`)return(0,D.jsx)(Pe,{message:a.errorMessage??`Failed to load file`,session:e,path:t,root:r});let s=a.peerBadge===`saved-elsewhere`?`Saved in another window`:a.peerBadge===`dirty-elsewhere`?`Also being edited in another window`:null;return(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[a.restoredNotice&&(0,D.jsxs)(`div`,{className:`flex items-center gap-3 bg-elevated px-3 py-1.5 text-xs text-fg-secondary`,children:[(0,D.jsx)(`span`,{children:`Restored unsaved changes`}),(0,D.jsx)(`button`,{type:`button`,onClick:a.discardRestore,className:`text-fg-muted transition-colors hover:text-fg`,children:`Discard`})]}),s&&(0,D.jsx)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:s}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:a.model&&(0,D.jsx)(w,{path:a.model.uri.toString(),defaultValue:a.model.getValue(),theme:`puddle`,keepCurrentModel:!0,onMount:e=>a.onMount(e),loading:(0,D.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 Ie({children:e}){return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center px-4 text-xs text-fg-muted`,children:e})}function Le(e,t){let n=(0,E.useRef)(t);n.current=t,(0,E.useEffect)(()=>(ve(e),()=>{n.current?.(),ue(e)}),[e])}function Re(e,t,n,r){let i=r.split(`/`).map(encodeURIComponent).join(`/`);return`${e}://${encodeURIComponent(t)}/${encodeURIComponent(n)}/${i}`}function ze({session:e,refName:t,path:n,content:r}){let i=se(),a=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,D.jsx)(w,{path:Re(`puddle-view`,e,t,n),defaultValue:r,theme:be,loading:(0,D.jsx)(Ie,{children:`…`}),options:{readOnly:!0,automaticLayout:!0,fontFamily:a,fontSize:i.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function Be({session:e,against:t,path:n,root:r}){let i=v(e,t,n,{root:r});return i.isPending?(0,D.jsx)(Ie,{children:`…`}):i.error?(0,D.jsx)(Ie,{children:i.error instanceof Error?i.error.message:`Failed to load`}):i.data.binary?(0,D.jsx)(Ie,{children:`Binary file — deleted`}):(0,D.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,D.jsx)(`div`,{className:`bg-surface px-4 py-1 text-xs text-fg-muted`,children:`Deleted`}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(ze,{session:e,refName:t,path:n,content:i.data.content??``})})]})}function Ve({session:e,against:t,path:n,basePath:r,root:i}){let a=se(),o=Ne(e,n,null,i),s=v(e,t,r,{root:i}),c=(0,E.useRef)(null);Le(ye(e,n),()=>{let e=c.current;if(!e)return;let t=e.getModel();e.setModel(null),t?.original.dispose(),c.current=null});let l=(0,E.useRef)(o.save);l.current=o.save;let u=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]),d=s.error instanceof ee&&s.error.status===404;return o.status===`binary`||s.data?.binary?(0,D.jsx)(Ie,{children:`Binary file`}):o.status===`too-large`?(0,D.jsx)(Ie,{children:`File too large to show`}):o.status===`error`?(0,D.jsx)(Ie,{children:o.errorMessage??`Failed to load file`}):d?(0,D.jsx)(Fe,{session:e,path:n,reveal:null}):s.isPending||!o.model?(0,D.jsx)(Ie,{children:`…`}):s.error?(0,D.jsx)(Ie,{children:s.error instanceof Error?s.error.message:`Failed to load base`}):(0,D.jsx)(fe,{modifiedModelPath:o.model.uri.toString(),originalModelPath:Re(`puddle-base`,e,t,r),original:s.data.content??``,language:o.model.getLanguageId(),theme:be,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(Ie,{children:`…`}),onMount:e=>{c.current=e,e.onDidDispose(()=>{c.current=null}),e.getModifiedEditor().addCommand(ce.CtrlCmd|le.KeyS,()=>l.current())},options:{readOnly:!1,originalEditable:!1,renderSideBySide:!0,automaticLayout:!0,fontFamily:u,fontSize:a.editorFontSize,wordWrap:a.editorWordWrap?`on`:`off`,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})}function He({session:e,path:t,root:n}){return Le(ye(e,t,n)),(0,D.jsx)(Fe,{session:e,path:t,reveal:null,root:n})}function Ue({session:e,against:t,entry:n,root:r}){switch(n.status){case`added`:return(0,D.jsx)(He,{session:e,path:n.path,root:r});case`deleted`:return(0,D.jsx)(Be,{session:e,against:t,path:n.path,root:r});case`modified`:case`renamed`:return(0,D.jsx)(Ve,{session:e,against:t,path:n.path,basePath:n.old_path??n.path,root:r});default:return null}}function We({session:e,sha:t,path:n}){let r=v(e,t,n);return r.isPending?(0,D.jsx)(Ie,{children:`…`}):r.error?(0,D.jsx)(Ie,{children:r.error instanceof Error?r.error.message:`Failed to load file`}):r.data.binary?(0,D.jsx)(Ie,{children:`Binary file`}):(0,D.jsx)(ze,{session:e,refName:t,path:n,content:r.data.content??``})}function Ge({session:e,originalRef:t,originalPath:n,originalContent:r,modifiedRef:i,modifiedPath:a,modifiedContent:o}){let s=se(),c=(0,E.useRef)(null),l=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);return(0,E.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,D.jsx)(fe,{originalModelPath:Re(`puddle-hist-orig`,e,t,n),modifiedModelPath:Re(`puddle-hist-mod`,e,i,a),original:r,modified:o,theme:be,keepCurrentOriginalModel:!0,keepCurrentModifiedModel:!0,loading:(0,D.jsx)(Ie,{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 Ke({session:e,sha:t,path:n,basePath:r}){let i=v(e,`${t}^`,r),a=v(e,t,n);return i.error instanceof ee&&i.error.status===404?(0,D.jsx)(We,{session:e,sha:t,path:n}):i.isPending||a.isPending?(0,D.jsx)(Ie,{children:`…`}):i.error?(0,D.jsx)(Ie,{children:i.error instanceof Error?i.error.message:`Failed to load original`}):a.error?(0,D.jsx)(Ie,{children:a.error instanceof Error?a.error.message:`Failed to load file`}):i.data.binary||a.data.binary?(0,D.jsx)(Ie,{children:`Binary file`}):(0,D.jsx)(Ge,{session:e,originalRef:`${t}^`,originalPath:r,originalContent:i.data.content??``,modifiedRef:t,modifiedPath:n,modifiedContent:a.data.content??``})}function qe({session:e,sha:t,entry:n,isRootCommit:r}){switch(p(n.status,r)){case`added`:return(0,D.jsx)(We,{session:e,sha:t,path:n.path});case`deleted`:return(0,D.jsx)(Be,{session:e,against:`${t}^`,path:n.path});case`modified`:case`renamed`:return(0,D.jsx)(Ke,{session:e,sha:t,path:n.path,basePath:n.old_path??n.path});default:return null}}function Je({session:e,sha:t,path:n,root:r}){let i=o(e,t,r);if(i.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading commit…`});if(i.error)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:i.error instanceof Error?i.error.message:`Failed to load commit`});let a=i.data.files.find(e=>e.path===n);return a?(0,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(qe,{session:e,sha:t,entry:a,isRootCommit:i.data.parents.length===0})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[(0,D.jsx)(`span`,{className:`font-mono`,children:n}),` is not part of `,t.slice(0,7),`.`]})}function Ye({session:e,path:t,root:n}){let r=c(e,{root:n});if(r.isPending)return(0,D.jsx)(`div`,{className:`px-4 py-3 text-xs text-fg-muted`,children:`Loading diff…`});if(r.error)return(0,D.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,D.jsx)(`div`,{className:`h-full`,children:(0,D.jsx)(Ue,{session:e,against:r.data.against,entry:i,root:n})}):(0,D.jsxs)(`div`,{className:`flex h-full items-center justify-center px-4 text-center text-xs text-fg-muted`,children:[`No changes to `,(0,D.jsx)(`span`,{className:`mx-1 font-mono`,children:t}),` against the base.`]})}var Xe=800;function Ze({name:e}){let t=se(),n=r(),i=h(n,e),o=a(`editor.save`),s=(0,E.useRef)(null),c=(0,E.useRef)(null),l=(0,E.useMemo)(()=>getComputedStyle(document.documentElement).getPropertyValue(`--font-mono`).trim()||void 0,[]);if((0,E.useEffect)(()=>{if(n===null)return;let t=oe(t=>{d(n,e,t).catch(e=>S.error(e instanceof Error?e.message:`Draft not saved`))},Xe);return c.current=t,()=>{t.flush(),c.current=null}},[n,e]),n===null)return null;if(i.error)return(0,D.jsx)(`div`,{className:`flex h-full items-center justify-center bg-ground text-sm text-fg-muted`,children:i.error instanceof Error?i.error.message:`Failed to load the draft`});if(i.data===void 0)return(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`});let f=()=>{let t=s.current;t&&(c.current?.flush(),u({name:e,content:t.getValue()}))};return(0,D.jsxs)(`div`,{className:`flex h-full flex-col bg-ground`,children:[(0,D.jsxs)(`div`,{className:`bg-surface px-3 py-1 text-xs text-fg-muted`,children:[`Draft — not in any worktree; `,o,` saves it into one`]}),(0,D.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,D.jsx)(w,{path:`puddle-untitled://${n}/${e}`,defaultValue:i.data.content,theme:be,keepCurrentModel:!1,loading:(0,D.jsx)(`div`,{className:`p-3 text-xs text-fg-muted`,children:`…`}),onMount:t=>{s.current=t,g(e,t.getValue()),Me(t,{onSave:f})},onChange:t=>{let n=t??``;g(e,n),c.current?.(n)},options:{automaticLayout:!0,fontFamily:l,fontSize:t.editorFontSize,minimap:{enabled:!1},fixedOverflowWidgets:!0,scrollBeyondLastLine:!1}})})]})}function Qe(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 $e(e){if(Array.isArray(e))return e}function et(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 tt(){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 nt(e,t){return $e(e)||et(e,t)||rt(e,t)||tt()}function rt(e,t){if(e){if(typeof e==`string`)return Qe(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)?Qe(e,t):void 0}}var it=Object.entries,at=Object.setPrototypeOf,ot=Object.isFrozen,st=Object.getPrototypeOf,ct=Object.getOwnPropertyDescriptor,lt=Object.freeze,ut=Object.seal,dt=Object.create,ft=typeof Reflect<`u`&&Reflect,pt=ft.apply,mt=ft.construct;lt||=function(e){return e},ut||=function(e){return e},pt||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},mt||=function(e){return new e(...[...arguments].slice(1))};var ht=Ft(Array.prototype.forEach),gt=Ft(Array.prototype.lastIndexOf),_t=Ft(Array.prototype.pop),vt=Ft(Array.prototype.push),yt=Ft(Array.prototype.splice),bt=Array.isArray,xt=Ft(String.prototype.toLowerCase),St=Ft(String.prototype.toString),Ct=Ft(String.prototype.match),wt=Ft(String.prototype.replace),Tt=Ft(String.prototype.indexOf),Et=Ft(String.prototype.trim),Dt=Ft(Number.prototype.toString),Ot=Ft(Boolean.prototype.toString),kt=typeof BigInt>`u`?null:Ft(BigInt.prototype.toString),At=typeof Symbol>`u`?null:Ft(Symbol.prototype.toString),jt=Ft(Object.prototype.hasOwnProperty),Mt=Ft(Object.prototype.toString),Nt=Ft(RegExp.prototype.test),Pt=It(TypeError);function Ft(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return pt(e,t,n)}}function It(e){return function(){return mt(e,[...arguments])}}function O(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:xt;if(at&&at(e,null),!bt(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(ot(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Lt(e){for(let t=0;t<e.length;t++)jt(e,t)||(e[t]=null);return e}function Rt(e){let t=dt(null);for(let r of it(e)){var n=nt(r,2);let i=n[0],a=n[1];jt(e,i)&&(bt(a)?t[i]=Lt(a):a&&typeof a==`object`&&a.constructor===Object?t[i]=Rt(a):t[i]=a)}return t}function zt(e){switch(typeof e){case`string`:return e;case`number`:return Dt(e);case`boolean`:return Ot(e);case`bigint`:return kt?kt(e):`0`;case`symbol`:return At?At(e):`Symbol()`;case`undefined`:return Mt(e);case`function`:case`object`:{if(e===null)return Mt(e);let t=e,n=Bt(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Mt(e)}return Mt(e)}default:return Mt(e)}}function Bt(e,t){for(;e!==null;){let n=ct(e,t);if(n){if(n.get)return Ft(n.get);if(typeof n.value==`function`)return Ft(n.value)}e=st(e)}function n(){return null}return n}function Vt(e){try{return Nt(e,``),!0}catch{return!1}}var Ht=lt(`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(`.`)),Ut=lt(`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(`.`)),Wt=lt([`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`]),Gt=lt([`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`]),Kt=lt(`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(`.`)),qt=lt([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Jt=lt([`#text`]),Yt=lt(`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(`.`)),Xt=lt(`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(`.`)),Zt=lt(`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(`.`)),Qt=lt([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),$t=ut(/{{[\w\W]*|^[\w\W]*}}/g),en=ut(/<%[\w\W]*|^[\w\W]*%>/g),tn=ut(/\${[\w\W]*/g),nn=ut(/^data-[\-\w.\u00B7-\uFFFF]+$/),rn=ut(/^aria-[\-\w]+$/),an=ut(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),on=ut(/^(?:\w+script|data):/i),sn=ut(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),cn=ut(/^html$/i),ln=ut(/^[a-z][.\w]*(-[.\w]+)+$/i),un=ut(/<[/\w!]/g),dn=ut(/<[/\w]/g),fn=ut(/<\/no(script|embed|frames)/i),pn=ut(/\/>/i),mn={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},hn=function(){return typeof window>`u`?null:window},gn=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}},_n=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},vn=function(e,t,n,r){return jt(e,t)&&bt(e[t])?O(r.base?Rt(r.base):{},e[t],r.transform):n};function yn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:hn(),t=e=>yn(e);if(t.version=`3.4.12`,t.removed=[],!e||!e.document||e.document.nodeType!==mn.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=Bt(d,`cloneNode`),p=Bt(d,`remove`),m=Bt(d,`nextSibling`),h=Bt(d,`childNodes`),g=Bt(d,`parentNode`),_=Bt(d,`shadowRoot`),v=Bt(d,`attributes`),y=o&&o.prototype?Bt(o.prototype,`nodeType`):null,b=o&&o.prototype?Bt(o.prototype,`nodeName`):null;if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,C,ee=!1,te=0,ne=function(){if(te>0)throw Pt(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},re=function(e){ne(),te++;try{return x.createHTML(e)}finally{te--}},ie=function(e){ne(),te++;try{return x.createScriptURL(e)}finally{te--}},ae=function(){return ee||=(C=gn(u,i),!0),C},oe=n,se=oe.implementation,ce=oe.createNodeIterator,le=oe.createDocumentFragment,ue=oe.getElementsByTagName,de=r.importNode,w=_n();t.isSupported=typeof it==`function`&&typeof g==`function`&&se&&se.createHTMLDocument!==void 0;let fe=$t,pe=en,me=tn,he=nn,ge=rn,_e=on,ve=sn,ye=ln,be=an,T=null,xe=O({},[...Ht,...Ut,...Wt,...Kt,...Jt]),Se=null,Ce=O({},[...Yt,...Xt,...Zt,...Qt]),we=Object.seal(dt(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Te=null,Ee=null,De=Object.seal(dt(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Oe=!0,ke=!0,E=!1,Ae=!0,je=!1,Me=!0,Ne=!1,D=!1,Pe=null,Fe=null,Ie=!1,Le=!1,Re=!1,ze=!1,Be=!0,Ve=!1,He=`user-content-`,Ue=!0,We=!1,Ge={},Ke=null,qe=O({},`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(`.`)),Je=null,Ye=O({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Xe=null,Ze=O({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Qe=`http://www.w3.org/1998/Math/MathML`,$e=`http://www.w3.org/2000/svg`,et=`http://www.w3.org/1999/xhtml`,tt=et,nt=!1,rt=null,at=O({},[Qe,$e,et],St),ot=lt([`mi`,`mo`,`mn`,`ms`,`mtext`]),st=O({},ot),ct=lt([`annotation-xml`]),ft=O({},ct),pt=O({},[`title`,`style`,`font`,`a`,`script`]),mt=null,Dt=[`application/xhtml+xml`,`text/html`],Ot=null,kt=null,At=n.createElement(`form`),Mt=function(e){return e instanceof RegExp||e instanceof Function},Ft=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(kt&&kt===e)return;(!e||typeof e!=`object`)&&(e={}),e=Rt(e),mt=Dt.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,Ot=mt===`application/xhtml+xml`?St:xt,T=vn(e,`ALLOWED_TAGS`,xe,{transform:Ot}),Se=vn(e,`ALLOWED_ATTR`,Ce,{transform:Ot}),rt=vn(e,`ALLOWED_NAMESPACES`,at,{transform:St}),Xe=vn(e,`ADD_URI_SAFE_ATTR`,Ze,{transform:Ot,base:Ze}),Je=vn(e,`ADD_DATA_URI_TAGS`,Ye,{transform:Ot,base:Ye}),Ke=vn(e,`FORBID_CONTENTS`,qe,{transform:Ot}),Te=vn(e,`FORBID_TAGS`,Rt({}),{transform:Ot}),Ee=vn(e,`FORBID_ATTR`,Rt({}),{transform:Ot}),Ge=jt(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?Rt(e.USE_PROFILES):e.USE_PROFILES:!1,Oe=e.ALLOW_ARIA_ATTR!==!1,ke=e.ALLOW_DATA_ATTR!==!1,E=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ae=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,je=e.SAFE_FOR_TEMPLATES||!1,Me=e.SAFE_FOR_XML!==!1,Ne=e.WHOLE_DOCUMENT||!1,Le=e.RETURN_DOM||!1,Re=e.RETURN_DOM_FRAGMENT||!1,ze=e.RETURN_TRUSTED_TYPE||!1,Ie=e.FORCE_BODY||!1,Be=e.SANITIZE_DOM!==!1,Ve=e.SANITIZE_NAMED_PROPS||!1,Ue=e.KEEP_CONTENT!==!1,We=e.IN_PLACE||!1,be=Vt(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:an,tt=typeof e.NAMESPACE==`string`?e.NAMESPACE:et,st=jt(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?Rt(e.MATHML_TEXT_INTEGRATION_POINTS):O({},ot),ft=jt(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?Rt(e.HTML_INTEGRATION_POINTS):O({},ct);let t=jt(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?Rt(e.CUSTOM_ELEMENT_HANDLING):dt(null);if(we=dt(null),jt(t,`tagNameCheck`)&&Mt(t.tagNameCheck)&&(we.tagNameCheck=t.tagNameCheck),jt(t,`attributeNameCheck`)&&Mt(t.attributeNameCheck)&&(we.attributeNameCheck=t.attributeNameCheck),jt(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(we.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),ut(we),je&&(ke=!1),Re&&(Le=!0),Ge&&(T=O({},Jt),Se=dt(null),Ge.html===!0&&(O(T,Ht),O(Se,Yt)),Ge.svg===!0&&(O(T,Ut),O(Se,Xt),O(Se,Qt)),Ge.svgFilters===!0&&(O(T,Wt),O(Se,Xt),O(Se,Qt)),Ge.mathMl===!0&&(O(T,Kt),O(Se,Zt),O(Se,Qt))),De.tagCheck=null,De.attributeCheck=null,jt(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?De.tagCheck=e.ADD_TAGS:bt(e.ADD_TAGS)&&(T===xe&&(T=Rt(T)),O(T,e.ADD_TAGS,Ot))),jt(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?De.attributeCheck=e.ADD_ATTR:bt(e.ADD_ATTR)&&(Se===Ce&&(Se=Rt(Se)),O(Se,e.ADD_ATTR,Ot))),jt(e,`ADD_URI_SAFE_ATTR`)&&bt(e.ADD_URI_SAFE_ATTR)&&O(Xe,e.ADD_URI_SAFE_ATTR,Ot),jt(e,`FORBID_CONTENTS`)&&bt(e.FORBID_CONTENTS)&&(Ke===qe&&(Ke=Rt(Ke)),O(Ke,e.FORBID_CONTENTS,Ot)),jt(e,`ADD_FORBID_CONTENTS`)&&bt(e.ADD_FORBID_CONTENTS)&&(Ke===qe&&(Ke=Rt(Ke)),O(Ke,e.ADD_FORBID_CONTENTS,Ot)),Ue&&(T[`#text`]=!0),Ne&&O(T,[`html`,`head`,`body`]),T.table&&(O(T,[`tbody`]),delete Te.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Pt(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Pt(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=re(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=ae()),x&&typeof S==`string`&&(S=re(``)));lt&<(e),kt=e},It=O({},[...Ut,...Wt,...Gt]),Lt=O({},[...Kt,...qt]),bn=function(e,t,n){return t.namespaceURI===et?e===`svg`:t.namespaceURI===Qe?e===`svg`&&(n===`annotation-xml`||st[n]):!!It[e]},xn=function(e,t,n){return t.namespaceURI===et?e===`math`:t.namespaceURI===$e?e===`math`&&ft[n]:!!Lt[e]},Sn=function(e,t,n){return t.namespaceURI===$e&&!ft[n]||t.namespaceURI===Qe&&!st[n]?!1:!Lt[e]&&(pt[e]||!It[e])},Cn=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:tt,tagName:`template`});let n=xt(e.tagName),r=xt(t.tagName);return rt[e.namespaceURI]?e.namespaceURI===$e?bn(n,t,r):e.namespaceURI===Qe?xn(n,t,r):e.namespaceURI===et?Sn(n,t,r):!!(mt===`application/xhtml+xml`&&rt[e.namespaceURI]):!1},wn=function(e){vt(t.removed,{element:e});try{g(e).removeChild(e)}catch{if(p(e),!g(e))throw Pt(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},Tn=function(e){Dn(e);let t=h(e);if(t){let e=[];ht(t,t=>{vt(e,t)}),ht(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{}}},k=function(e,n){try{vt(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{vt(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(Le||Re)try{wn(n)}catch{}else try{n.setAttribute(e,``)}catch{}},En=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`||Se[Ot(i)]))try{e.removeAttribute(i)}catch{}}},Dn=function(e){let t=[e];for(;t.length>0;){let e=t.pop();(y?y(e):e.nodeType)===mn.element&&En(e);let n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}},On=function(e){if(!Me)return;let t=[e];for(;t.length>0;){let e=t.pop(),n=y?y(e):e.nodeType;if(n===mn.processingInstruction||n===mn.comment&&Nt(dn,e.data)){try{p(e)}catch{}continue}if(n===mn.element){let t=e,n=Ot(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])}},kn=function(e){let t=null,r=null;if(Ie)e=`<remove></remove>`+e;else{let t=Ct(e,/^[\r\n\t ]+/);r=t&&t[0]}mt===`application/xhtml+xml`&&tt===et&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=x?re(e):e;if(tt===et)try{t=new l().parseFromString(i,mt)}catch{}if(!t||!t.documentElement){t=se.createDocument(tt,`template`,null);try{t.documentElement.innerHTML=nt?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),tt===et?ue.call(t,Ne?`html`:`body`)[0]:Ne?t.documentElement:a},An=function(e){return ce.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},jn=function(e){return e=wt(e,fe,` `),e=wt(e,pe,` `),e=wt(e,me,` `),e},Mn=function(e){e.normalize();let t=ce.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),n=t.nextNode();for(;n;)n.data=jn(n.data),n=t.nextNode();let r=e.querySelectorAll?.call(e,`template`);r&&ht(r,e=>{Pn(e.content)&&Mn(e.content)})},Nn=function(e){let t=b?b(e):null;return typeof t!=`string`||Ot(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)},Pn=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===mn.documentFragment}catch{return!1}},Fn=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function In(e,n,r){e.length!==0&&ht(e,e=>{e.call(t,n,r,kt)})}let Ln=function(e,t){return!!(Me&&e.hasChildNodes()&&!Fn(e.firstElementChild)&&Nt(un,e.textContent)&&Nt(un,e.innerHTML)||Me&&e.namespaceURI===et&&t===`style`&&Fn(e.firstElementChild)||e.nodeType===mn.processingInstruction||Me&&e.nodeType===mn.comment&&Nt(dn,e.data))},Rn=function(e,t){if(!Te[t]&&Hn(t)&&(we.tagNameCheck instanceof RegExp&&Nt(we.tagNameCheck,t)||we.tagNameCheck instanceof Function&&we.tagNameCheck(t)))return!1;if(Ue&&!Ke[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=We?n[i]:f(n[i],!0);t.insertBefore(r,m(e))}}}return wn(e),!0},zn=function(e,n){if(In(w.beforeSanitizeElements,e,null),e!==n&&g(e)===null)return!0;if(Nn(e))return wn(e),!0;let r=Ot(b?b(e):e.nodeName);if(In(w.uponSanitizeElement,e,{tagName:r,allowedTags:T}),e!==n&&g(e)===null)return!0;if(Ln(e,r))return wn(e),!0;if(Te[r]||!(De.tagCheck instanceof Function&&De.tagCheck(r))&&!T[r]){let t=Rn(e,r);return t===!1&&In(w.afterSanitizeElements,e,null),t}if((y?y(e):e.nodeType)===mn.element&&!Cn(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&Nt(fn,e.innerHTML))return wn(e),!0;if(je&&e.nodeType===mn.text){let n=jn(e.textContent);e.textContent!==n&&(vt(t.removed,{element:e.cloneNode()}),e.textContent=n)}return In(w.afterSanitizeElements,e,null),!1},Bn=function(e,t,r){if(Ee[t]||Me&&t===`patchsrc`||Me&&t===`for`&&e!==`label`&&e!==`output`||Be&&(t===`id`||t===`name`)&&(r in n||r in At))return!1;let i=Se[t]||De.attributeCheck instanceof Function&&De.attributeCheck(t,e);if(!(ke&&Nt(he,t))&&!(Oe&&Nt(ge,t))){if(!i){if(!(Hn(e)&&(we.tagNameCheck instanceof RegExp&&Nt(we.tagNameCheck,e)||we.tagNameCheck instanceof Function&&we.tagNameCheck(e))&&(we.attributeNameCheck instanceof RegExp&&Nt(we.attributeNameCheck,t)||we.attributeNameCheck instanceof Function&&we.attributeNameCheck(t,e))||t===`is`&&we.allowCustomizedBuiltInElements&&(we.tagNameCheck instanceof RegExp&&Nt(we.tagNameCheck,r)||we.tagNameCheck instanceof Function&&we.tagNameCheck(r))))return!1}else if(!Xe[t]&&!Nt(be,wt(r,ve,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Tt(r,`data:`)===0&&Je[e])&&!(E&&!Nt(_e,wt(r,ve,``)))&&r)return!1}return!0},Vn=O({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Hn=function(e){return!Vn[xt(e)]&&Nt(ye,e)},Un=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return re(r);case`TrustedScriptURL`:return ie(r)}return r},Wn=function(e,n,r,i){try{r?e.setAttributeNS(r,n,i):e.setAttribute(n,i),Nn(e)?wn(e):_t(t.removed)}catch{k(n,e)}},Gn=function(e){In(w.beforeSanitizeAttributes,e,null);let t=e.attributes;if(!t||Nn(e))return;let n={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:Se,forceKeepAttr:void 0},r=t.length,i=Ot(e.nodeName);for(;r--;){let a=t[r],o=a.name,s=a.namespaceURI,c=a.value,l=Ot(o),u=c,d=o===`value`?u:Et(u);if(n.attrName=l,n.attrValue=d,n.keepAttr=!0,n.forceKeepAttr=void 0,In(w.uponSanitizeAttribute,e,n),d=n.attrValue,Ve&&(l===`id`||l===`name`)&&Tt(d,He)!==0&&(k(o,e),d=He+d),Me&&Nt(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){k(o,e);continue}if(l===`attributename`&&Ct(d,`href`)){k(o,e);continue}if(!n.forceKeepAttr){if(!n.keepAttr){k(o,e);continue}if(!Ae&&Nt(pn,d)){k(o,e);continue}if(je&&(d=jn(d)),!Bn(i,l,d)){k(o,e);continue}d=Un(i,l,s,d),d!==u&&Wn(e,o,s,d)}}In(w.afterSanitizeAttributes,e,null)},Kn=function(e){let t=null,n=An(e);for(In(w.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(In(w.uponSanitizeShadowNode,t,null),zn(t,e),Gn(t),Pn(t.content)&&Kn(t.content),(y?y(t):t.nodeType)===mn.element){let e=_(t);Pn(e)&&(qn(e),Kn(e))}In(w.afterSanitizeShadowDOM,e,null)},qn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){Kn(e.shadow);continue}let n=e.node,r=(y?y(n):n.nodeType)===mn.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`&&Ot(e)===`template`){let e=n.content;Pn(e)&&t.push({node:e,shadow:null})}}if(r){let e=_(n);Pn(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(nt=!e,nt&&(e=`<!-->`),typeof e!=`string`&&!Fn(e)&&(e=zt(e),typeof e!=`string`))throw Pt(`dirty is not a string, aborting`);if(!t.isSupported)return e;D?(T=Pe,Se=Fe):Ft(n),(w.uponSanitizeElement.length>0||w.uponSanitizeAttribute.length>0)&&(T=Rt(T)),w.uponSanitizeAttribute.length>0&&(Se=Rt(Se)),t.removed=[];let c=We&&typeof e!=`string`&&Fn(e);if(c){On(e);let t=b?b(e):e.nodeName;if(typeof t==`string`){let n=Ot(t);if(!T[n]||Te[n])throw Tn(e),Pt(`root node is forbidden and cannot be sanitized in-place`)}if(Nn(e))throw Tn(e),Pt(`root node is clobbered and cannot be sanitized in-place`);try{qn(e)}catch(t){throw Tn(e),t}}else if(Fn(e))i=kn(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===mn.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),qn(a);else{if(!Le&&!je&&!Ne&&e.indexOf(`<`)===-1)return x&&ze?re(e):e;if(i=kn(e),!i)return Le?null:ze?S:``}i&&Ie&&wn(i.firstChild);let l=c?e:i,u=An(l);try{for(;o=u.nextNode();)zn(o,l),Gn(o),Pn(o.content)&&Kn(o.content)}catch(n){throw c&&(Tn(e),ht(t.removed,e=>{e.element&&Dn(e.element)})),n}if(c)return ht(t.removed,e=>{e.element&&Dn(e.element)}),je&&Mn(e),e;if(Le){if(je&&Mn(i),Re)for(s=le.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(Se.shadowroot||Se.shadowrootmode)&&(s=de.call(r,s,!0)),s}let d=Ne?i.outerHTML:i.innerHTML;return Ne&&T[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Nt(cn,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
3
3
|
`+d),je&&(d=jn(d)),x&&ze?re(d):d},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ft(e),D=!0,Pe=T,Fe=Se},t.clearConfig=function(){kt=null,D=!1,Pe=null,Fe=null,x=C,S=``},t.isValidAttribute=function(e,t,n){kt||Ft({});let r=Ot(e),i=Ot(t);return Bn(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&jt(w,e)&&vt(w[e],t)},t.removeHook=function(e,t){if(jt(w,e)){if(t!==void 0){let n=gt(w[e],t);return n===-1?void 0:yt(w[e],n,1)[0]}return _t(w[e])}},t.removeHooks=function(e){jt(w,e)&&(w[e]=[])},t.removeAllHooks=function(){w=_n()},t}var bn=yn();function xn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Sn=xn();function Cn(e){Sn=e}var wn={exec:()=>null};function Tn(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 k(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(Dn.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var En=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),Dn={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:Tn(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Tn(e=>RegExp(`^ {0,${e}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`)),fencesBeginRegex:Tn(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Tn(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Tn(e=>RegExp(`^ {0,${e}}<(?:[a-z].*>|!--)`,`i`)),blockquoteBeginRegex:Tn(e=>RegExp(`^ {0,${e}}>`))},On=/^(?:[ \t]*(?:\n|$))+/,kn=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,An=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,jn=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Mn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,Nn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Pn=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Fn=k(Pn).replace(/bull/g,Nn).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(),In=k(Pn).replace(/bull/g,Nn).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(),Ln=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Rn=/^[^\n]+/,zn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Bn=k(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,zn).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Vn=k(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,Nn).getRegex(),Hn=`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`,Un=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Wn=k(`^ {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`,Un).replace(`tag`,Hn).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Gn=e=>k(Ln).replace(`hr`,jn).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`,Hn).getRegex(),Kn=Gn(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),qn=Gn(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Jn={blockquote:k(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,qn).getRegex(),code:kn,def:Bn,fences:An,heading:Mn,hr:jn,html:Wn,lheading:Fn,list:Vn,newline:On,paragraph:Kn,table:wn,text:Rn},Yn=k(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,jn).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`,Hn).getRegex(),Xn={...Jn,lheading:In,table:Yn,paragraph:k(Ln).replace(`hr`,jn).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,Yn).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`,Hn).getRegex()},Zn={...Jn,html:k(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Un).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:wn,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:k(Ln).replace(`hr`,jn).replace(`heading`,` *#{1,6} *[^
|
|
4
4
|
]`).replace(`lheading`,Fn).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Qn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,$n=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,er=/^( {2,}|\\)\n(?!\s*$)/,tr=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,nr=/[\p{P}\p{S}]/u,rr=/[\s\p{P}\p{S}]/u,ir=/[^\s\p{P}\p{S}]/u,ar=k(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,rr).getRegex(),or=/(?!~)[\p{P}\p{S}]/u,sr=/(?!~)[\s\p{P}\p{S}]/u,cr=/(?:[^\s\p{P}\p{S}]|~)/u,lr=k(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,En?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),ur=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,dr=k(ur,`u`).replace(/punct/g,nr).getRegex(),fr=k(ur,`u`).replace(/punct/g,or).getRegex(),pr=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,mr=k(pr,`gu`).replace(/notPunctSpace/g,ir).replace(/punctSpace/g,rr).replace(/punct/g,nr).getRegex(),hr=k(pr,`gu`).replace(/notPunctSpace/g,cr).replace(/punctSpace/g,sr).replace(/punct/g,or).getRegex(),gr=k(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,ir).replace(/punctSpace/g,rr).replace(/punct/g,nr).getRegex(),_r=k(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,nr).getRegex(),vr=k(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,ir).replace(/punctSpace/g,rr).replace(/punct/g,nr).getRegex(),yr=k(/\\(punct)/,`gu`).replace(/punct/g,nr).getRegex(),br=k(/^<(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(),xr=k(Un).replace(`(?:-->|$)`,`-->`).getRegex(),Sr=k(`^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`,xr).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Cr=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,wr=k(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace(`label`,Cr).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Tr=k(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Cr).replace(`ref`,zn).getRegex(),Er=k(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,zn).getRegex(),Dr=k(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Tr).replace(`nolink`,Er).getRegex(),Or=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,kr={_backpedal:wn,anyPunctuation:yr,autolink:br,blockSkip:lr,br:er,code:$n,del:wn,delLDelim:wn,delRDelim:wn,emStrongLDelim:dr,emStrongRDelimAst:mr,emStrongRDelimUnd:gr,escape:Qn,link:wr,nolink:Er,punctuation:ar,reflink:Tr,reflinkSearch:Dr,tag:Sr,text:tr,url:wn},Ar={...kr,link:k(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Cr).getRegex(),reflink:k(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Cr).getRegex()},jr={...kr,emStrongRDelimAst:hr,emStrongLDelim:fr,delLDelim:_r,delRDelim:vr,url:k(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`protocol`,Or).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:k(/^(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace(`protocol`,Or).getRegex()},Mr={...jr,br:k(er).replace(`{2,}`,`*`).getRegex(),text:k(jr.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Nr={normal:Jn,gfm:Xn,pedantic:Zn},Pr={normal:kr,gfm:jr,breaks:Mr,pedantic:Ar},Fr={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Ir=e=>Fr[e];function Lr(e,t){if(t){if(Dn.escapeTest.test(e))return e.replace(Dn.escapeReplace,Ir)}else if(Dn.escapeTestNoEncode.test(e))return e.replace(Dn.escapeReplaceNoEncode,Ir);return e}function Rr(e){try{e=encodeURI(e).replace(Dn.percentDecode,`%`)}catch{return null}return e}function zr(e,t){let n=e.replace(Dn.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(Dn.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(Dn.slashPipe,`|`);return n}function Br(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 Vr(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 ]*`,Ol=`[̀-ͯ]`,kl=RegExp(Ol+`+$`),Al=`(`+Cl+`+)|`+(Dl+`|`)+`([!-\\[\\]-‧-豈-]`+(Ol+`*`)+`|[\ud800-\udbff][\udc00-\udfff]`+(Ol+`*`)+`|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5`+(`|`+El)+(`|`+Tl+`)`),jl=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(Al,`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 Mc(`EOF`,new jc(this,t,t));var n=this.tokenRegex.exec(e);if(n===null||n.index!==t)throw new j(`Unexpected character: '`+e[t]+`'`,new Mc(e[t],new jc(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 Mc(r,new jc(this,t,this.tokenRegex.lastIndex))}},Ml=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 j(`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}},Nl=Ac;$(`\\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 Pl={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 j("\\char` missing argument");else r=t.text.charCodeAt(0);else n=10;if(n){if(r=Pl[t.text],r==null||r>=n)throw new j(`Invalid base-`+n+` digit `+t.text);for(var i;(i=Pl[e.future().text])!=null&&i<n;)r*=n,r+=i,e.popToken()}return`\\@char{`+r+`}`});var Fl=(e,t,n,r)=>{var i=e.consumeArg().tokens;if(i.length!==1)throw new j(`\\newcommand's first argument must be a macro name`);var a=i[0].text,o=e.isDefined(a);if(o&&!t)throw new j(`\\newcommand{`+a+`} attempting to redefine `+(a+`; use \\renewcommand`));if(!o&&!n)throw new j(`\\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 j(`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=>Fl(e,!1,!0,!1)),$(`\\renewcommand`,e=>Fl(e,!0,!1,!1)),$(`\\providecommand`,e=>Fl(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),Sl[n],P.math[n],P.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 Il={",":`\\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`},Ll=new Set([`bin`,`rel`]);$(`\\dots`,function(e){var t=`\\dotso`,n=e.expandAfterFuture().text;return n in Il?t=Il[n]:(n.slice(0,4)===`\\not`||n in P.math&&Ll.has(P.math[n].group))&&(t=`\\dotsb`),t});var Rl={")":!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 Rl?`\\ldots\\,`:`\\ldots`}),$(`\\dotsc`,function(e){var t=e.future().text;return t in Rl&&t!==`,`?`\\ldots\\,`:`\\ldots`}),$(`\\cdots`,function(e){return e.future().text in Rl?`\\@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 j(`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 zl=N(ga[`Main-Regular`][84][1]-.7*ga[`Main-Regular`][65][1]);$(`\\LaTeX`,`\\textrm{\\html@mathml{`+(`L\\kern-.36em\\raisebox{`+zl+`}{\\scriptstyle A}`)+`\\kern-.15em\\TeX}{LaTeX}}`),$(`\\KaTeX`,`\\textrm{\\html@mathml{`+(`K\\kern-.17em\\raisebox{`+zl+`}{\\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 Bl=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`,Bl(!1)),$(`\\bra@set`,Bl(!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 Vl={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0},Hl=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 Ml(Nl,t.macros),this.mode=n,this.stack=[]}feed(e){this.lexer=new jl(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 Mc(`EOF`,n.loc)),this.pushTokens(r),new Mc(``,jc.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 j(`Extra }`,i)}else if(i.text===`EOF`)throw new j(`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 j(`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 j(`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 j(`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 j(`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 j(`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 j(`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 Mc(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 jl(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(Sl,e)||Object.prototype.hasOwnProperty.call(P.math,e)||Object.prototype.hasOwnProperty.call(P.text,e)||Object.prototype.hasOwnProperty.call(Vl,e)}isExpandable(e){var t=this.macros.get(e);return t==null?Object.prototype.hasOwnProperty.call(Sl,e)&&!Sl[e].primitive:typeof t==`string`||typeof t==`function`||!t.unexpandable}},Ul=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,Wl=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`,ᵝ:`β`,ᵞ:`γ`,ᵟ:`δ`,ᵠ:`ϕ`,ᵡ:`χ`,ᶿ:`θ`}),Gl={"́":{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`}},Kl={á:`á`,à:`à`,ä:`ä`,ǟ:`ǟ`,ã:`ã`,ā:`ā`,ă:`ă`,ắ:`ắ`,ằ:`ằ`,ẵ:`ẵ`,ǎ:`ǎ`,â:`â`,ấ:`ấ`,ầ:`ầ`,ẫ:`ẫ`,ȧ:`ȧ`,ǡ:`ǡ`,å:`å`,ǻ:`ǻ`,ḃ:`ḃ`,ć:`ć`,ḉ:`ḉ`,č:`č`,ĉ:`ĉ`,ċ:`ċ`,ç:`ç`,ď:`ď`,ḋ:`ḋ`,ḑ:`ḑ`,é:`é`,è:`è`,ë:`ë`,ẽ:`ẽ`,ē:`ē`,ḗ:`ḗ`,ḕ:`ḕ`,ĕ:`ĕ`,ḝ:`ḝ`,ě:`ě`,ê:`ê`,ế:`ế`,ề:`ề`,ễ:`ễ`,ė:`ė`,ȩ:`ȩ`,ḟ:`ḟ`,ǵ:`ǵ`,ḡ:`ḡ`,ğ:`ğ`,ǧ:`ǧ`,ĝ:`ĝ`,ġ:`ġ`,ģ:`ģ`,ḧ:`ḧ`,ȟ:`ȟ`,ĥ:`ĥ`,ḣ:`ḣ`,ḩ:`ḩ`,í:`í`,ì:`ì`,ï:`ï`,ḯ:`ḯ`,ĩ:`ĩ`,ī:`ī`,ĭ:`ĭ`,ǐ:`ǐ`,î:`î`,ǰ:`ǰ`,ĵ:`ĵ`,ḱ:`ḱ`,ǩ:`ǩ`,ķ:`ķ`,ĺ:`ĺ`,ľ:`ľ`,ļ:`ļ`,ḿ:`ḿ`,ṁ:`ṁ`,ń:`ń`,ǹ:`ǹ`,ñ:`ñ`,ň:`ň`,ṅ:`ṅ`,ņ:`ņ`,ó:`ó`,ò:`ò`,ö:`ö`,ȫ:`ȫ`,õ:`õ`,ṍ:`ṍ`,ṏ:`ṏ`,ȭ:`ȭ`,ō:`ō`,ṓ:`ṓ`,ṑ:`ṑ`,ŏ:`ŏ`,ǒ:`ǒ`,ô:`ô`,ố:`ố`,ồ:`ồ`,ỗ:`ỗ`,ȯ:`ȯ`,ȱ:`ȱ`,ő:`ő`,ṕ:`ṕ`,ṗ:`ṗ`,ŕ:`ŕ`,ř:`ř`,ṙ:`ṙ`,ŗ:`ŗ`,ś:`ś`,ṥ:`ṥ`,š:`š`,ṧ:`ṧ`,ŝ:`ŝ`,ṡ:`ṡ`,ş:`ş`,ẗ:`ẗ`,ť:`ť`,ṫ:`ṫ`,ţ:`ţ`,ú:`ú`,ù:`ù`,ü:`ü`,ǘ:`ǘ`,ǜ:`ǜ`,ǖ:`ǖ`,ǚ:`ǚ`,ũ:`ũ`,ṹ:`ṹ`,ū:`ū`,ṻ:`ṻ`,ŭ:`ŭ`,ǔ:`ǔ`,û:`û`,ů:`ů`,ű:`ű`,ṽ:`ṽ`,ẃ:`ẃ`,ẁ:`ẁ`,ẅ:`ẅ`,ŵ:`ŵ`,ẇ:`ẇ`,ẘ:`ẘ`,ẍ:`ẍ`,ẋ:`ẋ`,ý:`ý`,ỳ:`ỳ`,ÿ:`ÿ`,ỹ:`ỹ`,ȳ:`ȳ`,ŷ:`ŷ`,ẏ:`ẏ`,ẙ:`ẙ`,ź:`ź`,ž:`ž`,ẑ:`ẑ`,ż:`ż`,Á:`Á`,À:`À`,Ä:`Ä`,Ǟ:`Ǟ`,Ã:`Ã`,Ā:`Ā`,Ă:`Ă`,Ắ:`Ắ`,Ằ:`Ằ`,Ẵ:`Ẵ`,Ǎ:`Ǎ`,Â:`Â`,Ấ:`Ấ`,Ầ:`Ầ`,Ẫ:`Ẫ`,Ȧ:`Ȧ`,Ǡ:`Ǡ`,Å:`Å`,Ǻ:`Ǻ`,Ḃ:`Ḃ`,Ć:`Ć`,Ḉ:`Ḉ`,Č:`Č`,Ĉ:`Ĉ`,Ċ:`Ċ`,Ç:`Ç`,Ď:`Ď`,Ḋ:`Ḋ`,Ḑ:`Ḑ`,É:`É`,È:`È`,Ë:`Ë`,Ẽ:`Ẽ`,Ē:`Ē`,Ḗ:`Ḗ`,Ḕ:`Ḕ`,Ĕ:`Ĕ`,Ḝ:`Ḝ`,Ě:`Ě`,Ê:`Ê`,Ế:`Ế`,Ề:`Ề`,Ễ:`Ễ`,Ė:`Ė`,Ȩ:`Ȩ`,Ḟ:`Ḟ`,Ǵ:`Ǵ`,Ḡ:`Ḡ`,Ğ:`Ğ`,Ǧ:`Ǧ`,Ĝ:`Ĝ`,Ġ:`Ġ`,Ģ:`Ģ`,Ḧ:`Ḧ`,Ȟ:`Ȟ`,Ĥ:`Ĥ`,Ḣ:`Ḣ`,Ḩ:`Ḩ`,Í:`Í`,Ì:`Ì`,Ï:`Ï`,Ḯ:`Ḯ`,Ĩ:`Ĩ`,Ī:`Ī`,Ĭ:`Ĭ`,Ǐ:`Ǐ`,Î:`Î`,İ:`İ`,Ĵ:`Ĵ`,Ḱ:`Ḱ`,Ǩ:`Ǩ`,Ķ:`Ķ`,Ĺ:`Ĺ`,Ľ:`Ľ`,Ļ:`Ļ`,Ḿ:`Ḿ`,Ṁ:`Ṁ`,Ń:`Ń`,Ǹ:`Ǹ`,Ñ:`Ñ`,Ň:`Ň`,Ṅ:`Ṅ`,Ņ:`Ņ`,Ó:`Ó`,Ò:`Ò`,Ö:`Ö`,Ȫ:`Ȫ`,Õ:`Õ`,Ṍ:`Ṍ`,Ṏ:`Ṏ`,Ȭ:`Ȭ`,Ō:`Ō`,Ṓ:`Ṓ`,Ṑ:`Ṑ`,Ŏ:`Ŏ`,Ǒ:`Ǒ`,Ô:`Ô`,Ố:`Ố`,Ồ:`Ồ`,Ỗ:`Ỗ`,Ȯ:`Ȯ`,Ȱ:`Ȱ`,Ő:`Ő`,Ṕ:`Ṕ`,Ṗ:`Ṗ`,Ŕ:`Ŕ`,Ř:`Ř`,Ṙ:`Ṙ`,Ŗ:`Ŗ`,Ś:`Ś`,Ṥ:`Ṥ`,Š:`Š`,Ṧ:`Ṧ`,Ŝ:`Ŝ`,Ṡ:`Ṡ`,Ş:`Ş`,Ť:`Ť`,Ṫ:`Ṫ`,Ţ:`Ţ`,Ú:`Ú`,Ù:`Ù`,Ü:`Ü`,Ǘ:`Ǘ`,Ǜ:`Ǜ`,Ǖ:`Ǖ`,Ǚ:`Ǚ`,Ũ:`Ũ`,Ṹ:`Ṹ`,Ū:`Ū`,Ṻ:`Ṻ`,Ŭ:`Ŭ`,Ǔ:`Ǔ`,Û:`Û`,Ů:`Ů`,Ű:`Ű`,Ṽ:`Ṽ`,Ẃ:`Ẃ`,Ẁ:`Ẁ`,Ẅ:`Ẅ`,Ŵ:`Ŵ`,Ẇ:`Ẇ`,Ẍ:`Ẍ`,Ẋ:`Ẋ`,Ý:`Ý`,Ỳ:`Ỳ`,Ÿ:`Ÿ`,Ỹ:`Ỹ`,Ȳ:`Ȳ`,Ŷ:`Ŷ`,Ẏ:`Ẏ`,Ź:`Ź`,Ž:`Ž`,Ẑ:`Ẑ`,Ż:`Ż`,ά:`ά`,ὰ:`ὰ`,ᾱ:`ᾱ`,ᾰ:`ᾰ`,έ:`έ`,ὲ:`ὲ`,ή:`ή`,ὴ:`ὴ`,ί:`ί`,ὶ:`ὶ`,ϊ:`ϊ`,ΐ:`ΐ`,ῒ:`ῒ`,ῑ:`ῑ`,ῐ:`ῐ`,ό:`ό`,ὸ:`ὸ`,ύ:`ύ`,ὺ:`ὺ`,ϋ:`ϋ`,ΰ:`ΰ`,ῢ:`ῢ`,ῡ:`ῡ`,ῠ:`ῠ`,ώ:`ώ`,ὼ:`ὼ`,Ύ:`Ύ`,Ὺ:`Ὺ`,Ϋ:`Ϋ`,Ῡ:`Ῡ`,Ῠ:`Ῠ`,Ώ:`Ώ`,Ὼ:`Ὼ`},ql=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 Hl(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 j(`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 Mc(`}`)),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&&Sl[i.text]&&Sl[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 j(`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 j(`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 j(`Limit controls must follow a math operator`,i);this.consume()}else if(i.text===`^`){if(n)throw new j(`Double superscript`,i);n=this.handleSupSubscript(`superscript`)}else if(i.text===`_`){if(r)throw new j(`Double subscript`,i);r=this.handleSupSubscript(`subscript`)}else if(i.text===`'`){if(n)throw new j(`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(Wl[i.text]){var s=Ul.test(i.text),c=[];for(c.push(new Mc(Wl[i.text])),this.consume();;){var l=this.fetch().text;if(!Wl[l]||Ul.test(l)!==s)break;c.unshift(new Mc(Wl[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=Sl[r];if(!i)return null;if(this.consume(),t&&t!==`atom`&&!i.allowedInArgument)throw new j(`Got function '`+r+`' with no arguments`+(t?` as `+t:``),n);if(this.mode===`text`&&!i.allowedInText)throw new j(`Can't use function '`+r+`' in text mode`,n);if(this.mode===`math`&&i.allowedInMath===!1)throw new j(`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=Sl[e];if(o&&o.handler)return o.handler(a,t,n);throw new j(`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 j(`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 j(`A primitive argument cannot be optional`);var a=this.parseGroup(e);if(a==null)throw new j(`Expected group as `+e,this.fetch());return a;case`original`:case void 0:return this.parseArgumentGroup(n);default:throw new j(`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 j(`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 j(`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 j(`Invalid size: '`+t.text+`'`,t);var i={number:+(r[1]+r[2]),unit:r[3]};if(!Zi(i))throw new j(`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:jc.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(Vl,r)){if(this.settings.throwOnError)throw new j(`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:jc.range(r,o),text:`---`}),t-=2):(e.splice(n,2,{type:`textord`,mode:`text`,loc:jc.range(r,a),text:`--`}),--t)}(i===`'`||i==="`")&&a.text===i&&(e.splice(n,2,{type:`textord`,mode:`text`,loc:jc.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 j(`\\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(Kl,t[0])&&!P[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=Kl[t[0]]+t.slice(1));var i=kl.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(P[this.mode][t]){this.settings.strict&&this.mode===`math`&&Ua.includes(t)&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,e);var o=P[this.mode][t].group,s=jc.range(e);a=Ds(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&&(Ni(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:jc.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(!Gl[l])throw new j(`Unknown accent ' `+l+`'`,e);var u=Gl[l][this.mode]||Gl[l].text;if(!u)throw new j(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:jc.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};ql.endOfExpression=new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var Jl=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new ql(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 j(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new Mc(`\\df@tag`)])}]}return r},Yl=function(e,t,n){t.textContent=``;var r=$l(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.`),Yl=function(){throw new j(`KaTeX doesn't work in quirks mode.`)});var Xl=function(e,t){return $l(e,t).toMarkup()},Zl=function(e,t){return Jl(e,new pi(t))},Ql=function(e,t,n){if(n.throwOnError||!(e instanceof j))throw e;var r=K([`katex-error`],[new la(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},$l=function(e,t){var n=new pi(t);try{return hs(Jl(e,n),e,n)}catch(t){return Ql(t,e,n)}},eu={version:`0.18.1`,render:Yl,renderToString:Xl,ParseError:j,SETTINGS_SCHEMA:li,__parse:Zl,__renderToDomTree:$l,__renderToHTMLTree:function(e,t){var n=new pi(t);try{return gs(Jl(e,n),e,n)}catch(t){return Ql(t,e,n)}},__setFontMetrics:ya,__defineSymbol:F,__defineFunction:J,__defineMacro:$,__domTree:{Span:aa,Anchor:oa,SymbolNode:la,SvgNode:ua,PathNode:da,LineNode:fa}},tu=[[`$$`,`$$`,!0],[`\\[`,`\\]`,!0],[`\\(`,`\\)`,!1],[`$`,`$`,!1]];function nu(e){return e===`$`||e===`\\`}function ru(e,t=0){for(let[n,r,i]of tu){if(!e.startsWith(n,t))continue;let a=t+n.length,o=au(e,a,r);if(o<0)continue;let s=e.slice(a,o);if(!(s.trim()===``||/\n[ \t]*\n/.test(s))&&!(n===`$`&&!ou(s,e[o+r.length])))return{length:o+r.length-t,tex:s,display:i}}return null}function iu(e,t=0){for(let n=t;n<e.length;n++){if(!nu(e[n]))continue;let t=ru(e,n);if(t)return{...t,start:n}}return null}function au(e,t,n){for(let r=t;r<e.length;r++){if(e.startsWith(n,r))return r;e[r]===`\\`&&r++}return-1}function ou(e,t){return!/^\s|\s$/.test(e)&&!(t!==void 0&&/\d/.test(t))}function su(e,t,n={}){let r=eu.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="${lu(e)}">${r}</span>`}var cu=`.math-display{display:block}`;function lu(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var uu={},du=new Qr({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=ru(e);if(t)return{type:`math`,raw:e.slice(0,t.length),text:t.tex,display:t.display}},renderer(e){return su(e.text??``,e.display===!0,uu)}}],renderer:{code({text:e,lang:t}){return t===`math`&&su(e,!0,uu)}}});function fu(e){return uu={},du.parse(e)}var pu=`script, style, pre, code, kbd, samp, textarea, math, svg, .katex`,mu=/\bmathjax\b|\bkatex\b/i;function hu(e){if(gu(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(pu)||r.push(e))}let i={},a=!1;for(let t of r)_u(e,t,i)&&(a=!0);return a}function gu(e){if(e.querySelector(`.katex, math`))return!0;for(let t of e.querySelectorAll(`script`))if(mu.test(t.getAttribute(`src`)??``)||mu.test(t.textContent??``))return!0;return!1}function _u(e,t,n){let r=t.data;if(!iu(r))return!1;let i=e.createDocumentFragment(),a=e.createElement(`span`),o=0;for(let t=iu(r,0);t;t=iu(r,o)){for(t.start>o&&i.appendChild(e.createTextNode(r.slice(o,t.start))),a.innerHTML=su(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 vu({session:e,path:t,kind:n}){let r=yu(e,t);return r===null?null:n===`markdown`?(0,D.jsx)(bu,{session:e,path:t,text:r}):(0,D.jsx)(Cu,{session:e,path:t,text:r})}function yu(e,t){let n=s(e,t),r=n.data&&!n.data.binary?n.data.content:null,i=r!==null&&n.data?he(e,t,r,n.data.mtime_ms):null;return(0,E.useSyncExternalStore)(n=>me(ye(e,t),n),()=>i?.getValue()??null)}bn.addHook(`afterSanitizeAttributes`,e=>{e.tagName===`A`&&/^https?:/i.test(e.getAttribute(`href`)??``)&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))});function bu({session:e,path:t,text:n}){let r=(0,E.useMemo)(()=>bn.sanitize(fu(n)),[n]),i=(0,E.useRef)(null);(0,E.useEffect)(()=>{let n=i.current;if(!n)return;let r=!1,a=[];for(let i of n.querySelectorAll(`img`)){let n=m(t,i.getAttribute(`src`)??``);n&&(i.removeAttribute(`src`),C(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(n)}`).then(e=>e.blob()).then(e=>{if(r)return;let t=URL.createObjectURL(e);a.push(t),i.src=t}).catch(()=>void 0))}return()=>{r=!0;for(let e of a)URL.revokeObjectURL(e)}},[r,e,t]);let{openFile:a}=f(),o=n=>{let r=n.target.closest(`a`);if(!r)return;let i=r.getAttribute(`href`)??``;if(/^https?:/i.test(i)||(n.preventDefault(),!n.metaKey&&!n.ctrlKey))return;let o=m(t,i);o&&a(e,o,void 0,_(o)?{view:`preview`}:void 0)},s=re().editorFontSize;return(0,D.jsx)(`div`,{className:`h-full overflow-y-auto bg-ground`,children:(0,D.jsx)(`div`,{ref:i,onClick:o,style:{fontSize:s},className:`md-preview mx-auto max-w-3xl px-6 py-5 text-fg-secondary`,dangerouslySetInnerHTML:{__html:r}})})}var xu=[[`img`,`src`],[`script`,`src`],[`link[rel~="stylesheet" i]`,`href`],[`link[rel~="icon" i]`,`href`],[`source`,`src`],[`video`,`src`],[`video`,`poster`],[`audio`,`src`]],Su=20*1024*1024;function Cu({session:e,path:t,text:n}){let[r,i]=(0,E.useState)(null),a=(0,E.useRef)(new Map),o=re().editorFontSize;return(0,E.useEffect)(()=>{let r=!1;return wu(e,t,n,a.current,o).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n,o]),r===null?null:(0,D.jsx)(`iframe`,{sandbox:`allow-scripts`,srcDoc:r,title:t,className:`size-full bg-paper`})}async function wu(e,t,n,r,i){let a=new DOMParser().parseFromString(n,`text/html`);if(i!==void 0){let e=a.createElement(`style`);e.textContent=`:where(html) { font-size: ${i}px; }`;let t=a.head??a.documentElement;t.insertBefore(e,t.firstChild)}hu(a)&&await Tu(a);let o=[];for(let[n,i]of xu)for(let s of a.querySelectorAll(n)){let n=m(t,s.getAttribute(i)??``);n&&(s.removeAttribute(i),o.push(Eu(e,n,r).then(e=>{e&&s.setAttribute(i,e)})))}return await Promise.all(o),`<!doctype html>${a.documentElement.outerHTML}`}async function Tu(e){let{default:t}=await x(async()=>{let{default:e}=await import(`./_virtual_katex-inline-css-DN-_JSKR.js`);return{default:e}},[]),n=e.createElement(`style`);n.textContent=`${t}\n${cu}`,(e.head??e.documentElement).appendChild(n)}function Eu(e,t,n){let r=n.get(t);if(r)return r;let i=C(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(t)}`).then(e=>e.blob()).then(async e=>e.size>Su?null:`data:${Du(t,e.type)};base64,${Ou(await e.arrayBuffer())}`).catch(()=>null);return n.set(t,i),i}function Du(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 Ou(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 ku={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 Au(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<=0?null:ku[t.slice(n+1).toLowerCase()]??null}function ju({session:e,path:t,kind:n,root:r}){let{url:i,error:a}=Pu(e,t,r);return a?(0,D.jsxs)(Mu,{children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Couldn’t load this file.`}),(0,D.jsx)(Nu,{session:e,path:t})]}):i?n===`image`?(0,D.jsx)(Mu,{children:(0,D.jsx)(`img`,{src:i,alt:t,className:`max-h-full max-w-full object-contain`})}):n===`video`?(0,D.jsx)(Mu,{children:(0,D.jsx)(`video`,{src:i,controls:!0,className:`max-h-full max-w-full`})}):n===`audio`?(0,D.jsx)(Mu,{children:(0,D.jsx)(`audio`,{src:i,controls:!0,className:`w-full max-w-xl`})}):(0,D.jsx)(`iframe`,{src:i,title:t,className:`h-full w-full border-0 bg-ground`}):(0,D.jsx)(Mu,{children:(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`…`})})}function Mu({children:e}){return(0,D.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 Nu({session:e,path:t}){return(0,D.jsx)(`button`,{type:`button`,onClick:()=>void b(e,t).catch(e=>S.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 Pu(e,t,n){let[r,i]=(0,E.useState)(null),[a,o]=(0,E.useState)(!1);return(0,E.useEffect)(()=>{let r=null,a=!1;return i(null),o(!1),C(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(t)}${y(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 Fu({tab:e,reveal:t}){let n=ie(e);if(n===`diff`)return(0,D.jsx)(Ye,{session:e.session,path:e.path,root:e.root},se(e));if(n===`commit`&&e.sha)return(0,D.jsx)(Je,{session:e.session,sha:e.sha,path:e.path,root:e.root},se(e));if(n===`external`&&e.root!==void 0){let n=Au(e.path);return n?(0,D.jsx)(ju,{session:e.session,path:e.path,kind:n,root:e.root},se(e)):(0,D.jsx)(Fe,{session:e.session,path:e.path,reveal:t,root:e.root},se(e))}if(n===`untitled`)return(0,D.jsx)(Ze,{name:e.path},se(e));let r=Au(e.path);if(r)return(0,D.jsx)(ju,{session:e.session,path:e.path,kind:r},se(e));let i=e.view===`preview`?_(e.path):null;return i?(0,D.jsx)(vu,{session:e.session,path:e.path,kind:i},se(e)):(0,D.jsx)(Fe,{session:e.session,path:e.path,reveal:t},se(e))}export{Fu 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(Kl,t[0])&&!P[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=Kl[t[0]]+t.slice(1));var i=kl.exec(t);i&&(t=t.substring(0,i.index),t===`i`?t=`ı`:t===`j`&&(t=`ȷ`));var a;if(P[this.mode][t]){this.settings.strict&&this.mode===`math`&&Ua.includes(t)&&this.settings.reportNonstrict(`unicodeTextInMathMode`,`Latin-1/Unicode text character "`+t[0]+`" used in math mode`,e);var o=P[this.mode][t].group,s=jc.range(e);a=Ds(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&&(Ni(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:jc.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(!Gl[l])throw new j(`Unknown accent ' `+l+`'`,e);var u=Gl[l][this.mode]||Gl[l].text;if(!u)throw new j(`Accent `+l+` unsupported in `+this.mode+` mode`,e);a={type:`accent`,mode:this.mode,loc:jc.range(e),label:u,isStretchy:!1,isShifty:!0,base:a}}return a}};ql.endOfExpression=new Set([`}`,`\\endgroup`,`\\end`,`\\right`,`&`]);var Jl=function(e,t){if(!(typeof e==`string`||e instanceof String))throw TypeError(`KaTeX can only parse string typed expression`);var n=new ql(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 j(`\\tag works only in display equations`);r=[{type:`tag`,mode:`text`,body:r,tag:n.subparse([new Mc(`\\df@tag`)])}]}return r},Yl=function(e,t,n){t.textContent=``;var r=$l(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.`),Yl=function(){throw new j(`KaTeX doesn't work in quirks mode.`)});var Xl=function(e,t){return $l(e,t).toMarkup()},Zl=function(e,t){return Jl(e,new pi(t))},Ql=function(e,t,n){if(n.throwOnError||!(e instanceof j))throw e;var r=K([`katex-error`],[new la(t)]);return r.setAttribute(`title`,e.toString()),r.setAttribute(`style`,`color:`+n.errorColor),r},$l=function(e,t){var n=new pi(t);try{return hs(Jl(e,n),e,n)}catch(t){return Ql(t,e,n)}},eu={version:`0.18.1`,render:Yl,renderToString:Xl,ParseError:j,SETTINGS_SCHEMA:li,__parse:Zl,__renderToDomTree:$l,__renderToHTMLTree:function(e,t){var n=new pi(t);try{return gs(Jl(e,n),e,n)}catch(t){return Ql(t,e,n)}},__setFontMetrics:ya,__defineSymbol:F,__defineFunction:J,__defineMacro:$,__domTree:{Span:aa,Anchor:oa,SymbolNode:la,SvgNode:ua,PathNode:da,LineNode:fa}},tu=[[`$$`,`$$`,!0],[`\\[`,`\\]`,!0],[`\\(`,`\\)`,!1],[`$`,`$`,!1]];function nu(e){return e===`$`||e===`\\`}function ru(e,t=0){for(let[n,r,i]of tu){if(!e.startsWith(n,t))continue;let a=t+n.length,o=au(e,a,r);if(o<0)continue;let s=e.slice(a,o);if(!(s.trim()===``||/\n[ \t]*\n/.test(s))&&!(n===`$`&&!ou(s,e[o+r.length])))return{length:o+r.length-t,tex:s,display:i}}return null}function iu(e,t=0){for(let n=t;n<e.length;n++){if(!nu(e[n]))continue;let t=ru(e,n);if(t)return{...t,start:n}}return null}function au(e,t,n){for(let r=t;r<e.length;r++){if(e.startsWith(n,r))return r;e[r]===`\\`&&r++}return-1}function ou(e,t){return!/^\s|\s$/.test(e)&&!(t!==void 0&&/\d/.test(t))}function su(e,t,n={}){let r=eu.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="${lu(e)}">${r}</span>`}var cu=`.math-display{display:block}`;function lu(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var uu={},du=new Qr({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=ru(e);if(t)return{type:`math`,raw:e.slice(0,t.length),text:t.tex,display:t.display}},renderer(e){return su(e.text??``,e.display===!0,uu)}}],renderer:{code({text:e,lang:t}){return t===`math`&&su(e,!0,uu)}}});function fu(e){return uu={},du.parse(e)}var pu=`script, style, pre, code, kbd, samp, textarea, math, svg, .katex`,mu=/\bmathjax\b|\bkatex\b/i;function hu(e){if(gu(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(pu)||r.push(e))}let i={},a=!1;for(let t of r)_u(e,t,i)&&(a=!0);return a}function gu(e){if(e.querySelector(`.katex, math`))return!0;for(let t of e.querySelectorAll(`script`))if(mu.test(t.getAttribute(`src`)??``)||mu.test(t.textContent??``))return!0;return!1}function _u(e,t,n){let r=t.data;if(!iu(r))return!1;let i=e.createDocumentFragment(),a=e.createElement(`span`),o=0;for(let t=iu(r,0);t;t=iu(r,o)){for(t.start>o&&i.appendChild(e.createTextNode(r.slice(o,t.start))),a.innerHTML=su(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 vu({session:e,path:t,kind:n}){let r=yu(e,t);return r===null?null:n===`markdown`?(0,D.jsx)(bu,{session:e,path:t,text:r}):(0,D.jsx)(Cu,{session:e,path:t,text:r})}function yu(e,t){let n=s(e,t),r=n.data&&!n.data.binary?n.data.content:null,i=r!==null&&n.data?he(e,t,r,n.data.mtime_ms):null;return(0,E.useSyncExternalStore)(n=>me(ye(e,t),n),()=>i?.getValue()??null)}bn.addHook(`afterSanitizeAttributes`,e=>{e.tagName===`A`&&/^https?:/i.test(e.getAttribute(`href`)??``)&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))});function bu({session:e,path:t,text:n}){let r=(0,E.useMemo)(()=>bn.sanitize(fu(n)),[n]),i=(0,E.useRef)(null);(0,E.useEffect)(()=>{let n=i.current;if(!n)return;let r=!1,a=[];for(let i of n.querySelectorAll(`img`)){let n=m(t,i.getAttribute(`src`)??``);n&&(i.removeAttribute(`src`),C(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(n)}`).then(e=>e.blob()).then(e=>{if(r)return;let t=URL.createObjectURL(e);a.push(t),i.src=t}).catch(()=>void 0))}return()=>{r=!0;for(let e of a)URL.revokeObjectURL(e)}},[r,e,t]);let{openFile:a}=f(),o=n=>{let r=n.target.closest(`a`);if(!r)return;let i=r.getAttribute(`href`)??``;if(/^https?:/i.test(i)||(n.preventDefault(),!n.metaKey&&!n.ctrlKey))return;let o=m(t,i);o&&a(e,o,void 0,_(o)?{view:`preview`}:void 0)},s=se().editorFontSize;return(0,D.jsx)(`div`,{className:`h-full overflow-y-auto bg-ground`,children:(0,D.jsx)(`div`,{ref:i,onClick:o,style:{fontSize:s},className:`md-preview mx-auto max-w-3xl px-6 py-5 text-fg-secondary`,dangerouslySetInnerHTML:{__html:r}})})}var xu=[[`img`,`src`],[`script`,`src`],[`link[rel~="stylesheet" i]`,`href`],[`link[rel~="icon" i]`,`href`],[`source`,`src`],[`video`,`src`],[`video`,`poster`],[`audio`,`src`]],Su=20*1024*1024;function Cu({session:e,path:t,text:n}){let[r,i]=(0,E.useState)(null),a=(0,E.useRef)(new Map),o=se().editorFontSize;return(0,E.useEffect)(()=>{let r=!1;return wu(e,t,n,a.current,o).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n,o]),r===null?null:(0,D.jsx)(`iframe`,{sandbox:`allow-scripts`,srcDoc:r,title:t,className:`size-full bg-paper`})}async function wu(e,t,n,r,i){let a=new DOMParser().parseFromString(n,`text/html`);if(i!==void 0){let e=a.createElement(`style`);e.textContent=`:where(html) { font-size: ${i}px; }`;let t=a.head??a.documentElement;t.insertBefore(e,t.firstChild)}hu(a)&&await Tu(a);let o=[];for(let[n,i]of xu)for(let s of a.querySelectorAll(n)){let n=m(t,s.getAttribute(i)??``);n&&(s.removeAttribute(i),o.push(Eu(e,n,r).then(e=>{e&&s.setAttribute(i,e)})))}return await Promise.all(o),`<!doctype html>${a.documentElement.outerHTML}`}async function Tu(e){let{default:t}=await x(async()=>{let{default:e}=await import(`./_virtual_katex-inline-css-DN-_JSKR.js`);return{default:e}},[]),n=e.createElement(`style`);n.textContent=`${t}\n${cu}`,(e.head??e.documentElement).appendChild(n)}function Eu(e,t,n){let r=n.get(t);if(r)return r;let i=C(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(t)}`).then(e=>e.blob()).then(async e=>e.size>Su?null:`data:${Du(t,e.type)};base64,${Ou(await e.arrayBuffer())}`).catch(()=>null);return n.set(t,i),i}function Du(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 Ou(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 ku={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 Au(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<=0?null:ku[t.slice(n+1).toLowerCase()]??null}function ju({session:e,path:t,kind:n,root:r}){let{url:i,error:a}=Pu(e,t,r);return a?(0,D.jsxs)(Mu,{children:[(0,D.jsx)(`p`,{className:`text-sm text-fg-secondary`,children:`Couldn’t load this file.`}),(0,D.jsx)(Nu,{session:e,path:t})]}):i?n===`image`?(0,D.jsx)(Mu,{children:(0,D.jsx)(`img`,{src:i,alt:t,className:`max-h-full max-w-full object-contain`})}):n===`video`?(0,D.jsx)(Mu,{children:(0,D.jsx)(`video`,{src:i,controls:!0,className:`max-h-full max-w-full`})}):n===`audio`?(0,D.jsx)(Mu,{children:(0,D.jsx)(`audio`,{src:i,controls:!0,className:`w-full max-w-xl`})}):(0,D.jsx)(`iframe`,{src:i,title:t,className:`h-full w-full border-0 bg-ground`}):(0,D.jsx)(Mu,{children:(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`…`})})}function Mu({children:e}){return(0,D.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 Nu({session:e,path:t}){return(0,D.jsx)(`button`,{type:`button`,onClick:()=>void b(e,t).catch(e=>S.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 Pu(e,t,n){let[r,i]=(0,E.useState)(null),[a,o]=(0,E.useState)(!1);return(0,E.useEffect)(()=>{let r=null,a=!1;return i(null),o(!1),C(`GET`,`/api/worktrees/${e}/media?path=${encodeURIComponent(t)}${y(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 Fu({tab:e,reveal:t}){let n=ae(e);if(n===`diff`)return(0,D.jsx)(Ye,{session:e.session,path:e.path,root:e.root},ie(e));if(n===`commit`&&e.sha)return(0,D.jsx)(Je,{session:e.session,sha:e.sha,path:e.path,root:e.root},ie(e));if(n===`external`&&e.root!==void 0){let n=Au(e.path);return n?(0,D.jsx)(ju,{session:e.session,path:e.path,kind:n,root:e.root},ie(e)):(0,D.jsx)(Fe,{session:e.session,path:e.path,reveal:t,root:e.root},ie(e))}if(n===`untitled`)return(0,D.jsx)(Ze,{name:e.path},ie(e));let r=Au(e.path);if(r)return(0,D.jsx)(ju,{session:e.session,path:e.path,kind:r},ie(e));let i=e.view===`preview`?_(e.path):null;return i?(0,D.jsx)(vu,{session:e.session,path:e.path,kind:i},ie(e)):(0,D.jsx)(Fe,{session:e.session,path:e.path,reveal:t},ie(e))}export{Fu as PaneEditorBody};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{t}from"./react-CZI7_Jkm.js";import{t as n}from"./jsx-runtime-ffCh33zF.js";import{_ as r,a as i,d as a,h as o,i as s,n as c,t as l}from"./hotkeys-VY-O_esT.js";import{S as u,_ as d,f,g as p,h as m,m as h,p as g}from"./api-B3lAdmrV.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{C as w,E as T,H as E,I as D,K as O,M as ee,P as k,R as te,V as ne,W as re,Y as ie,_ as ae,ct as A,et as oe,f as se,i as j,j as ce,k as le,lt as M,o as ue,p as de,q as N,r as fe,st as pe,tt as me,v as he,z as ge}from"./LazyTerminal-CBUKfCRA.js";import{t as P}from"./utils-B6KiDbIe.js";import{t as F}from"./createLucideIcon-DyMAgLa3.js";import{a as I,i as L,n as R,o as z,r as B,s as _e,t as ve}from"./session-seed-c86Sck-7.js";import{r as ye}from"./dist-i-QevsUb.js";import{B as be,Ct as xe,F as V,Ft as Se,G as Ce,H as we,K as H,Q as Te,R as U,St as Ee,U as De,V as Oe,W as ke,X as Ae,Y as je,Z as Me,_t as Ne,bt as Pe,ct as Fe,et as Ie,gt as Le,ht as Re,jt as ze,lt as Be,mt as Ve,pt as He,q as W,r as Ue,rt as We,st as Ge,xt as Ke,z as qe}from"./index-C4dEk1bI.js";var Je=F(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),Ye=F(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),Xe=F(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),Ze=F(`rotate-ccw`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}]]),Qe=F(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),$e=F(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),et=F(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),tt=F(`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)(A,{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:P(`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:P(`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 nt(){let e=W(),[t,n]=(0,G.useState)(Se());return(0,K.jsxs)(`div`,{children:[(0,K.jsx)(Y,{children:`Appearance`}),(0,K.jsx)(J,{label:`Theme`,children:(0,K.jsxs)(R,{value:t,onValueChange:e=>{n(e),ze(e)},children:[(0,K.jsx)(I,{className:`w-32`,children:(0,K.jsx)(z,{})}),(0,K.jsxs)(B,{children:[(0,K.jsx)(L,{value:`dark`,children:`Dark`}),(0,K.jsx)(L,{value:`light`,children:`Light`}),(0,K.jsx)(L,{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=>H({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=>H({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=>H({editorFontSize:e})})}),(0,K.jsx)(J,{label:`Density`,children:(0,K.jsxs)(R,{value:e.density,onValueChange:e=>H({density:e}),children:[(0,K.jsx)(I,{className:`w-36`,children:(0,K.jsx)(z,{})}),(0,K.jsxs)(B,{children:[(0,K.jsx)(L,{value:`compact`,children:`Compact`}),(0,K.jsx)(L,{value:`comfortable`,children:`Comfortable`})]})]})}),(0,K.jsx)(J,{label:`Project-based layout`,description:`Whether each project keeps its own editor layout.`,htmlFor:`project-based-layout`,children:(0,K.jsx)(V,{id:`project-based-layout`,checked:e.projectBasedLayout,onCheckedChange:e=>H({projectBasedLayout:e})})}),(0,K.jsx)(J,{label:`All projects in the session list`,description:`Whether right sidebar displays sessions from all projects.`,htmlFor:`show-all-project-sessions`,children:(0,K.jsx)(V,{id:`show-all-project-sessions`,checked:e.showAllProjectSessions,onCheckedChange:e=>H({showAllProjectSessions:e})})})]})}function rt({profile:e}){let t=ne(),[n,r]=(0,G.useState)(!1),i=n=>{t.mutate({id:e.id,icon:n},{onError:e=>j(e)}),r(!1)},a=n=>t.mutate({id:e.id,icon_colour:n},{onError:e=>j(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)(Te,{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)(He,{icon:e.icon,colour:e.icon_colour,className:`size-5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Choose an icon`})]})}),(0,K.jsx)(Me,{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:P(`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)(He,{icon:null,colour:null,className:`size-4`})}),Re.map(({name:t,Icon:n})=>(0,K.jsx)(`button`,{type:`button`,title:t,onClick:()=>i(t),className:P(`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:P(`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`})]}),p.map(t=>(0,K.jsxs)(`button`,{type:`button`,title:t,onClick:()=>a(t),className:P(`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:P(`size-3.5 rounded-full bg-current`,Ve(t))}),(0,K.jsx)(`span`,{className:`sr-only`,children:t})]},t))]})})]})}var X=`__none__`;function it(){let e=r(),t=N().data?.find(t=>t.id===e),n=se(e??void 0),i=O(e??void 0),a=ne(),s=E(e??``),c=le(),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(``);if((0,G.useEffect)(()=>{t&&(u(t.name),f(t.branch_prefix))},[t]),!t)return null;let w=i.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)(A,{id:`profile-name`,value:l,onChange:e=>u(e.target.value),className:`w-44 font-mono`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:l===t.name||l.trim()===``||a.isPending,onClick:()=>a.mutate({id:t.id,name:l},{onError:e=>j(e)}),children:`Save`})]}),(0,K.jsxs)(J,{label:`Branch prefix`,description:`Session branches become <prefix><slug(title)>.`,htmlFor:`branch-prefix`,children:[(0,K.jsx)(A,{id:`branch-prefix`,value:d,onChange:e=>f(e.target.value),placeholder:`no prefix`,className:`w-44 font-mono`}),(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:d===t.branch_prefix||a.isPending,onClick:()=>a.mutate({id:t.id,branch_prefix:d},{onError:e=>j(e)}),children:`Save`})]}),(0,K.jsx)(rt,{profile:t}),(0,K.jsx)(J,{label:`Default account`,description:`Preselected in the new-session modal.`,children:(0,K.jsxs)(R,{value:typeof w==`number`?String(w):X,onValueChange:e=>s.mutate({default_account_id:e===X?null:Number(e)},{onError:e=>j(e)}),children:[(0,K.jsx)(I,{className:`w-56`,children:(0,K.jsx)(z,{})}),(0,K.jsxs)(B,{children:[(0,K.jsx)(L,{value:X,children:`First available`}),n.data?.map(e=>(0,K.jsx)(L,{value:String(e.id),children:(0,K.jsxs)(`span`,{className:`font-mono`,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:`font-mono`,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)(pe,{htmlFor:`delete-confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`font-mono text-fg`,children:t.name}),` to confirm`]}),(0,K.jsx)(A,{id:`delete-confirm-name`,value:h,onChange:e=>g(e.target.value),className:`font-mono`,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||c.isPending,onClick:()=>c.mutate(t.id,{onSuccess:()=>{Ge(),o.set(null)},onError:e=>{m(!1),g(``),j(e)}}),children:`Delete profile`})]})]})})]})}function at({agent:e,profileId:t,onClose:n,onCreated:r}){let i=he(),[a,o]=(0,G.useState)(``),[s,c]=(0,G.useState)(``),l=ce(We(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=>j(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)(A,{autoFocus:!0,placeholder:`label, e.g. personal`,value:a,onChange:e=>o(e.target.value),className:`font-mono`}),(0,K.jsx)(fe,{value:s,onValueChange:c,placeholder:`(optional) existing config dir, e.g. ~/.claude`,hints:(l.data?.entries??[]).map(e=>({value:e.path,label:e.name})),className:`font-mono`})]}),(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)(Ke,{}),`Add account`]})]})]})})}function ot({account:e,gateOpen:t,installed:n}){let r=D(),i=te(),a=T(),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(e.label);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.jsx)(`input`,{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=>{j(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 truncate rounded-sm bg-transparent px-1 py-0.5 font-mono text-sm text-fg transition-colors hover:bg-elevated focus:bg-elevated focus:outline-none`}),(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)(V,{checked:e.skip_permissions_default,onCheckedChange:t=>i.mutate({id:e.id,skip_permissions_default:t},{onError:e=>j(e)})})]}),(0,K.jsxs)(v,{size:`sm`,variant:`secondary`,disabled:r.isPending||!n,onClick:()=>r.mutate(e.id,{onSuccess:e=>s(e.stream),onError:e=>j(e)}),children:[(0,K.jsx)(xe,{}),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)(Ne,{}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Delete account`})]}),o&&(0,K.jsx)(je,{stream:o,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:`font-mono`,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),j(e)}}),children:`Delete account`})]})]})})]})}function st(){let e=r(),t=de(),n=se(e??void 0),i=O(e??void 0),a=D(),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(null),d=i.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:`font-mono 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)(ot,{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:()=>l(e),children:[(0,K.jsx)(Ke,{}),`Add account`]})})]})]},e.id)}),o&&(0,K.jsx)(je,{stream:o.stream,label:o.label,onClose:()=>s(null)}),c!==null&&e!==null&&(0,K.jsx)(at,{agent:c,profileId:e,onClose:()=>l(null),onCreated:(e,t)=>{if(t){e.logged_in||u.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}`}),onError:e=>j(e)})}})]})}function ct(){let e=ae(),t=ge(),[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)(A,{id:`agent-path`,type:`text`,className:`w-64 font-mono text-2xs`,value:n,onChange:e=>r(e.target.value),onBlur:()=>{e.data&&n!==e.data.agentPath&&t.mutate({agentPath:n})}})})}function lt({kind:e,heading:t,settings:n,onSave:r,pending:i}){let a=ve(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)(A,{id:`${e}-default-base`,type:`text`,placeholder:`repository default`,className:`w-48 font-mono`,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)(V,{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)(V,{id:`${e}-default-dir`,checked:a.separateWorktree,disabled:i||a.separateBranch,onCheckedChange:e=>l({separateWorktree:e})})})]})}function ut(){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:W().terminalScrollback,onCommit:e=>H({terminalScrollback:e})})})}function dt({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)(M,{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 ft={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 pt({initial:e,onSave:t,pending:n}){let[r,i]=(0,G.useState)(e),a=r.length>0?r:m;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)(A,{id:`tab-title-template`,value:r,onChange:e=>i(e.target.value),className:`font-mono`,placeholder:m}),(0,K.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[`Preview`,` `,(0,K.jsx)(`span`,{className:`ml-1 font-sans text-fg`,children:Ie(ft,a)})]}),(0,K.jsx)(`dl`,{className:`mt-1 flex flex-col gap-0.5 text-xs`,children:d.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(m),t(m)},children:`Reset to default`})]})]})}function mt(){let e=r(),t=N().data?.find(t=>t.id===e),n=O(e??void 0),i=E(e??``),[a,o]=(0,G.useState)(!1),[s,c]=(0,G.useState)(``),l=n.data?.allowSkipPermissions===!0,u=e=>i.mutate({allowSkipPermissions:e},{onSuccess:()=>{o(!1),c(``)},onError:e=>j(e)}),d=e=>t=>i.mutate({[e]:t},{onError:e=>j(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)(V,{id:`gate`,checked:l,onCheckedChange:e=>{e?o(!0):u(!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)(V,{id:`capture-env`,checked:n.data?.captureSessionEnv!==!1,disabled:i.isPending,onCheckedChange:e=>i.mutate({captureSessionEnv:e},{onError:e=>j(e)})})}),(0,K.jsx)(ct,{}),(0,K.jsx)(ut,{}),(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)(lt,{kind:`agent`,heading:`New agents`,settings:n.data,onSave:e=>i.mutate({sessionDefaults:e},{onError:e=>j(e)}),pending:i.isPending},`${e}:agent-seed`),(0,K.jsx)(lt,{kind:`terminal`,heading:`New terminals`,settings:n.data,onSave:e=>i.mutate({sessionDefaults:e},{onError:e=>j(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)(dt,{id:`onboarding-template`,label:`New worktree`,description:`Use {{rules}} where the repo's onboarding notes should appear.`,initial:n.data.onboardingTemplate??g,defaultText:g,onSave:d(`onboardingTemplate`),pending:i.isPending},`${e}:onboarding`),(0,K.jsx)(dt,{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??f,defaultText:f,onSave:d(`concurrentTemplate`),pending:i.isPending},`${e}:concurrent`),(0,K.jsx)(dt,{id:`restart-template`,label:`Resume after restart`,description:`Sent when a session resumes after a daemon restart or machine reboot.`,initial:n.data.restartTemplate??h,defaultText:h,onSave:d(`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)(pt,{initial:n.data.tabTitleTemplate||"${name}",onSave:d(`tabTitleTemplate`),pending:i.isPending},`${e}:tab-title`)]}),(0,K.jsx)(C,{open:a,onOpenChange:e=>{e||(o(!1),c(``))},children:(0,K.jsxs)(b,{children:[(0,K.jsxs)(_,{children:[(0,K.jsxs)(x,{className:`flex items-center gap-2`,children:[(0,K.jsx)($e,{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)(pe,{htmlFor:`confirm-name`,children:[`Type `,(0,K.jsx)(`span`,{className:`font-mono text-fg`,children:t?.name}),` to confirm`]}),(0,K.jsx)(A,{id:`confirm-name`,value:s,onChange:e=>c(e.target.value),className:`font-mono`,autoFocus:!0})]}),(0,K.jsxs)(y,{children:[(0,K.jsx)(v,{variant:`ghost`,onClick:()=>{o(!1),c(``)},children:`Cancel`}),(0,K.jsx)(v,{variant:`danger`,disabled:s!==t?.name||i.isPending,onClick:()=>u(!0),children:`Open the gate`})]})]})})]})}var ht={desktop:!0,sound:!1,muted_projects:[]};function gt(){let[e,t]=(0,G.useState)(U);return(0,G.useEffect)(()=>{let e=()=>t(U());return window.addEventListener(`focus`,e),()=>window.removeEventListener(`focus`,e)},[]),[e,()=>t(U())]}function _t({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 vt(){let e=r(),t=O(e??void 0),n=E(e??``),i=ie(e??void 0),[a,o]=gt(),s={...ht,...t.data?.notifications??{}},c=e=>n.mutate({notifications:e},{onError:e=>j(e)}),l=()=>{typeof Notification>`u`||Notification.requestPermission().then(o)};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)(V,{id:`notify-desktop`,checked:s.desktop,onCheckedChange:e=>{e&&l(),c({...s,desktop:e})}})}),s.desktop&&(0,K.jsx)(_t,{permission:a,onRequest:l}),(0,K.jsx)(J,{label:`Sound`,htmlFor:`notify-sound`,children:(0,K.jsx)(V,{id:`notify-sound`,checked:s.sound,onCheckedChange:e=>c({...s,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:[s.muted_projects.length,` muted`]})}),(0,K.jsx)(`div`,{className:`flex flex-col gap-1`,children:i.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)(V,{checked:s.muted_projects.includes(e.id),onCheckedChange:t=>c({...s,muted_projects:t?[...s.muted_projects,e.id]:s.muted_projects.filter(t=>t!==e.id)})}),e.name]},e.id))})]})}function yt(){let e=W();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=>H({editorTabSize:e})})}),(0,K.jsx)(J,{label:`Word wrap`,htmlFor:`word-wrap`,children:(0,K.jsx)(V,{id:`word-wrap`,checked:e.editorWordWrap,onCheckedChange:e=>H({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)(A,{id:`editor-link-host`,type:`text`,placeholder:Ue.get()??`user@host`,className:`w-48`,value:e.editorLinkSshHost,onChange:e=>H({editorLinkSshHost:e.target.value})})})]})}function bt({value:e,isDefault:t,onRecord:n,onReset:r}){let[a,o]=(0,G.useState)(!1);return(0,K.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,K.jsx)(`button`,{type:`button`,onClick:()=>o(!0),onBlur:()=>o(!1),onKeyDown:e=>{if(!a)return;if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){o(!1);return}let t=s(e.nativeEvent);t&&(n(t),o(!1))},className:P(`min-w-24 rounded-md px-2 py-1 text-center font-mono text-xs transition-colors`,a?`bg-action text-action-ink`:`bg-elevated text-fg hover:bg-border/70`),children:a?`Press keys…`:i(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)(Ze,{className:`size-3.5`}),(0,K.jsx)(`span`,{className:`sr-only`,children:`Reset to default`})]})]})}function xt(){let e=r(),t=O(e??void 0),n=E(e??``),i=t.data?.hotkeys??{},o=(e,t)=>i[e]||t,s=new Map;for(let e of l){let t=o(e.id,a(e));s.set(t,(s.get(t)??0)+1)}let u=(e,t)=>n.mutate({hotkeys:{...i,[e]:t}},{onError:e=>j(e)}),d=e=>{let t={...i};delete t[e],n.mutate({hotkeys:t},{onError:e=>j(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.`}),c.map(e=>{let t=l.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=o(e.id,a(e)),n=(s.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)(bt,{value:t,isDefault:!i[e.id],onRecord:t=>u(e.id,t),onReset:()=>d(e.id)})},e.id)})]},e)})]})}var St=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`,Z=65,Q=Object.fromEntries([...St].map((e,t)=>[e,t])),Ct=`H`,wt=(()=>{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 Tt(e){let t=4294967295;for(let n of e)t=wt[(t^n)&255]^t>>>8;return((t^4294967295)>>>0).toString(16).padStart(8,`0`)}function Et(e){let t=``;for(let n of e)t+=String.fromCharCode(n);return btoa(t)}function Dt(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 Ot(e){let t=new Blob([new TextEncoder().encode(e)]).stream().pipeThrough(new CompressionStream(`gzip`));return new Uint8Array(await new Response(t).arrayBuffer())}async function kt(e){let t=new Blob([e]).stream().pipeThrough(new DecompressionStream(`gzip`));return new Response(t).text()}function At(e,t){let n=(t%Z+Z)%Z,r=``;for(let t of e){let e=Q[t];r+=e===void 0?t:St[(e+n)%Z]}return r}async function jt(e){let t=await Ot(JSON.stringify(e));return At(Et(t)+Tt(t),1+Math.floor(Math.random()*(Z-1)))}async function Mt(e){let t=e.trim(),n=t[0];if(!n||Q[n]===void 0)throw Error(`Not a settings export.`);let r=At(t,-((Q[n]-Q[Ct]+Z)%Z));if(r.length<9||r[0]!==Ct)throw Error(`Not a settings export.`);let i=r.slice(0,-8),a=r.slice(-8),o=Dt(i);if(Tt(o)!==a)throw Error(`Settings export is corrupt (checksum mismatch).`);return JSON.parse(await kt(o))}var Nt=`puddle.sync-selection`;function Pt(){try{let e=JSON.parse(localStorage.getItem(Nt)??`null`);if(Array.isArray(e))return e.filter(e=>typeof e==`string`)}catch{}return we.map(e=>e.id)}function Ft({selected:e,onToggle:t}){return(0,K.jsx)(`div`,{className:`flex flex-col gap-2 pl-1`,children:we.map(n=>(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(V,{checked:e.includes(n.id),onCheckedChange:e=>t(n.id,e)}),n.label]},n.id))})}function It(){let e=r(),t=O(e??void 0),n=N().data?.find(t=>t.id===e),i=me(e??void 0,void 0),a=E(e??``),o=ne(),s=w(),c=be(),l=Oe(),[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)(Pt),S=n&&c.data?qe(c.data.file,n.name):void 0,C=S?.enabled===!0,T=C&&S?S.groups:b,D=()=>({client:Ce(),theme:Se(),profileSettings:t.data??{},profile:n??{},scratchpad:i.data??[]}),ee={setClient:e=>H(e),setTheme:e=>{typeof e==`string`&&ze(e)},patchProfileSettings:e=>a.mutate(e,{onError:e=>j(e)}),patchProfileColumns:t=>{e&&o.mutate({id:e,...t},{onError:e=>j(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})}},k=(e,t)=>{n&&l.mutate({profile:n.name,entry:{enabled:e.enabled??C,groups:t,doc:ke(t,D()),updatedAt:new Date().toISOString()}},{onError:e=>j(e)})},te=(e,t)=>{let n=t?[...T,e]:T.filter(t=>t!==e);x(n),localStorage.setItem(Nt,JSON.stringify(n)),C&&k({},n)},re=async()=>{y(!0);try{let e=De(await Mt(d.trim()),ee,{profileSettings:t.data??{},scratchpad:i.data??[]});e.length===0?u.error(`Nothing recognised to import.`):(u.success(`Imported ${e.join(`, `)}.`),f(``))}catch(e){u.error(e.message)}finally{y(!1)}},ie=async()=>{y(!0);try{let e=await jt(ke(T,D()));m(e),await navigator.clipboard?.writeText(e),u.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:`font-mono`,children:`~/.puddle`}),`, so every Puddle window stays in step for profiles named `,(0,K.jsx)(`span`,{className:`font-mono`,children:n?.name??`…`}),`.`]}),(0,K.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,K.jsx)(V,{checked:C,disabled:!n||c.isLoading||l.isPending,onCheckedChange:e=>k({enabled:e},T)}),`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)(_e,{className:`size-3.5`}):(0,K.jsx)(ye,{className:`size-3.5`}),`Choose what to sync`]}),h&&(0,K.jsx)(`div`,{className:`mt-2`,children:(0,K.jsx)(Ft,{selected:T,onToggle:te})})]}),(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 ie(),children:`Export & copy`}),p&&(0,K.jsx)(M,{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)(M,{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 re(),children:`Import`})})]})]})}function Lt({repo:e}){let t=re(),n=ee(),[r,i]=(0,G.useState)(e.default_base_branch),[a,o]=(0,G.useState)(e.onboarding_notes??``),s=e=>j(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 font-mono 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:()=>u.success(`Fetched.`),onError:s}),children:[(0,K.jsx)(Pe,{}),`Fetch now`]})]}),(0,K.jsxs)(J,{label:`Default base branch`,htmlFor:`base-${e.id}`,className:`py-1.5`,children:[(0,K.jsx)(A,{id:`base-${e.id}`,value:r,onChange:e=>i(e.target.value),className:`w-40 font-mono`}),(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:s}),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)(V,{id:`fetch-${e.id}`,checked:e.fetch_enabled,onCheckedChange:n=>t.mutate({id:e.id,fetch_enabled:n},{onError:s})})}),(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)(M,{id:`notes-${e.id}`,value:a,onChange:e=>o(e.target.value),rows:4,className:`font-mono`}),(0,K.jsx)(`div`,{children:(0,K.jsx)(v,{size:`sm`,variant:`secondary`,disabled:a===(e.onboarding_notes??``)||t.isPending,onClick:()=>t.mutate({id:e.id,onboarding_notes:a},{onError:s}),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 font-mono text-2xs text-fg-muted`,children:e},e))})]})]})}function Rt(){let e=oe();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)(Lt,{repo:e},e.id))]})}function $({label:e,description:t,field:n,config:r,min:i,step:a=1}){let o=ge();return(0,K.jsx)(J,{label:e,description:t,htmlFor:`host-${n}`,children:(0,K.jsx)(A,{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=>j(e)})}})})}function zt(){let e=ae(),t=ge(),n=k();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)(A,{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=>j(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)(V,{id:`host-autoResume`,checked:e.data.autoResume,onCheckedChange:e=>t.mutate({autoResume:e},{onError:e=>j(e)})})})]}):null}var Bt=[{id:`appearance`,label:`Appearance`,icon:Ee,render:()=>(0,K.jsx)(nt,{})},{id:`profile`,label:`Profile`,icon:Le,render:()=>(0,K.jsx)(it,{})},{id:`accounts`,label:`Accounts`,icon:tt,render:()=>(0,K.jsx)(st,{})},{id:`sessions`,label:`Sessions`,icon:et,render:()=>(0,K.jsx)(mt,{})},{id:`editor`,label:`Editor`,icon:Ye,render:()=>(0,K.jsx)(yt,{})},{id:`hotkeys`,label:`Hotkeys`,icon:Xe,render:()=>(0,K.jsx)(xt,{})},{id:`notifications`,label:`Notifications`,icon:Je,render:()=>(0,K.jsx)(vt,{})},{id:`projects`,label:`Projects`,icon:ue,render:()=>(0,K.jsx)(Rt,{})},{id:`host`,label:`Host`,icon:Qe,render:()=>(0,K.jsx)(zt,{})},{id:`sync`,label:`Sync`,icon:Pe,render:()=>(0,K.jsx)(It,{})}],Vt={terminal:`sessions`,repositories:`projects`};function Ht(){let e=Be(),t=e===null?null:Vt[e]??e,n=Bt.find(e=>e.id===t)??Bt[0];return(0,K.jsx)(C,{open:e!==null,onOpenChange:e=>!e&&Ge(),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`}),Bt.map(({id:e,label:t,icon:r})=>(0,K.jsxs)(`button`,{onClick:()=>Fe(e),className:P(`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{Ht as SettingsDialog};
|