diff --git a/Cargo.lock b/Cargo.lock index d4fd1d9a..3e4378b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1505,7 +1505,7 @@ dependencies = [ [[package]] name = "nightcrow" -version = "0.1.27" +version = "0.1.28" dependencies = [ "aes-gcm", "alacritty_terminal", @@ -1546,7 +1546,7 @@ dependencies = [ [[package]] name = "nightcrow-memory" -version = "0.1.27" +version = "0.1.28" dependencies = [ "anyhow", "rusqlite", @@ -1557,7 +1557,7 @@ dependencies = [ [[package]] name = "nightcrow-recovery" -version = "0.1.27" +version = "0.1.28" dependencies = [ "anyhow", "serde", diff --git a/Cargo.toml b/Cargo.toml index d91f3825..8ad84f27 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ members = [".", "plugins/nightcrow-recovery", "plugins/nightcrow-memory"] # was never built at — a class of drift the release check could only report # after the fact. [workspace.package] -version = "0.1.27" +version = "0.1.28" [package] name = "nightcrow" diff --git a/docs/keybindings.md b/docs/keybindings.md index 8f842b06..8c43c02f 100644 --- a/docs/keybindings.md +++ b/docs/keybindings.md @@ -48,7 +48,7 @@ From `md` width up, a hint line under the footer mirrors the TUI's hint bar. Idl The leader followed by `t`, `w`, `s`, `z`, `r`, `c`, `l`, `b`, `o`, `x`, `p`, or `u` does what the matching bullet under [Leader commands](#leader-commands) describes, using the same controls the buttons use. In the browser, `r` is the sizing recovery command and `z` remains an alias. The focus keys `1`, `2`, and `3`–`9`, `0` address the list, the content pane, and terminal panes 1–8 with the same numbering. `Ctrl+Shift+Left` and `Ctrl+Shift+Right` switch projects exactly as they do in the TUI. -`Shift+Left` and `Shift+Right` walk the same ring — the list, the content pane, then each terminal pane — among whatever is on screen: a maximized terminal offers its panes alone, a maximized upper region the list and the content pane, and a narrow screen only the view its bottom navigation chose, which is what the TUI's fullscreen rules amount to. Stepping onto a pane while another is zoomed moves the zoom to it, as the TUI's fullscreen cycle does. A control inside a region — the sidebar's filter, a pane's toolbar — counts as that region; a keyboard nowhere on the ring (in the header or the footer, say) enters it at the near end. The chord is the page's wherever it is not typing, so it never reaches a pane as `ESC[1;2D`; in a text field it stays the browser's word selection. +`Shift+Left` and `Shift+Right` walk the same ring — the list, the content pane, then each terminal pane — among whatever is on screen: a maximized terminal offers its panes alone, a maximized upper region the list and the content pane, and a narrow screen only the view its bottom navigation chose, which is what the TUI's fullscreen rules amount to. Stepping onto a pane while another is zoomed moves the zoom to it, as the TUI's fullscreen cycle does. A control inside a region — the sidebar's filter, a pane's toolbar — counts as that region; a keyboard nowhere on the ring (in the header or the footer, say) enters it at the near end. The physical chord is the page's wherever it is not typing, so it never reaches a pane as `ESC[1;2D`; in a text field it stays the browser's word selection. To send `Shift+Left` to the active terminal instead, for example to answer a Codex question prompt, use the key bar's `⇧←` button. `Shift+PageUp` and `Shift+PageDown` scroll the focused pane a page, as in the TUI — xterm.js binds them itself. diff --git a/docs/web-viewer.md b/docs/web-viewer.md index 8da1dff1..09e8c01e 100644 --- a/docs/web-viewer.md +++ b/docs/web-viewer.md @@ -22,9 +22,9 @@ From `md` width up, the project tabs run across the header or down the page's le The terminal toolbar can add a pane, show panes as a grid or tabs (from `md` width up; below it the panel is always tabbed and the control is hidden, since a split grid would give each pane fewer columns than a command line needs), maximize the terminal panel, claim sizing for this screen, show or hide the on-screen key bar, and open a message form for the active pane. The key-bar toggle remains in the terminal toolbar. A project has up to 8 panes. Pane order and zoom are shared while the session runs; they are not restored after the session ends. A PTY has one size, so the client whose most recent key/paste/click/touch/wheel interaction claimed sizing determines the grid rendered by every client. A new connection, browser resize, focus change, or reconnect leaves the current owner in place; the terminal toolbar's sizing button remains available for manual recovery. -On phones and other narrow layouts, the bottom navigation switches among `Repo`, `Content`, and `Terminal`. Swiping the row of terminal tabs scrolls it and tapping a tab switches to it; to reorder by touch, rest a finger on a tab until it dims, then drag (a mouse still drags at once). Scrolling a list, the content pane or a terminal back to its top does not trigger the browser's pull-to-refresh; pulling down on the header or another fixed bar still refreshes. Touch-dragging a terminal scrolls it; the key bar supplies Escape, Tab, arrows, and control keys when a soft keyboard cannot. A soft keyboard opening does not resize the panes: the PTY keeps its grid and the pane shows the part of it around the cursor — the bottom of a full screen, the top of a terminal just opened — so a full-screen program is not made to repaint from the top every time the keyboard comes and goes. Layout changes made while the keyboard is up are applied once it closes. Its `Ctrl` button is a latch for the next typed character. The keyboard-bar preference is stored in the browser, so it can be changed from the terminal toolbar. The shortcut leader key is stored in the browser too, and can be rebound or switched off from the shortcut sheet. +On phones and other narrow layouts, the bottom navigation switches among `Repo`, `Content`, and `Terminal`. Swiping the row of terminal tabs scrolls it and tapping a tab switches to it; to reorder by touch, rest a finger on a tab until it dims, then drag (a mouse still drags at once). Scrolling a list, the content pane or a terminal back to its top does not trigger the browser's pull-to-refresh; pulling down on the header or another fixed bar still refreshes. Touch-dragging a terminal scrolls it; the key bar supplies Escape, Tab, Shift+Tab, arrows, Shift+Left (`⇧←`), and control keys when a soft keyboard cannot. A soft keyboard opening does not resize the panes: the PTY keeps its grid and the pane shows the part of it around the cursor — the bottom of a full screen, the top of a terminal just opened — so a full-screen program is not made to repaint from the top every time the keyboard comes and goes. Layout changes made while the keyboard is up are applied once it closes. Its `Ctrl` button is a latch for the next typed character. The keyboard-bar preference is stored in the browser, so it can be changed from the terminal toolbar. The shortcut leader key is stored in the browser too, and can be rebound or switched off from the shortcut sheet. -The message form (the pencil in the terminal toolbar, or the leader followed by `m`) exists because xterm's hidden input field drops and repeats characters from an IME on iPadOS, which makes Korean typed straight into a pane unreliable; an ordinary text field composes it correctly. Send writes the message into the active pane and presses Return, so it runs at once; Cmd/Ctrl+Return does the same from the keyboard, and Return alone adds a line. When the program has turned on bracketed paste, a multi-line message goes in as one paste rather than one command per line. Clear empties the field. A draft is kept per pane for the life of the page, so closing the form does not lose it. The TUI has no such form: it reads keys from the host terminal, whose IME already composes. +The message form (the pencil in the terminal toolbar, or the leader followed by `m`) exists because xterm's hidden input field drops and repeats characters from an IME on iPadOS, which makes Korean typed straight into a pane unreliable; an ordinary text field composes it correctly. Send writes the message into the active pane and presses Return, so it runs at once; Cmd/Ctrl+Return does the same from the keyboard, and Return alone adds a line. When the program has turned on bracketed paste, a multi-line message goes in as one paste rather than one command per line. Clear empties the field. A draft is kept per pane for the life of the page, so closing the form does not lose it. Voice adds one spoken phrase to the end of the draft through the browser's speech recognition, in the browser's language. It never sends; the text waits in the field to be checked. Chrome sends the audio to Google's speech service to recognize it, and Safari to Apple's. The button is missing where the browser has no speech recognition, such as Firefox. Browsers open the microphone only on `https://` or `http://localhost`, so over a plain `http://` address the button is dimmed and does nothing, its tooltip saying why; serve the viewer over HTTPS as [Notifications](notifications.md#web-push) describes. The operating system's own dictation, such as the microphone on a phone keyboard, works in the field everywhere. The TUI has no such form or voice button: it reads keys from the host terminal, whose IME already composes and whose dictation types straight in. Terminal programs may write to the clipboard through OSC 52; the text reaches the browser device viewing the pane. A program requesting clipboard contents is not answered. If the browser requires a user gesture to write, the viewer shows a Copy action. diff --git a/viewer-ui/dist/assets/Terminal-BuLVJ0Wx.js b/viewer-ui/dist/assets/Terminal-BuLVJ0Wx.js deleted file mode 100644 index 607d01b0..00000000 --- a/viewer-ui/dist/assets/Terminal-BuLVJ0Wx.js +++ /dev/null @@ -1,81 +0,0 @@ -import{t as e}from"./jsx-runtime-EIAPxkjE.js";import{t}from"./react-BPk_wmJm.js";import{$ as n,A as r,B as i,C as a,E as o,F as s,H as c,I as l,K as u,M as d,N as f,P as p,R as m,S as h,T as g,U as _,X as v,_ as y,_t as b,a as x,c as ee,ct as te,d as S,f as C,ft as w,gt as T,h as ne,ht as E,j as re,l as ie,m as ae,n as D,o as O,p as k,pt as oe,r as se,s as ce,st as le,t as ue,u as de,w as fe,x as pe,y as me}from"./lastPane-Kg5ZBFNS.js";import{t as he}from"./api-BwgkHPos.js";var A=t();function ge(e,t){for(;t;)[e,t]=[t,e%t];return e}function _e(e,t){switch(e){case 1:return[1];case 2:return t?[2]:[1,1];case 3:return[2,1];case 4:return[2,2];case 5:return[3,2];case 6:return[3,3];case 7:return[4,3];default:return[4,4]}}function ve(e,t){let n=_e(e,t),r=n.reduce((e,t)=>e*t/ge(e,t),1),i=[];return n.forEach((e,t)=>{let n=r/e;for(let r=0;r1,h=()=>{c.current!==null&&clearTimeout(c.current),c.current=null},g=()=>{h(),l.current=!1,i.current=null,a.current=null,o.current=null,s.current=!1,d(null),p(null)};return{draggingPane:u,dragOverPane:f,reorderable:m,endPaneDrag:g,onPaneDragStart:(e,t,r)=>{if(e.target.closest(`button`))return;let o=r?.holdToDrag===!0&&e.pointerType===`touch`;if(o||n(t),e.button!==0||!m&&!o)return;if(i.current=t,a.current={x:e.clientX,y:e.clientY},s.current=!1,!o){e.currentTarget.setPointerCapture(e.pointerId);return}if(l.current=!0,!m)return;let u=e.currentTarget,f=e.pointerId;h(),c.current=setTimeout(()=>{c.current=null,l.current=!1,s.current=!0,d(t);try{u.setPointerCapture(f)}catch{g()}},350)},onPaneDragMove:e=>{let t=i.current,n=a.current;if(t===null||n===null)return;if(!s.current){if(!(Math.hypot(e.clientX-n.x,e.clientY-n.y)>=4))return;if(l.current){g();return}}s.current=!0,d(t);let r=document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-pane-id]`),c=r?Number(r.getAttribute(`data-pane-id`)):null,u=c!==null&&c!==t?c:null;o.current=u,p(u)},onPaneDragEnd:()=>{let t=i.current,a=o.current;t!==null&&l.current&&n(t),t!==null&&s.current&&a!==null&&r(ee(e,t,a)),g()}}}function be(e){return typeof e==`number`&&Number.isSafeInteger(e)}function xe(e){return be(e)&&e>=0}function Se(e){return typeof e==`string`&&/^[0-9]+$/.test(e)}function Ce(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r;switch(n.type){case`created`:r=xe(n.pane)&&xe(n.rows)&&xe(n.cols)&&(n.client===void 0||xe(n.client))&&(n.title===void 0||typeof n.title==`string`);break;case`exited`:r=xe(n.pane);break;case`resized`:r=xe(n.pane)&&xe(n.rows)&&xe(n.cols);break;case`hello`:r=xe(n.client)&&xe(n.panes);break;case`replay_complete`:r=!0;break;case`size_owner`:r=typeof n.owned==`boolean`&&(n.generation===void 0||Se(n.generation));break;case`error`:r=typeof n.message==`string`;break;case`reordered`:r=Array.isArray(n.order)&&n.order.every(xe);break;case`zoomed`:r=n.pane===null||xe(n.pane);break;case`pending`:r=xe(n.count);break;case`attention`:r=xe(n.pane)&&(n.message===void 0||typeof n.message==`string`);break;case`recovery`:r=xe(n.pane)&&typeof n.state==`string`&&(n.detail===void 0||typeof n.detail==`string`)&&(n.deadline_epoch===void 0||be(n.deadline_epoch))&&xe(n.attempt);break;default:return null}return r?n:null}function we(e,t){return!e||e.readyState!==WebSocket.OPEN?!1:(e.send(JSON.stringify(t)),!0)}function Te(e){return e.byteLength<4?null:{pane:new DataView(e).getUint32(0,!0),data:new Uint8Array(e,4)}}function Ee(e){let[t,n]=(0,A.useState)({});return{recovery:t,setRecovery:n,cancelRecovery:(0,A.useCallback)(t=>{we(e.current,{type:`cancel_recovery`,pane:t})},[e])}}var De=240,Oe=`cubic-bezier(0.2, 0, 0, 1)`;function ke(){return typeof window>`u`||typeof window.matchMedia!=`function`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Ae(e){return e instanceof HTMLElement&&typeof e.animate==`function`&&!ke()}function je(e,t){if(!Ae(e)){t();return}let n=!1,r=()=>{n||(n=!0,t())},i=e.animate([{opacity:1,transform:`translateY(0)`},{opacity:0,transform:`translateY(12px)`}],{duration:200,easing:Oe,fill:`forwards`});i.onfinish=r,i.oncancel=r}function Me(e){Ae(e)&&e.animate([{opacity:0},{opacity:1}],{duration:De,easing:Oe})}var Ne={esc:`\x1B`,tab:` `,"shift-tab":`\x1B[Z`,"ctrl-b":``,"ctrl-c":``,"ctrl-d":``,"ctrl-z":``,"ctrl-l":`\f`,"ctrl-r":``,up:`\x1B[A`,down:`\x1B[B`,right:`\x1B[C`,left:`\x1B[D`},Pe={up:`\x1BOA`,down:`\x1BOB`,right:`\x1BOC`,left:`\x1BOD`};function Fe(e,t=!1){if(t){let t=Pe[e];if(t)return t}return Ne[e]}function Ie(e){if(e.length!==1)return null;if(e===` `)return`\0`;if(e===`?`)return``;let t=e.charCodeAt(0);return t>=97&&t<=122&&(t-=32),t<64||t>95?null:String.fromCharCode(t&31)}function Le(e,t){return e?t.startsWith(`\x1B`)?{data:t,armed:!0}:{data:Ie(t)??t,armed:!1}:{data:t,armed:!1}}function Re(e,t){return e?t.startsWith(`\x1B`)?{data:t,armed:!0}:{data:[...t].length===1?`\x1b${t}`:t,armed:!1}:{data:t,armed:!1}}function ze(e){return e===`shown`||e===`hidden`?e:null}function Be(e,t){return e||t<768}var Ve=[{kind:`key`,key:`esc`,label:`Esc`,aria:`Escape`},{kind:`key`,key:`tab`,label:`Tab`,aria:`Tab`},{kind:`key`,key:`shift-tab`,label:`⇧Tab`,aria:`Shift Tab`},{kind:`latch`,latch:`alt`,label:`Alt`,aria:`Alt for the next key`},{kind:`latch`,latch:`ctrl`,label:`Ctrl`,aria:`Control for the next key`},{kind:`key`,key:`ctrl-b`,label:`^B`,aria:`Control B`},{kind:`key`,key:`ctrl-c`,label:`^C`,aria:`Control C`},{kind:`key`,key:`ctrl-d`,label:`^D`,aria:`Control D`},{kind:`key`,key:`ctrl-z`,label:`^Z`,aria:`Control Z`},{kind:`key`,key:`ctrl-l`,label:`^L`,aria:`Control L`},{kind:`key`,key:`ctrl-r`,label:`^R`,aria:`Control R`},{kind:`key`,key:`left`,label:`←`,aria:`Left arrow`},{kind:`key`,key:`down`,label:`↓`,aria:`Down arrow`},{kind:`key`,key:`up`,label:`↑`,aria:`Up arrow`},{kind:`key`,key:`right`,label:`→`,aria:`Right arrow`}];function He(e,t){return e!==null&&t.includes(e)?e:null}function Ue(e,t){return e!==null&&He(e,t)===null}function We(e,t){return e===t?null:t}function Ge({socketRef:e,viewsRef:t,zoomed:n,zoomAskedRef:r,active:i,onForceFit:a}){let o=t=>we(e.current,t),s=()=>o({type:`create`,rows:24,cols:80}),c=e=>{let t=We(r.current===void 0?n:r.current,e);o({type:`zoom`,pane:t})&&(r.current=t)},l=()=>o({type:`claim_size`});return{create:s,toggleZoom:c,claimSize:()=>{l()&&a()},requestSize:l,closePane:e=>je(document.querySelector(`[data-pane-cell][data-pane-id="${e}"]`),()=>o({type:`close`,pane:e})),reorder:e=>o({type:`reorder`,order:e}),sendKey:e=>{if(i===null)return;let n=t.current.get(i)?.term.modes.applicationCursorKeysMode??!1;o({type:`input`,pane:i,data:Fe(e,n)})}}}function Ke(e){return e===`live`}function qe(e,t,n,r,i){let a=r!==void 0&&r!==t.current;n&&(!e.current||a)&&i(),e.current=n,t.current=r??null}function Je(e,t){let[n,r]=(0,A.useState)(0);return y(()=>{Ke(e)&&we(t.current,{type:`claim_size`})},e===`live`),{refitEpoch:n,forceFit:(0,A.useCallback)(()=>r(e=>e+1),[])}}function Ye(){let[e,t]=(0,A.useState)(null),[n,r]=(0,A.useState)(`connecting`),[i,a]=(0,A.useState)(0),[o,s]=(0,A.useState)([]),[c,l]=(0,A.useState)(null),[u,d]=(0,A.useState)(null),[f,p]=(0,A.useState)({}),[m,h]=(0,A.useState)(null),[g,_]=(0,A.useState)(!0);return{pending:e,setPending:t,link:n,setLink:r,replayLeft:i,setReplayLeft:a,panes:o,setPanes:s,active:c,setActive:l,zoomed:u,setZoomed:d,titles:f,setTitles:p,closing:m,setClosing:h,ownsSize:g,setOwnsSize:_}}function Xe(e){let t=e.indexOf(`;`);if(t===-1)return{kind:`ignore`};let n=e.slice(0,t),r=e.slice(t+1);if(!$e(n)||r===`?`||r===``)return{kind:`ignore`};let i=et(r);return i===null?{kind:`ignore`}:{kind:`write`,text:i}}var Ze=`cpqs01234567`,Qe=`cs`;function $e(e){if(e===``)return!0;let t=[...e];return t.every(e=>Ze.includes(e))?t.some(e=>Qe.includes(e)):!1}function et(e){try{let t=atob(e),n=Uint8Array.from(t,e=>e.charCodeAt(0));return new TextDecoder(`utf-8`,{fatal:!0}).decode(n)}catch{return null}}var tt=1048576,nt=262144,rt=class{term;highWater;lowWater;items=[];outstanding=0;pumping=!1;barrierInFlight=null;constructor(e,t=tt,n=nt){this.term=e,this.highWater=t,this.lowWater=n}write(e){this.items.push({kind:`bytes`,data:e}),this.pump()}barrier(e){this.items.push({kind:`barrier`,run:e,cancelled:!1}),this.pump()}clear(){for(let e of this.items)e.kind===`barrier`&&(e.cancelled=!0);this.items=[],this.barrierInFlight&&(this.barrierInFlight.cancelled=!0)}pump(){if(!this.pumping){this.pumping=!0;try{for(;this.items.length>0;){if(this.barrierInFlight)return;let e=this.items[0];if(e.kind===`barrier`){this.items.shift();let t={cancelled:e.cancelled};if(this.barrierInFlight=t,this.term.write(``,()=>{this.barrierInFlight=null,t.cancelled||e.run(),this.pump()}),this.barrierInFlight===t)return;continue}if(this.outstanding>=this.highWater)return;this.items.shift();let t=e.data.byteLength;this.outstanding+=t,this.term.write(e.data,()=>{this.outstanding-=t,this.outstanding<=this.lowWater&&this.pump()})}}finally{this.pumping=!1}}}},it=new WeakMap;function at(e){let t=it.get(e);return t||(t=new rt(e),it.set(e,t)),t}function ot(e,t){at(e).write(t)}function st(e,t){at(e).barrier(t)}function ct(e){it.get(e)?.clear()}function lt(e,t,n){st(e,()=>{t.release(),n()})}function ut(e){let t=e[0];return Array.isArray(t)?t[0]:t}function dt(e,t,n){let r=t,i=()=>r;return e.parser.registerCsiHandler({final:`n`},i),e.parser.registerCsiHandler({prefix:`?`,final:`n`},i),e.parser.registerCsiHandler({final:`c`},i),e.parser.registerCsiHandler({prefix:`>`,final:`c`},i),e.parser.registerCsiHandler({prefix:`=`,final:`c`},i),e.parser.registerCsiHandler({intermediates:`$`,final:`p`},i),e.parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},i),e.parser.registerCsiHandler({final:`t`},e=>r&&[14,16,18].includes(ut(e)??-1)),e.parser.registerDcsHandler({intermediates:`$`,final:`q`},i),e.parser.registerDcsHandler({prefix:`?`,intermediates:`$`,final:`q`},i),e.parser.registerOscHandler(52,e=>(r||n(e),!0)),{begin(){r=!0},release(){r=!1}}}function ft(){return{active:!1,panes:new Map,order:[],zoomed:!1}}function pt(){return{containerRef:(0,A.useRef)(null),socketRef:(0,A.useRef)(null),viewsRef:(0,A.useRef)(new Map),bodyRefs:(0,A.useRef)(new Map),ptySizesRef:(0,A.useRef)(new Map),askedSizesRef:(0,A.useRef)(new Map),desiredSizesRef:(0,A.useRef)(new Map),ownsSizeRef:(0,A.useRef)(!0),sizeOwnerGenerationRef:(0,A.useRef)(null),pendingRef:(0,A.useRef)(new Map),replayRef:(0,A.useRef)(ft()),zoomAskedRef:(0,A.useRef)(void 0),slotRefs:(0,A.useRef)(new Map)}}function mt({socketRef:e,panes:t,active:r,zoom:i,link:a,commands:o,focusPane:s,cancelRecovery:c,openCompose:l}){let u=pe(),d=(0,A.useRef)({commands:o,focusPane:s,cancelRecovery:c,openCompose:l,socketRef:e});d.current={commands:o,focusPane:s,cancelRecovery:c,openCompose:l,socketRef:e};let f=(0,A.useMemo)(()=>{let e={"terminal.newPane":()=>d.current.commands.create(),paneCursor:()=>({index:r===null?-1:t.indexOf(r),count:t.length})};t.length>0&&(e.focusPaneAt=e=>{let n=t[e];n!==void 0&&(i!==null&&n!==i?d.current.commands.toggleZoom(n):d.current.focusPane(n))});for(let r of v){let i=n(r.id);if(i===null)continue;let a=O(t,i);a!==null&&(e[r.id]=()=>d.current.focusPane(a))}return r===null||(e[`terminal.closePane`]=()=>d.current.commands.closePane(r),e[`terminal.claimSizing`]=()=>d.current.commands.claimSize(),e[`terminal.cancelRecovery`]=()=>d.current.cancelRecovery(r),e[`terminal.composeMessage`]=()=>d.current.openCompose(),e[`terminal.swapPanePrompt`]=ht,e.swapPanes=e=>{let n=O(t,e);n!==null&&d.current.commands.reorder(ie(t,r,n))},e.zoomActivePane=()=>d.current.commands.toggleZoom(r),e.sendInput=e=>void we(d.current.socketRef.current,{type:`input`,pane:r,data:e})),e},[t,r,i]);me(f);let p=u?.disarm;(0,A.useEffect)(()=>{a!==`live`&&p?.()},[a,p])}function ht(){}function gt({termHeight:e,bodyHeight:t,rows:n,cursorRow:r,atLive:i}){let a=e-t;if(a<=0||n<=0||!i)return 0;let o=e/n,s=(Math.min(Math.max(r,0),n-1)+1)*o,c=Math.min(Math.max(s-t,0),a);return Math.round(a-c)}function _t({panes:e,viewsRef:t,bodyRefs:n,keyboardOpen:r,size:i,zoomed:a,mode:o}){(0,A.useEffect)(()=>{let r=[];for(let i of e){let e=t.current.get(i),a=n.current.get(i),o=e?.term.element;if(!e||!a||!o)continue;let{term:s}=e,c=()=>{let e=s.buffer.active,t=gt({termHeight:o.offsetHeight,bodyHeight:a.clientHeight,rows:s.rows,cursorRow:e.cursorY,atLive:e.viewportY===e.baseY}),n=t>0?`-${t}px`:``;o.style.marginBottom!==n&&(o.style.marginBottom=n)};c();let l=s.onRender(c),u=s.onScroll(c),d=new ResizeObserver(c);d.observe(a),r.push(()=>{l.dispose(),u.dispose(),d.disconnect()})}return()=>{for(let e of r)e()}},[e,t,n,r,i,a,o])}function vt({repo:e,panes:t,replayLeft:n,active:r,setActive:i,zoomed:s,zoom:c,viewsRef:l,panelRef:u,size:d,mode:f}){(0,A.useEffect)(()=>{if(Ue(s,t))return;let a=g(r,t,n,D(e));a!==null&&(i(a),se(e,a))},[r,t,n,e,s,i]),(0,A.useEffect)(()=>{c!==null&&c!==r&&(i(c),se(e,c))},[c,r,e,i]);let p=(0,A.useRef)(null);(0,A.useEffect)(()=>{let e=r===null?void 0:l.current.get(r),t=e?.term.element,n=o(r,!!t&&t.clientHeight>0,p.current);if(!n.focus||!e){p.current=n.held;return}let i=a(document.activeElement,u.current);fe(i)&&(e.term.focus(),p.current=n.held)},[r,t,d,f,c,l,u])}var yt=60;function bt({panes:e,size:t,zoomed:n,mode:r,screenScale:i,socketRef:a,viewsRef:o,bodyRefs:s,ptySizesRef:c,desiredSizesRef:l,askedSizesRef:u,ownsSize:d,layoutPending:f,keyboardOpen:p,refitEpoch:m}){let h=(0,A.useRef)(null),g=(0,A.useRef)(m),_=(0,A.useCallback)(()=>{for(let[e,t]of o.current){let n=s.current.get(e);if(!n||n.clientHeight===0||n.clientWidth===0)continue;let r=l.current.get(e)??{rows:t.term.rows,cols:t.term.cols},i=u.current.get(e);i&&i.rows===r.rows&&i.cols===r.cols||we(a.current,{type:`resize`,pane:e,rows:r.rows,cols:r.cols})&&u.current.set(e,r)}},[a,o,s,u,l]);(0,A.useEffect)(()=>{if(!p){g.current!==m&&(u.current.clear(),g.current=m);for(let[e,t]of o.current){let n=s.current.get(e);if(n&&n.clientHeight!==0&&n.clientWidth!==0){if(!d||f){let n=c.current.get(e);n?(t.term.resize(n.cols,n.rows),l.current.set(e,n)):t.term.resize(t.term.cols,t.term.rows)}else t.term.resize(t.term.cols,t.term.rows),t.fit.fit(),l.current.set(e,{rows:t.term.rows,cols:t.term.cols})}}if(d&&!f)return h.current&&clearTimeout(h.current),h.current=setTimeout(_,yt),()=>{h.current&&clearTimeout(h.current)}}},[e,n,r,i,m,t,_,o,s,c,l,u,d,f,p])}var xt=Object.defineProperty,St=Object.getOwnPropertyDescriptor,Ct=(e,t)=>{for(var n in t)xt(e,n,{get:t[n],enumerable:!0})},j=(e,t,n,r)=>{for(var i=r>1?void 0:r?St(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&xt(t,n,i),i},M=(e,t)=>(n,r)=>t(n,r,e),wt=`Terminal input`,Tt={get:()=>wt,set:e=>wt=e},Et=`Too much output to announce, navigate to rows manually to read`,Dt={get:()=>Et,set:e=>Et=e};function Ot(e){return e.replace(/\r?\n/g,`\r`)}function kt(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function At(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function jt(e,t,n,r){e.stopPropagation(),e.clipboardData&&Mt(e.clipboardData.getData(`text/plain`),t,n,r)}function Mt(e,t,n,r){e=Ot(e),e=kt(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function Nt(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function Pt(e,t,n,r,i){Nt(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Ft(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function It(e,t=0,n=e.length){let r=``;for(let i=t;i65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var Lt=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},Rt=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128||(c=(i&31)<<6|a&63,c<128)){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},zt=``,Bt=` `,Vt=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Ht}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Ht=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Ut=class e extends Vt{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Ht,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ft(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Wt=`di$target`,Gt=`di$dependencies`,Kt=new Map;function qt(e){return e[Gt]||[]}function Jt(e){if(Kt.has(e))return Kt.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Yt(t,e,r)};return t._id=e,Kt.set(e,t),t}function Yt(e,t,n){t[Wt]===t?t[Gt].push({id:e,index:n}):(t[Gt]=[{id:e,index:n}],t[Wt]=t)}var Xt=Jt(`BufferService`),Zt=Jt(`CoreMouseService`),Qt=Jt(`CoreService`),$t=Jt(`CharsetService`),en=Jt(`InstantiationService`),tn=Jt(`LogService`),nn=Jt(`OptionsService`),rn=Jt(`OscLinkService`),an=Jt(`UnicodeService`),on=Jt(`DecorationService`),sn=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new Ut,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;ti?i.activate(e,t,a):cn(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};sn=j([M(0,Xt),M(1,nn),M(2,rn)],sn);function cn(e,t){if(confirm(`Do you want to navigate to ${t}? - -WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var ln=Jt(`CharSizeService`),un=Jt(`CoreBrowserService`),dn=Jt(`MouseService`),fn=Jt(`RenderService`),pn=Jt(`SelectionService`),mn=Jt(`CharacterJoinerService`),hn=Jt(`ThemeService`),gn=Jt(`LinkProviderService`),_n=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Cn.isErrorNoTelemetry(e)?new Cn(e.message+` - -`+e.stack):Error(e.message+` - -`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function vn(e){bn(e)||_n.onUnexpectedError(e)}var yn=`Canceled`;function bn(e){return e instanceof xn||e instanceof Error&&e.name===yn&&e.message===yn}var xn=class extends Error{constructor(){super(yn),this.name=this.message}};function Sn(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var Cn=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},wn=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function Tn(e,t=0){return e[e.length-(1+t)]}var En;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(En||={});var Dn=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||En.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};Dn.empty=new Dn(e=>{});function On(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var kn;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function In(...e){return N(()=>Fn(e))}function N(e){let t=jn({dispose:On(()=>{Mn(t),e()})});return t}var Ln=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,jn(this)}dispose(){this._isDisposed||(Mn(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Fn(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return Nn(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),Nn(e,null))}};Ln.DISABLE_DISPOSED_WARNING=!1;var Rn=Ln,P=class{constructor(){this._store=new Rn,jn(this),Nn(this._store,this)}dispose(){Mn(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};P.None=Object.freeze({dispose(){}});var zn=class{constructor(){this._isDisposed=!1,jn(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&Nn(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,Mn(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&Nn(e,null),e}},Bn=typeof window==`object`?window:globalThis,Vn=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};Vn.Undefined=new Vn(void 0);var F=Vn,Hn=class{constructor(){this._first=F.Undefined,this._last=F.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===F.Undefined}clear(){let e=this._first;for(;e!==F.Undefined;){let t=e.next;e.prev=F.Undefined,e.next=F.Undefined,e=t}this._first=F.Undefined,this._last=F.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new F(e);if(this._first===F.Undefined)this._first=n,this._last=n;else if(t){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==F.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==F.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==F.Undefined&&e.next!==F.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===F.Undefined&&e.next===F.Undefined?(this._first=F.Undefined,this._last=F.Undefined):e.next===F.Undefined?(this._last=this._last.prev,this._last.next=F.Undefined):e.prev===F.Undefined&&(this._first=this._first.next,this._first.prev=F.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==F.Undefined;)yield e.element,e=e.next}},Un=globalThis.performance&&typeof globalThis.performance.now==`function`,Wn=class e{static create(t){return new e(t)}constructor(e){this._now=Un&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},Gn;(e=>{e.None=()=>P.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(In(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new I({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new I({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new I({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new I({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new I({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function ee(e){let t=new I;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=ee;function te(e,t){return e(e=>t.fire(e))}e.forward=te;function S(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=S;class C{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new I(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function w(e,t){return new C(e,t).emitter.event}e.fromObservable=w;function T(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof Rn?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=T})(Gn||={});var Kn=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new Wn,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Kn.all=new Set,Kn._idPool=0;var qn=Kn,Jn=-1,Yn=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t0||this._options?.leakWarningThreshold?new Xn(e?.onListenerError??vn,this._options?.leakWarningThreshold??Jn):void 0,this._perfMon=this._options?._profName?new qn(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new $n(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||vn)(n),P.None}if(this._disposed)return P.None;t&&(e=e.bind(t));let r=new tr(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Zn.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof tr?(this._deliveryQueue??=new rr,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=N(()=>{i?.(),this._removeListener(r)});return n instanceof Rn?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*nr<=t.length){let e=0;for(let n=0;n0}},rr=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},ir=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new I,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new I,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};ir.INSTANCE=new ir;var ar=ir;function or(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}ar.INSTANCE.onDidChangeZoomLevel;function sr(e){return ar.INSTANCE.getZoomFactor(e)}ar.INSTANCE.onDidChangeFullscreen;var cr=typeof navigator==`object`?navigator.userAgent:``,lr=cr.indexOf(`Firefox`)>=0,ur=cr.indexOf(`AppleWebKit`)>=0,dr=cr.indexOf(`Chrome`)>=0,fr=!dr&&cr.indexOf(`Safari`)>=0;cr.indexOf(`Electron/`),cr.indexOf(`Android`);var pr=!1;if(typeof Bn.matchMedia==`function`){let e=Bn.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=Bn.matchMedia(`(display-mode: fullscreen)`);pr=e.matches,or(Bn,e,({matches:e})=>{pr&&t.matches||(pr=e)})}function mr(){return pr}var hr=`en`,gr=!1,_r=!1,vr=!1,yr=!1,br=!1,xr=hr,Sr,Cr=globalThis,wr;typeof Cr.vscode<`u`&&typeof Cr.vscode.process<`u`?wr=Cr.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(wr=process);var Tr=typeof wr?.versions?.electron==`string`&&wr?.type===`renderer`;if(typeof wr==`object`){gr=wr.platform===`win32`,_r=wr.platform===`darwin`,vr=wr.platform===`linux`,vr&&wr.env.SNAP&&wr.env.SNAP_REVISION,wr.env.CI||wr.env.BUILD_ARTIFACTSTAGINGDIRECTORY,xr=hr;let e=wr.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,xr=t.resolvedLanguage||hr,t.languagePack?.translationsConfigFile}catch{}yr=!0}else typeof navigator==`object`&&!Tr?(Sr=navigator.userAgent,gr=Sr.indexOf(`Windows`)>=0,_r=Sr.indexOf(`Macintosh`)>=0,(Sr.indexOf(`Macintosh`)>=0||Sr.indexOf(`iPad`)>=0||Sr.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,vr=Sr.indexOf(`Linux`)>=0,Sr?.indexOf(`Mobi`),br=!0,xr=globalThis._VSCODE_NLS_LANGUAGE||hr,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var Er=gr,Dr=_r,Or=vr,kr=yr;br&&typeof Cr.importScripts==`function`&&Cr.origin;var Ar=Sr,jr=xr,Mr;(e=>{function t(){return jr}e.value=t;function n(){return jr.length===2?jr===`en`:jr.length>=3&&jr[0]===`e`&&jr[1]===`n`&&jr[2]===`-`}e.isDefaultVariant=n;function r(){return jr===`en`}e.isDefault=r})(Mr||={});var Nr=typeof Cr.postMessage==`function`&&!Cr.importScripts;(()=>{if(Nr){let e=[];Cr.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n{let r=++t;e.push({id:r,callback:n}),Cr.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var Pr=!!(Ar&&Ar.indexOf(`Chrome`)>=0);Ar&&Ar.indexOf(`Firefox`),!Pr&&Ar&&Ar.indexOf(`Safari`),Ar&&Ar.indexOf(`Edg/`),Ar&&Ar.indexOf(`Android`);var Fr=typeof navigator==`object`?navigator:{};kr||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||Fr&&Fr.clipboard&&Fr.clipboard.writeText,kr||Fr&&Fr.clipboard&&Fr.clipboard.readText,kr||mr()||Fr.keyboard,`ontouchstart`in Bn||Fr.maxTouchPoints,Bn.PointerEvent&&(`ontouchstart`in Bn||navigator.maxTouchPoints);var Ir=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Lr=new Ir,Rr=new Ir,zr=new Ir,Br=Array(230),Vr;(e=>{function t(e){return Lr.keyCodeToStr(e)}e.toString=t;function n(e){return Lr.strToKeyCode(e)}e.fromString=n;function r(e){return Rr.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return zr.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return Rr.strToKeyCode(e)||zr.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return Lr.keyCodeToStr(e)}e.toElectronAccelerator=o})(Vr||={});var Hr=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Ur([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Ur=class{constructor(e){if(e.length===0)throw Sn(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t{function t(t){return t===e.None||t===e.Cancelled||t instanceof ri?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Gn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:ti})})(ni||={});var ri=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?ti:(this._emitter||=new I,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},ii=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e==`function`&&typeof t==`number`&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new wn(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new wn(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},ai=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new wn(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=N(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var oi;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(oi||={});var si=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new I,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};si.EMPTY=si.fromArray([]);function ci(e){return li(e,0)}function li(e,t){switch(typeof e){case`object`:return e===null?ui(349,t):Array.isArray(e)?pi(e,t):mi(e,t);case`string`:return fi(e,t);case`boolean`:return di(e,t);case`number`:return ui(e,t);case`undefined`:return ui(937,t);default:return ui(617,t)}}function ui(e,t){return(t<<5)-t+e|0}function di(e,t){return ui(e?433:863,t)}function fi(e,t){t=ui(149417,t);for(let n=0,r=e.length;nli(t,e),t)}function mi(e,t){return t=ui(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=fi(n,t),li(e[n],t)),t)}var{registerWindow:hi,getWindow:gi,getDocument:_i,getWindows:vi,getWindowsCount:yi,getWindowId:bi,getWindowById:xi,hasWindow:Si,onDidRegisterWindow:Ci,onWillUnregisterWindow:wi,onDidUnregisterWindow:Ti}=function(){let e=new Map,t={window:Bn,disposables:new Rn};e.set(Bn.vscodeWindowId,t);let n=new I,r=new I,i=new I;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return P.None;let a=new Rn,o={window:t,disposables:a.add(new Rn)};return e.set(t.vscodeWindowId,o),a.add(N(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(L(t,Fi.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:Bn},getDocument(e){return gi(e).document}}}(),Ei=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function L(e,t,n,r){return new Ei(e,t,n,r)}function Di(e,t){return function(n){return t(new $r(e,n))}}function Oi(e){return function(t){return e(new Yr(t))}}var ki=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=Di(gi(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=Oi(n)),L(e,t,i,r)},Ai,ji=class extends ai{constructor(e){super(),this.defaultTarget=e&&gi(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Mi=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){vn(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(Mi.sort),a.shift().execute();r.set(i,!1)};Ai=(t,r,a=0)=>{let o=bi(t),s=new Mi(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var Ni=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};Ni.None=new Ni(0,0);function Pi(e){let t=e.getBoundingClientRect(),n=gi(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=ci(n),a=r.get(i);if(a)a.users+=1;else{let o=new I,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(N(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var Fi={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:ur?`webkitAnimationStart`:`animationstart`,ANIMATION_END:ur?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:ur?`webkitAnimationIteration`:`animationiteration`},Ii=class{constructor(e){this.domNode=e,this._maxWidth=``,this._width=``,this._height=``,this._top=``,this._left=``,this._bottom=``,this._right=``,this._paddingTop=``,this._paddingLeft=``,this._paddingBottom=``,this._paddingRight=``,this._fontFamily=``,this._fontWeight=``,this._fontSize=``,this._fontStyle=``,this._fontFeatureSettings=``,this._fontVariationSettings=``,this._textDecoration=``,this._lineHeight=``,this._letterSpacing=``,this._className=``,this._display=``,this._position=``,this._visibility=``,this._color=``,this._backgroundColor=``,this._layerHint=!1,this._contain=`none`,this._boxShadow=``}setMaxWidth(e){let t=Li(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Li(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Li(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Li(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Li(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Li(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Li(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Li(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Li(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Li(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Li(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=Li(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=Li(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Li(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?`translate3d(0px, 0px, 0px)`:``)}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function Li(e){return typeof e==`number`?`${e}px`:e}function Ri(e){return new Ii(e)}var zi=class{constructor(){this._hooks=new Rn,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(N(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=gi(e)}this._hooks.add(L(a,Fi.POINTER_MOVE,e=>{e.buttons===n?(e.preventDefault(),this._pointerMoveCallback(e)):this.stopMonitoring(!0)})),this._hooks.add(L(a,Fi.POINTER_UP,e=>this.stopMonitoring(!0)))}};function Bi(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var Vi;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(Vi||={});var Hi=class e extends P{constructor(){super(),this.dispatched=!1,this.targets=new Hn,this.ignoreTargets=new Hn,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Gn.runAndSubscribe(Ci,({window:e,disposables:t})=>{t.add(L(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(L(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(L(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:Bn,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=Pn(new e),N(e.INSTANCE.targets.push(t))):P.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=Pn(new e),N(e.INSTANCE.ignoreTargets.push(t))):P.None}static isTouchDevice(){return`ontouchstart`in Bn||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n=e.HOLD_DELAY&&Math.abs(s.initialPageX-Tn(s.rollingPageX))<30&&Math.abs(s.initialPageY-Tn(s.rollingPageY))<30){let e=this.newGestureEvent(Vi.Contextmenu,s.initialTarget);e.pageX=Tn(s.rollingPageX),e.pageY=Tn(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=Tn(s.rollingPageX),n=Tn(s.rollingPageY),i=Tn(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(Vi.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===Vi.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===Vi.Change||t.type===Vi.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=Ai(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(Vi.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};Hi.SCROLL_FRICTION=-.005,Hi.HOLD_DELAY=700,Hi.CLEAR_TAP_COUNT_TIME=400,j([Bi],Hi,`isTouchDevice`,1);var Ui=Hi,Wi=class extends P{onclick(e,t){this._register(L(e,Fi.CLICK,n=>t(new $r(gi(e),n))))}onmousedown(e,t){this._register(L(e,Fi.MOUSE_DOWN,n=>t(new $r(gi(e),n))))}onmouseover(e,t){this._register(L(e,Fi.MOUSE_OVER,n=>t(new $r(gi(e),n))))}onmouseleave(e,t){this._register(L(e,Fi.MOUSE_LEAVE,n=>t(new $r(gi(e),n))))}onkeydown(e,t){this._register(L(e,Fi.KEY_DOWN,e=>t(new Yr(e))))}onkeyup(e,t){this._register(L(e,Fi.KEY_UP,e=>t(new Yr(e))))}oninput(e,t){this._register(L(e,Fi.INPUT,t))}onblur(e,t){this._register(L(e,Fi.BLUR,t))}onfocus(e,t){this._register(L(e,Fi.FOCUS,t))}onchange(e,t){this._register(L(e,Fi.CHANGE,t))}ignoreGesture(e){return Ui.ignoreTarget(e)}},Gi=11,Ki=class extends Wi{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement(`div`),this.bgDomNode.className=`arrow-background`,this.bgDomNode.style.position=`absolute`,this.bgDomNode.style.width=e.bgWidth+`px`,this.bgDomNode.style.height=e.bgHeight+`px`,typeof e.top<`u`&&(this.bgDomNode.style.top=`0px`),typeof e.left<`u`&&(this.bgDomNode.style.left=`0px`),typeof e.bottom<`u`&&(this.bgDomNode.style.bottom=`0px`),typeof e.right<`u`&&(this.bgDomNode.style.right=`0px`),this.domNode=document.createElement(`div`),this.domNode.className=e.className,this.domNode.style.position=`absolute`,this.domNode.style.width=Gi+`px`,this.domNode.style.height=Gi+`px`,typeof e.top<`u`&&(this.domNode.style.top=e.top+`px`),typeof e.left<`u`&&(this.domNode.style.left=e.left+`px`),typeof e.bottom<`u`&&(this.domNode.style.bottom=e.bottom+`px`),typeof e.right<`u`&&(this.domNode.style.right=e.right+`px`),this._pointerMoveMonitor=this._register(new zi),this._register(ki(this.bgDomNode,Fi.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(ki(this.domNode,Fi.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new ji),this._pointerdownScheduleRepeatTimer=this._register(new ii)}_arrowPointerDown(e){e.target&&e.target instanceof Element&&(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,gi(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},qi=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<`u`?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<`u`?t.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},Ji=class extends P{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new I),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new qi(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new Qi(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=Qi.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},Yi=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Xi(e,t){let n=t-e;return function(t){return e+n*ea(t)}}function Zi(e,t,n){return function(r){return r2.5*n){let r,i;return e{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},na=140,ra=class extends Wi{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new ta(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new zi),this._shouldRender=!0,this.domNode=Ri(document.createElement(`div`)),this.domNode.setAttribute(`role`,`presentation`),this.domNode.setAttribute(`aria-hidden`,`true`),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition(`absolute`),this._register(L(this.domNode.domNode,Fi.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new Ki(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=Ri(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(L(this.slider.domNode,Fi.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=Pi(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if(Er&&a>na){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName(`active`,!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},ia=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize!==t&&(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize!==t&&(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition!==t&&(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if(this._isAlmostInt(e.deltaX)&&this._isAlmostInt(e.deltaY)||(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};da.INSTANCE=new da;var fa=da,pa=class extends Wi{constructor(e,t,n){super(),this._onScroll=this._register(new I),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new I),this.onWillScroll=this._onWillScroll.event,this._options=ha(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new oa(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new aa(this._scrollable,this._options,r)),this._domNode=document.createElement(`div`),this._domNode.className=`xterm-scrollable-element `+this._options.className,this._domNode.setAttribute(`role`,`presentation`),this._domNode.style.position=`relative`,this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Ri(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Ri(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Ri(document.createElement(`div`)),this._topLeftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new ii),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Fn(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,Dr&&(this._options.className+=` mac`),this._domNode.className=`xterm-scrollable-element `+this._options.className}updateOptions(e){typeof e.handleMouseWheel<`u`&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<`u`&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<`u`&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<`u`&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<`u`&&(this._options.horizontal=e.horizontal),typeof e.vertical<`u`&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<`u`&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<`u`&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<`u`&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new ei(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Fn(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(L(this._listenOnDomNode,Fi.MOUSE_WHEEL,e=>{this._onMouseWheel(new ei(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=fa.INSTANCE;la&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!Dr&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=ca*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=ca*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(la&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),sa)}},ma=class extends pa{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function ha(e){let t={lazyRender:typeof e.lazyRender<`u`&&e.lazyRender,className:typeof e.className<`u`?e.className:``,useShadows:typeof e.useShadows<`u`?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<`u`?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<`u`&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`&&e.alwaysConsumeMouseWheel,scrollYToX:typeof e.scrollYToX<`u`&&e.scrollYToX,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<`u`?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<`u`?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<`u`?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<`u`?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<`u`?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<`u`?e.listenOnDomNode:null,horizontal:typeof e.horizontal<`u`?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<`u`?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<`u`&&e.horizontalHasArrows,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`&&e.verticalHasArrows,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`&&e.scrollByPage};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,Dr&&(t.className+=` mac`),t}var ga=class extends P{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new I),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new Ji({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>Ai(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new ma(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Gn.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(N(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(N(()=>this._styleElement.remove())),this._register(Gn.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(` -`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};ga=j([M(2,Xt),M(3,un),M(4,Zt),M(5,hn),M(6,nn),M(7,fn)],ga);var _a=class extends P{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(N(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?`none`:`block`,this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};_a=j([M(1,Xt),M(2,un),M(3,on),M(4,fn)],_a);var va=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},ya={full:0,left:0,center:0,right:0},ba={full:0,left:0,center:0,right:0},xa={full:0,left:0,center:0,right:0},Sa=class extends P{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new va,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(N(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw Error(`Ctx cannot be null`);this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange(`overviewRuler`,()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);ba.full=this._canvas.width,ba.left=e,ba.center=t,ba.right=e,this._refreshDrawHeightConstants(),xa.full=1,xa.left=1,xa.center=1+ba.left,xa.right=1+ba.left+ba.center}_refreshDrawHeightConstants(){ya.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);ya.left=t,ya.center=t,ya.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ya.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ya.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ya.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ya.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(xa[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ya[e.position||`full`]/2),ba[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ya[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Sa=j([M(2,Xt),M(3,on),M(4,fn),M(5,nn),M(6,hn),M(7,un)],Sa);var R;(e=>(e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=` -`,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``))(R||={});var Ca;(e=>(e.PAD=`€`,e.HOP=``,e.BPH=`‚`,e.NBH=`ƒ`,e.IND=`„`,e.NEL=`…`,e.SSA=`†`,e.ESA=`‡`,e.HTS=`ˆ`,e.HTJ=`‰`,e.VTS=`Š`,e.PLD=`‹`,e.PLU=`Œ`,e.RI=``,e.SS2=`Ž`,e.SS3=``,e.DCS=``,e.PU1=`‘`,e.PU2=`’`,e.STS=`“`,e.CCH=`”`,e.MW=`•`,e.SPA=`–`,e.EPA=`—`,e.SOS=`˜`,e.SGCI=`™`,e.SCI=`š`,e.CSI=`›`,e.ST=`œ`,e.OSC=``,e.PM=`ž`,e.APC=`Ÿ`))(Ca||={});var wa;(e=>e.ST=`${R.ESC}\\`)(wa||={});var Ta=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.lengththis.updateCompositionElements(!0),0)}}};Ta=j([M(2,Xt),M(3,nn),M(4,Qt),M(5,fn)],Ta);var Ea=0,Da=0,Oa=0,z=0,ka={css:`#00000000`,rgba:0},B;(e=>{function t(e,t,n,r){return r===void 0?`#${Ma(e)}${Ma(t)}${Ma(n)}`:`#${Ma(e)}${Ma(t)}${Ma(n)}${Ma(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(B||={});var V;(e=>{function t(e,t){if(z=(t.rgba&255)/255,z===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return Ea=a+Math.round((n-a)*z),Da=o+Math.round((r-o)*z),Oa=s+Math.round((i-s)*z),{css:B.toCss(Ea,Da,Oa),rgba:B.toRgba(Ea,Da,Oa)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=ja.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return B.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[Ea,Da,Oa]=ja.toChannels(t),{css:B.toCss(Ea,Da,Oa),rgba:t}}e.opaque=i;function a(e,t){return z=Math.round(t*255),[Ea,Da,Oa]=ja.toChannels(e.rgba),{css:B.toCss(Ea,Da,Oa,z),rgba:B.toRgba(Ea,Da,Oa,z)}}e.opacity=a;function o(e,t){return z=e.rgba&255,a(e,z*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(V||={});var H;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return Ea=parseInt(e.slice(1,2).repeat(2),16),Da=parseInt(e.slice(2,3).repeat(2),16),Oa=parseInt(e.slice(3,4).repeat(2),16),B.toColor(Ea,Da,Oa);case 5:return Ea=parseInt(e.slice(1,2).repeat(2),16),Da=parseInt(e.slice(2,3).repeat(2),16),Oa=parseInt(e.slice(3,4).repeat(2),16),z=parseInt(e.slice(4,5).repeat(2),16),B.toColor(Ea,Da,Oa,z);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return Ea=parseInt(r[1]),Da=parseInt(r[2]),Oa=parseInt(r[3]),z=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),B.toColor(Ea,Da,Oa,z);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[Ea,Da,Oa,z]=t.getImageData(0,0,1,1).data,z!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:B.toRgba(Ea,Da,Oa,z),css:e}}e.toColor=r})(H||={});var Aa;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(Aa||={});var ja;(e=>{function t(e,t){if(z=(t&255)/255,z===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return Ea=a+Math.round((n-a)*z),Da=o+Math.round((r-o)*z),Oa=s+Math.round((i-s)*z),B.toRgba(Ea,Da,Oa)}e.blend=t;function n(e,t,n){let a=Aa.relativeLuminance(e>>8),o=Aa.relativeLuminance(t>>8);if(Na(a,o)>8));if(sNa(a,Aa.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=Na(a,Aa.relativeLuminance(s>>8));if(cNa(a,Aa.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Na(Aa.relativeLuminance2(o,s,c),Aa.relativeLuminance2(r,i,a));for(;l0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=Na(Aa.relativeLuminance2(o,s,c),Aa.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Na(Aa.relativeLuminance2(o,s,c),Aa.relativeLuminance2(r,i,a));for(;l>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(ja||={});function Ma(e){let t=e.toString(16);return t.length<2?`0`+t:t}function Na(e,t){return e1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t=w,ae=E,D=this._workCell;if(f.length>0&&E===f[0][0]&&ie){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v=r[1],ie?(re=!0,D=new Pa(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),ae=r[1]-1,m=D.getWidth()):w=r[1]}let O=this._isCellInSelection(E,t),k=n&&E===a,oe=ne&&E>=l&&E<=u,se=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,e=>{se=!0});let ce=D.getChars()||Bt;if(ce===` `&&(D.isUnderline()||D.isOverline())&&(ce=`\xA0`),C=m*s-c.get(ce,D.isBold(),D.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(O&&S||!O&&!S&&D.bg===y)&&(O&&S&&p.selectionForeground||D.fg===b)&&D.extended.ext===x&&oe===ee&&C===te&&!k&&!re&&!se&&ie){D.isInvisible()?_+=Bt:_+=ce,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=D.bg,b=D.fg,x=D.extended.ext,ee=oe,te=C,S=O,re&&a>=E&&a<=ae&&(a=E),!this._coreService.isCursorHidden&&k&&this._coreService.isCursorInitialized){if(T.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&T.push(`xterm-cursor-blink`),T.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:T.push(`xterm-cursor-outline`);break;case`block`:T.push(`xterm-cursor-block`);break;case`bar`:T.push(`xterm-cursor-bar`);break;case`underline`:T.push(`xterm-cursor-underline`)}}if(D.isBold()&&T.push(`xterm-bold`),D.isItalic()&&T.push(`xterm-italic`),D.isDim()&&T.push(`xterm-dim`),_=D.isInvisible()?Bt:D.getChars()||Bt,D.isUnderline()&&(T.push(`xterm-underline-${D.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!D.isUnderlineColorDefault())){if(D.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${Vt.toColorRGB(D.getUnderlineColor()).join(`,`)})`;else{let e=D.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&D.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}}D.isOverline()&&(T.push(`xterm-overline`),_===` `&&(_=`\xA0`)),D.isStrikethrough()&&T.push(`xterm-strikethrough`),oe&&(h.style.textDecoration=`underline`);let le=D.getFgColor(),ue=D.getFgColorMode(),de=D.getBgColor(),fe=D.getBgColorMode(),pe=!!D.isInverse();if(pe){let e=le;le=de,de=e;let t=ue;ue=fe,fe=t}let me,he,A=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,e=>{e.options.layer!==`top`&&A||(e.backgroundColorRGB&&(fe=50331648,de=e.backgroundColorRGB.rgba>>8&16777215,me=e.backgroundColorRGB),e.foregroundColorRGB&&(ue=50331648,le=e.foregroundColorRGB.rgba>>8&16777215,he=e.foregroundColorRGB),A=e.options.layer===`top`)}),!A&&O&&(me=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,de=me.rgba>>8&16777215,fe=50331648,A=!0,p.selectionForeground&&(ue=50331648,le=p.selectionForeground.rgba>>8&16777215,he=p.selectionForeground)),A&&T.push(`xterm-decoration-top`);let ge;switch(fe){case 16777216:case 33554432:ge=p.ansi[de],T.push(`xterm-bg-${de}`);break;case 50331648:ge=B.toColor(de>>16,de>>8&255,de&255),this._addStyle(h,`background-color:#${Ha((de>>>0).toString(16),`0`,6)}`);break;default:pe?(ge=p.foreground,T.push(`xterm-bg-257`)):ge=p.background}switch(me||D.isDim()&&(me=V.multiplyOpacity(ge,.5)),ue){case 16777216:case 33554432:D.isBold()&&le<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(le+=8),this._applyMinimumContrast(h,ge,p.ansi[le],D,me,void 0)||T.push(`xterm-fg-${le}`);break;case 50331648:let e=B.toColor(le>>16&255,le>>8&255,le&255);this._applyMinimumContrast(h,ge,e,D,me,he)||this._addStyle(h,`color:#${Ha(le.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,ge,p.foreground,D,me,he)||pe&&T.push(`xterm-fg-257`)}T.length&&=(h.className=T.join(` `),0),!k&&!re&&!se&&ie?g++:h.textContent=_,C!==this.defaultSpacing&&(h.style.letterSpacing=`${C}px`),d.push(h),E=ae}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||Ra(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=V.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t=n[0]&&e=n[0]}};Va=j([M(1,mn),M(2,nn),M(3,un),M(4,Qt),M(5,on),M(6,hn)],Va);function Ha(e,t,n){for(;e.length0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},Wa=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);s>=e.rows||c<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0])}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n=this.startCol&&t=this.startCol):!1}};function Ga(){return new Wa}var Ka=`xterm-dom-renderer-owner-`,qa=`xterm-rows`,Ja=`xterm-fg-`,Ya=`xterm-bg-`,Xa=`xterm-focus`,Za=`xterm-selection`,Qa=1,$a=class extends P{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=Qa++,this._rowElements=[],this._selectionRenderModel=Ga(),this.onRequestRedraw=this._register(new I).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(qa),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add(Za),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=za(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(Va,document),this._element.classList.add(Ka+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(N(()=>{this._element.classList.remove(Ka+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Ua(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${qa} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${qa} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${qa} .xterm-dim { color: ${V.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${qa}.${Xa} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${qa}.${Xa} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${qa}.${Xa} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${qa} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${qa} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${qa} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${qa} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${qa} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Za} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Za} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Za} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${Ja}${n} { color: ${r.css}; }${this._terminalSelector} .${Ja}${n}.xterm-dim { color: ${V.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${Ya}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${Ja}257 { color: ${V.opaque(e.background).css}; }${this._terminalSelector} .${Ja}257.xterm-dim { color: ${V.multiplyOpacity(V.opaque(e.background),.5).css}; }${this._terminalSelector} .${Ya}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Xa),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Xa),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ka}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};$a=j([M(7,en),M(8,ln),M(9,nn),M(10,Xt),M(11,Qt),M(12,un),M(13,hn)],$a);var eo=class extends P{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new I),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new ro(this._optionsService))}catch{this._measureStrategy=this._register(new no(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};eo=j([M(2,nn)],eo);var to=class extends P{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},no=class extends to{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},ro=class extends to{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},io=class extends P{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new ao(this._window)),this._onDprChange=this._register(new I),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new I),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(Gn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(L(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(L(this._textarea,`blur`,()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},ao=class extends P{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new zn),this._onDprChange=this._register(new I),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(N(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=L(this._parentWindow,`resize`,()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},oo=class extends P{constructor(){super(),this.linkProviders=[],this._register(N(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function so(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function co(e,t,n,r,i,a,o,s,c){if(!a)return;let l=so(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+ +!!c),l[1]=Math.min(Math.max(l[1],1),i),l}var lo=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return co(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=so(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};lo=j([M(0,fn),M(1,ln)],lo);var uo=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},fo={};Ct(fo,{getSafariVersion:()=>yo,isChromeOS:()=>To,isFirefox:()=>go,isIpad:()=>xo,isIphone:()=>So,isLegacyEdge:()=>_o,isLinux:()=>wo,isMac:()=>bo,isNode:()=>po,isSafari:()=>vo,isWindows:()=>Co});var po=typeof process<`u`&&`title`in process,mo=po?`node`:navigator.userAgent,ho=po?`node`:navigator.platform,go=mo.includes(`Firefox`),_o=mo.includes(`Edge`),vo=/^((?!chrome|android).)*safari/i.test(mo);function yo(){if(!vo)return 0;let e=mo.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var bo=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(ho),xo=ho===`iPad`,So=ho===`iPhone`,Co=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(ho),wo=ho.indexOf(`Linux`)>=0,To=/\bCrOS\b/.test(mo),Eo=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ii){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},Do=class extends Eo{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},Oo=class extends Eo{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},ko=!po&&`requestIdleCallback`in window?Oo:Do,Ao=class{constructor(){this._queue=new ko}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},jo=class extends P{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new zn),this._pausedResizeTask=new Ao,this._observerDisposable=this._register(new zn),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new I),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new I),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new I),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new I),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new uo((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Mo(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(N(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=N(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};jo=j([M(2,nn),M(3,ln),M(4,Qt),M(5,on),M(6,Xt),M(7,un),M(8,hn)],jo);var Mo=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function No(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return Io(i,a,e,t,n,r)+Lo(a,t,n,r)+Ro(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,Go(Math.abs(i-e),Wo(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return Go(Fo(a>t?e:i,n)+(s-1)*n.cols+1+Po(a>t?i:e,n),Wo(o,r))}function Po(e,t){return e-1}function Fo(e,t){return t.cols-e}function Io(e,t,n,r,i,a){return Lo(t,r,i,a).length===0?``:Go(Uo(e,t,e,t-Bo(t,i),!1,i).length,Wo(`D`,a))}function Lo(e,t,n,r){let i=e-Bo(e,n),a=t-Bo(t,n);return Go(Math.abs(i-a)-zo(e,t,n),Wo(Ho(e,t),r))}function Ro(e,t,n,r,i,a){let o;o=Lo(t,r,i,a).length>0?r-Bo(r,i):t;let s=r,c=Vo(e,t,n,r,i,a);return Go(Uo(e,o,n,s,c===`C`,i).length,Wo(c,a))}function zo(e,t,n){let r=0,i=e-Bo(e,n),a=t-Bo(t,n);for(let o=0;o=0&&e0?r-Bo(r,i):t,e=n&&ot?`A`:`B`}function Uo(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&sa.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function Wo(e,t){let n=t?`O`:`[`;return R.ESC+n+e}function Go(e,t){e=Math.floor(e);let n=``;for(let r=0;rthis._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function qo(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Jo=50,Yo=15,Xo=50,Zo=500,Qo=RegExp(`\xA0`,`g`),$o=class extends P{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Ut,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new I),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new I),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new I),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new I),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new Ko(this._bufferService),this._activeSelectionMode=0,this._register(N(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]e.replace(Qo,` `)).join(Co?`\r -`:` -`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),wo&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=qo(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=so(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-Jo),Jo),t/=Jo,t/Math.abs(t)+Math.round(t*(Yo-1)))}shouldForceSelection(e){return bo?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),Xo)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(bo&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&tthis._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(t||o.slice(s,c).trim()!==``){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=qo(n,this._bufferService.cols)}};$o=j([M(3,Xt),M(4,Qt),M(5,dn),M(6,nn),M(7,fn),M(8,un)],$o);var es=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},ts=class{constructor(){this._color=new es,this._css=new es}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},U=Object.freeze((()=>{let e=[H.toColor(`#2e3436`),H.toColor(`#cc0000`),H.toColor(`#4e9a06`),H.toColor(`#c4a000`),H.toColor(`#3465a4`),H.toColor(`#75507b`),H.toColor(`#06989a`),H.toColor(`#d3d7cf`),H.toColor(`#555753`),H.toColor(`#ef2929`),H.toColor(`#8ae234`),H.toColor(`#fce94f`),H.toColor(`#729fcf`),H.toColor(`#ad7fa8`),H.toColor(`#34e2e2`),H.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:B.toCss(r,i,a),rgba:B.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:B.toCss(n,n,n),rgba:B.toRgba(n,n,n)})}return e})()),ns=H.toColor(`#ffffff`),rs=H.toColor(`#000000`),is=H.toColor(`#ffffff`),as=rs,os={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},ss=ns,cs=class extends P{constructor(e){super(),this._optionsService=e,this._contrastCache=new ts,this._halfContrastCache=new ts,this._onChangeColors=this._register(new I),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ns,background:rs,cursor:is,cursorAccent:as,selectionForeground:void 0,selectionBackgroundTransparent:os,selectionBackgroundOpaque:V.blend(rs,os),selectionInactiveBackgroundTransparent:os,selectionInactiveBackgroundOpaque:V.blend(rs,os),scrollbarSliderBackground:V.opacity(ns,.2),scrollbarSliderHoverBackground:V.opacity(ns,.4),scrollbarSliderActiveBackground:V.opacity(ns,.5),overviewRulerBorder:ns,ansi:U.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=W(e.foreground,ns),t.background=W(e.background,rs),t.cursor=V.blend(t.background,W(e.cursor,is)),t.cursorAccent=V.blend(t.background,W(e.cursorAccent,as)),t.selectionBackgroundTransparent=W(e.selectionBackground,os),t.selectionBackgroundOpaque=V.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=W(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=V.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?W(e.selectionForeground,ka):void 0,t.selectionForeground===ka&&(t.selectionForeground=void 0),V.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=V.opacity(t.selectionBackgroundTransparent,.3)),V.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=V.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=W(e.scrollbarSliderBackground,V.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=W(e.scrollbarSliderHoverBackground,V.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=W(e.scrollbarSliderActiveBackground,V.opacity(t.foreground,.5)),t.overviewRulerBorder=W(e.overviewRulerBorder,ss),t.ansi=U.slice(),t.ansi[0]=W(e.black,U[0]),t.ansi[1]=W(e.red,U[1]),t.ansi[2]=W(e.green,U[2]),t.ansi[3]=W(e.yellow,U[3]),t.ansi[4]=W(e.blue,U[4]),t.ansi[5]=W(e.magenta,U[5]),t.ansi[6]=W(e.cyan,U[6]),t.ansi[7]=W(e.white,U[7]),t.ansi[8]=W(e.brightBlack,U[8]),t.ansi[9]=W(e.brightRed,U[9]),t.ansi[10]=W(e.brightGreen,U[10]),t.ansi[11]=W(e.brightYellow,U[11]),t.ansi[12]=W(e.brightBlue,U[12]),t.ansi[13]=W(e.brightMagenta,U[13]),t.ansi[14]=W(e.brightCyan,U[14]),t.ansi[15]=W(e.brightWhite,U[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;re.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},ds={trace:0,debug:1,info:2,warn:3,error:4,off:5},fs=`xterm.js: `,ps=class extends P{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),ms=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=ds[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;tthis._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*G+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*G+0]=e|2097152|t[2]<<22):this._data[e*G+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*G+0]>>22}hasWidth(e){return this._data[e*G+0]&12582912}getFg(e){return this._data[e*G+1]}getBg(e){return this._data[e*G+2]}hasContent(e){return this._data[e*G+0]&4194303}getCodePoint(e){let t=this._data[e*G+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*G+0]&2097152}getString(e){let t=this._data[e*G+0];return t&2097152?this._combined[e]:t&2097151?Ft(t&2097151):``}isProtected(e){return this._data[e*G+2]&536870912}loadCell(e,t){return gs=e*G,t.content=this._data[gs+0],t.fg=this._data[gs+1],t.bg=this._data[gs+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*G+0]=t.content,this._data[e*G+1]=t.fg,this._data[e*G+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*G+0]=t|n<<22,this._data[e*G+1]=r.fg,this._data[e*G+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*G+0];r&2097152?this._combined[e]+=Ft(t):r&2097151?(this._combined[e]=Ft(r&2097151)+Ft(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*G+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;rthis.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*_s=0;--e)if(this._data[e*G+0]&4194303)return e+(this._data[e*G+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*G+0]&4194303||this._data[e*G+2]&50331648)return e+(this._data[e*G+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t>22||1}return r&&r.push(t),i}};function ys(e,t,n,r,i,a){let o=[];for(let s=0;s=s&&r0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function bs(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;oCs(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;sc&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function Cs(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var ws=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new I),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Fn(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};ws._nextId=1;var Ts=ws,Es={},Ds=Es.B;Es[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:`␤`,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},Es.A={"#":`£`},Es.B=void 0,Es[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},Es.C=Es[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},Es.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},Es.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},Es.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},Es.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},Es.E=Es[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},Es.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},Es.H=Es[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},Es[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var Os=4294967295,ks=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=K.clone(),this.savedCharset=Ds,this.markers=[],this._nullCell=Ut.fromCharData([0,zt,1,0]),this._whitespaceCell=Ut.fromCharData([0,Bt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new ko,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new hs(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Ht),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Ht),this._whitespaceCell}getBlankLine(e,t){return new vs(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&eOs?Os:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=K);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new hs(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(K),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new vs(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=ys(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(K),n);if(r.length>0){let n=bs(this.lines,r);xs(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(K),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=Cs(c,Math.max(g,0),this._cols))}for(let t=0;t0;)this.ybase===0?this.y0){let e=[],t=[];for(let e=0;e=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+10;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.linee.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},As=class extends P{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new I),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new ks(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new ks(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},js=2,Ms=1,Ns=class extends P{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new I),this.onResize=this._onResize.event,this._onScroll=this._register(new I),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,js),this.rows=Math.max(e.rawOptions.rows||0,Ms),this.buffers=this._register(new As(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,r&&r.length===this.cols&&r.getFg(0)===e.fg&&r.getBg(0)===e.bg||(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};Ns=j([M(0,nn)],Ns);var Ps={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:bo,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},Fs=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],Is=class extends P{constructor(e){super(),this._onOptionChange=this._register(new I),this.onOptionChange=this._onOptionChange.event;let t={...Ps};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(N(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in Ps))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in Ps))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=Ps[e],!Ls(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=Ps[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=Fs.includes(t)?t:Ps[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={}}return t}};function Ls(e){return e===`block`||e===`underline`||e===`bar`}function Rs(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&Rs(e[r],t-1);return n}var zs=Object.freeze({insertMode:!1}),Bs=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Vs=class extends P{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new I),this.onData=this._onData.event,this._onUserInput=this._register(new I),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new I),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new I),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Rs(zs),this.decPrivateModes=Rs(Bs)}reset(){this.modes=Rs(zs),this.decPrivateModes=Rs(Bs)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};Vs=j([M(0,Xt),M(1,tn),M(2,nn)],Vs);var Hs={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function Us(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var Ws=String.fromCharCode,Gs={DEFAULT:e=>{let t=[Us(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${Ws(t[0])}${Ws(t[1])}${Ws(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${Us(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${Us(e,!0)};${e.x};${e.y}${t}`}},Ks=class extends P{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new I),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(Hs))this.addProtocol(e,Hs[e]);for(let e of Object.keys(Gs))this.addEncoding(e,Gs[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};Ks=j([M(0,Xt),M(1,Qt),M(2,nn)],Ks);var qs=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],Js=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Ys;function Xs(e,t){let n=0,r=t.length-1,i;if(et[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=Qs.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return Qs.createPropertyValue(0,n,r)}},Qs=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new I,this.onChange=this._onChange.event;let e=new Zs;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(e&1)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},$s=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function ec(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var tc=2147483647,nc=256,rc=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>nc)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>tc?tc:e}}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>tc?tc:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,tc):e}},ic=[],ac=class{constructor(){this._state=0,this._active=ic,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=ic}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=ic,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||ic,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,It(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3){if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}}this._active=ic,this._id=-1,this._state=0}}},oc=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=It(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},sc=[],cc=class{constructor(){this._handlers=Object.create(null),this._active=sc,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=sc}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=sc,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||sc,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,It(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=sc,this._ident=0}},lc=new rc;lc.addParam(0);var uc=class{constructor(e){this._handler=e,this._data=``,this._params=lc,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():lc,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=It(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=lc,this._data=``,this._hitLimit=!1,e));return this._params=lc,this._data=``,this._hitLimit=!1,t}},dc=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;it),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(fc,0,2,0),e.add(fc,8,5,8),e.add(fc,6,0,6),e.add(fc,11,0,11),e.add(fc,13,13,13),e}(),mc=class extends P{constructor(e=pc){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new rc,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(N(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new ac),this._dcsParser=this._register(new cc),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;tr||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state){if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}}for(let n=a;n>4){case 2:for(let i=n+1;;++i)if(i>=t||(r=e[i])<32||r>126&&r=t||(r=e[i])<32||r>126&&r=t||(r=e[i])<32||r>126&&r=t||(r=e[i])<32||r>126&&r=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r=t||(r=e[i])<32||r>127&&r>4:i>>8}return n}}function vc(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function yc(e,t=16){let[n,r,i]=e;return`rgb:${vc(n,t)}/${vc(r,t)}/${vc(i,t)}`}var bc={"(":0,")":1,"*":2,"+":3,"-":1,".":2},xc=131072,Sc=10;function Cc(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var wc=5e3,Tc=0,Ec=class extends P{constructor(e,t,n,r,i,a,o,s,c=new mc){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Lt,this._utf8Decoder=new Rt,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=K.clone(),this._eraseAttrDataInternal=K.clone(),this._onRequestBell=this._register(new I),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new I),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new I),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new I),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new I),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new I),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new I),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new I),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new I),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new I),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new I),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new I),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new I),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new Dc(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(R.BEL,()=>this.bell()),this._parser.setExecuteHandler(R.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(R.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(R.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(R.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(R.BS,()=>this.backspace()),this._parser.setExecuteHandler(R.HT,()=>this.tab()),this._parser.setExecuteHandler(R.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(R.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ca.IND,()=>this.index()),this._parser.setExecuteHandler(Ca.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ca.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new oc(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new oc(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new oc(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new oc(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new oc(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new oc(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new oc(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new oc(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new oc(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new oc(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new oc(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new oc(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in Es)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new uc((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),wc))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${wc} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>xc&&(a=this._parseStack.position+xc)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.lengthxc)for(let t=a;t0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;ps){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof vs&&d.copyCellsFrom(e,t,0,m,!1);t=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}else if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!Cc(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new uc(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new oc(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let c=s;for(let e=1;e0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent(R.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(R.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(R.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(R.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(R.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${R.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=Vt.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=K.fg,e.bg=K.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=K.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=K.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=K.fg&16777215,r.bg&=-67108864,r.bg|=K.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${R.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${R.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${R.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=K.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Cc(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${R.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Sc&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Sc&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(Oc(n)){if(r===`?`)t.push({type:0,index:n});else{let e=_c(r);e&&t.push({type:1,index:n,color:e})}}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=_c(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=K.clone(),this._eraseAttrDataInternal=K.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Ut;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t(this._coreService.triggerDataEvent(`${R.ESC}${e}${R.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Dc=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Tc=e,e=t,t=Tc),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Dc=j([M(0,Xt)],Dc);function Oc(e){return 0<=e&&e<256}var kc=5e7,Ac=12,jc=50,Mc=class extends P{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new I),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>kc)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=Ac?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=Ac)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>jc&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Nc=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Nc=j([M(0,Xt)],Nc);var Pc=!1,Fc=class extends P{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new zn),this._onBinary=this._register(new I),this.onBinary=this._onBinary.event,this._onData=this._register(new I),this.onData=this._onData.event,this._onLineFeed=this._register(new I),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new I),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new I),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new I),this._instantiationService=new us,this.optionsService=this._register(new Is(e)),this._instantiationService.setService(nn,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Ns)),this._instantiationService.setService(Xt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(ps)),this._instantiationService.setService(tn,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Vs)),this._instantiationService.setService(Qt,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Ks)),this._instantiationService.setService(Zt,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Qs)),this._instantiationService.setService(an,this.unicodeService),this._charsetService=this._instantiationService.createInstance($s),this._instantiationService.setService($t,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Nc),this._instantiationService.setService(rn,this._oscLinkService),this._inputHandler=this._register(new Ec(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Gn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Gn.forward(this._bufferService.onResize,this._onResize)),this._register(Gn.forward(this.coreService.onData,this._onData)),this._register(Gn.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new Mc((e,t)=>this._inputHandler.parse(e,t))),this._register(Gn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new I),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Pc&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),Pc=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,js),t=Math.max(t,Ms),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(ec.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(ec(this._bufferService),!1))),this._windowsWrappingHeuristics.value=N(()=>{for(let t of e)t.dispose()})}}},Ic={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function Lc(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=+!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?i.key=t?R.ESC+`OA`:R.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?R.ESC+`OD`:R.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?R.ESC+`OC`:R.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?R.ESC+`OB`:R.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:R.DEL,e.altKey&&(i.key=R.ESC+i.key);break;case 9:if(e.shiftKey){i.key=R.ESC+`[Z`;break}i.key=R.HT,i.cancel=!0;break;case 13:i.key=e.altKey?R.ESC+R.CR:R.CR,i.cancel=!0;break;case 27:i.key=R.ESC,e.altKey&&(i.key=R.ESC+R.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?R.ESC+`[1;`+(a+1)+`D`:t?R.ESC+`OD`:R.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?R.ESC+`[1;`+(a+1)+`C`:t?R.ESC+`OC`:R.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?R.ESC+`[1;`+(a+1)+`A`:t?R.ESC+`OA`:R.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?R.ESC+`[1;`+(a+1)+`B`:t?R.ESC+`OB`:R.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=R.ESC+`[2~`);break;case 46:i.key=a?R.ESC+`[3;`+(a+1)+`~`:R.ESC+`[3~`;break;case 36:i.key=a?R.ESC+`[1;`+(a+1)+`H`:t?R.ESC+`OH`:R.ESC+`[H`;break;case 35:i.key=a?R.ESC+`[1;`+(a+1)+`F`:t?R.ESC+`OF`:R.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?R.ESC+`[5;`+(a+1)+`~`:R.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?R.ESC+`[6;`+(a+1)+`~`:R.ESC+`[6~`;break;case 112:i.key=a?R.ESC+`[1;`+(a+1)+`P`:R.ESC+`OP`;break;case 113:i.key=a?R.ESC+`[1;`+(a+1)+`Q`:R.ESC+`OQ`;break;case 114:i.key=a?R.ESC+`[1;`+(a+1)+`R`:R.ESC+`OR`;break;case 115:i.key=a?R.ESC+`[1;`+(a+1)+`S`:R.ESC+`OS`;break;case 116:i.key=a?R.ESC+`[15;`+(a+1)+`~`:R.ESC+`[15~`;break;case 117:i.key=a?R.ESC+`[17;`+(a+1)+`~`:R.ESC+`[17~`;break;case 118:i.key=a?R.ESC+`[18;`+(a+1)+`~`:R.ESC+`[18~`;break;case 119:i.key=a?R.ESC+`[19;`+(a+1)+`~`:R.ESC+`[19~`;break;case 120:i.key=a?R.ESC+`[20;`+(a+1)+`~`:R.ESC+`[20~`;break;case 121:i.key=a?R.ESC+`[21;`+(a+1)+`~`:R.ESC+`[21~`;break;case 122:i.key=a?R.ESC+`[23;`+(a+1)+`~`:R.ESC+`[23~`;break;case 123:i.key=a?R.ESC+`[24;`+(a+1)+`~`:R.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=R.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=R.DEL:e.keyCode===219?i.key=R.ESC:e.keyCode===220?i.key=R.FS:e.keyCode===221&&(i.key=R.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=Ic[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=R.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=R.ESC+n}else if(e.keyCode===32)i.key=R.ESC+(e.ctrlKey?R.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=R.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=R.US),e.key===`@`&&(i.key=R.NUL))}return i}var q=0,Rc=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new ko,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new ko,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(q=this._search(t),q===-1)||this._getKey(this._array[q])!==t)return!1;do if(this._array[q]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(q),!0;while(++qe-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(q=this._search(e),!(q<0||q>=this._array.length)&&this._getKey(this._array[q])===e))do yield this._array[q];while(++q=this._array.length)&&this._getKey(this._array[q])===e))do t(this._array[q]);while(++q=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},zc=0,Bc=0,Vc=class extends P{constructor(){super(),this._decorations=new Rc(e=>e?.marker.line),this._onDecorationRegistered=this._register(new I),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new I),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(N(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Hc(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e{zc=t.options.x??0,Bc=zc+(t.options.width??1),e>=zc&&e=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Gc=20,Kc=class extends P{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;ethis._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Wc(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` -`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(L(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(N(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===` -`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Gc+1&&(this._liveRegion.textContent+=Dt.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(a&&o){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;ee;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e{Fn(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(L(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(L(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(L(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(L(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;re?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;tthis._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;ethis._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Jc(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Fn(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};qc=j([M(1,dn),M(2,fn),M(3,Xt),M(4,gn)],qc);function Jc(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var Yc=class extends Fc{constructor(e={}){super(e),this._linkifier=this._register(new zn),this.browser=fo,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new zn),this._onCursorMove=this._register(new I),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new I),this.onKey=this._onKey.event,this._onRender=this._register(new I),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new I),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new I),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new I),this.onBell=this._onBell.event,this._onFocus=this._register(new I),this._onBlur=this._register(new I),this._onA11yCharEmitter=this._register(new I),this._onA11yTabEmitter=this._register(new I),this._onWillOpen=this._register(new I),this._setup(),this._decorationService=this._instantiationService.createInstance(Vc),this._instantiationService.setService(on,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(oo),this._instantiationService.setService(gn,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(sn)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(Gn.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Gn.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Gn.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Gn.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(N(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=V.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${R.ESC}]${n};${yc(r)}${wa.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=B.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=B.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Kc,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(R.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(R.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(L(this.element,`copy`,e=>{this.hasSelection()&&At(e,this._selectionService)}));let e=e=>jt(e,this.textarea,this.coreService,this.optionsService);this._register(L(this.textarea,`paste`,e)),this._register(L(this.element,`paste`,e)),go?this._register(L(this.element,`mousedown`,e=>{e.button===2&&Pt(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(L(this.element,`contextmenu`,e=>{Pt(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),wo&&this._register(L(this.element,`auxclick`,e=>{e.button===1&&Nt(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(L(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(L(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(L(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(L(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(L(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(L(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(L(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(L(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,Tt.get()),To||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(io,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(un,this._coreBrowserService),this._register(L(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(L(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(eo,this._document,this._helperContainer),this._instantiationService.setService(ln,this._charSizeService),this._themeService=this._instantiationService.createInstance(cs),this._instantiationService.setService(hn,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Fa),this._instantiationService.setService(mn,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(jo,this.rows,this.screenElement)),this._instantiationService.setService(fn,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(Ta,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(lo),this._instantiationService.setService(dn,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(qc,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(ga,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance($o,this.element,this.screenElement,r)),this._instantiationService.setService(pn,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(Gn.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(_a,this.screenElement)),this._register(L(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Kc,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Sa,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Sa,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance($a,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(L(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(L(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=R.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Mt(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;t||e.key!==`Dead`&&e.key!==`AltGraph`||(this._unprocessedDeadKey=!0);let n=Lc(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===R.ETX||n.key===R.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Xc(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){e===this.cols&&t===this.rows?this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure():super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Ut)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},$c=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new Qc(t)}getNullCell(){return new Ut}},el=class extends P{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new I),this.onBufferChange=this._onBufferChange.event,this._normal=new $c(this._core.buffers.normal,`normal`),this._alternate=new $c(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},tl=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},nl=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},rl=[`cols`,`rows`],il=0,al=class extends P{constructor(e){super(),this._core=this._register(new Yc(e)),this._addonManager=this._register(new Zc),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(rl.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new tl(this._core),this._parser}get unicode(){return this._checkProposedApi(),new nl(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new el(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r -`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Tt.get()},set promptLabel(e){Tt.set(e)},get tooMuchOutput(){return Dt.get()},set tooMuchOutput(e){Dt.set(e)}}}_verifyIntegers(...e){for(il of e)if(il===1/0||isNaN(il)||il%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(il of e)if(il&&(il===1/0||isNaN(il)||il%1!=0||il<0))throw Error(`This API only accepts positive integers`)}},ol=2,sl=1,cl=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(ol,Math.floor(u/e.css.cell.width)),rows:Math.max(sl,Math.floor(l/e.css.cell.height))}}};function ll(e=r()){return{fontSize:typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(pointer: coarse)`).matches?13*e/100:12*e/100,fontFamily:getComputedStyle(document.body).fontFamily}}function ul({pending:e,size:t,screenScale:n,socketRef:r,slotRefs:i,panesExist:a,onAnswered:o}){(0,A.useEffect)(()=>{if(e===null)return;let t=r.current;if(!t||t.readyState!==WebSocket.OPEN)return;let s=[];for(let n=0;n{let t=new al(ll(n)),r=new cl;t.loadAddon(r),t.open(e);let i=r.proposeDimensions();if(t.dispose(),!i)throw Error(`could not measure the cell`);return{rows:i.rows,cols:i.cols}})}catch{c=[]}we(t,{type:`start`,sizes:c})&&o()},[e,t,n,r,i,a,o])}var dl=15e3,fl=1e4,pl=.2;function ml(e,t=Math.random){let n=Math.min(500*2**Math.min(Number.isFinite(e)?Math.max(0,Math.floor(e)):0,16),dl),r=n*pl,i=n+(t()*2-1)*r;return Math.max(0,Math.min(dl,Math.round(i)))}var hl=`nightcrow.viewer`;function gl(){return globalThis.crypto?.randomUUID?.()||`tab-${Math.floor(Math.random()*2**48).toString(36)}`}function _l(){try{let e=sessionStorage.getItem(hl);if(e)return e;let t=gl();return sessionStorage.setItem(hl,t),t}catch{return gl()}}function vl(e,t){return t.state===`cancelled`?yl(e,t.pane):{...e,[t.pane]:{state:t.state,detail:t.detail,deadlineEpoch:t.deadline_epoch,attempt:t.attempt}}}function yl(e,t){if(!(t in e))return e;let n={...e};return delete n[t],n}function bl(e,t){return Object.keys(e).map(Number).filter(e=>!t.includes(e)).sort((e,t)=>e-t)}function xl(e){if(e===void 0||!Number.isFinite(e))return;let t=new Date(e*1e3);if(!Number.isNaN(t.getTime()))return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function Sl(e){let t=xl(e.deadlineEpoch),n=[e.state];return t&&n.push(`until ${t}`),e.attempt>0&&n.push(`attempt ${e.attempt}`),n.join(` · `)}function Cl(e,t){if(typeof e==`string`){let n=Ce(e);n&&wl(n,t);return}if(!(e instanceof ArrayBuffer))return;let n=Te(e);if(!n)return;let r;t.replayRef.current.active&&(r=t.replayRef.current.panes.get(n.pane),r||(r=Symbol(),t.replayRef.current.panes.set(n.pane,r)));let i=t.viewsRef.current.get(n.pane);if(i){r&&i.replayGate.begin(),ot(i.term,n.data);return}let a=t.pendingRef.current.get(n.pane)??[];a.push(n.data),t.pendingRef.current.set(n.pane,a)}function wl(e,t){switch(e.type){case`hello`:t.clientIdRef.current=e.client,t.setLink(`live`),t.replayRef.current.active=!0,t.replayRef.current.panes.clear(),t.replayRef.current.order.length=0,t.replayRef.current.zoomed=!1,t.setReplayLeft(e.panes);return;case`replay_complete`:Tl(t);return;case`pending`:t.setPending(e.count);return;case`created`:{let n=e.pane;if(t.replayRef.current.active){t.replayRef.current.panes.set(n,Symbol());let e=t.replayRef.current.order;e.includes(n)||e.push(n)}t.ptySizesRef.current.set(n,{rows:e.rows,cols:e.cols});let r=t.viewsRef.current.get(n);r&&(r.term.rows!==e.rows||r.term.cols!==e.cols)&&r.term.resize(e.cols,e.rows);let i=e.title;i&&t.setTitles(e=>({...e,[n]:i})),t.setPanes(e=>e.includes(n)?e:[...e,n]),t.setReplayLeft(e=>e>0?e-1:0),e.client!=null&&e.client===t.clientIdRef.current?(t.setActive(n),se(t.repo,n)):D(t.repo)===n&&t.setActive(n);return}case`exited`:t.setPanes(t=>t.filter(t=>t!==e.pane)),t.setActive(t=>t===e.pane?null:t),t.pendingRef.current.delete(e.pane),t.replayRef.current.panes.delete(e.pane),t.ptySizesRef.current.delete(e.pane),t.askedSizesRef.current.delete(e.pane),t.desiredSizesRef.current.delete(e.pane),ue(t.repo,e.pane),t.setTitles(t=>{if(!(e.pane in t))return t;let n={...t};return delete n[e.pane],n});return;case`resized`:t.ptySizesRef.current.set(e.pane,{rows:e.rows,cols:e.cols}),t.viewsRef.current.get(e.pane)?.term.resize(e.cols,e.rows);return;case`recovery`:t.setRecovery(t=>vl(t,e));return;case`size_owner`:qe(t.ownsSizeRef,t.sizeOwnerGenerationRef,e.owned,e.generation,()=>{t.askedSizesRef.current.clear(),t.onSizeAcquired()}),t.setOwnsSize(e.owned);return;case`reordered`:t.setPanes(t=>ce(t,e.order));return;case`zoomed`:t.replayRef.current.zoomed=!0,t.zoomAskedRef.current=void 0,t.setZoomed(e.pane??null);return;case`error`:E.error(e.message);return;case`attention`:E.info(e.message??`A terminal wants your attention`);return}return e}function Tl(e){let t=e.replayRef.current;if(!t.active)return;t.active=!1,e.setReplayLeft(0);for(let[n,r]of t.panes){let i=e.viewsRef.current.get(n);if(i)lt(i.term,i.replayGate,()=>{e.viewsRef.current.get(n)===i&&t.panes.get(n)===r&&t.panes.delete(n)});else{let t=e.pendingRef.current.get(n)??[];t.push({kind:`replay_complete`,token:r}),e.pendingRef.current.set(n,t)}}let n=t.order.slice();e.setPanes(e=>e.length===n.length&&e.every((e,t)=>e===n[t])?e:n),t.zoomed||e.setZoomed(null),e.setActive(e=>e!==null&&n.includes(e)?e:null),e.setTitles(e=>{if(!Object.keys(e).some(e=>!n.includes(Number(e))))return e;let t={};for(let r of n){let n=e[r];n!==void 0&&(t[r]=n)}return t})}function El({repo:e,socketRef:t,viewsRef:n,pendingRef:r,replayRef:i,ptySizesRef:a,askedSizesRef:o,desiredSizesRef:s,ownsSizeRef:c,sizeOwnerGenerationRef:l,onSizeAcquired:u,zoomAskedRef:d,setLink:f,setPending:p,setReplayLeft:m,setPanes:h,setActive:g,setZoomed:_,setTitles:v,setOwnsSize:y,setRecovery:b}){let x=(0,A.useRef)(null);(0,A.useLayoutEffect)(()=>{let ee=!1,te,S,C=0,w=!1,T=!1,ne=e=>{e===`live`&&(w=!0),f(e)},E=()=>w?`reconnecting`:`connecting`,re=()=>{S&&clearTimeout(S),S=void 0},ie={repo:e,clientIdRef:x,viewsRef:n,pendingRef:r,replayRef:i,ptySizesRef:a,askedSizesRef:o,desiredSizesRef:s,ownsSizeRef:c,sizeOwnerGenerationRef:l,onSizeAcquired:u,zoomAskedRef:d,setLink:ne,setPending:p,setReplayLeft:m,setPanes:h,setActive:g,setZoomed:_,setTitles:v,setOwnsSize:y,setRecovery:b},ae=()=>{n.current.forEach(e=>{ct(e.term),e.term.dispose()}),n.current.clear(),r.current.clear(),i.current.active=!1,i.current.panes.clear(),i.current.order.length=0,a.current.clear(),o.current.clear(),s.current.clear()},D=()=>{re();let u=T;if(T=!0,x.current=null,c.current=!1,l.current=null,ne(E()),m(0),d.current=void 0,p(null),b({}),u){for(let e of n.current.values()){let t=at(e.term);t.clear(),t.barrier(()=>e.term.reset())}r.current.clear(),i.current.active=!1,i.current.panes.clear(),i.current.order.length=0,a.current.clear(),o.current.clear(),s.current.clear()}else h([]),g(null),_(null),v({}),ae();let f=location.protocol===`https:`?`wss:`:`ws:`,y=new URLSearchParams({repo:e,viewer:_l()}),w=new WebSocket(`${f}//${location.host}/ws/term?${y}`);w.binaryType=`arraybuffer`,t.current=w,w.onopen=()=>{t.current===w&&(re(),S=setTimeout(()=>{S=void 0,C=0},fl))},w.onmessage=e=>{t.current===w&&Cl(e.data,ie)},w.onclose=()=>{if(ee)return;re(),ne(E());let e=ml(C);C+=1,te=setTimeout(D,e)}};return D(),()=>{ee=!0,te&&clearTimeout(te),re(),t.current?.close(),ae()}},[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b])}var Dl=`\x1B`,Ol=`${Dl}[200~`,kl=`${Dl}[201~`;function Al(e,t){let n=e.split(Dl).join(``).replace(/\r?\n/g,`\r`);return t?Ol+n+kl:n}function jl(e){return e.trim().length>0}function Ml(e){return/mac|iphone|ipad|ipod/i.test(e)?`⌘↩`:`Ctrl+Enter`}var Nl=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`];function Pl(e){if(!e||e.getData(`text/plain`))return null;for(let t of Array.from(e.files))if(Nl.includes(t.type))return t;return null}function Fl(e){return/[\s"']/.test(e)?`"${e.replace(/"/g,`\\"`)}" `:`${e} `}function Il(e){if(!(e instanceof Element))return null;let t=e.closest(`[data-pane-id]`)?.getAttribute(`data-pane-id`);return t==null?null:Number(t)}function Ll({containerRef:e,socketRef:t,viewsRef:n}){(0,A.useEffect)(()=>{let r=e.current;if(!r)return;let i=async(e,r)=>{try{let i=await he.pasteImage(r),a=n.current.get(e)?.term.modes.bracketedPasteMode??!1;we(t.current,{type:`input`,pane:e,data:Al(Fl(i),a)})||E.error(`Not connected — the image was not pasted.`)}catch(e){E.error(e instanceof Error?`Could not paste the image: ${e.message}`:`Could not paste the image.`)}},a=(e,t)=>{let n=Pl(t);if(!n)return;let r=Il(e.target);r!==null&&(e.preventDefault(),e.stopPropagation(),i(r,n))},o=e=>a(e,e.clipboardData),s=e=>a(e,e.dataTransfer),c=e=>{Pl(e.dataTransfer)&&e.preventDefault()};return r.addEventListener(`paste`,o,!0),r.addEventListener(`drop`,s,!0),r.addEventListener(`dragover`,c,!0),()=>{r.removeEventListener(`paste`,o,!0),r.removeEventListener(`drop`,s,!0),r.removeEventListener(`dragover`,c,!0)}},[e,t,n])}var Rl=Object.defineProperty,zl=Object.getOwnPropertyDescriptor,Bl=(e,t,n,r)=>{for(var i=r>1?void 0:r?zl(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Rl(t,n,i),i},Vl=(e,t)=>(n,r)=>t(n,r,e),Hl=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?ql.isErrorNoTelemetry(e)?new ql(e.message+` - -`+e.stack):Error(e.message+` - -`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function Ul(e){Gl(e)||Hl.onUnexpectedError(e)}var Wl=`Canceled`;function Gl(e){return e instanceof Kl||e instanceof Error&&e.name===Wl&&e.message===Wl}var Kl=class extends Error{constructor(){super(Wl),this.name=this.message}},ql=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},Jl;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Jl||={});var Yl=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||Jl.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};Yl.empty=new Yl(e=>{});function Xl(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var Zl;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function ru(...e){return iu(()=>nu(e))}function iu(e){let t=$l({dispose:Xl(()=>{eu(t),e()})});return t}var au=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,$l(this)}dispose(){this._isDisposed||(eu(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{nu(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return tu(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),tu(e,null))}};au.DISABLE_DISPOSED_WARNING=!1;var ou=au,su=class{constructor(){this._store=new ou,$l(this),tu(this._store,this)}dispose(){eu(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};su.None=Object.freeze({dispose(){}});var cu=class{constructor(){this._isDisposed=!1,$l(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&tu(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,eu(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&tu(e,null),e}},lu=typeof process<`u`&&`title`in process,uu=lu?`node`:navigator.userAgent,du=lu?`node`:navigator.platform,fu=uu.includes(`Firefox`),pu=uu.includes(`Edge`),mu=/^((?!chrome|android).)*safari/i.test(uu);function hu(){if(!mu)return 0;let e=uu.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(du),[`Windows`,`Win16`,`Win32`,`WinCE`].includes(du),du.indexOf(`Linux`),/\bCrOS\b/.test(uu);var gu=``,_u=0,vu=0,yu=0,J=0,bu={css:`#00000000`,rgba:0},xu;(e=>{function t(e,t,n,r){return r===void 0?`#${Eu(e)}${Eu(t)}${Eu(n)}`:`#${Eu(e)}${Eu(t)}${Eu(n)}${Eu(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(xu||={});var Su;(e=>{function t(e,t){if(J=(t.rgba&255)/255,J===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return _u=a+Math.round((n-a)*J),vu=o+Math.round((r-o)*J),yu=s+Math.round((i-s)*J),{css:xu.toCss(_u,vu,yu),rgba:xu.toRgba(_u,vu,yu)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=Tu.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return xu.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[_u,vu,yu]=Tu.toChannels(t),{css:xu.toCss(_u,vu,yu),rgba:t}}e.opaque=i;function a(e,t){return J=Math.round(t*255),[_u,vu,yu]=Tu.toChannels(e.rgba),{css:xu.toCss(_u,vu,yu,J),rgba:xu.toRgba(_u,vu,yu,J)}}e.opacity=a;function o(e,t){return J=e.rgba&255,a(e,J*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(Su||={});var Cu;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return _u=parseInt(e.slice(1,2).repeat(2),16),vu=parseInt(e.slice(2,3).repeat(2),16),yu=parseInt(e.slice(3,4).repeat(2),16),xu.toColor(_u,vu,yu);case 5:return _u=parseInt(e.slice(1,2).repeat(2),16),vu=parseInt(e.slice(2,3).repeat(2),16),yu=parseInt(e.slice(3,4).repeat(2),16),J=parseInt(e.slice(4,5).repeat(2),16),xu.toColor(_u,vu,yu,J);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return _u=parseInt(r[1]),vu=parseInt(r[2]),yu=parseInt(r[3]),J=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),xu.toColor(_u,vu,yu,J);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[_u,vu,yu,J]=t.getImageData(0,0,1,1).data,J!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:xu.toRgba(_u,vu,yu,J),css:e}}e.toColor=r})(Cu||={});var wu;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(wu||={});var Tu;(e=>{function t(e,t){if(J=(t&255)/255,J===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return _u=a+Math.round((n-a)*J),vu=o+Math.round((r-o)*J),yu=s+Math.round((i-s)*J),xu.toRgba(_u,vu,yu)}e.blend=t;function n(e,t,n){let a=wu.relativeLuminance(e>>8),o=wu.relativeLuminance(t>>8);if(Du(a,o)>8));if(sDu(a,wu.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=Du(a,wu.relativeLuminance(s>>8));if(cDu(a,wu.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Du(wu.relativeLuminance2(o,s,c),wu.relativeLuminance2(r,i,a));for(;l0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=Du(wu.relativeLuminance2(o,s,c),wu.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Du(wu.relativeLuminance2(o,s,c),wu.relativeLuminance2(r,i,a));for(;l>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(Tu||={});function Eu(e){let t=e.toString(16);return t.length<2?`0`+t:t}function Du(e,t){return e=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}function Nu(e,t,n,r){return t===1&&n>Math.ceil(r*1.5)&&e!==void 0&&e>255&&!Mu(e)&&!Ou(e)&&!Au(e)}function Pu(e){return Ou(e)||ju(e)}function Fu(){return{css:{canvas:Iu(),cell:Iu()},device:{canvas:Iu(),cell:Iu(),char:{width:0,height:0,left:0,top:0}}}}function Iu(){return{width:0,height:0}}function Lu(e,t,n=0){return(e-(Math.round(t)*2-n))%(Math.round(t)*2)}var Ru=0,zu=0,Bu=!1,Vu=!1,Hu=!1,Uu,Wu=0,Gu=class{constructor(e,t,n,r,i,a){this._terminal=e,this._optionService=t,this._selectionRenderModel=n,this._decorationService=r,this._coreBrowserService=i,this._themeService=a,this.result={fg:0,bg:0,ext:0}}resolve(e,t,n,r){if(this.result.bg=e.bg,this.result.fg=e.fg,this.result.ext=e.bg&268435456?e.extended.ext:0,zu=0,Ru=0,Vu=!1,Bu=!1,Hu=!1,Uu=this._themeService.colors,Wu=0,e.getCode()!==0&&e.extended.underlineStyle===4){let e=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));Wu=t*r%(Math.round(e)*2)}if(this._decorationService.forEachDecorationAtCell(t,n,`bottom`,e=>{e.backgroundColorRGB&&(zu=e.backgroundColorRGB.rgba>>8&16777215,Vu=!0),e.foregroundColorRGB&&(Ru=e.foregroundColorRGB.rgba>>8&16777215,Bu=!0)}),Hu=this._selectionRenderModel.isCellSelected(this._terminal,t,n),Hu){if(this.result.fg&67108864||this.result.bg&50331648){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:zu=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:zu=(this.result.fg&16777215)<<8|255;break;default:zu=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:zu=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:zu=(this.result.bg&16777215)<<8|255}zu=Tu.blend(zu,(this._coreBrowserService.isFocused?Uu.selectionBackgroundOpaque:Uu.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else zu=(this._coreBrowserService.isFocused?Uu.selectionBackgroundOpaque:Uu.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(Vu=!0,Uu.selectionForeground&&(Ru=Uu.selectionForeground.rgba>>8&16777215,Bu=!0),Pu(e.getCode())){if(this.result.fg&67108864&&!(this.result.bg&50331648))Ru=(this._coreBrowserService.isFocused?Uu.selectionBackgroundOpaque:Uu.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:Ru=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:Ru=(this.result.bg&16777215)<<8|255}else switch(this.result.fg&50331648){case 16777216:case 33554432:Ru=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:Ru=(this.result.fg&16777215)<<8|255;break;default:Ru=this._themeService.colors.foreground.rgba}Ru=Tu.blend(Ru,(this._coreBrowserService.isFocused?Uu.selectionBackgroundOpaque:Uu.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}Bu=!0}}this._decorationService.forEachDecorationAtCell(t,n,`top`,e=>{e.backgroundColorRGB&&(zu=e.backgroundColorRGB.rgba>>8&16777215,Vu=!0),e.foregroundColorRGB&&(Ru=e.foregroundColorRGB.rgba>>8&16777215,Bu=!0)}),Vu&&(zu=Hu?e.bg&-150994944|zu|50331648:e.bg&-16777216|zu|50331648),Bu&&(Ru=e.fg&-83886080|Ru|50331648),this.result.fg&67108864&&(Vu&&!Bu&&(Ru=this.result.bg&50331648?this.result.fg&-134217728|this.result.bg&67108863:this.result.fg&-134217728|Uu.background.rgba>>8&16777215|50331648,Bu=!0),!Vu&&Bu&&(zu=this.result.fg&50331648?this.result.bg&-67108864|this.result.fg&67108863:this.result.bg&-67108864|Uu.foreground.rgba>>8&16777215|50331648,Vu=!0)),Uu=void 0,this.result.bg=Vu?zu:this.result.bg,this.result.fg=Bu?Ru:this.result.fg,this.result.ext&=536870911,this.result.ext|=Wu<<29&3758096384}},Ku=.5,qu=fu||pu?`bottom`:`ideographic`,Ju={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},Yu={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]},Xu={"─":{1:`M0,.5 L1,.5`},"━":{3:`M0,.5 L1,.5`},"│":{1:`M.5,0 L.5,1`},"┃":{3:`M.5,0 L.5,1`},"┌":{1:`M0.5,1 L.5,.5 L1,.5`},"┏":{3:`M0.5,1 L.5,.5 L1,.5`},"┐":{1:`M0,.5 L.5,.5 L.5,1`},"┓":{3:`M0,.5 L.5,.5 L.5,1`},"└":{1:`M.5,0 L.5,.5 L1,.5`},"┗":{3:`M.5,0 L.5,.5 L1,.5`},"┘":{1:`M.5,0 L.5,.5 L0,.5`},"┛":{3:`M.5,0 L.5,.5 L0,.5`},"├":{1:`M.5,0 L.5,1 M.5,.5 L1,.5`},"┣":{3:`M.5,0 L.5,1 M.5,.5 L1,.5`},"┤":{1:`M.5,0 L.5,1 M.5,.5 L0,.5`},"┫":{3:`M.5,0 L.5,1 M.5,.5 L0,.5`},"┬":{1:`M0,.5 L1,.5 M.5,.5 L.5,1`},"┳":{3:`M0,.5 L1,.5 M.5,.5 L.5,1`},"┴":{1:`M0,.5 L1,.5 M.5,.5 L.5,0`},"┻":{3:`M0,.5 L1,.5 M.5,.5 L.5,0`},"┼":{1:`M0,.5 L1,.5 M.5,0 L.5,1`},"╋":{3:`M0,.5 L1,.5 M.5,0 L.5,1`},"╴":{1:`M.5,.5 L0,.5`},"╸":{3:`M.5,.5 L0,.5`},"╵":{1:`M.5,.5 L.5,0`},"╹":{3:`M.5,.5 L.5,0`},"╶":{1:`M.5,.5 L1,.5`},"╺":{3:`M.5,.5 L1,.5`},"╷":{1:`M.5,.5 L.5,1`},"╻":{3:`M.5,.5 L.5,1`},"═":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"║":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╒":{1:(e,t)=>`M.5,1 L.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╓":{1:(e,t)=>`M${.5-e},1 L${.5-e},.5 L1,.5 M${.5+e},.5 L${.5+e},1`},"╔":{1:(e,t)=>`M1,${.5-t} L${.5-e},${.5-t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╕":{1:(e,t)=>`M0,${.5-t} L.5,${.5-t} L.5,1 M0,${.5+t} L.5,${.5+t}`},"╖":{1:(e,t)=>`M${.5+e},1 L${.5+e},.5 L0,.5 M${.5-e},.5 L${.5-e},1`},"╗":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5+e},${.5-t} L${.5+e},1`},"╘":{1:(e,t)=>`M.5,0 L.5,${.5+t} L1,${.5+t} M.5,${.5-t} L1,${.5-t}`},"╙":{1:(e,t)=>`M1,.5 L${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╚":{1:(e,t)=>`M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0 M1,${.5+t} L${.5-e},${.5+t} L${.5-e},0`},"╛":{1:(e,t)=>`M0,${.5+t} L.5,${.5+t} L.5,0 M0,${.5-t} L.5,${.5-t}`},"╜":{1:(e,t)=>`M0,.5 L${.5+e},.5 L${.5+e},0 M${.5-e},.5 L${.5-e},0`},"╝":{1:(e,t)=>`M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M0,${.5+t} L${.5+e},${.5+t} L${.5+e},0`},"╞":{1:(e,t)=>`M.5,0 L.5,1 M.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╟":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1 M${.5+e},.5 L1,.5`},"╠":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╡":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L.5,${.5-t} M0,${.5+t} L.5,${.5+t}`},"╢":{1:(e,t)=>`M0,.5 L${.5-e},.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╣":{1:(e,t)=>`M${.5+e},0 L${.5+e},1 M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0`},"╤":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t} M.5,${.5+t} L.5,1`},"╥":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},1 M${.5+e},.5 L${.5+e},1`},"╦":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╧":{1:(e,t)=>`M.5,0 L.5,${.5-t} M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╨":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╩":{1:(e,t)=>`M0,${.5+t} L1,${.5+t} M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╪":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╫":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╬":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╱":{1:`M1,0 L0,1`},"╲":{1:`M0,0 L1,1`},"╳":{1:`M1,0 L0,1 M0,0 L1,1`},"╼":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"╽":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L.5,1`},"╾":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"╿":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"┍":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L1,.5`},"┎":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┑":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L0,.5`},"┒":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L.5,1`},"┕":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L1,.5`},"┖":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┙":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L0,.5`},"┚":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L.5,0`},"┝":{1:`M.5,0 L.5,1`,3:`M.5,.5 L1,.5`},"┞":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┟":{1:`M.5,0 L.5,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┠":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,1`},"┡":{1:`M.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L1,.5`},"┢":{1:`M.5,.5 L.5,0`,3:`M0.5,1 L.5,.5 L1,.5`},"┥":{1:`M.5,0 L.5,1`,3:`M.5,.5 L0,.5`},"┦":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"┧":{1:`M.5,0 L.5,.5 L0,.5`,3:`M.5,.5 L.5,1`},"┨":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,1`},"┩":{1:`M.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L0,.5`},"┪":{1:`M.5,.5 L.5,0`,3:`M0,.5 L.5,.5 L.5,1`},"┭":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┮":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,.5 L1,.5`},"┯":{1:`M.5,.5 L.5,1`,3:`M0,.5 L1,.5`},"┰":{1:`M0,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┱":{1:`M.5,.5 L1,.5`,3:`M0,.5 L.5,.5 L.5,1`},"┲":{1:`M.5,.5 L0,.5`,3:`M0.5,1 L.5,.5 L1,.5`},"┵":{1:`M.5,0 L.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┶":{1:`M.5,0 L.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"┷":{1:`M.5,.5 L.5,0`,3:`M0,.5 L1,.5`},"┸":{1:`M0,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┹":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,.5 L0,.5`},"┺":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,.5 L1,.5`},"┽":{1:`M.5,0 L.5,1 M.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┾":{1:`M.5,0 L.5,1 M.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"┿":{1:`M.5,0 L.5,1`,3:`M0,.5 L1,.5`},"╀":{1:`M0,.5 L1,.5 M.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"╁":{1:`M.5,.5 L.5,0 M0,.5 L1,.5`,3:`M.5,.5 L.5,1`},"╂":{1:`M0,.5 L1,.5`,3:`M.5,0 L.5,1`},"╃":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,0 L.5,.5 L0,.5`},"╄":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L1,.5`},"╅":{1:`M.5,0 L.5,.5 L1,.5`,3:`M0,.5 L.5,.5 L.5,1`},"╆":{1:`M.5,0 L.5,.5 L0,.5`,3:`M0.5,1 L.5,.5 L1,.5`},"╇":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L.5,0 M0,.5 L1,.5`},"╈":{1:`M.5,.5 L.5,0`,3:`M0,.5 L1,.5 M.5,.5 L.5,1`},"╉":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,1 M.5,.5 L0,.5`},"╊":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,1 M.5,.5 L1,.5`},"╌":{1:`M.1,.5 L.4,.5 M.6,.5 L.9,.5`},"╍":{3:`M.1,.5 L.4,.5 M.6,.5 L.9,.5`},"┄":{1:`M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5`},"┅":{3:`M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5`},"┈":{1:`M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5`},"┉":{3:`M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5`},"╎":{1:`M.5,.1 L.5,.4 M.5,.6 L.5,.9`},"╏":{3:`M.5,.1 L.5,.4 M.5,.6 L.5,.9`},"┆":{1:`M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333`},"┇":{3:`M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333`},"┊":{1:`M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95`},"┋":{3:`M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95`},"╭":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,1,.5`},"╮":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,0,.5`},"╯":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,0,.5`},"╰":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,1,.5`}},Zu={"":{d:`M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655`,type:0},"":{d:`M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5`,type:0},"":{d:`M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82`,type:0},"":{d:`M0,0 L1,.5 L0,1`,type:0,rightPadding:2},"":{d:`M-1,-.5 L1,.5 L-1,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M1,0 L0,.5 L1,1`,type:0,leftPadding:2},"":{d:`M2,-.5 L0,.5 L2,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0`,type:0,rightPadding:1},"":{d:`M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0`,type:1,rightPadding:1},"":{d:`M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0`,type:0,leftPadding:1},"":{d:`M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0`,type:1,leftPadding:1},"":{d:`M-.5,-.5 L1.5,1.5 L-.5,1.5`,type:0},"":{d:`M-.5,-.5 L1.5,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M1.5,-.5 L-.5,1.5 L1.5,1.5`,type:0},"":{d:`M1.5,-.5 L-.5,1.5 L-.5,-.5`,type:0},"":{d:`M1.5,-.5 L-.5,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M-.5,-.5 L1.5,1.5 L1.5,-.5`,type:0}};Zu[``]=Zu[``],Zu[``]=Zu[``];function Qu(e,t,n,r,i,a,o,s){let c=Ju[t];if(c)return $u(e,c,n,r,i,a),!0;let l=Yu[t];if(l)return td(e,l,n,r,i,a),!0;let u=Xu[t];if(u)return nd(e,u,n,r,i,a,s),!0;let d=Zu[t];return d?(rd(e,d,n,r,i,a,o,s),!0):!1}function $u(e,t,n,r,i,a){for(let o=0;o7&&parseInt(s.slice(7,9),16)||1;else if(s.startsWith(`rgba`))[u,d,f,p]=s.substring(5,s.length-1).split(`,`).map(e=>parseFloat(e));else throw Error(`Unexpected fillStyle color format "${s}" when drawing pattern glyph`);for(let e=0;ee.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]),L:(e,t)=>e.lineTo(t[0],t[1]),M:(e,t)=>e.moveTo(t[0],t[1])};function od(e,t,n,r,i,a,o,s=0,c=0){let l=e.map(e=>parseFloat(e)||parseInt(e));if(l.length<2)throw Error(`Too few arguments for instruction`);for(let e=0;ei){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},ud=class extends ld{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},dd=class extends ld{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},fd=!lu&&`requestIdleCallback`in window?dd:ud,pd=class e{constructor(){this.fg=0,this.bg=0,this.extended=new md}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},md=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},hd=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};hd.Undefined=new hd(void 0);var gd=globalThis.performance&&typeof globalThis.performance.now==`function`,_d=class e{static create(t){return new e(t)}constructor(e){this._now=gd&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},vd;(e=>{e.None=()=>su.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(ru(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new X({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new X({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new X({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new X({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new X({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function ee(e){let t=new X;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=ee;function te(e,t){return e(e=>t.fire(e))}e.forward=te;function S(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=S;class C{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new X(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function w(e,t){return new C(e,t).emitter.event}e.fromObservable=w;function T(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof ou?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=T})(vd||={});var yd=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new _d,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};yd.all=new Set,yd._idPool=0;var bd=yd,xd=-1,Sd=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t0||this._options?.leakWarningThreshold?new Cd(e?.onListenerError??Ul,this._options?.leakWarningThreshold??xd):void 0,this._perfMon=this._options?._profName?new bd(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new Ed(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||Ul)(n),su.None}if(this._disposed)return su.None;t&&(e=e.bind(t));let r=new Od(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=wd.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof Od?(this._deliveryQueue??=new Ad,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=iu(()=>{i?.(),this._removeListener(r)});return n instanceof ou?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*kd<=t.length){let e=0;for(let n=0;n0}},Ad=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},jd={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},Md=2,Nd,Pd=class e{constructor(e,t,n){this._document=e,this._config=t,this._unicodeService=n,this._didWarmUp=!1,this._cacheMap=new cd,this._cacheMapCombined=new cd,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new pd,this._textureSize=512,this._onAddTextureAtlasCanvas=new X,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new X,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=Rd(e,this._config.deviceCellWidth*4+Md*2,this._config.deviceCellHeight+Md*2),this._tmpCtx=Y(this._tmpCanvas.getContext(`2d`,{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||=(this._doWarmUp(),!0)}_doWarmUp(){let e=new fd;for(let t=33;t<126;t++)e.enqueue(()=>{if(!this._cacheMap.get(t,0,0,0)){let e=this._drawToCache(t,0,0,0,!1,void 0);this._cacheMap.set(t,0,0,0,e)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(this._pages[0].currentRow.x!==0||this._pages[0].currentRow.y!==0){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(e.maxAtlasPages&&this._pages.length>=Math.max(4,e.maxAtlasPages)){let t=this._pages.filter(t=>t.canvas.width*2<=(e.maxTextureSize||4096)).sort((e,t)=>t.canvas.width===e.canvas.width?t.percentageUsed-e.percentageUsed:t.canvas.width-e.canvas.width),n=-1,r=0;for(let e=0;ee.glyphs[0].texturePage).sort((e,t)=>e>t?1:-1),o=this.pages.length-i.length,s=this._mergePages(i,o);s.version++;for(let e=a.length-1;e>=0;e--)this._deletePage(a[e]);this.pages.push(s),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(s.canvas)}let t=new Fd(this._document,this._textureSize);return this._pages.push(t),this._activePages.push(t),this._onAddTextureAtlasCanvas.fire(t.canvas),t}_mergePages(e,t){let n=e[0].canvas.width*2,r=new Fd(this._document,n,e);for(let[i,a]of e.entries()){let e=i*a.canvas.width%n,o=Math.floor(i/2)*a.canvas.height;r.ctx.drawImage(a.canvas,e,o);for(let r of a.glyphs)r.texturePage=t,r.sizeClipSpace.x=r.size.x/n,r.sizeClipSpace.y=r.size.y/n,r.texturePosition.x+=e,r.texturePosition.y+=o,r.texturePositionClipSpace.x=r.texturePosition.x/n,r.texturePositionClipSpace.y=r.texturePosition.y/n;this._onRemoveTextureAtlasCanvas.fire(a.canvas);let s=this._activePages.indexOf(a);s!==-1&&this._activePages.splice(s,1)}return r}_deletePage(e){this._pages.splice(e,1);for(let t=e;t=this._config.colors.ansi.length)throw Error(`No color found for idx `+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,t,n,r){if(this._config.allowTransparency)return bu;let i;switch(e){case 16777216:case 33554432:i=this._getColorFromAnsiIndex(t);break;case 50331648:let e=pd.toColorRGB(t);i=xu.toColor(e[0],e[1],e[2]);break;default:i=n?Su.opaque(this._config.colors.foreground):this._config.colors.background}return this._config.allowTransparency||(i=Su.opaque(i)),i}_getForegroundColor(e,t,n,r,i,a,o,s,c,l){let u=this._getMinimumContrastColor(e,t,n,r,i,a,o,c,s,l);if(u)return u;let d;switch(i){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&c&&a<8&&(a+=8),d=this._getColorFromAnsiIndex(a);break;case 50331648:let e=pd.toColorRGB(a);d=xu.toColor(e[0],e[1],e[2]);break;default:d=o?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(d=Su.opaque(d)),s&&(d=Su.multiplyOpacity(d,Ku)),d}_resolveBackgroundRgba(e,t,n){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return n?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,t,n,r){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&r&&t<8&&(t+=8),this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return n?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,t,n,r,i,a,o,s,c,l){if(this._config.minimumContrastRatio===1||l)return;let u=this._getContrastCache(c),d=u.getColor(e,r);if(d!==void 0)return d||void 0;let f=this._resolveBackgroundRgba(t,n,o),p=this._resolveForegroundRgba(i,a,o,s),m=Tu.ensureContrastRatio(f,p,this._config.minimumContrastRatio/(c?2:1));if(!m){u.setColor(e,r,null);return}let h=xu.toColor(m>>24&255,m>>16&255,m>>8&255);return u.setColor(e,r,h),h}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(t,n,r,i,a,o){let s=typeof t==`number`?String.fromCharCode(t):t;o&&this._tmpCanvas.parentElement!==o&&(this._tmpCanvas.style.display=`none`,o.append(this._tmpCanvas));let c=Math.min(this._config.deviceCellWidth*Math.max(s.length,2)+Md*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width=e?e*2-c:e-c;c>=e||f===0?(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(s+f,r),this._tmpCtx.lineTo(l,r)):(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(s+f,r),this._tmpCtx.moveTo(s+f+e,r),this._tmpCtx.lineTo(l,r)),c=Lu(l-s,e,c);break;case 5:let p=l-s,m=Math.floor(.6*p),h=Math.floor(.3*p),g=p-m-h;this._tmpCtx.setLineDash([m,h,g]),this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(l,r);break;default:this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(l,r)}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!ne&&this._config.fontSize>=12&&!this._config.allowTransparency&&s!==` `){this._tmpCtx.save(),this._tmpCtx.textBaseline=`alphabetic`;let t=this._tmpCtx.measureText(s);if(this._tmpCtx.restore(),`actualBoundingBoxDescent`in t&&t.actualBoundingBoxDescent>0){this._tmpCtx.save();let t=new Path2D;t.rect(n,r-Math.ceil(e/2),this._config.deviceCellWidth*re,o-r+Math.ceil(e/2)),this._tmpCtx.clip(t),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=x.css,this._tmpCtx.strokeText(s,T,T+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(g){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(T,T+t),this._tmpCtx.lineTo(T+this._config.deviceCharWidth*re,T+t),this._tmpCtx.stroke()}if(ne||this._tmpCtx.fillText(s,T,T+this._config.deviceCharHeight),s===`_`&&!this._config.allowTransparency){let e=Id(this._tmpCtx.getImageData(T,T,this._config.deviceCellWidth,this._config.deviceCellHeight),x,w,E);if(e)for(let t=1;t<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=x.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(s,T,T+this._config.deviceCharHeight-t),e=Id(this._tmpCtx.getImageData(T,T,this._config.deviceCellWidth,this._config.deviceCellHeight),x,w,E),e);t++);}if(h){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),t=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(T,T+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.lineTo(T+this._config.deviceCharWidth*re,T+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.stroke()}this._tmpCtx.restore();let ie=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),ae;if(ae=this._config.allowTransparency?Ld(ie):Id(ie,x,w,E),ae)return jd;let D=this._findGlyphBoundingBox(ie,this._workBoundingBox,c,C,ne,T),O,k;for(;;){if(this._activePages.length===0){let e=this._createNewPage();O=e,k=e.currentRow,k.height=D.size.y;break}O=this._activePages[this._activePages.length-1],k=O.currentRow;for(let e of this._activePages)D.size.y<=e.currentRow.height&&(O=e,k=e.currentRow);for(let e=this._activePages.length-1;e>=0;e--)for(let t of this._activePages[e].fixedRows)t.height<=k.height&&D.size.y<=t.height&&(O=this._activePages[e],k=t);if(D.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new Fd(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),O=this._overflowSizePage,k=this._overflowSizePage.currentRow,k.x+D.size.x>=O.canvas.width&&(k.x=0,k.y+=k.height,k.height=0);break}if(k.y+D.size.y>=O.canvas.height||k.height>D.size.y+2){let t=!1;if(O.currentRow.y+O.currentRow.height+D.size.y>=O.canvas.height){let n;for(let e of this._activePages)if(e.currentRow.y+e.currentRow.height+D.size.y=e.maxAtlasPages&&k.y+D.size.y<=O.canvas.height&&k.height>=D.size.y&&k.x+D.size.x<=O.canvas.width)t=!0;else{let e=this._createNewPage();O=e,k=e.currentRow,k.height=D.size.y,t=!0}}t||(O.currentRow.height>0&&O.fixedRows.push(O.currentRow),k={x:0,y:O.currentRow.y+O.currentRow.height,height:D.size.y},O.fixedRows.push(k),O.currentRow={x:0,y:k.y+k.height,height:0})}if(k.x+D.size.x<=O.canvas.width)break;k===O.currentRow?(k.x=0,k.y+=k.height,k.height=0):O.fixedRows.splice(O.fixedRows.indexOf(k),1)}return D.texturePage=this._pages.indexOf(O),D.texturePosition.x=k.x,D.texturePosition.y=k.y,D.texturePositionClipSpace.x=k.x/O.canvas.width,D.texturePositionClipSpace.y=k.y/O.canvas.height,D.sizeClipSpace.x/=O.canvas.width,D.sizeClipSpace.y/=O.canvas.height,k.height=Math.max(k.height,D.size.y),k.x+=D.size.x,O.ctx.putImageData(ie,D.texturePosition.x-this._workBoundingBox.left,D.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,D.size.x,D.size.y),O.addGlyph(D),O.version++,D}_findGlyphBoundingBox(e,t,n,r,i,a){t.top=0;let o=r?this._config.deviceCellHeight:this._tmpCanvas.height,s=r?this._config.deviceCellWidth:n,c=!1;for(let n=0;n=a;n--){for(let r=0;r=0;n--){for(let r=0;r>>24,a=t.rgba>>>16&255,o=t.rgba>>>8&255,s=n.rgba>>>24,c=n.rgba>>>16&255,l=n.rgba>>>8&255,u=Math.floor((Math.abs(i-s)+Math.abs(a-c)+Math.abs(o-l))/12),d=!0;for(let t=0;t0)return!1;return!0}function Rd(e,t,n){let r=e.createElement(`canvas`);return r.width=t,r.height=n,r}function zd(e,t,n,r,i,a,o,s){let c={foreground:a.foreground,background:a.background,cursor:bu,cursorAccent:bu,selectionForeground:bu,selectionBackgroundTransparent:bu,selectionBackgroundOpaque:bu,selectionInactiveBackgroundTransparent:bu,selectionInactiveBackgroundOpaque:bu,overviewRulerBorder:bu,scrollbarSliderBackground:bu,scrollbarSliderHoverBackground:bu,scrollbarSliderActiveBackground:bu,ansi:a.ansi.slice(),contrastCache:a.contrastCache,halfContrastCache:a.halfContrastCache};return{customGlyphs:i.customGlyphs,devicePixelRatio:o,deviceMaxTextureSize:s,letterSpacing:i.letterSpacing,lineHeight:i.lineHeight,deviceCellWidth:e,deviceCellHeight:t,deviceCharWidth:n,deviceCharHeight:r,fontFamily:i.fontFamily,fontSize:i.fontSize,fontWeight:i.fontWeight,fontWeightBold:i.fontWeightBold,allowTransparency:i.allowTransparency,drawBoldTextInBrightColors:i.drawBoldTextInBrightColors,minimumContrastRatio:i.minimumContrastRatio,colors:c}}function Bd(e,t){for(let n=0;n=0){if(Bd(n.config,l))return n.atlas;n.ownedBy.length===1?(n.atlas.dispose(),Hd.splice(t,1)):n.ownedBy.splice(r,1);break}}for(let t=0;t{this._renderCallback(),this._animationFrame=void 0}))}_restartInterval(e=Gd){this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=Gd-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0){this._restartInterval(e);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let e=Gd-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e)}else this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},Gd)},e)}pause(){this.isCursorVisible=!0,this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout&&=(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),void 0),this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}};function qd(e,t,n){let r=new t.ResizeObserver(t=>{let i=t.find(t=>t.target===e);if(!i)return;if(!(`devicePixelContentBoxSize`in i)){r?.disconnect(),r=void 0;return}let a=i.devicePixelContentBoxSize[0].inlineSize,o=i.devicePixelContentBoxSize[0].blockSize;a>0&&o>0&&n(a,o)});try{r.observe(e,{box:[`device-pixel-content-box`]})}catch{r.disconnect(),r=void 0}return iu(()=>r?.disconnect())}function Jd(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}var Yd=class e extends pd{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new md,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Jd(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Xd=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function Zd(e,t,n){let r=Y(e.createProgram());if(e.attachShader(r,Y(Qd(e,e.VERTEX_SHADER,t))),e.attachShader(r,Y(Qd(e,e.FRAGMENT_SHADER,n))),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS))return r;console.error(e.getProgramInfoLog(r)),e.deleteProgram(r)}function Qd(e,t,n){let r=Y(e.createShader(t));if(e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS))return r;console.error(e.getShaderInfoLog(r)),e.deleteShader(r)}function $d(e,t){let n=Math.min(e.length*2,t),r=new Float32Array(n);for(let t=0;ti.deleteProgram(this._program))),this._projectionLocation=Y(i.getUniformLocation(this._program,`u_projection`)),this._resolutionLocation=Y(i.getUniformLocation(this._program,`u_resolution`)),this._textureLocation=Y(i.getUniformLocation(this._program,`u_texture`)),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),o=i.createBuffer();this._register(iu(()=>i.deleteBuffer(o))),i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,a,i.STATIC_DRAW),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let s=new Uint8Array([0,1,2,3]),c=i.createBuffer();this._register(iu(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=Y(i.createBuffer()),this._register(iu(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,2,i.FLOAT,!1,af,0),i.vertexAttribDivisor(2,1),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,i.FLOAT,!1,af,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(3,1),i.enableVertexAttribArray(4),i.vertexAttribPointer(4,1,i.FLOAT,!1,af,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(4,1),i.enableVertexAttribArray(5),i.vertexAttribPointer(5,2,i.FLOAT,!1,af,5*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(5,1),i.enableVertexAttribArray(6),i.vertexAttribPointer(6,2,i.FLOAT,!1,af,7*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(6,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,af,9*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.useProgram(this._program);let l=new Int32Array(Pd.maxAtlasPages);for(let e=0;ei.deleteTexture(t.texture))),i.activeTexture(i.TEXTURE0+e),i.bindTexture(i.TEXTURE_2D,t.texture),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[e]=t}i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return!this._atlas||this._atlas.beginFrame()}updateCell(e,t,n,r,i,a,o,s,c){this._updateCell(this._vertices.attributes,e,t,n,r,i,a,o,s,c)}_updateCell(e,t,n,r,i,a,o,s,c,l){Z=(n*this._terminal.cols+t)*rf,r===0||r===void 0?e.fill(0,Z,Z+rf-1-of):this._atlas&&(Q=s&&s.length>1?this._atlas.getRasterizedGlyphCombinedChar(s,i,a,o,!1,this._terminal.element):this._atlas.getRasterizedGlyph(r,i,a,o,!1,this._terminal.element),sf=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),i!==l&&Q.offset.x>sf?(cf=Q.offset.x-sf,e[Z]=-(Q.offset.x-cf)+this._dimensions.device.char.left,e[Z+1]=-Q.offset.y+this._dimensions.device.char.top,e[Z+2]=(Q.size.x-cf)/this._dimensions.device.canvas.width,e[Z+3]=Q.size.y/this._dimensions.device.canvas.height,e[Z+4]=Q.texturePage,e[Z+5]=Q.texturePositionClipSpace.x+cf/this._atlas.pages[Q.texturePage].canvas.width,e[Z+6]=Q.texturePositionClipSpace.y,e[Z+7]=Q.sizeClipSpace.x-cf/this._atlas.pages[Q.texturePage].canvas.width,e[Z+8]=Q.sizeClipSpace.y):(e[Z]=-Q.offset.x+this._dimensions.device.char.left,e[Z+1]=-Q.offset.y+this._dimensions.device.char.top,e[Z+2]=Q.size.x/this._dimensions.device.canvas.width,e[Z+3]=Q.size.y/this._dimensions.device.canvas.height,e[Z+4]=Q.texturePage,e[Z+5]=Q.texturePositionClipSpace.x,e[Z+6]=Q.texturePositionClipSpace.y,e[Z+7]=Q.sizeClipSpace.x,e[Z+8]=Q.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&Nu(r,c,Q.size.x,this._dimensions.device.cell.width)&&(e[Z+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let e=this._terminal,t=e.cols*e.rows*rf;this._vertices.count===t?this._vertices.attributes.fill(0):this._vertices.attributes=new Float32Array(t);let n=0;for(;n=e.rows||c<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0])}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n=this.startCol&&t=this.startCol):!1}};function df(){return new uf}var ff=4,pf=1,mf=2,hf=3,gf=2147483648,_f=class{constructor(){this.cells=new Uint32Array,this.lineLengths=new Uint32Array,this.selection=df()}resize(e,t){let n=e*t*ff;n!==this.cells.length&&(this.cells=new Uint32Array(n),this.lineLengths=new Uint32Array(t))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},vf=`#version 300 es -layout (location = 0) in vec2 a_position; -layout (location = 1) in vec2 a_size; -layout (location = 2) in vec4 a_color; -layout (location = 3) in vec2 a_unitquad; - -uniform mat4 u_projection; - -out vec4 v_color; - -void main() { - vec2 zeroToOne = a_position + (a_unitquad * a_size); - gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0); - v_color = a_color; -}`,yf=`#version 300 es -precision lowp float; - -in vec4 v_color; - -out vec4 outColor; - -void main() { - outColor = v_color; -}`,bf=8,xf=bf*Float32Array.BYTES_PER_ELEMENT,Sf=20*bf,Cf=class{constructor(){this.attributes=new Float32Array(Sf),this.count=0}},wf=0,Tf=0,Ef=0,Df=0,Of=0,kf=0,Af=0,jf=class extends su{constructor(e,t,n,r){super(),this._terminal=e,this._gl=t,this._dimensions=n,this._themeService=r,this._vertices=new Cf,this._verticesCursor=new Cf;let i=this._gl;this._program=Y(Zd(i,vf,yf)),this._register(iu(()=>i.deleteProgram(this._program))),this._projectionLocation=Y(i.getUniformLocation(this._program,`u_projection`)),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),o=i.createBuffer();this._register(iu(()=>i.deleteBuffer(o))),i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,a,i.STATIC_DRAW),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let s=new Uint8Array([0,1,2,3]),c=i.createBuffer();this._register(iu(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=Y(i.createBuffer()),this._register(iu(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,xf,0),i.vertexAttribDivisor(0,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,xf,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,4,i.FLOAT,!1,xf,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(2,1),this._updateCachedColors(r.colors),this._register(this._themeService.onChangeColors(e=>{this._updateCachedColors(e),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(e){let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),t.uniformMatrix4fv(this._projectionLocation,!1,Xd),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,e.attributes,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,e.count)}handleResize(){this._updateViewportRectangle()}setDimensions(e){this._dimensions=e}_updateCachedColors(e){this._bgFloat=this._colorToFloat32Array(e.background),this._cursorFloat=this._colorToFloat32Array(e.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(e){let t=this._terminal,n=this._vertices,r=1,i,a,o,s,c,l,u,d,f,p,m;for(i=0;i>24&255)/255,Of=(wf>>16&255)/255,kf=(wf>>8&255)/255,Af=1,this._addRectangle(e.attributes,t,Tf,Ef,(a-i)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,Df,Of,kf,Af)}_addRectangle(e,t,n,r,i,a,o,s,c,l){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o,e[t+5]=s,e[t+6]=c,e[t+7]=l}_addRectangleFloat(e,t,n,r,i,a,o){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o[0],e[t+5]=o[1],e[t+6]=o[2],e[t+7]=o[3]}_colorToFloat32Array(e){return new Float32Array([(e.rgba>>24&255)/255,(e.rgba>>16&255)/255,(e.rgba>>8&255)/255,(e.rgba&255)/255])}},Mf=class extends su{constructor(e,t,n,r,i,a,o,s){super(),this._container=t,this._alpha=i,this._coreBrowserService=a,this._optionsService=o,this._themeService=s,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-${n}-layer`),this._canvas.style.zIndex=r.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(t=>{this._refreshCharAtlas(e,t),this.reset(e)})),this._register(iu(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=Y(this._canvas.getContext(`2d`,{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(e){}handleFocus(e){}handleCursorMove(e){}handleGridChanged(e,t,n){}handleSelectionChanged(e,t,n,r=!1){}_setTransparency(e,t){if(t===this._alpha)return;let n=this._canvas;this._alpha=t,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,n),this._refreshCharAtlas(e,this._themeService.colors),this.handleGridChanged(e,0,e.rows-1)}_refreshCharAtlas(e,t){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=Ud(e,this._optionsService.rawOptions,t,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(e,t){this._deviceCellWidth=t.device.cell.width,this._deviceCellHeight=t.device.cell.height,this._deviceCharWidth=t.device.char.width,this._deviceCharHeight=t.device.char.height,this._deviceCharLeft=t.device.char.left,this._deviceCharTop=t.device.char.top,this._canvas.width=t.device.canvas.width,this._canvas.height=t.device.canvas.height,this._canvas.style.width=`${t.css.canvas.width}px`,this._canvas.style.height=`${t.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(e,this._themeService.colors)}_fillBottomLineAtCells(e,t,n=1){this._ctx.fillRect(e*this._deviceCellWidth,(t+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,n*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(e,t,n,r){this._alpha?this._ctx.clearRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight))}_fillCharTrueColor(e,t,n,r){this._ctx.font=this._getFont(e,!1,!1),this._ctx.textBaseline=qu,this._clipCell(n,r,t.getWidth()),this._ctx.fillText(t.getChars(),n*this._deviceCellWidth+this._deviceCharLeft,r*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(e,t,n){this._ctx.beginPath(),this._ctx.rect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(e,t,n){let r=t?e.options.fontWeightBold:e.options.fontWeight;return`${n?`italic`:``} ${r} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}},Nf=class extends Mf{constructor(e,t,n,r,i,a,o){super(n,e,`link`,t,!0,i,a,o),this._register(r.onShowLinkUnderline(e=>this._handleShowLinkUnderline(e))),this._register(r.onHideLinkUnderline(e=>this._handleHideLinkUnderline(e)))}resize(e,t){super.resize(e,t),this._state=void 0}reset(e){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let e=this._state.y2-this._state.y1-1;e>0&&this._clearCells(0,this._state.y1+1,this._state.cols,e),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(e){if(e.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:e.fg!==void 0&&Vd(e.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[e.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,e.y1===e.y2)this._fillBottomLineAtCells(e.x1,e.y1,e.x2-e.x1);else{this._fillBottomLineAtCells(e.x1,e.y1,e.cols-e.x1);for(let t=e.y1+1;t=0;!(Rf.indexOf(`Chrome`)>=0)&&Rf.indexOf(`Safari`),Rf.indexOf(`Electron/`),Rf.indexOf(`Android`);var Bf=!1;if(typeof Pf.matchMedia==`function`){let e=Pf.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=Pf.matchMedia(`(display-mode: fullscreen)`);Bf=e.matches,Lf(Pf,e,({matches:e})=>{Bf&&t.matches||(Bf=e)})}function Vf(){return Bf}var Hf=`en`,Uf=!1,Wf=!1,Gf=!1,Kf=Hf,qf,Jf=globalThis,Yf;typeof Jf.vscode<`u`&&typeof Jf.vscode.process<`u`?Yf=Jf.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(Yf=process);var Xf=typeof Yf?.versions?.electron==`string`&&Yf?.type===`renderer`;if(typeof Yf==`object`){Yf.platform,Yf.platform,Uf=Yf.platform===`linux`,Uf&&Yf.env.SNAP&&Yf.env.SNAP_REVISION,Yf.env.CI||Yf.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Kf=Hf;let e=Yf.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,Kf=t.resolvedLanguage||Hf,t.languagePack?.translationsConfigFile}catch{}Wf=!0}else typeof navigator==`object`&&!Xf?(qf=navigator.userAgent,qf.indexOf(`Windows`),qf.indexOf(`Macintosh`),(qf.indexOf(`Macintosh`)>=0||qf.indexOf(`iPad`)>=0||qf.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,Uf=qf.indexOf(`Linux`)>=0,qf?.indexOf(`Mobi`),Gf=!0,Kf=globalThis._VSCODE_NLS_LANGUAGE||Hf,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var Zf=Wf;Gf&&typeof Jf.importScripts==`function`&&Jf.origin;var Qf=qf,$f=Kf,ep;(e=>{function t(){return $f}e.value=t;function n(){return $f.length===2?$f===`en`:$f.length>=3&&$f[0]===`e`&&$f[1]===`n`&&$f[2]===`-`}e.isDefaultVariant=n;function r(){return $f===`en`}e.isDefault=r})(ep||={});var tp=typeof Jf.postMessage==`function`&&!Jf.importScripts;(()=>{if(tp){let e=[];Jf.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n{let r=++t;e.push({id:r,callback:n}),Jf.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var np=!!(Qf&&Qf.indexOf(`Chrome`)>=0);Qf&&Qf.indexOf(`Firefox`),!np&&Qf&&Qf.indexOf(`Safari`),Qf&&Qf.indexOf(`Edg/`),Qf&&Qf.indexOf(`Android`);var rp=typeof navigator==`object`?navigator:{};Zf||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||rp&&rp.clipboard&&rp.clipboard.writeText,Zf||rp&&rp.clipboard&&rp.clipboard.readText,Zf||Vf()||rp.keyboard,`ontouchstart`in Pf||rp.maxTouchPoints,Pf.PointerEvent&&(`ontouchstart`in Pf||navigator.maxTouchPoints);var ip=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},ap=new ip,op=new ip,sp=new ip;Array(230);var cp;(e=>{function t(e){return ap.keyCodeToStr(e)}e.toString=t;function n(e){return ap.strToKeyCode(e)}e.fromString=n;function r(e){return op.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return sp.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return op.strToKeyCode(e)||sp.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return ap.keyCodeToStr(e)}e.toElectronAccelerator=o})(cp||={});var lp=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),up;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof dp?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:vd.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:lp})})(up||={});var dp=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?lp:(this._emitter||=new X,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var fp;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(fp||={});var pp=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new X,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};pp.EMPTY=pp.fromArray([]);function mp(e){return hp(e,0)}function hp(e,t){switch(typeof e){case`object`:return e===null?gp(349,t):Array.isArray(e)?yp(e,t):bp(e,t);case`string`:return vp(e,t);case`boolean`:return _p(e,t);case`number`:return gp(e,t);case`undefined`:return gp(937,t);default:return gp(617,t)}}function gp(e,t){return(t<<5)-t+e|0}function _p(e,t){return gp(e?433:863,t)}function vp(e,t){t=gp(149417,t);for(let n=0,r=e.length;nhp(t,e),t)}function bp(e,t){return t=gp(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=vp(n,t),hp(e[n],t)),t)}var{registerWindow:xp,getWindow:Sp,getDocument:Cp,getWindows:wp,getWindowsCount:Tp,getWindowId:Ep,getWindowById:Dp,hasWindow:Op,onDidRegisterWindow:kp,onWillUnregisterWindow:Ap,onDidUnregisterWindow:jp}=function(){let e=new Map,t={window:Pf,disposables:new ou};e.set(Pf.vscodeWindowId,t);let n=new X,r=new X,i=new X;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return su.None;let a=new ou,o={window:t,disposables:a.add(new ou)};return e.set(t.vscodeWindowId,o),a.add(iu(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(Np(t,Fp.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:Pf},getDocument(e){return Sp(e).document}}}(),Mp=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function Np(e,t,n,r){return new Mp(e,t,n,r)}var Pp=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};Pp.None=new Pp(0,0),new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=mp(n),a=r.get(i);if(a)a.users+=1;else{let o=new X,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(iu(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var Fp={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:zf?`webkitAnimationStart`:`animationstart`,ANIMATION_END:zf?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:zf?`webkitAnimationIteration`:`animationiteration`},Ip=class extends su{constructor(e,t,n,r,i,a,o,s,c){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._optionsService=o,this._themeService=s,this._cursorBlinkStateManager=new cu,this._charAtlasDisposable=this._register(new cu),this._observerDisposable=this._register(new cu),this._model=new _f,this._workCell=new Yd,this._workCell2=new Yd,this._rectangleRenderer=this._register(new cu),this._glyphRenderer=this._register(new cu),this._onChangeTextureAtlas=this._register(new X),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new X),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new X),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new X),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new X),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`);let l={antialias:!1,depth:!1,preserveDrawingBuffer:c};if(this._gl=this._canvas.getContext(`webgl2`,l),!this._gl)throw Error(`WebGL2 not supported `+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new Gu(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new Nf(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions=Fu(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(o.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(Np(this._canvas,`webglcontextlost`,e=>{console.log(`webglcontextlost event received`),e.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn(`webgl context not restored; firing onContextLoss`),this._onContextLoss.fire(e)},3e3)})),this._register(Np(this._canvas,`webglcontextrestored`,e=>{console.warn(`webglcontextrestored event received`),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,Wd(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=qd(this._canvas,this._coreBrowserService.window,(e,t)=>this._setCanvasDevicePixelDimensions(e,t)),this._register(this._coreBrowserService.onWindowChange(e=>{this._observerDisposable.value=qd(this._canvas,e,(e,t)=>this._setCanvasDevicePixelDimensions(e,t))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(iu(()=>{for(let e of this._renderLayers)e.dispose();this._canvas.parentElement?.removeChild(this._canvas),Wd(this._terminal)}))}get textureAtlas(){return this._charAtlas?.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(e,t){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let e of this._renderLayers)e.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,this._rectangleRenderer.value?.setDimensions(this.dimensions),this._rectangleRenderer.value?.handleResize(),this._glyphRenderer.value?.setDimensions(this.dimensions),this._glyphRenderer.value?.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){for(let e of this._renderLayers)e.handleBlur(this._terminal);this._cursorBlinkStateManager.value?.pause(),this._requestRedrawViewport()}handleFocus(){for(let e of this._renderLayers)e.handleFocus(this._terminal);this._cursorBlinkStateManager.value?.resume(),this._requestRedrawViewport()}handleSelectionChanged(e,t,n){for(let r of this._renderLayers)r.handleSelectionChanged(this._terminal,e,t,n);this._model.selection.update(this._core,e,t,n),this._requestRedrawViewport()}handleCursorMove(){for(let e of this._renderLayers)e.handleCursorMove(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new jf(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new lf(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let e=Ud(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize);this._charAtlas!==e&&(this._onChangeTextureAtlas.fire(e.pages[0].canvas),this._charAtlasDisposable.value=ru(vd.forward(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),vd.forward(e.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=e,this._charAtlas.warmUp(),this._glyphRenderer.value?.setAtlas(this._charAtlas)}_clearModel(e){this._model.clear(),e&&this._glyphRenderer.value?.clear()}clearTextureAtlas(){this._charAtlas?.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(e,t){if(!this._isAttached){if(this._core.screenElement?.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return}for(let n of this._renderLayers)n.handleGridChanged(this._terminal,e,t);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(e,t),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new Kd(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let n=this._core,r=this._workCell,i,a,o,s,c,l,u=0,d=!0,f,p,m,h,g,_,v,y,b;e=Rp(e,n.rows-1,0),t=Rp(t,n.rows-1,0);let x=this._coreService.decPrivateModes.cursorStyle??n.options.cursorStyle??`block`,ee=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,te=ee-n.buffer.ydisp,S=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),C=-1,w=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let T=!1;for(a=e;a<=t;a++)for(o=a+n.buffer.ydisp,s=n.buffer.lines.get(o),this._model.lineLengths[a]=0,m=ee===o,u=0,c=this._characterJoinerService.getJoinedCharacters(o),y=0;y=u,f=y,c.length>0&&y===c[0][0]&&d){p=c.shift();let e=this._model.selection.isCellSelected(this._terminal,p[0],o);for(v=p[0]+1;v=p[1],d?(l=!0,r=new Lp(r,s.translateToString(!0,p[0],p[1]),p[1]-p[0]),f=p[1]-1):u=p[1]}if(h=r.getChars(),g=r.getCode(),v=(a*n.cols+y)*ff,this._cellColorResolver.resolve(r,y,o,this.dimensions.device.cell.width),w&&o===ee&&(y===S&&(this._model.cursor={x:S,y:te,width:r.getWidth(),style:this._coreBrowserService.isFocused?x:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},C=S+r.getWidth()-1),y>=S&&y<=C&&(this._coreBrowserService.isFocused&&x===`block`||this._coreBrowserService.isFocused===!1&&n.options.cursorInactiveStyle===`block`)&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),g!==0&&(this._model.lineLengths[a]=y+1),(this._model.cells[v]!==g||this._model.cells[v+pf]!==this._cellColorResolver.result.bg||this._model.cells[v+mf]!==this._cellColorResolver.result.fg||this._model.cells[v+hf]!==this._cellColorResolver.result.ext)&&(T=!0,h.length>1&&(g|=gf),this._model.cells[v]=g,this._model.cells[v+pf]=this._cellColorResolver.result.bg,this._model.cells[v+mf]=this._cellColorResolver.result.fg,this._model.cells[v+hf]=this._cellColorResolver.result.ext,_=r.getWidth(),this._glyphRenderer.value.updateCell(y,a,g,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,h,_,i),l)){for(r=this._workCell,y++;y<=f;y++)b=(a*n.cols+y)*ff,this._glyphRenderer.value.updateCell(y,a,0,0,0,0,gu,0,0),this._model.cells[b]=0,this._model.cells[b+pf]=this._cellColorResolver.result.bg,this._model.cells[b+mf]=this._cellColorResolver.result.fg,this._model.cells[b+hf]=this._cellColorResolver.result.ext;y--}}T&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let e=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:e,end:e})}},Lp=class extends pd{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function Rp(e,t,n=0){return Math.max(Math.min(e,t),n)}var zp=`di$target`,Bp=`di$dependencies`,Vp=new Map;function Hp(e){if(Vp.has(e))return Vp.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Up(t,e,r)};return t._id=e,Vp.set(e,t),t}function Up(e,t,n){t[zp]===t?t[Bp].push({id:e,index:n}):(t[Bp]=[{id:e,index:n}],t[zp]=t)}Hp(`BufferService`),Hp(`CoreMouseService`),Hp(`CoreService`),Hp(`CharsetService`),Hp(`InstantiationService`),Hp(`LogService`);var Wp=Hp(`OptionsService`);Hp(`OscLinkService`),Hp(`UnicodeService`),Hp(`DecorationService`);var Gp={trace:0,debug:1,info:2,warn:3,error:4,off:5},Kp=`xterm.js: `,qp=class extends su{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),Jp=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Gp[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis.activate(e)));return}this._terminal=e;let n=t.coreService,r=t.optionsService,i=t,a=i._renderService,o=i._characterJoinerService,s=i._charSizeService,c=i._coreBrowserService,l=i._decorationService;i._logService;let u=i._themeService;this._renderer=this._register(new Ip(e,o,s,c,n,l,r,u,this._preserveDrawingBuffer)),this._register(vd.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(vd.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(vd.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(vd.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),a.setRenderer(this._renderer),this._register(iu(()=>{if(this._terminal._core._store._isDisposed)return;let t=this._terminal._core._renderService;t.setRenderer(this._terminal._core._createRenderer()),t.handleResize(e.cols,e.rows)}))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}},Xp=250;function Zp(e){return e.type===`keydown`&&e.ctrlKey&&!e.altKey&&!e.metaKey&&(e.code===`KeyL`||e.key===`l`||e.key===`L`)}var Qp=class{seen=null;noteKey(e,t){Zp(e)&&(this.seen={at:t,trusted:e.isTrusted,repeat:e.repeat,code:e.code})}report(e,t){if(!e.includes(`\f`))return null;let n=this.seen;return this.seen=null,!n||t-n.at>Xp||t{let e=sm;e!==null&&am(e).then(n=>{n&&sm===e&&(sm=null,oe(t))})}}})}function lm(e,t=250){let n=null,r=0,i=null,a=null,o=()=>{a!==null&&clearTimeout(a),a=null},s=t=>{n=t,r=Date.now(),e(t)},c=()=>{if(a=null,i===null)return;let e=i;i=null,e!==n&&s(e)};return{push(e){if(e===n){i=null,o();return}let l=Date.now()-r;r===0||l>=t?(i=null,o(),s(e)):(i=e,a===null&&(a=setTimeout(c,t-l)))},cancel(){o(),i=null}}}function um(e,t){let n;try{n=t()}catch{return!1}let r=n.onContextLoss(()=>n.dispose());try{e.loadAddon(n)}catch{return r.dispose(),n.dispose(),!1}return!0}var dm=new Set([20,229,16,17,18]);function fm(e){let t=e.parentElement;if(!t)return{dispose(){},noteKeyPassedToXterm(){}};let n=!1,r=0,i,a=()=>{i!==void 0&&clearTimeout(i),i=void 0},o=t=>{t.target===e&&(r++,n=!0,a())},s=t=>{if(t.target!==e||!n)return;let a=r;i=setTimeout(()=>{i=void 0,r===a&&(n=!1)},0)},c=t=>{let r=t;n&&t.target===e&&r.inputType===`insertText`&&t.stopImmediatePropagation()};return t.addEventListener(`compositionstart`,o),t.addEventListener(`compositionend`,s),t.addEventListener(`input`,c,!0),{noteKeyPassedToXterm(e){e.type===`keydown`&&!dm.has(e.keyCode)&&n&&(r++,n=!1,a())},dispose(){n=!1,r++,a(),t.removeEventListener(`compositionstart`,o),t.removeEventListener(`compositionend`,s),t.removeEventListener(`input`,c,!0)}}}function pm({panes:e,size:t,zoomed:n,mode:r,screenScale:i,socketRef:a,viewsRef:o,bodyRefs:s,pendingRef:c,replayRef:l,ptySizesRef:u,consumeLatches:d,setTitles:f}){let p=(0,A.useRef)(new Map);(0,A.useEffect)(()=>{let e=p.current;return()=>e.forEach(e=>e.cancel())},[]),(0,A.useEffect)(()=>{let t=ll(i);for(let n of e){let e=o.current.get(n);if(e){e.term.options.fontSize!==t.fontSize&&(e.term.options.fontSize=t.fontSize),e.term.options.fontFamily!==t.fontFamily&&(e.term.options.fontFamily=t.fontFamily);continue}let r=s.current.get(n);if(!r)continue;let i=new al({...t,theme:{background:`#111112`,foreground:`#f2f2f3`},cursorBlink:!0,macOptionIsMeta:!1,macOptionClickForcesSelection:!0}),m=new cl;i.loadAddon(m);let h=new Qp,g=null;i.attachCustomKeyEventHandler(e=>{if(h.noteKey(e,performance.now()),tm(e,navigator.platform))return!1;let t=em(e);return t===null?(g?.noteKeyPassedToXterm(e),!0):(i.input(t),!1)}),i.onData(e=>{let t=h.report(e,performance.now()),r=d(e);we(a.current,{type:`input`,pane:n,data:r})&&t&&we(a.current,{type:`clear_key_report`,pane:n,...t})});let _=dt(i,l.current.panes.has(n),e=>{im(e).catch(e=>{console.error(`nightcrow: a pane's clipboard request failed`,e)})}),v=lm(e=>{f(t=>t[n]===e?t:{...t,[n]:e})});p.current.set(n,v),i.onTitleChange(e=>{let t=e.replace(/\s+/g,` `).trim();t&&v.push(t)}),i.open(r),i.textarea&&(g=fm(i.textarea),i.loadAddon({activate(){},dispose(){g?.dispose()}})),um(i,()=>new Yp);let y=u.current.get(n);y&&i.resize(y.cols,y.rows);let b={term:i,fit:m,replayGate:_};o.current.set(n,b);let x=c.current.get(n);if(x){for(let e of x)e instanceof Uint8Array?ot(i,e):lt(i,b.replayGate,()=>{o.current.get(n)===b&&l.current.panes.get(n)===e.token&&l.current.panes.delete(n)});c.current.delete(n),st(i,()=>i.scrollToBottom())}}for(let[t,n]of o.current)e.includes(t)||(p.current.get(t)?.cancel(),p.current.delete(t),ct(n.term),n.term.dispose(),o.current.delete(t))},[e,t,n,r,i,a,o,s,c,l,u,d,f])}function mm({repo:e,refs:t,size:n,mode:r,panes:i,active:a,replayLeft:o,pending:s,ownsSize:c,keyboardOpen:l,screenScale:u,refitEpoch:d,zoomShown:f,zoomServer:p,consumeLatches:m,setLink:h,setPending:g,setReplayLeft:_,setPanes:v,setActive:y,setZoomed:b,setTitles:x,setOwnsSize:ee,onSizeAcquired:te,setRecovery:S}){let{containerRef:C,socketRef:w,viewsRef:T,bodyRefs:ne,ptySizesRef:E,askedSizesRef:re,desiredSizesRef:ie,ownsSizeRef:ae,sizeOwnerGenerationRef:D,pendingRef:O,replayRef:k,zoomAskedRef:oe,slotRefs:se}=t;El({repo:e,socketRef:w,viewsRef:T,pendingRef:O,replayRef:k,ptySizesRef:E,askedSizesRef:re,desiredSizesRef:ie,ownsSizeRef:ae,sizeOwnerGenerationRef:D,zoomAskedRef:oe,setLink:h,setPending:g,setReplayLeft:_,setPanes:v,setActive:y,setZoomed:b,setTitles:x,setOwnsSize:ee,onSizeAcquired:te,setRecovery:S}),Ll({containerRef:C,socketRef:w,viewsRef:T}),pm({panes:i,size:n,zoomed:f,mode:r,screenScale:u,socketRef:w,viewsRef:T,bodyRefs:ne,pendingRef:O,replayRef:k,ptySizesRef:E,consumeLatches:m,setTitles:x});let ce=(0,A.useCallback)(()=>g(null),[g]);ul({pending:s,size:n,screenScale:u,socketRef:w,slotRefs:se,panesExist:i.length>0,onAnswered:ce}),bt({panes:i,size:n,zoomed:f,mode:r,screenScale:u,socketRef:w,viewsRef:T,bodyRefs:ne,ptySizesRef:E,askedSizesRef:re,desiredSizesRef:ie,ownsSize:c,layoutPending:Ue(p,i),keyboardOpen:l,refitEpoch:d}),_t({panes:i,viewsRef:T,bodyRefs:ne,keyboardOpen:l,size:n,zoomed:f,mode:r}),vt({repo:e,panes:i,replayLeft:o,active:a,setActive:y,zoomed:p,zoom:f,viewsRef:T,panelRef:C,size:n,mode:r})}var hm=()=>_m(Le),gm=()=>_m(Re);function _m(e){let[t,n]=(0,A.useState)(!1),r=(0,A.useRef)(!1),i=(0,A.useCallback)(e=>{r.current=e,n(e)},[]),a=(0,A.useCallback)(t=>{let n=e(r.current,t);return n.armed!==r.current&&i(n.armed),n.data},[e,i]);return{armed:t,toggle:(0,A.useCallback)(()=>{let e=!r.current;return i(e),e},[i]),clear:(0,A.useCallback)(()=>i(!1),[i]),consume:a}}function vm(e){let[t,n]=(0,A.useState)({w:0,h:0});return(0,A.useEffect)(()=>{let t=e.current;if(!t)return;let r=new ResizeObserver(()=>{let e=t.clientWidth,r=t.clientHeight;n(t=>t.w===e&&t.h===r?t:{w:e,h:r})});return r.observe(t),()=>r.disconnect()},[e]),t}function ym(e=window){return(0,A.useSyncExternalStore)(t=>bm(e,t),()=>x(e)>0,()=>!1)}function bm(e,t){let n=e.visualViewport;return e.addEventListener(`resize`,t),n?.addEventListener(`resize`,t),n?.addEventListener(`scroll`,t),()=>{e.removeEventListener(`resize`,t),n?.removeEventListener(`resize`,t),n?.removeEventListener(`scroll`,t)}}function xm({link:e,panes:t,replayLeft:n,pending:r}){return e===`live`?n>0?{kind:`attaching`,left:n}:t>0?{kind:`ready`}:r===null?{kind:`empty`}:{kind:`starting`,count:r}:{kind:e}}function Sm(e){switch(e.kind){case`connecting`:return`Connecting…`;case`reconnecting`:return`Reconnecting…`;case`attaching`:return`Attaching ${Cm(e.left)}…`;case`starting`:return`Starting ${Cm(e.count)}…`;case`empty`:case`ready`:return null}}function Cm(e){return`${e} terminal${e===1?``:`s`}`}var $=e();function wm({status:e}){if(e.kind===`empty`)return(0,$.jsxs)(`p`,{className:`p-3 text-ink-400`,children:[`No terminal open. Press `,(0,$.jsx)(`span`,{className:`text-accent`,children:`+`}),` above to start one.`]});let t=e.kind===`starting`?null:Sm(e);return t?(0,$.jsx)(`div`,{role:`status`,className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center p-6`,children:(0,$.jsxs)(`span`,{className:`flex animate-pulse items-center gap-2 text-caption text-ink-400 uppercase`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-accent`}),t]})}):null}var Tm=100;function Em({socketRef:e,viewsRef:t,active:n,panes:r,onSent:i}){let[a,o]=(0,A.useState)(null),[s,c]=(0,A.useState)({}),[l,u]=(0,A.useState)(!1),[d,f]=(0,A.useState)(null),p=(0,A.useRef)(null),m=(0,A.useRef)(r),h=(0,A.useRef)(0),g=(0,A.useRef)(!1);m.current=r;let _=a!==null&&r.includes(a)?a:null,v=_===null?``:s[_]??``,y=()=>{h.current+=1,g.current=!1,u(!1),f(null)};(0,A.useEffect)(()=>()=>{h.current+=1,g.current=!1,p.current=null},[]),(0,A.useEffect)(()=>{a!==null&&!r.includes(a)&&(p.current=null,y(),o(null))},[a,r]);let b=e=>{_!==null&&c(t=>({...t,[_]:e}))};return{target:_,draft:v,setDraft:b,open:()=>{p.current===null&&n!==null&&(y(),p.current=n,o(n))},close:()=>{p.current=null,y(),o(null)},send:()=>{if(_===null||g.current||d!==null||!jl(v))return!1;let n=t.current.get(_)?.term.modes.bracketedPasteMode??!1,r=Al(v,n);return we(e.current,{type:`input`,pane:_,data:r})?(window.setTimeout(()=>{we(e.current,{type:`input`,pane:_,data:`\r`})},Tm),b(``),p.current=null,y(),o(null),i(_),!0):!1},attachImage:async e=>{if(_===null||g.current)return;if(!Nl.includes(e.type)){f(`Choose a PNG, JPEG, GIF, or WebP image.`);return}if(e.size>10485760){f(`Image must be 10 MiB or smaller.`);return}let t=_,n=h.current,r=()=>n===h.current&&p.current===t&&m.current.includes(t);g.current=!0,u(!0),f(null);try{let n=await he.pasteImage(e);if(!n)throw Error(`the server returned no image path`);if(!r())return;c(e=>{let r=e[t]??``,i=r.length>0&&!/\s$/.test(r)?` `:``;return{...e,[t]:`${r}${i}${Fl(n)}`}})}catch(e){r()&&f(e instanceof Error?`Could not attach image: ${e.message}`:`Could not attach image.`)}finally{r()&&(g.current=!1,u(!1))}},uploading:l,uploadError:d,dismissUploadError:()=>f(null)}}var Dm=b(),Om=`nc-compose-title`;function km(){let e=navigator;return e.userAgentData?.platform||e.platform||``}function Am({label:e,draft:t,onChange:n,onSend:r,onAttachImage:i,uploading:a,uploadError:o,onDismissUploadError:s,onClose:c}){let l=(0,A.useRef)(null),u=(0,A.useRef)(null),[d,f]=(0,A.useState)(!1),p=jl(t)&&!a&&o===null,m=Ml(km());(0,A.useEffect)(()=>{let e=l.current;e?.focus(),e?.setSelectionRange(e.value.length,e.value.length)},[]),(0,A.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!e.isComposing&&c()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[c]);let h=()=>{p&&f(!r())};return(0,Dm.createPortal)((0,$.jsx)(`div`,{className:`nc-fade-in fixed inset-0 z-50 flex items-start justify-center bg-black/60 p-4 pt-[8vh]`,onClick:c,children:(0,$.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":Om,className:`nc-rise-in flex w-[56rem] max-w-full flex-col rounded-lg border border-ink-700 bg-ink-900`,onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-ink-700 px-3 py-2`,children:[(0,$.jsxs)(`span`,{id:Om,className:`min-w-0 truncate font-medium text-ink-50`,children:[`Send to `,e]}),(0,$.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`close`,className:`ml-auto flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-ink-200`,children:(0,$.jsx)(w,{})})]}),(0,$.jsx)(`textarea`,{ref:l,value:t,onChange:e=>{n(e.target.value),f(!1)},onKeyDown:e=>{e.key!==`Enter`||e.nativeEvent.isComposing||(e.metaKey||e.ctrlKey)&&(e.preventDefault(),h())},rows:10,"aria-label":`message`,className:`m-3 resize-y rounded-sm border border-ink-700 bg-ink-950 p-2 font-mono text-[16px] text-ink-50 focus:border-accent focus:outline-none`}),(0,$.jsx)(`input`,{ref:u,type:`file`,accept:Nl.join(`,`),"aria-label":`Choose an image`,tabIndex:-1,className:`hidden`,onChange:e=>{let t=e.currentTarget.files?.[0];e.currentTarget.value=``,t&&i(t)}}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3 pb-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>u.current?.click(),disabled:a,"aria-label":`Attach image`,className:`min-h-11 rounded-sm border border-ink-700 px-3 text-ink-200 hover:text-ink-50 disabled:text-ink-500`,children:`Attach image`}),a&&(0,$.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`text-ink-300`,children:`Uploading image…`}),o&&(0,$.jsxs)(`span`,{role:`alert`,className:`flex basis-full items-center gap-2 text-removed`,children:[(0,$.jsx)(`span`,{className:`min-w-0`,children:o}),(0,$.jsx)(`button`,{type:`button`,onClick:s,className:`min-h-11 shrink-0 rounded-sm px-2 underline`,children:`Dismiss`})]}),d&&(0,$.jsx)(`span`,{role:`alert`,className:`min-w-0 basis-full truncate text-removed`,children:`Not connected — nothing was sent.`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{n(``),f(!1),l.current?.focus()},disabled:t.length===0,className:`ml-auto min-h-11 rounded-sm px-3 text-ink-200 hover:text-ink-50 disabled:text-ink-600`,children:`Clear`}),(0,$.jsxs)(`button`,{type:`button`,onClick:h,disabled:!p,title:`Send and run (${m})`,"aria-keyshortcuts":`Meta+Enter Control+Enter`,className:`flex min-h-11 items-center gap-1.5 rounded-sm bg-accent px-3 py-1.5 font-medium text-ink-950 disabled:bg-ink-700 disabled:text-ink-400`,children:[(0,$.jsx)(`kbd`,{"aria-hidden":`true`,className:`font-sans opacity-70`,children:m}),`Send`]})]})]})}),document.body)}function jm({closing:e,panes:t,paneLabel:n,onConfirmClose:r,onCancelClose:i,compose:a}){return(0,$.jsxs)($.Fragment,{children:[e!==null&&t.includes(e)&&(0,$.jsx)(T,{label:n(e),detail:`The process running in it will be terminated.`,onConfirm:()=>r(e),onCancel:i}),a.target!==null&&(0,$.jsx)(Am,{label:n(a.target),draft:a.draft,onChange:a.setDraft,onSend:a.send,onAttachImage:a.attachImage,uploading:a.uploading,uploadError:a.uploadError,onDismissUploadError:a.dismissUploadError,onClose:a.close})]})}function Mm({report:e,pane:t,onCancel:n}){let r=t===void 0?Sl(e):`pane ${t} · ${Sl(e)}`;return(0,$.jsxs)(`span`,{className:`flex min-w-0 shrink items-center gap-1 rounded-sm bg-ink-800 px-1 text-accent`,title:e.detail??r,children:[(0,$.jsx)(`span`,{className:`truncate`,children:r}),e.detail&&(0,$.jsx)(`span`,{className:`hidden min-w-0 truncate text-ink-400 md:inline`,children:e.detail}),(0,$.jsx)(`button`,{onMouseDown:e=>e.stopPropagation(),onClick:n,title:`Stop waiting and release this pane's slot`,"aria-label":`cancel recovery${t===void 0?``:` for pane ${t}`}`,className:`flex h-5 w-5 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-removed`,children:(0,$.jsx)(w,{className:`h-3 w-3`})})]})}function Nm({pane:e,index:t,label:n,cellStyle:r,isActive:i,isZoomed:a,showZoom:o,isDragged:s,isDropTarget:d,reorderable:f,showHeader:p,recovery:m,onCancelRecovery:h,onFocus:g,onToggleZoom:_,onClose:v,onPaneDragStart:y,onPaneDragMove:b,onPaneDragEnd:x,onPaneDragCancel:ee,bodyRef:te,bodyTouch:S}){let C=u(),T=(e,t)=>i?C(e,t):{title:t};return(0,$.jsxs)(`div`,{"data-pane-id":e,"data-pane-cell":!0,onMouseDown:g,style:r,className:`nc-cell-in relative min-h-0 min-w-0 flex-col overflow-hidden rounded-sm border ${d?`border-accent ring-1 ring-accent`:i?`border-accent`:`border-ink-700`} ${s?`opacity-60`:``}`,children:[!p&&m&&(0,$.jsx)(`div`,{className:`absolute top-1 right-1 z-10 text-xs`,children:(0,$.jsx)(Mm,{report:m,onCancel:h})}),p&&(0,$.jsxs)(`div`,{onPointerDown:y,onPointerMove:b,onPointerUp:x,onPointerCancel:ee,"data-active":i,className:`nc-title-target flex shrink-0 items-center gap-1 select-none bg-ink-900 px-2 py-0.5 text-xs ${f?s?`cursor-grabbing touch-none`:`cursor-grab touch-none`:``}`,children:[(0,$.jsx)(`span`,{title:n,className:`min-w-0 flex-1 ${i?`text-ink-50`:`text-ink-400`}`,children:(0,$.jsx)(c,{title:n})}),m&&(0,$.jsx)(Mm,{report:m,onCancel:h}),o&&(0,$.jsx)(`button`,{onMouseDown:e=>e.stopPropagation(),onClick:_,"aria-pressed":a,...T(`view.toggleMaximize`,a?`Restore the grid`:`Zoom this terminal`),"aria-label":a?`Restore the grid`:`Zoom this terminal`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-accent md:h-6 md:w-6`,children:(0,$.jsx)(l,{maximized:a})}),(0,$.jsx)(`button`,{onMouseDown:e=>e.stopPropagation(),onClick:v,...T(`terminal.closePane`,`Close terminal`),"aria-label":`close terminal ${t+1}`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-removed md:h-6 md:w-6`,children:(0,$.jsx)(w,{})})]}),(0,$.jsx)(`div`,{ref:te,...S,className:`nc-pane-body flex min-h-0 flex-1 flex-col justify-end overflow-hidden touch-pinch-zoom`})]})}function Pm({count:e,slotStyle:t,showHeader:n,bodyTouch:r,slotRefs:i}){return Array.from({length:e},(e,a)=>(0,$.jsx)(Nm,{pane:-1-a,index:a,label:`starting…`,cellStyle:t(a),isActive:!1,isZoomed:!1,showZoom:!1,isDragged:!1,isDropTarget:!1,reorderable:!1,showHeader:n,bodyTouch:r,onCancelRecovery:()=>{},onFocus:()=>{},onToggleZoom:()=>{},onClose:()=>{},onPaneDragStart:()=>{},onPaneDragMove:()=>{},onPaneDragEnd:()=>{},onPaneDragCancel:()=>{},bodyRef:e=>{e?i.current.set(a,e):i.current.delete(a)}},`slot-${a}`))}function Fm(e,t){let n=(0,A.useRef)(t);(0,A.useLayoutEffect)(()=>{n.current!==t&&(n.current=t,Me(e.current))},[e,t])}function Im({containerRef:e,mode:t,panes:n,titles:r,active:i,shown:a,layout:o,pending:s,maximized:c=!1,recovery:l,draggingPane:u,dragOverPane:d,reorderable:f,bodyTouch:p,slotRefs:m,bodyRefs:h,onFocus:g,onToggleZoom:_,onClose:v,onCancelRecovery:y,onPaneDragStart:b,onPaneDragMove:x,onPaneDragEnd:ee,onPaneDragCancel:te}){let S=t===`tabs`;Fm(e,`${t}:${a}:${o.cols}x${o.rows}:${c}`);let C=e=>{let t=o.cells[e];return{display:`flex`,gridColumn:`${t.colStart} / span ${t.colSpan}`,gridRow:`${t.row}`}},w=(e,t)=>S?ne(e===a):a===null?C(t):{display:e===a?`flex`:`none`};return(0,$.jsxs)(`div`,{ref:e,className:S?de:`grid h-full gap-1`,style:S?void 0:a===null?{gridTemplateColumns:`repeat(${o.cols}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${o.rows}, minmax(0, 1fr))`}:{gridTemplateColumns:`1fr`,gridTemplateRows:`1fr`},children:[n.length===0&&s!==null&&(0,$.jsx)(Pm,{count:s,showHeader:!S,bodyTouch:p,slotStyle:e=>S?ne(e===0):C(e),slotRefs:m}),n.map((e,t)=>(0,$.jsx)(Nm,{pane:e,index:t,label:r[e]??`term ${t+1}`,cellStyle:w(e,t),isActive:e===i,isZoomed:!S&&a===e,showZoom:!S&&n.length>1,isDragged:u===e,isDropTarget:d===e,reorderable:f,showHeader:!S,bodyTouch:p,recovery:l[e],onCancelRecovery:()=>y(e),onFocus:()=>g(e),onToggleZoom:()=>_(e),onClose:()=>v(e),onPaneDragStart:t=>b(t,e),onPaneDragMove:x,onPaneDragEnd:ee,onPaneDragCancel:te,bodyRef:t=>{t?h.current.set(e,t):h.current.delete(e)}},e))]})}function Lm({panes:e,titles:t,shown:n,reorderable:r,draggingPane:i,dragOverPane:a,onClose:o,onPaneDragStart:s,onPaneDragMove:l,onPaneDragEnd:u,onPaneDragCancel:d}){let f=(0,A.useRef)(new Map);(0,A.useEffect)(()=>{n!==null&&f.current.get(n)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[n,e.length]);let p=(0,A.useRef)(null),m=(0,A.useRef)(!1);return(0,A.useEffect)(()=>{m.current=i!==null},[i]),(0,A.useEffect)(()=>{let e=p.current;if(!e)return;let t=e=>{m.current&&e.cancelable&&e.preventDefault()};return e.addEventListener(`touchmove`,t,{passive:!1}),()=>e.removeEventListener(`touchmove`,t)},[]),(0,$.jsx)(`div`,{ref:p,role:`tablist`,"aria-label":`Terminals`,className:`-my-1 flex min-w-0 flex-1 items-stretch self-stretch overflow-x-auto`,children:e.map((e,p)=>{let m=t[e]??`term ${p+1}`,h=e===n;return(0,$.jsxs)(`div`,{"data-pane-id":e,ref:t=>{t?f.current.set(e,t):f.current.delete(e)},role:`tab`,"aria-selected":h,title:m,onPointerDown:t=>s(t,e,{holdToDrag:!0}),onPointerMove:l,onPointerUp:u,onPointerCancel:d,onLostPointerCapture:d,className:`nc-title-target flex shrink-0 touch-pan-x items-center border-r border-ink-700 whitespace-nowrap select-none [-webkit-touch-callout:none] ${r?`cursor-grab`:``} ${i===e?`opacity-60`:``} ${a===e?`bg-ink-800 ring-1 ring-inset ring-accent`:``} ${h?`bg-ink-950 text-ink-50 shadow-[inset_0_-1px_0_0_var(--color-accent)]`:`text-ink-400 hover:bg-ink-850 hover:text-ink-200`}`,children:[(0,$.jsx)(`span`,{className:`flex min-w-0 items-center self-stretch pr-1 pl-3`,children:(0,$.jsx)(c,{title:m,className:_})}),(0,$.jsx)(`button`,{onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),o(e)},"data-tab-close":!0,title:`Close terminal`,"aria-label":`close terminal ${p+1}`,className:`mr-1 flex h-5 w-5 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:bg-ink-700 hover:text-removed`,children:(0,$.jsx)(w,{className:`h-3.5 w-3.5`})})]},e)})})}var Rm=`flex min-h-9 min-w-9 shrink-0 items-center justify-center rounded-xs border px-2 text-xs active:bg-ink-700 active:text-accent`,zm=`border-ink-700 bg-ink-850 text-ink-200`,Bm=`border-accent bg-ink-700 text-accent`;function Vm({onKey:e,ctrl:t,alt:n,onArm:r}){(0,A.useEffect)(()=>t.clear,[t.clear]),(0,A.useEffect)(()=>n.clear,[n.clear]);let i=()=>{t.clear(),n.clear()};return(0,$.jsx)(`div`,{className:`flex shrink-0 items-stretch gap-1 overflow-x-auto border-t border-chrome-line bg-ink-900 px-1 py-1`,children:Ve.map(a=>a.kind===`latch`?(0,$.jsx)(Hm,{latch:a.latch===`ctrl`?t:n,label:a.label,aria:a.aria,onArm:r},a.latch):(0,$.jsx)(`button`,{onPointerDown:e=>e.preventDefault(),onClick:()=>{i(),e(a.key)},"aria-label":a.aria,className:`${Rm} ${zm}`,children:a.label},a.key))})}function Hm({latch:e,label:t,aria:n,onArm:r}){return(0,$.jsx)(`button`,{onPointerDown:e=>e.preventDefault(),onClick:()=>{e.toggle()&&r()},"aria-pressed":e.armed,"aria-label":n,className:`${Rm} ${e.armed?Bm:zm}`,children:t})}function Um(e){return{lastY:e,pending:0,scrolling:!1}}function Wm(e,t){let n=e.pending+(e.lastY-t);return Math.abs(n)<50?{next:{...e,lastY:t,pending:n},deltaY:0}:{next:{lastY:t,pending:0,scrolling:!0},deltaY:n}}function Gm({viewsRef:e,bodyRefs:t}){let n=(0,A.useRef)(null),r=(0,A.useRef)(null),i=(0,A.useCallback)(()=>{n.current=null,r.current=null},[]),a=(0,A.useCallback)(e=>{e.pointerType===`touch`&&(n.current===null?(n.current=e.pointerId,r.current=Um(e.clientY)):i())},[i]),o=(0,A.useCallback)(i=>{if(i.pointerId!==n.current)return;let a=r.current;if(!a)return;let{next:o,deltaY:s}=Wm(a,i.clientY);if(r.current=o,s===0)return;i.preventDefault();let c=i.currentTarget;qm(c,i,s,Km(c,e,t))},[e,t]),s=(0,A.useCallback)(e=>{e.pointerId===n.current&&i()},[i]);return{onPointerDown:a,onPointerMove:o,onPointerUp:s,onPointerCancel:s}}function Km(e,t,n){for(let[r,i]of n.current)if(i===e)return t.current.get(r)}function qm(e,t,n,r){let i=e.querySelector(`.xterm`);if(!i)return;let a=new WheelEvent(`wheel`,{deltaY:n,deltaMode:WheelEvent.DOM_DELTA_PIXEL,clientX:t.clientX,clientY:t.clientY,bubbles:!0,cancelable:!0,view:window});if(i.dispatchEvent(a),a.defaultPrevented||!r)return;let o=r.term.rows,s=o>0?i.clientHeight/o:0;if(s<=0)return;let c=Math.round(n/s);r.term.scrollLines(n<0?Math.min(-1,c):Math.max(1,c))}var Jm=`nightcrow.paneViewMode`;function Ym(){return C(d(Jm))}function Xm(e){f(Jm,e)}function Zm(){return typeof window>`u`?768:window.innerWidth}function Qm(){let[e,t]=(0,A.useState)(Ym),[n,r]=(0,A.useState)(Zm);(0,A.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>r(window.innerWidth);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let i=k(e,n),a=S(n);return{mode:i,toggle:(0,A.useCallback)(()=>{if(!a)return;let e=i===`tabs`?`grid`:`tabs`;Xm(e),t(e)},[i,a]),canToggle:a}}var $m=`nightcrow.termKeyBar`,eh=`(pointer: coarse)`;function th(){return ze(d($m))}function nh(e){f($m,e)}function rh(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(eh).matches}function ih(){return typeof window>`u`?768:window.innerWidth}function ah(){let[e,t]=(0,A.useState)(th),[n,r]=(0,A.useState)(rh),[i,a]=(0,A.useState)(ih);(0,A.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>a(window.innerWidth);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,A.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(eh),t=()=>r(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let o=e?e===`shown`:Be(n,i);return{shown:o,toggle:(0,A.useCallback)(()=>{let e=o?`hidden`:`shown`;nh(e),t(e)},[o])}}function oh({showDivider:e,draggingUpper:t,onUpperDragStart:n,onUpperDragMove:r,onUpperDragEnd:i,onUpperDragCancel:a}){return e?(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize the terminal panel (double-click to reset)`,title:`Drag to resize · double-click to reset`,onPointerDown:n,onPointerMove:r,onPointerUp:i,onPointerCancel:a,onLostPointerCapture:i,className:`absolute -top-px left-0 z-10 hidden h-1.5 w-full cursor-row-resize touch-none md:block ${t?`bg-accent`:`hover:bg-accent`}`}):null}function sh({mode:e,onToggleMode:t,canToggleMode:n,tabs:r,ownsSize:a,maximized:o,keyBarShown:c,waiting:d,recovery:f,panes:g,onCancelRecovery:_,onClaimSize:v,onCreate:y,onCompose:b,onToggleKeyBar:x,onToggleMaximized:ee}){let S=u(),C=(0,A.useRef)(null),w=(0,A.useRef)(g.length);(0,A.useLayoutEffect)(()=>{let e=w.current;w.current=g.length;let t=document.activeElement===null||document.activeElement===document.body;h(g.length,e,t)&&C.current?.focus()},[g.length]);let T=`flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-accent`;return(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 bg-ink-900 px-2 py-1 text-xs`,children:[d&&(0,$.jsxs)(`span`,{role:`status`,className:`flex min-w-0 shrink animate-pulse items-center gap-1 rounded-sm bg-ink-800 px-1 text-ink-400`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-accent`}),(0,$.jsx)(`span`,{className:`truncate`,children:d})]}),bl(f,g).map(e=>(0,$.jsx)(Mm,{pane:e,report:f[e],onCancel:()=>_(e)},e)),r,!a&&(0,$.jsx)(`button`,{onClick:v,...S(`terminal.claimSizing`,`These panes are sized for another client. Resize them to fit this screen.`),"aria-label":`Fit the panes to this screen`,className:`ml-auto ${T}`,children:(0,$.jsx)(p,{})}),(0,$.jsx)(`button`,{ref:C,onClick:y,...S(`terminal.newPane`,`New terminal`),"aria-label":`New terminal`,className:`${T} ${a?`ml-auto`:``}`,children:(0,$.jsx)(te,{})}),n&&(0,$.jsx)(`button`,{onClick:t,"aria-pressed":e===`tabs`,title:e===`tabs`?`Show the panes side by side`:`Show one pane per tab`,"aria-label":e===`tabs`?`Show the panes side by side`:`Show one pane per tab`,className:T,children:e===`tabs`?(0,$.jsx)(m,{}):(0,$.jsx)(i,{})}),g.length>0&&(0,$.jsx)(`button`,{onClick:b,...S(`terminal.composeMessage`,`Write a message to the active terminal`),"aria-label":`Write a message to the active terminal`,className:T,children:(0,$.jsx)(le,{})}),g.length>0&&(0,$.jsx)(`button`,{onClick:x,"aria-pressed":c,title:c?`Hide the key bar`:`Show the key bar`,"aria-label":c?`Hide the key bar`:`Show the key bar`,className:`${T} ${c?`text-accent`:``}`,children:(0,$.jsx)(s,{})}),(0,$.jsx)(`button`,{onClick:ee,"aria-pressed":o,...S(`view.toggleMaximize`,o?`Restore panel height`:`Maximize the panel`),"aria-label":o?`Restore panel height`:`Maximize the panel`,className:`hidden md:flex ${T}`,children:(0,$.jsx)(l,{maximized:o})})]})}function ch({repo:e,maximized:t,onToggleMaximized:n,className:r=``,sectionRef:i,...a}){let o=pt(),{containerRef:s,socketRef:c,viewsRef:l,bodyRefs:u,zoomAskedRef:d,slotRefs:f}=o,{pending:p,setPending:m,link:h,setLink:g,replayLeft:_,setReplayLeft:v,panes:y,setPanes:b,active:x,setActive:ee,zoomed:te,setZoomed:S,titles:C,setTitles:w,closing:T,setClosing:ne,ownsSize:E,setOwnsSize:ie}=Ye(),D=vm(s),{scale:O}=re(),{refitEpoch:k,forceFit:oe}=Je(h,c),ce=ym(),{recovery:le,setRecovery:ue,cancelRecovery:de}=Ee(c),fe=He(te,y),pe=Gm({viewsRef:l,bodyRefs:u}),{mode:me,toggle:he,canToggle:ge}=Qm(),_e=ah(),be=hm(),xe=gm(),Se=be.consume,Ce=xe.consume,we=(0,A.useCallback)(e=>Ce(Se(e)),[Ce,Se]),Te=me===`tabs`,De=Te?null:fe,Oe=Te?null:te,ke=Te?ae(x,y):fe;mm({repo:e,refs:o,size:D,mode:me,panes:y,active:x,replayLeft:_,pending:p,ownsSize:E,keyboardOpen:ce,screenScale:O,refitEpoch:k,zoomShown:De,zoomServer:Oe,consumeLatches:we,setLink:g,setPending:m,setReplayLeft:v,setPanes:b,setActive:ee,setZoomed:S,setTitles:w,setOwnsSize:ie,onSizeAcquired:oe,setRecovery:ue});let Ae=t=>{ee(t),se(e,t),l.current.get(t)?.term.focus()},je=e=>C[e]||`terminal ${y.indexOf(e)+1}`,Me=()=>x!==null&&Ae(x),Ne=Em({socketRef:c,viewsRef:l,active:x,panes:y,onSent:e=>{be.clear(),xe.clear(),Ae(e)}}),Pe=Ge({socketRef:c,viewsRef:l,zoomed:fe,zoomAskedRef:d,active:x,onForceFit:oe}),{create:Fe,toggleZoom:Ie,claimSize:Le,closePane:Re,reorder:ze,sendKey:Be}=Pe;mt({socketRef:c,panes:y,active:x,zoom:De,link:h,commands:Pe,focusPane:Ae,cancelRecovery:de,openCompose:Ne.open});let{draggingPane:Ve,dragOverPane:Ue,reorderable:We,endPaneDrag:Ke,onPaneDragStart:qe,onPaneDragMove:Xe,onPaneDragEnd:Ze}=ye({panes:y,zoomed:De,onFocus:Ae,onReorder:ze}),Qe=ve(y.length+_>0?y.length+_:p??0,D.w>=D.h),$e=xm({link:h,panes:y.length,replayLeft:_,pending:p});return(0,$.jsxs)(`section`,{ref:i,"data-terminal-panel":``,className:`relative flex min-h-0 min-w-0 flex-col border-t border-chrome-line ${r}`,children:[(0,$.jsx)(oh,{...a}),(0,$.jsx)(sh,{mode:me,onToggleMode:he,canToggleMode:ge,tabs:Te&&y.length>0?(0,$.jsx)(Lm,{panes:y,titles:C,shown:ke,reorderable:We,draggingPane:Ve,dragOverPane:Ue,onClose:ne,onPaneDragStart:qe,onPaneDragMove:Xe,onPaneDragEnd:Ze,onPaneDragCancel:Ke}):void 0,ownsSize:E,maximized:t,keyBarShown:_e.shown,waiting:y.length>0?Sm($e):null,recovery:le,panes:y,onCancelRecovery:de,onClaimSize:Le,onCreate:Fe,onCompose:Ne.open,onToggleKeyBar:_e.toggle,onToggleMaximized:n}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden bg-ink-950 p-1`,children:[y.length===0&&(0,$.jsx)(wm,{status:$e}),(0,$.jsx)(Im,{containerRef:s,mode:me,maximized:t,panes:y,titles:C,active:x,shown:ke,layout:Qe,pending:p,recovery:le,draggingPane:Ve,dragOverPane:Ue,reorderable:We,bodyTouch:pe,slotRefs:f,bodyRefs:u,onFocus:Ae,onToggleZoom:Ie,onClose:ne,onCancelRecovery:de,onPaneDragStart:qe,onPaneDragMove:Xe,onPaneDragEnd:Ze,onPaneDragCancel:Ke})]}),y.length>0&&_e.shown&&(0,$.jsx)(Vm,{onKey:Be,ctrl:be,alt:xe,onArm:Me}),(0,$.jsx)(jm,{closing:T,panes:y,paneLabel:je,onConfirmClose:e=>{ne(null),Re(e)},onCancelClose:()=>{ne(null),Me()},compose:Ne})]})}var lh=(0,A.memo)(ch);export{lh as TerminalPanel}; \ No newline at end of file diff --git a/viewer-ui/dist/assets/Terminal-C0v33aMU.js b/viewer-ui/dist/assets/Terminal-C0v33aMU.js new file mode 100644 index 00000000..28f126f2 --- /dev/null +++ b/viewer-ui/dist/assets/Terminal-C0v33aMU.js @@ -0,0 +1,81 @@ +import{t as e}from"./jsx-runtime-EIAPxkjE.js";import{t}from"./react-BPk_wmJm.js";import{$ as n,A as r,B as i,C as a,E as o,F as s,H as c,I as l,K as u,M as d,N as f,P as p,R as m,S as h,T as g,U as _,X as v,_ as y,_t as b,a as x,c as S,ct as ee,d as C,f as w,gt as T,h as E,ht as te,j as D,l as ne,lt as re,m as ie,mt as O,n as k,o as A,ot as ae,p as oe,r as se,s as ce,t as le,u as ue,ut as de,vt as fe,w as pe,x as me,y as he,yt as ge}from"./lastPane-FlqACl6i.js";import{t as _e}from"./api-BwgkHPos.js";var j=t();function ve(e,t){for(;t;)[e,t]=[t,e%t];return e}function ye(e,t){switch(e){case 1:return[1];case 2:return t?[2]:[1,1];case 3:return[2,1];case 4:return[2,2];case 5:return[3,2];case 6:return[3,3];case 7:return[4,3];default:return[4,4]}}function be(e,t){let n=ye(e,t),r=n.reduce((e,t)=>e*t/ve(e,t),1),i=[];return n.forEach((e,t)=>{let n=r/e;for(let r=0;r1,h=()=>{c.current!==null&&clearTimeout(c.current),c.current=null},g=()=>{h(),l.current=!1,i.current=null,a.current=null,o.current=null,s.current=!1,d(null),p(null)};return{draggingPane:u,dragOverPane:f,reorderable:m,endPaneDrag:g,onPaneDragStart:(e,t,r)=>{if(e.target.closest(`button`))return;let o=r?.holdToDrag===!0&&e.pointerType===`touch`;if(o||n(t),e.button!==0||!m&&!o)return;if(i.current=t,a.current={x:e.clientX,y:e.clientY},s.current=!1,!o){e.currentTarget.setPointerCapture(e.pointerId);return}if(l.current=!0,!m)return;let u=e.currentTarget,f=e.pointerId;h(),c.current=setTimeout(()=>{c.current=null,l.current=!1,s.current=!0,d(t);try{u.setPointerCapture(f)}catch{g()}},350)},onPaneDragMove:e=>{let t=i.current,n=a.current;if(t===null||n===null)return;if(!s.current){if(!(Math.hypot(e.clientX-n.x,e.clientY-n.y)>=4))return;if(l.current){g();return}}s.current=!0,d(t);let r=document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-pane-id]`),c=r?Number(r.getAttribute(`data-pane-id`)):null,u=c!==null&&c!==t?c:null;o.current=u,p(u)},onPaneDragEnd:()=>{let t=i.current,a=o.current;t!==null&&l.current&&n(t),t!==null&&s.current&&a!==null&&r(S(e,t,a)),g()}}}function Se(e){return typeof e==`number`&&Number.isSafeInteger(e)}function Ce(e){return Se(e)&&e>=0}function we(e){return typeof e==`string`&&/^[0-9]+$/.test(e)}function Te(e){let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t,r;switch(n.type){case`created`:r=Ce(n.pane)&&Ce(n.rows)&&Ce(n.cols)&&(n.client===void 0||Ce(n.client))&&(n.title===void 0||typeof n.title==`string`);break;case`exited`:r=Ce(n.pane);break;case`resized`:r=Ce(n.pane)&&Ce(n.rows)&&Ce(n.cols);break;case`hello`:r=Ce(n.client)&&Ce(n.panes);break;case`replay_complete`:r=!0;break;case`size_owner`:r=typeof n.owned==`boolean`&&(n.generation===void 0||we(n.generation));break;case`error`:r=typeof n.message==`string`;break;case`reordered`:r=Array.isArray(n.order)&&n.order.every(Ce);break;case`zoomed`:r=n.pane===null||Ce(n.pane);break;case`pending`:r=Ce(n.count);break;case`attention`:r=Ce(n.pane)&&(n.message===void 0||typeof n.message==`string`);break;case`recovery`:r=Ce(n.pane)&&typeof n.state==`string`&&(n.detail===void 0||typeof n.detail==`string`)&&(n.deadline_epoch===void 0||Se(n.deadline_epoch))&&Ce(n.attempt);break;default:return null}return r?n:null}function Ee(e,t){return!e||e.readyState!==WebSocket.OPEN?!1:(e.send(JSON.stringify(t)),!0)}function De(e){return e.byteLength<4?null:{pane:new DataView(e).getUint32(0,!0),data:new Uint8Array(e,4)}}function Oe(e){let[t,n]=(0,j.useState)({});return{recovery:t,setRecovery:n,cancelRecovery:(0,j.useCallback)(t=>{Ee(e.current,{type:`cancel_recovery`,pane:t})},[e])}}var ke=240,Ae=`cubic-bezier(0.2, 0, 0, 1)`;function je(){return typeof window>`u`||typeof window.matchMedia!=`function`||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function Me(e){return e instanceof HTMLElement&&typeof e.animate==`function`&&!je()}function Ne(e,t){if(!Me(e)){t();return}let n=!1,r=()=>{n||(n=!0,t())},i=e.animate([{opacity:1,transform:`translateY(0)`},{opacity:0,transform:`translateY(12px)`}],{duration:200,easing:Ae,fill:`forwards`});i.onfinish=r,i.oncancel=r}function Pe(e){Me(e)&&e.animate([{opacity:0},{opacity:1}],{duration:ke,easing:Ae})}var Fe={esc:`\x1B`,tab:` `,"shift-tab":`\x1B[Z`,"shift-left":`\x1B[1;2D`,"ctrl-b":``,"ctrl-c":``,"ctrl-d":``,"ctrl-z":``,"ctrl-l":`\f`,"ctrl-r":``,up:`\x1B[A`,down:`\x1B[B`,right:`\x1B[C`,left:`\x1B[D`},Ie={up:`\x1BOA`,down:`\x1BOB`,right:`\x1BOC`,left:`\x1BOD`};function Le(e,t=!1){if(t){let t=Ie[e];if(t)return t}return Fe[e]}function Re(e){if(e.length!==1)return null;if(e===` `)return`\0`;if(e===`?`)return``;let t=e.charCodeAt(0);return t>=97&&t<=122&&(t-=32),t<64||t>95?null:String.fromCharCode(t&31)}function ze(e,t){return e?t.startsWith(`\x1B`)?{data:t,armed:!0}:{data:Re(t)??t,armed:!1}:{data:t,armed:!1}}function Be(e,t){return e?t.startsWith(`\x1B`)?{data:t,armed:!0}:{data:[...t].length===1?`\x1b${t}`:t,armed:!1}:{data:t,armed:!1}}function Ve(e){return e===`shown`||e===`hidden`?e:null}function He(e,t){return e||t<768}var Ue=[{kind:`key`,key:`esc`,label:`Esc`,aria:`Escape`},{kind:`key`,key:`tab`,label:`Tab`,aria:`Tab`},{kind:`key`,key:`shift-tab`,label:`⇧Tab`,aria:`Shift Tab`},{kind:`latch`,latch:`alt`,label:`Alt`,aria:`Alt for the next key`},{kind:`latch`,latch:`ctrl`,label:`Ctrl`,aria:`Control for the next key`},{kind:`key`,key:`ctrl-b`,label:`^B`,aria:`Control B`},{kind:`key`,key:`ctrl-c`,label:`^C`,aria:`Control C`},{kind:`key`,key:`ctrl-d`,label:`^D`,aria:`Control D`},{kind:`key`,key:`ctrl-z`,label:`^Z`,aria:`Control Z`},{kind:`key`,key:`ctrl-l`,label:`^L`,aria:`Control L`},{kind:`key`,key:`ctrl-r`,label:`^R`,aria:`Control R`},{kind:`key`,key:`shift-left`,label:`⇧←`,aria:`Shift Left arrow`},{kind:`key`,key:`left`,label:`←`,aria:`Left arrow`},{kind:`key`,key:`down`,label:`↓`,aria:`Down arrow`},{kind:`key`,key:`up`,label:`↑`,aria:`Up arrow`},{kind:`key`,key:`right`,label:`→`,aria:`Right arrow`}];function We(e,t){return e!==null&&t.includes(e)?e:null}function Ge(e,t){return e!==null&&We(e,t)===null}function Ke(e,t){return e===t?null:t}function qe({socketRef:e,viewsRef:t,zoomed:n,zoomAskedRef:r,active:i,onForceFit:a}){let o=t=>Ee(e.current,t),s=()=>o({type:`create`,rows:24,cols:80}),c=e=>{let t=Ke(r.current===void 0?n:r.current,e);o({type:`zoom`,pane:t})&&(r.current=t)},l=()=>o({type:`claim_size`});return{create:s,toggleZoom:c,claimSize:()=>{l()&&a()},requestSize:l,closePane:e=>Ne(document.querySelector(`[data-pane-cell][data-pane-id="${e}"]`),()=>o({type:`close`,pane:e})),reorder:e=>o({type:`reorder`,order:e}),sendKey:e=>{if(i===null)return;let n=t.current.get(i)?.term.modes.applicationCursorKeysMode??!1;o({type:`input`,pane:i,data:Le(e,n)})}}}function Je(e){return e===`live`}function Ye(e,t,n,r,i){let a=r!==void 0&&r!==t.current;n&&(!e.current||a)&&i(),e.current=n,t.current=r??null}function Xe(e,t){let[n,r]=(0,j.useState)(0);return y(()=>{Je(e)&&Ee(t.current,{type:`claim_size`})},e===`live`),{refitEpoch:n,forceFit:(0,j.useCallback)(()=>r(e=>e+1),[])}}function Ze(){let[e,t]=(0,j.useState)(null),[n,r]=(0,j.useState)(`connecting`),[i,a]=(0,j.useState)(0),[o,s]=(0,j.useState)([]),[c,l]=(0,j.useState)(null),[u,d]=(0,j.useState)(null),[f,p]=(0,j.useState)({}),[m,h]=(0,j.useState)(null),[g,_]=(0,j.useState)(!0);return{pending:e,setPending:t,link:n,setLink:r,replayLeft:i,setReplayLeft:a,panes:o,setPanes:s,active:c,setActive:l,zoomed:u,setZoomed:d,titles:f,setTitles:p,closing:m,setClosing:h,ownsSize:g,setOwnsSize:_}}function Qe(e){let t=e.indexOf(`;`);if(t===-1)return{kind:`ignore`};let n=e.slice(0,t),r=e.slice(t+1);if(!tt(n)||r===`?`||r===``)return{kind:`ignore`};let i=nt(r);return i===null?{kind:`ignore`}:{kind:`write`,text:i}}var $e=`cpqs01234567`,et=`cs`;function tt(e){if(e===``)return!0;let t=[...e];return t.every(e=>$e.includes(e))?t.some(e=>et.includes(e)):!1}function nt(e){try{let t=atob(e),n=Uint8Array.from(t,e=>e.charCodeAt(0));return new TextDecoder(`utf-8`,{fatal:!0}).decode(n)}catch{return null}}var rt=1048576,it=262144,at=class{term;highWater;lowWater;items=[];outstanding=0;pumping=!1;barrierInFlight=null;constructor(e,t=rt,n=it){this.term=e,this.highWater=t,this.lowWater=n}write(e){this.items.push({kind:`bytes`,data:e}),this.pump()}barrier(e){this.items.push({kind:`barrier`,run:e,cancelled:!1}),this.pump()}clear(){for(let e of this.items)e.kind===`barrier`&&(e.cancelled=!0);this.items=[],this.barrierInFlight&&(this.barrierInFlight.cancelled=!0)}pump(){if(!this.pumping){this.pumping=!0;try{for(;this.items.length>0;){if(this.barrierInFlight)return;let e=this.items[0];if(e.kind===`barrier`){this.items.shift();let t={cancelled:e.cancelled};if(this.barrierInFlight=t,this.term.write(``,()=>{this.barrierInFlight=null,t.cancelled||e.run(),this.pump()}),this.barrierInFlight===t)return;continue}if(this.outstanding>=this.highWater)return;this.items.shift();let t=e.data.byteLength;this.outstanding+=t,this.term.write(e.data,()=>{this.outstanding-=t,this.outstanding<=this.lowWater&&this.pump()})}}finally{this.pumping=!1}}}},ot=new WeakMap;function st(e){let t=ot.get(e);return t||(t=new at(e),ot.set(e,t)),t}function ct(e,t){st(e).write(t)}function lt(e,t){st(e).barrier(t)}function ut(e){ot.get(e)?.clear()}function dt(e,t,n){lt(e,()=>{t.release(),n()})}function ft(e){let t=e[0];return Array.isArray(t)?t[0]:t}function pt(e,t,n){let r=t,i=()=>r;return e.parser.registerCsiHandler({final:`n`},i),e.parser.registerCsiHandler({prefix:`?`,final:`n`},i),e.parser.registerCsiHandler({final:`c`},i),e.parser.registerCsiHandler({prefix:`>`,final:`c`},i),e.parser.registerCsiHandler({prefix:`=`,final:`c`},i),e.parser.registerCsiHandler({intermediates:`$`,final:`p`},i),e.parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},i),e.parser.registerCsiHandler({final:`t`},e=>r&&[14,16,18].includes(ft(e)??-1)),e.parser.registerDcsHandler({intermediates:`$`,final:`q`},i),e.parser.registerDcsHandler({prefix:`?`,intermediates:`$`,final:`q`},i),e.parser.registerOscHandler(52,e=>(r||n(e),!0)),{begin(){r=!0},release(){r=!1}}}function mt(){return{active:!1,panes:new Map,order:[],zoomed:!1}}function ht(){return{containerRef:(0,j.useRef)(null),socketRef:(0,j.useRef)(null),viewsRef:(0,j.useRef)(new Map),bodyRefs:(0,j.useRef)(new Map),ptySizesRef:(0,j.useRef)(new Map),askedSizesRef:(0,j.useRef)(new Map),desiredSizesRef:(0,j.useRef)(new Map),ownsSizeRef:(0,j.useRef)(!0),sizeOwnerGenerationRef:(0,j.useRef)(null),pendingRef:(0,j.useRef)(new Map),replayRef:(0,j.useRef)(mt()),zoomAskedRef:(0,j.useRef)(void 0),slotRefs:(0,j.useRef)(new Map)}}function gt({socketRef:e,panes:t,active:r,zoom:i,link:a,commands:o,focusPane:s,cancelRecovery:c,openCompose:l}){let u=me(),d=(0,j.useRef)({commands:o,focusPane:s,cancelRecovery:c,openCompose:l,socketRef:e});d.current={commands:o,focusPane:s,cancelRecovery:c,openCompose:l,socketRef:e};let f=(0,j.useMemo)(()=>{let e={"terminal.newPane":()=>d.current.commands.create(),paneCursor:()=>({index:r===null?-1:t.indexOf(r),count:t.length})};t.length>0&&(e.focusPaneAt=e=>{let n=t[e];n!==void 0&&(i!==null&&n!==i?d.current.commands.toggleZoom(n):d.current.focusPane(n))});for(let r of v){let i=n(r.id);if(i===null)continue;let a=A(t,i);a!==null&&(e[r.id]=()=>d.current.focusPane(a))}return r===null||(e[`terminal.closePane`]=()=>d.current.commands.closePane(r),e[`terminal.claimSizing`]=()=>d.current.commands.claimSize(),e[`terminal.cancelRecovery`]=()=>d.current.cancelRecovery(r),e[`terminal.composeMessage`]=()=>d.current.openCompose(),e[`terminal.swapPanePrompt`]=_t,e.swapPanes=e=>{let n=A(t,e);n!==null&&d.current.commands.reorder(ne(t,r,n))},e.zoomActivePane=()=>d.current.commands.toggleZoom(r),e.sendInput=e=>void Ee(d.current.socketRef.current,{type:`input`,pane:r,data:e})),e},[t,r,i]);he(f);let p=u?.disarm;(0,j.useEffect)(()=>{a!==`live`&&p?.()},[a,p])}function _t(){}function vt({termHeight:e,bodyHeight:t,rows:n,cursorRow:r,atLive:i}){let a=e-t;if(a<=0||n<=0||!i)return 0;let o=e/n,s=(Math.min(Math.max(r,0),n-1)+1)*o,c=Math.min(Math.max(s-t,0),a);return Math.round(a-c)}function yt({panes:e,viewsRef:t,bodyRefs:n,keyboardOpen:r,size:i,zoomed:a,mode:o}){(0,j.useEffect)(()=>{let r=[];for(let i of e){let e=t.current.get(i),a=n.current.get(i),o=e?.term.element;if(!e||!a||!o)continue;let{term:s}=e,c=()=>{let e=s.buffer.active,t=vt({termHeight:o.offsetHeight,bodyHeight:a.clientHeight,rows:s.rows,cursorRow:e.cursorY,atLive:e.viewportY===e.baseY}),n=t>0?`-${t}px`:``;o.style.marginBottom!==n&&(o.style.marginBottom=n)};c();let l=s.onRender(c),u=s.onScroll(c),d=new ResizeObserver(c);d.observe(a),r.push(()=>{l.dispose(),u.dispose(),d.disconnect()})}return()=>{for(let e of r)e()}},[e,t,n,r,i,a,o])}function bt({repo:e,panes:t,replayLeft:n,active:r,setActive:i,zoomed:s,zoom:c,viewsRef:l,panelRef:u,size:d,mode:f}){(0,j.useEffect)(()=>{if(Ge(s,t))return;let a=g(r,t,n,k(e));a!==null&&(i(a),se(e,a))},[r,t,n,e,s,i]),(0,j.useEffect)(()=>{c!==null&&c!==r&&(i(c),se(e,c))},[c,r,e,i]);let p=(0,j.useRef)(null);(0,j.useEffect)(()=>{let e=r===null?void 0:l.current.get(r),t=e?.term.element,n=o(r,!!t&&t.clientHeight>0,p.current);if(!n.focus||!e){p.current=n.held;return}let i=a(document.activeElement,u.current);pe(i)&&(e.term.focus(),p.current=n.held)},[r,t,d,f,c,l,u])}var xt=60;function St({panes:e,size:t,zoomed:n,mode:r,screenScale:i,socketRef:a,viewsRef:o,bodyRefs:s,ptySizesRef:c,desiredSizesRef:l,askedSizesRef:u,ownsSize:d,layoutPending:f,keyboardOpen:p,refitEpoch:m}){let h=(0,j.useRef)(null),g=(0,j.useRef)(m),_=(0,j.useCallback)(()=>{for(let[e,t]of o.current){let n=s.current.get(e);if(!n||n.clientHeight===0||n.clientWidth===0)continue;let r=l.current.get(e)??{rows:t.term.rows,cols:t.term.cols},i=u.current.get(e);i&&i.rows===r.rows&&i.cols===r.cols||Ee(a.current,{type:`resize`,pane:e,rows:r.rows,cols:r.cols})&&u.current.set(e,r)}},[a,o,s,u,l]);(0,j.useEffect)(()=>{if(!p){g.current!==m&&(u.current.clear(),g.current=m);for(let[e,t]of o.current){let n=s.current.get(e);if(n&&n.clientHeight!==0&&n.clientWidth!==0){if(!d||f){let n=c.current.get(e);n?(t.term.resize(n.cols,n.rows),l.current.set(e,n)):t.term.resize(t.term.cols,t.term.rows)}else t.term.resize(t.term.cols,t.term.rows),t.fit.fit(),l.current.set(e,{rows:t.term.rows,cols:t.term.cols})}}if(d&&!f)return h.current&&clearTimeout(h.current),h.current=setTimeout(_,xt),()=>{h.current&&clearTimeout(h.current)}}},[e,n,r,i,m,t,_,o,s,c,l,u,d,f,p])}var Ct=Object.defineProperty,wt=Object.getOwnPropertyDescriptor,Tt=(e,t)=>{for(var n in t)Ct(e,n,{get:t[n],enumerable:!0})},M=(e,t,n,r)=>{for(var i=r>1?void 0:r?wt(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Ct(t,n,i),i},N=(e,t)=>(n,r)=>t(n,r,e),Et=`Terminal input`,Dt={get:()=>Et,set:e=>Et=e},Ot=`Too much output to announce, navigate to rows manually to read`,kt={get:()=>Ot,set:e=>Ot=e};function At(e){return e.replace(/\r?\n/g,`\r`)}function jt(e,t){return t?`\x1B[200~`+e+`\x1B[201~`:e}function Mt(e,t){e.clipboardData&&e.clipboardData.setData(`text/plain`,t.selectionText),e.preventDefault()}function Nt(e,t,n,r){e.stopPropagation(),e.clipboardData&&Pt(e.clipboardData.getData(`text/plain`),t,n,r)}function Pt(e,t,n,r){e=At(e),e=jt(e,n.decPrivateModes.bracketedPasteMode&&r.rawOptions.ignoreBracketedPasteMode!==!0),n.triggerDataEvent(e,!0),t.value=``}function Ft(e,t,n){let r=n.getBoundingClientRect(),i=e.clientX-r.left-10,a=e.clientY-r.top-10;t.style.width=`20px`,t.style.height=`20px`,t.style.left=`${i}px`,t.style.top=`${a}px`,t.style.zIndex=`1000`,t.focus()}function It(e,t,n,r,i){Ft(e,t,n),i&&r.rightClickSelect(e),t.value=r.selectionText,t.select()}function Lt(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Rt(e,t=0,n=e.length){let r=``;for(let i=t;i65535?(t-=65536,r+=String.fromCharCode((t>>10)+55296)+String.fromCharCode(t%1024+56320)):r+=String.fromCharCode(t)}return r}var zt=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i=0;if(this._interim){let n=e.charCodeAt(i++);56320<=n&&n<=57343?t[r++]=(this._interim-55296)*1024+n-56320+65536:(t[r++]=this._interim,t[r++]=n),this._interim=0}for(let a=i;a=n)return this._interim=i,r;let o=e.charCodeAt(a);56320<=o&&o<=57343?t[r++]=(i-55296)*1024+o-56320+65536:(t[r++]=i,t[r++]=o)}else i!==65279&&(t[r++]=i)}return r}},Bt=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let n=e.length;if(!n)return 0;let r=0,i,a,o,s,c=0,l=0;if(this.interim[0]){let i=!1,a=this.interim[0];a&=(a&224)==192?31:(a&240)==224?15:7;let o=0,s;for(;(s=this.interim[++o]&63)&&o<4;)a<<=6,a|=s;let c=(this.interim[0]&224)==192?2:(this.interim[0]&240)==224?3:4,u=c-o;for(;l=n)return 0;if(s=e[l++],(s&192)!=128){l--,i=!0;break}this.interim[o++]=s,a<<=6,a|=s&63}i||(c===2?a<128?l--:t[r++]=a:c===3?a<2048||a>=55296&&a<=57343||a===65279||(t[r++]=a):a<65536||a>1114111||(t[r++]=a)),this.interim.fill(0)}let u=n-4,d=l;for(;d=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128||(c=(i&31)<<6|a&63,c<128)){d--;continue}t[r++]=c}else if((i&240)==224){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(c=(i&15)<<12|(a&63)<<6|o&63,c<2048||c>=55296&&c<=57343||c===65279)continue;t[r++]=c}else if((i&248)==240){if(d>=n)return this.interim[0]=i,r;if(a=e[d++],(a&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,r;if(o=e[d++],(o&192)!=128){d--;continue}if(d>=n)return this.interim[0]=i,this.interim[1]=a,this.interim[2]=o,r;if(s=e[d++],(s&192)!=128){d--;continue}if(c=(i&7)<<18|(a&63)<<12|(o&63)<<6|s&63,c<65536||c>1114111)continue;t[r++]=c}}return r}},Vt=``,Ht=` `,Ut=class e{constructor(){this.fg=0,this.bg=0,this.extended=new Wt}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Wt=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},Gt=class e extends Ut{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Wt,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Lt(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Kt=`di$target`,qt=`di$dependencies`,Jt=new Map;function Yt(e){return e[qt]||[]}function Xt(e){if(Jt.has(e))return Jt.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Zt(t,e,r)};return t._id=e,Jt.set(e,t),t}function Zt(e,t,n){t[Kt]===t?t[qt].push({id:e,index:n}):(t[qt]=[{id:e,index:n}],t[Kt]=t)}var Qt=Xt(`BufferService`),$t=Xt(`CoreMouseService`),en=Xt(`CoreService`),tn=Xt(`CharsetService`),nn=Xt(`InstantiationService`),rn=Xt(`LogService`),an=Xt(`OptionsService`),on=Xt(`OscLinkService`),sn=Xt(`UnicodeService`),cn=Xt(`DecorationService`),ln=class{constructor(e,t,n){this._bufferService=e,this._optionsService=t,this._oscLinkService=n}provideLinks(e,t){let n=this._bufferService.buffer.lines.get(e-1);if(!n){t(void 0);return}let r=[],i=this._optionsService.rawOptions.linkHandler,a=new Gt,o=n.getTrimmedLength(),s=-1,c=-1,l=!1;for(let t=0;ti?i.activate(e,t,a):un(e,t),hover:(e,t)=>i?.hover?.(e,t,a),leave:(e,t)=>i?.leave?.(e,t,a)})}l=!1,a.hasExtendedAttrs()&&a.extended.urlId?(c=t,s=a.extended.urlId):(c=-1,s=-1)}}t(r)}};ln=M([N(0,Qt),N(1,an),N(2,on)],ln);function un(e,t){if(confirm(`Do you want to navigate to ${t}? + +WARNING: This link could potentially be dangerous`)){let e=window.open();if(e){try{e.opener=null}catch{}e.location.href=t}else console.warn(`Opening link blocked as opener could not be cleared`)}}var dn=Xt(`CharSizeService`),fn=Xt(`CoreBrowserService`),pn=Xt(`MouseService`),mn=Xt(`RenderService`),hn=Xt(`SelectionService`),gn=Xt(`CharacterJoinerService`),_n=Xt(`ThemeService`),vn=Xt(`LinkProviderService`),yn=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Tn.isErrorNoTelemetry(e)?new Tn(e.message+` + +`+e.stack):Error(e.message+` + +`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function bn(e){Sn(e)||yn.onUnexpectedError(e)}var xn=`Canceled`;function Sn(e){return e instanceof Cn||e instanceof Error&&e.name===xn&&e.message===xn}var Cn=class extends Error{constructor(){super(xn),this.name=this.message}};function wn(e){return Error(e?`Illegal argument: ${e}`:`Illegal argument`)}var Tn=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},En=class e extends Error{constructor(t){super(t||`An unexpected bug occurred.`),Object.setPrototypeOf(this,e.prototype)}};function Dn(e,t=0){return e[e.length-(1+t)]}var On;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(On||={});var kn=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||On.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};kn.empty=new kn(e=>{});function An(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var jn;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function Rn(...e){return P(()=>Ln(e))}function P(e){let t=Nn({dispose:An(()=>{Pn(t),e()})});return t}var zn=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,Nn(this)}dispose(){this._isDisposed||(Pn(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Ln(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return Fn(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),Fn(e,null))}};zn.DISABLE_DISPOSED_WARNING=!1;var Bn=zn,F=class{constructor(){this._store=new Bn,Nn(this),Fn(this._store,this)}dispose(){Pn(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};F.None=Object.freeze({dispose(){}});var Vn=class{constructor(){this._isDisposed=!1,Nn(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&Fn(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,Pn(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&Fn(e,null),e}},Hn=typeof window==`object`?window:globalThis,Un=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};Un.Undefined=new Un(void 0);var I=Un,Wn=class{constructor(){this._first=I.Undefined,this._last=I.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===I.Undefined}clear(){let e=this._first;for(;e!==I.Undefined;){let t=e.next;e.prev=I.Undefined,e.next=I.Undefined,e=t}this._first=I.Undefined,this._last=I.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let n=new I(e);if(this._first===I.Undefined)this._first=n,this._last=n;else if(t){let e=this._last;this._last=n,n.prev=e,e.next=n}else{let e=this._first;this._first=n,n.next=e,e.prev=n}this._size+=1;let r=!1;return()=>{r||(r=!0,this._remove(n))}}shift(){if(this._first!==I.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==I.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==I.Undefined&&e.next!==I.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===I.Undefined&&e.next===I.Undefined?(this._first=I.Undefined,this._last=I.Undefined):e.next===I.Undefined?(this._last=this._last.prev,this._last.next=I.Undefined):e.prev===I.Undefined&&(this._first=this._first.next,this._first.prev=I.Undefined);--this._size}*[Symbol.iterator](){let e=this._first;for(;e!==I.Undefined;)yield e.element,e=e.next}},Gn=globalThis.performance&&typeof globalThis.performance.now==`function`,Kn=class e{static create(t){return new e(t)}constructor(e){this._now=Gn&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},qn;(e=>{e.None=()=>F.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(Rn(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new L({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new L({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new L({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new L({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new L({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function S(e){let t=new L;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function ee(e,t){return e(e=>t.fire(e))}e.forward=ee;function C(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=C;class w{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new L(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function T(e,t){return new w(e,t).emitter.event}e.fromObservable=T;function E(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof Bn?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=E})(qn||={});var Jn=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new Kn,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Jn.all=new Set,Jn._idPool=0;var Yn=Jn,Xn=-1,Zn=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t0||this._options?.leakWarningThreshold?new Qn(e?.onListenerError??bn,this._options?.leakWarningThreshold??Xn):void 0,this._perfMon=this._options?._profName?new Yn(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new tr(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||bn)(n),F.None}if(this._disposed)return F.None;t&&(e=e.bind(t));let r=new rr(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=$n.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof rr?(this._deliveryQueue??=new ar,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=P(()=>{i?.(),this._removeListener(r)});return n instanceof Bn?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*ir<=t.length){let e=0;for(let n=0;n0}},ar=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},or=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new L,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new L,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(e){return this.mapWindowIdToZoomLevel.get(this.getWindowId(e))??0}setZoomLevel(e,t){if(this.getZoomLevel(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToZoomLevel.set(n,e),this._onDidChangeZoomLevel.fire(n)}getZoomFactor(e){return this.mapWindowIdToZoomFactor.get(this.getWindowId(e))??1}setZoomFactor(e,t){this.mapWindowIdToZoomFactor.set(this.getWindowId(t),e)}setFullscreen(e,t){if(this.isFullscreen(t)===e)return;let n=this.getWindowId(t);this.mapWindowIdToFullScreen.set(n,e),this._onDidChangeFullscreen.fire(n)}isFullscreen(e){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(e))}getWindowId(e){return e.vscodeWindowId}};or.INSTANCE=new or;var sr=or;function cr(e,t,n){typeof t==`string`&&(t=e.matchMedia(t)),t.addEventListener(`change`,n)}sr.INSTANCE.onDidChangeZoomLevel;function lr(e){return sr.INSTANCE.getZoomFactor(e)}sr.INSTANCE.onDidChangeFullscreen;var ur=typeof navigator==`object`?navigator.userAgent:``,dr=ur.indexOf(`Firefox`)>=0,fr=ur.indexOf(`AppleWebKit`)>=0,pr=ur.indexOf(`Chrome`)>=0,mr=!pr&&ur.indexOf(`Safari`)>=0;ur.indexOf(`Electron/`),ur.indexOf(`Android`);var hr=!1;if(typeof Hn.matchMedia==`function`){let e=Hn.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=Hn.matchMedia(`(display-mode: fullscreen)`);hr=e.matches,cr(Hn,e,({matches:e})=>{hr&&t.matches||(hr=e)})}function gr(){return hr}var _r=`en`,vr=!1,yr=!1,br=!1,xr=!1,Sr=!1,Cr=_r,wr,Tr=globalThis,Er;typeof Tr.vscode<`u`&&typeof Tr.vscode.process<`u`?Er=Tr.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(Er=process);var Dr=typeof Er?.versions?.electron==`string`&&Er?.type===`renderer`;if(typeof Er==`object`){vr=Er.platform===`win32`,yr=Er.platform===`darwin`,br=Er.platform===`linux`,br&&Er.env.SNAP&&Er.env.SNAP_REVISION,Er.env.CI||Er.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Cr=_r;let e=Er.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,Cr=t.resolvedLanguage||_r,t.languagePack?.translationsConfigFile}catch{}xr=!0}else typeof navigator==`object`&&!Dr?(wr=navigator.userAgent,vr=wr.indexOf(`Windows`)>=0,yr=wr.indexOf(`Macintosh`)>=0,(wr.indexOf(`Macintosh`)>=0||wr.indexOf(`iPad`)>=0||wr.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,br=wr.indexOf(`Linux`)>=0,wr?.indexOf(`Mobi`),Sr=!0,Cr=globalThis._VSCODE_NLS_LANGUAGE||_r,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var Or=vr,kr=yr,Ar=br,jr=xr;Sr&&typeof Tr.importScripts==`function`&&Tr.origin;var Mr=wr,Nr=Cr,Pr;(e=>{function t(){return Nr}e.value=t;function n(){return Nr.length===2?Nr===`en`:Nr.length>=3&&Nr[0]===`e`&&Nr[1]===`n`&&Nr[2]===`-`}e.isDefaultVariant=n;function r(){return Nr===`en`}e.isDefault=r})(Pr||={});var Fr=typeof Tr.postMessage==`function`&&!Tr.importScripts;(()=>{if(Fr){let e=[];Tr.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n{let r=++t;e.push({id:r,callback:n}),Tr.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var Ir=!!(Mr&&Mr.indexOf(`Chrome`)>=0);Mr&&Mr.indexOf(`Firefox`),!Ir&&Mr&&Mr.indexOf(`Safari`),Mr&&Mr.indexOf(`Edg/`),Mr&&Mr.indexOf(`Android`);var Lr=typeof navigator==`object`?navigator:{};jr||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||Lr&&Lr.clipboard&&Lr.clipboard.writeText,jr||Lr&&Lr.clipboard&&Lr.clipboard.readText,jr||gr()||Lr.keyboard,`ontouchstart`in Hn||Lr.maxTouchPoints,Hn.PointerEvent&&(`ontouchstart`in Hn||navigator.maxTouchPoints);var Rr=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},zr=new Rr,Br=new Rr,Vr=new Rr,Hr=Array(230),Ur;(e=>{function t(e){return zr.keyCodeToStr(e)}e.toString=t;function n(e){return zr.strToKeyCode(e)}e.fromString=n;function r(e){return Br.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return Vr.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return Br.strToKeyCode(e)||Vr.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return zr.keyCodeToStr(e)}e.toElectronAccelerator=o})(Ur||={});var Wr=class e{constructor(e,t,n,r,i){this.ctrlKey=e,this.shiftKey=t,this.altKey=n,this.metaKey=r,this.keyCode=i}equals(t){return t instanceof e&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){return`K${this.ctrlKey?`1`:`0`}${this.shiftKey?`1`:`0`}${this.altKey?`1`:`0`}${this.metaKey?`1`:`0`}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new Gr([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},Gr=class{constructor(e){if(e.length===0)throw wn(`chords`);this.chords=e}getHashCode(){let e=``;for(let t=0,n=this.chords.length;t{function t(t){return t===e.None||t===e.Cancelled||t instanceof ai?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:qn.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:ri})})(ii||={});var ai=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?ri:(this._emitter||=new L,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}},oi=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e==`function`&&typeof t==`number`&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new En(`Calling 'cancelAndSet' on a disposed TimeoutTimer`);this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new En(`Calling 'setIfNotSet' on a disposed TimeoutTimer`);this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},si=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){this.disposable?.dispose(),this.disposable=void 0}cancelAndSet(e,t,n=globalThis){if(this.isDisposed)throw new En(`Calling 'cancelAndSet' on a disposed IntervalTimer`);this.cancel();let r=n.setInterval(()=>{e()},t);this.disposable=P(()=>{n.clearInterval(r),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var ci;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(ci||={});var li=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new L,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};li.EMPTY=li.fromArray([]);function ui(e){return di(e,0)}function di(e,t){switch(typeof e){case`object`:return e===null?fi(349,t):Array.isArray(e)?hi(e,t):gi(e,t);case`string`:return mi(e,t);case`boolean`:return pi(e,t);case`number`:return fi(e,t);case`undefined`:return fi(937,t);default:return fi(617,t)}}function fi(e,t){return(t<<5)-t+e|0}function pi(e,t){return fi(e?433:863,t)}function mi(e,t){t=fi(149417,t);for(let n=0,r=e.length;ndi(t,e),t)}function gi(e,t){return t=fi(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=mi(n,t),di(e[n],t)),t)}var{registerWindow:_i,getWindow:vi,getDocument:yi,getWindows:bi,getWindowsCount:xi,getWindowId:Si,getWindowById:Ci,hasWindow:wi,onDidRegisterWindow:Ti,onWillUnregisterWindow:Ei,onDidUnregisterWindow:Di}=function(){let e=new Map,t={window:Hn,disposables:new Bn};e.set(Hn.vscodeWindowId,t);let n=new L,r=new L,i=new L;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return F.None;let a=new Bn,o={window:t,disposables:a.add(new Bn)};return e.set(t.vscodeWindowId,o),a.add(P(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(R(t,Li.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:Hn},getDocument(e){return vi(e).document}}}(),Oi=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function R(e,t,n,r){return new Oi(e,t,n,r)}function ki(e,t){return function(n){return t(new ti(e,n))}}function Ai(e){return function(t){return e(new Zr(t))}}var ji=function(e,t,n,r){let i=n;return t===`click`||t===`mousedown`||t===`contextmenu`?i=ki(vi(e),n):(t===`keydown`||t===`keypress`||t===`keyup`)&&(i=Ai(n)),R(e,t,i,r)},Mi,Ni=class extends si{constructor(e){super(),this.defaultTarget=e&&vi(e)}cancelAndSet(e,t,n){return super.cancelAndSet(e,t,n??this.defaultTarget)}},Pi=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){bn(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,n=new Map,r=new Map,i=i=>{n.set(i,!1);let a=e.get(i)??[];for(t.set(i,a),e.set(i,[]),r.set(i,!0);a.length>0;)a.sort(Pi.sort),a.shift().execute();r.set(i,!1)};Mi=(t,r,a=0)=>{let o=Si(t),s=new Pi(r,a),c=e.get(o);return c||(c=[],e.set(o,c)),c.push(s),n.get(o)||(n.set(o,!0),t.requestAnimationFrame(()=>i(o))),s}})();var Fi=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};Fi.None=new Fi(0,0);function Ii(e){let t=e.getBoundingClientRect(),n=vi(e);return{left:t.left+n.scrollX,top:t.top+n.scrollY,width:t.width,height:t.height}}new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=ui(n),a=r.get(i);if(a)a.users+=1;else{let o=new L,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(P(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var Li={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:fr?`webkitAnimationStart`:`animationstart`,ANIMATION_END:fr?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:fr?`webkitAnimationIteration`:`animationiteration`},Ri=class{constructor(e){this.domNode=e,this._maxWidth=``,this._width=``,this._height=``,this._top=``,this._left=``,this._bottom=``,this._right=``,this._paddingTop=``,this._paddingLeft=``,this._paddingBottom=``,this._paddingRight=``,this._fontFamily=``,this._fontWeight=``,this._fontSize=``,this._fontStyle=``,this._fontFeatureSettings=``,this._fontVariationSettings=``,this._textDecoration=``,this._lineHeight=``,this._letterSpacing=``,this._className=``,this._display=``,this._position=``,this._visibility=``,this._color=``,this._backgroundColor=``,this._layerHint=!1,this._contain=`none`,this._boxShadow=``}setMaxWidth(e){let t=zi(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=zi(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=zi(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=zi(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=zi(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=zi(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=zi(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=zi(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=zi(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=zi(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=zi(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=zi(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=zi(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=zi(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?`translate3d(0px, 0px, 0px)`:``)}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function zi(e){return typeof e==`number`?`${e}px`:e}function Bi(e){return new Ri(e)}var Vi=class{constructor(){this._hooks=new Bn,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let n=this._onStopCallback;this._onStopCallback=null,e&&n&&n(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,n,r,i){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=r,this._onStopCallback=i;let a=e;try{e.setPointerCapture(t),this._hooks.add(P(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{a=vi(e)}this._hooks.add(R(a,Li.POINTER_MOVE,e=>{e.buttons===n?(e.preventDefault(),this._pointerMoveCallback(e)):this.stopMonitoring(!0)})),this._hooks.add(R(a,Li.POINTER_UP,e=>this.stopMonitoring(!0)))}};function Hi(e,t,n){let r=null,i=null;if(typeof n.value==`function`?(r=`value`,i=n.value,i.length!==0&&console.warn(`Memoize should only be used in functions with zero parameters`)):typeof n.get==`function`&&(r=`get`,i=n.get),!i)throw Error(`not supported`);let a=`$memoize$${t}`;n[r]=function(...e){return this.hasOwnProperty(a)||Object.defineProperty(this,a,{configurable:!1,enumerable:!1,writable:!1,value:i.apply(this,e)}),this[a]}}var Ui;(e=>(e.Tap=`-xterm-gesturetap`,e.Change=`-xterm-gesturechange`,e.Start=`-xterm-gesturestart`,e.End=`-xterm-gesturesend`,e.Contextmenu=`-xterm-gesturecontextmenu`))(Ui||={});var Wi=class e extends F{constructor(){super(),this.dispatched=!1,this.targets=new Wn,this.ignoreTargets=new Wn,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(qn.runAndSubscribe(Ti,({window:e,disposables:t})=>{t.add(R(e.document,`touchstart`,e=>this.onTouchStart(e),{passive:!1})),t.add(R(e.document,`touchend`,t=>this.onTouchEnd(e,t))),t.add(R(e.document,`touchmove`,e=>this.onTouchMove(e),{passive:!1}))},{window:Hn,disposables:this._store}))}static addTarget(t){return e.isTouchDevice()?(e.INSTANCE||=In(new e),P(e.INSTANCE.targets.push(t))):F.None}static ignoreTarget(t){return e.isTouchDevice()?(e.INSTANCE||=In(new e),P(e.INSTANCE.ignoreTargets.push(t))):F.None}static isTouchDevice(){return`ontouchstart`in Hn||navigator.maxTouchPoints>0}dispose(){this.handle&&=(this.handle.dispose(),null),super.dispose()}onTouchStart(e){let t=Date.now();this.handle&&=(this.handle.dispose(),null);for(let n=0,r=e.targetTouches.length;n=e.HOLD_DELAY&&Math.abs(s.initialPageX-Dn(s.rollingPageX))<30&&Math.abs(s.initialPageY-Dn(s.rollingPageY))<30){let e=this.newGestureEvent(Ui.Contextmenu,s.initialTarget);e.pageX=Dn(s.rollingPageX),e.pageY=Dn(s.rollingPageY),this.dispatchEvent(e)}else if(i===1){let e=Dn(s.rollingPageX),n=Dn(s.rollingPageY),i=Dn(s.rollingTimestamps)-s.rollingTimestamps[0],a=e-s.rollingPageX[0],o=n-s.rollingPageY[0],c=[...this.targets].filter(e=>s.initialTarget instanceof Node&&e.contains(s.initialTarget));this.inertia(t,c,r,Math.abs(a)/i,a>0?1:-1,e,Math.abs(o)/i,o>0?1:-1,n)}this.dispatchEvent(this.newGestureEvent(Ui.End,s.initialTarget)),delete this.activeTouches[o.identifier]}this.dispatched&&=(n.preventDefault(),n.stopPropagation(),!1)}newGestureEvent(e,t){let n=document.createEvent(`CustomEvent`);return n.initEvent(e,!1,!0),n.initialTarget=t,n.tapCount=0,n}dispatchEvent(t){if(t.type===Ui.Tap){let n=new Date().getTime(),r=0;r=n-this._lastSetTapCountTime>e.CLEAR_TAP_COUNT_TIME?1:2,this._lastSetTapCountTime=n,t.tapCount=r}else(t.type===Ui.Change||t.type===Ui.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let e of this.ignoreTargets)if(e.contains(t.initialTarget))return;let e=[];for(let n of this.targets)if(n.contains(t.initialTarget)){let r=0,i=t.initialTarget;for(;i&&i!==n;)r++,i=i.parentElement;e.push([r,n])}e.sort((e,t)=>e[0]-t[0]);for(let[n,r]of e)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,n,r,i,a,o,s,c,l){this.handle=Mi(t,()=>{let u=Date.now(),d=u-r,f=0,p=0,m=!0;i+=e.SCROLL_FRICTION*d,s+=e.SCROLL_FRICTION*d,i>0&&(m=!1,f=a*i*d),s>0&&(m=!1,p=c*s*d);let h=this.newGestureEvent(Ui.Change);h.translationX=f,h.translationY=p,n.forEach(e=>e.dispatchEvent(h)),m||this.inertia(t,n,u,i,a,o+f,s,c,l+p)})}onTouchMove(e){let t=Date.now();for(let n=0,r=e.changedTouches.length;n3&&(i.rollingPageX.shift(),i.rollingPageY.shift(),i.rollingTimestamps.shift()),i.rollingPageX.push(r.pageX),i.rollingPageY.push(r.pageY),i.rollingTimestamps.push(t)}this.dispatched&&=(e.preventDefault(),e.stopPropagation(),!1)}};Wi.SCROLL_FRICTION=-.005,Wi.HOLD_DELAY=700,Wi.CLEAR_TAP_COUNT_TIME=400,M([Hi],Wi,`isTouchDevice`,1);var Gi=Wi,Ki=class extends F{onclick(e,t){this._register(R(e,Li.CLICK,n=>t(new ti(vi(e),n))))}onmousedown(e,t){this._register(R(e,Li.MOUSE_DOWN,n=>t(new ti(vi(e),n))))}onmouseover(e,t){this._register(R(e,Li.MOUSE_OVER,n=>t(new ti(vi(e),n))))}onmouseleave(e,t){this._register(R(e,Li.MOUSE_LEAVE,n=>t(new ti(vi(e),n))))}onkeydown(e,t){this._register(R(e,Li.KEY_DOWN,e=>t(new Zr(e))))}onkeyup(e,t){this._register(R(e,Li.KEY_UP,e=>t(new Zr(e))))}oninput(e,t){this._register(R(e,Li.INPUT,t))}onblur(e,t){this._register(R(e,Li.BLUR,t))}onfocus(e,t){this._register(R(e,Li.FOCUS,t))}onchange(e,t){this._register(R(e,Li.CHANGE,t))}ignoreGesture(e){return Gi.ignoreTarget(e)}},qi=11,Ji=class extends Ki{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement(`div`),this.bgDomNode.className=`arrow-background`,this.bgDomNode.style.position=`absolute`,this.bgDomNode.style.width=e.bgWidth+`px`,this.bgDomNode.style.height=e.bgHeight+`px`,typeof e.top<`u`&&(this.bgDomNode.style.top=`0px`),typeof e.left<`u`&&(this.bgDomNode.style.left=`0px`),typeof e.bottom<`u`&&(this.bgDomNode.style.bottom=`0px`),typeof e.right<`u`&&(this.bgDomNode.style.right=`0px`),this.domNode=document.createElement(`div`),this.domNode.className=e.className,this.domNode.style.position=`absolute`,this.domNode.style.width=qi+`px`,this.domNode.style.height=qi+`px`,typeof e.top<`u`&&(this.domNode.style.top=e.top+`px`),typeof e.left<`u`&&(this.domNode.style.left=e.left+`px`),typeof e.bottom<`u`&&(this.domNode.style.bottom=e.bottom+`px`),typeof e.right<`u`&&(this.domNode.style.right=e.right+`px`),this._pointerMoveMonitor=this._register(new Vi),this._register(ji(this.bgDomNode,Li.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._register(ji(this.domNode,Li.POINTER_DOWN,e=>this._arrowPointerDown(e))),this._pointerdownRepeatTimer=this._register(new Ni),this._pointerdownScheduleRepeatTimer=this._register(new oi)}_arrowPointerDown(e){e.target&&e.target instanceof Element&&(this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,vi(e))},200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault())}},Yi=class e{constructor(e,t,n,r,i,a,o){this._forceIntegerValues=e,this._scrollStateBrand=void 0,this._forceIntegerValues&&(t|=0,n|=0,r|=0,i|=0,a|=0,o|=0),this.rawScrollLeft=r,this.rawScrollTop=o,t<0&&(t=0),r+t>n&&(r=n-t),r<0&&(r=0),i<0&&(i=0),o+i>a&&(o=a-i),o<0&&(o=0),this.width=t,this.scrollWidth=n,this.scrollLeft=r,this.height=i,this.scrollHeight=a,this.scrollTop=o}equals(e){return this.rawScrollLeft===e.rawScrollLeft&&this.rawScrollTop===e.rawScrollTop&&this.width===e.width&&this.scrollWidth===e.scrollWidth&&this.scrollLeft===e.scrollLeft&&this.height===e.height&&this.scrollHeight===e.scrollHeight&&this.scrollTop===e.scrollTop}withScrollDimensions(t,n){return new e(this._forceIntegerValues,typeof t.width<`u`?t.width:this.width,typeof t.scrollWidth<`u`?t.scrollWidth:this.scrollWidth,n?this.rawScrollLeft:this.scrollLeft,typeof t.height<`u`?t.height:this.height,typeof t.scrollHeight<`u`?t.scrollHeight:this.scrollHeight,n?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new e(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<`u`?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<`u`?t.scrollTop:this.rawScrollTop)}createScrollEvent(e,t){let n=this.width!==e.width,r=this.scrollWidth!==e.scrollWidth,i=this.scrollLeft!==e.scrollLeft,a=this.height!==e.height,o=this.scrollHeight!==e.scrollHeight,s=this.scrollTop!==e.scrollTop;return{inSmoothScrolling:t,oldWidth:e.width,oldScrollWidth:e.scrollWidth,oldScrollLeft:e.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:e.height,oldScrollHeight:e.scrollHeight,oldScrollTop:e.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:n,scrollWidthChanged:r,scrollLeftChanged:i,heightChanged:a,scrollHeightChanged:o,scrollTopChanged:s}}},Xi=class extends F{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new L),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Yi(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){let n=this._state.withScrollDimensions(e,t);this._setState(n,!!this._smoothScrolling),this._smoothScrolling?.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&=(this._smoothScrolling.dispose(),null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>`u`?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>`u`?this._smoothScrolling.to.scrollTop:e.scrollTop};let n=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===n.scrollLeft&&this._smoothScrolling.to.scrollTop===n.scrollTop)return;let r;r=t?new ea(this._smoothScrolling.from,n,this._smoothScrolling.startTime,this._smoothScrolling.duration):this._smoothScrolling.combine(this._state,n,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=r}else{let t=this._state.withScrollPosition(e);this._smoothScrolling=ea.start(this._state,t,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let n=this._state;n.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(n,t)))}},Zi=class{constructor(e,t,n){this.scrollLeft=e,this.scrollTop=t,this.isDone=n}};function Qi(e,t){let n=t-e;return function(t){return e+n*na(t)}}function $i(e,t,n){return function(r){return r2.5*n){let r,i;return e{this._domNode?.setClassName(this._visibleClassName)},0))}_hide(e){this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,this._domNode?.setClassName(this._invisibleClassName+(e?` fade`:``)))}},ia=140,aa=class extends Ki{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new ra(e.visibility,`visible scrollbar `+e.extraScrollbarClassName,`invisible scrollbar `+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Vi),this._shouldRender=!0,this.domNode=Bi(document.createElement(`div`)),this.domNode.setAttribute(`role`,`presentation`),this.domNode.setAttribute(`aria-hidden`,`true`),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition(`absolute`),this._register(R(this.domNode.domNode,Li.POINTER_DOWN,e=>this._domNodePointerDown(e)))}_createArrow(e){let t=this._register(new Ji(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,n,r){this.slider=Bi(document.createElement(`div`)),this.slider.setClassName(`slider`),this.slider.setPosition(`absolute`),this.slider.setTop(e),this.slider.setLeft(t),typeof n==`number`&&this.slider.setWidth(n),typeof r==`number`&&this.slider.setHeight(r),this.slider.setLayerHinting(!0),this.slider.setContain(`strict`),this.domNode.domNode.appendChild(this.slider.domNode),this._register(R(this.slider.domNode,Li.POINTER_DOWN,e=>{e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))})),this.onclick(this.slider.domNode,e=>{e.leftButton&&e.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,n=t+this._scrollbarState.getSliderPosition(),r=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),i=this._sliderPointerPosition(e);n<=i&&i<=r?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,n;if(e.target===this.domNode.domNode&&typeof e.offsetX==`number`&&typeof e.offsetY==`number`)t=e.offsetX,n=e.offsetY;else{let r=Ii(this.domNode.domNode);t=e.pageX-r.left,n=e.pageY-r.top}let r=this._pointerDownRelativePosition(t,n);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(r):this._scrollbarState.getDesiredScrollPositionFromOffset(r)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),n=this._sliderOrthogonalPointerPosition(e),r=this._scrollbarState.clone();this.slider.toggleClassName(`active`,!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,e=>{let i=this._sliderOrthogonalPointerPosition(e),a=Math.abs(i-n);if(Or&&a>ia){this._setDesiredScrollPositionNow(r.getScrollPosition());return}let o=this._sliderPointerPosition(e)-t;this._setDesiredScrollPositionNow(r.getDesiredScrollPositionFromDelta(o))},()=>{this.slider.toggleClassName(`active`,!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},oa=class e{constructor(e,t,n,r,i,a){this._scrollbarSize=Math.round(t),this._oppositeScrollbarSize=Math.round(n),this._arrowSize=Math.round(e),this._visibleSize=r,this._scrollSize=i,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new e(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(e){let t=Math.round(e);return this._visibleSize!==t&&(this._visibleSize=t,this._refreshComputedValues(),!0)}setScrollSize(e){let t=Math.round(e);return this._scrollSize!==t&&(this._scrollSize=t,this._refreshComputedValues(),!0)}setScrollPosition(e){let t=Math.round(e);return this._scrollPosition!==t&&(this._scrollPosition=t,this._refreshComputedValues(),!0)}setScrollbarSize(e){this._scrollbarSize=Math.round(e)}setOppositeScrollbarSize(e){this._oppositeScrollbarSize=Math.round(e)}static _computeValues(e,t,n,r,i){let a=Math.max(0,n-e),o=Math.max(0,a-2*t),s=r>0&&r>n;if(!s)return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(o),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(n*o/r))),l=(o-c)/(r-n),u=i*l;return{computedAvailableSize:Math.round(a),computedIsNeeded:s,computedSliderSize:Math.round(c),computedSliderRatio:l,computedSliderPosition:Math.round(u)}}_refreshComputedValues(){let t=e._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize-this._computedSliderSize/2;return Math.round(t/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(e){if(!this._computedIsNeeded)return 0;let t=e-this._arrowSize,n=this._scrollPosition;return t0&&Math.abs(e.deltaY)>0)return 1;let n=.5;if(this._isAlmostInt(e.deltaX)&&this._isAlmostInt(e.deltaY)||(n+=.25),t){let r=Math.abs(e.deltaX),i=Math.abs(e.deltaY),a=Math.abs(t.deltaX),o=Math.abs(t.deltaY),s=Math.max(Math.min(r,a),1),c=Math.max(Math.min(i,o),1),l=Math.max(r,a),u=Math.max(i,o);l%s===0&&u%c===0&&(n-=.5)}return Math.min(Math.max(n,0),1)}_isAlmostInt(e){return Math.abs(Math.round(e)-e)<.01}};pa.INSTANCE=new pa;var ma=pa,ha=class extends Ki{constructor(e,t,n){super(),this._onScroll=this._register(new L),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new L),this.onWillScroll=this._onWillScroll.event,this._options=_a(t),this._scrollable=n,this._register(this._scrollable.onScroll(e=>{this._onWillScroll.fire(e),this._onDidScroll(e),this._onScroll.fire(e)}));let r={onMouseWheel:e=>this._onMouseWheel(e),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new ca(this._scrollable,this._options,r)),this._horizontalScrollbar=this._register(new sa(this._scrollable,this._options,r)),this._domNode=document.createElement(`div`),this._domNode.className=`xterm-scrollable-element `+this._options.className,this._domNode.setAttribute(`role`,`presentation`),this._domNode.style.position=`relative`,this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Bi(document.createElement(`div`)),this._leftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Bi(document.createElement(`div`)),this._topShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Bi(document.createElement(`div`)),this._topLeftShadowDomNode.setClassName(`shadow`),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,e=>this._onMouseOver(e)),this.onmouseleave(this._listenOnDomNode,e=>this._onMouseLeave(e)),this._hideTimeout=this._register(new oi),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Ln(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,kr&&(this._options.className+=` mac`),this._domNode.className=`xterm-scrollable-element `+this._options.className}updateOptions(e){typeof e.handleMouseWheel<`u`&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<`u`&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<`u`&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<`u`&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<`u`&&(this._options.horizontal=e.horizontal),typeof e.vertical<`u`&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<`u`&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<`u`&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<`u`&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new ni(e))}_setListeningToMouseWheel(e){this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Ln(this._mouseWheelToDispose),e)&&this._mouseWheelToDispose.push(R(this._listenOnDomNode,Li.MOUSE_WHEEL,e=>{this._onMouseWheel(new ni(e))},{passive:!1}))}_onMouseWheel(e){if(e.browserEvent?.defaultPrevented)return;let t=ma.INSTANCE;da&&t.acceptStandardWheelEvent(e);let n=!1;if(e.deltaY||e.deltaX){let r=e.deltaY*this._options.mouseWheelScrollSensitivity,i=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&i+r===0?i=r=0:Math.abs(r)>=Math.abs(i)?i=0:r=0),this._options.flipAxes&&([r,i]=[i,r]);let a=!kr&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||a)&&!i&&(i=r,r=0),e.browserEvent&&e.browserEvent.altKey&&(i*=this._options.fastScrollSensitivity,r*=this._options.fastScrollSensitivity);let o=this._scrollable.getFutureScrollPosition(),s={};if(r){let e=ua*r,t=o.scrollTop-(e<0?Math.floor(e):Math.ceil(e));this._verticalScrollbar.writeScrollPosition(s,t)}if(i){let e=ua*i,t=o.scrollLeft-(e<0?Math.floor(e):Math.ceil(e));this._horizontalScrollbar.writeScrollPosition(s,t)}s=this._scrollable.validateScrollPosition(s),(o.scrollLeft!==s.scrollLeft||o.scrollTop!==s.scrollTop)&&(da&&this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(s):this._scrollable.setScrollPositionNow(s),n=!0)}let r=n;!r&&this._options.alwaysConsumeMouseWheel&&(r=!0),!r&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(r=!0),r&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,n=e.scrollLeft>0,r=n?` left`:``,i=t?` top`:``,a=n||t?` top-left-corner`:``;this._leftShadowDomNode.setClassName(`shadow${r}`),this._topShadowDomNode.setClassName(`shadow${i}`),this._topLeftShadowDomNode.setClassName(`shadow${a}${i}${r}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),la)}},ga=class extends ha{constructor(e,t,n){super(e,t,n)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function _a(e){let t={lazyRender:typeof e.lazyRender<`u`&&e.lazyRender,className:typeof e.className<`u`?e.className:``,useShadows:typeof e.useShadows<`u`?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<`u`?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<`u`&&e.flipAxes,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<`u`&&e.consumeMouseWheelIfScrollbarIsNeeded,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<`u`&&e.alwaysConsumeMouseWheel,scrollYToX:typeof e.scrollYToX<`u`&&e.scrollYToX,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<`u`?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<`u`?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<`u`?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<`u`?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<`u`?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<`u`?e.listenOnDomNode:null,horizontal:typeof e.horizontal<`u`?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<`u`?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<`u`&&e.horizontalHasArrows,vertical:typeof e.vertical<`u`?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<`u`?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<`u`&&e.verticalHasArrows,verticalSliderSize:typeof e.verticalSliderSize<`u`?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<`u`&&e.scrollByPage};return t.horizontalSliderSize=typeof e.horizontalSliderSize<`u`?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<`u`?e.verticalSliderSize:t.verticalScrollbarSize,kr&&(t.className+=` mac`),t}var va=class extends F{constructor(e,t,n,r,i,a,o,s){super(),this._bufferService=n,this._optionsService=o,this._renderService=s,this._onRequestScrollLines=this._register(new L),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let c=this._register(new Xi({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:e=>Mi(r.window,e)}));this._register(this._optionsService.onSpecificOptionChange(`smoothScrollDuration`,()=>{c.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new ga(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},c)),this._register(this._optionsService.onMultipleOptionChange([`scrollSensitivity`,`fastScrollSensitivity`,`overviewRuler`],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(i.onProtocolChange(e=>{this._scrollableElement.updateOptions({handleMouseWheel:!(e&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(qn.runAndSubscribe(a.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=a.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(P(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=r.mainDocument.createElement(`style`),t.appendChild(this._styleElement),this._register(P(()=>this._styleElement.remove())),this._register(qn.runAndSubscribe(a.onChangeColors,()=>{this._styleElement.textContent=[`.xterm .xterm-scrollable-element > .scrollbar > .slider {`,` background: ${a.colors.scrollbarSliderBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider:hover {`,` background: ${a.colors.scrollbarSliderHoverBackground.css};`,`}`,`.xterm .xterm-scrollable-element > .scrollbar > .slider.active {`,` background: ${a.colors.scrollbarSliderActiveBackground.css};`,`}`].join(` +`)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(e=>this._handleScroll(e)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:this._optionsService.rawOptions.overviewRuler?.width||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),n=t-this._bufferService.buffer.ydisp;n!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(n)),this._isHandlingScroll=!1}};va=M([N(2,Qt),N(3,fn),N(4,$t),N(5,_n),N(6,an),N(7,mn)],va);var ya=class extends F{constructor(e,t,n,r,i){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=n,this._decorationService=r,this._renderService=i,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement(`div`),this._container.classList.add(`xterm-decoration-container`),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(e=>this._removeDecoration(e))),this._register(P(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){let t=this._coreBrowserService.mainDocument.createElement(`div`);t.classList.add(`xterm-decoration`),t.classList.toggle(`xterm-decoration-top-layer`,e?.options?.layer===`top`),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let n=e.options.x??0;return n&&n>this._bufferService.cols&&(t.style.display=`none`),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display=`none`,e.onRenderEmitter.fire(e.element));else{let n=this._decorationElements.get(e);n||(n=this._createElement(e),e.element=n,this._decorationElements.set(e,n),this._container.appendChild(n),e.onDispose(()=>{this._decorationElements.delete(e),n.remove()})),n.style.display=this._altBufferIsActive?`none`:`block`,this._altBufferIsActive||(n.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,n.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,n.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,n.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(n)}}_refreshXPosition(e,t=e.element){if(!t)return;let n=e.options.x??0;(e.options.anchor||`left`)===`right`?t.style.right=n?`${n*this._renderService.dimensions.css.cell.width}px`:``:t.style.left=n?`${n*this._renderService.dimensions.css.cell.width}px`:``}_removeDecoration(e){this._decorationElements.get(e)?.remove(),this._decorationElements.delete(e),e.dispose()}};ya=M([N(1,Qt),N(2,fn),N(3,cn),N(4,mn)],ya);var ba=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,n){return t>=e.startBufferLine-this._linePadding[n||`full`]&&t<=e.endBufferLine+this._linePadding[n||`full`]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},xa={full:0,left:0,center:0,right:0},Sa={full:0,left:0,center:0,right:0},Ca={full:0,left:0,center:0,right:0},wa=class extends F{constructor(e,t,n,r,i,a,o,s){super(),this._viewportElement=e,this._screenElement=t,this._bufferService=n,this._decorationService=r,this._renderService=i,this._optionsService=a,this._themeService=o,this._coreBrowserService=s,this._colorZoneStore=new ba,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-decoration-overview-ruler`),this._refreshCanvasDimensions(),this._viewportElement.parentElement?.insertBefore(this._canvas,this._viewportElement),this._register(P(()=>this._canvas?.remove()));let c=this._canvas.getContext(`2d`);if(c)this._ctx=c;else throw Error(`Ctx cannot be null`);this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?`none`:`block`})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange(`overviewRuler`,()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){return this._optionsService.options.overviewRuler?.width||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Sa.full=this._canvas.width,Sa.left=e,Sa.center=t,Sa.right=e,this._refreshDrawHeightConstants(),Ca.full=1,Ca.left=1,Ca.center=1+Sa.left,Ca.right=1+Sa.left+Sa.center}_refreshDrawHeightConstants(){xa.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);xa.left=t,xa.center=t,xa.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*xa.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*xa.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*xa.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*xa.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let e of this._decorationService.decorations)this._colorZoneStore.addDecoration(e);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!==`full`&&this._renderColorZone(t);for(let t of e)t.position===`full`&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Ca[e.position||`full`],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-xa[e.position||`full`]/2),Sa[e.position||`full`],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+xa[e.position||`full`]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};wa=M([N(2,Qt),N(3,cn),N(4,mn),N(5,an),N(6,_n),N(7,fn)],wa);var z;(e=>(e.NUL=`\0`,e.SOH=``,e.STX=``,e.ETX=``,e.EOT=``,e.ENQ=``,e.ACK=``,e.BEL=`\x07`,e.BS=`\b`,e.HT=` `,e.LF=` +`,e.VT=`\v`,e.FF=`\f`,e.CR=`\r`,e.SO=``,e.SI=``,e.DLE=``,e.DC1=``,e.DC2=``,e.DC3=``,e.DC4=``,e.NAK=``,e.SYN=``,e.ETB=``,e.CAN=``,e.EM=``,e.SUB=``,e.ESC=`\x1B`,e.FS=``,e.GS=``,e.RS=``,e.US=``,e.SP=` `,e.DEL=``))(z||={});var Ta;(e=>(e.PAD=`€`,e.HOP=``,e.BPH=`‚`,e.NBH=`ƒ`,e.IND=`„`,e.NEL=`…`,e.SSA=`†`,e.ESA=`‡`,e.HTS=`ˆ`,e.HTJ=`‰`,e.VTS=`Š`,e.PLD=`‹`,e.PLU=`Œ`,e.RI=``,e.SS2=`Ž`,e.SS3=``,e.DCS=``,e.PU1=`‘`,e.PU2=`’`,e.STS=`“`,e.CCH=`”`,e.MW=`•`,e.SPA=`–`,e.EPA=`—`,e.SOS=`˜`,e.SGCI=`™`,e.SCI=`š`,e.CSI=`›`,e.ST=`œ`,e.OSC=``,e.PM=`ž`,e.APC=`Ÿ`))(Ta||={});var Ea;(e=>e.ST=`${z.ESC}\\`)(Ea||={});var Da=class{constructor(e,t,n,r,i,a){this._textarea=e,this._compositionView=t,this._bufferService=n,this._optionsService=r,this._coreService=i,this._renderService=a,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=``}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent=``,this._dataAlreadySent=``,this._compositionView.classList.add(`active`)}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(e){if(this._compositionView.classList.remove(`active`),this._isComposing=!1,e){let e={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let t;e.start+=this._dataAlreadySent.length,t=this._isComposing?this._textarea.value.substring(e.start,this._compositionPosition.start):this._textarea.value.substring(e.start),t.length>0&&this._coreService.triggerDataEvent(t,!0)}},0)}else{this._isSendingComposition=!1;let e=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(e,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,n=t.replace(e,``);this._dataAlreadySent=n,t.length>e.length?this._coreService.triggerDataEvent(n,!0):t.lengththis.updateCompositionElements(!0),0)}}};Da=M([N(2,Qt),N(3,an),N(4,en),N(5,mn)],Da);var Oa=0,ka=0,Aa=0,B=0,ja={css:`#00000000`,rgba:0},V;(e=>{function t(e,t,n,r){return r===void 0?`#${Pa(e)}${Pa(t)}${Pa(n)}`:`#${Pa(e)}${Pa(t)}${Pa(n)}${Pa(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(V||={});var H;(e=>{function t(e,t){if(B=(t.rgba&255)/255,B===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return Oa=a+Math.round((n-a)*B),ka=o+Math.round((r-o)*B),Aa=s+Math.round((i-s)*B),{css:V.toCss(Oa,ka,Aa),rgba:V.toRgba(Oa,ka,Aa)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=Na.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return V.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[Oa,ka,Aa]=Na.toChannels(t),{css:V.toCss(Oa,ka,Aa),rgba:t}}e.opaque=i;function a(e,t){return B=Math.round(t*255),[Oa,ka,Aa]=Na.toChannels(e.rgba),{css:V.toCss(Oa,ka,Aa,B),rgba:V.toRgba(Oa,ka,Aa,B)}}e.opacity=a;function o(e,t){return B=e.rgba&255,a(e,B*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(H||={});var U;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return Oa=parseInt(e.slice(1,2).repeat(2),16),ka=parseInt(e.slice(2,3).repeat(2),16),Aa=parseInt(e.slice(3,4).repeat(2),16),V.toColor(Oa,ka,Aa);case 5:return Oa=parseInt(e.slice(1,2).repeat(2),16),ka=parseInt(e.slice(2,3).repeat(2),16),Aa=parseInt(e.slice(3,4).repeat(2),16),B=parseInt(e.slice(4,5).repeat(2),16),V.toColor(Oa,ka,Aa,B);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return Oa=parseInt(r[1]),ka=parseInt(r[2]),Aa=parseInt(r[3]),B=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),V.toColor(Oa,ka,Aa,B);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[Oa,ka,Aa,B]=t.getImageData(0,0,1,1).data,B!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:V.toRgba(Oa,ka,Aa,B),css:e}}e.toColor=r})(U||={});var Ma;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(Ma||={});var Na;(e=>{function t(e,t){if(B=(t&255)/255,B===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return Oa=a+Math.round((n-a)*B),ka=o+Math.round((r-o)*B),Aa=s+Math.round((i-s)*B),V.toRgba(Oa,ka,Aa)}e.blend=t;function n(e,t,n){let a=Ma.relativeLuminance(e>>8),o=Ma.relativeLuminance(t>>8);if(Fa(a,o)>8));if(sFa(a,Ma.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=Fa(a,Ma.relativeLuminance(s>>8));if(cFa(a,Ma.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Fa(Ma.relativeLuminance2(o,s,c),Ma.relativeLuminance2(r,i,a));for(;l0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=Fa(Ma.relativeLuminance2(o,s,c),Ma.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Fa(Ma.relativeLuminance2(o,s,c),Ma.relativeLuminance2(r,i,a));for(;l>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(Na||={});function Pa(e){let t=e.toString(16);return t.length<2?`0`+t:t}function Fa(e,t){return e1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t1){let e=this._getJoinedRanges(r,o,a,t,i);for(let t=0;t=T,ie=D,O=this._workCell;if(f.length>0&&D===f[0][0]&&re){let r=f.shift(),i=this._isCellInSelection(r[0],t);for(v=r[0]+1;v=r[1],re?(ne=!0,O=new Ia(this._workCell,e.translateToString(!0,r[0],r[1]),r[1]-r[0]),ie=r[1]-1,m=O.getWidth()):T=r[1]}let k=this._isCellInSelection(D,t),A=n&&D===a,ae=te&&D>=l&&D<=u,oe=!1;this._decorationService.forEachDecorationAtCell(D,t,void 0,e=>{oe=!0});let se=O.getChars()||Ht;if(se===` `&&(O.isUnderline()||O.isOverline())&&(se=`\xA0`),w=m*s-c.get(se,O.isBold(),O.isItalic()),!h)h=this._document.createElement(`span`);else if(g&&(k&&C||!k&&!C&&O.bg===y)&&(k&&C&&p.selectionForeground||O.fg===b)&&O.extended.ext===x&&ae===S&&w===ee&&!A&&!ne&&!oe&&re){O.isInvisible()?_+=Ht:_+=se,g++;continue}else g&&(h.textContent=_),h=this._document.createElement(`span`),g=0,_=``;if(y=O.bg,b=O.fg,x=O.extended.ext,S=ae,ee=w,C=k,ne&&a>=D&&a<=ie&&(a=D),!this._coreService.isCursorHidden&&A&&this._coreService.isCursorInitialized){if(E.push(`xterm-cursor`),this._coreBrowserService.isFocused)o&&E.push(`xterm-cursor-blink`),E.push(r===`bar`?`xterm-cursor-bar`:r===`underline`?`xterm-cursor-underline`:`xterm-cursor-block`);else if(i)switch(i){case`outline`:E.push(`xterm-cursor-outline`);break;case`block`:E.push(`xterm-cursor-block`);break;case`bar`:E.push(`xterm-cursor-bar`);break;case`underline`:E.push(`xterm-cursor-underline`)}}if(O.isBold()&&E.push(`xterm-bold`),O.isItalic()&&E.push(`xterm-italic`),O.isDim()&&E.push(`xterm-dim`),_=O.isInvisible()?Ht:O.getChars()||Ht,O.isUnderline()&&(E.push(`xterm-underline-${O.extended.underlineStyle}`),_===` `&&(_=`\xA0`),!O.isUnderlineColorDefault())){if(O.isUnderlineColorRGB())h.style.textDecorationColor=`rgb(${Ut.toColorRGB(O.getUnderlineColor()).join(`,`)})`;else{let e=O.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&O.isBold()&&e<8&&(e+=8),h.style.textDecorationColor=p.ansi[e].css}}O.isOverline()&&(E.push(`xterm-overline`),_===` `&&(_=`\xA0`)),O.isStrikethrough()&&E.push(`xterm-strikethrough`),ae&&(h.style.textDecoration=`underline`);let ce=O.getFgColor(),le=O.getFgColorMode(),ue=O.getBgColor(),de=O.getBgColorMode(),fe=!!O.isInverse();if(fe){let e=ce;ce=ue,ue=e;let t=le;le=de,de=t}let pe,me,he=!1;this._decorationService.forEachDecorationAtCell(D,t,void 0,e=>{e.options.layer!==`top`&&he||(e.backgroundColorRGB&&(de=50331648,ue=e.backgroundColorRGB.rgba>>8&16777215,pe=e.backgroundColorRGB),e.foregroundColorRGB&&(le=50331648,ce=e.foregroundColorRGB.rgba>>8&16777215,me=e.foregroundColorRGB),he=e.options.layer===`top`)}),!he&&k&&(pe=this._coreBrowserService.isFocused?p.selectionBackgroundOpaque:p.selectionInactiveBackgroundOpaque,ue=pe.rgba>>8&16777215,de=50331648,he=!0,p.selectionForeground&&(le=50331648,ce=p.selectionForeground.rgba>>8&16777215,me=p.selectionForeground)),he&&E.push(`xterm-decoration-top`);let ge;switch(de){case 16777216:case 33554432:ge=p.ansi[ue],E.push(`xterm-bg-${ue}`);break;case 50331648:ge=V.toColor(ue>>16,ue>>8&255,ue&255),this._addStyle(h,`background-color:#${Wa((ue>>>0).toString(16),`0`,6)}`);break;default:fe?(ge=p.foreground,E.push(`xterm-bg-257`)):ge=p.background}switch(pe||O.isDim()&&(pe=H.multiplyOpacity(ge,.5)),le){case 16777216:case 33554432:O.isBold()&&ce<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(ce+=8),this._applyMinimumContrast(h,ge,p.ansi[ce],O,pe,void 0)||E.push(`xterm-fg-${ce}`);break;case 50331648:let e=V.toColor(ce>>16&255,ce>>8&255,ce&255);this._applyMinimumContrast(h,ge,e,O,pe,me)||this._addStyle(h,`color:#${Wa(ce.toString(16),`0`,6)}`);break;default:this._applyMinimumContrast(h,ge,p.foreground,O,pe,me)||fe&&E.push(`xterm-fg-257`)}E.length&&=(h.className=E.join(` `),0),!A&&!ne&&!oe&&re?g++:h.textContent=_,w!==this.defaultSpacing&&(h.style.letterSpacing=`${w}px`),d.push(h),D=ie}return h&&g&&(h.textContent=_),d}_applyMinimumContrast(e,t,n,r,i,a){if(this._optionsService.rawOptions.minimumContrastRatio===1||Ba(r.getCode()))return!1;let o=this._getContrastCache(r),s;if(!i&&!a&&(s=o.getColor(t.rgba,n.rgba)),s===void 0){let e=this._optionsService.rawOptions.minimumContrastRatio/(r.isDim()?2:1);s=H.ensureContrastRatio(i||t,a||n,e),o.setColor((i||t).rgba,(a||n).rgba,s??null)}return s?(this._addStyle(e,`color:${s.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute(`style`,`${e.getAttribute(`style`)||``}${t};`)}_isCellInSelection(e,t){let n=this._selectionStart,r=this._selectionEnd;return!n||!r?!1:this._columnSelectMode?n[0]<=r[0]?e>=n[0]&&t>=n[1]&&e=n[1]&&e>=r[0]&&t<=r[1]:t>n[1]&&t=n[0]&&e=n[0]}};Ua=M([N(1,gn),N(2,an),N(3,fn),N(4,en),N(5,cn),N(6,_n)],Ua);function Wa(e,t,n){for(;e.length0&&(this._flat[r]=t),t}let i=e;t&&(i+=`B`),n&&(i+=`I`);let a=this._holey.get(i);if(a===void 0){let r=0;t&&(r|=1),n&&(r|=2),a=this._measure(e,r),a>0&&this._holey.set(i,a)}return a}_measure(e,t){let n=this._measureElements[t];return n.textContent=e.repeat(32),n.offsetWidth/32}},Ka=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,n,r=!1){if(this.selectionStart=t,this.selectionEnd=n,!t||!n||t[0]===n[0]&&t[1]===n[1]){this.clear();return}let i=e.buffers.active.ydisp,a=t[1]-i,o=n[1]-i,s=Math.max(a,0),c=Math.min(o,e.rows-1);s>=e.rows||c<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0])}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n=this.startCol&&t=this.startCol):!1}};function qa(){return new Ka}var Ja=`xterm-dom-renderer-owner-`,Ya=`xterm-rows`,Xa=`xterm-fg-`,Za=`xterm-bg-`,Qa=`xterm-focus`,$a=`xterm-selection`,eo=1,to=class extends F{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f,p){super(),this._terminal=e,this._document=t,this._element=n,this._screenElement=r,this._viewportElement=i,this._helperContainer=a,this._linkifier2=o,this._charSizeService=c,this._optionsService=l,this._bufferService=u,this._coreService=d,this._coreBrowserService=f,this._themeService=p,this._terminalClass=eo++,this._rowElements=[],this._selectionRenderModel=qa(),this.onRequestRedraw=this._register(new L).event,this._rowContainer=this._document.createElement(`div`),this._rowContainer.classList.add(Ya),this._rowContainer.style.lineHeight=`normal`,this._rowContainer.setAttribute(`aria-hidden`,`true`),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement(`div`),this._selectionContainer.classList.add($a),this._selectionContainer.setAttribute(`aria-hidden`,`true`),this.dimensions=Va(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(e=>this._injectCss(e))),this._injectCss(this._themeService.colors),this._rowFactory=s.createInstance(Ua,document),this._element.classList.add(Ja+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(e=>this._handleLinkHover(e))),this._register(this._linkifier2.onHideLinkUnderline(e=>this._handleLinkLeave(e))),this._register(P(()=>{this._element.classList.remove(Ja+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Ga(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let e of this._rowElements)e.style.width=`${this.dimensions.css.canvas.width}px`,e.style.height=`${this.dimensions.css.cell.height}px`,e.style.lineHeight=`${this.dimensions.css.cell.height}px`,e.style.overflow=`hidden`;this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Ya} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement(`style`),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Ya} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Ya} .xterm-dim { color: ${H.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let n=`blink_underline_${this._terminalClass}`,r=`blink_bar_${this._terminalClass}`,i=`blink_block_${this._terminalClass}`;t+=`@keyframes ${n} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${r} { 50% { box-shadow: none; }}`,t+=`@keyframes ${i} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Ya}.${Qa} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${Ya}.${Qa} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Ya}.${Qa} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Ya} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Ya} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Ya} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Ya} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Ya} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${$a} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${$a} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${$a} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,r]of e.ansi.entries())t+=`${this._terminalSelector} .${Xa}${n} { color: ${r.css}; }${this._terminalSelector} .${Xa}${n}.xterm-dim { color: ${H.multiplyOpacity(r,.5).css}; }${this._terminalSelector} .${Za}${n} { background-color: ${r.css}; }`;t+=`${this._terminalSelector} .${Xa}257 { color: ${H.opaque(e.background).css}; }${this._terminalSelector} .${Xa}257.xterm-dim { color: ${H.multiplyOpacity(H.opaque(e.background),.5).css}; }${this._terminalSelector} .${Za}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get(`W`,!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let e=this._rowElements.length;e<=t;e++){let e=this._document.createElement(`div`);this._rowContainer.appendChild(e),this._rowElements.push(e)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Qa),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Qa),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,n){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,n),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,n),!this._selectionRenderModel.hasSelection))return;let r=this._selectionRenderModel.viewportStartRow,i=this._selectionRenderModel.viewportEndRow,a=this._selectionRenderModel.viewportCappedStartRow,o=this._selectionRenderModel.viewportCappedEndRow,s=this._document.createDocumentFragment();if(n){let n=e[0]>t[0];s.appendChild(this._createSelectionElement(a,n?t[0]:e[0],n?e[0]:t[0],o-a+1))}else{let n=r===a?e[0]:0,c=a===i?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(a,n,c));let l=o-a-1;if(s.appendChild(this._createSelectionElement(a+1,0,this._bufferService.cols,l)),a!==o){let e=i===o?t[0]:this._bufferService.cols;s.appendChild(this._createSelectionElement(o,0,e))}}this._selectionContainer.appendChild(s)}_createSelectionElement(e,t,n,r=1){let i=this._document.createElement(`div`),a=t*this.dimensions.css.cell.width,o=this.dimensions.css.cell.width*(n-t);return a+o>this.dimensions.css.canvas.width&&(o=this.dimensions.css.canvas.width-a),i.style.height=`${r*this.dimensions.css.cell.height}px`,i.style.top=`${e*this.dimensions.css.cell.height}px`,i.style.left=`${a}px`,i.style.width=`${o}px`,i}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let n=this._bufferService.buffer,r=n.ybase+n.y,i=Math.min(n.x,this._bufferService.cols-1),a=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,o=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,s=this._optionsService.rawOptions.cursorInactiveStyle;for(let c=e;c<=t;c++){let e=c+n.ydisp,t=this._rowElements[c],l=n.lines.get(e);if(!t||!l)break;t.replaceChildren(...this._rowFactory.createRow(l,e,e===r,o,s,i,a,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Ja}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,n,r,i,a){n<0&&(e=0),r<0&&(t=0);let o=this._bufferService.rows-1;n=Math.max(Math.min(n,o),0),r=Math.max(Math.min(r,o),0),i=Math.min(i,this._bufferService.cols);let s=this._bufferService.buffer,c=s.ybase+s.y,l=Math.min(s.x,i-1),u=this._optionsService.rawOptions.cursorBlink,d=this._optionsService.rawOptions.cursorStyle,f=this._optionsService.rawOptions.cursorInactiveStyle;for(let o=n;o<=r;++o){let p=o+s.ydisp,m=this._rowElements[o],h=s.lines.get(p);if(!m||!h)break;m.replaceChildren(...this._rowFactory.createRow(h,p,p===c,d,f,l,u,this.dimensions.css.cell.width,this._widthCache,a?o===n?e:0:-1,a?(o===r?t:i)-1:-1))}}};to=M([N(7,nn),N(8,dn),N(9,an),N(10,Qt),N(11,en),N(12,fn),N(13,_n)],to);var no=class extends F{constructor(e,t,n){super(),this._optionsService=n,this.width=0,this.height=0,this._onCharSizeChange=this._register(new L),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new ao(this._optionsService))}catch{this._measureStrategy=this._register(new io(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange([`fontFamily`,`fontSize`],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};no=M([N(2,an)],no);var ro=class extends F{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},io=class extends ro{constructor(e,t,n){super(),this._document=e,this._parentElement=t,this._optionsService=n,this._measureElement=this._document.createElement(`span`),this._measureElement.classList.add(`xterm-char-measure-element`),this._measureElement.textContent=`W`.repeat(32),this._measureElement.setAttribute(`aria-hidden`,`true`),this._measureElement.style.whiteSpace=`pre`,this._measureElement.style.fontKerning=`none`,this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},ao=class extends ro{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext(`2d`);let t=this._ctx.measureText(`W`);if(!(`width`in t&&`fontBoundingBoxAscent`in t&&`fontBoundingBoxDescent`in t))throw Error(`Required font metrics not supported`)}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText(`W`);return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},oo=class extends F{constructor(e,t,n){super(),this._textarea=e,this._window=t,this.mainDocument=n,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new so(this._window)),this._onDprChange=this._register(new L),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new L),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(e=>this._screenDprMonitor.setWindow(e))),this._register(qn.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(R(this._textarea,`focus`,()=>this._isFocused=!0)),this._register(R(this._textarea,`blur`,()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},so=class extends F{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new Vn),this._onDprChange=this._register(new L),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(P(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=R(this._parentWindow,`resize`,()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){this._outerListener&&(this._resolutionMediaMatchList?.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},co=class extends F{constructor(){super(),this.linkProviders=[],this._register(P(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function lo(e,t,n){let r=n.getBoundingClientRect(),i=e.getComputedStyle(n),a=parseInt(i.getPropertyValue(`padding-left`)),o=parseInt(i.getPropertyValue(`padding-top`));return[t.clientX-r.left-a,t.clientY-r.top-o]}function uo(e,t,n,r,i,a,o,s,c){if(!a)return;let l=lo(e,t,n);if(l)return l[0]=Math.ceil((l[0]+(c?o/2:0))/o),l[1]=Math.ceil(l[1]/s),l[0]=Math.min(Math.max(l[0],1),r+ +!!c),l[1]=Math.min(Math.max(l[1],1),i),l}var fo=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,n,r,i){return uo(window,e,t,n,r,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,i)}getMouseReportCoords(e,t){let n=lo(window,e,t);if(this._charSizeService.hasValidSize)return n[0]=Math.min(Math.max(n[0],0),this._renderService.dimensions.css.canvas.width-1),n[1]=Math.min(Math.max(n[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(n[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(n[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(n[0]),y:Math.floor(n[1])}}};fo=M([N(0,mn),N(1,dn)],fo);var po=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()),this._animationFrame}refresh(e,t,n){this._rowCount=n,e=e===void 0?0:e,t=t===void 0?this._rowCount-1:t,this._rowStart=this._rowStart===void 0?e:Math.min(this._rowStart,e),this._rowEnd=this._rowEnd===void 0?t:Math.max(this._rowEnd,t),!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},mo={};Tt(mo,{getSafariVersion:()=>xo,isChromeOS:()=>Do,isFirefox:()=>vo,isIpad:()=>Co,isIphone:()=>wo,isLegacyEdge:()=>yo,isLinux:()=>Eo,isMac:()=>So,isNode:()=>ho,isSafari:()=>bo,isWindows:()=>To});var ho=typeof process<`u`&&`title`in process,go=ho?`node`:navigator.userAgent,_o=ho?`node`:navigator.platform,vo=go.includes(`Firefox`),yo=go.includes(`Edge`),bo=/^((?!chrome|android).)*safari/i.test(go);function xo(){if(!bo)return 0;let e=go.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var So=[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(_o),Co=_o===`iPad`,wo=_o===`iPhone`,To=[`Windows`,`Win16`,`Win32`,`WinCE`].includes(_o),Eo=_o.indexOf(`Linux`)>=0,Do=/\bCrOS\b/.test(go),Oo=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._ii){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},ko=class extends Oo{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},Ao=class extends Oo{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},jo=!ho&&`requestIdleCallback`in window?Ao:ko,Mo=class{constructor(){this._queue=new jo}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},No=class extends F{constructor(e,t,n,r,i,a,o,s,c){super(),this._rowCount=e,this._optionsService=n,this._charSizeService=r,this._coreService=i,this._coreBrowserService=s,this._renderer=this._register(new Vn),this._pausedResizeTask=new Mo,this._observerDisposable=this._register(new Vn),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new L),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new L),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new L),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new L),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new po((e,t)=>this._renderRows(e,t),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new Po(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(P(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(o.onResize(()=>this._fullRefresh())),this._register(o.buffers.onBufferActivate(()=>this._renderer.value?.clear())),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(a.onDecorationRegistered(()=>this._fullRefresh())),this._register(a.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange([`customGlyphs`,`drawBoldTextInBrightColors`,`letterSpacing`,`lineHeight`,`fontFamily`,`fontSize`,`fontWeight`,`fontWeightBold`,`minimumContrastRatio`,`rescaleOverlappingGlyphs`],()=>{this.clear(),this.handleResize(o.cols,o.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange([`cursorBlink`,`cursorStyle`],()=>this.refreshRows(o.buffer.y,o.buffer.y,!0))),this._register(c.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(e=>this._registerIntersectionObserver(e,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if(`IntersectionObserver`in e){let n=new e.IntersectionObserver(e=>this._handleIntersectionChange(e[e.length-1]),{threshold:0});n.observe(t),this._observerDisposable.value=P(()=>n.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,n=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let r=this._syncOutputHandler.flush();r&&(e=Math.min(e,r.start),t=Math.max(t,r.end)),n||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&=(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(e=>this.refreshRows(e.start,e.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){this._renderer.value&&(this._renderer.value.clearTextureAtlas?.(),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>this._renderer.value?.handleResize(e,t)):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){this._renderer.value?.handleCharSizeChanged()}handleBlur(){this._renderer.value?.handleBlur()}handleFocus(){this._renderer.value?.handleFocus()}handleSelectionChanged(e,t,n){this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=n,this._renderer.value?.handleSelectionChanged(e,t,n)}handleCursorMove(){this._renderer.value?.handleCursorMove()}clear(){this._renderer.value?.clear()}};No=M([N(2,an),N(3,dn),N(4,en),N(5,cn),N(6,Qt),N(7,fn),N(8,_n)],No);var Po=class{constructor(e,t,n){this._coreBrowserService=e,this._coreService=t,this._onTimeout=n,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function Fo(e,t,n,r){let i=n.buffer.x,a=n.buffer.y;if(!n.buffer.hasScrollback)return Ro(i,a,e,t,n,r)+zo(a,t,n,r)+Bo(i,a,e,t,n,r);let o;if(a===t)return o=i>e?`D`:`C`,qo(Math.abs(i-e),Ko(o,r));o=a>t?`D`:`C`;let s=Math.abs(a-t);return qo(Lo(a>t?e:i,n)+(s-1)*n.cols+1+Io(a>t?i:e,n),Ko(o,r))}function Io(e,t){return e-1}function Lo(e,t){return t.cols-e}function Ro(e,t,n,r,i,a){return zo(t,r,i,a).length===0?``:qo(Go(e,t,e,t-Ho(t,i),!1,i).length,Ko(`D`,a))}function zo(e,t,n,r){let i=e-Ho(e,n),a=t-Ho(t,n);return qo(Math.abs(i-a)-Vo(e,t,n),Ko(Wo(e,t),r))}function Bo(e,t,n,r,i,a){let o;o=zo(t,r,i,a).length>0?r-Ho(r,i):t;let s=r,c=Uo(e,t,n,r,i,a);return qo(Go(e,o,n,s,c===`C`,i).length,Ko(c,a))}function Vo(e,t,n){let r=0,i=e-Ho(e,n),a=t-Ho(t,n);for(let o=0;o=0&&e0?r-Ho(r,i):t,e=n&&ot?`A`:`B`}function Go(e,t,n,r,i,a){let o=e,s=t,c=``;for(;(o!==n||s!==r)&&s>=0&&sa.cols-1?(c+=a.buffer.translateBufferLineToString(s,!1,e,o),o=0,e=0,s++):!i&&o<0&&(c+=a.buffer.translateBufferLineToString(s,!1,0,e+1),o=a.cols-1,e=o,s--);return c+a.buffer.translateBufferLineToString(s,!1,e,o)}function Ko(e,t){let n=t?`O`:`[`;return z.ESC+n+e}function qo(e,t){e=Math.floor(e);let n=``;for(let r=0;rthis._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function Yo(e,t){if(e.start.y>e.end.y)throw Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Xo=50,Zo=15,Qo=50,$o=500,es=RegExp(`\xA0`,`g`),ts=class extends F{constructor(e,t,n,r,i,a,o,s,c){super(),this._element=e,this._screenElement=t,this._linkifier=n,this._bufferService=r,this._coreService=i,this._mouseService=a,this._optionsService=o,this._renderService=s,this._coreBrowserService=c,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new Gt,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new L),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new L),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new L),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new L),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=e=>this._handleMouseMove(e),this._mouseUpListener=e=>this._handleMouseUp(e),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(e=>this._handleTrim(e)),this._register(this._bufferService.buffers.onBufferActivate(e=>this._handleBufferActivate(e))),this.enable(),this._model=new Jo(this._bufferService),this._activeSelectionMode=0,this._register(P(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(e=>{e.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return``;let n=this._bufferService.buffer,r=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return``;let i=e[0]e.replace(es,` `)).join(To?`\r +`:` +`)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh()),Eo&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r||!t?!1:this._areCoordsInSelection(t,n,r)}isCellInSelection(e,t){let n=this._model.finalSelectionStart,r=this._model.finalSelectionEnd;return!n||!r?!1:this._areCoordsInSelection([e,t],n,r)}_areCoordsInSelection(e,t,n){return e[1]>t[1]&&e[1]=t[0]&&e[0]=t[0]}_selectWordAtCursor(e,t){let n=this._linkifier.currentLink?.link?.range;if(n)return this._model.selectionStart=[n.start.x-1,n.start.y-1],this._model.selectionStartLength=Yo(n,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let r=this._getMouseBufferCoords(e);return r?(this._selectWordAt(r,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=lo(this._coreBrowserService.window,e,this._screenElement)[1],n=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=n?0:(t>n&&(t-=n),t=Math.min(Math.max(t,-Xo),Xo),t/=Xo,t/Math.abs(t)+Math.round(t*(Zo-1)))}shouldForceSelection(e){return So?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener(`mouseup`,this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),Qo)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener(`mousemove`,this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener(`mouseup`,this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(So&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let n=this._bufferService.buffer;if(this._model.selectionEnd[1]0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<$o&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let t=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(t&&t[0]!==void 0&&t[1]!==void 0){let e=Fo(t[0]-1,t[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(e,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,n=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);n?!e||!t||this._oldSelectionStart&&this._oldSelectionEnd&&e[0]===this._oldSelectionStart[0]&&e[1]===this._oldSelectionStart[1]&&t[0]===this._oldSelectionEnd[0]&&t[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(e,t,n):this._oldHasSelection&&this._fireOnSelectionChange(e,t,n)}_fireOnSelectionChange(e,t,n){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=n,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(e=>this._handleTrim(e))}_convertViewportColToCharacterIndex(e,t){let n=t;for(let r=0;t>=r;r++){let i=e.loadCell(r,this._workCell).getChars().length;this._workCell.getWidth()===0?n--:i>1&&t!==r&&(n+=i-1)}return n}setSelection(e,t,n){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=n,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,n=!0,r=!0){if(e[0]>=this._bufferService.cols)return;let i=this._bufferService.buffer,a=i.lines.get(e[1]);if(!a)return;let o=i.translateBufferLineToString(e[1],!1),s=this._convertViewportColToCharacterIndex(a,e[0]),c=s,l=e[0]-s,u=0,d=0,f=0,p=0;if(o.charAt(s)===` `){for(;s>0&&o.charAt(s-1)===` `;)s--;for(;c1&&(p+=r-1,c+=r-1);t>0&&s>0&&!this._isCharWordSeparator(a.loadCell(t-1,this._workCell));){a.loadCell(t-1,this._workCell);let e=this._workCell.getChars().length;this._workCell.getWidth()===0?(u++,t--):e>1&&(f+=e-1,s-=e-1),s--,t--}for(;n1&&(p+=e-1,c+=e-1),c++,n++}}c++;let m=s+l-u+f,h=Math.min(this._bufferService.cols,c-s+u+d-f-p);if(t||o.slice(s,c).trim()!==``){if(n&&m===0&&a.getCodePoint(0)!==32){let t=i.lines.get(e[1]-1);if(t&&a.isWrapped&&t.getCodePoint(this._bufferService.cols-1)!==32){let t=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(t){let e=this._bufferService.cols-t.start;m-=e,h+=e}}}if(r&&m+h===this._bufferService.cols&&a.getCodePoint(this._bufferService.cols-1)!==32){let t=i.lines.get(e[1]+1);if(t?.isWrapped&&t.getCodePoint(0)!==32){let t=this._getWordAt([0,e[1]+1],!1,!1,!0);t&&(h+=t.length)}}return{start:m,length:h}}}_selectWordAt(e,t){let n=this._getWordAt(e,t);if(n){for(;n.start<0;)n.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[n.start,e[1]],this._model.selectionStartLength=n.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let n=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,n--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,n++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,n]}}_isCharWordSeparator(e){return e.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),n={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=Yo(n,this._bufferService.cols)}};ts=M([N(3,Qt),N(4,en),N(5,pn),N(6,an),N(7,mn),N(8,fn)],ts);var ns=class{constructor(){this._data={}}set(e,t,n){this._data[e]||(this._data[e]={}),this._data[e][t]=n}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},rs=class{constructor(){this._color=new ns,this._css=new ns}setCss(e,t,n){this._css.set(e,t,n)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,n){this._color.set(e,t,n)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},is=Object.freeze((()=>{let e=[U.toColor(`#2e3436`),U.toColor(`#cc0000`),U.toColor(`#4e9a06`),U.toColor(`#c4a000`),U.toColor(`#3465a4`),U.toColor(`#75507b`),U.toColor(`#06989a`),U.toColor(`#d3d7cf`),U.toColor(`#555753`),U.toColor(`#ef2929`),U.toColor(`#8ae234`),U.toColor(`#fce94f`),U.toColor(`#729fcf`),U.toColor(`#ad7fa8`),U.toColor(`#34e2e2`),U.toColor(`#eeeeec`)],t=[0,95,135,175,215,255];for(let n=0;n<216;n++){let r=t[n/36%6|0],i=t[n/6%6|0],a=t[n%6];e.push({css:V.toCss(r,i,a),rgba:V.toRgba(r,i,a)})}for(let t=0;t<24;t++){let n=8+t*10;e.push({css:V.toCss(n,n,n),rgba:V.toRgba(n,n,n)})}return e})()),as=U.toColor(`#ffffff`),os=U.toColor(`#000000`),ss=U.toColor(`#ffffff`),cs=os,ls={css:`rgba(255, 255, 255, 0.3)`,rgba:4294967117},us=as,ds=class extends F{constructor(e){super(),this._optionsService=e,this._contrastCache=new rs,this._halfContrastCache=new rs,this._onChangeColors=this._register(new L),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:as,background:os,cursor:ss,cursorAccent:cs,selectionForeground:void 0,selectionBackgroundTransparent:ls,selectionBackgroundOpaque:H.blend(os,ls),selectionInactiveBackgroundTransparent:ls,selectionInactiveBackgroundOpaque:H.blend(os,ls),scrollbarSliderBackground:H.opacity(as,.2),scrollbarSliderHoverBackground:H.opacity(as,.4),scrollbarSliderActiveBackground:H.opacity(as,.5),overviewRulerBorder:as,ansi:is.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange(`minimumContrastRatio`,()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange(`theme`,()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=W(e.foreground,as),t.background=W(e.background,os),t.cursor=H.blend(t.background,W(e.cursor,ss)),t.cursorAccent=H.blend(t.background,W(e.cursorAccent,cs)),t.selectionBackgroundTransparent=W(e.selectionBackground,ls),t.selectionBackgroundOpaque=H.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=W(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=H.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?W(e.selectionForeground,ja):void 0,t.selectionForeground===ja&&(t.selectionForeground=void 0),H.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=H.opacity(t.selectionBackgroundTransparent,.3)),H.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=H.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=W(e.scrollbarSliderBackground,H.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=W(e.scrollbarSliderHoverBackground,H.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=W(e.scrollbarSliderActiveBackground,H.opacity(t.foreground,.5)),t.overviewRulerBorder=W(e.overviewRulerBorder,us),t.ansi=is.slice(),t.ansi[0]=W(e.black,is[0]),t.ansi[1]=W(e.red,is[1]),t.ansi[2]=W(e.green,is[2]),t.ansi[3]=W(e.yellow,is[3]),t.ansi[4]=W(e.blue,is[4]),t.ansi[5]=W(e.magenta,is[5]),t.ansi[6]=W(e.cyan,is[6]),t.ansi[7]=W(e.white,is[7]),t.ansi[8]=W(e.brightBlack,is[8]),t.ansi[9]=W(e.brightRed,is[9]),t.ansi[10]=W(e.brightGreen,is[10]),t.ansi[11]=W(e.brightYellow,is[11]),t.ansi[12]=W(e.brightBlue,is[12]),t.ansi[13]=W(e.brightMagenta,is[13]),t.ansi[14]=W(e.brightCyan,is[14]),t.ansi[15]=W(e.brightWhite,is[15]),e.extendedAnsi){let n=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let r=0;re.index-t.index),r=[];for(let t of n){let n=this._services.get(t.id);if(!n)throw Error(`[createInstance] ${e.name} depends on UNKNOWN service ${t.id._id}.`);r.push(n)}let i=n.length>0?n[0].index:t.length;if(t.length!==i)throw Error(`[createInstance] First service dependency of ${e.name} at position ${i+1} conflicts with ${t.length} static arguments`);return new e(...t,...r)}},ms={trace:0,debug:1,info:2,warn:3,error:4,off:5},hs=`xterm.js: `,gs=class extends F{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),_s=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=ms[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis._length)for(let t=this._length;t=e;t--)this._array[this._getCyclicIndex(t+n.length)]=this._array[this._getCyclicIndex(t)];for(let t=0;tthis._maxLength){let e=this._length+n.length-this._maxLength;this._startIndex+=e,this._length=this._maxLength,this.onTrimEmitter.fire(e)}else this._length+=n.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,n){if(!(t<=0)){if(e<0||e>=this._length)throw Error(`start argument out of range`);if(e+n<0)throw Error(`Cannot shift elements in list beyond index 0`);if(n>0){for(let r=t-1;r>=0;r--)this.set(e+r+n,this.get(e+r));let r=e+t+n-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r>22,t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):n]}set(e,t){this._data[e*G+1]=t[0],t[1].length>1?(this._combined[e]=t[1],this._data[e*G+0]=e|2097152|t[2]<<22):this._data[e*G+0]=t[1].charCodeAt(0)|t[2]<<22}getWidth(e){return this._data[e*G+0]>>22}hasWidth(e){return this._data[e*G+0]&12582912}getFg(e){return this._data[e*G+1]}getBg(e){return this._data[e*G+2]}hasContent(e){return this._data[e*G+0]&4194303}getCodePoint(e){let t=this._data[e*G+0];return t&2097152?this._combined[e].charCodeAt(this._combined[e].length-1):t&2097151}isCombined(e){return this._data[e*G+0]&2097152}getString(e){let t=this._data[e*G+0];return t&2097152?this._combined[e]:t&2097151?Lt(t&2097151):``}isProtected(e){return this._data[e*G+2]&536870912}loadCell(e,t){return ys=e*G,t.content=this._data[ys+0],t.fg=this._data[ys+1],t.bg=this._data[ys+2],t.content&2097152&&(t.combinedData=this._combined[e]),t.bg&268435456&&(t.extended=this._extendedAttrs[e]),t}setCell(e,t){t.content&2097152&&(this._combined[e]=t.combinedData),t.bg&268435456&&(this._extendedAttrs[e]=t.extended),this._data[e*G+0]=t.content,this._data[e*G+1]=t.fg,this._data[e*G+2]=t.bg}setCellFromCodepoint(e,t,n,r){r.bg&268435456&&(this._extendedAttrs[e]=r.extended),this._data[e*G+0]=t|n<<22,this._data[e*G+1]=r.fg,this._data[e*G+2]=r.bg}addCodepointToCell(e,t,n){let r=this._data[e*G+0];r&2097152?this._combined[e]+=Lt(t):r&2097151?(this._combined[e]=Lt(r&2097151)+Lt(t),r&=-2097152,r|=2097152):r=t|1<<22,n&&(r&=-12582913,r|=n<<22),this._data[e*G+0]=r}insertCells(e,t,n){if(e%=this.length,e&&this.getWidth(e-1)===2&&this.setCellFromCodepoint(e-1,0,1,n),t=0;--n)this.setCell(e+t+n,this.loadCell(e+n,r));for(let r=0;rthis.length){if(this._data.buffer.byteLength>=n*4)this._data=new Uint32Array(this._data.buffer,0,n);else{let e=new Uint32Array(n);e.set(this._data),this._data=e}for(let n=this.length;n=e&&delete this._combined[r]}let r=Object.keys(this._extendedAttrs);for(let t=0;t=e&&delete this._extendedAttrs[n]}}return this.length=e,n*4*bs=0;--e)if(this._data[e*G+0]&4194303)return e+(this._data[e*G+0]>>22);return 0}getNoBgTrimmedLength(){for(let e=this.length-1;e>=0;--e)if(this._data[e*G+0]&4194303||this._data[e*G+2]&50331648)return e+(this._data[e*G+0]>>22);return 0}copyCellsFrom(e,t,n,r,i){let a=e._data;if(i)for(let i=r-1;i>=0;i--){for(let e=0;e=t&&(this._combined[i-t+n]=e._combined[i])}}translateToString(e,t,n,r){t??=0,n??=this.length,e&&(n=Math.min(n,this.getTrimmedLength())),r&&(r.length=0);let i=``;for(;t>22||1}return r&&r.push(t),i}};function Ss(e,t,n,r,i,a){let o=[];for(let s=0;s=s&&r0&&(e>d||u[e].getTrimmedLength()===0);e--)h++;h>0&&(o.push(s+u.length-h),o.push(h)),s+=u.length-1}return o}function Cs(e,t){let n=[],r=0,i=t[r],a=0;for(let o=0;oEs(e,r,t)).reduce((e,t)=>e+t),a=0,o=0,s=0;for(;sc&&(a-=c,o++);let l=e[o].getWidth(a-1)===2;l&&a--;let u=l?n-1:n;r.push(u),s+=u}return r}function Es(e,t,n){if(t===e.length-1)return e[t].getTrimmedLength();let r=!e[t].hasContent(n-1)&&e[t].getWidth(n-1)===1,i=e[t+1].getWidth(0)===2;return r&&i?n-1:n}var Ds=class e{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=e._nextId++,this._onDispose=this.register(new L),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Ln(this._disposables),this._disposables.length=0)}register(e){return this._disposables.push(e),e}};Ds._nextId=1;var Os=Ds,ks={},As=ks.B;ks[0]={"`":`◆`,a:`▒`,b:`␉`,c:`␌`,d:`␍`,e:`␊`,f:`°`,g:`±`,h:`␤`,i:`␋`,j:`┘`,k:`┐`,l:`┌`,m:`└`,n:`┼`,o:`⎺`,p:`⎻`,q:`─`,r:`⎼`,s:`⎽`,t:`├`,u:`┤`,v:`┴`,w:`┬`,x:`│`,y:`≤`,z:`≥`,"{":`π`,"|":`≠`,"}":`£`,"~":`·`},ks.A={"#":`£`},ks.B=void 0,ks[4]={"#":`£`,"@":`¾`,"[":`ij`,"\\":`½`,"]":`|`,"{":`¨`,"|":`f`,"}":`¼`,"~":`´`},ks.C=ks[5]={"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},ks.R={"#":`£`,"@":`à`,"[":`°`,"\\":`ç`,"]":`§`,"{":`é`,"|":`ù`,"}":`è`,"~":`¨`},ks.Q={"@":`à`,"[":`â`,"\\":`ç`,"]":`ê`,"^":`î`,"`":`ô`,"{":`é`,"|":`ù`,"}":`è`,"~":`û`},ks.K={"@":`§`,"[":`Ä`,"\\":`Ö`,"]":`Ü`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`ß`},ks.Y={"#":`£`,"@":`§`,"[":`°`,"\\":`ç`,"]":`é`,"`":`ù`,"{":`à`,"|":`ò`,"}":`è`,"~":`ì`},ks.E=ks[6]={"@":`Ä`,"[":`Æ`,"\\":`Ø`,"]":`Å`,"^":`Ü`,"`":`ä`,"{":`æ`,"|":`ø`,"}":`å`,"~":`ü`},ks.Z={"#":`£`,"@":`§`,"[":`¡`,"\\":`Ñ`,"]":`¿`,"{":`°`,"|":`ñ`,"}":`ç`},ks.H=ks[7]={"@":`É`,"[":`Ä`,"\\":`Ö`,"]":`Å`,"^":`Ü`,"`":`é`,"{":`ä`,"|":`ö`,"}":`å`,"~":`ü`},ks[`=`]={"#":`ù`,"@":`à`,"[":`é`,"\\":`ç`,"]":`ê`,"^":`î`,_:`è`,"`":`ô`,"{":`ä`,"|":`ö`,"}":`ü`,"~":`û`};var js=4294967295,Ms=class{constructor(e,t,n){this._hasScrollback=e,this._optionsService=t,this._bufferService=n,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=K.clone(),this.savedCharset=As,this.markers=[],this._nullCell=Gt.fromCharData([0,Vt,1,0]),this._whitespaceCell=Gt.fromCharData([0,Ht,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new jo,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new vs(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Wt),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Wt),this._whitespaceCell}getBlankLine(e,t){return new xs(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&ejs?js:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=K);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new vs(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let n=this.getNullCell(K),r=0,i=this._getCorrectBufferLength(t);if(i>this.lines.maxLength&&(this.lines.maxLength=i),this.lines.length>0){if(this._cols0&&this.lines.length<=this.ybase+this.y+a+1?(this.ybase--,a++,this.ydisp>0&&this.ydisp--):this.lines.push(new xs(e,n)));else for(let e=this._rows;e>t;e--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(i0&&(this.lines.trimStart(e),this.ybase=Math.max(this.ybase-e,0),this.ydisp=Math.max(this.ydisp-e,0),this.savedY=Math.max(this.savedY-e,0)),this.lines.maxLength=i}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),a&&(this.y+=a),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let t=0;t.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend===`conpty`&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let n=this._optionsService.rawOptions.reflowCursorLine,r=Ss(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(K),n);if(r.length>0){let n=Cs(this.lines,r);ws(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,n){let r=this.getNullCell(K),i=n;for(;i-->0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length=0;o--){let s=this.lines.get(o);if(!s||!s.isWrapped&&s.getTrimmedLength()<=e)continue;let c=[s];for(;s.isWrapped&&o>0;)s=this.lines.get(--o),c.unshift(s);if(!n){let e=this.ybase+this.y;if(e>=o&&e0&&(i.push({start:o+c.length+a,newLines:p}),a+=p.length),c.push(...p);let m=u.length-1,h=u[m];h===0&&(m--,h=u[m]);let g=c.length-d-1,_=l;for(;g>=0;){let e=Math.min(_,h);if(c[m]===void 0)break;c[m].copyCellsFrom(c[g],_-e,h-e,e,!0),h-=e,h===0&&(m--,h=u[m]),_-=e,_===0&&(g--,_=Es(c,Math.max(g,0),this._cols))}for(let t=0;t0;)this.ybase===0?this.y0){let e=[],t=[];for(let e=0;e=0;l--)if(s&&s.start>r+c){for(let e=s.newLines.length-1;e>=0;e--)this.lines.set(l--,s.newLines[e]);l++,e.push({index:r+1,amount:s.newLines.length}),c+=s.newLines.length,s=i[++o]}else this.lines.set(l,t[r--]);let l=0;for(let t=e.length-1;t>=0;t--)e[t].index+=l,this.lines.onInsertEmitter.fire(e[t]),l+=e[t].amount;let u=Math.max(0,n+a-this.lines.maxLength);u>0&&this.lines.onTrimEmitter.fire(u)}}translateBufferLineToString(e,t,n=0,r){let i=this.lines.get(e);return i?i.translateToString(t,n,r):``}getWrappedRangeForLine(e){let t=e,n=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;n+10;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e??=this.x;!this.tabs[++e]&&e=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t{t.line-=e,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(e=>{t.line>=e.index&&(t.line+=e.amount)})),t.register(this.lines.onDelete(e=>{t.line>=e.index&&t.linee.index&&(t.line-=e.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},Ns=class extends F{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new L),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange(`scrollback`,()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange(`tabStopWidth`,()=>this.setupTabStops()))}reset(){this._normal=new Ms(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new Ms(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},Ps=2,Fs=1,Is=class extends F{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new L),this.onResize=this._onResize.event,this._onScroll=this._register(new L),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,Ps),this.rows=Math.max(e.rawOptions.rows||0,Fs),this.buffers=this._register(new Ns(e,this)),this._register(this.buffers.onBufferActivate(e=>{this._onScroll.fire(e.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let n=this.cols!==e,r=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:n,rowsChanged:r})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let n=this.buffer,r;r=this._cachedBlankLine,r&&r.length===this.cols&&r.getFg(0)===e.fg&&r.getBg(0)===e.bg||(r=n.getBlankLine(e,t),this._cachedBlankLine=r),r.isWrapped=t;let i=n.ybase+n.scrollTop,a=n.ybase+n.scrollBottom;if(n.scrollTop===0){let e=n.lines.isFull;a===n.lines.length-1?e?n.lines.recycle().copyFrom(r):n.lines.push(r.clone()):n.lines.splice(a+1,0,r.clone()),e?this.isUserScrolling&&(n.ydisp=Math.max(n.ydisp-1,0)):(n.ybase++,this.isUserScrolling||n.ydisp++)}else{let e=a-i+1;n.lines.shiftElements(i+1,e-1,-1),n.lines.set(a,r.clone())}this.isUserScrolling||(n.ydisp=n.ybase),this._onScroll.fire(n.ydisp)}scrollLines(e,t){let n=this.buffer;if(e<0){if(n.ydisp===0)return;this.isUserScrolling=!0}else e+n.ydisp>=n.ybase&&(this.isUserScrolling=!1);let r=n.ydisp;n.ydisp=Math.max(Math.min(n.ydisp+e,n.ybase),0),r!==n.ydisp&&(t||this._onScroll.fire(n.ydisp))}};Is=M([N(0,an)],Is);var Ls={cols:80,rows:24,cursorBlink:!1,cursorStyle:`block`,cursorWidth:1,cursorInactiveStyle:`outline`,customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:`alt`,fastScrollSensitivity:5,fontFamily:`monospace`,fontSize:15,fontWeight:`normal`,fontWeightBold:`bold`,ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:`info`,logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:So,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:` ()[]{}',"\``,altClickMovesCursor:!0,convertEol:!1,termName:`xterm`,cancelEvents:!1,overviewRuler:{}},Rs=[`normal`,`bold`,`100`,`200`,`300`,`400`,`500`,`600`,`700`,`800`,`900`],zs=class extends F{constructor(e){super(),this._onOptionChange=this._register(new L),this.onOptionChange=this._onOptionChange.event;let t={...Ls};for(let n in e)if(n in t)try{let r=e[n];t[n]=this._sanitizeAndValidateOption(n,r)}catch(e){console.error(e)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(P(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(n=>{n===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(n=>{e.indexOf(n)!==-1&&t()})}_setupOptions(){let e=e=>{if(!(e in Ls))throw Error(`No option with key "${e}"`);return this.rawOptions[e]},t=(e,t)=>{if(!(e in Ls))throw Error(`No option with key "${e}"`);t=this._sanitizeAndValidateOption(e,t),this.rawOptions[e]!==t&&(this.rawOptions[e]=t,this._onOptionChange.fire(e))};for(let n in this.rawOptions){let r={get:e.bind(this,n),set:t.bind(this,n)};Object.defineProperty(this.options,n,r)}}_sanitizeAndValidateOption(e,t){switch(e){case`cursorStyle`:if(t||=Ls[e],!Bs(t))throw Error(`"${t}" is not a valid value for ${e}`);break;case`wordSeparator`:t||=Ls[e];break;case`fontWeight`:case`fontWeightBold`:if(typeof t==`number`&&1<=t&&t<=1e3)break;t=Rs.includes(t)?t:Ls[e];break;case`cursorWidth`:t=Math.floor(t);case`lineHeight`:case`tabStopWidth`:if(t<1)throw Error(`${e} cannot be less than 1, value: ${t}`);break;case`minimumContrastRatio`:t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case`scrollback`:if(t=Math.min(t,4294967295),t<0)throw Error(`${e} cannot be less than 0, value: ${t}`);break;case`fastScrollSensitivity`:case`scrollSensitivity`:if(t<=0)throw Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case`rows`:case`cols`:if(!t&&t!==0)throw Error(`${e} must be numeric, value: ${t}`);break;case`windowsPty`:t??={}}return t}};function Bs(e){return e===`block`||e===`underline`||e===`bar`}function Vs(e,t=5){if(typeof e!=`object`)return e;let n=Array.isArray(e)?[]:{};for(let r in e)n[r]=t<=1?e[r]:e[r]&&Vs(e[r],t-1);return n}var Hs=Object.freeze({insertMode:!1}),Us=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Ws=class extends F{constructor(e,t,n){super(),this._bufferService=e,this._logService=t,this._optionsService=n,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new L),this.onData=this._onData.event,this._onUserInput=this._register(new L),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new L),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new L),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Vs(Hs),this.decPrivateModes=Vs(Us)}reset(){this.modes=Vs(Hs),this.decPrivateModes=Vs(Us)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let n=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&n.ybase!==n.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace(`sending data (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace(`sending binary (codes)`,()=>e.split(``).map(e=>e.charCodeAt(0))),this._onBinary.fire(e))}};Ws=M([N(0,Qt),N(1,rn),N(2,an)],Ws);var Gs={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>e.action!==32||e.button!==3},ANY:{events:31,restrict:e=>!0}};function Ks(e,t){let n=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(n|=64,n|=e.action):(n|=e.button&3,e.button&4&&(n|=64),e.button&8&&(n|=128),e.action===32?n|=32:e.action===0&&!t&&(n|=3)),n}var qs=String.fromCharCode,Js={DEFAULT:e=>{let t=[Ks(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?``:`\x1B[M${qs(t[0])}${qs(t[1])}${qs(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${Ks(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?`m`:`M`;return`\x1B[<${Ks(e,!0)};${e.x};${e.y}${t}`}},Ys=class extends F{constructor(e,t,n){super(),this._bufferService=e,this._coreService=t,this._optionsService=n,this._protocols={},this._encodings={},this._activeProtocol=``,this._activeEncoding=``,this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new L),this.onProtocolChange=this._onProtocolChange.event;for(let e of Object.keys(Gs))this.addProtocol(e,Gs[e]);for(let e of Object.keys(Js))this.addEncoding(e,Js[e]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol=`NONE`,this.activeEncoding=`DEFAULT`,this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,n){if(e.deltaY===0||e.shiftKey||t===void 0||n===void 0)return 0;let r=t/n,i=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(i/=r+0,Math.abs(e.deltaY)<50&&(i*=.3),this._wheelPartialScroll+=i,i=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(i*=this._bufferService.rows),i}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding===`SGR_PIXELS`))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding===`DEFAULT`?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,n){if(n){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return e.button===t.button&&e.action===t.action&&e.ctrl===t.ctrl&&e.alt===t.alt&&e.shift===t.shift}};Ys=M([N(0,Qt),N(1,en),N(2,an)],Ys);var Xs=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],Zs=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],Qs;function $s(e,t){let n=0,r=t.length-1,i;if(et[r][1])return!1;for(;r>=n;)if(i=n+r>>1,e>t[i][1])n=i+1;else if(e=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let n=this.wcwidth(e),r=n===0&&t!==0;if(r){let e=tc.extractWidth(t);e===0?r=!1:e>n&&(n=e)}return tc.createPropertyValue(0,n,r)}},tc=class e{constructor(){this._providers=Object.create(null),this._active=``,this._onChange=new L,this.onChange=this._onChange.event;let e=new ec;this.register(e),this._active=e.version,this._activeProvider=e}static extractShouldJoin(e){return!!(e&1)}static extractWidth(e){return e>>1&3}static extractCharKind(e){return e>>3}static createPropertyValue(e,t,n=!1){return(e&16777215)<<3|(t&3)<<1|!!n}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(e){if(!this._providers[e])throw Error(`unknown Unicode version "${e}"`);this._active=e,this._activeProvider=this._providers[e],this._onChange.fire(e)}register(e){this._providers[e.version]=e}wcwidth(e){return this._activeProvider.wcwidth(e)}getStringCellWidth(t){let n=0,r=0,i=t.length;for(let a=0;a=i)return n+this.wcwidth(o);let e=t.charCodeAt(a);56320<=e&&e<=57343?o=(o-55296)*1024+e-56320+65536:n+=this.wcwidth(e)}let s=this.charProperties(o,r),c=e.extractWidth(s);e.extractShouldJoin(s)&&(c-=e.extractWidth(r)),n+=c,r=s}return n}charProperties(e,t){return this._activeProvider.charProperties(e,t)}},nc=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function rc(e){let t=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1)?.get(e.cols-1),n=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);n&&t&&(n.isWrapped=t[3]!==0&&t[3]!==32)}var ic=2147483647,ac=256,oc=class e{constructor(e=32,t=32){if(this.maxLength=e,this.maxSubParamsLength=t,t>ac)throw Error(`maxSubParamsLength must not be greater than 256`);this.params=new Int32Array(e),this.length=0,this._subParams=new Int32Array(t),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(e),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let n=new e;if(!t.length)return n;for(let e=+!!Array.isArray(t[0]);e>8,r=this._subParamsIdx[t]&255;r-n>0&&e.push(Array.prototype.slice.call(this._subParams,n,r))}return e}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(e){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=e>ic?ic:e}}addSubParam(e){if(this._digitIsSub=!0,this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(e<-1)throw Error(`values lesser than -1 are not allowed`);this._subParams[this._subParamsLength++]=e>ic?ic:e,this._subParamsIdx[this.length-1]++}}hasSubParams(e){return(this._subParamsIdx[e]&255)-(this._subParamsIdx[e]>>8)>0}getSubParams(e){let t=this._subParamsIdx[e]>>8,n=this._subParamsIdx[e]&255;return n-t>0?this._subParams.subarray(t,n):null}getSubParamsAll(){let e={};for(let t=0;t>8,r=this._subParamsIdx[t]&255;r-n>0&&(e[t]=this._subParams.slice(n,r))}return e}addDigit(e){let t;if(this._rejectDigits||!(t=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let n=this._digitIsSub?this._subParams:this.params,r=n[t-1];n[t-1]=~r?Math.min(r*10+e,ic):e}},sc=[],cc=class{constructor(){this._state=0,this._active=sc,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=sc}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=sc,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||sc,!this._active.length)this._handlerFb(this._id,`START`);else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,n){if(!this._active.length)this._handlerFb(this._id,`PUT`,Rt(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}start(){this.reset(),this._state=1}put(e,t,n){if(this._state!==3){if(this._state===1)for(;t0&&this._put(e,t,n)}}end(e,t=!0){if(this._state!==0){if(this._state!==3){if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,`END`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].end(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].end(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}}this._active=sc,this._id=-1,this._state=0}}},lc=class{constructor(e){this._handler=e,this._data=``,this._hitLimit=!1}start(){this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Rt(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(e=>(this._data=``,this._hitLimit=!1,e));return this._data=``,this._hitLimit=!1,t}},uc=[],dc=class{constructor(){this._handlers=Object.create(null),this._active=uc,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=uc}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let n=this._handlers[e];return n.push(t),{dispose:()=>{let e=n.indexOf(t);e!==-1&&n.splice(e,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=uc,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||uc,!this._active.length)this._handlerFb(this._ident,`HOOK`,t);else for(let e=this._active.length-1;e>=0;e--)this._active[e].hook(t)}put(e,t,n){if(!this._active.length)this._handlerFb(this._ident,`PUT`,Rt(e,t,n));else for(let r=this._active.length-1;r>=0;r--)this._active[r].put(e,t,n)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,`UNHOOK`,e);else{let n=!1,r=this._active.length-1,i=!1;if(this._stack.paused&&(r=this._stack.loopPosition-1,n=t,i=this._stack.fallThrough,this._stack.paused=!1),!i&&n===!1){for(;r>=0&&(n=this._active[r].unhook(e),n!==!0);r--)if(n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!1,n;r--}for(;r>=0;r--)if(n=this._active[r].unhook(!1),n instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=r,this._stack.fallThrough=!0,n}this._active=uc,this._ident=0}},fc=new oc;fc.addParam(0);var pc=class{constructor(e){this._handler=e,this._data=``,this._params=fc,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():fc,this._data=``,this._hitLimit=!1}put(e,t,n){this._hitLimit||(this._data+=Rt(e,t,n),this._data.length>1e7&&(this._data=``,this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(e=>(this._params=fc,this._data=``,this._hitLimit=!1,e));return this._params=fc,this._data=``,this._hitLimit=!1,t}},mc=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,n,r){this.table[t<<8|e]=n<<4|r}addMany(e,t,n,r){for(let i=0;it),n=(e,n)=>t.slice(e,n),r=n(32,127),i=n(0,24);i.push(25),i.push.apply(i,n(28,32));let a=n(0,14),o;for(o in e.setDefault(1,0),e.addMany(r,0,2,0),a)e.addMany([24,26,153,154],o,3,0),e.addMany(n(128,144),o,3,0),e.addMany(n(144,152),o,3,0),e.add(156,o,0,0),e.add(27,o,11,1),e.add(157,o,4,8),e.addMany([152,158,159],o,0,7),e.add(155,o,11,3),e.add(144,o,11,9);return e.addMany(i,0,3,0),e.addMany(i,1,3,1),e.add(127,1,0,1),e.addMany(i,8,0,8),e.addMany(i,3,3,3),e.add(127,3,0,3),e.addMany(i,4,3,4),e.add(127,4,0,4),e.addMany(i,6,3,6),e.addMany(i,5,3,5),e.add(127,5,0,5),e.addMany(i,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(r,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(n(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(r,7,0,7),e.addMany(i,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(n(64,127),3,7,0),e.addMany(n(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(n(48,60),4,8,4),e.addMany(n(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(n(32,64),6,0,6),e.add(127,6,0,6),e.addMany(n(64,127),6,0,0),e.addMany(n(32,48),3,9,5),e.addMany(n(32,48),5,9,5),e.addMany(n(48,64),5,0,6),e.addMany(n(64,127),5,7,0),e.addMany(n(32,48),4,9,5),e.addMany(n(32,48),1,9,2),e.addMany(n(32,48),2,9,2),e.addMany(n(48,127),2,10,0),e.addMany(n(48,80),1,10,0),e.addMany(n(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(n(96,127),1,10,0),e.add(80,1,11,9),e.addMany(i,9,0,9),e.add(127,9,0,9),e.addMany(n(28,32),9,0,9),e.addMany(n(32,48),9,9,12),e.addMany(n(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(i,11,0,11),e.addMany(n(32,128),11,0,11),e.addMany(n(28,32),11,0,11),e.addMany(i,10,0,10),e.add(127,10,0,10),e.addMany(n(28,32),10,0,10),e.addMany(n(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(n(32,48),10,9,12),e.addMany(i,12,0,12),e.add(127,12,0,12),e.addMany(n(28,32),12,0,12),e.addMany(n(32,48),12,9,12),e.addMany(n(48,64),12,0,11),e.addMany(n(64,127),12,12,13),e.addMany(n(64,127),10,12,13),e.addMany(n(64,127),9,12,13),e.addMany(i,13,13,13),e.addMany(r,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(hc,0,2,0),e.add(hc,8,5,8),e.add(hc,6,0,6),e.add(hc,11,0,11),e.add(hc,13,13,13),e}(),_c=class extends F{constructor(e=gc){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new oc,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(e,t,n)=>{},this._executeHandlerFb=e=>{},this._csiHandlerFb=(e,t)=>{},this._escHandlerFb=e=>{},this._errorHandlerFb=e=>e,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(P(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new cc),this._dcsParser=this._register(new dc),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:`\\`},()=>!0)}_identifier(e,t=[64,126]){let n=0;if(e.prefix){if(e.prefix.length>1)throw Error(`only one byte as prefix supported`);if(n=e.prefix.charCodeAt(0),n&&60>n||n>63)throw Error(`prefix must be in range 0x3c .. 0x3f`)}if(e.intermediates){if(e.intermediates.length>2)throw Error(`only two bytes as intermediates are supported`);for(let t=0;tr||r>47)throw Error(`intermediate must be in range 0x20 .. 0x2f`);n<<=8,n|=r}}if(e.final.length!==1)throw Error(`final must be a single byte`);let r=e.final.charCodeAt(0);if(t[0]>r||r>t[1])throw Error(`final must be in range ${t[0]} .. ${t[1]}`);return n<<=8,n|=r,n}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join(``)}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let n=this._identifier(e,[48,126]);this._escHandlers[n]===void 0&&(this._escHandlers[n]=[]);let r=this._escHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let n=this._identifier(e);this._csiHandlers[n]===void 0&&(this._csiHandlers[n]=[]);let r=this._csiHandlers[n];return r.push(t),{dispose:()=>{let e=r.indexOf(t);e!==-1&&r.splice(e,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,n,r,i){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=n,this._parseStack.transition=r,this._parseStack.chunkPos=i}parse(e,t,n){let r=0,i=0,a=0,o;if(this._parseStack.state){if(this._parseStack.state===2)this._parseStack.state=0,a=this._parseStack.chunkPos+1;else{if(n===void 0||this._parseStack.state===1)throw this._parseStack.state=1,Error(`improper continuation due to previous async handler, giving up parsing`);let t=this._parseStack.handlers,i=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](this._params),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 4:if(n===!1&&i>-1){for(;i>=0&&(o=t[i](),o!==!0);i--)if(o instanceof Promise)return this._parseStack.handlerPos=i,o}this._parseStack.handlers=[];break;case 6:if(r=e[this._parseStack.chunkPos],o=this._dcsParser.unhook(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(r=e[this._parseStack.chunkPos],o=this._oscParser.end(r!==24&&r!==26,n),o)return o;r===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,a=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}}for(let n=a;n>4){case 2:for(let i=n+1;;++i)if(i>=t||(r=e[i])<32||r>126&&r=t||(r=e[i])<32||r>126&&r=t||(r=e[i])<32||r>126&&r=t||(r=e[i])<32||r>126&&r=0&&(o=a[s](this._params),o!==!0);s--)if(o instanceof Promise)return this._preserveStack(3,a,s,i,n),o;s<0&&this._csiHandlerFb(this._collect<<8|r,this._params),this.precedingJoinState=0;break;case 8:do switch(r){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(r-48)}while(++n47&&r<60);n--;break;case 9:this._collect<<=8,this._collect|=r;break;case 10:let c=this._escHandlers[this._collect<<8|r],l=c?c.length-1:-1;for(;l>=0&&(o=c[l](),o!==!0);l--)if(o instanceof Promise)return this._preserveStack(4,c,l,i,n),o;l<0&&this._escHandlerFb(this._collect<<8|r),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|r,this._params);break;case 13:for(let i=n+1;;++i)if(i>=t||(r=e[i])===24||r===26||r===27||r>127&&r=t||(r=e[i])<32||r>127&&r>4:i>>8}return n}}function xc(e,t){let n=e.toString(16),r=n.length<2?`0`+n:n;switch(t){case 4:return n[0];case 8:return r;case 12:return(r+r).slice(0,3);default:return r+r}}function Sc(e,t=16){let[n,r,i]=e;return`rgb:${xc(n,t)}/${xc(r,t)}/${xc(i,t)}`}var Cc={"(":0,")":1,"*":2,"+":3,"-":1,".":2},wc=131072,Tc=10;function Ec(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Dc=5e3,Oc=0,kc=class extends F{constructor(e,t,n,r,i,a,o,s,c=new _c){super(),this._bufferService=e,this._charsetService=t,this._coreService=n,this._logService=r,this._optionsService=i,this._oscLinkService=a,this._coreMouseService=o,this._unicodeService=s,this._parser=c,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new zt,this._utf8Decoder=new Bt,this._windowTitle=``,this._iconName=``,this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=K.clone(),this._eraseAttrDataInternal=K.clone(),this._onRequestBell=this._register(new L),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new L),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new L),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new L),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new L),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new L),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new L),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new L),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new L),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new L),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new L),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new L),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new L),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new Ac(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(e=>this._activeBuffer=e.activeBuffer)),this._parser.setCsiHandlerFallback((e,t)=>{this._logService.debug(`Unknown CSI code: `,{identifier:this._parser.identToString(e),params:t.toArray()})}),this._parser.setEscHandlerFallback(e=>{this._logService.debug(`Unknown ESC code: `,{identifier:this._parser.identToString(e)})}),this._parser.setExecuteHandlerFallback(e=>{this._logService.debug(`Unknown EXECUTE code: `,{code:e})}),this._parser.setOscHandlerFallback((e,t,n)=>{this._logService.debug(`Unknown OSC code: `,{identifier:e,action:t,data:n})}),this._parser.setDcsHandlerFallback((e,t,n)=>{t===`HOOK`&&(n=n.toArray()),this._logService.debug(`Unknown DCS code: `,{identifier:this._parser.identToString(e),action:t,payload:n})}),this._parser.setPrintHandler((e,t,n)=>this.print(e,t,n)),this._parser.registerCsiHandler({final:`@`},e=>this.insertChars(e)),this._parser.registerCsiHandler({intermediates:` `,final:`@`},e=>this.scrollLeft(e)),this._parser.registerCsiHandler({final:`A`},e=>this.cursorUp(e)),this._parser.registerCsiHandler({intermediates:` `,final:`A`},e=>this.scrollRight(e)),this._parser.registerCsiHandler({final:`B`},e=>this.cursorDown(e)),this._parser.registerCsiHandler({final:`C`},e=>this.cursorForward(e)),this._parser.registerCsiHandler({final:`D`},e=>this.cursorBackward(e)),this._parser.registerCsiHandler({final:`E`},e=>this.cursorNextLine(e)),this._parser.registerCsiHandler({final:`F`},e=>this.cursorPrecedingLine(e)),this._parser.registerCsiHandler({final:`G`},e=>this.cursorCharAbsolute(e)),this._parser.registerCsiHandler({final:`H`},e=>this.cursorPosition(e)),this._parser.registerCsiHandler({final:`I`},e=>this.cursorForwardTab(e)),this._parser.registerCsiHandler({final:`J`},e=>this.eraseInDisplay(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`J`},e=>this.eraseInDisplay(e,!0)),this._parser.registerCsiHandler({final:`K`},e=>this.eraseInLine(e,!1)),this._parser.registerCsiHandler({prefix:`?`,final:`K`},e=>this.eraseInLine(e,!0)),this._parser.registerCsiHandler({final:`L`},e=>this.insertLines(e)),this._parser.registerCsiHandler({final:`M`},e=>this.deleteLines(e)),this._parser.registerCsiHandler({final:`P`},e=>this.deleteChars(e)),this._parser.registerCsiHandler({final:`S`},e=>this.scrollUp(e)),this._parser.registerCsiHandler({final:`T`},e=>this.scrollDown(e)),this._parser.registerCsiHandler({final:`X`},e=>this.eraseChars(e)),this._parser.registerCsiHandler({final:`Z`},e=>this.cursorBackwardTab(e)),this._parser.registerCsiHandler({final:"`"},e=>this.charPosAbsolute(e)),this._parser.registerCsiHandler({final:`a`},e=>this.hPositionRelative(e)),this._parser.registerCsiHandler({final:`b`},e=>this.repeatPrecedingCharacter(e)),this._parser.registerCsiHandler({final:`c`},e=>this.sendDeviceAttributesPrimary(e)),this._parser.registerCsiHandler({prefix:`>`,final:`c`},e=>this.sendDeviceAttributesSecondary(e)),this._parser.registerCsiHandler({final:`d`},e=>this.linePosAbsolute(e)),this._parser.registerCsiHandler({final:`e`},e=>this.vPositionRelative(e)),this._parser.registerCsiHandler({final:`f`},e=>this.hVPosition(e)),this._parser.registerCsiHandler({final:`g`},e=>this.tabClear(e)),this._parser.registerCsiHandler({final:`h`},e=>this.setMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`h`},e=>this.setModePrivate(e)),this._parser.registerCsiHandler({final:`l`},e=>this.resetMode(e)),this._parser.registerCsiHandler({prefix:`?`,final:`l`},e=>this.resetModePrivate(e)),this._parser.registerCsiHandler({final:`m`},e=>this.charAttributes(e)),this._parser.registerCsiHandler({final:`n`},e=>this.deviceStatus(e)),this._parser.registerCsiHandler({prefix:`?`,final:`n`},e=>this.deviceStatusPrivate(e)),this._parser.registerCsiHandler({intermediates:`!`,final:`p`},e=>this.softReset(e)),this._parser.registerCsiHandler({intermediates:` `,final:`q`},e=>this.setCursorStyle(e)),this._parser.registerCsiHandler({final:`r`},e=>this.setScrollRegion(e)),this._parser.registerCsiHandler({final:`s`},e=>this.saveCursor(e)),this._parser.registerCsiHandler({final:`t`},e=>this.windowOptions(e)),this._parser.registerCsiHandler({final:`u`},e=>this.restoreCursor(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`}`},e=>this.insertColumns(e)),this._parser.registerCsiHandler({intermediates:`'`,final:`~`},e=>this.deleteColumns(e)),this._parser.registerCsiHandler({intermediates:`"`,final:`q`},e=>this.selectProtected(e)),this._parser.registerCsiHandler({intermediates:`$`,final:`p`},e=>this.requestMode(e,!0)),this._parser.registerCsiHandler({prefix:`?`,intermediates:`$`,final:`p`},e=>this.requestMode(e,!1)),this._parser.setExecuteHandler(z.BEL,()=>this.bell()),this._parser.setExecuteHandler(z.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(z.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(z.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(z.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(z.BS,()=>this.backspace()),this._parser.setExecuteHandler(z.HT,()=>this.tab()),this._parser.setExecuteHandler(z.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(z.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ta.IND,()=>this.index()),this._parser.setExecuteHandler(Ta.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ta.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new lc(e=>(this.setTitle(e),this.setIconName(e),!0))),this._parser.registerOscHandler(1,new lc(e=>this.setIconName(e))),this._parser.registerOscHandler(2,new lc(e=>this.setTitle(e))),this._parser.registerOscHandler(4,new lc(e=>this.setOrReportIndexedColor(e))),this._parser.registerOscHandler(8,new lc(e=>this.setHyperlink(e))),this._parser.registerOscHandler(10,new lc(e=>this.setOrReportFgColor(e))),this._parser.registerOscHandler(11,new lc(e=>this.setOrReportBgColor(e))),this._parser.registerOscHandler(12,new lc(e=>this.setOrReportCursorColor(e))),this._parser.registerOscHandler(104,new lc(e=>this.restoreIndexedColor(e))),this._parser.registerOscHandler(110,new lc(e=>this.restoreFgColor(e))),this._parser.registerOscHandler(111,new lc(e=>this.restoreBgColor(e))),this._parser.registerOscHandler(112,new lc(e=>this.restoreCursorColor(e))),this._parser.registerEscHandler({final:`7`},()=>this.saveCursor()),this._parser.registerEscHandler({final:`8`},()=>this.restoreCursor()),this._parser.registerEscHandler({final:`D`},()=>this.index()),this._parser.registerEscHandler({final:`E`},()=>this.nextLine()),this._parser.registerEscHandler({final:`H`},()=>this.tabSet()),this._parser.registerEscHandler({final:`M`},()=>this.reverseIndex()),this._parser.registerEscHandler({final:`=`},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:`>`},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:`c`},()=>this.fullReset()),this._parser.registerEscHandler({final:`n`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`o`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`|`},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:`}`},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:`~`},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:`%`,final:`@`},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:`%`,final:`G`},()=>this.selectDefaultCharset());for(let e in ks)this._parser.registerEscHandler({intermediates:`(`,final:e},()=>this.selectCharset(`(`+e)),this._parser.registerEscHandler({intermediates:`)`,final:e},()=>this.selectCharset(`)`+e)),this._parser.registerEscHandler({intermediates:`*`,final:e},()=>this.selectCharset(`*`+e)),this._parser.registerEscHandler({intermediates:`+`,final:e},()=>this.selectCharset(`+`+e)),this._parser.registerEscHandler({intermediates:`-`,final:e},()=>this.selectCharset(`-`+e)),this._parser.registerEscHandler({intermediates:`.`,final:e},()=>this.selectCharset(`.`+e)),this._parser.registerEscHandler({intermediates:`/`,final:e},()=>this.selectCharset(`/`+e));this._parser.registerEscHandler({intermediates:`#`,final:`8`},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(e=>(this._logService.error(`Parsing error: `,e),e)),this._parser.registerDcsHandler({intermediates:`$`,final:`q`},new pc((e,t)=>this.requestStatusString(e,t)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,n,r){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=n,this._parseStack.position=r}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((e,t)=>setTimeout(()=>t(`#SLOW_TIMEOUT`),Dc))]).catch(e=>{if(e!==`#SLOW_TIMEOUT`)throw e;console.warn(`async parser handler taking longer than ${Dc} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let n,r=this._activeBuffer.x,i=this._activeBuffer.y,a=0,o=this._parseStack.paused;if(o){if(n=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(n),n;r=this._parseStack.cursorStartX,i=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>wc&&(a=this._parseStack.position+wc)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e==`string`?` "${e}"`:` "${Array.prototype.map.call(e,e=>String.fromCharCode(e)).join(``)}"`}`),this._logService.logLevel===0&&this._logService.trace(`parsing data (codes)`,typeof e==`string`?e.split(``).map(e=>e.charCodeAt(0)):e),this._parseBuffer.lengthwc)for(let t=a;t0&&d.getWidth(this._activeBuffer.x-1)===2&&d.setCellFromCodepoint(this._activeBuffer.x-1,0,1,u);let f=this._parser.precedingJoinState;for(let p=t;ps){if(c){let e=d,t=this._activeBuffer.x-m;for(this._activeBuffer.x=m,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),d=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),m>0&&d instanceof xs&&d.copyCellsFrom(e,t,0,m,!1);t=0;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}else if(l&&(d.insertCells(this._activeBuffer.x,i-m,this._activeBuffer.getNullCell(u)),d.getWidth(s-1)===2&&d.setCellFromCodepoint(s-1,0,1,u)),d.setCellFromCodepoint(this._activeBuffer.x++,r,i,u),i>0)for(;--i;)d.setCellFromCodepoint(this._activeBuffer.x++,0,0,u)}this._parser.precedingJoinState=f,this._activeBuffer.x0&&d.getWidth(this._activeBuffer.x)===0&&!d.hasContent(this._activeBuffer.x)&&d.setCellFromCodepoint(this._activeBuffer.x,0,1,u),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final===`t`&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,e=>!Ec(e.params[0],this._optionsService.rawOptions.windowOptions)||t(e)):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new pc(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new lc(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)?.isWrapped){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);e.hasWidth(this._activeBuffer.x)&&!e.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,n,r=!1,i=!1){let a=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);a.replaceCells(t,n,this._activeBuffer.getNullCell(this._eraseAttrData()),i),r&&(a.isWrapped=!1)}_resetBufferLine(e,t=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n&&(n.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),n.isWrapped=!1)}eraseInDisplay(e,t=!1){this._restrictCursor(this._bufferService.cols);let n;switch(e.params[0]){case 0:for(n=this._activeBuffer.y,this._dirtyRowTracker.markDirty(n),this._eraseInBufferLine(n++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);n=this._bufferService.cols&&(this._activeBuffer.lines.get(n+1).isWrapped=!1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(n=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,n-1);n--&&!this._activeBuffer.lines.get(this._activeBuffer.ybase+n)?.getTrimmedLength(););for(;n>=0;n--)this._bufferService.scroll(this._eraseAttrData())}else{for(n=this._bufferService.rows,this._dirtyRowTracker.markDirty(n-1);n--;)this._resetBufferLine(n,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let e=this._activeBuffer.lines.length-this._bufferService.rows;e>0&&(this._activeBuffer.lines.trimStart(e),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-e,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-e,0),this._onScroll.fire(0))}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.ythis._activeBuffer.scrollBottom||this._activeBuffer.y65535?2:1}let c=s;for(let e=1;e0||(this._is(`xterm`)||this._is(`rxvt-unicode`)||this._is(`screen`)?this._coreService.triggerDataEvent(z.ESC+`[?1;2c`):this._is(`linux`)&&this._coreService.triggerDataEvent(z.ESC+`[?6c`)),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is(`xterm`)?this._coreService.triggerDataEvent(z.ESC+`[>0;276;0c`):this._is(`rxvt-unicode`)?this._coreService.triggerDataEvent(z.ESC+`[>85;95;0c`):this._is(`linux`)?this._coreService.triggerDataEvent(e.params[0]+`c`):this._is(`screen`)&&this._coreService.triggerDataEvent(z.ESC+`[>83;40003;0c`)),!0}_is(e){return(this._optionsService.rawOptions.termName+``).indexOf(e)===0}setMode(e){for(let t=0;t(e[e.NOT_RECOGNIZED=0]=`NOT_RECOGNIZED`,e[e.SET=1]=`SET`,e[e.RESET=2]=`RESET`,e[e.PERMANENTLY_SET=3]=`PERMANENTLY_SET`,e[e.PERMANENTLY_RESET=4]=`PERMANENTLY_RESET`))(n||={});let r=this._coreService.decPrivateModes,{activeProtocol:i,activeEncoding:a}=this._coreMouseService,o=this._coreService,{buffers:s,cols:c}=this._bufferService,{active:l,alt:u}=s,d=this._optionsService.rawOptions,f=(e,n)=>(o.triggerDataEvent(`${z.ESC}[${t?``:`?`}${e};${n}$y`),!0),p=e=>e?1:2,m=e.params[0];return t?m===2?f(m,4):m===4?f(m,p(o.modes.insertMode)):m===12?f(m,3):m===20?f(m,p(d.convertEol)):f(m,0):m===1?f(m,p(r.applicationCursorKeys)):m===3?f(m,d.windowOptions.setWinLines?c===80?2:+(c===132):0):m===6?f(m,p(r.origin)):m===7?f(m,p(r.wraparound)):m===8?f(m,3):m===9?f(m,p(i===`X10`)):m===12?f(m,p(d.cursorBlink)):m===25?f(m,p(!o.isCursorHidden)):m===45?f(m,p(r.reverseWraparound)):m===66?f(m,p(r.applicationKeypad)):m===67?f(m,4):m===1e3?f(m,p(i===`VT200`)):m===1002?f(m,p(i===`DRAG`)):m===1003?f(m,p(i===`ANY`)):m===1004?f(m,p(r.sendFocus)):m===1005?f(m,4):m===1006?f(m,p(a===`SGR`)):m===1015?f(m,4):m===1016?f(m,p(a===`SGR_PIXELS`)):m===1048?f(m,1):m===47||m===1047||m===1049?f(m,p(l===u)):m===2004?f(m,p(r.bracketedPasteMode)):m===2026?f(m,p(r.synchronizedOutput)):f(m,0)}_updateAttrColor(e,t,n,r,i){return t===2?(e|=50331648,e&=-16777216,e|=Ut.fromColorRGB([n,r,i])):t===5&&(e&=-50331904,e|=33554432|n&255),e}_extractColor(e,t,n){let r=[0,0,-1,0,0,0],i=0,a=0;do{if(r[a+i]=e.params[t+a],e.hasSubParams(t+a)){let n=e.getSubParams(t+a),o=0;do r[1]===5&&(i=1),r[a+o+1+i]=n[o];while(++o=2||r[1]===2&&a+i>=5)break;r[1]&&(i=1)}while(++a+t5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=K.fg,e.bg=K.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,n,r=this._curAttrData;for(let i=0;i=30&&n<=37?(r.fg&=-50331904,r.fg|=16777216|n-30):n>=40&&n<=47?(r.bg&=-50331904,r.bg|=16777216|n-40):n>=90&&n<=97?(r.fg&=-50331904,r.fg|=n-90|16777224):n>=100&&n<=107?(r.bg&=-50331904,r.bg|=n-100|16777224):n===0?this._processSGR0(r):n===1?r.fg|=134217728:n===3?r.bg|=67108864:n===4?(r.fg|=268435456,this._processUnderline(e.hasSubParams(i)?e.getSubParams(i)[0]:1,r)):n===5?r.fg|=536870912:n===7?r.fg|=67108864:n===8?r.fg|=1073741824:n===9?r.fg|=2147483648:n===2?r.bg|=134217728:n===21?this._processUnderline(2,r):n===22?(r.fg&=-134217729,r.bg&=-134217729):n===23?r.bg&=-67108865:n===24?(r.fg&=-268435457,this._processUnderline(0,r)):n===25?r.fg&=-536870913:n===27?r.fg&=-67108865:n===28?r.fg&=-1073741825:n===29?r.fg&=2147483647:n===39?(r.fg&=-67108864,r.fg|=K.fg&16777215):n===49?(r.bg&=-67108864,r.bg|=K.bg&16777215):n===38||n===48||n===58?i+=this._extractColor(e,i,r):n===53?r.bg|=1073741824:n===55?r.bg&=-1073741825:n===59?(r.extended=r.extended.clone(),r.extended.underlineColor=-1,r.updateExtended()):n===100?(r.fg&=-67108864,r.fg|=K.fg&16777215,r.bg&=-67108864,r.bg|=K.bg&16777215):this._logService.debug(`Unknown SGR attribute: %d.`,n);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${z.ESC}[0n`);break;case 6:let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${z.ESC}[${e};${t}R`)}return!0}deviceStatusPrivate(e){if(e.params[0]===6){let e=this._activeBuffer.y+1,t=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${z.ESC}[?${e};${t}R`)}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=K.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle=`block`;break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle=`underline`;break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle=`bar`}let e=t%2==1;this._coreService.decPrivateModes.cursorBlink=e}return!0}setScrollRegion(e){let t=e.params[0]||1,n;return(e.length<2||(n=e.params[1])>this._bufferService.rows||n===0)&&(n=this._bufferService.rows),n>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=n-1,this._setCursor(0,0)),!0}windowOptions(e){if(!Ec(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${z.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>Tc&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>Tc&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],n=e.split(`;`);for(;n.length>1;){let e=n.shift(),r=n.shift();if(/^\d+$/.exec(e)){let n=parseInt(e);if(jc(n)){if(r===`?`)t.push({type:0,index:n});else{let e=bc(r);e&&t.push({type:1,index:n,color:e})}}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(`;`);if(t===-1)return!0;let n=e.slice(0,t).trim(),r=e.slice(t+1);return r?this._createHyperlink(n,r):!n.trim()&&this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let n=e.split(`:`),r,i=n.findIndex(e=>e.startsWith(`id=`));return i!==-1&&(r=n[i].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:r,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let n=e.split(`;`);for(let e=0;e=this._specialColors.length);++e,++t)if(n[e]===`?`)this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=bc(n[e]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],n=e.split(`;`);for(let e=0;e=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=K.clone(),this._eraseAttrDataInternal=K.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new Gt;e.content=4194373,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t(this._coreService.triggerDataEvent(`${z.ESC}${e}${z.ESC}\\`),!0),r=this._bufferService.buffer,i=this._optionsService.rawOptions;return n(e===`"q`?`P1$r${+!!this._curAttrData.isProtected()}"q`:e===`"p`?`P1$r61;1"p`:e===`r`?`P1$r${r.scrollTop+1};${r.scrollBottom+1}r`:e===`m`?`P1$r0m`:e===` q`?`P1$r${{block:2,underline:4,bar:6}[i.cursorStyle]-+!!i.cursorBlink} q`:`P0$r`)}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Ac=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){ethis.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(Oc=e,e=t,t=Oc),ethis.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Ac=M([N(0,Qt)],Ac);function jc(e){return 0<=e&&e<256}var Mc=5e7,Nc=12,Pc=50,Fc=class extends F{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new L),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let n;for(;n=this._writeBuffer.shift();){this._action(n);let e=this._callbacks.shift();e&&e()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>Mc)throw Error(`write data discarded, use flow control to avoid losing data`);if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let n=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let e=this._writeBuffer[this._bufferOffset],r=this._action(e,t);if(r){r.catch(e=>(queueMicrotask(()=>{throw e}),Promise.resolve(!1))).then(e=>performance.now()-n>=Nc?setTimeout(()=>this._innerWrite(0,e)):this._innerWrite(n,e));return}let i=this._callbacks[this._bufferOffset];if(i&&i(),this._bufferOffset++,this._pendingData-=e.length,performance.now()-n>=Nc)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>Pc&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Ic=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let n=t.addMarker(t.ybase+t.y),r={data:e,id:this._nextId++,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(r,n)),this._dataByLinkId.set(r.id,r),r.id}let n=e,r=this._getEntryIdKey(n),i=this._entriesWithId.get(r);if(i)return this.addLineToLink(i.id,t.ybase+t.y),i.id;let a=t.addMarker(t.ybase+t.y),o={id:this._nextId++,key:this._getEntryIdKey(n),data:n,lines:[a]};return a.onDispose(()=>this._removeMarkerFromLink(o,a)),this._entriesWithId.set(o.key,o),this._dataByLinkId.set(o.id,o),o.id}addLineToLink(e,t){let n=this._dataByLinkId.get(e);if(n&&n.lines.every(e=>e.line!==t)){let e=this._bufferService.buffer.addMarker(t);n.lines.push(e),e.onDispose(()=>this._removeMarkerFromLink(n,e))}}getLinkData(e){return this._dataByLinkId.get(e)?.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let n=e.lines.indexOf(t);n!==-1&&(e.lines.splice(n,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Ic=M([N(0,Qt)],Ic);var Lc=!1,Rc=class extends F{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new Vn),this._onBinary=this._register(new L),this.onBinary=this._onBinary.event,this._onData=this._register(new L),this.onData=this._onData.event,this._onLineFeed=this._register(new L),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new L),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new L),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new L),this._instantiationService=new ps,this.optionsService=this._register(new zs(e)),this._instantiationService.setService(an,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Is)),this._instantiationService.setService(Qt,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(gs)),this._instantiationService.setService(rn,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Ws)),this._instantiationService.setService(en,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(Ys)),this._instantiationService.setService($t,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(tc)),this._instantiationService.setService(sn,this.unicodeService),this._charsetService=this._instantiationService.createInstance(nc),this._instantiationService.setService(tn,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Ic),this._instantiationService.setService(on,this._oscLinkService),this._inputHandler=this._register(new kc(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(qn.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(qn.forward(this._bufferService.onResize,this._onResize)),this._register(qn.forward(this.coreService.onData,this._onData)),this._register(qn.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange([`windowsMode`,`windowsPty`],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new Fc((e,t)=>this._inputHandler.parse(e,t))),this._register(qn.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new L),this._onScroll.event(e=>{this._onScrollApi?.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Lc&&(this._logService.warn(`writeSync is unreliable and will be removed soon.`),Lc=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,Ps),t=Math.max(t,Fs),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend===`conpty`&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(rc.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:`H`},()=>(rc(this._bufferService),!1))),this._windowsWrappingHeuristics.value=P(()=>{for(let t of e)t.dispose()})}}},zc={48:[`0`,`)`],49:[`1`,`!`],50:[`2`,`@`],51:[`3`,`#`],52:[`4`,`$`],53:[`5`,`%`],54:[`6`,`^`],55:[`7`,`&`],56:[`8`,`*`],57:[`9`,`(`],186:[`;`,`:`],187:[`=`,`+`],188:[`,`,`<`],189:[`-`,`_`],190:[`.`,`>`],191:[`/`,`?`],192:["`",`~`],219:[`[`,`{`],220:[`\\`,`|`],221:[`]`,`}`],222:[`'`,`"`]};function Bc(e,t,n,r){let i={type:0,cancel:!1,key:void 0},a=+!!e.shiftKey|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key===`UIKeyInputUpArrow`?i.key=t?z.ESC+`OA`:z.ESC+`[A`:e.key===`UIKeyInputLeftArrow`?i.key=t?z.ESC+`OD`:z.ESC+`[D`:e.key===`UIKeyInputRightArrow`?i.key=t?z.ESC+`OC`:z.ESC+`[C`:e.key===`UIKeyInputDownArrow`&&(i.key=t?z.ESC+`OB`:z.ESC+`[B`);break;case 8:i.key=e.ctrlKey?`\b`:z.DEL,e.altKey&&(i.key=z.ESC+i.key);break;case 9:if(e.shiftKey){i.key=z.ESC+`[Z`;break}i.key=z.HT,i.cancel=!0;break;case 13:i.key=e.altKey?z.ESC+z.CR:z.CR,i.cancel=!0;break;case 27:i.key=z.ESC,e.altKey&&(i.key=z.ESC+z.ESC),i.cancel=!0;break;case 37:if(e.metaKey)break;i.key=a?z.ESC+`[1;`+(a+1)+`D`:t?z.ESC+`OD`:z.ESC+`[D`;break;case 39:if(e.metaKey)break;i.key=a?z.ESC+`[1;`+(a+1)+`C`:t?z.ESC+`OC`:z.ESC+`[C`;break;case 38:if(e.metaKey)break;i.key=a?z.ESC+`[1;`+(a+1)+`A`:t?z.ESC+`OA`:z.ESC+`[A`;break;case 40:if(e.metaKey)break;i.key=a?z.ESC+`[1;`+(a+1)+`B`:t?z.ESC+`OB`:z.ESC+`[B`;break;case 45:!e.shiftKey&&!e.ctrlKey&&(i.key=z.ESC+`[2~`);break;case 46:i.key=a?z.ESC+`[3;`+(a+1)+`~`:z.ESC+`[3~`;break;case 36:i.key=a?z.ESC+`[1;`+(a+1)+`H`:t?z.ESC+`OH`:z.ESC+`[H`;break;case 35:i.key=a?z.ESC+`[1;`+(a+1)+`F`:t?z.ESC+`OF`:z.ESC+`[F`;break;case 33:e.shiftKey?i.type=2:i.key=e.ctrlKey?z.ESC+`[5;`+(a+1)+`~`:z.ESC+`[5~`;break;case 34:e.shiftKey?i.type=3:i.key=e.ctrlKey?z.ESC+`[6;`+(a+1)+`~`:z.ESC+`[6~`;break;case 112:i.key=a?z.ESC+`[1;`+(a+1)+`P`:z.ESC+`OP`;break;case 113:i.key=a?z.ESC+`[1;`+(a+1)+`Q`:z.ESC+`OQ`;break;case 114:i.key=a?z.ESC+`[1;`+(a+1)+`R`:z.ESC+`OR`;break;case 115:i.key=a?z.ESC+`[1;`+(a+1)+`S`:z.ESC+`OS`;break;case 116:i.key=a?z.ESC+`[15;`+(a+1)+`~`:z.ESC+`[15~`;break;case 117:i.key=a?z.ESC+`[17;`+(a+1)+`~`:z.ESC+`[17~`;break;case 118:i.key=a?z.ESC+`[18;`+(a+1)+`~`:z.ESC+`[18~`;break;case 119:i.key=a?z.ESC+`[19;`+(a+1)+`~`:z.ESC+`[19~`;break;case 120:i.key=a?z.ESC+`[20;`+(a+1)+`~`:z.ESC+`[20~`;break;case 121:i.key=a?z.ESC+`[21;`+(a+1)+`~`:z.ESC+`[21~`;break;case 122:i.key=a?z.ESC+`[23;`+(a+1)+`~`:z.ESC+`[23~`;break;case 123:i.key=a?z.ESC+`[24;`+(a+1)+`~`:z.ESC+`[24~`;break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?i.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?i.key=z.NUL:e.keyCode>=51&&e.keyCode<=55?i.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?i.key=z.DEL:e.keyCode===219?i.key=z.ESC:e.keyCode===220?i.key=z.FS:e.keyCode===221&&(i.key=z.GS);else if((!n||r)&&e.altKey&&!e.metaKey){let t=zc[e.keyCode]?.[+!!e.shiftKey];if(t)i.key=z.ESC+t;else if(e.keyCode>=65&&e.keyCode<=90){let t=e.ctrlKey?e.keyCode-64:e.keyCode+32,n=String.fromCharCode(t);e.shiftKey&&(n=n.toUpperCase()),i.key=z.ESC+n}else if(e.keyCode===32)i.key=z.ESC+(e.ctrlKey?z.NUL:` `);else if(e.key===`Dead`&&e.code.startsWith(`Key`)){let t=e.code.slice(3,4);e.shiftKey||(t=t.toLowerCase()),i.key=z.ESC+t,i.cancel=!0}}else n&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(i.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?i.key=e.key:e.key&&e.ctrlKey&&(e.key===`_`&&(i.key=z.US),e.key===`@`&&(i.key=z.NUL))}return i}var q=0,Vc=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new jo,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new jo,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((e,t)=>this._getKey(e)-this._getKey(t)),t=0,n=0,r=Array(this._array.length+this._insertedValues.length);for(let i=0;i=this._array.length||this._getKey(e[t])<=this._getKey(this._array[n])?(r[i]=e[t],t++):r[i]=this._array[n++];this._array=r,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(q=this._search(t),q===-1)||this._getKey(this._array[q])!==t)return!1;do if(this._array[q]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(q),!0;while(++qe-t),t=0,n=Array(this._array.length-e.length),r=0;for(let i=0;i0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(q=this._search(e),!(q<0||q>=this._array.length)&&this._getKey(this._array[q])===e))do yield this._array[q];while(++q=this._array.length)&&this._getKey(this._array[q])===e))do t(this._array[q]);while(++q=t;){let r=t+n>>1,i=this._getKey(this._array[r]);if(i>e)n=r-1;else if(i0&&this._getKey(this._array[r-1])===e;)r--;return r}}return t}},Hc=0,Uc=0,Wc=class extends F{constructor(){super(),this._decorations=new Vc(e=>e?.marker.line),this._onDecorationRegistered=this._register(new L),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new L),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(P(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Gc(e);if(t){let e=t.marker.onDispose(()=>t.dispose()),n=t.onDispose(()=>{n.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),e.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,n){let r=0,i=0;for(let a of this._decorations.getKeyIterator(t))r=a.options.x??0,i=r+(a.options.width??1),e>=r&&e{Hc=t.options.x??0,Uc=Hc+(t.options.width??1),e>=Hc&&e=this._debounceThresholdMS)this._lastRefreshMs=r,this._innerRefresh();else if(!this._additionalRefreshRequested){let e=r-this._lastRefreshMs,t=this._debounceThresholdMS-e;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},t)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},Jc=20,Yc=class extends F{constructor(e,t,n,r){super(),this._terminal=e,this._coreBrowserService=n,this._renderService=r,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce=``;let i=this._coreBrowserService.mainDocument;this._accessibilityContainer=i.createElement(`div`),this._accessibilityContainer.classList.add(`xterm-accessibility`),this._rowContainer=i.createElement(`div`),this._rowContainer.setAttribute(`role`,`list`),this._rowContainer.classList.add(`xterm-accessibility-tree`),this._rowElements=[];for(let e=0;ethis._handleBoundaryFocus(e,0),this._bottomBoundaryFocusListener=e=>this._handleBoundaryFocus(e,1),this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=i.createElement(`div`),this._liveRegion.classList.add(`live-region`),this._liveRegion.setAttribute(`aria-live`,`assertive`),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new qc(this._renderRows.bind(this))),!this._terminal.element)throw Error(`Cannot enable accessibility before Terminal.open`);this._terminal.element.insertAdjacentElement(`afterbegin`,this._accessibilityContainer),this._register(this._terminal.onResize(e=>this._handleResize(e.rows))),this._register(this._terminal.onRender(e=>this._refreshRows(e.start,e.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(e=>this._handleChar(e))),this._register(this._terminal.onLineFeed(()=>this._handleChar(` +`))),this._register(this._terminal.onA11yTab(e=>this._handleTab(e))),this._register(this._terminal.onKey(e=>this._handleKey(e.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(R(i,`selectionchange`,()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(P(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===` +`&&(this._liveRegionLineCount++,this._liveRegionLineCount===Jc+1&&(this._liveRegion.textContent+=kt.get())))}_clearLiveRegion(){this._liveRegion.textContent=``,this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),/\p{Control}/u.test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let n=this._terminal.buffer,r=n.lines.length.toString();for(let i=e;i<=t;i++){let e=n.lines.get(n.ydisp+i),t=[],a=e?.translateToString(!0,void 0,void 0,t)||``,o=(n.ydisp+i+1).toString(),s=this._rowElements[i];s&&(a.length===0?(s.textContent=`\xA0`,this._rowColumns.set(s,[0,1])):(s.textContent=a,this._rowColumns.set(s,t)),s.setAttribute(`aria-posinset`,o),s.setAttribute(`aria-setsize`,r),this._alignRowWidth(s))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce=``)}_handleBoundaryFocus(e,t){let n=e.target,r=this._rowElements[t===0?1:this._rowElements.length-2];if(n.getAttribute(`aria-posinset`)===(t===0?`1`:`${this._terminal.buffer.lines.length}`)||e.relatedTarget!==r)return;let i,a;if(t===0?(i=n,a=this._rowElements.pop(),this._rowContainer.removeChild(a)):(i=this._rowElements.shift(),a=n,this._rowContainer.removeChild(i)),i.removeEventListener(`focus`,this._topBoundaryFocusListener),a.removeEventListener(`focus`,this._bottomBoundaryFocusListener),t===0){let e=this._createAccessibilityTreeNode();this._rowElements.unshift(e),this._rowContainer.insertAdjacentElement(`afterbegin`,e)}else{let e=this._createAccessibilityTreeNode();this._rowElements.push(e),this._rowContainer.appendChild(e)}this._rowElements[0].addEventListener(`focus`,this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error(`anchorNode and/or focusNode are null`);return}let t={node:e.anchorNode,offset:e.anchorOffset},n={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(n.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===n.node&&t.offset>n.offset)&&([t,n]=[n,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let r=this._rowElements.slice(-1)[0];if(n.node.compareDocumentPosition(r)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(n={node:r,offset:r.textContent?.length??0}),!this._rowContainer.contains(n.node))return;let i=({node:e,offset:t})=>{let n=e instanceof Text?e.parentNode:e,r=parseInt(n?.getAttribute(`aria-posinset`),10)-1;if(isNaN(r))return console.warn(`row is invalid. Race condition?`),null;let i=this._rowColumns.get(n);if(!i)return console.warn(`columns is null. Race condition?`),null;let a=t=this._terminal.cols&&(++r,a=0),{row:r,column:a}},a=i(t),o=i(n);if(a&&o){if(a.row>o.row||a.row===o.row&&a.column>=o.column)throw Error(`invalid range`);this._terminal.select(a.column,a.row,(o.row-a.row)*this._terminal.cols-a.column+o.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener(`focus`,this._bottomBoundaryFocusListener);for(let e=this._rowContainer.children.length;ee;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener(`focus`,this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement(`div`);return e.setAttribute(`role`,`listitem`),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e{Ln(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,this._activeProviderReplies?.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(R(this._element,`mouseleave`,()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(R(this._element,`mousemove`,this._handleMouseMove.bind(this))),this._register(R(this._element,`mousedown`,this._handleMouseDown.bind(this))),this._register(R(this._element,`mouseup`,this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let n=e.composedPath();for(let e=0;e{e?.forEach(e=>{e.link.dispose&&e.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let n=!1;for(let[r,i]of this._linkProviderService.linkProviders.entries())t?this._activeProviderReplies?.get(r)&&(n=this._checkLinkProviderResult(r,e,n)):i.provideLinks(e.y,t=>{if(this._isMouseOut)return;let i=t?.map(e=>({link:e}));this._activeProviderReplies?.set(r,i),n=this._checkLinkProviderResult(r,e,n),this._activeProviderReplies?.size===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let n=new Set;for(let r=0;re?this._bufferService.cols:r.link.range.end.x;for(let e=a;e<=o;e++){if(n.has(e)){i.splice(t--,1);break}n.add(e)}}}}_checkLinkProviderResult(e,t,n){if(!this._activeProviderReplies)return n;let r=this._activeProviderReplies.get(e),i=!1;for(let t=0;tthis._linkAtPosition(e.link,t));e&&(n=!0,this._handleNewLink(e))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!n)for(let e=0;ethis._linkAtPosition(e.link,t));if(r){n=!0,this._handleNewLink(r);break}}return n}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Zc(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Ln(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0||e.link.decorations.underline,pointerCursor:e.link.decorations===void 0||e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>this._currentLink?.state?.decorations.pointerCursor,set:e=>{this._currentLink?.state&&this._currentLink.state.decorations.pointerCursor!==e&&(this._currentLink.state.decorations.pointerCursor=e,this._currentLink.state.isHovered&&this._element.classList.toggle(`xterm-cursor-pointer`,e))}},underline:{get:()=>this._currentLink?.state?.decorations.underline,set:t=>{this._currentLink?.state&&this._currentLink?.state?.decorations.underline!==t&&(this._currentLink.state.decorations.underline=t,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,t))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(e=>{if(!this._currentLink)return;let t=e.start===0?0:e.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+e.end;if(this._currentLink.link.range.start.y>=t&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(t,n),this._lastMouseEvent)){let e=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);e&&this._askForLink(e,!1)}})))}_linkHover(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add(`xterm-cursor-pointer`)),t.hover&&t.hover(n,t.text)}_fireUnderlineEvent(e,t){let n=e.range,r=this._bufferService.buffer.ydisp,i=this._createLinkUnderlineEvent(n.start.x-1,n.start.y-r-1,n.end.x,n.end.y-r-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(i)}_linkLeave(e,t,n){this._currentLink?.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove(`xterm-cursor-pointer`)),t.leave&&t.leave(n,t.text)}_linkAtPosition(e,t){let n=e.range.start.y*this._bufferService.cols+e.range.start.x,r=e.range.end.y*this._bufferService.cols+e.range.end.x,i=t.y*this._bufferService.cols+t.x;return n<=i&&i<=r}_positionFromMouseEvent(e,t,n){let r=n.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(r)return{x:r[0],y:r[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,n,r,i){return{x1:e,y1:t,x2:n,y2:r,cols:this._bufferService.cols,fg:i}}};Xc=M([N(1,pn),N(2,mn),N(3,Qt),N(4,vn)],Xc);function Zc(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var Qc=class extends Rc{constructor(e={}){super(e),this._linkifier=this._register(new Vn),this.browser=mo,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new Vn),this._onCursorMove=this._register(new L),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new L),this.onKey=this._onKey.event,this._onRender=this._register(new L),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new L),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new L),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new L),this.onBell=this._onBell.event,this._onFocus=this._register(new L),this._onBlur=this._register(new L),this._onA11yCharEmitter=this._register(new L),this._onA11yTabEmitter=this._register(new L),this._onWillOpen=this._register(new L),this._setup(),this._decorationService=this._instantiationService.createInstance(Wc),this._instantiationService.setService(cn,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(co),this._instantiationService.setService(vn,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(ln)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(e=>this.refresh(e?.start??0,e?.end??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(e=>this._reportWindowsOptions(e))),this._register(this._inputHandler.onColor(e=>this._handleColorEvent(e))),this._register(qn.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(qn.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(qn.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(qn.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(e=>this._afterResize(e.cols,e.rows))),this._register(P(()=>{this._customKeyEventHandler=void 0,this.element?.parentNode?.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let e,n=``;switch(t.index){case 256:e=`foreground`,n=`10`;break;case 257:e=`background`,n=`11`;break;case 258:e=`cursor`,n=`12`;break;default:e=`ansi`,n=`4;`+t.index}switch(t.type){case 0:let r=H.toColorRGB(e===`ansi`?this._themeService.colors.ansi[t.index]:this._themeService.colors[e]);this.coreService.triggerDataEvent(`${z.ESC}]${n};${Sc(r)}${Ea.ST}`);break;case 1:if(e===`ansi`)this._themeService.modifyColors(e=>e.ansi[t.index]=V.toColor(...t.color));else{let n=e;this._themeService.modifyColors(e=>e[n]=V.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Yc,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.ESC+`[I`),this.element.classList.add(`focus`),this._showCursor(),this._onFocus.fire()}blur(){return this.textarea?.blur()}_handleTextAreaBlur(){this.textarea.value=``,this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.ESC+`[O`),this.element.classList.remove(`focus`),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let n=Math.min(this.buffer.x,this.cols-1),r=this._renderService.dimensions.css.cell.height,i=t.getWidth(n),a=this._renderService.dimensions.css.cell.width*i,o=this.buffer.y*this._renderService.dimensions.css.cell.height,s=n*this._renderService.dimensions.css.cell.width;this.textarea.style.left=s+`px`,this.textarea.style.top=o+`px`,this.textarea.style.width=a+`px`,this.textarea.style.height=r+`px`,this.textarea.style.lineHeight=r+`px`,this.textarea.style.zIndex=`-5`}_initGlobal(){this._bindKeys(),this._register(R(this.element,`copy`,e=>{this.hasSelection()&&Mt(e,this._selectionService)}));let e=e=>Nt(e,this.textarea,this.coreService,this.optionsService);this._register(R(this.textarea,`paste`,e)),this._register(R(this.element,`paste`,e)),vo?this._register(R(this.element,`mousedown`,e=>{e.button===2&&It(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(R(this.element,`contextmenu`,e=>{It(e,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Eo&&this._register(R(this.element,`auxclick`,e=>{e.button===1&&Ft(e,this.textarea,this.screenElement)}))}_bindKeys(){this._register(R(this.textarea,`keyup`,e=>this._keyUp(e),!0)),this._register(R(this.textarea,`keydown`,e=>this._keyDown(e),!0)),this._register(R(this.textarea,`keypress`,e=>this._keyPress(e),!0)),this._register(R(this.textarea,`compositionstart`,()=>this._compositionHelper.compositionstart())),this._register(R(this.textarea,`compositionupdate`,e=>this._compositionHelper.compositionupdate(e))),this._register(R(this.textarea,`compositionend`,()=>this._compositionHelper.compositionend())),this._register(R(this.textarea,`input`,e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){if(!e)throw Error(`Terminal requires a parent element.`);if(e.isConnected||this._logService.debug(`Terminal.open was called on an element that was not attached to the DOM`),this.element?.ownerDocument.defaultView&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement(`div`),this.element.dir=`ltr`,this.element.classList.add(`terminal`),this.element.classList.add(`xterm`),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement(`div`),this._viewportElement.classList.add(`xterm-viewport`),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement(`div`),this.screenElement.classList.add(`xterm-screen`),this._register(R(this.screenElement,`mousemove`,e=>this.updateCursorStyle(e))),this._helperContainer=this._document.createElement(`div`),this._helperContainer.classList.add(`xterm-helpers`),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let n=this.textarea=this._document.createElement(`textarea`);this.textarea.classList.add(`xterm-helper-textarea`),this.textarea.setAttribute(`aria-label`,Dt.get()),Do||this.textarea.setAttribute(`aria-multiline`,`false`),this.textarea.setAttribute(`autocorrect`,`off`),this.textarea.setAttribute(`autocapitalize`,`off`),this.textarea.setAttribute(`spellcheck`,`false`),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange(`disableStdin`,()=>n.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(oo,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<`u`?window.document:null)),this._instantiationService.setService(fn,this._coreBrowserService),this._register(R(this.textarea,`focus`,e=>this._handleTextAreaFocus(e))),this._register(R(this.textarea,`blur`,()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(no,this._document,this._helperContainer),this._instantiationService.setService(dn,this._charSizeService),this._themeService=this._instantiationService.createInstance(ds),this._instantiationService.setService(_n,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(La),this._instantiationService.setService(gn,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(No,this.rows,this.screenElement)),this._instantiationService.setService(mn,this._renderService),this._register(this._renderService.onRenderedViewportChange(e=>this._onRender.fire(e))),this.onResize(e=>this._renderService.resize(e.cols,e.rows)),this._compositionView=this._document.createElement(`div`),this._compositionView.classList.add(`composition-view`),this._compositionHelper=this._instantiationService.createInstance(Da,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(fo),this._instantiationService.setService(pn,this._mouseService);let r=this._linkifier.value=this._register(this._instantiationService.createInstance(Xc,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(va,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(e=>{super.scrollLines(e,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(ts,this.element,this.screenElement,r)),this._instantiationService.setService(hn,this._selectionService),this._register(this._selectionService.onRequestScrollLines(e=>this.scrollLines(e.amount,e.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(e=>this._renderService.handleSelectionChanged(e.start,e.end,e.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(e=>{this.textarea.value=e,this.textarea.focus(),this.textarea.select()})),this._register(qn.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{this._selectionService.refresh(),this._viewport?.queueSync()})),this._register(this._instantiationService.createInstance(ya,this.screenElement)),this._register(R(this.element,`mousedown`,e=>this._selectionService.handleMouseDown(e))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add(`enable-mouse-events`)):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(Yc,this)),this._register(this.optionsService.onSpecificOptionChange(`screenReaderMode`,e=>this._handleScreenReaderModeOptionChange(e))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(wa,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange(`overviewRuler`,e=>{!this._overviewRulerRenderer&&e&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(wa,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(to,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function n(t){let n=e._mouseService.getMouseReportCoords(t,e.screenElement);if(!n)return!1;let r,i;switch(t.overrideType||t.type){case`mousemove`:i=32,t.buttons===void 0?(r=3,t.button!==void 0&&(r=t.button<3?t.button:3)):r=t.buttons&1?0:t.buttons&4?1:t.buttons&2?2:3;break;case`mouseup`:i=0,r=t.button<3?t.button:3;break;case`mousedown`:i=1,r=t.button<3?t.button:3;break;case`wheel`:if(e._customWheelEventHandler&&e._customWheelEventHandler(t)===!1)return!1;let n=t.deltaY;if(n===0||e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return!1;i=n<0?0:1,r=4;break;default:return!1}return i===void 0||r===void 0||r>4?!1:e.coreMouseService.triggerMouseEvent({col:n.col,row:n.row,x:n.x,y:n.y,button:r,action:i,ctrl:t.ctrlKey,alt:t.altKey,shift:t.shiftKey})}let r={mouseup:null,wheel:null,mousedrag:null,mousemove:null},i={mouseup:e=>(n(e),e.buttons||(this._document.removeEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.removeEventListener(`mousemove`,r.mousedrag)),this.cancel(e)),wheel:e=>(n(e),this.cancel(e,!0)),mousedrag:e=>{e.buttons&&n(e)},mousemove:e=>{e.buttons||n(e)}};this._register(this.coreMouseService.onProtocolChange(e=>{e?(this.optionsService.rawOptions.logLevel===`debug`&&this._logService.debug(`Binding to mouse events:`,this.coreMouseService.explainEvents(e)),this.element.classList.add(`enable-mouse-events`),this._selectionService.disable()):(this._logService.debug(`Unbinding from mouse events.`),this.element.classList.remove(`enable-mouse-events`),this._selectionService.enable()),e&8?r.mousemove||=(t.addEventListener(`mousemove`,i.mousemove),i.mousemove):(t.removeEventListener(`mousemove`,r.mousemove),r.mousemove=null),e&16?r.wheel||=(t.addEventListener(`wheel`,i.wheel,{passive:!1}),i.wheel):(t.removeEventListener(`wheel`,r.wheel),r.wheel=null),e&2?r.mouseup||=i.mouseup:(this._document.removeEventListener(`mouseup`,r.mouseup),r.mouseup=null),e&4?r.mousedrag||=i.mousedrag:(this._document.removeEventListener(`mousemove`,r.mousedrag),r.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(R(t,`mousedown`,e=>{if(e.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(e))return n(e),r.mouseup&&this._document.addEventListener(`mouseup`,r.mouseup),r.mousedrag&&this._document.addEventListener(`mousemove`,r.mousedrag),this.cancel(e)})),this._register(R(t,`wheel`,t=>{if(!r.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(t)===!1)return!1;if(!this.buffer.hasScrollback){if(t.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(t,e._renderService?.dimensions?.device?.cell?.height,e._coreBrowserService?.dpr)===0)return this.cancel(t,!0);let n=z.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?`O`:`[`)+(t.deltaY<0?`A`:`B`);return this.coreService.triggerDataEvent(n,!0),this.cancel(t,!0)}}},{passive:!1}))}refresh(e,t){this._renderService?.refreshRows(e,t)}updateCursorStyle(e){this._selectionService?.shouldColumnSelect(e)?this.element.classList.add(`column-select`):this.element.classList.remove(`column-select`)}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Pt(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw Error(`Terminal must be opened first`);this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,n){this._selectionService.setSelection(e,t,n)}getSelection(){return this._selectionService?this._selectionService.selectionText:``}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){this._selectionService?.clearSelection()}selectAll(){this._selectionService?.selectAll()}selectLines(e,t){this._selectionService?.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;t||e.key!==`Dead`&&e.key!==`AltGraph`||(this._unprocessedDeadKey=!0);let n=Bc(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),n.type===3||n.type===2){let t=this.rows-1;return this.scrollLines(n.type===2?-t:t),this.cancel(e,!0)}if(n.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(n.cancel&&this.cancel(e,!0),!n.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((n.key===z.ETX||n.key===z.CR)&&(this.textarea.value=``),this._onKey.fire({key:n.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(n.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let n=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState(`AltGraph`);return t.type===`keypress`?n:n&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&($c(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType===`insertText`&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){e===this.cols&&t===this.rows?this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure():super.resize(e,t)}_afterResize(e,t){this._charSizeService?.measure()}clear(){if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let n={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(n),t.dispose=()=>this._wrappedAddonDispose(n),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let n=0;n=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new Gt)}translateToString(e,t,n){return this._line.translateToString(e,t,n)}},nl=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new tl(t)}getNullCell(){return new Gt}},rl=class extends F{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new L),this.onBufferChange=this._onBufferChange.event,this._normal=new nl(this._core.buffers.normal,`normal`),this._alternate=new nl(this._core.buffers.alt,`alternate`),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw Error(`Active buffer is neither normal nor alternate`)}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},il=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,e=>t(e.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(e,n)=>t(e,n.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},al=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},ol=[`cols`,`rows`],sl=0,cl=class extends F{constructor(e){super(),this._core=this._register(new Qc(e)),this._addonManager=this._register(new el),this._publicOptions={...this._core.options};let t=e=>this._core.options[e],n=(e,t)=>{this._checkReadonlyOptions(e),this._core.options[e]=t};for(let e in this._core.options){let r={get:t.bind(this,e),set:n.bind(this,e)};Object.defineProperty(this._publicOptions,e,r)}}_checkReadonlyOptions(e){if(ol.includes(e))throw Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw Error(`You must set the allowProposedApi option to true to use proposed API`)}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||=new il(this._core),this._parser}get unicode(){return this._checkProposedApi(),new al(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||=this._register(new rl(this._core)),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t=`none`;switch(this._core.coreMouseService.activeProtocol){case`X10`:t=`x10`;break;case`VT200`:t=`vt200`;break;case`DRAG`:t=`drag`;break;case`ANY`:t=`any`}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,n){this._verifyIntegers(e,t,n),this._core.select(e,t,n)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r +`,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Dt.get()},set promptLabel(e){Dt.set(e)},get tooMuchOutput(){return kt.get()},set tooMuchOutput(e){kt.set(e)}}}_verifyIntegers(...e){for(sl of e)if(sl===1/0||isNaN(sl)||sl%1!=0)throw Error(`This API only accepts integers`)}_verifyPositiveIntegers(...e){for(sl of e)if(sl&&(sl===1/0||isNaN(sl)||sl%1!=0||sl<0))throw Error(`This API only accepts positive integers`)}},ll=2,ul=1,dl=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue(`height`)),i=Math.max(0,parseInt(n.getPropertyValue(`width`))),a=window.getComputedStyle(this._terminal.element),o={top:parseInt(a.getPropertyValue(`padding-top`)),bottom:parseInt(a.getPropertyValue(`padding-bottom`)),right:parseInt(a.getPropertyValue(`padding-right`)),left:parseInt(a.getPropertyValue(`padding-left`))},s=o.top+o.bottom,c=o.right+o.left,l=r-s,u=i-c-t;return{cols:Math.max(ll,Math.floor(u/e.css.cell.width)),rows:Math.max(ul,Math.floor(l/e.css.cell.height))}}};function fl(e=r()){return{fontSize:typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(pointer: coarse)`).matches?13*e/100:12*e/100,fontFamily:getComputedStyle(document.body).fontFamily}}function pl({pending:e,size:t,screenScale:n,socketRef:r,slotRefs:i,panesExist:a,onAnswered:o}){(0,j.useEffect)(()=>{if(e===null)return;let t=r.current;if(!t||t.readyState!==WebSocket.OPEN)return;let s=[];for(let n=0;n{let t=new cl(fl(n)),r=new dl;t.loadAddon(r),t.open(e);let i=r.proposeDimensions();if(t.dispose(),!i)throw Error(`could not measure the cell`);return{rows:i.rows,cols:i.cols}})}catch{c=[]}Ee(t,{type:`start`,sizes:c})&&o()},[e,t,n,r,i,a,o])}var ml=15e3,hl=1e4,gl=.2;function _l(e,t=Math.random){let n=Math.min(500*2**Math.min(Number.isFinite(e)?Math.max(0,Math.floor(e)):0,16),ml),r=n*gl,i=n+(t()*2-1)*r;return Math.max(0,Math.min(ml,Math.round(i)))}var vl=`nightcrow.viewer`;function yl(){return globalThis.crypto?.randomUUID?.()||`tab-${Math.floor(Math.random()*2**48).toString(36)}`}function bl(){try{let e=sessionStorage.getItem(vl);if(e)return e;let t=yl();return sessionStorage.setItem(vl,t),t}catch{return yl()}}function xl(e,t){return t.state===`cancelled`?Sl(e,t.pane):{...e,[t.pane]:{state:t.state,detail:t.detail,deadlineEpoch:t.deadline_epoch,attempt:t.attempt}}}function Sl(e,t){if(!(t in e))return e;let n={...e};return delete n[t],n}function Cl(e,t){return Object.keys(e).map(Number).filter(e=>!t.includes(e)).sort((e,t)=>e-t)}function wl(e){if(e===void 0||!Number.isFinite(e))return;let t=new Date(e*1e3);if(!Number.isNaN(t.getTime()))return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function Tl(e){let t=wl(e.deadlineEpoch),n=[e.state];return t&&n.push(`until ${t}`),e.attempt>0&&n.push(`attempt ${e.attempt}`),n.join(` · `)}function El(e,t){if(typeof e==`string`){let n=Te(e);n&&Dl(n,t);return}if(!(e instanceof ArrayBuffer))return;let n=De(e);if(!n)return;let r;t.replayRef.current.active&&(r=t.replayRef.current.panes.get(n.pane),r||(r=Symbol(),t.replayRef.current.panes.set(n.pane,r)));let i=t.viewsRef.current.get(n.pane);if(i){r&&i.replayGate.begin(),ct(i.term,n.data);return}let a=t.pendingRef.current.get(n.pane)??[];a.push(n.data),t.pendingRef.current.set(n.pane,a)}function Dl(e,t){switch(e.type){case`hello`:t.clientIdRef.current=e.client,t.setLink(`live`),t.replayRef.current.active=!0,t.replayRef.current.panes.clear(),t.replayRef.current.order.length=0,t.replayRef.current.zoomed=!1,t.setReplayLeft(e.panes);return;case`replay_complete`:Ol(t);return;case`pending`:t.setPending(e.count);return;case`created`:{let n=e.pane;if(t.replayRef.current.active){t.replayRef.current.panes.set(n,Symbol());let e=t.replayRef.current.order;e.includes(n)||e.push(n)}t.ptySizesRef.current.set(n,{rows:e.rows,cols:e.cols});let r=t.viewsRef.current.get(n);r&&(r.term.rows!==e.rows||r.term.cols!==e.cols)&&r.term.resize(e.cols,e.rows);let i=e.title;i&&t.setTitles(e=>({...e,[n]:i})),t.setPanes(e=>e.includes(n)?e:[...e,n]),t.setReplayLeft(e=>e>0?e-1:0),e.client!=null&&e.client===t.clientIdRef.current?(t.setActive(n),se(t.repo,n)):k(t.repo)===n&&t.setActive(n);return}case`exited`:t.setPanes(t=>t.filter(t=>t!==e.pane)),t.setActive(t=>t===e.pane?null:t),t.pendingRef.current.delete(e.pane),t.replayRef.current.panes.delete(e.pane),t.ptySizesRef.current.delete(e.pane),t.askedSizesRef.current.delete(e.pane),t.desiredSizesRef.current.delete(e.pane),le(t.repo,e.pane),t.setTitles(t=>{if(!(e.pane in t))return t;let n={...t};return delete n[e.pane],n});return;case`resized`:t.ptySizesRef.current.set(e.pane,{rows:e.rows,cols:e.cols}),t.viewsRef.current.get(e.pane)?.term.resize(e.cols,e.rows);return;case`recovery`:t.setRecovery(t=>xl(t,e));return;case`size_owner`:Ye(t.ownsSizeRef,t.sizeOwnerGenerationRef,e.owned,e.generation,()=>{t.askedSizesRef.current.clear(),t.onSizeAcquired()}),t.setOwnsSize(e.owned);return;case`reordered`:t.setPanes(t=>ce(t,e.order));return;case`zoomed`:t.replayRef.current.zoomed=!0,t.zoomAskedRef.current=void 0,t.setZoomed(e.pane??null);return;case`error`:b.error(e.message);return;case`attention`:b.info(e.message??`A terminal wants your attention`);return}return e}function Ol(e){let t=e.replayRef.current;if(!t.active)return;t.active=!1,e.setReplayLeft(0);for(let[n,r]of t.panes){let i=e.viewsRef.current.get(n);if(i)dt(i.term,i.replayGate,()=>{e.viewsRef.current.get(n)===i&&t.panes.get(n)===r&&t.panes.delete(n)});else{let t=e.pendingRef.current.get(n)??[];t.push({kind:`replay_complete`,token:r}),e.pendingRef.current.set(n,t)}}let n=t.order.slice();e.setPanes(e=>e.length===n.length&&e.every((e,t)=>e===n[t])?e:n),t.zoomed||e.setZoomed(null),e.setActive(e=>e!==null&&n.includes(e)?e:null),e.setTitles(e=>{if(!Object.keys(e).some(e=>!n.includes(Number(e))))return e;let t={};for(let r of n){let n=e[r];n!==void 0&&(t[r]=n)}return t})}function kl({repo:e,socketRef:t,viewsRef:n,pendingRef:r,replayRef:i,ptySizesRef:a,askedSizesRef:o,desiredSizesRef:s,ownsSizeRef:c,sizeOwnerGenerationRef:l,onSizeAcquired:u,zoomAskedRef:d,setLink:f,setPending:p,setReplayLeft:m,setPanes:h,setActive:g,setZoomed:_,setTitles:v,setOwnsSize:y,setRecovery:b}){let x=(0,j.useRef)(null);(0,j.useLayoutEffect)(()=>{let S=!1,ee,C,w=0,T=!1,E=!1,te=e=>{e===`live`&&(T=!0),f(e)},D=()=>T?`reconnecting`:`connecting`,ne=()=>{C&&clearTimeout(C),C=void 0},re={repo:e,clientIdRef:x,viewsRef:n,pendingRef:r,replayRef:i,ptySizesRef:a,askedSizesRef:o,desiredSizesRef:s,ownsSizeRef:c,sizeOwnerGenerationRef:l,onSizeAcquired:u,zoomAskedRef:d,setLink:te,setPending:p,setReplayLeft:m,setPanes:h,setActive:g,setZoomed:_,setTitles:v,setOwnsSize:y,setRecovery:b},ie=()=>{n.current.forEach(e=>{ut(e.term),e.term.dispose()}),n.current.clear(),r.current.clear(),i.current.active=!1,i.current.panes.clear(),i.current.order.length=0,a.current.clear(),o.current.clear(),s.current.clear()},O=()=>{ne();let u=E;if(E=!0,x.current=null,c.current=!1,l.current=null,te(D()),m(0),d.current=void 0,p(null),b({}),u){for(let e of n.current.values()){let t=st(e.term);t.clear(),t.barrier(()=>e.term.reset())}r.current.clear(),i.current.active=!1,i.current.panes.clear(),i.current.order.length=0,a.current.clear(),o.current.clear(),s.current.clear()}else h([]),g(null),_(null),v({}),ie();let f=location.protocol===`https:`?`wss:`:`ws:`,y=new URLSearchParams({repo:e,viewer:bl()}),T=new WebSocket(`${f}//${location.host}/ws/term?${y}`);T.binaryType=`arraybuffer`,t.current=T,T.onopen=()=>{t.current===T&&(ne(),C=setTimeout(()=>{C=void 0,w=0},hl))},T.onmessage=e=>{t.current===T&&El(e.data,re)},T.onclose=()=>{if(S)return;ne(),te(D());let e=_l(w);w+=1,ee=setTimeout(O,e)}};return O(),()=>{S=!0,ee&&clearTimeout(ee),ne(),t.current?.close(),ie()}},[e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b])}var Al=`\x1B`,jl=`${Al}[200~`,Ml=`${Al}[201~`;function Nl(e,t){let n=e.split(Al).join(``).replace(/\r?\n/g,`\r`);return t?jl+n+Ml:n}function Pl(e){return e.trim().length>0}function Fl(e){return/mac|iphone|ipad|ipod/i.test(e)?`⌘↩`:`Ctrl+Enter`}var Il=[`image/png`,`image/jpeg`,`image/gif`,`image/webp`];function Ll(e){if(!e||e.getData(`text/plain`))return null;for(let t of Array.from(e.files))if(Il.includes(t.type))return t;return null}function Rl(e){return/[\s"']/.test(e)?`"${e.replace(/"/g,`\\"`)}" `:`${e} `}function zl(e){if(!(e instanceof Element))return null;let t=e.closest(`[data-pane-id]`)?.getAttribute(`data-pane-id`);return t==null?null:Number(t)}function Bl({containerRef:e,socketRef:t,viewsRef:n}){(0,j.useEffect)(()=>{let r=e.current;if(!r)return;let i=async(e,r)=>{try{let i=await _e.pasteImage(r),a=n.current.get(e)?.term.modes.bracketedPasteMode??!1;Ee(t.current,{type:`input`,pane:e,data:Nl(Rl(i),a)})||b.error(`Not connected — the image was not pasted.`)}catch(e){b.error(e instanceof Error?`Could not paste the image: ${e.message}`:`Could not paste the image.`)}},a=(e,t)=>{let n=Ll(t);if(!n)return;let r=zl(e.target);r!==null&&(e.preventDefault(),e.stopPropagation(),i(r,n))},o=e=>a(e,e.clipboardData),s=e=>a(e,e.dataTransfer),c=e=>{Ll(e.dataTransfer)&&e.preventDefault()};return r.addEventListener(`paste`,o,!0),r.addEventListener(`drop`,s,!0),r.addEventListener(`dragover`,c,!0),()=>{r.removeEventListener(`paste`,o,!0),r.removeEventListener(`drop`,s,!0),r.removeEventListener(`dragover`,c,!0)}},[e,t,n])}var Vl=Object.defineProperty,Hl=Object.getOwnPropertyDescriptor,Ul=(e,t,n,r)=>{for(var i=r>1?void 0:r?Hl(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&Vl(t,n,i),i},Wl=(e,t)=>(n,r)=>t(n,r,e),Gl=new class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Xl.isErrorNoTelemetry(e)?new Xl(e.message+` + +`+e.stack):Error(e.message+` + +`+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}};function Kl(e){Jl(e)||Gl.onUnexpectedError(e)}var ql=`Canceled`;function Jl(e){return e instanceof Yl||e instanceof Error&&e.name===ql&&e.message===ql}var Yl=class extends Error{constructor(){super(ql),this.name=this.message}},Xl=class e extends Error{constructor(e){super(e),this.name=`CodeExpectedError`}static fromError(t){if(t instanceof e)return t;let n=new e;return n.message=t.message,n.stack=t.stack,n}static isErrorNoTelemetry(e){return e.name===`CodeExpectedError`}},Zl;(e=>{function t(e){return e<0}e.isLessThan=t;function n(e){return e<=0}e.isLessThanOrEqual=n;function r(e){return e>0}e.isGreaterThan=r;function i(e){return e===0}e.isNeitherLessOrGreaterThan=i,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Zl||={});var Ql=class e{constructor(e){this.iterate=e}forEach(e){this.iterate(t=>(e(t),!0))}toArray(){let e=[];return this.iterate(t=>(e.push(t),!0)),e}filter(t){return new e(e=>this.iterate(n=>!t(n)||e(n)))}map(t){return new e(e=>this.iterate(n=>e(t(n))))}some(e){let t=!1;return this.iterate(n=>(t=e(n),!t)),t}findFirst(e){let t;return this.iterate(n=>!e(n)||(t=n,!1)),t}findLast(e){let t;return this.iterate(n=>(e(n)&&(t=n),!0)),t}findLastMaxBy(e){let t,n=!0;return this.iterate(r=>((n||Zl.isGreaterThan(e(r,t)))&&(n=!1,t=r),!0)),t}};Ql.empty=new Ql(e=>{});function $l(e,t){let n=this,r=!1,i;return function(){if(r)return i;if(r=!0,t)try{i=e.apply(n,arguments)}finally{t()}else i=e.apply(n,arguments);return i}}var eu;(e=>{function t(e){return e&&typeof e==`object`&&typeof e[Symbol.iterator]==`function`}e.is=t;let n=Object.freeze([]);function r(){return n}e.empty=r;function*i(e){yield e}e.single=i;function a(e){return t(e)?e:i(e)}e.wrap=a;function o(e){return e||n}e.from=o;function*s(e){for(let t=e.length-1;t>=0;t--)yield e[t]}e.reverse=s;function c(e){return!e||e[Symbol.iterator]().next().done===!0}e.isEmpty=c;function l(e){return e[Symbol.iterator]().next().value}e.first=l;function u(e,t){let n=0;for(let r of e)if(t(r,n++))return!0;return!1}e.some=u;function d(e,t){for(let n of e)if(t(n))return n}e.find=d;function*f(e,t){for(let n of e)t(n)&&(yield n)}e.filter=f;function*p(e,t){let n=0;for(let r of e)yield t(r,n++)}e.map=p;function*m(e,t){let n=0;for(let r of e)yield*t(r,n++)}e.flatMap=m;function*h(...e){for(let t of e)yield*t}e.concat=h;function g(e,t,n){let r=n;for(let n of e)r=t(r,n);return r}e.reduce=g;function*_(e,t,n=e.length){for(t<0&&(t+=e.length),n<0?n+=e.length:n>e.length&&(n=e.length);t1)throw AggregateError(t,`Encountered errors while disposing of store`);return Array.isArray(e)?[]:e}if(e)return e.dispose(),e}function ou(...e){return su(()=>au(e))}function su(e){let t=nu({dispose:$l(()=>{ru(t),e()})});return t}var cu=class e{constructor(){this._toDispose=new Set,this._isDisposed=!1,nu(this)}dispose(){this._isDisposed||(ru(this),this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{au(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw Error(`Cannot register a disposable on itself!`);return iu(t,this),this._isDisposed?e.DISABLE_DISPOSED_WARNING||console.warn(Error(`Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!`).stack):this._toDispose.add(t),t}delete(e){if(e){if(e===this)throw Error(`Cannot dispose a disposable on itself!`);this._toDispose.delete(e),e.dispose()}}deleteAndLeak(e){e&&this._toDispose.has(e)&&(this._toDispose.delete(e),iu(e,null))}};cu.DISABLE_DISPOSED_WARNING=!1;var lu=cu,uu=class{constructor(){this._store=new lu,nu(this),iu(this._store,this)}dispose(){ru(this),this._store.dispose()}_register(e){if(e===this)throw Error(`Cannot register a disposable on itself!`);return this._store.add(e)}};uu.None=Object.freeze({dispose(){}});var du=class{constructor(){this._isDisposed=!1,nu(this)}get value(){return this._isDisposed?void 0:this._value}set value(e){this._isDisposed||e===this._value||(this._value?.dispose(),e&&iu(e,this),this._value=e)}clear(){this.value=void 0}dispose(){this._isDisposed=!0,ru(this),this._value?.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e&&iu(e,null),e}},fu=typeof process<`u`&&`title`in process,pu=fu?`node`:navigator.userAgent,mu=fu?`node`:navigator.platform,hu=pu.includes(`Firefox`),gu=pu.includes(`Edge`),_u=/^((?!chrome|android).)*safari/i.test(pu);function vu(){if(!_u)return 0;let e=pu.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}[`Macintosh`,`MacIntel`,`MacPPC`,`Mac68K`].includes(mu),[`Windows`,`Win16`,`Win32`,`WinCE`].includes(mu),mu.indexOf(`Linux`),/\bCrOS\b/.test(pu);var yu=``,bu=0,xu=0,Su=0,J=0,Cu={css:`#00000000`,rgba:0},wu;(e=>{function t(e,t,n,r){return r===void 0?`#${ku(e)}${ku(t)}${ku(n)}`:`#${ku(e)}${ku(t)}${ku(n)}${ku(r)}`}e.toCss=t;function n(e,t,n,r=255){return(e<<24|t<<16|n<<8|r)>>>0}e.toRgba=n;function r(t,n,r,i){return{css:e.toCss(t,n,r,i),rgba:e.toRgba(t,n,r,i)}}e.toColor=r})(wu||={});var Tu;(e=>{function t(e,t){if(J=(t.rgba&255)/255,J===1)return{css:t.css,rgba:t.rgba};let n=t.rgba>>24&255,r=t.rgba>>16&255,i=t.rgba>>8&255,a=e.rgba>>24&255,o=e.rgba>>16&255,s=e.rgba>>8&255;return bu=a+Math.round((n-a)*J),xu=o+Math.round((r-o)*J),Su=s+Math.round((i-s)*J),{css:wu.toCss(bu,xu,Su),rgba:wu.toRgba(bu,xu,Su)}}e.blend=t;function n(e){return(e.rgba&255)==255}e.isOpaque=n;function r(e,t,n){let r=Ou.ensureContrastRatio(e.rgba,t.rgba,n);if(r)return wu.toColor(r>>24&255,r>>16&255,r>>8&255)}e.ensureContrastRatio=r;function i(e){let t=(e.rgba|255)>>>0;return[bu,xu,Su]=Ou.toChannels(t),{css:wu.toCss(bu,xu,Su),rgba:t}}e.opaque=i;function a(e,t){return J=Math.round(t*255),[bu,xu,Su]=Ou.toChannels(e.rgba),{css:wu.toCss(bu,xu,Su,J),rgba:wu.toRgba(bu,xu,Su,J)}}e.opacity=a;function o(e,t){return J=e.rgba&255,a(e,J*t/255)}e.multiplyOpacity=o;function s(e){return[e.rgba>>24&255,e.rgba>>16&255,e.rgba>>8&255]}e.toColorRGB=s})(Tu||={});var Eu;(e=>{let t,n;try{let e=document.createElement(`canvas`);e.width=1,e.height=1;let r=e.getContext(`2d`,{willReadFrequently:!0});r&&(t=r,t.globalCompositeOperation=`copy`,n=t.createLinearGradient(0,0,1,1))}catch{}function r(e){if(e.match(/#[\da-f]{3,8}/i))switch(e.length){case 4:return bu=parseInt(e.slice(1,2).repeat(2),16),xu=parseInt(e.slice(2,3).repeat(2),16),Su=parseInt(e.slice(3,4).repeat(2),16),wu.toColor(bu,xu,Su);case 5:return bu=parseInt(e.slice(1,2).repeat(2),16),xu=parseInt(e.slice(2,3).repeat(2),16),Su=parseInt(e.slice(3,4).repeat(2),16),J=parseInt(e.slice(4,5).repeat(2),16),wu.toColor(bu,xu,Su,J);case 7:return{css:e,rgba:(parseInt(e.slice(1),16)<<8|255)>>>0};case 9:return{css:e,rgba:parseInt(e.slice(1),16)>>>0}}let r=e.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(r)return bu=parseInt(r[1]),xu=parseInt(r[2]),Su=parseInt(r[3]),J=Math.round((r[5]===void 0?1:parseFloat(r[5]))*255),wu.toColor(bu,xu,Su,J);if(!t||!n||(t.fillStyle=n,t.fillStyle=e,typeof t.fillStyle!=`string`)||(t.fillRect(0,0,1,1),[bu,xu,Su,J]=t.getImageData(0,0,1,1).data,J!==255))throw Error(`css.toColor: Unsupported css format`);return{rgba:wu.toRgba(bu,xu,Su,J),css:e}}e.toColor=r})(Eu||={});var Du;(e=>{function t(e){return n(e>>16&255,e>>8&255,e&255)}e.relativeLuminance=t;function n(e,t,n){let r=e/255,i=t/255,a=n/255,o=r<=.03928?r/12.92:((r+.055)/1.055)**2.4,s=i<=.03928?i/12.92:((i+.055)/1.055)**2.4,c=a<=.03928?a/12.92:((a+.055)/1.055)**2.4;return o*.2126+s*.7152+c*.0722}e.relativeLuminance2=n})(Du||={});var Ou;(e=>{function t(e,t){if(J=(t&255)/255,J===1)return t;let n=t>>24&255,r=t>>16&255,i=t>>8&255,a=e>>24&255,o=e>>16&255,s=e>>8&255;return bu=a+Math.round((n-a)*J),xu=o+Math.round((r-o)*J),Su=s+Math.round((i-s)*J),wu.toRgba(bu,xu,Su)}e.blend=t;function n(e,t,n){let a=Du.relativeLuminance(e>>8),o=Du.relativeLuminance(t>>8);if(Au(a,o)>8));if(sAu(a,Du.relativeLuminance(r>>8))?o:r}return o}let s=i(e,t,n),c=Au(a,Du.relativeLuminance(s>>8));if(cAu(a,Du.relativeLuminance(i>>8))?s:i}return s}}e.ensureContrastRatio=n;function r(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Au(Du.relativeLuminance2(o,s,c),Du.relativeLuminance2(r,i,a));for(;l0||s>0||c>0);)o-=Math.max(0,Math.ceil(o*.1)),s-=Math.max(0,Math.ceil(s*.1)),c-=Math.max(0,Math.ceil(c*.1)),l=Au(Du.relativeLuminance2(o,s,c),Du.relativeLuminance2(r,i,a));return(o<<24|s<<16|c<<8|255)>>>0}e.reduceLuminance=r;function i(e,t,n){let r=e>>24&255,i=e>>16&255,a=e>>8&255,o=t>>24&255,s=t>>16&255,c=t>>8&255,l=Au(Du.relativeLuminance2(o,s,c),Du.relativeLuminance2(r,i,a));for(;l>>0}e.increaseLuminance=i;function a(e){return[e>>24&255,e>>16&255,e>>8&255,e&255]}e.toChannels=a})(Ou||={});function ku(e){let t=e.toString(16);return t.length<2?`0`+t:t}function Au(e,t){return e=128512&&e<=128591||e>=127744&&e<=128511||e>=128640&&e<=128767||e>=9728&&e<=9983||e>=9984&&e<=10175||e>=65024&&e<=65039||e>=129280&&e<=129535||e>=127462&&e<=127487}function Iu(e,t,n,r){return t===1&&n>Math.ceil(r*1.5)&&e!==void 0&&e>255&&!Fu(e)&&!ju(e)&&!Nu(e)}function Lu(e){return ju(e)||Pu(e)}function Ru(){return{css:{canvas:zu(),cell:zu()},device:{canvas:zu(),cell:zu(),char:{width:0,height:0,left:0,top:0}}}}function zu(){return{width:0,height:0}}function Bu(e,t,n=0){return(e-(Math.round(t)*2-n))%(Math.round(t)*2)}var Vu=0,Hu=0,Uu=!1,Wu=!1,Gu=!1,Ku,qu=0,Ju=class{constructor(e,t,n,r,i,a){this._terminal=e,this._optionService=t,this._selectionRenderModel=n,this._decorationService=r,this._coreBrowserService=i,this._themeService=a,this.result={fg:0,bg:0,ext:0}}resolve(e,t,n,r){if(this.result.bg=e.bg,this.result.fg=e.fg,this.result.ext=e.bg&268435456?e.extended.ext:0,Hu=0,Vu=0,Wu=!1,Uu=!1,Gu=!1,Ku=this._themeService.colors,qu=0,e.getCode()!==0&&e.extended.underlineStyle===4){let e=Math.max(1,Math.floor(this._optionService.rawOptions.fontSize*this._coreBrowserService.dpr/15));qu=t*r%(Math.round(e)*2)}if(this._decorationService.forEachDecorationAtCell(t,n,`bottom`,e=>{e.backgroundColorRGB&&(Hu=e.backgroundColorRGB.rgba>>8&16777215,Wu=!0),e.foregroundColorRGB&&(Vu=e.foregroundColorRGB.rgba>>8&16777215,Uu=!0)}),Gu=this._selectionRenderModel.isCellSelected(this._terminal,t,n),Gu){if(this.result.fg&67108864||this.result.bg&50331648){if(this.result.fg&67108864)switch(this.result.fg&50331648){case 16777216:case 33554432:Hu=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:Hu=(this.result.fg&16777215)<<8|255;break;default:Hu=this._themeService.colors.foreground.rgba}else switch(this.result.bg&50331648){case 16777216:case 33554432:Hu=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:Hu=(this.result.bg&16777215)<<8|255}Hu=Ou.blend(Hu,(this._coreBrowserService.isFocused?Ku.selectionBackgroundOpaque:Ku.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}else Hu=(this._coreBrowserService.isFocused?Ku.selectionBackgroundOpaque:Ku.selectionInactiveBackgroundOpaque).rgba>>8&16777215;if(Wu=!0,Ku.selectionForeground&&(Vu=Ku.selectionForeground.rgba>>8&16777215,Uu=!0),Lu(e.getCode())){if(this.result.fg&67108864&&!(this.result.bg&50331648))Vu=(this._coreBrowserService.isFocused?Ku.selectionBackgroundOpaque:Ku.selectionInactiveBackgroundOpaque).rgba>>8&16777215;else{if(this.result.fg&67108864)switch(this.result.bg&50331648){case 16777216:case 33554432:Vu=this._themeService.colors.ansi[this.result.bg&255].rgba;break;case 50331648:Vu=(this.result.bg&16777215)<<8|255}else switch(this.result.fg&50331648){case 16777216:case 33554432:Vu=this._themeService.colors.ansi[this.result.fg&255].rgba;break;case 50331648:Vu=(this.result.fg&16777215)<<8|255;break;default:Vu=this._themeService.colors.foreground.rgba}Vu=Ou.blend(Vu,(this._coreBrowserService.isFocused?Ku.selectionBackgroundOpaque:Ku.selectionInactiveBackgroundOpaque).rgba&4294967040|128)>>8&16777215}Uu=!0}}this._decorationService.forEachDecorationAtCell(t,n,`top`,e=>{e.backgroundColorRGB&&(Hu=e.backgroundColorRGB.rgba>>8&16777215,Wu=!0),e.foregroundColorRGB&&(Vu=e.foregroundColorRGB.rgba>>8&16777215,Uu=!0)}),Wu&&(Hu=Gu?e.bg&-150994944|Hu|50331648:e.bg&-16777216|Hu|50331648),Uu&&(Vu=e.fg&-83886080|Vu|50331648),this.result.fg&67108864&&(Wu&&!Uu&&(Vu=this.result.bg&50331648?this.result.fg&-134217728|this.result.bg&67108863:this.result.fg&-134217728|Ku.background.rgba>>8&16777215|50331648,Uu=!0),!Wu&&Uu&&(Hu=this.result.fg&50331648?this.result.bg&-67108864|this.result.fg&67108863:this.result.bg&-67108864|Ku.foreground.rgba>>8&16777215|50331648,Wu=!0)),Ku=void 0,this.result.bg=Wu?Hu:this.result.bg,this.result.fg=Uu?Vu:this.result.fg,this.result.ext&=536870911,this.result.ext|=qu<<29&3758096384}},Yu=.5,Xu=hu||gu?`bottom`:`ideographic`,Zu={"▀":[{x:0,y:0,w:8,h:4}],"▁":[{x:0,y:7,w:8,h:1}],"▂":[{x:0,y:6,w:8,h:2}],"▃":[{x:0,y:5,w:8,h:3}],"▄":[{x:0,y:4,w:8,h:4}],"▅":[{x:0,y:3,w:8,h:5}],"▆":[{x:0,y:2,w:8,h:6}],"▇":[{x:0,y:1,w:8,h:7}],"█":[{x:0,y:0,w:8,h:8}],"▉":[{x:0,y:0,w:7,h:8}],"▊":[{x:0,y:0,w:6,h:8}],"▋":[{x:0,y:0,w:5,h:8}],"▌":[{x:0,y:0,w:4,h:8}],"▍":[{x:0,y:0,w:3,h:8}],"▎":[{x:0,y:0,w:2,h:8}],"▏":[{x:0,y:0,w:1,h:8}],"▐":[{x:4,y:0,w:4,h:8}],"▔":[{x:0,y:0,w:8,h:1}],"▕":[{x:7,y:0,w:1,h:8}],"▖":[{x:0,y:4,w:4,h:4}],"▗":[{x:4,y:4,w:4,h:4}],"▘":[{x:0,y:0,w:4,h:4}],"▙":[{x:0,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"▚":[{x:0,y:0,w:4,h:4},{x:4,y:4,w:4,h:4}],"▛":[{x:0,y:0,w:4,h:8},{x:4,y:0,w:4,h:4}],"▜":[{x:0,y:0,w:8,h:4},{x:4,y:0,w:4,h:8}],"▝":[{x:4,y:0,w:4,h:4}],"▞":[{x:4,y:0,w:4,h:4},{x:0,y:4,w:4,h:4}],"▟":[{x:4,y:0,w:4,h:8},{x:0,y:4,w:8,h:4}],"🭰":[{x:1,y:0,w:1,h:8}],"🭱":[{x:2,y:0,w:1,h:8}],"🭲":[{x:3,y:0,w:1,h:8}],"🭳":[{x:4,y:0,w:1,h:8}],"🭴":[{x:5,y:0,w:1,h:8}],"🭵":[{x:6,y:0,w:1,h:8}],"🭶":[{x:0,y:1,w:8,h:1}],"🭷":[{x:0,y:2,w:8,h:1}],"🭸":[{x:0,y:3,w:8,h:1}],"🭹":[{x:0,y:4,w:8,h:1}],"🭺":[{x:0,y:5,w:8,h:1}],"🭻":[{x:0,y:6,w:8,h:1}],"🭼":[{x:0,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🭽":[{x:0,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭾":[{x:7,y:0,w:1,h:8},{x:0,y:0,w:8,h:1}],"🭿":[{x:7,y:0,w:1,h:8},{x:0,y:7,w:8,h:1}],"🮀":[{x:0,y:0,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮁":[{x:0,y:0,w:8,h:1},{x:0,y:2,w:8,h:1},{x:0,y:4,w:8,h:1},{x:0,y:7,w:8,h:1}],"🮂":[{x:0,y:0,w:8,h:2}],"🮃":[{x:0,y:0,w:8,h:3}],"🮄":[{x:0,y:0,w:8,h:5}],"🮅":[{x:0,y:0,w:8,h:6}],"🮆":[{x:0,y:0,w:8,h:7}],"🮇":[{x:6,y:0,w:2,h:8}],"🮈":[{x:5,y:0,w:3,h:8}],"🮉":[{x:3,y:0,w:5,h:8}],"🮊":[{x:2,y:0,w:6,h:8}],"🮋":[{x:1,y:0,w:7,h:8}],"🮕":[{x:0,y:0,w:2,h:2},{x:4,y:0,w:2,h:2},{x:2,y:2,w:2,h:2},{x:6,y:2,w:2,h:2},{x:0,y:4,w:2,h:2},{x:4,y:4,w:2,h:2},{x:2,y:6,w:2,h:2},{x:6,y:6,w:2,h:2}],"🮖":[{x:2,y:0,w:2,h:2},{x:6,y:0,w:2,h:2},{x:0,y:2,w:2,h:2},{x:4,y:2,w:2,h:2},{x:2,y:4,w:2,h:2},{x:6,y:4,w:2,h:2},{x:0,y:6,w:2,h:2},{x:4,y:6,w:2,h:2}],"🮗":[{x:0,y:2,w:8,h:2},{x:0,y:6,w:8,h:2}]},Qu={"░":[[1,0,0,0],[0,0,0,0],[0,0,1,0],[0,0,0,0]],"▒":[[1,0],[0,0],[0,1],[0,0]],"▓":[[0,1],[1,1],[1,0],[1,1]]},$u={"─":{1:`M0,.5 L1,.5`},"━":{3:`M0,.5 L1,.5`},"│":{1:`M.5,0 L.5,1`},"┃":{3:`M.5,0 L.5,1`},"┌":{1:`M0.5,1 L.5,.5 L1,.5`},"┏":{3:`M0.5,1 L.5,.5 L1,.5`},"┐":{1:`M0,.5 L.5,.5 L.5,1`},"┓":{3:`M0,.5 L.5,.5 L.5,1`},"└":{1:`M.5,0 L.5,.5 L1,.5`},"┗":{3:`M.5,0 L.5,.5 L1,.5`},"┘":{1:`M.5,0 L.5,.5 L0,.5`},"┛":{3:`M.5,0 L.5,.5 L0,.5`},"├":{1:`M.5,0 L.5,1 M.5,.5 L1,.5`},"┣":{3:`M.5,0 L.5,1 M.5,.5 L1,.5`},"┤":{1:`M.5,0 L.5,1 M.5,.5 L0,.5`},"┫":{3:`M.5,0 L.5,1 M.5,.5 L0,.5`},"┬":{1:`M0,.5 L1,.5 M.5,.5 L.5,1`},"┳":{3:`M0,.5 L1,.5 M.5,.5 L.5,1`},"┴":{1:`M0,.5 L1,.5 M.5,.5 L.5,0`},"┻":{3:`M0,.5 L1,.5 M.5,.5 L.5,0`},"┼":{1:`M0,.5 L1,.5 M.5,0 L.5,1`},"╋":{3:`M0,.5 L1,.5 M.5,0 L.5,1`},"╴":{1:`M.5,.5 L0,.5`},"╸":{3:`M.5,.5 L0,.5`},"╵":{1:`M.5,.5 L.5,0`},"╹":{3:`M.5,.5 L.5,0`},"╶":{1:`M.5,.5 L1,.5`},"╺":{3:`M.5,.5 L1,.5`},"╷":{1:`M.5,.5 L.5,1`},"╻":{3:`M.5,.5 L.5,1`},"═":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"║":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╒":{1:(e,t)=>`M.5,1 L.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╓":{1:(e,t)=>`M${.5-e},1 L${.5-e},.5 L1,.5 M${.5+e},.5 L${.5+e},1`},"╔":{1:(e,t)=>`M1,${.5-t} L${.5-e},${.5-t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╕":{1:(e,t)=>`M0,${.5-t} L.5,${.5-t} L.5,1 M0,${.5+t} L.5,${.5+t}`},"╖":{1:(e,t)=>`M${.5+e},1 L${.5+e},.5 L0,.5 M${.5-e},.5 L${.5-e},1`},"╗":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5+e},${.5-t} L${.5+e},1`},"╘":{1:(e,t)=>`M.5,0 L.5,${.5+t} L1,${.5+t} M.5,${.5-t} L1,${.5-t}`},"╙":{1:(e,t)=>`M1,.5 L${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╚":{1:(e,t)=>`M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0 M1,${.5+t} L${.5-e},${.5+t} L${.5-e},0`},"╛":{1:(e,t)=>`M0,${.5+t} L.5,${.5+t} L.5,0 M0,${.5-t} L.5,${.5-t}`},"╜":{1:(e,t)=>`M0,.5 L${.5+e},.5 L${.5+e},0 M${.5-e},.5 L${.5-e},0`},"╝":{1:(e,t)=>`M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M0,${.5+t} L${.5+e},${.5+t} L${.5+e},0`},"╞":{1:(e,t)=>`M.5,0 L.5,1 M.5,${.5-t} L1,${.5-t} M.5,${.5+t} L1,${.5+t}`},"╟":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1 M${.5+e},.5 L1,.5`},"╠":{1:(e,t)=>`M${.5-e},0 L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╡":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L.5,${.5-t} M0,${.5+t} L.5,${.5+t}`},"╢":{1:(e,t)=>`M0,.5 L${.5-e},.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╣":{1:(e,t)=>`M${.5+e},0 L${.5+e},1 M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0`},"╤":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t} M.5,${.5+t} L.5,1`},"╥":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},1 M${.5+e},.5 L${.5+e},1`},"╦":{1:(e,t)=>`M0,${.5-t} L1,${.5-t} M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1`},"╧":{1:(e,t)=>`M.5,0 L.5,${.5-t} M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╨":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},.5 L${.5-e},0 M${.5+e},.5 L${.5+e},0`},"╩":{1:(e,t)=>`M0,${.5+t} L1,${.5+t} M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╪":{1:(e,t)=>`M.5,0 L.5,1 M0,${.5-t} L1,${.5-t} M0,${.5+t} L1,${.5+t}`},"╫":{1:(e,t)=>`M0,.5 L1,.5 M${.5-e},0 L${.5-e},1 M${.5+e},0 L${.5+e},1`},"╬":{1:(e,t)=>`M0,${.5+t} L${.5-e},${.5+t} L${.5-e},1 M1,${.5+t} L${.5+e},${.5+t} L${.5+e},1 M0,${.5-t} L${.5-e},${.5-t} L${.5-e},0 M1,${.5-t} L${.5+e},${.5-t} L${.5+e},0`},"╱":{1:`M1,0 L0,1`},"╲":{1:`M0,0 L1,1`},"╳":{1:`M1,0 L0,1 M0,0 L1,1`},"╼":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"╽":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L.5,1`},"╾":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"╿":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"┍":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L1,.5`},"┎":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┑":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L0,.5`},"┒":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L.5,1`},"┕":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L1,.5`},"┖":{1:`M.5,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┙":{1:`M.5,.5 L.5,0`,3:`M.5,.5 L0,.5`},"┚":{1:`M.5,.5 L0,.5`,3:`M.5,.5 L.5,0`},"┝":{1:`M.5,0 L.5,1`,3:`M.5,.5 L1,.5`},"┞":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┟":{1:`M.5,0 L.5,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┠":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,1`},"┡":{1:`M.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L1,.5`},"┢":{1:`M.5,.5 L.5,0`,3:`M0.5,1 L.5,.5 L1,.5`},"┥":{1:`M.5,0 L.5,1`,3:`M.5,.5 L0,.5`},"┦":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"┧":{1:`M.5,0 L.5,.5 L0,.5`,3:`M.5,.5 L.5,1`},"┨":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,1`},"┩":{1:`M.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L0,.5`},"┪":{1:`M.5,.5 L.5,0`,3:`M0,.5 L.5,.5 L.5,1`},"┭":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┮":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,.5 L1,.5`},"┯":{1:`M.5,.5 L.5,1`,3:`M0,.5 L1,.5`},"┰":{1:`M0,.5 L1,.5`,3:`M.5,.5 L.5,1`},"┱":{1:`M.5,.5 L1,.5`,3:`M0,.5 L.5,.5 L.5,1`},"┲":{1:`M.5,.5 L0,.5`,3:`M0.5,1 L.5,.5 L1,.5`},"┵":{1:`M.5,0 L.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┶":{1:`M.5,0 L.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"┷":{1:`M.5,.5 L.5,0`,3:`M0,.5 L1,.5`},"┸":{1:`M0,.5 L1,.5`,3:`M.5,.5 L.5,0`},"┹":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,.5 L0,.5`},"┺":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,.5 L1,.5`},"┽":{1:`M.5,0 L.5,1 M.5,.5 L1,.5`,3:`M.5,.5 L0,.5`},"┾":{1:`M.5,0 L.5,1 M.5,.5 L0,.5`,3:`M.5,.5 L1,.5`},"┿":{1:`M.5,0 L.5,1`,3:`M0,.5 L1,.5`},"╀":{1:`M0,.5 L1,.5 M.5,.5 L.5,1`,3:`M.5,.5 L.5,0`},"╁":{1:`M.5,.5 L.5,0 M0,.5 L1,.5`,3:`M.5,.5 L.5,1`},"╂":{1:`M0,.5 L1,.5`,3:`M.5,0 L.5,1`},"╃":{1:`M0.5,1 L.5,.5 L1,.5`,3:`M.5,0 L.5,.5 L0,.5`},"╄":{1:`M0,.5 L.5,.5 L.5,1`,3:`M.5,0 L.5,.5 L1,.5`},"╅":{1:`M.5,0 L.5,.5 L1,.5`,3:`M0,.5 L.5,.5 L.5,1`},"╆":{1:`M.5,0 L.5,.5 L0,.5`,3:`M0.5,1 L.5,.5 L1,.5`},"╇":{1:`M.5,.5 L.5,1`,3:`M.5,.5 L.5,0 M0,.5 L1,.5`},"╈":{1:`M.5,.5 L.5,0`,3:`M0,.5 L1,.5 M.5,.5 L.5,1`},"╉":{1:`M.5,.5 L1,.5`,3:`M.5,0 L.5,1 M.5,.5 L0,.5`},"╊":{1:`M.5,.5 L0,.5`,3:`M.5,0 L.5,1 M.5,.5 L1,.5`},"╌":{1:`M.1,.5 L.4,.5 M.6,.5 L.9,.5`},"╍":{3:`M.1,.5 L.4,.5 M.6,.5 L.9,.5`},"┄":{1:`M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5`},"┅":{3:`M.0667,.5 L.2667,.5 M.4,.5 L.6,.5 M.7333,.5 L.9333,.5`},"┈":{1:`M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5`},"┉":{3:`M.05,.5 L.2,.5 M.3,.5 L.45,.5 M.55,.5 L.7,.5 M.8,.5 L.95,.5`},"╎":{1:`M.5,.1 L.5,.4 M.5,.6 L.5,.9`},"╏":{3:`M.5,.1 L.5,.4 M.5,.6 L.5,.9`},"┆":{1:`M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333`},"┇":{3:`M.5,.0667 L.5,.2667 M.5,.4 L.5,.6 M.5,.7333 L.5,.9333`},"┊":{1:`M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95`},"┋":{3:`M.5,.05 L.5,.2 M.5,.3 L.5,.45 L.5,.55 M.5,.7 L.5,.95`},"╭":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,1,.5`},"╮":{1:(e,t)=>`M.5,1 L.5,${.5+t/.15*.5} C.5,${.5+t/.15*.5},.5,.5,0,.5`},"╯":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,0,.5`},"╰":{1:(e,t)=>`M.5,0 L.5,${.5-t/.15*.5} C.5,${.5-t/.15*.5},.5,.5,1,.5`}},ed={"":{d:`M.3,1 L.03,1 L.03,.88 C.03,.82,.06,.78,.11,.73 C.15,.7,.2,.68,.28,.65 L.43,.6 C.49,.58,.53,.56,.56,.53 C.59,.5,.6,.47,.6,.43 L.6,.27 L.4,.27 L.69,.1 L.98,.27 L.78,.27 L.78,.46 C.78,.52,.76,.56,.72,.61 C.68,.66,.63,.67,.56,.7 L.48,.72 C.42,.74,.38,.76,.35,.78 C.32,.8,.31,.84,.31,.88 L.31,1 M.3,.5 L.03,.59 L.03,.09 L.3,.09 L.3,.655`,type:0},"":{d:`M.7,.4 L.7,.47 L.2,.47 L.2,.03 L.355,.03 L.355,.4 L.705,.4 M.7,.5 L.86,.5 L.86,.95 L.69,.95 L.44,.66 L.46,.86 L.46,.95 L.3,.95 L.3,.49 L.46,.49 L.71,.78 L.69,.565 L.69,.5`,type:0},"":{d:`M.25,.94 C.16,.94,.11,.92,.11,.87 L.11,.53 C.11,.48,.15,.455,.23,.45 L.23,.3 C.23,.25,.26,.22,.31,.19 C.36,.16,.43,.15,.51,.15 C.59,.15,.66,.16,.71,.19 C.77,.22,.79,.26,.79,.3 L.79,.45 C.87,.45,.91,.48,.91,.53 L.91,.87 C.91,.92,.86,.94,.77,.94 L.24,.94 M.53,.2 C.49,.2,.45,.21,.42,.23 C.39,.25,.38,.27,.38,.3 L.38,.45 L.68,.45 L.68,.3 C.68,.27,.67,.25,.64,.23 C.61,.21,.58,.2,.53,.2 M.58,.82 L.58,.66 C.63,.65,.65,.63,.65,.6 C.65,.58,.64,.57,.61,.56 C.58,.55,.56,.54,.52,.54 C.48,.54,.46,.55,.43,.56 C.4,.57,.39,.59,.39,.6 C.39,.63,.41,.64,.46,.66 L.46,.82 L.57,.82`,type:0},"":{d:`M0,0 L1,.5 L0,1`,type:0,rightPadding:2},"":{d:`M-1,-.5 L1,.5 L-1,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M1,0 L0,.5 L1,1`,type:0,leftPadding:2},"":{d:`M2,-.5 L0,.5 L2,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M0,0 L0,1 C0.552,1,1,0.776,1,.5 C1,0.224,0.552,0,0,0`,type:0,rightPadding:1},"":{d:`M.2,1 C.422,1,.8,.826,.78,.5 C.8,.174,0.422,0,.2,0`,type:1,rightPadding:1},"":{d:`M1,0 L1,1 C0.448,1,0,0.776,0,.5 C0,0.224,0.448,0,1,0`,type:0,leftPadding:1},"":{d:`M.8,1 C0.578,1,0.2,.826,.22,.5 C0.2,0.174,0.578,0,0.8,0`,type:1,leftPadding:1},"":{d:`M-.5,-.5 L1.5,1.5 L-.5,1.5`,type:0},"":{d:`M-.5,-.5 L1.5,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M1.5,-.5 L-.5,1.5 L1.5,1.5`,type:0},"":{d:`M1.5,-.5 L-.5,1.5 L-.5,-.5`,type:0},"":{d:`M1.5,-.5 L-.5,1.5`,type:1,leftPadding:1,rightPadding:1},"":{d:`M-.5,-.5 L1.5,1.5 L1.5,-.5`,type:0}};ed[``]=ed[``],ed[``]=ed[``];function td(e,t,n,r,i,a,o,s){let c=Zu[t];if(c)return nd(e,c,n,r,i,a),!0;let l=Qu[t];if(l)return id(e,l,n,r,i,a),!0;let u=$u[t];if(u)return ad(e,u,n,r,i,a,s),!0;let d=ed[t];return d?(od(e,d,n,r,i,a,o,s),!0):!1}function nd(e,t,n,r,i,a){for(let o=0;o7&&parseInt(s.slice(7,9),16)||1;else if(s.startsWith(`rgba`))[u,d,f,p]=s.substring(5,s.length-1).split(`,`).map(e=>parseFloat(e));else throw Error(`Unexpected fillStyle color format "${s}" when drawing pattern glyph`);for(let e=0;ee.bezierCurveTo(t[0],t[1],t[2],t[3],t[4],t[5]),L:(e,t)=>e.lineTo(t[0],t[1]),M:(e,t)=>e.moveTo(t[0],t[1])};function ld(e,t,n,r,i,a,o,s=0,c=0){let l=e.map(e=>parseFloat(e)||parseInt(e));if(l.length<2)throw Error(`Too few arguments for instruction`);for(let e=0;ei){r-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-t))}ms`),this._start();return}r=i}this.clear()}},pd=class extends fd{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},md=class extends fd{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},hd=!fu&&`requestIdleCallback`in window?md:pd,gd=class e{constructor(){this.fg=0,this.bg=0,this.extended=new _d}static toColorRGB(e){return[e>>>16&255,e>>>8&255,e&255]}static fromColorRGB(e){return(e[0]&255)<<16|(e[1]&255)<<8|e[2]&255}clone(){let t=new e;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)==50331648}isBgRGB(){return(this.bg&50331648)==50331648}isFgPalette(){return(this.fg&50331648)==16777216||(this.fg&50331648)==33554432}isBgPalette(){return(this.bg&50331648)==16777216||(this.bg&50331648)==33554432}isFgDefault(){return!(this.fg&50331648)}isBgDefault(){return!(this.bg&50331648)}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)==16777216||(this.extended.underlineColor&50331648)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?!(this.extended.underlineColor&50331648):this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},_d=class e{constructor(e=0,t=0){this._ext=0,this._urlId=0,this._ext=e,this._urlId=t}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(e){this._ext=e}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(e){this._ext&=-469762049,this._ext|=e<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(e){this._ext&=-67108864,this._ext|=e&67108863}get urlId(){return this._urlId}set urlId(e){this._urlId=e}get underlineVariantOffset(){let e=(this._ext&3758096384)>>29;return e<0?e^4294967288:e}set underlineVariantOffset(e){this._ext&=536870911,this._ext|=e<<29&3758096384}clone(){return new e(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},vd=class e{constructor(t){this.element=t,this.next=e.Undefined,this.prev=e.Undefined}};vd.Undefined=new vd(void 0);var yd=globalThis.performance&&typeof globalThis.performance.now==`function`,bd=class e{static create(t){return new e(t)}constructor(e){this._now=yd&&e===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime===-1?this._now()-this._startTime:this._stopTime-this._startTime}},xd;(e=>{e.None=()=>uu.None;function t(e,t){return d(e,()=>{},0,void 0,!0,void 0,t)}e.defer=t;function n(e){return(t,n=null,r)=>{let i=!1,a;return a=e(e=>{if(!i)return a?a.dispose():i=!0,t.call(n,e)},null,r),i&&a.dispose(),a}}e.once=n;function r(e,t,n){return l((n,r=null,i)=>e(e=>n.call(r,t(e)),null,i),n)}e.map=r;function i(e,t,n){return l((n,r=null,i)=>e(e=>{t(e),n.call(r,e)},null,i),n)}e.forEach=i;function a(e,t,n){return l((n,r=null,i)=>e(e=>t(e)&&n.call(r,e),null,i),n)}e.filter=a;function o(e){return e}e.signal=o;function s(...e){return(t,n=null,r)=>u(ou(...e.map(e=>e(e=>t.call(n,e)))),r)}e.any=s;function c(e,t,n,i){let a=n;return r(e,e=>(a=t(a,e),a),i)}e.reduce=c;function l(e,t){let n,r=new X({onWillAddFirstListener(){n=e(r.fire,r)},onDidRemoveLastListener(){n?.dispose()}});return t?.add(r),r.event}function u(e,t){return t instanceof Array?t.push(e):t&&t.add(e),e}function d(e,t,n=100,r=!1,i=!1,a,o){let s,c,l,u=0,d,f=new X({leakWarningThreshold:a,onWillAddFirstListener(){s=e(e=>{u++,c=t(c,e),r&&!l&&(f.fire(c),c=void 0),d=()=>{let e=c;c=void 0,l=void 0,(!r||u>1)&&f.fire(e),u=0},typeof n==`number`?(clearTimeout(l),l=setTimeout(d,n)):l===void 0&&(l=0,queueMicrotask(d))})},onWillRemoveListener(){i&&u>0&&d?.()},onDidRemoveLastListener(){d=void 0,s.dispose()}});return o?.add(f),f.event}e.debounce=d;function f(t,n=0,r){return e.debounce(t,(e,t)=>e?(e.push(t),e):[t],n,void 0,!0,void 0,r)}e.accumulate=f;function p(e,t=(e,t)=>e===t,n){let r=!0,i;return a(e,e=>{let n=r||!t(e,i);return r=!1,i=e,n},n)}e.latch=p;function m(t,n,r){return[e.filter(t,n,r),e.filter(t,e=>!n(e),r)]}e.split=m;function h(e,t=!1,n=[],r){let i=n.slice(),a=e(e=>{i?i.push(e):s.fire(e)});r&&r.add(a);let o=()=>{i?.forEach(e=>s.fire(e)),i=null},s=new X({onWillAddFirstListener(){a||(a=e(e=>s.fire(e)),r&&r.add(a))},onDidAddFirstListener(){i&&(t?setTimeout(o):o())},onDidRemoveLastListener(){a&&a.dispose(),a=null}});return r&&r.add(s),s.event}e.buffer=h;function g(e,t){return(n,r,i)=>{let a=t(new v);return e(function(e){let t=a.evaluate(e);t!==_&&n.call(r,t)},void 0,i)}}e.chain=g;let _=Symbol(`HaltChainable`);class v{constructor(){this.steps=[]}map(e){return this.steps.push(e),this}forEach(e){return this.steps.push(t=>(e(t),t)),this}filter(e){return this.steps.push(t=>e(t)?t:_),this}reduce(e,t){let n=t;return this.steps.push(t=>(n=e(n,t),n)),this}latch(e=(e,t)=>e===t){let t=!0,n;return this.steps.push(r=>{let i=t||!e(r,n);return t=!1,n=r,i?r:_}),this}evaluate(e){for(let t of this.steps)if(e=t(e),e===_)break;return e}}function y(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new X({onWillAddFirstListener:()=>e.on(t,r),onDidRemoveLastListener:()=>e.removeListener(t,r)});return i.event}e.fromNodeEventEmitter=y;function b(e,t,n=e=>e){let r=(...e)=>i.fire(n(...e)),i=new X({onWillAddFirstListener:()=>e.addEventListener(t,r),onDidRemoveLastListener:()=>e.removeEventListener(t,r)});return i.event}e.fromDOMEventEmitter=b;function x(e){return new Promise(t=>n(e)(t))}e.toPromise=x;function S(e){let t=new X;return e.then(e=>{t.fire(e)},()=>{t.fire(void 0)}).finally(()=>{t.dispose()}),t.event}e.fromPromise=S;function ee(e,t){return e(e=>t.fire(e))}e.forward=ee;function C(e,t,n){return t(n),e(e=>t(e))}e.runAndSubscribe=C;class w{constructor(e,t){this._observable=e,this._counter=0,this._hasChanged=!1;let n={onWillAddFirstListener:()=>{e.addObserver(this)},onDidRemoveLastListener:()=>{e.removeObserver(this)}};this.emitter=new X(n),t&&t.add(this.emitter)}beginUpdate(e){this._counter++}handlePossibleChange(e){}handleChange(e,t){this._hasChanged=!0}endUpdate(e){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function T(e,t){return new w(e,t).emitter.event}e.fromObservable=T;function E(e){return(t,n,r)=>{let i=0,a=!1,o={beginUpdate(){i++},endUpdate(){i--,i===0&&(e.reportChanges(),a&&(a=!1,t.call(n)))},handlePossibleChange(){},handleChange(){a=!0}};e.addObserver(o),e.reportChanges();let s={dispose(){e.removeObserver(o)}};return r instanceof lu?r.add(s):Array.isArray(r)&&r.push(s),s}}e.fromObservableLight=E})(xd||={});var Sd=class e{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${e._idPool++}`,e.all.add(this)}start(e){this._stopWatch=new bd,this.listenerCount=e}stop(){if(this._stopWatch){let e=this._stopWatch.elapsed();this.durations.push(e),this.elapsedOverall+=e,this.invocationCount+=1,this._stopWatch=void 0}}};Sd.all=new Set,Sd._idPool=0;var Cd=Sd,wd=-1,Td=class e{constructor(t,n,r=(e._idPool++).toString(16).padStart(3,`0`)){this._errorHandler=t,this.threshold=n,this.name=r,this._warnCountdown=0}dispose(){this._stacks?.clear()}check(e,t){let n=this.threshold;if(n<=0||t{let t=this._stacks.get(e.value)||0;this._stacks.set(e.value,t-1)}}getMostFrequentStack(){if(!this._stacks)return;let e,t=0;for(let[n,r]of this._stacks)(!e||t0||this._options?.leakWarningThreshold?new Ed(e?.onListenerError??Kl,this._options?.leakWarningThreshold??wd):void 0,this._perfMon=this._options?._profName?new Cd(this._options._profName):void 0,this._deliveryQueue=this._options?.deliveryQueue}dispose(){this._disposed||(this._disposed=!0,this._deliveryQueue?.current===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),this._options?.onDidRemoveLastListener?.(),this._leakageMon?.dispose())}get event(){return this._event??=(e,t,n)=>{if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let e=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(e);let t=this._leakageMon.getMostFrequentStack()??[`UNKNOWN stack`,-1],n=new kd(`${e}. HINT: Stack shows most frequent listener (${t[1]}-times)`,t[0]);return(this._options?.onListenerError||Kl)(n),uu.None}if(this._disposed)return uu.None;t&&(e=e.bind(t));let r=new jd(e),i;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=Dd.create(),i=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof jd?(this._deliveryQueue??=new Nd,this._listeners=[this._listeners,r]):this._listeners.push(r):(this._options?.onWillAddFirstListener?.(this),this._listeners=r,this._options?.onDidAddFirstListener?.(this)),this._size++;let a=su(()=>{i?.(),this._removeListener(r)});return n instanceof lu?n.add(a):Array.isArray(n)&&n.push(a),a},this._event}_removeListener(e){if(this._options?.onWillRemoveListener?.(this),!this._listeners)return;if(this._size===1){this._listeners=void 0,this._options?.onDidRemoveLastListener?.(this),this._size=0;return}let t=this._listeners,n=t.indexOf(e);if(n===-1)throw console.log(`disposed?`,this._disposed),console.log(`size?`,this._size),console.log(`arr?`,JSON.stringify(this._listeners)),Error(`Attempted to dispose unknown listener`);this._size--,t[n]=void 0;let r=this._deliveryQueue.current===this;if(this._size*Md<=t.length){let e=0;for(let n=0;n0}},Nd=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,n){this.i=0,this.end=n,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},Pd={texturePage:0,texturePosition:{x:0,y:0},texturePositionClipSpace:{x:0,y:0},offset:{x:0,y:0},size:{x:0,y:0},sizeClipSpace:{x:0,y:0}},Fd=2,Id,Ld=class e{constructor(e,t,n){this._document=e,this._config=t,this._unicodeService=n,this._didWarmUp=!1,this._cacheMap=new dd,this._cacheMapCombined=new dd,this._pages=[],this._activePages=[],this._workBoundingBox={top:0,left:0,bottom:0,right:0},this._workAttributeData=new gd,this._textureSize=512,this._onAddTextureAtlasCanvas=new X,this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=new X,this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._requestClearModel=!1,this._createNewPage(),this._tmpCanvas=Vd(e,this._config.deviceCellWidth*4+Fd*2,this._config.deviceCellHeight+Fd*2),this._tmpCtx=Y(this._tmpCanvas.getContext(`2d`,{alpha:this._config.allowTransparency,willReadFrequently:!0}))}get pages(){return this._pages}dispose(){this._tmpCanvas.remove();for(let e of this.pages)e.canvas.remove();this._onAddTextureAtlasCanvas.dispose()}warmUp(){this._didWarmUp||=(this._doWarmUp(),!0)}_doWarmUp(){let e=new hd;for(let t=33;t<126;t++)e.enqueue(()=>{if(!this._cacheMap.get(t,0,0,0)){let e=this._drawToCache(t,0,0,0,!1,void 0);this._cacheMap.set(t,0,0,0,e)}})}beginFrame(){return this._requestClearModel}clearTexture(){if(this._pages[0].currentRow.x!==0||this._pages[0].currentRow.y!==0){for(let e of this._pages)e.clear();this._cacheMap.clear(),this._cacheMapCombined.clear(),this._didWarmUp=!1}}_createNewPage(){if(e.maxAtlasPages&&this._pages.length>=Math.max(4,e.maxAtlasPages)){let t=this._pages.filter(t=>t.canvas.width*2<=(e.maxTextureSize||4096)).sort((e,t)=>t.canvas.width===e.canvas.width?t.percentageUsed-e.percentageUsed:t.canvas.width-e.canvas.width),n=-1,r=0;for(let e=0;ee.glyphs[0].texturePage).sort((e,t)=>e>t?1:-1),o=this.pages.length-i.length,s=this._mergePages(i,o);s.version++;for(let e=a.length-1;e>=0;e--)this._deletePage(a[e]);this.pages.push(s),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(s.canvas)}let t=new Rd(this._document,this._textureSize);return this._pages.push(t),this._activePages.push(t),this._onAddTextureAtlasCanvas.fire(t.canvas),t}_mergePages(e,t){let n=e[0].canvas.width*2,r=new Rd(this._document,n,e);for(let[i,a]of e.entries()){let e=i*a.canvas.width%n,o=Math.floor(i/2)*a.canvas.height;r.ctx.drawImage(a.canvas,e,o);for(let r of a.glyphs)r.texturePage=t,r.sizeClipSpace.x=r.size.x/n,r.sizeClipSpace.y=r.size.y/n,r.texturePosition.x+=e,r.texturePosition.y+=o,r.texturePositionClipSpace.x=r.texturePosition.x/n,r.texturePositionClipSpace.y=r.texturePosition.y/n;this._onRemoveTextureAtlasCanvas.fire(a.canvas);let s=this._activePages.indexOf(a);s!==-1&&this._activePages.splice(s,1)}return r}_deletePage(e){this._pages.splice(e,1);for(let t=e;t=this._config.colors.ansi.length)throw Error(`No color found for idx `+e);return this._config.colors.ansi[e]}_getBackgroundColor(e,t,n,r){if(this._config.allowTransparency)return Cu;let i;switch(e){case 16777216:case 33554432:i=this._getColorFromAnsiIndex(t);break;case 50331648:let e=gd.toColorRGB(t);i=wu.toColor(e[0],e[1],e[2]);break;default:i=n?Tu.opaque(this._config.colors.foreground):this._config.colors.background}return this._config.allowTransparency||(i=Tu.opaque(i)),i}_getForegroundColor(e,t,n,r,i,a,o,s,c,l){let u=this._getMinimumContrastColor(e,t,n,r,i,a,o,c,s,l);if(u)return u;let d;switch(i){case 16777216:case 33554432:this._config.drawBoldTextInBrightColors&&c&&a<8&&(a+=8),d=this._getColorFromAnsiIndex(a);break;case 50331648:let e=gd.toColorRGB(a);d=wu.toColor(e[0],e[1],e[2]);break;default:d=o?this._config.colors.background:this._config.colors.foreground}return this._config.allowTransparency&&(d=Tu.opaque(d)),s&&(d=Tu.multiplyOpacity(d,Yu)),d}_resolveBackgroundRgba(e,t,n){switch(e){case 16777216:case 33554432:return this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return n?this._config.colors.foreground.rgba:this._config.colors.background.rgba}}_resolveForegroundRgba(e,t,n,r){switch(e){case 16777216:case 33554432:return this._config.drawBoldTextInBrightColors&&r&&t<8&&(t+=8),this._getColorFromAnsiIndex(t).rgba;case 50331648:return t<<8;default:return n?this._config.colors.background.rgba:this._config.colors.foreground.rgba}}_getMinimumContrastColor(e,t,n,r,i,a,o,s,c,l){if(this._config.minimumContrastRatio===1||l)return;let u=this._getContrastCache(c),d=u.getColor(e,r);if(d!==void 0)return d||void 0;let f=this._resolveBackgroundRgba(t,n,o),p=this._resolveForegroundRgba(i,a,o,s),m=Ou.ensureContrastRatio(f,p,this._config.minimumContrastRatio/(c?2:1));if(!m){u.setColor(e,r,null);return}let h=wu.toColor(m>>24&255,m>>16&255,m>>8&255);return u.setColor(e,r,h),h}_getContrastCache(e){return e?this._config.colors.halfContrastCache:this._config.colors.contrastCache}_drawToCache(t,n,r,i,a,o){let s=typeof t==`number`?String.fromCharCode(t):t;o&&this._tmpCanvas.parentElement!==o&&(this._tmpCanvas.style.display=`none`,o.append(this._tmpCanvas));let c=Math.min(this._config.deviceCellWidth*Math.max(s.length,2)+Fd*2,this._config.deviceMaxTextureSize);this._tmpCanvas.width=e?e*2-c:e-c;c>=e||f===0?(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(s+f,r),this._tmpCtx.lineTo(l,r)):(this._tmpCtx.setLineDash([Math.round(e),Math.round(e)]),this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(s+f,r),this._tmpCtx.moveTo(s+f+e,r),this._tmpCtx.lineTo(l,r)),c=Bu(l-s,e,c);break;case 5:let p=l-s,m=Math.floor(.6*p),h=Math.floor(.3*p),g=p-m-h;this._tmpCtx.setLineDash([m,h,g]),this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(l,r);break;default:this._tmpCtx.moveTo(s,r),this._tmpCtx.lineTo(l,r)}this._tmpCtx.stroke(),this._tmpCtx.restore()}if(this._tmpCtx.restore(),!te&&this._config.fontSize>=12&&!this._config.allowTransparency&&s!==` `){this._tmpCtx.save(),this._tmpCtx.textBaseline=`alphabetic`;let t=this._tmpCtx.measureText(s);if(this._tmpCtx.restore(),`actualBoundingBoxDescent`in t&&t.actualBoundingBoxDescent>0){this._tmpCtx.save();let t=new Path2D;t.rect(n,r-Math.ceil(e/2),this._config.deviceCellWidth*ne,o-r+Math.ceil(e/2)),this._tmpCtx.clip(t),this._tmpCtx.lineWidth=this._config.devicePixelRatio*3,this._tmpCtx.strokeStyle=x.css,this._tmpCtx.strokeText(s,E,E+this._config.deviceCharHeight),this._tmpCtx.restore()}}}if(g){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/15)),t=e%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(E,E+t),this._tmpCtx.lineTo(E+this._config.deviceCharWidth*ne,E+t),this._tmpCtx.stroke()}if(te||this._tmpCtx.fillText(s,E,E+this._config.deviceCharHeight),s===`_`&&!this._config.allowTransparency){let e=zd(this._tmpCtx.getImageData(E,E,this._config.deviceCellWidth,this._config.deviceCellHeight),x,T,D);if(e)for(let t=1;t<=5&&(this._tmpCtx.save(),this._tmpCtx.fillStyle=x.css,this._tmpCtx.fillRect(0,0,this._tmpCanvas.width,this._tmpCanvas.height),this._tmpCtx.restore(),this._tmpCtx.fillText(s,E,E+this._config.deviceCharHeight-t),e=zd(this._tmpCtx.getImageData(E,E,this._config.deviceCellWidth,this._config.deviceCellHeight),x,T,D),e);t++);}if(h){let e=Math.max(1,Math.floor(this._config.fontSize*this._config.devicePixelRatio/10)),t=this._tmpCtx.lineWidth%2==1?.5:0;this._tmpCtx.lineWidth=e,this._tmpCtx.strokeStyle=this._tmpCtx.fillStyle,this._tmpCtx.beginPath(),this._tmpCtx.moveTo(E,E+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.lineTo(E+this._config.deviceCharWidth*ne,E+Math.floor(this._config.deviceCharHeight/2)-t),this._tmpCtx.stroke()}this._tmpCtx.restore();let re=this._tmpCtx.getImageData(0,0,this._tmpCanvas.width,this._tmpCanvas.height),ie;if(ie=this._config.allowTransparency?Bd(re):zd(re,x,T,D),ie)return Pd;let O=this._findGlyphBoundingBox(re,this._workBoundingBox,c,w,te,E),k,A;for(;;){if(this._activePages.length===0){let e=this._createNewPage();k=e,A=e.currentRow,A.height=O.size.y;break}k=this._activePages[this._activePages.length-1],A=k.currentRow;for(let e of this._activePages)O.size.y<=e.currentRow.height&&(k=e,A=e.currentRow);for(let e=this._activePages.length-1;e>=0;e--)for(let t of this._activePages[e].fixedRows)t.height<=A.height&&O.size.y<=t.height&&(k=this._activePages[e],A=t);if(O.size.x>this._textureSize){this._overflowSizePage||(this._overflowSizePage=new Rd(this._document,this._config.deviceMaxTextureSize),this.pages.push(this._overflowSizePage),this._requestClearModel=!0,this._onAddTextureAtlasCanvas.fire(this._overflowSizePage.canvas)),k=this._overflowSizePage,A=this._overflowSizePage.currentRow,A.x+O.size.x>=k.canvas.width&&(A.x=0,A.y+=A.height,A.height=0);break}if(A.y+O.size.y>=k.canvas.height||A.height>O.size.y+2){let t=!1;if(k.currentRow.y+k.currentRow.height+O.size.y>=k.canvas.height){let n;for(let e of this._activePages)if(e.currentRow.y+e.currentRow.height+O.size.y=e.maxAtlasPages&&A.y+O.size.y<=k.canvas.height&&A.height>=O.size.y&&A.x+O.size.x<=k.canvas.width)t=!0;else{let e=this._createNewPage();k=e,A=e.currentRow,A.height=O.size.y,t=!0}}t||(k.currentRow.height>0&&k.fixedRows.push(k.currentRow),A={x:0,y:k.currentRow.y+k.currentRow.height,height:O.size.y},k.fixedRows.push(A),k.currentRow={x:0,y:A.y+A.height,height:0})}if(A.x+O.size.x<=k.canvas.width)break;A===k.currentRow?(A.x=0,A.y+=A.height,A.height=0):k.fixedRows.splice(k.fixedRows.indexOf(A),1)}return O.texturePage=this._pages.indexOf(k),O.texturePosition.x=A.x,O.texturePosition.y=A.y,O.texturePositionClipSpace.x=A.x/k.canvas.width,O.texturePositionClipSpace.y=A.y/k.canvas.height,O.sizeClipSpace.x/=k.canvas.width,O.sizeClipSpace.y/=k.canvas.height,A.height=Math.max(A.height,O.size.y),A.x+=O.size.x,k.ctx.putImageData(re,O.texturePosition.x-this._workBoundingBox.left,O.texturePosition.y-this._workBoundingBox.top,this._workBoundingBox.left,this._workBoundingBox.top,O.size.x,O.size.y),k.addGlyph(O),k.version++,O}_findGlyphBoundingBox(e,t,n,r,i,a){t.top=0;let o=r?this._config.deviceCellHeight:this._tmpCanvas.height,s=r?this._config.deviceCellWidth:n,c=!1;for(let n=0;n=a;n--){for(let r=0;r=0;n--){for(let r=0;r>>24,a=t.rgba>>>16&255,o=t.rgba>>>8&255,s=n.rgba>>>24,c=n.rgba>>>16&255,l=n.rgba>>>8&255,u=Math.floor((Math.abs(i-s)+Math.abs(a-c)+Math.abs(o-l))/12),d=!0;for(let t=0;t0)return!1;return!0}function Vd(e,t,n){let r=e.createElement(`canvas`);return r.width=t,r.height=n,r}function Hd(e,t,n,r,i,a,o,s){let c={foreground:a.foreground,background:a.background,cursor:Cu,cursorAccent:Cu,selectionForeground:Cu,selectionBackgroundTransparent:Cu,selectionBackgroundOpaque:Cu,selectionInactiveBackgroundTransparent:Cu,selectionInactiveBackgroundOpaque:Cu,overviewRulerBorder:Cu,scrollbarSliderBackground:Cu,scrollbarSliderHoverBackground:Cu,scrollbarSliderActiveBackground:Cu,ansi:a.ansi.slice(),contrastCache:a.contrastCache,halfContrastCache:a.halfContrastCache};return{customGlyphs:i.customGlyphs,devicePixelRatio:o,deviceMaxTextureSize:s,letterSpacing:i.letterSpacing,lineHeight:i.lineHeight,deviceCellWidth:e,deviceCellHeight:t,deviceCharWidth:n,deviceCharHeight:r,fontFamily:i.fontFamily,fontSize:i.fontSize,fontWeight:i.fontWeight,fontWeightBold:i.fontWeightBold,allowTransparency:i.allowTransparency,drawBoldTextInBrightColors:i.drawBoldTextInBrightColors,minimumContrastRatio:i.minimumContrastRatio,colors:c}}function Ud(e,t){for(let n=0;n=0){if(Ud(n.config,l))return n.atlas;n.ownedBy.length===1?(n.atlas.dispose(),Gd.splice(t,1)):n.ownedBy.splice(r,1);break}}for(let t=0;t{this._renderCallback(),this._animationFrame=void 0}))}_restartInterval(e=Jd){this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout=this._coreBrowserService.window.setTimeout(()=>{if(this._animationTimeRestarted){let e=Jd-(Date.now()-this._animationTimeRestarted);if(this._animationTimeRestarted=void 0,e>0){this._restartInterval(e);return}}this.isCursorVisible=!1,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0}),this._blinkInterval=this._coreBrowserService.window.setInterval(()=>{if(this._animationTimeRestarted){let e=Jd-(Date.now()-this._animationTimeRestarted);this._animationTimeRestarted=void 0,this._restartInterval(e)}else this.isCursorVisible=!this.isCursorVisible,this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._renderCallback(),this._animationFrame=void 0})},Jd)},e)}pause(){this.isCursorVisible=!0,this._blinkInterval&&=(this._coreBrowserService.window.clearInterval(this._blinkInterval),void 0),this._blinkStartTimeout&&=(this._coreBrowserService.window.clearTimeout(this._blinkStartTimeout),void 0),this._animationFrame&&=(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),void 0)}resume(){this.pause(),this._animationTimeRestarted=void 0,this._restartInterval(),this.restartBlinkAnimation()}};function Xd(e,t,n){let r=new t.ResizeObserver(t=>{let i=t.find(t=>t.target===e);if(!i)return;if(!(`devicePixelContentBoxSize`in i)){r?.disconnect(),r=void 0;return}let a=i.devicePixelContentBoxSize[0].inlineSize,o=i.devicePixelContentBoxSize[0].blockSize;a>0&&o>0&&n(a,o)});try{r.observe(e,{box:[`device-pixel-content-box`]})}catch{r.disconnect(),r=void 0}return su(()=>r?.disconnect())}function Zd(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}var Qd=class e extends gd{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new _d,this.combinedData=``}static fromCharData(t){let n=new e;return n.setFromCharData(t),n}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Zd(this.content&2097151):``}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(e){this.fg=e[0],this.bg=0;let t=!1;if(e[1].length>2)t=!0;else if(e[1].length===2){let n=e[1].charCodeAt(0);if(55296<=n&&n<=56319){let r=e[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(n-55296)*1024+r-56320+65536|e[2]<<22:t=!0}else t=!0}else this.content=e[1].charCodeAt(0)|e[2]<<22;t&&(this.combinedData=e[1],this.content=2097152|e[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},$d=new Float32Array([2,0,0,0,0,-2,0,0,0,0,1,0,-1,1,0,1]);function ef(e,t,n){let r=Y(e.createProgram());if(e.attachShader(r,Y(tf(e,e.VERTEX_SHADER,t))),e.attachShader(r,Y(tf(e,e.FRAGMENT_SHADER,n))),e.linkProgram(r),e.getProgramParameter(r,e.LINK_STATUS))return r;console.error(e.getProgramInfoLog(r)),e.deleteProgram(r)}function tf(e,t,n){let r=Y(e.createShader(t));if(e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS))return r;console.error(e.getShaderInfoLog(r)),e.deleteShader(r)}function nf(e,t){let n=Math.min(e.length*2,t),r=new Float32Array(n);for(let t=0;ti.deleteProgram(this._program))),this._projectionLocation=Y(i.getUniformLocation(this._program,`u_projection`)),this._resolutionLocation=Y(i.getUniformLocation(this._program,`u_resolution`)),this._textureLocation=Y(i.getUniformLocation(this._program,`u_texture`)),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),o=i.createBuffer();this._register(su(()=>i.deleteBuffer(o))),i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,a,i.STATIC_DRAW),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,this._gl.FLOAT,!1,0,0);let s=new Uint8Array([0,1,2,3]),c=i.createBuffer();this._register(su(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=Y(i.createBuffer()),this._register(su(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,2,i.FLOAT,!1,cf,0),i.vertexAttribDivisor(2,1),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,i.FLOAT,!1,cf,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(3,1),i.enableVertexAttribArray(4),i.vertexAttribPointer(4,1,i.FLOAT,!1,cf,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(4,1),i.enableVertexAttribArray(5),i.vertexAttribPointer(5,2,i.FLOAT,!1,cf,5*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(5,1),i.enableVertexAttribArray(6),i.vertexAttribPointer(6,2,i.FLOAT,!1,cf,7*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(6,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,cf,9*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.useProgram(this._program);let l=new Int32Array(Ld.maxAtlasPages);for(let e=0;ei.deleteTexture(t.texture))),i.activeTexture(i.TEXTURE0+e),i.bindTexture(i.TEXTURE_2D,t.texture),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,new Uint8Array([255,0,0,255])),this._atlasTextures[e]=t}i.enable(i.BLEND),i.blendFunc(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA),this.handleResize()}beginFrame(){return!this._atlas||this._atlas.beginFrame()}updateCell(e,t,n,r,i,a,o,s,c){this._updateCell(this._vertices.attributes,e,t,n,r,i,a,o,s,c)}_updateCell(e,t,n,r,i,a,o,s,c,l){Z=(n*this._terminal.cols+t)*sf,r===0||r===void 0?e.fill(0,Z,Z+sf-1-lf):this._atlas&&(Q=s&&s.length>1?this._atlas.getRasterizedGlyphCombinedChar(s,i,a,o,!1,this._terminal.element):this._atlas.getRasterizedGlyph(r,i,a,o,!1,this._terminal.element),uf=Math.floor((this._dimensions.device.cell.width-this._dimensions.device.char.width)/2),i!==l&&Q.offset.x>uf?(df=Q.offset.x-uf,e[Z]=-(Q.offset.x-df)+this._dimensions.device.char.left,e[Z+1]=-Q.offset.y+this._dimensions.device.char.top,e[Z+2]=(Q.size.x-df)/this._dimensions.device.canvas.width,e[Z+3]=Q.size.y/this._dimensions.device.canvas.height,e[Z+4]=Q.texturePage,e[Z+5]=Q.texturePositionClipSpace.x+df/this._atlas.pages[Q.texturePage].canvas.width,e[Z+6]=Q.texturePositionClipSpace.y,e[Z+7]=Q.sizeClipSpace.x-df/this._atlas.pages[Q.texturePage].canvas.width,e[Z+8]=Q.sizeClipSpace.y):(e[Z]=-Q.offset.x+this._dimensions.device.char.left,e[Z+1]=-Q.offset.y+this._dimensions.device.char.top,e[Z+2]=Q.size.x/this._dimensions.device.canvas.width,e[Z+3]=Q.size.y/this._dimensions.device.canvas.height,e[Z+4]=Q.texturePage,e[Z+5]=Q.texturePositionClipSpace.x,e[Z+6]=Q.texturePositionClipSpace.y,e[Z+7]=Q.sizeClipSpace.x,e[Z+8]=Q.sizeClipSpace.y),this._optionsService.rawOptions.rescaleOverlappingGlyphs&&Iu(r,c,Q.size.x,this._dimensions.device.cell.width)&&(e[Z+2]=(this._dimensions.device.cell.width-1)/this._dimensions.device.canvas.width))}clear(){let e=this._terminal,t=e.cols*e.rows*sf;this._vertices.count===t?this._vertices.attributes.fill(0):this._vertices.attributes=new Float32Array(t);let n=0;for(;n=e.rows||c<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=r,this.viewportStartRow=a,this.viewportEndRow=o,this.viewportCappedStartRow=s,this.viewportCappedEndRow=c,this.startCol=t[0],this.endCol=n[0])}isCellSelected(e,t,n){return this.hasSelection?(n-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&n>=this.viewportCappedStartRow&&t=this.viewportCappedStartRow&&t>=this.endCol&&n<=this.viewportCappedEndRow:n>this.viewportStartRow&&n=this.startCol&&t=this.startCol):!1}};function mf(){return new pf}var hf=4,gf=1,_f=2,vf=3,yf=2147483648,bf=class{constructor(){this.cells=new Uint32Array,this.lineLengths=new Uint32Array,this.selection=mf()}resize(e,t){let n=e*t*hf;n!==this.cells.length&&(this.cells=new Uint32Array(n),this.lineLengths=new Uint32Array(t))}clear(){this.cells.fill(0,0),this.lineLengths.fill(0,0)}},xf=`#version 300 es +layout (location = 0) in vec2 a_position; +layout (location = 1) in vec2 a_size; +layout (location = 2) in vec4 a_color; +layout (location = 3) in vec2 a_unitquad; + +uniform mat4 u_projection; + +out vec4 v_color; + +void main() { + vec2 zeroToOne = a_position + (a_unitquad * a_size); + gl_Position = u_projection * vec4(zeroToOne, 0.0, 1.0); + v_color = a_color; +}`,Sf=`#version 300 es +precision lowp float; + +in vec4 v_color; + +out vec4 outColor; + +void main() { + outColor = v_color; +}`,Cf=8,wf=Cf*Float32Array.BYTES_PER_ELEMENT,Tf=20*Cf,Ef=class{constructor(){this.attributes=new Float32Array(Tf),this.count=0}},Df=0,Of=0,kf=0,Af=0,jf=0,Mf=0,Nf=0,Pf=class extends uu{constructor(e,t,n,r){super(),this._terminal=e,this._gl=t,this._dimensions=n,this._themeService=r,this._vertices=new Ef,this._verticesCursor=new Ef;let i=this._gl;this._program=Y(ef(i,xf,Sf)),this._register(su(()=>i.deleteProgram(this._program))),this._projectionLocation=Y(i.getUniformLocation(this._program,`u_projection`)),this._vertexArrayObject=i.createVertexArray(),i.bindVertexArray(this._vertexArrayObject);let a=new Float32Array([0,0,1,0,0,1,1,1]),o=i.createBuffer();this._register(su(()=>i.deleteBuffer(o))),i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,a,i.STATIC_DRAW),i.enableVertexAttribArray(3),i.vertexAttribPointer(3,2,this._gl.FLOAT,!1,0,0);let s=new Uint8Array([0,1,2,3]),c=i.createBuffer();this._register(su(()=>i.deleteBuffer(c))),i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,c),i.bufferData(i.ELEMENT_ARRAY_BUFFER,s,i.STATIC_DRAW),this._attributesBuffer=Y(i.createBuffer()),this._register(su(()=>i.deleteBuffer(this._attributesBuffer))),i.bindBuffer(i.ARRAY_BUFFER,this._attributesBuffer),i.enableVertexAttribArray(0),i.vertexAttribPointer(0,2,i.FLOAT,!1,wf,0),i.vertexAttribDivisor(0,1),i.enableVertexAttribArray(1),i.vertexAttribPointer(1,2,i.FLOAT,!1,wf,2*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(1,1),i.enableVertexAttribArray(2),i.vertexAttribPointer(2,4,i.FLOAT,!1,wf,4*Float32Array.BYTES_PER_ELEMENT),i.vertexAttribDivisor(2,1),this._updateCachedColors(r.colors),this._register(this._themeService.onChangeColors(e=>{this._updateCachedColors(e),this._updateViewportRectangle()}))}renderBackgrounds(){this._renderVertices(this._vertices)}renderCursor(){this._renderVertices(this._verticesCursor)}_renderVertices(e){let t=this._gl;t.useProgram(this._program),t.bindVertexArray(this._vertexArrayObject),t.uniformMatrix4fv(this._projectionLocation,!1,$d),t.bindBuffer(t.ARRAY_BUFFER,this._attributesBuffer),t.bufferData(t.ARRAY_BUFFER,e.attributes,t.DYNAMIC_DRAW),t.drawElementsInstanced(this._gl.TRIANGLE_STRIP,4,t.UNSIGNED_BYTE,0,e.count)}handleResize(){this._updateViewportRectangle()}setDimensions(e){this._dimensions=e}_updateCachedColors(e){this._bgFloat=this._colorToFloat32Array(e.background),this._cursorFloat=this._colorToFloat32Array(e.cursor)}_updateViewportRectangle(){this._addRectangleFloat(this._vertices.attributes,0,0,0,this._terminal.cols*this._dimensions.device.cell.width,this._terminal.rows*this._dimensions.device.cell.height,this._bgFloat)}updateBackgrounds(e){let t=this._terminal,n=this._vertices,r=1,i,a,o,s,c,l,u,d,f,p,m;for(i=0;i>24&255)/255,jf=(Df>>16&255)/255,Mf=(Df>>8&255)/255,Nf=1,this._addRectangle(e.attributes,t,Of,kf,(a-i)*this._dimensions.device.cell.width,this._dimensions.device.cell.height,Af,jf,Mf,Nf)}_addRectangle(e,t,n,r,i,a,o,s,c,l){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o,e[t+5]=s,e[t+6]=c,e[t+7]=l}_addRectangleFloat(e,t,n,r,i,a,o){e[t]=n/this._dimensions.device.canvas.width,e[t+1]=r/this._dimensions.device.canvas.height,e[t+2]=i/this._dimensions.device.canvas.width,e[t+3]=a/this._dimensions.device.canvas.height,e[t+4]=o[0],e[t+5]=o[1],e[t+6]=o[2],e[t+7]=o[3]}_colorToFloat32Array(e){return new Float32Array([(e.rgba>>24&255)/255,(e.rgba>>16&255)/255,(e.rgba>>8&255)/255,(e.rgba&255)/255])}},Ff=class extends uu{constructor(e,t,n,r,i,a,o,s){super(),this._container=t,this._alpha=i,this._coreBrowserService=a,this._optionsService=o,this._themeService=s,this._deviceCharWidth=0,this._deviceCharHeight=0,this._deviceCellWidth=0,this._deviceCellHeight=0,this._deviceCharLeft=0,this._deviceCharTop=0,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`),this._canvas.classList.add(`xterm-${n}-layer`),this._canvas.style.zIndex=r.toString(),this._initCanvas(),this._container.appendChild(this._canvas),this._register(this._themeService.onChangeColors(t=>{this._refreshCharAtlas(e,t),this.reset(e)})),this._register(su(()=>{this._canvas.remove()}))}_initCanvas(){this._ctx=Y(this._canvas.getContext(`2d`,{alpha:this._alpha})),this._alpha||this._clearAll()}handleBlur(e){}handleFocus(e){}handleCursorMove(e){}handleGridChanged(e,t,n){}handleSelectionChanged(e,t,n,r=!1){}_setTransparency(e,t){if(t===this._alpha)return;let n=this._canvas;this._alpha=t,this._canvas=this._canvas.cloneNode(),this._initCanvas(),this._container.replaceChild(this._canvas,n),this._refreshCharAtlas(e,this._themeService.colors),this.handleGridChanged(e,0,e.rows-1)}_refreshCharAtlas(e,t){this._deviceCharWidth<=0&&this._deviceCharHeight<=0||(this._charAtlas=Kd(e,this._optionsService.rawOptions,t,this._deviceCellWidth,this._deviceCellHeight,this._deviceCharWidth,this._deviceCharHeight,this._coreBrowserService.dpr,2048),this._charAtlas.warmUp())}resize(e,t){this._deviceCellWidth=t.device.cell.width,this._deviceCellHeight=t.device.cell.height,this._deviceCharWidth=t.device.char.width,this._deviceCharHeight=t.device.char.height,this._deviceCharLeft=t.device.char.left,this._deviceCharTop=t.device.char.top,this._canvas.width=t.device.canvas.width,this._canvas.height=t.device.canvas.height,this._canvas.style.width=`${t.css.canvas.width}px`,this._canvas.style.height=`${t.css.canvas.height}px`,this._alpha||this._clearAll(),this._refreshCharAtlas(e,this._themeService.colors)}_fillBottomLineAtCells(e,t,n=1){this._ctx.fillRect(e*this._deviceCellWidth,(t+1)*this._deviceCellHeight-this._coreBrowserService.dpr-1,n*this._deviceCellWidth,this._coreBrowserService.dpr)}_clearAll(){this._alpha?this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(0,0,this._canvas.width,this._canvas.height))}_clearCells(e,t,n,r){this._alpha?this._ctx.clearRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight):(this._ctx.fillStyle=this._themeService.colors.background.css,this._ctx.fillRect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,r*this._deviceCellHeight))}_fillCharTrueColor(e,t,n,r){this._ctx.font=this._getFont(e,!1,!1),this._ctx.textBaseline=Xu,this._clipCell(n,r,t.getWidth()),this._ctx.fillText(t.getChars(),n*this._deviceCellWidth+this._deviceCharLeft,r*this._deviceCellHeight+this._deviceCharTop+this._deviceCharHeight)}_clipCell(e,t,n){this._ctx.beginPath(),this._ctx.rect(e*this._deviceCellWidth,t*this._deviceCellHeight,n*this._deviceCellWidth,this._deviceCellHeight),this._ctx.clip()}_getFont(e,t,n){let r=t?e.options.fontWeightBold:e.options.fontWeight;return`${n?`italic`:``} ${r} ${e.options.fontSize*this._coreBrowserService.dpr}px ${e.options.fontFamily}`}},If=class extends Ff{constructor(e,t,n,r,i,a,o){super(n,e,`link`,t,!0,i,a,o),this._register(r.onShowLinkUnderline(e=>this._handleShowLinkUnderline(e))),this._register(r.onHideLinkUnderline(e=>this._handleHideLinkUnderline(e)))}resize(e,t){super.resize(e,t),this._state=void 0}reset(e){this._clearCurrentLink()}_clearCurrentLink(){if(this._state){this._clearCells(this._state.x1,this._state.y1,this._state.cols-this._state.x1,1);let e=this._state.y2-this._state.y1-1;e>0&&this._clearCells(0,this._state.y1+1,this._state.cols,e),this._clearCells(0,this._state.y2,this._state.x2,1),this._state=void 0}}_handleShowLinkUnderline(e){if(e.fg===257?this._ctx.fillStyle=this._themeService.colors.background.css:e.fg!==void 0&&Wd(e.fg)?this._ctx.fillStyle=this._themeService.colors.ansi[e.fg].css:this._ctx.fillStyle=this._themeService.colors.foreground.css,e.y1===e.y2)this._fillBottomLineAtCells(e.x1,e.y1,e.x2-e.x1);else{this._fillBottomLineAtCells(e.x1,e.y1,e.cols-e.x1);for(let t=e.y1+1;t=0;!(Vf.indexOf(`Chrome`)>=0)&&Vf.indexOf(`Safari`),Vf.indexOf(`Electron/`),Vf.indexOf(`Android`);var Uf=!1;if(typeof Lf.matchMedia==`function`){let e=Lf.matchMedia(`(display-mode: standalone) or (display-mode: window-controls-overlay)`),t=Lf.matchMedia(`(display-mode: fullscreen)`);Uf=e.matches,Bf(Lf,e,({matches:e})=>{Uf&&t.matches||(Uf=e)})}function Wf(){return Uf}var Gf=`en`,Kf=!1,qf=!1,Jf=!1,Yf=Gf,Xf,Zf=globalThis,Qf;typeof Zf.vscode<`u`&&typeof Zf.vscode.process<`u`?Qf=Zf.vscode.process:typeof process<`u`&&typeof process?.versions?.node==`string`&&(Qf=process);var $f=typeof Qf?.versions?.electron==`string`&&Qf?.type===`renderer`;if(typeof Qf==`object`){Qf.platform,Qf.platform,Kf=Qf.platform===`linux`,Kf&&Qf.env.SNAP&&Qf.env.SNAP_REVISION,Qf.env.CI||Qf.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Yf=Gf;let e=Qf.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);t.userLocale,t.osLocale,Yf=t.resolvedLanguage||Gf,t.languagePack?.translationsConfigFile}catch{}qf=!0}else typeof navigator==`object`&&!$f?(Xf=navigator.userAgent,Xf.indexOf(`Windows`),Xf.indexOf(`Macintosh`),(Xf.indexOf(`Macintosh`)>=0||Xf.indexOf(`iPad`)>=0||Xf.indexOf(`iPhone`)>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints,Kf=Xf.indexOf(`Linux`)>=0,Xf?.indexOf(`Mobi`),Jf=!0,Yf=globalThis._VSCODE_NLS_LANGUAGE||Gf,navigator.language.toLowerCase()):console.error(`Unable to resolve platform.`);var ep=qf;Jf&&typeof Zf.importScripts==`function`&&Zf.origin;var tp=Xf,np=Yf,rp;(e=>{function t(){return np}e.value=t;function n(){return np.length===2?np===`en`:np.length>=3&&np[0]===`e`&&np[1]===`n`&&np[2]===`-`}e.isDefaultVariant=n;function r(){return np===`en`}e.isDefault=r})(rp||={});var ip=typeof Zf.postMessage==`function`&&!Zf.importScripts;(()=>{if(ip){let e=[];Zf.addEventListener(`message`,t=>{if(t.data&&t.data.vscodeScheduleAsyncWork)for(let n=0,r=e.length;n{let r=++t;e.push({id:r,callback:n}),Zf.postMessage({vscodeScheduleAsyncWork:r},`*`)}}return e=>setTimeout(e)})();var ap=!!(tp&&tp.indexOf(`Chrome`)>=0);tp&&tp.indexOf(`Firefox`),!ap&&tp&&tp.indexOf(`Safari`),tp&&tp.indexOf(`Edg/`),tp&&tp.indexOf(`Android`);var op=typeof navigator==`object`?navigator:{};ep||document.queryCommandSupported&&document.queryCommandSupported(`copy`)||op&&op.clipboard&&op.clipboard.writeText,ep||op&&op.clipboard&&op.clipboard.readText,ep||Wf()||op.keyboard,`ontouchstart`in Lf||op.maxTouchPoints,Lf.PointerEvent&&(`ontouchstart`in Lf||navigator.maxTouchPoints);var sp=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},cp=new sp,lp=new sp,up=new sp;Array(230);var dp;(e=>{function t(e){return cp.keyCodeToStr(e)}e.toString=t;function n(e){return cp.strToKeyCode(e)}e.fromString=n;function r(e){return lp.keyCodeToStr(e)}e.toUserSettingsUS=r;function i(e){return up.keyCodeToStr(e)}e.toUserSettingsGeneral=i;function a(e){return lp.strToKeyCode(e)||up.strToKeyCode(e)}e.fromUserSettings=a;function o(e){if(e>=98&&e<=113)return null;switch(e){case 16:return`Up`;case 18:return`Down`;case 15:return`Left`;case 17:return`Right`}return cp.keyCodeToStr(e)}e.toElectronAccelerator=o})(dp||={});var fp=Object.freeze(function(e,t){let n=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(n)}}}),pp;(e=>{function t(t){return t===e.None||t===e.Cancelled||t instanceof mp?!0:!t||typeof t!=`object`?!1:typeof t.isCancellationRequested==`boolean`&&typeof t.onCancellationRequested==`function`}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:xd.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:fp})})(pp||={});var mp=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?fp:(this._emitter||=new X,this._emitter.event)}dispose(){this._emitter&&=(this._emitter.dispose(),null)}};(function(){typeof globalThis.requestIdleCallback!=`function`||globalThis.cancelIdleCallback})();var hp;(e=>{async function t(e){let t,n=await Promise.all(e.map(e=>e.then(e=>e,e=>{t||=e})));if(typeof t<`u`)throw t;return n}e.settled=t;function n(e){return new Promise(async(t,n)=>{try{await e(t,n)}catch(e){n(e)}})}e.withAsyncBody=n})(hp||={});var gp=class e{static fromArray(t){return new e(e=>{e.emitMany(t)})}static fromPromise(t){return new e(async e=>{e.emitMany(await t)})}static fromPromises(t){return new e(async e=>{await Promise.all(t.map(async t=>e.emitOne(await t)))})}static merge(t){return new e(async e=>{await Promise.all(t.map(async t=>{for await(let n of t)e.emitOne(n)}))})}constructor(e,t){this._state=0,this._results=[],this._error=null,this._onReturn=t,this._onStateChanged=new X,queueMicrotask(async()=>{let t={emitOne:e=>this.emitOne(e),emitMany:e=>this.emitMany(e),reject:e=>this.reject(e)};try{await Promise.resolve(e(t)),this.resolve()}catch(e){this.reject(e)}finally{t.emitOne=void 0,t.emitMany=void 0,t.reject=void 0}})}[Symbol.asyncIterator](){let e=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(e(this._onReturn?.(),{done:!0,value:void 0})}}static map(t,n){return new e(async e=>{for await(let r of t)e.emitOne(n(r))})}map(t){return e.map(this,t)}static filter(t,n){return new e(async e=>{for await(let r of t)n(r)&&e.emitOne(r)})}filter(t){return e.filter(this,t)}static coalesce(t){return e.filter(t,e=>!!e)}coalesce(){return e.coalesce(this)}static async toPromise(e){let t=[];for await(let n of e)t.push(n);return t}toPromise(){return e.toPromise(this)}emitOne(e){this._state===0&&(this._results.push(e),this._onStateChanged.fire())}emitMany(e){this._state===0&&(this._results=this._results.concat(e),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(e){this._state===0&&(this._state=2,this._error=e,this._onStateChanged.fire())}};gp.EMPTY=gp.fromArray([]);function _p(e){return vp(e,0)}function vp(e,t){switch(typeof e){case`object`:return e===null?yp(349,t):Array.isArray(e)?Sp(e,t):Cp(e,t);case`string`:return xp(e,t);case`boolean`:return bp(e,t);case`number`:return yp(e,t);case`undefined`:return yp(937,t);default:return yp(617,t)}}function yp(e,t){return(t<<5)-t+e|0}function bp(e,t){return yp(e?433:863,t)}function xp(e,t){t=yp(149417,t);for(let n=0,r=e.length;nvp(t,e),t)}function Cp(e,t){return t=yp(181387,t),Object.keys(e).sort().reduce((t,n)=>(t=xp(n,t),vp(e[n],t)),t)}var{registerWindow:wp,getWindow:Tp,getDocument:Ep,getWindows:Dp,getWindowsCount:Op,getWindowId:kp,getWindowById:Ap,hasWindow:jp,onDidRegisterWindow:Mp,onWillUnregisterWindow:Np,onDidUnregisterWindow:Pp}=function(){let e=new Map,t={window:Lf,disposables:new lu};e.set(Lf.vscodeWindowId,t);let n=new X,r=new X,i=new X;function a(n,r){return(typeof n==`number`?e.get(n):void 0)??(r?t:void 0)}return{onDidRegisterWindow:n.event,onWillUnregisterWindow:i.event,onDidUnregisterWindow:r.event,registerWindow(t){if(e.has(t.vscodeWindowId))return uu.None;let a=new lu,o={window:t,disposables:a.add(new lu)};return e.set(t.vscodeWindowId,o),a.add(su(()=>{e.delete(t.vscodeWindowId),r.fire(t)})),a.add(Ip(t,Rp.BEFORE_UNLOAD,()=>{i.fire(t)})),n.fire(o),a},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(e){return e.vscodeWindowId},hasWindow(t){return e.has(t)},getWindowById:a,getWindow(e){let t=e;if(t?.ownerDocument?.defaultView)return t.ownerDocument.defaultView.window;let n=e;return n?.view?n.view.window:Lf},getDocument(e){return Tp(e).document}}}(),Fp=class{constructor(e,t,n,r){this._node=e,this._type=t,this._handler=n,this._options=r||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&=(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,null)}};function Ip(e,t,n,r){return new Fp(e,t,n,r)}var Lp=class e{constructor(e,t){this.width=e,this.height=t}with(t=this.width,n=this.height){return t!==this.width||n!==this.height?new e(t,n):this}static is(e){return typeof e==`object`&&typeof e.height==`number`&&typeof e.width==`number`}static lift(t){return t instanceof e?t:new e(t.width,t.height)}static equals(e,t){return e===t?!0:!e||!t?!1:e.width===t.width&&e.height===t.height}};Lp.None=new Lp(0,0),new class{constructor(){this.mutationObservers=new Map}observe(e,t,n){let r=this.mutationObservers.get(e);r||(r=new Map,this.mutationObservers.set(e,r));let i=_p(n),a=r.get(i);if(a)a.users+=1;else{let o=new X,s=new MutationObserver(e=>o.fire(e));s.observe(e,n);let c=a={users:1,observer:s,onDidMutate:o.event};t.add(su(()=>{--c.users,c.users===0&&(o.dispose(),s.disconnect(),r?.delete(i),r?.size===0&&this.mutationObservers.delete(e))})),r.set(i,a)}return a.onDidMutate}};var Rp={CLICK:`click`,AUXCLICK:`auxclick`,DBLCLICK:`dblclick`,MOUSE_UP:`mouseup`,MOUSE_DOWN:`mousedown`,MOUSE_OVER:`mouseover`,MOUSE_MOVE:`mousemove`,MOUSE_OUT:`mouseout`,MOUSE_ENTER:`mouseenter`,MOUSE_LEAVE:`mouseleave`,MOUSE_WHEEL:`wheel`,POINTER_UP:`pointerup`,POINTER_DOWN:`pointerdown`,POINTER_MOVE:`pointermove`,POINTER_LEAVE:`pointerleave`,CONTEXT_MENU:`contextmenu`,WHEEL:`wheel`,KEY_DOWN:`keydown`,KEY_PRESS:`keypress`,KEY_UP:`keyup`,LOAD:`load`,BEFORE_UNLOAD:`beforeunload`,UNLOAD:`unload`,PAGE_SHOW:`pageshow`,PAGE_HIDE:`pagehide`,PASTE:`paste`,ABORT:`abort`,ERROR:`error`,RESIZE:`resize`,SCROLL:`scroll`,FULLSCREEN_CHANGE:`fullscreenchange`,WK_FULLSCREEN_CHANGE:`webkitfullscreenchange`,SELECT:`select`,CHANGE:`change`,SUBMIT:`submit`,RESET:`reset`,FOCUS:`focus`,FOCUS_IN:`focusin`,FOCUS_OUT:`focusout`,BLUR:`blur`,INPUT:`input`,STORAGE:`storage`,DRAG_START:`dragstart`,DRAG:`drag`,DRAG_ENTER:`dragenter`,DRAG_LEAVE:`dragleave`,DRAG_OVER:`dragover`,DROP:`drop`,DRAG_END:`dragend`,ANIMATION_START:Hf?`webkitAnimationStart`:`animationstart`,ANIMATION_END:Hf?`webkitAnimationEnd`:`animationend`,ANIMATION_ITERATION:Hf?`webkitAnimationIteration`:`animationiteration`},zp=class extends uu{constructor(e,t,n,r,i,a,o,s,c){super(),this._terminal=e,this._characterJoinerService=t,this._charSizeService=n,this._coreBrowserService=r,this._coreService=i,this._decorationService=a,this._optionsService=o,this._themeService=s,this._cursorBlinkStateManager=new du,this._charAtlasDisposable=this._register(new du),this._observerDisposable=this._register(new du),this._model=new bf,this._workCell=new Qd,this._workCell2=new Qd,this._rectangleRenderer=this._register(new du),this._glyphRenderer=this._register(new du),this._onChangeTextureAtlas=this._register(new X),this.onChangeTextureAtlas=this._onChangeTextureAtlas.event,this._onAddTextureAtlasCanvas=this._register(new X),this.onAddTextureAtlasCanvas=this._onAddTextureAtlasCanvas.event,this._onRemoveTextureAtlasCanvas=this._register(new X),this.onRemoveTextureAtlasCanvas=this._onRemoveTextureAtlasCanvas.event,this._onRequestRedraw=this._register(new X),this.onRequestRedraw=this._onRequestRedraw.event,this._onContextLoss=this._register(new X),this.onContextLoss=this._onContextLoss.event,this._canvas=this._coreBrowserService.mainDocument.createElement(`canvas`);let l={antialias:!1,depth:!1,preserveDrawingBuffer:c};if(this._gl=this._canvas.getContext(`webgl2`,l),!this._gl)throw Error(`WebGL2 not supported `+this._gl);this._register(this._themeService.onChangeColors(()=>this._handleColorChange())),this._cellColorResolver=new Ju(this._terminal,this._optionsService,this._model.selection,this._decorationService,this._coreBrowserService,this._themeService),this._core=this._terminal._core,this._renderLayers=[new If(this._core.screenElement,2,this._terminal,this._core.linkifier,this._coreBrowserService,o,this._themeService)],this.dimensions=Ru(),this._devicePixelRatio=this._coreBrowserService.dpr,this._updateDimensions(),this._updateCursorBlink(),this._register(o.onOptionChange(()=>this._handleOptionsChanged())),this._deviceMaxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._register(Ip(this._canvas,`webglcontextlost`,e=>{console.log(`webglcontextlost event received`),e.preventDefault(),this._contextRestorationTimeout=setTimeout(()=>{this._contextRestorationTimeout=void 0,console.warn(`webgl context not restored; firing onContextLoss`),this._onContextLoss.fire(e)},3e3)})),this._register(Ip(this._canvas,`webglcontextrestored`,e=>{console.warn(`webglcontextrestored event received`),clearTimeout(this._contextRestorationTimeout),this._contextRestorationTimeout=void 0,qd(this._terminal),this._initializeWebGLState(),this._requestRedrawViewport()})),this._observerDisposable.value=Xd(this._canvas,this._coreBrowserService.window,(e,t)=>this._setCanvasDevicePixelDimensions(e,t)),this._register(this._coreBrowserService.onWindowChange(e=>{this._observerDisposable.value=Xd(this._canvas,e,(e,t)=>this._setCanvasDevicePixelDimensions(e,t))})),this._core.screenElement.appendChild(this._canvas),[this._rectangleRenderer.value,this._glyphRenderer.value]=this._initializeWebGLState(),this._isAttached=this._core.screenElement.isConnected,this._register(su(()=>{for(let e of this._renderLayers)e.dispose();this._canvas.parentElement?.removeChild(this._canvas),qd(this._terminal)}))}get textureAtlas(){return this._charAtlas?.pages[0].canvas}_handleColorChange(){this._refreshCharAtlas(),this._clearModel(!0)}handleDevicePixelRatioChange(){this._devicePixelRatio!==this._coreBrowserService.dpr&&(this._devicePixelRatio=this._coreBrowserService.dpr,this.handleResize(this._terminal.cols,this._terminal.rows))}handleResize(e,t){this._updateDimensions(),this._model.resize(this._terminal.cols,this._terminal.rows);for(let e of this._renderLayers)e.resize(this._terminal,this.dimensions);this._canvas.width=this.dimensions.device.canvas.width,this._canvas.height=this.dimensions.device.canvas.height,this._canvas.style.width=`${this.dimensions.css.canvas.width}px`,this._canvas.style.height=`${this.dimensions.css.canvas.height}px`,this._core.screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._core.screenElement.style.height=`${this.dimensions.css.canvas.height}px`,this._rectangleRenderer.value?.setDimensions(this.dimensions),this._rectangleRenderer.value?.handleResize(),this._glyphRenderer.value?.setDimensions(this.dimensions),this._glyphRenderer.value?.handleResize(),this._refreshCharAtlas(),this._clearModel(!1)}handleCharSizeChanged(){this.handleResize(this._terminal.cols,this._terminal.rows)}handleBlur(){for(let e of this._renderLayers)e.handleBlur(this._terminal);this._cursorBlinkStateManager.value?.pause(),this._requestRedrawViewport()}handleFocus(){for(let e of this._renderLayers)e.handleFocus(this._terminal);this._cursorBlinkStateManager.value?.resume(),this._requestRedrawViewport()}handleSelectionChanged(e,t,n){for(let r of this._renderLayers)r.handleSelectionChanged(this._terminal,e,t,n);this._model.selection.update(this._core,e,t,n),this._requestRedrawViewport()}handleCursorMove(){for(let e of this._renderLayers)e.handleCursorMove(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation()}_handleOptionsChanged(){this._updateDimensions(),this._refreshCharAtlas(),this._updateCursorBlink()}_initializeWebGLState(){return this._rectangleRenderer.value=new Pf(this._terminal,this._gl,this.dimensions,this._themeService),this._glyphRenderer.value=new ff(this._terminal,this._gl,this.dimensions,this._optionsService),this.handleCharSizeChanged(),[this._rectangleRenderer.value,this._glyphRenderer.value]}_refreshCharAtlas(){if(this.dimensions.device.char.width<=0&&this.dimensions.device.char.height<=0){this._isAttached=!1;return}let e=Kd(this._terminal,this._optionsService.rawOptions,this._themeService.colors,this.dimensions.device.cell.width,this.dimensions.device.cell.height,this.dimensions.device.char.width,this.dimensions.device.char.height,this._coreBrowserService.dpr,this._deviceMaxTextureSize);this._charAtlas!==e&&(this._onChangeTextureAtlas.fire(e.pages[0].canvas),this._charAtlasDisposable.value=ou(xd.forward(e.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas),xd.forward(e.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas))),this._charAtlas=e,this._charAtlas.warmUp(),this._glyphRenderer.value?.setAtlas(this._charAtlas)}_clearModel(e){this._model.clear(),e&&this._glyphRenderer.value?.clear()}clearTextureAtlas(){this._charAtlas?.clearTexture(),this._clearModel(!0),this._requestRedrawViewport()}clear(){this._clearModel(!0);for(let e of this._renderLayers)e.reset(this._terminal);this._cursorBlinkStateManager.value?.restartBlinkAnimation(),this._updateCursorBlink()}renderRows(e,t){if(!this._isAttached){if(this._core.screenElement?.isConnected&&this._charSizeService.width&&this._charSizeService.height)this._updateDimensions(),this._refreshCharAtlas(),this._isAttached=!0;else return}for(let n of this._renderLayers)n.handleGridChanged(this._terminal,e,t);!this._glyphRenderer.value||!this._rectangleRenderer.value||(this._glyphRenderer.value.beginFrame()?(this._clearModel(!0),this._updateModel(0,this._terminal.rows-1)):this._updateModel(e,t),this._rectangleRenderer.value.renderBackgrounds(),this._glyphRenderer.value.render(this._model),(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible)&&this._rectangleRenderer.value.renderCursor())}_updateCursorBlink(){this._coreService.decPrivateModes.cursorBlink??this._terminal.options.cursorBlink?this._cursorBlinkStateManager.value=new Yd(()=>{this._requestRedrawCursor()},this._coreBrowserService):this._cursorBlinkStateManager.clear(),this._requestRedrawCursor()}_updateModel(e,t){let n=this._core,r=this._workCell,i,a,o,s,c,l,u=0,d=!0,f,p,m,h,g,_,v,y,b;e=Vp(e,n.rows-1,0),t=Vp(t,n.rows-1,0);let x=this._coreService.decPrivateModes.cursorStyle??n.options.cursorStyle??`block`,S=this._terminal.buffer.active.baseY+this._terminal.buffer.active.cursorY,ee=S-n.buffer.ydisp,C=Math.min(this._terminal.buffer.active.cursorX,n.cols-1),w=-1,T=this._coreService.isCursorInitialized&&!this._coreService.isCursorHidden&&(!this._cursorBlinkStateManager.value||this._cursorBlinkStateManager.value.isCursorVisible);this._model.cursor=void 0;let E=!1;for(a=e;a<=t;a++)for(o=a+n.buffer.ydisp,s=n.buffer.lines.get(o),this._model.lineLengths[a]=0,m=S===o,u=0,c=this._characterJoinerService.getJoinedCharacters(o),y=0;y=u,f=y,c.length>0&&y===c[0][0]&&d){p=c.shift();let e=this._model.selection.isCellSelected(this._terminal,p[0],o);for(v=p[0]+1;v=p[1],d?(l=!0,r=new Bp(r,s.translateToString(!0,p[0],p[1]),p[1]-p[0]),f=p[1]-1):u=p[1]}if(h=r.getChars(),g=r.getCode(),v=(a*n.cols+y)*hf,this._cellColorResolver.resolve(r,y,o,this.dimensions.device.cell.width),T&&o===S&&(y===C&&(this._model.cursor={x:C,y:ee,width:r.getWidth(),style:this._coreBrowserService.isFocused?x:n.options.cursorInactiveStyle,cursorWidth:n.options.cursorWidth,dpr:this._devicePixelRatio},w=C+r.getWidth()-1),y>=C&&y<=w&&(this._coreBrowserService.isFocused&&x===`block`||this._coreBrowserService.isFocused===!1&&n.options.cursorInactiveStyle===`block`)&&(this._cellColorResolver.result.fg=50331648|this._themeService.colors.cursorAccent.rgba>>8&16777215,this._cellColorResolver.result.bg=50331648|this._themeService.colors.cursor.rgba>>8&16777215)),g!==0&&(this._model.lineLengths[a]=y+1),(this._model.cells[v]!==g||this._model.cells[v+gf]!==this._cellColorResolver.result.bg||this._model.cells[v+_f]!==this._cellColorResolver.result.fg||this._model.cells[v+vf]!==this._cellColorResolver.result.ext)&&(E=!0,h.length>1&&(g|=yf),this._model.cells[v]=g,this._model.cells[v+gf]=this._cellColorResolver.result.bg,this._model.cells[v+_f]=this._cellColorResolver.result.fg,this._model.cells[v+vf]=this._cellColorResolver.result.ext,_=r.getWidth(),this._glyphRenderer.value.updateCell(y,a,g,this._cellColorResolver.result.bg,this._cellColorResolver.result.fg,this._cellColorResolver.result.ext,h,_,i),l)){for(r=this._workCell,y++;y<=f;y++)b=(a*n.cols+y)*hf,this._glyphRenderer.value.updateCell(y,a,0,0,0,0,yu,0,0),this._model.cells[b]=0,this._model.cells[b+gf]=this._cellColorResolver.result.bg,this._model.cells[b+_f]=this._cellColorResolver.result.fg,this._model.cells[b+vf]=this._cellColorResolver.result.ext;y--}}E&&this._rectangleRenderer.value.updateBackgrounds(this._model),this._rectangleRenderer.value.updateCursor(this._model)}_updateDimensions(){!this._charSizeService.width||!this._charSizeService.height||(this.dimensions.device.char.width=Math.floor(this._charSizeService.width*this._devicePixelRatio),this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*this._devicePixelRatio),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.top=this._optionsService.rawOptions.lineHeight===1?0:Math.round((this.dimensions.device.cell.height-this.dimensions.device.char.height)/2),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.char.left=Math.floor(this._optionsService.rawOptions.letterSpacing/2),this.dimensions.device.canvas.height=this._terminal.rows*this.dimensions.device.cell.height,this.dimensions.device.canvas.width=this._terminal.cols*this.dimensions.device.cell.width,this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/this._devicePixelRatio),this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/this._devicePixelRatio),this.dimensions.css.cell.height=this.dimensions.device.cell.height/this._devicePixelRatio,this.dimensions.css.cell.width=this.dimensions.device.cell.width/this._devicePixelRatio)}_setCanvasDevicePixelDimensions(e,t){this._canvas.width===e&&this._canvas.height===t||(this._canvas.width=e,this._canvas.height=t,this._requestRedrawViewport())}_requestRedrawViewport(){this._onRequestRedraw.fire({start:0,end:this._terminal.rows-1})}_requestRedrawCursor(){let e=this._terminal.buffer.active.cursorY;this._onRequestRedraw.fire({start:e,end:e})}},Bp=class extends gd{constructor(e,t,n){super(),this.content=0,this.combinedData=``,this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=n}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw Error(`not implemented`)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}};function Vp(e,t,n=0){return Math.max(Math.min(e,t),n)}var Hp=`di$target`,Up=`di$dependencies`,Wp=new Map;function Gp(e){if(Wp.has(e))return Wp.get(e);let t=function(e,n,r){if(arguments.length!==3)throw Error(`@IServiceName-decorator can only be used to decorate a parameter`);Kp(t,e,r)};return t._id=e,Wp.set(e,t),t}function Kp(e,t,n){t[Hp]===t?t[Up].push({id:e,index:n}):(t[Up]=[{id:e,index:n}],t[Hp]=t)}Gp(`BufferService`),Gp(`CoreMouseService`),Gp(`CoreService`),Gp(`CharsetService`),Gp(`InstantiationService`),Gp(`LogService`);var qp=Gp(`OptionsService`);Gp(`OscLinkService`),Gp(`UnicodeService`),Gp(`DecorationService`);var Jp={trace:0,debug:1,info:2,warn:3,error:4,off:5},Yp=`xterm.js: `,Xp=class extends uu{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange(`logLevel`,()=>this._updateLogLevel())),Zp=this}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=Jp[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;tthis.activate(e)));return}this._terminal=e;let n=t.coreService,r=t.optionsService,i=t,a=i._renderService,o=i._characterJoinerService,s=i._charSizeService,c=i._coreBrowserService,l=i._decorationService;i._logService;let u=i._themeService;this._renderer=this._register(new zp(e,o,s,c,n,l,r,u,this._preserveDrawingBuffer)),this._register(xd.forward(this._renderer.onContextLoss,this._onContextLoss)),this._register(xd.forward(this._renderer.onChangeTextureAtlas,this._onChangeTextureAtlas)),this._register(xd.forward(this._renderer.onAddTextureAtlasCanvas,this._onAddTextureAtlasCanvas)),this._register(xd.forward(this._renderer.onRemoveTextureAtlasCanvas,this._onRemoveTextureAtlasCanvas)),a.setRenderer(this._renderer),this._register(su(()=>{if(this._terminal._core._store._isDisposed)return;let t=this._terminal._core._renderService;t.setRenderer(this._terminal._core._createRenderer()),t.handleResize(e.cols,e.rows)}))}get textureAtlas(){return this._renderer?.textureAtlas}clearTextureAtlas(){this._renderer?.clearTextureAtlas()}},$p=250;function em(e){return e.type===`keydown`&&e.ctrlKey&&!e.altKey&&!e.metaKey&&(e.code===`KeyL`||e.key===`l`||e.key===`L`)}var tm=class{seen=null;noteKey(e,t){em(e)&&(this.seen={at:t,trusted:e.isTrusted,repeat:e.repeat,code:e.code})}report(e,t){if(!e.includes(`\f`))return null;let n=this.seen;return this.seen=null,!n||t-n.at>$p||t{let e=um;e!==null&&cm(e).then(n=>{n&&um===e&&(um=null,te(t))})}}})}function fm(e,t=250){let n=null,r=0,i=null,a=null,o=()=>{a!==null&&clearTimeout(a),a=null},s=t=>{n=t,r=Date.now(),e(t)},c=()=>{if(a=null,i===null)return;let e=i;i=null,e!==n&&s(e)};return{push(e){if(e===n){i=null,o();return}let l=Date.now()-r;r===0||l>=t?(i=null,o(),s(e)):(i=e,a===null&&(a=setTimeout(c,t-l)))},cancel(){o(),i=null}}}function pm(e,t){let n;try{n=t()}catch{return!1}let r=n.onContextLoss(()=>n.dispose());try{e.loadAddon(n)}catch{return r.dispose(),n.dispose(),!1}return!0}var mm=new Set([20,229,16,17,18]);function hm(e){let t=e.parentElement;if(!t)return{dispose(){},noteKeyPassedToXterm(){}};let n=!1,r=0,i,a=()=>{i!==void 0&&clearTimeout(i),i=void 0},o=t=>{t.target===e&&(r++,n=!0,a())},s=t=>{if(t.target!==e||!n)return;let a=r;i=setTimeout(()=>{i=void 0,r===a&&(n=!1)},0)},c=t=>{let r=t;n&&t.target===e&&r.inputType===`insertText`&&t.stopImmediatePropagation()};return t.addEventListener(`compositionstart`,o),t.addEventListener(`compositionend`,s),t.addEventListener(`input`,c,!0),{noteKeyPassedToXterm(e){e.type===`keydown`&&!mm.has(e.keyCode)&&n&&(r++,n=!1,a())},dispose(){n=!1,r++,a(),t.removeEventListener(`compositionstart`,o),t.removeEventListener(`compositionend`,s),t.removeEventListener(`input`,c,!0)}}}function gm({panes:e,size:t,zoomed:n,mode:r,screenScale:i,socketRef:a,viewsRef:o,bodyRefs:s,pendingRef:c,replayRef:l,ptySizesRef:u,consumeLatches:d,setTitles:f}){let p=(0,j.useRef)(new Map);(0,j.useEffect)(()=>{let e=p.current;return()=>e.forEach(e=>e.cancel())},[]),(0,j.useEffect)(()=>{let t=fl(i);for(let n of e){let e=o.current.get(n);if(e){e.term.options.fontSize!==t.fontSize&&(e.term.options.fontSize=t.fontSize),e.term.options.fontFamily!==t.fontFamily&&(e.term.options.fontFamily=t.fontFamily);continue}let r=s.current.get(n);if(!r)continue;let i=new cl({...t,theme:{background:`#111112`,foreground:`#f2f2f3`},cursorBlink:!0,macOptionIsMeta:!1,macOptionClickForcesSelection:!0}),m=new dl;i.loadAddon(m);let h=new tm,g=null;i.attachCustomKeyEventHandler(e=>{if(h.noteKey(e,performance.now()),im(e,navigator.platform))return!1;let t=rm(e);return t===null?(g?.noteKeyPassedToXterm(e),!0):(i.input(t),!1)}),i.onData(e=>{let t=h.report(e,performance.now()),r=d(e);Ee(a.current,{type:`input`,pane:n,data:r})&&t&&Ee(a.current,{type:`clear_key_report`,pane:n,...t})});let _=pt(i,l.current.panes.has(n),e=>{sm(e).catch(e=>{console.error(`nightcrow: a pane's clipboard request failed`,e)})}),v=fm(e=>{f(t=>t[n]===e?t:{...t,[n]:e})});p.current.set(n,v),i.onTitleChange(e=>{let t=e.replace(/\s+/g,` `).trim();t&&v.push(t)}),i.open(r),i.textarea&&(g=hm(i.textarea),i.loadAddon({activate(){},dispose(){g?.dispose()}})),pm(i,()=>new Qp);let y=u.current.get(n);y&&i.resize(y.cols,y.rows);let b={term:i,fit:m,replayGate:_};o.current.set(n,b);let x=c.current.get(n);if(x){for(let e of x)e instanceof Uint8Array?ct(i,e):dt(i,b.replayGate,()=>{o.current.get(n)===b&&l.current.panes.get(n)===e.token&&l.current.panes.delete(n)});c.current.delete(n),lt(i,()=>i.scrollToBottom())}}for(let[t,n]of o.current)e.includes(t)||(p.current.get(t)?.cancel(),p.current.delete(t),ut(n.term),n.term.dispose(),o.current.delete(t))},[e,t,n,r,i,a,o,s,c,l,u,d,f])}function _m({repo:e,refs:t,size:n,mode:r,panes:i,active:a,replayLeft:o,pending:s,ownsSize:c,keyboardOpen:l,screenScale:u,refitEpoch:d,zoomShown:f,zoomServer:p,consumeLatches:m,setLink:h,setPending:g,setReplayLeft:_,setPanes:v,setActive:y,setZoomed:b,setTitles:x,setOwnsSize:S,onSizeAcquired:ee,setRecovery:C}){let{containerRef:w,socketRef:T,viewsRef:E,bodyRefs:te,ptySizesRef:D,askedSizesRef:ne,desiredSizesRef:re,ownsSizeRef:ie,sizeOwnerGenerationRef:O,pendingRef:k,replayRef:A,zoomAskedRef:ae,slotRefs:oe}=t;kl({repo:e,socketRef:T,viewsRef:E,pendingRef:k,replayRef:A,ptySizesRef:D,askedSizesRef:ne,desiredSizesRef:re,ownsSizeRef:ie,sizeOwnerGenerationRef:O,zoomAskedRef:ae,setLink:h,setPending:g,setReplayLeft:_,setPanes:v,setActive:y,setZoomed:b,setTitles:x,setOwnsSize:S,onSizeAcquired:ee,setRecovery:C}),Bl({containerRef:w,socketRef:T,viewsRef:E}),gm({panes:i,size:n,zoomed:f,mode:r,screenScale:u,socketRef:T,viewsRef:E,bodyRefs:te,pendingRef:k,replayRef:A,ptySizesRef:D,consumeLatches:m,setTitles:x});let se=(0,j.useCallback)(()=>g(null),[g]);pl({pending:s,size:n,screenScale:u,socketRef:T,slotRefs:oe,panesExist:i.length>0,onAnswered:se}),St({panes:i,size:n,zoomed:f,mode:r,screenScale:u,socketRef:T,viewsRef:E,bodyRefs:te,ptySizesRef:D,askedSizesRef:ne,desiredSizesRef:re,ownsSize:c,layoutPending:Ge(p,i),keyboardOpen:l,refitEpoch:d}),yt({panes:i,viewsRef:E,bodyRefs:te,keyboardOpen:l,size:n,zoomed:f,mode:r}),bt({repo:e,panes:i,replayLeft:o,active:a,setActive:y,zoomed:p,zoom:f,viewsRef:E,panelRef:w,size:n,mode:r})}var vm=()=>bm(ze),ym=()=>bm(Be);function bm(e){let[t,n]=(0,j.useState)(!1),r=(0,j.useRef)(!1),i=(0,j.useCallback)(e=>{r.current=e,n(e)},[]),a=(0,j.useCallback)(t=>{let n=e(r.current,t);return n.armed!==r.current&&i(n.armed),n.data},[e,i]);return{armed:t,toggle:(0,j.useCallback)(()=>{let e=!r.current;return i(e),e},[i]),clear:(0,j.useCallback)(()=>i(!1),[i]),consume:a}}function xm(e){let[t,n]=(0,j.useState)({w:0,h:0});return(0,j.useEffect)(()=>{let t=e.current;if(!t)return;let r=new ResizeObserver(()=>{let e=t.clientWidth,r=t.clientHeight;n(t=>t.w===e&&t.h===r?t:{w:e,h:r})});return r.observe(t),()=>r.disconnect()},[e]),t}function Sm(e=window){return(0,j.useSyncExternalStore)(t=>Cm(e,t),()=>x(e)>0,()=>!1)}function Cm(e,t){let n=e.visualViewport;return e.addEventListener(`resize`,t),n?.addEventListener(`resize`,t),n?.addEventListener(`scroll`,t),()=>{e.removeEventListener(`resize`,t),n?.removeEventListener(`resize`,t),n?.removeEventListener(`scroll`,t)}}function wm({link:e,panes:t,replayLeft:n,pending:r}){return e===`live`?n>0?{kind:`attaching`,left:n}:t>0?{kind:`ready`}:r===null?{kind:`empty`}:{kind:`starting`,count:r}:{kind:e}}function Tm(e){switch(e.kind){case`connecting`:return`Connecting…`;case`reconnecting`:return`Reconnecting…`;case`attaching`:return`Attaching ${Em(e.left)}…`;case`starting`:return`Starting ${Em(e.count)}…`;case`empty`:case`ready`:return null}}function Em(e){return`${e} terminal${e===1?``:`s`}`}var $=e();function Dm({status:e}){if(e.kind===`empty`)return(0,$.jsxs)(`p`,{className:`p-3 text-ink-400`,children:[`No terminal open. Press `,(0,$.jsx)(`span`,{className:`text-accent`,children:`+`}),` above to start one.`]});let t=e.kind===`starting`?null:Tm(e);return t?(0,$.jsx)(`div`,{role:`status`,className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center p-6`,children:(0,$.jsxs)(`span`,{className:`flex animate-pulse items-center gap-2 rounded-md bg-ink-950/80 px-3 py-2 text-caption text-ink-400 uppercase`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-accent`}),t]})}):null}var Om=100;function km({socketRef:e,viewsRef:t,active:n,panes:r,onSent:i}){let[a,o]=(0,j.useState)(null),[s,c]=(0,j.useState)({}),[l,u]=(0,j.useState)(!1),d=(0,j.useRef)(null),f=(0,j.useRef)(r),p=(0,j.useRef)(0),m=(0,j.useRef)(!1);f.current=r;let h=a!==null&&r.includes(a)?a:null,g=h===null?``:s[h]??``,_=()=>{p.current+=1,m.current=!1,u(!1)};(0,j.useEffect)(()=>()=>{p.current+=1,m.current=!1,d.current=null},[]),(0,j.useEffect)(()=>{a!==null&&!r.includes(a)&&(d.current=null,_(),o(null))},[a,r]);let v=e=>{h!==null&&c(t=>({...t,[h]:e}))};return{target:h,draft:g,setDraft:v,open:()=>{d.current===null&&n!==null&&(_(),d.current=n,o(n))},close:()=>{d.current=null,_(),o(null)},send:()=>{if(h===null||m.current||!Pl(g))return!1;let n=t.current.get(h)?.term.modes.bracketedPasteMode??!1,r=Nl(g,n);return Ee(e.current,{type:`input`,pane:h,data:r})?(window.setTimeout(()=>{Ee(e.current,{type:`input`,pane:h,data:`\r`})},Om),v(``),d.current=null,_(),o(null),i(h),!0):!1},attachImage:async e=>{if(h===null||m.current)return;if(!Il.includes(e.type)){b.error(`Choose a PNG, JPEG, GIF, or WebP image.`);return}if(e.size>10485760){b.error(`Image must be 10 MiB or smaller.`);return}let t=h,n=p.current,r=()=>n===p.current&&d.current===t&&f.current.includes(t);m.current=!0,u(!0);try{let n=await _e.pasteImage(e);if(!n)throw Error(`the server returned no image path`);if(!r())return;c(e=>{let r=e[t]??``,i=r.length>0&&!/\s$/.test(r)?` `:``;return{...e,[t]:`${r}${i}${Rl(n)}`}})}catch(e){r()&&b.error(e instanceof Error?`Could not attach image: ${e.message}`:`Could not attach image.`)}finally{r()&&(m.current=!1,u(!1))}},uploading:l}}var Am=ge();function jm(){let e=window,t=e.SpeechRecognition??e.webkitSpeechRecognition;return t?()=>new t:null}function Mm(e,t){return t?e?`ready`:`insecure`:`unsupported`}function Nm(e){let t=``;for(let n=e.resultIndex;n{i.current?.stop()},[]),s=(0,j.useCallback)(()=>{if(!e||i.current)return;let t;try{t=e()}catch{Lm(`unavailable`);return}t.lang=navigator.language,t.continuous=!1,t.interimResults=!1,t.onresult=e=>{let t=Nm(e);t&&a.current(t)},t.onerror=e=>Lm(e.error),t.onend=()=>{i.current===t&&(i.current=null),r(!1)};try{t.start()}catch{Lm(`start-failed`);return}i.current=t,r(!0)},[e]);return(0,j.useEffect)(()=>()=>{let e=i.current;i.current=null,e&&(e.onend=null,e.onresult=null,e.onerror=null,e.abort())},[]),{listening:n,toggle:n?o:s}}var zm=`flex h-11 w-11 shrink-0 items-center justify-center rounded-sm hover:text-accent`;function Bm({availability:e,factory:t,onText:n}){let{listening:r,toggle:i}=Rm(e===`ready`?t:null,n);if(e===`unsupported`)return null;let a=e===`ready`;return(0,$.jsx)(`button`,{type:`button`,onClick:a?i:void 0,"aria-disabled":!a||void 0,"aria-pressed":a?r:void 0,"aria-label":a?r?`Stop voice input`:`Voice input`:`Voice input needs HTTPS`,title:a?r?`Stop voice input`:`Voice input`:Im,className:`${zm} ${r?`animate-pulse text-accent`:a?`text-ink-400`:`text-ink-600`}`,children:(0,$.jsx)(ee,{})})}function Vm(){let[e,t]=(0,j.useState)(null),n=(0,j.useRef)(new Map);return(0,j.useEffect)(()=>T(e=>{let r=e.filter(e=>e.kind===`error`),i=r.filter(e=>n.current.get(e.id)!==e.bump);n.current=new Map(r.map(e=>[e.id,e.bump])),i.length>0?t(i[i.length-1]):t(e=>e&&n.current.has(e.id)?e:null)}),[]),(0,$.jsx)(`div`,{className:`sr-only`,children:e&&(0,$.jsx)(`p`,{role:`alert`,children:e.message},`${e.id}-${e.bump}`)})}var Hm=`nc-compose-title`;function Um(){let e=navigator;return e.userAgentData?.platform||e.platform||``}function Wm({label:e,draft:t,onChange:n,onSend:r,onAttachImage:i,uploading:a,onClose:o,dictation:s}){let c=(0,j.useRef)(null),l=(0,j.useRef)(null),[u,d]=(0,j.useState)(!1),f=Pl(t)&&!a,p=Fl(Um()),[m]=(0,j.useState)(()=>{if(s)return s;let e=jm();return{availability:Mm(window.isSecureContext,e),factory:e}});(0,j.useEffect)(()=>{let e=c.current;e?.focus(),e?.setSelectionRange(e.value.length,e.value.length)},[]),(0,j.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!e.isComposing&&o()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o]);let h=()=>{f&&d(!r())};return(0,Am.createPortal)((0,$.jsx)(`div`,{className:`nc-fade-in fixed inset-0 z-50 flex items-start justify-center bg-black/60 p-4 pt-[8vh]`,onClick:o,children:(0,$.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":Hm,className:`nc-rise-in flex w-[56rem] max-w-full flex-col rounded-lg border border-ink-700 bg-ink-900`,onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(Vm,{}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-ink-700 px-3 py-2`,children:[(0,$.jsxs)(`span`,{id:Hm,className:`min-w-0 truncate font-medium text-ink-50`,children:[`Send to `,e]}),(0,$.jsx)(`button`,{type:`button`,onClick:o,"aria-label":`close`,className:`ml-auto flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-ink-200`,children:(0,$.jsx)(O,{})})]}),(0,$.jsx)(`textarea`,{ref:c,value:t,onChange:e=>{n(e.target.value),d(!1)},onKeyDown:e=>{e.key!==`Enter`||e.nativeEvent.isComposing||(e.metaKey||e.ctrlKey)&&(e.preventDefault(),h())},rows:8,"aria-label":`message`,className:`m-3 resize-none overflow-y-auto rounded-sm border border-ink-700 bg-ink-950 p-2 font-mono text-[16px] text-ink-50 focus:border-accent focus:outline-none`}),(0,$.jsx)(`input`,{ref:l,type:`file`,accept:Il.join(`,`),"aria-label":`Choose an image`,tabIndex:-1,className:`hidden`,onChange:e=>{let t=e.currentTarget.files?.[0];e.currentTarget.value=``,t&&i(t)}}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-3 pb-3`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>l.current?.click(),disabled:a,"aria-label":`Attach image`,title:`Attach image`,className:`${zm} text-ink-400 disabled:text-ink-600 disabled:hover:text-ink-600`,children:(0,$.jsx)(ae,{})}),(0,$.jsx)(Bm,{availability:m.availability,factory:m.factory,onText:e=>{n(Pm(t,e)),d(!1)}}),a&&(0,$.jsx)(`span`,{role:`status`,"aria-live":`polite`,className:`text-ink-300`,children:`Uploading image…`}),u&&(0,$.jsx)(`span`,{role:`alert`,className:`min-w-0 basis-full truncate text-removed`,children:`Not connected — nothing was sent.`}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>{n(``),d(!1),c.current?.focus()},disabled:t.length===0,className:`min-h-11 rounded-sm px-3 text-ink-200 hover:text-ink-50 disabled:text-ink-600`,children:`Clear`}),(0,$.jsxs)(`button`,{type:`button`,onClick:h,disabled:!f,title:`Send and run (${p})`,"aria-keyshortcuts":`Meta+Enter Control+Enter`,className:`flex min-h-11 items-center gap-1.5 rounded-sm bg-accent px-3 py-1.5 font-medium text-ink-950 disabled:bg-ink-700 disabled:text-ink-400`,children:[(0,$.jsx)(`kbd`,{"aria-hidden":`true`,className:`font-sans opacity-70`,children:p}),`Send`]})]})]})]})}),document.body)}function Gm({closing:e,panes:t,paneLabel:n,onConfirmClose:r,onCancelClose:i,compose:a}){return(0,$.jsxs)($.Fragment,{children:[e!==null&&t.includes(e)&&(0,$.jsx)(fe,{label:n(e),detail:`The process running in it will be terminated.`,onConfirm:()=>r(e),onCancel:i}),a.target!==null&&(0,$.jsx)(Wm,{label:n(a.target),draft:a.draft,onChange:a.setDraft,onSend:a.send,onAttachImage:a.attachImage,uploading:a.uploading,onClose:a.close})]})}function Km({report:e,pane:t,onCancel:n}){let r=t===void 0?Tl(e):`pane ${t} · ${Tl(e)}`;return(0,$.jsxs)(`span`,{className:`flex min-w-0 shrink items-center gap-1 rounded-sm bg-ink-800 px-1 text-accent`,title:e.detail??r,children:[(0,$.jsx)(`span`,{className:`truncate`,children:r}),e.detail&&(0,$.jsx)(`span`,{className:`hidden min-w-0 truncate text-ink-400 md:inline`,children:e.detail}),(0,$.jsx)(`button`,{onMouseDown:e=>e.stopPropagation(),onClick:n,title:`Stop waiting and release this pane's slot`,"aria-label":`cancel recovery${t===void 0?``:` for pane ${t}`}`,className:`flex h-5 w-5 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-removed`,children:(0,$.jsx)(O,{className:`h-3 w-3`})})]})}function qm({pane:e,index:t,label:n,cellStyle:r,isActive:i,isZoomed:a,showZoom:o,isDragged:s,isDropTarget:d,reorderable:f,showHeader:p,recovery:m,onCancelRecovery:h,onFocus:g,onToggleZoom:_,onClose:v,onPaneDragStart:y,onPaneDragMove:b,onPaneDragEnd:x,onPaneDragCancel:S,bodyRef:ee,bodyTouch:C}){let w=u(),T=(e,t)=>i?w(e,t):{title:t};return(0,$.jsxs)(`div`,{"data-pane-id":e,"data-pane-cell":!0,onMouseDown:g,style:r,className:`nc-cell-in relative min-h-0 min-w-0 flex-col overflow-hidden rounded-sm border ${d?`border-accent ring-1 ring-accent`:i?`border-accent`:`border-ink-700`} ${s?`opacity-60`:``}`,children:[!p&&m&&(0,$.jsx)(`div`,{className:`absolute top-1 right-1 z-10 text-xs`,children:(0,$.jsx)(Km,{report:m,onCancel:h})}),p&&(0,$.jsxs)(`div`,{onPointerDown:y,onPointerMove:b,onPointerUp:x,onPointerCancel:S,"data-active":i,className:`nc-title-target flex shrink-0 items-center gap-1 select-none bg-ink-900 px-2 py-0.5 text-xs ${f?s?`cursor-grabbing touch-none`:`cursor-grab touch-none`:``}`,children:[(0,$.jsx)(`span`,{title:n,className:`min-w-0 flex-1 ${i?`text-ink-50`:`text-ink-400`}`,children:(0,$.jsx)(c,{title:n})}),m&&(0,$.jsx)(Km,{report:m,onCancel:h}),o&&(0,$.jsx)(`button`,{onMouseDown:e=>e.stopPropagation(),onClick:_,"aria-pressed":a,...T(`view.toggleMaximize`,a?`Restore the grid`:`Zoom this terminal`),"aria-label":a?`Restore the grid`:`Zoom this terminal`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-accent md:h-6 md:w-6`,children:(0,$.jsx)(l,{maximized:a})}),(0,$.jsx)(`button`,{onMouseDown:e=>e.stopPropagation(),onClick:v,...T(`terminal.closePane`,`Close terminal`),"aria-label":`close terminal ${t+1}`,className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-removed md:h-6 md:w-6`,children:(0,$.jsx)(O,{})})]}),(0,$.jsx)(`div`,{ref:ee,...C,className:`nc-pane-body flex min-h-0 flex-1 flex-col justify-end overflow-hidden touch-pinch-zoom`})]})}function Jm({count:e,slotStyle:t,showHeader:n,bodyTouch:r,slotRefs:i}){return Array.from({length:e},(e,a)=>(0,$.jsx)(qm,{pane:-1-a,index:a,label:`starting…`,cellStyle:t(a),isActive:!1,isZoomed:!1,showZoom:!1,isDragged:!1,isDropTarget:!1,reorderable:!1,showHeader:n,bodyTouch:r,onCancelRecovery:()=>{},onFocus:()=>{},onToggleZoom:()=>{},onClose:()=>{},onPaneDragStart:()=>{},onPaneDragMove:()=>{},onPaneDragEnd:()=>{},onPaneDragCancel:()=>{},bodyRef:e=>{e?i.current.set(a,e):i.current.delete(a)}},`slot-${a}`))}function Ym(e,t){let n=(0,j.useRef)(t);(0,j.useLayoutEffect)(()=>{n.current!==t&&(n.current=t,Pe(e.current))},[e,t])}function Xm({containerRef:e,mode:t,panes:n,titles:r,active:i,shown:a,layout:o,pending:s,maximized:c=!1,recovery:l,draggingPane:u,dragOverPane:d,reorderable:f,bodyTouch:p,slotRefs:m,bodyRefs:h,onFocus:g,onToggleZoom:_,onClose:v,onCancelRecovery:y,onPaneDragStart:b,onPaneDragMove:x,onPaneDragEnd:S,onPaneDragCancel:ee}){let C=t===`tabs`;Ym(e,`${t}:${a}:${o.cols}x${o.rows}:${c}`);let w=e=>{let t=o.cells[e];return{display:`flex`,gridColumn:`${t.colStart} / span ${t.colSpan}`,gridRow:`${t.row}`}},T=(e,t)=>C?E(e===a):a===null?w(t):{display:e===a?`flex`:`none`};return(0,$.jsxs)(`div`,{ref:e,className:C?ue:`grid h-full gap-1`,style:C?void 0:a===null?{gridTemplateColumns:`repeat(${o.cols}, minmax(0, 1fr))`,gridTemplateRows:`repeat(${o.rows}, minmax(0, 1fr))`}:{gridTemplateColumns:`1fr`,gridTemplateRows:`1fr`},children:[n.length===0&&s!==null&&(0,$.jsx)(Jm,{count:s,showHeader:!C,bodyTouch:p,slotStyle:e=>C?E(e===0):w(e),slotRefs:m}),n.map((e,t)=>(0,$.jsx)(qm,{pane:e,index:t,label:r[e]??`term ${t+1}`,cellStyle:T(e,t),isActive:e===i,isZoomed:!C&&a===e,showZoom:!C&&n.length>1,isDragged:u===e,isDropTarget:d===e,reorderable:f,showHeader:!C,bodyTouch:p,recovery:l[e],onCancelRecovery:()=>y(e),onFocus:()=>g(e),onToggleZoom:()=>_(e),onClose:()=>v(e),onPaneDragStart:t=>b(t,e),onPaneDragMove:x,onPaneDragEnd:S,onPaneDragCancel:ee,bodyRef:t=>{t?h.current.set(e,t):h.current.delete(e)}},e))]})}function Zm({panes:e,titles:t,shown:n,reorderable:r,draggingPane:i,dragOverPane:a,onClose:o,onPaneDragStart:s,onPaneDragMove:l,onPaneDragEnd:u,onPaneDragCancel:d}){let f=(0,j.useRef)(new Map);(0,j.useEffect)(()=>{n!==null&&f.current.get(n)?.scrollIntoView({block:`nearest`,inline:`nearest`})},[n,e.length]);let p=(0,j.useRef)(null),m=(0,j.useRef)(!1);return(0,j.useEffect)(()=>{m.current=i!==null},[i]),(0,j.useEffect)(()=>{let e=p.current;if(!e)return;let t=e=>{m.current&&e.cancelable&&e.preventDefault()};return e.addEventListener(`touchmove`,t,{passive:!1}),()=>e.removeEventListener(`touchmove`,t)},[]),(0,$.jsx)(`div`,{ref:p,role:`tablist`,"aria-label":`Terminals`,className:`-my-1 flex min-w-0 flex-1 items-stretch self-stretch overflow-x-auto`,children:e.map((e,p)=>{let m=t[e]??`term ${p+1}`,h=e===n;return(0,$.jsxs)(`div`,{"data-pane-id":e,ref:t=>{t?f.current.set(e,t):f.current.delete(e)},role:`tab`,"aria-selected":h,title:m,onPointerDown:t=>s(t,e,{holdToDrag:!0}),onPointerMove:l,onPointerUp:u,onPointerCancel:d,onLostPointerCapture:d,className:`nc-title-target flex shrink-0 touch-pan-x items-center border-r border-ink-700 whitespace-nowrap select-none [-webkit-touch-callout:none] ${r?`cursor-grab`:``} ${i===e?`opacity-60`:``} ${a===e?`bg-ink-800 ring-1 ring-inset ring-accent`:``} ${h?`bg-ink-950 text-ink-50 shadow-[inset_0_-1px_0_0_var(--color-accent)]`:`text-ink-400 hover:bg-ink-850 hover:text-ink-200`}`,children:[(0,$.jsx)(`span`,{className:`flex min-w-0 items-center self-stretch pr-1 pl-3`,children:(0,$.jsx)(c,{title:m,className:_})}),(0,$.jsx)(`button`,{onPointerDown:e=>e.stopPropagation(),onClick:t=>{t.stopPropagation(),o(e)},"data-tab-close":!0,title:`Close terminal`,"aria-label":`close terminal ${p+1}`,className:`mr-1 flex h-5 w-5 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:bg-ink-700 hover:text-removed`,children:(0,$.jsx)(O,{className:`h-3.5 w-3.5`})})]},e)})})}var Qm=`flex min-h-9 min-w-9 shrink-0 items-center justify-center rounded-xs border px-2 text-xs active:bg-ink-700 active:text-accent`,$m=`border-ink-700 bg-ink-850 text-ink-200`,eh=`border-accent bg-ink-700 text-accent`;function th({onKey:e,ctrl:t,alt:n,onArm:r}){(0,j.useEffect)(()=>t.clear,[t.clear]),(0,j.useEffect)(()=>n.clear,[n.clear]);let i=()=>{t.clear(),n.clear()};return(0,$.jsx)(`div`,{className:`flex shrink-0 items-stretch gap-1 overflow-x-auto border-t border-chrome-line bg-ink-900 px-1 py-1`,children:Ue.map(a=>a.kind===`latch`?(0,$.jsx)(nh,{latch:a.latch===`ctrl`?t:n,label:a.label,aria:a.aria,onArm:r},a.latch):(0,$.jsx)(`button`,{onPointerDown:e=>e.preventDefault(),onClick:()=>{i(),e(a.key)},"aria-label":a.aria,className:`${Qm} ${$m}`,children:a.label},a.key))})}function nh({latch:e,label:t,aria:n,onArm:r}){return(0,$.jsx)(`button`,{onPointerDown:e=>e.preventDefault(),onClick:()=>{e.toggle()&&r()},"aria-pressed":e.armed,"aria-label":n,className:`${Qm} ${e.armed?eh:$m}`,children:t})}function rh(e){return{lastY:e,pending:0,scrolling:!1}}function ih(e,t){let n=e.pending+(e.lastY-t);return Math.abs(n)<50?{next:{...e,lastY:t,pending:n},deltaY:0}:{next:{lastY:t,pending:0,scrolling:!0},deltaY:n}}function ah({viewsRef:e,bodyRefs:t}){let n=(0,j.useRef)(null),r=(0,j.useRef)(null),i=(0,j.useCallback)(()=>{n.current=null,r.current=null},[]),a=(0,j.useCallback)(e=>{e.pointerType===`touch`&&(n.current===null?(n.current=e.pointerId,r.current=rh(e.clientY)):i())},[i]),o=(0,j.useCallback)(i=>{if(i.pointerId!==n.current)return;let a=r.current;if(!a)return;let{next:o,deltaY:s}=ih(a,i.clientY);if(r.current=o,s===0)return;i.preventDefault();let c=i.currentTarget;sh(c,i,s,oh(c,e,t))},[e,t]),s=(0,j.useCallback)(e=>{e.pointerId===n.current&&i()},[i]);return{onPointerDown:a,onPointerMove:o,onPointerUp:s,onPointerCancel:s}}function oh(e,t,n){for(let[r,i]of n.current)if(i===e)return t.current.get(r)}function sh(e,t,n,r){let i=e.querySelector(`.xterm`);if(!i)return;let a=new WheelEvent(`wheel`,{deltaY:n,deltaMode:WheelEvent.DOM_DELTA_PIXEL,clientX:t.clientX,clientY:t.clientY,bubbles:!0,cancelable:!0,view:window});if(i.dispatchEvent(a),a.defaultPrevented||!r)return;let o=r.term.rows,s=o>0?i.clientHeight/o:0;if(s<=0)return;let c=Math.round(n/s);r.term.scrollLines(n<0?Math.min(-1,c):Math.max(1,c))}var ch=`nightcrow.paneViewMode`;function lh(){return w(d(ch))}function uh(e){f(ch,e)}function dh(){return typeof window>`u`?768:window.innerWidth}function fh(){let[e,t]=(0,j.useState)(lh),[n,r]=(0,j.useState)(dh);(0,j.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>r(window.innerWidth);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let i=oe(e,n),a=C(n);return{mode:i,toggle:(0,j.useCallback)(()=>{if(!a)return;let e=i===`tabs`?`grid`:`tabs`;uh(e),t(e)},[i,a]),canToggle:a}}var ph=`nightcrow.termKeyBar`,mh=`(pointer: coarse)`;function hh(){return Ve(d(ph))}function gh(e){f(ph,e)}function _h(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(mh).matches}function vh(){return typeof window>`u`?768:window.innerWidth}function yh(){let[e,t]=(0,j.useState)(hh),[n,r]=(0,j.useState)(_h),[i,a]=(0,j.useState)(vh);(0,j.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>a(window.innerWidth);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),(0,j.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(mh),t=()=>r(e.matches);return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let o=e?e===`shown`:He(n,i);return{shown:o,toggle:(0,j.useCallback)(()=>{let e=o?`hidden`:`shown`;gh(e),t(e)},[o])}}function bh({showDivider:e,draggingUpper:t,onUpperDragStart:n,onUpperDragMove:r,onUpperDragEnd:i,onUpperDragCancel:a}){return e?(0,$.jsx)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":`Resize the terminal panel (double-click to reset)`,title:`Drag to resize · double-click to reset`,onPointerDown:n,onPointerMove:r,onPointerUp:i,onPointerCancel:a,onLostPointerCapture:i,className:`absolute -top-px left-0 z-10 hidden h-1.5 w-full cursor-row-resize touch-none md:block ${t?`bg-accent`:`hover:bg-accent`}`}):null}function xh({mode:e,onToggleMode:t,canToggleMode:n,tabs:r,ownsSize:a,maximized:o,keyBarShown:c,recovery:d,panes:f,onCancelRecovery:g,onClaimSize:_,onCreate:v,onCompose:y,onToggleKeyBar:b,onToggleMaximized:x}){let S=u(),ee=(0,j.useRef)(null),C=(0,j.useRef)(f.length);(0,j.useLayoutEffect)(()=>{let e=C.current;C.current=f.length;let t=document.activeElement===null||document.activeElement===document.body;h(f.length,e,t)&&ee.current?.focus()},[f.length]);let w=`flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-accent`;return(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 bg-ink-900 px-2 py-1 text-xs`,children:[Cl(d,f).map(e=>(0,$.jsx)(Km,{pane:e,report:d[e],onCancel:()=>g(e)},e)),r,!a&&(0,$.jsx)(`button`,{onClick:_,...S(`terminal.claimSizing`,`These panes are sized for another client. Resize them to fit this screen.`),"aria-label":`Fit the panes to this screen`,className:`ml-auto ${w}`,children:(0,$.jsx)(p,{})}),(0,$.jsx)(`button`,{ref:ee,onClick:v,...S(`terminal.newPane`,`New terminal`),"aria-label":`New terminal`,className:`${w} ${a?`ml-auto`:``}`,children:(0,$.jsx)(de,{})}),n&&(0,$.jsx)(`button`,{onClick:t,"aria-pressed":e===`tabs`,title:e===`tabs`?`Show the panes side by side`:`Show one pane per tab`,"aria-label":e===`tabs`?`Show the panes side by side`:`Show one pane per tab`,className:w,children:e===`tabs`?(0,$.jsx)(m,{}):(0,$.jsx)(i,{})}),f.length>0&&(0,$.jsx)(`button`,{onClick:y,...S(`terminal.composeMessage`,`Write a message to the active terminal`),"aria-label":`Write a message to the active terminal`,className:w,children:(0,$.jsx)(re,{})}),f.length>0&&(0,$.jsx)(`button`,{onClick:b,"aria-pressed":c,title:c?`Hide the key bar`:`Show the key bar`,"aria-label":c?`Hide the key bar`:`Show the key bar`,className:`${w} ${c?`text-accent`:``}`,children:(0,$.jsx)(s,{})}),(0,$.jsx)(`button`,{onClick:x,"aria-pressed":o,...S(`view.toggleMaximize`,o?`Restore panel height`:`Maximize the panel`),"aria-label":o?`Restore panel height`:`Maximize the panel`,className:`hidden md:flex ${w}`,children:(0,$.jsx)(l,{maximized:o})})]})}function Sh({repo:e,maximized:t,onToggleMaximized:n,className:r=``,sectionRef:i,...a}){let o=ht(),{containerRef:s,socketRef:c,viewsRef:l,bodyRefs:u,zoomAskedRef:d,slotRefs:f}=o,{pending:p,setPending:m,link:h,setLink:g,replayLeft:_,setReplayLeft:v,panes:y,setPanes:b,active:x,setActive:S,zoomed:ee,setZoomed:C,titles:w,setTitles:T,closing:E,setClosing:te,ownsSize:ne,setOwnsSize:re}=Ze(),O=xm(s),{scale:k}=D(),{refitEpoch:A,forceFit:ae}=Xe(h,c),oe=Sm(),{recovery:ce,setRecovery:le,cancelRecovery:ue}=Oe(c),de=We(ee,y),fe=ah({viewsRef:l,bodyRefs:u}),{mode:pe,toggle:me,canToggle:he}=fh(),ge=yh(),_e=vm(),ve=ym(),ye=_e.consume,Se=ve.consume,Ce=(0,j.useCallback)(e=>Se(ye(e)),[Se,ye]),we=pe===`tabs`,Te=we?null:de,Ee=we?null:ee,De=we?ie(x,y):de;_m({repo:e,refs:o,size:O,mode:pe,panes:y,active:x,replayLeft:_,pending:p,ownsSize:ne,keyboardOpen:oe,screenScale:k,refitEpoch:A,zoomShown:Te,zoomServer:Ee,consumeLatches:Ce,setLink:g,setPending:m,setReplayLeft:v,setPanes:b,setActive:S,setZoomed:C,setTitles:T,setOwnsSize:re,onSizeAcquired:ae,setRecovery:le});let ke=t=>{S(t),se(e,t),l.current.get(t)?.term.focus()},Ae=e=>w[e]||`terminal ${y.indexOf(e)+1}`,je=()=>x!==null&&ke(x),Me=km({socketRef:c,viewsRef:l,active:x,panes:y,onSent:e=>{_e.clear(),ve.clear(),ke(e)}}),Ne=qe({socketRef:c,viewsRef:l,zoomed:de,zoomAskedRef:d,active:x,onForceFit:ae}),{create:Pe,toggleZoom:Fe,claimSize:Ie,closePane:Le,reorder:Re,sendKey:ze}=Ne;gt({socketRef:c,panes:y,active:x,zoom:Te,link:h,commands:Ne,focusPane:ke,cancelRecovery:ue,openCompose:Me.open});let{draggingPane:Be,dragOverPane:Ve,reorderable:He,endPaneDrag:Ue,onPaneDragStart:Ge,onPaneDragMove:Ke,onPaneDragEnd:Je}=xe({panes:y,zoomed:Te,onFocus:ke,onReorder:Re}),Ye=be(y.length+_>0?y.length+_:p??0,O.w>=O.h),Qe=wm({link:h,panes:y.length,replayLeft:_,pending:p});return(0,$.jsxs)(`section`,{ref:i,"data-terminal-panel":``,className:`relative flex min-h-0 min-w-0 flex-col border-t border-chrome-line ${r}`,children:[(0,$.jsx)(bh,{...a}),(0,$.jsx)(xh,{mode:pe,onToggleMode:me,canToggleMode:he,tabs:we&&y.length>0?(0,$.jsx)(Zm,{panes:y,titles:w,shown:De,reorderable:He,draggingPane:Be,dragOverPane:Ve,onClose:te,onPaneDragStart:Ge,onPaneDragMove:Ke,onPaneDragEnd:Je,onPaneDragCancel:Ue}):void 0,ownsSize:ne,maximized:t,keyBarShown:ge.shown,recovery:ce,panes:y,onCancelRecovery:ue,onClaimSize:Ie,onCreate:Pe,onCompose:Me.open,onToggleKeyBar:ge.toggle,onToggleMaximized:n}),(0,$.jsxs)(`div`,{className:`relative min-h-0 flex-1 overflow-hidden bg-ink-950 p-1`,children:[(0,$.jsx)(Dm,{status:Qe}),(0,$.jsx)(Xm,{containerRef:s,mode:pe,maximized:t,panes:y,titles:w,active:x,shown:De,layout:Ye,pending:p,recovery:ce,draggingPane:Be,dragOverPane:Ve,reorderable:He,bodyTouch:fe,slotRefs:f,bodyRefs:u,onFocus:ke,onToggleZoom:Fe,onClose:te,onCancelRecovery:ue,onPaneDragStart:Ge,onPaneDragMove:Ke,onPaneDragEnd:Je,onPaneDragCancel:Ue})]}),y.length>0&&ge.shown&&(0,$.jsx)(th,{onKey:ze,ctrl:_e,alt:ve,onArm:je}),(0,$.jsx)(Gm,{closing:E,panes:y,paneLabel:Ae,onConfirmClose:e=>{te(null),Le(e)},onCancelClose:()=>{te(null),je()},compose:Me})]})}var Ch=(0,j.memo)(Sh);export{Ch as TerminalPanel}; \ No newline at end of file diff --git a/viewer-ui/dist/assets/index-C0YZmztO.js b/viewer-ui/dist/assets/index-C0YZmztO.js deleted file mode 100644 index 0d2c3043..00000000 --- a/viewer-ui/dist/assets/index-C0YZmztO.js +++ /dev/null @@ -1,11 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Markdown-DEJAds14.js","./jsx-runtime-EIAPxkjE.js","./react-BPk_wmJm.js","./Markdown-C8LL_u4z.css","./Html-DGFy4jGa.js","./HtmlEditor-DzgQSTDx.js","./BusyLabel-BNTNuT1X.js","./api-BwgkHPos.js","./Terminal-BuLVJ0Wx.js","./lastPane-Kg5ZBFNS.js"])))=>i.map(i=>d[i]); -import{n as e,t}from"./jsx-runtime-EIAPxkjE.js";import{t as n}from"./react-BPk_wmJm.js";import{$ as r,A as i,C as a,D as o,F as s,G as c,H as l,I as u,J as d,K as f,L as p,M as m,N as h,O as g,Q as _,R as v,U as y,V as b,W as x,X as S,Y as C,Z as w,_t as T,at as E,b as ee,c as te,ct as ne,dt as re,et as ie,ft as ae,g as oe,gt as se,ht as D,i as ce,it as le,j as ue,k as de,lt as fe,mt as pe,nt as me,ot as he,pt as ge,q as _e,r as ve,rt as ye,s as be,st as xe,tt as O,ut as k,v as Se,w as Ce,x as we,y as Te,z as Ee}from"./lastPane-Kg5ZBFNS.js";import{t as A}from"./BusyLabel-BNTNuT1X.js";import{a as De,i as Oe,n as ke,o as Ae,r as je,s as Me,t as j}from"./api-BwgkHPos.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Ne=e((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,te());else{var t=n(l);t!==null&&ie(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-Tt&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ie(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?te():S=!1}}}var te;if(typeof y==`function`)te=function(){y(ee)};else if(typeof MessageChannel<`u`){var ne=new MessageChannel,re=ne.port2;ne.port1.onmessage=ee,te=function(){re.postMessage(null)}}else te=function(){_(ee,0)};function ie(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ie(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,te()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Pe=e(((e,t)=>{t.exports=Ne()})),Fe=e((e=>{var t=Pe(),r=n(),i=T();function a(e){var t=`https://react.dev/errors/`+e;if(1we||(e.current=Ce[we],Ce[we]=null,we--)}function A(e,t){we++,Ce[we]=e.current,e.current=t}var De=Te(null),Oe=Te(null),ke=Te(null),Ae=Te(null);function je(e,t){switch(A(ke,t),A(Oe,e),A(De,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}Ee(De),A(De,e)}function Me(){Ee(De),Ee(Oe),Ee(ke)}function j(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,A(Ae,e)),t=De.current;var n=dp(t,e.type);t!==n&&(A(Oe,e),A(De,n))}function Ne(e){Oe.current===e&&(Ee(De),Ee(Oe)),Ae.current===e&&(Ee(Ae),sh._currentValue=Se)}var Fe,Ie;function M(e){if(Fe===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Fe=t&&t[1]||``,Ie=-1)`:-1i||c[r]!==l[i]){var u=` -`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{N=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?M(n):``}function Re(e,t){switch(e.tag){case 26:case 27:case 5:return M(e.type);case 16:return M(`Lazy`);case 13:return e.child!==t&&t!==null?M(`Suspense Fallback`):M(`Suspense`);case 19:return M(`SuspenseList`);case 0:case 15:return Le(e.type,!1);case 11:return Le(e.type.render,!1);case 1:return Le(e.type,!0);case 31:return M(`Activity`);case 30:return M(`ViewTransition`);default:return``}}function ze(e){try{var t=``,n=null;do t+=Re(e,n),n=e,e=e.return;while(e);return t}catch(e){return` -Error generating stack: `+e.message+` -`+e.stack}}var Be=Object.prototype.hasOwnProperty,Ve=t.unstable_scheduleCallback,He=t.unstable_cancelCallback,Ue=t.unstable_shouldYield,We=t.unstable_requestPaint,Ge=t.unstable_now,Ke=t.unstable_getCurrentPriorityLevel,qe=t.unstable_ImmediatePriority,Je=t.unstable_UserBlockingPriority,Ye=t.unstable_NormalPriority,Xe=t.unstable_LowPriority,Ze=t.unstable_IdlePriority,Qe=t.log,$e=t.unstable_setDisableYieldValue,et=null,tt=null;function nt(e){if(typeof Qe==`function`&&$e(e),tt&&typeof tt.setStrictMode==`function`)try{tt.setStrictMode(et,e)}catch{}}var rt=Math.clz32?Math.clz32:ot,it=Math.log,at=Math.LN2;function ot(e){return e>>>=0,e===0?32:31-(it(e)/at|0)|0}var st=256,ct=262144,lt=4194304;function ut(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function dt(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=ut(n))):i=ut(o):i=ut(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=ut(n))):i=ut(o)):i=ut(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function ft(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function pt(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0n;n++)t.push(e);return t}function _t(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function vt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0=gr),yr=` `,br=!1;function xr(e,t){switch(e){case`keyup`:return mr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Sr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Cr=!1;function wr(e,t){switch(e){case`compositionend`:return Sr(t);case`keypress`:return t.which===32?(br=!0,yr):null;case`textInput`:return e=t.data,e===yr&&br?null:e;default:return null}}function Tr(e,t){if(Cr)return e===`compositionend`||!hr&&xr(e,t)?(e=Rn(),Ln=In=Fn=null,Cr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Jr(n)}}function Xr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Xr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Zr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=qr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=qr(e.document)}return t}function Qr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var $r=Mn&&`documentMode`in document&&11>=document.documentMode,ei=null,ti=null,ni=null,ri=!1;function ii(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ri||ei==null||ei!==qr(r)||(r=ei,`selectionStart`in r&&Qr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ni&&Kr(ni,r)||(ni=r,r=Jf(ti,`onSelect`),0>=o,i-=o,ea=1<<32-rt(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),L&&na(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),L&&na(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return L&&na(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),L&&na(i,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===re&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case te:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===re){if(r.tag===7){n(e,r.sibling),c=i(r,o.props.children),fo(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===de&&io(l)===r.type){n(e,r.sibling),c=i(r,o.props),fo(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===re?(c=Vi(o.props.children,e.mode,c,o.key),fo(c,o),c.return=e,e=c):(c=Bi(o.type,o.key,o.props,null,e.mode,c),fo(c,o),c.return=e,e=c)}return s(e);case ne:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=i(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Wi(o,e.mode,c),c.return=e,e=c}return s(e);case de:return o=io(o),_(e,r,o,c)}if(xe(o))return h(e,r,o,c);if(ve(o)){if(l=ve(o),typeof l!=`function`)throw Error(a(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,uo(o),c);if(o.$$typeof===se)return _(e,r,ka(e,o),c);po(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,o),c.return=e,e=c):(n(e,r),c=Hi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{lo=0;var i=_(e,t,n,r);return co=null,i}catch(t){if(t===Qa||t===eo)throw t;var a=Ii(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var ho=mo(!0),go=mo(!1),_o=!1;function vo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function yo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function bo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function xo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,W&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Ni(e),Mi(e,null,n),t}return ki(e,r,t,n),Ni(e)}function So(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,bt(e,n)}}function Co(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var wo=!1;function To(){if(wo){var e=Ua;if(e!==null)throw e}}function Eo(e,t,n,r){wo=!1;var i=e.updateQueue;_o=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(q&f)===f:(r&f)===f){f!==0&&f===Ha&&(wo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=E({},d,f);break a;case 2:_o=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),sd|=o,e.lanes=o,e.memoizedState=d}}function Do(e,t){if(typeof e!=`function`)throw Error(a(191,e));e.call(t)}function Oo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=O.T,s={};s.types=o===null?null:o.types,O.T=s,pc(e,!1,t,n);try{var c=i(),l=O.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?fc(e,t,Ka(c,r),jd(e)):fc(e,t,r,jd(e))}catch(n){fc(e,t,{then:function(){},status:`rejected`,reason:n},jd())}finally{k.p=a,o!==null&&s.types!==null&&(o.types=s.types),O.T=o}}function nc(){}function rc(e,t,n,r){if(e.tag!==5)throw Error(a(476));var i=ic(e).queue;tc(e,i,t,Se,n===null?nc:function(){return ac(e),n(r)})}function ic(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Se,baseState:Se,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ms,lastRenderedState:Se},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ms,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ac(e){var t=ic(e);t.next===null&&(t=e.alternate.memoizedState),fc(e,t.next.queue,{},jd())}function oc(){return Oa(sh)}function sc(){return ls().memoizedState}function cc(){return ls().memoizedState}function lc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=jd();e=bo(n);var r=xo(t,e,n);r!==null&&(Pd(r,t,n),So(r,t,n)),t={cache:Fa()},e.payload=t;return}t=t.return}}function uc(e,t,n){var r=jd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},mc(e)?hc(t,n):(n=Ai(e,t,n,r),n!==null&&(Pd(n,e,r),gc(n,t,r)))}function dc(e,t,n){fc(e,t,n,jd())}function fc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(mc(e))hc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Gr(s,o))return ki(e,t,i,0),G===null&&Oi(),!1}catch{}if(n=Ai(e,t,i,r),n!==null)return Pd(n,e,r),gc(n,t,r),!0}return!1}function pc(e,t,n,r){if(r={lane:2,revertLane:Pf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},mc(e)){if(t)throw Error(a(479))}else t=Ai(e,n,r,2),t!==null&&Pd(t,e,2)}function mc(e){var t=e.alternate;return e===R||t!==null&&t===R}function hc(e,t){Jo=qo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function gc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,bt(e,n)}}var _c={readContext:Oa,use:fs,useCallback:B,useContext:B,useEffect:B,useImperativeHandle:B,useLayoutEffect:B,useInsertionEffect:B,useMemo:B,useReducer:B,useRef:B,useState:B,useDebugValue:B,useDeferredValue:B,useTransition:B,useSyncExternalStore:B,useId:B,useHostTransitionStatus:B,useFormState:B,useActionState:B,useOptimistic:B,useMemoCache:B,useCacheRefresh:B,useEffectEvent:B},vc={readContext:Oa,use:fs,useCallback:function(e,t){return cs().memoizedState=[e,t===void 0?null:t],e},useContext:Oa,useEffect:Hs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Bs(4194308,4,Js.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Bs(4194308,4,e,t)},useInsertionEffect:function(e,t){Bs(4,2,e,t)},useMemo:function(e,t){var n=cs();t=t===void 0?null:t;var r=e();if(Yo){nt(!0);try{e()}finally{nt(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=cs();if(n!==void 0){var i=n(t);if(Yo){nt(!0);try{n(t)}finally{nt(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=uc.bind(null,R,e),[r.memoizedState,e]},useRef:function(e){var t=cs();return e={current:e},t.memoizedState=e},useState:function(e){e=ws(e);var t=e.queue,n=dc.bind(null,R,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Xs,useDeferredValue:function(e,t){return $s(cs(),e,t)},useTransition:function(){var e=ws(!1);return e=tc.bind(null,R,e.queue,!0,!1),cs().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=R,i=cs();if(L){if(n===void 0)throw Error(a(407));n=n()}else{if(n=t(),G===null)throw Error(a(349));q&127||ys(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,Hs(xs.bind(null,r,o,e),[e]),r.flags|=2048,Rs(9,{destroy:void 0},bs.bind(null,r,o,n,t),null),n},useId:function(){var e=cs(),t=G.identifierPrefix;if(L){var n=ta,r=ea;n=(r&~(1<<32-rt(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Xo++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(i,{is:r.is}):s.createElement(i)}}o[Dt]=t,o[Ot]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(np(o,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&gl(t)}}return V(t),t.subtreeFlags&=-33554433,_l(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&gl(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(a(166));if(e=ke.current,ma(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=sa,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[Dt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||ep(e.nodeValue,n)),e||da(t,!0)}else e=lp(e).createTextNode(r),e[Dt]=t,t.stateNode=e}return V(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ma(t),n!==null){if(e===null){if(!r)throw Error(a(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(a(557));e[Dt]=t}else ha(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;V(t),e=!1}else n=ga(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Bo(t),t):(Bo(t),null);if(t.flags&128)throw Error(a(558))}return V(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=ma(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(a(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(a(317));i[Dt]=t}else ha(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;V(t),i=!1}else i=ga(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(Bo(t),t):(Bo(t),null)}return Bo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),yl(t,t.updateQueue),V(t),null);case 4:return Me(),e===null&&Wf(t.stateNode.containerInfo),t.flags|=67108864,V(t),null;case 10:return Sa(t.type),V(t),null;case 19:if(Uo(t),r=t.memoizedState,r===null)return V(t),null;if(i=!!(t.flags&128),o=r.rendering,o===null){if(i)bl(r,!1);else{if(Y!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Wo(e),o!==null){for(t.flags|=128,bl(r,!1),e=o.updateQueue,t.updateQueue=e,yl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)zi(n,e),n=n.sibling;return Ho(t,Vo.current&1|2),L&&na(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ge()>_d&&(t.flags|=128,i=!0,bl(r,!1),t.lanes=4194304)}}else{if(!i){if(e=Wo(o),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,yl(t,e),bl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!L)return V(t),null}else 2*Ge()-r.renderingStartTime>_d&&n!==536870912&&(t.flags|=128,i=!0,bl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ge(),e.sibling=null,o=Vo.current,o=i?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||L?Ho(t,o):(n=o,A(Po,t),A(Vo,n),Fo===null&&(Fo=t)),L&&na(t,r.treeForkCount),e}return V(t),null;case 22:case 23:return Bo(t),No(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(V(t),t.subtreeFlags&6&&(t.flags|=8192)):V(t),n=t.updateQueue,n!==null&&yl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&Ee(Ja),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Sa(Pa),V(t),null;case 25:return null;case 30:return t.flags|=33554432,V(t),null}throw Error(a(156,t.tag))}function Sl(e,t){switch(aa(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Sa(Pa),Me(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Ne(t),null;case 31:if(t.memoizedState!==null){if(Bo(t),t.alternate===null)throw Error(a(340));ha()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Bo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(a(340));ha()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Uo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return Me(),null;case 10:return Sa(t.type),null;case 22:case 23:return Bo(t),No(),e!==null&&Ee(Ja),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Sa(Pa),null;case 25:return null;default:return null}}function Cl(e,t){switch(aa(t),t.tag){case 3:Sa(Pa),Me();break;case 26:case 27:case 5:Ne(t);break;case 4:Me();break;case 31:t.memoizedState!==null&&Bo(t);break;case 13:Bo(t);break;case 19:Uo(t);break;case 10:Sa(t.type);break;case 22:case 23:Bo(t),No(),e!==null&&Ee(Ja);break;case 24:Sa(Pa)}}function wl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Z(t,t.return,e)}}function Tl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Z(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Z(t,t.return,e)}}function El(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Oo(t,n)}catch(t){Z(e,e.return,t)}}}function Dl(e,t,n){n.props=Tc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Z(e,t,n)}}function Ol(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=xi(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Pp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Fp(e);p(e.child,!1,Qp,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Z(e,t,n)}}function kl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Z(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Z(e,t,n)}else n.current=null}}function Al(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n title`))),np(r,t,n),r[Dt]=e,Vt(r),t=r;break a;case`link`:if(o=Gm(`link`,`href`,i).get(t+(n.href||``))){for(s=0;sg&&(o=g,g=h,h=o);var _=Yr(s,h),v=Yr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,O.T=null,n=wd,wd=null;var o=bd,s=Sd;if(X=0,xd=bd=null,Sd=0,W&6)throw Error(a(331));var c=W;if(W|=4,Zu(o.current),Uu(o,o.current,s,n),W=c,Df(0,!1),tt&&typeof tt.onPostCommitFiberRoot==`function`)try{tt.onPostCommitFiberRoot(et,o)}catch{}return!0}finally{k.p=i,O.T=r,uf(e,t)}}function pf(e,t,n){t=Ki(n,t),t=jc(e.stateNode,t,2),e=xo(e,t,2),e!==null&&(_t(e,2),Ef(e))}function Z(e,t,n){if(e.tag===3)pf(e,e,n);else for(;t!==null;){if(t.tag===3){pf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(yd===null||!yd.has(r))){e=Ki(n,e),n=Mc(2),r=xo(t,n,2),r!==null&&(Nc(n,r,t,e),_t(r,2),Ef(r));break}}t=t.return}}function mf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new td;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(ad=!0,i.add(n),e=hf.bind(null,e,t,n),t.then(e,e))}function hf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,G===e&&(q&n)===n&&(Y===4||Y===3&&(q&62914560)===q&&300>Ge()-hd?W&2?ld|=n:Vd(e,0):ld|=n,dd===q&&(dd=0)),Ef(e)}function gf(e,t){t===0&&(t=ht()),e=ji(e,t),e!==null&&(_t(e,t),Ef(e))}function _f(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),gf(e,n)}function vf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(a(314))}r!==null&&r.delete(t),gf(e,n)}function yf(e,t){return Ve(e,t)}var bf=null,xf=null,Sf=!1,Cf=!1,wf=!1,Tf=0;function Ef(e){e!==xf&&e.next===null&&(xf===null?bf=xf=e:xf=xf.next=e),Cf=!0,Sf||(Sf=!0,Nf())}function Df(e,t){if(!wf&&Cf){wf=!0;do for(var n=!1,r=bf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-rt(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Mf(r,a))}else a=q,a=dt(r,r===G?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||ft(r,a)||(n=!0,Mf(r,a))}r=r.next}while(n);wf=!1}}function Of(){kf()}function kf(){Cf=Sf=!1;var e=0;Tf!==0&&hp()&&(e=Tf);for(var t=Ge(),n=null,r=bf;r!==null;){var i=r.next,a=Af(r,t);a===0?(r.next=null,n===null?bf=i:n.next=i,i===null&&(xf=n)):(n=r,(e!==0||a&3)&&(Cf=!0)),r=i}X!==0&&X!==5||Df(e,!1),Tf!==0&&(Tf=0)}function Af(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&ap(d)&&(c=c.responseEnd,o+=u*(c$m){s.length=o;break}f=new Promise(jp.bind(f)),s.push(f)}}}if(0`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=cn(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),Vt(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+cn(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+cn(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+cn(n.imageSizes)+`"]`)):i+=`[href="`+cn(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=E({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[Ft]=!0,o.onload=o.onerror=function(){Ht(o)}),Vt(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+cn(r)+`"][href="`+cn(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=E({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),Vt(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=Bt(r).hoistableStyles,a=Pm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=E({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);Vt(c),np(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=Bt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=E({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Vt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=Bt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=E({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Vt(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var i=(i=ke.current)?bm(i):null;if(!i)throw Error(a(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Pm(n.href),t=Bt(i).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pm(n.href);var o=Bt(i).hoistableStyles,s=o.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=i.querySelector(Fm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=vm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vm.set(e,o)),Lm(i,e,o,s.state))),t&&r===null)throw Error(a(528,``));return s}if(t&&r!==null)throw Error(a(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Rm(n),t=Bt(i).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(a(444,e))}}function Pm(e){return`href="`+cn(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return E({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Ft]){r.loading=1;return}}else t=e.createElement(`link`),t[Ft]=!0,t.onload=t.onerror=Ht.bind(null,t),np(t,`link`,n),Vt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Rm(e){return`[src="`+cn(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+cn(n.href)+`"]`);if(r)return t.instance=r,Vt(r),r;var i=E({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Vt(r),np(r,`style`,i),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Pm(n.href);var o=e.querySelector(Fm(i));if(o)return t.state.loading|=4,t.instance=o,Vt(o),o;r=Im(n),(i=vm.get(i))&&Hm(r,i),o=(e.ownerDocument||e).createElement(`link`),Vt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),np(o,`link`,r),t.state.loading|=4,Vm(o,n.precedence,e),t.instance=o;case`script`:return o=Rm(n.src),(i=e.querySelector(zm(o)))?(t.instance=i,Vt(i),i):(r=n,(i=vm.get(o))&&(r=E({},n),Um(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),Vt(i),np(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(a(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vm(r,n.precedence,e));return t.instance}function Vm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function qm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Vt(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),Vt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Fe()}))(),M=n(),N=t();function Le({onClose:e,onOpened:t,canClone:n,cloning:r,onClone:i}){let[a,o]=(0,M.useState)(null),[s,c]=(0,M.useState)(null),[l,u]=(0,M.useState)(null),[d,f]=(0,M.useState)(!1),[p,m]=(0,M.useState)(``),[h,g]=(0,M.useState)(!1),[_,v]=(0,M.useState)(``),[y,b]=(0,M.useState)(0);(0,M.useEffect)(()=>{let e=!1;return j.browse(a??void 0).then(t=>{e||(c(t),u(null))}).catch(t=>{e||u(t instanceof Error?t.message:`could not browse`)}),()=>{e=!0}},[a,y]);let x=e=>o(`${s.path.replace(/\/$/,``)}/${e}`),S=async()=>{if(s){f(!0);try{t(await j.open(s.path))}catch(e){D.error(e instanceof Error?e.message:`could not open`),f(!1)}}},C=async()=>{if(!s)return;let e=p.trim();if(e){g(!0);try{await j.mkdir(s.path,e),m(``),b(e=>e+1)}catch(e){D.error(e instanceof Error?e.message:`could not create folder`)}finally{g(!1)}}};return(0,N.jsx)(`div`,{className:`nc-fade-in fixed inset-0 z-50 flex items-start justify-center bg-black/60 p-4 md:pt-[8vh]`,onClick:e,children:(0,N.jsxs)(`div`,{className:`nc-rise-in flex max-h-[min(80vh,calc(var(--nc-visual-viewport-height,100vh)-8vh-1rem))] w-[34rem] max-w-full flex-col rounded-lg border border-ink-700 bg-ink-900`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-ink-700 px-3 py-2`,children:[(0,N.jsx)(`span`,{className:`font-medium text-ink-50`,children:`Open a project`}),(0,N.jsx)(`button`,{onClick:e,"aria-label":`close`,className:`ml-auto flex h-6 w-6 items-center justify-center rounded-sm text-ink-400 hover:text-ink-200`,children:(0,N.jsx)(ae,{})})]}),(0,N.jsx)(`div`,{className:`shrink-0 truncate border-b border-ink-700 px-3 py-1.5 text-ink-400`,children:s?.path??`…`}),(0,N.jsxs)(`ul`,{className:`h-72 min-h-0 overflow-y-auto`,children:[s?.parent&&(0,N.jsx)(`li`,{children:(0,N.jsx)(`button`,{onClick:()=>o(s.parent),className:`w-full px-3 py-1 text-left text-ink-400 hover:bg-ink-850`,children:`../`})}),s?.entries.map(e=>(0,N.jsx)(`li`,{children:(0,N.jsxs)(`button`,{onClick:()=>x(e.name),className:`flex w-full items-center gap-2 px-3 py-1 text-left hover:bg-ink-850`,children:[(0,N.jsxs)(`span`,{className:`truncate text-accent`,children:[e.name,`/`]}),e.is_repo&&(0,N.jsx)(`span`,{className:`rounded-sm bg-ink-700 px-1 text-2xs text-ink-200`,children:`git`})]})},e.name)),s&&s.entries.length===0&&(0,N.jsx)(`li`,{className:`px-3 py-1 text-ink-400`,children:`No sub-folders.`})]}),l&&(0,N.jsx)(`p`,{className:`shrink-0 px-3 py-1 text-removed`,children:l}),(0,N.jsxs)(`div`,{className:`flex shrink-0 items-stretch gap-2 border-t border-ink-700 px-3 py-2`,children:[(0,N.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&C()},placeholder:`New folder name`,"aria-label":`new folder name`,className:`min-w-0 flex-1 rounded-sm border border-ink-700 bg-ink-950 px-2 py-1 text-ink-50 placeholder:text-ink-400 focus:border-ink-600 focus:outline-none`}),(0,N.jsx)(`button`,{onClick:C,disabled:!s||!p.trim()||h,"aria-busy":h,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850 disabled:opacity-50`,children:(0,N.jsx)(A,{busy:h,children:`Create`})})]}),(0,N.jsxs)(`div`,{className:`flex shrink-0 items-stretch gap-2 border-t border-ink-700 px-3 py-2`,children:[(0,N.jsx)(`input`,{value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s&&i(s.path,_)},disabled:!n,placeholder:n?`Clone a git URL here`:`git is not installed on the server`,"aria-label":`git URL to clone`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,className:`min-w-0 flex-1 rounded-sm border border-ink-700 bg-ink-950 px-2 py-1 text-ink-50 placeholder:text-ink-400 focus:border-ink-600 focus:outline-none disabled:opacity-50`}),(0,N.jsx)(`button`,{onClick:()=>s&&i(s.path,_),disabled:!n||!s||!_.trim()||r,"aria-busy":r,title:n?void 0:`the server has no git on its PATH`,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850 disabled:opacity-50`,children:(0,N.jsx)(A,{busy:r,children:`Clone`})})]}),(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-ink-700 px-3 py-2`,children:[(0,N.jsx)(`span`,{className:`truncate text-ink-400`,children:s?s.path:``}),(0,N.jsx)(`button`,{onClick:S,disabled:!s||d,"aria-busy":d,className:`ml-auto shrink-0 rounded-sm bg-ink-50 px-3 py-1 font-semibold text-ink-950 hover:bg-white disabled:opacity-50`,children:(0,N.jsx)(A,{busy:d,children:`Open`})})]})]})})}var Re=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='12%2057%201150%201150'%20role='img'%20aria-label='Black%20crow'%3e%3ctitle%3eBlack%20crow%3c/title%3e%3cdesc%3eMonochrome%20black%20crow%20silhouette%20on%20a%20transparent%20background,%20framed%20so%20the%20bird%20sits%20centred%20for%20use%20as%20an%20inline%20mark%20on%20a%20square%20tile.%3c/desc%3e%3cg%20fill-rule='evenodd'%20clip-rule='evenodd'%3e%3cpath%20fill='%23000000'%20d='M%20882%20147%20L%20859%20136%20L%20844%20131%20L%20831%20129%20L%20830%20128%20L%20815%20127%20L%20814%20126%20L%20796%20126%20L%20795%20127%20L%20786%20127%20L%20785%20128%20L%20775%20129%20L%20752%20136%20L%20732%20146%20L%20713%20160%20L%20701%20172%20L%20684%20172%20L%20683%20173%20L%20673%20173%20L%20672%20174%20L%20650%20176%20L%20649%20177%20L%20627%20181%20L%20602%20190%20L%20589%20197%20L%20579%20204%20L%20562%20221%20L%20562%20223%20L%20565%20223%20L%20578%20228%20L%20581%20228%20L%20612%20238%20L%20672%20252%20L%20684%20258%20L%20698%20271%20L%20702%20278%20L%20705%20288%20L%20705%20294%20L%20703%20301%20L%20699%20308%20L%20688%20318%20L%20630%20347%20L%20593%20372%20L%20561%20399%20L%20544%20416%20L%20522%20441%20L%20492%20481%20L%20461%20531%20L%20438%20576%20L%20431%20594%20L%20425%20602%20L%20405%20635%20L%20387%20668%20L%20385%20676%20L%20390%20679%20L%20368%20705%20L%20330%20755%20L%20306%20790%20L%20296%20808%20L%20289%20818%20L%20280%20838%20L%20280%20843%20L%20283%20845%20L%20292%20843%20L%20297%20840%20L%20299%20840%20L%20321%20828%20L%20322%20830%20L%20311%20844%20L%20288%20878%20L%20287%20881%20L%20259%20924%20L%20235%20965%20L%20205%201023%20L%20205%201025%20L%20197%201042%20L%20191%201061%20L%20191%201071%20L%20192%201072%20L%20198%201071%20L%20220%201056%20L%20242%201038%20L%20300%20986%20L%20302%20987%20L%20265%201040%20L%20264%201043%20L%20246%201070%20L%20235%201090%20L%20227%201112%20L%20227%201123%20L%20229%201128%20L%20234%201133%20L%20239%201135%20L%20255%201135%20L%20274%201129%20L%20279%201134%20L%20286%201137%20L%20290%201137%20L%20291%201138%20L%20310%201138%20L%20311%201137%20L%20317%201137%20L%20318%201136%20L%20326%201135%20L%20344%201129%20L%20369%201116%20L%20395%201097%20L%20420%201073%20L%20445%201042%20L%20457%201024%20L%20461%201016%20L%20464%201013%20L%20468%201011%20L%20489%20994%20L%20595%20901%20L%20601%20906%20L%20606%20913%20L%20614%20921%20L%20637%20949%20L%20639%20953%20L%20639%20956%20L%20636%20960%20L%20634%20961%20L%20619%20962%20L%20613%20965%20L%20605%20974%20L%20602%20982%20L%20602%20994%20L%20605%201001%20L%20608%201004%20L%20609%201004%20L%20609%20999%20L%20612%20992%20L%20616%20988%20L%20620%20986%20L%20627%20986%20L%20635%20983%20L%20645%20983%20L%20646%20982%20L%20655%20982%20L%20668%20986%20L%20676%20990%20L%20682%20996%20L%20685%201003%20L%20688%201006%20L%20696%201009%20L%20697%201012%20L%20697%201024%20L%20693%201033%20L%20693%201035%20L%20695%201035%20L%20700%201032%20L%20707%201025%20L%20710%201020%20L%20713%201010%20L%20713%201003%20L%20711%20998%20L%20711%20994%20L%20712%20993%20L%20719%201003%20L%20723%201005%20L%20727%201005%20L%20730%201011%20L%20730%201022%20L%20727%201031%20L%20728%201033%20L%20740%201021%20L%20743%201014%20L%20744%201003%20L%20747%20999%20L%20749%20992%20L%20748%20977%20L%20744%20968%20L%20740%20963%20L%20741%20962%20L%20755%20961%20L%20768%20964%20L%20777%20969%20L%20783%20975%20L%20786%20981%20L%20789%20984%20L%20795%20987%20L%20799%20987%20L%20801%20991%20L%20801%20997%20L%20802%20998%20L%20799%201013%20L%20802%201012%20L%20808%201007%20L%20813%201000%20L%20816%20991%20L%20816%20981%20L%20814%20976%20L%20814%20968%20L%20815%20967%20L%20819%20970%20L%20823%20970%20L%20826%20973%20L%20829%20980%20L%20830%20993%20L%20834%20990%20L%20838%20979%20L%20838%20968%20L%20832%20951%20L%20822%20940%20L%20815%20936%20L%20803%20933%20L%20776%20935%20L%20763%20931%20L%20753%20922%20L%20731%20898%20L%20703%20865%20L%20703%20863%20L%20710%20853%20L%20711%20855%20L%20707%20862%20L%20709%20862%20L%20718%20857%20L%20754%20832%20L%20793%20799%20L%20818%20774%20L%20849%20737%20L%20850%20741%20L%20845%20755%20L%20847%20755%20L%20861%20743%20L%20881%20721%20L%20906%20686%20L%20918%20665%20L%20933%20635%20L%20951%20590%20L%20971%20525%20L%20971%20521%20L%20974%20512%20L%20974%20508%20L%20978%20493%20L%20979%20482%20L%20980%20481%20L%20981%20466%20L%20982%20465%20L%20983%20441%20L%20982%20440%20L%20982%20428%20L%20981%20427%20L%20980%20414%20L%20978%20409%20L%20976%20397%20L%20970%20381%20L%20971%20379%20L%20974%20383%20L%20976%20381%20L%20977%20334%20L%20976%20333%20L%20976%20322%20L%20975%20321%20L%20974%20307%20L%20973%20306%20L%20973%20301%20L%20972%20300%20L%20969%20280%20L%20958%20243%20L%20949%20224%20L%20949%20222%20L%20939%20204%20L%20922%20181%20L%20903%20162%20Z%20M%20625%20888%20L%20656%20874%20L%20658%20874%20L%20665%20870%20L%20725%20930%20L%20728%20934%20L%20728%20940%20L%20723%20943%20L%20714%20944%20L%20707%20950%20L%20683%20951%20L%20673%20947%20L%20659%20932%20Z%20M%20787%20182%20L%20792%20182%20L%20796%20187%20L%20795%20192%20L%20791%20195%20L%20788%20195%20L%20783%20191%20L%20783%20186%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20895%20156%20L%20863%20138%20L%20838%20130%20L%20819%20127%20L%20789%20127%20L%20777%20129%20L%20753%20136%20L%20736%20144%20L%20717%20157%20L%20702%20172%20L%20652%20176%20L%20628%20181%20L%20607%20188%20L%20585%20200%20L%20562%20222%20L%20613%20238%20L%20670%20251%20L%20683%20257%20L%20697%20269%20L%20705%20286%20L%20705%20296%20L%20703%20302%20L%20698%20310%20L%20687%20319%20L%20631%20347%20L%20591%20374%20L%20568%20393%20L%20538%20423%20L%20520%20444%20L%20481%20498%20L%20457%20539%20L%20437%20579%20L%20432%20593%20L%20413%20622%20L%20386%20671%20L%20386%20677%20L%20390%20677%20L%20391%20679%20L%20374%20698%20L%20334%20750%20L%20307%20789%20L%20290%20817%20L%20280%20839%20L%20281%20844%20L%20291%20843%20L%20323%20826%20L%20325%20827%20L%20289%20877%20L%20237%20962%20L%20209%201015%20L%20198%201040%20L%20191%201063%20L%20191%201070%20L%20194%201072%20L%20213%201061%20L%20259%201023%20L%20302%20984%20L%20303%20985%20L%20262%201045%20L%20245%201072%20L%20233%201095%20L%20227%201114%20L%20228%201126%20L%20233%201132%20L%20242%201135%20L%20252%201135%20L%20274%201128%20L%20278%201133%20L%20288%201137%20L%20313%201137%20L%20343%201129%20L%20373%201113%20L%20398%201094%20L%20424%201068%20L%20441%201047%20L%20465%201012%20L%20520%20967%20L%20595%20900%20L%20611%20917%20L%20639%20952%20L%20639%20957%20L%20637%20960%20L%20632%20962%20L%20618%20963%20L%20611%20967%20L%20606%20973%20L%20602%20983%20L%20602%20992%20L%20608%201004%20L%20611%20993%20L%20619%20986%20L%20626%20986%20L%20643%20982%20L%20656%20982%20L%20675%20989%20L%20683%20997%20L%20688%201006%20L%20696%201009%20L%20697%201025%20L%20693%201034%20L%20694%201035%20L%20701%201031%20L%20710%201019%20L%20712%201013%20L%20712%20993%20L%20720%201003%20L%20727%201005%20L%20730%201009%20L%20730%201025%20L%20727%201032%20L%20732%201030%20L%20739%201022%20L%20743%201013%20L%20743%201004%20L%20749%20991%20L%20748%20978%20L%20740%20964%20L%20743%20961%20L%20757%20961%20L%20769%20964%20L%20781%20972%20L%20791%20985%20L%20798%20986%20L%20802%20994%20L%20802%201003%20L%20799%201013%20L%20810%201004%20L%20815%20994%20L%20816%20983%20L%20814%20977%20L%20814%20965%20L%20818%20969%20L%20825%20971%20L%20830%20983%20L%20830%20993%20L%20833%20991%20L%20837%20982%20L%20838%20969%20L%20834%20956%20L%20825%20943%20L%20820%20939%20L%20807%20934%20L%20774%20935%20L%20762%20931%20L%20736%20904%20L%20702%20864%20L%20715%20845%20L%20716%20847%20L%20707%20862%20L%20719%20856%20L%20744%20839%20L%20786%20805%20L%20824%20767%20L%20851%20733%20L%20852%20735%20L%20846%20755%20L%20853%20750%20L%20883%20718%20L%20906%20685%20L%20927%20647%20L%20951%20589%20L%20968%20535%20L%20976%20502%20L%20982%20461%20L%20981%20422%20L%20976%20398%20L%20968%20378%20L%20969%20376%20L%20975%20383%20L%20977%20341%20L%20970%20286%20L%20958%20244%20L%20945%20215%20L%20925%20185%20L%20906%20165%20Z%20M%20625%20888%20L%20665%20870%20L%20728%20933%20L%20729%20940%20L%20726%20943%20L%20715%20944%20L%20708%20950%20L%20692%20952%20L%20678%20950%20L%20672%20947%20L%20662%20936%20Z%20M%20785%20183%20L%20792%20182%20L%20796%20186%20L%20796%20191%20L%20791%20195%20L%20785%20194%20L%20783%20191%20L%20783%20186%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20896%20157%20L%20869%20141%20L%20837%20130%20L%20817%20127%20L%20792%20127%20L%20778%20129%20L%20751%20137%20L%20733%20146%20L%20715%20159%20L%20702%20172%20L%20653%20176%20L%20610%20187%20L%20581%20203%20L%20562%20222%20L%20625%20241%20L%20671%20251%20L%20683%20257%20L%20698%20270%20L%20705%20285%20L%20704%20300%20L%20699%20309%20L%20689%20318%20L%20628%20349%20L%20581%20382%20L%20540%20421%20L%20517%20448%20L%20478%20503%20L%20456%20541%20L%20439%20575%20L%20432%20593%20L%20412%20624%20L%20388%20667%20L%20386%20676%20L%20390%20677%20L%20391%20679%20L%20363%20712%20L%20332%20753%20L%20289%20819%20L%20281%20836%20L%20281%20844%20L%20293%20842%20L%20323%20826%20L%20325%20827%20L%20284%20885%20L%20236%20964%20L%20205%201024%20L%20197%201043%20L%20191%201064%20L%20191%201070%20L%20197%201071%20L%20210%201063%20L%20253%201028%20L%20303%20983%20L%20304%20984%20L%20259%201050%20L%20235%201091%20L%20227%201115%20L%20228%201125%20L%20232%201131%20L%20238%201134%20L%20249%201135%20L%20261%201133%20L%20274%201128%20L%20278%201133%20L%20289%201137%20L%20312%201137%20L%20342%201129%20L%20368%201116%20L%20399%201093%20L%20423%201069%20L%20443%201044%20L%20463%201013%20L%20493%20990%20L%20595%20900%20L%20612%20918%20L%20639%20952%20L%20639%20957%20L%20636%20961%20L%20616%20964%20L%20606%20973%20L%20602%20984%20L%20602%20991%20L%20608%201004%20L%20611%20993%20L%20621%20985%20L%20625%20986%20L%20639%20982%20L%20657%20982%20L%20677%20990%20L%20685%201002%20L%20690%201007%20L%20697%201010%20L%20698%201021%20L%20693%201034%20L%20694%201035%20L%20705%201027%20L%20710%201018%20L%20712%201011%20L%20712%201001%20L%20710%20994%20L%20712%20993%20L%20720%201003%20L%20729%201006%20L%20731%201020%20L%20728%201032%20L%20738%201023%20L%20743%201012%20L%20743%201003%20L%20748%20994%20L%20747%20976%20L%20740%20964%20L%20743%20961%20L%20759%20961%20L%20767%20963%20L%20780%20971%20L%20790%20984%20L%20799%20986%20L%20802%20992%20L%20802%201004%20L%20799%201012%20L%20803%201011%20L%20810%201004%20L%20815%20994%20L%20814%20965%20L%20818%20969%20L%20823%20969%20L%20830%20982%20L%20830%20992%20L%20832%20992%20L%20837%20982%20L%20837%20965%20L%20831%20950%20L%20821%20940%20L%20806%20934%20L%20772%20935%20L%20762%20931%20L%20733%20901%20L%20702%20863%20L%20717%20842%20L%20718%20844%20L%20707%20862%20L%20738%20843%20L%20780%20810%20L%20822%20769%20L%20851%20733%20L%20852%20735%20L%20846%20755%20L%20855%20748%20L%20882%20719%20L%20904%20688%20L%20930%20640%20L%20950%20591%20L%20967%20538%20L%20978%20490%20L%20982%20459%20L%20982%20434%20L%20976%20399%20L%20967%20376%20L%20969%20375%20L%20975%20383%20L%20976%20329%20L%20971%20293%20L%20960%20250%20L%20942%20210%20L%20923%20183%20Z%20M%20625%20888%20L%20665%20870%20L%20729%20934%20L%20729%20940%20L%20726%20943%20L%20716%20944%20L%20708%20950%20L%20695%20952%20L%20677%20950%20L%20666%20941%20Z%20M%20786%20182%20L%20790%20181%20L%20794%20183%20L%20797%20188%20L%20792%20195%20L%20787%20195%20L%20782%20190%20L%20782%20187%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20893%20155%20L%20873%20143%20L%20841%20131%20L%20816%20127%20L%20794%20127%20L%20779%20129%20L%20754%20136%20L%20735%20145%20L%20715%20159%20L%20702%20172%20L%20648%20177%20L%20629%20181%20L%20608%20188%20L%20584%20201%20L%20562%20222%20L%20614%20238%20L%20671%20251%20L%20685%20258%20L%20698%20270%20L%20704%20281%20L%20706%20292%20L%20703%20303%20L%20699%20309%20L%20686%20320%20L%20628%20349%20L%20590%20375%20L%20565%20396%20L%20543%20418%20L%20518%20447%20L%20490%20485%20L%20460%20534%20L%20441%20571%20L%20431%20595%20L%20405%20636%20L%20386%20672%20L%20386%20676%20L%20390%20677%20L%20391%20679%20L%20371%20702%20L%20335%20749%20L%20291%20816%20L%20280%20840%20L%20282%20844%20L%20298%20840%20L%20324%20825%20L%20326%20826%20L%20294%20870%20L%20235%20966%20L%20206%201022%20L%20198%201041%20L%20191%201065%20L%20191%201070%20L%20196%201071%20L%20214%201060%20L%20254%201027%20L%20303%20983%20L%20304%20984%20L%20256%201055%20L%20232%201098%20L%20227%201115%20L%20228%201125%20L%20232%201131%20L%20239%201134%20L%20248%201135%20L%20264%201132%20L%20274%201128%20L%20280%201134%20L%20289%201137%20L%20311%201137%20L%20339%201130%20L%20371%201114%20L%20401%201091%20L%20422%201070%20L%20440%201048%20L%20463%201013%20L%20487%20995%20L%20595%20900%20L%20613%20919%20L%20639%20951%20L%20639%20958%20L%20636%20961%20L%20619%20963%20L%20613%20966%20L%20605%20975%20L%20602%20991%20L%20604%20998%20L%20608%201003%20L%20611%20993%20L%20620%20985%20L%20624%20986%20L%20632%20983%20L%20647%20981%20L%20658%20982%20L%20677%20990%20L%20689%201006%20L%20697%201009%20L%20698%201021%20L%20694%201035%20L%20703%201029%20L%20710%201018%20L%20712%201010%20L%20712%201002%20L%20710%20997%20L%20711%20992%20L%20720%201003%20L%20728%201005%20L%20730%201008%20L%20731%201021%20L%20728%201032%20L%20738%201023%20L%20742%201014%20L%20743%201003%20L%20748%20994%20L%20748%20980%20L%20742%20966%20L%20739%20963%20L%20741%20961%20L%20753%20960%20L%20770%20964%20L%20780%20971%20L%20790%20984%20L%20799%20986%20L%20802%20992%20L%20802%201005%20L%20799%201012%20L%20804%201010%20L%20809%201005%20L%20815%20993%20L%20813%20964%20L%20817%20968%20L%20823%20969%20L%20826%20972%20L%20830%20982%20L%20831%20992%20L%20834%20989%20L%20838%20975%20L%20837%20966%20L%20831%20950%20L%20821%20940%20L%20804%20934%20L%20779%20936%20L%20763%20932%20L%20731%20899%20L%20702%20865%20L%20702%20863%20L%20717%20842%20L%20718%20844%20L%20708%20862%20L%20749%20835%20L%20781%20809%20L%20820%20771%20L%20851%20733%20L%20852%20736%20L%20846%20755%20L%20857%20746%20L%20881%20720%20L%20907%20683%20L%20928%20644%20L%20945%20604%20L%20967%20537%20L%20978%20489%20L%20982%20455%20L%20982%20437%20L%20979%20413%20L%20975%20396%20L%20967%20377%20L%20968%20374%20L%20975%20382%20L%20976%20332%20L%20972%20299%20L%20962%20257%20L%20954%20235%20L%20943%20212%20L%20923%20183%20Z%20M%20624%20888%20L%20666%20870%20L%20729%20934%20L%20729%20940%20L%20726%20943%20L%20716%20944%20L%20706%20951%20L%20684%20952%20L%20677%20950%20L%20665%20940%20Z%20M%20701%20220%20L%20710%20219%20L%20717%20221%20L%20704%20223%20L%20704%20221%20Z%20M%20666%20217%20L%20679%20216%20L%20689%20218%20L%20685%20220%20L%20675%20220%20Z%20M%20658%20210%20L%20661%20208%20L%20686%20205%20L%20706%20206%20L%20725%20209%20L%20733%20217%20L%20741%20220%20L%20738%20221%20L%20696%20214%20L%20661%20212%20Z%20M%20788%20181%20L%20793%20182%20L%20797%20188%20L%20792%20195%20L%20786%20195%20L%20782%20190%20L%20783%20185%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20893%20155%20L%20864%20139%20L%20836%20130%20L%20813%20127%20L%20796%20127%20L%20774%20130%20L%20749%20138%20L%20735%20145%20L%20720%20155%20L%20702%20172%20L%20687%20173%20L%20700%20174%20L%20694%20181%20L%20674%20184%20L%20670%20180%20L%20665%20183%20L%20657%20184%20L%20639%20196%20L%20641%20198%20L%20647%20198%20L%20648%20194%20L%20654%20193%20L%20686%20204%20L%20724%20208%20L%20740%20213%20L%20751%20222%20L%20750%20223%20L%20693%20214%20L%20671%20212%20L%20639%20212%20L%20636%20211%20L%20634%20207%20L%20629%20207%20L%20626%20210%20L%20617%20210%20L%20614%20208%20L%20604%20207%20L%20594%20213%20L%20582%20216%20L%20580%20214%20L%20581%20210%20L%20576%20208%20L%20586%20200%20L%20565%20218%20L%20563%20222%20L%20618%20239%20L%20671%20251%20L%20682%20256%20L%20689%20261%20L%20702%20276%20L%20706%20288%20L%20704%20301%20L%20700%20308%20L%20683%20322%20L%20630%20348%20L%20585%20379%20L%20563%20398%20L%20523%20441%20L%20497%20475%20L%20459%20536%20L%20443%20567%20L%20431%20595%20L%20411%20626%20L%20387%20670%20L%20386%20676%20L%20390%20677%20L%20391%20679%20L%20368%20706%20L%20333%20752%20L%20290%20818%20L%20281%20837%20L%20282%20844%20L%20300%20839%20L%20324%20825%20L%20326%20826%20L%20285%20884%20L%20242%20954%20L%20207%201020%20L%20192%201060%20L%20192%201071%20L%20196%201071%20L%20211%201062%20L%20240%201039%20L%20303%20983%20L%20305%20984%20L%20277%201023%20L%20242%201078%20L%20228%201110%20L%20227%201119%20L%20231%201130%20L%20239%201134%20L%20255%201134%20L%20274%201128%20L%20280%201134%20L%20285%201136%20L%20310%201137%20L%20339%201130%20L%20374%201112%20L%20394%201097%20L%20421%201071%20L%20445%201041%20L%20463%201013%20L%20488%20994%20L%20595%20900%20L%20614%20920%20L%20639%20951%20L%20639%20958%20L%20636%20961%20L%20619%20963%20L%20613%20966%20L%20607%20972%20L%20603%20980%20L%20602%20989%20L%20603%20995%20L%20608%201003%20L%20610%20994%20L%20620%20985%20L%20623%20986%20L%20631%20983%20L%20647%20981%20L%20665%20984%20L%20676%20989%20L%20689%201006%20L%20695%201007%20L%20697%201009%20L%20698%201023%20L%20694%201035%20L%20699%201032%20L%20709%201020%20L%20712%201010%20L%20710%20997%20L%20711%20992%20L%20719%201002%20L%20725%201005%20L%20727%201004%20L%20730%201008%20L%20731%201022%20L%20728%201032%20L%20739%201021%20L%20743%201010%20L%20743%201003%20L%20748%20993%20L%20748%20981%20L%20746%20974%20L%20739%20963%20L%20741%20961%20L%20755%20960%20L%20770%20964%20L%20779%20970%20L%20789%20983%20L%20799%20986%20L%20802%20992%20L%20802%201005%20L%20799%201012%20L%20808%201006%20L%20815%20993%20L%20813%20964%20L%20817%20968%20L%20825%20970%20L%20829%20978%20L%20831%20992%20L%20837%20981%20L%20837%20966%20L%20832%20952%20L%20822%20941%20L%20813%20936%20L%20803%20934%20L%20776%20936%20L%20763%20932%20L%20723%20890%20L%20702%20865%20L%20702%20863%20L%20717%20841%20L%20719%20842%20L%20708%20862%20L%20742%20840%20L%20782%20808%20L%20818%20773%20L%20851%20733%20L%20852%20736%20L%20846%20754%20L%20850%20752%20L%20881%20720%20L%20905%20686%20L%20932%20635%20L%20950%20590%20L%20969%20529%20L%20977%20494%20L%20982%20454%20L%20980%20419%20L%20975%20396%20L%20967%20377%20L%20968%20374%20L%20975%20382%20L%20976%20334%20L%20969%20284%20L%20959%20248%20L%20941%20209%20L%20921%20181%20Z%20M%20624%20888%20L%20666%20870%20L%20729%20934%20L%20729%20941%20L%20724%20944%20L%20716%20944%20L%20707%20951%20L%20683%20952%20L%20673%20948%20L%20659%20933%20Z%20M%20563%20618%20L%20569%20614%20L%20579%20621%20L%20576%20626%20L%20572%20627%20L%20568%20623%20L%20565%20623%20Z%20M%20575%20603%20L%20578%20603%20L%20588%20613%20L%20588%20619%20L%20585%20621%20L%20582%20620%20L%20575%20613%20L%20576%20612%20L%20573%20605%20Z%20M%20748%20398%20L%20752%20412%20L%20752%20432%20L%20748%20444%20L%20732%20470%20L%20716%20484%20L%20698%20493%20L%20685%20494%20L%20682%20491%20L%20707%20445%20L%20685%20473%20L%20667%20492%20L%20647%20508%20L%20632%20517%20L%20619%20519%20L%20615%20517%20L%20615%20513%20L%20643%20470%20L%20603%20514%20L%20589%20526%20L%20569%20538%20L%20558%20540%20L%20554%20539%20L%20552%20535%20L%20577%20498%20L%20549%20528%20L%20526%20546%20L%20508%20554%20L%20498%20555%20L%20495%20552%20L%20501%20541%20L%20482%20555%20L%20471%20558%20L%20464%20558%20L%20461%20560%20L%20460%20559%20L%20461%20555%20L%20469%20547%20L%20473%20537%20L%20491%20512%20L%20511%20497%20L%20582%20434%20L%20617%20408%20L%20632%20399%20L%20659%20386%20L%20677%20380%20L%20695%20377%20L%20712%20377%20L%20725%20380%20L%20739%20388%20Z%20M%20625%20216%20L%20683%20216%20L%20737%20222%20L%20742%20224%20L%20733%20226%20L%20721%20225%20L%20713%20230%20L%20711%20228%20L%20706%20228%20L%20694%20237%20L%20690%20233%20L%20690%20225%20L%20679%20228%20L%20674%20232%20L%20668%20232%20L%20659%20229%20L%20649%20222%20L%20632%20219%20L%20632%20217%20Z%20M%20788%20181%20L%20793%20182%20L%20797%20187%20L%20795%20193%20L%20792%20195%20L%20786%20195%20L%20782%20190%20L%20783%20185%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20607%20972%20L%20603%20981%20L%20603%20995%20L%20608%201003%20L%20610%20994%20L%20616%20987%20L%20620%20985%20L%20627%20985%20L%20635%20982%20L%20655%20981%20L%20676%20989%20L%20683%20996%20L%20689%201006%20L%20695%201007%20L%20697%201009%20L%20698%201024%20L%20694%201034%20L%20699%201032%20L%20706%201025%20L%20712%201010%20L%20710%20994%20L%20709%20997%20L%20706%20994%20L%20700%20994%20L%20694%20997%20L%20672%20976%20L%20658%20974%20L%20647%20967%20L%20642%20974%20L%20638%20974%20L%20636%20972%20L%20636%20961%20L%20629%20963%20L%20631%20972%20L%20625%20977%20L%20620%20977%20L%20613%20967%20L%20614%20966%20Z%20M%20686%20966%20L%20704%20980%20L%20719%201002%20L%20727%201004%20L%20730%201007%20L%20731%201023%20L%20728%201032%20L%20731%201030%20L%20741%201017%20L%20743%201003%20L%20748%20992%20L%20748%20981%20L%20742%20967%20L%20740%20965%20L%20742%20968%20L%20735%20972%20L%20726%20965%20L%20705%20960%20L%20724%20968%20L%20740%20983%20L%20742%20987%20L%20740%20991%20L%20732%20991%20L%20728%20996%20L%20726%20996%20L%20721%20992%20L%20713%20979%20Z%20M%20784%20943%20L%20784%20946%20L%20798%20950%20L%20819%20969%20L%20825%20970%20L%20830%20981%20L%20831%20992%20L%20837%20981%20L%20837%20966%20L%20829%20948%20L%20825%20944%20L%20830%20950%20L%20821%20957%20L%20813%20951%20L%20794%20942%20Z%20M%20659%20933%20L%20662%20937%20L%20658%20942%20L%20658%20945%20L%20663%20947%20L%20666%20945%20L%20667%20946%20L%20668%20944%20L%20670%20946%20Z%20M%20643%20913%20L%20647%20918%20L%20644%20921%20L%20642%20928%20L%20629%20938%20L%20627%20936%20L%20636%20947%20L%20634%20945%20L%20641%20933%20L%20651%20923%20L%20657%20930%20Z%20M%20936%20310%20L%20934%20309%20L%20945%20338%20L%20949%20368%20L%20949%20381%20L%20947%20383%20L%20935%20367%20L%20914%20348%20L%20929%20377%20L%20934%20397%20L%20936%20414%20L%20935%20440%20L%20933%20442%20L%20930%20440%20L%20924%20419%20L%20912%20395%20L%20909%20393%20L%20910%20410%20L%20907%20433%20L%20899%20458%20L%20895%20462%20L%20893%20460%20L%20892%20445%20L%20888%20427%20L%20873%20390%20L%20873%20416%20L%20871%20430%20L%20866%20448%20L%20862%20454%20L%20859%20452%20L%20853%20433%20L%20842%20410%20L%20823%20382%20L%20807%20365%20L%20805%20366%20L%20811%20394%20L%20812%20416%20L%20810%20425%20L%20806%20428%20L%20801%20423%20L%20790%20403%20L%20772%20383%20L%20759%20372%20L%20733%20357%20L%20724%20355%20L%20705%20346%20L%20693%20344%20L%20669%20344%20L%20646%20349%20L%20636%20353%20L%20662%20349%20L%20677%20349%20L%20699%20353%20L%20708%20356%20L%20725%20366%20L%20736%20376%20L%20745%20389%20L%20753%20415%20L%20752%20442%20L%20743%20476%20L%20723%20520%20L%20693%20569%20L%20646%20631%20L%20605%20676%20L%20568%20709%20L%20565%20710%20L%20562%20706%20L%20562%20692%20L%20567%20665%20L%20578%20636%20L%20602%20619%20L%20622%20602%20L%20645%20578%20L%20670%20546%20L%20630%20588%20L%20603%20610%20L%20574%20628%20L%20560%20633%20L%20556%20633%20L%20555%20631%20L%20563%20617%20L%20596%20572%20L%20647%20509%20L%20636%20515%20L%20562%20609%20L%20541%20630%20L%20520%20645%20L%20502%20653%20L%20490%20653%20L%20536%20590%20L%20513%20617%20L%20478%20651%20L%20454%20665%20L%20440%20669%20L%20436%20667%20L%20488%20596%20L%20459%20630%20L%20436%20653%20L%20411%20671%20L%20392%20678%20L%20372%20701%20L%20319%20772%20L%20289%20820%20L%20281%20838%20L%20282%20844%20L%20295%20841%20L%20324%20825%20L%20326%20826%20L%20289%20878%20L%20242%20954%20L%20209%201016%20L%20193%201056%20L%20191%201069%20L%20192%201071%20L%20196%201071%20L%20219%201056%20L%20303%20983%20L%20305%20984%20L%20255%201057%20L%20234%201094%20L%20228%201111%20L%20228%201124%20L%20234%201132%20L%20240%201134%20L%20254%201134%20L%20275%201128%20L%20279%201133%20L%20291%201137%20L%20316%201136%20L%20344%201128%20L%20364%201118%20L%20389%201101%20L%20403%201089%20L%20427%201064%20L%20447%201038%20L%20463%201013%20L%20489%20993%20L%20594%20901%20L%20595%20899%20L%20593%20894%20L%20588%20891%20L%20567%20868%20L%20569%20865%20L%20576%20867%20L%20586%20873%20L%20589%20867%20L%20607%20867%20L%20619%20880%20L%20622%20887%20L%20626%20891%20L%20624%20889%20L%20626%20886%20L%20666%20870%20L%20705%20909%20L%20710%20905%20L%20713%20905%20L%20716%20908%20L%20716%20911%20L%20712%20916%20L%20728%20932%20L%20730%20939%20L%20727%20943%20L%20717%20944%20L%20710%20949%20L%20712%20948%20L%20725%20951%20L%20739%20963%20L%20740%20961%20L%20756%20960%20L%20774%20966%20L%20784%20975%20L%20789%20983%20L%20800%20987%20L%20802%20991%20L%20802%201005%20L%20799%201012%20L%20806%201008%20L%20811%201002%20L%20815%20993%20L%20813%20968%20L%20812%20973%20L%20807%20971%20L%20796%20976%20L%20791%20973%20L%20788%20967%20L%20779%20958%20L%20767%20952%20L%20762%20941%20L%20756%20940%20L%20751%20932%20L%20749%20931%20L%20743%20936%20L%20738%20936%20L%20736%20933%20L%20741%20925%20L%20739%20915%20L%20742%20912%20L%20745%20914%20L%20702%20865%20L%20702%20863%20L%20717%20841%20L%20719%20842%20L%20709%20861%20L%20746%20837%20L%20783%20807%20L%20826%20764%20L%20851%20732%20L%20853%20734%20L%20846%20754%20L%20851%20751%20L%20874%20728%20L%20890%20708%20L%20908%20681%20L%20938%20621%20L%20960%20560%20L%20971%20521%20L%20979%20481%20L%20982%20444%20L%20977%20405%20L%20970%20382%20L%20966%20375%20L%20968%20374%20L%20974%20381%20L%20975%20368%20L%20974%20372%20L%20968%20364%20L%20966%20354%20L%20957%20337%20Z%20M%20247%201077%20L%20251%201085%20L%20246%201088%20L%20245%201091%20L%20240%201092%20L%20239%201085%20L%20241%201081%20Z%20M%20370%20935%20L%20371%20937%20L%20326%20997%20L%20301%201034%20L%20289%201044%20L%20286%201042%20L%20283%201045%20L%20277%201045%20L%20273%201043%20L%20264%201052%20L%20261%201049%20L%20270%201037%20L%20271%201038%20L%20281%201027%20L%20293%201010%20L%20326%20971%20Z%20M%20726%20921%20L%20728%20921%20L%20731%20926%20L%20729%20933%20L%20722%20926%20Z%20M%20729%20897%20L%20734%20902%20L%20732%20906%20L%20726%20902%20L%20726%20899%20Z%20M%20715%20882%20L%20720%20886%20L%20718%20890%20L%20711%20887%20Z%20M%20605%20762%20L%20608%20761%20L%20607%20760%20L%20609%20757%20L%20610%20759%20L%20617%20761%20L%20620%20764%20L%20611%20770%20L%20607%20770%20L%20606%20765%20L%20608%20765%20Z%20M%20611%20754%20L%20617%20750%20L%20620%20751%20L%20621%20749%20L%20625%20749%20L%20628%20752%20L%20628%20756%20L%20623%20761%20Z%20M%20549%20710%20L%20551%20713%20L%20551%20722%20L%20506%20774%20L%20403%20878%20L%20309%20963%20L%20307%20961%20L%20313%20953%20L%20322%20945%20L%20340%20922%20L%20375%20885%20Z%20M%20695%20704%20L%20696%20708%20L%20698%20709%20L%20695%20710%20L%20695%20713%20L%20692%20715%20L%20688%20710%20Z%20M%20704%20694%20L%20706%20695%20L%20706%20698%20L%20710%20698%20L%20713%20703%20L%20708%20708%20L%20707%20714%20L%20705%20716%20L%20701%20716%20L%20697%20708%20L%20699%20706%20L%20697%20705%20L%20701%20701%20L%20704%20705%20L%20706%20704%20L%20706%20700%20L%20702%20697%20Z%20M%20552%20678%20L%20554%20681%20L%20552%20701%20L%20465%20787%20L%20361%20883%20L%20316%20927%20L%20253%20993%20L%20211%201042%20L%20211%201036%20L%20222%201011%20L%20261%20942%20L%20292%20898%20L%20338%20843%20L%20374%20807%20L%20387%20807%20L%20403%20801%20L%20419%20792%20L%20456%20766%20L%20500%20728%20Z%20M%20704%20654%20L%20706%20658%20L%20711%20658%20L%20714%20661%20L%20715%20673%20L%20713%20676%20L%20705%20676%20L%20702%20674%20L%20704%20677%20L%20704%20681%20L%20702%20682%20L%20704%20685%20L%20700%20686%20L%20694%20678%20L%20691%20678%20L%20688%20674%20L%20692%20670%20L%20692%20664%20L%20694%20661%20Z%20M%20565%20642%20L%20558%20663%20L%20545%20677%20L%20494%20726%20L%20443%20767%20L%20401%20792%20L%20392%20795%20L%20387%20794%20L%20405%20766%20L%20455%20707%20L%20388%20767%20L%20355%20794%20L%20304%20827%20L%20299%20826%20L%20302%20817%20L%20316%20795%20L%20360%20739%20L%20398%20700%20L%20425%20677%20L%20428%20679%20L%20443%20679%20L%20461%20673%20L%20476%20664%20L%20493%20666%20L%20517%20657%20L%20542%20641%20L%20546%20643%20Z%20M%20563%20221%20L%20572%20225%20L%20571%20223%20L%20574%20220%20L%20585%20217%20L%20596%20218%20L%20607%20215%20L%20653%20214%20L%20706%20218%20L%20749%20224%20L%20749%20226%20L%20735%20233%20L%20732%20238%20L%20732%20249%20L%20693%20242%20L%20620%20239%20L%20672%20251%20L%20688%20260%20L%20701%20274%20L%20706%20287%20L%20704%20301%20L%20707%20297%20L%20711%20300%20L%20713%20309%20L%20720%20324%20L%20723%20327%20L%20724%20308%20L%20726%20304%20L%20735%20318%20L%20757%20341%20L%20753%20319%20L%20754%20313%20L%20760%20317%20L%20786%20345%20L%20784%20324%20L%20775%20300%20L%20779%20300%20L%20800%20317%20L%20800%20312%20L%20787%20283%20L%20772%20264%20L%20778%20263%20L%20800%20271%20L%20803%20270%20L%20770%20236%20L%20772%20234%20L%20797%20234%20L%20807%20230%20L%20801%20230%20L%20800%20228%20L%20811%20218%20L%20818%20203%20L%20818%20193%20L%20812%20179%20L%20798%20168%20L%20784%20166%20L%20760%20173%20L%20747%20173%20L%20712%20163%20L%20718%20157%20L%20703%20171%20L%20711%20173%20L%20720%20178%20L%20723%20182%20L%20720%20186%20L%20695%20190%20L%20680%20190%20L%20670%20193%20L%20656%20193%20L%20687%20204%20L%20729%20209%20L%20742%20214%20L%20753%20223%20L%20752%20224%20L%20729%20219%20L%20669%20212%20L%20610%20213%20L%20576%20218%20L%20565%20221%20L%20565%20219%20Z%20M%20771%20189%20L%20772%20201%20L%20775%20207%20L%20780%20212%20L%20787%20215%20L%20796%20216%20L%20796%20218%20L%20784%20219%20L%20776%20215%20L%20771%20210%20L%20768%20204%20L%20768%20194%20Z%20M%20788%20181%20L%20793%20182%20L%20797%20187%20L%20796%20192%20L%20790%20196%20L%20786%20195%20L%20782%20191%20L%20782%20186%20Z'/%3e%3c/g%3e%3c/svg%3e`;function ze({className:e}){return(0,N.jsx)(`span`,{className:`block overflow-hidden rounded-[20.7%] bg-accent ${e??``}`,children:(0,N.jsx)(`img`,{src:Re,alt:``,"aria-hidden":`true`,className:`h-full w-full`})})}function Be(){return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(ze,{className:`h-[22px] w-[22px] shrink-0`}),(0,N.jsx)(`span`,{className:`hidden text-[16px] font-medium tracking-[0.04em] text-ink-50 md:inline`,children:`nightcrow`})]})}function Ve({open:e}){return(0,N.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-3.5 w-3.5 shrink-0 transition-transform ${e?`rotate-90`:``}`,children:(0,N.jsx)(`path`,{d:`m9 18 6-6-6-6`})})}function He({className:e=`h-4 w-4`}){return(0,N.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,N.jsx)(`path`,{d:`M3 6h.01`}),(0,N.jsx)(`path`,{d:`M3 12h.01`}),(0,N.jsx)(`path`,{d:`M3 18h.01`}),(0,N.jsx)(`path`,{d:`M8 6h13`}),(0,N.jsx)(`path`,{d:`M8 12h13`}),(0,N.jsx)(`path`,{d:`M8 18h13`})]})}function Ue({className:e=`h-4 w-4`}){return(0,N.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,N.jsx)(`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`}),(0,N.jsx)(`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`}),(0,N.jsx)(`path`,{d:`M10 9H8`}),(0,N.jsx)(`path`,{d:`M16 13H8`}),(0,N.jsx)(`path`,{d:`M16 17H8`})]})}function We({className:e=`h-4 w-4`}){return(0,N.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,N.jsx)(`path`,{d:`m4 17 6-6-6-6`}),(0,N.jsx)(`path`,{d:`M12 19h8`})]})}function Ge({repos:e,currentId:t,onSelect:n,onCloseProject:r,onOpenPicker:i,className:a=``}){let[o,s]=(0,M.useState)(!1),c=f(),l=(0,M.useRef)(null),u=e.find(e=>e.id===t);return(0,M.useEffect)(()=>{if(!o)return;let e=e=>{e.key===`Escape`&&(s(!1),l.current?.focus())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o]),(0,N.jsxs)(`div`,{className:`relative min-w-0 flex-1 ${a}`,children:[(0,N.jsxs)(`button`,{ref:l,onClick:()=>s(e=>!e),"aria-haspopup":`menu`,"aria-expanded":o,title:u?.display_path??`Select a project`,className:`flex min-w-0 max-w-full items-center gap-1 rounded-sm bg-ink-700 py-0.5 pl-2 pr-1 text-ink-50`,children:[(0,N.jsx)(`span`,{className:`truncate`,children:u?.name??`No project`}),(0,N.jsx)(Ve,{open:o})]}),o&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>s(!1)}),(0,N.jsxs)(`div`,{role:`menu`,className:`nc-pop-in origin-top-left absolute left-0 z-50 mt-1 max-h-[70vh] w-56 max-w-[80vw] overflow-y-auto rounded-md border border-ink-700 bg-ink-900 py-1 shadow-lg`,children:[e.length===0&&(0,N.jsx)(`p`,{className:`px-3 py-1.5 text-ink-400`,children:`No projects open.`}),e.map(e=>(0,N.jsxs)(`div`,{className:`flex items-center ${e.id===t?`bg-ink-700 text-ink-50`:`text-ink-200`}`,children:[(0,N.jsx)(`button`,{role:`menuitem`,onClick:()=>{n(e.id),s(!1)},title:e.display_path,className:`min-w-0 flex-1 truncate py-1.5 pl-3 pr-1 text-left hover:text-accent`,children:e.name}),(0,N.jsx)(`button`,{onClick:()=>r(e.id),"aria-label":`close ${e.name}`,...e.id===t?c(`project.close`,`Close project`):{title:`Close project`},className:`mr-1 flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-removed`,children:(0,N.jsx)(ae,{className:`h-3.5 w-3.5`})})]},e.id)),(0,N.jsx)(`div`,{className:`my-1 border-t border-ink-800`}),(0,N.jsxs)(`button`,{role:`menuitem`,onClick:()=>{i(),s(!1)},...c(`project.openDialog`,`Open a project`),className:`flex w-full items-center gap-1 px-3 py-1.5 text-left text-ink-400 hover:text-ink-200`,children:[(0,N.jsx)(ne,{className:`h-3.5 w-3.5`}),`open`]})]})]})]})}function Ke({side:e,repos:t,repo:n,onSelectRepo:r,onCloseRepo:i,onOpenPicker:a,draggingRepo:o,dragOverRepo:s,onRepoDragStart:u,onRepoDragMove:p,onRepoDragEnd:m}){let h=f(),g=c(),_=t.length>1?[`project.previous`,`project.next`]:[],v=e=>e!==null,b=_.map(e=>_e(e,g)).filter(v),x=_.map(e=>d(e,g)).filter(v),S=e===`left`;return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`nav`,{"aria-keyshortcuts":b.length>0?b.join(` `):void 0,title:x.length>0?`Previous or next project (${x.join(`, `)})`:void 0,className:S?`hidden min-h-0 flex-1 flex-col overflow-y-auto md:flex`:`hidden items-stretch self-stretch overflow-x-auto pl-1 md:flex`,children:t.map(e=>(0,N.jsxs)(`div`,{"data-repo-id":e.id,onPointerDown:t=>u(t,e.id),onPointerMove:p,onPointerUp:m,onPointerCancel:m,onLostPointerCapture:m,"data-active":e.id===n,className:`nc-title-target flex items-center whitespace-nowrap ${S?`min-w-0 border-b border-ink-700`:`border-r border-ink-700`} ${t.length>1?`touch-none`:``} ${o===e.id?`opacity-60`:``} ${s===e.id?`bg-ink-800 ring-1 ring-inset ring-accent`:``} ${e.id===n?S?`bg-ink-900 text-ink-50 shadow-[inset_1px_0_0_0_var(--color-accent)]`:`bg-ink-950 text-ink-50 shadow-[inset_0_-1px_0_0_var(--color-accent)]`:`text-ink-400 hover:bg-ink-850 hover:text-ink-200`}`,title:e.display_path,children:[(0,N.jsx)(`button`,{onClick:()=>{r(e.id)},"aria-label":e.name,className:`self-stretch pl-3 pr-1 text-left ${S?`min-w-0 flex-1 py-2`:``}`,children:(0,N.jsx)(l,{title:e.name,className:S?``:y})}),(0,N.jsx)(`button`,{onClick:t=>{t.stopPropagation(),i(e.id)},"data-tab-close":!0,...e.id===n?h(`project.close`,`Close project`):{title:`Close project`},"aria-label":`close ${e.name}`,className:`mr-1 flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-removed`,children:(0,N.jsx)(ae,{})})]},e.id))}),(0,N.jsxs)(`button`,{onClick:a,...h(`project.openDialog`,`Open a project`),className:`hidden shrink-0 items-center gap-1 rounded-sm px-2 py-0.5 text-ink-400 hover:text-accent md:inline-flex ${S?`mx-1 my-2 justify-center`:``}`,children:[(0,N.jsx)(ne,{className:`h-3.5 w-3.5`}),`open`]})]})}var qe={key:()=>je(`/api/push/key`).then(e=>e.public_key),subscribe:e=>Oe(`/api/push/subscribe`,e),unsubscribe:e=>Oe(`/api/push/unsubscribe`,{endpoint:e}),status:e=>Oe(`/api/push/status`,{endpoint:e}).then(e=>e.subscribed),test:e=>Oe(`/api/push/test`,{endpoint:e})};function Je(){let e=navigator;return{secure:window.isSecureContext,serviceWorker:`serviceWorker`in navigator?navigator.serviceWorker:void 0,hasPushManager:`PushManager`in window,permission:()=>typeof Notification>`u`?void 0:Notification.permission,requestPermission:()=>Notification.requestPermission(),isIos:/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&navigator.maxTouchPoints>1,standalone:e.standalone===!0||window.matchMedia?.(`(display-mode: standalone)`).matches===!0}}function Ye(e){return e.secure?e.isIos&&!e.standalone?`needs-install`:!e.serviceWorker||!e.hasPushManager||e.permission()===void 0?`unsupported`:e.permission()===`denied`?`denied`:null:`insecure`}function Xe(e){e.secure&&e.serviceWorker&&e.serviceWorker.register(`./sw.js`).catch(()=>{})}async function Ze(e){return(await e.serviceWorker.ready).pushManager.getSubscription()}async function Qe(e){let t=Ye(e);if(t)return t;let n=await Ze(e);return n?await qe.status(n.endpoint)?`on`:(await n.unsubscribe().catch(()=>!1),`off`):`off`}async function $e(e){let t=Ye(e);if(t)return t;let n=await e.requestPermission();if(n===`denied`)return`denied`;if(n!==`granted`)return`off`;let r;try{r=await qe.key()}catch{return`unavailable`}let i=await e.serviceWorker.ready;await(await i.pushManager.getSubscription())?.unsubscribe();let a=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:nt(r)});return await qe.subscribe(a.toJSON()),`on`}async function et(e){let t=await Ze(e);return t&&(await qe.unsubscribe(t.endpoint).catch(()=>void 0),await t.unsubscribe().catch(()=>!1)),Ye(e)??`off`}async function tt(e){let t=await Ze(e);if(!t)throw Error(`notifications are off in this browser`);await qe.test(t.endpoint)}function nt(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t+`=`.repeat((4-t.length%4)%4),r=atob(n),i=new Uint8Array(new ArrayBuffer(r.length));for(let e=0;e{let e=!1;return Qe(a).then(t=>!e&&n(t)).catch(()=>!e&&n(`off`)),()=>{e=!0}},[a]);let o=(0,M.useCallback)(async(e,t)=>{i(!0);try{let t=await e();return t&&n(t),!0}catch(e){return D.error(e instanceof Error?`${t}: ${e.message}`:t),!1}finally{i(!1)}},[]);return{state:t,busy:r,enable:()=>o(()=>$e(a),`could not turn notifications on`),disable:()=>o(()=>et(a),`could not turn notifications off`),test:async()=>{await o(()=>tt(a),`could not send a test`)&&D.info(`Test notification sent`)}}}var it={unsupported:`This browser does not support notifications.`,insecure:`Notifications need HTTPS or localhost. See the notifications guide for tailscale serve.`,"needs-install":`On iPhone and iPad, add nightcrow to the Home Screen and open it from there first.`,denied:`Notifications are blocked for this site. Allow them in the browser's site settings.`,unavailable:`The server could not load its notification key. Check the daemon log.`},at=`rounded-sm px-2 py-1 text-ink-200 hover:bg-ink-700 disabled:cursor-progress disabled:text-ink-400 disabled:hover:bg-transparent`;function ot(){let{state:e,busy:t,enable:n,disable:r,test:i}=rt(),a=e?it[e]:void 0;return(0,N.jsxs)(`section`,{"aria-labelledby":`nc-notifications-title`,className:`border-t border-ink-800 px-3 py-2`,children:[(0,N.jsx)(`h3`,{id:`nc-notifications-title`,className:`mb-1 text-xs uppercase tracking-wide text-ink-400`,children:`Notifications`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-200`,children:`When a terminal asks for you`}),(e===`off`||e===`on`)&&(0,N.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e===`on`,"aria-busy":t,disabled:t,onClick:e===`on`?r:n,className:at,children:e===`on`?`On`:`Off`}),e===null&&(0,N.jsx)(`span`,{className:`text-ink-400`,children:`…`})]}),a&&(0,N.jsx)(`p`,{className:`mt-1 text-xs text-ink-400`,children:a}),e===`on`&&(0,N.jsx)(`button`,{type:`button`,disabled:t,onClick:i,className:`mt-1 ${at}`,children:`Send a test notification`})]})}var st=`nc-settings-title`,ct=`nc-settings-dialog`,lt=`nc-screen-scale`;function ut({accent:e,next:t,cycle:n,onReloadConfig:r,reloading:i,onShowShortcuts:a}){let[c,l]=(0,M.useState)(!1),u=(0,M.useRef)(null),d=(0,M.useRef)(null),{scale:p,setScale:m}=ue(),h=f();(0,M.useLayoutEffect)(()=>{if(!c)return;let e=d.current;if(!e)return;e.querySelector(`[data-initial-focus]`)?.focus();let t=()=>[...e.querySelectorAll(`a[href], button:not(:disabled), select:not(:disabled), input:not(:disabled), [tabindex]:not([tabindex="-1"])`)],n=n=>{if(n.key===`Escape`){n.preventDefault(),l(!1),u.current?.focus();return}if(n.key!==`Tab`)return;let r=t(),i=r[0],a=r.at(-1);!i||!a?(n.preventDefault(),e.focus()):n.shiftKey&&document.activeElement===i?(n.preventDefault(),a.focus()):!n.shiftKey&&document.activeElement===a&&(n.preventDefault(),i.focus())},r=t=>{let n=t.target;n instanceof Node&&!e.contains(n)&&!u.current?.contains(n)&&l(!1)};return document.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r),()=>{document.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r)}},[c]);let g=()=>{l(!1),u.current?.focus(),a()};return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`button`,{ref:u,type:`button`,onClick:()=>l(e=>!e),"aria-label":`Settings`,"aria-haspopup":`dialog`,"aria-expanded":c,"aria-controls":ct,title:`Settings`,className:`ml-auto flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-accent`,children:(0,N.jsx)(re,{})}),c&&(0,N.jsxs)(`div`,{ref:d,id:ct,role:`dialog`,"aria-labelledby":st,tabIndex:-1,className:`nc-pop-in origin-top-right fixed right-2 top-[calc(var(--nc-header-h)+8px)] z-50 flex max-h-[calc(100vh-3.75rem)] w-72 max-w-[calc(100vw-1rem)] flex-col overflow-y-auto rounded-md border border-ink-700 bg-ink-900 shadow-xl focus:outline-none`,style:{maxHeight:`calc(100dvh - 3.75rem)`},children:[(0,N.jsx)(`div`,{className:`border-b border-ink-700 px-3 py-2`,children:(0,N.jsx)(`h2`,{id:st,className:`font-medium text-ink-50`,children:`Settings`})}),(0,N.jsxs)(`section`,{"aria-labelledby":`nc-appearance-title`,className:`px-3 py-2`,children:[(0,N.jsx)(`h3`,{id:`nc-appearance-title`,className:`mb-1 text-xs uppercase tracking-wide text-ink-400`,children:`Appearance`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-200`,children:`Accent colour`}),(0,N.jsxs)(`button`,{type:`button`,"data-initial-focus":!0,onClick:n,...h(`session.cycleAccent`,`Accent: ${e.name} (click for ${t.name})`),"aria-label":`accent colour: ${e.name}, click for ${t.name}`,className:`flex items-center gap-1.5 rounded-sm px-2 py-1 text-ink-200 hover:bg-ink-700`,children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-3 rounded-full bg-accent ring-1 ring-ink-600`}),e.name]})]}),(0,N.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,N.jsx)(`label`,{htmlFor:lt,className:`min-w-0 flex-1 text-ink-200`,children:`Screen scale`}),(0,N.jsxs)(`div`,{className:`relative`,children:[(0,N.jsx)(`select`,{id:lt,"aria-label":`Screen scale`,value:p,onChange:e=>m(Number(e.currentTarget.value)),className:`appearance-none rounded-sm border border-ink-700 bg-ink-850 py-1 pl-2 pr-7 text-ink-50 focus:border-accent focus:outline-none`,children:o.map(e=>(0,N.jsxs)(`option`,{value:e,children:[e,`%`]},e))}),(0,N.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 right-2 flex items-center text-ink-400`,children:(0,N.jsx)(Ve,{open:!0})})]})]})]}),(0,N.jsx)(ot,{}),(0,N.jsxs)(`div`,{className:`border-t border-ink-800 px-3 py-2`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:r,disabled:i,"aria-busy":i,...h(`session.reloadConfig`,`Reload config.toml on the server (does not reload this page)`),"aria-label":`reload the server config`,className:`flex w-full items-center gap-2 rounded-sm py-1.5 text-left text-ink-200 hover:bg-ink-700 disabled:cursor-progress disabled:text-ink-400 disabled:hover:bg-transparent`,children:[(0,N.jsx)(fe,{className:`h-3.5 w-3.5 ${i?`animate-spin`:``}`}),`Reload config.toml`]}),(0,N.jsxs)(`button`,{type:`button`,onClick:g,...h(`help.shortcuts`,`Keyboard shortcuts`),"aria-label":`keyboard shortcuts`,className:`mt-1 flex w-full items-center gap-2 rounded-sm py-1.5 text-left text-ink-200 hover:bg-ink-700`,children:[(0,N.jsx)(s,{className:`h-3.5 w-3.5`}),`Keyboard shortcuts`]})]})]})]})}function dt(e){return e===`top`||e===`left`?e:null}function ft(e){return e===`top`?`left`:`top`}function pt({repos:e,repo:t,onSelectRepo:n,onCloseRepo:r,onOpenPicker:i,cloning:a,accent:o,next:s,cycle:c,draggingRepo:l,dragOverRepo:u,onRepoDragStart:d,onRepoDragMove:f,onRepoDragEnd:p,onReloadConfig:m,reloading:h,onShowShortcuts:g,tabStrip:_}){return(0,N.jsxs)(`header`,{className:`flex h-(--nc-header-h) items-center gap-2 border-b border-chrome-line bg-ink-900 px-[12.8px]`,children:[(0,N.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,N.jsx)(Be,{})}),(0,N.jsx)(Ge,{className:`md:hidden`,repos:e,currentId:t,onSelect:n,onCloseProject:r,onOpenPicker:i}),_.side===`top`&&(0,N.jsx)(Ke,{side:`top`,repos:e,repo:t,onSelectRepo:n,onCloseRepo:r,onOpenPicker:i,draggingRepo:l,dragOverRepo:u,onRepoDragStart:d,onRepoDragMove:f,onRepoDragEnd:p}),a&&(0,N.jsxs)(`span`,{role:`status`,title:`A clone is running on the server`,className:`flex shrink-0 items-center gap-1.5 px-2 py-0.5 text-ink-400`,children:[(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 animate-pulse rounded-full bg-accent`}),`Cloning…`]}),(0,N.jsx)(ut,{accent:o,next:s,cycle:c,onReloadConfig:m,reloading:h,onShowShortcuts:g}),(0,N.jsx)(`button`,{onClick:_.toggle,title:`Project tabs ${_.side===`top`?`across the top`:`down the left`} (click to move them ${ft(_.side)})`,"aria-label":`project tabs: ${_.side}, click for ${ft(_.side)}`,"aria-pressed":_.side===`left`,className:`ml-1 hidden h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-accent md:flex`,children:(0,N.jsx)(Ee,{side:_.side})}),(0,N.jsx)(`a`,{href:`/logout`,title:`Sign out`,"aria-label":`sign out`,className:`ml-1 flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-accent`,children:(0,N.jsx)(he,{})})]})}var mt=[`w-3/5`,`w-2/5`,`w-4/5`,`w-1/2`,`w-3/4`,`w-1/3`,`w-2/3`];function ht({className:e=``}){return(0,N.jsx)(`span`,{"aria-hidden":`true`,className:`nc-skeleton block h-2.5 rounded-xs ${e}`})}function gt({rows:e=6,as:t=`div`,className:n=``}){let r=t;return(0,N.jsx)(N.Fragment,{children:Array.from({length:e},(e,t)=>(0,N.jsxs)(r,{"aria-hidden":`true`,className:`flex items-center gap-2 px-3 py-1.5 ${n}`,children:[(0,N.jsx)(ht,{className:`w-3 shrink-0`}),(0,N.jsx)(ht,{className:mt[t%mt.length]})]},t))})}function _t(){return(0,N.jsxs)(`div`,{"aria-busy":`true`,"aria-label":`Loading`,className:`flex h-full flex-col`,children:[(0,N.jsxs)(`div`,{className:`flex h-(--nc-header-h) shrink-0 items-center gap-2 border-b border-chrome-line bg-ink-900 px-[12.8px]`,children:[(0,N.jsx)(ht,{className:`h-[22px] w-[22px] shrink-0 rounded-sm`}),(0,N.jsx)(ht,{className:`hidden w-24 md:block`}),(0,N.jsx)(ht,{className:`w-28 md:hidden`}),(0,N.jsx)(ht,{className:`ml-auto h-4 w-4 shrink-0`}),(0,N.jsx)(ht,{className:`ml-1 h-4 w-4 shrink-0`})]}),(0,N.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 grid-rows-[minmax(0,1fr)] md:grid-cols-[18rem_minmax(0,1fr)] md:grid-rows-[minmax(0,3fr)_minmax(0,2fr)]`,children:[(0,N.jsx)(`div`,{className:`overflow-hidden border-chrome-line py-2 md:border-r`,children:(0,N.jsx)(gt,{rows:10})}),(0,N.jsx)(`div`,{className:`hidden overflow-hidden py-2 md:block`,children:(0,N.jsx)(gt,{rows:14})}),(0,N.jsxs)(`div`,{className:`hidden overflow-hidden border-t border-chrome-line md:col-span-2 md:block`,children:[(0,N.jsxs)(`div`,{className:`flex h-8 items-center gap-2 border-b border-chrome-line px-3`,children:[(0,N.jsx)(ht,{className:`w-30`}),(0,N.jsx)(ht,{className:`w-30`})]}),(0,N.jsx)(`div`,{className:`py-2`,children:(0,N.jsx)(gt,{rows:5})})]})]}),(0,N.jsx)(`div`,{className:`flex shrink-0 border-t border-chrome-line bg-ink-900 md:hidden`,children:[0,1,2].map(e=>(0,N.jsxs)(`div`,{className:`flex min-h-11 flex-1 flex-col items-center justify-center gap-1 py-1`,children:[(0,N.jsx)(ht,{className:`h-5 w-5`}),(0,N.jsx)(ht,{className:`h-2 w-10`})]},e))})]})}function vt({onSuccess:e}){let[t,n]=(0,M.useState)(``),[r,i]=(0,M.useState)(null),[a,o]=(0,M.useState)(!1);return(0,N.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,N.jsxs)(`form`,{onSubmit:async n=>{n.preventDefault(),o(!0),i(null);try{await j.login(t),e()}catch(e){i(e instanceof Error?e.message:`login failed`)}finally{o(!1)}},className:`w-[17rem] max-w-[86vw]`,children:[(0,N.jsx)(ze,{className:`mx-auto mb-3 block h-10 w-10`}),(0,N.jsx)(`h1`,{className:`text-center text-lg font-medium tracking-wide text-ink-50`,children:`nightcrow`}),(0,N.jsx)(`p`,{className:`mt-1 mb-5 text-center text-caption text-ink-400 uppercase`,children:`web viewer`}),r&&(0,N.jsx)(`p`,{className:`mb-2.5 text-center text-removed`,children:r}),(0,N.jsx)(`input`,{type:`password`,autoFocus:!0,value:t,onChange:e=>n(e.target.value),placeholder:`password`,className:`mb-2 w-full rounded-sm border border-ink-700 bg-ink-900 px-2.5 py-1.5 outline-none placeholder:text-ink-400 focus:border-accent focus:ring-[3px] focus:ring-accent/15`}),(0,N.jsx)(`button`,{"aria-busy":a,type:`submit`,disabled:a,className:`w-full rounded-sm bg-ink-50 py-1.5 font-semibold text-ink-950 hover:bg-white disabled:opacity-50`,children:(0,N.jsx)(A,{busy:a,children:`Sign in`})})]})})}var yt=`nightcrow.sidebarWidth`,bt=.5;function xt(e){return Math.min(Math.max(Math.round(e),280),720)}function St(e){let t=720;try{t=Math.min(t,Math.round(window.innerWidth*bt))}catch{}return Math.min(Math.max(Math.round(e),280),Math.max(t,280))}function Ct(){let e=Number(m(yt));return Number.isFinite(e)&&e>0?xt(e):460}function wt(e){h(yt,String(e))}function Tt(){let[e,t]=(0,M.useState)(Ct),n=(0,M.useCallback)(e=>{let n=St(e);t(n),wt(n)},[]);return{width:e,resize:n,commit:n,reset:(0,M.useCallback)(()=>{let e=xt(460);t(e),wt(e)},[])}}var Et=`[data-terminal-panel]`,Dt=`dialog[open], [role="dialog"], [aria-modal="true"]`,Ot=`input, textarea, select, [contenteditable], [role="textbox"], [role="searchbox"], [role="combobox"]`,kt=`data-focus-region`;function At(e){return{"data-focus-region":e,tabIndex:-1}}function jt(e){if(!(e instanceof Element)||e.closest(`[data-terminal-panel]`))return null;let t=e.closest(Ot)??e;return{tagName:t.tagName,isContentEditable:Ft(t),role:t.getAttribute(`role`),type:It(t),inDialog:e.closest(Dt)!==null}}function Mt(e=document){return Nt(e)===`terminal`}function Nt(e=document){let t=e.activeElement;if(!t)return null;if(t.closest(`[data-terminal-panel]`))return`terminal`;let n=t.closest(`[${kt}]`)?.getAttribute(kt);return n===`list`||n===`content`?n:null}function Pt(e,t=document){let n=t.querySelector(`[${kt}="${e}"]`);if(!n)return!1;let r=a(t.activeElement,t.querySelector(Et));return Ce(r)?(n.focus(),!0):!1}function Ft(e){let t=e.getAttribute(`contenteditable`);return t===null?e.isContentEditable===!0:t!==`false`}function It(e){return e.tagName===`INPUT`?e.type?.toLowerCase()??null:null}var Lt=600;function Rt(e){let[t,n]=(0,M.useState)({scrollTop:0,height:Lt}),r=(0,M.useCallback)(()=>{let t=e.current;if(!t)return;let r={scrollTop:t.scrollTop,height:t.clientHeight||Lt};n(e=>e.scrollTop===r.scrollTop&&e.height===r.height?e:r)},[e]);return(0,M.useLayoutEffect)(()=>{r();let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(r);return n.observe(t),()=>n.disconnect()},[e,r]),{viewport:t,refresh:r}}function zt(){let e=new Map;return{start(t){let n=(e.get(t)??0)+1;return e.set(t,n),n},isCurrent(t,n){return e.get(t)===n}}}var Bt={children:{},expanded:new Set};function Vt(e,t,n){return{...e,children:{...e.children,[t]:n}}}function Ht(e,t){let n=new Set(e);return n.delete(t)||n.add(t),n}function Ut(e,t){return{...e,expanded:Ht(e.expanded,t)}}function Wt(e,t){let n=new Set(e.expanded);return t.forEach(e=>n.add(e)),{...e,expanded:n}}function Gt(e){let t=[],n=``;for(let r of e.split(`/`))n=n?`${n}/${r}`:r,t.push(n);return t}var Kt=180,qt={items:[],truncated:!1};function Jt({repo:e,authed:t,tab:n,filter:r,filterOpen:i,handle:a}){let[o,s]=(0,M.useState)(Bt),[c,l]=(0,M.useState)(qt),[u,d]=(0,M.useState)(!1),[f]=(0,M.useState)(zt);(0,M.useEffect)(()=>{if(!e||!t||n!==`tree`||!i||!r){l(qt),d(!1);return}d(!0);let o=!0,s=setTimeout(()=>{j.treeSearch(e,r).then(e=>{o&&l({items:e.matches,truncated:e.truncated})}).catch(e=>{o&&a(e)}).finally(()=>{o&&d(!1)})},Kt);return()=>{o=!1,clearTimeout(s)}},[e,t,n,r,i,a]);let p=(0,M.useCallback)((t,n)=>{if(!e)return;let r=f.start(t);j.tree(e,t).then(e=>{f.isCurrent(t,r)&&s(n=>Vt(n,t,e.entries))}).catch(e=>{if(!f.isCurrent(t,r)||n?.restoring)return Me(e)?a(e):void 0;a(e)})},[e,a,f]);(0,M.useEffect)(()=>{e&&t&&n===`tree`&&p(``)},[e,t,n,p]);let m=(0,M.useCallback)(e=>{let t=!o.expanded.has(e);s(t=>Ut(t,e)),t&&!(e in o.children)&&p(e)},[o,p]),h=(0,M.useCallback)(e=>{s(t=>({...t,expanded:new Set(e)})),e.forEach(e=>{e in o.children||p(e,{restoring:!0})})},[o,p]),g=(0,M.useCallback)(e=>{let t=Gt(e);s(e=>Wt(e,t)),t.forEach(e=>{e in o.children||p(e)})},[o,p]);return{treeChildren:o.children,treeExpanded:o.expanded,treeMatches:c.items,treeTruncated:c.truncated,treeSearchLoading:u,loadTreeChildren:p,toggleTreeDir:m,revealTreeDir:g,seedTreeExpanded:h}}function Yt(e,t){let n=[],r=(i,a)=>{for(let o of e[i]??[]){let e=i?`${i}/${o.name}`:o.name;n.push({path:e,name:o.name,is_dir:o.is_dir,depth:a}),o.is_dir&&t.has(e)&&r(e,a+1)}};return r(``,0),n}var Xt=[`status`,`log`,`tree`],P={status:`Show the working-tree status`,log:`Show the commit log`,tree:`Show the file tree`};function Zt(e){return e===`log`?`view.toggleLog`:e===`tree`?`view.toggleTree`:null}function Qt({tab:e,onChoose:t,filterOpen:n,onToggleFilter:r}){let i=f();return(0,N.jsxs)(`div`,{className:`flex shrink-0 items-stretch border-b border-chrome-line px-2`,children:[Xt.map(n=>{let r=Zt(n);return(0,N.jsx)(`button`,{onClick:()=>t(n),"aria-current":n===e?`page`:void 0,...r&&n!==e?i(r,P[n]):{title:P[n]},className:`px-2 py-1.5 ${n===e?`text-ink-50 shadow-[inset_0_-1px_0_0_var(--color-accent)]`:`text-ink-400 hover:text-ink-200`}`,children:n},n)}),(0,N.jsx)(`button`,{onClick:r,"aria-pressed":n,title:n?`Hide the filter`:`Filter the list`,"aria-label":n?`Hide the filter`:`Filter the list`,className:`my-1 ml-auto flex shrink-0 items-center rounded-sm px-1.5 hover:text-accent ${n?`text-ink-50`:`text-ink-400`}`,children:(0,N.jsx)(k,{})})]})}function $t({path:e,from:t,className:n}){return(0,N.jsx)(`span`,{className:`whitespace-nowrap ${n??``}`,title:t?`${t} → ${e}`:e,children:t?`${t} → ${e}`:e})}var en=1e3;function tn(e,t){return e===void 0||e<=0?0:e-t}function nn(e,t,n){let r=tn(t,n);return e===null||Math.abs(r-e)>=1e3?r:e}function rn(e,t,n){if(e===void 0)return`cool`;let r=Math.max(0,t-e);return r>=n?`cool`:r<5e3?`fresh`:`warm`}function an(e,t,n){return e.some(e=>rn(e,t,n)!==`cool`)}var on={fresh:`text-accent font-bold`,warm:`text-accent`,cool:``};function sn(e,t,n){let[r,i]=(0,M.useState)(()=>Date.now()+n);return(0,M.useEffect)(()=>{if(t<=0||!e)return;let r=e.map(e=>e.mtime),a=Date.now()+n;if(i(a),!an(r,a,t))return;let o=setInterval(()=>{let e=Date.now()+n;i(e),an(r,e,t)||clearInterval(o)},en);return()=>clearInterval(o)},[e,t,n]),r}function cn(e){return e.startsWith(`not a git repository`)?`Not a git repository. Run git init here to track changes.`:`Status unavailable: ${e}`}function ln(e){let t=Math.max(0,Math.floor(Date.now()/1e3-e));return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:t<2592e3?`${Math.floor(t/86400)}d`:t<31536e3?`${Math.floor(t/2592e3)}mo`:`${Math.floor(t/31536e3)}y`}function un(e){return e===`+`?`bg-added/10`:e===`-`?`bg-removed/10`:``}function dn(e){return e===`?`?`text-ink-400`:e===`D`?`text-removed`:e===`A`?`text-added`:`text-accent`}function fn(e,t,n,r=20,i=12){let a=Math.max(1,Math.ceil(n/r)),o=Math.min(Math.floor(Math.max(0,t)/r),Math.max(0,e-a)),s=o+a,c=Math.max(0,Math.min(e,o-i)),l=Math.max(c,Math.min(e,s+i));return{start:c,end:l,before:c*r,after:(e-l)*r}}function pn(e){return Math.max(0,e-1)*20}function mn({status:e,files:t,hotWindowMs:n,clockSkewMs:r,viewport:i,openDiff:a}){let o=sn(t,n,r);if(e===null)return(0,N.jsx)(gt,{as:`li`,rows:8});if(e.unavailable!==void 0)return(0,N.jsx)(`li`,{className:`nc-fade-in px-3 py-1 text-ink-400`,children:cn(e.unavailable)});let s=t.length>200?fn(t.length,i.scrollTop,i.height):null,c=s?.start??0,l=s?t.slice(s.start,s.end):t;return(0,N.jsxs)(N.Fragment,{children:[s&&(0,N.jsx)(`li`,{"aria-hidden":`true`,"data-virtual-count":t.length,style:{height:s.before}}),l.map((e,t)=>{let r=c+t;return(0,N.jsx)(`li`,{"data-virtual-row":s?r:void 0,children:(0,N.jsxs)(`button`,{onClick:()=>a(e.path),className:`flex w-max min-w-full gap-2 px-3 py-0.5 text-left hover:bg-ink-850`,children:[(0,N.jsxs)(`span`,{className:`shrink-0`,children:[(0,N.jsx)(`span`,{className:dn(e.index),children:e.index===` `?` `:e.index}),(0,N.jsx)(`span`,{className:dn(e.worktree),children:e.worktree===` `?` `:e.worktree})]}),(0,N.jsx)($t,{path:e.path,from:e.old_path,className:on[rn(e.mtime,o,n)]})]})},e.path)}),s&&(0,N.jsx)(`li`,{"aria-hidden":`true`,style:{height:s.after}}),e.truncated&&(0,N.jsxs)(`li`,{className:`px-3 py-1 text-accent`,children:[`Showing the first `,e.files.length,` changed files.`]})]})}var hn={merge:`MERGING`,rebase:`REBASING`,"cherry-pick":`CHERRY-PICKING`,revert:`REVERTING`,bisect:`BISECTING`,am:`APPLYING`};function gn(e){let t=e?.operation,n=t?t.step!==void 0&&t.total!==void 0?`${hn[t.kind]} ${t.step}/${t.total}`:hn[t.kind]:null,r=e?.conflicts??0,i=r===0?null:r===1?`1 conflict`:`${r} conflicts`;return n&&i?`${n} · ${i}`:n??i}function _n(e){return e.kind===`head`&&e.name!==`HEAD`?`HEAD → ${e.name}`:e.name}function vn(e){switch(e){case`head`:return`border-accent text-accent font-medium`;case`local`:return`border-added/60 text-added`;case`tag`:return`border-ink-600 text-ink-200`;case`remote`:return`border-ink-700 text-ink-400`}}function yn({visibleCommits:e,decorations:t,commits:n,commitDrillDown:r,visibleCommitFiles:i,logDone:a,logStalled:o,logPagingPaused:s,viewport:c,setLogStalled:l,logSentinelRef:u,openCommitFiles:d,openCommit:f,openCommitFileDiff:p,setCommitDrillDown:m,setPaneEmpty:h,bumpPaneRequest:g}){let _=!r&&e.length>200?fn(e.length,c.scrollTop,c.height):null,v=_?e.slice(_.start,_.end):e,y=_?.start??0,b=r&&i.length>200?fn(i.length,c.scrollTop,c.height):null,x=b?i.slice(b.start,b.end):i,S=b?.start??0;return(0,N.jsxs)(N.Fragment,{children:[!r&&_&&(0,N.jsx)(`li`,{"aria-hidden":`true`,"data-virtual-count":e.length,style:{height:_.before}}),!r&&v.map((e,n)=>{let r=y+n,i=t.divergenceOf(e.oid);return(0,N.jsx)(`li`,{"data-virtual-row":_?r:void 0,children:(0,N.jsxs)(`button`,{onClick:()=>void d(e),title:`${e.author} · ${e.summary}`,className:`flex w-max min-w-full items-baseline gap-2 px-3 py-0.5 text-left hover:bg-ink-850`,children:[(0,N.jsx)(`span`,{className:`w-2 shrink-0 ${i===`behind`?`text-accent`:`text-added`}`,title:i===`ahead`?`Not on the upstream yet`:i===`behind`?`On the upstream, not here yet`:void 0,children:i===`ahead`?`↑`:i===`behind`?`↓`:``}),(0,N.jsx)(`span`,{className:`shrink-0 text-accent`,children:e.short_id}),(0,N.jsx)(`span`,{className:`w-10 shrink-0 text-right text-ink-400`,children:ln(e.time)}),(0,N.jsx)(`span`,{className:`max-w-[6rem] shrink-0 truncate text-ink-400`,children:e.author}),t.refsOf(e.oid)?.map(e=>(0,N.jsx)(`span`,{className:`shrink-0 self-center rounded-sm border px-1 text-2xs ${vn(e.kind)}`,children:_n(e)},`${e.kind}:${e.name}`)),(0,N.jsx)(`span`,{className:`whitespace-nowrap ${e.merge?`text-ink-400`:``}`,children:e.summary})]})},e.oid)}),!r&&_&&(0,N.jsx)(`li`,{"aria-hidden":`true`,style:{height:_.after}}),!r&&t.truncated&&(0,N.jsx)(`li`,{className:`px-3 py-1 text-2xs text-ink-400`,children:`Too many refs to mark them all — some branch, tag or upstream marks are not shown.`}),!r&&!a&&!o&&!s&&(0,N.jsxs)(`li`,{ref:u,className:`flex flex-col gap-2 px-3 py-1.5`,"aria-hidden":`true`,children:[(0,N.jsx)(ht,{className:`w-3/5`}),(0,N.jsx)(ht,{className:`w-2/5`}),(0,N.jsx)(ht,{className:`w-1/2`})]}),!r&&!a&&!o&&s&&(0,N.jsxs)(`li`,{className:`px-3 py-1 text-ink-400`,children:[`filtering `,n.length,` loaded commits — clear the filter to load more`]}),!r&&o&&(0,N.jsx)(`li`,{className:`px-3 py-1`,children:(0,N.jsx)(`button`,{onClick:()=>l(!1),className:`text-ink-400 hover:text-accent`,children:`could not load more — retry`})}),r&&(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`li`,{className:`sticky top-0 z-10 flex w-max min-w-full items-center gap-1 bg-ink-900 px-2 py-1 text-ink-400`,children:[(0,N.jsx)(`button`,{onClick:()=>{g(),m(null),h()},className:`rounded-sm px-1 hover:text-accent`,title:`Back to commit log`,children:`< log`}),(0,N.jsx)(`span`,{className:`text-ink-600`,children:`·`}),(0,N.jsx)(`span`,{className:`shrink-0 text-accent`,children:r.commit.short_id}),(0,N.jsx)(`button`,{onClick:()=>f(r.commit.oid),className:`rounded-sm px-1 hover:text-accent`,title:`Show the complete commit diff`,children:`all changes`})]}),b&&(0,N.jsx)(`li`,{"aria-hidden":`true`,"data-virtual-count":i.length,style:{height:b.before}}),x.map((e,t)=>{let n=S+t;return(0,N.jsx)(`li`,{"data-virtual-row":b?n:void 0,children:(0,N.jsxs)(`button`,{onClick:()=>p(r.commit.oid,e.path),className:`flex w-max min-w-full gap-2 px-3 py-0.5 text-left hover:bg-ink-850`,children:[(0,N.jsx)(`span`,{className:dn(e.index),children:e.index}),(0,N.jsx)($t,{path:e.path,from:e.old_path})]})},e.path)}),b&&(0,N.jsx)(`li`,{"aria-hidden":`true`,style:{height:b.after}}),r.files.length===0&&(0,N.jsx)(`li`,{className:`px-3 py-2 text-ink-400`,children:`No changed files.`}),r.files.length>0&&i.length===0&&(0,N.jsx)(`li`,{className:`px-3 py-2 text-ink-400`,children:`No matching files.`}),r.truncated&&(0,N.jsxs)(`li`,{className:`px-3 py-1 text-accent`,children:[`Showing the first `,r.files.length,` files.`]})]})]})}function bn({treeSearching:e,treeMatches:t,treeTruncated:n,treeSearchLoading:r,treeRows:i,treeExpanded:a,openFile:o,revealTreeDir:s,toggleTreeDir:c}){return e?(0,N.jsxs)(N.Fragment,{children:[t.map(e=>(0,N.jsx)(`li`,{children:(0,N.jsx)(`button`,{onClick:()=>{e.is_dir?s(e.path):o(e.path)},title:e.path,className:`w-max min-w-full whitespace-nowrap px-3 py-0.5 text-left hover:bg-ink-850`,children:e.is_dir?(0,N.jsxs)(`span`,{className:`text-accent`,children:[e.path,`/`]}):e.path})},e.path)),t.length===0&&(0,N.jsx)(`li`,{className:`px-3 py-0.5 text-ink-400`,children:r?`searching…`:`no matches`}),n&&(0,N.jsxs)(`li`,{className:`px-3 py-0.5 text-ink-400`,children:[`showing the first `,t.length,` matches`]})]}):(0,N.jsx)(N.Fragment,{children:i.map(e=>(0,N.jsx)(`li`,{children:(0,N.jsxs)(`button`,{onClick:()=>e.is_dir?c(e.path):o(e.path),title:e.path,style:{paddingLeft:`${e.depth*.75+.5}rem`},className:`flex w-max min-w-full items-center gap-1 py-0.5 pr-3 text-left hover:bg-ink-850`,children:[e.is_dir?(0,N.jsx)(Ve,{open:a.has(e.path)}):(0,N.jsx)(`span`,{className:`h-3.5 w-3.5 shrink-0`}),(0,N.jsx)(`span`,{className:`whitespace-nowrap ${e.is_dir?`text-accent`:``}`,children:e.is_dir?`${e.name}/`:e.name})]})},e.path))})}function xn(e){let{tab:t,chooseTab:n,filter:r,setFilter:i,filterOpen:a,setFilterOpen:o,status:s,files:c,hotWindowMs:l,clockSkewMs:u,openDiff:d,openFile:f,openCommit:p,openCommitFileDiff:m,openCommitFiles:h,repo:g,authed:_,handle:v,sidebarRef:y,draggingSidebar:b,onSidebarDragStart:x,onSidebarDragMove:S,onSidebarDragEnd:C,onSidebarDragCancel:w,filesMax:T,bumpPaneRequest:E,commits:ee,logDone:te,logStalled:ne,setLogStalled:re,commitDrillDown:ie,setCommitDrillDown:ae,logSentinelRef:oe,visibleCommits:se,decorations:D,logPagingPaused:ce,visibleCommitFiles:le,mobileView:ue,restoreTree:de,restoreKnown:fe,onTreeExpanded:pe,clearPane:me,touched:he}=e,ge=Jt({repo:g,authed:_,tab:t,filter:r,filterOpen:a,handle:v}),_e=(0,M.useRef)(null),{viewport:ve,refresh:ye}=Rt(_e),be=t===`tree`&&a&&r!==``,xe=Yt(ge.treeChildren,ge.treeExpanded),{seedTreeExpanded:O}=ge,k=(0,M.useRef)(!1);(0,M.useEffect)(()=>{k.current||fe&&!he&&t===`tree`&&(k.current=!0,de.length!==0&&O(de))},[t,fe,he,de,O]);let Se=e=>{pe([...Ht(ge.treeExpanded,e)]),ge.toggleTreeDir(e)},Ce=e=>{let t=new Set(ge.treeExpanded);Gt(e).forEach(e=>t.add(e)),pe([...t]),ge.revealTreeDir(e)},we=()=>{a&&i(``),o(e=>!e)};return(0,N.jsxs)(`section`,{ref:y,...At(`list`),className:`nc-fade-in relative min-h-0 flex-col overflow-hidden ${ue===`files`?`flex`:`hidden md:flex`} ${T?`md:flex`:`border-chrome-line md:border-r`}`,children:[!T&&(0,N.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the file sidebar (double-click to reset)`,title:`Drag to resize · double-click to reset`,onPointerDown:x,onPointerMove:S,onPointerUp:C,onPointerCancel:w,onLostPointerCapture:C,className:`absolute -right-px top-0 z-20 hidden h-full w-1.5 cursor-col-resize touch-none md:block ${b?`bg-accent`:`hover:bg-accent`}`}),(0,N.jsx)(Qt,{tab:t,onChoose:n,filterOpen:a,onToggleFilter:we}),a&&(0,N.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`filter…`,autoFocus:!0,className:`mx-2 mb-1 shrink-0 rounded-sm bg-ink-850 px-2 py-1 outline-none placeholder:text-ink-400 focus:ring-1 focus:ring-accent`}),(0,N.jsxs)(`ul`,{ref:_e,onScroll:ye,className:`nc-content min-h-0 flex-1 overflow-auto`,children:[t===`status`&&(0,N.jsx)(mn,{status:s,files:c,hotWindowMs:l,clockSkewMs:u,viewport:ve,openDiff:d}),t===`log`&&(0,N.jsx)(yn,{visibleCommits:se,decorations:D,commits:ee,commitDrillDown:ie,visibleCommitFiles:le,logDone:te,logStalled:ne,logPagingPaused:ce,viewport:ve,setLogStalled:re,logSentinelRef:oe,openCommitFiles:h,openCommit:p,openCommitFileDiff:m,setCommitDrillDown:ae,setPaneEmpty:me,bumpPaneRequest:E}),t===`tree`&&(0,N.jsx)(bn,{treeSearching:be,treeMatches:ge.treeMatches,treeTruncated:ge.treeTruncated,treeSearchLoading:ge.treeSearchLoading,treeRows:xe,treeExpanded:ge.treeExpanded,openFile:f,revealTreeDir:Ce,toggleTreeDir:Se})]})]})}function Sn(e){let t=[],n=[],r=[],i=()=>{let e=Math.max(n.length,r.length);for(let i=0;i{t(e=>e===`split`?`unified`:`split`)},[])}}var wn=[`.md`,`.markdown`],Tn=[`.html`,`.htm`];function En(e){let t=e.toLowerCase();return wn.some(e=>t.endsWith(e))}function Dn(e){let t=e.toLowerCase();return Tn.some(e=>t.endsWith(e))}function On(e){return En(e)||Dn(e)}function kn(e){return e.map(e=>e.map(e=>e.t).join(``)).join(` -`)}function An(e,t=0){if(new Set(e.hunks.map(t=>t.file_path??e.path)).size>1)return null;for(let n of e.hunks.slice(Math.max(0,t)))for(let e of n.lines)if(e.new_lineno!==void 0)return e.new_lineno;return null}function jn(e){return Math.max(0,e-1-2)}function Mn(e,t){return t<=0?null:Math.min(e,t)}function Nn(e,t){let n=0;return e.forEach((e,r)=>{e<=t&&(n=r)}),n}function Pn(e){return e.kind===`empty`||!e.source?null:{want:e.kind===`diff`?`file`:`diff`,source:e.source}}function Fn(e){return e.index!==`D`&&e.worktree!==`D`}function In(e){return e.hunks.some(e=>e.lines.some(e=>e.old_lineno!==void 0||e.new_lineno!==void 0))}function Ln(e){return e.kind===`workdir`?`workdir:${e.path}`:`commit:${e.oid}:${e.path}`}function Rn({pane:e,previewRendered:t,setPreviewRendered:n,filesMax:r,setMaximized:i,onShowOtherFace:a,canEdit:o,editing:s,onToggleEdit:c}){let l=Cn(),d=f();return(0,N.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[Pn(e)&&(0,N.jsx)(`button`,{onClick:a,"aria-pressed":e.kind===`file`,title:e.kind===`file`?`Back to the diff`:`Open the whole file at this change`,"aria-label":e.kind===`file`?`Back to the diff`:`Open the whole file at this change`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${e.kind===`file`?`text-accent`:``}`,children:(0,N.jsx)(b,{})}),e.kind===`diff`&&(0,N.jsx)(`button`,{onClick:l.toggle,"aria-pressed":l.layout===`split`,title:l.layout===`split`?`Switch to unified diff`:`Switch to split diff`,"aria-label":l.layout===`split`?`Switch to unified diff`:`Switch to split diff`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${l.layout===`split`?`text-accent`:``}`,children:(0,N.jsx)(v,{})}),o&&(0,N.jsx)(`button`,{onClick:c,"aria-pressed":s,title:s?`Stop editing`:`Edit this page's text`,"aria-label":s?`Stop editing`:`Edit this page's text`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${s?`text-accent`:``}`,children:(0,N.jsx)(xe,{})}),e.kind===`file`&&On(e.value.path)&&!s&&(0,N.jsx)(`button`,{onClick:()=>n(e=>!e),"aria-pressed":t,title:t?`Show raw source`:`Show the rendered page`,"aria-label":t?`Show raw source`:`Show the rendered page`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${t?`text-accent`:``}`,children:(0,N.jsx)(p,{})}),(0,N.jsx)(`button`,{onClick:()=>i(r?`none`:`files`),"aria-pressed":r,...d(`view.toggleMaximize`,r?`Restore the layout`:`Maximize the file pane`),"aria-label":r?`Restore the layout`:`Maximize the file pane`,className:`hidden shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent md:flex`,children:(0,N.jsx)(u,{maximized:r})})]})}var zn=3;function Bn(e){let t=e<1?1:String(Math.floor(e)).length;return Math.max(t,zn)}function Vn(e){let t=0;for(let n of e)for(let e of n.lines)t=Math.max(t,e.old_lineno??0,e.new_lineno??0);return Bn(t)}function F({nos:e,digits:t,tint:n=``,stickyClass:r=`sticky left-0`}){return(0,N.jsx)(`span`,{className:`${r} shrink-0 select-none bg-ink-950`,children:(0,N.jsx)(`span`,{className:`flex gap-[1ch] px-[1ch] text-ink-400 ${n}`,children:e.map((e,n)=>(0,N.jsx)(`span`,{className:`text-right`,style:{width:`${t}ch`},children:e??``},n))})})}function Hn(){let e=`(min-width: 768px)`,[t,n]=(0,M.useState)(()=>window.matchMedia(e).matches);return(0,M.useEffect)(()=>{let t=window.matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[]),t}function Un(e,t,n){return e.hunks.flatMap((e,r)=>{let i={kind:`header`,hunk:r,text:`${e.file_path?`${e.file_path} `:``}${e.header}`};if(!t)return[i,...e.lines.map(e=>({kind:`unified`,hunk:r,line:e}))];let a=Sn(e.lines);return n?[i,...a.map(({left:e,right:t})=>({kind:`pair`,hunk:r,left:e,right:t}))]:[i,...a.map(({left:e})=>({kind:`side`,hunk:r,line:e,side:`old`,border:!1})),...a.map(({right:e},t)=>({kind:`side`,hunk:r,line:e,side:`new`,border:t===0}))]})}function Wn({line:e}){return(0,N.jsxs)(`span`,{className:`whitespace-pre pr-3`,children:[(0,N.jsx)(`span`,{className:`select-none text-ink-400`,children:e.kind}),e.spans.map((e,t)=>(0,N.jsx)(`span`,{style:{color:e.c},children:e.t},t))]})}function Gn({line:e,side:t,digits:n,stickyClass:r}){let i=e?un(e.kind):`bg-ink-900/40`;return(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 ${i}`,children:[(0,N.jsx)(F,{nos:[e?t===`old`?e.old_lineno:e.new_lineno:void 0],digits:n,tint:i,stickyClass:r}),e?(0,N.jsx)(Wn,{line:e}):(0,N.jsx)(`span`,{className:`pr-3`,children:` `})]})}function Kn({diff:e,split:t,viewport:n}){let r=Hn(),i=(0,M.useMemo)(()=>Un(e,t,r),[e,t,r]),a=Vn(e.hunks),o=fn(i.length,n.scrollTop,n.height);return(0,N.jsxs)(`div`,{className:`min-w-full py-1`,"data-virtual-count":i.length,children:[(0,N.jsx)(`div`,{"aria-hidden":`true`,style:{height:o.before}}),i.slice(o.start,o.end).map((e,t)=>{let n=o.start+t,r={"data-hunk":e.hunk,"data-virtual-row":n};if(e.kind===`header`)return(0,N.jsx)(`div`,{...r,className:`h-5 bg-ink-850 px-3 text-ink-400`,children:e.text},n);if(e.kind===`unified`){let t=un(e.line.kind);return(0,N.jsxs)(`div`,{...r,className:`flex h-5 w-max min-w-full ${t}`,children:[(0,N.jsx)(F,{nos:[e.line.old_lineno,e.line.new_lineno],digits:a,tint:t}),(0,N.jsx)(Wn,{line:e.line})]},n)}return e.kind===`pair`?(0,N.jsxs)(`div`,{...r,className:`flex h-5 min-w-full`,children:[(0,N.jsx)(Gn,{line:e.left,side:`old`,digits:a}),(0,N.jsx)(`div`,{className:`flex min-w-0 flex-1 border-l border-ink-800`,children:(0,N.jsx)(Gn,{line:e.right,side:`new`,digits:a,stickyClass:`sticky left-1/2`})})]},n):(0,N.jsx)(`div`,{...r,className:`flex h-5 min-w-full ${e.border?`border-t border-ink-800`:``}`,children:(0,N.jsx)(Gn,{line:e.line,side:e.side,digits:a})},n)}),(0,N.jsx)(`div`,{"aria-hidden":`true`,style:{height:o.after}})]})}function qn({line:e}){return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`text-ink-400 select-none`,children:e.kind}),e.spans.map((e,t)=>(0,N.jsx)(`span`,{style:{color:e.c},children:e.t},t))]})}function Jn({line:e,digits:t,side:n}){if(e===null)return(0,N.jsxs)(`div`,{className:`flex bg-ink-900/40`,children:[(0,N.jsx)(F,{nos:[void 0],digits:t,tint:`bg-ink-900/40`}),(0,N.jsx)(`span`,{className:`whitespace-pre pr-3`,children:` `})]});let r=un(e.kind);return(0,N.jsxs)(`div`,{className:`flex ${r}`,children:[(0,N.jsx)(F,{nos:[n===`old`?e.old_lineno:e.new_lineno],digits:t,tint:r}),(0,N.jsx)(`span`,{className:`whitespace-pre pr-3`,children:(0,N.jsx)(qn,{line:e})})]})}function Yn({cells:e,digits:t,side:n,border:r}){return(0,N.jsx)(`div`,{className:`min-w-0 flex-none overflow-x-auto md:flex-1 md:basis-1/2 ${r?`border-t border-ink-800 md:border-t-0 md:border-l`:``}`,children:(0,N.jsx)(`div`,{className:`w-max min-w-full`,children:e.map((e,r)=>(0,N.jsx)(Jn,{line:e,digits:t,side:n},r))})})}function Xn({lines:e,digits:t}){let n=Sn(e);return(0,N.jsxs)(`div`,{className:`flex flex-col md:flex-row`,children:[(0,N.jsx)(Yn,{cells:n.map(e=>e.left),digits:t,side:`old`,border:!1}),(0,N.jsx)(Yn,{cells:n.map(e=>e.right),digits:t,side:`new`,border:!0})]})}function Zn({diff:e,split:t,viewport:n={scrollTop:0,height:600}}){if(e.hunks.reduce((e,t)=>e+t.lines.length,0)>200)return(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(Kn,{diff:e,split:t,viewport:n}),e.truncated&&(0,N.jsx)(`p`,{className:`p-3 text-accent`,children:`Diff truncated — it exceeded the server's size ceiling.`})]});let r=Vn(e.hunks);return(0,N.jsxs)(`div`,{className:`p-1`,children:[e.hunks.length===0&&(0,N.jsx)(`p`,{className:`p-3 text-ink-400`,children:`No changes.`}),e.hunks.map((e,n)=>{let i=(0,N.jsxs)(`div`,{className:`bg-ink-850 px-3 py-0.5 text-ink-400`,children:[e.file_path?`${e.file_path} `:``,e.header]});return(0,N.jsx)(`div`,{"data-hunk":n,className:`mb-2`,children:t?(0,N.jsxs)(N.Fragment,{children:[i,(0,N.jsx)(Xn,{lines:e.lines,digits:r})]}):(0,N.jsxs)(`div`,{className:`w-max min-w-full`,children:[i,e.lines.map((e,t)=>{let n=un(e.kind);return(0,N.jsxs)(`div`,{className:`flex ${n}`,children:[(0,N.jsx)(F,{nos:[e.old_lineno,e.new_lineno],digits:r,tint:n}),(0,N.jsx)(`span`,{className:`whitespace-pre pr-3`,children:(0,N.jsx)(qn,{line:e})})]},t)})]})},n)}),e.truncated&&(0,N.jsx)(`p`,{className:`p-3 text-accent`,children:`Diff truncated — it exceeded the server's size ceiling.`})]})}var Qn=[`failed to fetch dynamically imported module`,`error loading dynamically imported module`,`importing a module script failed`,`unable to preload css`];function $n(e){let t=e instanceof Error?e.message:typeof e==`string`?e:``;if(!t)return!1;let n=t.toLowerCase();return Qn.some(e=>n.includes(e))}var er=class extends M.Component{state={error:null,failed:!1};static getDerivedStateFromError(e){return{error:e,failed:!0}}componentDidCatch(e,t){console.error(`nightcrow: a subtree failed to render`,e,t)}render(){return this.state.failed?(0,N.jsx)(tr,{chunk:$n(this.state.error),region:this.props.region,className:this.props.className}):this.props.children}};function tr({chunk:e,region:t,className:n}){return(0,N.jsxs)(`div`,{role:`alert`,className:`h-full min-h-0 flex-col items-start gap-3 p-4 text-ink-400 ${n??`flex`}`,children:[e?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`p`,{className:`text-accent`,children:`Part of the app could not be loaded.`}),(0,N.jsx)(`p`,{children:`Most likely the server was updated while this tab was open, and reloading picks up the current version. If the reload fails too, the server is not reachable from here. Either way nothing on the server is affected — the session, its repositories, and its terminals are untouched.`})]}):(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`p`,{className:`text-removed`,children:t?`The ${t} could not be rendered.`:`Something went wrong.`}),(0,N.jsx)(`p`,{children:`The details are in the browser console.`})]}),(0,N.jsx)(`button`,{onClick:()=>window.location.reload(),className:`rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:border-accent hover:text-accent`,children:`Reload`})]})}function nr({lines:e}){let t=Bn(e.length);return(0,N.jsx)(`pre`,{className:`w-max min-w-full py-2 text-ink-200`,children:e.map((e,n)=>(0,N.jsxs)(`div`,{"data-line":n+1,className:`flex`,children:[(0,N.jsx)(F,{nos:[n+1],digits:t}),(0,N.jsx)(`span`,{className:`whitespace-pre pr-3`,children:e.length===0?` `:e.map((e,t)=>(0,N.jsx)(`span`,{style:{color:e.c},children:e.t},t))})]},n))})}function rr({lines:e,viewport:t}){let n=Bn(e.length),r=fn(e.length,t.scrollTop,t.height);return(0,N.jsxs)(`pre`,{className:`w-max min-w-full`,"data-virtual-count":e.length,children:[(0,N.jsx)(`div`,{"aria-hidden":`true`,style:{height:r.before}}),e.slice(r.start,r.end).map((e,t)=>{let i=r.start+t;return(0,N.jsxs)(`div`,{"data-line":i+1,"data-virtual-row":i,className:`flex h-5 text-ink-200`,children:[(0,N.jsx)(F,{nos:[i+1],digits:n}),(0,N.jsx)(`span`,{className:`whitespace-pre pr-3`,children:e.length===0?` `:e.map((e,t)=>(0,N.jsx)(`span`,{style:{color:e.c},children:e.t},t))})]},i)}),(0,N.jsx)(`div`,{"aria-hidden":`true`,style:{height:r.after}})]})}var ir=`modulepreload`,ar=function(e,t){return new URL(e,t).href},or={},sr=function(e){return e.pathname.endsWith(`.css`)},cr=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},lr=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=ar(t,n);let r=s(t),i=sr(r);return cr(or,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:ir,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function ur(e,t){return`${e??``}\u0000${Ln(t)}`}var dr=(0,M.lazy)(()=>lr(()=>import(`./Markdown-DEJAds14.js`).then(e=>({default:e.MarkdownView})),__vite__mapDeps([0,1,2,3]),import.meta.url)),fr=(0,M.lazy)(()=>lr(()=>import(`./Html-DGFy4jGa.js`).then(e=>({default:e.HtmlView})),__vite__mapDeps([4,1]),import.meta.url)),pr=(0,M.lazy)(()=>lr(()=>import(`./HtmlEditor-DzgQSTDx.js`).then(e=>({default:e.HtmlEditor})),__vite__mapDeps([5,1,2,6,7]),import.meta.url));function mr({repo:e,pane:t,loading:n=!1,previewRendered:r,setPreviewRendered:i,filesMax:a,setMaximized:o,showOtherFace:s,status:c,className:l=``}){let u=Cn(),[d,f]=(0,M.useState)(!1),p=t.kind===`file`?t.value.path:null,m=t.kind===`file`&&t.source?.kind===`commit`,h=e!==null&&p!==null&&!m&&Dn(p),g=(0,M.useRef)(null),{viewport:_,refresh:v}=Rt(g),y=t.kind===`file`?t.anchor:void 0,b=(0,M.useRef)(null),x=()=>{let n=g.current;if(!n)return 0;let r=n.getBoundingClientRect().top,i=Array.from(n.querySelectorAll(`[data-hunk]`),e=>({offset:e.getBoundingClientRect().top-r+n.scrollTop,hunk:Number(e.dataset.hunk??0)}));return t.kind===`diff`&&t.source&&(b.current={key:ur(e,t.source),top:n.scrollTop,left:n.scrollLeft}),i[Nn(i.map(e=>e.offset),n.scrollTop)]?.hunk??0};return(0,M.useEffect)(()=>{let n=g.current;if(!n)return;if(t.kind===`diff`&&t.source){let r=b.current;r&&r.key===ur(e,t.source)&&(n.scrollTop=r.top,n.scrollLeft=r.left,b.current=null,v());return}if(y===void 0||t.kind!==`file`)return;let r=Mn(y,t.value.lines.length);if(r===null)return;if(t.value.lines.length>200){n.scrollTop=pn(r),v();return}let i=n.querySelector(`[data-line="${r}"]`);i&&(n.scrollTop+=i.getBoundingClientRect().top-n.getBoundingClientRect().top,v())},[t,y,e,v]),(0,M.useEffect)(()=>{f(!1)},[e,p,m]),(0,N.jsxs)(`section`,{...At(`content`),className:`min-h-0 min-w-0 flex-col ${l}`,children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 bg-ink-850 px-3 py-0.5 text-ink-400`,children:[t.kind===`file`&&(0,N.jsx)($t,{path:t.value.path,className:`min-w-0 truncate`}),(0,N.jsx)(Rn,{pane:t,previewRendered:r,setPreviewRendered:i,filesMax:a,setMaximized:o,onShowOtherFace:()=>s(x()),canEdit:h,editing:d&&h,onToggleEdit:()=>f(e=>!e)})]}),(0,N.jsx)(`div`,{ref:g,onScroll:v,className:`nc-content min-h-0 flex-1 overflow-auto`,children:n?(0,N.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Loading`,className:`py-2`,children:(0,N.jsx)(gt,{rows:12})}):(0,N.jsxs)(N.Fragment,{children:[t.kind===`empty`&&(c===null?(0,N.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Loading`,className:`py-2`,children:(0,N.jsx)(gt,{rows:12})}):c.unavailable===void 0?(0,N.jsx)(`p`,{className:`nc-fade-in p-4 text-ink-400`,children:`Select a file or commit.`}):(0,N.jsx)(`p`,{className:`nc-fade-in p-4 text-ink-400`,children:cn(c.unavailable)})),t.kind===`file`&&(0,N.jsxs)(N.Fragment,{children:[d&&h&&e!==null&&p!==null?(0,N.jsx)(er,{region:`preview`,children:(0,N.jsx)(M.Suspense,{fallback:(0,N.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Opening the editor`,className:`py-2`,children:(0,N.jsx)(gt,{rows:12})}),children:(0,N.jsx)(pr,{repo:e,path:p})})},`edit:${p}`):On(t.value.path)&&r?(0,N.jsx)(er,{region:`preview`,children:(0,N.jsx)(M.Suspense,{fallback:(0,N.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Rendering`,className:`py-2`,children:(0,N.jsx)(gt,{rows:12})}),children:Dn(t.value.path)&&e!==null?(0,N.jsx)(fr,{src:j.previewUrl(e,t.value.path,t.source?.kind===`commit`?t.source.oid:void 0)}):(0,N.jsx)(dr,{source:kn(t.value.lines)})})},t.value.path):t.value.lines.length>200?(0,N.jsx)(rr,{lines:t.value.lines,viewport:_}):(0,N.jsx)(nr,{lines:t.value.lines}),t.value.truncated&&(0,N.jsx)(`p`,{className:`p-3 text-accent`,children:`File truncated — it exceeded the server's size ceiling.`})]}),t.kind===`diff`&&(0,N.jsx)(Zn,{diff:t.value,split:u.layout===`split`,viewport:_})]})})]})}var hr=[{key:`files`,label:`Repo`,icon:He},{key:`diff`,label:`Content`,icon:Ue},{key:`terminal`,label:`Terminal`,icon:We}];function gr({view:e,onSelect:t}){return(0,N.jsx)(`nav`,{"aria-label":`Switch view`,className:`flex shrink-0 items-stretch border-t border-chrome-line bg-ink-900 md:hidden`,children:hr.map(({key:n,label:r,icon:i})=>(0,N.jsxs)(`button`,{onClick:()=>t(n),"aria-current":e===n?`page`:void 0,className:`flex min-h-11 flex-1 flex-col items-center justify-center gap-0.5 py-1 text-xs ${e===n?`text-accent`:`text-ink-400`}`,children:[(0,N.jsx)(i,{className:`h-5 w-5`}),r]},n))})}var _r=(0,M.lazy)(()=>lr(()=>import(`./Terminal-BuLVJ0Wx.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([8,1,2,9,7]),import.meta.url));function vr({repository:{id:e,current:t,status:n},sidebar:r,filePane:i,layout:{sidebarWidth:a,sidebarRef:o,draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d,upperRef:f,lowerRef:p,draggingUpper:m,onUpperDragStart:h,onUpperDragMove:g,onUpperDragEnd:_,onUpperDragCancel:v,maximized:y,setMaximized:b,mobileView:x,setMobileView:S}}){let C=y===`files`;(0,M.useEffect)(()=>d,[e,d]),(0,M.useEffect)(()=>v,[v]);let w=(0,M.useCallback)(()=>b(e=>e===`terminal`?`none`:`terminal`),[b]);return(0,N.jsxs)(N.Fragment,{children:[s&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-col-resize`}),m&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-row-resize`}),(0,N.jsxs)(`main`,{ref:f,className:`grid min-h-0 grid-cols-1 md:grid-cols-[var(--nc-sidebar)_minmax(0,1fr)] ${x===`terminal`?`hidden md:grid`:``} ${s||m?`select-none`:``}`,style:{"--nc-sidebar":C?`0px`:`min(${a}px, ${bt*100}vw)`},children:[(0,N.jsx)(xn,{...r,repo:e,status:n,sidebarRef:o,draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d,filesMax:C,mobileView:x},e),(0,N.jsx)(mr,{...i,filesMax:C,setMaximized:b,status:n,className:`nc-fade-in ${x===`diff`?`flex`:`hidden md:flex`}`})]}),(0,N.jsx)(er,{region:`terminal panel`,className:x===`terminal`?`flex`:`hidden md:flex`,children:(0,N.jsx)(M.Suspense,{fallback:(0,N.jsx)(`div`,{className:`min-h-0 border-t border-chrome-line ${x===`terminal`?`block`:`hidden md:block`}`}),children:(0,N.jsx)(_r,{repo:e,maximized:y===`terminal`,onToggleMaximized:w,className:`nc-fade-in ${x===`terminal`?`flex`:`hidden md:flex`} ${y===`files`?`overflow-hidden`:``}`,sectionRef:p,showDivider:y===`none`,draggingUpper:m,onUpperDragStart:h,onUpperDragMove:g,onUpperDragEnd:_,onUpperDragCancel:v})})}),(0,N.jsx)(gr,{view:x,onSelect:S}),(0,N.jsxs)(`footer`,{className:`flex shrink-0 items-center gap-3 border-t border-chrome-line bg-ink-900 px-3 py-1 text-ink-400`,children:[(0,N.jsx)(`span`,{className:`min-w-0 shrink-[1000] truncate`,children:t?.display_path}),n?.branch&&(0,N.jsx)(`span`,{className:`max-w-[50%] shrink-0 truncate text-accent`,children:n.branch}),gn(n)&&(0,N.jsx)(`span`,{className:`shrink-0 font-medium text-removed`,role:`status`,children:gn(n)}),n?.tracking&&(0,N.jsxs)(`span`,{className:`shrink-0`,children:[`↑`,n.tracking.ahead,` ↓`,n.tracking.behind]}),(0,N.jsx)(`span`,{className:`ml-auto shrink-0`,children:n?(0,N.jsx)(`span`,{className:`text-added`,children:`● live`}):`connecting…`})]})]})}var yr=`0.1.27`;function br({settings:e}){let{leaderText:t,conflict:n,setLeader:r,disable:i,reset:a}=e,[o,s]=(0,M.useState)(t),[c,l]=(0,M.useState)(null);(0,M.useEffect)(()=>{s(t),l(null)},[t]);let u=()=>{r(o)?l(null):l(`"${o}" is not a chord. Write it as Ctrl+F, Alt+Space or Ctrl+Shift+ArrowLeft.`)};return(0,N.jsxs)(`section`,{className:`shrink-0 border-b border-ink-700 px-3 py-2`,children:[(0,N.jsxs)(`p`,{className:`text-ink-400`,children:[`Leader chord:`,` `,t?(0,N.jsx)(`kbd`,{className:`rounded-sm border border-ink-600 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-50`,children:t}):(0,N.jsx)(`span`,{className:`text-ink-200`,children:`switched off`})]}),(0,N.jsxs)(`div`,{className:`mt-1.5 flex items-stretch gap-2`,children:[(0,N.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&u()},placeholder:`Ctrl+F`,"aria-label":`leader chord`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,className:`min-w-0 flex-1 rounded-sm border border-ink-700 bg-ink-950 px-2 py-1 font-mono text-ink-50 placeholder:text-ink-400 focus:border-ink-600 focus:outline-none`}),(0,N.jsx)(`button`,{type:`button`,onClick:u,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Rebind`}),(0,N.jsx)(`button`,{type:`button`,onClick:i,title:`Leave the leader unbound. Standalone chords keep working.`,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Switch off`}),(0,N.jsx)(`button`,{type:`button`,onClick:a,title:`Back to the leader the TUI ships with`,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Reset`})]}),c&&(0,N.jsx)(`p`,{role:`alert`,className:`mt-1 text-removed`,children:c}),n&&(0,N.jsxs)(`p`,{role:`status`,className:`mt-1 text-accent`,children:[n,` Rebind it above if you would rather keep that key.`]})]})}function xr({keys:e}){return e?(0,N.jsx)(`span`,{className:`flex shrink-0 items-center gap-1`,children:e.map((e,t)=>(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t>0&&(0,N.jsx)(`span`,{className:`text-ink-400`,children:`then`}),(0,N.jsx)(`kbd`,{className:`rounded-sm border border-ink-600 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-50`,children:e})]},e))}):(0,N.jsx)(`span`,{className:`shrink-0 text-ink-400`,children:`no key — the leader is switched off`})}function Sr({action:e,keys:t,ariaKeys:n,available:r,onRun:i}){let a=`flex w-full flex-col gap-0.5 rounded-sm px-3 py-1.5 text-left ${r?``:`opacity-50`}`,o=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`span`,{className:`flex w-full items-baseline gap-2`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-50`,children:e.label}),e.support===`reinterpreted`&&(0,N.jsx)(`span`,{className:`shrink-0 rounded-sm bg-ink-700 px-1 text-2xs uppercase tracking-wide text-ink-200`,children:`reinterpreted`}),e.support===`browserOnly`&&(0,N.jsx)(`span`,{className:`shrink-0 rounded-sm bg-ink-700 px-1 text-2xs uppercase tracking-wide text-ink-200`,children:`browser only`}),!r&&(0,N.jsx)(`span`,{className:`shrink-0 text-2xs uppercase tracking-wide text-ink-400`,children:`not available here`}),(0,N.jsx)(xr,{keys:t})]}),e.note&&(0,N.jsx)(`span`,{className:`text-ink-400`,children:e.note})]}),s={"data-shortcut-action":e.id,"aria-disabled":!r||void 0,"aria-keyshortcuts":n??void 0};return e.keyboardOnly?(0,N.jsx)(`li`,{children:(0,N.jsx)(`div`,{...s,className:a,children:o})}):(0,N.jsx)(`li`,{children:(0,N.jsx)(`button`,{type:`button`,...s,onClick:()=>{r&&i()},className:`${a} ${r?`hover:bg-ink-850`:``}`,children:o})})}var Cr={terminal:`Terminal`,project:`Projects`,view:`Layout and views`,focus:`Focus`,session:`Session`,help:`Help`},wr=(()=>{let e=[];for(let t of S){let n=e.find(e=>e.group===t.group);n?n.actions.push(t):e.push({group:t.group,actions:[t]})}return e})(),Tr=`nc-shortcut-help-title`;function Er({onClose:e,leader:t}){let n=we(),r=ee(),i=(0,M.useRef)(null),a=(0,M.useRef)(!1);(0,M.useEffect)(()=>{let e=document.activeElement;return i.current?.focus(),()=>{a.current||e instanceof HTMLElement&&e.isConnected&&e.focus()}},[]),(0,M.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]);let o=t=>{a.current=!0,n?.runAction(t.id),e()};return(0,N.jsx)(`div`,{className:`nc-fade-in fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e,children:(0,N.jsxs)(`div`,{ref:i,role:`dialog`,"aria-modal":`true`,"aria-labelledby":Tr,tabIndex:-1,className:`nc-rise-in flex max-h-[85vh] w-[40rem] max-w-full flex-col rounded-lg border border-ink-700 bg-ink-900 focus:outline-none`,onClick:e=>e.stopPropagation(),children:[(0,N.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-ink-700 px-3 py-2`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`span`,{id:Tr,className:`block font-medium text-ink-50`,children:`Keyboard shortcuts`}),(0,N.jsxs)(`span`,{className:`block text-caption text-ink-400`,children:[`nightcrow v`,yr]})]}),(0,N.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`close`,className:`ml-auto flex h-6 w-6 items-center justify-center rounded-sm text-ink-400 hover:text-ink-200`,children:(0,N.jsx)(ae,{})})]}),(0,N.jsx)(br,{settings:t}),(0,N.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-1`,children:[wr.map(({group:e,actions:n})=>(0,N.jsxs)(`section`,{children:[(0,N.jsx)(`h3`,{className:`px-3 py-1 text-caption uppercase text-ink-400`,children:Cr[e]}),(0,N.jsx)(`ul`,{children:n.map(e=>(0,N.jsx)(Sr,{action:e,keys:C(e.id,t.leader),ariaKeys:_e(e.id,t.leader),available:r(e.id),onRun:()=>o(e)},e.id))})]},e)),(0,N.jsxs)(`section`,{children:[(0,N.jsx)(`h3`,{className:`px-3 py-1 text-caption uppercase text-ink-400`,children:`Not bound in the browser`}),(0,N.jsx)(`ul`,{children:w.map(e=>(0,N.jsxs)(`li`,{className:`px-3 py-1.5`,children:[(0,N.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-200`,children:e.label}),(0,N.jsx)(`kbd`,{className:`shrink-0 rounded-sm border border-ink-700 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-400`,children:e.leader})]}),(0,N.jsx)(`span`,{className:`text-ink-400`,children:e.reason})]},e.leader))})]})]})]})})}var Dr=[`terminal.newPane`,`terminal.closePane`,`view.toggleMaximize`,`project.openDialog`,`help.shortcuts`],Or={keys:`3-9,0`,label:`pane 1-8`,click:null},kr={keys:`3-9,0`,label:`swap active pane with this pane`,click:null},Ar={keys:`esc`,label:`cancel`,click:null};function jr(e,t,n){return e.armed&&e.swapPending?{chip:`SWAP`,segments:[kr,Ar]}:e.armed?{chip:`PREFIX`,segments:Nr(n)}:t?{chip:null,segments:Mr(t,n)}:{chip:null,segments:Pr(n)}}function Mr(e,t){let n=me(e),r=[{keys:n,label:`leader`,click:{kind:`arm`}}];for(let e of S)Dr.includes(e.id)&&t(e.id)&&r.push(Fr(e,`${n} ${e.leader}`));return r}function Nr(e){let t=[],n=!1;for(let i of S)i.leader!==void 0&&e(i.id)&&(r(i.id)===null?t.push(Fr(i,i.leader)):(n||t.push(Or),n=!0));return t.push(Ar),t}function Pr(e){let t=[{keys:`leader`,label:`switched off`,click:{kind:`run`,action:`help.shortcuts`}}];for(let n of S)n.chord!==void 0&&e(n.id)&&t.push(Fr(n,n.chord));return t}function Fr(e,t){return{keys:t,label:e.hint,click:{kind:`run`,action:e.id}}}var Ir=`shrink-0 whitespace-nowrap`;function Lr({state:e,onClick:t}){let n=jr(e,c(),ee());return(0,N.jsxs)(`div`,{role:`toolbar`,"aria-label":`Keyboard hints`,className:`hidden shrink-0 items-center gap-1 overflow-hidden border-t border-chrome-line bg-ink-900 px-2 py-0.5 text-xs text-ink-400 md:flex`,children:[n.chip&&(0,N.jsx)(`span`,{"data-hint-chip":n.chip,className:`shrink-0 bg-accent px-1 font-bold text-ink-950`,children:n.chip}),n.segments.map((e,n)=>(0,N.jsxs)(M.Fragment,{children:[n>0&&(0,N.jsx)(`span`,{className:`shrink-0 text-ink-600`,children:`|`}),(0,N.jsx)(Rr,{segment:e,onClick:t})]},`${e.keys} ${e.label}`))]})}function Rr({segment:e,onClick:t}){let n=(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(`span`,{className:`text-ink-200`,children:e.keys}),`: `,e.label]});if(!e.click)return(0,N.jsx)(`span`,{className:Ir,children:n});let r=e.click;return(0,N.jsx)(`button`,{type:`button`,"data-hint-action":r.kind===`run`?r.action:`arm`,onPointerDown:e=>e.preventDefault(),onClick:()=>t(r),className:`${Ir} rounded-sm hover:text-accent`,children:n})}function zr(e,t){return e?`grid-rows-[minmax(0,1fr)_auto_auto] ${t===`terminal`?`md:grid-rows-[minmax(0,0fr)_minmax(0,1fr)_auto_auto]`:t===`files`?`md:grid-rows-[minmax(0,1fr)_minmax(0,0fr)_auto_auto]`:`md:grid-rows-[minmax(0,var(--nc-upper))_minmax(0,var(--nc-lower))_auto_auto]`}`:`grid-rows-[1fr]`}function Br(e,t){let n=Vr(e);if(n.length===0)return null;let r=e.at,i=r===null?-1:n.findIndex(e=>Hr(e,r)),a;return a=i===-1?t>0?n[0]:n[n.length-1]:n[(i+t+n.length)%n.length],r!==null&&Hr(a,r)?null:a}function Vr({paneCount:e,maximized:t,narrow:n,mobileView:r}){let i={kind:`list`},a={kind:`content`},o=Array.from({length:e},(e,t)=>({kind:`pane`,index:t}));if(n)switch(r){case`files`:return[i];case`diff`:return[a];case`terminal`:return o}switch(t){case`terminal`:return o;case`files`:return[i,a];case`none`:return[i,a,...o]}}function Hr(e,t){return e.kind===t.kind?e.kind!==`pane`||t.kind!==`pane`||e.index===t.index:!1}function Ur(e,t,n){if(e.length<=1||t===null)return null;let r=e.indexOf(t);return r<0?null:e[(r+n+e.length)%e.length]}var Wr={armed:!1},Gr={kind:`none`};function Kr(e=Gr){return{state:Wr,effect:e}}function qr(e,t){switch(t.kind){case`blur`:case`focusChange`:case`dialogOpen`:case`repoChange`:case`socketReconnect`:case`disabled`:case`suppressed`:case`cancel`:return Kr();case`consumed`:return Kr();case`arm`:return{state:{armed:!0,swapPending:!1},effect:Gr};case`literalLeader`:return Kr({kind:`sendLiteralLeader`,data:t.data});case`action`:return Jr(e,t.action.id);case`ignore`:return{state:e,effect:Gr}}}function Jr(e,t){if(e.armed&&e.swapPending){let e=r(t);return e===null?Kr():Kr({kind:`swapWith`,pane:e})}return t===`terminal.swapPanePrompt`?{state:{armed:!0,swapPending:!0},effect:Gr}:Kr({kind:`run`,action:t})}var Yr=S.flatMap(e=>{if(!e.chord)return[];let t=E(e.chord);return t?[{spec:t,action:e}]:[]}),Xr=new Set([`Shift`,`Control`,`Alt`,`Meta`]),Zr=229,Qr=new Set([`Process`,`Unidentified`]),$r={kind:`ignore`};function ei(e){return e.isComposing===!0||e.keyCode===Zr||Qr.has(e.key)}function ti(e){return e.key===`Escape`||e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey&&e.key.toLowerCase()===`c`}function ni(e,t){if(e.type!==`keydown`||ei(e)||e.repeat===!0||t.suppressed)return $r;if(t.armed){if(ti(e))return{kind:`cancel`};if(t.leader&&O(t.leader,e))return{kind:`literalLeader`,data:le(t.leader)??``};if(e.key.length===1){let t=_(e.key);if(t)return{kind:`action`,action:t}}return Xr.has(e.key)?$r:{kind:`consumed`}}if(t.leader&&O(t.leader,e))return{kind:`arm`};for(let{spec:t,action:n}of Yr)if(O(t,e))return{kind:`action`,action:n};return $r}var ri=new Set([`checkbox`,`radio`,`button`,`submit`,`reset`,`image`,`range`,`color`,`file`]),ii=new Set([`textbox`,`searchbox`,`combobox`]);function ai(e){if(!e)return!1;if(e.isContentEditable===!0)return!0;let t=e.role?.toLowerCase()??``;if(ii.has(t))return!0;switch(e.tagName.toUpperCase()){case`INPUT`:return!ri.has(e.type?.toLowerCase()??`text`);case`TEXTAREA`:case`SELECT`:return!0;default:return!1}}function oi(e){return e.dialogOpen||e.composing||e.target?.inDialog===!0?!0:ai(e.target)}function si(e,t=!0){let n=(0,M.useRef)(e);n.current=e,(0,M.useEffect)(()=>{if(!t)return;let e=e=>{n.current(e)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())};return document.addEventListener(`keydown`,e,{capture:!0}),()=>document.removeEventListener(`keydown`,e,{capture:!0})},[t])}function ci({enabled:e,leader:t,dialogOpen:n,repo:r}){let i=we(),a=(0,M.useRef)(Wr),[o,s]=(0,M.useState)(Wr),c=(0,M.useRef)(i);c.current=i;let l=(0,M.useCallback)(e=>{let t=qr(a.current,e);a.current=t.state,s(t.state);let n=c.current;n&&li(t.effect,n)},[]);si((0,M.useCallback)(e=>{let r=oi({target:jt(e.target),dialogOpen:n,composing:e.isComposing===!0}),i=ni(e,{leader:t,armed:a.current.armed,suppressed:r});return r?(l({kind:`suppressed`}),!1):(l(i),i.kind!==`ignore`)},[n,t,l]),e&&i!==null),(0,M.useEffect)(()=>{if(!e)return;let t=()=>l({kind:`blur`}),n=e=>{let t=jt(e.target);(ai(t)||t?.inDialog===!0)&&l({kind:`focusChange`})};return window.addEventListener(`blur`,t),document.addEventListener(`focusin`,n,{capture:!0}),()=>{window.removeEventListener(`blur`,t),document.removeEventListener(`focusin`,n,{capture:!0})}},[e,l]),(0,M.useEffect)(()=>{n&&l({kind:`dialogOpen`})},[n,l]),(0,M.useEffect)(()=>{e||l({kind:`disabled`})},[e,l]);let u=(0,M.useRef)(r);return(0,M.useEffect)(()=>{u.current!==r&&(u.current=r,l({kind:`repoChange`}))},[r,l]),(0,M.useEffect)(()=>{if(i)return i.onDisarm(()=>l({kind:`socketReconnect`}))},[i,l]),(0,M.useEffect)(()=>{l({kind:`cancel`})},[t,l]),{state:o,arm:(0,M.useCallback)(()=>l({kind:`arm`}),[l]),disarm:(0,M.useCallback)(()=>l({kind:`cancel`}),[l])}}function li(e,t){switch(e.kind){case`none`:return;case`run`:t.runAction(e.action);return;case`swapWith`:t.swapPanes(e.pane);return;case`sendLiteralLeader`:e.data&&t.sendLiteralLeader(e.data);return}}var ui=`nightcrow.shortcut.leader`;function di(){let[e,t]=(0,M.useState)(fi),n=(0,M.useCallback)(e=>{t(e),mi(e===null?null:me(e))},[]),r=(0,M.useCallback)(e=>{let t=E(e);return t?(n(t),!0):!1},[n]),i=(0,M.useCallback)(()=>n(null),[n]),a=(0,M.useCallback)(()=>n(ie),[n]);return{leader:e,leaderText:e?me(e):``,conflict:e?ye(e):null,setLeader:r,disable:i,reset:a}}function fi(){let e=pi();return e?e.leader===null?null:E(e.leader)??ie:ie}function pi(){try{let e=localStorage.getItem(ui);if(!e)return null;let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.leader;return n===null?{leader:null}:typeof n==`string`?{leader:n}:null}catch{return null}}function mi(e){try{localStorage.setItem(ui,JSON.stringify({leader:e}))}catch{}}function hi({enabled:e,repo:t,repos:n,selectRepo:r,closeRepo:i,openPicker:a,pickerOpen:o,cycleAccent:s,reloadConfig:c,tab:l,chooseTab:u,maximized:d,setMaximized:f,mobileView:p}){let m=we(),h=di(),[g,_]=(0,M.useState)(!1),v=(0,M.useCallback)(()=>_(!0),[]),y=(0,M.useCallback)(()=>_(!1),[]),b=(0,M.useCallback)(e=>{let i=Ur(n.map(e=>e.id),t,e);i!==null&&r(i)},[n,t,r]),x=m?.zoomActivePane,S=(0,M.useCallback)(()=>{Mt()?(f(e=>e===`terminal`?`none`:`terminal`),x?.()):f(e=>e===`files`?`none`:`files`)},[f,x]),C=(0,M.useCallback)(e=>{let t=m?.paneCursor()??null,n=Nt(),r=null;n===`terminal`?t&&t.index>=0&&(r={kind:`pane`,index:t.index}):n!==null&&(r={kind:n});let i=Br({at:r,paneCount:t?.count??0,maximized:d,narrow:window.innerWidth<768,mobileView:p},e);i!==null&&(i.kind===`pane`?m?.focusPaneAt(i.index):Pt(i.kind))},[m,d,p]),w=(0,M.useMemo)(()=>{let e={"project.openDialog":a,"session.cycleAccent":s,"session.reloadConfig":c,"help.shortcuts":v};return n.length>1&&(e[`project.previous`]=()=>b(-1),e[`project.next`]=()=>b(1)),t===null||(e[`project.close`]=()=>i(t),e[`view.toggleLog`]=()=>u(l===`log`?`status`:`log`),e[`view.toggleTree`]=()=>u(l===`tree`?`status`:`tree`),e[`view.toggleMaximize`]=S,e[`focus.list`]=()=>void Pt(`list`),e[`focus.content`]=()=>void Pt(`content`),e[`focus.previous`]=()=>C(-1),e[`focus.next`]=()=>C(1)),e},[a,s,c,v,n.length,b,t,l,i,u,S,C]);Te(w);let T=ci({enabled:e,leader:h.leader,dialogOpen:o||g,repo:t}),{arm:E,disarm:ee}=T,te=(0,M.useCallback)(e=>{e.kind===`arm`?E():(ee(),m?.runAction(e.action))},[E,ee,m]);return{shortcutHelp:{open:g,show:v,hide:y},settings:h,hint:{state:T.state,onClick:te}}}var gi=1e3,_i=3,vi=2e3;function yi(e,t){let[n,r]=(0,M.useState)(!1),i=(0,M.useRef)(!1),a=(0,M.useRef)(!1);(0,M.useEffect)(()=>(a.current=!1,()=>{a.current=!0}),[]);let o=(0,M.useCallback)(async t=>{for(;!a.current;){if(await new Promise(e=>setTimeout(e,gi)),a.current)return;let n;try{n=await j.cloneStatus(t)}catch(e){if(Me(e)){i.current=!1,a.current||r(!1);return}if(e instanceof De&&e.status===404){if(a.current)return;D.error(`the clone's progress is no longer available`),i.current=!1,r(!1);return}continue}if(a.current)return;if(n.state===`done`){try{let t=await j.open(n.path);if(a.current)return;e(t)}catch(e){if(a.current)return;D.error(e instanceof Error?e.message:`could not open`)}finally{i.current=!1,a.current||r(!1)}return}if(n.state===`failed`){D.error(n.message),i.current=!1,r(!1);return}}},[e]),s=(0,M.useCallback)(async(e=()=>!1)=>{for(let t=0;t<_i;t++){if(t>0&&await new Promise(e=>setTimeout(e,vi)),i.current||e()||a.current)return;let n;try{({job:n}=await j.runningClone())}catch(e){if(Me(e))return;continue}if(n===null||e()||a.current||i.current)return;i.current=!0,r(!0),o(n);return}},[o]);return(0,M.useEffect)(()=>{if(!t)return;let e=!1;return s(()=>e),()=>{e=!0}},[t,s]),{busy:n,start:(0,M.useCallback)(async(e,t)=>{if(t.trim()&&!i.current){i.current=!0,r(!0);try{let{job:n}=await j.clone(e,t.trim());await o(n)}catch(e){if(i.current=!1,a.current)return;let t=e instanceof De&&e.status>=400;D.error(t?e.message:`could not confirm the clone started — check this folder before retrying`),r(!1),s()}}},[o,s])}}function bi(e,t,n,r=!1){return r&&n&&t.includes(n)?n:e&&t.includes(e)?e:n&&t.includes(n)?n:t[0]??null}function xi(e){let t=!1,n=null,r=()=>{if(t||n===null)return;let i=n;n=null,t=!0,e(i).catch(()=>{}).finally(()=>{t=!1,r()})};return e=>{n=e,r()}}function Si(e,t){return e?.enabled===t.enabled&&e.window_secs===t.window_secs?e:t}function Ci(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.name===r.name&&e.display_path===r.display_path})?e:t}var wi=`The viewer was updated on the server.`,Ti=null,Ei=null,Di=null;function Oi(e,t){return e===null||t===null?!1:e!==t}function ki(e){Ti=e}function Ai(e){Oi(Ti,e)?Ei!==e&&(Ei=e,Di=D.info(wi,{sticky:!0,action:{label:`Reload`,run:()=>window.location.reload()}})):e===Ti&&Ei!==null&&(Di!==null&&ge(Di),Ei=null,Di=null)}var ji=3e3;function Mi({authed:e,setAuthed:t,handle:n,adoptAccent:r,adoptUpperPct:i,adoptMaximized:a,adoptViews:o,upperDraggingRef:s,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,resumeTick:f,orderWrites:p,repoDraggingRef:m,reorderInFlightRef:h,pendingReorderRef:g}){let[_,v]=(0,M.useState)([]),[y,b]=(0,M.useState)(null),[x,S]=(0,M.useState)(null),[C,w]=(0,M.useState)(null),[T,E]=(0,M.useState)(!1),[ee,te]=(0,M.useState)(!0),{current:ne}=(0,M.useRef)(xi(j.setActiveRepo)),re=(0,M.useRef)(null),ie=(0,M.useRef)(null);return(0,M.useEffect)(()=>{if(e===!1)return;let f=!1,_,y=new AbortController,x=()=>{let e=c.current,C=l.current,T=u.current,ee=d.current,ne=p.current;return j.repos(y.signal).then(n=>{let{repos:y,hot:ae,accent:oe,upper_pct:se,active_repo:D,maximized:ce,last_view:le,now_ms:ue,can_clone:de,viewer_build:fe}=n;if(f)return;Ai(fe),S(e=>Si(e,ae)),te(de),w(e=>nn(e,ue,Date.now())),c.current===e&&r(oe),l.current===C&&!s.current&&i(se),u.current===T&&a(ce),d.current===ee&&o(le??{},y.map(e=>e.id)),t(!0),E(!0);let pe=h.current||g.current!==null;p.current===ne&&!m.current&&!pe?v(e=>Ci(e,y)):v(e=>{let t=be(y.map(e=>e.id),e.map(e=>e.id)),n=new Map(y.map(e=>[e.id,e]));return Ci(e,t.map(e=>n.get(e)).filter(Boolean))});let me=y.map(e=>e.id),he=D!==re.current;re.current=D??null,he&&D&&me.includes(D)&&(ie.current=D),b(e=>bi(e,me,D,he)),f||(_=setTimeout(x,ji))}).catch(e=>{f||(Me(e)?(t(!1),E(!1)):(Ae(e)||n(e),_=setTimeout(x,ji)))})};return x(),()=>{f=!0,y.abort(),_&&clearTimeout(_)}},[e,t,n,r,i,f,c,l,u,d,s,a,o,p,m,h,g]),(0,M.useEffect)(()=>{y?y!==ie.current&&(ie.current=null,ne(y)):ie.current=null},[y,ne]),{repos:_,setRepos:v,repo:y,setRepo:b,hot:x,clockSkewMs:C,reposLoaded:T,canClone:ee}}var Ni=4;function Pi({ids:e,onReorder:t,draggingRef:n}){let r=(0,M.useRef)(null),i=(0,M.useRef)(null),a=(0,M.useRef)(null),[o,s]=(0,M.useState)(null),[c,l]=(0,M.useState)(null);return{dragging:o,target:c,onStart:(t,a)=>{t.target.closest(`button[data-tab-close]`)||t.button!==0||e.length<2||(r.current=a,i.current={x:t.clientX,y:t.clientY},n.current=!1)},onMove:e=>{let t=r.current,o=i.current;if(t===null||o===null)return;if(!n.current&&e.buttons===0){r.current=null,i.current=null;return}if(!n.current&&Math.hypot(e.clientX-o.x,e.clientY-o.y){let o=r.current,c=a.current;o!==null&&n.current&&c!==null&&t(te(e,o,c)),r.current=null,i.current=null,a.current=null,n.current=!1,s(null),l(null)}}}function Fi({repos:e,setRepos:t,handle:n,writesRef:r,draggingRef:i,inFlightRef:a,pendingRef:o}){let s=(0,M.useCallback)(()=>{if(a.current||o.current===null)return;let e=o.current;o.current=null,a.current=!0;let i=r.current;j.reorderRepos(e).then(e=>{r.current===i&&t(e)}).catch(n).finally(()=>{a.current=!1,s()})},[n,t,a,o,r]),c=(0,M.useCallback)(e=>{r.current+=1,t(t=>{let n=be(t.map(e=>e.id),e),r=new Map(t.map(e=>[e.id,e]));return n.map(e=>r.get(e)).filter(Boolean)}),o.current=e,s()},[s,t,o,r]);return{...Pi({ids:e.map(e=>e.id),onReorder:c,draggingRef:i}),writesRef:r,draggingRef:i,inFlightRef:a,pendingRef:o}}function Ii({authed:e,setAuthed:t,handle:n,resumeTick:r,adoptAccent:i,adoptUpperPct:a,adoptMaximized:o,adoptViews:s,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,upperDraggingRef:f}){let p=(0,M.useRef)(0),m=(0,M.useRef)(!1),h=(0,M.useRef)(!1),g=(0,M.useRef)(null),_=Mi({authed:e,setAuthed:t,handle:n,adoptAccent:i,adoptUpperPct:a,adoptMaximized:o,adoptViews:s,upperDraggingRef:f,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,resumeTick:r,orderWrites:p,repoDraggingRef:m,reorderInFlightRef:h,pendingReorderRef:g}),{dragging:v,target:y,onStart:b,onMove:x,onEnd:S}=Fi({repos:_.repos,setRepos:_.setRepos,handle:n,writesRef:p,draggingRef:m,inFlightRef:h,pendingRef:g});return{..._,orderWrites:p,draggingRepo:v,dragOverRepo:y,onRepoDragStart:b,onRepoDragMove:x,onRepoDragEnd:S}}function Li(){let[e,t]=(0,M.useState)(!1),n=(0,M.useRef)(!1);return{reload:(0,M.useCallback)(async()=>{if(!n.current){n.current=!0,t(!0);try{D.success(await j.reloadConfig())}catch(e){D.error(e instanceof Error?e.message:`could not reload the config`)}finally{n.current=!1,t(!1)}}},[]),pending:e}}function Ri(e,t){let n=e.indexOf(t);return n===-1?e[0]??null:e[n+1]??e[n-1]??null}function zi({repo:e,repos:t,setRepos:n,setRepo:r,setPane:i,setTab:a,setPickerOpen:o,handle:s,orderWrites:c}){let l=(0,M.useRef)(t);l.current=t;let u=(0,M.useRef)(e);return u.current=e,{selectOpenedRepo:(0,M.useCallback)(e=>{c.current+=1,n(t=>t.some(t=>t.id===e.id)?t:[...t,e]),r(e.id),e.id!==u.current&&(i({kind:`empty`}),a(`status`)),o(!1)},[n,r,i,a,o,c]),closeRepo:(0,M.useCallback)(async e=>{try{await j.close(e),c.current+=1;let t=Ri(l.current.map(e=>e.id),e);n(t=>t.filter(t=>t.id!==e)),r(n=>n===e?t:n)}catch(e){s(e)}},[n,r,s,c])}}function Bi(e,t,n){return t!==e&&(n.bumpPaneRequest(),e===`log`&&n.leaveLog(),n.recordTab(t),n.forgetPane(),!0)}function Vi(e,t,n,r,i){(0,M.useLayoutEffect)(()=>{t&&(e.some(e=>e.oid===t.commit.oid)||(r(),n(null),i()))},[e,t,n,r,i])}var Hi=5e3,Ui={refs:{},ahead:[],behind:[],truncated:!1};function Wi({repo:e,authed:t,tab:n,head:r,branch:i,refs:a,upstream:o}){let[s,c]=(0,M.useState)({key:``,value:Ui}),[l,u]=(0,M.useState)(0),d=e&&r!==void 0?`${e}|${r??``}|${i??``}|${a??``}|${o??``}`:``,f=(0,M.useRef)(s.key);f.current=s.key,(0,M.useEffect)(()=>{if(!e||!t||n!==`log`||d===``||f.current===d)return;let r=new AbortController,i;return j.logDecorations(e,r.signal).then(e=>c({key:d,value:e})).catch(()=>{r.signal.aborted||(i=setTimeout(()=>u(e=>e+1),Hi))}),()=>{r.abort(),i&&clearTimeout(i)}},[e,t,n,d,l]);let p=s.key.startsWith(`${e}|`)?s.value:Ui;return(0,M.useMemo)(()=>{let e=new Set(p.ahead),t=new Set(p.behind);return{refsOf:e=>p.refs[e],divergenceOf:n=>e.has(n)?`ahead`:t.has(n)?`behind`:void 0,truncated:p.truncated}},[p])}function Gi(e,t,n){let r=!e.truncated||e.head===void 0,i=t[0]?.oid,a=i===void 0?-1:e.commits.findIndex(e=>e.oid===i),o=a<0?[]:e.commits.slice(a);return a>=0&&o.length<=t.length&&o.every((e,n)=>e.oid===t[n].oid)?{commits:a===0?t:[...e.commits.slice(0,a),...t],anchor:e.head??null,done:n||r,mode:`prepend`}:{commits:e.commits,anchor:e.head??null,done:r,mode:`replace`}}function Ki({repo:e,authed:t,tab:n,filter:r,head:i,handle:a}){let o=(0,M.useRef)([]),[,s]=(0,M.useState)(0),c=(0,M.useCallback)(()=>s(e=>e+1),[]),l=o.current,[u,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)(!1),m=(0,M.useRef)(null),h=(0,M.useRef)(!1),g=(0,M.useRef)(!1),_=(0,M.useRef)(0),v=(0,M.useRef)(void 0),y=(0,M.useRef)(void 0),b=(0,M.useCallback)(()=>{_.current+=1,h.current=!1,g.current=!1,o.current=[],c(),m.current=null,d(!1),p(!1),v.current=void 0,y.current=void 0},[c]),[x,S]=(0,M.useState)(null),C=(0,M.useRef)(u);C.current=u;let w=(0,M.useRef)(i);w.current=i;let T=(0,M.useCallback)(async t=>{if(!e)return;y.current=w.current,_.current+=1;let n=_.current;h.current=!0,g.current=!0;try{let r=await j.log(e);if(n!==_.current)return;let i=t??{commits:o.current,done:C.current},a=Gi(r,i.commits,i.done);o.current=a.commits,c(),m.current=a.anchor,v.current=a.anchor,a.anchor===w.current&&(y.current=void 0),d(a.done),p(!1)}catch(e){n===_.current&&(y.current=void 0,a(e),p(!0))}finally{n===_.current&&(h.current=!1,g.current=!1)}},[e,a,c]),E=(0,M.useCallback)(async()=>{if(!e||h.current)return;h.current=!0;let t=_.current;try{let n=m.current,r=await j.log(e,n===null?void 0:{from:n,skip:o.current.length});if(t!==_.current)return;if(o.current.push(...r.commits),c(),m.current=r.head??null,d(!r.truncated||r.head===void 0),n===null){v.current=r.head??null;let e=w.current;e!==void 0&&e!==(r.head??null)&&T({commits:r.commits,done:!r.truncated||r.head===void 0})}}catch(e){t===_.current&&(a(e),p(!0))}finally{t===_.current&&(h.current=!1)}},[e,a,T,c]);(0,M.useEffect)(()=>{e&&t&&n===`log`&&l.length===0&&!u&&!f&&E()},[e,t,n,l.length,u,f,E]),(0,M.useEffect)(()=>{if(!e||!t||n!==`log`||i===void 0||f)return;let r=v.current;r!==void 0&&(r===i?g.current||(y.current=void 0):y.current!==i&&T())},[e,t,n,i,f,T]);let ee=r.toLowerCase(),te=ee===``?l:l.filter(e=>e.summary.toLowerCase().includes(ee)),ne=r!==``,re=(0,M.useRef)(null);return(0,M.useEffect)(()=>{let e=re.current;if(!e)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&E()},{root:e.closest(`ul`),rootMargin:`400px`});return t.observe(e),()=>t.disconnect()},[E,u,f,ne,x,n,te.length]),{commits:l,logDone:u,logStalled:f,setLogStalled:p,commitDrillDown:x,setCommitDrillDown:S,resetLog:b,logSentinelRef:re,visibleCommits:te,logPagingPaused:ne}}function qi(e,t){return[t??``,e.index,e.worktree,e.mtime??``,e.old_path??``].join(`\0`)}function Ji({repo:e,authed:t,resumeTick:n,tab:r,pane:i,setPane:a,handle:o,paneRequestRef:s}){let[c,l]=(0,M.useState)(null),u=(0,M.useRef)(i);u.current=i;let d=(0,M.useRef)(r);d.current=r;let f=(0,M.useRef)(null),p=(0,M.useRef)(null);return(0,M.useLayoutEffect)(()=>{l(null),p.current=null},[e,t]),(0,M.useEffect)(()=>{if(e&&t)return ke(e,l,({reason:e})=>l({files:[],truncated:!1,unavailable:e}))},[e,t,n]),(0,M.useEffect)(()=>{if(!e||!c)return;let t=p.current;p.current=new Map(c.files.map(e=>[e.path,qi(e,c.head)]));let n=u.current;if(d.current!==`status`||n.kind!==`diff`){f.current=null;return}let r=n.value.path,i=c.files.find(e=>e.path===r);if(!i){f.current=null,a({kind:`empty`});return}let l=qi(i,c.head),m=f.current;if(m?.path===r&&m.key===l)return;if(m?.path!==r&&t?.get(r)===l){f.current={path:r,key:l};return}let h=s.current,g=!0,_=()=>{let e=u.current;return g&&h===s.current&&e.kind===`diff`&&e.value.path===r};return j.diff(e,r).then(e=>{_()&&(f.current={path:r,key:l},a({kind:`diff`,value:e,source:Fn(i)&&In(e)?{kind:`workdir`,path:r}:void 0}))}).catch(e=>{_()&&o(e)}),()=>{g=!1}},[c,e,o,u,d,s,a]),{status:c,paneRef:u,tabRef:d}}function Yi({repo:e,authed:t,hot:n,clockSkewMs:r,resumeTick:i,handle:a}){let[o,s]=(0,M.useState)(`status`),[c,l]=(0,M.useState)(``),[u,d]=(0,M.useState)(!1),[f,p]=(0,M.useState)({kind:`empty`}),[m,h]=(0,M.useState)(e);m!==e&&(h(e),p({kind:`empty`}),s(`status`));let g=(0,M.useRef)(0),_=(0,M.useCallback)(()=>{g.current+=1},[]),v=(0,M.useCallback)(()=>p({kind:`empty`}),[]),{status:y}=Ji({repo:e,authed:t,resumeTick:i,tab:o,pane:f,setPane:p,handle:a,paneRequestRef:g}),b=n?.enabled?n.window_secs*1e3:0,x=Ki({repo:e,authed:t,tab:o,filter:c,head:y?y.head??null:void 0,handle:a}),S=Wi({repo:e,authed:t,tab:o,head:y?y.head??null:void 0,branch:y?.branch,refs:y?.refs,upstream:y?.tracking?.upstream}),C=x.setCommitDrillDown,w=x.resetLog;(0,M.useLayoutEffect)(()=>{_(),C(null),w()},[e,_,C,w]);let T=c.toLowerCase(),E=(0,M.useMemo)(()=>(y?.files??[]).filter(e=>e.path.toLowerCase().includes(T)),[y?.files,T]),ee=(0,M.useMemo)(()=>(x.commitDrillDown?.files??[]).filter(e=>e.path.toLowerCase().includes(T)||e.old_path?.toLowerCase().includes(T)),[x.commitDrillDown?.files,T]);return{screen:{tab:o,setTab:s,filter:c,setFilter:l,filterOpen:u,setFilterOpen:d,pane:f,setPane:p},request:{paneRequestRef:g,bumpPaneRequest:_,clearPane:v},status:{value:y,files:E,hotWindowMs:b,clockSkewMs:r??0},log:{...x,decorations:S,visibleCommitFiles:ee}}}var Xi=`nightcrow.mobileView`;function Zi(e){return e===`diff`||e===`terminal`||e===`files`?e:`files`}function Qi(){return Zi(m(Xi))}function $i(){let[e,t]=(0,M.useState)(Qi);return{mobileView:e,setMobileView:(0,M.useCallback)(e=>{h(Xi,e),t(e)},[])}}function ea({repo:e,handle:t,setPane:n,paneRequestRef:r,setCommitDrillDown:i,setMobileView:a,setPreviewRendered:o,statusRef:s,track:c}){let l=(0,M.useCallback)(e=>{let t=s.current?.files.find(t=>t.path===e);return t?Fn(t):!1},[s]);return{openDiff:(0,M.useCallback)((i,o)=>{if(!e)return;o?.restoring||a(`diff`);let s=r.current+=1;c(s,j.diff(e,i)).then(e=>{s===r.current&&n({kind:`diff`,value:e,source:l(i)&&In(e)?{kind:`workdir`,path:i}:void 0})}).catch(e=>{if(s!==r.current)return Me(e)?t(e):void 0;if(!o?.restoring)return t(e);Me(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,l,c]),openFile:(0,M.useCallback)((i,s)=>{if(!e)return;s?.restoring||a(`diff`),o(!0);let l=r.current+=1;c(l,j.file(e,i)).then(e=>{l===r.current&&n({kind:`file`,value:e})}).catch(e=>{if(l!==r.current)return Me(e)?t(e):void 0;if(!s?.restoring)return t(e);Me(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,o,c]),openCommit:(0,M.useCallback)(i=>{if(!e)return;a(`diff`);let o=r.current+=1;c(o,j.commit(e,i)).then(e=>{o===r.current&&n({kind:`diff`,value:e})}).catch(e=>{o===r.current&&t(e)})},[e,t,n,r,a,c]),openCommitFileDiff:(0,M.useCallback)((i,o,s)=>{if(!e)return;s?.restoring||a(`diff`);let l=r.current+=1;c(l,j.commitFileDiff(e,i,o)).then(e=>{l===r.current&&n({kind:`diff`,value:e,source:In(e)?{kind:`commit`,oid:i,path:o}:void 0})}).catch(e=>{if(l!==r.current)return Me(e)?t(e):void 0;if(!s?.restoring)return t(e);Me(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,c]),openCommitFiles:(0,M.useCallback)(async o=>{if(!e)return;a(`diff`);let s=r.current+=1;try{let t=await c(s,j.commitFiles(e,o.oid));if(s!==r.current)return;if(i({commit:o,...t}),t.files.length===0){n({kind:`empty`});return}let a=await c(s,j.commit(e,o.oid));s===r.current&&n({kind:`diff`,value:a})}catch(e){s===r.current&&t(e)}},[e,t,n,r,i,a,c]),showOtherFace:(0,M.useCallback)((i,a=0)=>{let s=Pn(i);if(!e||!s)return;let{source:u}=s,d=s.want===`file`,f=d&&i.kind===`diff`?An(i.value,a):null,p=r.current+=1,m=u.kind===`workdir`?d?j.file(e,u.path):j.diff(e,u.path):d?j.commitFile(e,u.oid,u.path):j.commitFileDiff(e,u.oid,u.path);d&&o(!1),c(p,m).then(e=>{p===r.current&&n(d?{kind:`file`,value:e,source:u,anchor:f===null?void 0:jn(f)+1}:{kind:`diff`,value:e,source:In(e)&&(u.kind!==`workdir`||l(u.path))?u:void 0})}).catch(e=>{p===r.current&&t(e)})},[e,t,n,r,o,l,c])}}function ta(){let[e,t]=(0,M.useState)(null),n=(0,M.useCallback)((e,n)=>{t(e);let r=()=>t(t=>t===e?null:t);return n.then(r,r),n},[]);return{loading:e!==null,track:n}}function na({repo:e,handle:t,pane:n,setPane:r,paneRequestRef:i,setCommitDrillDown:a,status:o}){let{mobileView:s,setMobileView:c}=$i(),[l,u]=(0,M.useState)(!0),{loading:d,track:f}=ta(),p=(0,M.useRef)(o);p.current=o;let{openDiff:m,openFile:h,openCommit:g,openCommitFileDiff:_,openCommitFiles:v,showOtherFace:y}=ea({repo:e,handle:t,setPane:r,paneRequestRef:i,setCommitDrillDown:a,setMobileView:c,setPreviewRendered:u,statusRef:p,track:f}),b=(0,M.useMemo)(()=>({openDiff:m,openFile:h,openCommit:g,openCommitFileDiff:_,openCommitFiles:v,showOtherFace:y}),[m,h,g,_,v,y]);return(0,M.useMemo)(()=>({openers:b,pane:n,setPane:r,paneLoading:d,previewRendered:l,setPreviewRendered:u,mobileView:s,setMobileView:c}),[b,n,r,d,l,s,c])}var ra=[`status`,`log`,`tree`];function ia(){return{tab:`status`,file:null,tree_expanded:[]}}function aa(e,t){return{path:e,commit:null,face:t}}function oa(e,t,n){return{path:t,commit:e,face:n}}function sa(e){return[...e].sort().slice(0,200)}function I(e){let t=e?.file;return!t||!t.path?{kind:`none`}:t.commit?{kind:`commitDiff`,oid:t.commit,path:t.path}:t.face===`source`?{kind:`file`,path:t.path}:{kind:`diff`,path:t.path}}function L(e){let t=e?.tab;return t&&ra.includes(t)?t:`status`}function ca(e,t){return e?e.tab===t.tab&&e.tree_expanded.length===t.tree_expanded.length&&e.tree_expanded.every((e,n)=>e===t.tree_expanded[n])&&la(e.file,t.file):!1}function la(e,t){return!e||!t?e===t:e.path===t.path&&e.commit===t.commit&&e.face===t.face}function ua({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,openDiff:o,openFile:s,openCommitFileDiff:c}){let l=(0,M.useRef)(null),u=(0,M.useRef)(null),d=(0,M.useRef)(new Map),[f,p]=(0,M.useState)(!1),m=(0,M.useRef)(!1);(0,M.useEffect)(()=>{if(u.current!==e&&(u.current=e,l.current=null,m.current=!1,p(!1)),!e||!t||l.current===e)return;l.current=e;let r=d.current.get(e);d.current.delete(e);let f=r?{...n??ia(),...r}:n;if(r&&i(e,f),m.current)return;a(L(f));let h=I(f);if(h.kind===`none`)return;let g={restoring:!0};h.kind===`diff`?o(h.path,g):h.kind===`file`?s(h.path,g):c(h.oid,h.path,g)},[e,t,n,i,a,o,s,c]);let h=(0,M.useCallback)(t=>{if(e){if(m.current=!0,p(!0),l.current!==e){let n=d.current.get(e);d.current.set(e,{...n,...t})}else i(e,{...r(e)??ia(),...t})}},[e,r,i]);return{touched:f,noteTab:(0,M.useCallback)(e=>h({tab:e}),[h]),noteFile:(0,M.useCallback)(e=>h({file:e}),[h]),noteTree:(0,M.useCallback)(e=>h({tree_expanded:sa(e)}),[h])}}function da({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,clearPane:o,openers:s}){let c=ua({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,openDiff:s.openDiff,openFile:s.openFile,openCommitFileDiff:s.openCommitFileDiff}),{noteFile:l,noteTab:u,noteTree:d}=c,f=(0,M.useCallback)(e=>{u(e),a(e)},[u,a]),p=(0,M.useCallback)(()=>{l(null),o()},[l,o]),m=(0,M.useMemo)(()=>({openDiff:e=>{l(aa(e,`diff`)),s.openDiff(e)},openFile:e=>{l(aa(e,`source`)),s.openFile(e)},openCommit:e=>{l(null),s.openCommit(e)},openCommitFiles:e=>(l(null),s.openCommitFiles(e)),openCommitFileDiff:(e,t)=>{l(oa(e,t,`diff`)),s.openCommitFileDiff(e,t)}}),[s,l]),h=(0,M.useCallback)((e,t)=>{l(e.kind===`commit`?oa(e.oid,e.path,t):aa(e.path,t))},[l]);return{...c,noteTree:d,chooseTab:f,forgetPane:p,asked:m,noteOtherFace:h}}function fa({project:e,view:t,layout:n}){let{repo:r,repos:i,authed:a,hot:o,clockSkewMs:s,resumeTick:c,handle:l}=e,u=Yi({repo:r,authed:a,hot:o,clockSkewMs:s,resumeTick:c,handle:l}),d=na({repo:r,handle:l,pane:u.screen.pane,setPane:u.screen.setPane,paneRequestRef:u.request.paneRequestRef,setCommitDrillDown:u.log.setCommitDrillDown,status:u.status.value}),f=da({repo:r,known:t.known,remembered:t.remembered,latest:t.latest,remember:t.remember,setTab:u.screen.setTab,clearPane:u.request.clearPane,openers:d.openers}),p=u.screen.tab,{bumpPaneRequest:m}=u.request,{setCommitDrillDown:h,resetLog:g}=u.log,{chooseTab:_,forgetPane:v}=f,y=(0,M.useCallback)(e=>void Bi(p,e,{bumpPaneRequest:m,leaveLog:()=>{h(null),g()},recordTab:_,forgetPane:v}),[p,m,h,g,_,v]);Vi(u.log.commits,u.log.commitDrillDown,u.log.setCommitDrillDown,u.request.bumpPaneRequest,f.forgetPane);let b=n.maximizedPanelOf(r),x=n.setMaximizedFor,S=(0,M.useCallback)(e=>x(r,e),[r,x]),C=d.pane,w=d.openers.showOtherFace,T=f.noteOtherFace,E=(0,M.useCallback)(e=>{let t=Pn(C);t&&T(t.source,t.want===`file`?`source`:`diff`),w(C,e)},[C,T,w]);return{setPane:d.setPane,setTab:u.screen.setTab,clearPane:u.request.clearPane,maximized:b,tab:p,chooseTab:y,setMaximized:S,repoShell:r?{repository:{id:r,current:i.find(e=>e.id===r),status:u.status.value},sidebar:{tab:u.screen.tab,filter:u.screen.filter,setFilter:u.screen.setFilter,filterOpen:u.screen.filterOpen,setFilterOpen:u.screen.setFilterOpen,files:u.status.files,hotWindowMs:u.status.hotWindowMs,clockSkewMs:u.status.clockSkewMs,...d.openers,...f.asked,chooseTab:y,authed:a,handle:l,bumpPaneRequest:u.request.bumpPaneRequest,...u.log,restoreTree:t.remembered?.tree_expanded??[],restoreKnown:t.known,onTreeExpanded:f.noteTree,clearPane:f.forgetPane,touched:f.touched},filePane:{repo:r,pane:d.pane,loading:d.paneLoading,previewRendered:d.previewRendered,setPreviewRendered:d.setPreviewRendered,showOtherFace:E},layout:{...n.shell,maximized:b,setMaximized:S,mobileView:d.mobileView,setMobileView:d.setMobileView}}:null}}function pa(){let[e,t]=(0,M.useState)(0);return(0,M.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&t(e=>e+1)};return document.addEventListener(`visibilitychange`,e),window.addEventListener(`online`,e),()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`online`,e)}},[]),e}var ma=[{name:`yellow`,color:`#d9a441`},{name:`cyan`,color:`#03c4db`},{name:`green`,color:`#77c47a`},{name:`magenta`,color:`#dc8fd5`},{name:`blue`,color:`#87acfd`}],ha=`nightcrow.viewer.accent`;function ga(e){if(!Number.isFinite(e))return 0;let t=ma.length;return(Math.trunc(e)%t+t)%t}function _a(){let e=m(ha);return e===null?0:ga(Number(e))}function va(e){h(ha,String(e))}function ya(){let[e,t]=(0,M.useState)(_a);(0,M.useLayoutEffect)(()=>{document.documentElement.style.setProperty(`--color-accent`,ma[e].color)},[e]);let n=(0,M.useCallback)(()=>{t(e=>{let t=ga(e+1);return va(t),j.setAccent(t).catch(()=>{}),t})},[]),r=(0,M.useCallback)(e=>{t(t=>{let n=ga(e);return n===t?t:(va(n),n)})},[]);return{accent:ma[e],next:ma[ga(e+1)],cycle:n,adopt:r}}function ba(e){return Number.isFinite(e)?Math.min(Math.max(e,20),85):55}function xa(e){return Math.round(ba(e))}function Sa(e,t,n,r){let i=n-t;return ba(i<=0?r:(e-t)/i*100)}var Ca=`nightcrow.upperPct`;function wa(){try{let e=Number(localStorage.getItem(Ca));return Number.isFinite(e)&&e>0?xa(e):55}catch{return 55}}function Ta(e){try{localStorage.setItem(Ca,String(e))}catch{}}function Ea(){let[e,t]=(0,M.useState)(wa);return{pct:e,resize:(0,M.useCallback)(e=>{t(ba(e))},[]),commit:(0,M.useCallback)(e=>{let n=xa(e);t(n),Ta(n),j.setUpperPct(n).catch(()=>{})},[]),reset:(0,M.useCallback)(()=>{t(55),Ta(55),j.setUpperPct(55).catch(()=>{})},[]),adopt:(0,M.useCallback)(e=>{t(t=>{let n=xa(e);return n===t?t:(Ta(n),n)})},[])}}function Da(){let[e,t]=(0,M.useState)({}),n=(0,M.useRef)(e),r=(0,M.useCallback)(e=>{n.current=e,t(e)},[]),i=(0,M.useRef)(0),a=(0,M.useRef)(new Map),o=(0,M.useCallback)(e=>{let t=a.current.get(e);if(t)return t;let n=xi(t=>j.setMaximized(e,t===`none`?null:t));return a.current.set(e,n),n},[]),s=(0,M.useCallback)((e,t)=>{if(e==null)return;let a=n.current,s=typeof t==`function`?t(a[e]??`none`):t;i.current+=1,o(e)(s);let{[e]:c,...l}=a;r(s===`none`?l:{...a,[e]:s})},[o,r]);return{panelOf:(0,M.useCallback)(t=>t!=null&&e[t]||`none`,[e]),setFor:s,adopt:(0,M.useCallback)(e=>{Oa(n.current,e)||r(e)},[r]),writes:i}}function Oa(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])}function ka(){let[e,t]=(0,M.useState)({}),n=(0,M.useRef)(e),r=(0,M.useCallback)(e=>{n.current=e,t(e)},[]),i=(0,M.useRef)(0),a=(0,M.useRef)(new Map),o=(0,M.useCallback)(e=>{let t=a.current.get(e);if(t)return t;let n=xi(t=>j.setRepoView(e,t));return a.current.set(e,n),n},[]),s=(0,M.useCallback)((e,t)=>{e!=null&&(ca(n.current[e],t)||(i.current+=1,o(e)(t),r({...n.current,[e]:t})))},[o,r]),c=(0,M.useCallback)(t=>t==null?void 0:e[t],[e]),l=(0,M.useCallback)(e=>n.current[e],[]),u=(0,M.useRef)(new Set),[d,f]=(0,M.useState)(0);return{viewOf:c,rememberedFor:l,remember:s,adopt:(0,M.useCallback)((e,t)=>{let i=u.current;(i.size!==t.length||t.some(e=>!i.has(e)))&&(u.current=new Set(t),f(e=>e+1)),!Aa(n.current,e)&&r(e)},[r]),covers:(0,M.useCallback)(e=>e!=null&&u.current.has(e),[d]),writes:i}}function Aa(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>t[n]!==void 0&&ca(e[n],t[n]))}function ja(){let{accent:e,next:t,cycle:n,adopt:r}=ya(),{width:i,resize:a,commit:o,reset:s}=Tt(),{pct:c,resize:l,commit:u,reset:d,adopt:f}=Ea(),p=Da(),m=ka(),h=(0,M.useRef)(0),g=(0,M.useRef)(0);return{accent:e,next:t,cycle:(0,M.useCallback)(()=>{h.current+=1,n()},[n]),adoptAccent:r,accentWrites:h,sidebarWidth:i,resizeSidebar:a,commitSidebarWidth:o,resetSidebarWidth:s,upperPct:c,resizeUpperPct:l,commitUpperPct:(0,M.useCallback)(e=>{g.current+=1,u(e)},[u]),resetUpperPct:(0,M.useCallback)(()=>{g.current+=1,d()},[d]),bumpUpperPctWrites:(0,M.useCallback)(()=>{g.current+=1},[]),adoptUpperPct:f,upperPctWrites:g,maximizedPanelOf:p.panelOf,setMaximizedFor:p.setFor,adoptMaximized:p.adopt,maximizedWrites:p.writes,viewOf:m.viewOf,rememberedViewFor:m.rememberedFor,rememberView:m.remember,adoptViews:m.adopt,viewCovers:m.covers,viewWrites:m.writes}}var Ma=400;function Na({value:e,valueAt:t,onGestureStart:n,resize:r,commit:i,reset:a,axis:o}){let s=(0,M.useRef)(0),c=(0,M.useRef)(0),l=(0,M.useRef)(!1),u=(0,M.useRef)(!1),d=(0,M.useRef)(0),[f,p]=(0,M.useState)(!1);return{dragging:f,onDragStart:(0,M.useCallback)(t=>{t.button===0&&t.isPrimary&&n()&&(s.current=o===`x`?t.clientX:t.clientY,c.current=e,l.current=!0,u.current=!1,p(!0),t.currentTarget.setPointerCapture(t.pointerId),t.preventDefault())},[e,n,o]),onDragMove:(0,M.useCallback)(e=>{if(!l.current)return;let n=o===`x`?e.clientX:e.clientY;if(!u.current&&Math.abs(n-s.current)<3)return;let i=t(e);i!==null&&(u.current=!0,c.current=i,r(i))},[t,r,o]),onDragEnd:(0,M.useCallback)(()=>{if(!l.current)return;if(l.current=!1,p(!1),u.current){i(c.current),d.current=0;return}let e=Date.now();e-d.current{l.current=!1,u.current=!1,d.current=0,p(!1)},[]),draggingRef:l}}function Pa({sidebarRef:e,sidebarWidth:t,resizeSidebar:n,commitSidebarWidth:r,resetSidebarWidth:i}){let a=(0,M.useRef)(0),o=(0,M.useCallback)(()=>{let t=e.current?.getBoundingClientRect().left;return t!==void 0&&(a.current=t,!0)},[e]),{dragging:s,onDragStart:c,onDragMove:l,onDragEnd:u,onDragCancel:d}=Na({value:t,valueAt:(0,M.useCallback)(e=>e.clientX-a.current,[]),onGestureStart:o,resize:n,commit:r,reset:i,axis:`x`});return{draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d}}function Fa({upperRef:e,lowerRef:t,upperPct:n,resizeUpperPct:r,commitUpperPct:i,resetUpperPct:a,bumpUpperPctWrites:o}){let s=(0,M.useRef)(0),c=(0,M.useRef)(0),l=(0,M.useCallback)(()=>{let n=e.current?.getBoundingClientRect().top,r=t.current?.getBoundingClientRect().bottom;return n===void 0||r===void 0?!1:(s.current=n,c.current=r,o(),!0)},[e,t,o]),{dragging:u,onDragStart:d,onDragMove:f,onDragEnd:p,onDragCancel:m,draggingRef:h}=Na({value:n,valueAt:(0,M.useCallback)(e=>Sa(e.clientY,s.current,c.current,n),[n]),onGestureStart:l,resize:r,commit:i,reset:a,axis:`y`});return{draggingUpper:u,onUpperDragStart:d,onUpperDragMove:f,onUpperDragEnd:p,onUpperDragCancel:m,upperDraggingRef:h}}function Ia(){let{accent:e,next:t,cycle:n,adoptAccent:r,accentWrites:i,sidebarWidth:a,resizeSidebar:o,commitSidebarWidth:s,resetSidebarWidth:c,upperPct:l,resizeUpperPct:u,commitUpperPct:d,resetUpperPct:f,bumpUpperPctWrites:p,adoptUpperPct:m,upperPctWrites:h,maximizedPanelOf:g,setMaximizedFor:_,adoptMaximized:v,maximizedWrites:y,viewOf:b,rememberedViewFor:x,rememberView:S,adoptViews:C,viewCovers:w,viewWrites:T}=ja(),E=(0,M.useRef)(null),ee=(0,M.useRef)(null),te=(0,M.useRef)(null),ne=Pa({sidebarRef:E,sidebarWidth:a,resizeSidebar:o,commitSidebarWidth:s,resetSidebarWidth:c}),re=Fa({upperRef:ee,lowerRef:te,upperPct:l,resizeUpperPct:u,commitUpperPct:d,resetUpperPct:f,bumpUpperPctWrites:p});return{accent:e,next:t,cycle:n,upperPct:l,maximizedPanelOf:g,setMaximizedFor:_,viewOf:b,rememberedViewFor:x,rememberView:S,viewCovers:w,shell:{sidebarWidth:a,sidebarRef:E,upperRef:ee,lowerRef:te,draggingSidebar:ne.draggingSidebar,onSidebarDragStart:ne.onSidebarDragStart,onSidebarDragMove:ne.onSidebarDragMove,onSidebarDragEnd:ne.onSidebarDragEnd,onSidebarDragCancel:ne.onSidebarDragCancel,draggingUpper:re.draggingUpper,onUpperDragStart:re.onUpperDragStart,onUpperDragMove:re.onUpperDragMove,onUpperDragEnd:re.onUpperDragEnd,onUpperDragCancel:re.onUpperDragCancel},guards:{adoptAccent:r,adoptUpperPct:m,adoptMaximized:v,adoptViews:C,accentWrites:i,upperPctWrites:h,maximizedWrites:y,viewWrites:T,upperDraggingRef:re.upperDraggingRef}}}var La=`nightcrow.tabStripSide`;function Ra(){return dt(m(La))??`top`}function za(e){h(La,e)}function Ba(){let[e,t]=(0,M.useState)(Ra);return{side:e,toggle:(0,M.useCallback)(()=>{t(e=>{let t=ft(e);return za(t),t})},[])}}function Va(){let[e,t]=(0,M.useState)(null),[n,r]=(0,M.useState)(!1),[i,a]=(0,M.useState)(null),o=(0,M.useCallback)(e=>{Me(e)?t(!1):D.error(e instanceof Error?e.message:`request failed`)},[]),s=pa(),c=Ia(),l=Ba(),u=Ii({authed:e,setAuthed:t,handle:o,resumeTick:s,...c.guards}),d=fa({project:{repo:u.repo,repos:u.repos,authed:e,hot:u.hot,clockSkewMs:u.clockSkewMs,resumeTick:s,handle:o},view:{known:c.viewCovers(u.repo),remembered:c.viewOf(u.repo),latest:c.rememberedViewFor,remember:c.rememberView},layout:{shell:c.shell,maximizedPanelOf:c.maximizedPanelOf,setMaximizedFor:c.setMaximizedFor}}),{selectOpenedRepo:f,closeRepo:p}=zi({repo:u.repo,repos:u.repos,setRepos:u.setRepos,setRepo:u.setRepo,setPane:d.setPane,setTab:d.setTab,setPickerOpen:r,handle:o,orderWrites:u.orderWrites}),{busy:m,start:h}=yi(f,e===!0),g=u.repo,_=u.setRepo,v=d.clearPane,y=(0,M.useCallback)(e=>{e!==g&&(_(e),v())},[g,_,v]),b=u.repos.find(e=>e.id===i),x=(0,M.useCallback)(()=>a(null),[]),S=(0,M.useCallback)(()=>r(!0),[]),C=(0,M.useCallback)(()=>r(!1),[]),w=Li(),T=hi({enabled:e===!0,repo:u.repo,repos:u.repos,selectRepo:y,closeRepo:p,openPicker:S,pickerOpen:n,cycleAccent:c.cycle,reloadConfig:w.reload,tab:d.tab,chooseTab:d.chooseTab,maximized:d.maximized,setMaximized:d.setMaximized,mobileView:d.repoShell?.layout.mobileView??`files`});return{authed:e,login:(0,M.useCallback)(()=>t(null),[]),reposLoaded:u.reposLoaded,rows:zr(u.repo,d.maximized),upperPct:c.upperPct,header:{repos:u.repos,repo:u.repo,onSelectRepo:y,onCloseRepo:a,onOpenPicker:S,cloning:m,accent:c.accent,next:c.next,cycle:c.cycle,draggingRepo:u.draggingRepo,dragOverRepo:u.dragOverRepo,onRepoDragStart:u.onRepoDragStart,onRepoDragMove:u.onRepoDragMove,onRepoDragEnd:u.onRepoDragEnd,onReloadConfig:w.reload,reloading:w.pending,tabStrip:l},tabStrip:l,shortcutHelp:T.shortcutHelp,leader:T.settings,hint:T.hint,repoShell:d.repoShell,closeConfirm:b?{label:b.name,detail:`Its terminals and the processes running in them will be terminated.`,onConfirm:()=>{a(null),p(b.id)},onCancel:x}:null,picker:n?{onClose:C,onOpened:f,canClone:u.canClone,cloning:m,onClone:h}:null}}function Ha(){let e=Va();return e.authed===null?(0,N.jsx)(_t,{}):e.authed?e.reposLoaded?(0,N.jsx)(g,{children:(0,N.jsx)(oe,{children:(0,N.jsx)(x,{leader:e.leader.leader,children:(0,N.jsxs)(`div`,{className:`nc-fade-in flex h-full flex-col`,children:[(0,N.jsx)(pt,{...e.header,onShowShortcuts:e.shortcutHelp.show}),(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[e.tabStrip.side===`left`&&(0,N.jsx)(`aside`,{className:`hidden w-48 shrink-0 flex-col border-r border-chrome-line bg-ink-950 md:flex`,children:(0,N.jsx)(Ke,{side:`left`,...e.header})}),(0,N.jsxs)(`div`,{className:`grid min-h-0 min-w-0 flex-1 grid-cols-[minmax(0,1fr)] ${e.rows}`,style:{"--nc-upper":`${e.upperPct}fr`,"--nc-lower":`${100-e.upperPct}fr`},children:[e.repoShell?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(vr,{...e.repoShell}),(0,N.jsx)(Lr,{...e.hint})]}):(0,N.jsxs)(`div`,{className:`flex items-center justify-center p-6 text-center text-ink-400`,children:[(0,N.jsxs)(`span`,{className:`md:hidden`,children:[`No repository open. Tap`,` `,(0,N.jsx)(`span`,{className:`text-ink-200`,children:`No project`}),` above, then`,` `,(0,N.jsx)(`span`,{className:`text-ink-200`,children:`+ open`}),`, to add one.`]}),(0,N.jsxs)(`span`,{className:`hidden md:inline`,children:[`No repository open. Click`,` `,(0,N.jsx)(`span`,{className:`text-ink-200`,children:`+ open`}),` `,e.tabStrip.side===`left`?`beside`:`above`,` to add one.`]})]}),e.picker&&(0,N.jsx)(Le,{...e.picker}),e.closeConfirm&&(0,N.jsx)(se,{...e.closeConfirm}),e.shortcutHelp.open&&(0,N.jsx)(Er,{onClose:e.shortcutHelp.hide,leader:e.leader})]})]})]})})})}):(0,N.jsx)(_t,{}):(0,N.jsx)(vt,{onSuccess:e.login})}var Ua={error:7e3,info:5e3,success:5e3},Wa={error:`text-removed`,info:`text-accent`,success:`text-added`};function Ga(){let[e,t]=(0,M.useState)([]);return(0,M.useEffect)(()=>pe(t),[]),e.length===0?null:(0,N.jsx)(`div`,{className:`pointer-events-none fixed right-3 top-3 z-[60] flex w-80 max-w-[calc(100vw-1.5rem)] flex-col gap-2`,"aria-live":`polite`,children:e.map(e=>(0,N.jsx)(Ka,{toast:e},e.id))})}function Ka({toast:e}){let[t,n]=(0,M.useState)(!1);return(0,M.useEffect)(()=>{if(t||e.sticky)return;let n=setTimeout(()=>ge(e.id),Ua[e.kind]);return()=>clearTimeout(n)},[e.id,e.kind,e.bump,e.sticky,t]),(0,N.jsxs)(`div`,{role:e.kind===`error`?`alert`:`status`,className:`nc-slide-in pointer-events-auto flex items-start gap-2 rounded-md border border-ink-700 bg-ink-850 px-3 py-2 text-xs shadow-lg`,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[(0,N.jsx)(`span`,{className:`min-w-0 flex-1 break-words ${Wa[e.kind]}`,children:e.message}),e.action&&(0,N.jsx)(`button`,{type:`button`,onClick:e.action.run,className:`shrink-0 rounded-sm border border-ink-700 px-1.5 py-0.5 text-ink-200 hover:border-accent hover:text-accent`,children:e.action.label}),(0,N.jsx)(`button`,{type:`button`,onClick:()=>ge(e.id),"aria-label":`dismiss`,className:`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:bg-ink-700 hover:text-ink-200`,children:(0,N.jsx)(ae,{className:`h-3 w-3`})})]})}function qa(e){let t=new URLSearchParams(e),n=t.get(`notice-repo`);if(!n)return null;let r=t.get(`notice-pane`);return{repo:n,pane:r!==null&&/^\d+$/.test(r)?Number(r):null}}async function Ja(e,t,n){let r=qa(e.search);if(!r)return;let i=new URL(e.href);i.searchParams.delete(`notice-repo`),i.searchParams.delete(`notice-pane`),t.replaceState(t.state,``,i.pathname+i.search+i.hash),r.pane!==null&&ve(r.repo,r.pane),await n(r.repo).catch(()=>void 0)}ce(document.documentElement,window),de(i()),ki(document.querySelector(`meta[name="nightcrow-build"]`)?.getAttribute(`content`)||null),Xe(Je()),await Ja(window.location,window.history,j.setActiveRepo);var Ya=1500;await Promise.race([document.fonts?.load(`400 12px "JetBrains Mono"`).catch(()=>void 0),new Promise(e=>setTimeout(e,Ya))]),(0,Ie.createRoot)(document.getElementById(`root`)).render((0,N.jsxs)(M.StrictMode,{children:[(0,N.jsx)(er,{children:(0,N.jsx)(Se,{children:(0,N.jsx)(Ha,{})})}),(0,N.jsx)(Ga,{})]})); \ No newline at end of file diff --git a/viewer-ui/dist/assets/index-CVFGi1WM.css b/viewer-ui/dist/assets/index-CVFGi1WM.css new file mode 100644 index 00000000..d2237bcb --- /dev/null +++ b/viewer-ui/dist/assets/index-CVFGi1WM.css @@ -0,0 +1,2 @@ +/*! tailwindcss v4.3.4 | MIT License | https://tailwindcss.com */ +@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-pan-x:initial;--tw-pan-y:initial;--tw-pinch-zoom:initial;--tw-border-style:solid;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}@layer theme{:root,:host{--font-sans:system-ui, sans-serif;--font-mono:"JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;--color-black:#000;--color-white:#fff;--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--radius-xs:4px;--radius-sm:4px;--radius-md:8px;--radius-lg:12px;--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-ink-950:#111112;--color-ink-900:#19191b;--color-ink-850:#202023;--color-ink-800:#232326;--color-ink-700:#343438;--color-ink-600:#48484e;--color-ink-400:#8f8f97;--color-ink-200:#c4c4ca;--color-ink-50:#f2f2f3;--color-chrome-line:#29292d;--color-accent:#d9a441;--color-added:#4ba36b;--color-removed:#d76a6a;--text-2xs:.65rem;--text-caption:.7rem;--text-caption--letter-spacing:.16em}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.invisible{visibility:hidden}.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:0}.inset-y-0{inset-block:0}.-top-0\.5{top:calc(var(--spacing) * -.5)}.-top-px{top:-1px}.top-0{top:0}.top-1{top:var(--spacing)}.top-3{top:calc(var(--spacing) * 3)}.top-\[calc\(var\(--nc-header-h\)\+8px\)\]{top:calc(var(--nc-header-h) + 8px)}.-right-2{right:calc(var(--spacing) * -2)}.-right-px{right:-1px}.right-1{right:var(--spacing)}.right-2{right:calc(var(--spacing) * 2)}.right-3{right:calc(var(--spacing) * 3)}.left-0{left:0}.left-1\/2{left:50%}.z-10{z-index:10}.z-20{z-index:20}.z-40{z-index:40}.z-50{z-index:50}.z-\[60\]{z-index:60}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.m-3{margin:calc(var(--spacing) * 3)}.mx-1{margin-inline:var(--spacing)}.mx-2{margin-inline:calc(var(--spacing) * 2)}.mx-auto{margin-inline:auto}.-my-1{margin-block:calc(var(--spacing) * -1)}.my-1{margin-block:var(--spacing)}.my-2{margin-block:calc(var(--spacing) * 2)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:var(--spacing)}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mr-1{margin-right:var(--spacing)}.mb-1{margin-bottom:var(--spacing)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-2\.5{margin-bottom:calc(var(--spacing) * 2.5)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-5{margin-bottom:calc(var(--spacing) * 5)}.ml-1{margin-left:var(--spacing)}.ml-auto{margin-left:auto}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.table{display:table}.h-\(--nc-header-h\){height:var(--nc-header-h)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-3{height:calc(var(--spacing) * 3)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-8{height:calc(var(--spacing) * 8)}.h-10{height:calc(var(--spacing) * 10)}.h-11{height:calc(var(--spacing) * 11)}.h-72{height:calc(var(--spacing) * 72)}.h-\[22px\]{height:22px}.h-full{height:100%}.max-h-\[70vh\]{max-height:70vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[calc\(100vh-3\.75rem\)\]{max-height:calc(100vh - 3.75rem)}.max-h-\[min\(80vh\,calc\(var\(--nc-visual-viewport-height\,100vh\)-8vh-1rem\)\)\]{max-height:min(80vh, calc(var(--nc-visual-viewport-height,100vh) - 8vh - 1rem))}.min-h-0{min-height:0}.min-h-9{min-height:calc(var(--spacing) * 9)}.min-h-11{min-height:calc(var(--spacing) * 11)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-1\/2{width:50%}.w-1\/3{width:33.3333%}.w-2{width:calc(var(--spacing) * 2)}.w-2\/3{width:66.6667%}.w-2\/5{width:40%}.w-3{width:calc(var(--spacing) * 3)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-3\/4{width:75%}.w-3\/5{width:60%}.w-4{width:calc(var(--spacing) * 4)}.w-4\/5{width:80%}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-8{width:calc(var(--spacing) * 8)}.w-10{width:calc(var(--spacing) * 10)}.w-11{width:calc(var(--spacing) * 11)}.w-24{width:calc(var(--spacing) * 24)}.w-28{width:calc(var(--spacing) * 28)}.w-30{width:calc(var(--spacing) * 30)}.w-48{width:calc(var(--spacing) * 48)}.w-56{width:calc(var(--spacing) * 56)}.w-72{width:calc(var(--spacing) * 72)}.w-80{width:calc(var(--spacing) * 80)}.w-\[17rem\]{width:17rem}.w-\[22px\]{width:22px}.w-\[28rem\]{width:28rem}.w-\[34rem\]{width:34rem}.w-\[40rem\]{width:40rem}.w-\[56rem\]{width:56rem}.w-full{width:100%}.w-max{width:max-content}.max-w-\[6rem\]{max-width:6rem}.max-w-\[50\%\]{max-width:50%}.max-w-\[80vw\]{max-width:80vw}.max-w-\[86vw\]{max-width:86vw}.max-w-\[calc\(100vw-1\.5rem\)\]{max-width:calc(100vw - 1.5rem)}.max-w-\[calc\(100vw-1rem\)\]{max-width:calc(100vw - 1rem)}.max-w-full{max-width:100%}.min-w-0{min-width:0}.min-w-9{min-width:calc(var(--spacing) * 9)}.min-w-full{min-width:100%}.flex-1{flex:1}.flex-none{flex:none}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.shrink-\[1000\]{flex-shrink:1000}.grow{flex-grow:1}.basis-full{flex-basis:100%}.origin-top-left{transform-origin:0 0}.origin-top-right{transform-origin:100% 0}.rotate-90{rotate:90deg}.transform{transform:var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, )}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-col-resize{cursor:col-resize}.cursor-grab{cursor:grab}.cursor-grabbing{cursor:grabbing}.cursor-row-resize{cursor:row-resize}.touch-pan-x{--tw-pan-x:pan-x;touch-action:var(--tw-pan-x, ) var(--tw-pan-y, ) var(--tw-pinch-zoom, )}.touch-pinch-zoom{--tw-pinch-zoom:pinch-zoom;touch-action:var(--tw-pan-x, ) var(--tw-pan-y, ) var(--tw-pinch-zoom, )}.touch-none{touch-action:none}.resize{resize:both}.resize-none{resize:none}.appearance-none{appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-\[minmax\(0\,1fr\)\]{grid-template-columns:minmax(0,1fr)}.grid-rows-\[1fr\]{grid-template-rows:1fr}.grid-rows-\[minmax\(0\,1fr\)\]{grid-template-rows:minmax(0,1fr)}.grid-rows-\[minmax\(0\,1fr\)_auto_auto\]{grid-template-rows:minmax(0,1fr) auto auto}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-\[1ch\]{gap:1ch}.self-center{align-self:center}.self-stretch{align-self:stretch}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-\[20\.7\%\]{border-radius:20.7%}.rounded-full{border-radius:2147483647px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xs{border-radius:var(--radius-xs)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-accent{border-color:var(--color-accent)}.border-added\/60{border-color:#4ba36b99}@supports (color:color-mix(in lab, red, red)){.border-added\/60{border-color:color-mix(in oklab, var(--color-added) 60%, transparent)}}.border-chrome-line{border-color:var(--color-chrome-line)}.border-ink-600{border-color:var(--color-ink-600)}.border-ink-700{border-color:var(--color-ink-700)}.border-ink-800{border-color:var(--color-ink-800)}.bg-accent{background-color:var(--color-accent)}.bg-added\/10{background-color:#4ba36b1a}@supports (color:color-mix(in lab, red, red)){.bg-added\/10{background-color:color-mix(in oklab, var(--color-added) 10%, transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab, red, red)){.bg-black\/60{background-color:color-mix(in oklab, var(--color-black) 60%, transparent)}}.bg-current{background-color:currentColor}.bg-ink-50{background-color:var(--color-ink-50)}.bg-ink-700{background-color:var(--color-ink-700)}.bg-ink-800{background-color:var(--color-ink-800)}.bg-ink-850{background-color:var(--color-ink-850)}.bg-ink-900{background-color:var(--color-ink-900)}.bg-ink-900\/40{background-color:#19191b66}@supports (color:color-mix(in lab, red, red)){.bg-ink-900\/40{background-color:color-mix(in oklab, var(--color-ink-900) 40%, transparent)}}.bg-ink-950{background-color:var(--color-ink-950)}.bg-ink-950\/80{background-color:#111112cc}@supports (color:color-mix(in lab, red, red)){.bg-ink-950\/80{background-color:color-mix(in oklab, var(--color-ink-950) 80%, transparent)}}.bg-removed{background-color:var(--color-removed)}.bg-removed\/10{background-color:#d76a6a1a}@supports (color:color-mix(in lab, red, red)){.bg-removed\/10{background-color:color-mix(in oklab, var(--color-removed) 10%, transparent)}}.bg-white{background-color:var(--color-white)}.p-1{padding:var(--spacing)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.px-1{padding-inline:var(--spacing)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-\[1ch\]{padding-inline:1ch}.px-\[12\.8px\]{padding-inline:12.8px}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.pt-\[8vh\]{padding-top:8vh}.pt-\[20vh\]{padding-top:20vh}.pr-1{padding-right:var(--spacing)}.pr-3{padding-right:calc(var(--spacing) * 3)}.pr-7{padding-right:calc(var(--spacing) * 7)}.pb-3{padding-bottom:calc(var(--spacing) * 3)}.pl-1{padding-left:var(--spacing)}.pl-2{padding-left:calc(var(--spacing) * 2)}.pl-3{padding-left:calc(var(--spacing) * 3)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-caption{font-size:var(--text-caption);letter-spacing:var(--tw-tracking,var(--text-caption--letter-spacing))}.text-2xs{font-size:var(--text-2xs)}.text-\[16px\]{font-size:16px}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[0\.04em\]{--tw-tracking:.04em;letter-spacing:.04em}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.break-words{overflow-wrap:break-word}.whitespace-nowrap{white-space:nowrap}.whitespace-pre{white-space:pre}.text-accent{color:var(--color-accent)}.text-added{color:var(--color-added)}.text-ink-50{color:var(--color-ink-50)}.text-ink-200{color:var(--color-ink-200)}.text-ink-400{color:var(--color-ink-400)}.text-ink-600{color:var(--color-ink-600)}.text-ink-950{color:var(--color-ink-950)}.text-removed{color:var(--color-removed)}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal, ) var(--tw-slashed-zero, ) var(--tw-numeric-figure, ) var(--tw-numeric-spacing, ) var(--tw-numeric-fraction, )}.underline{text-decoration-line:underline}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow-\[inset_0_-1px_0_0_var\(--color-accent\)\]{--tw-shadow:inset 0 -1px 0 0 var(--tw-shadow-color,var(--color-accent));box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-\[inset_1px_0_0_0_var\(--color-accent\)\]{--tw-shadow:inset 1px 0 0 0 var(--tw-shadow-color,var(--color-accent));box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring,.ring-1{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-accent{--tw-ring-color:var(--color-accent)}.ring-ink-600{--tw-ring-color:var(--color-ink-600)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}.filter{filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.\[-webkit-touch-callout\:none\]{-webkit-touch-callout:none}.ring-inset{--tw-ring-inset:inset}.placeholder\:text-ink-400::placeholder{color:var(--color-ink-400)}@media (hover:hover){.hover\:border-accent:hover{border-color:var(--color-accent)}.hover\:bg-accent:hover{background-color:var(--color-accent)}.hover\:bg-ink-700:hover{background-color:var(--color-ink-700)}.hover\:bg-ink-850:hover{background-color:var(--color-ink-850)}.hover\:bg-white:hover{background-color:var(--color-white)}.hover\:text-accent:hover{color:var(--color-accent)}.hover\:text-ink-50:hover{color:var(--color-ink-50)}.hover\:text-ink-200:hover{color:var(--color-ink-200)}.hover\:text-removed:hover{color:var(--color-removed)}}.focus\:border-accent:focus{border-color:var(--color-accent)}.focus\:border-ink-600:focus{border-color:var(--color-ink-600)}.focus\:ring-1:focus{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\:ring-\[3px\]:focus{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\:ring-accent:focus{--tw-ring-color:var(--color-accent)}.focus\:ring-accent\/15:focus{--tw-ring-color:#d9a44126}@supports (color:color-mix(in lab, red, red)){.focus\:ring-accent\/15:focus{--tw-ring-color:color-mix(in oklab, var(--color-accent) 15%, transparent)}}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.active\:bg-ink-700:active{background-color:var(--color-ink-700)}.active\:text-accent:active{color:var(--color-accent)}.disabled\:cursor-progress:disabled{cursor:progress}.disabled\:bg-ink-700:disabled{background-color:var(--color-ink-700)}.disabled\:text-ink-400:disabled{color:var(--color-ink-400)}.disabled\:text-ink-600:disabled{color:var(--color-ink-600)}.disabled\:opacity-50:disabled{opacity:.5}@media (hover:hover){.disabled\:hover\:bg-transparent:disabled:hover{background-color:#0000}.disabled\:hover\:text-ink-600:disabled:hover{color:var(--color-ink-600)}}@media (width>=48rem){.md\:col-span-2{grid-column:span 2/span 2}.md\:block{display:block}.md\:flex{display:flex}.md\:grid{display:grid}.md\:hidden{display:none}.md\:inline{display:inline}.md\:inline-flex{display:inline-flex}.md\:h-6{height:calc(var(--spacing) * 6)}.md\:w-6{width:calc(var(--spacing) * 6)}.md\:flex-1{flex:1}.md\:basis-1\/2{flex-basis:50%}.md\:grid-cols-\[18rem_minmax\(0\,1fr\)\]{grid-template-columns:18rem minmax(0,1fr)}.md\:grid-cols-\[var\(--nc-sidebar\)_minmax\(0\,1fr\)\]{grid-template-columns:var(--nc-sidebar) minmax(0,1fr)}.md\:grid-rows-\[minmax\(0\,0fr\)_minmax\(0\,1fr\)_auto_auto\]{grid-template-rows:minmax(0,0fr) minmax(0,1fr) auto auto}.md\:grid-rows-\[minmax\(0\,1fr\)_minmax\(0\,0fr\)_auto_auto\]{grid-template-rows:minmax(0,1fr) minmax(0,0fr) auto auto}.md\:grid-rows-\[minmax\(0\,3fr\)_minmax\(0\,2fr\)\]{grid-template-rows:minmax(0,3fr) minmax(0,2fr)}.md\:grid-rows-\[minmax\(0\,var\(--nc-upper\)\)_minmax\(0\,var\(--nc-lower\)\)_auto_auto\]{grid-template-rows:minmax(0,var(--nc-upper)) minmax(0,var(--nc-lower)) auto auto}.md\:flex-row{flex-direction:row}.md\:border-t-0{border-top-style:var(--tw-border-style);border-top-width:0}.md\:border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.md\:border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.md\:pt-\[8vh\]{padding-top:8vh}}}.xterm{cursor:text;-webkit-user-select:none;user-select:none;position:relative}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{z-index:5;position:absolute;top:0}.xterm .xterm-helper-textarea{opacity:0;z-index:-5;white-space:nowrap;resize:none;border:0;width:0;height:0;margin:0;padding:0;position:absolute;top:0;left:-9999em;overflow:hidden}.xterm .composition-view{color:#fff;white-space:nowrap;z-index:1;background:#000;display:none;position:absolute}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{cursor:default;background-color:#000;position:absolute;inset:0;overflow-y:scroll}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;top:0;left:0}.xterm-char-measure-element{visibility:hidden;line-height:normal;display:inline-block;position:absolute;top:0;left:-9999em}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{z-index:10;color:#0000;pointer-events:none;position:absolute;inset:0}.xterm .xterm-accessibility-tree:not(.debug) ::selection{color:#0000}.xterm .xterm-accessibility-tree{-webkit-user-select:text;user-select:text;white-space:pre;font-family:monospace}.xterm .xterm-accessibility-tree>div{transform-origin:0;width:fit-content}.xterm .live-region{width:1px;height:1px;position:absolute;left:-9999px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{-webkit-text-decoration:underline double;text-decoration:underline double}.xterm-underline-3{-webkit-text-decoration:underline wavy;text-decoration:underline wavy}.xterm-underline-4{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.xterm-underline-5{-webkit-text-decoration:underline dashed;text-decoration:underline dashed}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:underline overline}.xterm-overline.xterm-underline-2{-webkit-text-decoration:overline double underline;-webkit-text-decoration:overline double underline;-webkit-text-decoration:overline double underline;text-decoration:overline double underline}.xterm-overline.xterm-underline-3{-webkit-text-decoration:overline wavy underline;-webkit-text-decoration:overline wavy underline;-webkit-text-decoration:overline wavy underline;text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{-webkit-text-decoration:overline dotted underline;-webkit-text-decoration:overline dotted underline;-webkit-text-decoration:overline dotted underline;text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{-webkit-text-decoration:overline dashed underline;-webkit-text-decoration:overline dashed underline;-webkit-text-decoration:overline dashed underline;text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;pointer-events:none;position:absolute;top:0;right:0}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px!important}.xterm .xterm-scrollable-element>.visible{opacity:1;z-index:11;background:0 0;transition:opacity .1s linear}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity .8s linear}.xterm .xterm-scrollable-element>.shadow{display:none;position:absolute}.xterm .xterm-scrollable-element>.shadow.top{width:100%;height:3px;box-shadow:var(--vscode-scrollbar-shadow,#000) 0 6px 6px -6px inset;display:block;top:0;left:3px}.xterm .xterm-scrollable-element>.shadow.left{width:3px;height:100%;box-shadow:var(--vscode-scrollbar-shadow,#000) 6px 0 6px -6px inset;display:block;top:3px;left:0}.xterm .xterm-scrollable-element>.shadow.top-left-corner{width:3px;height:3px;display:block;top:0;left:0}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow,#000) 6px 0 6px -6px inset}:root{--nc-motion-fast:.12s;--nc-motion-base:.16s;--nc-motion-ease:cubic-bezier(.2, 0, 0, 1);--nc-title-fade:1rem;--nc-title-delay:.5s}.nc-title{white-space:nowrap;min-width:0;display:block;overflow:hidden}.nc-title-text{width:max-content;display:inline-block}.nc-title[data-overflow=true]{-webkit-mask-image:linear-gradient(to right, #000 calc(100% - var(--nc-title-fade)), transparent);-webkit-mask-image:linear-gradient(to right, #000 calc(100% - var(--nc-title-fade)), transparent);-webkit-mask-image:linear-gradient(to right, #000 calc(100% - var(--nc-title-fade)), transparent);mask-image:linear-gradient(to right, #000 calc(100% - var(--nc-title-fade)), transparent)}.nc-skeleton{background-color:var(--color-ink-800)}@keyframes nc-title-scroll{to{transform:translateX(calc(var(--nc-title-travel) - var(--nc-title-fade)))}}@keyframes nc-shimmer{0%{background-position:100% 0}to{background-position:0 0}}@keyframes nc-fade-in{0%{opacity:0}}@keyframes nc-pop-in{0%{opacity:0;transform:translateY(-4px)scale(.98)}}@keyframes nc-rise-in{0%{opacity:0;transform:translateY(8px)scale(.98)}}@keyframes nc-cell-in{0%{opacity:0;transform:translateY(12px)}}@keyframes nc-busy-dot{50%{opacity:.2}}@keyframes nc-slide-in{0%{opacity:0;transform:translate(16px)}}@media (prefers-reduced-motion:no-preference){.nc-title-target:is(:hover,:focus-visible,:has(:focus-visible)) .nc-title[data-overflow=true] .nc-title-text{animation:nc-title-scroll var(--nc-title-duration) linear var(--nc-title-delay) forwards}@media (hover:none){.nc-title-target:is([aria-selected=true],[data-active=true]) .nc-title[data-overflow=true] .nc-title-text{animation:nc-title-scroll var(--nc-title-duration) linear var(--nc-title-delay) forwards}}.nc-skeleton{background-image:linear-gradient(90deg, var(--color-ink-800) 40%, var(--color-ink-700) 50%, var(--color-ink-800) 60%);background-size:300% 100%;animation:1.6s linear infinite nc-shimmer}.nc-fade-in{animation:nc-fade-in var(--nc-motion-base) var(--nc-motion-ease)}.nc-pop-in{animation:nc-pop-in var(--nc-motion-fast) var(--nc-motion-ease)}.nc-rise-in{animation:nc-rise-in var(--nc-motion-base) var(--nc-motion-ease)}.nc-cell-in{animation:nc-cell-in .26s var(--nc-motion-ease)}.nc-busy-dot{animation:1s ease-in-out infinite nc-busy-dot}.nc-slide-in{animation:nc-slide-in var(--nc-motion-base) var(--nc-motion-ease)}[role=tab],.nc-title-target,.nc-content li>button{transition:background-color var(--nc-motion-fast) ease-out, color var(--nc-motion-fast) ease-out, box-shadow var(--nc-motion-fast) ease-out}}@font-face{font-family:JetBrains Mono;font-style:normal;font-display:block;font-weight:100 800;src:url(./jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2)format("woff2-variations");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:JetBrains Mono;font-style:normal;font-display:block;font-weight:100 800;src:url(./jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2)format("woff2-variations");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}html,body,#root{height:var(--nc-visual-viewport-height,100%)}html{font-size:14px}.nc-content{zoom:var(--nc-content-zoom,1)}@media (pointer:coarse){input:not([type=checkbox]):not([type=radio]),select,textarea:not(.xterm-helper-textarea){font-size:max(16px,1em)}}.overflow-auto,.overflow-y-auto,.xterm-viewport{overscroll-behavior-y:contain}body{background:var(--color-ink-950);color:var(--color-ink-50);font-family:var(--font-mono);margin:0;font-size:.85rem;line-height:1.4}button:not(:disabled),[role=button]:not(:disabled){cursor:pointer}:focus-visible{outline:1px solid var(--color-accent);outline-offset:-1px}:root{--nc-header-h:42px}*{scrollbar-width:thin;scrollbar-color:var(--color-ink-600) transparent}.nc-markdown{max-width:52rem;font-family:var(--font-sans);color:var(--color-ink-50);line-height:1.6}.nc-markdown h1,.nc-markdown h2,.nc-markdown h3,.nc-markdown h4,.nc-markdown h5,.nc-markdown h6{margin:1.4em 0 .6em;font-weight:600;line-height:1.25}.nc-markdown h1{border-bottom:1px solid var(--color-ink-700);padding-bottom:.3em;font-size:1.6em}.nc-markdown h2{border-bottom:1px solid var(--color-ink-800);padding-bottom:.25em;font-size:1.35em}.nc-markdown h3{font-size:1.15em}.nc-markdown h4{font-size:1em}.nc-markdown h5,.nc-markdown h6{color:var(--color-ink-200);font-size:.9em}.nc-markdown :first-child{margin-top:0}.nc-markdown p,.nc-markdown ul,.nc-markdown ol,.nc-markdown blockquote,.nc-markdown table,.nc-markdown pre{margin:.75em 0}.nc-markdown ul,.nc-markdown ol{padding-left:1.5em}.nc-markdown ul{list-style:outside}.nc-markdown ol{list-style:decimal}.nc-markdown li{margin:.25em 0}.nc-markdown li::marker{color:var(--color-ink-400)}.nc-markdown li:has(>input[type=checkbox]){margin-left:-1.2em;list-style:none}.nc-markdown a{color:var(--color-accent);text-underline-offset:2px;text-decoration:underline}.nc-markdown strong{font-weight:600}.nc-markdown em{font-style:italic}.nc-markdown blockquote{border-left:3px solid var(--color-ink-700);color:var(--color-ink-200);padding-left:1em}.nc-markdown hr{border:0;border-top:1px solid var(--color-ink-700);margin:1.5em 0}.nc-markdown img{max-width:100%}.nc-markdown :not(pre)>code{font-family:var(--font-mono);background:var(--color-ink-800);border-radius:3px;padding:.1em .35em;font-size:.9em}.nc-markdown pre{background:var(--color-ink-850);border:1px solid var(--color-ink-800);border-radius:4px;padding:.9em 1em;overflow-x:auto}.nc-markdown pre code{font-family:var(--font-mono);background:0 0;padding:0;font-size:.85em}.nc-markdown table{border-collapse:collapse;display:block;overflow-x:auto}.nc-markdown th,.nc-markdown td{border:1px solid var(--color-ink-700);text-align:left;padding:.4em .7em}.nc-markdown th{background:var(--color-ink-850);font-weight:600}.nc-pane-body>.xterm{flex:none}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-pan-x{syntax:"*";inherits:false}@property --tw-pan-y{syntax:"*";inherits:false}@property --tw-pinch-zoom{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}} diff --git a/viewer-ui/dist/assets/index-D6OgC7mI.css b/viewer-ui/dist/assets/index-D6OgC7mI.css deleted file mode 100644 index b0ca3ef9..00000000 --- a/viewer-ui/dist/assets/index-D6OgC7mI.css +++ /dev/null @@ -1,2 +0,0 @@ -/*! tailwindcss v4.3.4 | MIT License | https://tailwindcss.com */ -@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-pan-x:initial;--tw-pan-y:initial;--tw-pinch-zoom:initial;--tw-border-style:solid;--tw-font-weight:initial;--tw-tracking:initial;--tw-ordinal:initial;--tw-slashed-zero:initial;--tw-numeric-figure:initial;--tw-numeric-spacing:initial;--tw-numeric-fraction:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-outline-style:solid;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial}}}@layer theme{:root,:host{--font-sans:system-ui, sans-serif;--font-mono:"JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;--color-black:#000;--color-white:#fff;--spacing:.25rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--tracking-wide:.025em;--radius-xs:4px;--radius-sm:4px;--radius-md:8px;--radius-lg:12px;--animate-spin:spin 1s linear infinite;--animate-pulse:pulse 2s cubic-bezier(.4, 0, .6, 1) infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono);--color-ink-950:#111112;--color-ink-900:#19191b;--color-ink-850:#202023;--color-ink-800:#232326;--color-ink-700:#343438;--color-ink-600:#48484e;--color-ink-400:#8f8f97;--color-ink-200:#c4c4ca;--color-ink-50:#f2f2f3;--color-chrome-line:#29292d;--color-accent:#d9a441;--color-added:#4ba36b;--color-removed:#d76a6a;--text-2xs:.65rem;--text-caption:.7rem;--text-caption--letter-spacing:.16em}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring:where(:not(iframe)){outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab, red, red)){::placeholder{color:color-mix(in oklab, currentcolor 50%, transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.pointer-events-auto{pointer-events:auto}.pointer-events-none{pointer-events:none}.collapse{visibility:collapse}.invisible{visibility:hidden}.visible{visibility:visible}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.static{position:static}.sticky{position:sticky}.inset-0{inset:0}.inset-y-0{inset-block:0}.-top-0\.5{top:calc(var(--spacing) * -.5)}.-top-px{top:-1px}.top-0{top:0}.top-1{top:var(--spacing)}.top-3{top:calc(var(--spacing) * 3)}.top-\[calc\(var\(--nc-header-h\)\+8px\)\]{top:calc(var(--nc-header-h) + 8px)}.-right-2{right:calc(var(--spacing) * -2)}.-right-px{right:-1px}.right-1{right:var(--spacing)}.right-2{right:calc(var(--spacing) * 2)}.right-3{right:calc(var(--spacing) * 3)}.left-0{left:0}.left-1\/2{left:50%}.z-10{z-index:10}.z-20{z-index:20}.z-40{z-index:40}.z-50{z-index:50}.z-\[60\]{z-index:60}.container{width:100%}@media (width>=40rem){.container{max-width:40rem}}@media (width>=48rem){.container{max-width:48rem}}@media (width>=64rem){.container{max-width:64rem}}@media (width>=80rem){.container{max-width:80rem}}@media (width>=96rem){.container{max-width:96rem}}.m-3{margin:calc(var(--spacing) * 3)}.mx-1{margin-inline:var(--spacing)}.mx-2{margin-inline:calc(var(--spacing) * 2)}.mx-auto{margin-inline:auto}.-my-1{margin-block:calc(var(--spacing) * -1)}.my-1{margin-block:var(--spacing)}.my-2{margin-block:calc(var(--spacing) * 2)}.mt-0\.5{margin-top:calc(var(--spacing) * .5)}.mt-1{margin-top:var(--spacing)}.mt-1\.5{margin-top:calc(var(--spacing) * 1.5)}.mt-2{margin-top:calc(var(--spacing) * 2)}.mr-1{margin-right:var(--spacing)}.mb-1{margin-bottom:var(--spacing)}.mb-2{margin-bottom:calc(var(--spacing) * 2)}.mb-2\.5{margin-bottom:calc(var(--spacing) * 2.5)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.mb-5{margin-bottom:calc(var(--spacing) * 5)}.ml-1{margin-left:var(--spacing)}.ml-auto{margin-left:auto}.block{display:block}.contents{display:contents}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-block{display:inline-block}.table{display:table}.h-\(--nc-header-h\){height:var(--nc-header-h)}.h-1\.5{height:calc(var(--spacing) * 1.5)}.h-2{height:calc(var(--spacing) * 2)}.h-2\.5{height:calc(var(--spacing) * 2.5)}.h-3{height:calc(var(--spacing) * 3)}.h-3\.5{height:calc(var(--spacing) * 3.5)}.h-4{height:calc(var(--spacing) * 4)}.h-5{height:calc(var(--spacing) * 5)}.h-6{height:calc(var(--spacing) * 6)}.h-8{height:calc(var(--spacing) * 8)}.h-10{height:calc(var(--spacing) * 10)}.h-72{height:calc(var(--spacing) * 72)}.h-\[22px\]{height:22px}.h-full{height:100%}.max-h-\[70vh\]{max-height:70vh}.max-h-\[85vh\]{max-height:85vh}.max-h-\[calc\(100vh-3\.75rem\)\]{max-height:calc(100vh - 3.75rem)}.max-h-\[min\(80vh\,calc\(var\(--nc-visual-viewport-height\,100vh\)-8vh-1rem\)\)\]{max-height:min(80vh, calc(var(--nc-visual-viewport-height,100vh) - 8vh - 1rem))}.min-h-0{min-height:0}.min-h-9{min-height:calc(var(--spacing) * 9)}.min-h-11{min-height:calc(var(--spacing) * 11)}.w-1\.5{width:calc(var(--spacing) * 1.5)}.w-1\/2{width:50%}.w-1\/3{width:33.3333%}.w-2{width:calc(var(--spacing) * 2)}.w-2\/3{width:66.6667%}.w-2\/5{width:40%}.w-3{width:calc(var(--spacing) * 3)}.w-3\.5{width:calc(var(--spacing) * 3.5)}.w-3\/4{width:75%}.w-3\/5{width:60%}.w-4{width:calc(var(--spacing) * 4)}.w-4\/5{width:80%}.w-5{width:calc(var(--spacing) * 5)}.w-6{width:calc(var(--spacing) * 6)}.w-8{width:calc(var(--spacing) * 8)}.w-10{width:calc(var(--spacing) * 10)}.w-24{width:calc(var(--spacing) * 24)}.w-28{width:calc(var(--spacing) * 28)}.w-30{width:calc(var(--spacing) * 30)}.w-48{width:calc(var(--spacing) * 48)}.w-56{width:calc(var(--spacing) * 56)}.w-72{width:calc(var(--spacing) * 72)}.w-80{width:calc(var(--spacing) * 80)}.w-\[17rem\]{width:17rem}.w-\[22px\]{width:22px}.w-\[28rem\]{width:28rem}.w-\[34rem\]{width:34rem}.w-\[40rem\]{width:40rem}.w-\[56rem\]{width:56rem}.w-full{width:100%}.w-max{width:max-content}.max-w-\[6rem\]{max-width:6rem}.max-w-\[50\%\]{max-width:50%}.max-w-\[80vw\]{max-width:80vw}.max-w-\[86vw\]{max-width:86vw}.max-w-\[calc\(100vw-1\.5rem\)\]{max-width:calc(100vw - 1.5rem)}.max-w-\[calc\(100vw-1rem\)\]{max-width:calc(100vw - 1rem)}.max-w-full{max-width:100%}.min-w-0{min-width:0}.min-w-9{min-width:calc(var(--spacing) * 9)}.min-w-full{min-width:100%}.flex-1{flex:1}.flex-none{flex:none}.shrink{flex-shrink:1}.shrink-0{flex-shrink:0}.shrink-\[1000\]{flex-shrink:1000}.grow{flex-grow:1}.basis-full{flex-basis:100%}.origin-top-left{transform-origin:0 0}.origin-top-right{transform-origin:100% 0}.rotate-90{rotate:90deg}.transform{transform:var(--tw-rotate-x, ) var(--tw-rotate-y, ) var(--tw-rotate-z, ) var(--tw-skew-x, ) var(--tw-skew-y, )}.animate-pulse{animation:var(--animate-pulse)}.animate-spin{animation:var(--animate-spin)}.cursor-col-resize{cursor:col-resize}.cursor-grab{cursor:grab}.cursor-grabbing{cursor:grabbing}.cursor-row-resize{cursor:row-resize}.touch-pan-x{--tw-pan-x:pan-x;touch-action:var(--tw-pan-x, ) var(--tw-pan-y, ) var(--tw-pinch-zoom, )}.touch-pinch-zoom{--tw-pinch-zoom:pinch-zoom;touch-action:var(--tw-pan-x, ) var(--tw-pan-y, ) var(--tw-pinch-zoom, )}.touch-none{touch-action:none}.resize{resize:both}.resize-y{resize:vertical}.appearance-none{appearance:none}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.grid-cols-\[minmax\(0\,1fr\)\]{grid-template-columns:minmax(0,1fr)}.grid-rows-\[1fr\]{grid-template-rows:1fr}.grid-rows-\[minmax\(0\,1fr\)\]{grid-template-rows:minmax(0,1fr)}.grid-rows-\[minmax\(0\,1fr\)_auto_auto\]{grid-template-rows:minmax(0,1fr) auto auto}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-baseline{align-items:baseline}.items-center{align-items:center}.items-start{align-items:flex-start}.items-stretch{align-items:stretch}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:var(--spacing)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-3{gap:calc(var(--spacing) * 3)}.gap-\[1ch\]{gap:1ch}.self-center{align-self:center}.self-stretch{align-self:stretch}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-\[20\.7\%\]{border-radius:20.7%}.rounded-full{border-radius:2147483647px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.rounded-xs{border-radius:var(--radius-xs)}.border{border-style:var(--tw-border-style);border-width:1px}.border-0{border-style:var(--tw-border-style);border-width:0}.border-t{border-top-style:var(--tw-border-style);border-top-width:1px}.border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.border-b{border-bottom-style:var(--tw-border-style);border-bottom-width:1px}.border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.border-accent{border-color:var(--color-accent)}.border-added\/60{border-color:#4ba36b99}@supports (color:color-mix(in lab, red, red)){.border-added\/60{border-color:color-mix(in oklab, var(--color-added) 60%, transparent)}}.border-chrome-line{border-color:var(--color-chrome-line)}.border-ink-600{border-color:var(--color-ink-600)}.border-ink-700{border-color:var(--color-ink-700)}.border-ink-800{border-color:var(--color-ink-800)}.bg-accent{background-color:var(--color-accent)}.bg-added\/10{background-color:#4ba36b1a}@supports (color:color-mix(in lab, red, red)){.bg-added\/10{background-color:color-mix(in oklab, var(--color-added) 10%, transparent)}}.bg-black\/60{background-color:#0009}@supports (color:color-mix(in lab, red, red)){.bg-black\/60{background-color:color-mix(in oklab, var(--color-black) 60%, transparent)}}.bg-current{background-color:currentColor}.bg-ink-50{background-color:var(--color-ink-50)}.bg-ink-700{background-color:var(--color-ink-700)}.bg-ink-800{background-color:var(--color-ink-800)}.bg-ink-850{background-color:var(--color-ink-850)}.bg-ink-900{background-color:var(--color-ink-900)}.bg-ink-900\/40{background-color:#19191b66}@supports (color:color-mix(in lab, red, red)){.bg-ink-900\/40{background-color:color-mix(in oklab, var(--color-ink-900) 40%, transparent)}}.bg-ink-950{background-color:var(--color-ink-950)}.bg-removed{background-color:var(--color-removed)}.bg-removed\/10{background-color:#d76a6a1a}@supports (color:color-mix(in lab, red, red)){.bg-removed\/10{background-color:color-mix(in oklab, var(--color-removed) 10%, transparent)}}.bg-white{background-color:var(--color-white)}.p-1{padding:var(--spacing)}.p-2{padding:calc(var(--spacing) * 2)}.p-3{padding:calc(var(--spacing) * 3)}.p-4{padding:calc(var(--spacing) * 4)}.p-6{padding:calc(var(--spacing) * 6)}.px-1{padding-inline:var(--spacing)}.px-1\.5{padding-inline:calc(var(--spacing) * 1.5)}.px-2{padding-inline:calc(var(--spacing) * 2)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.px-\[1ch\]{padding-inline:1ch}.px-\[12\.8px\]{padding-inline:12.8px}.py-0\.5{padding-block:calc(var(--spacing) * .5)}.py-1{padding-block:var(--spacing)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.pt-\[8vh\]{padding-top:8vh}.pt-\[20vh\]{padding-top:20vh}.pr-1{padding-right:var(--spacing)}.pr-3{padding-right:calc(var(--spacing) * 3)}.pr-7{padding-right:calc(var(--spacing) * 7)}.pb-3{padding-bottom:calc(var(--spacing) * 3)}.pl-1{padding-left:var(--spacing)}.pl-2{padding-left:calc(var(--spacing) * 2)}.pl-3{padding-left:calc(var(--spacing) * 3)}.text-center{text-align:center}.text-left{text-align:left}.text-right{text-align:right}.font-mono{font-family:var(--font-mono)}.font-sans{font-family:var(--font-sans)}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.text-caption{font-size:var(--text-caption);letter-spacing:var(--tw-tracking,var(--text-caption--letter-spacing))}.text-2xs{font-size:var(--text-2xs)}.text-\[16px\]{font-size:16px}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.tracking-\[0\.04em\]{--tw-tracking:.04em;letter-spacing:.04em}.tracking-wide{--tw-tracking:var(--tracking-wide);letter-spacing:var(--tracking-wide)}.break-words{overflow-wrap:break-word}.whitespace-nowrap{white-space:nowrap}.whitespace-pre{white-space:pre}.text-accent{color:var(--color-accent)}.text-added{color:var(--color-added)}.text-ink-50{color:var(--color-ink-50)}.text-ink-200{color:var(--color-ink-200)}.text-ink-400{color:var(--color-ink-400)}.text-ink-600{color:var(--color-ink-600)}.text-ink-950{color:var(--color-ink-950)}.text-removed{color:var(--color-removed)}.lowercase{text-transform:lowercase}.uppercase{text-transform:uppercase}.italic{font-style:italic}.ordinal{--tw-ordinal:ordinal;font-variant-numeric:var(--tw-ordinal, ) var(--tw-slashed-zero, ) var(--tw-numeric-figure, ) var(--tw-numeric-spacing, ) var(--tw-numeric-fraction, )}.underline{text-decoration-line:underline}.opacity-50{opacity:.5}.opacity-60{opacity:.6}.opacity-70{opacity:.7}.shadow-\[inset_0_-1px_0_0_var\(--color-accent\)\]{--tw-shadow:inset 0 -1px 0 0 var(--tw-shadow-color,var(--color-accent));box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-\[inset_1px_0_0_0_var\(--color-accent\)\]{--tw-shadow:inset 1px 0 0 0 var(--tw-shadow-color,var(--color-accent));box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-lg{--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.shadow-xl{--tw-shadow:0 20px 25px -5px var(--tw-shadow-color,#0000001a), 0 8px 10px -6px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring,.ring-1{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring-accent{--tw-ring-color:var(--color-accent)}.ring-ink-600{--tw-ring-color:var(--color-ink-600)}.outline{outline-style:var(--tw-outline-style);outline-width:1px}.blur{--tw-blur:blur(8px);filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}.filter{filter:var(--tw-blur, ) var(--tw-brightness, ) var(--tw-contrast, ) var(--tw-grayscale, ) var(--tw-hue-rotate, ) var(--tw-invert, ) var(--tw-saturate, ) var(--tw-sepia, ) var(--tw-drop-shadow, )}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.\[-webkit-touch-callout\:none\]{-webkit-touch-callout:none}.ring-inset{--tw-ring-inset:inset}.placeholder\:text-ink-400::placeholder{color:var(--color-ink-400)}@media (hover:hover){.hover\:border-accent:hover{border-color:var(--color-accent)}.hover\:bg-accent:hover{background-color:var(--color-accent)}.hover\:bg-ink-700:hover{background-color:var(--color-ink-700)}.hover\:bg-ink-850:hover{background-color:var(--color-ink-850)}.hover\:bg-white:hover{background-color:var(--color-white)}.hover\:text-accent:hover{color:var(--color-accent)}.hover\:text-ink-50:hover{color:var(--color-ink-50)}.hover\:text-ink-200:hover{color:var(--color-ink-200)}.hover\:text-removed:hover{color:var(--color-removed)}}.focus\:border-accent:focus{border-color:var(--color-accent)}.focus\:border-ink-600:focus{border-color:var(--color-ink-600)}.focus\:ring-1:focus{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\:ring-\[3px\]:focus{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.focus\:ring-accent:focus{--tw-ring-color:var(--color-accent)}.focus\:ring-accent\/15:focus{--tw-ring-color:#d9a44126}@supports (color:color-mix(in lab, red, red)){.focus\:ring-accent\/15:focus{--tw-ring-color:color-mix(in oklab, var(--color-accent) 15%, transparent)}}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}.active\:bg-ink-700:active{background-color:var(--color-ink-700)}.active\:text-accent:active{color:var(--color-accent)}.disabled\:cursor-progress:disabled{cursor:progress}.disabled\:bg-ink-700:disabled{background-color:var(--color-ink-700)}.disabled\:text-ink-400:disabled{color:var(--color-ink-400)}.disabled\:text-ink-600:disabled{color:var(--color-ink-600)}.disabled\:opacity-50:disabled{opacity:.5}@media (hover:hover){.disabled\:hover\:bg-transparent:disabled:hover{background-color:#0000}}@media (width>=48rem){.md\:col-span-2{grid-column:span 2/span 2}.md\:block{display:block}.md\:flex{display:flex}.md\:grid{display:grid}.md\:hidden{display:none}.md\:inline{display:inline}.md\:inline-flex{display:inline-flex}.md\:h-6{height:calc(var(--spacing) * 6)}.md\:w-6{width:calc(var(--spacing) * 6)}.md\:flex-1{flex:1}.md\:basis-1\/2{flex-basis:50%}.md\:grid-cols-\[18rem_minmax\(0\,1fr\)\]{grid-template-columns:18rem minmax(0,1fr)}.md\:grid-cols-\[var\(--nc-sidebar\)_minmax\(0\,1fr\)\]{grid-template-columns:var(--nc-sidebar) minmax(0,1fr)}.md\:grid-rows-\[minmax\(0\,0fr\)_minmax\(0\,1fr\)_auto_auto\]{grid-template-rows:minmax(0,0fr) minmax(0,1fr) auto auto}.md\:grid-rows-\[minmax\(0\,1fr\)_minmax\(0\,0fr\)_auto_auto\]{grid-template-rows:minmax(0,1fr) minmax(0,0fr) auto auto}.md\:grid-rows-\[minmax\(0\,3fr\)_minmax\(0\,2fr\)\]{grid-template-rows:minmax(0,3fr) minmax(0,2fr)}.md\:grid-rows-\[minmax\(0\,var\(--nc-upper\)\)_minmax\(0\,var\(--nc-lower\)\)_auto_auto\]{grid-template-rows:minmax(0,var(--nc-upper)) minmax(0,var(--nc-lower)) auto auto}.md\:flex-row{flex-direction:row}.md\:border-t-0{border-top-style:var(--tw-border-style);border-top-width:0}.md\:border-r{border-right-style:var(--tw-border-style);border-right-width:1px}.md\:border-l{border-left-style:var(--tw-border-style);border-left-width:1px}.md\:pt-\[8vh\]{padding-top:8vh}}}.xterm{cursor:text;-webkit-user-select:none;user-select:none;position:relative}.xterm.focus,.xterm:focus{outline:none}.xterm .xterm-helpers{z-index:5;position:absolute;top:0}.xterm .xterm-helper-textarea{opacity:0;z-index:-5;white-space:nowrap;resize:none;border:0;width:0;height:0;margin:0;padding:0;position:absolute;top:0;left:-9999em;overflow:hidden}.xterm .composition-view{color:#fff;white-space:nowrap;z-index:1;background:#000;display:none;position:absolute}.xterm .composition-view.active{display:block}.xterm .xterm-viewport{cursor:default;background-color:#000;position:absolute;inset:0;overflow-y:scroll}.xterm .xterm-screen{position:relative}.xterm .xterm-screen canvas{position:absolute;top:0;left:0}.xterm-char-measure-element{visibility:hidden;line-height:normal;display:inline-block;position:absolute;top:0;left:-9999em}.xterm.enable-mouse-events{cursor:default}.xterm.xterm-cursor-pointer,.xterm .xterm-cursor-pointer{cursor:pointer}.xterm.column-select.focus{cursor:crosshair}.xterm .xterm-accessibility:not(.debug),.xterm .xterm-message{z-index:10;color:#0000;pointer-events:none;position:absolute;inset:0}.xterm .xterm-accessibility-tree:not(.debug) ::selection{color:#0000}.xterm .xterm-accessibility-tree{-webkit-user-select:text;user-select:text;white-space:pre;font-family:monospace}.xterm .xterm-accessibility-tree>div{transform-origin:0;width:fit-content}.xterm .live-region{width:1px;height:1px;position:absolute;left:-9999px;overflow:hidden}.xterm-dim{opacity:1!important}.xterm-underline-1{text-decoration:underline}.xterm-underline-2{-webkit-text-decoration:underline double;text-decoration:underline double}.xterm-underline-3{-webkit-text-decoration:underline wavy;text-decoration:underline wavy}.xterm-underline-4{-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.xterm-underline-5{-webkit-text-decoration:underline dashed;text-decoration:underline dashed}.xterm-overline{text-decoration:overline}.xterm-overline.xterm-underline-1{text-decoration:underline overline}.xterm-overline.xterm-underline-2{-webkit-text-decoration:overline double underline;-webkit-text-decoration:overline double underline;-webkit-text-decoration:overline double underline;text-decoration:overline double underline}.xterm-overline.xterm-underline-3{-webkit-text-decoration:overline wavy underline;-webkit-text-decoration:overline wavy underline;-webkit-text-decoration:overline wavy underline;text-decoration:overline wavy underline}.xterm-overline.xterm-underline-4{-webkit-text-decoration:overline dotted underline;-webkit-text-decoration:overline dotted underline;-webkit-text-decoration:overline dotted underline;text-decoration:overline dotted underline}.xterm-overline.xterm-underline-5{-webkit-text-decoration:overline dashed underline;-webkit-text-decoration:overline dashed underline;-webkit-text-decoration:overline dashed underline;text-decoration:overline dashed underline}.xterm-strikethrough{text-decoration:line-through}.xterm-screen .xterm-decoration-container .xterm-decoration{z-index:6;position:absolute}.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer{z-index:7}.xterm-decoration-overview-ruler{z-index:8;pointer-events:none;position:absolute;top:0;right:0}.xterm-decoration-top{z-index:2;position:relative}.xterm .xterm-scrollable-element>.scrollbar{cursor:default}.xterm .xterm-scrollable-element>.scrollbar>.scra{cursor:pointer;font-size:11px!important}.xterm .xterm-scrollable-element>.visible{opacity:1;z-index:11;background:0 0;transition:opacity .1s linear}.xterm .xterm-scrollable-element>.invisible{opacity:0;pointer-events:none}.xterm .xterm-scrollable-element>.invisible.fade{transition:opacity .8s linear}.xterm .xterm-scrollable-element>.shadow{display:none;position:absolute}.xterm .xterm-scrollable-element>.shadow.top{width:100%;height:3px;box-shadow:var(--vscode-scrollbar-shadow,#000) 0 6px 6px -6px inset;display:block;top:0;left:3px}.xterm .xterm-scrollable-element>.shadow.left{width:3px;height:100%;box-shadow:var(--vscode-scrollbar-shadow,#000) 6px 0 6px -6px inset;display:block;top:3px;left:0}.xterm .xterm-scrollable-element>.shadow.top-left-corner{width:3px;height:3px;display:block;top:0;left:0}.xterm .xterm-scrollable-element>.shadow.top.left{box-shadow:var(--vscode-scrollbar-shadow,#000) 6px 0 6px -6px inset}:root{--nc-motion-fast:.12s;--nc-motion-base:.16s;--nc-motion-ease:cubic-bezier(.2, 0, 0, 1);--nc-title-fade:1rem;--nc-title-delay:.5s}.nc-title{white-space:nowrap;min-width:0;display:block;overflow:hidden}.nc-title-text{width:max-content;display:inline-block}.nc-title[data-overflow=true]{-webkit-mask-image:linear-gradient(to right, #000 calc(100% - var(--nc-title-fade)), transparent);-webkit-mask-image:linear-gradient(to right, #000 calc(100% - var(--nc-title-fade)), transparent);-webkit-mask-image:linear-gradient(to right, #000 calc(100% - var(--nc-title-fade)), transparent);mask-image:linear-gradient(to right, #000 calc(100% - var(--nc-title-fade)), transparent)}.nc-skeleton{background-color:var(--color-ink-800)}@keyframes nc-title-scroll{to{transform:translateX(calc(var(--nc-title-travel) - var(--nc-title-fade)))}}@keyframes nc-shimmer{0%{background-position:100% 0}to{background-position:0 0}}@keyframes nc-fade-in{0%{opacity:0}}@keyframes nc-pop-in{0%{opacity:0;transform:translateY(-4px)scale(.98)}}@keyframes nc-rise-in{0%{opacity:0;transform:translateY(8px)scale(.98)}}@keyframes nc-cell-in{0%{opacity:0;transform:translateY(12px)}}@keyframes nc-busy-dot{50%{opacity:.2}}@keyframes nc-slide-in{0%{opacity:0;transform:translate(16px)}}@media (prefers-reduced-motion:no-preference){.nc-title-target:is(:hover,:focus-visible,:has(:focus-visible)) .nc-title[data-overflow=true] .nc-title-text{animation:nc-title-scroll var(--nc-title-duration) linear var(--nc-title-delay) forwards}@media (hover:none){.nc-title-target:is([aria-selected=true],[data-active=true]) .nc-title[data-overflow=true] .nc-title-text{animation:nc-title-scroll var(--nc-title-duration) linear var(--nc-title-delay) forwards}}.nc-skeleton{background-image:linear-gradient(90deg, var(--color-ink-800) 40%, var(--color-ink-700) 50%, var(--color-ink-800) 60%);background-size:300% 100%;animation:1.6s linear infinite nc-shimmer}.nc-fade-in{animation:nc-fade-in var(--nc-motion-base) var(--nc-motion-ease)}.nc-pop-in{animation:nc-pop-in var(--nc-motion-fast) var(--nc-motion-ease)}.nc-rise-in{animation:nc-rise-in var(--nc-motion-base) var(--nc-motion-ease)}.nc-cell-in{animation:nc-cell-in .26s var(--nc-motion-ease)}.nc-busy-dot{animation:1s ease-in-out infinite nc-busy-dot}.nc-slide-in{animation:nc-slide-in var(--nc-motion-base) var(--nc-motion-ease)}[role=tab],.nc-title-target,.nc-content li>button{transition:background-color var(--nc-motion-fast) ease-out, color var(--nc-motion-fast) ease-out, box-shadow var(--nc-motion-fast) ease-out}}@font-face{font-family:JetBrains Mono;font-style:normal;font-display:block;font-weight:100 800;src:url(./jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2)format("woff2-variations");unicode-range:U+??,U+131,U+152-153,U+2BB-2BC,U+2C6,U+2DA,U+2DC,U+304,U+308,U+329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}@font-face{font-family:JetBrains Mono;font-style:normal;font-display:block;font-weight:100 800;src:url(./jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2)format("woff2-variations");unicode-range:U+100-2BA,U+2BD-2C5,U+2C7-2CC,U+2CE-2D7,U+2DD-2FF,U+304,U+308,U+329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}html,body,#root{height:var(--nc-visual-viewport-height,100%)}html{font-size:14px}.nc-content{zoom:var(--nc-content-zoom,1)}@media (pointer:coarse){input:not([type=checkbox]):not([type=radio]),select,textarea:not(.xterm-helper-textarea){font-size:max(16px,1em)}}.overflow-auto,.overflow-y-auto,.xterm-viewport{overscroll-behavior-y:contain}body{background:var(--color-ink-950);color:var(--color-ink-50);font-family:var(--font-mono);margin:0;font-size:.85rem;line-height:1.4}button:not(:disabled),[role=button]:not(:disabled){cursor:pointer}:focus-visible{outline:1px solid var(--color-accent);outline-offset:-1px}:root{--nc-header-h:42px}*{scrollbar-width:thin;scrollbar-color:var(--color-ink-600) transparent}.nc-markdown{max-width:52rem;font-family:var(--font-sans);color:var(--color-ink-50);line-height:1.6}.nc-markdown h1,.nc-markdown h2,.nc-markdown h3,.nc-markdown h4,.nc-markdown h5,.nc-markdown h6{margin:1.4em 0 .6em;font-weight:600;line-height:1.25}.nc-markdown h1{border-bottom:1px solid var(--color-ink-700);padding-bottom:.3em;font-size:1.6em}.nc-markdown h2{border-bottom:1px solid var(--color-ink-800);padding-bottom:.25em;font-size:1.35em}.nc-markdown h3{font-size:1.15em}.nc-markdown h4{font-size:1em}.nc-markdown h5,.nc-markdown h6{color:var(--color-ink-200);font-size:.9em}.nc-markdown :first-child{margin-top:0}.nc-markdown p,.nc-markdown ul,.nc-markdown ol,.nc-markdown blockquote,.nc-markdown table,.nc-markdown pre{margin:.75em 0}.nc-markdown ul,.nc-markdown ol{padding-left:1.5em}.nc-markdown ul{list-style:outside}.nc-markdown ol{list-style:decimal}.nc-markdown li{margin:.25em 0}.nc-markdown li::marker{color:var(--color-ink-400)}.nc-markdown li:has(>input[type=checkbox]){margin-left:-1.2em;list-style:none}.nc-markdown a{color:var(--color-accent);text-underline-offset:2px;text-decoration:underline}.nc-markdown strong{font-weight:600}.nc-markdown em{font-style:italic}.nc-markdown blockquote{border-left:3px solid var(--color-ink-700);color:var(--color-ink-200);padding-left:1em}.nc-markdown hr{border:0;border-top:1px solid var(--color-ink-700);margin:1.5em 0}.nc-markdown img{max-width:100%}.nc-markdown :not(pre)>code{font-family:var(--font-mono);background:var(--color-ink-800);border-radius:3px;padding:.1em .35em;font-size:.9em}.nc-markdown pre{background:var(--color-ink-850);border:1px solid var(--color-ink-800);border-radius:4px;padding:.9em 1em;overflow-x:auto}.nc-markdown pre code{font-family:var(--font-mono);background:0 0;padding:0;font-size:.85em}.nc-markdown table{border-collapse:collapse;display:block;overflow-x:auto}.nc-markdown th,.nc-markdown td{border:1px solid var(--color-ink-700);text-align:left;padding:.4em .7em}.nc-markdown th{background:var(--color-ink-850);font-weight:600}.nc-pane-body>.xterm{flex:none}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-pan-x{syntax:"*";inherits:false}@property --tw-pan-y{syntax:"*";inherits:false}@property --tw-pinch-zoom{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-tracking{syntax:"*";inherits:false}@property --tw-ordinal{syntax:"*";inherits:false}@property --tw-slashed-zero{syntax:"*";inherits:false}@property --tw-numeric-figure{syntax:"*";inherits:false}@property --tw-numeric-spacing{syntax:"*";inherits:false}@property --tw-numeric-fraction{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-outline-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@keyframes spin{to{transform:rotate(360deg)}}@keyframes pulse{50%{opacity:.5}} diff --git a/viewer-ui/dist/assets/index-fDiSI_v6.js b/viewer-ui/dist/assets/index-fDiSI_v6.js new file mode 100644 index 00000000..217fa1ec --- /dev/null +++ b/viewer-ui/dist/assets/index-fDiSI_v6.js @@ -0,0 +1,11 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Markdown-DEJAds14.js","./jsx-runtime-EIAPxkjE.js","./react-BPk_wmJm.js","./Markdown-C8LL_u4z.css","./Html-DGFy4jGa.js","./HtmlEditor-DzgQSTDx.js","./BusyLabel-BNTNuT1X.js","./api-BwgkHPos.js","./Terminal-C0v33aMU.js","./lastPane-FlqACl6i.js"])))=>i.map(i=>d[i]); +import{n as e,t}from"./jsx-runtime-EIAPxkjE.js";import{t as n}from"./react-BPk_wmJm.js";import{$ as r,A as i,C as a,D as o,F as s,G as c,H as l,I as u,J as d,K as f,L as p,M as m,N as h,O as g,Q as _,R as v,U as y,V as b,W as x,X as S,Y as C,Z as w,_t as T,at as E,b as ee,c as te,dt as ne,et as re,ft as ie,g as ae,gt as oe,ht as se,i as ce,it as le,j as ue,k as de,lt as fe,mt as pe,nt as me,pt as he,q as ge,r as _e,rt as ve,s as ye,st as be,tt as xe,ut as D,v as O,vt as Se,w as Ce,x as we,y as Te,yt as Ee,z as De}from"./lastPane-FlqACl6i.js";import{t as k}from"./BusyLabel-BNTNuT1X.js";import{a as Oe,i as ke,n as Ae,o as je,r as Me,s as Ne,t as A}from"./api-BwgkHPos.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Pe=e((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,te());else{var t=n(l);t!==null&&ie(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-Tt&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&ie(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?te():S=!1}}}var te;if(typeof y==`function`)te=function(){y(ee)};else if(typeof MessageChannel<`u`){var ne=new MessageChannel,re=ne.port2;ne.port1.onmessage=ee,te=function(){re.postMessage(null)}}else te=function(){_(ee,0)};function ie(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,ie(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,te()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Fe=e(((e,t)=>{t.exports=Pe()})),Ie=e((e=>{var t=Fe(),r=n(),i=Ee();function a(e){var t=`https://react.dev/errors/`+e;if(1we||(e.current=Ce[we],Ce[we]=null,we--)}function k(e,t){we++,Ce[we]=e.current,e.current=t}var Oe=Te(null),ke=Te(null),Ae=Te(null),je=Te(null);function Me(e,t){switch(k(Ae,t),k(ke,e),k(Oe,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?up(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=up(t),e=dp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}De(Oe),k(Oe,e)}function Ne(){De(Oe),De(ke),De(Ae)}function A(e){var t=e.memoizedState;t!==null&&(sh._currentValue=t.memoizedState,k(je,e)),t=Oe.current;var n=dp(t,e.type);t!==n&&(k(ke,e),k(Oe,n))}function Pe(e){ke.current===e&&(De(Oe),De(ke)),je.current===e&&(De(je),sh._currentValue=Se)}var Ie,Le;function j(e){if(Ie===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ie=t&&t[1]||``,Le=-1)`:-1i||c[r]!==l[i]){var u=` +`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{M=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?j(n):``}function ze(e,t){switch(e.tag){case 26:case 27:case 5:return j(e.type);case 16:return j(`Lazy`);case 13:return e.child!==t&&t!==null?j(`Suspense Fallback`):j(`Suspense`);case 19:return j(`SuspenseList`);case 0:case 15:return Re(e.type,!1);case 11:return Re(e.type.render,!1);case 1:return Re(e.type,!0);case 31:return j(`Activity`);case 30:return j(`ViewTransition`);default:return``}}function Be(e){try{var t=``,n=null;do t+=ze(e,n),n=e,e=e.return;while(e);return t}catch(e){return` +Error generating stack: `+e.message+` +`+e.stack}}var Ve=Object.prototype.hasOwnProperty,He=t.unstable_scheduleCallback,Ue=t.unstable_cancelCallback,We=t.unstable_shouldYield,Ge=t.unstable_requestPaint,Ke=t.unstable_now,qe=t.unstable_getCurrentPriorityLevel,Je=t.unstable_ImmediatePriority,Ye=t.unstable_UserBlockingPriority,Xe=t.unstable_NormalPriority,Ze=t.unstable_LowPriority,Qe=t.unstable_IdlePriority,$e=t.log,et=t.unstable_setDisableYieldValue,tt=null,nt=null;function rt(e){if(typeof $e==`function`&&et(e),nt&&typeof nt.setStrictMode==`function`)try{nt.setStrictMode(tt,e)}catch{}}var it=Math.clz32?Math.clz32:st,at=Math.log,ot=Math.LN2;function st(e){return e>>>=0,e===0?32:31-(at(e)/ot|0)|0}var ct=256,lt=262144,ut=4194304;function dt(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function ft(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=dt(n))):i=dt(o):i=dt(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=dt(n))):i=dt(o)):i=dt(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function pt(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function mt(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0n;n++)t.push(e);return t}function vt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function yt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0=_r),br=` `,xr=!1;function Sr(e,t){switch(e){case`keyup`:return hr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Cr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var wr=!1;function Tr(e,t){switch(e){case`compositionend`:return Cr(t);case`keypress`:return t.which===32?(xr=!0,br):null;case`textInput`:return e=t.data,e===br&&xr?null:e;default:return null}}function Er(e,t){if(wr)return e===`compositionend`||!gr&&Sr(e,t)?(e=zn(),Rn=Ln=In=null,wr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Yr(n)}}function Zr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Zr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Qr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Jr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Jr(e.document)}return t}function $r(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var ei=Nn&&`documentMode`in document&&11>=document.documentMode,ti=null,ni=null,ri=null,ii=!1;function ai(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;ii||ti==null||ti!==Jr(r)||(r=ti,`selectionStart`in r&&$r(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),ri&&qr(ri,r)||(ri=r,r=Jf(ni,`onSelect`),0>=o,i-=o,ta=1<<32-it(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),I&&ra(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),I&&ra(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return I&&ra(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),I&&ra(i,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===ne&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case ee:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===ne){if(r.tag===7){n(e,r.sibling),c=i(r,o.props.children),fo(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===de&&io(l)===r.type){n(e,r.sibling),c=i(r,o.props),fo(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===ne?(c=Hi(o.props.children,e.mode,c,o.key),fo(c,o),c.return=e,e=c):(c=Vi(o.type,o.key,o.props,null,e.mode,c),fo(c,o),c.return=e,e=c)}return s(e);case te:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=i(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Gi(o,e.mode,c),c.return=e,e=c}return s(e);case de:return o=io(o),_(e,r,o,c)}if(xe(o))return h(e,r,o,c);if(ve(o)){if(l=ve(o),typeof l!=`function`)throw Error(a(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,uo(o),c);if(o.$$typeof===oe)return _(e,r,Aa(e,o),c);po(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,o),c.return=e,e=c):(n(e,r),c=Ui(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{lo=0;var i=_(e,t,n,r);return co=null,i}catch(t){if(t===Qa||t===eo)throw t;var a=Li(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var ho=mo(!0),go=mo(!1),_o=!1;function vo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function yo(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function bo(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function xo(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,W&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Pi(e),Ni(e,null,n),t}return Ai(e,r,t,n),Pi(e)}function So(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,xt(e,n)}}function Co(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var wo=!1;function To(){if(wo){var e=Ua;if(e!==null)throw e}}function Eo(e,t,n,r){wo=!1;var i=e.updateQueue;_o=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(q&f)===f:(r&f)===f){f!==0&&f===Ha&&(wo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=T({},d,f);break a;case 2:_o=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),sd|=o,e.lanes=o,e.memoizedState=d}}function Do(e,t){if(typeof e!=`function`)throw Error(a(191,e));e.call(t)}function Oo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=D.T,s={};s.types=o===null?null:o.types,D.T=s,pc(e,!1,t,n);try{var c=i(),l=D.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?fc(e,t,Ka(c,r),jd(e)):fc(e,t,r,jd(e))}catch(n){fc(e,t,{then:function(){},status:`rejected`,reason:n},jd())}finally{O.p=a,o!==null&&s.types!==null&&(o.types=s.types),D.T=o}}function nc(){}function rc(e,t,n,r){if(e.tag!==5)throw Error(a(476));var i=ic(e).queue;tc(e,i,t,Se,n===null?nc:function(){return ac(e),n(r)})}function ic(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:Se,baseState:Se,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ms,lastRenderedState:Se},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ms,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ac(e){var t=ic(e);t.next===null&&(t=e.alternate.memoizedState),fc(e,t.next.queue,{},jd())}function oc(){return ka(sh)}function sc(){return ls().memoizedState}function cc(){return ls().memoizedState}function lc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=jd();e=bo(n);var r=xo(t,e,n);r!==null&&(Pd(r,t,n),So(r,t,n)),t={cache:Fa()},e.payload=t;return}t=t.return}}function uc(e,t,n){var r=jd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},mc(e)?hc(t,n):(n=ji(e,t,n,r),n!==null&&(Pd(n,e,r),gc(n,t,r)))}function dc(e,t,n){fc(e,t,n,jd())}function fc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(mc(e))hc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Kr(s,o))return Ai(e,t,i,0),G===null&&ki(),!1}catch{}if(n=ji(e,t,i,r),n!==null)return Pd(n,e,r),gc(n,t,r),!0}return!1}function pc(e,t,n,r){if(r={lane:2,revertLane:Pf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},mc(e)){if(t)throw Error(a(479))}else t=ji(e,n,r,2),t!==null&&Pd(t,e,2)}function mc(e){var t=e.alternate;return e===R||t!==null&&t===R}function hc(e,t){Jo=qo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function gc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,xt(e,n)}}var _c={readContext:ka,use:fs,useCallback:B,useContext:B,useEffect:B,useImperativeHandle:B,useLayoutEffect:B,useInsertionEffect:B,useMemo:B,useReducer:B,useRef:B,useState:B,useDebugValue:B,useDeferredValue:B,useTransition:B,useSyncExternalStore:B,useId:B,useHostTransitionStatus:B,useFormState:B,useActionState:B,useOptimistic:B,useMemoCache:B,useCacheRefresh:B,useEffectEvent:B},vc={readContext:ka,use:fs,useCallback:function(e,t){return cs().memoizedState=[e,t===void 0?null:t],e},useContext:ka,useEffect:Hs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Bs(4194308,4,Js.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Bs(4194308,4,e,t)},useInsertionEffect:function(e,t){Bs(4,2,e,t)},useMemo:function(e,t){var n=cs();t=t===void 0?null:t;var r=e();if(Yo){rt(!0);try{e()}finally{rt(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=cs();if(n!==void 0){var i=n(t);if(Yo){rt(!0);try{n(t)}finally{rt(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=uc.bind(null,R,e),[r.memoizedState,e]},useRef:function(e){var t=cs();return e={current:e},t.memoizedState=e},useState:function(e){e=ws(e);var t=e.queue,n=dc.bind(null,R,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Xs,useDeferredValue:function(e,t){return $s(cs(),e,t)},useTransition:function(){var e=ws(!1);return e=tc.bind(null,R,e.queue,!0,!1),cs().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=R,i=cs();if(I){if(n===void 0)throw Error(a(407));n=n()}else{if(n=t(),G===null)throw Error(a(349));q&127||ys(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,Hs(xs.bind(null,r,o,e),[e]),r.flags|=2048,Rs(9,{destroy:void 0},bs.bind(null,r,o,n,t),null),n},useId:function(){var e=cs(),t=G.identifierPrefix;if(I){var n=na,r=ta;n=(r&~(1<<32-it(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Xo++,0<\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(i,{is:r.is}):s.createElement(i)}}o[Ot]=t,o[kt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(np(o,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&gl(t)}}return V(t),t.subtreeFlags&=-33554433,_l(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&gl(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(a(166));if(e=Ae.current,ha(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=ca,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[Ot]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||ep(e.nodeValue,n)),e||fa(t,!0)}else e=lp(e).createTextNode(r),e[Ot]=t,t.stateNode=e}return V(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ha(t),n!==null){if(e===null){if(!r)throw Error(a(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(a(557));e[Ot]=t}else ga(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;V(t),e=!1}else n=_a(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Bo(t),t):(Bo(t),null);if(t.flags&128)throw Error(a(558))}return V(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=ha(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(a(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(a(317));i[Ot]=t}else ga(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;V(t),i=!1}else i=_a(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(Bo(t),t):(Bo(t),null)}return Bo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),yl(t,t.updateQueue),V(t),null);case 4:return Ne(),e===null&&Wf(t.stateNode.containerInfo),t.flags|=67108864,V(t),null;case 10:return Ca(t.type),V(t),null;case 19:if(Uo(t),r=t.memoizedState,r===null)return V(t),null;if(i=!!(t.flags&128),o=r.rendering,o===null){if(i)bl(r,!1);else{if(Y!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Wo(e),o!==null){for(t.flags|=128,bl(r,!1),e=o.updateQueue,t.updateQueue=e,yl(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Bi(n,e),n=n.sibling;return Ho(t,Vo.current&1|2),I&&ra(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Ke()>_d&&(t.flags|=128,i=!0,bl(r,!1),t.lanes=4194304)}}else{if(!i){if(e=Wo(o),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,yl(t,e),bl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!I)return V(t),null}else 2*Ke()-r.renderingStartTime>_d&&n!==536870912&&(t.flags|=128,i=!0,bl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Ke(),e.sibling=null,o=Vo.current,o=i?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||I?Ho(t,o):(n=o,k(Po,t),k(Vo,n),Fo===null&&(Fo=t)),I&&ra(t,r.treeForkCount),e}return V(t),null;case 22:case 23:return Bo(t),No(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(V(t),t.subtreeFlags&6&&(t.flags|=8192)):V(t),n=t.updateQueue,n!==null&&yl(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&De(Ja),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ca(L),V(t),null;case 25:return null;case 30:return t.flags|=33554432,V(t),null}throw Error(a(156,t.tag))}function Sl(e,t){switch(oa(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ca(L),Ne(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Pe(t),null;case 31:if(t.memoizedState!==null){if(Bo(t),t.alternate===null)throw Error(a(340));ga()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Bo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(a(340));ga()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Uo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return Ne(),null;case 10:return Ca(t.type),null;case 22:case 23:return Bo(t),No(),e!==null&&De(Ja),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ca(L),null;case 25:return null;default:return null}}function Cl(e,t){switch(oa(t),t.tag){case 3:Ca(L),Ne();break;case 26:case 27:case 5:Pe(t);break;case 4:Ne();break;case 31:t.memoizedState!==null&&Bo(t);break;case 13:Bo(t);break;case 19:Uo(t);break;case 10:Ca(t.type);break;case 22:case 23:Bo(t),No(),e!==null&&De(Ja);break;case 24:Ca(L)}}function wl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Z(t,t.return,e)}}function Tl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Z(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Z(t,t.return,e)}}function El(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Oo(t,n)}catch(t){Z(e,e.return,t)}}}function Dl(e,t,n){n.props=Tc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Z(e,t,n)}}function Ol(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=Si(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Pp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Fp(e);p(e.child,!1,Qp,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Z(e,t,n)}}function kl(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Z(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Z(e,t,n)}else n.current=null}}function Al(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n title`))),np(r,t,n),r[Ot]=e,Ht(r),t=r;break a;case`link`:if(o=Gm(`link`,`href`,i).get(t+(n.href||``))){for(s=0;sg&&(o=g,g=h,h=o);var _=Xr(s,h),v=Xr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,D.T=null,n=wd,wd=null;var o=bd,s=Sd;if(X=0,xd=bd=null,Sd=0,W&6)throw Error(a(331));var c=W;if(W|=4,Zu(o.current),Uu(o,o.current,s,n),W=c,Df(0,!1),nt&&typeof nt.onPostCommitFiberRoot==`function`)try{nt.onPostCommitFiberRoot(tt,o)}catch{}return!0}finally{O.p=i,D.T=r,uf(e,t)}}function pf(e,t,n){t=qi(n,t),t=jc(e.stateNode,t,2),e=xo(e,t,2),e!==null&&(vt(e,2),Ef(e))}function Z(e,t,n){if(e.tag===3)pf(e,e,n);else for(;t!==null;){if(t.tag===3){pf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(yd===null||!yd.has(r))){e=qi(n,e),n=Mc(2),r=xo(t,n,2),r!==null&&(Nc(n,r,t,e),vt(r,2),Ef(r));break}}t=t.return}}function mf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new td;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(ad=!0,i.add(n),e=hf.bind(null,e,t,n),t.then(e,e))}function hf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,G===e&&(q&n)===n&&(Y===4||Y===3&&(q&62914560)===q&&300>Ke()-hd?W&2?ld|=n:Vd(e,0):ld|=n,dd===q&&(dd=0)),Ef(e)}function gf(e,t){t===0&&(t=gt()),e=Mi(e,t),e!==null&&(vt(e,t),Ef(e))}function _f(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),gf(e,n)}function vf(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(a(314))}r!==null&&r.delete(t),gf(e,n)}function yf(e,t){return He(e,t)}var bf=null,xf=null,Sf=!1,Cf=!1,wf=!1,Tf=0;function Ef(e){e!==xf&&e.next===null&&(xf===null?bf=xf=e:xf=xf.next=e),Cf=!0,Sf||(Sf=!0,Nf())}function Df(e,t){if(!wf&&Cf){wf=!0;do for(var n=!1,r=bf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-it(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Mf(r,a))}else a=q,a=ft(r,r===G?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||pt(r,a)||(n=!0,Mf(r,a))}r=r.next}while(n);wf=!1}}function Of(){kf()}function kf(){Cf=Sf=!1;var e=0;Tf!==0&&hp()&&(e=Tf);for(var t=Ke(),n=null,r=bf;r!==null;){var i=r.next,a=Af(r,t);a===0?(r.next=null,n===null?bf=i:n.next=i,i===null&&(xf=n)):(n=r,(e!==0||a&3)&&(Cf=!0)),r=i}X!==0&&X!==5||Df(e,!1),Tf!==0&&(Tf=0)}function Af(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&ap(d)&&(c=c.responseEnd,o+=u*(c$m){s.length=o;break}f=new Promise(jp.bind(f)),s.push(f)}}}if(0`u`?null:document;function Tm(e,t,n){var r=wm;if(r&&typeof t==`string`&&t){var i=ln(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),ym.has(i)||(ym.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),np(t,`link`,e),Ht(t),r.head.appendChild(t)))}}function Em(e){xm.D(e),Tm(`dns-prefetch`,e,null)}function Dm(e,t){xm.C(e,t),Tm(`preconnect`,e,t)}function Om(e,t,n){xm.L(e,t,n);var r=wm;if(r&&e&&t){var i=`link[rel="preload"][as="`+ln(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+ln(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+ln(n.imageSizes)+`"]`)):i+=`[href="`+ln(e)+`"]`;var a=i;switch(t){case`style`:a=Pm(e);break;case`script`:a=Rm(e)}if(!(vm.has(a)||(e=T({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vm.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Fm(a))||t===`script`&&r.querySelector(zm(a))))){var o=r.createElement(`link`);np(o,`link`,e),t===`style`&&(o[It]=!0,o.onload=o.onerror=function(){Ut(o)}),Ht(o),r.head.appendChild(o)}}}function km(e,t){xm.m(e,t);var n=wm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+ln(r)+`"][href="`+ln(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rm(e)}if(!vm.has(a)&&(e=T({rel:`modulepreload`,href:e},t),vm.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zm(a)))return}r=n.createElement(`link`),np(r,`link`,e),Ht(r),n.head.appendChild(r)}}}function Am(e,t,n){xm.S(e,t,n);var r=wm;if(r&&e){var i=Vt(r).hoistableStyles,a=Pm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Fm(a)))s.loading=5;else{e=T({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vm.get(a))&&Hm(e,n);var c=o=r.createElement(`link`);Ht(c),np(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jm(e,t){xm.X(e,t);var n=wm;if(n&&e){var r=Vt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=T({src:e,async:!0},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Ht(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mm(e,t){xm.M(e,t);var n=wm;if(n&&e){var r=Vt(n).hoistableScripts,i=Rm(e),a=r.get(i);a||(a=n.querySelector(zm(i)),a||(e=T({src:e,async:!0,type:`module`},t),(t=vm.get(i))&&Um(e,t),a=n.createElement(`script`),Ht(a),np(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nm(e,t,n,r){var i=(i=Ae.current)?bm(i):null;if(!i)throw Error(a(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Pm(n.href),t=Vt(i).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pm(n.href);var o=Vt(i).hoistableStyles,s=o.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=i.querySelector(Fm(e)))?o._p||(s.instance=o,s.state.loading=5):(o=vm.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vm.set(e,o)),Lm(i,e,o,s.state))),t&&r===null)throw Error(a(528,``));return s}if(t&&r!==null)throw Error(a(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Rm(n),t=Vt(i).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(a(444,e))}}function Pm(e){return`href="`+ln(e)+`"`}function Fm(e){return`link[rel="stylesheet"][`+e+`]`}function Im(e){return T({},e,{"data-precedence":e.precedence,precedence:null})}function Lm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[It]){r.loading=1;return}}else t=e.createElement(`link`),t[It]=!0,t.onload=t.onerror=Ut.bind(null,t),np(t,`link`,n),Ht(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Rm(e){return`[src="`+ln(e)+`"]`}function zm(e){return`script[async]`+e}function Bm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+ln(n.href)+`"]`);if(r)return t.instance=r,Ht(r),r;var i=T({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Ht(r),np(r,`style`,i),Vm(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Pm(n.href);var o=e.querySelector(Fm(i));if(o)return t.state.loading|=4,t.instance=o,Ht(o),o;r=Im(n),(i=vm.get(i))&&Hm(r,i),o=(e.ownerDocument||e).createElement(`link`),Ht(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),np(o,`link`,r),t.state.loading|=4,Vm(o,n.precedence,e),t.instance=o;case`script`:return o=Rm(n.src),(i=e.querySelector(zm(o)))?(t.instance=i,Ht(i),i):(r=n,(i=vm.get(o))&&(r=T({},n),Um(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),Ht(i),np(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(a(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vm(r,n.precedence,e));return t.instance}function Vm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function qm(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jm(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function Ym(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Xm(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function Zm(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=Xm(t),e.suspenseyImages.push(t)),e=rh.bind(e),t.decode().then(e,e))}function Qm(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pm(r.href),a=t.querySelector(Fm(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=nh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Ht(a);return}a=t.ownerDocument||t,r=Im(r),(i=vm.get(i))&&Hm(r,i),a=a.createElement(`link`),Ht(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),np(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=nh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var $m=0;function eh(e,t){return e.stylesheets&&e.count===0&&ah(e,e.stylesheets),0$m?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function th(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)ah(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function nh(){this.count--,th(this)}function rh(){this.imgCount--,th(this)}var ih=null;function ah(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ih=new Map,t.forEach(oh,e),ih=null,nh.call(e))}function oh(e,t){if(!(t.state.loading&4)){var n=ih.get(e);if(n)var r=n.get(null);else{n=new Map,ih.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=Ie()}))(),j=n(),M=t();function Re({onClose:e,onOpened:t,canClone:n,cloning:r,onClone:i}){let[a,o]=(0,j.useState)(null),[s,c]=(0,j.useState)(null),[l,u]=(0,j.useState)(null),[d,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)(``),[h,g]=(0,j.useState)(!1),[_,v]=(0,j.useState)(``),[y,b]=(0,j.useState)(0);(0,j.useEffect)(()=>{let e=!1;return A.browse(a??void 0).then(t=>{e||(c(t),u(null))}).catch(t=>{e||u(t instanceof Error?t.message:`could not browse`)}),()=>{e=!0}},[a,y]);let x=e=>o(`${s.path.replace(/\/$/,``)}/${e}`),S=async()=>{if(s){f(!0);try{t(await A.open(s.path))}catch(e){T.error(e instanceof Error?e.message:`could not open`),f(!1)}}},C=async()=>{if(!s)return;let e=p.trim();if(e){g(!0);try{await A.mkdir(s.path,e),m(``),b(e=>e+1)}catch(e){T.error(e instanceof Error?e.message:`could not create folder`)}finally{g(!1)}}};return(0,M.jsx)(`div`,{className:`nc-fade-in fixed inset-0 z-50 flex items-start justify-center bg-black/60 p-4 md:pt-[8vh]`,onClick:e,children:(0,M.jsxs)(`div`,{className:`nc-rise-in flex max-h-[min(80vh,calc(var(--nc-visual-viewport-height,100vh)-8vh-1rem))] w-[34rem] max-w-full flex-col rounded-lg border border-ink-700 bg-ink-900`,onClick:e=>e.stopPropagation(),children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-ink-700 px-3 py-2`,children:[(0,M.jsx)(`span`,{className:`font-medium text-ink-50`,children:`Open a project`}),(0,M.jsx)(`button`,{onClick:e,"aria-label":`close`,className:`ml-auto flex h-6 w-6 items-center justify-center rounded-sm text-ink-400 hover:text-ink-200`,children:(0,M.jsx)(pe,{})})]}),(0,M.jsx)(`div`,{className:`shrink-0 truncate border-b border-ink-700 px-3 py-1.5 text-ink-400`,children:s?.path??`…`}),(0,M.jsxs)(`ul`,{className:`h-72 min-h-0 overflow-y-auto`,children:[s?.parent&&(0,M.jsx)(`li`,{children:(0,M.jsx)(`button`,{onClick:()=>o(s.parent),className:`w-full px-3 py-1 text-left text-ink-400 hover:bg-ink-850`,children:`../`})}),s?.entries.map(e=>(0,M.jsx)(`li`,{children:(0,M.jsxs)(`button`,{onClick:()=>x(e.name),className:`flex w-full items-center gap-2 px-3 py-1 text-left hover:bg-ink-850`,children:[(0,M.jsxs)(`span`,{className:`truncate text-accent`,children:[e.name,`/`]}),e.is_repo&&(0,M.jsx)(`span`,{className:`rounded-sm bg-ink-700 px-1 text-2xs text-ink-200`,children:`git`})]})},e.name)),s&&s.entries.length===0&&(0,M.jsx)(`li`,{className:`px-3 py-1 text-ink-400`,children:`No sub-folders.`})]}),l&&(0,M.jsx)(`p`,{className:`shrink-0 px-3 py-1 text-removed`,children:l}),(0,M.jsxs)(`div`,{className:`flex shrink-0 items-stretch gap-2 border-t border-ink-700 px-3 py-2`,children:[(0,M.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&C()},placeholder:`New folder name`,"aria-label":`new folder name`,className:`min-w-0 flex-1 rounded-sm border border-ink-700 bg-ink-950 px-2 py-1 text-ink-50 placeholder:text-ink-400 focus:border-ink-600 focus:outline-none`}),(0,M.jsx)(`button`,{onClick:C,disabled:!s||!p.trim()||h,"aria-busy":h,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850 disabled:opacity-50`,children:(0,M.jsx)(k,{busy:h,children:`Create`})})]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 items-stretch gap-2 border-t border-ink-700 px-3 py-2`,children:[(0,M.jsx)(`input`,{value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s&&i(s.path,_)},disabled:!n,placeholder:n?`Clone a git URL here`:`git is not installed on the server`,"aria-label":`git URL to clone`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,className:`min-w-0 flex-1 rounded-sm border border-ink-700 bg-ink-950 px-2 py-1 text-ink-50 placeholder:text-ink-400 focus:border-ink-600 focus:outline-none disabled:opacity-50`}),(0,M.jsx)(`button`,{onClick:()=>s&&i(s.path,_),disabled:!n||!s||!_.trim()||r,"aria-busy":r,title:n?void 0:`the server has no git on its PATH`,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850 disabled:opacity-50`,children:(0,M.jsx)(k,{busy:r,children:`Clone`})})]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-t border-ink-700 px-3 py-2`,children:[(0,M.jsx)(`span`,{className:`truncate text-ink-400`,children:s?s.path:``}),(0,M.jsx)(`button`,{onClick:S,disabled:!s||d,"aria-busy":d,className:`ml-auto shrink-0 rounded-sm bg-ink-50 px-3 py-1 font-semibold text-ink-950 hover:bg-white disabled:opacity-50`,children:(0,M.jsx)(k,{busy:d,children:`Open`})})]})]})})}var ze=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='utf-8'?%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='12%2057%201150%201150'%20role='img'%20aria-label='Black%20crow'%3e%3ctitle%3eBlack%20crow%3c/title%3e%3cdesc%3eMonochrome%20black%20crow%20silhouette%20on%20a%20transparent%20background,%20framed%20so%20the%20bird%20sits%20centred%20for%20use%20as%20an%20inline%20mark%20on%20a%20square%20tile.%3c/desc%3e%3cg%20fill-rule='evenodd'%20clip-rule='evenodd'%3e%3cpath%20fill='%23000000'%20d='M%20882%20147%20L%20859%20136%20L%20844%20131%20L%20831%20129%20L%20830%20128%20L%20815%20127%20L%20814%20126%20L%20796%20126%20L%20795%20127%20L%20786%20127%20L%20785%20128%20L%20775%20129%20L%20752%20136%20L%20732%20146%20L%20713%20160%20L%20701%20172%20L%20684%20172%20L%20683%20173%20L%20673%20173%20L%20672%20174%20L%20650%20176%20L%20649%20177%20L%20627%20181%20L%20602%20190%20L%20589%20197%20L%20579%20204%20L%20562%20221%20L%20562%20223%20L%20565%20223%20L%20578%20228%20L%20581%20228%20L%20612%20238%20L%20672%20252%20L%20684%20258%20L%20698%20271%20L%20702%20278%20L%20705%20288%20L%20705%20294%20L%20703%20301%20L%20699%20308%20L%20688%20318%20L%20630%20347%20L%20593%20372%20L%20561%20399%20L%20544%20416%20L%20522%20441%20L%20492%20481%20L%20461%20531%20L%20438%20576%20L%20431%20594%20L%20425%20602%20L%20405%20635%20L%20387%20668%20L%20385%20676%20L%20390%20679%20L%20368%20705%20L%20330%20755%20L%20306%20790%20L%20296%20808%20L%20289%20818%20L%20280%20838%20L%20280%20843%20L%20283%20845%20L%20292%20843%20L%20297%20840%20L%20299%20840%20L%20321%20828%20L%20322%20830%20L%20311%20844%20L%20288%20878%20L%20287%20881%20L%20259%20924%20L%20235%20965%20L%20205%201023%20L%20205%201025%20L%20197%201042%20L%20191%201061%20L%20191%201071%20L%20192%201072%20L%20198%201071%20L%20220%201056%20L%20242%201038%20L%20300%20986%20L%20302%20987%20L%20265%201040%20L%20264%201043%20L%20246%201070%20L%20235%201090%20L%20227%201112%20L%20227%201123%20L%20229%201128%20L%20234%201133%20L%20239%201135%20L%20255%201135%20L%20274%201129%20L%20279%201134%20L%20286%201137%20L%20290%201137%20L%20291%201138%20L%20310%201138%20L%20311%201137%20L%20317%201137%20L%20318%201136%20L%20326%201135%20L%20344%201129%20L%20369%201116%20L%20395%201097%20L%20420%201073%20L%20445%201042%20L%20457%201024%20L%20461%201016%20L%20464%201013%20L%20468%201011%20L%20489%20994%20L%20595%20901%20L%20601%20906%20L%20606%20913%20L%20614%20921%20L%20637%20949%20L%20639%20953%20L%20639%20956%20L%20636%20960%20L%20634%20961%20L%20619%20962%20L%20613%20965%20L%20605%20974%20L%20602%20982%20L%20602%20994%20L%20605%201001%20L%20608%201004%20L%20609%201004%20L%20609%20999%20L%20612%20992%20L%20616%20988%20L%20620%20986%20L%20627%20986%20L%20635%20983%20L%20645%20983%20L%20646%20982%20L%20655%20982%20L%20668%20986%20L%20676%20990%20L%20682%20996%20L%20685%201003%20L%20688%201006%20L%20696%201009%20L%20697%201012%20L%20697%201024%20L%20693%201033%20L%20693%201035%20L%20695%201035%20L%20700%201032%20L%20707%201025%20L%20710%201020%20L%20713%201010%20L%20713%201003%20L%20711%20998%20L%20711%20994%20L%20712%20993%20L%20719%201003%20L%20723%201005%20L%20727%201005%20L%20730%201011%20L%20730%201022%20L%20727%201031%20L%20728%201033%20L%20740%201021%20L%20743%201014%20L%20744%201003%20L%20747%20999%20L%20749%20992%20L%20748%20977%20L%20744%20968%20L%20740%20963%20L%20741%20962%20L%20755%20961%20L%20768%20964%20L%20777%20969%20L%20783%20975%20L%20786%20981%20L%20789%20984%20L%20795%20987%20L%20799%20987%20L%20801%20991%20L%20801%20997%20L%20802%20998%20L%20799%201013%20L%20802%201012%20L%20808%201007%20L%20813%201000%20L%20816%20991%20L%20816%20981%20L%20814%20976%20L%20814%20968%20L%20815%20967%20L%20819%20970%20L%20823%20970%20L%20826%20973%20L%20829%20980%20L%20830%20993%20L%20834%20990%20L%20838%20979%20L%20838%20968%20L%20832%20951%20L%20822%20940%20L%20815%20936%20L%20803%20933%20L%20776%20935%20L%20763%20931%20L%20753%20922%20L%20731%20898%20L%20703%20865%20L%20703%20863%20L%20710%20853%20L%20711%20855%20L%20707%20862%20L%20709%20862%20L%20718%20857%20L%20754%20832%20L%20793%20799%20L%20818%20774%20L%20849%20737%20L%20850%20741%20L%20845%20755%20L%20847%20755%20L%20861%20743%20L%20881%20721%20L%20906%20686%20L%20918%20665%20L%20933%20635%20L%20951%20590%20L%20971%20525%20L%20971%20521%20L%20974%20512%20L%20974%20508%20L%20978%20493%20L%20979%20482%20L%20980%20481%20L%20981%20466%20L%20982%20465%20L%20983%20441%20L%20982%20440%20L%20982%20428%20L%20981%20427%20L%20980%20414%20L%20978%20409%20L%20976%20397%20L%20970%20381%20L%20971%20379%20L%20974%20383%20L%20976%20381%20L%20977%20334%20L%20976%20333%20L%20976%20322%20L%20975%20321%20L%20974%20307%20L%20973%20306%20L%20973%20301%20L%20972%20300%20L%20969%20280%20L%20958%20243%20L%20949%20224%20L%20949%20222%20L%20939%20204%20L%20922%20181%20L%20903%20162%20Z%20M%20625%20888%20L%20656%20874%20L%20658%20874%20L%20665%20870%20L%20725%20930%20L%20728%20934%20L%20728%20940%20L%20723%20943%20L%20714%20944%20L%20707%20950%20L%20683%20951%20L%20673%20947%20L%20659%20932%20Z%20M%20787%20182%20L%20792%20182%20L%20796%20187%20L%20795%20192%20L%20791%20195%20L%20788%20195%20L%20783%20191%20L%20783%20186%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20895%20156%20L%20863%20138%20L%20838%20130%20L%20819%20127%20L%20789%20127%20L%20777%20129%20L%20753%20136%20L%20736%20144%20L%20717%20157%20L%20702%20172%20L%20652%20176%20L%20628%20181%20L%20607%20188%20L%20585%20200%20L%20562%20222%20L%20613%20238%20L%20670%20251%20L%20683%20257%20L%20697%20269%20L%20705%20286%20L%20705%20296%20L%20703%20302%20L%20698%20310%20L%20687%20319%20L%20631%20347%20L%20591%20374%20L%20568%20393%20L%20538%20423%20L%20520%20444%20L%20481%20498%20L%20457%20539%20L%20437%20579%20L%20432%20593%20L%20413%20622%20L%20386%20671%20L%20386%20677%20L%20390%20677%20L%20391%20679%20L%20374%20698%20L%20334%20750%20L%20307%20789%20L%20290%20817%20L%20280%20839%20L%20281%20844%20L%20291%20843%20L%20323%20826%20L%20325%20827%20L%20289%20877%20L%20237%20962%20L%20209%201015%20L%20198%201040%20L%20191%201063%20L%20191%201070%20L%20194%201072%20L%20213%201061%20L%20259%201023%20L%20302%20984%20L%20303%20985%20L%20262%201045%20L%20245%201072%20L%20233%201095%20L%20227%201114%20L%20228%201126%20L%20233%201132%20L%20242%201135%20L%20252%201135%20L%20274%201128%20L%20278%201133%20L%20288%201137%20L%20313%201137%20L%20343%201129%20L%20373%201113%20L%20398%201094%20L%20424%201068%20L%20441%201047%20L%20465%201012%20L%20520%20967%20L%20595%20900%20L%20611%20917%20L%20639%20952%20L%20639%20957%20L%20637%20960%20L%20632%20962%20L%20618%20963%20L%20611%20967%20L%20606%20973%20L%20602%20983%20L%20602%20992%20L%20608%201004%20L%20611%20993%20L%20619%20986%20L%20626%20986%20L%20643%20982%20L%20656%20982%20L%20675%20989%20L%20683%20997%20L%20688%201006%20L%20696%201009%20L%20697%201025%20L%20693%201034%20L%20694%201035%20L%20701%201031%20L%20710%201019%20L%20712%201013%20L%20712%20993%20L%20720%201003%20L%20727%201005%20L%20730%201009%20L%20730%201025%20L%20727%201032%20L%20732%201030%20L%20739%201022%20L%20743%201013%20L%20743%201004%20L%20749%20991%20L%20748%20978%20L%20740%20964%20L%20743%20961%20L%20757%20961%20L%20769%20964%20L%20781%20972%20L%20791%20985%20L%20798%20986%20L%20802%20994%20L%20802%201003%20L%20799%201013%20L%20810%201004%20L%20815%20994%20L%20816%20983%20L%20814%20977%20L%20814%20965%20L%20818%20969%20L%20825%20971%20L%20830%20983%20L%20830%20993%20L%20833%20991%20L%20837%20982%20L%20838%20969%20L%20834%20956%20L%20825%20943%20L%20820%20939%20L%20807%20934%20L%20774%20935%20L%20762%20931%20L%20736%20904%20L%20702%20864%20L%20715%20845%20L%20716%20847%20L%20707%20862%20L%20719%20856%20L%20744%20839%20L%20786%20805%20L%20824%20767%20L%20851%20733%20L%20852%20735%20L%20846%20755%20L%20853%20750%20L%20883%20718%20L%20906%20685%20L%20927%20647%20L%20951%20589%20L%20968%20535%20L%20976%20502%20L%20982%20461%20L%20981%20422%20L%20976%20398%20L%20968%20378%20L%20969%20376%20L%20975%20383%20L%20977%20341%20L%20970%20286%20L%20958%20244%20L%20945%20215%20L%20925%20185%20L%20906%20165%20Z%20M%20625%20888%20L%20665%20870%20L%20728%20933%20L%20729%20940%20L%20726%20943%20L%20715%20944%20L%20708%20950%20L%20692%20952%20L%20678%20950%20L%20672%20947%20L%20662%20936%20Z%20M%20785%20183%20L%20792%20182%20L%20796%20186%20L%20796%20191%20L%20791%20195%20L%20785%20194%20L%20783%20191%20L%20783%20186%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20896%20157%20L%20869%20141%20L%20837%20130%20L%20817%20127%20L%20792%20127%20L%20778%20129%20L%20751%20137%20L%20733%20146%20L%20715%20159%20L%20702%20172%20L%20653%20176%20L%20610%20187%20L%20581%20203%20L%20562%20222%20L%20625%20241%20L%20671%20251%20L%20683%20257%20L%20698%20270%20L%20705%20285%20L%20704%20300%20L%20699%20309%20L%20689%20318%20L%20628%20349%20L%20581%20382%20L%20540%20421%20L%20517%20448%20L%20478%20503%20L%20456%20541%20L%20439%20575%20L%20432%20593%20L%20412%20624%20L%20388%20667%20L%20386%20676%20L%20390%20677%20L%20391%20679%20L%20363%20712%20L%20332%20753%20L%20289%20819%20L%20281%20836%20L%20281%20844%20L%20293%20842%20L%20323%20826%20L%20325%20827%20L%20284%20885%20L%20236%20964%20L%20205%201024%20L%20197%201043%20L%20191%201064%20L%20191%201070%20L%20197%201071%20L%20210%201063%20L%20253%201028%20L%20303%20983%20L%20304%20984%20L%20259%201050%20L%20235%201091%20L%20227%201115%20L%20228%201125%20L%20232%201131%20L%20238%201134%20L%20249%201135%20L%20261%201133%20L%20274%201128%20L%20278%201133%20L%20289%201137%20L%20312%201137%20L%20342%201129%20L%20368%201116%20L%20399%201093%20L%20423%201069%20L%20443%201044%20L%20463%201013%20L%20493%20990%20L%20595%20900%20L%20612%20918%20L%20639%20952%20L%20639%20957%20L%20636%20961%20L%20616%20964%20L%20606%20973%20L%20602%20984%20L%20602%20991%20L%20608%201004%20L%20611%20993%20L%20621%20985%20L%20625%20986%20L%20639%20982%20L%20657%20982%20L%20677%20990%20L%20685%201002%20L%20690%201007%20L%20697%201010%20L%20698%201021%20L%20693%201034%20L%20694%201035%20L%20705%201027%20L%20710%201018%20L%20712%201011%20L%20712%201001%20L%20710%20994%20L%20712%20993%20L%20720%201003%20L%20729%201006%20L%20731%201020%20L%20728%201032%20L%20738%201023%20L%20743%201012%20L%20743%201003%20L%20748%20994%20L%20747%20976%20L%20740%20964%20L%20743%20961%20L%20759%20961%20L%20767%20963%20L%20780%20971%20L%20790%20984%20L%20799%20986%20L%20802%20992%20L%20802%201004%20L%20799%201012%20L%20803%201011%20L%20810%201004%20L%20815%20994%20L%20814%20965%20L%20818%20969%20L%20823%20969%20L%20830%20982%20L%20830%20992%20L%20832%20992%20L%20837%20982%20L%20837%20965%20L%20831%20950%20L%20821%20940%20L%20806%20934%20L%20772%20935%20L%20762%20931%20L%20733%20901%20L%20702%20863%20L%20717%20842%20L%20718%20844%20L%20707%20862%20L%20738%20843%20L%20780%20810%20L%20822%20769%20L%20851%20733%20L%20852%20735%20L%20846%20755%20L%20855%20748%20L%20882%20719%20L%20904%20688%20L%20930%20640%20L%20950%20591%20L%20967%20538%20L%20978%20490%20L%20982%20459%20L%20982%20434%20L%20976%20399%20L%20967%20376%20L%20969%20375%20L%20975%20383%20L%20976%20329%20L%20971%20293%20L%20960%20250%20L%20942%20210%20L%20923%20183%20Z%20M%20625%20888%20L%20665%20870%20L%20729%20934%20L%20729%20940%20L%20726%20943%20L%20716%20944%20L%20708%20950%20L%20695%20952%20L%20677%20950%20L%20666%20941%20Z%20M%20786%20182%20L%20790%20181%20L%20794%20183%20L%20797%20188%20L%20792%20195%20L%20787%20195%20L%20782%20190%20L%20782%20187%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20893%20155%20L%20873%20143%20L%20841%20131%20L%20816%20127%20L%20794%20127%20L%20779%20129%20L%20754%20136%20L%20735%20145%20L%20715%20159%20L%20702%20172%20L%20648%20177%20L%20629%20181%20L%20608%20188%20L%20584%20201%20L%20562%20222%20L%20614%20238%20L%20671%20251%20L%20685%20258%20L%20698%20270%20L%20704%20281%20L%20706%20292%20L%20703%20303%20L%20699%20309%20L%20686%20320%20L%20628%20349%20L%20590%20375%20L%20565%20396%20L%20543%20418%20L%20518%20447%20L%20490%20485%20L%20460%20534%20L%20441%20571%20L%20431%20595%20L%20405%20636%20L%20386%20672%20L%20386%20676%20L%20390%20677%20L%20391%20679%20L%20371%20702%20L%20335%20749%20L%20291%20816%20L%20280%20840%20L%20282%20844%20L%20298%20840%20L%20324%20825%20L%20326%20826%20L%20294%20870%20L%20235%20966%20L%20206%201022%20L%20198%201041%20L%20191%201065%20L%20191%201070%20L%20196%201071%20L%20214%201060%20L%20254%201027%20L%20303%20983%20L%20304%20984%20L%20256%201055%20L%20232%201098%20L%20227%201115%20L%20228%201125%20L%20232%201131%20L%20239%201134%20L%20248%201135%20L%20264%201132%20L%20274%201128%20L%20280%201134%20L%20289%201137%20L%20311%201137%20L%20339%201130%20L%20371%201114%20L%20401%201091%20L%20422%201070%20L%20440%201048%20L%20463%201013%20L%20487%20995%20L%20595%20900%20L%20613%20919%20L%20639%20951%20L%20639%20958%20L%20636%20961%20L%20619%20963%20L%20613%20966%20L%20605%20975%20L%20602%20991%20L%20604%20998%20L%20608%201003%20L%20611%20993%20L%20620%20985%20L%20624%20986%20L%20632%20983%20L%20647%20981%20L%20658%20982%20L%20677%20990%20L%20689%201006%20L%20697%201009%20L%20698%201021%20L%20694%201035%20L%20703%201029%20L%20710%201018%20L%20712%201010%20L%20712%201002%20L%20710%20997%20L%20711%20992%20L%20720%201003%20L%20728%201005%20L%20730%201008%20L%20731%201021%20L%20728%201032%20L%20738%201023%20L%20742%201014%20L%20743%201003%20L%20748%20994%20L%20748%20980%20L%20742%20966%20L%20739%20963%20L%20741%20961%20L%20753%20960%20L%20770%20964%20L%20780%20971%20L%20790%20984%20L%20799%20986%20L%20802%20992%20L%20802%201005%20L%20799%201012%20L%20804%201010%20L%20809%201005%20L%20815%20993%20L%20813%20964%20L%20817%20968%20L%20823%20969%20L%20826%20972%20L%20830%20982%20L%20831%20992%20L%20834%20989%20L%20838%20975%20L%20837%20966%20L%20831%20950%20L%20821%20940%20L%20804%20934%20L%20779%20936%20L%20763%20932%20L%20731%20899%20L%20702%20865%20L%20702%20863%20L%20717%20842%20L%20718%20844%20L%20708%20862%20L%20749%20835%20L%20781%20809%20L%20820%20771%20L%20851%20733%20L%20852%20736%20L%20846%20755%20L%20857%20746%20L%20881%20720%20L%20907%20683%20L%20928%20644%20L%20945%20604%20L%20967%20537%20L%20978%20489%20L%20982%20455%20L%20982%20437%20L%20979%20413%20L%20975%20396%20L%20967%20377%20L%20968%20374%20L%20975%20382%20L%20976%20332%20L%20972%20299%20L%20962%20257%20L%20954%20235%20L%20943%20212%20L%20923%20183%20Z%20M%20624%20888%20L%20666%20870%20L%20729%20934%20L%20729%20940%20L%20726%20943%20L%20716%20944%20L%20706%20951%20L%20684%20952%20L%20677%20950%20L%20665%20940%20Z%20M%20701%20220%20L%20710%20219%20L%20717%20221%20L%20704%20223%20L%20704%20221%20Z%20M%20666%20217%20L%20679%20216%20L%20689%20218%20L%20685%20220%20L%20675%20220%20Z%20M%20658%20210%20L%20661%20208%20L%20686%20205%20L%20706%20206%20L%20725%20209%20L%20733%20217%20L%20741%20220%20L%20738%20221%20L%20696%20214%20L%20661%20212%20Z%20M%20788%20181%20L%20793%20182%20L%20797%20188%20L%20792%20195%20L%20786%20195%20L%20782%20190%20L%20783%20185%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20893%20155%20L%20864%20139%20L%20836%20130%20L%20813%20127%20L%20796%20127%20L%20774%20130%20L%20749%20138%20L%20735%20145%20L%20720%20155%20L%20702%20172%20L%20687%20173%20L%20700%20174%20L%20694%20181%20L%20674%20184%20L%20670%20180%20L%20665%20183%20L%20657%20184%20L%20639%20196%20L%20641%20198%20L%20647%20198%20L%20648%20194%20L%20654%20193%20L%20686%20204%20L%20724%20208%20L%20740%20213%20L%20751%20222%20L%20750%20223%20L%20693%20214%20L%20671%20212%20L%20639%20212%20L%20636%20211%20L%20634%20207%20L%20629%20207%20L%20626%20210%20L%20617%20210%20L%20614%20208%20L%20604%20207%20L%20594%20213%20L%20582%20216%20L%20580%20214%20L%20581%20210%20L%20576%20208%20L%20586%20200%20L%20565%20218%20L%20563%20222%20L%20618%20239%20L%20671%20251%20L%20682%20256%20L%20689%20261%20L%20702%20276%20L%20706%20288%20L%20704%20301%20L%20700%20308%20L%20683%20322%20L%20630%20348%20L%20585%20379%20L%20563%20398%20L%20523%20441%20L%20497%20475%20L%20459%20536%20L%20443%20567%20L%20431%20595%20L%20411%20626%20L%20387%20670%20L%20386%20676%20L%20390%20677%20L%20391%20679%20L%20368%20706%20L%20333%20752%20L%20290%20818%20L%20281%20837%20L%20282%20844%20L%20300%20839%20L%20324%20825%20L%20326%20826%20L%20285%20884%20L%20242%20954%20L%20207%201020%20L%20192%201060%20L%20192%201071%20L%20196%201071%20L%20211%201062%20L%20240%201039%20L%20303%20983%20L%20305%20984%20L%20277%201023%20L%20242%201078%20L%20228%201110%20L%20227%201119%20L%20231%201130%20L%20239%201134%20L%20255%201134%20L%20274%201128%20L%20280%201134%20L%20285%201136%20L%20310%201137%20L%20339%201130%20L%20374%201112%20L%20394%201097%20L%20421%201071%20L%20445%201041%20L%20463%201013%20L%20488%20994%20L%20595%20900%20L%20614%20920%20L%20639%20951%20L%20639%20958%20L%20636%20961%20L%20619%20963%20L%20613%20966%20L%20607%20972%20L%20603%20980%20L%20602%20989%20L%20603%20995%20L%20608%201003%20L%20610%20994%20L%20620%20985%20L%20623%20986%20L%20631%20983%20L%20647%20981%20L%20665%20984%20L%20676%20989%20L%20689%201006%20L%20695%201007%20L%20697%201009%20L%20698%201023%20L%20694%201035%20L%20699%201032%20L%20709%201020%20L%20712%201010%20L%20710%20997%20L%20711%20992%20L%20719%201002%20L%20725%201005%20L%20727%201004%20L%20730%201008%20L%20731%201022%20L%20728%201032%20L%20739%201021%20L%20743%201010%20L%20743%201003%20L%20748%20993%20L%20748%20981%20L%20746%20974%20L%20739%20963%20L%20741%20961%20L%20755%20960%20L%20770%20964%20L%20779%20970%20L%20789%20983%20L%20799%20986%20L%20802%20992%20L%20802%201005%20L%20799%201012%20L%20808%201006%20L%20815%20993%20L%20813%20964%20L%20817%20968%20L%20825%20970%20L%20829%20978%20L%20831%20992%20L%20837%20981%20L%20837%20966%20L%20832%20952%20L%20822%20941%20L%20813%20936%20L%20803%20934%20L%20776%20936%20L%20763%20932%20L%20723%20890%20L%20702%20865%20L%20702%20863%20L%20717%20841%20L%20719%20842%20L%20708%20862%20L%20742%20840%20L%20782%20808%20L%20818%20773%20L%20851%20733%20L%20852%20736%20L%20846%20754%20L%20850%20752%20L%20881%20720%20L%20905%20686%20L%20932%20635%20L%20950%20590%20L%20969%20529%20L%20977%20494%20L%20982%20454%20L%20980%20419%20L%20975%20396%20L%20967%20377%20L%20968%20374%20L%20975%20382%20L%20976%20334%20L%20969%20284%20L%20959%20248%20L%20941%20209%20L%20921%20181%20Z%20M%20624%20888%20L%20666%20870%20L%20729%20934%20L%20729%20941%20L%20724%20944%20L%20716%20944%20L%20707%20951%20L%20683%20952%20L%20673%20948%20L%20659%20933%20Z%20M%20563%20618%20L%20569%20614%20L%20579%20621%20L%20576%20626%20L%20572%20627%20L%20568%20623%20L%20565%20623%20Z%20M%20575%20603%20L%20578%20603%20L%20588%20613%20L%20588%20619%20L%20585%20621%20L%20582%20620%20L%20575%20613%20L%20576%20612%20L%20573%20605%20Z%20M%20748%20398%20L%20752%20412%20L%20752%20432%20L%20748%20444%20L%20732%20470%20L%20716%20484%20L%20698%20493%20L%20685%20494%20L%20682%20491%20L%20707%20445%20L%20685%20473%20L%20667%20492%20L%20647%20508%20L%20632%20517%20L%20619%20519%20L%20615%20517%20L%20615%20513%20L%20643%20470%20L%20603%20514%20L%20589%20526%20L%20569%20538%20L%20558%20540%20L%20554%20539%20L%20552%20535%20L%20577%20498%20L%20549%20528%20L%20526%20546%20L%20508%20554%20L%20498%20555%20L%20495%20552%20L%20501%20541%20L%20482%20555%20L%20471%20558%20L%20464%20558%20L%20461%20560%20L%20460%20559%20L%20461%20555%20L%20469%20547%20L%20473%20537%20L%20491%20512%20L%20511%20497%20L%20582%20434%20L%20617%20408%20L%20632%20399%20L%20659%20386%20L%20677%20380%20L%20695%20377%20L%20712%20377%20L%20725%20380%20L%20739%20388%20Z%20M%20625%20216%20L%20683%20216%20L%20737%20222%20L%20742%20224%20L%20733%20226%20L%20721%20225%20L%20713%20230%20L%20711%20228%20L%20706%20228%20L%20694%20237%20L%20690%20233%20L%20690%20225%20L%20679%20228%20L%20674%20232%20L%20668%20232%20L%20659%20229%20L%20649%20222%20L%20632%20219%20L%20632%20217%20Z%20M%20788%20181%20L%20793%20182%20L%20797%20187%20L%20795%20193%20L%20792%20195%20L%20786%20195%20L%20782%20190%20L%20783%20185%20Z'/%3e%3cpath%20fill='%23000000'%20d='M%20607%20972%20L%20603%20981%20L%20603%20995%20L%20608%201003%20L%20610%20994%20L%20616%20987%20L%20620%20985%20L%20627%20985%20L%20635%20982%20L%20655%20981%20L%20676%20989%20L%20683%20996%20L%20689%201006%20L%20695%201007%20L%20697%201009%20L%20698%201024%20L%20694%201034%20L%20699%201032%20L%20706%201025%20L%20712%201010%20L%20710%20994%20L%20709%20997%20L%20706%20994%20L%20700%20994%20L%20694%20997%20L%20672%20976%20L%20658%20974%20L%20647%20967%20L%20642%20974%20L%20638%20974%20L%20636%20972%20L%20636%20961%20L%20629%20963%20L%20631%20972%20L%20625%20977%20L%20620%20977%20L%20613%20967%20L%20614%20966%20Z%20M%20686%20966%20L%20704%20980%20L%20719%201002%20L%20727%201004%20L%20730%201007%20L%20731%201023%20L%20728%201032%20L%20731%201030%20L%20741%201017%20L%20743%201003%20L%20748%20992%20L%20748%20981%20L%20742%20967%20L%20740%20965%20L%20742%20968%20L%20735%20972%20L%20726%20965%20L%20705%20960%20L%20724%20968%20L%20740%20983%20L%20742%20987%20L%20740%20991%20L%20732%20991%20L%20728%20996%20L%20726%20996%20L%20721%20992%20L%20713%20979%20Z%20M%20784%20943%20L%20784%20946%20L%20798%20950%20L%20819%20969%20L%20825%20970%20L%20830%20981%20L%20831%20992%20L%20837%20981%20L%20837%20966%20L%20829%20948%20L%20825%20944%20L%20830%20950%20L%20821%20957%20L%20813%20951%20L%20794%20942%20Z%20M%20659%20933%20L%20662%20937%20L%20658%20942%20L%20658%20945%20L%20663%20947%20L%20666%20945%20L%20667%20946%20L%20668%20944%20L%20670%20946%20Z%20M%20643%20913%20L%20647%20918%20L%20644%20921%20L%20642%20928%20L%20629%20938%20L%20627%20936%20L%20636%20947%20L%20634%20945%20L%20641%20933%20L%20651%20923%20L%20657%20930%20Z%20M%20936%20310%20L%20934%20309%20L%20945%20338%20L%20949%20368%20L%20949%20381%20L%20947%20383%20L%20935%20367%20L%20914%20348%20L%20929%20377%20L%20934%20397%20L%20936%20414%20L%20935%20440%20L%20933%20442%20L%20930%20440%20L%20924%20419%20L%20912%20395%20L%20909%20393%20L%20910%20410%20L%20907%20433%20L%20899%20458%20L%20895%20462%20L%20893%20460%20L%20892%20445%20L%20888%20427%20L%20873%20390%20L%20873%20416%20L%20871%20430%20L%20866%20448%20L%20862%20454%20L%20859%20452%20L%20853%20433%20L%20842%20410%20L%20823%20382%20L%20807%20365%20L%20805%20366%20L%20811%20394%20L%20812%20416%20L%20810%20425%20L%20806%20428%20L%20801%20423%20L%20790%20403%20L%20772%20383%20L%20759%20372%20L%20733%20357%20L%20724%20355%20L%20705%20346%20L%20693%20344%20L%20669%20344%20L%20646%20349%20L%20636%20353%20L%20662%20349%20L%20677%20349%20L%20699%20353%20L%20708%20356%20L%20725%20366%20L%20736%20376%20L%20745%20389%20L%20753%20415%20L%20752%20442%20L%20743%20476%20L%20723%20520%20L%20693%20569%20L%20646%20631%20L%20605%20676%20L%20568%20709%20L%20565%20710%20L%20562%20706%20L%20562%20692%20L%20567%20665%20L%20578%20636%20L%20602%20619%20L%20622%20602%20L%20645%20578%20L%20670%20546%20L%20630%20588%20L%20603%20610%20L%20574%20628%20L%20560%20633%20L%20556%20633%20L%20555%20631%20L%20563%20617%20L%20596%20572%20L%20647%20509%20L%20636%20515%20L%20562%20609%20L%20541%20630%20L%20520%20645%20L%20502%20653%20L%20490%20653%20L%20536%20590%20L%20513%20617%20L%20478%20651%20L%20454%20665%20L%20440%20669%20L%20436%20667%20L%20488%20596%20L%20459%20630%20L%20436%20653%20L%20411%20671%20L%20392%20678%20L%20372%20701%20L%20319%20772%20L%20289%20820%20L%20281%20838%20L%20282%20844%20L%20295%20841%20L%20324%20825%20L%20326%20826%20L%20289%20878%20L%20242%20954%20L%20209%201016%20L%20193%201056%20L%20191%201069%20L%20192%201071%20L%20196%201071%20L%20219%201056%20L%20303%20983%20L%20305%20984%20L%20255%201057%20L%20234%201094%20L%20228%201111%20L%20228%201124%20L%20234%201132%20L%20240%201134%20L%20254%201134%20L%20275%201128%20L%20279%201133%20L%20291%201137%20L%20316%201136%20L%20344%201128%20L%20364%201118%20L%20389%201101%20L%20403%201089%20L%20427%201064%20L%20447%201038%20L%20463%201013%20L%20489%20993%20L%20594%20901%20L%20595%20899%20L%20593%20894%20L%20588%20891%20L%20567%20868%20L%20569%20865%20L%20576%20867%20L%20586%20873%20L%20589%20867%20L%20607%20867%20L%20619%20880%20L%20622%20887%20L%20626%20891%20L%20624%20889%20L%20626%20886%20L%20666%20870%20L%20705%20909%20L%20710%20905%20L%20713%20905%20L%20716%20908%20L%20716%20911%20L%20712%20916%20L%20728%20932%20L%20730%20939%20L%20727%20943%20L%20717%20944%20L%20710%20949%20L%20712%20948%20L%20725%20951%20L%20739%20963%20L%20740%20961%20L%20756%20960%20L%20774%20966%20L%20784%20975%20L%20789%20983%20L%20800%20987%20L%20802%20991%20L%20802%201005%20L%20799%201012%20L%20806%201008%20L%20811%201002%20L%20815%20993%20L%20813%20968%20L%20812%20973%20L%20807%20971%20L%20796%20976%20L%20791%20973%20L%20788%20967%20L%20779%20958%20L%20767%20952%20L%20762%20941%20L%20756%20940%20L%20751%20932%20L%20749%20931%20L%20743%20936%20L%20738%20936%20L%20736%20933%20L%20741%20925%20L%20739%20915%20L%20742%20912%20L%20745%20914%20L%20702%20865%20L%20702%20863%20L%20717%20841%20L%20719%20842%20L%20709%20861%20L%20746%20837%20L%20783%20807%20L%20826%20764%20L%20851%20732%20L%20853%20734%20L%20846%20754%20L%20851%20751%20L%20874%20728%20L%20890%20708%20L%20908%20681%20L%20938%20621%20L%20960%20560%20L%20971%20521%20L%20979%20481%20L%20982%20444%20L%20977%20405%20L%20970%20382%20L%20966%20375%20L%20968%20374%20L%20974%20381%20L%20975%20368%20L%20974%20372%20L%20968%20364%20L%20966%20354%20L%20957%20337%20Z%20M%20247%201077%20L%20251%201085%20L%20246%201088%20L%20245%201091%20L%20240%201092%20L%20239%201085%20L%20241%201081%20Z%20M%20370%20935%20L%20371%20937%20L%20326%20997%20L%20301%201034%20L%20289%201044%20L%20286%201042%20L%20283%201045%20L%20277%201045%20L%20273%201043%20L%20264%201052%20L%20261%201049%20L%20270%201037%20L%20271%201038%20L%20281%201027%20L%20293%201010%20L%20326%20971%20Z%20M%20726%20921%20L%20728%20921%20L%20731%20926%20L%20729%20933%20L%20722%20926%20Z%20M%20729%20897%20L%20734%20902%20L%20732%20906%20L%20726%20902%20L%20726%20899%20Z%20M%20715%20882%20L%20720%20886%20L%20718%20890%20L%20711%20887%20Z%20M%20605%20762%20L%20608%20761%20L%20607%20760%20L%20609%20757%20L%20610%20759%20L%20617%20761%20L%20620%20764%20L%20611%20770%20L%20607%20770%20L%20606%20765%20L%20608%20765%20Z%20M%20611%20754%20L%20617%20750%20L%20620%20751%20L%20621%20749%20L%20625%20749%20L%20628%20752%20L%20628%20756%20L%20623%20761%20Z%20M%20549%20710%20L%20551%20713%20L%20551%20722%20L%20506%20774%20L%20403%20878%20L%20309%20963%20L%20307%20961%20L%20313%20953%20L%20322%20945%20L%20340%20922%20L%20375%20885%20Z%20M%20695%20704%20L%20696%20708%20L%20698%20709%20L%20695%20710%20L%20695%20713%20L%20692%20715%20L%20688%20710%20Z%20M%20704%20694%20L%20706%20695%20L%20706%20698%20L%20710%20698%20L%20713%20703%20L%20708%20708%20L%20707%20714%20L%20705%20716%20L%20701%20716%20L%20697%20708%20L%20699%20706%20L%20697%20705%20L%20701%20701%20L%20704%20705%20L%20706%20704%20L%20706%20700%20L%20702%20697%20Z%20M%20552%20678%20L%20554%20681%20L%20552%20701%20L%20465%20787%20L%20361%20883%20L%20316%20927%20L%20253%20993%20L%20211%201042%20L%20211%201036%20L%20222%201011%20L%20261%20942%20L%20292%20898%20L%20338%20843%20L%20374%20807%20L%20387%20807%20L%20403%20801%20L%20419%20792%20L%20456%20766%20L%20500%20728%20Z%20M%20704%20654%20L%20706%20658%20L%20711%20658%20L%20714%20661%20L%20715%20673%20L%20713%20676%20L%20705%20676%20L%20702%20674%20L%20704%20677%20L%20704%20681%20L%20702%20682%20L%20704%20685%20L%20700%20686%20L%20694%20678%20L%20691%20678%20L%20688%20674%20L%20692%20670%20L%20692%20664%20L%20694%20661%20Z%20M%20565%20642%20L%20558%20663%20L%20545%20677%20L%20494%20726%20L%20443%20767%20L%20401%20792%20L%20392%20795%20L%20387%20794%20L%20405%20766%20L%20455%20707%20L%20388%20767%20L%20355%20794%20L%20304%20827%20L%20299%20826%20L%20302%20817%20L%20316%20795%20L%20360%20739%20L%20398%20700%20L%20425%20677%20L%20428%20679%20L%20443%20679%20L%20461%20673%20L%20476%20664%20L%20493%20666%20L%20517%20657%20L%20542%20641%20L%20546%20643%20Z%20M%20563%20221%20L%20572%20225%20L%20571%20223%20L%20574%20220%20L%20585%20217%20L%20596%20218%20L%20607%20215%20L%20653%20214%20L%20706%20218%20L%20749%20224%20L%20749%20226%20L%20735%20233%20L%20732%20238%20L%20732%20249%20L%20693%20242%20L%20620%20239%20L%20672%20251%20L%20688%20260%20L%20701%20274%20L%20706%20287%20L%20704%20301%20L%20707%20297%20L%20711%20300%20L%20713%20309%20L%20720%20324%20L%20723%20327%20L%20724%20308%20L%20726%20304%20L%20735%20318%20L%20757%20341%20L%20753%20319%20L%20754%20313%20L%20760%20317%20L%20786%20345%20L%20784%20324%20L%20775%20300%20L%20779%20300%20L%20800%20317%20L%20800%20312%20L%20787%20283%20L%20772%20264%20L%20778%20263%20L%20800%20271%20L%20803%20270%20L%20770%20236%20L%20772%20234%20L%20797%20234%20L%20807%20230%20L%20801%20230%20L%20800%20228%20L%20811%20218%20L%20818%20203%20L%20818%20193%20L%20812%20179%20L%20798%20168%20L%20784%20166%20L%20760%20173%20L%20747%20173%20L%20712%20163%20L%20718%20157%20L%20703%20171%20L%20711%20173%20L%20720%20178%20L%20723%20182%20L%20720%20186%20L%20695%20190%20L%20680%20190%20L%20670%20193%20L%20656%20193%20L%20687%20204%20L%20729%20209%20L%20742%20214%20L%20753%20223%20L%20752%20224%20L%20729%20219%20L%20669%20212%20L%20610%20213%20L%20576%20218%20L%20565%20221%20L%20565%20219%20Z%20M%20771%20189%20L%20772%20201%20L%20775%20207%20L%20780%20212%20L%20787%20215%20L%20796%20216%20L%20796%20218%20L%20784%20219%20L%20776%20215%20L%20771%20210%20L%20768%20204%20L%20768%20194%20Z%20M%20788%20181%20L%20793%20182%20L%20797%20187%20L%20796%20192%20L%20790%20196%20L%20786%20195%20L%20782%20191%20L%20782%20186%20Z'/%3e%3c/g%3e%3c/svg%3e`;function Be({className:e}){return(0,M.jsx)(`span`,{className:`block overflow-hidden rounded-[20.7%] bg-accent ${e??``}`,children:(0,M.jsx)(`img`,{src:ze,alt:``,"aria-hidden":`true`,className:`h-full w-full`})})}function Ve(){return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(Be,{className:`h-[22px] w-[22px] shrink-0`}),(0,M.jsx)(`span`,{className:`hidden text-[16px] font-medium tracking-[0.04em] text-ink-50 md:inline`,children:`nightcrow`})]})}function He({open:e}){return(0,M.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-3.5 w-3.5 shrink-0 transition-transform ${e?`rotate-90`:``}`,children:(0,M.jsx)(`path`,{d:`m9 18 6-6-6-6`})})}function Ue({className:e=`h-4 w-4`}){return(0,M.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,M.jsx)(`path`,{d:`M3 6h.01`}),(0,M.jsx)(`path`,{d:`M3 12h.01`}),(0,M.jsx)(`path`,{d:`M3 18h.01`}),(0,M.jsx)(`path`,{d:`M8 6h13`}),(0,M.jsx)(`path`,{d:`M8 12h13`}),(0,M.jsx)(`path`,{d:`M8 18h13`})]})}function We({className:e=`h-4 w-4`}){return(0,M.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,M.jsx)(`path`,{d:`M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z`}),(0,M.jsx)(`path`,{d:`M14 2v4a2 2 0 0 0 2 2h4`}),(0,M.jsx)(`path`,{d:`M10 9H8`}),(0,M.jsx)(`path`,{d:`M16 13H8`}),(0,M.jsx)(`path`,{d:`M16 17H8`})]})}function Ge({className:e=`h-4 w-4`}){return(0,M.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,M.jsx)(`path`,{d:`m4 17 6-6-6-6`}),(0,M.jsx)(`path`,{d:`M12 19h8`})]})}function Ke({repos:e,currentId:t,onSelect:n,onCloseProject:r,onOpenPicker:i,className:a=``}){let[o,s]=(0,j.useState)(!1),c=f(),l=(0,j.useRef)(null),u=e.find(e=>e.id===t);return(0,j.useEffect)(()=>{if(!o)return;let e=e=>{e.key===`Escape`&&(s(!1),l.current?.focus())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o]),(0,M.jsxs)(`div`,{className:`relative min-w-0 flex-1 ${a}`,children:[(0,M.jsxs)(`button`,{ref:l,onClick:()=>s(e=>!e),"aria-haspopup":`menu`,"aria-expanded":o,title:u?.display_path??`Select a project`,className:`flex min-w-0 max-w-full items-center gap-1 rounded-sm bg-ink-700 py-0.5 pl-2 pr-1 text-ink-50`,children:[(0,M.jsx)(`span`,{className:`truncate`,children:u?.name??`No project`}),(0,M.jsx)(He,{open:o})]}),o&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>s(!1)}),(0,M.jsxs)(`div`,{role:`menu`,className:`nc-pop-in origin-top-left absolute left-0 z-50 mt-1 max-h-[70vh] w-56 max-w-[80vw] overflow-y-auto rounded-md border border-ink-700 bg-ink-900 py-1 shadow-lg`,children:[e.length===0&&(0,M.jsx)(`p`,{className:`px-3 py-1.5 text-ink-400`,children:`No projects open.`}),e.map(e=>(0,M.jsxs)(`div`,{className:`flex items-center ${e.id===t?`bg-ink-700 text-ink-50`:`text-ink-200`}`,children:[(0,M.jsx)(`button`,{role:`menuitem`,onClick:()=>{n(e.id),s(!1)},title:e.display_path,className:`min-w-0 flex-1 truncate py-1.5 pl-3 pr-1 text-left hover:text-accent`,children:e.name}),(0,M.jsx)(`button`,{onClick:()=>r(e.id),"aria-label":`close ${e.name}`,...e.id===t?c(`project.close`,`Close project`):{title:`Close project`},className:`mr-1 flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-removed`,children:(0,M.jsx)(pe,{className:`h-3.5 w-3.5`})})]},e.id)),(0,M.jsx)(`div`,{className:`my-1 border-t border-ink-800`}),(0,M.jsxs)(`button`,{role:`menuitem`,onClick:()=>{i(),s(!1)},...c(`project.openDialog`,`Open a project`),className:`flex w-full items-center gap-1 px-3 py-1.5 text-left text-ink-400 hover:text-ink-200`,children:[(0,M.jsx)(D,{className:`h-3.5 w-3.5`}),`open`]})]})]})]})}function qe({side:e,repos:t,repo:n,onSelectRepo:r,onCloseRepo:i,onOpenPicker:a,draggingRepo:o,dragOverRepo:s,onRepoDragStart:u,onRepoDragMove:p,onRepoDragEnd:m}){let h=f(),g=c(),_=t.length>1?[`project.previous`,`project.next`]:[],v=e=>e!==null,b=_.map(e=>ge(e,g)).filter(v),x=_.map(e=>d(e,g)).filter(v),S=e===`left`;return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`nav`,{"aria-keyshortcuts":b.length>0?b.join(` `):void 0,title:x.length>0?`Previous or next project (${x.join(`, `)})`:void 0,className:S?`hidden min-h-0 flex-1 flex-col overflow-y-auto md:flex`:`hidden items-stretch self-stretch overflow-x-auto pl-1 md:flex`,children:t.map(e=>(0,M.jsxs)(`div`,{"data-repo-id":e.id,onPointerDown:t=>u(t,e.id),onPointerMove:p,onPointerUp:m,onPointerCancel:m,onLostPointerCapture:m,"data-active":e.id===n,className:`nc-title-target flex items-center whitespace-nowrap ${S?`min-w-0 border-b border-ink-700`:`border-r border-ink-700`} ${t.length>1?`touch-none`:``} ${o===e.id?`opacity-60`:``} ${s===e.id?`bg-ink-800 ring-1 ring-inset ring-accent`:``} ${e.id===n?S?`bg-ink-900 text-ink-50 shadow-[inset_1px_0_0_0_var(--color-accent)]`:`bg-ink-950 text-ink-50 shadow-[inset_0_-1px_0_0_var(--color-accent)]`:`text-ink-400 hover:bg-ink-850 hover:text-ink-200`}`,title:e.display_path,children:[(0,M.jsx)(`button`,{onClick:()=>{r(e.id)},"aria-label":e.name,className:`self-stretch pl-3 pr-1 text-left ${S?`min-w-0 flex-1 py-2`:``}`,children:(0,M.jsx)(l,{title:e.name,className:S?``:y})}),(0,M.jsx)(`button`,{onClick:t=>{t.stopPropagation(),i(e.id)},"data-tab-close":!0,...e.id===n?h(`project.close`,`Close project`):{title:`Close project`},"aria-label":`close ${e.name}`,className:`mr-1 flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-removed`,children:(0,M.jsx)(pe,{})})]},e.id))}),(0,M.jsxs)(`button`,{onClick:a,...h(`project.openDialog`,`Open a project`),className:`hidden shrink-0 items-center gap-1 rounded-sm px-2 py-0.5 text-ink-400 hover:text-accent md:inline-flex ${S?`mx-1 my-2 justify-center`:``}`,children:[(0,M.jsx)(D,{className:`h-3.5 w-3.5`}),`open`]})]})}var Je={key:()=>Me(`/api/push/key`).then(e=>e.public_key),subscribe:e=>ke(`/api/push/subscribe`,e),unsubscribe:e=>ke(`/api/push/unsubscribe`,{endpoint:e}),status:e=>ke(`/api/push/status`,{endpoint:e}).then(e=>e.subscribed),test:e=>ke(`/api/push/test`,{endpoint:e})};function Ye(){let e=navigator;return{secure:window.isSecureContext,serviceWorker:`serviceWorker`in navigator?navigator.serviceWorker:void 0,hasPushManager:`PushManager`in window,permission:()=>typeof Notification>`u`?void 0:Notification.permission,requestPermission:()=>Notification.requestPermission(),isIos:/iPhone|iPad|iPod/.test(navigator.userAgent)||/Macintosh/.test(navigator.userAgent)&&navigator.maxTouchPoints>1,standalone:e.standalone===!0||window.matchMedia?.(`(display-mode: standalone)`).matches===!0}}function Xe(e){return e.secure?e.isIos&&!e.standalone?`needs-install`:!e.serviceWorker||!e.hasPushManager||e.permission()===void 0?`unsupported`:e.permission()===`denied`?`denied`:null:`insecure`}function Ze(e){e.secure&&e.serviceWorker&&e.serviceWorker.register(`./sw.js`).catch(()=>{})}async function Qe(e){return(await e.serviceWorker.ready).pushManager.getSubscription()}async function $e(e){let t=Xe(e);if(t)return t;let n=await Qe(e);return n?await Je.status(n.endpoint)?`on`:(await n.unsubscribe().catch(()=>!1),`off`):`off`}async function et(e){let t=Xe(e);if(t)return t;let n=await e.requestPermission();if(n===`denied`)return`denied`;if(n!==`granted`)return`off`;let r;try{r=await Je.key()}catch{return`unavailable`}let i=await e.serviceWorker.ready;await(await i.pushManager.getSubscription())?.unsubscribe();let a=await i.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:rt(r)});return await Je.subscribe(a.toJSON()),`on`}async function tt(e){let t=await Qe(e);return t&&(await Je.unsubscribe(t.endpoint).catch(()=>void 0),await t.unsubscribe().catch(()=>!1)),Xe(e)??`off`}async function nt(e){let t=await Qe(e);if(!t)throw Error(`notifications are off in this browser`);await Je.test(t.endpoint)}function rt(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t+`=`.repeat((4-t.length%4)%4),r=atob(n),i=new Uint8Array(new ArrayBuffer(r.length));for(let e=0;e{let e=!1;return $e(a).then(t=>!e&&n(t)).catch(()=>!e&&n(`off`)),()=>{e=!0}},[a]);let o=(0,j.useCallback)(async(e,t)=>{i(!0);try{let t=await e();return t&&n(t),!0}catch(e){return T.error(e instanceof Error?`${t}: ${e.message}`:t),!1}finally{i(!1)}},[]);return{state:t,busy:r,enable:()=>o(()=>et(a),`could not turn notifications on`),disable:()=>o(()=>tt(a),`could not turn notifications off`),test:async()=>{await o(()=>nt(a),`could not send a test`)&&T.info(`Test notification sent`)}}}var at={unsupported:`This browser does not support notifications.`,insecure:`Notifications need HTTPS or localhost. See the notifications guide for tailscale serve.`,"needs-install":`On iPhone and iPad, add nightcrow to the Home Screen and open it from there first.`,denied:`Notifications are blocked for this site. Allow them in the browser's site settings.`,unavailable:`The server could not load its notification key. Check the daemon log.`},ot=`rounded-sm px-2 py-1 text-ink-200 hover:bg-ink-700 disabled:cursor-progress disabled:text-ink-400 disabled:hover:bg-transparent`;function st(){let{state:e,busy:t,enable:n,disable:r,test:i}=it(),a=e?at[e]:void 0;return(0,M.jsxs)(`section`,{"aria-labelledby":`nc-notifications-title`,className:`border-t border-ink-800 px-3 py-2`,children:[(0,M.jsx)(`h3`,{id:`nc-notifications-title`,className:`mb-1 text-xs uppercase tracking-wide text-ink-400`,children:`Notifications`}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-200`,children:`When a terminal asks for you`}),(e===`off`||e===`on`)&&(0,M.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e===`on`,"aria-busy":t,disabled:t,onClick:e===`on`?r:n,className:ot,children:e===`on`?`On`:`Off`}),e===null&&(0,M.jsx)(`span`,{className:`text-ink-400`,children:`…`})]}),a&&(0,M.jsx)(`p`,{className:`mt-1 text-xs text-ink-400`,children:a}),e===`on`&&(0,M.jsx)(`button`,{type:`button`,disabled:t,onClick:i,className:`mt-1 ${ot}`,children:`Send a test notification`})]})}var ct=`nc-settings-title`,lt=`nc-settings-dialog`,ut=`nc-screen-scale`;function dt({accent:e,next:t,cycle:n,onReloadConfig:r,reloading:i,onShowShortcuts:a}){let[c,l]=(0,j.useState)(!1),u=(0,j.useRef)(null),d=(0,j.useRef)(null),{scale:p,setScale:m}=ue(),h=f();(0,j.useLayoutEffect)(()=>{if(!c)return;let e=d.current;if(!e)return;e.querySelector(`[data-initial-focus]`)?.focus();let t=()=>[...e.querySelectorAll(`a[href], button:not(:disabled), select:not(:disabled), input:not(:disabled), [tabindex]:not([tabindex="-1"])`)],n=n=>{if(n.key===`Escape`){n.preventDefault(),l(!1),u.current?.focus();return}if(n.key!==`Tab`)return;let r=t(),i=r[0],a=r.at(-1);!i||!a?(n.preventDefault(),e.focus()):n.shiftKey&&document.activeElement===i?(n.preventDefault(),a.focus()):!n.shiftKey&&document.activeElement===a&&(n.preventDefault(),i.focus())},r=t=>{let n=t.target;n instanceof Node&&!e.contains(n)&&!u.current?.contains(n)&&l(!1)};return document.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r),()=>{document.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r)}},[c]);let g=()=>{l(!1),u.current?.focus(),a()};return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`button`,{ref:u,type:`button`,onClick:()=>l(e=>!e),"aria-label":`Settings`,"aria-haspopup":`dialog`,"aria-expanded":c,"aria-controls":lt,title:`Settings`,className:`ml-auto flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-accent`,children:(0,M.jsx)(he,{})}),c&&(0,M.jsxs)(`div`,{ref:d,id:lt,role:`dialog`,"aria-labelledby":ct,tabIndex:-1,className:`nc-pop-in origin-top-right fixed right-2 top-[calc(var(--nc-header-h)+8px)] z-50 flex max-h-[calc(100vh-3.75rem)] w-72 max-w-[calc(100vw-1rem)] flex-col overflow-y-auto rounded-md border border-ink-700 bg-ink-900 shadow-xl focus:outline-none`,style:{maxHeight:`calc(100dvh - 3.75rem)`},children:[(0,M.jsx)(`div`,{className:`border-b border-ink-700 px-3 py-2`,children:(0,M.jsx)(`h2`,{id:ct,className:`font-medium text-ink-50`,children:`Settings`})}),(0,M.jsxs)(`section`,{"aria-labelledby":`nc-appearance-title`,className:`px-3 py-2`,children:[(0,M.jsx)(`h3`,{id:`nc-appearance-title`,className:`mb-1 text-xs uppercase tracking-wide text-ink-400`,children:`Appearance`}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-200`,children:`Accent colour`}),(0,M.jsxs)(`button`,{type:`button`,"data-initial-focus":!0,onClick:n,...h(`session.cycleAccent`,`Accent: ${e.name} (click for ${t.name})`),"aria-label":`accent colour: ${e.name}, click for ${t.name}`,className:`flex items-center gap-1.5 rounded-sm px-2 py-1 text-ink-200 hover:bg-ink-700`,children:[(0,M.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-3 rounded-full bg-accent ring-1 ring-ink-600`}),e.name]})]}),(0,M.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,M.jsx)(`label`,{htmlFor:ut,className:`min-w-0 flex-1 text-ink-200`,children:`Screen scale`}),(0,M.jsxs)(`div`,{className:`relative`,children:[(0,M.jsx)(`select`,{id:ut,"aria-label":`Screen scale`,value:p,onChange:e=>m(Number(e.currentTarget.value)),className:`appearance-none rounded-sm border border-ink-700 bg-ink-850 py-1 pl-2 pr-7 text-ink-50 focus:border-accent focus:outline-none`,children:o.map(e=>(0,M.jsxs)(`option`,{value:e,children:[e,`%`]},e))}),(0,M.jsx)(`span`,{className:`pointer-events-none absolute inset-y-0 right-2 flex items-center text-ink-400`,children:(0,M.jsx)(He,{open:!0})})]})]})]}),(0,M.jsx)(st,{}),(0,M.jsxs)(`div`,{className:`border-t border-ink-800 px-3 py-2`,children:[(0,M.jsxs)(`button`,{type:`button`,onClick:r,disabled:i,"aria-busy":i,...h(`session.reloadConfig`,`Reload config.toml on the server (does not reload this page)`),"aria-label":`reload the server config`,className:`flex w-full items-center gap-2 rounded-sm py-1.5 text-left text-ink-200 hover:bg-ink-700 disabled:cursor-progress disabled:text-ink-400 disabled:hover:bg-transparent`,children:[(0,M.jsx)(ne,{className:`h-3.5 w-3.5 ${i?`animate-spin`:``}`}),`Reload config.toml`]}),(0,M.jsxs)(`button`,{type:`button`,onClick:g,...h(`help.shortcuts`,`Keyboard shortcuts`),"aria-label":`keyboard shortcuts`,className:`mt-1 flex w-full items-center gap-2 rounded-sm py-1.5 text-left text-ink-200 hover:bg-ink-700`,children:[(0,M.jsx)(s,{className:`h-3.5 w-3.5`}),`Keyboard shortcuts`]})]})]})]})}function ft(e){return e===`top`||e===`left`?e:null}function pt(e){return e===`top`?`left`:`top`}function mt({repos:e,repo:t,onSelectRepo:n,onCloseRepo:r,onOpenPicker:i,cloning:a,accent:o,next:s,cycle:c,draggingRepo:l,dragOverRepo:u,onRepoDragStart:d,onRepoDragMove:f,onRepoDragEnd:p,onReloadConfig:m,reloading:h,onShowShortcuts:g,tabStrip:_}){return(0,M.jsxs)(`header`,{className:`flex h-(--nc-header-h) items-center gap-2 border-b border-chrome-line bg-ink-900 px-[12.8px]`,children:[(0,M.jsx)(`div`,{className:`flex shrink-0 items-center gap-2`,children:(0,M.jsx)(Ve,{})}),(0,M.jsx)(Ke,{className:`md:hidden`,repos:e,currentId:t,onSelect:n,onCloseProject:r,onOpenPicker:i}),_.side===`top`&&(0,M.jsx)(qe,{side:`top`,repos:e,repo:t,onSelectRepo:n,onCloseRepo:r,onOpenPicker:i,draggingRepo:l,dragOverRepo:u,onRepoDragStart:d,onRepoDragMove:f,onRepoDragEnd:p}),a&&(0,M.jsxs)(`span`,{role:`status`,title:`A clone is running on the server`,className:`flex shrink-0 items-center gap-1.5 px-2 py-0.5 text-ink-400`,children:[(0,M.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 animate-pulse rounded-full bg-accent`}),`Cloning…`]}),(0,M.jsx)(dt,{accent:o,next:s,cycle:c,onReloadConfig:m,reloading:h,onShowShortcuts:g}),(0,M.jsx)(`button`,{onClick:_.toggle,title:`Project tabs ${_.side===`top`?`across the top`:`down the left`} (click to move them ${pt(_.side)})`,"aria-label":`project tabs: ${_.side}, click for ${pt(_.side)}`,"aria-pressed":_.side===`left`,className:`ml-1 hidden h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-accent md:flex`,children:(0,M.jsx)(De,{side:_.side})}),(0,M.jsx)(`a`,{href:`/logout`,title:`Sign out`,"aria-label":`sign out`,className:`ml-1 flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-accent`,children:(0,M.jsx)(be,{})})]})}var ht=[`w-3/5`,`w-2/5`,`w-4/5`,`w-1/2`,`w-3/4`,`w-1/3`,`w-2/3`];function gt({className:e=``}){return(0,M.jsx)(`span`,{"aria-hidden":`true`,className:`nc-skeleton block h-2.5 rounded-xs ${e}`})}function _t({rows:e=6,as:t=`div`,className:n=``}){let r=t;return(0,M.jsx)(M.Fragment,{children:Array.from({length:e},(e,t)=>(0,M.jsxs)(r,{"aria-hidden":`true`,className:`flex items-center gap-2 px-3 py-1.5 ${n}`,children:[(0,M.jsx)(gt,{className:`w-3 shrink-0`}),(0,M.jsx)(gt,{className:ht[t%ht.length]})]},t))})}function vt(){return(0,M.jsxs)(`div`,{"aria-busy":`true`,"aria-label":`Loading`,className:`flex h-full flex-col`,children:[(0,M.jsxs)(`div`,{className:`flex h-(--nc-header-h) shrink-0 items-center gap-2 border-b border-chrome-line bg-ink-900 px-[12.8px]`,children:[(0,M.jsx)(gt,{className:`h-[22px] w-[22px] shrink-0 rounded-sm`}),(0,M.jsx)(gt,{className:`hidden w-24 md:block`}),(0,M.jsx)(gt,{className:`w-28 md:hidden`}),(0,M.jsx)(gt,{className:`ml-auto h-4 w-4 shrink-0`}),(0,M.jsx)(gt,{className:`ml-1 h-4 w-4 shrink-0`})]}),(0,M.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 grid-rows-[minmax(0,1fr)] md:grid-cols-[18rem_minmax(0,1fr)] md:grid-rows-[minmax(0,3fr)_minmax(0,2fr)]`,children:[(0,M.jsx)(`div`,{className:`overflow-hidden border-chrome-line py-2 md:border-r`,children:(0,M.jsx)(_t,{rows:10})}),(0,M.jsx)(`div`,{className:`hidden overflow-hidden py-2 md:block`,children:(0,M.jsx)(_t,{rows:14})}),(0,M.jsxs)(`div`,{className:`hidden overflow-hidden border-t border-chrome-line md:col-span-2 md:block`,children:[(0,M.jsxs)(`div`,{className:`flex h-8 items-center gap-2 border-b border-chrome-line px-3`,children:[(0,M.jsx)(gt,{className:`w-30`}),(0,M.jsx)(gt,{className:`w-30`})]}),(0,M.jsx)(`div`,{className:`py-2`,children:(0,M.jsx)(_t,{rows:5})})]})]}),(0,M.jsx)(`div`,{className:`flex shrink-0 border-t border-chrome-line bg-ink-900 md:hidden`,children:[0,1,2].map(e=>(0,M.jsxs)(`div`,{className:`flex min-h-11 flex-1 flex-col items-center justify-center gap-1 py-1`,children:[(0,M.jsx)(gt,{className:`h-5 w-5`}),(0,M.jsx)(gt,{className:`h-2 w-10`})]},e))})]})}function yt({onSuccess:e}){let[t,n]=(0,j.useState)(``),[r,i]=(0,j.useState)(null),[a,o]=(0,j.useState)(!1);return(0,M.jsx)(`div`,{className:`flex h-full items-center justify-center p-6`,children:(0,M.jsxs)(`form`,{onSubmit:async n=>{n.preventDefault(),o(!0),i(null);try{await A.login(t),e()}catch(e){i(e instanceof Error?e.message:`login failed`)}finally{o(!1)}},className:`w-[17rem] max-w-[86vw]`,children:[(0,M.jsx)(Be,{className:`mx-auto mb-3 block h-10 w-10`}),(0,M.jsx)(`h1`,{className:`text-center text-lg font-medium tracking-wide text-ink-50`,children:`nightcrow`}),(0,M.jsx)(`p`,{className:`mt-1 mb-5 text-center text-caption text-ink-400 uppercase`,children:`web viewer`}),r&&(0,M.jsx)(`p`,{className:`mb-2.5 text-center text-removed`,children:r}),(0,M.jsx)(`input`,{type:`password`,autoFocus:!0,value:t,onChange:e=>n(e.target.value),placeholder:`password`,className:`mb-2 w-full rounded-sm border border-ink-700 bg-ink-900 px-2.5 py-1.5 outline-none placeholder:text-ink-400 focus:border-accent focus:ring-[3px] focus:ring-accent/15`}),(0,M.jsx)(`button`,{"aria-busy":a,type:`submit`,disabled:a,className:`w-full rounded-sm bg-ink-50 py-1.5 font-semibold text-ink-950 hover:bg-white disabled:opacity-50`,children:(0,M.jsx)(k,{busy:a,children:`Sign in`})})]})})}var bt=`nightcrow.sidebarWidth`,xt=.5;function St(e){return Math.min(Math.max(Math.round(e),280),720)}function Ct(e){let t=720;try{t=Math.min(t,Math.round(window.innerWidth*xt))}catch{}return Math.min(Math.max(Math.round(e),280),Math.max(t,280))}function wt(){let e=Number(m(bt));return Number.isFinite(e)&&e>0?St(e):460}function Tt(e){h(bt,String(e))}function Et(){let[e,t]=(0,j.useState)(wt),n=(0,j.useCallback)(e=>{let n=Ct(e);t(n),Tt(n)},[]);return{width:e,resize:n,commit:n,reset:(0,j.useCallback)(()=>{let e=St(460);t(e),Tt(e)},[])}}var Dt=`[data-terminal-panel]`,Ot=`dialog[open], [role="dialog"], [aria-modal="true"]`,kt=`input, textarea, select, [contenteditable], [role="textbox"], [role="searchbox"], [role="combobox"]`,At=`data-focus-region`;function jt(e){return{"data-focus-region":e,tabIndex:-1}}function Mt(e){if(!(e instanceof Element)||e.closest(`[data-terminal-panel]`))return null;let t=e.closest(kt)??e;return{tagName:t.tagName,isContentEditable:It(t),role:t.getAttribute(`role`),type:Lt(t),inDialog:e.closest(Ot)!==null}}function Nt(e=document){return Pt(e)===`terminal`}function Pt(e=document){let t=e.activeElement;if(!t)return null;if(t.closest(`[data-terminal-panel]`))return`terminal`;let n=t.closest(`[${At}]`)?.getAttribute(At);return n===`list`||n===`content`?n:null}function Ft(e,t=document){let n=t.querySelector(`[${At}="${e}"]`);if(!n)return!1;let r=a(t.activeElement,t.querySelector(Dt));return Ce(r)?(n.focus(),!0):!1}function It(e){let t=e.getAttribute(`contenteditable`);return t===null?e.isContentEditable===!0:t!==`false`}function Lt(e){return e.tagName===`INPUT`?e.type?.toLowerCase()??null:null}var Rt=600;function zt(e){let[t,n]=(0,j.useState)({scrollTop:0,height:Rt}),r=(0,j.useCallback)(()=>{let t=e.current;if(!t)return;let r={scrollTop:t.scrollTop,height:t.clientHeight||Rt};n(e=>e.scrollTop===r.scrollTop&&e.height===r.height?e:r)},[e]);return(0,j.useLayoutEffect)(()=>{r();let t=e.current;if(!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(r);return n.observe(t),()=>n.disconnect()},[e,r]),{viewport:t,refresh:r}}function Bt(){let e=new Map;return{start(t){let n=(e.get(t)??0)+1;return e.set(t,n),n},isCurrent(t,n){return e.get(t)===n}}}var Vt={children:{},expanded:new Set};function Ht(e,t,n){return{...e,children:{...e.children,[t]:n}}}function Ut(e,t){let n=new Set(e);return n.delete(t)||n.add(t),n}function Wt(e,t){return{...e,expanded:Ut(e.expanded,t)}}function Gt(e,t){let n=new Set(e.expanded);return t.forEach(e=>n.add(e)),{...e,expanded:n}}function Kt(e){let t=[],n=``;for(let r of e.split(`/`))n=n?`${n}/${r}`:r,t.push(n);return t}var qt=180,Jt={items:[],truncated:!1};function Yt({repo:e,authed:t,tab:n,filter:r,filterOpen:i,handle:a}){let[o,s]=(0,j.useState)(Vt),[c,l]=(0,j.useState)(Jt),[u,d]=(0,j.useState)(!1),[f]=(0,j.useState)(Bt);(0,j.useEffect)(()=>{if(!e||!t||n!==`tree`||!i||!r){l(Jt),d(!1);return}d(!0);let o=!0,s=setTimeout(()=>{A.treeSearch(e,r).then(e=>{o&&l({items:e.matches,truncated:e.truncated})}).catch(e=>{o&&a(e)}).finally(()=>{o&&d(!1)})},qt);return()=>{o=!1,clearTimeout(s)}},[e,t,n,r,i,a]);let p=(0,j.useCallback)((t,n)=>{if(!e)return;let r=f.start(t);A.tree(e,t).then(e=>{f.isCurrent(t,r)&&s(n=>Ht(n,t,e.entries))}).catch(e=>{if(!f.isCurrent(t,r)||n?.restoring)return Ne(e)?a(e):void 0;a(e)})},[e,a,f]);(0,j.useEffect)(()=>{e&&t&&n===`tree`&&p(``)},[e,t,n,p]);let m=(0,j.useCallback)(e=>{let t=!o.expanded.has(e);s(t=>Wt(t,e)),t&&!(e in o.children)&&p(e)},[o,p]),h=(0,j.useCallback)(e=>{s(t=>({...t,expanded:new Set(e)})),e.forEach(e=>{e in o.children||p(e,{restoring:!0})})},[o,p]),g=(0,j.useCallback)(e=>{let t=Kt(e);s(e=>Gt(e,t)),t.forEach(e=>{e in o.children||p(e)})},[o,p]);return{treeChildren:o.children,treeExpanded:o.expanded,treeMatches:c.items,treeTruncated:c.truncated,treeSearchLoading:u,loadTreeChildren:p,toggleTreeDir:m,revealTreeDir:g,seedTreeExpanded:h}}function Xt(e,t){let n=[],r=(i,a)=>{for(let o of e[i]??[]){let e=i?`${i}/${o.name}`:o.name;n.push({path:e,name:o.name,is_dir:o.is_dir,depth:a}),o.is_dir&&t.has(e)&&r(e,a+1)}};return r(``,0),n}var Zt=[`status`,`log`,`tree`],N={status:`Show the working-tree status`,log:`Show the commit log`,tree:`Show the file tree`};function Qt(e){return e===`log`?`view.toggleLog`:e===`tree`?`view.toggleTree`:null}function $t({tab:e,onChoose:t,filterOpen:n,onToggleFilter:r}){let i=f();return(0,M.jsxs)(`div`,{className:`flex shrink-0 items-stretch border-b border-chrome-line px-2`,children:[Zt.map(n=>{let r=Qt(n);return(0,M.jsx)(`button`,{onClick:()=>t(n),"aria-current":n===e?`page`:void 0,...r&&n!==e?i(r,N[n]):{title:N[n]},className:`px-2 py-1.5 ${n===e?`text-ink-50 shadow-[inset_0_-1px_0_0_var(--color-accent)]`:`text-ink-400 hover:text-ink-200`}`,children:n},n)}),(0,M.jsx)(`button`,{onClick:r,"aria-pressed":n,title:n?`Hide the filter`:`Filter the list`,"aria-label":n?`Hide the filter`:`Filter the list`,className:`my-1 ml-auto flex shrink-0 items-center rounded-sm px-1.5 hover:text-accent ${n?`text-ink-50`:`text-ink-400`}`,children:(0,M.jsx)(ie,{})})]})}function en({path:e,from:t,className:n}){return(0,M.jsx)(`span`,{className:`whitespace-nowrap ${n??``}`,title:t?`${t} → ${e}`:e,children:t?`${t} → ${e}`:e})}var tn=1e3;function nn(e,t){return e===void 0||e<=0?0:e-t}function rn(e,t,n){let r=nn(t,n);return e===null||Math.abs(r-e)>=1e3?r:e}function an(e,t,n){if(e===void 0)return`cool`;let r=Math.max(0,t-e);return r>=n?`cool`:r<5e3?`fresh`:`warm`}function on(e,t,n){return e.some(e=>an(e,t,n)!==`cool`)}var sn={fresh:`text-accent font-bold`,warm:`text-accent`,cool:``};function cn(e,t,n){let[r,i]=(0,j.useState)(()=>Date.now()+n);return(0,j.useEffect)(()=>{if(t<=0||!e)return;let r=e.map(e=>e.mtime),a=Date.now()+n;if(i(a),!on(r,a,t))return;let o=setInterval(()=>{let e=Date.now()+n;i(e),on(r,e,t)||clearInterval(o)},tn);return()=>clearInterval(o)},[e,t,n]),r}function ln(e){return e.startsWith(`not a git repository`)?`Not a git repository. Run git init here to track changes.`:`Status unavailable: ${e}`}function un(e){let t=Math.max(0,Math.floor(Date.now()/1e3-e));return t<60?`${t}s`:t<3600?`${Math.floor(t/60)}m`:t<86400?`${Math.floor(t/3600)}h`:t<2592e3?`${Math.floor(t/86400)}d`:t<31536e3?`${Math.floor(t/2592e3)}mo`:`${Math.floor(t/31536e3)}y`}function dn(e){return e===`+`?`bg-added/10`:e===`-`?`bg-removed/10`:``}function fn(e){return e===`?`?`text-ink-400`:e===`D`?`text-removed`:e===`A`?`text-added`:`text-accent`}function pn(e,t,n,r=20,i=12){let a=Math.max(1,Math.ceil(n/r)),o=Math.min(Math.floor(Math.max(0,t)/r),Math.max(0,e-a)),s=o+a,c=Math.max(0,Math.min(e,o-i)),l=Math.max(c,Math.min(e,s+i));return{start:c,end:l,before:c*r,after:(e-l)*r}}function mn(e){return Math.max(0,e-1)*20}function hn({status:e,files:t,hotWindowMs:n,clockSkewMs:r,viewport:i,openDiff:a}){let o=cn(t,n,r);if(e===null)return(0,M.jsx)(_t,{as:`li`,rows:8});if(e.unavailable!==void 0)return(0,M.jsx)(`li`,{className:`nc-fade-in px-3 py-1 text-ink-400`,children:ln(e.unavailable)});let s=t.length>200?pn(t.length,i.scrollTop,i.height):null,c=s?.start??0,l=s?t.slice(s.start,s.end):t;return(0,M.jsxs)(M.Fragment,{children:[s&&(0,M.jsx)(`li`,{"aria-hidden":`true`,"data-virtual-count":t.length,style:{height:s.before}}),l.map((e,t)=>{let r=c+t;return(0,M.jsx)(`li`,{"data-virtual-row":s?r:void 0,children:(0,M.jsxs)(`button`,{onClick:()=>a(e.path),className:`flex w-max min-w-full gap-2 px-3 py-0.5 text-left hover:bg-ink-850`,children:[(0,M.jsxs)(`span`,{className:`shrink-0`,children:[(0,M.jsx)(`span`,{className:fn(e.index),children:e.index===` `?` `:e.index}),(0,M.jsx)(`span`,{className:fn(e.worktree),children:e.worktree===` `?` `:e.worktree})]}),(0,M.jsx)(en,{path:e.path,from:e.old_path,className:sn[an(e.mtime,o,n)]})]})},e.path)}),s&&(0,M.jsx)(`li`,{"aria-hidden":`true`,style:{height:s.after}}),e.truncated&&(0,M.jsxs)(`li`,{className:`px-3 py-1 text-accent`,children:[`Showing the first `,e.files.length,` changed files.`]})]})}var gn={merge:`MERGING`,rebase:`REBASING`,"cherry-pick":`CHERRY-PICKING`,revert:`REVERTING`,bisect:`BISECTING`,am:`APPLYING`};function _n(e){let t=e?.operation,n=t?t.step!==void 0&&t.total!==void 0?`${gn[t.kind]} ${t.step}/${t.total}`:gn[t.kind]:null,r=e?.conflicts??0,i=r===0?null:r===1?`1 conflict`:`${r} conflicts`;return n&&i?`${n} · ${i}`:n??i}function vn(e){return e.kind===`head`&&e.name!==`HEAD`?`HEAD → ${e.name}`:e.name}function yn(e){switch(e){case`head`:return`border-accent text-accent font-medium`;case`local`:return`border-added/60 text-added`;case`tag`:return`border-ink-600 text-ink-200`;case`remote`:return`border-ink-700 text-ink-400`}}function bn({visibleCommits:e,decorations:t,commits:n,commitDrillDown:r,visibleCommitFiles:i,logDone:a,logStalled:o,logPagingPaused:s,viewport:c,setLogStalled:l,logSentinelRef:u,openCommitFiles:d,openCommit:f,openCommitFileDiff:p,setCommitDrillDown:m,setPaneEmpty:h,bumpPaneRequest:g}){let _=!r&&e.length>200?pn(e.length,c.scrollTop,c.height):null,v=_?e.slice(_.start,_.end):e,y=_?.start??0,b=r&&i.length>200?pn(i.length,c.scrollTop,c.height):null,x=b?i.slice(b.start,b.end):i,S=b?.start??0;return(0,M.jsxs)(M.Fragment,{children:[!r&&_&&(0,M.jsx)(`li`,{"aria-hidden":`true`,"data-virtual-count":e.length,style:{height:_.before}}),!r&&v.map((e,n)=>{let r=y+n,i=t.divergenceOf(e.oid);return(0,M.jsx)(`li`,{"data-virtual-row":_?r:void 0,children:(0,M.jsxs)(`button`,{onClick:()=>void d(e),title:`${e.author} · ${e.summary}`,className:`flex w-max min-w-full items-baseline gap-2 px-3 py-0.5 text-left hover:bg-ink-850`,children:[(0,M.jsx)(`span`,{className:`w-2 shrink-0 ${i===`behind`?`text-accent`:`text-added`}`,title:i===`ahead`?`Not on the upstream yet`:i===`behind`?`On the upstream, not here yet`:void 0,children:i===`ahead`?`↑`:i===`behind`?`↓`:``}),(0,M.jsx)(`span`,{className:`shrink-0 text-accent`,children:e.short_id}),(0,M.jsx)(`span`,{className:`w-10 shrink-0 text-right text-ink-400`,children:un(e.time)}),(0,M.jsx)(`span`,{className:`max-w-[6rem] shrink-0 truncate text-ink-400`,children:e.author}),t.refsOf(e.oid)?.map(e=>(0,M.jsx)(`span`,{className:`shrink-0 self-center rounded-sm border px-1 text-2xs ${yn(e.kind)}`,children:vn(e)},`${e.kind}:${e.name}`)),(0,M.jsx)(`span`,{className:`whitespace-nowrap ${e.merge?`text-ink-400`:``}`,children:e.summary})]})},e.oid)}),!r&&_&&(0,M.jsx)(`li`,{"aria-hidden":`true`,style:{height:_.after}}),!r&&t.truncated&&(0,M.jsx)(`li`,{className:`px-3 py-1 text-2xs text-ink-400`,children:`Too many refs to mark them all — some branch, tag or upstream marks are not shown.`}),!r&&!a&&!o&&!s&&(0,M.jsxs)(`li`,{ref:u,className:`flex flex-col gap-2 px-3 py-1.5`,"aria-hidden":`true`,children:[(0,M.jsx)(gt,{className:`w-3/5`}),(0,M.jsx)(gt,{className:`w-2/5`}),(0,M.jsx)(gt,{className:`w-1/2`})]}),!r&&!a&&!o&&s&&(0,M.jsxs)(`li`,{className:`px-3 py-1 text-ink-400`,children:[`filtering `,n.length,` loaded commits — clear the filter to load more`]}),!r&&o&&(0,M.jsx)(`li`,{className:`px-3 py-1`,children:(0,M.jsx)(`button`,{onClick:()=>l(!1),className:`text-ink-400 hover:text-accent`,children:`could not load more — retry`})}),r&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`li`,{className:`sticky top-0 z-10 flex w-max min-w-full items-center gap-1 bg-ink-900 px-2 py-1 text-ink-400`,children:[(0,M.jsx)(`button`,{onClick:()=>{g(),m(null),h()},className:`rounded-sm px-1 hover:text-accent`,title:`Back to commit log`,children:`< log`}),(0,M.jsx)(`span`,{className:`text-ink-600`,children:`·`}),(0,M.jsx)(`span`,{className:`shrink-0 text-accent`,children:r.commit.short_id}),(0,M.jsx)(`button`,{onClick:()=>f(r.commit.oid),className:`rounded-sm px-1 hover:text-accent`,title:`Show the complete commit diff`,children:`all changes`})]}),b&&(0,M.jsx)(`li`,{"aria-hidden":`true`,"data-virtual-count":i.length,style:{height:b.before}}),x.map((e,t)=>{let n=S+t;return(0,M.jsx)(`li`,{"data-virtual-row":b?n:void 0,children:(0,M.jsxs)(`button`,{onClick:()=>p(r.commit.oid,e.path),className:`flex w-max min-w-full gap-2 px-3 py-0.5 text-left hover:bg-ink-850`,children:[(0,M.jsx)(`span`,{className:fn(e.index),children:e.index}),(0,M.jsx)(en,{path:e.path,from:e.old_path})]})},e.path)}),b&&(0,M.jsx)(`li`,{"aria-hidden":`true`,style:{height:b.after}}),r.files.length===0&&(0,M.jsx)(`li`,{className:`px-3 py-2 text-ink-400`,children:`No changed files.`}),r.files.length>0&&i.length===0&&(0,M.jsx)(`li`,{className:`px-3 py-2 text-ink-400`,children:`No matching files.`}),r.truncated&&(0,M.jsxs)(`li`,{className:`px-3 py-1 text-accent`,children:[`Showing the first `,r.files.length,` files.`]})]})]})}function xn({treeSearching:e,treeMatches:t,treeTruncated:n,treeSearchLoading:r,treeRows:i,treeExpanded:a,openFile:o,revealTreeDir:s,toggleTreeDir:c}){return e?(0,M.jsxs)(M.Fragment,{children:[t.map(e=>(0,M.jsx)(`li`,{children:(0,M.jsx)(`button`,{onClick:()=>{e.is_dir?s(e.path):o(e.path)},title:e.path,className:`w-max min-w-full whitespace-nowrap px-3 py-0.5 text-left hover:bg-ink-850`,children:e.is_dir?(0,M.jsxs)(`span`,{className:`text-accent`,children:[e.path,`/`]}):e.path})},e.path)),t.length===0&&(0,M.jsx)(`li`,{className:`px-3 py-0.5 text-ink-400`,children:r?`searching…`:`no matches`}),n&&(0,M.jsxs)(`li`,{className:`px-3 py-0.5 text-ink-400`,children:[`showing the first `,t.length,` matches`]})]}):(0,M.jsx)(M.Fragment,{children:i.map(e=>(0,M.jsx)(`li`,{children:(0,M.jsxs)(`button`,{onClick:()=>e.is_dir?c(e.path):o(e.path),title:e.path,style:{paddingLeft:`${e.depth*.75+.5}rem`},className:`flex w-max min-w-full items-center gap-1 py-0.5 pr-3 text-left hover:bg-ink-850`,children:[e.is_dir?(0,M.jsx)(He,{open:a.has(e.path)}):(0,M.jsx)(`span`,{className:`h-3.5 w-3.5 shrink-0`}),(0,M.jsx)(`span`,{className:`whitespace-nowrap ${e.is_dir?`text-accent`:``}`,children:e.is_dir?`${e.name}/`:e.name})]})},e.path))})}function Sn(e){let{tab:t,chooseTab:n,filter:r,setFilter:i,filterOpen:a,setFilterOpen:o,status:s,files:c,hotWindowMs:l,clockSkewMs:u,openDiff:d,openFile:f,openCommit:p,openCommitFileDiff:m,openCommitFiles:h,repo:g,authed:_,handle:v,sidebarRef:y,draggingSidebar:b,onSidebarDragStart:x,onSidebarDragMove:S,onSidebarDragEnd:C,onSidebarDragCancel:w,filesMax:T,bumpPaneRequest:E,commits:ee,logDone:te,logStalled:ne,setLogStalled:re,commitDrillDown:ie,setCommitDrillDown:ae,logSentinelRef:oe,visibleCommits:se,decorations:ce,logPagingPaused:le,visibleCommitFiles:ue,mobileView:de,restoreTree:fe,restoreKnown:pe,onTreeExpanded:me,clearPane:he,touched:ge}=e,_e=Yt({repo:g,authed:_,tab:t,filter:r,filterOpen:a,handle:v}),ve=(0,j.useRef)(null),{viewport:ye,refresh:be}=zt(ve),xe=t===`tree`&&a&&r!==``,D=Xt(_e.treeChildren,_e.treeExpanded),{seedTreeExpanded:O}=_e,Se=(0,j.useRef)(!1);(0,j.useEffect)(()=>{Se.current||pe&&!ge&&t===`tree`&&(Se.current=!0,fe.length!==0&&O(fe))},[t,pe,ge,fe,O]);let Ce=e=>{me([...Ut(_e.treeExpanded,e)]),_e.toggleTreeDir(e)},we=e=>{let t=new Set(_e.treeExpanded);Kt(e).forEach(e=>t.add(e)),me([...t]),_e.revealTreeDir(e)},Te=()=>{a&&i(``),o(e=>!e)};return(0,M.jsxs)(`section`,{ref:y,...jt(`list`),className:`nc-fade-in relative min-h-0 flex-col overflow-hidden ${de===`files`?`flex`:`hidden md:flex`} ${T?`md:flex`:`border-chrome-line md:border-r`}`,children:[!T&&(0,M.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the file sidebar (double-click to reset)`,title:`Drag to resize · double-click to reset`,onPointerDown:x,onPointerMove:S,onPointerUp:C,onPointerCancel:w,onLostPointerCapture:C,className:`absolute -right-px top-0 z-20 hidden h-full w-1.5 cursor-col-resize touch-none md:block ${b?`bg-accent`:`hover:bg-accent`}`}),(0,M.jsx)($t,{tab:t,onChoose:n,filterOpen:a,onToggleFilter:Te}),a&&(0,M.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),placeholder:`filter…`,autoFocus:!0,className:`mx-2 mb-1 shrink-0 rounded-sm bg-ink-850 px-2 py-1 outline-none placeholder:text-ink-400 focus:ring-1 focus:ring-accent`}),(0,M.jsxs)(`ul`,{ref:ve,onScroll:be,className:`nc-content min-h-0 flex-1 overflow-auto`,children:[t===`status`&&(0,M.jsx)(hn,{status:s,files:c,hotWindowMs:l,clockSkewMs:u,viewport:ye,openDiff:d}),t===`log`&&(0,M.jsx)(bn,{visibleCommits:se,decorations:ce,commits:ee,commitDrillDown:ie,visibleCommitFiles:ue,logDone:te,logStalled:ne,logPagingPaused:le,viewport:ye,setLogStalled:re,logSentinelRef:oe,openCommitFiles:h,openCommit:p,openCommitFileDiff:m,setCommitDrillDown:ae,setPaneEmpty:he,bumpPaneRequest:E}),t===`tree`&&(0,M.jsx)(xn,{treeSearching:xe,treeMatches:_e.treeMatches,treeTruncated:_e.treeTruncated,treeSearchLoading:_e.treeSearchLoading,treeRows:D,treeExpanded:_e.treeExpanded,openFile:f,revealTreeDir:we,toggleTreeDir:Ce})]})]})}function Cn(e){let t=[],n=[],r=[],i=()=>{let e=Math.max(n.length,r.length);for(let i=0;i{t(e=>e===`split`?`unified`:`split`)},[])}}var Tn=[`.md`,`.markdown`],En=[`.html`,`.htm`];function Dn(e){let t=e.toLowerCase();return Tn.some(e=>t.endsWith(e))}function On(e){let t=e.toLowerCase();return En.some(e=>t.endsWith(e))}function kn(e){return Dn(e)||On(e)}function An(e){return e.map(e=>e.map(e=>e.t).join(``)).join(` +`)}function jn(e,t=0){if(new Set(e.hunks.map(t=>t.file_path??e.path)).size>1)return null;for(let n of e.hunks.slice(Math.max(0,t)))for(let e of n.lines)if(e.new_lineno!==void 0)return e.new_lineno;return null}function Mn(e){return Math.max(0,e-1-2)}function Nn(e,t){return t<=0?null:Math.min(e,t)}function Pn(e,t){let n=0;return e.forEach((e,r)=>{e<=t&&(n=r)}),n}function Fn(e){return e.kind===`empty`||!e.source?null:{want:e.kind===`diff`?`file`:`diff`,source:e.source}}function In(e){return e.index!==`D`&&e.worktree!==`D`}function Ln(e){return e.hunks.some(e=>e.lines.some(e=>e.old_lineno!==void 0||e.new_lineno!==void 0))}function Rn(e){return e.kind===`workdir`?`workdir:${e.path}`:`commit:${e.oid}:${e.path}`}function zn({pane:e,previewRendered:t,setPreviewRendered:n,filesMax:r,setMaximized:i,onShowOtherFace:a,canEdit:o,editing:s,onToggleEdit:c}){let l=wn(),d=f();return(0,M.jsxs)(`div`,{className:`ml-auto flex shrink-0 items-center gap-1`,children:[Fn(e)&&(0,M.jsx)(`button`,{onClick:a,"aria-pressed":e.kind===`file`,title:e.kind===`file`?`Back to the diff`:`Open the whole file at this change`,"aria-label":e.kind===`file`?`Back to the diff`:`Open the whole file at this change`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${e.kind===`file`?`text-accent`:``}`,children:(0,M.jsx)(b,{})}),e.kind===`diff`&&(0,M.jsx)(`button`,{onClick:l.toggle,"aria-pressed":l.layout===`split`,title:l.layout===`split`?`Switch to unified diff`:`Switch to split diff`,"aria-label":l.layout===`split`?`Switch to unified diff`:`Switch to split diff`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${l.layout===`split`?`text-accent`:``}`,children:(0,M.jsx)(v,{})}),o&&(0,M.jsx)(`button`,{onClick:c,"aria-pressed":s,title:s?`Stop editing`:`Edit this page's text`,"aria-label":s?`Stop editing`:`Edit this page's text`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${s?`text-accent`:``}`,children:(0,M.jsx)(fe,{})}),e.kind===`file`&&kn(e.value.path)&&!s&&(0,M.jsx)(`button`,{onClick:()=>n(e=>!e),"aria-pressed":t,title:t?`Show raw source`:`Show the rendered page`,"aria-label":t?`Show raw source`:`Show the rendered page`,className:`flex shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent ${t?`text-accent`:``}`,children:(0,M.jsx)(p,{})}),(0,M.jsx)(`button`,{onClick:()=>i(r?`none`:`files`),"aria-pressed":r,...d(`view.toggleMaximize`,r?`Restore the layout`:`Maximize the file pane`),"aria-label":r?`Restore the layout`:`Maximize the file pane`,className:`hidden shrink-0 items-center rounded-sm px-1.5 py-0.5 hover:text-accent md:flex`,children:(0,M.jsx)(u,{maximized:r})})]})}var Bn=3;function Vn(e){let t=e<1?1:String(Math.floor(e)).length;return Math.max(t,Bn)}function Hn(e){let t=0;for(let n of e)for(let e of n.lines)t=Math.max(t,e.old_lineno??0,e.new_lineno??0);return Vn(t)}function P({nos:e,digits:t,tint:n=``,stickyClass:r=`sticky left-0`}){return(0,M.jsx)(`span`,{className:`${r} shrink-0 select-none bg-ink-950`,children:(0,M.jsx)(`span`,{className:`flex gap-[1ch] px-[1ch] text-ink-400 ${n}`,children:e.map((e,n)=>(0,M.jsx)(`span`,{className:`text-right`,style:{width:`${t}ch`},children:e??``},n))})})}function Un(){let e=`(min-width: 768px)`,[t,n]=(0,j.useState)(()=>window.matchMedia(e).matches);return(0,j.useEffect)(()=>{let t=window.matchMedia(e),r=()=>n(t.matches);return t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[]),t}function Wn(e,t,n){return e.hunks.flatMap((e,r)=>{let i={kind:`header`,hunk:r,text:`${e.file_path?`${e.file_path} `:``}${e.header}`};if(!t)return[i,...e.lines.map(e=>({kind:`unified`,hunk:r,line:e}))];let a=Cn(e.lines);return n?[i,...a.map(({left:e,right:t})=>({kind:`pair`,hunk:r,left:e,right:t}))]:[i,...a.map(({left:e})=>({kind:`side`,hunk:r,line:e,side:`old`,border:!1})),...a.map(({right:e},t)=>({kind:`side`,hunk:r,line:e,side:`new`,border:t===0}))]})}function Gn({line:e}){return(0,M.jsxs)(`span`,{className:`whitespace-pre pr-3`,children:[(0,M.jsx)(`span`,{className:`select-none text-ink-400`,children:e.kind}),e.spans.map((e,t)=>(0,M.jsx)(`span`,{style:{color:e.c},children:e.t},t))]})}function Kn({line:e,side:t,digits:n,stickyClass:r}){let i=e?dn(e.kind):`bg-ink-900/40`;return(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-1 ${i}`,children:[(0,M.jsx)(P,{nos:[e?t===`old`?e.old_lineno:e.new_lineno:void 0],digits:n,tint:i,stickyClass:r}),e?(0,M.jsx)(Gn,{line:e}):(0,M.jsx)(`span`,{className:`pr-3`,children:` `})]})}function qn({diff:e,split:t,viewport:n}){let r=Un(),i=(0,j.useMemo)(()=>Wn(e,t,r),[e,t,r]),a=Hn(e.hunks),o=pn(i.length,n.scrollTop,n.height);return(0,M.jsxs)(`div`,{className:`min-w-full py-1`,"data-virtual-count":i.length,children:[(0,M.jsx)(`div`,{"aria-hidden":`true`,style:{height:o.before}}),i.slice(o.start,o.end).map((e,t)=>{let n=o.start+t,r={"data-hunk":e.hunk,"data-virtual-row":n};if(e.kind===`header`)return(0,M.jsx)(`div`,{...r,className:`h-5 bg-ink-850 px-3 text-ink-400`,children:e.text},n);if(e.kind===`unified`){let t=dn(e.line.kind);return(0,M.jsxs)(`div`,{...r,className:`flex h-5 w-max min-w-full ${t}`,children:[(0,M.jsx)(P,{nos:[e.line.old_lineno,e.line.new_lineno],digits:a,tint:t}),(0,M.jsx)(Gn,{line:e.line})]},n)}return e.kind===`pair`?(0,M.jsxs)(`div`,{...r,className:`flex h-5 min-w-full`,children:[(0,M.jsx)(Kn,{line:e.left,side:`old`,digits:a}),(0,M.jsx)(`div`,{className:`flex min-w-0 flex-1 border-l border-ink-800`,children:(0,M.jsx)(Kn,{line:e.right,side:`new`,digits:a,stickyClass:`sticky left-1/2`})})]},n):(0,M.jsx)(`div`,{...r,className:`flex h-5 min-w-full ${e.border?`border-t border-ink-800`:``}`,children:(0,M.jsx)(Kn,{line:e.line,side:e.side,digits:a})},n)}),(0,M.jsx)(`div`,{"aria-hidden":`true`,style:{height:o.after}})]})}function Jn({line:e}){return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`text-ink-400 select-none`,children:e.kind}),e.spans.map((e,t)=>(0,M.jsx)(`span`,{style:{color:e.c},children:e.t},t))]})}function Yn({line:e,digits:t,side:n}){if(e===null)return(0,M.jsxs)(`div`,{className:`flex bg-ink-900/40`,children:[(0,M.jsx)(P,{nos:[void 0],digits:t,tint:`bg-ink-900/40`}),(0,M.jsx)(`span`,{className:`whitespace-pre pr-3`,children:` `})]});let r=dn(e.kind);return(0,M.jsxs)(`div`,{className:`flex ${r}`,children:[(0,M.jsx)(P,{nos:[n===`old`?e.old_lineno:e.new_lineno],digits:t,tint:r}),(0,M.jsx)(`span`,{className:`whitespace-pre pr-3`,children:(0,M.jsx)(Jn,{line:e})})]})}function Xn({cells:e,digits:t,side:n,border:r}){return(0,M.jsx)(`div`,{className:`min-w-0 flex-none overflow-x-auto md:flex-1 md:basis-1/2 ${r?`border-t border-ink-800 md:border-t-0 md:border-l`:``}`,children:(0,M.jsx)(`div`,{className:`w-max min-w-full`,children:e.map((e,r)=>(0,M.jsx)(Yn,{line:e,digits:t,side:n},r))})})}function Zn({lines:e,digits:t}){let n=Cn(e);return(0,M.jsxs)(`div`,{className:`flex flex-col md:flex-row`,children:[(0,M.jsx)(Xn,{cells:n.map(e=>e.left),digits:t,side:`old`,border:!1}),(0,M.jsx)(Xn,{cells:n.map(e=>e.right),digits:t,side:`new`,border:!0})]})}function Qn({diff:e,split:t,viewport:n={scrollTop:0,height:600}}){if(e.hunks.reduce((e,t)=>e+t.lines.length,0)>200)return(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(qn,{diff:e,split:t,viewport:n}),e.truncated&&(0,M.jsx)(`p`,{className:`p-3 text-accent`,children:`Diff truncated — it exceeded the server's size ceiling.`})]});let r=Hn(e.hunks);return(0,M.jsxs)(`div`,{className:`p-1`,children:[e.hunks.length===0&&(0,M.jsx)(`p`,{className:`p-3 text-ink-400`,children:`No changes.`}),e.hunks.map((e,n)=>{let i=(0,M.jsxs)(`div`,{className:`bg-ink-850 px-3 py-0.5 text-ink-400`,children:[e.file_path?`${e.file_path} `:``,e.header]});return(0,M.jsx)(`div`,{"data-hunk":n,className:`mb-2`,children:t?(0,M.jsxs)(M.Fragment,{children:[i,(0,M.jsx)(Zn,{lines:e.lines,digits:r})]}):(0,M.jsxs)(`div`,{className:`w-max min-w-full`,children:[i,e.lines.map((e,t)=>{let n=dn(e.kind);return(0,M.jsxs)(`div`,{className:`flex ${n}`,children:[(0,M.jsx)(P,{nos:[e.old_lineno,e.new_lineno],digits:r,tint:n}),(0,M.jsx)(`span`,{className:`whitespace-pre pr-3`,children:(0,M.jsx)(Jn,{line:e})})]},t)})]})},n)}),e.truncated&&(0,M.jsx)(`p`,{className:`p-3 text-accent`,children:`Diff truncated — it exceeded the server's size ceiling.`})]})}var $n=[`failed to fetch dynamically imported module`,`error loading dynamically imported module`,`importing a module script failed`,`unable to preload css`];function er(e){let t=e instanceof Error?e.message:typeof e==`string`?e:``;if(!t)return!1;let n=t.toLowerCase();return $n.some(e=>n.includes(e))}var tr=class extends j.Component{state={error:null,failed:!1};static getDerivedStateFromError(e){return{error:e,failed:!0}}componentDidCatch(e,t){console.error(`nightcrow: a subtree failed to render`,e,t)}render(){return this.state.failed?(0,M.jsx)(nr,{chunk:er(this.state.error),region:this.props.region,className:this.props.className}):this.props.children}};function nr({chunk:e,region:t,className:n}){return(0,M.jsxs)(`div`,{role:`alert`,className:`h-full min-h-0 flex-col items-start gap-3 p-4 text-ink-400 ${n??`flex`}`,children:[e?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`p`,{className:`text-accent`,children:`Part of the app could not be loaded.`}),(0,M.jsx)(`p`,{children:`Most likely the server was updated while this tab was open, and reloading picks up the current version. If the reload fails too, the server is not reachable from here. Either way nothing on the server is affected — the session, its repositories, and its terminals are untouched.`})]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`p`,{className:`text-removed`,children:t?`The ${t} could not be rendered.`:`Something went wrong.`}),(0,M.jsx)(`p`,{children:`The details are in the browser console.`})]}),(0,M.jsx)(`button`,{onClick:()=>window.location.reload(),className:`rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:border-accent hover:text-accent`,children:`Reload`})]})}function rr({lines:e}){let t=Vn(e.length);return(0,M.jsx)(`pre`,{className:`w-max min-w-full py-2 text-ink-200`,children:e.map((e,n)=>(0,M.jsxs)(`div`,{"data-line":n+1,className:`flex`,children:[(0,M.jsx)(P,{nos:[n+1],digits:t}),(0,M.jsx)(`span`,{className:`whitespace-pre pr-3`,children:e.length===0?` `:e.map((e,t)=>(0,M.jsx)(`span`,{style:{color:e.c},children:e.t},t))})]},n))})}function ir({lines:e,viewport:t}){let n=Vn(e.length),r=pn(e.length,t.scrollTop,t.height);return(0,M.jsxs)(`pre`,{className:`w-max min-w-full`,"data-virtual-count":e.length,children:[(0,M.jsx)(`div`,{"aria-hidden":`true`,style:{height:r.before}}),e.slice(r.start,r.end).map((e,t)=>{let i=r.start+t;return(0,M.jsxs)(`div`,{"data-line":i+1,"data-virtual-row":i,className:`flex h-5 text-ink-200`,children:[(0,M.jsx)(P,{nos:[i+1],digits:n}),(0,M.jsx)(`span`,{className:`whitespace-pre pr-3`,children:e.length===0?` `:e.map((e,t)=>(0,M.jsx)(`span`,{style:{color:e.c},children:e.t},t))})]},i)}),(0,M.jsx)(`div`,{"aria-hidden":`true`,style:{height:r.after}})]})}var ar=`modulepreload`,or=function(e,t){return new URL(e,t).href},sr={},cr=function(e){return e.pathname.endsWith(`.css`)},lr=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},ur=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=or(t,n);let r=s(t),i=cr(r);return lr(sr,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:ar,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function dr(e,t){return`${e??``}\u0000${Rn(t)}`}var fr=(0,j.lazy)(()=>ur(()=>import(`./Markdown-DEJAds14.js`).then(e=>({default:e.MarkdownView})),__vite__mapDeps([0,1,2,3]),import.meta.url)),pr=(0,j.lazy)(()=>ur(()=>import(`./Html-DGFy4jGa.js`).then(e=>({default:e.HtmlView})),__vite__mapDeps([4,1]),import.meta.url)),mr=(0,j.lazy)(()=>ur(()=>import(`./HtmlEditor-DzgQSTDx.js`).then(e=>({default:e.HtmlEditor})),__vite__mapDeps([5,1,2,6,7]),import.meta.url));function hr({repo:e,pane:t,loading:n=!1,previewRendered:r,setPreviewRendered:i,filesMax:a,setMaximized:o,showOtherFace:s,status:c,className:l=``}){let u=wn(),[d,f]=(0,j.useState)(!1),p=t.kind===`file`?t.value.path:null,m=t.kind===`file`&&t.source?.kind===`commit`,h=e!==null&&p!==null&&!m&&On(p),g=(0,j.useRef)(null),{viewport:_,refresh:v}=zt(g),y=t.kind===`file`?t.anchor:void 0,b=(0,j.useRef)(null),x=()=>{let n=g.current;if(!n)return 0;let r=n.getBoundingClientRect().top,i=Array.from(n.querySelectorAll(`[data-hunk]`),e=>({offset:e.getBoundingClientRect().top-r+n.scrollTop,hunk:Number(e.dataset.hunk??0)}));return t.kind===`diff`&&t.source&&(b.current={key:dr(e,t.source),top:n.scrollTop,left:n.scrollLeft}),i[Pn(i.map(e=>e.offset),n.scrollTop)]?.hunk??0};return(0,j.useEffect)(()=>{let n=g.current;if(!n)return;if(t.kind===`diff`&&t.source){let r=b.current;r&&r.key===dr(e,t.source)&&(n.scrollTop=r.top,n.scrollLeft=r.left,b.current=null,v());return}if(y===void 0||t.kind!==`file`)return;let r=Nn(y,t.value.lines.length);if(r===null)return;if(t.value.lines.length>200){n.scrollTop=mn(r),v();return}let i=n.querySelector(`[data-line="${r}"]`);i&&(n.scrollTop+=i.getBoundingClientRect().top-n.getBoundingClientRect().top,v())},[t,y,e,v]),(0,j.useEffect)(()=>{f(!1)},[e,p,m]),(0,M.jsxs)(`section`,{...jt(`content`),className:`min-h-0 min-w-0 flex-col ${l}`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 bg-ink-850 px-3 py-0.5 text-ink-400`,children:[t.kind===`file`&&(0,M.jsx)(en,{path:t.value.path,className:`min-w-0 truncate`}),(0,M.jsx)(zn,{pane:t,previewRendered:r,setPreviewRendered:i,filesMax:a,setMaximized:o,onShowOtherFace:()=>s(x()),canEdit:h,editing:d&&h,onToggleEdit:()=>f(e=>!e)})]}),(0,M.jsx)(`div`,{ref:g,onScroll:v,className:`nc-content min-h-0 flex-1 overflow-auto`,children:n?(0,M.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Loading`,className:`py-2`,children:(0,M.jsx)(_t,{rows:12})}):(0,M.jsxs)(M.Fragment,{children:[t.kind===`empty`&&(c===null?(0,M.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Loading`,className:`py-2`,children:(0,M.jsx)(_t,{rows:12})}):c.unavailable===void 0?(0,M.jsx)(`p`,{className:`nc-fade-in p-4 text-ink-400`,children:`Select a file or commit.`}):(0,M.jsx)(`p`,{className:`nc-fade-in p-4 text-ink-400`,children:ln(c.unavailable)})),t.kind===`file`&&(0,M.jsxs)(M.Fragment,{children:[d&&h&&e!==null&&p!==null?(0,M.jsx)(tr,{region:`preview`,children:(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Opening the editor`,className:`py-2`,children:(0,M.jsx)(_t,{rows:12})}),children:(0,M.jsx)(mr,{repo:e,path:p})})},`edit:${p}`):kn(t.value.path)&&r?(0,M.jsx)(tr,{region:`preview`,children:(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(`div`,{"aria-busy":`true`,"aria-label":`Rendering`,className:`py-2`,children:(0,M.jsx)(_t,{rows:12})}),children:On(t.value.path)&&e!==null?(0,M.jsx)(pr,{src:A.previewUrl(e,t.value.path,t.source?.kind===`commit`?t.source.oid:void 0)}):(0,M.jsx)(fr,{source:An(t.value.lines)})})},t.value.path):t.value.lines.length>200?(0,M.jsx)(ir,{lines:t.value.lines,viewport:_}):(0,M.jsx)(rr,{lines:t.value.lines}),t.value.truncated&&(0,M.jsx)(`p`,{className:`p-3 text-accent`,children:`File truncated — it exceeded the server's size ceiling.`})]}),t.kind===`diff`&&(0,M.jsx)(Qn,{diff:t.value,split:u.layout===`split`,viewport:_})]})})]})}var gr=[{key:`files`,label:`Repo`,icon:Ue},{key:`diff`,label:`Content`,icon:We},{key:`terminal`,label:`Terminal`,icon:Ge}];function _r({view:e,onSelect:t}){return(0,M.jsx)(`nav`,{"aria-label":`Switch view`,className:`flex shrink-0 items-stretch border-t border-chrome-line bg-ink-900 md:hidden`,children:gr.map(({key:n,label:r,icon:i})=>(0,M.jsxs)(`button`,{onClick:()=>t(n),"aria-current":e===n?`page`:void 0,className:`flex min-h-11 flex-1 flex-col items-center justify-center gap-0.5 py-1 text-xs ${e===n?`text-accent`:`text-ink-400`}`,children:[(0,M.jsx)(i,{className:`h-5 w-5`}),r]},n))})}var vr=(0,j.lazy)(()=>ur(()=>import(`./Terminal-C0v33aMU.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([8,1,2,9,7]),import.meta.url));function yr({repository:{id:e,current:t,status:n},sidebar:r,filePane:i,layout:{sidebarWidth:a,sidebarRef:o,draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d,upperRef:f,lowerRef:p,draggingUpper:m,onUpperDragStart:h,onUpperDragMove:g,onUpperDragEnd:_,onUpperDragCancel:v,maximized:y,setMaximized:b,mobileView:x,setMobileView:S}}){let C=y===`files`;(0,j.useEffect)(()=>d,[e,d]),(0,j.useEffect)(()=>v,[v]);let w=(0,j.useCallback)(()=>b(e=>e===`terminal`?`none`:`terminal`),[b]);return(0,M.jsxs)(M.Fragment,{children:[s&&(0,M.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-col-resize`}),m&&(0,M.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-row-resize`}),(0,M.jsxs)(`main`,{ref:f,className:`grid min-h-0 grid-cols-1 md:grid-cols-[var(--nc-sidebar)_minmax(0,1fr)] ${x===`terminal`?`hidden md:grid`:``} ${s||m?`select-none`:``}`,style:{"--nc-sidebar":C?`0px`:`min(${a}px, ${xt*100}vw)`},children:[(0,M.jsx)(Sn,{...r,repo:e,status:n,sidebarRef:o,draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d,filesMax:C,mobileView:x},e),(0,M.jsx)(hr,{...i,filesMax:C,setMaximized:b,status:n,className:`nc-fade-in ${x===`diff`?`flex`:`hidden md:flex`}`})]}),(0,M.jsx)(tr,{region:`terminal panel`,className:x===`terminal`?`flex`:`hidden md:flex`,children:(0,M.jsx)(j.Suspense,{fallback:(0,M.jsx)(`div`,{className:`min-h-0 border-t border-chrome-line ${x===`terminal`?`block`:`hidden md:block`}`}),children:(0,M.jsx)(vr,{repo:e,maximized:y===`terminal`,onToggleMaximized:w,className:`nc-fade-in ${x===`terminal`?`flex`:`hidden md:flex`} ${y===`files`?`overflow-hidden`:``}`,sectionRef:p,showDivider:y===`none`,draggingUpper:m,onUpperDragStart:h,onUpperDragMove:g,onUpperDragEnd:_,onUpperDragCancel:v})})}),(0,M.jsx)(_r,{view:x,onSelect:S}),(0,M.jsxs)(`footer`,{className:`flex shrink-0 items-center gap-3 border-t border-chrome-line bg-ink-900 px-3 py-1 text-ink-400`,children:[(0,M.jsx)(`span`,{className:`min-w-0 shrink-[1000] truncate`,children:t?.display_path}),n?.branch&&(0,M.jsx)(`span`,{className:`max-w-[50%] shrink-0 truncate text-accent`,children:n.branch}),_n(n)&&(0,M.jsx)(`span`,{className:`shrink-0 font-medium text-removed`,role:`status`,children:_n(n)}),n?.tracking&&(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`↑`,n.tracking.ahead,` ↓`,n.tracking.behind]}),(0,M.jsx)(`span`,{className:`ml-auto shrink-0`,children:n?(0,M.jsx)(`span`,{className:`text-added`,children:`● live`}):`connecting…`})]})]})}var br=`0.1.28`;function xr({settings:e}){let{leaderText:t,conflict:n,setLeader:r,disable:i,reset:a}=e,[o,s]=(0,j.useState)(t),[c,l]=(0,j.useState)(null);(0,j.useEffect)(()=>{s(t),l(null)},[t]);let u=()=>{r(o)?l(null):l(`"${o}" is not a chord. Write it as Ctrl+F, Alt+Space or Ctrl+Shift+ArrowLeft.`)};return(0,M.jsxs)(`section`,{className:`shrink-0 border-b border-ink-700 px-3 py-2`,children:[(0,M.jsxs)(`p`,{className:`text-ink-400`,children:[`Leader chord:`,` `,t?(0,M.jsx)(`kbd`,{className:`rounded-sm border border-ink-600 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-50`,children:t}):(0,M.jsx)(`span`,{className:`text-ink-200`,children:`switched off`})]}),(0,M.jsxs)(`div`,{className:`mt-1.5 flex items-stretch gap-2`,children:[(0,M.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&u()},placeholder:`Ctrl+F`,"aria-label":`leader chord`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`,className:`min-w-0 flex-1 rounded-sm border border-ink-700 bg-ink-950 px-2 py-1 font-mono text-ink-50 placeholder:text-ink-400 focus:border-ink-600 focus:outline-none`}),(0,M.jsx)(`button`,{type:`button`,onClick:u,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Rebind`}),(0,M.jsx)(`button`,{type:`button`,onClick:i,title:`Leave the leader unbound. Standalone chords keep working.`,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Switch off`}),(0,M.jsx)(`button`,{type:`button`,onClick:a,title:`Back to the leader the TUI ships with`,className:`shrink-0 rounded-sm border border-ink-700 px-2 py-1 text-ink-200 hover:bg-ink-850`,children:`Reset`})]}),c&&(0,M.jsx)(`p`,{role:`alert`,className:`mt-1 text-removed`,children:c}),n&&(0,M.jsxs)(`p`,{role:`status`,className:`mt-1 text-accent`,children:[n,` Rebind it above if you would rather keep that key.`]})]})}function Sr({keys:e}){return e?(0,M.jsx)(`span`,{className:`flex shrink-0 items-center gap-1`,children:e.map((e,t)=>(0,M.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t>0&&(0,M.jsx)(`span`,{className:`text-ink-400`,children:`then`}),(0,M.jsx)(`kbd`,{className:`rounded-sm border border-ink-600 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-50`,children:e})]},e))}):(0,M.jsx)(`span`,{className:`shrink-0 text-ink-400`,children:`no key — the leader is switched off`})}function Cr({action:e,keys:t,ariaKeys:n,available:r,onRun:i}){let a=`flex w-full flex-col gap-0.5 rounded-sm px-3 py-1.5 text-left ${r?``:`opacity-50`}`,o=(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`span`,{className:`flex w-full items-baseline gap-2`,children:[(0,M.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-50`,children:e.label}),e.support===`reinterpreted`&&(0,M.jsx)(`span`,{className:`shrink-0 rounded-sm bg-ink-700 px-1 text-2xs uppercase tracking-wide text-ink-200`,children:`reinterpreted`}),e.support===`browserOnly`&&(0,M.jsx)(`span`,{className:`shrink-0 rounded-sm bg-ink-700 px-1 text-2xs uppercase tracking-wide text-ink-200`,children:`browser only`}),!r&&(0,M.jsx)(`span`,{className:`shrink-0 text-2xs uppercase tracking-wide text-ink-400`,children:`not available here`}),(0,M.jsx)(Sr,{keys:t})]}),e.note&&(0,M.jsx)(`span`,{className:`text-ink-400`,children:e.note})]}),s={"data-shortcut-action":e.id,"aria-disabled":!r||void 0,"aria-keyshortcuts":n??void 0};return e.keyboardOnly?(0,M.jsx)(`li`,{children:(0,M.jsx)(`div`,{...s,className:a,children:o})}):(0,M.jsx)(`li`,{children:(0,M.jsx)(`button`,{type:`button`,...s,onClick:()=>{r&&i()},className:`${a} ${r?`hover:bg-ink-850`:``}`,children:o})})}var wr={terminal:`Terminal`,project:`Projects`,view:`Layout and views`,focus:`Focus`,session:`Session`,help:`Help`},Tr=(()=>{let e=[];for(let t of S){let n=e.find(e=>e.group===t.group);n?n.actions.push(t):e.push({group:t.group,actions:[t]})}return e})(),Er=`nc-shortcut-help-title`;function Dr({onClose:e,leader:t}){let n=we(),r=ee(),i=(0,j.useRef)(null),a=(0,j.useRef)(!1);(0,j.useEffect)(()=>{let e=document.activeElement;return i.current?.focus(),()=>{a.current||e instanceof HTMLElement&&e.isConnected&&e.focus()}},[]),(0,j.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]);let o=t=>{a.current=!0,n?.runAction(t.id),e()};return(0,M.jsx)(`div`,{className:`nc-fade-in fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4`,onClick:e,children:(0,M.jsxs)(`div`,{ref:i,role:`dialog`,"aria-modal":`true`,"aria-labelledby":Er,tabIndex:-1,className:`nc-rise-in flex max-h-[85vh] w-[40rem] max-w-full flex-col rounded-lg border border-ink-700 bg-ink-900 focus:outline-none`,onClick:e=>e.stopPropagation(),children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-ink-700 px-3 py-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`span`,{id:Er,className:`block font-medium text-ink-50`,children:`Keyboard shortcuts`}),(0,M.jsxs)(`span`,{className:`block text-caption text-ink-400`,children:[`nightcrow v`,br]})]}),(0,M.jsx)(`button`,{type:`button`,onClick:e,"aria-label":`close`,className:`ml-auto flex h-6 w-6 items-center justify-center rounded-sm text-ink-400 hover:text-ink-200`,children:(0,M.jsx)(pe,{})})]}),(0,M.jsx)(xr,{settings:t}),(0,M.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-1`,children:[Tr.map(({group:e,actions:n})=>(0,M.jsxs)(`section`,{children:[(0,M.jsx)(`h3`,{className:`px-3 py-1 text-caption uppercase text-ink-400`,children:wr[e]}),(0,M.jsx)(`ul`,{children:n.map(e=>(0,M.jsx)(Cr,{action:e,keys:C(e.id,t.leader),ariaKeys:ge(e.id,t.leader),available:r(e.id),onRun:()=>o(e)},e.id))})]},e)),(0,M.jsxs)(`section`,{children:[(0,M.jsx)(`h3`,{className:`px-3 py-1 text-caption uppercase text-ink-400`,children:`Not bound in the browser`}),(0,M.jsx)(`ul`,{children:w.map(e=>(0,M.jsxs)(`li`,{className:`px-3 py-1.5`,children:[(0,M.jsxs)(`span`,{className:`flex items-baseline gap-2`,children:[(0,M.jsx)(`span`,{className:`min-w-0 flex-1 text-ink-200`,children:e.label}),(0,M.jsx)(`kbd`,{className:`shrink-0 rounded-sm border border-ink-700 bg-ink-850 px-1.5 py-0.5 font-mono text-ink-400`,children:e.leader})]}),(0,M.jsx)(`span`,{className:`text-ink-400`,children:e.reason})]},e.leader))})]})]})]})})}var Or=[`terminal.newPane`,`terminal.closePane`,`view.toggleMaximize`,`project.openDialog`,`help.shortcuts`],kr={keys:`3-9,0`,label:`pane 1-8`,click:null},Ar={keys:`3-9,0`,label:`swap active pane with this pane`,click:null},jr={keys:`esc`,label:`cancel`,click:null};function Mr(e,t,n){return e.armed&&e.swapPending?{chip:`SWAP`,segments:[Ar,jr]}:e.armed?{chip:`PREFIX`,segments:Pr(n)}:t?{chip:null,segments:Nr(t,n)}:{chip:null,segments:Fr(n)}}function Nr(e,t){let n=me(e),r=[{keys:n,label:`leader`,click:{kind:`arm`}}];for(let e of S)Or.includes(e.id)&&t(e.id)&&r.push(Ir(e,`${n} ${e.leader}`));return r}function Pr(e){let t=[],n=!1;for(let i of S)i.leader!==void 0&&e(i.id)&&(r(i.id)===null?t.push(Ir(i,i.leader)):(n||t.push(kr),n=!0));return t.push(jr),t}function Fr(e){let t=[{keys:`leader`,label:`switched off`,click:{kind:`run`,action:`help.shortcuts`}}];for(let n of S)n.chord!==void 0&&e(n.id)&&t.push(Ir(n,n.chord));return t}function Ir(e,t){return{keys:t,label:e.hint,click:{kind:`run`,action:e.id}}}var Lr=`shrink-0 whitespace-nowrap`;function Rr({state:e,onClick:t}){let n=Mr(e,c(),ee());return(0,M.jsxs)(`div`,{role:`toolbar`,"aria-label":`Keyboard hints`,className:`hidden shrink-0 items-center gap-1 overflow-hidden border-t border-chrome-line bg-ink-900 px-2 py-0.5 text-xs text-ink-400 md:flex`,children:[n.chip&&(0,M.jsx)(`span`,{"data-hint-chip":n.chip,className:`shrink-0 bg-accent px-1 font-bold text-ink-950`,children:n.chip}),n.segments.map((e,n)=>(0,M.jsxs)(j.Fragment,{children:[n>0&&(0,M.jsx)(`span`,{className:`shrink-0 text-ink-600`,children:`|`}),(0,M.jsx)(zr,{segment:e,onClick:t})]},`${e.keys} ${e.label}`))]})}function zr({segment:e,onClick:t}){let n=(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`text-ink-200`,children:e.keys}),`: `,e.label]});if(!e.click)return(0,M.jsx)(`span`,{className:Lr,children:n});let r=e.click;return(0,M.jsx)(`button`,{type:`button`,"data-hint-action":r.kind===`run`?r.action:`arm`,onPointerDown:e=>e.preventDefault(),onClick:()=>t(r),className:`${Lr} rounded-sm hover:text-accent`,children:n})}function Br(e,t){return e?`grid-rows-[minmax(0,1fr)_auto_auto] ${t===`terminal`?`md:grid-rows-[minmax(0,0fr)_minmax(0,1fr)_auto_auto]`:t===`files`?`md:grid-rows-[minmax(0,1fr)_minmax(0,0fr)_auto_auto]`:`md:grid-rows-[minmax(0,var(--nc-upper))_minmax(0,var(--nc-lower))_auto_auto]`}`:`grid-rows-[1fr]`}function Vr(e,t){let n=Hr(e);if(n.length===0)return null;let r=e.at,i=r===null?-1:n.findIndex(e=>Ur(e,r)),a;return a=i===-1?t>0?n[0]:n[n.length-1]:n[(i+t+n.length)%n.length],r!==null&&Ur(a,r)?null:a}function Hr({paneCount:e,maximized:t,narrow:n,mobileView:r}){let i={kind:`list`},a={kind:`content`},o=Array.from({length:e},(e,t)=>({kind:`pane`,index:t}));if(n)switch(r){case`files`:return[i];case`diff`:return[a];case`terminal`:return o}switch(t){case`terminal`:return o;case`files`:return[i,a];case`none`:return[i,a,...o]}}function Ur(e,t){return e.kind===t.kind?e.kind!==`pane`||t.kind!==`pane`||e.index===t.index:!1}function Wr(e,t,n){if(e.length<=1||t===null)return null;let r=e.indexOf(t);return r<0?null:e[(r+n+e.length)%e.length]}var Gr={armed:!1},Kr={kind:`none`};function qr(e=Kr){return{state:Gr,effect:e}}function Jr(e,t){switch(t.kind){case`blur`:case`focusChange`:case`dialogOpen`:case`repoChange`:case`socketReconnect`:case`disabled`:case`suppressed`:case`cancel`:return qr();case`consumed`:return qr();case`arm`:return{state:{armed:!0,swapPending:!1},effect:Kr};case`literalLeader`:return qr({kind:`sendLiteralLeader`,data:t.data});case`action`:return Yr(e,t.action.id);case`ignore`:return{state:e,effect:Kr}}}function Yr(e,t){if(e.armed&&e.swapPending){let e=r(t);return e===null?qr():qr({kind:`swapWith`,pane:e})}return t===`terminal.swapPanePrompt`?{state:{armed:!0,swapPending:!0},effect:Kr}:qr({kind:`run`,action:t})}var Xr=S.flatMap(e=>{if(!e.chord)return[];let t=E(e.chord);return t?[{spec:t,action:e}]:[]}),Zr=new Set([`Shift`,`Control`,`Alt`,`Meta`]),Qr=229,$r=new Set([`Process`,`Unidentified`]),ei={kind:`ignore`};function ti(e){return e.isComposing===!0||e.keyCode===Qr||$r.has(e.key)}function ni(e){return e.key===`Escape`||e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey&&e.key.toLowerCase()===`c`}function ri(e,t){if(e.type!==`keydown`||ti(e)||e.repeat===!0||t.suppressed)return ei;if(t.armed){if(ni(e))return{kind:`cancel`};if(t.leader&&xe(t.leader,e))return{kind:`literalLeader`,data:le(t.leader)??``};if(e.key.length===1){let t=_(e.key);if(t)return{kind:`action`,action:t}}return Zr.has(e.key)?ei:{kind:`consumed`}}if(t.leader&&xe(t.leader,e))return{kind:`arm`};for(let{spec:t,action:n}of Xr)if(xe(t,e))return{kind:`action`,action:n};return ei}var ii=new Set([`checkbox`,`radio`,`button`,`submit`,`reset`,`image`,`range`,`color`,`file`]),ai=new Set([`textbox`,`searchbox`,`combobox`]);function oi(e){if(!e)return!1;if(e.isContentEditable===!0)return!0;let t=e.role?.toLowerCase()??``;if(ai.has(t))return!0;switch(e.tagName.toUpperCase()){case`INPUT`:return!ii.has(e.type?.toLowerCase()??`text`);case`TEXTAREA`:case`SELECT`:return!0;default:return!1}}function si(e){return e.dialogOpen||e.composing||e.target?.inDialog===!0?!0:oi(e.target)}function ci(e,t=!0){let n=(0,j.useRef)(e);n.current=e,(0,j.useEffect)(()=>{if(!t)return;let e=e=>{n.current(e)&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation())};return document.addEventListener(`keydown`,e,{capture:!0}),()=>document.removeEventListener(`keydown`,e,{capture:!0})},[t])}function li({enabled:e,leader:t,dialogOpen:n,repo:r}){let i=we(),a=(0,j.useRef)(Gr),[o,s]=(0,j.useState)(Gr),c=(0,j.useRef)(i);c.current=i;let l=(0,j.useCallback)(e=>{let t=Jr(a.current,e);a.current=t.state,s(t.state);let n=c.current;n&&ui(t.effect,n)},[]);ci((0,j.useCallback)(e=>{let r=si({target:Mt(e.target),dialogOpen:n,composing:e.isComposing===!0}),i=ri(e,{leader:t,armed:a.current.armed,suppressed:r});return r?(l({kind:`suppressed`}),!1):(l(i),i.kind!==`ignore`)},[n,t,l]),e&&i!==null),(0,j.useEffect)(()=>{if(!e)return;let t=()=>l({kind:`blur`}),n=e=>{let t=Mt(e.target);(oi(t)||t?.inDialog===!0)&&l({kind:`focusChange`})};return window.addEventListener(`blur`,t),document.addEventListener(`focusin`,n,{capture:!0}),()=>{window.removeEventListener(`blur`,t),document.removeEventListener(`focusin`,n,{capture:!0})}},[e,l]),(0,j.useEffect)(()=>{n&&l({kind:`dialogOpen`})},[n,l]),(0,j.useEffect)(()=>{e||l({kind:`disabled`})},[e,l]);let u=(0,j.useRef)(r);return(0,j.useEffect)(()=>{u.current!==r&&(u.current=r,l({kind:`repoChange`}))},[r,l]),(0,j.useEffect)(()=>{if(i)return i.onDisarm(()=>l({kind:`socketReconnect`}))},[i,l]),(0,j.useEffect)(()=>{l({kind:`cancel`})},[t,l]),{state:o,arm:(0,j.useCallback)(()=>l({kind:`arm`}),[l]),disarm:(0,j.useCallback)(()=>l({kind:`cancel`}),[l])}}function ui(e,t){switch(e.kind){case`none`:return;case`run`:t.runAction(e.action);return;case`swapWith`:t.swapPanes(e.pane);return;case`sendLiteralLeader`:e.data&&t.sendLiteralLeader(e.data);return}}var di=`nightcrow.shortcut.leader`;function fi(){let[e,t]=(0,j.useState)(pi),n=(0,j.useCallback)(e=>{t(e),hi(e===null?null:me(e))},[]),r=(0,j.useCallback)(e=>{let t=E(e);return t?(n(t),!0):!1},[n]),i=(0,j.useCallback)(()=>n(null),[n]),a=(0,j.useCallback)(()=>n(re),[n]);return{leader:e,leaderText:e?me(e):``,conflict:e?ve(e):null,setLeader:r,disable:i,reset:a}}function pi(){let e=mi();return e?e.leader===null?null:E(e.leader)??re:re}function mi(){try{let e=localStorage.getItem(di);if(!e)return null;let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t.leader;return n===null?{leader:null}:typeof n==`string`?{leader:n}:null}catch{return null}}function hi(e){try{localStorage.setItem(di,JSON.stringify({leader:e}))}catch{}}function gi({enabled:e,repo:t,repos:n,selectRepo:r,closeRepo:i,openPicker:a,pickerOpen:o,cycleAccent:s,reloadConfig:c,tab:l,chooseTab:u,maximized:d,setMaximized:f,mobileView:p}){let m=we(),h=fi(),[g,_]=(0,j.useState)(!1),v=(0,j.useCallback)(()=>_(!0),[]),y=(0,j.useCallback)(()=>_(!1),[]),b=(0,j.useCallback)(e=>{let i=Wr(n.map(e=>e.id),t,e);i!==null&&r(i)},[n,t,r]),x=m?.zoomActivePane,S=(0,j.useCallback)(()=>{Nt()?(f(e=>e===`terminal`?`none`:`terminal`),x?.()):f(e=>e===`files`?`none`:`files`)},[f,x]),C=(0,j.useCallback)(e=>{let t=m?.paneCursor()??null,n=Pt(),r=null;n===`terminal`?t&&t.index>=0&&(r={kind:`pane`,index:t.index}):n!==null&&(r={kind:n});let i=Vr({at:r,paneCount:t?.count??0,maximized:d,narrow:window.innerWidth<768,mobileView:p},e);i!==null&&(i.kind===`pane`?m?.focusPaneAt(i.index):Ft(i.kind))},[m,d,p]),w=(0,j.useMemo)(()=>{let e={"project.openDialog":a,"session.cycleAccent":s,"session.reloadConfig":c,"help.shortcuts":v};return n.length>1&&(e[`project.previous`]=()=>b(-1),e[`project.next`]=()=>b(1)),t===null||(e[`project.close`]=()=>i(t),e[`view.toggleLog`]=()=>u(l===`log`?`status`:`log`),e[`view.toggleTree`]=()=>u(l===`tree`?`status`:`tree`),e[`view.toggleMaximize`]=S,e[`focus.list`]=()=>void Ft(`list`),e[`focus.content`]=()=>void Ft(`content`),e[`focus.previous`]=()=>C(-1),e[`focus.next`]=()=>C(1)),e},[a,s,c,v,n.length,b,t,l,i,u,S,C]);Te(w);let T=li({enabled:e,leader:h.leader,dialogOpen:o||g,repo:t}),{arm:E,disarm:ee}=T,te=(0,j.useCallback)(e=>{e.kind===`arm`?E():(ee(),m?.runAction(e.action))},[E,ee,m]);return{shortcutHelp:{open:g,show:v,hide:y},settings:h,hint:{state:T.state,onClick:te}}}var _i=1e3,vi=3,yi=2e3;function bi(e,t){let[n,r]=(0,j.useState)(!1),i=(0,j.useRef)(!1),a=(0,j.useRef)(!1);(0,j.useEffect)(()=>(a.current=!1,()=>{a.current=!0}),[]);let o=(0,j.useCallback)(async t=>{for(;!a.current;){if(await new Promise(e=>setTimeout(e,_i)),a.current)return;let n;try{n=await A.cloneStatus(t)}catch(e){if(Ne(e)){i.current=!1,a.current||r(!1);return}if(e instanceof Oe&&e.status===404){if(a.current)return;T.error(`the clone's progress is no longer available`),i.current=!1,r(!1);return}continue}if(a.current)return;if(n.state===`done`){try{let t=await A.open(n.path);if(a.current)return;e(t)}catch(e){if(a.current)return;T.error(e instanceof Error?e.message:`could not open`)}finally{i.current=!1,a.current||r(!1)}return}if(n.state===`failed`){T.error(n.message),i.current=!1,r(!1);return}}},[e]),s=(0,j.useCallback)(async(e=()=>!1)=>{for(let t=0;t0&&await new Promise(e=>setTimeout(e,yi)),i.current||e()||a.current)return;let n;try{({job:n}=await A.runningClone())}catch(e){if(Ne(e))return;continue}if(n===null||e()||a.current||i.current)return;i.current=!0,r(!0),o(n);return}},[o]);return(0,j.useEffect)(()=>{if(!t)return;let e=!1;return s(()=>e),()=>{e=!0}},[t,s]),{busy:n,start:(0,j.useCallback)(async(e,t)=>{if(t.trim()&&!i.current){i.current=!0,r(!0);try{let{job:n}=await A.clone(e,t.trim());await o(n)}catch(e){if(i.current=!1,a.current)return;let t=e instanceof Oe&&e.status>=400;T.error(t?e.message:`could not confirm the clone started — check this folder before retrying`),r(!1),s()}}},[o,s])}}function xi(e,t,n,r=!1){return r&&n&&t.includes(n)?n:e&&t.includes(e)?e:n&&t.includes(n)?n:t[0]??null}function Si(e){let t=!1,n=null,r=()=>{if(t||n===null)return;let i=n;n=null,t=!0,e(i).catch(()=>{}).finally(()=>{t=!1,r()})};return e=>{n=e,r()}}function Ci(e,t){return e?.enabled===t.enabled&&e.window_secs===t.window_secs?e:t}function wi(e,t){return e.length===t.length&&e.every((e,n)=>{let r=t[n];return e.id===r.id&&e.name===r.name&&e.display_path===r.display_path})?e:t}var Ti=`The viewer was updated on the server.`,Ei=null,Di=null,Oi=null;function ki(e,t){return e===null||t===null?!1:e!==t}function Ai(e){Ei=e}function ji(e){ki(Ei,e)?Di!==e&&(Di=e,Oi=T.info(Ti,{sticky:!0,action:{label:`Reload`,run:()=>window.location.reload()}})):e===Ei&&Di!==null&&(Oi!==null&&se(Oi),Di=null,Oi=null)}var Mi=3e3;function Ni({authed:e,setAuthed:t,handle:n,adoptAccent:r,adoptUpperPct:i,adoptMaximized:a,adoptViews:o,upperDraggingRef:s,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,resumeTick:f,orderWrites:p,repoDraggingRef:m,reorderInFlightRef:h,pendingReorderRef:g}){let[_,v]=(0,j.useState)([]),[y,b]=(0,j.useState)(null),[x,S]=(0,j.useState)(null),[C,w]=(0,j.useState)(null),[T,E]=(0,j.useState)(!1),[ee,te]=(0,j.useState)(!0),{current:ne}=(0,j.useRef)(Si(A.setActiveRepo)),re=(0,j.useRef)(null),ie=(0,j.useRef)(null);return(0,j.useEffect)(()=>{if(e===!1)return;let f=!1,_,y=new AbortController,x=()=>{let e=c.current,C=l.current,T=u.current,ee=d.current,ne=p.current;return A.repos(y.signal).then(n=>{let{repos:y,hot:ae,accent:oe,upper_pct:se,active_repo:ce,maximized:le,last_view:ue,now_ms:de,can_clone:fe,viewer_build:pe}=n;if(f)return;ji(pe),S(e=>Ci(e,ae)),te(fe),w(e=>rn(e,de,Date.now())),c.current===e&&r(oe),l.current===C&&!s.current&&i(se),u.current===T&&a(le),d.current===ee&&o(ue??{},y.map(e=>e.id)),t(!0),E(!0);let me=h.current||g.current!==null;p.current===ne&&!m.current&&!me?v(e=>wi(e,y)):v(e=>{let t=ye(y.map(e=>e.id),e.map(e=>e.id)),n=new Map(y.map(e=>[e.id,e]));return wi(e,t.map(e=>n.get(e)).filter(Boolean))});let he=y.map(e=>e.id),ge=ce!==re.current;re.current=ce??null,ge&&ce&&he.includes(ce)&&(ie.current=ce),b(e=>xi(e,he,ce,ge)),f||(_=setTimeout(x,Mi))}).catch(e=>{f||(Ne(e)?(t(!1),E(!1)):(je(e)||n(e),_=setTimeout(x,Mi)))})};return x(),()=>{f=!0,y.abort(),_&&clearTimeout(_)}},[e,t,n,r,i,f,c,l,u,d,s,a,o,p,m,h,g]),(0,j.useEffect)(()=>{y?y!==ie.current&&(ie.current=null,ne(y)):ie.current=null},[y,ne]),{repos:_,setRepos:v,repo:y,setRepo:b,hot:x,clockSkewMs:C,reposLoaded:T,canClone:ee}}var Pi=4;function Fi({ids:e,onReorder:t,draggingRef:n}){let r=(0,j.useRef)(null),i=(0,j.useRef)(null),a=(0,j.useRef)(null),[o,s]=(0,j.useState)(null),[c,l]=(0,j.useState)(null);return{dragging:o,target:c,onStart:(t,a)=>{t.target.closest(`button[data-tab-close]`)||t.button!==0||e.length<2||(r.current=a,i.current={x:t.clientX,y:t.clientY},n.current=!1)},onMove:e=>{let t=r.current,o=i.current;if(t===null||o===null)return;if(!n.current&&e.buttons===0){r.current=null,i.current=null;return}if(!n.current&&Math.hypot(e.clientX-o.x,e.clientY-o.y){let o=r.current,c=a.current;o!==null&&n.current&&c!==null&&t(te(e,o,c)),r.current=null,i.current=null,a.current=null,n.current=!1,s(null),l(null)}}}function Ii({repos:e,setRepos:t,handle:n,writesRef:r,draggingRef:i,inFlightRef:a,pendingRef:o}){let s=(0,j.useCallback)(()=>{if(a.current||o.current===null)return;let e=o.current;o.current=null,a.current=!0;let i=r.current;A.reorderRepos(e).then(e=>{r.current===i&&t(e)}).catch(n).finally(()=>{a.current=!1,s()})},[n,t,a,o,r]),c=(0,j.useCallback)(e=>{r.current+=1,t(t=>{let n=ye(t.map(e=>e.id),e),r=new Map(t.map(e=>[e.id,e]));return n.map(e=>r.get(e)).filter(Boolean)}),o.current=e,s()},[s,t,o,r]);return{...Fi({ids:e.map(e=>e.id),onReorder:c,draggingRef:i}),writesRef:r,draggingRef:i,inFlightRef:a,pendingRef:o}}function Li({authed:e,setAuthed:t,handle:n,resumeTick:r,adoptAccent:i,adoptUpperPct:a,adoptMaximized:o,adoptViews:s,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,upperDraggingRef:f}){let p=(0,j.useRef)(0),m=(0,j.useRef)(!1),h=(0,j.useRef)(!1),g=(0,j.useRef)(null),_=Ni({authed:e,setAuthed:t,handle:n,adoptAccent:i,adoptUpperPct:a,adoptMaximized:o,adoptViews:s,upperDraggingRef:f,accentWrites:c,upperPctWrites:l,maximizedWrites:u,viewWrites:d,resumeTick:r,orderWrites:p,repoDraggingRef:m,reorderInFlightRef:h,pendingReorderRef:g}),{dragging:v,target:y,onStart:b,onMove:x,onEnd:S}=Ii({repos:_.repos,setRepos:_.setRepos,handle:n,writesRef:p,draggingRef:m,inFlightRef:h,pendingRef:g});return{..._,orderWrites:p,draggingRepo:v,dragOverRepo:y,onRepoDragStart:b,onRepoDragMove:x,onRepoDragEnd:S}}function Ri(){let[e,t]=(0,j.useState)(!1),n=(0,j.useRef)(!1);return{reload:(0,j.useCallback)(async()=>{if(!n.current){n.current=!0,t(!0);try{T.success(await A.reloadConfig())}catch(e){T.error(e instanceof Error?e.message:`could not reload the config`)}finally{n.current=!1,t(!1)}}},[]),pending:e}}function zi(e,t){let n=e.indexOf(t);return n===-1?e[0]??null:e[n+1]??e[n-1]??null}function Bi({repo:e,repos:t,setRepos:n,setRepo:r,setPane:i,setTab:a,setPickerOpen:o,handle:s,orderWrites:c}){let l=(0,j.useRef)(t);l.current=t;let u=(0,j.useRef)(e);return u.current=e,{selectOpenedRepo:(0,j.useCallback)(e=>{c.current+=1,n(t=>t.some(t=>t.id===e.id)?t:[...t,e]),r(e.id),e.id!==u.current&&(i({kind:`empty`}),a(`status`)),o(!1)},[n,r,i,a,o,c]),closeRepo:(0,j.useCallback)(async e=>{try{await A.close(e),c.current+=1;let t=zi(l.current.map(e=>e.id),e);n(t=>t.filter(t=>t.id!==e)),r(n=>n===e?t:n)}catch(e){s(e)}},[n,r,s,c])}}function Vi(e,t,n){return t!==e&&(n.bumpPaneRequest(),e===`log`&&n.leaveLog(),n.recordTab(t),n.forgetPane(),!0)}function Hi(e,t,n,r,i){(0,j.useLayoutEffect)(()=>{t&&(e.some(e=>e.oid===t.commit.oid)||(r(),n(null),i()))},[e,t,n,r,i])}var Ui=5e3,Wi={refs:{},ahead:[],behind:[],truncated:!1};function Gi({repo:e,authed:t,tab:n,head:r,branch:i,refs:a,upstream:o}){let[s,c]=(0,j.useState)({key:``,value:Wi}),[l,u]=(0,j.useState)(0),d=e&&r!==void 0?`${e}|${r??``}|${i??``}|${a??``}|${o??``}`:``,f=(0,j.useRef)(s.key);f.current=s.key,(0,j.useEffect)(()=>{if(!e||!t||n!==`log`||d===``||f.current===d)return;let r=new AbortController,i;return A.logDecorations(e,r.signal).then(e=>c({key:d,value:e})).catch(()=>{r.signal.aborted||(i=setTimeout(()=>u(e=>e+1),Ui))}),()=>{r.abort(),i&&clearTimeout(i)}},[e,t,n,d,l]);let p=s.key.startsWith(`${e}|`)?s.value:Wi;return(0,j.useMemo)(()=>{let e=new Set(p.ahead),t=new Set(p.behind);return{refsOf:e=>p.refs[e],divergenceOf:n=>e.has(n)?`ahead`:t.has(n)?`behind`:void 0,truncated:p.truncated}},[p])}function Ki(e,t,n){let r=!e.truncated||e.head===void 0,i=t[0]?.oid,a=i===void 0?-1:e.commits.findIndex(e=>e.oid===i),o=a<0?[]:e.commits.slice(a);return a>=0&&o.length<=t.length&&o.every((e,n)=>e.oid===t[n].oid)?{commits:a===0?t:[...e.commits.slice(0,a),...t],anchor:e.head??null,done:n||r,mode:`prepend`}:{commits:e.commits,anchor:e.head??null,done:r,mode:`replace`}}function qi({repo:e,authed:t,tab:n,filter:r,head:i,handle:a}){let o=(0,j.useRef)([]),[,s]=(0,j.useState)(0),c=(0,j.useCallback)(()=>s(e=>e+1),[]),l=o.current,[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)(!1),m=(0,j.useRef)(null),h=(0,j.useRef)(!1),g=(0,j.useRef)(!1),_=(0,j.useRef)(0),v=(0,j.useRef)(void 0),y=(0,j.useRef)(void 0),b=(0,j.useCallback)(()=>{_.current+=1,h.current=!1,g.current=!1,o.current=[],c(),m.current=null,d(!1),p(!1),v.current=void 0,y.current=void 0},[c]),[x,S]=(0,j.useState)(null),C=(0,j.useRef)(u);C.current=u;let w=(0,j.useRef)(i);w.current=i;let T=(0,j.useCallback)(async t=>{if(!e)return;y.current=w.current,_.current+=1;let n=_.current;h.current=!0,g.current=!0;try{let r=await A.log(e);if(n!==_.current)return;let i=t??{commits:o.current,done:C.current},a=Ki(r,i.commits,i.done);o.current=a.commits,c(),m.current=a.anchor,v.current=a.anchor,a.anchor===w.current&&(y.current=void 0),d(a.done),p(!1)}catch(e){n===_.current&&(y.current=void 0,a(e),p(!0))}finally{n===_.current&&(h.current=!1,g.current=!1)}},[e,a,c]),E=(0,j.useCallback)(async()=>{if(!e||h.current)return;h.current=!0;let t=_.current;try{let n=m.current,r=await A.log(e,n===null?void 0:{from:n,skip:o.current.length});if(t!==_.current)return;if(o.current.push(...r.commits),c(),m.current=r.head??null,d(!r.truncated||r.head===void 0),n===null){v.current=r.head??null;let e=w.current;e!==void 0&&e!==(r.head??null)&&T({commits:r.commits,done:!r.truncated||r.head===void 0})}}catch(e){t===_.current&&(a(e),p(!0))}finally{t===_.current&&(h.current=!1)}},[e,a,T,c]);(0,j.useEffect)(()=>{e&&t&&n===`log`&&l.length===0&&!u&&!f&&E()},[e,t,n,l.length,u,f,E]),(0,j.useEffect)(()=>{if(!e||!t||n!==`log`||i===void 0||f)return;let r=v.current;r!==void 0&&(r===i?g.current||(y.current=void 0):y.current!==i&&T())},[e,t,n,i,f,T]);let ee=r.toLowerCase(),te=ee===``?l:l.filter(e=>e.summary.toLowerCase().includes(ee)),ne=r!==``,re=(0,j.useRef)(null);return(0,j.useEffect)(()=>{let e=re.current;if(!e)return;let t=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&E()},{root:e.closest(`ul`),rootMargin:`400px`});return t.observe(e),()=>t.disconnect()},[E,u,f,ne,x,n,te.length]),{commits:l,logDone:u,logStalled:f,setLogStalled:p,commitDrillDown:x,setCommitDrillDown:S,resetLog:b,logSentinelRef:re,visibleCommits:te,logPagingPaused:ne}}function Ji(e,t){return[t??``,e.index,e.worktree,e.mtime??``,e.old_path??``].join(`\0`)}function Yi({repo:e,authed:t,resumeTick:n,tab:r,pane:i,setPane:a,handle:o,paneRequestRef:s}){let[c,l]=(0,j.useState)(null),u=(0,j.useRef)(i);u.current=i;let d=(0,j.useRef)(r);d.current=r;let f=(0,j.useRef)(null),p=(0,j.useRef)(null);return(0,j.useLayoutEffect)(()=>{l(null),p.current=null},[e,t]),(0,j.useEffect)(()=>{if(e&&t)return Ae(e,l,({reason:e})=>l({files:[],truncated:!1,unavailable:e}))},[e,t,n]),(0,j.useEffect)(()=>{if(!e||!c)return;let t=p.current;p.current=new Map(c.files.map(e=>[e.path,Ji(e,c.head)]));let n=u.current;if(d.current!==`status`||n.kind!==`diff`){f.current=null;return}let r=n.value.path,i=c.files.find(e=>e.path===r);if(!i){f.current=null,a({kind:`empty`});return}let l=Ji(i,c.head),m=f.current;if(m?.path===r&&m.key===l)return;if(m?.path!==r&&t?.get(r)===l){f.current={path:r,key:l};return}let h=s.current,g=!0,_=()=>{let e=u.current;return g&&h===s.current&&e.kind===`diff`&&e.value.path===r};return A.diff(e,r).then(e=>{_()&&(f.current={path:r,key:l},a({kind:`diff`,value:e,source:In(i)&&Ln(e)?{kind:`workdir`,path:r}:void 0}))}).catch(e=>{_()&&o(e)}),()=>{g=!1}},[c,e,o,u,d,s,a]),{status:c,paneRef:u,tabRef:d}}function Xi({repo:e,authed:t,hot:n,clockSkewMs:r,resumeTick:i,handle:a}){let[o,s]=(0,j.useState)(`status`),[c,l]=(0,j.useState)(``),[u,d]=(0,j.useState)(!1),[f,p]=(0,j.useState)({kind:`empty`}),[m,h]=(0,j.useState)(e);m!==e&&(h(e),p({kind:`empty`}),s(`status`));let g=(0,j.useRef)(0),_=(0,j.useCallback)(()=>{g.current+=1},[]),v=(0,j.useCallback)(()=>p({kind:`empty`}),[]),{status:y}=Yi({repo:e,authed:t,resumeTick:i,tab:o,pane:f,setPane:p,handle:a,paneRequestRef:g}),b=n?.enabled?n.window_secs*1e3:0,x=qi({repo:e,authed:t,tab:o,filter:c,head:y?y.head??null:void 0,handle:a}),S=Gi({repo:e,authed:t,tab:o,head:y?y.head??null:void 0,branch:y?.branch,refs:y?.refs,upstream:y?.tracking?.upstream}),C=x.setCommitDrillDown,w=x.resetLog;(0,j.useLayoutEffect)(()=>{_(),C(null),w()},[e,_,C,w]);let T=c.toLowerCase(),E=(0,j.useMemo)(()=>(y?.files??[]).filter(e=>e.path.toLowerCase().includes(T)),[y?.files,T]),ee=(0,j.useMemo)(()=>(x.commitDrillDown?.files??[]).filter(e=>e.path.toLowerCase().includes(T)||e.old_path?.toLowerCase().includes(T)),[x.commitDrillDown?.files,T]);return{screen:{tab:o,setTab:s,filter:c,setFilter:l,filterOpen:u,setFilterOpen:d,pane:f,setPane:p},request:{paneRequestRef:g,bumpPaneRequest:_,clearPane:v},status:{value:y,files:E,hotWindowMs:b,clockSkewMs:r??0},log:{...x,decorations:S,visibleCommitFiles:ee}}}var Zi=`nightcrow.mobileView`;function Qi(e){return e===`diff`||e===`terminal`||e===`files`?e:`files`}function $i(){return Qi(m(Zi))}function ea(){let[e,t]=(0,j.useState)($i);return{mobileView:e,setMobileView:(0,j.useCallback)(e=>{h(Zi,e),t(e)},[])}}function ta({repo:e,handle:t,setPane:n,paneRequestRef:r,setCommitDrillDown:i,setMobileView:a,setPreviewRendered:o,statusRef:s,track:c}){let l=(0,j.useCallback)(e=>{let t=s.current?.files.find(t=>t.path===e);return t?In(t):!1},[s]);return{openDiff:(0,j.useCallback)((i,o)=>{if(!e)return;o?.restoring||a(`diff`);let s=r.current+=1;c(s,A.diff(e,i)).then(e=>{s===r.current&&n({kind:`diff`,value:e,source:l(i)&&Ln(e)?{kind:`workdir`,path:i}:void 0})}).catch(e=>{if(s!==r.current)return Ne(e)?t(e):void 0;if(!o?.restoring)return t(e);Ne(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,l,c]),openFile:(0,j.useCallback)((i,s)=>{if(!e)return;s?.restoring||a(`diff`),o(!0);let l=r.current+=1;c(l,A.file(e,i)).then(e=>{l===r.current&&n({kind:`file`,value:e})}).catch(e=>{if(l!==r.current)return Ne(e)?t(e):void 0;if(!s?.restoring)return t(e);Ne(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,o,c]),openCommit:(0,j.useCallback)(i=>{if(!e)return;a(`diff`);let o=r.current+=1;c(o,A.commit(e,i)).then(e=>{o===r.current&&n({kind:`diff`,value:e})}).catch(e=>{o===r.current&&t(e)})},[e,t,n,r,a,c]),openCommitFileDiff:(0,j.useCallback)((i,o,s)=>{if(!e)return;s?.restoring||a(`diff`);let l=r.current+=1;c(l,A.commitFileDiff(e,i,o)).then(e=>{l===r.current&&n({kind:`diff`,value:e,source:Ln(e)?{kind:`commit`,oid:i,path:o}:void 0})}).catch(e=>{if(l!==r.current)return Ne(e)?t(e):void 0;if(!s?.restoring)return t(e);Ne(e)&&t(e),n({kind:`empty`})})},[e,t,n,r,a,c]),openCommitFiles:(0,j.useCallback)(async o=>{if(!e)return;a(`diff`);let s=r.current+=1;try{let t=await c(s,A.commitFiles(e,o.oid));if(s!==r.current)return;if(i({commit:o,...t}),t.files.length===0){n({kind:`empty`});return}let a=await c(s,A.commit(e,o.oid));s===r.current&&n({kind:`diff`,value:a})}catch(e){s===r.current&&t(e)}},[e,t,n,r,i,a,c]),showOtherFace:(0,j.useCallback)((i,a=0)=>{let s=Fn(i);if(!e||!s)return;let{source:u}=s,d=s.want===`file`,f=d&&i.kind===`diff`?jn(i.value,a):null,p=r.current+=1,m=u.kind===`workdir`?d?A.file(e,u.path):A.diff(e,u.path):d?A.commitFile(e,u.oid,u.path):A.commitFileDiff(e,u.oid,u.path);d&&o(!1),c(p,m).then(e=>{p===r.current&&n(d?{kind:`file`,value:e,source:u,anchor:f===null?void 0:Mn(f)+1}:{kind:`diff`,value:e,source:Ln(e)&&(u.kind!==`workdir`||l(u.path))?u:void 0})}).catch(e=>{p===r.current&&t(e)})},[e,t,n,r,o,l,c])}}function na(){let[e,t]=(0,j.useState)(null),n=(0,j.useCallback)((e,n)=>{t(e);let r=()=>t(t=>t===e?null:t);return n.then(r,r),n},[]);return{loading:e!==null,track:n}}function ra({repo:e,handle:t,pane:n,setPane:r,paneRequestRef:i,setCommitDrillDown:a,status:o}){let{mobileView:s,setMobileView:c}=ea(),[l,u]=(0,j.useState)(!0),{loading:d,track:f}=na(),p=(0,j.useRef)(o);p.current=o;let{openDiff:m,openFile:h,openCommit:g,openCommitFileDiff:_,openCommitFiles:v,showOtherFace:y}=ta({repo:e,handle:t,setPane:r,paneRequestRef:i,setCommitDrillDown:a,setMobileView:c,setPreviewRendered:u,statusRef:p,track:f}),b=(0,j.useMemo)(()=>({openDiff:m,openFile:h,openCommit:g,openCommitFileDiff:_,openCommitFiles:v,showOtherFace:y}),[m,h,g,_,v,y]);return(0,j.useMemo)(()=>({openers:b,pane:n,setPane:r,paneLoading:d,previewRendered:l,setPreviewRendered:u,mobileView:s,setMobileView:c}),[b,n,r,d,l,s,c])}var ia=[`status`,`log`,`tree`];function aa(){return{tab:`status`,file:null,tree_expanded:[]}}function oa(e,t){return{path:e,commit:null,face:t}}function sa(e,t,n){return{path:t,commit:e,face:n}}function ca(e){return[...e].sort().slice(0,200)}function F(e){let t=e?.file;return!t||!t.path?{kind:`none`}:t.commit?{kind:`commitDiff`,oid:t.commit,path:t.path}:t.face===`source`?{kind:`file`,path:t.path}:{kind:`diff`,path:t.path}}function I(e){let t=e?.tab;return t&&ia.includes(t)?t:`status`}function la(e,t){return e?e.tab===t.tab&&e.tree_expanded.length===t.tree_expanded.length&&e.tree_expanded.every((e,n)=>e===t.tree_expanded[n])&&ua(e.file,t.file):!1}function ua(e,t){return!e||!t?e===t:e.path===t.path&&e.commit===t.commit&&e.face===t.face}function da({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,openDiff:o,openFile:s,openCommitFileDiff:c}){let l=(0,j.useRef)(null),u=(0,j.useRef)(null),d=(0,j.useRef)(new Map),[f,p]=(0,j.useState)(!1),m=(0,j.useRef)(!1);(0,j.useEffect)(()=>{if(u.current!==e&&(u.current=e,l.current=null,m.current=!1,p(!1)),!e||!t||l.current===e)return;l.current=e;let r=d.current.get(e);d.current.delete(e);let f=r?{...n??aa(),...r}:n;if(r&&i(e,f),m.current)return;a(I(f));let h=F(f);if(h.kind===`none`)return;let g={restoring:!0};h.kind===`diff`?o(h.path,g):h.kind===`file`?s(h.path,g):c(h.oid,h.path,g)},[e,t,n,i,a,o,s,c]);let h=(0,j.useCallback)(t=>{if(e){if(m.current=!0,p(!0),l.current!==e){let n=d.current.get(e);d.current.set(e,{...n,...t})}else i(e,{...r(e)??aa(),...t})}},[e,r,i]);return{touched:f,noteTab:(0,j.useCallback)(e=>h({tab:e}),[h]),noteFile:(0,j.useCallback)(e=>h({file:e}),[h]),noteTree:(0,j.useCallback)(e=>h({tree_expanded:ca(e)}),[h])}}function fa({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,clearPane:o,openers:s}){let c=da({repo:e,known:t,remembered:n,latest:r,remember:i,setTab:a,openDiff:s.openDiff,openFile:s.openFile,openCommitFileDiff:s.openCommitFileDiff}),{noteFile:l,noteTab:u,noteTree:d}=c,f=(0,j.useCallback)(e=>{u(e),a(e)},[u,a]),p=(0,j.useCallback)(()=>{l(null),o()},[l,o]),m=(0,j.useMemo)(()=>({openDiff:e=>{l(oa(e,`diff`)),s.openDiff(e)},openFile:e=>{l(oa(e,`source`)),s.openFile(e)},openCommit:e=>{l(null),s.openCommit(e)},openCommitFiles:e=>(l(null),s.openCommitFiles(e)),openCommitFileDiff:(e,t)=>{l(sa(e,t,`diff`)),s.openCommitFileDiff(e,t)}}),[s,l]),h=(0,j.useCallback)((e,t)=>{l(e.kind===`commit`?sa(e.oid,e.path,t):oa(e.path,t))},[l]);return{...c,noteTree:d,chooseTab:f,forgetPane:p,asked:m,noteOtherFace:h}}function pa({project:e,view:t,layout:n}){let{repo:r,repos:i,authed:a,hot:o,clockSkewMs:s,resumeTick:c,handle:l}=e,u=Xi({repo:r,authed:a,hot:o,clockSkewMs:s,resumeTick:c,handle:l}),d=ra({repo:r,handle:l,pane:u.screen.pane,setPane:u.screen.setPane,paneRequestRef:u.request.paneRequestRef,setCommitDrillDown:u.log.setCommitDrillDown,status:u.status.value}),f=fa({repo:r,known:t.known,remembered:t.remembered,latest:t.latest,remember:t.remember,setTab:u.screen.setTab,clearPane:u.request.clearPane,openers:d.openers}),p=u.screen.tab,{bumpPaneRequest:m}=u.request,{setCommitDrillDown:h,resetLog:g}=u.log,{chooseTab:_,forgetPane:v}=f,y=(0,j.useCallback)(e=>void Vi(p,e,{bumpPaneRequest:m,leaveLog:()=>{h(null),g()},recordTab:_,forgetPane:v}),[p,m,h,g,_,v]);Hi(u.log.commits,u.log.commitDrillDown,u.log.setCommitDrillDown,u.request.bumpPaneRequest,f.forgetPane);let b=n.maximizedPanelOf(r),x=n.setMaximizedFor,S=(0,j.useCallback)(e=>x(r,e),[r,x]),C=d.pane,w=d.openers.showOtherFace,T=f.noteOtherFace,E=(0,j.useCallback)(e=>{let t=Fn(C);t&&T(t.source,t.want===`file`?`source`:`diff`),w(C,e)},[C,T,w]);return{setPane:d.setPane,setTab:u.screen.setTab,clearPane:u.request.clearPane,maximized:b,tab:p,chooseTab:y,setMaximized:S,repoShell:r?{repository:{id:r,current:i.find(e=>e.id===r),status:u.status.value},sidebar:{tab:u.screen.tab,filter:u.screen.filter,setFilter:u.screen.setFilter,filterOpen:u.screen.filterOpen,setFilterOpen:u.screen.setFilterOpen,files:u.status.files,hotWindowMs:u.status.hotWindowMs,clockSkewMs:u.status.clockSkewMs,...d.openers,...f.asked,chooseTab:y,authed:a,handle:l,bumpPaneRequest:u.request.bumpPaneRequest,...u.log,restoreTree:t.remembered?.tree_expanded??[],restoreKnown:t.known,onTreeExpanded:f.noteTree,clearPane:f.forgetPane,touched:f.touched},filePane:{repo:r,pane:d.pane,loading:d.paneLoading,previewRendered:d.previewRendered,setPreviewRendered:d.setPreviewRendered,showOtherFace:E},layout:{...n.shell,maximized:b,setMaximized:S,mobileView:d.mobileView,setMobileView:d.setMobileView}}:null}}function ma(){let[e,t]=(0,j.useState)(0);return(0,j.useEffect)(()=>{let e=()=>{document.visibilityState===`visible`&&t(e=>e+1)};return document.addEventListener(`visibilitychange`,e),window.addEventListener(`online`,e),()=>{document.removeEventListener(`visibilitychange`,e),window.removeEventListener(`online`,e)}},[]),e}var ha=[{name:`yellow`,color:`#d9a441`},{name:`cyan`,color:`#03c4db`},{name:`green`,color:`#77c47a`},{name:`magenta`,color:`#dc8fd5`},{name:`blue`,color:`#87acfd`}],ga=`nightcrow.viewer.accent`;function _a(e){if(!Number.isFinite(e))return 0;let t=ha.length;return(Math.trunc(e)%t+t)%t}function va(){let e=m(ga);return e===null?0:_a(Number(e))}function ya(e){h(ga,String(e))}function ba(){let[e,t]=(0,j.useState)(va);(0,j.useLayoutEffect)(()=>{document.documentElement.style.setProperty(`--color-accent`,ha[e].color)},[e]);let n=(0,j.useCallback)(()=>{t(e=>{let t=_a(e+1);return ya(t),A.setAccent(t).catch(()=>{}),t})},[]),r=(0,j.useCallback)(e=>{t(t=>{let n=_a(e);return n===t?t:(ya(n),n)})},[]);return{accent:ha[e],next:ha[_a(e+1)],cycle:n,adopt:r}}function xa(e){return Number.isFinite(e)?Math.min(Math.max(e,20),85):55}function Sa(e){return Math.round(xa(e))}function Ca(e,t,n,r){let i=n-t;return xa(i<=0?r:(e-t)/i*100)}var wa=`nightcrow.upperPct`;function Ta(){try{let e=Number(localStorage.getItem(wa));return Number.isFinite(e)&&e>0?Sa(e):55}catch{return 55}}function Ea(e){try{localStorage.setItem(wa,String(e))}catch{}}function Da(){let[e,t]=(0,j.useState)(Ta);return{pct:e,resize:(0,j.useCallback)(e=>{t(xa(e))},[]),commit:(0,j.useCallback)(e=>{let n=Sa(e);t(n),Ea(n),A.setUpperPct(n).catch(()=>{})},[]),reset:(0,j.useCallback)(()=>{t(55),Ea(55),A.setUpperPct(55).catch(()=>{})},[]),adopt:(0,j.useCallback)(e=>{t(t=>{let n=Sa(e);return n===t?t:(Ea(n),n)})},[])}}function Oa(){let[e,t]=(0,j.useState)({}),n=(0,j.useRef)(e),r=(0,j.useCallback)(e=>{n.current=e,t(e)},[]),i=(0,j.useRef)(0),a=(0,j.useRef)(new Map),o=(0,j.useCallback)(e=>{let t=a.current.get(e);if(t)return t;let n=Si(t=>A.setMaximized(e,t===`none`?null:t));return a.current.set(e,n),n},[]),s=(0,j.useCallback)((e,t)=>{if(e==null)return;let a=n.current,s=typeof t==`function`?t(a[e]??`none`):t;i.current+=1,o(e)(s);let{[e]:c,...l}=a;r(s===`none`?l:{...a,[e]:s})},[o,r]);return{panelOf:(0,j.useCallback)(t=>t!=null&&e[t]||`none`,[e]),setFor:s,adopt:(0,j.useCallback)(e=>{ka(n.current,e)||r(e)},[r]),writes:i}}function ka(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>e[n]===t[n])}function Aa(){let[e,t]=(0,j.useState)({}),n=(0,j.useRef)(e),r=(0,j.useCallback)(e=>{n.current=e,t(e)},[]),i=(0,j.useRef)(0),a=(0,j.useRef)(new Map),o=(0,j.useCallback)(e=>{let t=a.current.get(e);if(t)return t;let n=Si(t=>A.setRepoView(e,t));return a.current.set(e,n),n},[]),s=(0,j.useCallback)((e,t)=>{e!=null&&(la(n.current[e],t)||(i.current+=1,o(e)(t),r({...n.current,[e]:t})))},[o,r]),c=(0,j.useCallback)(t=>t==null?void 0:e[t],[e]),l=(0,j.useCallback)(e=>n.current[e],[]),u=(0,j.useRef)(new Set),[d,f]=(0,j.useState)(0);return{viewOf:c,rememberedFor:l,remember:s,adopt:(0,j.useCallback)((e,t)=>{let i=u.current;(i.size!==t.length||t.some(e=>!i.has(e)))&&(u.current=new Set(t),f(e=>e+1)),!ja(n.current,e)&&r(e)},[r]),covers:(0,j.useCallback)(e=>e!=null&&u.current.has(e),[d]),writes:i}}function ja(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>t[n]!==void 0&&la(e[n],t[n]))}function Ma(){let{accent:e,next:t,cycle:n,adopt:r}=ba(),{width:i,resize:a,commit:o,reset:s}=Et(),{pct:c,resize:l,commit:u,reset:d,adopt:f}=Da(),p=Oa(),m=Aa(),h=(0,j.useRef)(0),g=(0,j.useRef)(0);return{accent:e,next:t,cycle:(0,j.useCallback)(()=>{h.current+=1,n()},[n]),adoptAccent:r,accentWrites:h,sidebarWidth:i,resizeSidebar:a,commitSidebarWidth:o,resetSidebarWidth:s,upperPct:c,resizeUpperPct:l,commitUpperPct:(0,j.useCallback)(e=>{g.current+=1,u(e)},[u]),resetUpperPct:(0,j.useCallback)(()=>{g.current+=1,d()},[d]),bumpUpperPctWrites:(0,j.useCallback)(()=>{g.current+=1},[]),adoptUpperPct:f,upperPctWrites:g,maximizedPanelOf:p.panelOf,setMaximizedFor:p.setFor,adoptMaximized:p.adopt,maximizedWrites:p.writes,viewOf:m.viewOf,rememberedViewFor:m.rememberedFor,rememberView:m.remember,adoptViews:m.adopt,viewCovers:m.covers,viewWrites:m.writes}}var Na=400;function Pa({value:e,valueAt:t,onGestureStart:n,resize:r,commit:i,reset:a,axis:o}){let s=(0,j.useRef)(0),c=(0,j.useRef)(0),l=(0,j.useRef)(!1),u=(0,j.useRef)(!1),d=(0,j.useRef)(0),[f,p]=(0,j.useState)(!1);return{dragging:f,onDragStart:(0,j.useCallback)(t=>{t.button===0&&t.isPrimary&&n()&&(s.current=o===`x`?t.clientX:t.clientY,c.current=e,l.current=!0,u.current=!1,p(!0),t.currentTarget.setPointerCapture(t.pointerId),t.preventDefault())},[e,n,o]),onDragMove:(0,j.useCallback)(e=>{if(!l.current)return;let n=o===`x`?e.clientX:e.clientY;if(!u.current&&Math.abs(n-s.current)<3)return;let i=t(e);i!==null&&(u.current=!0,c.current=i,r(i))},[t,r,o]),onDragEnd:(0,j.useCallback)(()=>{if(!l.current)return;if(l.current=!1,p(!1),u.current){i(c.current),d.current=0;return}let e=Date.now();e-d.current{l.current=!1,u.current=!1,d.current=0,p(!1)},[]),draggingRef:l}}function L({sidebarRef:e,sidebarWidth:t,resizeSidebar:n,commitSidebarWidth:r,resetSidebarWidth:i}){let a=(0,j.useRef)(0),o=(0,j.useCallback)(()=>{let t=e.current?.getBoundingClientRect().left;return t!==void 0&&(a.current=t,!0)},[e]),{dragging:s,onDragStart:c,onDragMove:l,onDragEnd:u,onDragCancel:d}=Pa({value:t,valueAt:(0,j.useCallback)(e=>e.clientX-a.current,[]),onGestureStart:o,resize:n,commit:r,reset:i,axis:`x`});return{draggingSidebar:s,onSidebarDragStart:c,onSidebarDragMove:l,onSidebarDragEnd:u,onSidebarDragCancel:d}}function Fa({upperRef:e,lowerRef:t,upperPct:n,resizeUpperPct:r,commitUpperPct:i,resetUpperPct:a,bumpUpperPctWrites:o}){let s=(0,j.useRef)(0),c=(0,j.useRef)(0),l=(0,j.useCallback)(()=>{let n=e.current?.getBoundingClientRect().top,r=t.current?.getBoundingClientRect().bottom;return n===void 0||r===void 0?!1:(s.current=n,c.current=r,o(),!0)},[e,t,o]),{dragging:u,onDragStart:d,onDragMove:f,onDragEnd:p,onDragCancel:m,draggingRef:h}=Pa({value:n,valueAt:(0,j.useCallback)(e=>Ca(e.clientY,s.current,c.current,n),[n]),onGestureStart:l,resize:r,commit:i,reset:a,axis:`y`});return{draggingUpper:u,onUpperDragStart:d,onUpperDragMove:f,onUpperDragEnd:p,onUpperDragCancel:m,upperDraggingRef:h}}function Ia(){let{accent:e,next:t,cycle:n,adoptAccent:r,accentWrites:i,sidebarWidth:a,resizeSidebar:o,commitSidebarWidth:s,resetSidebarWidth:c,upperPct:l,resizeUpperPct:u,commitUpperPct:d,resetUpperPct:f,bumpUpperPctWrites:p,adoptUpperPct:m,upperPctWrites:h,maximizedPanelOf:g,setMaximizedFor:_,adoptMaximized:v,maximizedWrites:y,viewOf:b,rememberedViewFor:x,rememberView:S,adoptViews:C,viewCovers:w,viewWrites:T}=Ma(),E=(0,j.useRef)(null),ee=(0,j.useRef)(null),te=(0,j.useRef)(null),ne=L({sidebarRef:E,sidebarWidth:a,resizeSidebar:o,commitSidebarWidth:s,resetSidebarWidth:c}),re=Fa({upperRef:ee,lowerRef:te,upperPct:l,resizeUpperPct:u,commitUpperPct:d,resetUpperPct:f,bumpUpperPctWrites:p});return{accent:e,next:t,cycle:n,upperPct:l,maximizedPanelOf:g,setMaximizedFor:_,viewOf:b,rememberedViewFor:x,rememberView:S,viewCovers:w,shell:{sidebarWidth:a,sidebarRef:E,upperRef:ee,lowerRef:te,draggingSidebar:ne.draggingSidebar,onSidebarDragStart:ne.onSidebarDragStart,onSidebarDragMove:ne.onSidebarDragMove,onSidebarDragEnd:ne.onSidebarDragEnd,onSidebarDragCancel:ne.onSidebarDragCancel,draggingUpper:re.draggingUpper,onUpperDragStart:re.onUpperDragStart,onUpperDragMove:re.onUpperDragMove,onUpperDragEnd:re.onUpperDragEnd,onUpperDragCancel:re.onUpperDragCancel},guards:{adoptAccent:r,adoptUpperPct:m,adoptMaximized:v,adoptViews:C,accentWrites:i,upperPctWrites:h,maximizedWrites:y,viewWrites:T,upperDraggingRef:re.upperDraggingRef}}}var La=`nightcrow.tabStripSide`;function Ra(){return ft(m(La))??`top`}function za(e){h(La,e)}function Ba(){let[e,t]=(0,j.useState)(Ra);return{side:e,toggle:(0,j.useCallback)(()=>{t(e=>{let t=pt(e);return za(t),t})},[])}}function Va(){let[e,t]=(0,j.useState)(null),[n,r]=(0,j.useState)(!1),[i,a]=(0,j.useState)(null),o=(0,j.useCallback)(e=>{Ne(e)?t(!1):T.error(e instanceof Error?e.message:`request failed`)},[]),s=ma(),c=Ia(),l=Ba(),u=Li({authed:e,setAuthed:t,handle:o,resumeTick:s,...c.guards}),d=pa({project:{repo:u.repo,repos:u.repos,authed:e,hot:u.hot,clockSkewMs:u.clockSkewMs,resumeTick:s,handle:o},view:{known:c.viewCovers(u.repo),remembered:c.viewOf(u.repo),latest:c.rememberedViewFor,remember:c.rememberView},layout:{shell:c.shell,maximizedPanelOf:c.maximizedPanelOf,setMaximizedFor:c.setMaximizedFor}}),{selectOpenedRepo:f,closeRepo:p}=Bi({repo:u.repo,repos:u.repos,setRepos:u.setRepos,setRepo:u.setRepo,setPane:d.setPane,setTab:d.setTab,setPickerOpen:r,handle:o,orderWrites:u.orderWrites}),{busy:m,start:h}=bi(f,e===!0),g=u.repo,_=u.setRepo,v=d.clearPane,y=(0,j.useCallback)(e=>{e!==g&&(_(e),v())},[g,_,v]),b=u.repos.find(e=>e.id===i),x=(0,j.useCallback)(()=>a(null),[]),S=(0,j.useCallback)(()=>r(!0),[]),C=(0,j.useCallback)(()=>r(!1),[]),w=Ri(),E=gi({enabled:e===!0,repo:u.repo,repos:u.repos,selectRepo:y,closeRepo:p,openPicker:S,pickerOpen:n,cycleAccent:c.cycle,reloadConfig:w.reload,tab:d.tab,chooseTab:d.chooseTab,maximized:d.maximized,setMaximized:d.setMaximized,mobileView:d.repoShell?.layout.mobileView??`files`});return{authed:e,login:(0,j.useCallback)(()=>t(null),[]),reposLoaded:u.reposLoaded,rows:Br(u.repo,d.maximized),upperPct:c.upperPct,header:{repos:u.repos,repo:u.repo,onSelectRepo:y,onCloseRepo:a,onOpenPicker:S,cloning:m,accent:c.accent,next:c.next,cycle:c.cycle,draggingRepo:u.draggingRepo,dragOverRepo:u.dragOverRepo,onRepoDragStart:u.onRepoDragStart,onRepoDragMove:u.onRepoDragMove,onRepoDragEnd:u.onRepoDragEnd,onReloadConfig:w.reload,reloading:w.pending,tabStrip:l},tabStrip:l,shortcutHelp:E.shortcutHelp,leader:E.settings,hint:E.hint,repoShell:d.repoShell,closeConfirm:b?{label:b.name,detail:`Its terminals and the processes running in them will be terminated.`,onConfirm:()=>{a(null),p(b.id)},onCancel:x}:null,picker:n?{onClose:C,onOpened:f,canClone:u.canClone,cloning:m,onClone:h}:null}}function Ha(){let e=Va();return e.authed===null?(0,M.jsx)(vt,{}):e.authed?e.reposLoaded?(0,M.jsx)(g,{children:(0,M.jsx)(ae,{children:(0,M.jsx)(x,{leader:e.leader.leader,children:(0,M.jsxs)(`div`,{className:`nc-fade-in flex h-full flex-col`,children:[(0,M.jsx)(mt,{...e.header,onShowShortcuts:e.shortcutHelp.show}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[e.tabStrip.side===`left`&&(0,M.jsx)(`aside`,{className:`hidden w-48 shrink-0 flex-col border-r border-chrome-line bg-ink-950 md:flex`,children:(0,M.jsx)(qe,{side:`left`,...e.header})}),(0,M.jsxs)(`div`,{className:`grid min-h-0 min-w-0 flex-1 grid-cols-[minmax(0,1fr)] ${e.rows}`,style:{"--nc-upper":`${e.upperPct}fr`,"--nc-lower":`${100-e.upperPct}fr`},children:[e.repoShell?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(yr,{...e.repoShell}),(0,M.jsx)(Rr,{...e.hint})]}):(0,M.jsxs)(`div`,{className:`flex items-center justify-center p-6 text-center text-ink-400`,children:[(0,M.jsxs)(`span`,{className:`md:hidden`,children:[`No repository open. Tap`,` `,(0,M.jsx)(`span`,{className:`text-ink-200`,children:`No project`}),` above, then`,` `,(0,M.jsx)(`span`,{className:`text-ink-200`,children:`+ open`}),`, to add one.`]}),(0,M.jsxs)(`span`,{className:`hidden md:inline`,children:[`No repository open. Click`,` `,(0,M.jsx)(`span`,{className:`text-ink-200`,children:`+ open`}),` `,e.tabStrip.side===`left`?`beside`:`above`,` to add one.`]})]}),e.picker&&(0,M.jsx)(Re,{...e.picker}),e.closeConfirm&&(0,M.jsx)(Se,{...e.closeConfirm}),e.shortcutHelp.open&&(0,M.jsx)(Dr,{onClose:e.shortcutHelp.hide,leader:e.leader})]})]})]})})})}):(0,M.jsx)(vt,{}):(0,M.jsx)(yt,{onSuccess:e.login})}var Ua={error:7e3,info:5e3,success:5e3},Wa={error:`text-removed`,info:`text-accent`,success:`text-added`};function Ga(){let[e,t]=(0,j.useState)([]);return(0,j.useEffect)(()=>oe(t),[]),e.length===0?null:(0,M.jsx)(`div`,{className:`pointer-events-none fixed right-3 top-3 z-[60] flex w-80 max-w-[calc(100vw-1.5rem)] flex-col gap-2`,"aria-live":`polite`,children:e.map(e=>(0,M.jsx)(Ka,{toast:e},e.id))})}function Ka({toast:e}){let[t,n]=(0,j.useState)(!1);return(0,j.useEffect)(()=>{if(t||e.sticky)return;let n=setTimeout(()=>se(e.id),Ua[e.kind]);return()=>clearTimeout(n)},[e.id,e.kind,e.bump,e.sticky,t]),(0,M.jsxs)(`div`,{role:e.kind===`error`?`alert`:`status`,className:`nc-slide-in pointer-events-auto flex items-start gap-2 rounded-md border border-ink-700 bg-ink-850 px-3 py-2 text-xs shadow-lg`,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[(0,M.jsx)(`span`,{className:`min-w-0 flex-1 break-words ${Wa[e.kind]}`,children:e.message}),e.action&&(0,M.jsx)(`button`,{type:`button`,onClick:e.action.run,className:`shrink-0 rounded-sm border border-ink-700 px-1.5 py-0.5 text-ink-200 hover:border-accent hover:text-accent`,children:e.action.label}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>se(e.id),"aria-label":`dismiss`,className:`mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:bg-ink-700 hover:text-ink-200`,children:(0,M.jsx)(pe,{className:`h-3 w-3`})})]})}function qa(e){let t=new URLSearchParams(e),n=t.get(`notice-repo`);if(!n)return null;let r=t.get(`notice-pane`);return{repo:n,pane:r!==null&&/^\d+$/.test(r)?Number(r):null}}async function Ja(e,t,n){let r=qa(e.search);if(!r)return;let i=new URL(e.href);i.searchParams.delete(`notice-repo`),i.searchParams.delete(`notice-pane`),t.replaceState(t.state,``,i.pathname+i.search+i.hash),r.pane!==null&&_e(r.repo,r.pane),await n(r.repo).catch(()=>void 0)}ce(document.documentElement,window),de(i()),Ai(document.querySelector(`meta[name="nightcrow-build"]`)?.getAttribute(`content`)||null),Ze(Ye()),await Ja(window.location,window.history,A.setActiveRepo);var Ya=1500;await Promise.race([document.fonts?.load(`400 12px "JetBrains Mono"`).catch(()=>void 0),new Promise(e=>setTimeout(e,Ya))]),(0,Le.createRoot)(document.getElementById(`root`)).render((0,M.jsxs)(j.StrictMode,{children:[(0,M.jsx)(tr,{children:(0,M.jsx)(O,{children:(0,M.jsx)(Ha,{})})}),(0,M.jsx)(Ga,{})]})); \ No newline at end of file diff --git a/viewer-ui/dist/assets/lastPane-FlqACl6i.js b/viewer-ui/dist/assets/lastPane-FlqACl6i.js new file mode 100644 index 00000000..03aa582a --- /dev/null +++ b/viewer-ui/dist/assets/lastPane-FlqACl6i.js @@ -0,0 +1 @@ +import{n as e,t}from"./jsx-runtime-EIAPxkjE.js";import{t as n}from"./react-BPk_wmJm.js";var r=e((e=>{var t=n();function r(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=r()})),a=n(),o=i(),s=t(),c=`nc-confirm-close-title`;function l({label:e,detail:t,onConfirm:n,onCancel:r}){let i=(0,a.useRef)(null);return(0,a.useEffect)(()=>{i.current?.focus()},[]),(0,a.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!e.isComposing&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]),(0,o.createPortal)((0,s.jsx)(`div`,{className:`nc-fade-in fixed inset-0 z-50 flex items-start justify-center bg-black/60 p-4 pt-[20vh]`,onClick:r,children:(0,s.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":c,className:`nc-rise-in flex w-[28rem] max-w-full flex-col gap-3 rounded-lg border border-ink-700 bg-ink-900 p-4`,onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)(`span`,{id:c,className:`font-medium break-words text-ink-50`,children:[`Close `,e,`?`]}),(0,s.jsx)(`p`,{className:`text-ink-200`,children:t}),(0,s.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,s.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-sm px-3 py-1.5 text-ink-200 hover:text-ink-50`,children:`Cancel`}),(0,s.jsx)(`button`,{ref:i,type:`button`,onClick:n,className:`rounded-sm bg-removed px-3 py-1.5 font-medium text-ink-950`,children:`Close`})]})]})}),document.body)}var u=4,d=[],ee=1,f=new Set;function p(){let e=d;f.forEach(t=>t(e))}function te(e){return f.add(e),e(d),()=>{f.delete(e)}}function ne(e){let t=d.filter(t=>t.id!==e);t.length!==d.length&&(d=t,p())}function m(e,t,n={}){let r=d.findIndex(n=>n.kind===e&&n.message===t);if(r!==-1){let e=d[r];return d=d.map((e,t)=>t===r?{...e,...n,bump:e.bump+1}:e),p(),e.id}let i=ee++;return d=h([...d,{id:i,kind:e,message:t,bump:0,...n}]),p(),i}function h(e){if(e.length<=u)return e;let t=e[e.length-1],n=e.slice(0,-1);for(;n.length>=u;){let e=n.findIndex(e=>!e.sticky);n.splice(e===-1?0:e,1)}return[...n,t]}var g={error:(e,t)=>m(`error`,e,t),info:(e,t)=>m(`info`,e,t),success:(e,t)=>m(`success`,e,t)};function _({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,s.jsx)(`path`,{d:`M18 6 6 18`}),(0,s.jsx)(`path`,{d:`m6 6 12 12`})]})}function v({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,s.jsx)(`path`,{d:`M5 12h14`}),(0,s.jsx)(`path`,{d:`M12 5v14`})]})}function re(){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-4 w-4`,children:[(0,s.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,s.jsx)(`path`,{d:`m21 21-4.3-4.3`})]})}function ie({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,s.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,s.jsx)(`path`,{d:`m16 17 5-5-5-5`}),(0,s.jsx)(`path`,{d:`M21 12H9`})]})}function ae({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,s.jsx)(`path`,{d:`M12 20h9`}),(0,s.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]})}function oe({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,s.jsx)(`path`,{d:`M3 12a9 9 0 0 1 9-9 9 9 0 0 1 6.7 3H21`}),(0,s.jsx)(`path`,{d:`M21 3v6h-6`}),(0,s.jsx)(`path`,{d:`M21 12a9 9 0 0 1-9 9 9 9 0 0 1-6.7-3H3`}),(0,s.jsx)(`path`,{d:`M3 21v-6h6`})]})}function se({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,s.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,s.jsx)(`path`,{d:`M12 2.5v2M12 19.5v2M2.5 12h2m15 0h2M5.3 5.3l1.4 1.4m10.6 10.6 1.4 1.4m0-13.4-1.4 1.4M6.7 17.3l-1.4 1.4`}),(0,s.jsx)(`circle`,{cx:`12`,cy:`12`,r:`7`})]})}function ce({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,s.jsx)(`path`,{d:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z`}),(0,s.jsx)(`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`}),(0,s.jsx)(`path`,{d:`M12 19v3`})]})}function le({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,s.jsx)(`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`}),(0,s.jsx)(`circle`,{cx:`9`,cy:`9`,r:`2`}),(0,s.jsx)(`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`})]})}var ue={ctrl:`ctrl`,control:`ctrl`,alt:`alt`,option:`alt`,shift:`shift`,meta:`meta`,cmd:`meta`,command:`meta`,super:`meta`,win:`meta`},de=new Map(`ArrowLeft.ArrowRight.ArrowUp.ArrowDown.Escape.Enter.Tab.Space.Backspace.Delete.Insert.Home.End.PageUp.PageDown.F1.F2.F3.F4.F5.F6.F7.F8.F9.F10.F11.F12`.split(`.`).map(e=>[e.toLowerCase(),e]));function y(e){return de.get(e.toLowerCase())||(e.length===1?e.toUpperCase():e)}function fe(e){return e===` `?`Space`:e}function pe(e){let t=e.split(`+`).map(e=>e.trim());if(t.some(e=>e.length===0))return null;let n={key:``,ctrl:!1,shift:!1,alt:!1,meta:!1},r=[];for(let e of t){let t=ue[e.toLowerCase()];if(t){if(n[t])return null;n[t]=!0}else r.push(e)}return r.length===1?(n.key=y(r[0]),n):null}function b(e){let t=[];return e.ctrl&&t.push(`Ctrl`),e.alt&&t.push(`Alt`),e.shift&&t.push(`Shift`),e.meta&&t.push(`Meta`),t.push(y(e.key)),t.join(`+`)}function me(e,t){return t.ctrlKey!==e.ctrl||t.shiftKey!==e.shift||t.altKey!==e.alt||t.metaKey!==e.meta?!1:fe(t.key).toLowerCase()===e.key.toLowerCase()}var he={key:`F`,ctrl:!0,shift:!1,alt:!1,meta:!1},ge={F:`the browser's in-page Find`,T:`opening a new tab`,N:`opening a new window`,W:`closing the tab`,L:`focusing the address bar`,D:`bookmarking the page`,P:`printing`,S:`saving the page`,R:`reloading the page`},_e={I:`opening developer tools`,J:`opening the developer console`,C:`the devtools element inspector`};function ve(e){let t=y(e.key),n=e.ctrl||e.meta;if(n&&!e.alt&&t===`Space`)return`${b(e)} switches the input source on most systems, so an IME user may never reach it.`;if(e.ctrl&&e.shift&&!e.alt&&!e.meta){let n=_e[t];if(n)return`${b(e)} is the browser default for ${n}.`}if(n&&!e.shift&&!e.alt){let n=ge[t];if(n)return`${b(e)} is the browser shortcut for ${n}.`}return null}function ye(e){if(e.meta)return null;let t=e.key===`Space`?` `:e.key;if(t.length!==1)return null;let n=e.shift?t.toUpperCase():t.toLowerCase();if(e.ctrl){let t=be(n);return t===null?null:e.alt?`\x1B`+t:t}return e.alt?`\x1B`+n:n}function be(e){if(e===` `)return`\0`;if(e===`?`)return``;let t=e.charCodeAt(0);return t>=97&&t<=122&&(t-=32),t<64||t>95?null:String.fromCharCode(t&31)}var x=[{id:`terminal.newPane`,label:`New terminal pane`,hint:`new pane`,leader:`t`,support:`direct`,group:`terminal`},{id:`terminal.closePane`,label:`Close terminal pane`,hint:`close pane`,leader:`w`,support:`direct`,group:`terminal`},{id:`terminal.swapPanePrompt`,label:`Swap pane with...`,hint:`swap pane`,leader:`s`,support:`direct`,group:`terminal`,keyboardOnly:!0,note:`Arms a second step: the next pane digit picks the pane to swap with, so there is no button for it. Drag a pane to move it instead.`},{id:`terminal.claimSizing`,label:`Reclaim and fit terminal sizing`,hint:`resize panes here`,leader:`r`,support:`direct`,group:`terminal`},{id:`terminal.cancelRecovery`,label:`Cancel plugin recovery`,hint:`cancel recovery`,leader:`c`,support:`direct`,group:`terminal`},{id:`terminal.composeMessage`,label:`Write a message to the active terminal`,hint:`message`,leader:`m`,support:`browserOnly`,group:`terminal`,note:`Opens a text field that sends its text to the pane and presses Return — for input an IME garbles when typed into the terminal itself.`},{id:`view.toggleLog`,label:`Toggle status and commit log`,hint:`log/status view`,leader:`l`,support:`direct`,group:`view`},{id:`view.toggleTree`,label:`Toggle tree view`,hint:`tree view`,leader:`b`,support:`direct`,group:`view`},{id:`view.toggleMaximize`,label:`Maximize panel`,hint:`maximize`,leader:`f`,support:`reinterpreted`,group:`view`,note:`In the browser this maximizes the panel and zooms the active terminal pane rather than entering OS fullscreen; it is never bound to F11.`},{id:`project.openDialog`,label:`Open project...`,hint:`open project`,leader:`o`,support:`direct`,group:`project`},{id:`project.close`,label:`Close project`,hint:`close project`,leader:`x`,support:`direct`,group:`project`},{id:`project.previous`,label:`Previous project`,hint:`prev project`,chord:`Ctrl+Shift+ArrowLeft`,support:`direct`,group:`project`,note:`Wraps around at the first project.`},{id:`project.next`,label:`Next project`,hint:`next project`,chord:`Ctrl+Shift+ArrowRight`,support:`direct`,group:`project`,note:`Wraps around at the last project.`},{id:`session.cycleAccent`,label:`Cycle session accent`,hint:`theme`,leader:`p`,support:`direct`,group:`session`},{id:`session.reloadConfig`,label:`Reload configuration`,hint:`reload config`,leader:`u`,support:`direct`,group:`session`},{id:`focus.list`,label:`Focus file or commit list`,hint:`focus list`,leader:`1`,support:`direct`,group:`focus`},{id:`focus.content`,label:`Focus content pane`,hint:`focus content`,leader:`2`,support:`direct`,group:`focus`},{id:`focus.previous`,label:`Focus previous panel or pane`,hint:`focus prev`,chord:`Shift+ArrowLeft`,support:`direct`,group:`focus`,note:`Walks the file list, the content pane and each terminal pane in turn, among whatever is on screen.`},{id:`focus.next`,label:`Focus next panel or pane`,hint:`focus next`,chord:`Shift+ArrowRight`,support:`direct`,group:`focus`,note:`Walks the file list, the content pane and each terminal pane in turn, among whatever is on screen.`},...[`3`,`4`,`5`,`6`,`7`,`8`,`9`,`0`].map((e,t)=>({id:`focus.pane${t+1}`,label:`Focus terminal pane ${t+1}`,hint:`pane ${t+1}`,leader:e,support:`direct`,group:`focus`})),{id:`help.shortcuts`,label:`Keyboard shortcuts`,hint:`shortcuts`,leader:`?`,support:`direct`,group:`help`}],xe=[{leader:`q`,label:`Detach`,reason:`A browser tab is not an attached TUI - closing it already leaves the session running. Signing out is a different, destructive action and is deliberately not bound to a key.`},{leader:`F1-F10`,label:`Select project tab`,reason:`Bare F-keys are reserved by the browser and the OS, so the web cannot claim them. Use Ctrl+Shift+ArrowLeft / Ctrl+Shift+ArrowRight or the project menu instead.`}],S=new Map(x.filter(e=>e.leader!==void 0).map(e=>[e.leader,e])),C=new Map(x.map(e=>[e.id,e])),w={z:`terminal.claimSizing`};function T(e){let t=e.toLowerCase(),n=S.get(t);if(n)return n;let r=w[t];return r?E(r):null}function E(e){let t=C.get(e);if(!t)throw Error(`unknown shortcut action id: ${e}`);return t}function D(e){let t=/^focus\.pane([1-8])$/.exec(e);return t?Number(t[1]):null}function O(e,t){let n=E(e);return n.chord?[n.chord]:!n.leader||!t?null:[b(t),n.leader]}function k(e,t){let n=O(e,t);return n?n.join(` then `):null}function A(e,t){return t===null?e:`${e} (${t})`}var j={Ctrl:`Control`};function M(e,t){if(!E(e).chord)return null;let n=O(e,t);return n?n.map(Se).join(` `):null}function Se(e){return e.split(`+`).map(e=>j[e]??Ce(e)).join(`+`)}function Ce(e){return e.length===1?e.toUpperCase():e}var N=(0,a.createContext)(null);function we({leader:e,children:t}){return(0,s.jsx)(N.Provider,{value:e,children:t})}function P(){return(0,a.useContext)(N)}function Te(){let e=P();return(0,a.useCallback)((t,n)=>{let r=M(t,e),i={title:A(n,k(t,e))};return r!==null&&(i[`aria-keyshortcuts`]=r),i},[e])}var Ee=30,De=`w-30`;function Oe({title:e,className:t=``}){let n=(0,a.useRef)(null),r=(0,a.useRef)(null),[i,o]=(0,a.useState)(0);(0,a.useLayoutEffect)(()=>{let e=n.current,t=r.current;if(e===null||t===null)return;let i=()=>o(Math.max(0,t.scrollWidth-e.clientWidth));if(i(),typeof ResizeObserver>`u`)return;let a=new ResizeObserver(i);return a.observe(e),a.observe(t),document.fonts?.addEventListener?.(`loadingdone`,i),()=>{a.disconnect(),document.fonts?.removeEventListener?.(`loadingdone`,i)}},[e]);let c={"--nc-title-travel":`${-i}px`,"--nc-title-duration":`${Math.max(2,i/Ee)}s`};return(0,s.jsx)(`span`,{ref:n,className:`nc-title ${t}`,"data-overflow":i>0,style:c,children:(0,s.jsx)(`span`,{ref:r,className:`nc-title-text`,children:e})})}function ke({maximized:e}){return(0,s.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-4 w-4`,children:e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`}),(0,s.jsx)(`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`}),(0,s.jsx)(`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`}),(0,s.jsx)(`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`}),(0,s.jsx)(`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`}),(0,s.jsx)(`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`}),(0,s.jsx)(`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`})]})})}function Ae(){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-4 w-4`,children:[(0,s.jsx)(`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}),(0,s.jsx)(`path`,{d:`M12 3v18`})]})}function je(){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-4 w-4`,children:[(0,s.jsx)(`rect`,{width:`18`,height:`13`,x:`3`,y:`8`,rx:`2`}),(0,s.jsx)(`path`,{d:`M3 8V6a2 2 0 0 1 2-2h5v4`})]})}function Me(){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-4 w-4`,children:[(0,s.jsx)(`path`,{d:`M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7Z`}),(0,s.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}function Ne({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:e,children:[(0,s.jsx)(`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`}),(0,s.jsx)(`path`,{d:`M6 9h.01`}),(0,s.jsx)(`path`,{d:`M10 9h.01`}),(0,s.jsx)(`path`,{d:`M14 9h.01`}),(0,s.jsx)(`path`,{d:`M18 9h.01`}),(0,s.jsx)(`path`,{d:`M8 13h8`})]})}function Pe({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,s.jsx)(`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`}),(0,s.jsx)(`path`,{d:`M12 17v4`}),(0,s.jsx)(`path`,{d:`M8 21h8`}),(0,s.jsx)(`path`,{d:`m9 13 6-6`}),(0,s.jsx)(`path`,{d:`M9 10v3h3`}),(0,s.jsx)(`path`,{d:`M15 10V7h-3`})]})}function Fe(){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-4 w-4`,children:[(0,s.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8Z`}),(0,s.jsx)(`path`,{d:`M14 3v5h5`}),(0,s.jsx)(`path`,{d:`M9 13h6`}),(0,s.jsx)(`path`,{d:`M9 17h3`})]})}function Ie({side:e}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-3.5 w-3.5`,children:[(0,s.jsx)(`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}),e===`top`?(0,s.jsx)(`path`,{d:`M3 9h18`}):(0,s.jsx)(`path`,{d:`M9 3v18`})]})}function F(e){try{return globalThis.localStorage.getItem(e)}catch{return null}}function I(e,t){try{globalThis.localStorage.setItem(e,t)}catch{}}var L=`nightcrow.viewer.scale`,R=[50,60,70,80,90,100,110,120,130],z=(0,a.createContext)({scale:100,setScale:()=>void 0});function Le({children:e}){let[t,n]=(0,a.useState)(B);(0,a.useLayoutEffect)(()=>V(t),[t]);let r=(0,a.useCallback)(e=>{let t=H(e);n(t),I(L,String(t))},[]);return(0,s.jsx)(z.Provider,{value:{scale:t,setScale:r},children:e})}function Re(){return(0,a.useContext)(z)}function B(){let e=F(L);return e===null?100:H(Number(e))}function V(e){typeof document<`u`&&document.documentElement.style.setProperty(`--nc-content-zoom`,String(e/100))}function H(e){return Number.isFinite(e)?R.reduce((t,n)=>Math.abs(n-e)0?null:r!==void 0&&t.includes(r)?r:t[0]??null}function He(e,t,n){return n&&e===0&&t>0}function Ue(e,t,n){return t?e===null||e===n?{focus:!1,held:n}:{focus:!0,held:e}:{focus:!1,held:null}}function We(e,t){return e?{tagName:e.tagName,editable:e.isContentEditable===!0,insidePanel:t!==null&&t.contains(e)}:null}var U=(0,a.createContext)(null),W=(0,a.createContext)(0);function Ge({children:e}){let t=(0,a.useRef)(new Map),n=(0,a.useRef)(new Set),r=(0,a.useRef)(``),[i,o]=(0,a.useState)(0),c=(0,a.useMemo)(()=>{let e=e=>t.current.get(e)?.fn,i=()=>{let e=[...t.current.keys()].sort().join(`,`);e!==r.current&&(r.current=e,o(e=>e+1))};return{registerShortcutHandlers:e=>{let n={},r=e,a=Object.keys(r).filter(e=>typeof r[e]==`function`);for(let e of a)t.current.set(e,{owner:n,fn:r[e]});return i(),()=>{for(let e of a)t.current.get(e)?.owner===n&&t.current.delete(e);i()}},runAction:t=>{let n=e(t);return n?(n(),!0):!1},isAvailable:e=>t.current.has(e),sendLiteralLeader:t=>e(`sendInput`)?.(t),swapPanes:t=>{let n=e(`swapPanes`);return n?(n(t),!0):!1},zoomActivePane:()=>{let t=e(`zoomActivePane`);return t?(t(),!0):!1},paneCursor:()=>e(`paneCursor`)?.()??null,focusPaneAt:t=>{let n=e(`focusPaneAt`);return n?(n(t),!0):!1},disarm:()=>n.current.forEach(e=>e()),onDisarm:e=>(n.current.add(e),()=>void n.current.delete(e))}},[]);return(0,s.jsx)(U.Provider,{value:c,children:(0,s.jsx)(W.Provider,{value:i,children:e})})}function Ke(){return(0,a.useContext)(U)}function qe(e){let t=(0,a.useContext)(U)?.registerShortcutHandlers;(0,a.useEffect)(()=>{if(t)return t(e)},[t,e])}function Je(){let e=(0,a.useContext)(U),t=(0,a.useContext)(W);return(0,a.useCallback)(t=>e?.isAvailable(t)??!1,[e,t])}var G=[`pointerdown`,`keydown`,`beforeinput`,`paste`,`wheel`],K=(0,a.createContext)(()=>()=>void 0);function Ye({children:e}){let t=(0,a.useRef)(new Set),n=(0,a.useCallback)(e=>(t.current.add(e),()=>t.current.delete(e)),[]);return(0,a.useEffect)(()=>{let e=document.getElementById(`root`);if(!e)return;let n=n=>{Qe(n,e)&&t.current.forEach(e=>e())};for(let e of G)window.addEventListener(e,n,!0);return()=>{for(let e of G)window.removeEventListener(e,n,!0)}},[]),(0,s.jsx)(K.Provider,{value:n,children:e})}function Xe(e,t){let n=(0,a.useContext)(K),r=(0,a.useRef)(e);r.current=e,(0,a.useEffect)(()=>{if(t)return n(()=>r.current())},[t,n])}function Ze(e){return e.isTrusted}function Qe(e,t){return Ze(e)&&e.target instanceof Node&&t.contains(e.target)}function $e(e){return e<768?`tabs`:`grid`}function q(e){return e>=768}function et(e,t){return q(t)?e??$e(t):`tabs`}function tt(e){return e===`grid`||e===`tabs`?e:null}function nt(e,t){return e!==null&&t.includes(e)?e:t[0]??null}function rt(e){return{position:`absolute`,inset:0,display:`flex`,visibility:e?`visible`:`hidden`,transform:e?void 0:`translateX(calc(-100% - 2px))`}}var it=`relative h-full overflow-hidden`;function at(e,t,n){if(t===n)return e;let r=e.indexOf(t),i=e.indexOf(n);if(r===-1||i===-1)return e;let a=e.filter(e=>e!==t),o=a.indexOf(n),s=r=120?n:0}function X(e){if(!e||!Number.isFinite(e.height)||e.height<=0)return null;let t=Number.isFinite(e.offsetTop)&&e.offsetTop>0?e.offsetTop:0;return e.height+t}function lt(e,t){let n=t.visualViewport,r=()=>{let t=X(n);t===null?e.style.removeProperty(Y):e.style.setProperty(Y,`${t}px`)};return r(),n?(n.addEventListener(`resize`,r),n.addEventListener(`scroll`,r),t.addEventListener(`resize`,r),()=>{n.removeEventListener(`resize`,r),n.removeEventListener(`scroll`,r),t.removeEventListener(`resize`,r),e.style.removeProperty(Y)}):()=>void 0}var Z=`nightcrow.pane.active`;function Q(){try{let e=sessionStorage.getItem(Z);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`number`&&Number.isInteger(r)&&(n[e]=r);return n}catch{return{}}}function $(e){try{sessionStorage.setItem(Z,JSON.stringify(e))}catch{}}function ut(e){return Q()[e]}function dt(e,t){let n=Q();n[e]!==t&&(n[e]=t,$(n))}function ft(e,t){let n=Q();n[e]===t&&(delete n[e],$(n))}export{D as $,B as A,je as B,We as C,R as D,Ue as E,Ne as F,P as G,Oe as H,ke as I,k as J,Te as K,Me as L,F as M,I as N,Le as O,Pe as P,T as Q,Ae as R,He as S,Ve as T,De as U,Fe as V,we as W,x as X,O as Y,xe as Z,Xe as _,g as _t,ct as a,pe as at,Je as b,at as c,ce as ct,q as d,oe as dt,he as et,tt as f,re as ft,Ye as g,te as gt,rt as h,ne as ht,lt as i,ye as it,Re as j,V as k,st as l,ae as lt,nt as m,_ as mt,ut as n,b as nt,J as o,le as ot,et as p,se as pt,M as q,dt as r,ve as rt,ot as s,ie as st,ft as t,me as tt,it as u,v as ut,Ge as v,l as vt,Be as w,Ke as x,qe as y,i as yt,Ie as z}; \ No newline at end of file diff --git a/viewer-ui/dist/assets/lastPane-Kg5ZBFNS.js b/viewer-ui/dist/assets/lastPane-Kg5ZBFNS.js deleted file mode 100644 index 2d46c924..00000000 --- a/viewer-ui/dist/assets/lastPane-Kg5ZBFNS.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e,t}from"./jsx-runtime-EIAPxkjE.js";import{t as n}from"./react-BPk_wmJm.js";var r=e((e=>{var t=n();function r(e){var t=`https://react.dev/errors/`+e;if(1{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=r()})),a=n(),o=i(),s=t(),c=`nc-confirm-close-title`;function l({label:e,detail:t,onConfirm:n,onCancel:r}){let i=(0,a.useRef)(null);return(0,a.useEffect)(()=>{i.current?.focus()},[]),(0,a.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!e.isComposing&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[r]),(0,o.createPortal)((0,s.jsx)(`div`,{className:`nc-fade-in fixed inset-0 z-50 flex items-start justify-center bg-black/60 p-4 pt-[20vh]`,onClick:r,children:(0,s.jsxs)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":c,className:`nc-rise-in flex w-[28rem] max-w-full flex-col gap-3 rounded-lg border border-ink-700 bg-ink-900 p-4`,onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)(`span`,{id:c,className:`font-medium break-words text-ink-50`,children:[`Close `,e,`?`]}),(0,s.jsx)(`p`,{className:`text-ink-200`,children:t}),(0,s.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,s.jsx)(`button`,{type:`button`,onClick:r,className:`rounded-sm px-3 py-1.5 text-ink-200 hover:text-ink-50`,children:`Cancel`}),(0,s.jsx)(`button`,{ref:i,type:`button`,onClick:n,className:`rounded-sm bg-removed px-3 py-1.5 font-medium text-ink-950`,children:`Close`})]})]})}),document.body)}var u=4,d=[],ee=1,f=new Set;function p(){let e=d;f.forEach(t=>t(e))}function te(e){return f.add(e),e(d),()=>{f.delete(e)}}function ne(e){let t=d.filter(t=>t.id!==e);t.length!==d.length&&(d=t,p())}function m(e,t,n={}){let r=d.findIndex(n=>n.kind===e&&n.message===t);if(r!==-1){let e=d[r];return d=d.map((e,t)=>t===r?{...e,...n,bump:e.bump+1}:e),p(),e.id}let i=ee++;return d=h([...d,{id:i,kind:e,message:t,bump:0,...n}]),p(),i}function h(e){if(e.length<=u)return e;let t=e[e.length-1],n=e.slice(0,-1);for(;n.length>=u;){let e=n.findIndex(e=>!e.sticky);n.splice(e===-1?0:e,1)}return[...n,t]}var g={error:(e,t)=>m(`error`,e,t),info:(e,t)=>m(`info`,e,t),success:(e,t)=>m(`success`,e,t)};function _({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,s.jsx)(`path`,{d:`M18 6 6 18`}),(0,s.jsx)(`path`,{d:`m6 6 12 12`})]})}function v({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,s.jsx)(`path`,{d:`M5 12h14`}),(0,s.jsx)(`path`,{d:`M12 5v14`})]})}function re(){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-4 w-4`,children:[(0,s.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,s.jsx)(`path`,{d:`m21 21-4.3-4.3`})]})}function ie({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,s.jsx)(`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`}),(0,s.jsx)(`path`,{d:`m16 17 5-5-5-5`}),(0,s.jsx)(`path`,{d:`M21 12H9`})]})}function ae({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,s.jsx)(`path`,{d:`M12 20h9`}),(0,s.jsx)(`path`,{d:`M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z`})]})}function oe({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,s.jsx)(`path`,{d:`M3 12a9 9 0 0 1 9-9 9 9 0 0 1 6.7 3H21`}),(0,s.jsx)(`path`,{d:`M21 3v6h-6`}),(0,s.jsx)(`path`,{d:`M21 12a9 9 0 0 1-9 9 9 9 0 0 1-6.7-3H3`}),(0,s.jsx)(`path`,{d:`M3 21v-6h6`})]})}function se({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,s.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,s.jsx)(`path`,{d:`M12 2.5v2M12 19.5v2M2.5 12h2m15 0h2M5.3 5.3l1.4 1.4m10.6 10.6 1.4 1.4m0-13.4-1.4 1.4M6.7 17.3l-1.4 1.4`}),(0,s.jsx)(`circle`,{cx:`12`,cy:`12`,r:`7`})]})}var ce={ctrl:`ctrl`,control:`ctrl`,alt:`alt`,option:`alt`,shift:`shift`,meta:`meta`,cmd:`meta`,command:`meta`,super:`meta`,win:`meta`},le=new Map(`ArrowLeft.ArrowRight.ArrowUp.ArrowDown.Escape.Enter.Tab.Space.Backspace.Delete.Insert.Home.End.PageUp.PageDown.F1.F2.F3.F4.F5.F6.F7.F8.F9.F10.F11.F12`.split(`.`).map(e=>[e.toLowerCase(),e]));function y(e){return le.get(e.toLowerCase())||(e.length===1?e.toUpperCase():e)}function ue(e){return e===` `?`Space`:e}function de(e){let t=e.split(`+`).map(e=>e.trim());if(t.some(e=>e.length===0))return null;let n={key:``,ctrl:!1,shift:!1,alt:!1,meta:!1},r=[];for(let e of t){let t=ce[e.toLowerCase()];if(t){if(n[t])return null;n[t]=!0}else r.push(e)}return r.length===1?(n.key=y(r[0]),n):null}function b(e){let t=[];return e.ctrl&&t.push(`Ctrl`),e.alt&&t.push(`Alt`),e.shift&&t.push(`Shift`),e.meta&&t.push(`Meta`),t.push(y(e.key)),t.join(`+`)}function fe(e,t){return t.ctrlKey!==e.ctrl||t.shiftKey!==e.shift||t.altKey!==e.alt||t.metaKey!==e.meta?!1:ue(t.key).toLowerCase()===e.key.toLowerCase()}var pe={key:`F`,ctrl:!0,shift:!1,alt:!1,meta:!1},me={F:`the browser's in-page Find`,T:`opening a new tab`,N:`opening a new window`,W:`closing the tab`,L:`focusing the address bar`,D:`bookmarking the page`,P:`printing`,S:`saving the page`,R:`reloading the page`},he={I:`opening developer tools`,J:`opening the developer console`,C:`the devtools element inspector`};function ge(e){let t=y(e.key),n=e.ctrl||e.meta;if(n&&!e.alt&&t===`Space`)return`${b(e)} switches the input source on most systems, so an IME user may never reach it.`;if(e.ctrl&&e.shift&&!e.alt&&!e.meta){let n=he[t];if(n)return`${b(e)} is the browser default for ${n}.`}if(n&&!e.shift&&!e.alt){let n=me[t];if(n)return`${b(e)} is the browser shortcut for ${n}.`}return null}function _e(e){if(e.meta)return null;let t=e.key===`Space`?` `:e.key;if(t.length!==1)return null;let n=e.shift?t.toUpperCase():t.toLowerCase();if(e.ctrl){let t=ve(n);return t===null?null:e.alt?`\x1B`+t:t}return e.alt?`\x1B`+n:n}function ve(e){if(e===` `)return`\0`;if(e===`?`)return``;let t=e.charCodeAt(0);return t>=97&&t<=122&&(t-=32),t<64||t>95?null:String.fromCharCode(t&31)}var x=[{id:`terminal.newPane`,label:`New terminal pane`,hint:`new pane`,leader:`t`,support:`direct`,group:`terminal`},{id:`terminal.closePane`,label:`Close terminal pane`,hint:`close pane`,leader:`w`,support:`direct`,group:`terminal`},{id:`terminal.swapPanePrompt`,label:`Swap pane with...`,hint:`swap pane`,leader:`s`,support:`direct`,group:`terminal`,keyboardOnly:!0,note:`Arms a second step: the next pane digit picks the pane to swap with, so there is no button for it. Drag a pane to move it instead.`},{id:`terminal.claimSizing`,label:`Reclaim and fit terminal sizing`,hint:`resize panes here`,leader:`r`,support:`direct`,group:`terminal`},{id:`terminal.cancelRecovery`,label:`Cancel plugin recovery`,hint:`cancel recovery`,leader:`c`,support:`direct`,group:`terminal`},{id:`terminal.composeMessage`,label:`Write a message to the active terminal`,hint:`message`,leader:`m`,support:`browserOnly`,group:`terminal`,note:`Opens a text field that sends its text to the pane and presses Return — for input an IME garbles when typed into the terminal itself.`},{id:`view.toggleLog`,label:`Toggle status and commit log`,hint:`log/status view`,leader:`l`,support:`direct`,group:`view`},{id:`view.toggleTree`,label:`Toggle tree view`,hint:`tree view`,leader:`b`,support:`direct`,group:`view`},{id:`view.toggleMaximize`,label:`Maximize panel`,hint:`maximize`,leader:`f`,support:`reinterpreted`,group:`view`,note:`In the browser this maximizes the panel and zooms the active terminal pane rather than entering OS fullscreen; it is never bound to F11.`},{id:`project.openDialog`,label:`Open project...`,hint:`open project`,leader:`o`,support:`direct`,group:`project`},{id:`project.close`,label:`Close project`,hint:`close project`,leader:`x`,support:`direct`,group:`project`},{id:`project.previous`,label:`Previous project`,hint:`prev project`,chord:`Ctrl+Shift+ArrowLeft`,support:`direct`,group:`project`,note:`Wraps around at the first project.`},{id:`project.next`,label:`Next project`,hint:`next project`,chord:`Ctrl+Shift+ArrowRight`,support:`direct`,group:`project`,note:`Wraps around at the last project.`},{id:`session.cycleAccent`,label:`Cycle session accent`,hint:`theme`,leader:`p`,support:`direct`,group:`session`},{id:`session.reloadConfig`,label:`Reload configuration`,hint:`reload config`,leader:`u`,support:`direct`,group:`session`},{id:`focus.list`,label:`Focus file or commit list`,hint:`focus list`,leader:`1`,support:`direct`,group:`focus`},{id:`focus.content`,label:`Focus content pane`,hint:`focus content`,leader:`2`,support:`direct`,group:`focus`},{id:`focus.previous`,label:`Focus previous panel or pane`,hint:`focus prev`,chord:`Shift+ArrowLeft`,support:`direct`,group:`focus`,note:`Walks the file list, the content pane and each terminal pane in turn, among whatever is on screen.`},{id:`focus.next`,label:`Focus next panel or pane`,hint:`focus next`,chord:`Shift+ArrowRight`,support:`direct`,group:`focus`,note:`Walks the file list, the content pane and each terminal pane in turn, among whatever is on screen.`},...[`3`,`4`,`5`,`6`,`7`,`8`,`9`,`0`].map((e,t)=>({id:`focus.pane${t+1}`,label:`Focus terminal pane ${t+1}`,hint:`pane ${t+1}`,leader:e,support:`direct`,group:`focus`})),{id:`help.shortcuts`,label:`Keyboard shortcuts`,hint:`shortcuts`,leader:`?`,support:`direct`,group:`help`}],ye=[{leader:`q`,label:`Detach`,reason:`A browser tab is not an attached TUI - closing it already leaves the session running. Signing out is a different, destructive action and is deliberately not bound to a key.`},{leader:`F1-F10`,label:`Select project tab`,reason:`Bare F-keys are reserved by the browser and the OS, so the web cannot claim them. Use Ctrl+Shift+ArrowLeft / Ctrl+Shift+ArrowRight or the project menu instead.`}],be=new Map(x.filter(e=>e.leader!==void 0).map(e=>[e.leader,e])),xe=new Map(x.map(e=>[e.id,e])),S={z:`terminal.claimSizing`};function C(e){let t=e.toLowerCase(),n=be.get(t);if(n)return n;let r=S[t];return r?w(r):null}function w(e){let t=xe.get(e);if(!t)throw Error(`unknown shortcut action id: ${e}`);return t}function T(e){let t=/^focus\.pane([1-8])$/.exec(e);return t?Number(t[1]):null}function E(e,t){let n=w(e);return n.chord?[n.chord]:!n.leader||!t?null:[b(t),n.leader]}function D(e,t){let n=E(e,t);return n?n.join(` then `):null}function O(e,t){return t===null?e:`${e} (${t})`}var k={Ctrl:`Control`};function A(e,t){if(!w(e).chord)return null;let n=E(e,t);return n?n.map(j).join(` `):null}function j(e){return e.split(`+`).map(e=>k[e]??M(e)).join(`+`)}function M(e){return e.length===1?e.toUpperCase():e}var N=(0,a.createContext)(null);function Se({leader:e,children:t}){return(0,s.jsx)(N.Provider,{value:e,children:t})}function P(){return(0,a.useContext)(N)}function Ce(){let e=P();return(0,a.useCallback)((t,n)=>{let r=A(t,e),i={title:O(n,D(t,e))};return r!==null&&(i[`aria-keyshortcuts`]=r),i},[e])}var we=30,Te=`w-30`;function Ee({title:e,className:t=``}){let n=(0,a.useRef)(null),r=(0,a.useRef)(null),[i,o]=(0,a.useState)(0);(0,a.useLayoutEffect)(()=>{let e=n.current,t=r.current;if(e===null||t===null)return;let i=()=>o(Math.max(0,t.scrollWidth-e.clientWidth));if(i(),typeof ResizeObserver>`u`)return;let a=new ResizeObserver(i);return a.observe(e),a.observe(t),document.fonts?.addEventListener?.(`loadingdone`,i),()=>{a.disconnect(),document.fonts?.removeEventListener?.(`loadingdone`,i)}},[e]);let c={"--nc-title-travel":`${-i}px`,"--nc-title-duration":`${Math.max(2,i/we)}s`};return(0,s.jsx)(`span`,{ref:n,className:`nc-title ${t}`,"data-overflow":i>0,style:c,children:(0,s.jsx)(`span`,{ref:r,className:`nc-title-text`,children:e})})}function De({maximized:e}){return(0,s.jsx)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-4 w-4`,children:e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`path`,{d:`M8 3v3a2 2 0 0 1-2 2H3`}),(0,s.jsx)(`path`,{d:`M21 8h-3a2 2 0 0 1-2-2V3`}),(0,s.jsx)(`path`,{d:`M3 16h3a2 2 0 0 1 2 2v3`}),(0,s.jsx)(`path`,{d:`M16 21v-3a2 2 0 0 1 2-2h3`})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`path`,{d:`M8 3H5a2 2 0 0 0-2 2v3`}),(0,s.jsx)(`path`,{d:`M21 8V5a2 2 0 0 0-2-2h-3`}),(0,s.jsx)(`path`,{d:`M3 16v3a2 2 0 0 0 2 2h3`}),(0,s.jsx)(`path`,{d:`M16 21h3a2 2 0 0 0 2-2v-3`})]})})}function Oe(){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-4 w-4`,children:[(0,s.jsx)(`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}),(0,s.jsx)(`path`,{d:`M12 3v18`})]})}function ke(){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-4 w-4`,children:[(0,s.jsx)(`rect`,{width:`18`,height:`13`,x:`3`,y:`8`,rx:`2`}),(0,s.jsx)(`path`,{d:`M3 8V6a2 2 0 0 1 2-2h5v4`})]})}function Ae(){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-4 w-4`,children:[(0,s.jsx)(`path`,{d:`M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7Z`}),(0,s.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}function je({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:e,children:[(0,s.jsx)(`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`}),(0,s.jsx)(`path`,{d:`M6 9h.01`}),(0,s.jsx)(`path`,{d:`M10 9h.01`}),(0,s.jsx)(`path`,{d:`M14 9h.01`}),(0,s.jsx)(`path`,{d:`M18 9h.01`}),(0,s.jsx)(`path`,{d:`M8 13h8`})]})}function Me({className:e=`h-4 w-4`}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`shrink-0 ${e}`,children:[(0,s.jsx)(`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`}),(0,s.jsx)(`path`,{d:`M12 17v4`}),(0,s.jsx)(`path`,{d:`M8 21h8`}),(0,s.jsx)(`path`,{d:`m9 13 6-6`}),(0,s.jsx)(`path`,{d:`M9 10v3h3`}),(0,s.jsx)(`path`,{d:`M15 10V7h-3`})]})}function Ne(){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-4 w-4`,children:[(0,s.jsx)(`path`,{d:`M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8Z`}),(0,s.jsx)(`path`,{d:`M14 3v5h5`}),(0,s.jsx)(`path`,{d:`M9 13h6`}),(0,s.jsx)(`path`,{d:`M9 17h3`})]})}function Pe({side:e}){return(0,s.jsxs)(`svg`,{viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,className:`h-3.5 w-3.5`,children:[(0,s.jsx)(`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`}),e===`top`?(0,s.jsx)(`path`,{d:`M3 9h18`}):(0,s.jsx)(`path`,{d:`M9 3v18`})]})}function F(e){try{return globalThis.localStorage.getItem(e)}catch{return null}}function I(e,t){try{globalThis.localStorage.setItem(e,t)}catch{}}var L=`nightcrow.viewer.scale`,R=[50,60,70,80,90,100,110,120,130],z=(0,a.createContext)({scale:100,setScale:()=>void 0});function Fe({children:e}){let[t,n]=(0,a.useState)(B);(0,a.useLayoutEffect)(()=>V(t),[t]);let r=(0,a.useCallback)(e=>{let t=H(e);n(t),I(L,String(t))},[]);return(0,s.jsx)(z.Provider,{value:{scale:t,setScale:r},children:e})}function Ie(){return(0,a.useContext)(z)}function B(){let e=F(L);return e===null?100:H(Number(e))}function V(e){typeof document<`u`&&document.documentElement.style.setProperty(`--nc-content-zoom`,String(e/100))}function H(e){return Number.isFinite(e)?R.reduce((t,n)=>Math.abs(n-e)0?null:r!==void 0&&t.includes(r)?r:t[0]??null}function Be(e,t,n){return n&&e===0&&t>0}function Ve(e,t,n){return t?e===null||e===n?{focus:!1,held:n}:{focus:!0,held:e}:{focus:!1,held:null}}function He(e,t){return e?{tagName:e.tagName,editable:e.isContentEditable===!0,insidePanel:t!==null&&t.contains(e)}:null}var U=(0,a.createContext)(null),W=(0,a.createContext)(0);function Ue({children:e}){let t=(0,a.useRef)(new Map),n=(0,a.useRef)(new Set),r=(0,a.useRef)(``),[i,o]=(0,a.useState)(0),c=(0,a.useMemo)(()=>{let e=e=>t.current.get(e)?.fn,i=()=>{let e=[...t.current.keys()].sort().join(`,`);e!==r.current&&(r.current=e,o(e=>e+1))};return{registerShortcutHandlers:e=>{let n={},r=e,a=Object.keys(r).filter(e=>typeof r[e]==`function`);for(let e of a)t.current.set(e,{owner:n,fn:r[e]});return i(),()=>{for(let e of a)t.current.get(e)?.owner===n&&t.current.delete(e);i()}},runAction:t=>{let n=e(t);return n?(n(),!0):!1},isAvailable:e=>t.current.has(e),sendLiteralLeader:t=>e(`sendInput`)?.(t),swapPanes:t=>{let n=e(`swapPanes`);return n?(n(t),!0):!1},zoomActivePane:()=>{let t=e(`zoomActivePane`);return t?(t(),!0):!1},paneCursor:()=>e(`paneCursor`)?.()??null,focusPaneAt:t=>{let n=e(`focusPaneAt`);return n?(n(t),!0):!1},disarm:()=>n.current.forEach(e=>e()),onDisarm:e=>(n.current.add(e),()=>void n.current.delete(e))}},[]);return(0,s.jsx)(U.Provider,{value:c,children:(0,s.jsx)(W.Provider,{value:i,children:e})})}function We(){return(0,a.useContext)(U)}function Ge(e){let t=(0,a.useContext)(U)?.registerShortcutHandlers;(0,a.useEffect)(()=>{if(t)return t(e)},[t,e])}function Ke(){let e=(0,a.useContext)(U),t=(0,a.useContext)(W);return(0,a.useCallback)(t=>e?.isAvailable(t)??!1,[e,t])}var G=[`pointerdown`,`keydown`,`beforeinput`,`paste`,`wheel`],K=(0,a.createContext)(()=>()=>void 0);function qe({children:e}){let t=(0,a.useRef)(new Set),n=(0,a.useCallback)(e=>(t.current.add(e),()=>t.current.delete(e)),[]);return(0,a.useEffect)(()=>{let e=document.getElementById(`root`);if(!e)return;let n=n=>{Xe(n,e)&&t.current.forEach(e=>e())};for(let e of G)window.addEventListener(e,n,!0);return()=>{for(let e of G)window.removeEventListener(e,n,!0)}},[]),(0,s.jsx)(K.Provider,{value:n,children:e})}function Je(e,t){let n=(0,a.useContext)(K),r=(0,a.useRef)(e);r.current=e,(0,a.useEffect)(()=>{if(t)return n(()=>r.current())},[t,n])}function Ye(e){return e.isTrusted}function Xe(e,t){return Ye(e)&&e.target instanceof Node&&t.contains(e.target)}function Ze(e){return e<768?`tabs`:`grid`}function q(e){return e>=768}function Qe(e,t){return q(t)?e??Ze(t):`tabs`}function $e(e){return e===`grid`||e===`tabs`?e:null}function J(e,t){return e!==null&&t.includes(e)?e:t[0]??null}function et(e){return{position:`absolute`,inset:0,display:`flex`,visibility:e?`visible`:`hidden`,transform:e?void 0:`translateX(calc(-100% - 2px))`}}var tt=`relative h-full overflow-hidden`;function nt(e,t,n){if(t===n)return e;let r=e.indexOf(t),i=e.indexOf(n);if(r===-1||i===-1)return e;let a=e.filter(e=>e!==t),o=a.indexOf(n),s=r=120?n:0}function X(e){if(!e||!Number.isFinite(e.height)||e.height<=0)return null;let t=Number.isFinite(e.offsetTop)&&e.offsetTop>0?e.offsetTop:0;return e.height+t}function st(e,t){let n=t.visualViewport,r=()=>{let t=X(n);t===null?e.style.removeProperty(Y):e.style.setProperty(Y,`${t}px`)};return r(),n?(n.addEventListener(`resize`,r),n.addEventListener(`scroll`,r),t.addEventListener(`resize`,r),()=>{n.removeEventListener(`resize`,r),n.removeEventListener(`scroll`,r),t.removeEventListener(`resize`,r),e.style.removeProperty(Y)}):()=>void 0}var Z=`nightcrow.pane.active`;function Q(){try{let e=sessionStorage.getItem(Z);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`number`&&Number.isInteger(r)&&(n[e]=r);return n}catch{return{}}}function $(e){try{sessionStorage.setItem(Z,JSON.stringify(e))}catch{}}function ct(e){return Q()[e]}function lt(e,t){let n=Q();n[e]!==t&&(n[e]=t,$(n))}function ut(e,t){let n=Q();n[e]===t&&(delete n[e],$(n))}export{T as $,B as A,ke as B,He as C,R as D,Ve as E,je as F,P as G,Ee as H,De as I,D as J,Ce as K,Ae as L,F as M,I as N,Fe as O,Me as P,C as Q,Oe as R,Be as S,ze as T,Te as U,Ne as V,Se as W,x as X,E as Y,ye as Z,Je as _,i as _t,ot as a,de as at,Ke as b,nt as c,v as ct,q as d,se as dt,pe as et,$e as f,_ as ft,qe as g,l as gt,et as h,g as ht,st as i,_e as it,Ie as j,V as k,at as l,oe as lt,J as m,te as mt,ct as n,b as nt,it as o,ie as ot,Qe as p,ne as pt,A as q,lt as r,ge as rt,rt as s,ae as st,ut as t,fe as tt,tt as u,re as ut,Ue as v,Re as w,We as x,Ge as y,Pe as z}; \ No newline at end of file diff --git a/viewer-ui/dist/index.html b/viewer-ui/dist/index.html index 57a0873f..ffe2403c 100644 --- a/viewer-ui/dist/index.html +++ b/viewer-ui/dist/index.html @@ -14,13 +14,13 @@ nightcrow - + - + - +
diff --git a/viewer-ui/package-lock.json b/viewer-ui/package-lock.json index 01df6680..7a0f700e 100644 --- a/viewer-ui/package-lock.json +++ b/viewer-ui/package-lock.json @@ -1,12 +1,12 @@ { "name": "nightcrow-viewer-ui", - "version": "0.1.27", + "version": "0.1.28", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "nightcrow-viewer-ui", - "version": "0.1.27", + "version": "0.1.28", "dependencies": { "@xterm/addon-fit": "^0.11.0", "@xterm/addon-webgl": "^0.19.0", diff --git a/viewer-ui/package.json b/viewer-ui/package.json index de6f938b..c0206011 100644 --- a/viewer-ui/package.json +++ b/viewer-ui/package.json @@ -1,7 +1,7 @@ { "name": "nightcrow-viewer-ui", "private": true, - "version": "0.1.27", + "version": "0.1.28", "type": "module", "scripts": { "dev": "vite", diff --git a/viewer-ui/src/components/feedback/ToastEcho.test.tsx b/viewer-ui/src/components/feedback/ToastEcho.test.tsx new file mode 100644 index 00000000..f55a9644 --- /dev/null +++ b/viewer-ui/src/components/feedback/ToastEcho.test.tsx @@ -0,0 +1,69 @@ +// @vitest-environment happy-dom + +import { act, cleanup, render, screen } from "@testing-library/react"; +import { afterEach, describe, expect, it } from "vitest"; +import { dismissToast, toast } from "../../lib/runtime/toast"; +import { ToastEcho } from "./ToastEcho"; + +const raised: number[] = []; + +afterEach(() => { + cleanup(); + act(() => raised.splice(0).forEach(dismissToast)); +}); + +describe("ToastEcho", () => { + it("repeats_the_newest_error_toast_as_an_alert", () => { + render(); + expect(screen.queryByRole("alert")).toBeNull(); + act(() => { + raised.push(toast.error("Microphone access is blocked.")); + }); + expect(screen.getByRole("alert").textContent).toBe("Microphone access is blocked."); + act(() => { + raised.push(toast.error("Image must be 10 MiB or smaller.")); + }); + expect(screen.getByRole("alert").textContent).toBe("Image must be 10 MiB or smaller."); + }); + + it("announces_an_error_raised_again_even_behind_a_newer_one", () => { + render(); + act(() => { + raised.push(toast.error("A")); + raised.push(toast.error("B")); + }); + expect(screen.getByRole("alert").textContent).toBe("B"); + act(() => { + toast.error("A"); + }); + expect(screen.getByRole("alert").textContent).toBe("A"); + }); + + it("does_not_bring_back_an_older_error_when_the_newer_one_is_dismissed", () => { + render(); + let older = 0; + let newer = 0; + act(() => { + older = toast.error("older"); + newer = toast.error("newer"); + }); + raised.push(older); + act(() => dismissToast(newer)); + expect(screen.queryByRole("alert")).toBeNull(); + }); + + it("ignores_toasts_that_are_not_errors_and_clears_when_dismissed", () => { + render(); + act(() => { + raised.push(toast.info("Saved.")); + }); + expect(screen.queryByRole("alert")).toBeNull(); + let id = 0; + act(() => { + id = toast.error("Could not attach image."); + }); + expect(screen.getByRole("alert")).toBeTruthy(); + act(() => dismissToast(id)); + expect(screen.queryByRole("alert")).toBeNull(); + }); +}); diff --git a/viewer-ui/src/components/feedback/ToastEcho.tsx b/viewer-ui/src/components/feedback/ToastEcho.tsx new file mode 100644 index 00000000..95113a5a --- /dev/null +++ b/viewer-ui/src/components/feedback/ToastEcho.tsx @@ -0,0 +1,44 @@ +import { useEffect, useRef, useState } from "react"; +import { subscribeToasts, type Toast } from "../../lib/runtime/toast"; + +/** + * Error toasts, said again inside a modal dialog for screen readers. + * + * The toaster lives outside the dialog, and `aria-modal` lets a screen reader + * ignore everything outside it, so an error raised from the dialog could go + * unheard. This repeats the newest error where the reader is, visually hidden, + * so the dialog's layout never moves for it. + */ +export function ToastEcho() { + const [latest, setLatest] = useState(null); + // Each error's repeat count when last seen, so only an error that is new or + // was raised again is announced. Stack order cannot say that: a repeat keeps + // its old place, and a dismissal would bring an older error back up. + const seen = useRef(new Map()); + useEffect( + () => + subscribeToasts((toasts) => { + const errors = toasts.filter((t) => t.kind === "error"); + const raised = errors.filter((t) => seen.current.get(t.id) !== t.bump); + seen.current = new Map(errors.map((t) => [t.id, t.bump])); + if (raised.length > 0) { + setLatest(raised[raised.length - 1]); + } else { + // Nothing raised: keep what was said unless its toast is gone. + setLatest((cur) => (cur && seen.current.has(cur.id) ? cur : null)); + } + }), + [], + ); + return ( +
+ {latest && ( + // Keyed by the repeat count too, so the same error raised again is + // announced again rather than left as unchanged text. +

+ {latest.message} +

+ )} +
+ ); +} diff --git a/viewer-ui/src/components/icons/actions.tsx b/viewer-ui/src/components/icons/actions.tsx index 999ffacb..2d065af8 100644 --- a/viewer-ui/src/components/icons/actions.tsx +++ b/viewer-ui/src/components/icons/actions.tsx @@ -146,3 +146,43 @@ export function SettingsIcon({ className = "h-4 w-4" }: { className?: string }) ); } + +export function MicIcon({ className = "h-4 w-4" }: { className?: string }) { + return ( + + ); +} + +export function ImageIcon({ className = "h-4 w-4" }: { className?: string }) { + return ( + + ); +} diff --git a/viewer-ui/src/components/terminal/AttachNotice.tsx b/viewer-ui/src/components/terminal/AttachNotice.tsx index d4017acb..b4c525c2 100644 --- a/viewer-ui/src/components/terminal/AttachNotice.tsx +++ b/viewer-ui/src/components/terminal/AttachNotice.tsx @@ -8,6 +8,11 @@ import { attachLabel, type AttachStatus } from "../../lib/terminal/attachStatus" * just connected, or was rebuilding its panes after the network dropped, read * as a session with no terminal in it. * + * The same notice sits over panes left on screen while a socket reconnects or + * a replay fills the panel, centred as it is in an empty one: there the panes + * look live while they are not, and a toolbar chip took the tab strip's room + * on a phone. + * * Startup terminals are the exception: their cells are already on screen saying * so (`StartupSlots`), so this adds nothing over them. */ @@ -32,7 +37,9 @@ export function AttachNotice({ status }: { status: AttachStatus }) { {/* The pulse carries the label, not just the dot beside it: a 6px dot breathing in the middle of an empty panel is easy to read as part of the layout, and the thing worth noticing is the sentence. */} - + {/* A soft shade rather than a box, so it reads over a pane's text the + same as on an empty panel; a border made it look like a button. */} + {label} diff --git a/viewer-ui/src/components/terminal/ComposeDialog.test.tsx b/viewer-ui/src/components/terminal/ComposeDialog.test.tsx index 28ad52b1..9dd249e8 100644 --- a/viewer-ui/src/components/terminal/ComposeDialog.test.tsx +++ b/viewer-ui/src/components/terminal/ComposeDialog.test.tsx @@ -7,10 +7,9 @@ import { ComposeDialog } from "./ComposeDialog"; afterEach(cleanup); -function mount(initial = "", sendResult = true, upload: { busy?: boolean; error?: string | null } = {}) { +function mount(initial = "", sendResult = true, upload: { busy?: boolean } = {}) { const onSend = vi.fn(() => sendResult); const onAttachImage = vi.fn(); - const onDismissUploadError = vi.fn(); const onClose = vi.fn(); function Host() { const [draft, setDraft] = useState(initial); @@ -22,8 +21,6 @@ function mount(initial = "", sendResult = true, upload: { busy?: boolean; error? onSend={onSend} onAttachImage={onAttachImage} uploading={upload.busy ?? false} - uploadError={upload.error ?? null} - onDismissUploadError={onDismissUploadError} onClose={onClose} /> ); @@ -35,7 +32,7 @@ function mount(initial = "", sendResult = true, upload: { busy?: boolean; error? , ); const field = screen.getByRole("textbox", { name: "message" }) as HTMLTextAreaElement; - return { field, onSend, onAttachImage, onDismissUploadError, onClose }; + return { field, onSend, onAttachImage, onClose }; } describe("ComposeDialog", () => { @@ -126,21 +123,12 @@ describe("ComposeDialog", () => { expect(input.value).toBe(""); }); - it("uploading_and_failed_attachments_keep_send_disabled", () => { + it("an_upload_in_progress_keeps_send_disabled", () => { const pending = mount("typed text", true, { busy: true }); expect(screen.getByRole("status").textContent).toBe("Uploading image…"); expect((screen.getByRole("button", { name: /send/i }) as HTMLButtonElement).disabled).toBe(true); fireEvent.keyDown(pending.field, { key: "Enter", ctrlKey: true }); fireEvent.keyDown(pending.field, { key: "Enter", metaKey: true }); expect(pending.onSend).not.toHaveBeenCalled(); - cleanup(); - const failed = mount("typed text", true, { error: "Could not attach image." }); - expect(screen.getByRole("alert").textContent).toMatch(/Could not attach image/); - expect((screen.getByRole("button", { name: /send/i }) as HTMLButtonElement).disabled).toBe(true); - fireEvent.keyDown(failed.field, { key: "Enter", ctrlKey: true }); - fireEvent.keyDown(failed.field, { key: "Enter", metaKey: true }); - expect(failed.onSend).not.toHaveBeenCalled(); - fireEvent.click(screen.getByRole("button", { name: "Dismiss" })); - expect(failed.onDismissUploadError).toHaveBeenCalled(); }); }); diff --git a/viewer-ui/src/components/terminal/ComposeDialog.tsx b/viewer-ui/src/components/terminal/ComposeDialog.tsx index ace95428..0a3aec80 100644 --- a/viewer-ui/src/components/terminal/ComposeDialog.tsx +++ b/viewer-ui/src/components/terminal/ComposeDialog.tsx @@ -1,8 +1,17 @@ import { useEffect, useRef, useState } from "react"; import { createPortal } from "react-dom"; -import { XIcon } from "../icons/actions"; +import { ImageIcon, XIcon } from "../icons/actions"; import { isSendable, sendChordLabel } from "../../lib/terminal/composeInput"; import { IMAGE_MIME_TYPES } from "../../lib/terminal/pasteImage"; +import { + appendDictation, + browserRecognizerFactory, + dictationAvailability, + type DictationAvailability, + type RecognizerFactory, +} from "../../lib/terminal/dictation"; +import { DictationButton, FORM_ICON_BUTTON } from "./DictationButton"; +import { ToastEcho } from "../feedback/ToastEcho"; const TITLE_ID = "nc-compose-title"; @@ -29,9 +38,8 @@ export function ComposeDialog({ onSend, onAttachImage, uploading, - uploadError, - onDismissUploadError, onClose, + dictation, }: { /** Which pane this goes to, said in the title. */ label: string; @@ -40,16 +48,21 @@ export function ComposeDialog({ onSend: () => boolean; onAttachImage: (image: File) => void; uploading: boolean; - uploadError: string | null; - onDismissUploadError: () => void; onClose: () => void; + /** Voice input, injected by tests; read from the browser otherwise. */ + dictation?: { availability: DictationAvailability; factory: RecognizerFactory | null }; }) { const fieldRef = useRef(null); const imageRef = useRef(null); const [failed, setFailed] = useState(false); const sendable = isSendable(draft); - const canSend = sendable && !uploading && uploadError === null; + const canSend = sendable && !uploading; const chord = sendChordLabel(platform()); + const [voice] = useState(() => { + if (dictation) return dictation; + const factory = browserRecognizerFactory(); + return { availability: dictationAvailability(window.isSecureContext, factory), factory }; + }); useEffect(() => { const field = fieldRef.current; @@ -90,6 +103,8 @@ export function ComposeDialog({ className="nc-rise-in flex w-[56rem] max-w-full flex-col rounded-lg border border-ink-700 bg-ink-900" onClick={(e) => e.stopPropagation()} > + {/* Upload and microphone errors are toasts, outside this modal. */} +
Send to {label} @@ -117,10 +132,10 @@ export function ComposeDialog({ send(); } }} - rows={10} + rows={8} aria-label="message" // 16px, not the page's 14: iOS zooms the page into any field smaller. - className="m-3 resize-y rounded-sm border border-ink-700 bg-ink-950 p-2 font-mono text-[16px] text-ink-50 focus:border-accent focus:outline-none" + className="m-3 resize-none overflow-y-auto rounded-sm border border-ink-700 bg-ink-950 p-2 font-mono text-[16px] text-ink-50 focus:border-accent focus:outline-none" /> imageRef.current?.click()} disabled={uploading} aria-label="Attach image" - className="min-h-11 rounded-sm border border-ink-700 px-3 text-ink-200 hover:text-ink-50 disabled:text-ink-500" + title="Attach image" + className={`${FORM_ICON_BUTTON} text-ink-400 disabled:text-ink-600 disabled:hover:text-ink-600`} > - Attach image + + { + onChange(appendDictation(draft, text)); + setFailed(false); + }} + /> {uploading && ( Uploading image… )} - {uploadError && ( - - {uploadError} - - - )} {failed && ( Not connected — nothing was sent. )} - - + {/* Together, so a narrow screen wraps them as one group and Send + never lands alone on the left. */} +
+ + +
, diff --git a/viewer-ui/src/components/terminal/DictationButton.test.tsx b/viewer-ui/src/components/terminal/DictationButton.test.tsx new file mode 100644 index 00000000..2725d195 --- /dev/null +++ b/viewer-ui/src/components/terminal/DictationButton.test.tsx @@ -0,0 +1,130 @@ +// @vitest-environment happy-dom + +import { act, cleanup, fireEvent, render, screen } from "@testing-library/react"; +import { afterEach, describe, expect, it, vi } from "vitest"; +import { useState } from "react"; +import { ComposeDialog } from "./ComposeDialog"; +import type { DictationAvailability, Recognizer } from "../../lib/terminal/dictation"; + +const { toastError } = vi.hoisted(() => ({ toastError: vi.fn() })); +vi.mock("../../lib/runtime/toast", async (original) => ({ + ...(await original()), + toast: { error: toastError }, +})); + +afterEach(() => { + cleanup(); + toastError.mockReset(); +}); + +function fakeRecognizer() { + const r: Recognizer = { + lang: "", + continuous: true, + interimResults: true, + onresult: null, + onerror: null, + onend: null, + start: vi.fn(), + stop: vi.fn(() => r.onend?.()), + abort: vi.fn(() => r.onend?.()), + }; + return r; +} + +function mount(availability: DictationAvailability, initial = "", startThrows = false) { + const recognizers: Recognizer[] = []; + const factory = () => { + const r = fakeRecognizer(); + if (startThrows) r.start = vi.fn(() => { throw new Error("busy"); }); + recognizers.push(r); + return r; + }; + function Host() { + const [draft, setDraft] = useState(initial); + return ( + true} + onAttachImage={() => {}} + uploading={false} + onClose={() => {}} + dictation={{ availability, factory }} + /> + ); + } + const view = render(); + const field = screen.getByRole("textbox", { name: "message" }) as HTMLTextAreaElement; + return { field, recognizers, view }; +} + +function say(r: Recognizer, text: string) { + act(() => r.onresult?.({ resultIndex: 0, results: [{ isFinal: true, 0: { transcript: text } }] })); +} + +describe("DictationButton", () => { + it("is_absent_where_the_browser_cannot_recognize_speech", () => { + mount("unsupported"); + expect(screen.queryByRole("button", { name: /voice input/i })).toBeNull(); + }); + + it("is_inert_on_plain_http_without_pushing_a_message_into_the_form", () => { + const { recognizers } = mount("insecure"); + const button = screen.getByRole("button", { name: "Voice input needs HTTPS" }); + expect(button.getAttribute("aria-disabled")).toBe("true"); + expect(button.getAttribute("title")).toMatch(/HTTPS or localhost/); + fireEvent.click(button); + expect(recognizers).toHaveLength(0); + expect(screen.queryByRole("alert")).toBeNull(); + expect(toastError).not.toHaveBeenCalled(); + }); + + it("appends_final_text_to_the_draft_without_sending", () => { + const { field, recognizers } = mount("ready", "git"); + fireEvent.click(screen.getByRole("button", { name: "Voice input" })); + const r = recognizers[0]; + expect(r.start).toHaveBeenCalled(); + expect(r.continuous).toBe(false); + expect(r.interimResults).toBe(false); + expect(screen.getByRole("button", { name: "Stop voice input" })).toBeTruthy(); + say(r, "status"); + act(() => r.onend?.()); + expect(field.value).toBe("git status"); + expect(screen.getByRole("button", { name: "Voice input" })).toBeTruthy(); + }); + + it("pressing_again_stops_listening", () => { + const { recognizers } = mount("ready"); + fireEvent.click(screen.getByRole("button", { name: "Voice input" })); + fireEvent.click(screen.getByRole("button", { name: "Stop voice input" })); + // Stopped, not aborted, so a phrase still being recognized is kept. + expect(recognizers[0].stop).toHaveBeenCalled(); + expect(recognizers[0].abort).not.toHaveBeenCalled(); + expect(screen.getByRole("button", { name: "Voice input" })).toBeTruthy(); + }); + + it("reports_a_blocked_microphone", () => { + const { recognizers } = mount("ready"); + fireEvent.click(screen.getByRole("button", { name: "Voice input" })); + act(() => recognizers[0].onerror?.({ error: "not-allowed" })); + act(() => recognizers[0].onend?.()); + expect(toastError).toHaveBeenCalledWith(expect.stringMatching(/blocked/)); + expect(screen.queryByRole("alert")).toBeNull(); + }); + + it("reports_a_start_that_throws_and_does_not_claim_to_listen", () => { + mount("ready", "", true); + fireEvent.click(screen.getByRole("button", { name: "Voice input" })); + expect(toastError).toHaveBeenCalledWith(expect.stringMatching(/failed/)); + expect(screen.getByRole("button", { name: "Voice input" })).toBeTruthy(); + }); + + it("closing_the_form_releases_the_microphone", () => { + const { recognizers, view } = mount("ready"); + fireEvent.click(screen.getByRole("button", { name: "Voice input" })); + view.unmount(); + expect(recognizers[0].abort).toHaveBeenCalled(); + }); +}); diff --git a/viewer-ui/src/components/terminal/DictationButton.tsx b/viewer-ui/src/components/terminal/DictationButton.tsx new file mode 100644 index 00000000..e2113746 --- /dev/null +++ b/viewer-ui/src/components/terminal/DictationButton.tsx @@ -0,0 +1,54 @@ +import { useDictation } from "../../hooks/terminal/useDictation"; +import { + INSECURE_DICTATION_MESSAGE, + type DictationAvailability, + type RecognizerFactory, +} from "../../lib/terminal/dictation"; +import { MicIcon } from "../icons/actions"; + +/** The message form's icon buttons: the toolbar's 16px icon and colours, in a + * square big enough to tap. */ +export const FORM_ICON_BUTTON = + "flex h-11 w-11 shrink-0 items-center justify-center rounded-sm hover:text-accent"; + +/** + * The message form's voice input. Absent where the browser has no speech + * recognition; on plain http it stays visible but inert, its name and tooltip + * saying why, since hiding it would leave no clue why a phone never offers it. + */ +export function DictationButton({ + availability, + factory, + onText, +}: { + availability: DictationAvailability; + factory: RecognizerFactory | null; + onText: (text: string) => void; +}) { + const { listening, toggle } = useDictation( + availability === "ready" ? factory : null, + onText, + ); + if (availability === "unsupported") return null; + const ready = availability === "ready"; + + return ( + + ); +} diff --git a/viewer-ui/src/components/terminal/PanelToolbar.tsx b/viewer-ui/src/components/terminal/PanelToolbar.tsx index 5bf6b99a..b2d01e4f 100644 --- a/viewer-ui/src/components/terminal/PanelToolbar.tsx +++ b/viewer-ui/src/components/terminal/PanelToolbar.tsx @@ -31,10 +31,6 @@ export interface PanelToolbarProps { * dismissed — and only while there are panes, which is when there is a bar * for it to speak for. */ keyBarShown: boolean; - /** What the panel is still waiting for, if anything. Only set while panes are - * on screen — there the body has no room to say it, and it is exactly then - * that a stale pane looks like a working one (see `AttachNotice`). */ - waiting: string | null; /** Every pane's recovery report, and the panes this page still lists. Reports * for panes it does not — a process that ended while its slot is held for a * relaunch — have no cell to sit in, so they surface here. */ @@ -60,7 +56,6 @@ export function PanelToolbar({ ownsSize, maximized, keyBarShown, - waiting, recovery, panes, onCancelRecovery, @@ -88,19 +83,6 @@ export function PanelToolbar({ "flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-ink-400 hover:text-accent"; return (
- {/* The chip pulses whole, matching `AttachNotice`: the panel says the same - thing in two places depending on whether it has panes to show, and a - waiting state that pulses in one and sits still in the other reads as - two different states. */} - {waiting && ( - - - {waiting} - - )} {orphanRecovery(recovery, panes).map((pane) => ( false, + clear: vi.fn(), + consume: (typed) => typed, + }; +} + +describe("TermKeyBar", () => { + it("sends Shift+Left to the active pane and clears modifier latches", () => { + const onKey = vi.fn(); + const ctrl = latch(); + const alt = latch(); + render(); + + fireEvent.click(screen.getByRole("button", { name: "Shift Left arrow" })); + + expect(onKey).toHaveBeenCalledTimes(1); + expect(onKey).toHaveBeenCalledWith("shift-left"); + expect(ctrl.clear).toHaveBeenCalledTimes(1); + expect(alt.clear).toHaveBeenCalledTimes(1); + }); +}); diff --git a/viewer-ui/src/components/terminal/Terminal.tsx b/viewer-ui/src/components/terminal/Terminal.tsx index 2fbcd0d2..5b0ff020 100644 --- a/viewer-ui/src/components/terminal/Terminal.tsx +++ b/viewer-ui/src/components/terminal/Terminal.tsx @@ -25,7 +25,7 @@ import { shownTab } from "../../lib/terminal/paneViewMode"; import { PanelDivider, type PanelDividerProps } from "./PanelDivider"; import { PanelToolbar } from "./PanelToolbar"; import { renderedZoom } from "../../lib/terminal/zoom"; -import { attachLabel, attachStatus } from "../../lib/terminal/attachStatus"; +import { attachStatus } from "../../lib/terminal/attachStatus"; import { useScreenScale } from "../../hooks/ui/screenScale"; function TerminalPanelView({ @@ -234,7 +234,6 @@ function TerminalPanelView({ ownsSize={ownsSize} maximized={maximized} keyBarShown={keyBar.shown} - waiting={panes.length > 0 ? attachLabel(status) : null} recovery={recovery} panes={panes} onCancelRecovery={cancelRecovery} @@ -245,7 +244,7 @@ function TerminalPanelView({ onToggleMaximized={onToggleMaximized} />
- {panes.length === 0 && } + )} diff --git a/viewer-ui/src/hooks/terminal/useCompose.test.tsx b/viewer-ui/src/hooks/terminal/useCompose.test.tsx index ac2a1206..36e4e3a5 100644 --- a/viewer-ui/src/hooks/terminal/useCompose.test.tsx +++ b/viewer-ui/src/hooks/terminal/useCompose.test.tsx @@ -6,8 +6,12 @@ import { useCompose } from "./useCompose"; import type { PaneView } from "../../lib/terminal/terminalLayout"; import { MAX_IMAGE_BYTES } from "../../lib/terminal/pasteImage"; -const { pasteImage } = vi.hoisted(() => ({ pasteImage: vi.fn() })); +const { pasteImage, toastError } = vi.hoisted(() => ({ + pasteImage: vi.fn(), + toastError: vi.fn(), +})); vi.mock("../../api", () => ({ api: { pasteImage } })); +vi.mock("../../lib/runtime/toast", () => ({ toast: { error: toastError } })); function fakeSocket(open = true) { const sent: unknown[] = []; @@ -160,32 +164,49 @@ describe("useCompose", () => { }); }); - it("retries_a_failed_attachment_before_an_image_only_send", async () => { + it("reports_a_failed_attachment_in_a_toast_and_leaves_the_draft_sendable", async () => { pasteImage .mockRejectedValueOnce(new Error("network unavailable")) .mockResolvedValueOnce("/tmp/recovered.png"); const { result, sent } = mount(); act(() => result.current.open()); await act(async () => result.current.attachImage(image())); - expect(result.current.uploadError).toMatch(/network unavailable/); + expect(toastError).toHaveBeenCalledWith(expect.stringMatching(/network unavailable/)); + // Nothing reached the draft, so there is still nothing to send. + expect(result.current.draft).toBe(""); expect(result.current.send()).toBe(false); expect(sent).toEqual([]); await act(async () => result.current.attachImage(image())); - expect(result.current.uploadError).toBeNull(); expect(result.current.draft).toBe("/tmp/recovered.png "); expect(result.current.send()).toBe(true); expect(sent[0]).toMatchObject({ pane: 7, data: expect.stringContaining("/tmp/recovered.png ") }); }); + it("a_failed_attachment_does_not_hold_back_a_typed_message", async () => { + pasteImage.mockRejectedValueOnce(new Error("network unavailable")); + const { result, sent } = mount(); + act(() => result.current.open()); + act(() => result.current.setDraft("look at this")); + await act(async () => result.current.attachImage(image())); + expect(toastError).toHaveBeenCalled(); + expect(result.current.uploading).toBe(false); + expect(result.current.draft).toBe("look at this"); + let ok = false; + act(() => { + ok = result.current.send(); + }); + expect(ok).toBe(true); + expect(sent[0]).toMatchObject({ pane: 7, data: expect.stringContaining("look at this") }); + }); + it("rejects_unsupported_and_oversized_images_before_upload", async () => { const { result } = mount(); act(() => result.current.open()); await act(async () => result.current.attachImage(image("image/bmp"))); - expect(result.current.uploadError).toMatch(/PNG, JPEG, GIF, or WebP/); + expect(toastError).toHaveBeenCalledWith(expect.stringMatching(/PNG, JPEG, GIF, or WebP/)); expect(pasteImage).not.toHaveBeenCalled(); - act(() => result.current.dismissUploadError()); await act(async () => result.current.attachImage(image("image/png", MAX_IMAGE_BYTES + 1))); - expect(result.current.uploadError).toMatch(/10 MiB or smaller/); + expect(toastError).toHaveBeenCalledWith(expect.stringMatching(/10 MiB or smaller/)); expect(pasteImage).not.toHaveBeenCalled(); pasteImage.mockResolvedValue("/tmp/limit.png"); await act(async () => result.current.attachImage(image("image/png", MAX_IMAGE_BYTES))); diff --git a/viewer-ui/src/hooks/terminal/useCompose.ts b/viewer-ui/src/hooks/terminal/useCompose.ts index 1202dd45..658e57df 100644 --- a/viewer-ui/src/hooks/terminal/useCompose.ts +++ b/viewer-ui/src/hooks/terminal/useCompose.ts @@ -1,6 +1,7 @@ import { useEffect, useRef, useState, type MutableRefObject } from "react"; import { api } from "../../api"; import { sendTerminalMessage } from "../../api/terminal"; +import { toast } from "../../lib/runtime/toast"; import { SUBMIT_KEY, composedInput, isSendable } from "../../lib/terminal/composeInput"; import { IMAGE_MIME_TYPES, MAX_IMAGE_BYTES, pathInput } from "../../lib/terminal/pasteImage"; import type { PaneView } from "../../lib/terminal/terminalLayout"; @@ -40,7 +41,6 @@ export function useCompose({ const [opened, setOpened] = useState(null); const [drafts, setDrafts] = useState>({}); const [uploading, setUploading] = useState(false); - const [uploadError, setUploadError] = useState(null); const openedRef = useRef(null); const panesRef = useRef(panes); const uploadSession = useRef(0); @@ -55,7 +55,6 @@ export function useCompose({ uploadSession.current += 1; uploadingRef.current = false; setUploading(false); - setUploadError(null); }; useEffect( @@ -94,11 +93,11 @@ export function useCompose({ const attachImage = async (image: File) => { if (target === null || uploadingRef.current) return; if (!IMAGE_MIME_TYPES.includes(image.type as (typeof IMAGE_MIME_TYPES)[number])) { - setUploadError("Choose a PNG, JPEG, GIF, or WebP image."); + toast.error("Choose a PNG, JPEG, GIF, or WebP image."); return; } if (image.size > MAX_IMAGE_BYTES) { - setUploadError("Image must be 10 MiB or smaller."); + toast.error("Image must be 10 MiB or smaller."); return; } @@ -110,7 +109,6 @@ export function useCompose({ panesRef.current.includes(pane); uploadingRef.current = true; setUploading(true); - setUploadError(null); try { const path = await api.pasteImage(image); if (!path) throw new Error("the server returned no image path"); @@ -122,7 +120,9 @@ export function useCompose({ }); } catch (err) { if (isCurrent()) { - setUploadError( + // A toast, not a line in the form: the draft shows no image path, so + // what Send would send is already on screen. + toast.error( err instanceof Error ? `Could not attach image: ${err.message}` : "Could not attach image.", ); } @@ -134,11 +134,9 @@ export function useCompose({ } }; - const dismissUploadError = () => setUploadError(null); - /** False when nothing went out — the socket is down — so the draft stays. */ const send = (): boolean => { - if (target === null || uploadingRef.current || uploadError !== null || !isSendable(draft)) { + if (target === null || uploadingRef.current || !isSendable(draft)) { return false; } const bracketed = @@ -171,7 +169,5 @@ export function useCompose({ send, attachImage, uploading, - uploadError, - dismissUploadError, }; } diff --git a/viewer-ui/src/hooks/terminal/useDictation.ts b/viewer-ui/src/hooks/terminal/useDictation.ts new file mode 100644 index 00000000..4bdee3f2 --- /dev/null +++ b/viewer-ui/src/hooks/terminal/useDictation.ts @@ -0,0 +1,88 @@ +import { useCallback, useEffect, useRef, useState } from "react"; +import { + dictationErrorMessage, + finalTranscript, + type Recognizer, + type RecognizerFactory, +} from "../../lib/terminal/dictation"; +import { toast } from "../../lib/runtime/toast"; + +/** A failure goes to a toast, so the form never shifts under the person. */ +function report(code: string) { + const message = dictationErrorMessage(code); + if (message) toast.error(message); +} + +/** + * One utterance per press: the recognizer stops on its own after a pause, and + * pressing again while it listens stops it early. Only final text is handed + * over, so nothing half-recognized reaches the draft. + * + * The recognizer is aborted when the form closes, so a microphone is never + * left open behind it. + */ +export function useDictation( + factory: RecognizerFactory | null, + onText: (text: string) => void, +) { + const [listening, setListening] = useState(false); + const recognizerRef = useRef(null); + // The latest callback, since a result arrives renders after the press. + const onTextRef = useRef(onText); + onTextRef.current = onText; + + // `stop`, not `abort`: a phrase still being recognized when the button is + // pressed would otherwise be thrown away. + const stop = useCallback(() => { + recognizerRef.current?.stop(); + }, []); + + const start = useCallback(() => { + if (!factory || recognizerRef.current) return; + let recognizer: Recognizer; + try { + recognizer = factory(); + } catch { + report("unavailable"); + return; + } + recognizer.lang = navigator.language; + recognizer.continuous = false; + recognizer.interimResults = false; + recognizer.onresult = (event) => { + const text = finalTranscript(event); + if (text) onTextRef.current(text); + }; + recognizer.onerror = (event) => report(event.error); + recognizer.onend = () => { + if (recognizerRef.current === recognizer) recognizerRef.current = null; + setListening(false); + }; + try { + recognizer.start(); + } catch { + // Starting can throw synchronously, e.g. while another start is pending. + report("start-failed"); + return; + } + recognizerRef.current = recognizer; + setListening(true); + }, [factory]); + + useEffect( + () => () => { + const recognizer = recognizerRef.current; + recognizerRef.current = null; + if (recognizer) { + // Unmounted: no state to update, only the microphone to release. + recognizer.onend = null; + recognizer.onresult = null; + recognizer.onerror = null; + recognizer.abort(); + } + }, + [], + ); + + return { listening, toggle: listening ? stop : start }; +} diff --git a/viewer-ui/src/lib/terminal/dictation.test.ts b/viewer-ui/src/lib/terminal/dictation.test.ts new file mode 100644 index 00000000..8457d3c7 --- /dev/null +++ b/viewer-ui/src/lib/terminal/dictation.test.ts @@ -0,0 +1,64 @@ +import { describe, expect, it } from "vitest"; +import { + appendDictation, + dictationAvailability, + dictationErrorMessage, + finalTranscript, + type Recognizer, +} from "./dictation"; + +const factory = () => ({}) as Recognizer; + +function event(resultIndex: number, results: [string, boolean][]) { + return { + resultIndex, + results: results.map(([transcript, isFinal]) => ({ isFinal, 0: { transcript } })), + }; +} + +describe("dictationAvailability", () => { + it("http_is_named_only_where_https_would_help", () => { + expect(dictationAvailability(false, factory)).toBe("insecure"); + expect(dictationAvailability(false, null)).toBe("unsupported"); + }); + + it("a_secure_page_depends_on_the_browser", () => { + expect(dictationAvailability(true, factory)).toBe("ready"); + expect(dictationAvailability(true, null)).toBe("unsupported"); + }); +}); + +describe("finalTranscript", () => { + it("keeps_only_final_results_from_the_changed_index", () => { + expect(finalTranscript(event(1, [["old", true], ["안녕 ", true], ["하세", false]]))).toBe("안녕"); + }); + + it("is_empty_without_a_final_result", () => { + expect(finalTranscript(event(0, [["partial", false]]))).toBe(""); + }); +}); + +describe("appendDictation", () => { + it("adds_a_space_only_where_one_is_missing", () => { + expect(appendDictation("", "hi")).toBe("hi"); + expect(appendDictation("run", "tests")).toBe("run tests"); + expect(appendDictation("run ", "tests")).toBe("run tests"); + expect(appendDictation("line\n", "next")).toBe("line\nnext"); + }); + + it("leaves_the_draft_alone_for_empty_text", () => { + expect(appendDictation("draft", "")).toBe("draft"); + }); +}); + +describe("dictationErrorMessage", () => { + it("is_silent_for_our_own_stop_and_for_silence", () => { + expect(dictationErrorMessage("aborted")).toBeNull(); + expect(dictationErrorMessage("no-speech")).toBeNull(); + }); + + it("explains_a_blocked_microphone_and_unknown_codes", () => { + expect(dictationErrorMessage("not-allowed")).toMatch(/blocked/); + expect(dictationErrorMessage("weird")).toMatch(/weird/); + }); +}); diff --git a/viewer-ui/src/lib/terminal/dictation.ts b/viewer-ui/src/lib/terminal/dictation.ts new file mode 100644 index 00000000..2b66a46c --- /dev/null +++ b/viewer-ui/src/lib/terminal/dictation.ts @@ -0,0 +1,103 @@ +/** + * Voice input for the message form, through the browser's speech recognition. + * + * Only the parts that need no browser live here; `useDictation` drives the + * recognizer itself. + */ + +/** Whether this page can offer dictation. */ +export type DictationAvailability = + /** No speech recognition in this browser (Firefox, for one). */ + | "unsupported" + /** Plain http on a name other than localhost: browsers keep the microphone + * closed there, without even asking. */ + | "insecure" + | "ready"; + +/** The slice of the Web Speech API the form uses. */ +export interface Recognizer { + lang: string; + continuous: boolean; + interimResults: boolean; + onresult: ((event: RecognizerResultEvent) => void) | null; + onerror: ((event: { error: string }) => void) | null; + onend: (() => void) | null; + start: () => void; + /** Stops listening but still delivers what was already heard. */ + stop: () => void; + /** Stops and discards, for a form that is going away. */ + abort: () => void; +} + +export interface RecognizerResultEvent { + resultIndex: number; + results: ArrayLike<{ isFinal: boolean; 0: { transcript: string } }>; +} + +export type RecognizerFactory = () => Recognizer; + +/** The browser's recognizer constructor, prefixed in Chrome and Safari. */ +export function browserRecognizerFactory(): RecognizerFactory | null { + const w = window as Window & { + SpeechRecognition?: new () => Recognizer; + webkitSpeechRecognition?: new () => Recognizer; + }; + const Ctor = w.SpeechRecognition ?? w.webkitSpeechRecognition; + return Ctor ? () => new Ctor() : null; +} + +/** A browser without recognition is unsupported on any address, since HTTPS + * would not help it. Chrome and Safari keep the constructor on http and fail + * only once started, so for them the address is what to point at. */ +export function dictationAvailability( + secure: boolean, + factory: RecognizerFactory | null, +): DictationAvailability { + if (!factory) return "unsupported"; + return secure ? "ready" : "insecure"; +} + +/** The final text in a result event, from the first result it changed. */ +export function finalTranscript(event: RecognizerResultEvent): string { + let text = ""; + for (let i = event.resultIndex; i < event.results.length; i++) { + const result = event.results[i]; + if (result.isFinal) text += result[0].transcript; + } + return text.trim(); +} + +/** The draft with dictated text added at its end, a space between them unless + * the draft already ends in whitespace. */ +export function appendDictation(draft: string, text: string): string { + if (text.length === 0) return draft; + if (draft.length === 0 || /\s$/.test(draft)) return draft + text; + return `${draft} ${text}`; +} + +/** + * What a recognizer error code means to the person, or null for one that + * needs no message: `aborted` is our own stop, and `no-speech` is a silence + * the person already noticed. + */ +export function dictationErrorMessage(code: string): string | null { + switch (code) { + case "aborted": + case "no-speech": + return null; + case "not-allowed": + case "service-not-allowed": + return "Microphone access is blocked. Allow it in the browser's site settings."; + case "audio-capture": + return "No microphone was found."; + case "network": + return "The speech service could not be reached."; + case "language-not-supported": + return "This browser cannot recognize speech in this language."; + default: + return `Voice input failed (${code}).`; + } +} + +export const INSECURE_DICTATION_MESSAGE = + "Voice input needs HTTPS or localhost. See the notifications guide for tailscale serve."; diff --git a/viewer-ui/src/lib/terminal/termKeys.test.ts b/viewer-ui/src/lib/terminal/termKeys.test.ts index 751d68c7..4dcd7fc6 100644 --- a/viewer-ui/src/lib/terminal/termKeys.test.ts +++ b/viewer-ui/src/lib/terminal/termKeys.test.ts @@ -26,6 +26,11 @@ describe("termKeySequence", () => { expect(termKeySequence("shift-tab", true)).toBe("\x1b[Z"); }); + it("Shift+Left sends the modified-arrow sequence in either cursor mode", () => { + expect(termKeySequence("shift-left")).toBe("\x1b[1;2D"); + expect(termKeySequence("shift-left", true)).toBe("\x1b[1;2D"); + }); + it("Ctrl combinations send control bytes based on alphabetic order", () => { // Ctrl-C = 3rd letter = 0x03, and so on down the list. expect(termKeySequence("ctrl-b")).toBe("\x02"); @@ -186,6 +191,11 @@ describe("TERM_KEY_BAR", () => { expect(labels[labels.indexOf("⇧Tab") + 1]).toBe("Alt"); }); + it("includes Shift+Left beside the ordinary Left arrow", () => { + const keys = TERM_KEY_BAR.filter((item) => item.kind === "key").map((item) => item.key); + expect(keys[keys.indexOf("left") - 1]).toBe("shift-left"); + }); + it("the bar has no duplicate keys", () => { const keys = TERM_KEY_BAR.map((k) => k.label); expect(new Set(keys).size).toBe(keys.length); diff --git a/viewer-ui/src/lib/terminal/termKeys.ts b/viewer-ui/src/lib/terminal/termKeys.ts index 7bc2cb78..53a4b8fd 100644 --- a/viewer-ui/src/lib/terminal/termKeys.ts +++ b/viewer-ui/src/lib/terminal/termKeys.ts @@ -17,6 +17,7 @@ export type TermKey = | "esc" | "tab" | "shift-tab" + | "shift-left" | "ctrl-b" | "ctrl-c" | "ctrl-d" @@ -37,6 +38,7 @@ export const TERM_KEY_SEQUENCES: Record = { esc: "\x1b", tab: "\t", "shift-tab": "\x1b[Z", + "shift-left": "\x1b[1;2D", "ctrl-b": "\x02", "ctrl-c": "\x03", "ctrl-d": "\x04", @@ -210,6 +212,7 @@ export const TERM_KEY_BAR: TermBarItem[] = [ { kind: "key", key: "ctrl-z", label: "^Z", aria: "Control Z" }, { kind: "key", key: "ctrl-l", label: "^L", aria: "Control L" }, { kind: "key", key: "ctrl-r", label: "^R", aria: "Control R" }, + { kind: "key", key: "shift-left", label: "⇧←", aria: "Shift Left arrow" }, { kind: "key", key: "left", label: "←", aria: "Left arrow" }, { kind: "key", key: "down", label: "↓", aria: "Down arrow" }, { kind: "key", key: "up", label: "↑", aria: "Up arrow" }, diff --git a/viewer-ui/visual/snapshots/linux/mobile-compose-image-upload.png b/viewer-ui/visual/snapshots/linux/mobile-compose-image-upload.png index a9741f6d..09fc7502 100644 Binary files a/viewer-ui/visual/snapshots/linux/mobile-compose-image-upload.png and b/viewer-ui/visual/snapshots/linux/mobile-compose-image-upload.png differ diff --git a/viewer-ui/visual/viewer.spec.ts b/viewer-ui/visual/viewer.spec.ts index 54a57ad3..1df93cdc 100644 --- a/viewer-ui/visual/viewer.spec.ts +++ b/viewer-ui/visual/viewer.spec.ts @@ -23,6 +23,7 @@ test.afterEach(async () => { }); async function openViewer(page: Page, options: ApiMockOptions = {}) { + const terminalMessages: string[] = []; await page.clock.setFixedTime(FIXED_TIME); await page.addInitScript(() => { const style = document.createElement("style"); @@ -38,6 +39,7 @@ async function openViewer(page: Page, options: ApiMockOptions = {}) { }); mocks = await installApiMocks(page, { status, ...options }); await page.routeWebSocket("**/ws/term**", (socket) => { + socket.onMessage((message) => terminalMessages.push(message.toString())); socket.send(JSON.stringify({ type: "hello", client: 1, panes: 1 })); socket.send(JSON.stringify({ type: "created", pane: 1, rows: 24, cols: 80, client: 1, title: "shell", @@ -49,6 +51,7 @@ async function openViewer(page: Page, options: ApiMockOptions = {}) { if ((page.viewportSize()?.width ?? 0) >= 768) await expect(page.locator("[data-terminal-panel] .xterm-screen")).toBeAttached(); await page.evaluate(() => document.fonts.ready); + return terminalMessages; } async function capture(page: Page, name: string) { @@ -148,6 +151,21 @@ test("a non-repository status is shown in the repository view", async ({ page }) await capture(page, "unavailable-repository"); }); +test("the mobile key bar sends Shift+Left to the active terminal", async ({ page }) => { + await page.setViewportSize({ width: 390, height: 844 }); + const terminalMessages = await openViewer(page); + await page.getByRole("button", { name: "Terminal" }).click(); + await expect(page.locator("[data-terminal-panel] .xterm-screen")).toBeAttached(); + + await page.getByRole("button", { name: "Shift Left arrow" }).click(); + + await expect.poll(() => + terminalMessages + .map((raw) => JSON.parse(raw) as { type: string }) + .filter((message) => message.type === "input"), + ).toContainEqual({ type: "input", pane: 1, data: "\x1b[1;2D" }); +}); + test("the mobile compose dialog keeps image upload available while uploading", async ({ page }) => { await page.setViewportSize({ width: 390, height: 844 }); await openViewer(page, { deferImage: true });